<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[165837] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/165837">165837</a></dd>
<dt>Author</dt> <dd>dbates@webkit.org</dd>
<dt>Date</dt> <dd>2014-03-18 13:00:47 -0700 (Tue, 18 Mar 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>REGRESSION (<a href="http://trac.webkit.org/projects/webkit/changeset/162334">r162334</a>): RenderTableCol::styleDidChange uses out-of-date table information
https://bugs.webkit.org/show_bug.cgi?id=129561

Reviewed by Antti Koivisto.

Source/WebCore:

Test: fast/table/update-col-width-and-remove-table-cell-crash.html

Fixes an issue where a table column or table column group may query an out-
of-date model of its associated table as part of its process to propagate
style changes to affected table cells.

* rendering/RenderTableCol.cpp:
(WebCore::RenderTableCol::styleDidChange): Ensure that all sections in the table
are up-to-date before querying for a table cell.
* rendering/RenderTableSection.cpp:
(WebCore::RenderTableSection::recalcCells): Update comment to read well. In
particular, remove the reference to RenderTableSection::fillRowsWithDefaultStartingAtPosition()
as this function was removed in &lt;http://trac.webkit.org/changeset/99919&gt;.
(WebCore::RenderTableSection::setNeedsCellRecalc): Clear the grid preemptively to
to ensure that accessors cannot access stale data. We'll build the grid again
in RenderTableSection::recalcCells().
(WebCore::RenderTableSection::numColumns): Add ASSERT(!m_needsCellRecalc) to assert
that the grid cells are up-to-date. That is, we don't need to calculate them again.
* rendering/RenderTableSection.h: Add ASSERT(!m_needsCellRecalc) or call recalcCellsIfNeeded()
before accessing the grid to ensure that it's up-to-date.

LayoutTests:

Add a test to ensure that a table column propagates a style change to applicable
table cells.

* fast/table/update-col-width-and-remove-table-cell-crash-expected.txt: Added.
* fast/table/update-col-width-and-remove-table-cell-crash.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderTableColcpp">trunk/Source/WebCore/rendering/RenderTableCol.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderTableSectioncpp">trunk/Source/WebCore/rendering/RenderTableSection.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderTableSectionh">trunk/Source/WebCore/rendering/RenderTableSection.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfasttableupdatecolwidthandremovetablecellcrashexpectedtxt">trunk/LayoutTests/fast/table/update-col-width-and-remove-table-cell-crash-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasttableupdatecolwidthandremovetablecellcrashhtml">trunk/LayoutTests/fast/table/update-col-width-and-remove-table-cell-crash.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (165836 => 165837)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2014-03-18 19:59:05 UTC (rev 165836)
+++ trunk/LayoutTests/ChangeLog        2014-03-18 20:00:47 UTC (rev 165837)
</span><span class="lines">@@ -1,5 +1,18 @@
</span><span class="cx"> 2014-03-18  Daniel Bates  &lt;dabates@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        REGRESSION (r162334): RenderTableCol::styleDidChange uses out-of-date table information
+        https://bugs.webkit.org/show_bug.cgi?id=129561
+
+        Reviewed by Antti Koivisto.
+
+        Add a test to ensure that a table column propagates a style change to applicable
+        table cells.
+
+        * fast/table/update-col-width-and-remove-table-cell-crash-expected.txt: Added.
+        * fast/table/update-col-width-and-remove-table-cell-crash.html: Added.
+
+2014-03-18  Daniel Bates  &lt;dabates@apple.com&gt;
+
</ins><span class="cx">         REGRESSION (r163560): ASSERTION FAILED: childrenInline() in WebCore::RenderSVGText::layout
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=130346
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsfasttableupdatecolwidthandremovetablecellcrashexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/table/update-col-width-and-remove-table-cell-crash-expected.txt (0 => 165837)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/table/update-col-width-and-remove-table-cell-crash-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/table/update-col-width-and-remove-table-cell-crash-expected.txt        2014-03-18 20:00:47 UTC (rev 165837)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+This test PASSED if it doesn't cause a crash, especially when run with Guard Malloc or MallocScribble enabled.
</ins></span></pre></div>
<a id="trunkLayoutTestsfasttableupdatecolwidthandremovetablecellcrashhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/table/update-col-width-and-remove-table-cell-crash.html (0 => 165837)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/table/update-col-width-and-remove-table-cell-crash.html                                (rev 0)
+++ trunk/LayoutTests/fast/table/update-col-width-and-remove-table-cell-crash.html        2014-03-18 20:00:47 UTC (rev 165837)
</span><span class="lines">@@ -0,0 +1,38 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+&lt;script&gt;
+if (window.testRunner)
+    testRunner.dumpAsText();
+
+function runTest() {
+    document.getElementById(&quot;column1&quot;).width = &quot;90&quot;;
+    var firstRow = document.getElementById(&quot;firstRow&quot;);
+    firstRow.removeChild(firstRow.firstElementChild);
+    document.getElementById(&quot;row&quot;).offsetWidth;
+}
+&lt;/script&gt;
+&lt;style&gt;
+.column2 {
+    width: 10px;
+}
+&lt;/style&gt;
+&lt;/head&gt;
+&lt;body onload=&quot;runTest()&quot;&gt;
+&lt;table&gt;
+    &lt;colgroup&gt;
+        &lt;col id=&quot;column1&quot; class=&quot;column1&quot;&gt;
+        &lt;col class=&quot;column2&quot;&gt;
+    &lt;/colgroup&gt;
+    &lt;tbody&gt;
+        &lt;tr id=&quot;firstRow&quot;&gt;
+            &lt;td colspan=&quot;4&quot;&gt;&lt;/td&gt;
+        &lt;/tr&gt;
+        &lt;tr id=&quot;row&quot;&gt;
+            &lt;td colspan=&quot;4&quot;&gt;&lt;/td&gt;
+        &lt;/tr&gt;
+    &lt;/tbody&gt;
+&lt;/table&gt;
+&lt;p&gt;This test PASSED if it doesn't cause a crash, especially when run with Guard Malloc or MallocScribble enabled.&lt;/p&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (165836 => 165837)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-03-18 19:59:05 UTC (rev 165836)
+++ trunk/Source/WebCore/ChangeLog        2014-03-18 20:00:47 UTC (rev 165837)
</span><span class="lines">@@ -1,5 +1,33 @@
</span><span class="cx"> 2014-03-18  Daniel Bates  &lt;dabates@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        REGRESSION (r162334): RenderTableCol::styleDidChange uses out-of-date table information
+        https://bugs.webkit.org/show_bug.cgi?id=129561
+
+        Reviewed by Antti Koivisto.
+
+        Test: fast/table/update-col-width-and-remove-table-cell-crash.html
+
+        Fixes an issue where a table column or table column group may query an out-
+        of-date model of its associated table as part of its process to propagate
+        style changes to affected table cells.
+
+        * rendering/RenderTableCol.cpp:
+        (WebCore::RenderTableCol::styleDidChange): Ensure that all sections in the table
+        are up-to-date before querying for a table cell.
+        * rendering/RenderTableSection.cpp:
+        (WebCore::RenderTableSection::recalcCells): Update comment to read well. In
+        particular, remove the reference to RenderTableSection::fillRowsWithDefaultStartingAtPosition()
+        as this function was removed in &lt;http://trac.webkit.org/changeset/99919&gt;.
+        (WebCore::RenderTableSection::setNeedsCellRecalc): Clear the grid preemptively to
+        to ensure that accessors cannot access stale data. We'll build the grid again
+        in RenderTableSection::recalcCells().
+        (WebCore::RenderTableSection::numColumns): Add ASSERT(!m_needsCellRecalc) to assert
+        that the grid cells are up-to-date. That is, we don't need to calculate them again.
+        * rendering/RenderTableSection.h: Add ASSERT(!m_needsCellRecalc) or call recalcCellsIfNeeded()
+        before accessing the grid to ensure that it's up-to-date.
+
+2014-03-18  Daniel Bates  &lt;dabates@apple.com&gt;
+
</ins><span class="cx">         REGRESSION (r163560): ASSERTION FAILED: childrenInline() in WebCore::RenderSVGText::layout
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=130346
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderTableColcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderTableCol.cpp (165836 => 165837)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderTableCol.cpp        2014-03-18 19:59:05 UTC (rev 165836)
+++ trunk/Source/WebCore/rendering/RenderTableCol.cpp        2014-03-18 20:00:47 UTC (rev 165837)
</span><span class="lines">@@ -55,6 +55,7 @@
</span><span class="cx">         if (table &amp;&amp; !table-&gt;selfNeedsLayout() &amp;&amp; !table-&gt;normalChildNeedsLayout() &amp;&amp; oldStyle &amp;&amp; oldStyle-&gt;border() != style().border())
</span><span class="cx">             table-&gt;invalidateCollapsedBorders();
</span><span class="cx">         else if (oldStyle-&gt;width() != style().width()) {
</span><ins>+            table-&gt;recalcSectionsIfNeeded();
</ins><span class="cx">             for (auto&amp; section : childrenOfType&lt;RenderTableSection&gt;(*table)) {
</span><span class="cx">                 unsigned nEffCols = table-&gt;numEffCols();
</span><span class="cx">                 for (unsigned j = 0; j &lt; nEffCols; j++) {
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderTableSectioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderTableSection.cpp (165836 => 165837)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderTableSection.cpp        2014-03-18 19:59:05 UTC (rev 165836)
+++ trunk/Source/WebCore/rendering/RenderTableSection.cpp        2014-03-18 20:00:47 UTC (rev 165837)
</span><span class="lines">@@ -1361,9 +1361,9 @@
</span><span class="cx"> void RenderTableSection::recalcCells()
</span><span class="cx"> {
</span><span class="cx">     ASSERT(m_needsCellRecalc);
</span><del>-    // We reset the flag here to ensure that |addCell| works. This is safe to do as
-    // fillRowsWithDefaultStartingAtPosition makes sure we match the table's columns
-    // representation.
</del><ins>+    // We reset the flag here to ensure that addCell() works. This is safe to do because we clear the grid
+    // and update its dimensions to be consistent with the table's column representation before we rebuild
+    // the grid using addCell().
</ins><span class="cx">     m_needsCellRecalc = false;
</span><span class="cx"> 
</span><span class="cx">     m_cCol = 0;
</span><span class="lines">@@ -1403,12 +1403,17 @@
</span><span class="cx"> void RenderTableSection::setNeedsCellRecalc()
</span><span class="cx"> {
</span><span class="cx">     m_needsCellRecalc = true;
</span><ins>+
+    // Clear the grid now to ensure that we don't hold onto any stale pointers (e.g. a cell renderer that is being removed).
+    m_grid.clear();
+
</ins><span class="cx">     if (RenderTable* t = table())
</span><span class="cx">         t-&gt;setNeedsSectionRecalc();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> unsigned RenderTableSection::numColumns() const
</span><span class="cx"> {
</span><ins>+    ASSERT(!m_needsCellRecalc);
</ins><span class="cx">     unsigned result = 0;
</span><span class="cx">     
</span><span class="cx">     for (unsigned r = 0; r &lt; m_grid.size(); ++r) {
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderTableSectionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderTableSection.h (165836 => 165837)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderTableSection.h        2014-03-18 19:59:05 UTC (rev 165836)
+++ trunk/Source/WebCore/rendering/RenderTableSection.h        2014-03-18 20:00:47 UTC (rev 165837)
</span><span class="lines">@@ -142,15 +142,30 @@
</span><span class="cx">     const RenderTableCell* firstRowCellAdjoiningTableStart() const;
</span><span class="cx">     const RenderTableCell* firstRowCellAdjoiningTableEnd() const;
</span><span class="cx"> 
</span><del>-    CellStruct&amp; cellAt(unsigned row,  unsigned col) { return m_grid[row].row[col]; }
-    const CellStruct&amp; cellAt(unsigned row, unsigned col) const { return m_grid[row].row[col]; }
</del><ins>+    CellStruct&amp; cellAt(unsigned row,  unsigned col)
+    {
+        recalcCellsIfNeeded();
+        return m_grid[row].row[col];
+    }
+
+    const CellStruct&amp; cellAt(unsigned row, unsigned col) const
+    {
+        ASSERT(!m_needsCellRecalc);
+        return m_grid[row].row[col];
+    }
+
</ins><span class="cx">     RenderTableCell* primaryCellAt(unsigned row, unsigned col)
</span><span class="cx">     {
</span><ins>+        recalcCellsIfNeeded();
</ins><span class="cx">         CellStruct&amp; c = m_grid[row].row[col];
</span><span class="cx">         return c.primaryCell();
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    RenderTableRow* rowRendererAt(unsigned row) const { return m_grid[row].rowRenderer; }
</del><ins>+    RenderTableRow* rowRendererAt(unsigned row) const
+    {
+        ASSERT(!m_needsCellRecalc);
+        return m_grid[row].rowRenderer;
+    }
</ins><span class="cx"> 
</span><span class="cx">     void appendColumn(unsigned pos);
</span><span class="cx">     void splitColumn(unsigned pos, unsigned first);
</span><span class="lines">@@ -194,7 +209,12 @@
</span><span class="cx">     return styleForCellFlow-&gt;isLeftToRightDirection() ? outerBorderEnd() : outerBorderStart();
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    unsigned numRows() const { return m_grid.size(); }
</del><ins>+    unsigned numRows() const
+    {
+        ASSERT(!m_needsCellRecalc);
+        return m_grid.size();
+    }
+
</ins><span class="cx">     unsigned numColumns() const;
</span><span class="cx">     void recalcCells();
</span><span class="cx">     void recalcCellsIfNeeded()
</span><span class="lines">@@ -206,7 +226,11 @@
</span><span class="cx">     bool needsCellRecalc() const { return m_needsCellRecalc; }
</span><span class="cx">     void setNeedsCellRecalc();
</span><span class="cx"> 
</span><del>-    LayoutUnit rowBaseline(unsigned row) { return m_grid[row].baseline; }
</del><ins>+    LayoutUnit rowBaseline(unsigned row)
+    {
+        recalcCellsIfNeeded();
+        return m_grid[row].baseline;
+    }
</ins><span class="cx"> 
</span><span class="cx">     void rowLogicalHeightChanged(unsigned rowIndex);
</span><span class="cx"> 
</span><span class="lines">@@ -263,7 +287,12 @@
</span><span class="cx">     bool hasOverflowingCell() const { return m_overflowingCells.size() || m_forceSlowPaintPathWithOverflowingCell; }
</span><span class="cx">     void computeOverflowFromCells(unsigned totalRows, unsigned nEffCols);
</span><span class="cx"> 
</span><del>-    CellSpan fullTableRowSpan() const { return CellSpan(0, m_grid.size()); }
</del><ins>+    CellSpan fullTableRowSpan() const
+    {
+        ASSERT(!m_needsCellRecalc);
+        return CellSpan(0, m_grid.size());
+    }
+
</ins><span class="cx">     CellSpan fullTableColumnSpan() const { return CellSpan(0, table()-&gt;columns().size()); }
</span><span class="cx"> 
</span><span class="cx">     // Flip the rect so it aligns with the coordinates used by the rowPos and columnPos vectors.
</span></span></pre>
</div>
</div>

</body>
</html>