summaryrefslogtreecommitdiff
path: root/layout/doc/debugtable.html
blob: 9c2ce0f8ed889fc8d80098882bd8e2aa1acc62ba (plain)
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
238
239
240
241
242
243
244
245
<!-- This Source Code Form is subject to the terms of the Mozilla Public
   - License, v. 2.0. If a copy of the MPL was not distributed with this
   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

 <style type="text/css">
  body {font-family:arial}
.log {background-color:silver; color:blue}
pre.log {display:table-cell}
  </style>

  <title>Debugging facilities in HTML-Table code</title>
</head>
<body>
 <h1>Debugging facilities in HTML-table code</h1>
 <h2>Reflow</h2>
 <p>The most efficient tool to claim that html-table code is the victim and not the source of layout bugs is a  <a href="http://lxr.mozilla.org/seamonkey/source/layout/doc/frame_reflow_debug.html">frame reflow  debug log</a>.  Look there especially how the maxElementsize (MES)  and desired size are propagated.

 <h2>Block Reflow</h2>
<p>
Another way to debug the reflow process is implemented inside <a href="http://lxr.mozilla.org/seamonkey/source/layout/html/base/src/nsBlockFrame.cpp">nsBlockFrame.cpp</a>. It can be invoked by<p>
<code>set GECKO_BLOCK_DEBUG_FLAGS=reflow</code>
<p>
The available options are:
<ul>
<li><code>reflow</code>
<li> <code>really-noisy-reflow</code>
<li><code>max-element-size</code>
<li><code> space-manager</code>
<li><code>verify-lines</code>
<li><code>damage-repair</code>
<li><code>lame-paint-metrics</code>
<li><code>lame-reflow-metrics</code>
<li><code>disable-resize-opt</code>
</ul>
<p>
These options can be combined with a comma separated list 
Messages generated by the <code>reflow</code> switch:
<ul>
<li><code> Block(div)(1)@00BE5AC4: reflowing dirty lines computedWidth=9000 computedHeight=1500</code>
<ul>
<li> this message is generated inside of <br>
<code>nsresult nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState)</code>
<li> it first shows the Block ID and Address
<li>and then the computed width and Height from the HTMLReflowState.
</ul>
</ul>

<h2>DEBUG_TABLE_STRATEGY</h2>
<p>
The table layout strategy can be visualized by defining in the <a href="http://lxr.mozilla.org/seamonkey/source/layout/html/table/src/Makefile.in">makefiles</a> the constant DEBUG_TABLE_STRATEGY.

If one takes for instance the following table
<table cellspacing="10"><tr><th>rendering</th><th>code</th></tr>
<tr valign="top"><td valign="top" style="padding-top:10px">
<table border width="300">
<colgroup>
<col>
<col width="50%">
<col width="1*">
<col>
</colgroup>
	<tr>
	      <td style="width:80px">cell 1</td>
            <td>cell 2</td>
            <td>cell 3</td>
            <td>cell 4</td>
	</tr>
</table>
</td>
<td valign="top"><pre class="log">
&lt;table border width="300"&gt;
&lt;colgroup&gt;
&lt;col&gt;
&lt;col width="50%"&gt;
&lt;col width="1*"&gt;
&lt;col&gt;
&lt;/colgroup&gt;
	&lt;tr&gt;
	      &lt;td style="width:80px"&gt;cell 1&lt;/td&gt;
            &lt;td&gt;cell 2&lt;/td&gt;
            &lt;td&gt;cell 3&lt;/td&gt;
            &lt;td&gt;cell 4&lt;/td&gt;
	&lt;/tr&gt;
&lt;/table&gt;
</pre>
</td>
</tr>
</table>
<p>
it will produce the following log at the entrance of <code>AssignNonPctColWidths</code>:
<p>
<table class="log"><tr><td>
<pre>
AssignNonPctColWidths en max=4500 count=0 
***START TABLE DUMP*** 
mColWidths=-1 -1 -1 -1 

 col frame cache -&gt;
