Use is<>() / downcast<>() for Table render objects
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 13 Oct 2014 18:21:11 +0000 (18:21 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 13 Oct 2014 18:21:11 +0000 (18:21 +0000)
https://bugs.webkit.org/show_bug.cgi?id=137641

Reviewed by Mihnea Ovidenie.

Use is<>() / downcast<>() for table-related render objects and clean
up the surrounding code.

No new tests, no behavior change.

* accessibility/AccessibilityARIAGrid.cpp:
(WebCore::AccessibilityARIAGrid::addChildren):
* accessibility/AccessibilityTable.cpp:
(WebCore::AccessibilityTable::tableElement):
(WebCore::AccessibilityTable::isDataTable):
(WebCore::AccessibilityTable::isTableExposableThroughAccessibility):
(WebCore::AccessibilityTable::addChildren):
* accessibility/AccessibilityTableCell.cpp:
(WebCore::AccessibilityTableCell::parentTable):
(WebCore::AccessibilityTableCell::rowIndexRange):
(WebCore::AccessibilityTableCell::columnIndexRange):
(WebCore::AccessibilityTableCell::titleUIElement):
* accessibility/AccessibilityTableColumn.cpp:
(WebCore::AccessibilityTableColumn::headerObject):
* editing/DeleteSelectionCommand.cpp:
(WebCore::DeleteSelectionCommand::removeNode):
* editing/TextIterator.cpp:
(WebCore::shouldEmitTabBeforeNode):
(WebCore::shouldEmitNewlinesBeforeAndAfterNode):
* html/HTMLTableCellElement.cpp:
(WebCore::HTMLTableCellElement::parseAttribute):
(WebCore::HTMLTableCellElement::cellAbove):
* html/HTMLTableColElement.cpp:
(WebCore::HTMLTableColElement::parseAttribute):
* mathml/MathMLElement.cpp:
(WebCore::MathMLElement::parseAttribute):
* rendering/AutoTableLayout.cpp:
(WebCore::AutoTableLayout::recalcColumn):
(WebCore::shouldScaleColumns):
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::computeIntrinsicLogicalWidths):
* rendering/RenderBox.cpp:
(WebCore::RenderBox::computePercentageLogicalHeight):
(WebCore::RenderBox::layoutOverflowRectForPropagation):
* rendering/RenderElement.cpp:
(WebCore::RenderElement::addChild):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::calculateClipRects):
* rendering/RenderTable.cpp:
(WebCore::RenderTable::addChild):
(WebCore::RenderTable::layout):
(WebCore::RenderTable::firstColumn):
(WebCore::RenderTable::recalcSections):
(WebCore::RenderTable::sectionAbove):
(WebCore::RenderTable::sectionBelow):
(WebCore::RenderTable::bottomSection):
* rendering/RenderTable.h:
* rendering/RenderTableCaption.cpp:
(WebCore::RenderTableCaption::table):
* rendering/RenderTableCell.h:
(WebCore::RenderTableCell::nextCell):
(WebCore::RenderTableCell::previousCell):
(WebCore::RenderTableRow::firstCell):
(WebCore::RenderTableRow::lastCell):
* rendering/RenderTableCol.cpp:
(WebCore::RenderTableCol::table):
(WebCore::RenderTableCol::enclosingColumnGroup):
(WebCore::RenderTableCol::nextColumn):
* rendering/RenderTableCol.h:
Make updateFromElement() public to allow the callers to use tighter
typing and devitualize the call as the class is final.

* rendering/RenderTableRow.cpp:
(WebCore::RenderTableRow::addChild):
* rendering/RenderTableRow.h:
(WebCore::RenderTableSection::firstRow):
(WebCore::RenderTableSection::lastRow):
(WebCore::RenderTableRow::nextRow):
(WebCore::RenderTableRow::previousRow):
* rendering/RenderTableSection.cpp:
(WebCore::RenderTableSection::addChild):
(WebCore::RenderTableSection::layoutRows):
(WebCore::RenderTableSection::paintCell):
* rendering/RenderTableSection.h:
* rendering/RenderTreeAsText.cpp:
(WebCore::writeTextRun):
(WebCore::writeSimpleLine):

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

26 files changed:
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityARIAGrid.cpp
Source/WebCore/accessibility/AccessibilityTable.cpp
Source/WebCore/accessibility/AccessibilityTableCell.cpp
Source/WebCore/accessibility/AccessibilityTableColumn.cpp
Source/WebCore/editing/DeleteSelectionCommand.cpp
Source/WebCore/editing/TextIterator.cpp
Source/WebCore/html/HTMLTableCellElement.cpp
Source/WebCore/html/HTMLTableColElement.cpp
Source/WebCore/mathml/MathMLElement.cpp
Source/WebCore/rendering/AutoTableLayout.cpp
Source/WebCore/rendering/RenderBlockFlow.cpp
Source/WebCore/rendering/RenderBox.cpp
Source/WebCore/rendering/RenderElement.cpp
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderTable.cpp
Source/WebCore/rendering/RenderTable.h
Source/WebCore/rendering/RenderTableCaption.cpp
Source/WebCore/rendering/RenderTableCell.h
Source/WebCore/rendering/RenderTableCol.cpp
Source/WebCore/rendering/RenderTableCol.h
Source/WebCore/rendering/RenderTableRow.cpp
Source/WebCore/rendering/RenderTableRow.h
Source/WebCore/rendering/RenderTableSection.cpp
Source/WebCore/rendering/RenderTableSection.h
Source/WebCore/rendering/RenderTreeAsText.cpp

index b0b437f..0bdfd20 100644 (file)
@@ -1,3 +1,93 @@
+2014-10-13  Chris Dumez  <cdumez@apple.com>
+
+        Use is<>() / downcast<>() for Table render objects
+        https://bugs.webkit.org/show_bug.cgi?id=137641
+
+        Reviewed by Mihnea Ovidenie.
+
+        Use is<>() / downcast<>() for table-related render objects and clean
+        up the surrounding code.
+
+        No new tests, no behavior change.
+
+        * accessibility/AccessibilityARIAGrid.cpp:
+        (WebCore::AccessibilityARIAGrid::addChildren):
+        * accessibility/AccessibilityTable.cpp:
+        (WebCore::AccessibilityTable::tableElement):
+        (WebCore::AccessibilityTable::isDataTable):
+        (WebCore::AccessibilityTable::isTableExposableThroughAccessibility):
+        (WebCore::AccessibilityTable::addChildren):
+        * accessibility/AccessibilityTableCell.cpp:
+        (WebCore::AccessibilityTableCell::parentTable):
+        (WebCore::AccessibilityTableCell::rowIndexRange):
+        (WebCore::AccessibilityTableCell::columnIndexRange):
+        (WebCore::AccessibilityTableCell::titleUIElement):
+        * accessibility/AccessibilityTableColumn.cpp:
+        (WebCore::AccessibilityTableColumn::headerObject):
+        * editing/DeleteSelectionCommand.cpp:
+        (WebCore::DeleteSelectionCommand::removeNode):
+        * editing/TextIterator.cpp:
+        (WebCore::shouldEmitTabBeforeNode):
+        (WebCore::shouldEmitNewlinesBeforeAndAfterNode):
+        * html/HTMLTableCellElement.cpp:
+        (WebCore::HTMLTableCellElement::parseAttribute):
+        (WebCore::HTMLTableCellElement::cellAbove):
+        * html/HTMLTableColElement.cpp:
+        (WebCore::HTMLTableColElement::parseAttribute):
+        * mathml/MathMLElement.cpp:
+        (WebCore::MathMLElement::parseAttribute):
+        * rendering/AutoTableLayout.cpp:
+        (WebCore::AutoTableLayout::recalcColumn):
+        (WebCore::shouldScaleColumns):
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::computeIntrinsicLogicalWidths):
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::computePercentageLogicalHeight):
+        (WebCore::RenderBox::layoutOverflowRectForPropagation):
+        * rendering/RenderElement.cpp:
+        (WebCore::RenderElement::addChild):
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::calculateClipRects):
+        * rendering/RenderTable.cpp:
+        (WebCore::RenderTable::addChild):
+        (WebCore::RenderTable::layout):
+        (WebCore::RenderTable::firstColumn):
+        (WebCore::RenderTable::recalcSections):
+        (WebCore::RenderTable::sectionAbove):
+        (WebCore::RenderTable::sectionBelow):
+        (WebCore::RenderTable::bottomSection):
+        * rendering/RenderTable.h:
+        * rendering/RenderTableCaption.cpp:
+        (WebCore::RenderTableCaption::table):
+        * rendering/RenderTableCell.h:
+        (WebCore::RenderTableCell::nextCell):
+        (WebCore::RenderTableCell::previousCell):
+        (WebCore::RenderTableRow::firstCell):
+        (WebCore::RenderTableRow::lastCell):
+        * rendering/RenderTableCol.cpp:
+        (WebCore::RenderTableCol::table):
+        (WebCore::RenderTableCol::enclosingColumnGroup):
+        (WebCore::RenderTableCol::nextColumn):
+        * rendering/RenderTableCol.h:
+        Make updateFromElement() public to allow the callers to use tighter
+        typing and devitualize the call as the class is final.
+
+        * rendering/RenderTableRow.cpp:
+        (WebCore::RenderTableRow::addChild):
+        * rendering/RenderTableRow.h:
+        (WebCore::RenderTableSection::firstRow):
+        (WebCore::RenderTableSection::lastRow):
+        (WebCore::RenderTableRow::nextRow):
+        (WebCore::RenderTableRow::previousRow):
+        * rendering/RenderTableSection.cpp:
+        (WebCore::RenderTableSection::addChild):
+        (WebCore::RenderTableSection::layoutRows):
+        (WebCore::RenderTableSection::paintCell):
+        * rendering/RenderTableSection.h:
+        * rendering/RenderTreeAsText.cpp:
+        (WebCore::writeTextRun):
+        (WebCore::writeSimpleLine):
+
 2014-10-08  Jer Noble  <jer.noble@apple.com>
 
         MediaPlayer::characteristicChanged() is not called when new tracks are found in SourceBufferPrivateAVFObjC
 2014-10-08  Jer Noble  <jer.noble@apple.com>
 
         MediaPlayer::characteristicChanged() is not called when new tracks are found in SourceBufferPrivateAVFObjC
