Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
% Calculate the vertical offset of current box due the 'clear' CSS property
2
%
3
% @param $y initial Y coordinate to begin offset from
4
% @param $context flow context containing the list of floats to interact with
5
% @return updated value of Y coordinate
6
%
7
/box-generic-apply-clear {         % => Context Y This
8
% Check if we need to offset box vertically due the 'clear' property
9
  dup /clear get-css-value         % => Context Y This Clear
10
 
11
  dup /both eq
12
  1 index /left eq or {            % => Context Y This Clear
13
    3 index context-floats {       % => Context Y This Clear FloatBox
14
      dup /float get-css-value     % => Context Y This Clear FloatBox FloatValue
15
      /left eq {                   % => Context Y This Clear FloatBox
16
% Float vertical margins are never collapsed
17
        get-bottom-margin          % => Context Y This Clear FloatBottomMargin
18
        2 index get-margin-top     % => Context Y This Clear FloatBottomMargin MarginTop
19
        sub                        % => Context Y This Clear Y'
20
        3 index min                % => Context Y This Clear Y
21
        4 3 roll                   % => Context This Clear Y' Y
22
        pop                        % => Context This Clear Y
23
        3 1 roll                   % => Context Y This Clear
24
      } {                          % => Context Y This Clear FloatBox
25
        pop
26
      } ifelse
27
    } forall
28
  } if                             % => Context Y This Clear
29
 
30
  dup /both eq
31
  1 index /right eq or {           % => Context Y This Clear
32
    3 index context-floats {       % => Context Y This Clear FloatBox
33
      dup /float get-css-value     % => Context Y This Clear FloatBox FloatValue
34
      /right eq {                  % => Context Y This Clear FloatBox
35
% Float vertical margins are never collapsed
36
        get-bottom-margin          % => Context Y This Clear FloatBottomMargin
37
        2 index get-margin-top     % => Context Y This Clear FloatBottomMargin MarginTop
38
        sub                        % => Context Y This Clear Y'
39
        3 index min                % => Context Y This Clear Y
40
        4 3 roll                   % => Context This Clear Y' Y
41
        pop                        % => Context This Clear Y
42
        3 1 roll                   % => Context Y This Clear
43
      } {                          % => Context Y This Clear FloatBox
44
        pop
45
      } ifelse
46
   } forall
47
  } if                             % => Context Y This Clear
48
 
49
  pop pop
50
  exch pop                         % => Y
51
} def
52
 