0=00B93138 1=00B931F0 2=024DD728 3=024DD780 
 **START COL DUMP** colIndex=0 isAnonymous=0 constraint=0
  widths=-1 -1 -1 -1 -1 -1 -1 -1 -1 -1  **END COL DUMP** 
 **START COL DUMP** colIndex=1 isAnonymous=0 constraint=0
  widths=-1 -1 -1 -1 -1 -1 -1 -1 -1 -1  **END COL DUMP** 
 **START COL DUMP** colIndex=2 isAnonymous=0 constraint=0
  widths=-1 -1 -1 -1 -1 -1 -1 -1 -1 -1  **END COL DUMP** 
 **START COL DUMP** colIndex=3 isAnonymous=0 constraint=0
  widths=-1 -1 -1 -1 -1 -1 -1 -1 -1 -1  **END COL DUMP**
***END TABLE DUMP***
</pre>
</td></tr></table>


<p>
The <span class="log">en</span> stands for entrance (<span class="log">ex</span> for leaving a routine). The first line of the data dump shows that no width has yet been assigned to the columns <span class="log">mColWidths=-1 -1 -1 -1</span>,  <code>-1</code> stands for: 
<pre>
#define WIDTH_NOT_SET   -1
</pre>
<p>
This is followed by a reference to the column frame pointers:
<p>
<pre class="log">
col frame cache -&gt;
0=00B93138 1=00B931F0 2=024DD728 3=024DD780 
</pre>
<p>
This is followed by the information which width has been set for each column. The index of the column, whether it is anonymous and what kind of constrained has been applied<span class="log">colIndex=0 isAnonymous=0 constraint=0</span>. The following constraint types are known:
<p>
<pre>
  eNoConstraint          = 0,
  ePixelConstraint       = 1,      // pixel width 
  ePercentConstraint     = 2,      // percent width
  eProportionConstraint  = 3,      // 1*, 2*, etc. cols attribute assigns 1*
  e0ProportionConstraint = 4       // 0*, means to force to min width
</pre>
<p>
After this follows the width information for each column:
<p>
<pre class="log">
widths=-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 
</pre>
<p>
The table code knows ten different width's: 
<pre>
#define NUM_WIDTHS       10
#define NUM_MAJOR_WIDTHS 3 // MIN, DES, FIX
#define MIN_CON          0 // minimum width required of the content + padding
#define DES_CON          1 // desired width of the content + padding
#define FIX              2 // fixed width either from the content or cell, col, etc. + padding
#define MIN_ADJ          3 // minimum width + padding due to col spans
#define DES_ADJ          4 // desired width + padding due to col spans
#define FIX_ADJ          5 // fixed width + padding due to col spans
#define PCT              6 // percent width of cell or col 
#define PCT_ADJ          7 // percent width of cell or col from percent colspan
#define MIN_PRO          8 // desired width due to proportional &lt;col&gt;s or cols attribute
#define FINAL            9 // width after the table has been balanced, considering all of the others
</pre>
<p>
In the last log snippet none of these width's has been set.
Leaving  AssignNonPctColWidths shows that already to all columns a width of 360 twips has been assigned
<pre class="log">
AssignNonPctColWidths ex
***START TABLE DUMP*** 
mColWidths=360 360 360 360 

 col frame cache -&gt;
0=00B93138 1=00B931F0 2=024DD728 3=024DD780 
 **START COL DUMP** colIndex=0 isAnonymous=0 constraint=0
  widths=360 540 1230 -1 -1 -1 -1 -1 -1 360  **END COL DUMP** 
 **START COL DUMP** colIndex=1 isAnonymous=0 constraint=0
  widths=360 540 -1 -1 -1 -1 -1 -1 -1 360  **END COL DUMP** 
 **START COL DUMP** colIndex=2 isAnonymous=0 constraint=3
  widths=360 540 -1 -1 -1 -1 -1 -1 540 360  **END COL DUMP** 
 **START COL DUMP** colIndex=3 isAnonymous=0 constraint=0
  widths=360 540 -1 -1 -1 -1 -1 -1 -1 360  **END COL DUMP**
