| 1 |
lars |
1 |
% $Header: /cvsroot/html2ps/postscript/height.ps,v 1.1 2005/12/18 07:21:38 Konstantin Exp $
|
|
|
2 |
|
|
|
3 |
/hc-apply { % => Box RawHeight HC
|
|
|
4 |
dup /constant get /null ne {
|
|
|
5 |
1 index % => Box RawHeight HC RawHeight
|
|
|
6 |
3 index % => Box RawHeight HC RawHeight Box
|
|
|
7 |
2 index /constant get % => Box RawHeight HC RawHeight Box Constant
|
|
|
8 |
hc-fix-value % => Box RawHeight HC H
|
|
|
9 |
} {
|
|
|
10 |
2 index % => Box RawHeight HC Box
|
|
|
11 |
2 index % => Box RawHeight HC Box RawHeight
|
|
|
12 |
2 index % => Box RawHeight HC Box RawHeight HC
|
|
|
13 |
hc-apply-max % => Box RawHeight HC H0
|
|
|
14 |
|
|
|
15 |
3 index exch % => Box RawHeight HC Box H0
|
|
|
16 |
2 index
|
|
|
17 |
hc-apply-min % => Box RawHeight HC H1
|
|
|
18 |
} ifelse % => Box RawHeight HC H
|
|
|
19 |
|
|
|
20 |
exch pop
|
|
|
21 |
exch pop
|
|
|
22 |
exch pop
|
|
|
23 |
} def
|
|
|
24 |
|
|
|
25 |
/hc-apply-max { % => Box Value HC
|
|
|
26 |
dup /max get /null eq {
|
|
|
27 |
1 index
|
|
|
28 |
} {
|
|
|
29 |
1 index
|
|
|
30 |
3 index % => Box Value HC Value Box
|
|
|
31 |
2 index /max get % => Box Value HC Value Box HC
|
|
|
32 |
hc-fix-value % => Box Value HC H
|
|
|
33 |
|
|
|
34 |
2 index min % => Box Value HC H
|
|
|
35 |
} ifelse % => Box Value HC H
|
|
|
36 |
|
|
|
37 |
exch pop
|
|
|
38 |
exch pop
|
|
|
39 |
exch pop
|
|
|
40 |
} def
|
|
|
41 |
|
|
|
42 |
/hc-apply-min { % => Box Value HC
|
|
|
43 |
dup /min get /null eq {
|
|
|
44 |
1 index
|
|
|
45 |
} {
|
|
|
46 |
1 index
|
|
|
47 |
3 index % => Box Value HC Value Box
|
|
|
48 |
2 index /min get % => Box Value HC Value Box HC
|
|
|
49 |
hc-fix-value % => Box Value HC H
|
|
|
50 |
|
|
|
51 |
2 index max % => Box Value HC H
|
|
|
52 |
} ifelse % => Box Value HC H
|
|
|
53 |
|
|
|
54 |
exch pop
|
|
|
55 |
exch pop
|
|
|
56 |
exch pop
|
|
|
57 |
} def
|
|
|
58 |
|
|
|
59 |
/hc-create { % => Max Min Constant
|
|
|
60 |
<< >>
|
|
|
61 |
dup /max 5 index put
|
|
|
62 |
dup /min 4 index put
|
|
|
63 |
dup /constant 3 index put
|
|
|
64 |
|
|
|
65 |
exch pop
|
|
|
66 |
exch pop
|
|
|
67 |
exch pop
|
|
|
68 |
} def
|
|
|
69 |
|
|
|
70 |
/hc-fix-value { % => Default Box Value
|
|
|
71 |
% A percentage or immediate value?
|
|
|
72 |
dup /percentage get { % => Default Box Value
|
|
|
73 |
|
|
|
74 |
% CSS 2.1: The percentage is calculated with respect to the height of the generated box's containing block.
|
|
|
75 |
% If the height of the containing block is not specified explicitly (i.e., it depends on content height),
|
|
|
76 |
% and this element is not absolutely positioned, the value is interpreted like 'auto'.
|
|
|
77 |
|
|
|
78 |
% Check if parent exists
|
|
|
79 |
|
|
|
80 |
1 index get-parent dup
|
|
|
81 |
/null ne { % => Default Box Value Parent
|
|
|
82 |
dup get-height-constraint % => Default Box Value Parent ParentHC
|
|
|
83 |
3 index get-parent /box-table-cell is-a not
|
|
|
84 |
1 index /constant get /null eq and
|
|
|
85 |
1 index /min get /null eq and
|
|
|
86 |
1 index /max get /null eq and {
|
|
|
87 |
% if parent does not constrained height, return null - no height constraint can be applied
|
|
|
88 |
pop pop 2 index
|
|
|
89 |
} { % => Default Box Value Parent ParentHC
|
|
|
90 |
3 index get-parent /box-table-cell is-a {
|
|
|
91 |
3 index get-parent
|
|
|
92 |
/row get % => Default Box Value Parent ParentHC Row
|
|
|
93 |
|
|
|
94 |
% Note that unlike pure PHP DOM tree, we have box-table-row as a direct parent of the cell here
|
|
|
95 |
4 index get-parent
|
|
|
96 |
get-parent
|
|
|
97 |
get-parent % => Default Box Value Parent ParentHC Row Table
|
|
|
98 |
|
|
|
99 |
box-table-get-rhc % => Default Box Value Parent ParentHC RHC
|
|
|
100 |
|
|
|
101 |
dup hc-is-null {
|
|
|
102 |
pop 4 index
|
|
|
103 |
} {
|
|
|
104 |
4 index exch % => Default Box Value Parent ParentHC Box RHC
|
|
|
105 |
1 index get-parent
|
|
|
106 |
get-height exch % => Default Box Value Parent ParentHC Box BaseHeight RHC
|
|
|
107 |
hc-apply % => Default Box Value Parent ParentHC H
|
|
|
108 |
} ifelse
|
|
|
109 |
|
|
|
110 |
exch pop
|
|
|
111 |
exch pop % => Default Box Value H
|
|
|
112 |
} {
|
|
|
113 |
pop
|
|
|
114 |
get-height % => Default Box Value ParentH
|
|
|
115 |
1 index /value get
|
|
|
116 |
mul 100 div % => Default Box Value H
|
|
|
117 |
} ifelse
|
|
|
118 |
} ifelse
|
|
|
119 |
} { % => Default Box Value
|
|
|
120 |
/null
|
|
|
121 |
} ifelse % => Default Box Value H
|
|
|
122 |
} { % => Default Box Value
|
|
|
123 |
dup /value get
|
|
|
124 |
} ifelse % => Default Box Value H
|
|
|
125 |
|
|
|
126 |
exch pop
|
|
|
127 |
exch pop
|
|
|
128 |
exch pop
|
|
|
129 |
} def
|
|
|
130 |
|
|
|
131 |
/hc-is-constant { % => HC
|
|
|
132 |
/constant get /null ne
|
|
|
133 |
} def
|
|
|
134 |
|
|
|
135 |
/hc-is-null { % => HC
|
|
|
136 |
dup /min get /null eq
|
|
|
137 |
1 index /max get /null eq and
|
|
|
138 |
1 index /constant get /null eq and
|
|
|
139 |
exch pop
|
|
|
140 |
} def
|
|
|
141 |
|
|
|
142 |
/hc-is-percentage { % => HC
|
|
|
143 |
dup /min get /null ne {
|
|
|
144 |
dup /min get /percentage get not
|
|
|
145 |
} { true } ifelse
|
|
|
146 |
|
|
|
147 |
1 index /max get /null ne {
|
|
|
148 |
1 index /max get /percentage get not
|
|
|
149 |
} { true } ifelse and
|
|
|
150 |
|
|
|
151 |
1 index /constant get /null ne {
|
|
|
152 |
1 index /constant get /percentage get not
|
|
|
153 |
} { true } ifelse and
|
|
|
154 |
|
|
|
155 |
not
|
|
|
156 |
exch pop
|
|
|
157 |
} def
|
|
|
158 |
|
|
|
159 |
%%%%%%%%%%%%%
|
|
|
160 |
|
|
|
161 |
/is-height-constrained { % => Box
|
|
|
162 |
dup get-box-dict % => Box Dict
|
|
|
163 |
/Height get
|
|
|
164 |
dup /Constrained get % => Box HDict /Constrained
|
|
|
165 |
1 index /Min get 0 gt % => Box HDict /Constrained /ConstrainedMin
|
|
|
166 |
or
|
|
|
167 |
exch pop
|
|
|
168 |
exch pop
|
|
|
169 |
} def
|
|
|
170 |
|
|
|
171 |
/get-min-height {
|
|
|
172 |
dup get-box-dict % => Box Dict
|
|
|
173 |
/Height get
|
|
|
174 |
dup /MinPercentage get { % => Box HeightDict
|
|
|
175 |
% Percentage height can be applied only if parent's height is explicitly height to the constant length
|
|
|
176 |
1 index get-box-dict
|
|
|
177 |
/Parent get % => Box HeightDict Parent
|
|
|
178 |
get-box-dict
|
|
|
179 |
/Height get % => Box HeightDict ParentHeightDict
|
|
|
180 |
dup /Constrained get { % => Box HeightDict ParentHeightDict
|
|
|
181 |
/ConstraintPercentage
|
|
|
182 |
get not { % => Box HeightDict
|
|
|
183 |
/Min get
|
|
|
184 |
1 index exch
|
|
|
185 |
get-parent-height-fraction
|
|
|
186 |
} { % => Box HeightDict
|
|
|
187 |
pop 0
|
|
|
188 |
} ifelse
|
|
|
189 |
} { % => Box HeightDict ParentHeightDict
|
|
|
190 |
pop pop 0
|
|
|
191 |
} ifelse
|
|
|
192 |
} {
|
|
|
193 |
/Min get
|
|
|
194 |
} ifelse
|
|
|
195 |
|
|
|
196 |
exch pop
|
|
|
197 |
} def
|
|
|
198 |
|
|
|
199 |
/find-containing-block-height { % => Box
|
|
|
200 |
% Check if the parent box have constrained height
|
|
|
201 |
dup get-box-dict % => Box Dict
|
|
|
202 |
dup /Parent known {
|
|
|
203 |
/Parent get % => Box Parent
|
|
|
204 |
get-box-dict % => Box ParentDict
|
|
|
205 |
/Height get % => Box ParentHeightDict
|
|
|
206 |
dup /Constrained get % => Box ParentHeightDict ParentConstrained
|
|
|
207 |
exch % => Box ParentConstrained ParentHeightDict
|
|
|
208 |
/ConstraintPercentage get
|
|
|
209 |
not % => Box ParentConstrained !ParentPercentageConstrained
|
|
|
210 |
and
|
|
|
211 |
{
|
|
|
212 |
get-box-dict /Parent get
|
|
|
213 |
get-height
|
|
|
214 |
} {
|
|
|
215 |
% Box parent is not height-constrained, proceed to its parent
|
|
|
216 |
get-box-dict /Parent get
|
|
|
217 |
find-containing-block-height
|
|
|
218 |
} ifelse
|
|
|
219 |
} {
|
|
|
220 |
pop pop 0
|
|
|
221 |
} ifelse
|
|
|
222 |
} def
|
|
|
223 |
|
|
|
224 |
/calc-auto-height-margins { % => Box
|
|
|
225 |
dup get-real-height % => Box RH
|
|
|
226 |
1 index get-min-height % => Box RH MH
|
|
|
227 |
max % => Box H1
|
|
|
228 |
1 index get-max-height
|
|
|
229 |
min % => Box H
|
|
|
230 |
exch pop
|
|
|
231 |
} def
|