| 1 |
lars |
1 |
/box-inline-create { % =>
|
|
|
2 |
box-generic-inline-create
|
|
|
3 |
|
|
|
4 |
dup /Lines [] put
|
|
|
5 |
|
|
|
6 |
dup box-inline-setup-methods
|
|
|
7 |
dup /box-inline add-type
|
|
|
8 |
} def % => Box
|
|
|
9 |
|
|
|
10 |
% Extends the existing line box to include the given child
|
|
|
11 |
% OR starts new line box, if current child is to the left of the box right edge
|
|
|
12 |
% (which should not happen white the line box is filled)
|
|
|
13 |
%
|
|
|
14 |
% @param $box child box which will be first in this line box
|
|
|
15 |
% @param $line_no number of line box
|
|
|
16 |
%
|
|
|
17 |
/box-inline-extend-line { % => LineNo Box This
|
|
|
18 |
dup box-inline-get-lines
|
|
|
19 |
length % => LineNo Box This NumLines
|
|
|
20 |
3 index le { % => LineNo Box This
|
|
|
21 |
% New line box started
|
|
|
22 |
2 index
|
|
|
23 |
2 index
|
|
|
24 |
2 index
|
|
|
25 |
box-inline-init-line % => LineNo Box This
|
|
|
26 |
2 index % => LineNo Box This LineNo
|
|
|
27 |
} { % => LineNo Box This
|
|
|
28 |
1 index get-left % => LineNo Box This BoxLeft
|
|
|
29 |
1 index box-inline-get-lines % => LineNo Box This BoxLeft Lines
|
|
|
30 |
4 index get % => LineNo Box This BoxLeft Line
|
|
|
31 |
line-get-right % => LineNo Box This BoxLeft LineRight
|
|
|
32 |
lt { % => LineNo Box This
|
|
|
33 |
2 index 1 add % => LineNo Box This LineNo'
|
|
|
34 |
dup
|
|
|
35 |
3 index
|
|
|
36 |
3 index % => LineNo Box This LineNo' LineNo' Box This
|
|
|
37 |
box-inline-init-line % => LineNo Box This LineNo'
|
|
|
38 |
} {
|
|
|
39 |
dup box-inline-get-lines % => LineNo Box This Lines
|
|
|
40 |
3 index get % => LineNo Box This Line
|
|
|
41 |
2 index exch line-extend % => LineNo Box This
|
|
|
42 |
2 index % => LineNo Box This LineNo
|
|
|
43 |
} ifelse % =>
|
|
|
44 |
} ifelse % => LineNo Box This LineNo'
|
|
|
45 |
|
|
|
46 |
exch pop
|
|
|
47 |
exch pop
|
|
|
48 |
exch pop
|
|
|
49 |
} def
|
|
|
50 |
|
|
|
51 |
/box-inline-get-extra-line-left { % => This
|
|
|
52 |
dup get-extra-left % => This EL
|
|
|
53 |
1 index get-parent /null ne { % => This EL
|
|
|
54 |
1 index get-parent
|
|
|
55 |
/get-extra-line-left
|
|
|
56 |
call-method % => This EL ParentEL
|
|
|
57 |
add
|
|
|
58 |
} if
|
|
|
59 |
|
|
|
60 |
exch pop
|
|
|
61 |
} def
|
|
|
62 |
|
|
|
63 |
/box-inline-get-extra-line-right {
|
|
|
64 |
dup get-extra-right % => This EL
|
|
|
65 |
1 index get-parent /null ne { % => This EL
|
|
|
66 |
1 index get-parent
|
|
|
67 |
/get-extra-line-right
|
|
|
68 |
call-method % => This EL ParentEL
|
|
|
69 |
add
|
|
|
70 |
} if
|
|
|
71 |
|
|
|
72 |
exch pop
|
|
|
73 |
} def
|
|
|
74 |
|
|
|
75 |
/box-inline-get-lines {
|
|
|
76 |
/Lines get
|
|
|
77 |
} def
|
|
|
78 |
|
|
|
79 |
% Initialize next line box inside this inline
|
|
|
80 |
%
|
|
|
81 |
% Adds the next element to _lines array inside the current object and initializes it with the
|
|
|
82 |
% $box parameters
|
|
|
83 |
%
|
|
|
84 |
% @param $box child box which will be first in this line box
|
|
|
85 |
% @param $line_no number of line box
|
|
|
86 |
%
|
|
|
87 |
/box-inline-init-line { % => LineNo Box This
|
|
|
88 |
1 index
|
|
|
89 |
line-create % => LinoNo Box This Line
|
|
|
90 |
|
|
|
91 |
1 index box-inline-get-lines
|
|
|
92 |
array-prepend
|
|
|
93 |
1 index box-inline-put-lines % => LineNo Box This
|
|
|
94 |
|
|
|
95 |
pop pop pop
|
|
|
96 |
} def
|
|
|
97 |
|
|
|
98 |
/box-inline-merge-line { % => LineNo Box This
|
|
|
99 |
1 index box-inline-get-lines { % => LineNo Box This Line
|
|
|
100 |
1 index box-inline-get-lines % => LineNo Box This Line Lines
|
|
|
101 |
array-prepend % => LineNo Box This Lines'
|
|
|
102 |
1 index box-inline-put-lines % => LineNo Box This
|
|
|
103 |
} forall % => LineNo Box This
|
|
|
104 |
|
|
|
105 |
exch pop
|
|
|
106 |
exch pop
|
|
|
107 |
box-inline-get-lines length % => LineNo'
|
|
|
108 |
} def
|
|
|
109 |
|
|
|
110 |
/box-inline-offset { % => DY DX This
|
|
|
111 |
3 copy
|
|
|
112 |
box-container-offset % => DY DX This
|
|
|
113 |
|
|
|
114 |
dup box-inline-get-lines { % => DY DX This Line
|
|
|
115 |
3 index exch
|
|
|
116 |
3 index exch
|
|
|
117 |
line-offset % => DY DX This
|
|
|
118 |
} forall
|
|
|
119 |
|
|
|
120 |
pop pop pop
|
|
|
121 |
} def
|
|
|
122 |
|
|
|
123 |
/box-inline-put-lines { % => Value This
|
|
|
124 |
exch /Lines exch put
|
|
|
125 |
} def
|
|
|
126 |
|
|
|
127 |
/box-inline-reflow { % => Context Parent This
|
|
|
128 |
% Note that inline boxes (actually SPANS)
|
|
|
129 |
% are never added to the parent's line boxes
|
|
|
130 |
|
|
|
131 |
% Move current box to the parent's current coordinates
|
|
|
132 |
% Note that span box will start at the far left of the parent, NOT on its current X!
|
|
|
133 |
% Also, note that inline box can have margins, padding and borders!
|
|
|
134 |
|
|
|
135 |
1 index get-left
|
|
|
136 |
1 index put-left
|
|
|
137 |
|
|
|
138 |
1 index get-top
|
|
|
139 |
1 index get-extra-top sub
|
|
|
140 |
1 index put-top % => Context Parent This
|
|
|
141 |
|
|
|
142 |
% first line of the SPAN will be offset to its parent current-x PLUS the left padding of current span!
|
|
|
143 |
1 index get-current-x
|
|
|
144 |
1 index get-extra-left
|
|
|
145 |
add % => Context Parent This CX
|
|
|
146 |
|
|
|
147 |
dup 3 index put-current-x % => Context Parent This CX
|
|
|
148 |
1 index put-current-x % => Context Pareht This
|
|
|
149 |
|
|
|
150 |
% Note that the same operation IS NOT applied to parent current-y!
|
|
|
151 |
% The padding space is just extended to the top possibly OVERLAPPING the above boxes.
|
|
|
152 |
|
|
|
153 |
|
|
|
154 |
|
|
|
155 |
% Reflow contents
|
|
|
156 |
|
|
|
157 |
|
|
|
158 |
1 index get-content { % => Context Parent This LineNo Child
|
|
|
159 |
% Add current element into _parent_ line box and reflow it
|
|
|
160 |
4 index
|
|
|
161 |
4 index % => Context Parent This LineNo Child Context Parent
|
|
|
162 |
2 index
|
|
|
163 |
/reflow call-method % => Context Parent This LineNo Child
|
|
|
164 |
|
|
|
165 |
% Track the real height of the inline box; it will be used by other functions
|
|
|
166 |
% (say, functions calculating content height)
|
|
|
167 |
dup get-bottom-margin % => Context Parent This LineNo' Child BM
|
|
|
168 |
3 index
|
|
|
169 |
box-generic-extend-height % => Context Parent This LineNo Child
|
|
|
170 |
|
|
|
171 |
pop
|
|
|
172 |
} forall % => Context Parent This LineNo
|
|
|
173 |
pop % => Context Parent This
|
|
|
174 |
|
|
|
175 |
% Extend parent height to fit this inline box
|
|
|
176 |
% TODO: Is it really required? Seems that it will be accomplished by child reflow functions
|
|
|
177 |
% dup get-bottom-margin % => Context Parent This GBM
|
|
|
178 |
% 2 index
|
|
|
179 |
% box-generic-extend-height % => Context Parent This
|
|
|
180 |
|
|
|
181 |
% Apply right extra space value (padding + border + margin)
|
|
|
182 |
1 index get-current-x
|
|
|
183 |
1 index get-extra-right
|
|
|
184 |
add
|
|
|
185 |
2 index put-current-x
|
|
|
186 |
|
|
|
187 |
% After reflow_content we should have the top stack value replace by the value
|
|
|
188 |
% of last child bottom collapsed margin
|
|
|
189 |
|
|
|
190 |
dup box-container-get-first-data /null ne {
|
|
|
191 |
2 index context-pop-collapsed-margin
|
|
|
192 |
|
|
|
193 |
} if
|
|
|
194 |
|
|
|
195 |
pop pop pop
|
|
|
196 |
} def
|
|
|
197 |
|
|
|
198 |
/box-inline-reflow-inline { % => This
|
|
|
199 |
|
|
|
200 |
1 index get-content { % => This LineNo Child
|
|
|
201 |
dup /reflow-inline call-method
|
|
|
202 |
|
|
|
203 |
dup /box-inline is-a {
|
|
|
204 |
1 index % => This LineNo Child LineNo
|
|
|
205 |
1 index % => This LineNo Child LineNo Child
|
|
|
206 |
4 index % => This LineNo Child LineNo Child This
|
|
|
207 |
box-inline-merge-line % => This LineNo Child LineNo'
|
|
|
208 |
|
|
|
209 |
3 2 roll % => This Child LineNo' LineNo
|
|
|
210 |
pop
|
|
|
211 |
exch % => This LineNo' Child
|
|
|
212 |
} {
|
|
|
213 |
1 index % => This LineNo Child LineNo
|
|
|
214 |
1 index % => This LineNo Child LineNo Child
|
|
|
215 |
4 index % => This LineNo Child LineNo Child This
|
|
|
216 |
box-inline-extend-line % => This LineNo Child LineNo'
|
|
|
217 |
3 2 roll % => This Child LineNo' LineNo
|
|
|
218 |
pop
|
|
|
219 |
exch % => This LineNo' Child
|
|
|
220 |
} ifelse % => This LineNo' Child
|
|
|
221 |
|
|
|
222 |
pop
|
|
|
223 |
} forall
|
|
|
224 |
|
|
|
225 |
pop pop
|
|
|
226 |
} def
|
|
|
227 |
|
|
|
228 |
/box-inline-setup-methods { % => Box
|
|
|
229 |
dup get-box-dict /Methods get % => Box Methods
|
|
|
230 |
dup /get-extra-line-left {box-inline-get-extra-line-left} put
|
|
|
231 |
dup /get-extra-line-right {box-inline-get-extra-line-right} put
|
|
|
232 |
dup /offset {box-inline-offset} put
|
|
|
233 |
dup /reflow {box-inline-reflow} put
|
|
|
234 |
dup /reflow-inline {box-inline-reflow-inline} put
|
|
|
235 |
dup /show {box-inline-show} put
|
|
|
236 |
pop pop
|
|
|
237 |
} def
|
|
|
238 |
|
|
|
239 |
/box-inline-show { % => Viewport This
|
|
|
240 |
% Show line boxes background and borders
|
|
|
241 |
dup box-inline-get-lines { % => Viewport This Line
|
|
|
242 |
1 index 1 index line-fake-box % => Viewport This Line FakeBox
|
|
|
243 |
|
|
|
244 |
dup
|
|
|
245 |
4 index % => Viewport This Line FakeBox FakeBox Viewport
|
|
|
246 |
4 index get-background
|
|
|
247 |
background-show % => Viewport This Line FakeBox
|
|
|
248 |
|
|
|
249 |
dup
|
|
|
250 |
4 index
|
|
|
251 |
4 index get-border
|
|
|
252 |
border-show % => Viewport This Line FakeBox
|
|
|
253 |
|
|
|
254 |
pop pop
|
|
|
255 |
} forall
|
|
|
256 |
|
|
|
257 |
% Show content
|
|
|
258 |
dup get-content { % => Viewport This Child
|
|
|
259 |
2 index exch
|
|
|
260 |
/show call-method % => Viewport This
|
|
|
261 |
} forall
|
|
|
262 |
|
|
|
263 |
pop pop
|
|
|
264 |
} def
|
|
|
265 |
|
|
|
266 |
/line-create { % => Box
|
|
|
267 |
<< >>
|
|
|
268 |
dup /right 3 index get-right put
|
|
|
269 |
dup /left 3 index get-left put
|
|
|
270 |
dup /top 3 index get-top put
|
|
|
271 |
dup /bottom 3 index get-bottom put
|
|
|
272 |
exch pop
|
|
|
273 |
} def
|
|
|
274 |
|
|
|
275 |
/line-extend { % => Box This
|
|
|
276 |
dup /top get % => Box This V1
|
|
|
277 |
2 index get-top % => Box This V1 V2
|
|
|
278 |
max
|
|
|
279 |
1 index exch /top exch put
|
|
|
280 |
|
|
|
281 |
dup /right get % => Box This V1
|
|
|
282 |
2 index get-right % => Box This V1 V2
|
|
|
283 |
max
|
|
|
284 |
1 index exch /right exch put
|
|
|
285 |
|
|
|
286 |
dup /bottom get % => Box This V1
|
|
|
287 |
2 index get-bottom % => Box This V1 V2
|
|
|
288 |
min
|
|
|
289 |
1 index exch /bottom exch put
|
|
|
290 |
|
|
|
291 |
% Left edge of the line box should never be modified
|
|
|
292 |
|
|
|
293 |
pop pop
|
|
|
294 |
} def
|
|
|
295 |
|
|
|
296 |
/line-get-right {
|
|
|
297 |
/right get
|
|
|
298 |
} def
|
|
|
299 |
|
|
|
300 |
/line-fake-box { % => Box This
|
|
|
301 |
% Create the fake box object
|
|
|
302 |
box-block-create % => Box This FakeBox
|
|
|
303 |
|
|
|
304 |
% Setup fake box size
|
|
|
305 |
1 index /left get
|
|
|
306 |
1 index put-left
|
|
|
307 |
|
|
|
308 |
1 index /right get
|
|
|
309 |
2 index /left get sub
|
|
|
310 |
1 index put-width
|
|
|
311 |
|
|
|
312 |
1 index /top get
|
|
|
313 |
1 index get-baseline sub
|
|
|
314 |
1 index put-top
|
|
|
315 |
|
|
|
316 |
1 index /top get
|
|
|
317 |
2 index /bottom get sub
|
|
|
318 |
1 index put-height
|
|
|
319 |
|
|
|
320 |
% Setup padding value
|
|
|
321 |
2 index get-padding
|
|
|
322 |
1 index put-padding
|
|
|
323 |
|
|
|
324 |
% Setup fake box border and background
|
|
|
325 |
2 index get-background
|
|
|
326 |
1 index put-background
|
|
|
327 |
|
|
|
328 |
2 index get-border
|
|
|
329 |
1 index put-border
|
|
|
330 |
|
|
|
331 |
exch pop
|
|
|
332 |
exch pop
|
|
|
333 |
} def
|
|
|
334 |
|
|
|
335 |
/line-offset { % => DY DX This
|
|
|
336 |
dup /top get % => DY DX This Top
|
|
|
337 |
3 index add % => DY DX This Top'
|
|
|
338 |
1 index exch % => DY DX This This Top'
|
|
|
339 |
/top exch put % => DY DX This
|
|
|
340 |
|
|
|
341 |
dup /bottom get % => DY DX This Bottom
|
|
|
342 |
3 index add % => DY DX This Bottom'
|
|
|
343 |
1 index exch % => DY DX This This Bottom'
|
|
|
344 |
/bottom exch put % => DY DX This
|
|
|
345 |
|
|
|
346 |
dup /left get % => DY DX This Left
|
|
|
347 |
2 index add % => DY DX This Left'
|
|
|
348 |
1 index exch % => DY DX This This Left'
|
|
|
349 |
/left exch put % => DY DX This
|
|
|
350 |
|
|
|
351 |
dup /right get % => DY DX This Right
|
|
|
352 |
2 index add % => DY DX This Right'
|
|
|
353 |
1 index exch % => DY DX This This Right'
|
|
|
354 |
/right exch put % => DY DX This
|
|
|
355 |
|
|
|
356 |
pop pop pop
|
|
|
357 |
} def
|