Skip to content

Commit 841a871

Browse files
committed
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): Canonical link: https://commits.webkit.org/128892@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@143762 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent f97e7a1 commit 841a871

7 files changed

Lines changed: 60 additions & 19 deletions

File tree

Source/WebCore/ChangeLog

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
1+
2013-02-21 Ojan Vafai <ojan@chromium.org>
2+
3+
Add computeInstrinsicLogicalWidths functions to TableLayout subclasses
4+
https://bugs.webkit.org/show_bug.cgi?id=110520
5+
6+
Reviewed by Tony Chang.
7+
8+
This is just a refactor in preparation for adding RenderTable::computeIntinsicLogicalWidths.
9+
No change in behavior.
10+
11+
Split the computePreferredLogicalWidths functions into a computeIntinsicLogicalWidths
12+
and a applyPreferredLogicalWidthQuirks. Also, move the addition of bordersPaddingAndSpacing
13+
into RenderTable since both TableLayout subclasses need this.
14+
15+
This has the added readability benefit of better isolating the quirks that each table layout
16+
mode requires.
17+
18+
* rendering/AutoTableLayout.cpp:
19+
(WebCore::AutoTableLayout::computeIntrinsicLogicalWidths):
20+
(WebCore::AutoTableLayout::applyPreferredLogicalWidthQuirks):
21+
* rendering/AutoTableLayout.h:
22+
(AutoTableLayout):
23+
* rendering/FixedTableLayout.cpp:
24+
(WebCore::FixedTableLayout::computeIntrinsicLogicalWidths):
25+
(WebCore::FixedTableLayout::applyPreferredLogicalWidthQuirks):
26+
* rendering/FixedTableLayout.h:
27+
(FixedTableLayout):
28+
* rendering/RenderTable.cpp:
29+
(WebCore::RenderTable::computePreferredLogicalWidths):
30+
* rendering/TableLayout.h:
31+
(TableLayout):
32+
133
2013-02-22 David Hyatt <hyatt@apple.com>
234

335
[New Multicolumn] Correctly track whether or not a layer is paginated.

Source/WebCore/rendering/AutoTableLayout.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ static bool shouldScaleColumns(RenderTable* table)
210210
return scale;
211211
}
212212

