OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. | 2 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 const ComputedStyle& parentStyle, | 84 const ComputedStyle& parentStyle, |
85 const ComputedStyle& childStyle, | 85 const ComputedStyle& childStyle, |
86 bool isRoot) { | 86 bool isRoot) { |
87 return parentStyle.hasIdenticalAscentDescentAndLineGap(childStyle) && | 87 return parentStyle.hasIdenticalAscentDescentAndLineGap(childStyle) && |
88 parentStyle.lineHeight() == childStyle.lineHeight() && | 88 parentStyle.lineHeight() == childStyle.lineHeight() && |
89 (parentStyle.verticalAlign() == EVerticalAlign::kBaseline || isRoot) && | 89 (parentStyle.verticalAlign() == EVerticalAlign::kBaseline || isRoot) && |
90 childStyle.verticalAlign() == EVerticalAlign::kBaseline; | 90 childStyle.verticalAlign() == EVerticalAlign::kBaseline; |
91 } | 91 } |
92 | 92 |
93 void InlineFlowBox::addToLine(InlineBox* child) { | 93 void InlineFlowBox::addToLine(InlineBox* child) { |
94 ASSERT(!child->parent()); | 94 DCHECK(!child->parent()); |
95 ASSERT(!child->nextOnLine()); | 95 DCHECK(!child->nextOnLine()); |
96 ASSERT(!child->prevOnLine()); | 96 DCHECK(!child->prevOnLine()); |
97 checkConsistency(); | 97 checkConsistency(); |
98 | 98 |
99 child->setParent(this); | 99 child->setParent(this); |
100 if (!m_firstChild) { | 100 if (!m_firstChild) { |
101 m_firstChild = child; | 101 m_firstChild = child; |
102 m_lastChild = child; | 102 m_lastChild = child; |
103 } else { | 103 } else { |
104 m_lastChild->setNextOnLine(child); | 104 m_lastChild->setNextOnLine(child); |
105 child->setPrevOnLine(m_lastChild); | 105 child->setPrevOnLine(m_lastChild); |
106 m_lastChild = child; | 106 m_lastChild = child; |
(...skipping 29 matching lines...) Expand all Loading... |
136 childStyle.getTextEmphasisMark() != TextEmphasisMarkNone) | 136 childStyle.getTextEmphasisMark() != TextEmphasisMarkNone) |
137 shouldClearDescendantsHaveSameLineHeightAndBaseline = true; | 137 shouldClearDescendantsHaveSameLineHeightAndBaseline = true; |
138 } else { | 138 } else { |
139 if (child->getLineLayoutItem().isBR()) { | 139 if (child->getLineLayoutItem().isBR()) { |
140 // FIXME: This is dumb. We only turn off because current layout test | 140 // FIXME: This is dumb. We only turn off because current layout test |
141 // results expect the <br> to be 0-height on the baseline. | 141 // results expect the <br> to be 0-height on the baseline. |
142 // Other than making a zillion tests have to regenerate results, there's | 142 // Other than making a zillion tests have to regenerate results, there's |
143 // no reason to ditch the optimization here. | 143 // no reason to ditch the optimization here. |
144 shouldClearDescendantsHaveSameLineHeightAndBaseline = true; | 144 shouldClearDescendantsHaveSameLineHeightAndBaseline = true; |
145 } else { | 145 } else { |
146 ASSERT(isInlineFlowBox()); | 146 DCHECK(isInlineFlowBox()); |
147 InlineFlowBox* childFlowBox = toInlineFlowBox(child); | 147 InlineFlowBox* childFlowBox = toInlineFlowBox(child); |
148 // Check the child's bit, and then also check for differences in font, | 148 // Check the child's bit, and then also check for differences in font, |
149 // line-height, vertical-align | 149 // line-height, vertical-align |
150 if (!childFlowBox->descendantsHaveSameLineHeightAndBaseline() || | 150 if (!childFlowBox->descendantsHaveSameLineHeightAndBaseline() || |
151 !hasIdenticalLineHeightProperties(parentStyle, childStyle, root) || | 151 !hasIdenticalLineHeightProperties(parentStyle, childStyle, root) || |
152 childStyle.hasBorder() || childStyle.hasPadding() || | 152 childStyle.hasBorder() || childStyle.hasPadding() || |
153 childStyle.hasTextCombine()) { | 153 childStyle.hasTextCombine()) { |
154 shouldClearDescendantsHaveSameLineHeightAndBaseline = true; | 154 shouldClearDescendantsHaveSameLineHeightAndBaseline = true; |
155 } | 155 } |
156 } | 156 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 | 216 |
217 child->setParent(nullptr); | 217 child->setParent(nullptr); |
218 | 218 |
219 checkConsistency(); | 219 checkConsistency(); |
220 } | 220 } |
221 | 221 |
222 void InlineFlowBox::deleteLine() { | 222 void InlineFlowBox::deleteLine() { |
223 InlineBox* child = firstChild(); | 223 InlineBox* child = firstChild(); |
224 InlineBox* next = nullptr; | 224 InlineBox* next = nullptr; |
225 while (child) { | 225 while (child) { |
226 ASSERT(this == child->parent()); | 226 DCHECK_EQ(this, child->parent()); |
227 next = child->nextOnLine(); | 227 next = child->nextOnLine(); |
228 #if DCHECK_IS_ON() | 228 #if DCHECK_IS_ON() |
229 child->setParent(nullptr); | 229 child->setParent(nullptr); |
230 #endif | 230 #endif |
231 child->deleteLine(); | 231 child->deleteLine(); |
232 child = next; | 232 child = next; |
233 } | 233 } |
234 #if DCHECK_IS_ON() | 234 #if DCHECK_IS_ON() |
235 m_firstChild = nullptr; | 235 m_firstChild = nullptr; |
236 m_lastChild = nullptr; | 236 m_lastChild = nullptr; |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 LineLayoutBoxModel(curr->getLineLayoutItem()); | 763 LineLayoutBoxModel(curr->getLineLayoutItem()); |
764 newLogicalTop -= boxObject.borderAndPaddingOver(); | 764 newLogicalTop -= boxObject.borderAndPaddingOver(); |
765 borderPaddingHeight = boxObject.borderAndPaddingLogicalHeight(); | 765 borderPaddingHeight = boxObject.borderAndPaddingLogicalHeight(); |
766 } | 766 } |
767 newLogicalTopIncludingMargins = newLogicalTop; | 767 newLogicalTopIncludingMargins = newLogicalTop; |
768 } else if (!curr->getLineLayoutItem().isBR()) { | 768 } else if (!curr->getLineLayoutItem().isBR()) { |
769 LineLayoutBox box = LineLayoutBox(curr->getLineLayoutItem()); | 769 LineLayoutBox box = LineLayoutBox(curr->getLineLayoutItem()); |
770 newLogicalTopIncludingMargins = newLogicalTop; | 770 newLogicalTopIncludingMargins = newLogicalTop; |
771 // TODO(kojii): isHorizontal() does not match to | 771 // TODO(kojii): isHorizontal() does not match to |
772 // m_layoutObject.isHorizontalWritingMode(). crbug.com/552954 | 772 // m_layoutObject.isHorizontalWritingMode(). crbug.com/552954 |
773 // ASSERT(curr->isHorizontal() == | 773 // DCHECK_EQ(curr->isHorizontal(), |
774 // curr->getLineLayoutItem().style()->isHorizontalWritingMode()); | 774 // curr->getLineLayoutItem().style()->isHorizontalWritingMode()); |
775 // We may flip lines in case of verticalLR mode, so we can | 775 // We may flip lines in case of verticalLR mode, so we can |
776 // assume verticalRL for now. | 776 // assume verticalRL for now. |
777 LayoutUnit overSideMargin = | 777 LayoutUnit overSideMargin = |
778 curr->isHorizontal() ? box.marginTop() : box.marginRight(); | 778 curr->isHorizontal() ? box.marginTop() : box.marginRight(); |
779 LayoutUnit underSideMargin = | 779 LayoutUnit underSideMargin = |
780 curr->isHorizontal() ? box.marginBottom() : box.marginLeft(); | 780 curr->isHorizontal() ? box.marginBottom() : box.marginLeft(); |
781 newLogicalTop += overSideMargin; | 781 newLogicalTop += overSideMargin; |
782 boxHeightIncludingMargins += overSideMargin + underSideMargin; | 782 boxHeightIncludingMargins += overSideMargin + underSideMargin; |
783 } | 783 } |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1195 it->value.second = glyphOverflow; | 1195 it->value.second = glyphOverflow; |
1196 } | 1196 } |
1197 } | 1197 } |
1198 | 1198 |
1199 void InlineFlowBox::computeOverflow( | 1199 void InlineFlowBox::computeOverflow( |
1200 LayoutUnit lineTop, | 1200 LayoutUnit lineTop, |
1201 LayoutUnit lineBottom, | 1201 LayoutUnit lineBottom, |
1202 GlyphOverflowAndFallbackFontsMap& textBoxDataMap) { | 1202 GlyphOverflowAndFallbackFontsMap& textBoxDataMap) { |
1203 // If we know we have no overflow, we can just bail. | 1203 // If we know we have no overflow, we can just bail. |
1204 if (knownToHaveNoOverflow()) { | 1204 if (knownToHaveNoOverflow()) { |
1205 ASSERT(!m_overflow); | 1205 DCHECK(!m_overflow); |
1206 return; | 1206 return; |
1207 } | 1207 } |
1208 | 1208 |
1209 if (m_overflow) | 1209 if (m_overflow) |
1210 m_overflow.reset(); | 1210 m_overflow.reset(); |
1211 | 1211 |
1212 // Visual overflow just includes overflow for stuff we need to issues paint | 1212 // Visual overflow just includes overflow for stuff we need to issues paint |
1213 // invalidations for ourselves. Self-painting layers are ignored. | 1213 // invalidations for ourselves. Self-painting layers are ignored. |
1214 // Layout overflow is used to determine scrolling extent, so it still includes | 1214 // Layout overflow is used to determine scrolling extent, so it still includes |
1215 // child layers and also factors in transforms, relative positioning, etc. | 1215 // child layers and also factors in transforms, relative positioning, etc. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1257 logicalVisualOverflow); | 1257 logicalVisualOverflow); |
1258 } | 1258 } |
1259 } | 1259 } |
1260 | 1260 |
1261 setOverflowFromLogicalRects(logicalLayoutOverflow, logicalVisualOverflow, | 1261 setOverflowFromLogicalRects(logicalLayoutOverflow, logicalVisualOverflow, |
1262 lineTop, lineBottom); | 1262 lineTop, lineBottom); |
1263 } | 1263 } |
1264 | 1264 |
1265 void InlineFlowBox::setLayoutOverflow(const LayoutRect& rect, | 1265 void InlineFlowBox::setLayoutOverflow(const LayoutRect& rect, |
1266 const LayoutRect& frameBox) { | 1266 const LayoutRect& frameBox) { |
1267 ASSERT(!knownToHaveNoOverflow()); | 1267 DCHECK(!knownToHaveNoOverflow()); |
1268 if (frameBox.contains(rect) || rect.isEmpty()) | 1268 if (frameBox.contains(rect) || rect.isEmpty()) |
1269 return; | 1269 return; |
1270 | 1270 |
1271 if (!m_overflow) | 1271 if (!m_overflow) |
1272 m_overflow = WTF::makeUnique<SimpleOverflowModel>(frameBox, frameBox); | 1272 m_overflow = WTF::makeUnique<SimpleOverflowModel>(frameBox, frameBox); |
1273 | 1273 |
1274 m_overflow->setLayoutOverflow(rect); | 1274 m_overflow->setLayoutOverflow(rect); |
1275 } | 1275 } |
1276 | 1276 |
1277 void InlineFlowBox::setVisualOverflow(const LayoutRect& rect, | 1277 void InlineFlowBox::setVisualOverflow(const LayoutRect& rect, |
1278 const LayoutRect& frameBox) { | 1278 const LayoutRect& frameBox) { |
1279 ASSERT(!knownToHaveNoOverflow()); | 1279 DCHECK(!knownToHaveNoOverflow()); |
1280 if (frameBox.contains(rect) || rect.isEmpty()) | 1280 if (frameBox.contains(rect) || rect.isEmpty()) |
1281 return; | 1281 return; |
1282 | 1282 |
1283 if (!m_overflow) | 1283 if (!m_overflow) |
1284 m_overflow = WTF::makeUnique<SimpleOverflowModel>(frameBox, frameBox); | 1284 m_overflow = WTF::makeUnique<SimpleOverflowModel>(frameBox, frameBox); |
1285 | 1285 |
1286 m_overflow->setVisualOverflow(rect); | 1286 m_overflow->setVisualOverflow(rect); |
1287 } | 1287 } |
1288 | 1288 |
1289 void InlineFlowBox::setOverflowFromLogicalRects( | 1289 void InlineFlowBox::setOverflowFromLogicalRects( |
1290 const LayoutRect& logicalLayoutOverflow, | 1290 const LayoutRect& logicalLayoutOverflow, |
1291 const LayoutRect& logicalVisualOverflow, | 1291 const LayoutRect& logicalVisualOverflow, |
1292 LayoutUnit lineTop, | 1292 LayoutUnit lineTop, |
1293 LayoutUnit lineBottom) { | 1293 LayoutUnit lineBottom) { |
1294 ASSERT(!knownToHaveNoOverflow()); | 1294 DCHECK(!knownToHaveNoOverflow()); |
1295 LayoutRect frameBox = frameRectIncludingLineHeight(lineTop, lineBottom); | 1295 LayoutRect frameBox = frameRectIncludingLineHeight(lineTop, lineBottom); |
1296 | 1296 |
1297 LayoutRect layoutOverflow(isHorizontal() | 1297 LayoutRect layoutOverflow(isHorizontal() |
1298 ? logicalLayoutOverflow | 1298 ? logicalLayoutOverflow |
1299 : logicalLayoutOverflow.transposedRect()); | 1299 : logicalLayoutOverflow.transposedRect()); |
1300 setLayoutOverflow(layoutOverflow, frameBox); | 1300 setLayoutOverflow(layoutOverflow, frameBox); |
1301 | 1301 |
1302 LayoutRect visualOverflow(isHorizontal() | 1302 LayoutRect visualOverflow(isHorizontal() |
1303 ? logicalVisualOverflow | 1303 ? logicalVisualOverflow |
1304 : logicalVisualOverflow.transposedRect()); | 1304 : logicalVisualOverflow.transposedRect()); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1348 LineLayoutItem currLayoutItem = curr->getLineLayoutItem(); | 1348 LineLayoutItem currLayoutItem = curr->getLineLayoutItem(); |
1349 while (true) { | 1349 while (true) { |
1350 // If the previous inline box is not a descendant of a current inline's | 1350 // If the previous inline box is not a descendant of a current inline's |
1351 // parent, the parent is a culled inline and we hit test it. | 1351 // parent, the parent is a culled inline and we hit test it. |
1352 // Otherwise, move to the previous inline box because we hit test first | 1352 // Otherwise, move to the previous inline box because we hit test first |
1353 // all candidate inline boxes under the parent to take a pre-order tree | 1353 // all candidate inline boxes under the parent to take a pre-order tree |
1354 // traversal in reverse. | 1354 // traversal in reverse. |
1355 bool hasSibling = | 1355 bool hasSibling = |
1356 currLayoutItem.previousSibling() || currLayoutItem.nextSibling(); | 1356 currLayoutItem.previousSibling() || currLayoutItem.nextSibling(); |
1357 LineLayoutItem culledParent = currLayoutItem.parent(); | 1357 LineLayoutItem culledParent = currLayoutItem.parent(); |
1358 ASSERT(culledParent); | 1358 DCHECK(culledParent); |
1359 | 1359 |
1360 if (culledParent == getLineLayoutItem() || | 1360 if (culledParent == getLineLayoutItem() || |
1361 (hasSibling && prev && | 1361 (hasSibling && prev && |
1362 prev->getLineLayoutItem().isDescendantOf(culledParent))) | 1362 prev->getLineLayoutItem().isDescendantOf(culledParent))) |
1363 break; | 1363 break; |
1364 | 1364 |
1365 if (culledParent.isLayoutInline() && | 1365 if (culledParent.isLayoutInline() && |
1366 LineLayoutInline(culledParent) | 1366 LineLayoutInline(culledParent) |
1367 .hitTestCulledInline(result, locationInContainer, | 1367 .hitTestCulledInline(result, locationInContainer, |
1368 accumulatedOffset)) | 1368 accumulatedOffset)) |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1716 for (const InlineBox* box = firstChild(); box; box = box->nextOnLine()) | 1716 for (const InlineBox* box = firstChild(); box; box = box->nextOnLine()) |
1717 box->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLabel2, | 1717 box->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLabel2, |
1718 obj, depth + 1); | 1718 obj, depth + 1); |
1719 } | 1719 } |
1720 | 1720 |
1721 #endif | 1721 #endif |
1722 | 1722 |
1723 #if DCHECK_IS_ON() | 1723 #if DCHECK_IS_ON() |
1724 void InlineFlowBox::checkConsistency() const { | 1724 void InlineFlowBox::checkConsistency() const { |
1725 #ifdef CHECK_CONSISTENCY | 1725 #ifdef CHECK_CONSISTENCY |
1726 ASSERT(!m_hasBadChildList); | 1726 DCHECK(!m_hasBadChildList); |
1727 const InlineBox* prev = nullptr; | 1727 const InlineBox* prev = nullptr; |
1728 for (const InlineBox* child = m_firstChild; child; | 1728 for (const InlineBox* child = m_firstChild; child; |
1729 child = child->nextOnLine()) { | 1729 child = child->nextOnLine()) { |
1730 ASSERT(child->parent() == this); | 1730 DCHECK_EQ(child->parent(), this); |
1731 ASSERT(child->prevOnLine() == prev); | 1731 DCHECK_EQ(child->prevOnLine(), prev); |
1732 prev = child; | 1732 prev = child; |
1733 } | 1733 } |
1734 ASSERT(prev == m_lastChild); | 1734 DCHECK_EQ(prev, m_lastChild); |
1735 #endif | 1735 #endif |
1736 } | 1736 } |
1737 | 1737 |
1738 #endif | 1738 #endif |
1739 | 1739 |
1740 } // namespace blink | 1740 } // namespace blink |
OLD | NEW |