53
% Apply 'line-height' CSS property; modifies the default_baseline value
54
% (NOT baseline, as it is calculated - and is overwritten - in the close_line
55
% method of container box
56
%
57
% Note that underline position (or 'descender' in terms of PDFLIB) -
58
% so, simple that space of text box under the baseline - is scaled too
59
% when 'line-height' is applied
60
%
61
/box-generic-apply-line-height {   % => Box
62
  dup get-height                   % => Box Height
63
 
64
  1 index /line-height get-css-value
65
  dup /Percentage get {            % => Box Height LineHeight
66
    /Value get
67
    1 index mul 100 div            % => Box Height NewHeight
68
  } {
69
    /Value get                     % => Box Height NewHeight
70
  } ifelse
71
 
72
  1 index
73
  3 index get-default-baseline sub % => Box Height NewHeight Under
74
 
75
  2 index 0 gt {
76
    1 index 3 index div            % => Box Height NewHeight Under Scale
77
  } {
78
 
79
  } ifelse                         % => Box Height NewHeight Under Scale
80
 
81
  2 index 5 index put-height       % => Box Height NewHeight Under Scale
82
  mul sub                          % => Box Height NewHeight-Under*Scale
83
  2 index put-default-baseline     % => Box Height
84
 
85
  pop pop
86
} def
87
 
88
/box-generic-check-page-break-after { % => Context Parent This
89
  1 index /null ne {
90
    dup /page-break-after
91
    get-css-value                  % => Context Parent This CSS-pba
92
 
93
    dup /avoid ne
94
    1 index /auto ne and {         % => Context Parent This CSS-pba
95
      3 index context-get-viewport % => Context Parent This CSS-pba Viewport
96
 
97
      dup flow-viewport-get-top    % => Context Parent This CSS-pba Viewport VTop
98
      4 index get-current-y sub    % => Context Parent This CSS-pba Viewport YOfs
99
      1 index
100
      flow-viewport-get-height div % => Context Parent This CSS-pba Viewport PagesFraction
101
      dup ceiling sub              % => Context Parent This CSS-pba Viewport PageFraction
102
 
103
      1 index flow-viewport-get-height
104
      mul                          % => Context Parent This CSS-pba Viewport YDelta
105
      4 index get-current-y add
106
      4 index put-current-y        % => Context Parent This CSS-pba Viewport
107
 
108
      pop
109
    } if                           % => Context Parent This CSS-pba
110
 
111
    pop
112
  } if                             % => Context Parent This
113
 
114
  pop pop pop
115
} def
116
 
117
/box-generic-collapse-margin { % => Context Parent This
118
% do margin collapsing
119
 
120
% Margin collapsing is done as follows:
121
% 1. If previous sibling was an inline element (so, parent line box was not empty),
122
% then no collapsing will take part
123
% 2. If NO previous element exists at all, then collapse current box top margin
124
% with parent's collapsed top margin.
125
% 2.1. If parent element was float, no collapsing should be
126
% 3. If there's previous block element, collapse current box top margin
127
% with previous elemenent's collapsed bottom margin
128
 
129
% Check if current parent line box contains inline elements only. In this case the only
130
% margin will be current box margin
131
  1 index box-container-line-box-empty not {
132
% Case (1). Previous element was inline element; no collapsing
133
    dup get-margin-top           % => Context Parent This MT
134
    3 index                      % => Context Parent This MT Context
135
    context-push-collapsed-margin
136
 
137
    2 index 2 index box-container-close-line
138
 
139
    1 index get-current-y        % => Context Parent This Y
140
    1 index get-margin-top sub   % => Context Parent This Y
141
  } {
142
% Case (2). No previous block element at all; Collapse with parent margins
143
% Case (3). There's a previous block element
144
% We can process both cases at once, as context object collapsed margin stack
145
% allows us to track collapsed margins value
146
 
147
% Calculate the value to offset current box vertically due margin
148
% note that we'll get non-negative value - the value to increate collapsed margin size,
149
% but we must offset box to the bottom
150
 
151
    dup get-margin-top
152
    dup                          % => Context Parent This MT MT
153
    4 index
154
    context-get-collapsed-margin % => Content Parent This MT MT CM
155
    min
156
    sub                          % => Context Parent This Y
157
 
158
    1 index get-margin-top
159
    4 index context-get-collapsed-margin
160
    max                          % => Context Parent This Y CM'
161
    4 index
162
    context-push-collapsed-margin
163
                                   % => Context Parent This Y
164
 
165
% Offset parent, if current box is the first child, as we should not get
166
% vertical gaps before the first child during margin collapsing
167
 
168
    2 index get-uid
169
    4 index context-container-uid ne
170
                                   % => Context Parent This vmargin if_expr
171
 
172
    {                            % => Context Parent This $vmargin
173
      dup neg 0 3 index          % => Context Parent This $vmargin -$vmargin 0 This
174
      5 index
175
      box-container-offset-if-first not {
176
                                   % => Context Parent This vmargin
177
        2 index get-current-y
178
        exch sub
179
        2 index put-current-y
180
      } { pop } ifelse           % => Context Parent This
181
 
182
      1 index get-current-y      % => Context Parent This Y
183
    } {                          % => Context Parent This $vmargin
184
      2 index get-current-y
185
      exch sub
186
    } ifelse                     % => Context Parent This Y
187
  } ifelse
188
 
189
  exch pop
190
  exch pop
191
  exch pop
192
} def
193
 
194
/box-generic-contains-point-margin { % => Y X Box
195
  dup get-left-margin rounding-epsilon sub 2 index le
196
  1 index get-right-margin rounding-epsilon add 3 index ge and
197
  1 index get-top-margin rounding-epsilon add 4 index ge and
198
  1 index get-bottom-margin 4 index lt and
199
 
200
  exch pop
201
  exch pop
202
  exch pop
203
} def
204
 
205
/box-generic-create {              % =>
206
  <<
207
    /AdditionalTextIndent 0
208
 
209
    /Cache << >>
210
 
211
    /CSS <<
212
      /background background-create
213
 
214
      /border border-create
215
 
216
      /cellpadding 1 px
217
      /cellspacing 1 px
218
      /clear /none
219
      /color 0 0 0 0 color-create
220
 
221
      /display /inline
222
 
223
      /float       /none
224
      /font-size   10 pt
225
      /font-family default-font
226
 
227
      /height <<
228
        /percentage false
229
        /auto true
230
        /value 0
231
      >>
232
 
233
      /left 0
234
 
235
      /line-height <<
236
        /Percentage true
237
        /Value 110
238
      >>
239
 
240
      /list-style <<
241
        /position /outside
242
        /type /disc
243
      >>
244
 
245
      /margin <<
246
        /left <<
247
          /value 0
248
          /percentage /null
249
          /auto false
250
        >>
251
        /right <<
252
          /value 0
253
          /percentage /null
254
          /auto false
255
        >>
256
        /top <<
257
          /value 0
258
          /percentage /null
259
          /auto false
260
        >>
261
        /bottom <<
262
          /value 0
263
          /percentage /null
264
          /auto false
265
        >>
266
      >>
267
 
268
      /overflow /visible
269
 
270
      /padding <<
271
        /left <<
272
          /value 0
273
          /percentage /null
274
          /auto false
275
        >>
276
        /right <<
277
          /value 0
278
          /percentage /null
279
          /auto false
280
        >>
281
        /top <<
282
          /value 0
283
          /percentage /null
284
          /auto false
285
        >>
286
        /bottom <<
287
          /value 0
288
          /percentage /null
289
          /auto false
290
        >>
291
      >>
292
      /page-break-after /auto
293
      /position /static
294
      /pseudo-align {text-align-left}
295
      /pseudo-nowrap /normal
296
      /pseudo-link-destination ()
297
      /pseudo-link-target << /type /none >>
298
 
299
      /text-align   {text-align-left}
300
      /text-decoration <<
301
        /overline false
302
        /underline false
303
        /line-through false
304
      >>
305
      /text-indent <<
306
        /Percentage false
307
        /Value 0
308
      >>
309
      /top << /value 0 /percentage false >>
310
 
311
      /vertical-align /baseline
312
      /visibility /visible
313
 
314
      /white-space /normal
315
    >>
316
 
317
    /CurrentX 0
318
    /CurrentY 0
319
 
320
    /DeferredFloats []
321
 
322
    /HeightConstraint /null /null /null hc-create
323
 
324
    /Methods <<
325
    >>
326
 
327
    /Parent /null
328
 
329
    /Position <<
330
      /left   0
331
      /top    0
332
      /width  0
333
      /height 0
334
      /baseline 0
335
      /default-baseline 0
336
    >>
337
 
338
    /UID 0
339
 
340
    /WidthConstraint wc-create-none
341
  >>
342
 
343
  dup box-generic-setup-methods
344
  dup /box-generic add-type
345
} def                              % => Box
346
 
347
/box-generic-calc-auto-width-margins {
348
                                   % => Parent This
349
  dup /float get-css-value
350
  /none ne {
351
    2 copy box-generic-calc-auto-width-margins-float
352
  } {
353
    2 copy box-generic-calc-auto-width-margins-normal
354
  } ifelse
355
  pop pop
356
} def
357
 
358
/box-generic-calc-auto-width-margins-float { % Parent This
359
  dup is-margin-auto-left {
360
 
361
  } if
362
 
363
  dup is-margin-auto-right {
364
 
365
  } if
366
 
367
  pop pop
368
} def
369
 
370
% 'margin-left' + 'border-left-width' + 'padding-left' + 'width' + 'padding-right' + 'border-right-width' + 'margin-right' = width of containing block
371
%
372
/box-generic-calc-auto-width-margins-normal {
373
                                   % => Parent This
374
% If both 'margin-left' and 'margin-right' are 'auto', their used values are equal.
375
% This horizontally centers the element with respect to the edges of the containing block.
376
  dup is-margin-auto-left
377
  1 index is-margin-auto-right and {
378
    1 index /get-width call-method              % => Parent This PW
379
    1 index get-full-width         % => Parent This PW W
380
    sub 2 div                      % => Parent This M
381
 
382
    dup 2 index put-margin-left
383
    dup 2 index put-margin-right   % => Parent This M
384
 
385
    pop
386
  } {                              % => Parent This
387
% If there is exactly one value specified as 'auto', its used value follows from the equality.
388
    dup is-margin-auto-left {
389
      1 index /get-width call-method
390
      1 index get-full-width
391
      sub
392
 
393
      1 index put-margin-left
394
    } if
395
 
396
    dup is-margin-auto-right {
397
      1 index /get-width call-method
398
      1 index get-full-width
399
      sub
400
 
401
      1 index put-margin-right
402
    } if
403
  } ifelse                         % => Parent This
404
 
405
  pop pop
406
} def
407
 
408
/box-generic-calc-percentage-margins {
409
                                   % => Parent This
410
  dup get-margin-percentage-left   % => Parent This LMP
411
  dup /null ne {
412
    2 index /get-width call-method              % => Parent This LMP PW
413
    mul 100 div                    % => Parent This LM
414
    1 index put-margin-left        % => Parent This
415
  } {
416
    pop
417
  } ifelse
418
 
419
  dup get-margin-percentage-right  % => Parent This LMP
420
  dup /null ne {
421
    2 index /get-width call-method              % => Parent This LMP PW
422
    mul 100 div                    % => Parent This LM
423
    1 index put-margin-right       % => Parent This
424
  } {
425
    pop
426
  } ifelse                         % => Parent This
427
 
428
  pop pop
429
} def
430
 
431
% If the containing block's width depends on this element's width,
432
% then the resulting layout is undefined in CSS 2.1.
433
%
434
/box-generic-calc-percentage-width {
435
                                   % => Context Parent This
436
  dup get-width-constraint
437
  dup wc-is-fraction               % => Context Parent This WC IsFraction
438
  {                                % => Context Parent This WC
439
% Calculate actual width
440
    2 index /get-width call-method
441
    exch                           % => Context Parent This PW WC
442
    2 index /get-width call-method
443
    exch                           % => Context Parent This PW CW WC
444
    wc-apply                       % => Context Parent This W
445
 
446
% Check if calculated width is less than minimal width
447
% Note that get_min_width will return the width including the extra horizontal space!
448
    3 index 2 index
449
    /get-min-width call-method     % => Context Parent This W MinW
450
 
451
    2 index get-hor-extra sub      % => Context Parent This W MinW'
452
 
453
    max                            % => Context Parent This W
454
 
455
% Assign calculated width
456
    dup 2 index put-width          % => Context Parent This W
457
 
458
% Remove any width constraint
459
    wc-create-constant             % => Context Parent This WC
460
    1 index put-width-constraint   % => Context Parent This
461
  } {
462
    pop
463
  } ifelse
464
 
465
  pop pop pop
466
} def
467
 
468
/box-generic-calc-text-indent {    % => Box
469
  dup /text-indent get-css-value   % => Box TextIndent
470
  dup /Percentage get {            % => Box TextIndent
471
    1 index /get-width call-method              % => Box TextIndent W
472
    1 index /Value get             % => Box TextIndent W Percent
473
    mul 100 div                    % => Box TextIndent TIValue
474
  } {                              % => Box TextIndent
475
    dup /Value get                 % => Box TextIndent TIValue
476
  } ifelse
477
 
478
  exch pop
479
  exch pop
480
} def
481
 
482
% Extends the box height to cover the given Y coordinate
483
% If box height is already big enough, no changes will be made
484
%
485
% @param $y_coord Y coordinate should be covered by the box
486
%
487
/box-generic-extend-height {       % => Y This
488
  dup get-height                   % => Y This H
489
  1 index get-top                  % => Y This H Top
490
  3 index sub                      % => Y This H Top-Y
491
  max
492
  1 index put-height
493
  pop pop
494
} def
495
 
496
/box-generic-extend-width {        % => X This
497
  dup /get-width call-method       % => X This Width
498
  2 index
499
  2 index get-left sub             % => X This Width NewWidth
500
  max
501
  1 index put-width                % => X This
502
  pop pop
503
} def
504
 
505
% Get the position and size of containing block for current
506
% ABSOLUTE POSITIONED element. It is assumed that this function
507
% is called for ABSOLUTE positioned boxes ONLY
508
%
509
% @return associative array with 'top', 'bottom', 'right' and 'left'
510
% indices in data space describing the position of containing block
511
%
512
/box-generic-get-containing-block {% => Box
513
  dup get-parent                   % => Box Parent
514
 
515
% No containing block at all...
516
% How could we get here?
517
  dup /null eq {
518
    (Error: No containing block found for absolute-positioned element) print
519
    quit
520
  } if
521
 
522
% CSS 2.1:
523
% If the element has 'position: absolute', the containing block is established by the
524
% nearest ancestor with a 'position' of 'absolute', 'relative' or 'fixed', in the following way:
525
% - In the case that the ancestor is inline-level, the containing block depends on
526
%   the 'direction' property of the ancestor:
527
%   1. If the 'direction' is 'ltr', the top and left of the containing block are the top and left
528
%      content edges of the first box generated by the ancestor, and the bottom and right are the
529
%      bottom and right content edges of the last box of the ancestor.
530
%   2. If the 'direction' is 'rtl', the top and right are the top and right edges of the first
531
%      box generated by the ancestor, and the bottom and left are the bottom and left content
532
%      edges of the last box of the ancestor.
533
% - Otherwise, the containing block is formed by the padding edge of the ancestor.
534
% TODO: inline-level ancestors
535
  {                                % => Box Parent
536
    dup get-parent                 % => Box Parent Parent2
537
    /null eq { exit } if           % => Box Parent
538
    dup /position get-css-value
539
    /static ne { exit } if         % => Box Parent
540
    get-parent                     % => Box Parent2
541
  } loop                           % => Box ContainingBox
542
 
543
% Note that initial containg block (containig BODY element) will be formed by BODY margin edge,
544
% unlike other blocks which are formed by content edges
545
  << >>                            % => Box ContainingBox CB
546
  1 index get-parent /null ne {
547
% Normal containing block
548
    dup /left   3 index get-left   put
549
    dup /right  3 index get-right  put
550
    dup /top    3 index get-top    put
551
    dup /bottom 3 index get-bottom put
552
  } {
553
% Initial containing block
554
    dup /left   3 index get-left-margin   put
555
    dup /right  3 index get-right-margin  put
556
    dup /top    3 index get-top-margin    put
557
    dup /bottom 3 index get-bottom-margin put
558
  } ifelse                         % => Box ContainingBox CB
559
 
560
  exch pop
561
  exch pop
562
} def
563
 
564
/box-generic-get-expandable-width {% => Box
565
  dup get-parent /null ne
566
  1 index get-width-constraint
567
  /type get /none eq and {
568
    get-parent box-generic-get-expandable-width
569
  } {
570
    /get-width call-method
571
  } ifelse
572
} def
573
 
574
/box-generic-get-extra-line-left { % => Box
575
  pop 0
576
} def
577
 
578
/box-generic-get-extra-line-right {% => Box
579
  pop 0
580
} def
581
 
582
/box-generic-get-real-full-height {
583
  get-full-height
584
} def
585
 
586
/box-generic-get-width {                       % => Box
587
  dup get-parent /null ne {
588
    dup get-parent                 % => Box Parent
589
    /get-width call-method                      % => Box ParentWidth
590
  } {
591
    dup /Position get
592
    /width get
593
  } ifelse
594
 
595
  1 index /Position get
596
  /width get                       % => Box ParentWidth Width
597
  2 index get-width-constraint     % => Box ParentWidth Width WC
598
  dup /apply get exec              % => Box W
599
  exch pop
600
} def
601
 
602
% Calculate the content upper-left corner position in curent flow
603
/box-generic-guess-corner {        % => Parent This
604
  1 index get-current-x
605
  1 index get-extra-left add
606
  1 index put-left
607
 
608
  1 index get-current-y
609
  1 index get-extra-top sub
610
  1 index put-top
611
 
612
  pop pop
613
} def
614
 
615
/box-generic-is-null {
616
  pop false
617
} def
618
 
619
/box-generic-is-whitespace {
620
  pop false
621
} def
622
 
623
/box-generic-line-break-allowed {  % => This
624
  dup /white-space get-css-value /normal eq
625
  1 index /pseudo-nowrap get-css-value /normal eq
626
  and                              % => This Flag
627
  exch pop
628
} def
629
 
630
/box-generic-move-to {             % => Y X This
631
  2 index 1 index get-top sub      % => Y X This DY
632
  2 index 2 index get-left sub     % => Y X This DY DX
633
  2 index
634
  /offset call-method              % => Y X This
635
  pop pop pop
636
} def
637
 
638
/box-generic-offset {              % => DY DX This
639
  2 index 1 index get-top add
640
  1 index put-top
641
 
642
  1 index 1 index get-left add
643
  1 index put-left
644
 
645
  pop pop pop
646
} def
647
 
648
/box-generic-pre-reflow-images {
649
  pop
650
} def
651
 
652
/box-generic-reflow {              % => Context Parent This
653
  pop pop pop                      % =>
654
 
655
  (Unimplemented /reflow method) print
656
  quit
657
} def                              % =>
658
 
659
/box-generic-reflow-anchors {      % => List Viewport Box
660
% make local link anchor
661
  dup /pseudo-link-destination
662
  get-css-value
663
  dup () ne {                      % => List Viewport Box Destination
664
    <<
665
      /page
666
      3 index get-top bmargin sub
667
      real-page-height
668
 
669
% NOTE: the coordinate system begins at the bottom of the very first page and directed to the top!
670
 
671
      div 0.5 add floor neg 2 add % => List Viewport Box Destination << /page <page>
672
 
673
      /x 5 index get-left         % => List Viewport Box Destination << /page <page> /x <x>
674
 
675
% As in most cases we'll use an empty <a name="..."></a> with fake zero-height whitespace inside,
676
% we can determine only the bottom edge of the linked area
677
      /y
678
      7 index get-bottom bmargin sub
679
      4 index 1 sub real-page-height mul
680
      add floor bmargin add
681
% now add some small vertical offset to make text in linked area visible
682
      20 pt add
683
    >>                             % => List Viewport Box Destination Anchor
684
    4 index 3 1 roll               % => List Viewport Box List Destination Anchor
685
    put                            % => List Viewport Box
686
  } {
687
    pop
688
  } ifelse                         % => List Viewport Box
689
 
690
  pop pop pop
691
} def
692
 
693
/box-generic-reflow-inline {
694
  pop
695
} def
696
 
697
/box-generic-setup-methods {       % => Box
698
  dup get-box-dict /Methods get    % => Box Methods
699
  dup /get-extra-line-left  { box-generic-get-extra-line-left } put
700
  dup /get-extra-line-right { box-generic-get-extra-line-right } put
701
  dup /get-real-full-height { box-generic-get-real-full-height } put
702
  dup /get-width            { box-generic-get-width } put
703
  dup /is-null              { box-generic-is-null } put
704
  dup /is-whitespace        { box-generic-is-whitespace } put
705
  dup /line-break-allowed   { box-generic-line-break-allowed } put
706
  dup /offset               { box-generic-offset } put
707
  dup /pre-reflow-images    { box-generic-pre-reflow-images } put
708
  dup /reflow               { box-generic-reflow } put
709
  dup /reflow-inline        { box-generic-reflow-inline } put
710
  dup /reflow-anchors       { box-generic-reflow-anchors } put
711
  dup /show                 { box-generic-show } put
712
  pop pop
713
} def
714
 
715
/box-generic-show {                % => Viewport This
716
% make a external/local link using pdfmark operator, if needed
717
  dup /pseudo-link-target
718
  get-css-value                    % => Viewport This Linktarget
719
  dup /type get /uri eq {
720
    [ /Rect [ 4 index get-left
721
              5 index get-bottom
722
              6 index get-right
723
              7 index get-top ]
724
      /Action << /Subtype /URI /URI 8 index /value get >>
725
      /Border [0 0 0]
726
      /Subtype /Link
727
      /ANN pdfmark
728
  } if
729
 
730
  dup /type get /local eq {        % => Viewport This Linktarget
731
    2 index exch /value get        % => Viewport This Viewport Linktarget
732
    viewport-get-anchor            % => Viewport This AnchorData
733
    dup /null ne {
734
      [ /Rect [ 4 index get-left
735
                5 index get-bottom
736
                6 index get-right
737
                7 index get-top ]
738
        /Page 4 index /page get
739
        /View [ /XYZ null 9 index /y get null ]
740
        /Border [0 0 0]
741
        /Subtype /Link
742
        /ANN pdfmark
743
    } if
744
  } if
745
 
746
  pop
747
 
748
  dup
749
  2 index
750
  2 index get-border
751
  border-show
752
 
753
  dup
754
  2 index
755
  2 index get-background
756
  background-show
757
 
758
  setting-debug-box {
759
 
760
    0.1 setlinewidth
761
    dup get-left  1 index get-top moveto
762
    dup get-right 1 index get-top lineto
763
    dup get-right 1 index get-bottom lineto
764
    dup get-left  1 index get-bottom lineto
765
    closepath
766
    stroke
767
  } if
768
 
769
% Set the text color
770
% Note that text color is used not only for text drawing (for example, list item markers
771
% are drawn with text color)
772
  dup /color get-css-value
773
  color-apply
774
 
775
  pop pop
776
} def
777
 
778
% Common
779
 
780
/get-additional-text-indent {
781
  /AdditionalTextIndent get
782
} def
783
 
784
/get-background {
785
  /background get-css-value
786
} def
787
 
788
/get-baseline {
789
  /Position get
790
  /baseline get
791
} def
792
 
793
/get-baseline-offset {             % => Box
794
  dup get-baseline
795
  1 index get-default-baseline sub
796
  exch pop
797
} def
798
 
799
/get-border {
800
  /border get-css-value
801
} def
802
 
803
/get-border-bottom {
804
  /border get-css-value
805
  /bottom get
806
} def
807
 
808
/get-border-bottom-width {
809
  get-border-bottom
810
  edge-get-width
811
} def
812
 
813
/get-border-left {
814
  /border get-css-value
815
  /left get
816
} def
817
 
818
/get-border-left-width {
819
  get-border-left
820
  edge-get-width
821
} def
822
 
823
/get-border-right {
824
  /border get-css-value
825
  /right get
826
} def
827
 
828
/get-border-right-width {
829
  get-border-right
830
  edge-get-width
831
} def
832
 
833
/get-border-top {
834
  /border get-css-value
835
  /top get
836
} def
837
 
838
/get-border-top-width {
839
  get-border-top
840
  edge-get-width
841
} def
842
 
843
/get-bottom {
844
  dup get-top
845
  1 index get-height sub
846
  exch pop
847
} def
848
 
849
/get-bottom-border {
850
  dup get-bottom-padding
851
  1 index get-border-bottom-width
852
  sub
853
  exch pop
854
} def
855
 
856
/get-bottom-margin {
857
  dup get-bottom-border
858
  1 index get-margin-bottom
859
  sub
860
  exch pop
861
} def
862
 
863
/get-bottom-padding {
864
  dup get-bottom
865
  1 index get-padding-bottom
866
  sub exch pop
867
} def
868
 
869
/get-box-dict {} def
870
 
871
% Get the calculated value of a CSS property for this box
872
%
873
% @param Box reference to a box object
874
% @param Name name of a CSS property
875
%
876
/get-css-value {                   % => Box Name
877
  1 index get-box-dict
878
  /CSS get                         % => Box Name CSS
879
 
880
% Check if this value is known
881
  dup 2 index known not {
882
    (Value is not known:) print
883
    1 index ==
884
    quit
885
  } if
886
 
887
% Get the value
888
  1 index get                     % => Box Name CSSValue
889
 
890
% clear the stack
891
  exch pop
892
  exch pop
893
} def
894
 
895
/get-current-x {
896
  /CurrentX get
897
} def
898
 
899
/get-current-y {
900
  /CurrentY get
901
} def
902
 
903
/get-default-baseline {
904
  /Position get
905
  /default-baseline get
906
} def
907
 
908
/get-extra-bottom {
909
  dup get-padding-bottom exch
910
  dup get-margin-bottom exch
911
  dup get-border-bottom-width exch
912
  pop
913
  add add
914
} def
915
 
916
/get-extra-left {
917
  dup get-padding-left exch
918
  dup get-margin-left exch
919
  dup get-border-left-width exch
920
  pop
921
  add add
922
} def
923
 
924
/get-extra-right {
925
  dup get-padding-right exch
926
  dup get-margin-right exch
927
  dup get-border-right-width exch
928
  pop
929
  add add
930
} def
931
 
932
/get-extra-top {
933
  dup get-padding-top exch
934
  dup get-margin-top exch
935
  dup get-border-top-width exch
936
  pop
937
  add add
938
} def
939
 
940
/get-full-width  {
941
  dup /get-width call-method
942
  exch get-hor-extra
943
  add
944
} def
945
 
946
/get-full-height {
947
  dup get-height
948
  exch get-vert-extra
949
  add
950
} def
951
 
952
/get-height {                      % => Box
953
  dup                              % => Box Box
954
  dup /Position get
955
  /height get                      % => Box Box RawHeight
956
  1 index get-height-constraint    % => Box Box RawHeight HC
957
  hc-apply
958
  exch pop                         % => H
959
} def
960
 
961
/get-height-constraint {           % => Box
962
  /HeightConstraint get
963
} def
964
 
965
/get-hor-extra  {                  % => Box
966
  dup get-extra-left
967
  1 index get-extra-right
968
  add
969
 
970
  exch pop
971
} def
972
 
973
/get-left {
974
  get-box-dict /Position get /left get
975
} def
976
 
977
/get-left-border {
978
  dup get-left-padding
979
  1 index get-border-left-width
980
  sub
981
  exch pop
982
} def
983
 
984
/get-left-padding {
985
  dup get-left
986
  1 index get-padding-left
987
  sub
988
  exch pop
989
} def
990
 
991
/get-left-margin      {
992
  dup get-left-border
993
  1 index get-margin-left
994
  sub
995
  exch pop
996
} def
997
 
998
/get-margin-bottom {               % => Box
999
  /margin get-css-value
1000
  /bottom get
1001
  /value get
1002
} def
1003
 
1004
/get-margin-left {                 % => Box
1005
  /margin get-css-value
1006
  /left get
1007
  /value get
1008
} def
1009
 
1010
/get-margin-percentage-left {      % => Box
1011
  /margin get-css-value
1012
  /left get
1013
  /percentage get
1014
} def
1015
 
1016
/get-margin-percentage-right {     % => Box
1017
  /margin get-css-value
1018
  /right get
1019
  /percentage get
1020
} def
1021
 
1022
/get-margin-right {                % => Box
1023
  /margin get-css-value
1024
  /right get
1025
  /value get
1026
} def
1027
 
1028
/get-margin-top {                  % => Box
1029
  /margin get-css-value
1030
  /top get
1031
  /value get
1032
} def
1033
 
1034
/get-padding {                     % => Box
1035
  /padding get-css-value
1036
} def
1037
 
1038
/get-padding-bottom {              % => Box
1039
  /padding get-css-value
1040
  /bottom get
1041
  /value get
1042
} def
1043
 
1044
/get-padding-left {                % => Box
1045
  /padding get-css-value
1046
  /left get
1047
  /value get
1048
} def
1049
 
1050
/get-padding-right {               % => Box
1051
  /padding get-css-value
1052
  /right get
1053
  /value get
1054
} def
1055
 
1056
/get-padding-top {                 % => Box
1057
  /padding get-css-value
1058
  /top get
1059
  /value get
1060
} def
1061
 
1062
/get-parent {
1063
  /Parent get
1064
} def
1065
 
1066
/get-right {
1067
  dup get-left                     % => Box Left
1068
  1 index /get-width call-method add
1069
  exch pop
1070
} def
1071
 
1072
/get-right-border {
1073
  dup get-right-padding
1074
  1 index get-border-right-width
1075
  add
1076
  exch pop
1077
} def
1078
 
1079
/get-right-margin {
1080
  dup get-right-border
1081
  1 index get-margin-right
1082
  add
1083
  exch pop
1084
} def
1085
 
1086
/get-right-padding {
1087
  dup get-right
1088
  1 index get-padding-right
1089
  add
1090
  exch pop
1091
} def
1092
 
1093
/get-top {
1094
  dup /Position get /top get       % => Box top
1095
  1 index get-baseline-offset sub  % => Box Top'
1096
  exch pop
1097
} def
1098
 
1099
/get-top-border {
1100
  dup get-top-padding
1101
  1 index get-border-top-width
1102
  add
1103
  exch pop
1104
} def
1105
 
1106
/get-top-margin {
1107
  dup get-top-border
1108
  1 index get-margin-top
1109
  add
1110
  exch pop
1111
} def
1112
 
1113
/get-top-padding {
1114
  dup get-top
1115
  1 index get-padding-top
1116
  add
1117
  exch pop
1118
} def
1119
 
1120
/get-uid {                         % => Box
1121
  get-box-dict
1122
  /UID get
1123
} def
1124
 
1125
/get-vert-extra  {                  % => Box
1126
  dup get-extra-top
1127
  1 index get-extra-bottom
1128
  add
1129
 
1130
  exch pop
1131
} def
1132
 
1133
/get-width-constraint {            % => Box
1134
  get-box-dict
1135
  /WidthConstraint get
1136
} def
1137
 
1138
/is-margin-auto-left {             % => Box
1139
  /margin get-css-value
1140
  /left get
1141
  /auto get
1142
} def
1143
 
1144
/is-margin-auto-right {            % => Box
1145
  /margin get-css-value
1146
  /right get
1147
  /auto get
1148
} def
1149
 
1150
/put-additional-text-indent {      % => Value Box
1151
  exch /AdditionalTextIndent exch put
1152
} def
1153
 
1154
/put-baseline {
1155
  /Position get
1156
  exch
1157
  /baseline
1158
  exch
1159
  put
1160
} def
1161
 
1162
/put-border {
1163
  exch /border exch put-css-value
1164
} def
1165
 
1166
/put-content {
1167
  exch
1168
  /Content exch                    % => Box /CurrentX Value
1169
  put
1170
} def
1171
 
1172
/put-css-value {                   % => Box Property Value
1173
  2 index /CSS get                 % => Box Property Value CSS
1174
  3 1 roll                         % => Box CSS Property Value
1175
  put pop
1176
} def
1177
 
1178
/put-current-x {                   % => Value Box
1179
  exch
1180
  /CurrentX exch                   % => Box /CurrentX Value
1181
  put
1182
} def
1183
 
1184
/put-current-y {                   % => Value Box
1185
  exch
1186
  /CurrentY exch                   % => Box /CurrentY Value
1187
  put
1188
} def
1189
 
1190
/put-default-baseline {
1191
  /Position get
1192
  exch
1193
  /default-baseline
1194
  exch
1195
  put
1196
} def
1197
 
1198
/put-full-width {                  % => Value Box
1199
  dup get-hor-extra                % => Value Box HE
1200
  2 index exch sub                 % => Value Box Value-HE
1201
  1 index put-width                % => Value Box
1202
  pop pop
1203
} def
1204
 
1205
/put-height {
1206
  /Position get
1207
  exch /height exch put
1208
} def
1209
 
1210
/put-height-constraint {           % => Value box
1211
  exch /HeightConstraint exch put
1212
} def
1213
 
1214
/put-left {                        % => Value Box
1215
  get-box-dict
1216
  /Position get
1217
  exch /left exch put
1218
} def
1219
 
1220
/put-margin-bottom {               % => Value Box
1221
  /margin get-css-value            % => Value Margins
1222
  /bottom get                      % => Value MarginsValues
1223
  exch /value exch put
1224
} def
1225
 
1226
/put-margin-left {                 % => Value Box
1227
  /margin get-css-value            % => Value Margins
1228
  /left get                        % => Value MarginsValues
1229
  exch /value exch put
1230
} def
1231
 
1232
/put-margin-right {                % => Value Box
1233
  /margin get-css-value            % => Value Margins
1234
  /right get                       % => Value MarginsValues
1235
  exch /value exch put
1236
} def
1237
 
1238
/put-margin-top {                  % => Value Box
1239
  /margin get-css-value            % => Value Margins
1240
  /top get                         % => Value MarginsValues
1241
  exch /value exch put
1242
} def
1243
 
1244
/put-padding {                     % => Value Box
1245
  exch /padding exch put-css-value
1246
} def
1247
 
1248
/put-parent {
1249
  exch /Parent exch put
1250
} def
1251
 
1252
/put-top {                         % => Value Box
1253
  exch
1254
  1 index get-baseline-offset
1255
  add exch
1256
 
1257
  /Position get
1258
  exch /top exch put
1259
} def
1260
 
1261
/put-uid {
1262
  exch /UID exch put
1263
} def
1264
 
1265
/put-width {
1266
  /Position get
1267
  exch /width exch put
1268
} def
1269
 
1270
/put-width-constraint {            % => Value Box
1271
  exch /WidthConstraint exch put
1272
} def
1273