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