***END TABLE DUMP***
</pre>
<p>
The first column has already the minimum content width, the table column can't shrink below that, the desired content width of <span class="log">540</span> twips, that's the space to layout <code>cell 1</code> without wrapping the text and the <span class="log">1230</span> which correspond to the <code>style="width:80px"</code> at the first cell. At this step the final size is <span class="log">360</span> twips.
<p>
<table cellpadding="8">
<tr>
<th> MIN_CON</th><th>DES_CON</th><th>FIX</th><th>MIN_ADJ</th><th>DES_ADJ</th><th>FIX_ADJ</th><th>PCT</th><th> PCT_ADJ</th><th> MIN_PRO</th><th>FINAL</th>
</tr>
<tr align="center">
<td>360</td><td> 540</td><td> 1230 </td><td>-1</td><td> -1 </td><td>-1</td><td> -1</td><td> -1</td><td> -1</td><td> 360</td></tr></table>
<p>
There was no change till the entrance of <code>BalanceColumnWidths
</code>
<p>
<pre class="log">
BalanceColumnWidths en count=1
***START TABLE DUMP*** 
mColWidths=360 360 360 360 

 col frame cache -&gt;
0=00B93138 1=00B931F0 2=024DD728 3=024DD780 
 **START COL DUMP** colIndex=0 isAnonymous=0 constraint=0
  widths=360 540 1230 -1 -1 -1 -1 -1 -1 360  **END COL DUMP** 
 **START COL DUMP** colIndex=1 isAnonymous=0 constraint=0
  widths=360 540 -1 -1 -1 -1 -1 -1 -1 360  **END COL DUMP** 
 **START COL DUMP** colIndex=2 isAnonymous=0 constraint=3
  widths=360 540 -1 -1 -1 -1 -1 -1 540 360  **END COL DUMP** 
 **START COL DUMP** colIndex=3 isAnonymous=0 constraint=0
  widths=360 540 -1 -1 -1 -1 -1 -1 -1 360  **END COL DUMP**
***END TABLE DUMP***
</pre>
<p>
But at the end the final distribution between the columns has been reached.
<p>
<pre class="log">
BalanceColumnWidths ex
***START TABLE DUMP*** 
mColWidths=1230 2160 465 465 

 col frame cache -&gt;
0=00B93138 1=00B931F0 2=024DD728 3=024DD780 
 **START COL DUMP** colIndex=0 isAnonymous=0 constraint=0
  widths=360 540 1230 -1 -1 -1 -1 -1 -1 1230  **END COL DUMP** 
 **START COL DUMP** colIndex=1 isAnonymous=0 constraint=0
  widths=360 540 -1 -1 -1 -1 2160 -1 -1 2160  **END COL DUMP** 
 **START COL DUMP** colIndex=2 isAnonymous=0 constraint=3
  widths=360 540 -1 -1 -1 -1 -1 -1 540 465  **END COL DUMP** 
 **START COL DUMP** colIndex=3 isAnonymous=0 constraint=0
  widths=360 540 -1 -1 -1 -1 -1 -1 -1 465  **END COL DUMP**
***END TABLE DUMP***
</pre>
<p>
The column dump is implemented in <code>nsTableColFrame.cpp</code> in the routine:
<code>void nsTableColFrame::Dump(int32_t aIndent)</code>.

<h2>DEBUG_TABLE_REFLOW_TIMING</h2>
<p>needs to be written

<hr>
<p style="text-align:right">author: Bernd Mielke <br>2002-06-05</p>

</body>
	
</html>