Title: [130698] trunk/Source/WebCore
Revision
130698
Author
[email protected]
Date
2012-10-08 15:59:36 -0700 (Mon, 08 Oct 2012)

Log Message

Make no-column table-layout cases a little faster with inlining
https://bugs.webkit.org/show_bug.cgi?id=98566

Reviewed by Julien Chaffraix.

This change is almost not worth it at only a couple percent boost on
http://www.robohornet.org/tests/resizecol.html
However, I think the logicalWidthFromTableColumn split it kinda nice
so I've decided to post it anyway.

* rendering/RenderTable.cpp:
(WebCore::RenderTable::slowColElement):
* rendering/RenderTable.h:
(WebCore::RenderTable::colElement):
(RenderTable):
* rendering/RenderTableCell.cpp:
(WebCore::RenderTableCell::logicalWidthFromTableColumn):
* rendering/RenderTableCell.h:
(WebCore::RenderTableCell::styleOrColLogicalWidth):
(RenderTableCell):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (130697 => 130698)


--- trunk/Source/WebCore/ChangeLog	2012-10-08 22:58:06 UTC (rev 130697)
+++ trunk/Source/WebCore/ChangeLog	2012-10-08 22:59:36 UTC (rev 130698)
@@ -1,3 +1,26 @@
+2012-10-08  Eric Seidel  <[email protected]>
+
+        Make no-column table-layout cases a little faster with inlining
+        https://bugs.webkit.org/show_bug.cgi?id=98566
+
+        Reviewed by Julien Chaffraix.
+
+        This change is almost not worth it at only a couple percent boost on
+        http://www.robohornet.org/tests/resizecol.html
+        However, I think the logicalWidthFromTableColumn split it kinda nice
+        so I've decided to post it anyway.
+
+        * rendering/RenderTable.cpp:
+        (WebCore::RenderTable::slowColElement):
+        * rendering/RenderTable.h:
+        (WebCore::RenderTable::colElement):
+        (RenderTable):
+        * rendering/RenderTableCell.cpp:
+        (WebCore::RenderTableCell::logicalWidthFromTableColumn):
+        * rendering/RenderTableCell.h:
+        (WebCore::RenderTableCell::styleOrColLogicalWidth):
+        (RenderTableCell):
+
 2012-10-08  Arpita Bahuguna  <[email protected]>
 
         Rename RenderObject::firstLineStyleSlowCase() to a more appropriate cachedFirstLineStyle()

Modified: trunk/Source/WebCore/rendering/RenderTable.cpp (130697 => 130698)


--- trunk/Source/WebCore/rendering/RenderTable.cpp	2012-10-08 22:58:06 UTC (rev 130697)
+++ trunk/Source/WebCore/rendering/RenderTable.cpp	2012-10-08 22:59:36 UTC (rev 130698)
@@ -754,10 +754,9 @@
     return 0;
 }
 
