Add computeInstrinsicLogicalWidths functions to TableLayout subclasses
authorojan@chromium.org <ojan@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Feb 2013 19:40:43 +0000 (19:40 +0000)
committerojan@chromium.org <ojan@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Feb 2013 19:40:43 +0000 (19:40 +0000)
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):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@143762 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/rendering/AutoTableLayout.cpp
Source/WebCore/rendering/AutoTableLayout.h
Source/WebCore/rendering/FixedTableLayout.cpp
Source/WebCore/rendering/FixedTableLayout.h
Source/WebCore/rendering/RenderTable.cpp
Source/WebCore/rendering/TableLayout.h

index d84f5d9..75dbe93 100644 (file)
@@ -1,3 +1,35 @@
+2013-02-21  Ojan Vafai  <ojan@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  <hyatt@apple.com>
 
         [New Multicolumn] Correctly track whether or not a layer is paginated.
index bacf2ab..96a707b 100644 (file)
@@ -210,7 +210,7 @@ static bool shouldScaleColumns(RenderTable* table)
     return scale;
 }
 
-void AutoTableLayout::computePreferredLogicalWidths(LayoutUnit& minWidth, LayoutUnit& maxWidth)
+void AutoTableLayout::computeIntrinsicLogicalWidths(LayoutUnit& minWidth, LayoutUnit& maxWidth)
 {
     fullRecalc();
 
@@ -248,18 +248,16 @@ void AutoTableLayout::computePreferredLogicalWidths(LayoutUnit& minWidth, Layout
 
     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());
 }
 
 /*
index 9d0adc1..a1fdad0 100644 (file)
@@ -36,7 +36,8 @@ public:
     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:
index bc8f586..a6b65e9 100644 (file)
@@ -176,14 +176,16 @@ int FixedTableLayout::calcWidthArray()
     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>
index 5609e8c..68ba084 100644 (file)
@@ -34,7 +34,8 @@ class FixedTableLayout : public TableLayout {
 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:
index 9b014f0..128c0e2 100644 (file)
@@ -720,7 +720,13 @@ void RenderTable::computePreferredLogicalWidths()
     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());
index eb9276d..27393d4 100644 (file)
@@ -38,7 +38,8 @@ public:
 
     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: