OLD | NEW |
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, 2013 Apple Inc. All r
ights 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 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 , m_cCol(0) | 82 , m_cCol(0) |
83 , m_cRow(0) | 83 , m_cRow(0) |
84 , m_outerBorderStart(0) | 84 , m_outerBorderStart(0) |
85 , m_outerBorderEnd(0) | 85 , m_outerBorderEnd(0) |
86 , m_outerBorderBefore(0) | 86 , m_outerBorderBefore(0) |
87 , m_outerBorderAfter(0) | 87 , m_outerBorderAfter(0) |
88 , m_needsCellRecalc(false) | 88 , m_needsCellRecalc(false) |
89 , m_forceSlowPaintPathWithOverflowingCell(false) | 89 , m_forceSlowPaintPathWithOverflowingCell(false) |
90 , m_hasMultipleCellLevels(false) | 90 , m_hasMultipleCellLevels(false) |
91 { | 91 { |
92 // init RenderObject attributes | 92 // init LayoutObject attributes |
93 setInline(false); // our object is not Inline | 93 setInline(false); // our object is not Inline |
94 } | 94 } |
95 | 95 |
96 LayoutTableSection::~LayoutTableSection() | 96 LayoutTableSection::~LayoutTableSection() |
97 { | 97 { |
98 } | 98 } |
99 | 99 |
100 void LayoutTableSection::styleDidChange(StyleDifference diff, const RenderStyle*
oldStyle) | 100 void LayoutTableSection::styleDidChange(StyleDifference diff, const RenderStyle*
oldStyle) |
101 { | 101 { |
102 RenderBox::styleDidChange(diff, oldStyle); | 102 RenderBox::styleDidChange(diff, oldStyle); |
103 propagateStyleToAnonymousChildren(); | 103 propagateStyleToAnonymousChildren(); |
104 | 104 |
105 // If border was changed, notify table. | 105 // If border was changed, notify table. |
106 LayoutTable* table = this->table(); | 106 LayoutTable* table = this->table(); |
107 if (table && !table->selfNeedsLayout() && !table->normalChildNeedsLayout() &
& oldStyle && oldStyle->border() != style()->border()) | 107 if (table && !table->selfNeedsLayout() && !table->normalChildNeedsLayout() &
& oldStyle && oldStyle->border() != style()->border()) |
108 table->invalidateCollapsedBorders(); | 108 table->invalidateCollapsedBorders(); |
109 } | 109 } |
110 | 110 |
111 void LayoutTableSection::willBeRemovedFromTree() | 111 void LayoutTableSection::willBeRemovedFromTree() |
112 { | 112 { |
113 RenderBox::willBeRemovedFromTree(); | 113 RenderBox::willBeRemovedFromTree(); |
114 | 114 |
115 // Preventively invalidate our cells as we may be re-inserted into | 115 // Preventively invalidate our cells as we may be re-inserted into |
116 // a new table which would require us to rebuild our structure. | 116 // a new table which would require us to rebuild our structure. |
117 setNeedsCellRecalc(); | 117 setNeedsCellRecalc(); |
118 } | 118 } |
119 | 119 |
120 void LayoutTableSection::addChild(RenderObject* child, RenderObject* beforeChild
) | 120 void LayoutTableSection::addChild(LayoutObject* child, LayoutObject* beforeChild
) |
121 { | 121 { |
122 if (!child->isTableRow()) { | 122 if (!child->isTableRow()) { |
123 RenderObject* last = beforeChild; | 123 LayoutObject* last = beforeChild; |
124 if (!last) | 124 if (!last) |
125 last = lastRow(); | 125 last = lastRow(); |
126 if (last && last->isAnonymous() && !last->isBeforeOrAfterContent()) { | 126 if (last && last->isAnonymous() && !last->isBeforeOrAfterContent()) { |
127 if (beforeChild == last) | 127 if (beforeChild == last) |
128 beforeChild = last->slowFirstChild(); | 128 beforeChild = last->slowFirstChild(); |
129 last->addChild(child, beforeChild); | 129 last->addChild(child, beforeChild); |
130 return; | 130 return; |
131 } | 131 } |
132 | 132 |
133 if (beforeChild && !beforeChild->isAnonymous() && beforeChild->parent()
== this) { | 133 if (beforeChild && !beforeChild->isAnonymous() && beforeChild->parent()
== this) { |
134 RenderObject* row = beforeChild->previousSibling(); | 134 LayoutObject* row = beforeChild->previousSibling(); |
135 if (row && row->isTableRow() && row->isAnonymous()) { | 135 if (row && row->isTableRow() && row->isAnonymous()) { |
136 row->addChild(child); | 136 row->addChild(child); |
137 return; | 137 return; |
138 } | 138 } |
139 } | 139 } |
140 | 140 |
141 // If beforeChild is inside an anonymous cell/row, insert into the cell
or into | 141 // If beforeChild is inside an anonymous cell/row, insert into the cell
or into |
142 // the anonymous row containing it, if there is one. | 142 // the anonymous row containing it, if there is one. |
143 RenderObject* lastBox = last; | 143 LayoutObject* lastBox = last; |
144 while (lastBox && lastBox->parent()->isAnonymous() && !lastBox->isTableR
ow()) | 144 while (lastBox && lastBox->parent()->isAnonymous() && !lastBox->isTableR
ow()) |
145 lastBox = lastBox->parent(); | 145 lastBox = lastBox->parent(); |
146 if (lastBox && lastBox->isAnonymous() && !lastBox->isBeforeOrAfterConten
t()) { | 146 if (lastBox && lastBox->isAnonymous() && !lastBox->isBeforeOrAfterConten
t()) { |
147 lastBox->addChild(child, beforeChild); | 147 lastBox->addChild(child, beforeChild); |
148 return; | 148 return; |
149 } | 149 } |
150 | 150 |
151 RenderObject* row = LayoutTableRow::createAnonymousWithParentRenderer(th
is); | 151 LayoutObject* row = LayoutTableRow::createAnonymousWithParentRenderer(th
is); |
152 addChild(row, beforeChild); | 152 addChild(row, beforeChild); |
153 row->addChild(child); | 153 row->addChild(child); |
154 return; | 154 return; |
155 } | 155 } |
156 | 156 |
157 if (beforeChild) | 157 if (beforeChild) |
158 setNeedsCellRecalc(); | 158 setNeedsCellRecalc(); |
159 | 159 |
160 unsigned insertionRow = m_cRow; | 160 unsigned insertionRow = m_cRow; |
161 ++m_cRow; | 161 ++m_cRow; |
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
908 totalPercent += m_grid[r].logicalHeight.percent(); | 908 totalPercent += m_grid[r].logicalHeight.percent(); |
909 } | 909 } |
910 | 910 |
911 int remainingExtraLogicalHeight = extraLogicalHeight; | 911 int remainingExtraLogicalHeight = extraLogicalHeight; |
912 distributeExtraLogicalHeightToPercentRows(remainingExtraLogicalHeight, total
Percent); | 912 distributeExtraLogicalHeightToPercentRows(remainingExtraLogicalHeight, total
Percent); |
913 distributeExtraLogicalHeightToAutoRows(remainingExtraLogicalHeight, autoRows
Count); | 913 distributeExtraLogicalHeightToAutoRows(remainingExtraLogicalHeight, autoRows
Count); |
914 distributeRemainingExtraLogicalHeight(remainingExtraLogicalHeight); | 914 distributeRemainingExtraLogicalHeight(remainingExtraLogicalHeight); |
915 return extraLogicalHeight - remainingExtraLogicalHeight; | 915 return extraLogicalHeight - remainingExtraLogicalHeight; |
916 } | 916 } |
917 | 917 |
918 static bool shouldFlexCellChild(RenderObject* cellDescendant) | 918 static bool shouldFlexCellChild(LayoutObject* cellDescendant) |
919 { | 919 { |
920 return cellDescendant->isReplaced() || (cellDescendant->isBox() && toRenderB
ox(cellDescendant)->scrollsOverflow()); | 920 return cellDescendant->isReplaced() || (cellDescendant->isBox() && toRenderB
ox(cellDescendant)->scrollsOverflow()); |
921 } | 921 } |
922 | 922 |
923 void LayoutTableSection::layoutRows() | 923 void LayoutTableSection::layoutRows() |
924 { | 924 { |
925 #if ENABLE(ASSERT) | 925 #if ENABLE(ASSERT) |
926 SetLayoutNeededForbiddenScope layoutForbiddenScope(*this); | 926 SetLayoutNeededForbiddenScope layoutForbiddenScope(*this); |
927 #endif | 927 #endif |
928 | 928 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
977 // time only). We may also not be handling row-spanning cells corre
ctly. | 977 // time only). We may also not be handling row-spanning cells corre
ctly. |
978 // | 978 // |
979 // Note also the oddity where replaced elements always flex, and yet
blocks/tables do | 979 // Note also the oddity where replaced elements always flex, and yet
blocks/tables do |
980 // not necessarily flex. WinIE is crazy and inconsistent, and we ca
n't hope to | 980 // not necessarily flex. WinIE is crazy and inconsistent, and we ca
n't hope to |
981 // match the behavior perfectly, but we'll continue to refine it as
we discover new | 981 // match the behavior perfectly, but we'll continue to refine it as
we discover new |
982 // bugs. :) | 982 // bugs. :) |
983 bool cellChildrenFlex = false; | 983 bool cellChildrenFlex = false; |
984 bool flexAllChildren = cell->style()->logicalHeight().isFixed() | 984 bool flexAllChildren = cell->style()->logicalHeight().isFixed() |
985 || (!table()->style()->logicalHeight().isAuto() && rHeight != ce
ll->logicalHeight()); | 985 || (!table()->style()->logicalHeight().isAuto() && rHeight != ce
ll->logicalHeight()); |
986 | 986 |
987 for (RenderObject* child = cell->firstChild(); child; child = child-
>nextSibling()) { | 987 for (LayoutObject* child = cell->firstChild(); child; child = child-
>nextSibling()) { |
988 if (!child->isText() && child->style()->logicalHeight().isPercen
t() | 988 if (!child->isText() && child->style()->logicalHeight().isPercen
t() |
989 && (flexAllChildren || shouldFlexCellChild(child)) | 989 && (flexAllChildren || shouldFlexCellChild(child)) |
990 && (!child->isTable() || toLayoutTable(child)->hasSections()
)) { | 990 && (!child->isTable() || toLayoutTable(child)->hasSections()
)) { |
991 cellChildrenFlex = true; | 991 cellChildrenFlex = true; |
992 break; | 992 break; |
993 } | 993 } |
994 } | 994 } |
995 | 995 |
996 if (!cellChildrenFlex) { | 996 if (!cellChildrenFlex) { |
997 if (TrackedRendererListHashSet* percentHeightDescendants = cell-
>percentHeightDescendants()) { | 997 if (TrackedRendererListHashSet* percentHeightDescendants = cell-
>percentHeightDescendants()) { |
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1542 CellStruct& current = cellAt(hitRow, hitColumn); | 1542 CellStruct& current = cellAt(hitRow, hitColumn); |
1543 | 1543 |
1544 // If the cell is empty, there's nothing to do | 1544 // If the cell is empty, there's nothing to do |
1545 if (!current.hasCells()) | 1545 if (!current.hasCells()) |
1546 continue; | 1546 continue; |
1547 | 1547 |
1548 for (unsigned i = current.cells.size() ; i; ) { | 1548 for (unsigned i = current.cells.size() ; i; ) { |
1549 --i; | 1549 --i; |
1550 LayoutTableCell* cell = current.cells[i]; | 1550 LayoutTableCell* cell = current.cells[i]; |
1551 LayoutPoint cellPoint = flipForWritingModeForChild(cell, adjuste
dLocation); | 1551 LayoutPoint cellPoint = flipForWritingModeForChild(cell, adjuste
dLocation); |
1552 if (static_cast<RenderObject*>(cell)->nodeAtPoint(request, resul
t, locationInContainer, cellPoint, action)) { | 1552 if (static_cast<LayoutObject*>(cell)->nodeAtPoint(request, resul
t, locationInContainer, cellPoint, action)) { |
1553 updateHitTestResult(result, locationInContainer.point() - to
LayoutSize(cellPoint)); | 1553 updateHitTestResult(result, locationInContainer.point() - to
LayoutSize(cellPoint)); |
1554 return true; | 1554 return true; |
1555 } | 1555 } |
1556 } | 1556 } |
1557 if (!result.isRectBasedTest()) | 1557 if (!result.isRectBasedTest()) |
1558 break; | 1558 break; |
1559 } | 1559 } |
1560 if (!result.isRectBasedTest()) | 1560 if (!result.isRectBasedTest()) |
1561 break; | 1561 break; |
1562 } | 1562 } |
(...skipping 17 matching lines...) Expand all Loading... |
1580 } | 1580 } |
1581 | 1581 |
1582 CollapsedBorderValue& LayoutTableSection::cachedCollapsedBorder(const LayoutTabl
eCell* cell, CollapsedBorderSide side) | 1582 CollapsedBorderValue& LayoutTableSection::cachedCollapsedBorder(const LayoutTabl
eCell* cell, CollapsedBorderSide side) |
1583 { | 1583 { |
1584 ASSERT(table()->collapseBorders()); | 1584 ASSERT(table()->collapseBorders()); |
1585 HashMap<pair<const LayoutTableCell*, int>, CollapsedBorderValue>::iterator i
t = m_cellsCollapsedBorders.find(std::make_pair(cell, side)); | 1585 HashMap<pair<const LayoutTableCell*, int>, CollapsedBorderValue>::iterator i
t = m_cellsCollapsedBorders.find(std::make_pair(cell, side)); |
1586 ASSERT_WITH_SECURITY_IMPLICATION(it != m_cellsCollapsedBorders.end()); | 1586 ASSERT_WITH_SECURITY_IMPLICATION(it != m_cellsCollapsedBorders.end()); |
1587 return it->value; | 1587 return it->value; |
1588 } | 1588 } |
1589 | 1589 |
1590 LayoutTableSection* LayoutTableSection::createAnonymousWithParentRenderer(const
RenderObject* parent) | 1590 LayoutTableSection* LayoutTableSection::createAnonymousWithParentRenderer(const
LayoutObject* parent) |
1591 { | 1591 { |
1592 RefPtr<RenderStyle> newStyle = RenderStyle::createAnonymousStyleWithDisplay(
parent->style(), TABLE_ROW_GROUP); | 1592 RefPtr<RenderStyle> newStyle = RenderStyle::createAnonymousStyleWithDisplay(
parent->style(), TABLE_ROW_GROUP); |
1593 LayoutTableSection* newSection = new LayoutTableSection(0); | 1593 LayoutTableSection* newSection = new LayoutTableSection(0); |
1594 newSection->setDocumentForAnonymous(&parent->document()); | 1594 newSection->setDocumentForAnonymous(&parent->document()); |
1595 newSection->setStyle(newStyle.release()); | 1595 newSection->setStyle(newStyle.release()); |
1596 return newSection; | 1596 return newSection; |
1597 } | 1597 } |
1598 | 1598 |
1599 void LayoutTableSection::setLogicalPositionForCell(LayoutTableCell* cell, unsign
ed effectiveColumn) const | 1599 void LayoutTableSection::setLogicalPositionForCell(LayoutTableCell* cell, unsign
ed effectiveColumn) const |
1600 { | 1600 { |
1601 LayoutPoint cellLocation(0, m_rowPos[cell->rowIndex()]); | 1601 LayoutPoint cellLocation(0, m_rowPos[cell->rowIndex()]); |
1602 int horizontalBorderSpacing = table()->hBorderSpacing(); | 1602 int horizontalBorderSpacing = table()->hBorderSpacing(); |
1603 | 1603 |
1604 // FIXME: The table's direction should determine our row's direction, not th
e section's (see bug 96691). | 1604 // FIXME: The table's direction should determine our row's direction, not th
e section's (see bug 96691). |
1605 if (!style()->isLeftToRightDirection()) | 1605 if (!style()->isLeftToRightDirection()) |
1606 cellLocation.setX(table()->columnPositions()[table()->numEffCols()] - ta
ble()->columnPositions()[table()->colToEffCol(cell->col() + cell->colSpan())] +
horizontalBorderSpacing); | 1606 cellLocation.setX(table()->columnPositions()[table()->numEffCols()] - ta
ble()->columnPositions()[table()->colToEffCol(cell->col() + cell->colSpan())] +
horizontalBorderSpacing); |
1607 else | 1607 else |
1608 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont
alBorderSpacing); | 1608 cellLocation.setX(table()->columnPositions()[effectiveColumn] + horizont
alBorderSpacing); |
1609 | 1609 |
1610 cell->setLogicalLocation(cellLocation); | 1610 cell->setLogicalLocation(cellLocation); |
1611 } | 1611 } |
1612 | 1612 |
1613 } // namespace blink | 1613 } // namespace blink |
OLD | NEW |