index f82c70e..11e21f0 100644 (file)
@@ -117,12 +117,11 @@ void AccessibilityARIAGrid::addChildren()
     for (RefPtr<AccessibilityObject> child = firstChild(); child; child = child->nextSibling()) {
         bool footerSection = false;
         if (RenderObject* childRenderer = child->renderer()) {
     for (RefPtr<AccessibilityObject> child = firstChild(); child; child = child->nextSibling()) {
         bool footerSection = false;
         if (RenderObject* childRenderer = child->renderer()) {
-            if (childRenderer->isTableSection()) {
-                if (RenderTableSection* childSection = toRenderTableSection(childRenderer)) {
-                    if (childSection == childSection->table()->footer()) {
-                        footerSections.append(child);
-                        footerSection = true;
-                    }
+            if (is<RenderTableSection>(*childRenderer)) {
+                RenderTableSection& childSection = downcast<RenderTableSection>(*childRenderer);
+                if (&childSection == childSection.table()->footer()) {
+                    footerSections.append(child);
+                    footerSection = true;
                 }
             }
         }
                 }
             }
         }
index 76df3c6..11ffd14 100644 (file)
@@ -92,16 +92,16 @@ bool AccessibilityTable::isAccessibilityTable() const
 
 HTMLTableElement* AccessibilityTable::tableElement() const
 {
 
 HTMLTableElement* AccessibilityTable::tableElement() const
 {
-    if (!m_renderer->isTable())
+    if (!is<RenderTable>(*m_renderer))
         return nullptr;
     
         return nullptr;
     
-    RenderTable* table = toRenderTable(m_renderer);
-    if (is<HTMLTableElement>(table->element()))
-        return downcast<HTMLTableElement>(table->element());
+    RenderTable& table = downcast<RenderTable>(*m_renderer);
+    if (is<HTMLTableElement>(table.element()))
+        return downcast<HTMLTableElement>(table.element());
     
     // If the table has a display:table-row-group, then the RenderTable does not have a pointer to it's HTMLTableElement.
     // We can instead find it by asking the firstSection for its parent.
     
     // If the table has a display:table-row-group, then the RenderTable does not have a pointer to it's HTMLTableElement.
     // We can instead find it by asking the firstSection for its parent.
-    RenderTableSection* firstBody = table->firstBody();
+    RenderTableSection* firstBody = table.firstBody();
     if (!firstBody || !firstBody->element())
         return nullptr;
     
     if (!firstBody || !firstBody->element())
         return nullptr;
     
@@ -127,16 +127,14 @@ bool AccessibilityTable::isDataTable() const
     if (node() && node()->hasEditableStyle())
         return true;
 
     if (node() && node()->hasEditableStyle())
         return true;
 
-    if (!m_renderer->isTable())
+    if (!is<RenderTable>(*m_renderer))
         return false;
 
     // This employs a heuristic to determine if this table should appear.
     // Only "data" tables should be exposed as tables.
     // Unfortunately, there is no good way to determine the difference
     // between a "layout" table and a "data" table.
         return false;
 
     // This employs a heuristic to determine if this table should appear.
     // Only "data" tables should be exposed as tables.
     // Unfortunately, there is no good way to determine the difference
     // between a "layout" table and a "data" table.
-    RenderTable* table = toRenderTable(m_renderer);
-    HTMLTableElement* tableElement = this->tableElement();
-    if (tableElement) {
+    if (HTMLTableElement* tableElement = this->tableElement()) {
         // If there is a caption element, summary, THEAD, or TFOOT section, it's most certainly a data table.
         if (!tableElement->summary().isEmpty() || tableElement->tHead() || tableElement->tFoot() || tableElement->caption())
             return true;
         // If there is a caption element, summary, THEAD, or TFOOT section, it's most certainly a data table.
         if (!tableElement->summary().isEmpty() || tableElement->tHead() || tableElement->tFoot() || tableElement->caption())
             return true;
@@ -146,16 +144,17 @@ bool AccessibilityTable::isDataTable() const
             return true;
 
         // If there's a colgroup or col element, it's probably a data table.
             return true;
 
         // If there's a colgroup or col element, it's probably a data table.
-        for (const auto& child : childrenOfType<Element>(*tableElement)) {
+        for (const auto& child : childrenOfType<HTMLElement>(*tableElement)) {
             if (child.hasTagName(colTag) || child.hasTagName(colgroupTag))
                 return true;
         }
     }
     
             if (child.hasTagName(colTag) || child.hasTagName(colgroupTag))
                 return true;
         }
     }
     
+    RenderTable& table = downcast<RenderTable>(*m_renderer);
     // go through the cell's and check for tell-tale signs of "data" table status
     // cells have borders, or use attributes like headers, abbr, scope or axis
     // go through the cell's and check for tell-tale signs of "data" table status
     // cells have borders, or use attributes like headers, abbr, scope or axis
-    table->recalcSectionsIfNeeded();
-    RenderTableSection* firstBody = table->firstBody();
+    table.recalcSectionsIfNeeded();
+    RenderTableSection* firstBody = table.firstBody();
     if (!firstBody)
         return false;
     
     if (!firstBody)
         return false;
     
@@ -171,7 +170,7 @@ bool AccessibilityTable::isDataTable() const
         return true;
     
     // Store the background color of the table to check against cell's background colors.
         return true;
     
     // Store the background color of the table to check against cell's background colors.
-    const RenderStyle& tableStyle = table->style();
+    const RenderStyle& tableStyle = table.style();
     Color tableBGColor = tableStyle.visitedDependentColor(CSSPropertyBackgroundColor);
     
     // check enough of the cells to find if the table matches our criteria
     Color tableBGColor = tableStyle.visitedDependentColor(CSSPropertyBackgroundColor);
     
     // check enough of the cells to find if the table matches our criteria
@@ -206,16 +205,16 @@ bool AccessibilityTable::isDataTable() const
             if (cell->width() < 1 || cell->height() < 1)
                 continue;
             
             if (cell->width() < 1 || cell->height() < 1)
                 continue;
             
-            validCellCount++;
+            ++validCellCount;
             
             bool isTHCell = cellElement->hasTagName(thTag);
             // If the first row is comprised of all <th> tags, assume it is a data table.
             if (!row && isTHCell)
             
             bool isTHCell = cellElement->hasTagName(thTag);
             // If the first row is comprised of all <th> tags, assume it is a data table.
             if (!row && isTHCell)
-                headersInFirstRowCount++;
+                ++headersInFirstRowCount;
 
             // If the first column is comprised of all <th> tags, assume it is a data table.
             if (!col && isTHCell)
 
             // If the first column is comprised of all <th> tags, assume it is a data table.
             if (!col && isTHCell)
-                headersInFirstColumnCount++;
+                ++headersInFirstColumnCount;
             
             // In this case, the developer explicitly assigned a "data" table attribute.
             if (is<HTMLTableCellElement>(*cellElement)) {
             
             // In this case, the developer explicitly assigned a "data" table attribute.
             if (is<HTMLTableCellElement>(*cellElement)) {
@@ -233,25 +232,25 @@ bool AccessibilityTable::isDataTable() const
             // If a cell has matching bordered sides, call it a (fully) bordered cell.
             if ((cell->borderTop() > 0 && cell->borderBottom() > 0)
                 || (cell->borderLeft() > 0 && cell->borderRight() > 0))
             // If a cell has matching bordered sides, call it a (fully) bordered cell.
             if ((cell->borderTop() > 0 && cell->borderBottom() > 0)
                 || (cell->borderLeft() > 0 && cell->borderRight() > 0))
-                borderedCellCount++;
+                ++borderedCellCount;
 
             // Also keep track of each individual border, so we can catch tables where most
             // cells have a bottom border, for example.
             if (cell->borderTop() > 0)
 
             // Also keep track of each individual border, so we can catch tables where most
             // cells have a bottom border, for example.
             if (cell->borderTop() > 0)
-                cellsWithTopBorder++;
+                ++cellsWithTopBorder;
             if (cell->borderBottom() > 0)
             if (cell->borderBottom() > 0)
-                cellsWithBottomBorder++;
+                ++cellsWithBottomBorder;
             if (cell->borderLeft() > 0)
             if (cell->borderLeft() > 0)
-                cellsWithLeftBorder++;
+                ++cellsWithLeftBorder;
             if (cell->borderRight() > 0)
             if (cell->borderRight() > 0)
-                cellsWithRightBorder++;
+                ++cellsWithRightBorder;
             
             // If the cell has a different color from the table and there is cell spacing,
             // then it is probably a data table cell (spacing and colors take the place of borders).
             Color cellColor = renderStyle.visitedDependentColor(CSSPropertyBackgroundColor);
             
             // If the cell has a different color from the table and there is cell spacing,
             // then it is probably a data table cell (spacing and colors take the place of borders).
             Color cellColor = renderStyle.visitedDependentColor(CSSPropertyBackgroundColor);
-            if (table->hBorderSpacing() > 0 && table->vBorderSpacing() > 0
+            if (table.hBorderSpacing() > 0 && table.vBorderSpacing() > 0
                 && tableBGColor != cellColor && cellColor.alpha() != 1)
                 && tableBGColor != cellColor && cellColor.alpha() != 1)
-                backgroundDifferenceCellCount++;
+                ++backgroundDifferenceCellCount;
             
             // If we've found 10 "good" cells, we don't need to keep searching.
             if (borderedCellCount >= 10 || backgroundDifferenceCellCount >= 10)
             
             // If we've found 10 "good" cells, we don't need to keep searching.
             if (borderedCellCount >= 10 || backgroundDifferenceCellCount >= 10)
@@ -327,7 +326,7 @@ bool AccessibilityTable::isTableExposableThroughAccessibility() const
 
     // Gtk+ ATs expect all tables to be exposed as tables.
 #if PLATFORM(GTK) || PLATFORM(EFL)
 
     // Gtk+ ATs expect all tables to be exposed as tables.
 #if PLATFORM(GTK) || PLATFORM(EFL)
-    Element* tableNode = toRenderTable(m_renderer)->element();
+    Element* tableNode = downcast<RenderTable>(*m_renderer).element();
     return is<HTMLTableElement>(tableNode);
 #endif
 
     return is<HTMLTableElement>(tableNode);
 #endif
 
@@ -356,17 +355,17 @@ void AccessibilityTable::addChildren()
     ASSERT(!m_haveChildren); 
     
     m_haveChildren = true;
     ASSERT(!m_haveChildren); 
     
     m_haveChildren = true;
-    if (!m_renderer || !m_renderer->isTable())
+    if (!is<RenderTable>(m_renderer))
         return;
     
         return;
     
-    RenderTable* table = toRenderTable(m_renderer);
+    RenderTable& table = downcast<RenderTable>(*m_renderer);
     // Go through all the available sections to pull out the rows and add them as children.
     // Go through all the available sections to pull out the rows and add them as children.
-    table->recalcSectionsIfNeeded();
+    table.recalcSectionsIfNeeded();
     
     unsigned maxColumnCount = 0;
     
     unsigned maxColumnCount = 0;
-    RenderTableSection* footer = table->footer();
+    RenderTableSection* footer = table.footer();
     
     
-    for (RenderTableSection* tableSection = table->topSection(); tableSection; tableSection = table->sectionBelow(tableSection, SkipEmptySections)) {
+    for (RenderTableSection* tableSection = table.topSection(); tableSection; tableSection = table.sectionBelow(tableSection, SkipEmptySections)) {
         if (tableSection == footer)
             continue;
         addChildrenFromSection(tableSection, maxColumnCount);
         if (tableSection == footer)
             continue;
         addChildrenFromSection(tableSection, maxColumnCount);
index 948cd77..d5833f0 100644 (file)
@@ -75,7 +75,7 @@ bool AccessibilityTableCell::computeAccessibilityIsIgnored() const
 
 AccessibilityTable* AccessibilityTableCell::parentTable() const
 {
 
 AccessibilityTable* AccessibilityTableCell::parentTable() const
 {
-    if (!m_renderer || !m_renderer->isTableCell())
+    if (!is<RenderTableCell>(m_renderer))
         return nullptr;
 
     // If the document no longer exists, we might not have an axObjectCache.
         return nullptr;
 
     // If the document no longer exists, we might not have an axObjectCache.
@@ -87,7 +87,7 @@ AccessibilityTable* AccessibilityTableCell::parentTable() const
     // By using only get() implies that the AXTable must be created before AXTableCells. This should
     // always be the case when AT clients access a table.
     // https://bugs.webkit.org/show_bug.cgi?id=42652
     // By using only get() implies that the AXTable must be created before AXTableCells. This should
     // always be the case when AT clients access a table.
     // https://bugs.webkit.org/show_bug.cgi?id=42652
-    AccessibilityObject* parentTable = axObjectCache()->get(toRenderTableCell(m_renderer)->table());
+    AccessibilityObject* parentTable = axObjectCache()->get(downcast<RenderTableCell>(*m_renderer).table());
     if (!parentTable || !parentTable->isTable())
         return nullptr;
     return toAccessibilityTable(parentTable);
     if (!parentTable || !parentTable->isTable())
         return nullptr;
     return toAccessibilityTable(parentTable);
@@ -224,16 +224,16 @@ void AccessibilityTableCell::rowHeaders(AccessibilityChildrenVector& headers)
     
 void AccessibilityTableCell::rowIndexRange(std::pair<unsigned, unsigned>& rowRange)
 {
     
 void AccessibilityTableCell::rowIndexRange(std::pair<unsigned, unsigned>& rowRange)
 {
-    if (!m_renderer || !m_renderer->isTableCell())
+    if (!is<RenderTableCell>(m_renderer))
         return;
     
         return;
     
-    RenderTableCell* renderCell = toRenderTableCell(m_renderer);
-    rowRange.first = renderCell->rowIndex();
-    rowRange.second = renderCell->rowSpan();
+    RenderTableCell& renderCell = downcast<RenderTableCell>(*m_renderer);
+    rowRange.first = renderCell.rowIndex();
+    rowRange.second = renderCell.rowSpan();
     
     // since our table might have multiple sections, we have to offset our row appropriately
     
     // since our table might have multiple sections, we have to offset our row appropriately
-    RenderTableSection* section = renderCell->section();
-    RenderTable* table = renderCell->table();
+    RenderTableSection* section = renderCell.section();
+    RenderTable* table = renderCell.table();
     if (!table || !section)
         return;
 
     if (!table || !section)
         return;
 
@@ -253,10 +253,10 @@ void AccessibilityTableCell::rowIndexRange(std::pair<unsigned, unsigned>& rowRan
     
 void AccessibilityTableCell::columnIndexRange(std::pair<unsigned, unsigned>& columnRange)
 {
     
 void AccessibilityTableCell::columnIndexRange(std::pair<unsigned, unsigned>& columnRange)
 {
-    if (!m_renderer || !m_renderer->isTableCell())
+    if (!is<RenderTableCell>(m_renderer))
         return;
     
         return;
     
-    const RenderTableCell& cell = *toRenderTableCell(m_renderer);
+    const RenderTableCell& cell = downcast<RenderTableCell>(*m_renderer);
     columnRange.first = cell.table()->colToEffCol(cell.col());
     columnRange.second = cell.table()->colToEffCol(cell.col() + cell.colSpan()) - columnRange.first;
 }
     columnRange.first = cell.table()->colToEffCol(cell.col());
     columnRange.second = cell.table()->colToEffCol(cell.col() + cell.colSpan()) - columnRange.first;
 }
@@ -266,7 +266,7 @@ AccessibilityObject* AccessibilityTableCell::titleUIElement() const
     // Try to find if the first cell in this row is a <th>. If it is,
     // then it can act as the title ui element. (This is only in the
     // case when the table is not appearing as an AXTable.)
     // Try to find if the first cell in this row is a <th>. If it is,
     // then it can act as the title ui element. (This is only in the
     // case when the table is not appearing as an AXTable.)
-    if (isTableCell() || !m_renderer || !m_renderer->isTableCell())
+    if (isTableCell() || !is<RenderTableCell>(m_renderer))
         return nullptr;
 
     // Table cells that are th cannot have title ui elements, since by definition
         return nullptr;
 
     // Table cells that are th cannot have title ui elements, since by definition
@@ -275,21 +275,21 @@ AccessibilityObject* AccessibilityTableCell::titleUIElement() const
     if (node && node->hasTagName(thTag))
         return nullptr;
     
     if (node && node->hasTagName(thTag))
         return nullptr;
     
-    RenderTableCell* renderCell = toRenderTableCell(m_renderer);
+    RenderTableCell& renderCell = downcast<RenderTableCell>(*m_renderer);
 
     // If this cell is in the first column, there is no need to continue.
 
     // If this cell is in the first column, there is no need to continue.
-    int col = renderCell->col();
+    int col = renderCell.col();
     if (!col)
         return nullptr;
 
     if (!col)
         return nullptr;
 
-    int row = renderCell->rowIndex();
+    int row = renderCell.rowIndex();
 
 
-    RenderTableSection* section = renderCell->section();
+    RenderTableSection* section = renderCell.section();
     if (!section)
         return nullptr;
     
     RenderTableCell* headerCell = section->primaryCellAt(row, 0);
     if (!section)
         return nullptr;
     
     RenderTableCell* headerCell = section->primaryCellAt(row, 0);
-    if (!headerCell || headerCell == renderCell)
+    if (!headerCell || headerCell == &renderCell)
         return nullptr;
 
     if (!headerCell->element() || !headerCell->element()->hasTagName(thTag))
         return nullptr;
 
     if (!headerCell->element() || !headerCell->element()->hasTagName(thTag))
index 78b6d5f..0b3116d 100644 (file)
@@ -89,23 +89,17 @@ AccessibilityObject* AccessibilityTableColumn::headerObject()
         return nullptr;
     }
 
         return nullptr;
     }
 
-    if (!renderer->isTable())
+    if (!is<RenderTable>(*renderer))
         return nullptr;
     
         return nullptr;
     
-    RenderTable* table = toRenderTable(renderer);
-    
-    AccessibilityObject* headerObject = nullptr;
-    
-    // try the <thead> section first. this doesn't require th tags
-    headerObject = headerObjectForSection(table->header(), false);
+    RenderTable& table = downcast<RenderTable>(*renderer);
 
 
-    if (headerObject)
+    // try the <thead> section first. this doesn't require th tags
+    if (auto* headerObject = headerObjectForSection(table.header(), false))
         return headerObject;
     
     // now try for <th> tags in the first body
         return headerObject;
     
     // now try for <th> tags in the first body
-    headerObject = headerObjectForSection(table->firstBody(), true);
-
-    return headerObject;
+    return headerObjectForSection(table.firstBody(), true);
 }
 
 AccessibilityObject* AccessibilityTableColumn::headerObjectForSection(RenderTableSection* section, bool thTagRequired)
 }
 
 AccessibilityObject* AccessibilityTableColumn::headerObjectForSection(RenderTableSection* section, bool thTagRequired)
index eeca943..a107e69 100644 (file)
@@ -386,8 +386,8 @@ void DeleteSelectionCommand::removeNode(PassRefPtr<Node> node, ShouldAssumeConte
         
         // Make sure empty cell has some height, if a placeholder can be inserted.
         document().updateLayoutIgnorePendingStylesheets();
         
         // Make sure empty cell has some height, if a placeholder can be inserted.
         document().updateLayoutIgnorePendingStylesheets();
-        RenderObject *r = node->renderer();
-        if (r && r->isTableCell() && toRenderTableCell(r)->contentHeight() <= 0) {
+        RenderObject* renderer = node->renderer();
+        if (is<RenderTableCell>(renderer) && downcast<RenderTableCell>(*renderer).contentHeight() <= 0) {
             Position firstEditablePosition = firstEditablePositionInNode(node.get());
             if (firstEditablePosition.isNotNull())
                 insertBlockPlaceholder(firstEditablePosition);
             Position firstEditablePosition = firstEditablePositionInNode(node.get());
             if (firstEditablePosition.isNotNull())
                 insertBlockPlaceholder(firstEditablePosition);
index 6be9723..9c0d646 100644 (file)
@@ -785,7 +785,7 @@ static bool shouldEmitTabBeforeNode(Node& node)
         return false;
     
     // Want a tab before every cell other than the first one.
         return false;
     
     // Want a tab before every cell other than the first one.
-    RenderTableCell& cell = toRenderTableCell(*renderer);
+    RenderTableCell& cell = downcast<RenderTableCell>(*renderer);
     RenderTable* table = cell.table();
     return table && (table->cellBefore(&cell) || table->cellAbove(&cell));
 }
     RenderTable* table = cell.table();
     return table && (table->cellBefore(&cell) || table->cellAbove(&cell));
 }
@@ -840,14 +840,14 @@ static bool shouldEmitNewlinesBeforeAndAfterNode(Node& node)
     
     // Need to make an exception for table row elements, because they are neither
     // "inline" or "RenderBlock", but we want newlines for them.
     
     // Need to make an exception for table row elements, because they are neither
     // "inline" or "RenderBlock", but we want newlines for them.
-    if (renderer->isTableRow()) {
-        RenderTable* table = toRenderTableRow(*renderer).table();
+    if (is<RenderTableRow>(*renderer)) {
+        RenderTable* table = downcast<RenderTableRow>(*renderer).table();
         if (table && !table->isInline())
             return true;
     }
     
     return !renderer->isInline()
         if (table && !table->isInline())
             return true;
     }
     
     return !renderer->isInline()
-        && renderer->isRenderBlock()
+        && is<RenderBlock>(*renderer)
         && !renderer->isFloatingOrOutOfFlowPositioned()
         && !renderer->isBody()
         && !renderer->isRubyText();
         && !renderer->isFloatingOrOutOfFlowPositioned()
         && !renderer->isBody()
         && !renderer->isRubyText();
index 1f99789..00f47cd 100644 (file)
@@ -105,11 +105,11 @@ void HTMLTableCellElement::collectStyleForPresentationAttribute(const QualifiedN
 void HTMLTableCellElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
 {
     if (name == rowspanAttr) {
 void HTMLTableCellElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
 {
     if (name == rowspanAttr) {
-        if (renderer() && renderer()->isTableCell())
-            toRenderTableCell(renderer())->colSpanOrRowSpanChanged();
+        if (is<RenderTableCell>(renderer()))
+            downcast<RenderTableCell>(*renderer()).colSpanOrRowSpanChanged();
     } else if (name == colspanAttr) {
     } else if (name == colspanAttr) {
-        if (renderer() && renderer()->isTableCell())
-            toRenderTableCell(renderer())->colSpanOrRowSpanChanged();
+        if (is<RenderTableCell>(renderer()))
+            downcast<RenderTableCell>(*renderer()).colSpanOrRowSpanChanged();
     } else
         HTMLTablePartElement::parseAttribute(name, value);
 }
     } else
         HTMLTablePartElement::parseAttribute(name, value);
 }
@@ -165,12 +165,12 @@ void HTMLTableCellElement::addSubresourceAttributeURLs(ListHashSet<URL>& urls) c
 
 HTMLTableCellElement* HTMLTableCellElement::cellAbove() const
 {
 
 HTMLTableCellElement* HTMLTableCellElement::cellAbove() const
 {
-    auto cellRenderer = renderer();
-    if (!cellRenderer || !cellRenderer->isTableCell())
+    auto* cellRenderer = renderer();
+    if (!is<RenderTableCell>(cellRenderer))
         return nullptr;
 
         return nullptr;
 
-    auto tableCellRenderer = toRenderTableCell(cellRenderer);
-    auto cellAboveRenderer = tableCellRenderer->table()->cellAbove(tableCellRenderer);
+    auto& tableCellRenderer = downcast<RenderTableCell>(*cellRenderer);
+    auto* cellAboveRenderer = tableCellRenderer.table()->cellAbove(&tableCellRenderer);
     if (!cellAboveRenderer)
         return nullptr;
 
     if (!cellAboveRenderer)
         return nullptr;
 
index 016899f..9fac7a8 100644 (file)
@@ -67,15 +67,15 @@ void HTMLTableColElement::parseAttribute(const QualifiedName& name, const Atomic
     if (name == spanAttr) {
         int newSpan = value.toInt();
         m_span = newSpan ? newSpan : 1;
     if (name == spanAttr) {
         int newSpan = value.toInt();
         m_span = newSpan ? newSpan : 1;
-        if (renderer() && renderer()->isRenderTableCol())
-            renderer()->updateFromElement();
+        if (is<RenderTableCol>(renderer()))
+            downcast<RenderTableCol>(*renderer()).updateFromElement();
     } else if (name == widthAttr) {
         if (!value.isEmpty()) {
     } else if (name == widthAttr) {
         if (!value.isEmpty()) {
-            if (renderer() && renderer()->isRenderTableCol()) {
-                RenderTableCol* col = toRenderTableCol(renderer());
+            if (is<RenderTableCol>(renderer())) {
+                RenderTableCol& col = downcast<RenderTableCol>(*renderer());
                 int newWidth = width().toInt();
                 int newWidth = width().toInt();
-                if (newWidth != col->width())
-                    col->setNeedsLayoutAndPrefWidthsRecalc();
+                if (newWidth != col.width())
+                    col.setNeedsLayoutAndPrefWidthsRecalc();
             }
         }
     } else
             }
         }
     } else
index 03a1906..229e0ea 100644 (file)
@@ -212,11 +212,11 @@ int MathMLElement::rowSpan() const
 void MathMLElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
 {
     if (name == rowspanAttr) {
 void MathMLElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
 {
     if (name == rowspanAttr) {
-        if (renderer() && renderer()->isTableCell() && hasTagName(mtdTag))
-            toRenderTableCell(renderer())->colSpanOrRowSpanChanged();
+        if (is<RenderTableCell>(renderer()) && hasTagName(mtdTag))
+            downcast<RenderTableCell>(*renderer()).colSpanOrRowSpanChanged();
     } else if (name == columnspanAttr) {
     } else if (name == columnspanAttr) {
-        if (renderer() && renderer()->isTableCell() && hasTagName(mtdTag))
-            toRenderTableCell(renderer())->colSpanOrRowSpanChanged();
+        if (is<RenderTableCell>(renderer()) && hasTagName(mtdTag))
+            downcast<RenderTableCell>(renderer())->colSpanOrRowSpanChanged();
     } else
         StyledElement::parseAttribute(name, value);
 }
     } else
         StyledElement::parseAttribute(name, value);
 }
index 69acb98..4d88362 100644 (file)
@@ -26,6 +26,7 @@
 #include "RenderTableCell.h"
 #include "RenderTableCol.h"
 #include "RenderTableSection.h"
 #include "RenderTableCell.h"
 #include "RenderTableCol.h"
 #include "RenderTableSection.h"
+#include "RenderView.h"
 
 namespace WebCore {
 
 
 namespace WebCore {
 
@@ -44,20 +45,20 @@ void AutoTableLayout::recalcColumn(unsigned effCol)
 {
     Layout& columnLayout = m_layoutStruct[effCol];
 
 {
     Layout& columnLayout = m_layoutStruct[effCol];
 
-    RenderTableCell* fixedContributor = 0;
-    RenderTableCell* maxContributor = 0;
+    RenderTableCell* fixedContributor = nullptr;
+    RenderTableCell* maxContributor = nullptr;
 
     for (RenderObject* child = m_table->firstChild(); child; child = child->nextSibling()) {
 
     for (RenderObject* child = m_table->firstChild(); child; child = child->nextSibling()) {
-        if (child->isRenderTableCol()){
+        if (is<RenderTableCol>(*child)) {
             // RenderTableCols don't have the concept of preferred logical width, but we need to clear their dirty bits
             // so that if we call setPreferredWidthsDirty(true) on a col or one of its descendants, we'll mark it's
             // ancestors as dirty.
             // RenderTableCols don't have the concept of preferred logical width, but we need to clear their dirty bits
             // so that if we call setPreferredWidthsDirty(true) on a col or one of its descendants, we'll mark it's
             // ancestors as dirty.
-            toRenderTableCol(child)->clearPreferredLogicalWidthsDirtyBits();
-        } else if (child->isTableSection()) {
-            RenderTableSection* section = toRenderTableSection(child);
-            unsigned numRows = section->numRows();
-            for (unsigned i = 0; i < numRows; i++) {
-                RenderTableSection::CellStruct current = section->cellAt(i, effCol);
+            downcast<RenderTableCol>(*child).clearPreferredLogicalWidthsDirtyBits();
+        } else if (is<RenderTableSection>(*child)) {
+            RenderTableSection& section = downcast<RenderTableSection>(*child);
+            unsigned numRows = section.numRows();
+            for (unsigned i = 0; i < numRows; ++i) {
+                RenderTableSection::CellStruct current = section.cellAt(i, effCol);
                 RenderTableCell* cell = current.primaryCell();
                 
                 if (current.inColSpan || !cell)
                 RenderTableCell* cell = current.primaryCell();
                 
                 if (current.inColSpan || !cell)
@@ -120,7 +121,7 @@ void AutoTableLayout::recalcColumn(unsigned effCol)
                     default:
                         break;
                     }
                     default:
                         break;
                     }
-                } else if (!effCol || section->primaryCellAt(i, effCol - 1) != cell) {
+                } else if (!effCol || section.primaryCellAt(i, effCol - 1) != cell) {
                     // This spanning cell originates in this column. Insert the cell into spanning cells list.
                     insertSpanCell(cell);
                 }
                     // This spanning cell originates in this column. Insert the cell into spanning cells list.
                     insertSpanCell(cell);
                 }
@@ -132,7 +133,7 @@ void AutoTableLayout::recalcColumn(unsigned effCol)
     if (columnLayout.logicalWidth.isFixed()) {
         if (m_table->document().inQuirksMode() && columnLayout.maxLogicalWidth > columnLayout.logicalWidth.value() && fixedContributor != maxContributor) {
             columnLayout.logicalWidth = Length();
     if (columnLayout.logicalWidth.isFixed()) {
         if (m_table->document().inQuirksMode() && columnLayout.maxLogicalWidth > columnLayout.logicalWidth.value() && fixedContributor != maxContributor) {
             columnLayout.logicalWidth = Length();
-            fixedContributor = 0;
+            fixedContributor = nullptr;
         }
     }
 
         }
     }
 
@@ -186,25 +187,25 @@ static bool shouldScaleColumns(RenderTable* table)
     // a cell, then don't bloat the maxwidth by examining percentage growth.
     bool scale = true;
     while (table) {
     // a cell, then don't bloat the maxwidth by examining percentage growth.
     bool scale = true;
     while (table) {
-        Length tw = table->style().width();
-        if ((tw.isAuto() || tw.isPercent()) && !table->isOutOfFlowPositioned()) {
-            RenderBlock* cb = table->containingBlock();
-            while (cb && !cb->isRenderView() && !cb->isTableCell() &&
-                cb->style().width().isAuto() && !cb->isOutOfFlowPositioned())
-                cb = cb->containingBlock();
-
-            table = 0;
-            if (cb && cb->isTableCell() &&
-                (cb->style().width().isAuto() || cb->style().width().isPercent())) {
-                RenderTableCell* cell = toRenderTableCell(cb);
-                if (cell->colSpan() > 1 || cell->table()->style().width().isAuto())
+        Length tableWidth = table->style().width();
+        if ((tableWidth.isAuto() || tableWidth.isPercent()) && !table->isOutOfFlowPositioned()) {
+            RenderBlock* containingBlock = table->containingBlock();
+            while (containingBlock && !is<RenderView>(*containingBlock) && !is<RenderTableCell>(*containingBlock)
+                && containingBlock->style().width().isAuto() && !containingBlock->isOutOfFlowPositioned())
+                containingBlock = containingBlock->containingBlock();
+
+            table = nullptr;
+            if (is<RenderTableCell>(containingBlock)
+                && (containingBlock->style().width().isAuto() || containingBlock->style().width().isPercent())) {
+                RenderTableCell& cell = downcast<RenderTableCell>(*containingBlock);
+                if (cell.colSpan() > 1 || cell.table()->style().width().isAuto())
                     scale = false;
                 else
                     scale = false;
                 else
-                    table = cell->table();
+                    table = cell.table();
             }
         }
         else
             }
         }
         else
-            table = 0;
+            table = nullptr;
     }
     return scale;
 }
     }
     return scale;
 }
index dccd68d..f0eeb01 100644 (file)
@@ -368,8 +368,8 @@ void RenderBlockFlow::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth,
             minLogicalWidth = 0;
     }
 
             minLogicalWidth = 0;
     }
 
-    if (isTableCell()) {
-        Length tableCellWidth = toRenderTableCell(this)->styleOrColLogicalWidth();
+    if (is<RenderTableCell>(*this)) {
+        Length tableCellWidth = downcast<RenderTableCell>(*this).styleOrColLogicalWidth();
         if (tableCellWidth.isFixed() && tableCellWidth.value() > 0)
             maxLogicalWidth = std::max(minLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(tableCellWidth.value()));
     }
         if (tableCellWidth.isFixed() && tableCellWidth.value() > 0)
             maxLogicalWidth = std::max(minLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(tableCellWidth.value()));
     }
index d6b3140..05ccd3a 100644 (file)
@@ -2812,7 +2812,7 @@ LayoutUnit RenderBox::computePercentageLogicalHeight(const Length& height) const
     else if (hasOverrideContainingBlockLogicalHeight())
         availableHeight = overrideContainingBlockContentLogicalHeight();
 #endif
     else if (hasOverrideContainingBlockLogicalHeight())
         availableHeight = overrideContainingBlockContentLogicalHeight();
 #endif
-    else if (cb->isTableCell()) {
+    else if (is<RenderTableCell>(*cb)) {
         if (!skippedAutoHeightContainingBlock) {
             // Table cells violate what the CSS spec says to do with heights. Basically we
             // don't care if the cell specified a height or not. We just always make ourselves
         if (!skippedAutoHeightContainingBlock) {
             // Table cells violate what the CSS spec says to do with heights. Basically we
             // don't care if the cell specified a height or not. We just always make ourselves
@@ -2825,8 +2825,8 @@ LayoutUnit RenderBox::computePercentageLogicalHeight(const Length& height) const
                 // no size and allow the flexing of the table or the cell to its specified height to cause us
                 // to grow to fill the space. This could end up being wrong in some cases, but it is
                 // preferable to the alternative (sizing intrinsically and making the row end up too big).
                 // no size and allow the flexing of the table or the cell to its specified height to cause us
                 // to grow to fill the space. This could end up being wrong in some cases, but it is
                 // preferable to the alternative (sizing intrinsically and making the row end up too big).
-                RenderTableCell* cell = toRenderTableCell(cb);
-                if (scrollsOverflowY() && (!cell->style().logicalHeight().isAuto() || !cell->table()->style().logicalHeight().isAuto()))
+                RenderTableCell& cell = downcast<RenderTableCell>(*cb);
+                if (scrollsOverflowY() && (!cell.style().logicalHeight().isAuto() || !cell.table()->style().logicalHeight().isAuto()))
                     return 0;
                 return -1;
             }
                     return 0;
                 return -1;
             }
@@ -4740,18 +4740,18 @@ bool RenderBox::hasRelativeLogicalHeight() const
             || style().logicalMaxHeight().isPercent();
 }
 
             || style().logicalMaxHeight().isPercent();
 }
 
-static void markBoxForRelayoutAfterSplit(RenderBox* box)
+static void markBoxForRelayoutAfterSplit(RenderBox& box)
 {
     // FIXME: The table code should handle that automatically. If not,
     // we should fix it and remove the table part checks.
 {
     // FIXME: The table code should handle that automatically. If not,
     // we should fix it and remove the table part checks.
-    if (box->isTable()) {
+    if (is<RenderTable>(box)) {
         // Because we may have added some sections with already computed column structures, we need to
         // sync the table structure with them now. This avoids crashes when adding new cells to the table.
         // Because we may have added some sections with already computed column structures, we need to
         // sync the table structure with them now. This avoids crashes when adding new cells to the table.
-        toRenderTable(box)->forceSectionsRecalc();
-    } else if (box->isTableSection())
-        toRenderTableSection(box)->setNeedsCellRecalc();
+        downcast<RenderTable>(box).forceSectionsRecalc();
+    } else if (is<RenderTableSection>(box))
+        downcast<RenderTableSection>(box).setNeedsCellRecalc();
 
 
-    box->setNeedsLayoutAndPrefWidthsRecalc();
+    box.setNeedsLayoutAndPrefWidthsRecalc();
 }
 
 RenderObject* RenderBox::splitAnonymousBoxesAroundChild(RenderObject* beforeChild)
 }
 
 RenderObject* RenderBox::splitAnonymousBoxesAroundChild(RenderObject* beforeChild)
@@ -4771,12 +4771,12 @@ RenderObject* RenderBox::splitAnonymousBoxesAroundChild(RenderObject* beforeChil
             // We need to invalidate the |parentBox| before inserting the new node
             // so that the table repainting logic knows the structure is dirty.
             // See for example RenderTableCell:clippedOverflowRectForRepaint.
             // We need to invalidate the |parentBox| before inserting the new node
             // so that the table repainting logic knows the structure is dirty.
             // See for example RenderTableCell:clippedOverflowRectForRepaint.
-            markBoxForRelayoutAfterSplit(parentBox);
+            markBoxForRelayoutAfterSplit(*parentBox);
             parentBox->insertChildInternal(postBox, boxToSplit->nextSibling(), NotifyChildren);
             boxToSplit->moveChildrenTo(postBox, beforeChild, 0, true);
 
             parentBox->insertChildInternal(postBox, boxToSplit->nextSibling(), NotifyChildren);
             boxToSplit->moveChildrenTo(postBox, beforeChild, 0, true);
 
-            markBoxForRelayoutAfterSplit(boxToSplit);
-            markBoxForRelayoutAfterSplit(postBox);
+            markBoxForRelayoutAfterSplit(*boxToSplit);
+            markBoxForRelayoutAfterSplit(*postBox);
 
             beforeChild = postBox;
         } else
 
             beforeChild = postBox;
         } else
@@ -4784,7 +4784,7 @@ RenderObject* RenderBox::splitAnonymousBoxesAroundChild(RenderObject* beforeChil
     }
 
     if (didSplitParentAnonymousBoxes)
     }
 
     if (didSplitParentAnonymousBoxes)
-        markBoxForRelayoutAfterSplit(this);
+        markBoxForRelayoutAfterSplit(*this);
 
     ASSERT(beforeChild->parent() == this);
     return beforeChild;
 
     ASSERT(beforeChild->parent() == this);
     return beforeChild;
index 130923e..fbec04a 100644 (file)
@@ -468,24 +468,24 @@ void RenderElement::addChild(RenderObject* newChild, RenderObject* beforeChild)
 {
     bool needsTable = false;
 
 {
     bool needsTable = false;
 
-    if (newChild->isRenderTableCol()) {
-        RenderTableCol* newTableColumn = toRenderTableCol(newChild);
-        bool isColumnInColumnGroup = newTableColumn->isTableColumn() && isRenderTableCol();
-        needsTable = !isTable() && !isColumnInColumnGroup;
-    } else if (newChild->isTableCaption())
-        needsTable = !isTable();
-    else if (newChild->isTableSection())
-        needsTable = !isTable();
-    else if (newChild->isTableRow())
-        needsTable = !isTableSection();
-    else if (newChild->isTableCell())
-        needsTable = !isTableRow();
+    if (is<RenderTableCol>(*newChild)) {
+        RenderTableCol& newTableColumn = downcast<RenderTableCol>(*newChild);
+        bool isColumnInColumnGroup = newTableColumn.isTableColumn() && is<RenderTableCol>(*this);
+        needsTable = !is<RenderTable>(*this) && !isColumnInColumnGroup;
+    } else if (is<RenderTableCaption>(*newChild))
+        needsTable = !is<RenderTable>(*this);
+    else if (is<RenderTableSection>(*newChild))
+        needsTable = !is<RenderTable>(*this);
+    else if (is<RenderTableRow>(*newChild))
+        needsTable = !is<RenderTableSection>(*this);
+    else if (is<RenderTableCell>(*newChild))
+        needsTable = !is<RenderTableRow>(*this);
 
     if (needsTable) {
         RenderTable* table;
         RenderObject* afterChild = beforeChild ? beforeChild->previousSibling() : m_lastChild;
 
     if (needsTable) {
         RenderTable* table;
         RenderObject* afterChild = beforeChild ? beforeChild->previousSibling() : m_lastChild;
-        if (afterChild && afterChild->isAnonymous() && afterChild->isTable() && !afterChild->isBeforeContent())
-            table = toRenderTable(afterChild);
+        if (afterChild && afterChild->isAnonymous() && is<RenderTable>(*afterChild) && !afterChild->isBeforeContent())
+            table = downcast<RenderTable>(afterChild);
         else {
             table = RenderTable::createAnonymousWithParentRenderer(this);
             addChild(table, beforeChild);
         else {
             table = RenderTable::createAnonymousWithParentRenderer(this);
             addChild(table, beforeChild);
@@ -494,7 +494,7 @@ void RenderElement::addChild(RenderObject* newChild, RenderObject* beforeChild)
     } else
         insertChildInternal(newChild, beforeChild, NotifyChildren);
 
     } else
         insertChildInternal(newChild, beforeChild, NotifyChildren);
 
-    if (is<RenderText>(newChild))
+    if (is<RenderText>(*newChild))
         downcast<RenderText>(*newChild).styleDidChange(StyleDifferenceEqual, nullptr);
 
     // SVG creates renderers for <g display="none">, as SVG requires children of hidden
         downcast<RenderText>(*newChild).styleDidChange(StyleDifferenceEqual, nullptr);
 
     // SVG creates renderers for <g display="none">, as SVG requires children of hidden
@@ -506,7 +506,7 @@ void RenderElement::addChild(RenderObject* newChild, RenderObject* beforeChild)
     // To avoid the problem alltogether, detect early if we're inside a hidden SVG subtree
     // and stop creating layers at all for these cases - they're not used anyways.
     if (newChild->hasLayer() && !layerCreationAllowedForSubtree())
     // To avoid the problem alltogether, detect early if we're inside a hidden SVG subtree
     // and stop creating layers at all for these cases - they're not used anyways.
     if (newChild->hasLayer() && !layerCreationAllowedForSubtree())
-        toRenderLayerModelObject(newChild)->layer()->removeOnlyThisLayer();
+        downcast<RenderLayerModelObject>(*newChild).layer()->removeOnlyThisLayer();
 
     SVGRenderSupport::childAdded(*this, *newChild);
 }
 
     SVGRenderSupport::childAdded(*this, *newChild);
 }
index bd86aea..44f242f 100644 (file)
@@ -5622,8 +5622,8 @@ LayoutRect RenderLayer::localBoundingBox(CalculateLayerBoundsFlags flags) const
     LayoutRect result;
     if (renderer().isInline() && renderer().isRenderInline())
         result = toRenderInline(renderer()).linesVisualOverflowBoundingBox();
     LayoutRect result;
     if (renderer().isInline() && renderer().isRenderInline())
         result = toRenderInline(renderer()).linesVisualOverflowBoundingBox();
-    else if (renderer().isTableRow()) {
-        RenderTableRow& tableRow = toRenderTableRow(renderer());
+    else if (is<RenderTableRow>(renderer())) {
+        RenderTableRow& tableRow = downcast<RenderTableRow>(renderer());
         // Our bounding box is just the union of all of our cells' border/overflow rects.
         for (RenderTableCell* cell = tableRow.firstCell(); cell; cell = cell->nextCell()) {
             LayoutRect bbox = cell->borderBoxRect();
         // Our bounding box is just the union of all of our cells' border/overflow rects.
         for (RenderTableCell* cell = tableRow.firstCell(); cell; cell = cell->nextCell()) {
             LayoutRect bbox = cell->borderBoxRect();
index d11ee6c..f8293a9 100644 (file)
@@ -139,28 +139,28 @@ void RenderTable::addChild(RenderObject* child, RenderObject* beforeChild)
 {
     bool wrapInAnonymousSection = !child->isOutOfFlowPositioned();
 
 {
     bool wrapInAnonymousSection = !child->isOutOfFlowPositioned();
 
-    if (child->isTableCaption())
+    if (is<RenderTableCaption>(*child))
         wrapInAnonymousSection = false;
         wrapInAnonymousSection = false;
-    else if (child->isRenderTableCol()) {
+    else if (is<RenderTableCol>(*child)) {
         m_hasColElements = true;
         wrapInAnonymousSection = false;
         m_hasColElements = true;
         wrapInAnonymousSection = false;
-    } else if (child->isTableSection()) {
+    } else if (is<RenderTableSection>(*child)) {
         switch (child->style().display()) {
             case TABLE_HEADER_GROUP:
                 resetSectionPointerIfNotBefore(m_head, beforeChild);
                 if (!m_head) {
         switch (child->style().display()) {
             case TABLE_HEADER_GROUP:
                 resetSectionPointerIfNotBefore(m_head, beforeChild);
                 if (!m_head) {
-                    m_head = toRenderTableSection(child);
+                    m_head = downcast<RenderTableSection>(child);
                 } else {
                     resetSectionPointerIfNotBefore(m_firstBody, beforeChild);
                     if (!m_firstBody) 
                 } else {
                     resetSectionPointerIfNotBefore(m_firstBody, beforeChild);
                     if (!m_firstBody) 
-                        m_firstBody = toRenderTableSection(child);
+                        m_firstBody = downcast<RenderTableSection>(child);
                 }
                 wrapInAnonymousSection = false;
                 break;
             case TABLE_FOOTER_GROUP:
                 resetSectionPointerIfNotBefore(m_foot, beforeChild);
                 if (!m_foot) {
                 }
                 wrapInAnonymousSection = false;
                 break;
             case TABLE_FOOTER_GROUP:
                 resetSectionPointerIfNotBefore(m_foot, beforeChild);
                 if (!m_foot) {
-                    m_foot = toRenderTableSection(child);
+                    m_foot = downcast<RenderTableSection>(child);
                     wrapInAnonymousSection = false;
                     break;
                 }
                     wrapInAnonymousSection = false;
                     break;
                 }
@@ -168,18 +168,18 @@ void RenderTable::addChild(RenderObject* child, RenderObject* beforeChild)
             case TABLE_ROW_GROUP:
                 resetSectionPointerIfNotBefore(m_firstBody, beforeChild);
                 if (!m_firstBody)
             case TABLE_ROW_GROUP:
                 resetSectionPointerIfNotBefore(m_firstBody, beforeChild);
                 if (!m_firstBody)
-                    m_firstBody = toRenderTableSection(child);
+                    m_firstBody = downcast<RenderTableSection>(child);
                 wrapInAnonymousSection = false;
                 break;
             default:
                 ASSERT_NOT_REACHED();
         }
                 wrapInAnonymousSection = false;
                 break;
             default:
                 ASSERT_NOT_REACHED();
         }
-    } else if (child->isTableCell() || child->isTableRow())
+    } else if (is<RenderTableCell>(*child) || is<RenderTableRow>(*child))
         wrapInAnonymousSection = true;
     else
         wrapInAnonymousSection = true;
 
         wrapInAnonymousSection = true;
     else
         wrapInAnonymousSection = true;
 
-    if (child->isTableSection())
+    if (is<RenderTableSection>(*child))
         setNeedsSectionRecalc();
 
     if (!wrapInAnonymousSection) {
         setNeedsSectionRecalc();
 
     if (!wrapInAnonymousSection) {
@@ -190,32 +190,32 @@ void RenderTable::addChild(RenderObject* child, RenderObject* beforeChild)
         return;
     }
 
         return;
     }
 
-    if (!beforeChild && lastChild() && lastChild()->isTableSection() && lastChild()->isAnonymous() && !lastChild()->isBeforeContent()) {
-        toRenderTableSection(lastChild())->addChild(child);
+    if (!beforeChild && is<RenderTableSection>(lastChild()) && lastChild()->isAnonymous() && !lastChild()->isBeforeContent()) {
+        downcast<RenderTableSection>(*lastChild()).addChild(child);
         return;
     }
 
     if (beforeChild && !beforeChild->isAnonymous() && beforeChild->parent() == this) {
         RenderObject* section = beforeChild->previousSibling();
         return;
     }
 
     if (beforeChild && !beforeChild->isAnonymous() && beforeChild->parent() == this) {
         RenderObject* section = beforeChild->previousSibling();
-        if (section && section->isTableSection() && section->isAnonymous()) {
-            toRenderTableSection(section)->addChild(child);
+        if (is<RenderTableSection>(section) && section->isAnonymous()) {
+            downcast<RenderTableSection>(*section).addChild(child);
             return;
         }
     }
 
     RenderObject* lastBox = beforeChild;
             return;
         }
     }
 
     RenderObject* lastBox = beforeChild;
-    while (lastBox && lastBox->parent()->isAnonymous() && !lastBox->isTableSection() && lastBox->style().display() != TABLE_CAPTION && lastBox->style().display() != TABLE_COLUMN_GROUP)
+    while (lastBox && lastBox->parent()->isAnonymous() && !is<RenderTableSection>(*lastBox) && lastBox->style().display() != TABLE_CAPTION && lastBox->style().display() != TABLE_COLUMN_GROUP)
         lastBox = lastBox->parent();
     if (lastBox && lastBox->isAnonymous() && !isAfterContent(lastBox) && lastBox->isTableSection()) {
         lastBox = lastBox->parent();
     if (lastBox && lastBox->isAnonymous() && !isAfterContent(lastBox) && lastBox->isTableSection()) {
-        RenderTableSection* section = toRenderTableSection(lastBox);
-        if (beforeChild == section)
-            beforeChild = section->firstRow();
-        section->addChild(child, beforeChild);
+        RenderTableSection& section = downcast<RenderTableSection>(*lastBox);
+        if (beforeChild == &section)
+            beforeChild = section.firstRow();
+        section.addChild(child, beforeChild);
         return;
     }
 
         return;
     }
 
-    if (beforeChild && !beforeChild->isTableSection() && beforeChild->style().display() != TABLE_CAPTION && beforeChild->style().display() != TABLE_COLUMN_GROUP)
-        beforeChild = 0;
+    if (beforeChild && !is<RenderTableSection>(*beforeChild) && beforeChild->style().display() != TABLE_CAPTION && beforeChild->style().display() != TABLE_COLUMN_GROUP)
+        beforeChild = nullptr;
 
     RenderTableSection* section = RenderTableSection::createAnonymousWithParentRenderer(this);
     addChild(section, beforeChild);
 
     RenderTableSection* section = RenderTableSection::createAnonymousWithParentRenderer(this);
     addChild(section, beforeChild);
@@ -459,8 +459,8 @@ void RenderTable::layout()
     bool collapsing = collapseBorders();
 
     for (auto& child : childrenOfType<RenderElement>(*this)) {
     bool collapsing = collapseBorders();
 
     for (auto& child : childrenOfType<RenderElement>(*this)) {
-        if (child.isTableSection()) {
-            RenderTableSection& section = toRenderTableSection(child);
+        if (is<RenderTableSection>(child)) {
+            RenderTableSection& section = downcast<RenderTableSection>(child);
             if (m_columnLogicalWidthChanged)
                 section.setChildNeedsLayout(MarkOnlyThis);
             section.layoutIfNeeded();
             if (m_columnLogicalWidthChanged)
                 section.setChildNeedsLayout(MarkOnlyThis);
             section.layoutIfNeeded();
@@ -468,8 +468,8 @@ void RenderTable::layout()
             if (collapsing)
                 section.recalcOuterBorder();
             ASSERT(!section.needsLayout());
             if (collapsing)
                 section.recalcOuterBorder();
             ASSERT(!section.needsLayout());
-        } else if (child.isRenderTableCol()) {
-            toRenderTableCol(child).layoutIfNeeded();
+        } else if (is<RenderTableCol>(child)) {
+            downcast<RenderTableCol>(child).layoutIfNeeded();
             ASSERT(!child.needsLayout());
         }
     }
             ASSERT(!child.needsLayout());
         }
     }
@@ -851,15 +851,15 @@ void RenderTable::appendColumn(unsigned span)
 RenderTableCol* RenderTable::firstColumn() const
 {
     for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
 RenderTableCol* RenderTable::firstColumn() const
 {
     for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
-        if (child->isRenderTableCol())
-            return toRenderTableCol(child);
+        if (is<RenderTableCol>(*child))
+            return downcast<RenderTableCol>(child);
 
         // We allow only table-captions before columns or column-groups.
 
         // We allow only table-captions before columns or column-groups.
-        if (!child->isTableCaption())
-            return 0;
+        if (!is<RenderTableCaption>(*child))
+            return nullptr;
     }
 
     }
 
-    return 0;
+    return nullptr;
 }
 
 void RenderTable::updateColumnCache() const
 }
 
 void RenderTable::updateColumnCache() const
@@ -1006,31 +1006,31 @@ void RenderTable::recalcSections() const
             m_hasColElements = true;
             break;
         case TABLE_HEADER_GROUP:
             m_hasColElements = true;
             break;
         case TABLE_HEADER_GROUP:
-            if (child->isTableSection()) {
-                RenderTableSection* section = toRenderTableSection(child);
+            if (is<RenderTableSection>(*child)) {
+                RenderTableSection& section = downcast<RenderTableSection>(*child);
                 if (!m_head)
                 if (!m_head)
-                    m_head = section;
+                    m_head = &section;
                 else if (!m_firstBody)
                 else if (!m_firstBody)
-                    m_firstBody = section;
-                section->recalcCellsIfNeeded();
+                    m_firstBody = &section;
+                section.recalcCellsIfNeeded();
             }
             break;
         case TABLE_FOOTER_GROUP:
             }
             break;
         case TABLE_FOOTER_GROUP:
-            if (child->isTableSection()) {
-                RenderTableSection* section = toRenderTableSection(child);
+            if (is<RenderTableSection>(*child)) {
+                RenderTableSection& section = downcast<RenderTableSection>(*child);
                 if (!m_foot)
                 if (!m_foot)
-                    m_foot = section;
+                    m_foot = &section;
                 else if (!m_firstBody)
                 else if (!m_firstBody)
-                    m_firstBody = section;
-                section->recalcCellsIfNeeded();
+                    m_firstBody = &section;
+                section.recalcCellsIfNeeded();
             }
             break;
         case TABLE_ROW_GROUP:
             }
             break;
         case TABLE_ROW_GROUP:
-            if (child->isTableSection()) {
-                RenderTableSection* section = toRenderTableSection(child);
+            if (is<RenderTableSection>(*child)) {
+                RenderTableSection& section = downcast<RenderTableSection>(*child);
                 if (!m_firstBody)
                 if (!m_firstBody)
-                    m_firstBody = section;
-                section->recalcCellsIfNeeded();
+                    m_firstBody = &section;
+                section.recalcCellsIfNeeded();
             }
             break;
         default:
             }
             break;
         default:
@@ -1284,17 +1284,17 @@ RenderTableSection* RenderTable::sectionAbove(const RenderTableSection* section,
     recalcSectionsIfNeeded();
 
     if (section == m_head)
     recalcSectionsIfNeeded();
 
     if (section == m_head)
-        return 0;
+        return nullptr;
 
     RenderObject* prevSection = section == m_foot ? lastChild() : section->previousSibling();
     while (prevSection) {
 
     RenderObject* prevSection = section == m_foot ? lastChild() : section->previousSibling();
     while (prevSection) {
-        if (prevSection->isTableSection() && prevSection != m_head && prevSection != m_foot && (skipEmptySections == DoNotSkipEmptySections || toRenderTableSection(prevSection)->numRows()))
+        if (is<RenderTableSection>(*prevSection) && prevSection != m_head && prevSection != m_foot && (skipEmptySections == DoNotSkipEmptySections || downcast<RenderTableSection>(*prevSection).numRows()))
             break;
         prevSection = prevSection->previousSibling();
     }
     if (!prevSection && m_head && (skipEmptySections == DoNotSkipEmptySections || m_head->numRows()))
         prevSection = m_head;
             break;
         prevSection = prevSection->previousSibling();
     }
     if (!prevSection && m_head && (skipEmptySections == DoNotSkipEmptySections || m_head->numRows()))
         prevSection = m_head;
-    return toRenderTableSection(prevSection);
+    return downcast<RenderTableSection>(prevSection);
 }
 
 RenderTableSection* RenderTable::sectionBelow(const RenderTableSection* section, SkipEmptySectionsValue skipEmptySections) const
 }
 
 RenderTableSection* RenderTable::sectionBelow(const RenderTableSection* section, SkipEmptySectionsValue skipEmptySections) const
@@ -1302,17 +1302,17 @@ RenderTableSection* RenderTable::sectionBelow(const RenderTableSection* section,
     recalcSectionsIfNeeded();
 
     if (section == m_foot)
     recalcSectionsIfNeeded();
 
     if (section == m_foot)
-        return 0;
+        return nullptr;
 
     RenderObject* nextSection = section == m_head ? firstChild() : section->nextSibling();
     while (nextSection) {
 
     RenderObject* nextSection = section == m_head ? firstChild() : section->nextSibling();
     while (nextSection) {
-        if (nextSection->isTableSection() && nextSection != m_head && nextSection != m_foot && (skipEmptySections  == DoNotSkipEmptySections || toRenderTableSection(nextSection)->numRows()))
+        if (is<RenderTableSection>(*nextSection) && nextSection != m_head && nextSection != m_foot && (skipEmptySections  == DoNotSkipEmptySections || downcast<RenderTableSection>(*nextSection).numRows()))
             break;
         nextSection = nextSection->nextSibling();
     }
     if (!nextSection && m_foot && (skipEmptySections == DoNotSkipEmptySections || m_foot->numRows()))
         nextSection = m_foot;
             break;
         nextSection = nextSection->nextSibling();
     }
     if (!nextSection && m_foot && (skipEmptySections == DoNotSkipEmptySections || m_foot->numRows()))
         nextSection = m_foot;
-    return toRenderTableSection(nextSection);
+    return downcast<RenderTableSection>(nextSection);
 }
 
 RenderTableSection* RenderTable::bottomSection() const
 }
 
 RenderTableSection* RenderTable::bottomSection() const
@@ -1323,11 +1323,11 @@ RenderTableSection* RenderTable::bottomSection() const
         return m_foot;
 
     for (RenderObject* child = lastChild(); child; child = child->previousSibling()) {
         return m_foot;
 
     for (RenderObject* child = lastChild(); child; child = child->previousSibling()) {
-        if (child->isTableSection())
-            return toRenderTableSection(child);
+        if (is<RenderTableSection>(*child))
+            return downcast<RenderTableSection>(child);
     }
 
     }
 
-    return 0;
+    return nullptr;
 }
 
 RenderTableCell* RenderTable::cellAbove(const RenderTableCell* cell) const
 }
 
 RenderTableCell* RenderTable::cellAbove(const RenderTableCell* cell) const
index d9d1ee8..94d1cbd 100644 (file)
@@ -381,8 +381,6 @@ inline RenderTableSection* RenderTable::topSection() const
     return m_foot;
 }
 
     return m_foot;
 }
 
-RENDER_OBJECT_TYPE_CASTS(RenderTable, isTable())
-
 } // namespace WebCore
 
 SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderTable, isTable())
 } // namespace WebCore
 
 SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderTable, isTable())
index ca18c4c..ce3241c 100644 (file)
@@ -55,7 +55,7 @@ void RenderTableCaption::willBeRemovedFromTree()
 
 RenderTable* RenderTableCaption::table() const
 {
 
 RenderTable* RenderTableCaption::table() const
 {
-    return toRenderTable(parent());
+    return downcast<RenderTable>(parent());
 }
 
 }
 }
 
 }
index 77c92b9..22f86dc 100644 (file)
@@ -74,9 +74,9 @@ public:
     RenderTableCell* nextCell() const;
     RenderTableCell* previousCell() const;
 
     RenderTableCell* nextCell() const;
     RenderTableCell* previousCell() const;
 
-    RenderTableRow* row() const { return toRenderTableRow(parent()); }
-    RenderTableSection* section() const { return toRenderTableSection(parent()->parent()); }
-    RenderTable* table() const { return toRenderTable(parent()->parent()->parent()); }
+    RenderTableRow* row() const { return downcast<RenderTableRow>(parent()); }
+    RenderTableSection* section() const { return downcast<RenderTableSection>(parent()->parent()); }
+    RenderTable* table() const { return downcast<RenderTable>(parent()->parent()->parent()); }
 
     unsigned rowIndex() const
     {
 
     unsigned rowIndex() const
     {
@@ -294,26 +294,24 @@ private:
     int m_intrinsicPaddingAfter;
 };
 
     int m_intrinsicPaddingAfter;
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderTableCell, isTableCell())
-
 inline RenderTableCell* RenderTableCell::nextCell() const
 {
 inline RenderTableCell* RenderTableCell::nextCell() const
 {
-    return toRenderTableCell(RenderBlockFlow::nextSibling());
+    return downcast<RenderTableCell>(RenderBlockFlow::nextSibling());
 }
 
 inline RenderTableCell* RenderTableCell::previousCell() const
 {
 }
 
 inline RenderTableCell* RenderTableCell::previousCell() const
 {
-    return toRenderTableCell(RenderBlockFlow::previousSibling());
+    return downcast<RenderTableCell>(RenderBlockFlow::previousSibling());
 }
 
 inline RenderTableCell* RenderTableRow::firstCell() const
 {
 }
 
 inline RenderTableCell* RenderTableRow::firstCell() const
 {
-    return toRenderTableCell(RenderBox::firstChild());
+    return downcast<RenderTableCell>(RenderBox::firstChild());
 }
 
 inline RenderTableCell* RenderTableRow::lastCell() const
 {
 }
 
 inline RenderTableCell* RenderTableRow::lastCell() const
 {
-    return toRenderTableCell(RenderBox::lastChild());
+    return downcast<RenderTableCell>(RenderBox::lastChild());
 }
 
 } // namespace WebCore
 }
 
 } // namespace WebCore
index 6fde494..bc18498 100644 (file)
@@ -30,6 +30,7 @@
 #include "HTMLTableColElement.h"
 #include "RenderIterator.h"
 #include "RenderTable.h"
 #include "HTMLTableColElement.h"
 #include "RenderIterator.h"
 #include "RenderTable.h"
+#include "RenderTableCaption.h"
 #include "RenderTableCell.h"
 
 namespace WebCore {
 #include "RenderTableCell.h"
 
 namespace WebCore {
@@ -139,44 +140,44 @@ void RenderTableCol::clearPreferredLogicalWidthsDirtyBits()
 RenderTable* RenderTableCol::table() const
 {
     auto table = parent();
 RenderTable* RenderTableCol::table() const
 {
     auto table = parent();
-    if (table && !table->isTable())
+    if (table && !is<RenderTable>(*table))
         table = table->parent();
         table = table->parent();
-    return table && table->isTable() ? toRenderTable(table) : 0;
+    return is<RenderTable>(table) ? downcast<RenderTable>(table) : nullptr;
 }
 
 RenderTableCol* RenderTableCol::enclosingColumnGroup() const
 {
 }
 
 RenderTableCol* RenderTableCol::enclosingColumnGroup() const
 {
-    if (!parent()->isRenderTableCol())
-        return 0;
+    if (!is<RenderTableCol>(*parent()))
+        return nullptr;
 
 
-    RenderTableCol* parentColumnGroup = toRenderTableCol(parent());
-    ASSERT(parentColumnGroup->isTableColumnGroup());
+    RenderTableCol& parentColumnGroup = downcast<RenderTableCol>(*parent());
+    ASSERT(parentColumnGroup.isTableColumnGroup());
     ASSERT(isTableColumn());
     ASSERT(isTableColumn());
-    return parentColumnGroup;
+    return &parentColumnGroup;
 }
 
 RenderTableCol* RenderTableCol::nextColumn() const
 {
     // If |this| is a column-group, the next column is the colgroup's first child column.
     if (RenderObject* firstChild = this->firstChild())
 }
 
 RenderTableCol* RenderTableCol::nextColumn() const
 {
     // If |this| is a column-group, the next column is the colgroup's first child column.
     if (RenderObject* firstChild = this->firstChild())
-        return toRenderTableCol(firstChild);
+        return downcast<RenderTableCol>(firstChild);
 
     // Otherwise it's the next column along.
     RenderObject* next = nextSibling();
 
     // Failing that, the child is the last column in a column-group, so the next column is the next column/column-group after its column-group.
 
     // Otherwise it's the next column along.
     RenderObject* next = nextSibling();
 
     // Failing that, the child is the last column in a column-group, so the next column is the next column/column-group after its column-group.
-    if (!next && parent()->isRenderTableCol())
+    if (!next && is<RenderTableCol>(*parent()))
         next = parent()->nextSibling();
 
         next = parent()->nextSibling();
 
-    for (; next && !next->isRenderTableCol(); next = next->nextSibling()) {
+    for (; next && !is<RenderTableCol>(*next); next = next->nextSibling()) {
         // We allow captions mixed with columns and column-groups.
         // We allow captions mixed with columns and column-groups.
-        if (next->isTableCaption())
+        if (is<RenderTableCaption>(*next))
             continue;
 
             continue;
 
-        return 0;
+        return nullptr;
     }
 
     }
 
-    return toRenderTableCol(next);
+    return downcast<RenderTableCol>(next);
 }
 
 const BorderValue& RenderTableCol::borderAdjoiningCellStartBorder(const RenderTableCell*) const
 }
 
 const BorderValue& RenderTableCol::borderAdjoiningCellStartBorder(const RenderTableCell*) const
index b79d2c3..0f3cd97 100644 (file)
@@ -75,11 +75,11 @@ public:
     virtual LayoutUnit offsetTop() const override;
     virtual LayoutUnit offsetWidth() const override;
     virtual LayoutUnit offsetHeight() const override;
     virtual LayoutUnit offsetTop() const override;
     virtual LayoutUnit offsetWidth() const override;
     virtual LayoutUnit offsetHeight() const override;
+    virtual void updateFromElement() override;
 
 private:
     virtual const char* renderName() const override { return "RenderTableCol"; }
     virtual bool isRenderTableCol() const override { return true; }
 
 private:
     virtual const char* renderName() const override { return "RenderTableCol"; }
     virtual bool isRenderTableCol() const override { return true; }
-    virtual void updateFromElement() override;
     virtual void computePreferredLogicalWidths() override { ASSERT_NOT_REACHED(); }
 
     virtual void insertedIntoTree() override;
     virtual void computePreferredLogicalWidths() override { ASSERT_NOT_REACHED(); }
 
     virtual void insertedIntoTree() override;
@@ -100,8 +100,6 @@ private:
     unsigned m_span;
 };
 
     unsigned m_span;
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderTableCol, isRenderTableCol())
-
 } // namespace WebCore
 
 SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderTableCol, isRenderTableCol())
 } // namespace WebCore
 
 SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderTableCol, isRenderTableCol())
index 6970eb3..20ec19d 100644 (file)
@@ -109,28 +109,28 @@ const BorderValue& RenderTableRow::borderAdjoiningEndCell(const RenderTableCell*
 
 void RenderTableRow::addChild(RenderObject* child, RenderObject* beforeChild)
 {
 
 void RenderTableRow::addChild(RenderObject* child, RenderObject* beforeChild)
 {
-    if (!child->isTableCell()) {
+    if (!is<RenderTableCell>(*child)) {
         RenderObject* last = beforeChild;
         if (!last)
             last = lastCell();
         RenderObject* last = beforeChild;
         if (!last)
             last = lastCell();
-        if (last && last->isAnonymous() && last->isTableCell() && !last->isBeforeOrAfterContent()) {
-            RenderTableCell* cell = toRenderTableCell(last);
-            if (beforeChild == cell)
-                beforeChild = cell->firstChild();
-            cell->addChild(child, beforeChild);
+        if (last && last->isAnonymous() && is<RenderTableCell>(*last) && !last->isBeforeOrAfterContent()) {
+            RenderTableCell& cell = downcast<RenderTableCell>(*last);
+            if (beforeChild == &cell)
+                beforeChild = cell.firstChild();
+            cell.addChild(child, beforeChild);
             return;
         }
 
         if (beforeChild && !beforeChild->isAnonymous() && beforeChild->parent() == this) {
             RenderObject* cell = beforeChild->previousSibling();
             return;
         }
 
         if (beforeChild && !beforeChild->isAnonymous() && beforeChild->parent() == this) {
             RenderObject* cell = beforeChild->previousSibling();
-            if (cell && cell->isTableCell() && cell->isAnonymous()) {
-                toRenderTableCell(cell)->addChild(child);
+            if (is<RenderTableCell>(cell) && cell->isAnonymous()) {
+                downcast<RenderTableCell>(*cell).addChild(child);
                 return;
             }
         }
 
         // If beforeChild is inside an anonymous cell, insert into the cell.
                 return;
             }
         }
 
         // If beforeChild is inside an anonymous cell, insert into the cell.
-        if (last && !last->isTableCell() && last->parent() && last->parent()->isAnonymous() && !last->parent()->isBeforeOrAfterContent()) {
+        if (last && !is<RenderTableCell>(*last) && last->parent() && last->parent()->isAnonymous() && !last->parent()->isBeforeOrAfterContent()) {
             last->parent()->addChild(child, beforeChild);
             return;
         }
             last->parent()->addChild(child, beforeChild);
             return;
         }
@@ -144,14 +144,14 @@ void RenderTableRow::addChild(RenderObject* child, RenderObject* beforeChild)
     if (beforeChild && beforeChild->parent() != this)
         beforeChild = splitAnonymousBoxesAroundChild(beforeChild);    
 
     if (beforeChild && beforeChild->parent() != this)
         beforeChild = splitAnonymousBoxesAroundChild(beforeChild);    
 
-    RenderTableCell* cell = toRenderTableCell(child);
+    RenderTableCell& cell = downcast<RenderTableCell>(*child);
 
     // Generated content can result in us having a null section so make sure to null check our parent.
     if (parent())
 
     // Generated content can result in us having a null section so make sure to null check our parent.
     if (parent())
-        section()->addCell(cell, this);
+        section()->addCell(&cell, this);
 
 
-    ASSERT(!beforeChild || beforeChild->isTableCell());
-    RenderBox::addChild(cell, beforeChild);
+    ASSERT(!beforeChild || is<RenderTableCell>(*beforeChild));
+    RenderBox::addChild(&cell, beforeChild);
 
     if (beforeChild || nextRow())
         section()->setNeedsCellRecalc();
 
     if (beforeChild || nextRow())
         section()->setNeedsCellRecalc();
index 75becb5..1096120 100644 (file)
@@ -43,8 +43,8 @@ public:
     RenderTableCell* firstCell() const;
     RenderTableCell* lastCell() const;
 
     RenderTableCell* firstCell() const;
     RenderTableCell* lastCell() const;
 
-    RenderTableSection* section() const { return toRenderTableSection(parent()); }
-    RenderTable* table() const { return toRenderTable(parent()->parent()); }
+    RenderTableSection* section() const { return downcast<RenderTableSection>(parent()); }
+    RenderTable* table() const { return downcast<RenderTable>(parent()->parent()); }
 
     void paintOutlineForRowIfNeeded(PaintInfo&, const LayoutPoint&);
 
 
     void paintOutlineForRowIfNeeded(PaintInfo&, const LayoutPoint&);
 
@@ -119,26 +119,24 @@ private:
     unsigned m_rowIndex : 31;
 };
 
     unsigned m_rowIndex : 31;
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderTableRow, isTableRow())
-
 inline RenderTableRow* RenderTableSection::firstRow() const
 {
 inline RenderTableRow* RenderTableSection::firstRow() const
 {
-    return toRenderTableRow(RenderBox::firstChild());
+    return downcast<RenderTableRow>(RenderBox::firstChild());
 }
 
 inline RenderTableRow* RenderTableSection::lastRow() const
 {
 }
 
 inline RenderTableRow* RenderTableSection::lastRow() const
 {
-    return toRenderTableRow(RenderBox::lastChild());
+    return downcast<RenderTableRow>(RenderBox::lastChild());
 }
 
 inline RenderTableRow* RenderTableRow::nextRow() const
 {
 }
 
 inline RenderTableRow* RenderTableRow::nextRow() const
 {
-    return toRenderTableRow(RenderBox::nextSibling());
+    return downcast<RenderTableRow>(RenderBox::nextSibling());
 }
 
 inline RenderTableRow* RenderTableRow::previousRow() const
 {
 }
 
 inline RenderTableRow* RenderTableRow::previousRow() const
 {
-    return toRenderTableRow(RenderBox::previousSibling());
+    return downcast<RenderTableRow>(RenderBox::previousSibling());
 }
 
 } // namespace WebCore
 }
 
 } // namespace WebCore
index af847d6..2dbec5e 100644 (file)
@@ -33,6 +33,7 @@
 #include "RenderTableCell.h"
 #include "RenderTableCol.h"
 #include "RenderTableRow.h"
 #include "RenderTableCell.h"
 #include "RenderTableCol.h"
 #include "RenderTableRow.h"
+#include "RenderTextControl.h"
 #include "RenderView.h"
 #include "StyleInheritedData.h"
 #include <limits>
 #include "RenderView.h"
 #include "StyleInheritedData.h"
 #include <limits>
@@ -135,22 +136,22 @@ void RenderTableSection::willBeRemovedFromTree()
 
 void RenderTableSection::addChild(RenderObject* child, RenderObject* beforeChild)
 {
 
 void RenderTableSection::addChild(RenderObject* child, RenderObject* beforeChild)
 {
-    if (!child->isTableRow()) {
+    if (!is<RenderTableRow>(*child)) {
         RenderObject* last = beforeChild;
         if (!last)
             last = lastRow();
         if (last && last->isAnonymous() && !last->isBeforeOrAfterContent()) {
         RenderObject* last = beforeChild;
         if (!last)
             last = lastRow();
         if (last && last->isAnonymous() && !last->isBeforeOrAfterContent()) {
-            RenderTableRow* row = toRenderTableRow(last);
-            if (beforeChild == row)
-                beforeChild = row->firstCell();
-            row->addChild(child, beforeChild);
+            RenderTableRow& row = downcast<RenderTableRow>(*last);
+            if (beforeChild == &row)
+                beforeChild = row.firstCell();
+            row.addChild(child, beforeChild);
             return;
         }
 
         if (beforeChild && !beforeChild->isAnonymous() && beforeChild->parent() == this) {
             RenderObject* row = beforeChild->previousSibling();
             return;
         }
 
         if (beforeChild && !beforeChild->isAnonymous() && beforeChild->parent() == this) {
             RenderObject* row = beforeChild->previousSibling();
-            if (row && row->isTableRow() && row->isAnonymous()) {
-                toRenderTableRow(row)->addChild(child);
+            if (is<RenderTableRow>(row) && row->isAnonymous()) {
+                downcast<RenderTableRow>(*row).addChild(child);
                 return;
             }
         }
                 return;
             }
         }
@@ -158,10 +159,10 @@ void RenderTableSection::addChild(RenderObject* child, RenderObject* beforeChild
         // If beforeChild is inside an anonymous cell/row, insert into the cell or into
         // the anonymous row containing it, if there is one.
         RenderObject* lastBox = last;
         // If beforeChild is inside an anonymous cell/row, insert into the cell or into
         // the anonymous row containing it, if there is one.
         RenderObject* lastBox = last;
-        while (lastBox && lastBox->parent()->isAnonymous() && !lastBox->isTableRow())
+        while (lastBox && lastBox->parent()->isAnonymous() && !is<RenderTableRow>(*lastBox))
             lastBox = lastBox->parent();
         if (lastBox && lastBox->isAnonymous() && !lastBox->isBeforeOrAfterContent()) {
             lastBox = lastBox->parent();
         if (lastBox && lastBox->isAnonymous() && !lastBox->isBeforeOrAfterContent()) {
-            toRenderTableRow(lastBox)->addChild(child, beforeChild);
+            downcast<RenderTableRow>(*lastBox).addChild(child, beforeChild);
             return;
         }
 
             return;
         }
 
@@ -180,9 +181,9 @@ void RenderTableSection::addChild(RenderObject* child, RenderObject* beforeChild
 
     ensureRows(m_cRow);
 
 
     ensureRows(m_cRow);
 
-    RenderTableRow* row = toRenderTableRow(child);
-    m_grid[insertionRow].rowRenderer = row;
-    row->setRowIndex(insertionRow);
+    RenderTableRow& row = downcast<RenderTableRow>(*child);
+    m_grid[insertionRow].rowRenderer = &row;
+    row.setRowIndex(insertionRow);
 
     if (!beforeChild)
         setRowLogicalHeightToRowStyleLogicalHeightIfNotRelative(m_grid[insertionRow]);
 
     if (!beforeChild)
         setRowLogicalHeightToRowStyleLogicalHeightIfNotRelative(m_grid[insertionRow]);
@@ -190,7 +191,7 @@ void RenderTableSection::addChild(RenderObject* child, RenderObject* beforeChild
     if (beforeChild && beforeChild->parent() != this)
         beforeChild = splitAnonymousBoxesAroundChild(beforeChild);
 
     if (beforeChild && beforeChild->parent() != this)
         beforeChild = splitAnonymousBoxesAroundChild(beforeChild);
 
-    ASSERT(!beforeChild || beforeChild->isTableRow());
+    ASSERT(!beforeChild || is<RenderTableRow>(*beforeChild));
     RenderBox::addChild(child, beforeChild);
 }
 
     RenderBox::addChild(child, beforeChild);
 }
 
@@ -577,11 +578,11 @@ void RenderTableSection::layoutRows()
             bool flexAllChildren = cell->style().logicalHeight().isFixed()
                 || (!table()->style().logicalHeight().isAuto() && rHeight != cell->logicalHeight());
 
             bool flexAllChildren = cell->style().logicalHeight().isFixed()
                 || (!table()->style().logicalHeight().isAuto() && rHeight != cell->logicalHeight());
 
-            for (RenderObject* o = cell->firstChild(); o; o = o->nextSibling()) {
-                if (!o->isText() && o->style().logicalHeight().isPercent() && (flexAllChildren || ((o->isReplaced() || (o->isBox() && toRenderBox(o)->scrollsOverflow())) && !o->isTextControl()))) {
+            for (RenderObject* renderer = cell->firstChild(); renderer; renderer = renderer->nextSibling()) {
+                if (!is<RenderText>(*renderer) && renderer->style().logicalHeight().isPercent() && (flexAllChildren || ((renderer->isReplaced() || (is<RenderBox>(*renderer) && downcast<RenderBox>(*renderer).scrollsOverflow())) && !is<RenderTextControl>(*renderer)))) {
                     // Tables with no sections do not flex.
                     // Tables with no sections do not flex.
-                    if (!o->isTable() || toRenderTable(o)->hasSections()) {
-                        o->setNeedsLayout(MarkOnlyThis);
+                    if (!is<RenderTable>(*renderer) || downcast<RenderTable>(*renderer).hasSections()) {
+                        renderer->setNeedsLayout(MarkOnlyThis);
                         cellChildrenFlex = true;
                     }
                 }
                         cellChildrenFlex = true;
                     }
                 }
@@ -985,13 +986,13 @@ void RenderTableSection::paintCell(RenderTableCell* cell, PaintInfo& paintInfo,
 {
     LayoutPoint cellPoint = flipForWritingModeForChild(cell, paintOffset);
     PaintPhase paintPhase = paintInfo.phase;
 {
     LayoutPoint cellPoint = flipForWritingModeForChild(cell, paintOffset);
     PaintPhase paintPhase = paintInfo.phase;
-    RenderTableRow* row = toRenderTableRow(cell->parent());
+    RenderTableRow& row = downcast<RenderTableRow>(*cell->parent());
 
     if (paintPhase == PaintPhaseBlockBackground || paintPhase == PaintPhaseChildBlockBackground) {
         // We need to handle painting a stack of backgrounds.  This stack (from bottom to top) consists of
         // the column group, column, row group, row, and then the cell.
         RenderTableCol* column = table()->colElement(cell->col());
 
     if (paintPhase == PaintPhaseBlockBackground || paintPhase == PaintPhaseChildBlockBackground) {
         // We need to handle painting a stack of backgrounds.  This stack (from bottom to top) consists of
         // the column group, column, row group, row, and then the cell.
         RenderTableCol* column = table()->colElement(cell->col());
-        RenderTableCol* columnGroup = column ? column->enclosingColumnGroup() : 0;
+        RenderTableCol* columnGroup = column ? column->enclosingColumnGroup() : nullptr;
 
         // Column groups and columns first.
         // FIXME: Columns and column groups do not currently support opacity, and they are being painted "too late" in
 
         // Column groups and columns first.
         // FIXME: Columns and column groups do not currently support opacity, and they are being painted "too late" in
@@ -1006,10 +1007,10 @@ void RenderTableSection::paintCell(RenderTableCell* cell, PaintInfo& paintInfo,
 
         // Paint the row next, but only if it doesn't have a layer.  If a row has a layer, it will be responsible for
         // painting the row background for the cell.
 
         // Paint the row next, but only if it doesn't have a layer.  If a row has a layer, it will be responsible for
         // painting the row background for the cell.
-        if (!row->hasSelfPaintingLayer())
-            cell->paintBackgroundsBehindCell(paintInfo, cellPoint, row);
+        if (!row.hasSelfPaintingLayer())
+            cell->paintBackgroundsBehindCell(paintInfo, cellPoint, &row);
     }
     }
-    if ((!cell->hasSelfPaintingLayer() && !row->hasSelfPaintingLayer()))
+    if ((!cell->hasSelfPaintingLayer() && !row.hasSelfPaintingLayer()))
         cell->paint(paintInfo, cellPoint);
 }
 
         cell->paint(paintInfo, cellPoint);
 }
 
index b4b30c1..ee85929 100644 (file)
@@ -81,7 +81,7 @@ public:
     void layoutRows();
     void computeOverflowFromCells();
 
     void layoutRows();
     void computeOverflowFromCells();
 
-    RenderTable* table() const { return toRenderTable(parent()); }
+    RenderTable* table() const { return downcast<RenderTable>(parent()); }
 
     struct CellStruct {
         Vector<RenderTableCell*, 1> cells; 
 
     struct CellStruct {
         Vector<RenderTableCell*, 1> cells; 
@@ -347,8 +347,6 @@ private:
     HashMap<std::pair<const RenderTableCell*, int>, CollapsedBorderValue > m_cellsCollapsedBorders;
 };
 
     HashMap<std::pair<const RenderTableCell*, int>, CollapsedBorderValue > m_cellsCollapsedBorders;
 };
 
-RENDER_OBJECT_TYPE_CASTS(RenderTableSection, isTableSection())
-
 } // namespace WebCore
 
 SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderTableSection, isTableSection())
 } // namespace WebCore
 
 SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderTableSection, isTableSection())
index dd90c5b..b7cde74 100644 (file)
@@ -467,8 +467,8 @@ static void writeTextRun(TextStream& ts, const RenderText& o, const InlineTextBo
     int logicalWidth = ceilf(run.left() + run.logicalWidth()) - x;
 
     // FIXME: Table cell adjustment is temporary until results can be updated.
     int logicalWidth = ceilf(run.left() + run.logicalWidth()) - x;
 
     // FIXME: Table cell adjustment is temporary until results can be updated.
-    if (o.containingBlock()->isTableCell())
-        y -= toRenderTableCell(o.containingBlock())->intrinsicPaddingBefore();
+    if (is<RenderTableCell>(*o.containingBlock()))
+        y -= downcast<RenderTableCell>(*o.containingBlock()).intrinsicPaddingBefore();
         
     ts << "text run at (" << x << "," << y << ") width " << logicalWidth;
     if (!run.isLeftToRightDirection() || run.dirOverride()) {
         
     ts << "text run at (" << x << "," << y << ") width " << logicalWidth;
     if (!run.isLeftToRightDirection() || run.dirOverride()) {
@@ -489,8 +489,8 @@ static void writeSimpleLine(TextStream& ts, const RenderText& o, const LayoutRec
     int y = rect.y();
     int logicalWidth = ceilf(rect.x() + rect.width()) - x;
 
     int y = rect.y();
     int logicalWidth = ceilf(rect.x() + rect.width()) - x;
 
-    if (o.containingBlock()->isTableCell())
-        y -= toRenderTableCell(o.containingBlock())->intrinsicPaddingBefore();
+    if (is<RenderTableCell>(*o.containingBlock()))
+        y -= downcast<RenderTableCell>(*o.containingBlock()).intrinsicPaddingBefore();
         
     ts << "text run at (" << x << "," << y << ") width " << logicalWidth;
     ts << ": "
         
     ts << "text run at (" << x << "," << y << ") width " << logicalWidth;
     ts << ": "