Spaces:
Sleeping
Sleeping
File size: 7,890 Bytes
07c3cdd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | /box-frame-create { % =>
box-container-create
dup box-frame-setup-methods
dup /box-frame add-type
} def
/box-frame-reflow { % => Context Parent This
% If frame contains no boxes (for example, the src link is broken)
% we just return - no further processing will be done
dup get-content length 0 gt {
% First box contained in a frame should always fill all its height
dup get-height
1 index get-content 0 get put-full-height
0 3 index context-push-collapsed-margin
dup get-uid 3 index context-push-container-uid
2 index 1 index
box-container-reflow-content
2 index context-pop-collapsed-margin
2 index context-pop-container-uid
} if
pop pop pop
} def
/box-frame-setup-methods { % => Box
dup /Methods get
dup /reflow {box-frame-reflow} put
pop pop
} def
/box-frameset-create {
box-container-create
dup box-frameset-setup-methods
dup /rows 1 put
dup /cols 1 put
dup /box-frameset add-type
} def
/box-frameset-guess-lengths { % => Height Lengths Frameset
% Initialization
[] % => Height Lengths Frameset Values
2 index { % => Height Lengths Frameset Values Length
pop 0 exch array-append % => Height Lengths Frameset Values'
} forall
% First pass: fixed-width columns
0 1 2 index length 1 sub { % => Height Lengths Frameset Values I
3 index 1 index get
dup /type get % => Height Lengths Frameset Values I Length Type
{
dup /percentage eq {
pop
/value get % => Height Lengths Frameset Values I Value
5 index mul
100 div % => Height Lengths Frameset Values I Value
2 index 2 index 2 index put
pop
exit
} if
dup /constant eq {
pop
/value get px % => Height Lengths Frameset Values I Value
2 index 2 index 2 index put
pop
exit
} if
pop pop exit
} loop % => Height Lengths Frameset Values I
pop % => Height Lengths Frameset Values
} for % => Height Lengths Frameset Values
% Second pass: relative-width columns
3 index 1 index sum sub % => Height Lengths Frameset Values Rest
0 % => Height Lengths Frameset Values Rest Parts
4 index
{ % => Height Lengths Frameset Values Rest Parts Value
dup /type get /fraction eq { % => Height Lengths Frameset Values Rest Parts Value
/value get add % => Height Lengths Frameset Values Rest Parts
} { % => Height Lengths Frameset Values Rest Parts Value
pop
} ifelse % => Height Lengths Frameset Values Rest Parts
} forall
dup 0 gt {
div % => Height Lengths Frameset Values PartSize
0 1 5 index length 1 sub { % => Height Lengths Frameset Values PartSize I
4 index 1 index get
dup /type get /fraction eq { % => Height Lengths Frameset Values PartSize I Length
/value get % => Height Lengths Frameset Values PartSize I Parts
2 index mul % => Height Lengths Frameset Values PartSize I Len
3 index exch
2 index exch put % => Height Lengths Frameset Values PartSize I
} {
pop
} ifelse % => Height Lengths Frameset Values PartSize I
pop
} for % => Height Lengths Frameset Values PartSize
pop
} { pop pop } ifelse % => Height Lengths Frameset Values
% Fix over/underconstrained framesets
dup sum % => Height Lengths Frameset Values Width
dup 0 gt {
4 index exch div % => Height Lengths Frameset Values Koeff
0 1 3 index length 1 sub { % => Height Lengths Frameset Values Koeff I
2 index 1 index get
2 index mul % => Height Lengths Frameset Values Koeff I Value'
3 index exch
2 index exch put % => Height Lengths Frameset Values Koeff I
pop
} for % => Height Lengths Frameset Values Koeff
pop
} {
pop
} ifelse
exch pop
exch pop
exch pop
} def
/box-frameset-put-cols { % => Value Box
exch /cols exch put
} def
/box-frameset-put-rows {
exch /rows exch put
} def
/box-frameset-reflow { % => Context Parent Box
2 index context-get-viewport % => Context Parent Box Viewport
% Frameset always fill all available space in viewport
dup flow-viewport-get-left
2 index get-extra-left add
2 index put-left
dup flow-viewport-get-top
2 index get-extra-top sub
2 index put-top
dup flow-viewport-get-width
2 index put-full-width
dup flow-viewport-get-height
2 index put-full-height
pop % => Context Parent Box
% Parse layout-colntrol values
dup get-height
1 index /rows get
2 index
box-frameset-guess-lengths % => Context Parent Box RowSizes
1 index /get-width call-method
2 index /cols get
3 index
box-frameset-guess-lengths % => Context Parent Box RowSizes ColSizes
% Now reflow all frames in frameset
0 0 % => Context Parent Box RowSizes ColSizes CurCol CurRow
4 index get-content { % => Context Parent Box RowSizes ColSizes CurCol CurRow Frame
% Had we run out of cols/rows ?
1 index 5 index length ge {
pop
exit
} if % => Context Parent Box RowSizes ColSizes CurCol CurRow Frame
% Guess frame size and position
5 index get-left % => Context Parent Box RowSizes ColSizes CurCol CurRow Frame Left
4 index 0 % => Context Parent Box RowSizes ColSizes CurCol CurRow Frame Left ColsSizes 0
5 index getinterval sum % => Context Parent Box RowSizes ColSizes CurCol CurRow Frame Left ColOfs
add
1 index get-extra-left add % => Context Parent Box RowSizes ColSizes CurCol CurRow Frame Left
1 index put-left % => Context Parent Box RowSizes ColSizes CurCol CurRow Frame
5 index get-top % => Context Parent Box RowSizes ColSizes CurCol CurRow Frame Top
5 index 0
4 index getinterval sum % => Context Parent Box RowSizes ColSizes CurCol CurRow Frame Top RowOfs
sub
1 index get-extra-top sub
1 index put-top % => Context Parent Box RowSizes ColSizes CurCol CurRow Frame
3 index 3 index get
1 index put-full-width % => Context Parent Box RowSizes ColSizes CurCol CurRow Frame
dup /get-width call-method wc-create-constant
1 index put-width-constraint
4 index 2 index get
1 index put-full-height % => Context Parent Box RowSizes ColSizes CurCol CurRow Frame
% Reflow frame contents
dup flow-viewport-create % => Context Parent Box RowSizes ColSizes CurCol CurRow Frame Viewport'
8 index context-push-viewport % => Context Parent Box RowSizes ColSizes CurCol CurRow Frame
7 index
6 index
2 index /reflow call-method % => Context Parent Box RowSizes ColSizes CurCol CurRow Frame
7 index context-pop-viewport
% Move to the nex frame position
3 2 roll 1 add 3 1 roll % => Context Parent Box RowSizes ColSizes CurCol' CurRow Frame
2 index 4 index length ge {
3 2 roll pop 0 3 1 roll
exch 1 add exch
} if
pop
} forall % => Context Parent Box RowSizes ColSizes CurCol CurRow
pop pop pop pop
pop pop pop
} def
/box-frameset-setup-methods {
dup /Methods get
dup /reflow {box-frameset-reflow} put
pop pop
} def
|