| 1 |
lars |
1 |
/box-generic-inline-create { % =>
|
|
|
2 |
box-container-create % => Box
|
|
|
3 |
dup box-generic-inline-setup-methods
|
|
|
4 |
dup /box-generic-inline add-type
|
|
|
5 |
} def % => Box
|
|
|
6 |
|
|
|
7 |
/box-generic-inline-setup-methods {% => Box
|
|
|
8 |
dup box-container-setup-methods
|
|
|
9 |
|
|
|
10 |
dup get-box-dict /Methods get % => Box Methods
|
|
|
11 |
dup /maybe-line-break {box-generic-inline-maybe-line-break} put
|
|
|
12 |
pop pop
|
|
|
13 |
} def
|
|
|
14 |
|
|
|
15 |
% Checks if current inline box should cause a line break inside the parent box
|
|
|
16 |
%
|
|
|
17 |
% @param $parent reference to a parent box
|
|
|
18 |
% @param $content flow context
|
|
|
19 |
% @return true if line break occurred; false otherwise
|
|
|
20 |
%
|
|
|
21 |
/box-generic-inline-maybe-line-break {
|
|
|
22 |
% => Context Parent This
|
|
|
23 |
1 index /line-break-allowed call-method {
|
|
|
24 |
% Calculate the x-coordinate of this box right edge
|
|
|
25 |
1 index get-current-x
|
|
|
26 |
1 index get-full-width
|
|
|
27 |
add % => Context Parent This RightX
|
|
|
28 |
|
|
|
29 |
false % => Context Parent This RightX NeedBreak
|
|
|
30 |
|
|
|
31 |
% Check for right-floating boxes
|
|
|
32 |
% If upper-right corner of this inline box is inside of some float, wrap the line
|
|
|
33 |
3 index get-current-y
|
|
|
34 |
2 index % => Context Parent This RightX NeedBreak CY X
|
|
|
35 |
6 index
|
|
|
36 |
context-point-in-floats
|
|
|
37 |
/null ne % => Context Parent This RightX NeedBreak NeedBreak'
|
|
|
38 |
or % => Context Parent This RightX NeedBreak
|
|
|
39 |
|
|
|
40 |
% No floats; check if we had run out the right edge of container
|
|
|
41 |
3 index get-right
|
|
|
42 |
rounding-epsilon add % => Context Parent This RightX NeedBreak $parent->get_right()+EPSILON
|
|
|
43 |
2 index le { % => Context Parent This RightX NeedBreak
|
|
|
44 |
|
|
|
45 |
% Now check if parent line box contains any other boxes;
|
|
|
46 |
% if not, we should draw this box unless we have a floating box to the left
|
|
|
47 |
|
|
|
48 |
3 index
|
|
|
49 |
box-container-get-first % => Context Parent This RightX NeedBreak First
|
|
|
50 |
|
|
|
51 |
4 index
|
|
|
52 |
box-generic-calc-text-indent % => Context Parent This RightX NeedBreak First IndentOffset
|
|
|
53 |
|
|
|
54 |
5 index get-current-x % => Context Parent This RightX NeedBreak First IndentOffset CX
|
|
|
55 |
6 index get-left % => Context Parent This RightX NeedBreak First IndentOffset CX L
|
|
|
56 |
2 index add
|
|
|
57 |
rounding-epsilon add % => Context Parent This RightX NeedBreak First IndentOffset CX X
|
|
|
58 |
gt % => Context Parent This RightX NeedBreak First IndentOffset CX>X
|
|
|
59 |
exch pop
|
|
|
60 |
exch pop % => Context Parent This RightX NeedBreak CX>X
|
|
|
61 |
or % => Context Parent This RightX NeedBreak'
|
|
|
62 |
} if % => Context Parent This RightX NeedBreak
|
|
|
63 |
|
|
|
64 |
% As close-line will not change the current-Y parent coordinate if no
|
|
|
65 |
% items were in the line box, we need to offset this explicitly in this case
|
|
|
66 |
|
|
|
67 |
3 index get-line length 0 eq
|
|
|
68 |
1 index and { % => Context Parent This RightX NeedBreak
|
|
|
69 |
3 index get-current-y
|
|
|
70 |
3 index get-height sub
|
|
|
71 |
5 index put-current-y
|
|
|
72 |
} if
|
|
|
73 |
|
|
|
74 |
dup {
|
|
|
75 |
4 index
|
|
|
76 |
4 index box-container-close-line
|
|
|
77 |
} if % => Context Pareht This RightX NeedBreak
|
|
|
78 |
|
|
|
79 |
exch pop
|
|
|
80 |
exch pop
|
|
|
81 |
exch pop
|
|
|
82 |
exch pop
|
|
|
83 |
} {
|
|
|
84 |
pop pop pop false
|
|
|
85 |
} ifelse
|
|
|
86 |
} def
|