| 1 |
lars |
1 |
/box-whitespace-create { % =>
|
|
|
2 |
box-text-create
|
|
|
3 |
|
|
|
4 |
dup get-box-dict
|
|
|
5 |
/Methods get
|
|
|
6 |
dup /reflow {box-whitespace-reflow} put
|
|
|
7 |
dup /is-whitespace {box-whitespace-is-whitespace} put
|
|
|
8 |
pop
|
|
|
9 |
|
|
|
10 |
dup /box-whitespace add-type
|
|
|
11 |
|
|
|
12 |
( ) 1 index put-text
|
|
|
13 |
} def
|
|
|
14 |
|
|
|
15 |
/box-whitespace-is-whitespace { % => Box
|
|
|
16 |
pop true
|
|
|
17 |
} def
|
|
|
18 |
|
|
|
19 |
/box-whitespace-reflow { % => Context Parent Box
|
|
|
20 |
% Check if there are any boxes in parent's line box
|
|
|
21 |
1 index % => Context Parent Box Parent
|
|
|
22 |
box-container-line-box-empty { % => Context Parent Box
|
|
|
23 |
% The very first whitespace in the line box should not affect neither height nor baseline of the line box;
|
|
|
24 |
% because following boxes can be smaller that assumed whitespace height
|
|
|
25 |
% Example: <br>[whitespace]<img height="2" width="2"><br>; whitespace can overextend this line
|
|
|
26 |
|
|
|
27 |
|
|
|
28 |
|
|
|
29 |
} { % => Context Parent Box
|
|
|
30 |
% Duplicate whitespace boxes should not offset further content and affect the line box length
|
|
|
31 |
1 index
|
|
|
32 |
get-line % => Context Parent Box Line
|
|
|
33 |
array-last
|
|
|
34 |
/box-whitespace is-a { % => Context Parent Box
|
|
|
35 |
|
|
|
36 |
|
|
|
37 |
|
|
|
38 |
} if
|
|
|
39 |
} ifelse
|
|
|
40 |
|
|
|
41 |
% Determine the baseline position and height of the text-box using line-height CSS property
|
|
|
42 |
dup box-generic-apply-line-height
|
|
|
43 |
|
|
|
44 |
% set default baseline
|
|
|
45 |
dup get-default-baseline
|
|
|
46 |
1 index put-baseline
|
|
|
47 |
|
|
|
48 |
% append current box to parent line box
|
|
|
49 |
dup 2 index
|
|
|
50 |
box-container-append-line % => Context Parent This
|
|
|
51 |
|
|
|
52 |
% Determine coordinates of upper-left _margin_ corner
|
|
|
53 |
1 index 1 index
|
|
|
54 |
box-generic-guess-corner % => Context Parent This
|
|
|
55 |
|
|
|
56 |
% Offset parent current X coordinate
|
|
|
57 |
dup get-full-width
|
|
|
58 |
2 index get-current-x
|
|
|
59 |
add % => Context Parent This CX'
|
|
|
60 |
2 index put-current-x % => Context Parent This
|
|
|
61 |
|
|
|
62 |
% Extends parents height
|
|
|
63 |
dup get-bottom-margin % => Context Parent This BM
|
|
|
64 |
2 index
|
|
|
65 |
box-generic-extend-height % => Context Parent This
|
|
|
66 |
|
|
|
67 |
% Update the value of current collapsed margin; pure text (non-span)
|
|
|
68 |
% boxes always have zero margin
|
|
|
69 |
|
|
|
70 |
2 index context-pop-collapsed-margin
|
|
|
71 |
|
|
|
72 |
|
|
|
73 |
pop pop pop
|
|
|
74 |
} def
|