File size: 5,343 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
/box-table-row-create {            % =>
  box-container-create             % => Box
  dup box-table-row-setup-methods  % => Box
  dup /box-table-row add-type      % => Box
} def

/box-table-row-get-baseline {      % => Row
  { box-table-cell-get-baseline max }
  0
  2 index get-content
  reduce                           % => Row RowBaseline
  exch pop
} def

/box-table-row-get-colspans {      % => RowIndex Row
  [] 0                             % => RowIndex Row Spans I
  2 index get-content {            % => RowIndex Row Spans I Cell
    dup box-table-cell-get-colspan
    1 gt {
      4 index                      % => RowIndex Row Spans I Cell Row
      2 index                      % => RowIndex Row Spans I Cell Row Col
      2 index
      box-table-cell-get-colspan   % => RowIndex Row Spans I Cell Row Col Size
      cellspan-create              % => RowIndex Row Spans I Cell Span

      exch pop                     % => RowIndex Row Spans I Span
      3 2 roll
      array-prepend
      exch                         % => RowIndex Row Spans' I 
    } { pop } ifelse
 
    1 add
  } forall                         % => RowIndex Row Spans I
  pop                              % => RowIndex Row Spans

  exch pop
  exch pop
} def

/box-table-row-get-rowspans {      % => RowIndex Row
  [] 0                             % => RowIndex Row Spans I
  2 index get-content {            % => RowIndex Row Spans I Cell
    dup box-table-cell-get-rowspan
    1 gt {
      4 index                      % => RowIndex Row Spans I Cell Row
      2 index                      % => RowIndex Row Spans I Cell Row Col
      2 index
      box-table-cell-get-rowspan   % => RowIndex Row Spans I Cell Row Col Size
      cellspan-create              % => RowIndex Row Spans I Cell Span

      exch pop                     % => RowIndex Row Spans I Span
      3 2 roll
      array-prepend
      exch                         % => RowIndex Row Spans' I 
    } { pop } ifelse
 
    1 add
  } forall                         % => RowIndex Row Spans I
  pop                              % => RowIndex Row Spans

  exch pop
  exch pop
} def

/box-table-row-get-table-columns-max-widths {
  2 copy /get-max-width box-table-row-get-table-columns-xxx-widths
  exch pop
  exch pop
} def

/box-table-row-get-table-columns-min-widths {
  2 copy /get-min-width box-table-row-get-table-columns-xxx-widths
  exch pop
  exch pop
} def

/box-table-row-get-table-columns-xxx-widths { % => Context Row Method
  []                               % => Context Row Method Widths 
  2 index get-content {            % => Context Row Method Widths Cell
    dup box-table-cell-get-colspan 
    1 gt {                         % => Context Row Method Widths Cell
      pop 0                        % => Context Row Method Widths 0
    } {                            % => Context Row Method Widths Cell
      4 index exch                 % => Context Row Method Widths Context Cell
      3 index call-method          % => Context Row Method Widths W
    } ifelse

    exch array-prepend             % => Context Row Method Widths'
  } forall                         % => Context Row Method Widths'
    
  exch pop
  exch pop
  exch pop 
} def

/box-table-row-height {            % => Row
  0 
  1 index get-content {            % => Row Height Cell
    dup box-table-cell-get-rowspan
    1 le {
      get-full-height
      max                          % => Row Height
    } {
      pop
    } ifelse    
  } forall                         % => Row Height
  exch pop
} def

/box-table-row-resize {            % => Top Height Row
% Do cell vertical-align
% Calculate row baseline 
  dup box-table-row-get-baseline   % => Top Height Row Baseline

% Process cells contained in current row
  1 index get-content {            % => Top Height Row Baseline Cell
% Offset cell if needed
    4 index
    1 index get-top-margin sub
    0
    2 index /offset call-method    % => Top Height Row Baseline Cell
    
% Vertical-align cell (do not apply to rowspans)

    dup box-table-cell-get-rowspan 1 eq {
      1 index
      4 index
      2 index                      % => Top Height Row Baseline Cell Baseline Height Cell
      box-table-cell-apply-vertical-align
                                   % => Top Height Row Baseline Cell

% Expand cell to full row height
      3 index
      1 index
      put-full-height              % => Top Height Row Baseline Cell
      
    } if                           % => Top Height Row Baseline Cell

    pop                            % => Top Height Row Baseline 
  } forall                         % => Top Height Row Baseline

  pop pop pop pop
} def

/box-table-row-setup-methods {     % => Box
  dup /Methods get
  dup /show {box-table-row-show} put
  pop pop
} def

% Note that we SHOULD owerride the show method inherited from GenericContainerBox, 
% as it MAY draw row background in case it was set via CSS rules. As row box 
% is a "fake" box and will never have reasonable size and/or position in the layout,
% we should prevent this
/box-table-row-show {              % => Viewport Box 
  dup get-content {                % => Viewport Box Element
    dup /visibility get-css-value
    /visible eq {
      2 index 1 index
      /show call-method
    } if                           % => Viewport Box Element
    pop 
  } forall 
  pop pop
} def