debugtable.html 9.2 KB

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