-RenderTableCol* RenderTable::colElement(unsigned col, bool* startEdge, bool* endEdge) const
+RenderTableCol* RenderTable::slowColElement(unsigned col, bool* startEdge, bool* endEdge) const
 {
-    if (!m_hasColElements)
-        return 0;
+    ASSERT(m_hasColElements);
 
     unsigned columnCount = 0;
     for (RenderTableCol* columnRenderer = firstColumn(); columnRenderer; columnRenderer = columnRenderer->nextColumn()) {

Modified: trunk/Source/WebCore/rendering/RenderTable.h (130697 => 130698)


--- trunk/Source/WebCore/rendering/RenderTable.h	2012-10-08 22:58:06 UTC (rev 130697)
+++ trunk/Source/WebCore/rendering/RenderTable.h	2012-10-08 22:59:36 UTC (rev 130698)
@@ -198,7 +198,13 @@
     // Return the first column or column-group.
     RenderTableCol* firstColumn() const;
 
-    RenderTableCol* colElement(unsigned col, bool* startEdge = 0, bool* endEdge = 0) const;
+    RenderTableCol* colElement(unsigned col, bool* startEdge = 0, bool* endEdge = 0) const
+    {
+        // The common case is to not have columns, make that case fast.
+        if (!m_hasColElements)
+            return 0;
+        return slowColElement(col, startEdge, endEdge);
+    }
 
     bool needsSectionRecalc() const { return m_needsSectionRecalc; }
     void setNeedsSectionRecalc()
@@ -267,6 +273,8 @@
     virtual LayoutUnit firstLineBoxBaseline() const OVERRIDE;
     virtual LayoutUnit lastLineBoxBaseline() const OVERRIDE;
 
+    RenderTableCol* slowColElement(unsigned col, bool* startEdge, bool* endEdge) const;
+
     virtual RenderBlock* firstLineBlock() const;
     virtual void updateFirstLetter();
     

Modified: trunk/Source/WebCore/rendering/RenderTableCell.cpp (130697 => 130698)


--- trunk/Source/WebCore/rendering/RenderTableCell.cpp	2012-10-08 22:58:06 UTC (rev 130697)
+++ trunk/Source/WebCore/rendering/RenderTableCell.cpp	2012-10-08 22:59:36 UTC (rev 130698)
@@ -144,44 +144,36 @@
     return max(styleLogicalHeight, adjustedLogicalHeight);
 }
 
-Length RenderTableCell::styleOrColLogicalWidth() const
+Length RenderTableCell::logicalWidthFromColumns(RenderTableCol* firstColForThisCell, Length widthFromStyle) const
 {
-    Length w = style()->logicalWidth();
-    if (!w.isAuto())
-        return w;
+    ASSERT(firstColForThisCell && firstColForThisCell == table()->colElement(col()));
+    RenderTableCol* tableCol = firstColForThisCell;
 
-    if (RenderTableCol* tableCol = table()->colElement(col())) {
-        unsigned colSpanCount = colSpan();
+    unsigned colSpanCount = colSpan();
+    int colWidthSum = 0;
+    for (unsigned i = 1; i <= colSpanCount; i++) {
+        Length colWidth = tableCol->style()->logicalWidth();
 
-        Length colWidthSum = Length(0, Fixed);
-        for (unsigned i = 1; i <= colSpanCount; i++) {
-            Length colWidth = tableCol->style()->logicalWidth();
-
-            // Percentage value should be returned only for colSpan == 1.
-            // Otherwise we return original width for the cell.
-            if (!colWidth.isFixed()) {
-                if (colSpanCount > 1)
-                    return w;
-                return colWidth;
-            }
-
-            colWidthSum = Length(colWidthSum.value() + colWidth.value(), Fixed);
-
-            tableCol = tableCol->nextColumn();
-            // If no next <col> tag found for the span we just return what we have for now.
-            if (!tableCol)
-                break;
+        // Percentage value should be returned only for colSpan == 1.
+        // Otherwise we return original width for the cell.
+        if (!colWidth.isFixed()) {
+            if (colSpanCount > 1)
+                return widthFromStyle;
+            return colWidth;
         }
 
-        // Column widths specified on <col> apply to the border box of the cell.
-        // Percentages don't need to be handled since they're always treated this way (even when specified on the cells).
-        // See Bugzilla bug 8126 for details.
-        if (colWidthSum.isFixed() && colWidthSum.value() > 0)
-            colWidthSum = Length(max(0.0f, colWidthSum.value() - borderAndPaddingLogicalWidth()), Fixed);
-        return colWidthSum;
+        colWidthSum += colWidth.value();
+        tableCol = tableCol->nextColumn();
+        // If no next <col> tag found for the span we just return what we have for now.
+        if (!tableCol)
+            break;
     }
 
-    return w;
+    // Column widths specified on <col> apply to the border box of the cell, see bug 8126.
+    // FIXME: Why is border/padding ignored in the negative width case?
+    if (colWidthSum > 0)
+        return Length(max(0, colWidthSum - borderAndPaddingLogicalWidth().ceil()), Fixed);
+    return Length(colWidthSum, Fixed);
 }
 
 void RenderTableCell::computePreferredLogicalWidths()

Modified: trunk/Source/WebCore/rendering/RenderTableCell.h (130697 => 130698)


--- trunk/Source/WebCore/rendering/RenderTableCell.h	2012-10-08 22:58:06 UTC (rev 130697)
+++ trunk/Source/WebCore/rendering/RenderTableCell.h	2012-10-08 22:59:36 UTC (rev 130698)
@@ -80,7 +80,15 @@
         return row()->rowIndex();
     }
 
-    Length styleOrColLogicalWidth() const;
+    Length styleOrColLogicalWidth() const
+    {
+        Length styleWidth = style()->logicalWidth();
+        if (!styleWidth.isAuto())
+            return styleWidth;
+        if (RenderTableCol* firstColumn = table()->colElement(col()))
+            return logicalWidthFromColumns(firstColumn, styleWidth);
+        return styleWidth;
+    }
 
     LayoutUnit logicalHeightForRowSizing() const;
 
@@ -237,6 +245,8 @@
     CollapsedBorderValue computeCollapsedBeforeBorder(IncludeBorderColorOrNot = IncludeBorderColor) const;
     CollapsedBorderValue computeCollapsedAfterBorder(IncludeBorderColorOrNot = IncludeBorderColor) const;
 
+    Length logicalWidthFromColumns(RenderTableCol* firstColForThisCell, Length widthFromStyle) const;
+
     void updateColAndRowSpanFlags();
 
     unsigned parseRowSpanFromDOM() const;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to