Diff
Modified: trunk/Source/WebCore/ChangeLog (129077 => 129078)
--- trunk/Source/WebCore/ChangeLog 2012-09-20 00:41:26 UTC (rev 129077)
+++ trunk/Source/WebCore/ChangeLog 2012-09-20 00:58:58 UTC (rev 129078)
@@ -1,3 +1,63 @@
+2012-09-19 Julien Chaffraix <[email protected]>
+
+ The collapsing border code needs direction-aware border getters
+ https://bugs.webkit.org/show_bug.cgi?id=96710
+
+ Reviewed by Ojan Vafai.
+
+ This refactoring is needed to extend our collapsing border support for mixed directionality
+ at the table cell level (we currently wrongly ignore any direction below the row-group). For
+ now, the new helpers are dumb and return exactly the old result but they will be made
+ direction-aware in a follow-up change.
+
+ Refactoring covered by existing tests.
+
+ * rendering/RenderBox.h:
+ (WebCore::RenderBox::hasSameDirectionAs):
+ Added this helper function. For now, it's only used to compare against
+ the table direction but we will reuse it to compare the current cell
+ direction against the other table parts.
+
+ * rendering/RenderTableCell.h:
+ (WebCore::RenderTableCell::computeCollapsedStartBorder):
+ (WebCore::RenderTableCell::computeCollapsedEndBorder):
+ Transitioned those 2 functions to using the new direction-aware functions.
+
+ * rendering/RenderTable.cpp:
+ (WebCore::RenderTable::tableStartBorderAdjoiningCell):
+ (WebCore::RenderTable::tableEndBorderAdjoiningCell):
+ * rendering/RenderTableSection.cpp:
+ (WebCore::RenderTableSection::firstRowCellAdjoiningTableStart):
+ (WebCore::RenderTableSection::firstRowCellAdjoiningTableEnd):
+ * rendering/RenderTableCell.h:
+ (WebCore::RenderTableCell::borderAdjoiningTableStart):
+ (WebCore::RenderTableCell::borderAdjoiningTableEnd):
+ * rendering/RenderTableSection.h:
+ (WebCore::RenderTableSection::borderAdjoiningTableStart):
+ (WebCore::RenderTableSection::borderAdjoiningTableEnd):
+ Updated those call sites to use RenderBox::hasSameDirectionAs.
+
+ * rendering/RenderTableCell.h:
+ (WebCore::RenderTableCell::borderAdjoiningNextCell):
+ (WebCore::RenderTableCell::borderAdjoiningPreviousCell):
+ * rendering/RenderTableCol.cpp:
+ (WebCore::RenderTableCol::borderAdjoiningCellStartBorder):
+ (WebCore::RenderTableCol::borderAdjoiningCellEndBorder):
+ (WebCore::RenderTableCol::borderAdjoiningCellBefore):
+ (WebCore::RenderTableCol::borderAdjoiningCellAfter):
+ * rendering/RenderTableCol.h:
+ * rendering/RenderTableRow.cpp:
+ (WebCore::RenderTableRow::borderAdjoiningStartCell):
+ (WebCore::RenderTableRow::borderAdjoiningEndCell):
+ * rendering/RenderTableRow.h:
+ (WebCore::RenderTableRow::borderAdjoiningTableStart):
+ (WebCore::RenderTableRow::borderAdjoiningTableEnd):
+ * rendering/RenderTableSection.cpp:
+ (WebCore::RenderTableSection::borderAdjoiningStartCell):
+ (WebCore::RenderTableSection::borderAdjoiningEndCell):
+ New direction-aware functions. Added some ASSERT to ensure
+ we don't call them with the wrong parameters.
+
2012-09-19 Kentaro Hara <[email protected]>
[V8] ScriptController::compileAndRunScript() can crash
Modified: trunk/Source/WebCore/rendering/RenderBox.h (129077 => 129078)
--- trunk/Source/WebCore/rendering/RenderBox.h 2012-09-20 00:41:26 UTC (rev 129077)
+++ trunk/Source/WebCore/rendering/RenderBox.h 2012-09-20 00:58:58 UTC (rev 129078)
@@ -543,6 +543,8 @@
return 0;
}
+ bool hasSameDirectionAs(const RenderBox* object) const { return style()->direction() == object->style()->direction(); }
+
protected:
virtual void willBeDestroyed();
Modified: trunk/Source/WebCore/rendering/RenderTable.cpp (129077 => 129078)
--- trunk/Source/WebCore/rendering/RenderTable.cpp 2012-09-20 00:41:26 UTC (rev 129077)
+++ trunk/Source/WebCore/rendering/RenderTable.cpp 2012-09-20 00:58:58 UTC (rev 129078)
@@ -1316,7 +1316,7 @@
const BorderValue& RenderTable::tableStartBorderAdjoiningCell(const RenderTableCell* cell) const
{
ASSERT(cell->isFirstOrLastCellInRow());
- if (cell->section()->hasSameDirectionAsTable())
+ if (hasSameDirectionAs(cell->section()))
return style()->borderStart();
return style()->borderEnd();
@@ -1325,7 +1325,7 @@
const BorderValue& RenderTable::tableEndBorderAdjoiningCell(const RenderTableCell* cell) const
{
ASSERT(cell->isFirstOrLastCellInRow());
- if (cell->section()->hasSameDirectionAsTable())
+ if (hasSameDirectionAs(cell->section()))
return style()->borderEnd();
return style()->borderStart();
Modified: trunk/Source/WebCore/rendering/RenderTableCell.cpp (129077 => 129078)
--- trunk/Source/WebCore/rendering/RenderTableCell.cpp 2012-09-20 00:41:26 UTC (rev 129077)
+++ trunk/Source/WebCore/rendering/RenderTableCell.cpp 2012-09-20 00:58:58 UTC (rev 129078)
@@ -422,18 +422,18 @@
// (2) The end border of the preceding cell.
if (RenderTableCell* prevCell = table->cellBefore(this)) {
- CollapsedBorderValue prevCellBorder = CollapsedBorderValue(prevCell->style()->borderEnd(), includeColor ? prevCell->style()->visitedDependentColor(endColorProperty) : Color(), BCELL);
+ CollapsedBorderValue prevCellBorder = CollapsedBorderValue(prevCell->borderAdjoiningCellAfter(this), includeColor ? prevCell->style()->visitedDependentColor(endColorProperty) : Color(), BCELL);
result = chooseBorder(prevCellBorder, result);
if (!result.exists())
return result;
} else if (isStartColumn) {
// (3) Our row's start border.
- result = chooseBorder(result, CollapsedBorderValue(parent()->style()->borderStart(), includeColor ? parent()->style()->visitedDependentColor(startColorProperty) : Color(), BROW));
+ result = chooseBorder(result, CollapsedBorderValue(row()->borderAdjoiningStartCell(this), includeColor ? parent()->style()->visitedDependentColor(startColorProperty) : Color(), BROW));
if (!result.exists())
return result;
-
+
// (4) Our row group's start border.
- result = chooseBorder(result, CollapsedBorderValue(section()->style()->borderStart(), includeColor ? section()->style()->visitedDependentColor(startColorProperty) : Color(), BROWGROUP));
+ result = chooseBorder(result, CollapsedBorderValue(section()->borderAdjoiningStartCell(this), includeColor ? section()->style()->visitedDependentColor(startColorProperty) : Color(), BROWGROUP));
if (!result.exists())
return result;
}
@@ -443,11 +443,11 @@
bool endColEdge;
RenderTableCol* colElt = table->colElement(col(), &startColEdge, &endColEdge);
if (colElt && startColEdge) {
- result = chooseBorder(result, CollapsedBorderValue(colElt->style()->borderStart(), includeColor ? colElt->style()->visitedDependentColor(startColorProperty) : Color(), BCOL));
+ result = chooseBorder(result, CollapsedBorderValue(colElt->borderAdjoiningCellStartBorder(this), includeColor ? colElt->style()->visitedDependentColor(startColorProperty) : Color(), BCOL));
if (!result.exists())
return result;
if (RenderTableCol* enclosingColumnGroup = colElt->enclosingColumnGroupIfAdjacentBefore()) {
- result = chooseBorder(result, CollapsedBorderValue(enclosingColumnGroup->style()->borderStart(), includeColor ? enclosingColumnGroup->style()->visitedDependentColor(startColorProperty) : Color(), BCOLGROUP));
+ result = chooseBorder(result, CollapsedBorderValue(enclosingColumnGroup->borderAdjoiningCellStartBorder(this), includeColor ? enclosingColumnGroup->style()->visitedDependentColor(startColorProperty) : Color(), BCOLGROUP));
if (!result.exists())
return result;
}
@@ -457,7 +457,7 @@
if (!isStartColumn) {
colElt = table->colElement(col() -1, &startColEdge, &endColEdge);
if (colElt && endColEdge) {
- CollapsedBorderValue endBorder = CollapsedBorderValue(colElt->style()->borderEnd(), includeColor ? colElt->style()->visitedDependentColor(endColorProperty) : Color(), BCOL);
+ CollapsedBorderValue endBorder = CollapsedBorderValue(colElt->borderAdjoiningCellAfter(this), includeColor ? colElt->style()->visitedDependentColor(endColorProperty) : Color(), BCOL);
result = chooseBorder(endBorder, result);
if (!result.exists())
return result;
@@ -495,19 +495,19 @@
if (!isEndColumn) {
RenderTableCell* nextCell = table->cellAfter(this);
if (nextCell && nextCell->style()) {
- CollapsedBorderValue startBorder = CollapsedBorderValue(nextCell->style()->borderStart(), includeColor ? nextCell->style()->visitedDependentColor(startColorProperty) : Color(), BCELL);
+ CollapsedBorderValue startBorder = CollapsedBorderValue(nextCell->borderAdjoiningCellBefore(this), includeColor ? nextCell->style()->visitedDependentColor(startColorProperty) : Color(), BCELL);
result = chooseBorder(result, startBorder);
if (!result.exists())
return result;
}
} else {
// (3) Our row's end border.
- result = chooseBorder(result, CollapsedBorderValue(parent()->style()->borderEnd(), includeColor ? parent()->style()->visitedDependentColor(endColorProperty) : Color(), BROW));
+ result = chooseBorder(result, CollapsedBorderValue(row()->borderAdjoiningEndCell(this), includeColor ? parent()->style()->visitedDependentColor(endColorProperty) : Color(), BROW));
if (!result.exists())
return result;
// (4) Our row group's end border.
- result = chooseBorder(result, CollapsedBorderValue(section()->style()->borderEnd(), includeColor ? section()->style()->visitedDependentColor(endColorProperty) : Color(), BROWGROUP));
+ result = chooseBorder(result, CollapsedBorderValue(section()->borderAdjoiningEndCell(this), includeColor ? section()->style()->visitedDependentColor(endColorProperty) : Color(), BROWGROUP));
if (!result.exists())
return result;
}
@@ -517,11 +517,11 @@
bool endColEdge;
RenderTableCol* colElt = table->colElement(col() + colSpan() - 1, &startColEdge, &endColEdge);
if (colElt && endColEdge) {
- result = chooseBorder(result, CollapsedBorderValue(colElt->style()->borderEnd(), includeColor ? colElt->style()->visitedDependentColor(endColorProperty) : Color(), BCOL));
+ result = chooseBorder(result, CollapsedBorderValue(colElt->borderAdjoiningCellEndBorder(this), includeColor ? colElt->style()->visitedDependentColor(endColorProperty) : Color(), BCOL));
if (!result.exists())
return result;
if (RenderTableCol* enclosingColumnGroup = colElt->enclosingColumnGroupIfAdjacentAfter()) {
- result = chooseBorder(result, CollapsedBorderValue(enclosingColumnGroup->style()->borderEnd(), includeColor ? enclosingColumnGroup->style()->visitedDependentColor(endColorProperty) : Color(), BCOLGROUP));
+ result = chooseBorder(result, CollapsedBorderValue(enclosingColumnGroup->borderAdjoiningCellEndBorder(this), includeColor ? enclosingColumnGroup->style()->visitedDependentColor(endColorProperty) : Color(), BCOLGROUP));
if (!result.exists())
return result;
}
@@ -531,7 +531,7 @@
if (!isEndColumn) {
colElt = table->colElement(col() + colSpan(), &startColEdge, &endColEdge);
if (colElt && startColEdge) {
- CollapsedBorderValue startBorder = CollapsedBorderValue(colElt->style()->borderStart(), includeColor ? colElt->style()->visitedDependentColor(startColorProperty) : Color(), BCOL);
+ CollapsedBorderValue startBorder = CollapsedBorderValue(colElt->borderAdjoiningCellBefore(this), includeColor ? colElt->style()->visitedDependentColor(startColorProperty) : Color(), BCOL);
result = chooseBorder(result, startBorder);
if (!result.exists())
return result;
Modified: trunk/Source/WebCore/rendering/RenderTableCell.h (129077 => 129078)
--- trunk/Source/WebCore/rendering/RenderTableCell.h 2012-09-20 00:41:26 UTC (rev 129077)
+++ trunk/Source/WebCore/rendering/RenderTableCell.h 2012-09-20 00:58:58 UTC (rev 129078)
@@ -144,7 +144,7 @@
const BorderValue& borderAdjoiningTableStart() const
{
ASSERT(isFirstOrLastCellInRow());
- if (section()->hasSameDirectionAsTable())
+ if (section()->hasSameDirectionAs(table()))
return style()->borderStart();
return style()->borderEnd();
@@ -153,12 +153,26 @@
const BorderValue& borderAdjoiningTableEnd() const
{
ASSERT(isFirstOrLastCellInRow());
- if (section()->hasSameDirectionAsTable())
+ if (section()->hasSameDirectionAs(table()))
return style()->borderEnd();
return style()->borderStart();
}
+ const BorderValue& borderAdjoiningCellBefore(const RenderTableCell* cell)
+ {
+ ASSERT_UNUSED(cell, table()->cellAfter(cell) == this);
+ // FIXME: https://webkit.org/b/79272 - Add support for mixed directionality at the cell level.
+ return style()->borderStart();
+ }
+
+ const BorderValue& borderAdjoiningCellAfter(const RenderTableCell* cell)
+ {
+ ASSERT_UNUSED(cell, table()->cellBefore(cell) == this);
+ // FIXME: https://webkit.org/b/79272 - Add support for mixed directionality at the cell level.
+ return style()->borderEnd();
+ }
+
#ifndef NDEBUG
bool isFirstOrLastCellInRow() const
{
Modified: trunk/Source/WebCore/rendering/RenderTableCol.cpp (129077 => 129078)
--- trunk/Source/WebCore/rendering/RenderTableCol.cpp 2012-09-20 00:41:26 UTC (rev 129077)
+++ trunk/Source/WebCore/rendering/RenderTableCol.cpp 2012-09-20 00:58:58 UTC (rev 129078)
@@ -30,6 +30,7 @@
#include "HTMLNames.h"
#include "HTMLTableColElement.h"
#include "RenderTable.h"
+#include "RenderTableCell.h"
namespace WebCore {
@@ -162,4 +163,26 @@
return toRenderTableCol(next);
}
+const BorderValue& RenderTableCol::borderAdjoiningCellStartBorder(const RenderTableCell*) const
+{
+ return style()->borderStart();
}
+
+const BorderValue& RenderTableCol::borderAdjoiningCellEndBorder(const RenderTableCell*) const
+{
+ return style()->borderEnd();
+}
+
+const BorderValue& RenderTableCol::borderAdjoiningCellBefore(const RenderTableCell* cell) const
+{
+ ASSERT_UNUSED(cell, table()->colElement(cell->col() + cell->colSpan()) == this);
+ return style()->borderStart();
+}
+
+const BorderValue& RenderTableCol::borderAdjoiningCellAfter(const RenderTableCell* cell) const
+{
+ ASSERT_UNUSED(cell, table()->colElement(cell->col() - 1) == this);
+ return style()->borderEnd();
+}
+
+}
Modified: trunk/Source/WebCore/rendering/RenderTableCol.h (129077 => 129078)
--- trunk/Source/WebCore/rendering/RenderTableCol.h 2012-09-20 00:41:26 UTC (rev 129077)
+++ trunk/Source/WebCore/rendering/RenderTableCol.h 2012-09-20 00:58:58 UTC (rev 129078)
@@ -31,6 +31,7 @@
namespace WebCore {
class RenderTable;
+class RenderTableCell;
class RenderTableCol : public RenderBox {
public:
@@ -67,6 +68,11 @@
// Returns the next column or column-group.
RenderTableCol* nextColumn() const;
+ const BorderValue& borderAdjoiningCellStartBorder(const RenderTableCell*) const;
+ const BorderValue& borderAdjoiningCellEndBorder(const RenderTableCell*) const;
+ const BorderValue& borderAdjoiningCellBefore(const RenderTableCell*) const;
+ const BorderValue& borderAdjoiningCellAfter(const RenderTableCell*) const;
+
private:
virtual RenderObjectChildList* virtualChildren() { return children(); }
virtual const RenderObjectChildList* virtualChildren() const { return children(); }
Modified: trunk/Source/WebCore/rendering/RenderTableRow.cpp (129077 => 129078)
--- trunk/Source/WebCore/rendering/RenderTableRow.cpp 2012-09-20 00:41:26 UTC (rev 129077)
+++ trunk/Source/WebCore/rendering/RenderTableRow.cpp 2012-09-20 00:58:58 UTC (rev 129078)
@@ -82,6 +82,20 @@
}
}
+const BorderValue& RenderTableRow::borderAdjoiningStartCell(const RenderTableCell* cell) const
+{
+ ASSERT_UNUSED(cell, !table()->cellBefore(cell));
+ // FIXME: https://webkit.org/b/79272 - Add support for mixed directionality at the cell level.
+ return style()->borderStart();
+}
+
+const BorderValue& RenderTableRow::borderAdjoiningEndCell(const RenderTableCell* cell) const
+{
+ ASSERT_UNUSED(cell, !table()->cellAfter(cell));
+ // FIXME: https://webkit.org/b/79272 - Add support for mixed directionality at the cell level.
+ return style()->borderEnd();
+}
+
void RenderTableRow::addChild(RenderObject* child, RenderObject* beforeChild)
{
// Make sure we don't append things after :after-generated content if we have it.
Modified: trunk/Source/WebCore/rendering/RenderTableRow.h (129077 => 129078)
--- trunk/Source/WebCore/rendering/RenderTableRow.h 2012-09-20 00:41:26 UTC (rev 129077)
+++ trunk/Source/WebCore/rendering/RenderTableRow.h 2012-09-20 00:58:58 UTC (rev 129078)
@@ -68,7 +68,7 @@
const BorderValue& borderAdjoiningTableStart() const
{
- if (section()->hasSameDirectionAsTable())
+ if (section()->hasSameDirectionAs(table()))
return style()->borderStart();
return style()->borderEnd();
@@ -76,12 +76,15 @@
const BorderValue& borderAdjoiningTableEnd() const
{
- if (section()->hasSameDirectionAsTable())
+ if (section()->hasSameDirectionAs(table()))
return style()->borderEnd();
return style()->borderStart();
}
+ const BorderValue& borderAdjoiningStartCell(const RenderTableCell*) const;
+ const BorderValue& borderAdjoiningEndCell(const RenderTableCell*) const;
+
private:
virtual RenderObjectChildList* virtualChildren() { return children(); }
virtual const RenderObjectChildList* virtualChildren() const { return children(); }
Modified: trunk/Source/WebCore/rendering/RenderTableSection.cpp (129077 => 129078)
--- trunk/Source/WebCore/rendering/RenderTableSection.cpp 2012-09-20 00:41:26 UTC (rev 129077)
+++ trunk/Source/WebCore/rendering/RenderTableSection.cpp 2012-09-20 00:58:58 UTC (rev 129078)
@@ -1317,15 +1317,29 @@
return result + 1;
}
+const BorderValue& RenderTableSection::borderAdjoiningStartCell(const RenderTableCell* cell) const
+{
+ ASSERT_UNUSED(cell, !table()->cellBefore(cell));
+ // FIXME: https://webkit.org/b/79272 - Add support for mixed directionality at the cell level.
+ return style()->borderStart();
+}
+
+const BorderValue& RenderTableSection::borderAdjoiningEndCell(const RenderTableCell* cell) const
+{
+ ASSERT_UNUSED(cell, !table()->cellAfter(cell));
+ // FIXME: https://webkit.org/b/79272 - Add support for mixed directionality at the cell level.
+ return style()->borderEnd();
+}
+
const RenderTableCell* RenderTableSection::firstRowCellAdjoiningTableStart() const
{
- unsigned adjoiningStartCellColumnIndex = hasSameDirectionAsTable() ? 0 : table()->lastColumnIndex();
+ unsigned adjoiningStartCellColumnIndex = hasSameDirectionAs(table()) ? 0 : table()->lastColumnIndex();
return cellAt(0, adjoiningStartCellColumnIndex).primaryCell();
}
const RenderTableCell* RenderTableSection::firstRowCellAdjoiningTableEnd() const
{
- unsigned adjoiningEndCellColumnIndex = hasSameDirectionAsTable() ? table()->lastColumnIndex() : 0;
+ unsigned adjoiningEndCellColumnIndex = hasSameDirectionAs(table()) ? table()->lastColumnIndex() : 0;
return cellAt(0, adjoiningEndCellColumnIndex).primaryCell();
}
Modified: trunk/Source/WebCore/rendering/RenderTableSection.h (129077 => 129078)
--- trunk/Source/WebCore/rendering/RenderTableSection.h 2012-09-20 00:41:26 UTC (rev 129077)
+++ trunk/Source/WebCore/rendering/RenderTableSection.h 2012-09-20 00:58:58 UTC (rev 129078)
@@ -117,14 +117,9 @@
Length logicalHeight;
};
- bool hasSameDirectionAsTable() const
- {
- return table()->style()->direction() == style()->direction();
- }
-
const BorderValue& borderAdjoiningTableStart() const
{
- if (hasSameDirectionAsTable())
+ if (hasSameDirectionAs(table()))
return style()->borderStart();
return style()->borderEnd();
@@ -132,12 +127,15 @@
const BorderValue& borderAdjoiningTableEnd() const
{
- if (hasSameDirectionAsTable())
+ if (hasSameDirectionAs(table()))
return style()->borderEnd();
return style()->borderStart();
}
+ const BorderValue& borderAdjoiningStartCell(const RenderTableCell*) const;
+ const BorderValue& borderAdjoiningEndCell(const RenderTableCell*) const;
+
const RenderTableCell* firstRowCellAdjoiningTableStart() const;
const RenderTableCell* firstRowCellAdjoiningTableEnd() const;