Title: [140047] trunk/Source/WebCore
Revision
140047
Author
o...@chromium.org
Date
2013-01-17 14:41:14 -0800 (Thu, 17 Jan 2013)

Log Message

Table layout does not need to explicitly call computePreferredLogicalWidths
https://bugs.webkit.org/show_bug.cgi?id=106931

Reviewed by Julien Chaffraix.

Code shouldn't need to explicitly call computePreferredLogicalWidths.
It should only get called as a by-product of calling minPreferredLogicalWidth
or maxPreferredLogicalWidth.

Instead, make it clear that the calling code is just trying to clear
preferred width dirty bits.

* rendering/AutoTableLayout.cpp:
(WebCore::AutoTableLayout::recalcColumn):
The computePreferredLogicalWidths call on the table cell is redundant
with the minPreferredLogicalWidth call on the next line.

* rendering/FixedTableLayout.cpp:
(WebCore::FixedTableLayout::calcWidthArray):
We only need to clear the dirty bit here. Table cells don't use
their preferred widths in fixed table layout calculations.

* rendering/RenderTableCell.h:
* rendering/RenderTableCol.cpp:
(WebCore::RenderTableCol::clearPreferredLogicalWidthsDirtyBits):
* rendering/RenderTableCol.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (140046 => 140047)


--- trunk/Source/WebCore/ChangeLog	2013-01-17 22:38:23 UTC (rev 140046)
+++ trunk/Source/WebCore/ChangeLog	2013-01-17 22:41:14 UTC (rev 140047)
@@ -1,3 +1,32 @@
+2013-01-17  Ojan Vafai  <o...@chromium.org>
+
+        Table layout does not need to explicitly call computePreferredLogicalWidths
+        https://bugs.webkit.org/show_bug.cgi?id=106931
+
+        Reviewed by Julien Chaffraix.
+
+        Code shouldn't need to explicitly call computePreferredLogicalWidths.
+        It should only get called as a by-product of calling minPreferredLogicalWidth
+        or maxPreferredLogicalWidth.
+
+        Instead, make it clear that the calling code is just trying to clear
+        preferred width dirty bits.
+
+        * rendering/AutoTableLayout.cpp:
+        (WebCore::AutoTableLayout::recalcColumn):
+        The computePreferredLogicalWidths call on the table cell is redundant
+        with the minPreferredLogicalWidth call on the next line.
+
+        * rendering/FixedTableLayout.cpp:
+        (WebCore::FixedTableLayout::calcWidthArray):
+        We only need to clear the dirty bit here. Table cells don't use
+        their preferred widths in fixed table layout calculations.
+
+        * rendering/RenderTableCell.h:
+        * rendering/RenderTableCol.cpp:
+        (WebCore::RenderTableCol::clearPreferredLogicalWidthsDirtyBits):
+        * rendering/RenderTableCol.h:
+
 2013-01-17  Julien Chaffraix  <jchaffr...@webkit.org>
 
         [CSS Grid Layout] Updating -webkit-grid-rows or -webkit-grid-columns doesn't work as expected

Modified: trunk/Source/WebCore/rendering/AutoTableLayout.cpp (140046 => 140047)


