Title: [143762] trunk/Source/WebCore
Revision
143762
Author
o...@chromium.org
Date
2013-02-22 11:40:43 -0800 (Fri, 22 Feb 2013)

Log Message

Add computeInstrinsicLogicalWidths functions to TableLayout subclasses
https://bugs.webkit.org/show_bug.cgi?id=110520

Reviewed by Tony Chang.

This is just a refactor in preparation for adding RenderTable::computeIntinsicLogicalWidths.
No change in behavior.

Split the computePreferredLogicalWidths functions into a computeIntinsicLogicalWidths
and a applyPreferredLogicalWidthQuirks. Also, move the addition of bordersPaddingAndSpacing
into RenderTable since both TableLayout subclasses need this.

This has the added readability benefit of better isolating the quirks that each table layout
mode requires.

* rendering/AutoTableLayout.cpp:
(WebCore::AutoTableLayout::computeIntrinsicLogicalWidths):
(WebCore::AutoTableLayout::applyPreferredLogicalWidthQuirks):
* rendering/AutoTableLayout.h:
(AutoTableLayout):
* rendering/FixedTableLayout.cpp:
(WebCore::FixedTableLayout::computeIntrinsicLogicalWidths):
(WebCore::FixedTableLayout::applyPreferredLogicalWidthQuirks):
* rendering/FixedTableLayout.h:
(FixedTableLayout):
* rendering/RenderTable.cpp:
(WebCore::RenderTable::computePreferredLogicalWidths):
* rendering/TableLayout.h:
(TableLayout):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (143761 => 143762)


--- trunk/Source/WebCore/ChangeLog	2013-02-22 19:25:26 UTC (rev 143761)
+++ trunk/Source/WebCore/ChangeLog	2013-02-22 19:40:43 UTC (rev 143762)
@@ -1,3 +1,35 @@
+2013-02-21  Ojan Vafai  <o...@chromium.org>
+
+        Add computeInstrinsicLogicalWidths functions to TableLayout subclasses
+        https://bugs.webkit.org/show_bug.cgi?id=110520
+
+        Reviewed by Tony Chang.
+
+        This is just a refactor in preparation for adding RenderTable::computeIntinsicLogicalWidths.
+        No change in behavior.
+
+        Split the computePreferredLogicalWidths functions into a computeIntinsicLogicalWidths
+        and a applyPreferredLogicalWidthQuirks. Also, move the addition of bordersPaddingAndSpacing
+        into RenderTable since both TableLayout subclasses need this.
+
+        This has the added readability benefit of better isolating the quirks that each table layout
+        mode requires.
+
+        * rendering/AutoTableLayout.cpp:
+        (WebCore::AutoTableLayout::computeIntrinsicLogicalWidths):
+        (WebCore::AutoTableLayout::applyPreferredLogicalWidthQuirks):
+        * rendering/AutoTableLayout.h:
+        (AutoTableLayout):
+        * rendering/FixedTableLayout.cpp:
+        (WebCore::FixedTableLayout::computeIntrinsicLogicalWidths):
+        (WebCore::FixedTableLayout::applyPreferredLogicalWidthQuirks):
+        * rendering/FixedTableLayout.h:
+        (FixedTableLayout):
+        * rendering/RenderTable.cpp:
+        (WebCore::RenderTable::computePreferredLogicalWidths):
+        * rendering/TableLayout.h:
+        (TableLayout):
+
 2013-02-22  David Hyatt  <hy...@apple.com>
 
         [New Multicolumn] Correctly track whether or not a layer is paginated.

Modified: trunk/Source/WebCore/rendering/AutoTableLayout.cpp (143761 => 143762)


--- trunk/Source/WebCore/rendering/AutoTableLayout.cpp	2013-02-22 19:25:26 UTC (rev 143761)
+++ trunk/Source/WebCore/rendering/AutoTableLayout.cpp	2013-02-22 19:40:43 UTC (rev 143762)
@@ -210,7 +210,7 @@
     return scale;
 }
 
-void AutoTableLayout::computePreferredLogicalWidths(LayoutUnit& minWidth, LayoutUnit& maxWidth)
+void AutoTableLayout::computeIntrinsicLogicalWidths(LayoutUnit& minWidth, LayoutUnit& maxWidth)
 {
     fullRecalc();
 
@@ -248,18 +248,16 @@
 
     maxWidth = max<int>(maxWidth, spanMaxLogicalWidth);
 
-    int bordersPaddingAndSpacing = m_table->bordersPaddingAndSpacingInRowDirection();
-    minWidth += bordersPaddingAndSpacing;
-    maxWidth += bordersPaddingAndSpacing;
+    // If there was no remaining percent, maxWidth is invalid
+    if (!remainingPercent && maxNonPercent)
+        maxWidth = tableMaxWidth;
+}
 