213-
void AutoTableLayout::computePreferredLogicalWidths(LayoutUnit& minWidth, LayoutUnit& maxWidth)
213+
void AutoTableLayout::computeIntrinsicLogicalWidths(LayoutUnit& minWidth, LayoutUnit& maxWidth)
214214
{
215215
fullRecalc();
216216

@@ -248,18 +248,16 @@ void AutoTableLayout::computePreferredLogicalWidths(LayoutUnit& minWidth, Layout
248248

249249
maxWidth = max<int>(maxWidth, spanMaxLogicalWidth);
250250

251-
int bordersPaddingAndSpacing = m_table->bordersPaddingAndSpacingInRowDirection();
252-
minWidth += bordersPaddingAndSpacing;
253-
maxWidth += bordersPaddingAndSpacing;
251+
// If there was no remaining percent, maxWidth is invalid
252+
if (!remainingPercent && maxNonPercent)
253+
maxWidth = tableMaxWidth;
254+
}
254255

256+
void AutoTableLayout::applyPreferredLogicalWidthQuirks(LayoutUnit& minWidth, LayoutUnit& maxWidth) const
257+
{
255258
Length tableLogicalWidth = m_table->style()->logicalWidth();
256-
if (tableLogicalWidth.isFixed() && tableLogicalWidth.isPositive()) {
257-
minWidth = max<int>(minWidth, tableLogicalWidth.value());
258-
maxWidth = minWidth;
259-
} else if (!remainingPercent && maxNonPercent) {
260-
// if there was no remaining percent, maxWidth is invalid
261-
maxWidth = tableMaxWidth;
262-
}
259+
if (tableLogicalWidth.isFixed() && tableLogicalWidth.isPositive())
260+
minWidth = maxWidth = max<int>(minWidth, tableLogicalWidth.value());
263261
}
264262

265263
/*

Source/WebCore/rendering/AutoTableLayout.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ class AutoTableLayout : public TableLayout {
3636
AutoTableLayout(RenderTable*);
3737
~AutoTableLayout();
3838

39-
virtual void computePreferredLogicalWidths(LayoutUnit& minWidth, LayoutUnit& maxWidth);
39+
virtual void computeIntrinsicLogicalWidths(LayoutUnit& minWidth, LayoutUnit& maxWidth) OVERRIDE;
40+
virtual void applyPreferredLogicalWidthQuirks(LayoutUnit& minWidth, LayoutUnit& maxWidth) const OVERRIDE;
4041
virtual void layout();
4142

4243
private:

Source/WebCore/rendering/FixedTableLayout.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,14 +176,16 @@ int FixedTableLayout::calcWidthArray()
176176
return usedWidth;
177177
}
178178

179-
void FixedTableLayout::computePreferredLogicalWidths(LayoutUnit& minWidth, LayoutUnit& maxWidth)
179+
void FixedTableLayout::computeIntrinsicLogicalWidths(LayoutUnit& minWidth, LayoutUnit& maxWidth)
180180
{
181-
int bordersPaddingAndSpacing = m_table->bordersPaddingAndSpacingInRowDirection();
182-
minWidth = maxWidth = calcWidthArray() + bordersPaddingAndSpacing;
181+
minWidth = maxWidth = calcWidthArray();
182+
}
183183

184+
void FixedTableLayout::applyPreferredLogicalWidthQuirks(LayoutUnit& minWidth, LayoutUnit& maxWidth) const
185+
{
184186
Length tableLogicalWidth = m_table->style()->logicalWidth();
185187
if (tableLogicalWidth.isFixed() && tableLogicalWidth.isPositive())
186-
minWidth = maxWidth = max<int>(minWidth, tableLogicalWidth.value() - bordersPaddingAndSpacing);
188+
minWidth = maxWidth = max<int>(minWidth, tableLogicalWidth.value() - m_table->bordersPaddingAndSpacingInRowDirection());
187189

188190
/*
189191
<table style="width:100%; background-color:red"><tr><td>

Source/WebCore/rendering/FixedTableLayout.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ class FixedTableLayout : public TableLayout {
3434
public:
3535
FixedTableLayout(RenderTable*);
3636

37-
virtual void computePreferredLogicalWidths(LayoutUnit& minWidth, LayoutUnit& maxWidth);
37+
virtual void computeIntrinsicLogicalWidths(LayoutUnit& minWidth, LayoutUnit& maxWidth) OVERRIDE;
38+
virtual void applyPreferredLogicalWidthQuirks(LayoutUnit& minWidth, LayoutUnit& maxWidth) const OVERRIDE;
3839
virtual void layout();
3940

4041
private:

Source/WebCore/rendering/RenderTable.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,13 @@ void RenderTable::computePreferredLogicalWidths()
720720
recalcSectionsIfNeeded();
721721
recalcBordersInRowDirection();
722722

723-
m_tableLayout->computePreferredLogicalWidths(m_minPreferredLogicalWidth, m_maxPreferredLogicalWidth);
723+
m_tableLayout->computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth, m_maxPreferredLogicalWidth);
724+
725+
int bordersPaddingAndSpacing = bordersPaddingAndSpacingInRowDirection();
726+
m_minPreferredLogicalWidth += bordersPaddingAndSpacing;
727+
m_maxPreferredLogicalWidth += bordersPaddingAndSpacing;
728+
729+
m_tableLayout->applyPreferredLogicalWidthQuirks(m_minPreferredLogicalWidth, m_maxPreferredLogicalWidth);
724730

725731
for (unsigned i = 0; i < m_captions.size(); i++)
726732
m_minPreferredLogicalWidth = max(m_minPreferredLogicalWidth, m_captions[i]->minPreferredLogicalWidth());

Source/WebCore/rendering/TableLayout.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ class TableLayout {
3838

3939
virtual ~TableLayout() { }
4040

41-
virtual void computePreferredLogicalWidths(LayoutUnit& minWidth, LayoutUnit& maxWidth) = 0;
41+
virtual void computeIntrinsicLogicalWidths(LayoutUnit& minWidth, LayoutUnit& maxWidth) = 0;
42+
virtual void applyPreferredLogicalWidthQuirks(LayoutUnit& minWidth, LayoutUnit& maxWidth) const = 0;
4243
virtual void layout() = 0;
4344

4445
protected:

0 commit comments

Comments
 (0)