--- trunk/Source/WebCore/rendering/AutoTableLayout.cpp	2013-01-17 22:38:23 UTC (rev 140046)
+++ trunk/Source/WebCore/rendering/AutoTableLayout.cpp	2013-01-17 22:41:14 UTC (rev 140047)
@@ -50,9 +50,12 @@
     RenderTableCell* maxContributor = 0;
 
     for (RenderObject* child = m_table->children()->firstChild(); child; child = child->nextSibling()) {
-        if (child->isRenderTableCol())
-            toRenderTableCol(child)->computePreferredLogicalWidths();
-        else if (child->isTableSection()) {
+        if (child->isRenderTableCol()){
+            // RenderTableCols don't have the concept of preferred logical width, but we need to clear their dirty bits
+            // so that if we call setPreferredWidthsDirty(true) on a col or one of its descendants, we'll mark it's
+            // ancestors as dirty.
+            toRenderTableCol(child)->clearPreferredLogicalWidthsDirtyBits();
+        } else if (child->isTableSection()) {
             RenderTableSection* section = toRenderTableSection(child);
             unsigned numRows = section->numRows();
             for (unsigned i = 0; i < numRows; i++) {
@@ -72,8 +75,6 @@
                 columnLayout.maxLogicalWidth = max<int>(columnLayout.maxLogicalWidth, 1);
 
                 if (cell->colSpan() == 1) {
-                    if (cell->preferredLogicalWidthsDirty())
-                        cell->computePreferredLogicalWidths();
                     columnLayout.minLogicalWidth = max<int>(cell->minPreferredLogicalWidth(), columnLayout.minLogicalWidth);
                     if (cell->maxPreferredLogicalWidth() > columnLayout.maxLogicalWidth) {
                         columnLayout.maxLogicalWidth = cell->maxPreferredLogicalWidth();

Modified: trunk/Source/WebCore/rendering/FixedTableLayout.cpp (140046 => 140047)


--- trunk/Source/WebCore/rendering/FixedTableLayout.cpp	2013-01-17 22:38:23 UTC (rev 140046)
+++ trunk/Source/WebCore/rendering/FixedTableLayout.cpp	2013-01-17 22:41:14 UTC (rev 140047)
@@ -88,7 +88,10 @@
 
     unsigned currentEffectiveColumn = 0;
     for (RenderTableCol* col = m_table->firstColumn(); col; col = col->nextColumn()) {
-        col->computePreferredLogicalWidths();
+        // RenderTableCols don't have the concept of preferred logical width, but we need to clear their dirty bits
+        // so that if we call setPreferredWidthsDirty(true) on a col or one of its descendants, we'll mark it's
+        // ancestors as dirty.
+        col->clearPreferredLogicalWidthsDirtyBits();
 
         // Width specified by column-groups that have column child does not affect column width in fixed layout tables
         if (col->isTableColumnGroupWithColumnChildren())
@@ -138,12 +141,12 @@
             continue;
 
         RenderTableCell* cell = toRenderTableCell(child);
-        if (cell->preferredLogicalWidthsDirty())
-            cell->computePreferredLogicalWidths();
 
         Length logicalWidth = cell->styleOrColLogicalWidth();
         unsigned span = cell->colSpan();
         int fixedBorderBoxLogicalWidth = 0;
+        // FIXME: Support other length types. If the width is non-auto, it should probably just use
+        // RenderBox::computeLogicalWidthInRegionUsing to compute the width.
         if (logicalWidth.isFixed() && logicalWidth.isPositive()) {
             fixedBorderBoxLogicalWidth = cell->adjustBorderBoxLogicalWidthForBoxSizing(logicalWidth.value());
             logicalWidth.setValue(fixedBorderBoxLogicalWidth);
@@ -161,6 +164,12 @@
             usedSpan += eSpan;
             ++currentColumn;
         }
+
+        // FixedTableLayout doesn't use min/maxPreferredLogicalWidths, but we need to clear the
+        // dirty bit on the cell so that we'll correctly mark its ancestors dirty
+        // in case we later call setPreferredLogicalWidthsDirty(true) on it later.
+        if (cell->preferredLogicalWidthsDirty())
+            cell->setPreferredLogicalWidthsDirty(false);
     }
 
     return usedWidth;

Modified: trunk/Source/WebCore/rendering/RenderTableCell.h (140046 => 140047)


--- trunk/Source/WebCore/rendering/RenderTableCell.h	2013-01-17 22:38:23 UTC (rev 140046)
+++ trunk/Source/WebCore/rendering/RenderTableCell.h	2013-01-17 22:41:14 UTC (rev 140047)
@@ -102,7 +102,6 @@
         return max(styleLogicalHeight, adjustedLogicalHeight);
     }
 
-    virtual void computePreferredLogicalWidths();
 
     void setCellLogicalWidth(int constrainedLogicalWidth);
 
@@ -207,6 +206,7 @@
 #endif
 protected:
     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
+    virtual void computePreferredLogicalWidths();
 
 private:
     virtual const char* renderName() const { return (isAnonymous() || isPseudoElement()) ? "RenderTableCell (anonymous)" : "RenderTableCell"; }

Modified: trunk/Source/WebCore/rendering/RenderTableCol.cpp (140046 => 140047)


--- trunk/Source/WebCore/rendering/RenderTableCol.cpp	2013-01-17 22:38:23 UTC (rev 140046)
+++ trunk/Source/WebCore/rendering/RenderTableCol.cpp	2013-01-17 22:41:14 UTC (rev 140047)
@@ -115,7 +115,7 @@
     repaint();
 }
 
-void RenderTableCol::computePreferredLogicalWidths()
+void RenderTableCol::clearPreferredLogicalWidthsDirtyBits()
 {
     setPreferredLogicalWidthsDirty(false);
 

Modified: trunk/Source/WebCore/rendering/RenderTableCol.h (140046 => 140047)


--- trunk/Source/WebCore/rendering/RenderTableCol.h	2013-01-17 22:38:23 UTC (rev 140046)
+++ trunk/Source/WebCore/rendering/RenderTableCol.h	2013-01-17 22:41:14 UTC (rev 140047)
@@ -43,7 +43,7 @@
     const RenderObjectChildList* children() const { return &m_children; }
     RenderObjectChildList* children() { return &m_children; }
 
-    virtual void computePreferredLogicalWidths();
+    void clearPreferredLogicalWidthsDirtyBits();
 
     unsigned span() const { return m_span; }
     void setSpan(unsigned span) { m_span = span; }
@@ -85,6 +85,7 @@
     virtual const char* renderName() const { return "RenderTableCol"; }
     virtual bool isRenderTableCol() const OVERRIDE { return true; }
     virtual void updateFromElement();
+    virtual void computePreferredLogicalWidths() OVERRIDE { ASSERT_NOT_REACHED(); }
 
     virtual void insertedIntoTree() OVERRIDE;
     virtual void willBeRemovedFromTree() OVERRIDE;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to