Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
/flow-table {                      % => Parent Child
2
% Calculate margin values if they have been set as a percentage
3
  2 copy
4
  calc-percentage-margins
5
 
6
% Calculate width value if it have been set as a percentage
7
  2 copy
8
  calc-percentage-width
9
 
10
%  dup get-box-dict
11
%  /Parent known {
12
%    dup calc-auto-width-margins
13
%  } if                             % => Parent Child
14
 
15
% As table width can be deterimined by its contents, we may calculate auto values
16
% only AFTER the contents have been reflown; thus, we'll offset the table
17
% as a whole by a value of left margin AFTER the content reflow
18
 
19
% suppress top/bottom margin for the first block box inside the table cell
20
% check if parent of this block is the table cell
21
  1 index get-box-dict /Display get
22
  /table-cell eq {
23
% check if current box is the first child
24
    1 index get-content 0 get 1 index eq {
25
 
26
    } if
27
% check if current box is the last child
28
    1 index get-content array-last 1 index eq {
29
 
30
    } if
31
  } if
32
 
33
% DO MARGIN COLLAPSING
34
  1 index get-line               % => Parent Child Line
35
  length                         % => Parent Child LL
36
 
37
 
38
    dup get-margin-top
39
    context-push-collapsed-margin-top
40
 
41
    dup get-margin-top
42
    neg
43
  } {
44
    1 index get-last             % => Parent Child Last
45
% Check if current element if the first child
46
    dup () eq { true }
47
      { 1 index is-container not } ifelse
48
    {
49
      pop                          % => Parent Child
50
% If parent is a table-cell, suppress top-margin
51
      1 index get-display
52
      /table-cell eq {
53
 
54
 
55
        1 index get-margin-top
56
        context-push-collapsed-margin-top
57
      } {
58
% Collapse with parent margins
59
        dup get-margin-top         % => Parent Child ChildMT
60
        context-get-collapsed-margin-top
61
        min                        % => Parent Child min(ChildMT, ParentCMT)
62
        1 index get-margin-top
63
        sub
64
 
65
        1 index get-margin-top
66
        context-get-collapsed-margin-top
67
        max
68
        context-push-collapsed-margin-top
69
      } ifelse
70
    } {                          % => Parent Child Last
71
% Collapse with sibling margins
72
      dup get-margin-bottom
73
      2 index get-margin-top
74
      max
75
      context-push-collapsed-margin-top
76
 
77
      get-margin-bottom          % => Parent Child M
78
      1 index get-margin-top
79
      exch sub 0 max neg
80
    } ifelse
81
  } ifelse
82
  2 index get-current-y          % => Parent Child M CY
83
  add                            % => Parent Child M+CY
84
 
85
% While drawing, we need position of margin edge, not border edge.
86
  1 index get-margin-top
87
  add                              % => Parent Child DY
88
 
89
% Check if we need to offset box vertically due the 'clear' property
90
  apply-clear
91
 
92
% Set the calculated value as the outer edge of this box
93
  2 index put-current-y          % => Parent Child
94
 
95
  1 index close-line             % =>
96
  dup 2 index append-line
97
 
98
% Set position of upper-left child corner
99
  1 index get-current-x
100
  2 index get-current-y       % => Parent Child X Y
101
 
102
  2 index
103
  move-to-box                 % => Parent Child
104
 
105
% By default, child block box will fill all available parent width;
106
% note that actual width will be smaller because of non-zero padding, border and margins
107
  1 index get-width         % => Parent Child PW
108
  1 index put-full-width    % => Parent Child
109
 
110
% reflow contents
111
  reflow                    % => Parent Child
112
 
113
% Update the collapsed margin value, with current box bottom margin
114
  context-pop-collapsed-margin-top
115
 
116
  dup get-margin-bottom
117
  context-push-collapsed-margin-top
118
 
119
% Calculate margins and/or width is 'auto' values have been specified
120
  dup get-box-dict
121
  /Parent known {
122
    dup calc-auto-width-margins
123
  } if                             % => Parent Child
124
 
125
% if left margin had 'auto' value, we need to offeset the box content by it value,
126
% as it changed; if margin had fixed value, we weill not offset content
127
  dup get-box-dict
128
  /Margin get
129
  /Auto get
130
  /Left get {
131
    dup get-margin-left 0            % => Parent Child LM 0
132
    2 index get-table-content        % => Parent Child LM 0 Content
133
    {
134
        2 index 2 index
135
        offset-box
136
    } forall
137
    pop pop                          % => Parent Child
138
  } if
139
 
140
%  dup
141
%  dup get-margin-left
142
%  0 offset-box                     % => Parent Child
143
 
144
% we're now interested in last content y, not the bottom border of the containing
145
% block, because, due the min-height, bottom border can contain lesser (lower on the page)
146
% value than current y
147
%  1 index get-bottom-internal
148
  1 index get-current-y
149
  1 index get-bottom
150
  sub
151
 
152
  2 index exch                  % => Parent Child Parent CH
153
  extend-height pop             % => Parent Child
154
 
155
  1 index get-right-internal
156
  2 index put-current-x
157
 
158
% terminate current line box
159
  1 index close-line
160
 
161
% clear the stack
162
  pop pop
163
} def