| 1 |
lars |
1 |
% $Header: /cvsroot/html2ps/postscript/box.block.ps,v 1.1 2005/12/18 07:21:36 Konstantin Exp $
|
|
|
2 |
|
|
|
3 |
/box-block-create {
|
|
|
4 |
box-container-create
|
|
|
5 |
|
|
|
6 |
% Setup method references
|
|
|
7 |
dup box-block-setup-methods
|
|
|
8 |
dup /box-block add-type
|
|
|
9 |
} def
|
|
|
10 |
|
|
|
11 |
/box-block-reflow { % => Content Parent This
|
|
|
12 |
dup /position get-css-value
|
|
|
13 |
{
|
|
|
14 |
dup /static eq { pop 3 copy /reflow-static call-method exit } if
|
|
|
15 |
dup /relative eq { pop 3 copy /reflow-relative call-method exit } if
|
|
|
16 |
dup /absolute eq { pop dup 3 index context-add-absolute-positioned exit } if
|
|
|
17 |
dup /fixed eq { pop dup 3 index context-add-fixed-positioned exit } if
|
|
|
18 |
} loop
|
|
|
19 |
|
|
|
20 |
pop pop pop % =>
|
|
|
21 |
} def % =>
|
|
|
22 |
|
|
|
23 |
/box-block-reflow-absolute { % => Context This
|
|
|
24 |
% Calculate actual box position relative to the containing block
|
|
|
25 |
dup box-generic-get-containing-block
|
|
|
26 |
% => Context This CBlock
|
|
|
27 |
|
|
|
28 |
dup containing-block-left % => Context This CBlock CBLeft
|
|
|
29 |
2 index /left get-css-value add % => Context This CBlock Left
|
|
|
30 |
2 index put-left % => COntext This CBlock
|
|
|
31 |
|
|
|
32 |
% TODO: top percentage values
|
|
|
33 |
|
|
|
34 |
dup containing-block-top
|
|
|
35 |
2 index /top get-css-value
|
|
|
36 |
/value get sub % => Context This CBlock Top
|
|
|
37 |
2 index get-extra-top sub % => Context This CBlock Top
|
|
|
38 |
2 index put-top % => Context This CBlock
|
|
|
39 |
|
|
|
40 |
% As sometimes left/right values may not be set, we need to use the "fit" width here
|
|
|
41 |
% if no width constraints been set, it will not be modified by the code below
|
|
|
42 |
|
|
|
43 |
2 index 2 index /get-max-width
|
|
|
44 |
call-method % => Context This CBlock MW
|
|
|
45 |
2 index put-full-width % => Context This CBlock
|
|
|
46 |
|
|
|
47 |
% Update the width, as it should be calculated based upon containing block width, not real parent
|
|
|
48 |
|
|
|
49 |
dup containing-block-right
|
|
|
50 |
1 index containing-block-left
|
|
|
51 |
sub % => Context This CBlock CBWidth
|
|
|
52 |
2 index /get-width call-method % => Context This CBlock CBWidth W
|
|
|
53 |
3 index get-width-constraint
|
|
|
54 |
wc-apply % => Context This CBlock W'
|
|
|
55 |
2 index put-full-width % => Context This CBlock
|
|
|
56 |
|
|
|
57 |
% And remove any width constraint after this, as they could refer to parent widths
|
|
|
58 |
wc-create-none % => Context This CBlock WCNone
|
|
|
59 |
2 index put-width-constraint % => Context This CBlock
|
|
|
60 |
|
|
|
61 |
2 index 2 index
|
|
|
62 |
box-container-reflow-content % => Context This CBlock
|
|
|
63 |
|
|
|
64 |
pop pop pop
|
|
|
65 |
} def
|
|
|
66 |
|
|
|
67 |
/box-block-reflow-fixed { % => Context This
|
|
|
68 |
|
|
|
69 |
|
|
|
70 |
|
|
|
71 |
% As sometimes left/right values may not be set, we need to use the "fit" width here
|
|
|
72 |
% if no width constraints been set, it will not be modified by the code below
|
|
|
73 |
|
|
|
74 |
1 index
|
|
|
75 |
1 index /get-max-width
|
|
|
76 |
call-method
|
|
|
77 |
1 index put-full-width % => Context This
|
|
|
78 |
|
|
|
79 |
dup /get-width call-method
|
|
|
80 |
dup
|
|
|
81 |
2 index get-width-constraint
|
|
|
82 |
wc-apply
|
|
|
83 |
1 index put-full-width % => Context This
|
|
|
84 |
|
|
|
85 |
wc-create-none 1 index
|
|
|
86 |
put-width-constraint % => Context This
|
|
|
87 |
|
|
|
88 |
2 copy
|
|
|
89 |
box-container-reflow-content
|
|
|
90 |
|
|
|
91 |
pop pop
|
|
|
92 |
} def
|
|
|
93 |
|
|
|
94 |
/box-block-reflow-relative { % => Context Parent This
|
|
|
95 |
% CSS 2.1:
|
|
|
96 |
% Once a box has been laid out according to the normal flow or floated, it may be shifted relative
|
|
|
97 |
% to this position. This is called relative positioning. Offsetting a box (B1) in this way has no
|
|
|
98 |
% effect on the box (B2) that follows: B2 is given a position as if B1 were not offset and B2 is
|
|
|
99 |
% not re-positioned after B1's offset is applied. This implies that relative positioning may cause boxes
|
|
|
100 |
% to overlap. However, if relative positioning causes an 'overflow:auto' box to have overflow, the UA must
|
|
|
101 |
% allow the user to access this content, which, through the creation of scrollbars, may affect layout.
|
|
|
102 |
|
|
|
103 |
3 copy
|
|
|
104 |
box-block-reflow-static
|
|
|
105 |
|
|
|
106 |
% Note that percentage values are ignored for relative positioning
|
|
|
107 |
|
|
|
108 |
% Check if top value is percentage
|
|
|
109 |
|
|
|
110 |
dup /top get-css-value /percentage get {
|
|
|
111 |
|
|
|
112 |
} {
|
|
|
113 |
dup /top get-css-value /value get
|
|
|
114 |
} ifelse % => Context Parent This Top
|
|
|
115 |
neg
|
|
|
116 |
|
|
|
117 |
2 index /left get-css-value % => Context Parent This Top Left
|
|
|
118 |
2 index /offset call-method % => Context Parent This
|
|
|
119 |
|
|
|
120 |
pop pop pop
|
|
|
121 |
} def
|
|
|
122 |
|
|
|
123 |
/box-block-reflow-static { % => Context Parent This
|
|
|
124 |
dup /float get-css-value
|
|
|
125 |
/none eq {
|
|
|
126 |
3 copy /reflow-static-normal call-method
|
|
|
127 |
} {
|
|
|
128 |
3 copy /reflow-static-float call-method
|
|
|
129 |
} ifelse
|
|
|
130 |
pop pop pop
|
|
|
131 |
} def
|
|
|
132 |
|
|
|
133 |
/box-block-reflow-static-normal { % => Context Parent This
|
|
|
134 |
1 index /null ne {
|
|
|
135 |
% By default, child block box will fill all available parent width;
|
|
|
136 |
% note that actual width will be smaller because of non-zero padding, border and margins
|
|
|
137 |
1 index /get-width call-method
|
|
|
138 |
1 index put-full-width
|
|
|
139 |
|
|
|
140 |
% calculate margin values if thy have been set as a percentage
|
|
|
141 |
1 index 1 index box-generic-calc-percentage-margins
|
|
|
142 |
|
|
|
143 |
% calculate width value if it had been set as percentage
|
|
|
144 |
2 index 2 index 2 index box-generic-calc-percentage-width
|
|
|
145 |
|
|
|
146 |
% calculate 'auto' values of width and margins
|
|
|
147 |
% unline tables, DIV width is either constrained by some CSS rules or
|
|
|
148 |
% expanded to the parent width; thus, we can calculate 'auto' margin
|
|
|
149 |
% values immediately
|
|
|
150 |
1 index 1 index box-generic-calc-auto-width-margins
|
|
|
151 |
|
|
|
152 |
3 copy box-generic-collapse-margin % => Context Parent This Y
|
|
|
153 |
|
|
|
154 |
% At this moment we have top parent/child collapsed margin at the top of context object
|
|
|
155 |
% margin stack
|
|
|
156 |
|
|
|
157 |
% Apply 'clear' property
|
|
|
158 |
|
|
|
159 |
3 index exch 2 index % => Context Parent This Context Y This
|
|
|
160 |
box-generic-apply-clear % => Context Parent This Y
|
|
|
161 |
|
|
|
162 |
% Store calculated Y coordinate as current Y in the parent box
|
|
|
163 |
2 index put-current-y % => Context Parent This
|
|
|
164 |
|
|
|
165 |
% Terminate current parent line-box
|
|
|
166 |
2 index
|
|
|
167 |
2 index
|
|
|
168 |
box-container-close-line
|
|
|
169 |
|
|
|
170 |
% And add current box to the parent's line-box (alone)
|
|
|
171 |
dup 2 index box-container-append-line
|
|
|
172 |
|
|
|
173 |
% Note that top margin already used above during margin collapsing
|
|
|
174 |
1 index get-current-y
|
|
|
175 |
1 index get-border-top-width sub
|
|
|
176 |
1 index get-padding-top sub % => Context Parent This Y
|
|
|
177 |
|
|
|
178 |
2 index get-left
|
|
|
179 |
2 index get-extra-left add % => Context Parent This Y X
|
|
|
180 |
|
|
|
181 |
2 index box-generic-move-to % => Context Parent This
|
|
|
182 |
} if
|
|
|
183 |
|
|
|
184 |
% Reflow contents
|
|
|
185 |
2 index 1 index % => Context Parent This Context This
|
|
|
186 |
box-container-reflow-content % => Context Parent This
|
|
|
187 |
|
|
|
188 |
% After reflow_content we should have the top stack value replaced by the value
|
|
|
189 |
% of last child bottom collapsed margin
|
|
|
190 |
|
|
|
191 |
dup box-container-get-first /null ne {
|
|
|
192 |
2 index context-get-collapsed-margin
|
|
|
193 |
} {
|
|
|
194 |
|
|
|
195 |
} ifelse
|
|
|
196 |
1 index get-margin-bottom
|
|
|
197 |
max % => Context Parent This max(cm,bm)
|
|
|
198 |
|
|
|
199 |
3 index context-pop-collapsed-margin
|
|
|
200 |
3 index context-pop-collapsed-margin
|
|
|
201 |
3 index context-push-collapsed-margin
|
|
|
202 |
% => Context Parent This
|
|
|
203 |
|
|
|
204 |
1 index /null ne {
|
|
|
205 |
% Extend parent's height to fit current box
|
|
|
206 |
1 index get-uid
|
|
|
207 |
3 index context-container-uid eq {
|
|
|
208 |
dup get-bottom-margin
|
|
|
209 |
2 index box-generic-extend-height
|
|
|
210 |
} {
|
|
|
211 |
dup get-bottom-border
|
|
|
212 |
2 index box-generic-extend-height
|
|
|
213 |
} ifelse % => Context Parent This
|
|
|
214 |
|
|
|
215 |
2 index 2 index
|
|
|
216 |
box-container-close-line
|
|
|
217 |
|
|
|
218 |
% Then shift current flow position to the current box margin edge
|
|
|
219 |
dup get-bottom-border
|
|
|
220 |
3 index context-get-collapsed-margin sub
|
|
|
221 |
2 index put-current-y
|
|
|
222 |
} if % => Context Parent This
|
|
|
223 |
|
|
|
224 |
3 copy
|
|
|
225 |
box-generic-check-page-break-after
|
|
|
226 |
|
|
|
227 |
pop pop pop
|
|
|
228 |
} def
|
|
|
229 |
|
|
|
230 |
/box-block-setup-methods { % => Box
|
|
|
231 |
dup get-box-dict /Methods get % => Box Methods
|
|
|
232 |
dup /reflow {box-block-reflow} put
|
|
|
233 |
dup /reflow-absolute {box-block-reflow-absolute} put
|
|
|
234 |
dup /reflow-relative {box-block-reflow-relative} put
|
|
|
235 |
dup /reflow-static {box-block-reflow-static} put
|
|
|
236 |
dup /reflow-static-normal {box-block-reflow-static-normal} put
|
|
|
237 |
pop pop
|
|
|
238 |
} def
|
|
|
239 |
|
|
|
240 |
/box-block-show-fixed { % => Viewport Box
|
|
|
241 |
1 index viewport-get-left
|
|
|
242 |
1 index /left get-css-value add % => Viewport Box Left
|
|
|
243 |
|
|
|
244 |
2 index viewport-get-top
|
|
|
245 |
2 index /top get-css-value
|
|
|
246 |
/value get sub % => Viewport Box Left Top
|
|
|
247 |
|
|
|
248 |
exch
|
|
|
249 |
|
|
|
250 |
2 index box-generic-move-to % => Viewport Box
|
|
|
251 |
|
|
|
252 |
2 copy /show call-method
|
|
|
253 |
|
|
|
254 |
pop pop
|
|
|
255 |
} def
|