Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(200)

Side by Side Diff: Source/core/rendering/RenderTableSection.cpp

Issue 294783004: Use tighter typing in table rendering code (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix typo / bug and update copyrights Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1997 Martin Jones (mjones@kde.org) 2 * Copyright (C) 1997 Martin Jones (mjones@kde.org)
3 * (C) 1997 Torben Weis (weis@kde.org) 3 * (C) 1997 Torben Weis (weis@kde.org)
4 * (C) 1998 Waldo Bastian (bastian@kde.org) 4 * (C) 1998 Waldo Bastian (bastian@kde.org)
5 * (C) 1999 Lars Knoll (knoll@kde.org) 5 * (C) 1999 Lars Knoll (knoll@kde.org)
6 * (C) 1999 Antti Koivisto (koivisto@kde.org) 6 * (C) 1999 Antti Koivisto (koivisto@kde.org)
7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010 Apple Inc. All rights reserved. 7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2013 Apple Inc. All r ights reserved.
8 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com) 8 * Copyright (C) 2006 Alexey Proskuryakov (ap@nypop.com)
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Library General Public 11 * modify it under the terms of the GNU Library General Public
12 * License as published by the Free Software Foundation; either 12 * License as published by the Free Software Foundation; either
13 * version 2 of the License, or (at your option) any later version. 13 * version 2 of the License, or (at your option) any later version.
14 * 14 *
15 * This library is distributed in the hope that it will be useful, 15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 // Preventively invalidate our cells as we may be re-inserted into 117 // Preventively invalidate our cells as we may be re-inserted into
118 // a new table which would require us to rebuild our structure. 118 // a new table which would require us to rebuild our structure.
119 setNeedsCellRecalc(); 119 setNeedsCellRecalc();
120 } 120 }
121 121
122 void RenderTableSection::addChild(RenderObject* child, RenderObject* beforeChild ) 122 void RenderTableSection::addChild(RenderObject* child, RenderObject* beforeChild )
123 { 123 {
124 if (!child->isTableRow()) { 124 if (!child->isTableRow()) {
125 RenderObject* last = beforeChild; 125 RenderObject* last = beforeChild;
126 if (!last) 126 if (!last)
127 last = lastChild(); 127 last = lastRow();
128 if (last && last->isAnonymous() && !last->isBeforeOrAfterContent()) { 128 if (last && last->isAnonymous() && !last->isBeforeOrAfterContent()) {
129 if (beforeChild == last) 129 if (beforeChild == last)
130 beforeChild = last->slowFirstChild(); 130 beforeChild = last->slowFirstChild();
131 last->addChild(child, beforeChild); 131 last->addChild(child, beforeChild);
132 return; 132 return;
133 } 133 }
134 134
135 if (beforeChild && !beforeChild->isAnonymous() && beforeChild->parent() == this) { 135 if (beforeChild && !beforeChild->isAnonymous() && beforeChild->parent() == this) {
136 RenderObject* row = beforeChild->previousSibling(); 136 RenderObject* row = beforeChild->previousSibling();
137 if (row && row->isTableRow() && row->isAnonymous()) { 137 if (row && row->isTableRow() && row->isAnonymous()) {
(...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 return 0; 1077 return 0;
1078 1078
1079 unsigned borderWidth = 0; 1079 unsigned borderWidth = 0;
1080 1080
1081 const BorderValue& sb = side == BorderBefore ? style()->borderBefore() : sty le()->borderAfter(); 1081 const BorderValue& sb = side == BorderBefore ? style()->borderBefore() : sty le()->borderAfter();
1082 if (sb.style() == BHIDDEN) 1082 if (sb.style() == BHIDDEN)
1083 return -1; 1083 return -1;
1084 if (sb.style() > BHIDDEN) 1084 if (sb.style() > BHIDDEN)
1085 borderWidth = sb.width(); 1085 borderWidth = sb.width();
1086 1086
1087 const BorderValue& rb = side == BorderBefore ? firstChild()->style()->border Before() : lastChild()->style()->borderAfter(); 1087 const BorderValue& rb = side == BorderBefore ? firstRow()->style()->borderBe fore() : lastRow()->style()->borderAfter();
1088 if (rb.style() == BHIDDEN) 1088 if (rb.style() == BHIDDEN)
1089 return -1; 1089 return -1;
1090 if (rb.style() > BHIDDEN && rb.width() > borderWidth) 1090 if (rb.style() > BHIDDEN && rb.width() > borderWidth)
1091 borderWidth = rb.width(); 1091 borderWidth = rb.width();
1092 1092
1093 bool allHidden = true; 1093 bool allHidden = true;
1094 for (unsigned c = 0; c < totalCols; c++) { 1094 for (unsigned c = 0; c < totalCols; c++) {
1095 const CellStruct& current = cellAt(side == BorderBefore ? 0 : m_grid.siz e() - 1, c); 1095 const CellStruct& current = cellAt(side == BorderBefore ? 0 : m_grid.siz e() - 1, c);
1096 if (current.inColSpan || !current.hasCells()) 1096 if (current.inColSpan || !current.hasCells())
1097 continue; 1097 continue;
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
1490 ASSERT(m_needsCellRecalc); 1490 ASSERT(m_needsCellRecalc);
1491 // We reset the flag here to ensure that |addCell| works. This is safe to do as 1491 // We reset the flag here to ensure that |addCell| works. This is safe to do as
1492 // fillRowsWithDefaultStartingAtPosition makes sure we match the table's col umns 1492 // fillRowsWithDefaultStartingAtPosition makes sure we match the table's col umns
1493 // representation. 1493 // representation.
1494 m_needsCellRecalc = false; 1494 m_needsCellRecalc = false;
1495 1495
1496 m_cCol = 0; 1496 m_cCol = 0;
1497 m_cRow = 0; 1497 m_cRow = 0;
1498 m_grid.clear(); 1498 m_grid.clear();
1499 1499
1500 for (RenderObject* row = firstChild(); row; row = row->nextSibling()) { 1500 for (RenderTableRow* row = firstRow(); row; row = row->nextRow()) {
1501 if (row->isTableRow()) { 1501 unsigned insertionRow = m_cRow;
1502 unsigned insertionRow = m_cRow; 1502 ++m_cRow;
1503 m_cRow++; 1503 m_cCol = 0;
1504 m_cCol = 0; 1504 ensureRows(m_cRow);
1505 ensureRows(m_cRow);
1506 1505
1507 RenderTableRow* tableRow = toRenderTableRow(row); 1506 m_grid[insertionRow].rowRenderer = row;
1508 m_grid[insertionRow].rowRenderer = tableRow; 1507 row->setRowIndex(insertionRow);
1509 tableRow->setRowIndex(insertionRow); 1508 setRowLogicalHeightToRowStyleLogicalHeight(m_grid[insertionRow]);
1510 setRowLogicalHeightToRowStyleLogicalHeight(m_grid[insertionRow]);
1511 1509
1512 for (RenderObject* cell = tableRow->firstChild(); cell; cell = cell- >nextSibling()) { 1510 for (RenderTableCell* cell = row->firstCell(); cell; cell = cell->nextCe ll())
1513 if (!cell->isTableCell()) 1511 addCell(cell, row);
1514 continue;
1515
1516 RenderTableCell* tableCell = toRenderTableCell(cell);
1517 addCell(tableCell, tableRow);
1518 }
1519 }
1520 } 1512 }
1521 1513
1522 m_grid.shrinkToFit(); 1514 m_grid.shrinkToFit();
1523 setNeedsLayout(); 1515 setNeedsLayout();
1524 } 1516 }
1525 1517
1526 // FIXME: This function could be made O(1) in certain cases (like for the non-mo st-constrainive cells' case). 1518 // FIXME: This function could be made O(1) in certain cases (like for the non-mo st-constrainive cells' case).
1527 void RenderTableSection::rowLogicalHeightChanged(unsigned rowIndex) 1519 void RenderTableSection::rowLogicalHeightChanged(unsigned rowIndex)
1528 { 1520 {
1529 if (needsCellRecalc()) 1521 if (needsCellRecalc())
1530 return; 1522 return;
1531 1523
1532 setRowLogicalHeightToRowStyleLogicalHeight(m_grid[rowIndex]); 1524 setRowLogicalHeightToRowStyleLogicalHeight(m_grid[rowIndex]);
1533 1525
1534 for (RenderObject* cell = m_grid[rowIndex].rowRenderer->firstChild(); cell; cell = cell->nextSibling()) { 1526 for (RenderTableCell* cell = m_grid[rowIndex].rowRenderer->firstCell(); cell ; cell = cell->nextCell())
1535 if (!cell->isTableCell()) 1527 updateLogicalHeightForCell(m_grid[rowIndex], cell);
1536 continue;
1537
1538 updateLogicalHeightForCell(m_grid[rowIndex], toRenderTableCell(cell));
1539 }
1540 } 1528 }
1541 1529
1542 void RenderTableSection::setNeedsCellRecalc() 1530 void RenderTableSection::setNeedsCellRecalc()
1543 { 1531 {
1544 m_needsCellRecalc = true; 1532 m_needsCellRecalc = true;
1545 if (RenderTable* t = table()) 1533 if (RenderTable* t = table())
1546 t->setNeedsSectionRecalc(); 1534 t->setNeedsSectionRecalc();
1547 } 1535 }
1548 1536
1549 unsigned RenderTableSection::numColumns() const 1537 unsigned RenderTableSection::numColumns() const
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1615 } else { 1603 } else {
1616 r[pos + 1].inColSpan = 0; 1604 r[pos + 1].inColSpan = 0;
1617 } 1605 }
1618 } 1606 }
1619 } 1607 }
1620 1608
1621 // Hit Testing 1609 // Hit Testing
1622 bool RenderTableSection::nodeAtPoint(const HitTestRequest& request, HitTestResul t& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumu latedOffset, HitTestAction action) 1610 bool RenderTableSection::nodeAtPoint(const HitTestRequest& request, HitTestResul t& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumu latedOffset, HitTestAction action)
1623 { 1611 {
1624 // If we have no children then we have nothing to do. 1612 // If we have no children then we have nothing to do.
1625 if (!firstChild()) 1613 if (!firstRow())
1626 return false; 1614 return false;
1627 1615
1628 // Table sections cannot ever be hit tested. Effectively they do not exist. 1616 // Table sections cannot ever be hit tested. Effectively they do not exist.
1629 // Just forward to our children always. 1617 // Just forward to our children always.
1630 LayoutPoint adjustedLocation = accumulatedOffset + location(); 1618 LayoutPoint adjustedLocation = accumulatedOffset + location();
1631 1619
1632 if (hasOverflowClip() && !locationInContainer.intersects(overflowClipRect(ad justedLocation))) 1620 if (hasOverflowClip() && !locationInContainer.intersects(overflowClipRect(ad justedLocation)))
1633 return false; 1621 return false;
1634 1622
1635 if (hasOverflowingCell()) { 1623 if (hasOverflowingCell()) {
1636 for (RenderObject* child = lastChild(); child; child = child->previousSi bling()) { 1624 for (RenderTableRow* row = lastRow(); row; row = row->previousRow()) {
1637 // FIXME: We have to skip over inline flows, since they can show up inside table rows 1625 // FIXME: We have to skip over inline flows, since they can show up inside table rows
1638 // at the moment (a demoted inline <form> for example). If we ever i mplement a 1626 // at the moment (a demoted inline <form> for example). If we ever i mplement a
1639 // table-specific hit-test method (which we should do for performanc e reasons anyway), 1627 // table-specific hit-test method (which we should do for performanc e reasons anyway),
1640 // then we can remove this check. 1628 // then we can remove this check.
1641 if (child->isBox() && !toRenderBox(child)->hasSelfPaintingLayer()) { 1629 if (!row->hasSelfPaintingLayer()) {
1642 LayoutPoint childPoint = flipForWritingModeForChild(toRenderBox( child), adjustedLocation); 1630 LayoutPoint childPoint = flipForWritingModeForChild(row, adjuste dLocation);
1643 if (child->nodeAtPoint(request, result, locationInContainer, chi ldPoint, action)) { 1631 if (row->nodeAtPoint(request, result, locationInContainer, child Point, action)) {
1644 updateHitTestResult(result, toLayoutPoint(locationInContaine r.point() - childPoint)); 1632 updateHitTestResult(result, toLayoutPoint(locationInContaine r.point() - childPoint));
1645 return true; 1633 return true;
1646 } 1634 }
1647 } 1635 }
1648 } 1636 }
1649 return false; 1637 return false;
1650 } 1638 }
1651 1639
1652 recalcCellsIfNeeded(); 1640 recalcCellsIfNeeded();
1653 1641
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1731 else 1719 else
1732 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont alBorderSpacing); 1720 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont alBorderSpacing);
1733 1721
1734 cell->setLogicalLocation(cellLocation); 1722 cell->setLogicalLocation(cellLocation);
1735 1723
1736 if (!RuntimeEnabledFeatures::repaintAfterLayoutEnabled()) 1724 if (!RuntimeEnabledFeatures::repaintAfterLayoutEnabled())
1737 view()->addLayoutDelta(oldCellLocation - cell->location()); 1725 view()->addLayoutDelta(oldCellLocation - cell->location());
1738 } 1726 }
1739 1727
1740 } // namespace WebCore 1728 } // namespace WebCore
OLDNEW
« Source/core/rendering/RenderBlock.h ('K') | « Source/core/rendering/RenderTableSection.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698