layout/doc/debugtable.html

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

     1 <!-- This Source Code Form is subject to the terms of the Mozilla Public
     2    - License, v. 2.0. If a copy of the MPL was not distributed with this
     3    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
     5 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
     7 <html>
     8 <head>
     9 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    11  <style type="text/css">
    12   body {font-family:arial}
    13 .log {background-color:silver; color:blue}
    14 pre.log {display:table-cell}
    15   </style>
    17   <title>Debugging facilities in HTML-Table code</title>
    18 </head>
    19 <body>
    20  <h1>Debugging facilities in HTML-table code</h1>
    21  <h2>Reflow</h2>
    22  <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.
    24  <h2>Block Reflow</h2>
    25 <p>
    26 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>
    27 <code>set GECKO_BLOCK_DEBUG_FLAGS=reflow</code>
    28 <p>
    29 The available options are:
    30 <ul>
    31 <li><code>reflow</code>
    32 <li> <code>really-noisy-reflow</code>
    33 <li><code>max-element-size</code>
    34 <li><code> space-manager</code>
    35 <li><code>verify-lines</code>
    36 <li><code>damage-repair</code>
    37 <li><code>lame-paint-metrics</code>
    38 <li><code>lame-reflow-metrics</code>
    39 <li><code>disable-resize-opt</code>
    40 </ul>
    41 <p>
    42 These options can be combined with a comma separated list 
    43 Messages generated by the <code>reflow</code> switch:
    44 <ul>
    45 <li><code> Block(div)(1)@00BE5AC4: reflowing dirty lines computedWidth=9000 computedHeight=1500</code>
    46 <ul>
    47 <li> this message is generated inside of <br>
    48 <code>nsresult nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState)</code>
    49 <li> it first shows the Block ID and Address
    50 <li>and then the computed width and Height from the HTMLReflowState.
    51 </ul>
    52 </ul>
    54 <h2>DEBUG_TABLE_STRATEGY</h2>
    55 <p>
    56 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.
    58 If one takes for instance the following table
    59 <table cellspacing="10"><tr><th>rendering</th><th>code</th></tr>
    60 <tr valign="top"><td valign="top" style="padding-top:10px">
    61 <table border width="300">
    62 <colgroup>
    63 <col>
    64 <col width="50%">
    65 <col width="1*">
    66 <col>
    67 </colgroup>
    68 	<tr>
    69 	      <td style="width:80px">cell 1</td>
    70             <td>cell 2</td>
    71             <td>cell 3</td>
    72             <td>cell 4</td>
    73 	</tr>
    74 </table>
    75 </td>
    76 <td valign="top"><pre class="log">
    77 &lt;table border width="300"&gt;
    78 &lt;colgroup&gt;
    79 &lt;col&gt;
    80 &lt;col width="50%"&gt;
    81 &lt;col width="1*"&gt;
    82 &lt;col&gt;
    83 &lt;/colgroup&gt;
    84 	&lt;tr&gt;
    85 	      &lt;td style="width:80px"&gt;cell 1&lt;/td&gt;
    86             &lt;td&gt;cell 2&lt;/td&gt;
    87             &lt;td&gt;cell 3&lt;/td&gt;
    88             &lt;td&gt;cell 4&lt;/td&gt;
    89 	&lt;/tr&gt;
    90 &lt;/table&gt;
    91 </pre>
    92 </td>
    93 </tr>
    94 </table>
    95 <p>
    96 it will produce the following log at the entrance of <code>AssignNonPctColWidths</code>:
    97 <p>
    98 <table class="log"><tr><td>
    99 <pre>
   100 AssignNonPctColWidths en max=4500 count=0 
   101 ***START TABLE DUMP*** 
   102 mColWidths=-1 -1 -1 -1 
   104  col frame cache -&gt;
   105 0=00B93138 1=00B931F0 2=024DD728 3=024DD780 
   106  **START COL DUMP** colIndex=0 isAnonymous=0 constraint=0
   107   widths=-1 -1 -1 -1 -1 -1 -1 -1 -1 -1  **END COL DUMP** 
   108  **START COL DUMP** colIndex=1 isAnonymous=0 constraint=0
   109   widths=-1 -1 -1 -1 -1 -1 -1 -1 -1 -1  **END COL DUMP** 
   110  **START COL DUMP** colIndex=2 isAnonymous=0 constraint=0
   111   widths=-1 -1 -1 -1 -1 -1 -1 -1 -1 -1  **END COL DUMP** 
   112  **START COL DUMP** colIndex=3 isAnonymous=0 constraint=0
   113   widths=-1 -1 -1 -1 -1 -1 -1 -1 -1 -1  **END COL DUMP**
   114 ***END TABLE DUMP***
   115 </pre>
   116 </td></tr></table>
   119 <p>
   120 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: 
   121 <pre>
   122 #define WIDTH_NOT_SET   -1
   123 </pre>
   124 <p>
   125 This is followed by a reference to the column frame pointers:
   126 <p>
   127 <pre class="log">
   128 col frame cache -&gt;
   129 0=00B93138 1=00B931F0 2=024DD728 3=024DD780 
   130 </pre>
   131 <p>
   132 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:
   133 <p>
   134 <pre>
   135   eNoConstraint          = 0,
   136   ePixelConstraint       = 1,      // pixel width 
   137   ePercentConstraint     = 2,      // percent width
   138   eProportionConstraint  = 3,      // 1*, 2*, etc. cols attribute assigns 1*
   139   e0ProportionConstraint = 4       // 0*, means to force to min width
   140 </pre>
   141 <p>
   142 After this follows the width information for each column:
   143 <p>
   144 <pre class="log">
   145 widths=-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 
   146 </pre>
   147 <p>
   148 The table code knows ten different width's: 
   149 <pre>
   150 #define NUM_WIDTHS       10
   151 #define NUM_MAJOR_WIDTHS 3 // MIN, DES, FIX
   152 #define MIN_CON          0 // minimum width required of the content + padding
   153 #define DES_CON          1 // desired width of the content + padding
   154 #define FIX              2 // fixed width either from the content or cell, col, etc. + padding
   155 #define MIN_ADJ          3 // minimum width + padding due to col spans
   156 #define DES_ADJ          4 // desired width + padding due to col spans
   157 #define FIX_ADJ          5 // fixed width + padding due to col spans
   158 #define PCT              6 // percent width of cell or col 
   159 #define PCT_ADJ          7 // percent width of cell or col from percent colspan
   160 #define MIN_PRO          8 // desired width due to proportional &lt;col&gt;s or cols attribute
   161 #define FINAL            9 // width after the table has been balanced, considering all of the others
   162 </pre>
   163 <p>
   164 In the last log snippet none of these width's has been set.
   165 Leaving  AssignNonPctColWidths shows that already to all columns a width of 360 twips has been assigned
   166 <pre class="log">
   167 AssignNonPctColWidths ex
   168 ***START TABLE DUMP*** 
   169 mColWidths=360 360 360 360 
   171  col frame cache -&gt;
   172 0=00B93138 1=00B931F0 2=024DD728 3=024DD780 
   173  **START COL DUMP** colIndex=0 isAnonymous=0 constraint=0
   174   widths=360 540 1230 -1 -1 -1 -1 -1 -1 360  **END COL DUMP** 
   175  **START COL DUMP** colIndex=1 isAnonymous=0 constraint=0
   176   widths=360 540 -1 -1 -1 -1 -1 -1 -1 360  **END COL DUMP** 
   177  **START COL DUMP** colIndex=2 isAnonymous=0 constraint=3
   178   widths=360 540 -1 -1 -1 -1 -1 -1 540 360  **END COL DUMP** 
   179  **START COL DUMP** colIndex=3 isAnonymous=0 constraint=0
   180   widths=360 540 -1 -1 -1 -1 -1 -1 -1 360  **END COL DUMP**
   181 ***END TABLE DUMP***
   182 </pre>
   183 <p>
   184 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.
   185 <p>
   186 <table cellpadding="8">
   187 <tr>
   188 <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>
   189 </tr>
   190 <tr align="center">
   191 <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>
   192 <p>
   193 There was no change till the entrance of <code>BalanceColumnWidths
   194 </code>
   195 <p>
   196 <pre class="log">
   197 BalanceColumnWidths en count=1
   198 ***START TABLE DUMP*** 
   199 mColWidths=360 360 360 360 
   201  col frame cache -&gt;
   202 0=00B93138 1=00B931F0 2=024DD728 3=024DD780 
   203  **START COL DUMP** colIndex=0 isAnonymous=0 constraint=0
   204   widths=360 540 1230 -1 -1 -1 -1 -1 -1 360  **END COL DUMP** 
   205  **START COL DUMP** colIndex=1 isAnonymous=0 constraint=0
   206   widths=360 540 -1 -1 -1 -1 -1 -1 -1 360  **END COL DUMP** 
   207  **START COL DUMP** colIndex=2 isAnonymous=0 constraint=3
   208   widths=360 540 -1 -1 -1 -1 -1 -1 540 360  **END COL DUMP** 
   209  **START COL DUMP** colIndex=3 isAnonymous=0 constraint=0
   210   widths=360 540 -1 -1 -1 -1 -1 -1 -1 360  **END COL DUMP**
   211 ***END TABLE DUMP***
   212 </pre>
   213 <p>
   214 But at the end the final distribution between the columns has been reached.
   215 <p>
   216 <pre class="log">
   217 BalanceColumnWidths ex
   218 ***START TABLE DUMP*** 
   219 mColWidths=1230 2160 465 465 
   221  col frame cache -&gt;
   222 0=00B93138 1=00B931F0 2=024DD728 3=024DD780 
   223  **START COL DUMP** colIndex=0 isAnonymous=0 constraint=0
   224   widths=360 540 1230 -1 -1 -1 -1 -1 -1 1230  **END COL DUMP** 
   225  **START COL DUMP** colIndex=1 isAnonymous=0 constraint=0
   226   widths=360 540 -1 -1 -1 -1 2160 -1 -1 2160  **END COL DUMP** 
   227  **START COL DUMP** colIndex=2 isAnonymous=0 constraint=3
   228   widths=360 540 -1 -1 -1 -1 -1 -1 540 465  **END COL DUMP** 
   229  **START COL DUMP** colIndex=3 isAnonymous=0 constraint=0
   230   widths=360 540 -1 -1 -1 -1 -1 -1 -1 465  **END COL DUMP**
   231 ***END TABLE DUMP***
   232 </pre>
   233 <p>
   234 The column dump is implemented in <code>nsTableColFrame.cpp</code> in the routine:
   235 <code>void nsTableColFrame::Dump(int32_t aIndent)</code>.
   237 <h2>DEBUG_TABLE_REFLOW_TIMING</h2>
   238 <p>needs to be written
   240 <hr>
   241 <p style="text-align:right">author: Bernd Mielke <br>2002-06-05</p>
   243 </body>
   245 </html>

mercurial