File size: 4,489 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
% $Header: /cvsroot/html2ps/postscript/box.table.cell.ps,v 1.1 2005/12/18 07:21:37 Konstantin Exp $

/box-table-cell-apply-vertical-align { % => Baseline Height Cell
  dup /vertical-align
  get-css-value                    % => Baseline Height Cell Valign
  {                                % => Baseline Height Cell Valign
    dup /baseline    eq {
      pop                          % => Baseline Height Cell 

      2 index
      1 index box-table-cell-get-baseline
      sub                          % => Baseline Height Cell Delta

      1 index get-top              % => Baseline Height Cell Delta OldTop
      1 index neg
      0
      4 index /offset call-method  % => Baseline Height Cell Delta OldTop
      2 index put-top              % => Baseline Height Cell Delta

      pop
      
      exit
    } if
    dup /bottom      eq {
      pop                          % => Baseline Height Cell 

      1 index
      1 index box-container-get-real-full-height
      sub                          % => Baseline Height Cell Delta

      1 index get-top              % => Baseline Height Cell Delta OldTop
      
      1 index neg 0
      4 index
      /offset call-method          % => Baseline Height Cell Delta OldTop

      2 index put-top              % => Baseline Height Cell Delta
      pop
      exit
    } if
    dup /middle      eq {
      pop                          % => Baseline Height Cell 

      1 index
      1 index box-container-get-real-full-height
      sub 2 div
      0 max                        % => Baseline Height Cell Delta

      1 index get-top              % => Baseline Height Cell Delta OldTop
      
      1 index neg 0
      4 index
      /offset call-method          % => Baseline Height Cell Delta OldTop

      2 index put-top              % => Baseline Height Cell Delta
      pop
      exit
    } if
    dup /super       eq { pop exit } if
    dup /sub         eq { pop exit } if
    dup /text-top    eq { pop exit } if
    dup /text-bottom eq {
      pop                          % => Baseline Height Cell 

      2 index
      1 index box-table-cell-get-baseline
      sub                          % => Baseline Height Cell Delta

      1 index get-top              % => Baseline Height Cell Delta OldTop
      1 index neg
      0
      4 index /offset call-method  % => Baseline Height Cell Delta OldTop
      2 index put-top              % => Baseline Height Cell Delta

      pop
      
      exit
    } if
    dup /top         eq { pop exit } if
    pop exit 
  } loop

  pop pop pop
} def

/box-table-cell-create {
  box-container-create
  dup box-table-cell-setup-methods
  dup /box-table-cell add-type

  dup /Colspan 1 put
  dup /Rowspan 1 put
  dup /column  0 put
  dup /row     0 put
} def

/box-table-cell-get-baseline {     % => Cell
  dup box-container-get-first-data % => Cell First
  dup /null eq {
    pop pop 0
  } {
    get-baseline exch pop
  } ifelse
} def

/box-table-cell-get-colspan {
  /Colspan get
} def

/box-table-cell-get-rowspan {
  /Rowspan get
} def

/box-table-cell-put-colspan {
  exch /Colspan exch put
} def

/box-table-cell-put-rowspan {
  exch /Rowspan exch put
} def

/box-table-cell-reflow {           % => Context Parent Cell
% Determine upper-left _content_ corner position of current box
  1 index get-current-x
  1 index get-extra-left add
  1 index put-left                 % => Content Parent Cell

% NOTE: Table cell margin is used as a cell-spacing value
  1 index get-current-y
  1 index get-border-top-width sub
  1 index get-padding-top sub
  1 index put-top                  % => Content Parent Cell

% CSS 2.1: 
% Floats, absolutely positioned elements, inline-blocks, table-cells, and elements with 'overflow' other than
% 'visible' establish new block formatting contexts.
  2 index context-push
  dup get-uid
  3 index context-push-container-uid

% Reflow cell content
  2 index 1 index
  box-container-reflow-content     % => Content Parent Cell

% Extend the table cell height to fit all contained floats
% Determine the bottom edge corrdinate of the bottommost float
  2 index context-float-bottom     % => Content Parent Cell FloatBottom
  dup /null ne {
    1 index box-generic-extend-height
  } {
    pop
  } ifelse                         % => Content Parent Cell 

% Restore old context
  2 index context-pop-container-uid
  2 index context-pop

  pop pop pop 
} def

/box-table-cell-setup-methods {
  dup /Methods get
  dup /reflow {box-table-cell-reflow} put
  pop pop
} def