+void AutoTableLayout::applyPreferredLogicalWidthQuirks(LayoutUnit& minWidth, LayoutUnit& maxWidth) const
+{
     Length tableLogicalWidth = m_table->style()->logicalWidth();
-    if (tableLogicalWidth.isFixed() && tableLogicalWidth.isPositive()) {
-        minWidth = max<int>(minWidth, tableLogicalWidth.value());
-        maxWidth = minWidth;
-    } else if (!remainingPercent && maxNonPercent) {
-        // if there was no remaining percent, maxWidth is invalid
-        maxWidth = tableMaxWidth;
-    }
+    if (tableLogicalWidth.isFixed() && tableLogicalWidth.isPositive())
+        minWidth = maxWidth = max<int>(minWidth, tableLogicalWidth.value());
 }
 
 /*

Modified: trunk/Source/WebCore/rendering/AutoTableLayout.h (143761 => 143762)


--- trunk/Source/WebCore/rendering/AutoTableLayout.h	2013-02-22 19:25:26 UTC (rev 143761)
+++ trunk/Source/WebCore/rendering/AutoTableLayout.h	2013-02-22 19:40:43 UTC (rev 143762)
@@ -36,7 +36,8 @@
     AutoTableLayout(RenderTable*);
     ~AutoTableLayout();
 
-    virtual void computePreferredLogicalWidths(LayoutUnit& minWidth, LayoutUnit& maxWidth);
+    virtual void computeIntrinsicLogicalWidths(LayoutUnit& minWidth, LayoutUnit& maxWidth) OVERRIDE;
+    virtual void applyPreferredLogicalWidthQuirks(LayoutUnit& minWidth, LayoutUnit& maxWidth) const OVERRIDE;
     virtual void layout();
 
 private:

Modified: trunk/Source/WebCore/rendering/FixedTableLayout.cpp (143761 => 143762)


--- trunk/Source/WebCore/rendering/FixedTableLayout.cpp	2013-02-22 19:25:26 UTC (rev 143761)
+++ trunk/Source/WebCore/rendering/FixedTableLayout.cpp	2013-02-22 19:40:43 UTC (rev 143762)
@@ -176,14 +176,16 @@
     return usedWidth;
 }
 
-void FixedTableLayout::computePreferredLogicalWidths(LayoutUnit& minWidth, LayoutUnit& maxWidth)
+void FixedTableLayout::computeIntrinsicLogicalWidths(LayoutUnit& minWidth, LayoutUnit& maxWidth)
 {
-    int bordersPaddingAndSpacing = m_table->bordersPaddingAndSpacingInRowDirection();
-    minWidth = maxWidth = calcWidthArray() + bordersPaddingAndSpacing;
+    minWidth = maxWidth = calcWidthArray();
+}
 
+void FixedTableLayout::applyPreferredLogicalWidthQuirks(LayoutUnit& minWidth, LayoutUnit& maxWidth) const
+{
     Length tableLogicalWidth = m_table->style()->logicalWidth();
     if (tableLogicalWidth.isFixed() && tableLogicalWidth.isPositive())
-        minWidth = maxWidth = max<int>(minWidth, tableLogicalWidth.value() - bordersPaddingAndSpacing);
+        minWidth = maxWidth = max<int>(minWidth, tableLogicalWidth.value() - m_table->bordersPaddingAndSpacingInRowDirection());
 
     /*
         <table style="width:100%; background-color:red"><tr><td>

Modified: trunk/Source/WebCore/rendering/FixedTableLayout.h (143761 => 143762)


--- trunk/Source/WebCore/rendering/FixedTableLayout.h	2013-02-22 19:25:26 UTC (rev 143761)
+++ trunk/Source/WebCore/rendering/FixedTableLayout.h	2013-02-22 19:40:43 UTC (rev 143762)
@@ -34,7 +34,8 @@
 public:
     FixedTableLayout(RenderTable*);
 
-    virtual void computePreferredLogicalWidths(LayoutUnit& minWidth, LayoutUnit& maxWidth);
+    virtual void computeIntrinsicLogicalWidths(LayoutUnit& minWidth, LayoutUnit& maxWidth) OVERRIDE;
+    virtual void applyPreferredLogicalWidthQuirks(LayoutUnit& minWidth, LayoutUnit& maxWidth) const OVERRIDE;
     virtual void layout();
 
 private:

Modified: trunk/Source/WebCore/rendering/RenderTable.cpp (143761 => 143762)


--- trunk/Source/WebCore/rendering/RenderTable.cpp	2013-02-22 19:25:26 UTC (rev 143761)
+++ trunk/Source/WebCore/rendering/RenderTable.cpp	2013-02-22 19:40:43 UTC (rev 143762)
@@ -720,8 +720,14 @@
     recalcSectionsIfNeeded();
     recalcBordersInRowDirection();
 
-    m_tableLayout->computePreferredLogicalWidths(m_minPreferredLogicalWidth, m_maxPreferredLogicalWidth);
+    m_tableLayout->computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth, m_maxPreferredLogicalWidth);
 
+    int bordersPaddingAndSpacing = bordersPaddingAndSpacingInRowDirection();
+    m_minPreferredLogicalWidth += bordersPaddingAndSpacing;
+    m_maxPreferredLogicalWidth += bordersPaddingAndSpacing;
+
+    m_tableLayout->applyPreferredLogicalWidthQuirks(m_minPreferredLogicalWidth, m_maxPreferredLogicalWidth);
+
     for (unsigned i = 0; i < m_captions.size(); i++)
         m_minPreferredLogicalWidth = max(m_minPreferredLogicalWidth, m_captions[i]->minPreferredLogicalWidth());
 

Modified: trunk/Source/WebCore/rendering/TableLayout.h (143761 => 143762)


--- trunk/Source/WebCore/rendering/TableLayout.h	2013-02-22 19:25:26 UTC (rev 143761)
+++ trunk/Source/WebCore/rendering/TableLayout.h	2013-02-22 19:40:43 UTC (rev 143762)
@@ -38,7 +38,8 @@
 
     virtual ~TableLayout() { }
 
-    virtual void computePreferredLogicalWidths(LayoutUnit& minWidth, LayoutUnit& maxWidth) = 0;
+    virtual void computeIntrinsicLogicalWidths(LayoutUnit& minWidth, LayoutUnit& maxWidth) = 0;
+    virtual void applyPreferredLogicalWidthQuirks(LayoutUnit& minWidth, LayoutUnit& maxWidth) const = 0;
     virtual void layout() = 0;
 
 protected:
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to