OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2007 David Smith (catfish.man@gmail.com) | 4 * (C) 2007 David Smith (catfish.man@gmail.com) |
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. |
6 * All rights reserved. | 6 * All rights reserved. |
7 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 7 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
102 m_hasPercentHeightDescendants(false), | 102 m_hasPercentHeightDescendants(false), |
103 m_paginationStateChanged(false) { | 103 m_paginationStateChanged(false) { |
104 // LayoutBlockFlow calls setChildrenInline(true). | 104 // LayoutBlockFlow calls setChildrenInline(true). |
105 // By default, subclasses do not have inline children. | 105 // By default, subclasses do not have inline children. |
106 } | 106 } |
107 | 107 |
108 void LayoutBlock::removeFromGlobalMaps() { | 108 void LayoutBlock::removeFromGlobalMaps() { |
109 if (hasPositionedObjects()) { | 109 if (hasPositionedObjects()) { |
110 std::unique_ptr<TrackedLayoutBoxListHashSet> descendants = | 110 std::unique_ptr<TrackedLayoutBoxListHashSet> descendants = |
111 gPositionedDescendantsMap->take(this); | 111 gPositionedDescendantsMap->take(this); |
112 ASSERT(!descendants->isEmpty()); | 112 DCHECK(!descendants->isEmpty()); |
113 for (LayoutBox* descendant : *descendants) { | 113 for (LayoutBox* descendant : *descendants) { |
114 ASSERT(gPositionedContainerMap->at(descendant) == this); | 114 DCHECK(gPositionedContainerMap->at(descendant) == this); |
tkent
2017/04/04 01:36:17
Use DCHECK_EQ
mrunal
2017/04/05 00:39:14
Done.
| |
115 gPositionedContainerMap->erase(descendant); | 115 gPositionedContainerMap->erase(descendant); |
116 } | 116 } |
117 } | 117 } |
118 if (hasPercentHeightDescendants()) { | 118 if (hasPercentHeightDescendants()) { |
119 std::unique_ptr<TrackedLayoutBoxListHashSet> descendants = | 119 std::unique_ptr<TrackedLayoutBoxListHashSet> descendants = |
120 gPercentHeightDescendantsMap->take(this); | 120 gPercentHeightDescendantsMap->take(this); |
121 ASSERT(!descendants->isEmpty()); | 121 DCHECK(!descendants->isEmpty()); |
122 for (LayoutBox* descendant : *descendants) { | 122 for (LayoutBox* descendant : *descendants) { |
123 ASSERT(descendant->percentHeightContainer() == this); | 123 DCHECK(descendant->percentHeightContainer() == this); |
tkent
2017/04/04 01:36:17
Use DCHECK_EQ
mrunal
2017/04/05 00:39:14
Done.
| |
124 descendant->setPercentHeightContainer(nullptr); | 124 descendant->setPercentHeightContainer(nullptr); |
125 } | 125 } |
126 } | 126 } |
127 } | 127 } |
128 | 128 |
129 LayoutBlock::~LayoutBlock() { | 129 LayoutBlock::~LayoutBlock() { |
130 removeFromGlobalMaps(); | 130 removeFromGlobalMaps(); |
131 } | 131 } |
132 | 132 |
133 void LayoutBlock::willBeDestroyed() { | 133 void LayoutBlock::willBeDestroyed() { |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
283 setHasOverflowClip(shouldClipOverflow); | 283 setHasOverflowClip(shouldClipOverflow); |
284 } | 284 } |
285 | 285 |
286 bool LayoutBlock::allowsOverflowClip() const { | 286 bool LayoutBlock::allowsOverflowClip() const { |
287 // If overflow has been propagated to the viewport, it has no effect here. | 287 // If overflow has been propagated to the viewport, it has no effect here. |
288 return node() != document().viewportDefiningElement(); | 288 return node() != document().viewportDefiningElement(); |
289 } | 289 } |
290 | 290 |
291 void LayoutBlock::addChildBeforeDescendant(LayoutObject* newChild, | 291 void LayoutBlock::addChildBeforeDescendant(LayoutObject* newChild, |
292 LayoutObject* beforeDescendant) { | 292 LayoutObject* beforeDescendant) { |
293 ASSERT(beforeDescendant->parent() != this); | 293 DCHECK_NE(beforeDescendant->parent(), this); |
294 LayoutObject* beforeDescendantContainer = beforeDescendant->parent(); | 294 LayoutObject* beforeDescendantContainer = beforeDescendant->parent(); |
295 while (beforeDescendantContainer->parent() != this) | 295 while (beforeDescendantContainer->parent() != this) |
296 beforeDescendantContainer = beforeDescendantContainer->parent(); | 296 beforeDescendantContainer = beforeDescendantContainer->parent(); |
297 ASSERT(beforeDescendantContainer); | 297 DCHECK(beforeDescendantContainer); |
298 | 298 |
299 // We really can't go on if what we have found isn't anonymous. We're not | 299 // We really can't go on if what we have found isn't anonymous. We're not |
300 // supposed to use some random non-anonymous object and put the child there. | 300 // supposed to use some random non-anonymous object and put the child there. |
301 // That's a recipe for security issues. | 301 // That's a recipe for security issues. |
302 CHECK(beforeDescendantContainer->isAnonymous()); | 302 CHECK(beforeDescendantContainer->isAnonymous()); |
303 | 303 |
304 // If the requested insertion point is not one of our children, then this is | 304 // If the requested insertion point is not one of our children, then this is |
305 // because there is an anonymous container within this object that contains | 305 // because there is an anonymous container within this object that contains |
306 // the beforeDescendant. | 306 // the beforeDescendant. |
307 if (beforeDescendantContainer->isAnonymousBlock() | 307 if (beforeDescendantContainer->isAnonymousBlock() |
308 // Full screen layoutObjects and full screen placeholders act as anonymous | 308 // Full screen layoutObjects and full screen placeholders act as anonymous |
309 // blocks, not tables: | 309 // blocks, not tables: |
310 || beforeDescendantContainer->isLayoutFullScreen() || | 310 || beforeDescendantContainer->isLayoutFullScreen() || |
311 beforeDescendantContainer->isLayoutFullScreenPlaceholder()) { | 311 beforeDescendantContainer->isLayoutFullScreenPlaceholder()) { |
312 // Insert the child into the anonymous block box instead of here. | 312 // Insert the child into the anonymous block box instead of here. |
313 if (newChild->isInline() || newChild->isFloatingOrOutOfFlowPositioned() || | 313 if (newChild->isInline() || newChild->isFloatingOrOutOfFlowPositioned() || |
314 beforeDescendant->parent()->slowFirstChild() != beforeDescendant) | 314 beforeDescendant->parent()->slowFirstChild() != beforeDescendant) |
315 beforeDescendant->parent()->addChild(newChild, beforeDescendant); | 315 beforeDescendant->parent()->addChild(newChild, beforeDescendant); |
316 else | 316 else |
317 addChild(newChild, beforeDescendant->parent()); | 317 addChild(newChild, beforeDescendant->parent()); |
318 return; | 318 return; |
319 } | 319 } |
320 | 320 |
321 ASSERT(beforeDescendantContainer->isTable()); | 321 DCHECK(beforeDescendantContainer->isTable()); |
322 if (newChild->isTablePart()) { | 322 if (newChild->isTablePart()) { |
323 // Insert into the anonymous table. | 323 // Insert into the anonymous table. |
324 beforeDescendantContainer->addChild(newChild, beforeDescendant); | 324 beforeDescendantContainer->addChild(newChild, beforeDescendant); |
325 return; | 325 return; |
326 } | 326 } |
327 | 327 |
328 LayoutObject* beforeChild = splitAnonymousBoxesAroundChild(beforeDescendant); | 328 LayoutObject* beforeChild = splitAnonymousBoxesAroundChild(beforeDescendant); |
329 | 329 |
330 ASSERT(beforeChild->parent() == this); | 330 DCHECK_EQ(beforeChild->parent(), this); |
331 if (beforeChild->parent() != this) { | 331 if (beforeChild->parent() != this) { |
332 // We should never reach here. If we do, we need to use the | 332 // We should never reach here. If we do, we need to use the |
333 // safe fallback to use the topmost beforeChild container. | 333 // safe fallback to use the topmost beforeChild container. |
334 beforeChild = beforeDescendantContainer; | 334 beforeChild = beforeDescendantContainer; |
335 } | 335 } |
336 | 336 |
337 addChild(newChild, beforeChild); | 337 addChild(newChild, beforeChild); |
338 } | 338 } |
339 | 339 |
340 void LayoutBlock::addChild(LayoutObject* newChild, LayoutObject* beforeChild) { | 340 void LayoutBlock::addChild(LayoutObject* newChild, LayoutObject* beforeChild) { |
341 if (beforeChild && beforeChild->parent() != this) { | 341 if (beforeChild && beforeChild->parent() != this) { |
342 addChildBeforeDescendant(newChild, beforeChild); | 342 addChildBeforeDescendant(newChild, beforeChild); |
343 return; | 343 return; |
344 } | 344 } |
345 | 345 |
346 // Only LayoutBlockFlow should have inline children, and then we shouldn't be | 346 // Only LayoutBlockFlow should have inline children, and then we shouldn't be |
347 // here. | 347 // here. |
348 ASSERT(!childrenInline()); | 348 DCHECK(!childrenInline()); |
349 | 349 |
350 if (newChild->isInline() || newChild->isFloatingOrOutOfFlowPositioned()) { | 350 if (newChild->isInline() || newChild->isFloatingOrOutOfFlowPositioned()) { |
351 // If we're inserting an inline child but all of our children are blocks, | 351 // If we're inserting an inline child but all of our children are blocks, |
352 // then we have to make sure it is put into an anomyous block box. We try to | 352 // then we have to make sure it is put into an anomyous block box. We try to |
353 // use an existing anonymous box if possible, otherwise a new one is created | 353 // use an existing anonymous box if possible, otherwise a new one is created |
354 // and inserted into our list of children in the appropriate position. | 354 // and inserted into our list of children in the appropriate position. |
355 LayoutObject* afterChild = | 355 LayoutObject* afterChild = |
356 beforeChild ? beforeChild->previousSibling() : lastChild(); | 356 beforeChild ? beforeChild->previousSibling() : lastChild(); |
357 | 357 |
358 if (afterChild && afterChild->isAnonymousBlock()) { | 358 if (afterChild && afterChild->isAnonymousBlock()) { |
359 afterChild->addChild(newChild); | 359 afterChild->addChild(newChild); |
360 return; | 360 return; |
361 } | 361 } |
362 | 362 |
363 if (newChild->isInline()) { | 363 if (newChild->isInline()) { |
364 // No suitable existing anonymous box - create a new one. | 364 // No suitable existing anonymous box - create a new one. |
365 LayoutBlock* newBox = createAnonymousBlock(); | 365 LayoutBlock* newBox = createAnonymousBlock(); |
366 LayoutBox::addChild(newBox, beforeChild); | 366 LayoutBox::addChild(newBox, beforeChild); |
367 newBox->addChild(newChild); | 367 newBox->addChild(newChild); |
368 return; | 368 return; |
369 } | 369 } |
370 } | 370 } |
371 | 371 |
372 LayoutBox::addChild(newChild, beforeChild); | 372 LayoutBox::addChild(newChild, beforeChild); |
373 } | 373 } |
374 | 374 |
375 void LayoutBlock::removeLeftoverAnonymousBlock(LayoutBlock* child) { | 375 void LayoutBlock::removeLeftoverAnonymousBlock(LayoutBlock* child) { |
376 ASSERT(child->isAnonymousBlock()); | 376 DCHECK(child->isAnonymousBlock()); |
377 ASSERT(!child->childrenInline()); | 377 DCHECK(!child->childrenInline()); |
378 ASSERT(child->parent() == this); | 378 DCHECK_EQ(child->parent(), this); |
379 | 379 |
380 if (child->continuation()) | 380 if (child->continuation()) |
381 return; | 381 return; |
382 | 382 |
383 // Promote all the leftover anonymous block's children (to become children of | 383 // Promote all the leftover anonymous block's children (to become children of |
384 // this block instead). We still want to keep the leftover block in the tree | 384 // this block instead). We still want to keep the leftover block in the tree |
385 // for a moment, for notification purposes done further below (flow threads | 385 // for a moment, for notification purposes done further below (flow threads |
386 // and grids). | 386 // and grids). |
387 child->moveAllChildrenTo(this, child->nextSibling()); | 387 child->moveAllChildrenTo(this, child->nextSibling()); |
388 | 388 |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
929 if (inlineBoxWrapper() && canUpdateSelectionOnRootLineBoxes()) | 929 if (inlineBoxWrapper() && canUpdateSelectionOnRootLineBoxes()) |
930 inlineBoxWrapper()->root().setHasSelectedChildren(state != SelectionNone); | 930 inlineBoxWrapper()->root().setHasSelectedChildren(state != SelectionNone); |
931 } | 931 } |
932 | 932 |
933 TrackedLayoutBoxListHashSet* LayoutBlock::positionedObjectsInternal() const { | 933 TrackedLayoutBoxListHashSet* LayoutBlock::positionedObjectsInternal() const { |
934 return gPositionedDescendantsMap ? gPositionedDescendantsMap->at(this) | 934 return gPositionedDescendantsMap ? gPositionedDescendantsMap->at(this) |
935 : nullptr; | 935 : nullptr; |
936 } | 936 } |
937 | 937 |
938 void LayoutBlock::insertPositionedObject(LayoutBox* o) { | 938 void LayoutBlock::insertPositionedObject(LayoutBox* o) { |
939 ASSERT(!isAnonymousBlock()); | 939 DCHECK(!isAnonymousBlock()); |
940 ASSERT(o->containingBlock() == this); | 940 DCHECK_EQ(o->containingBlock(), this); |
941 | 941 |
942 if (gPositionedContainerMap) { | 942 if (gPositionedContainerMap) { |
943 auto containerMapIt = gPositionedContainerMap->find(o); | 943 auto containerMapIt = gPositionedContainerMap->find(o); |
944 if (containerMapIt != gPositionedContainerMap->end()) { | 944 if (containerMapIt != gPositionedContainerMap->end()) { |
945 if (containerMapIt->value == this) { | 945 if (containerMapIt->value == this) { |
946 ASSERT(hasPositionedObjects() && positionedObjects()->contains(o)); | 946 DCHECK(hasPositionedObjects() && positionedObjects()->contains(o)); |
tkent
2017/04/04 01:36:17
Split this into two.
DCHECK(hasPositionedObjects(
mrunal
2017/04/05 00:39:14
Done.
| |
947 return; | 947 return; |
948 } | 948 } |
949 removePositionedObject(o); | 949 removePositionedObject(o); |
950 } | 950 } |
951 } else { | 951 } else { |
952 gPositionedContainerMap = new TrackedContainerMap; | 952 gPositionedContainerMap = new TrackedContainerMap; |
953 } | 953 } |
954 gPositionedContainerMap->set(o, this); | 954 gPositionedContainerMap->set(o, this); |
955 | 955 |
956 if (!gPositionedDescendantsMap) | 956 if (!gPositionedDescendantsMap) |
(...skipping 12 matching lines...) Expand all Loading... | |
969 void LayoutBlock::removePositionedObject(LayoutBox* o) { | 969 void LayoutBlock::removePositionedObject(LayoutBox* o) { |
970 if (!gPositionedContainerMap) | 970 if (!gPositionedContainerMap) |
971 return; | 971 return; |
972 | 972 |
973 LayoutBlock* container = gPositionedContainerMap->take(o); | 973 LayoutBlock* container = gPositionedContainerMap->take(o); |
974 if (!container) | 974 if (!container) |
975 return; | 975 return; |
976 | 976 |
977 TrackedLayoutBoxListHashSet* positionedDescendants = | 977 TrackedLayoutBoxListHashSet* positionedDescendants = |
978 gPositionedDescendantsMap->at(container); | 978 gPositionedDescendantsMap->at(container); |
979 ASSERT(positionedDescendants && positionedDescendants->contains(o)); | 979 DCHECK(positionedDescendants && positionedDescendants->contains(o)); |
tkent
2017/04/04 01:36:17
Split this into two.
DCHECK(positionedDescendants
mrunal
2017/04/05 00:39:14
Done.
| |
980 positionedDescendants->erase(o); | 980 positionedDescendants->erase(o); |
981 if (positionedDescendants->isEmpty()) { | 981 if (positionedDescendants->isEmpty()) { |
982 gPositionedDescendantsMap->erase(container); | 982 gPositionedDescendantsMap->erase(container); |
983 container->m_hasPositionedObjects = false; | 983 container->m_hasPositionedObjects = false; |
984 } | 984 } |
985 } | 985 } |
986 | 986 |
987 PaintInvalidationReason LayoutBlock::invalidatePaintIfNeeded( | 987 PaintInvalidationReason LayoutBlock::invalidatePaintIfNeeded( |
988 const PaintInvalidationState& paintInvalidationState) { | 988 const PaintInvalidationState& paintInvalidationState) { |
989 return LayoutBox::invalidatePaintIfNeeded(paintInvalidationState); | 989 return LayoutBox::invalidatePaintIfNeeded(paintInvalidationState); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1035 while (p && !p->isLayoutBlock()) | 1035 while (p && !p->isLayoutBlock()) |
1036 p = p->parent(); | 1036 p = p->parent(); |
1037 if (p) | 1037 if (p) |
1038 p->setChildNeedsLayout(); | 1038 p->setChildNeedsLayout(); |
1039 | 1039 |
1040 deadObjects.push_back(positionedObject); | 1040 deadObjects.push_back(positionedObject); |
1041 } | 1041 } |
1042 } | 1042 } |
1043 | 1043 |
1044 for (auto object : deadObjects) { | 1044 for (auto object : deadObjects) { |
1045 ASSERT(gPositionedContainerMap->at(object) == this); | 1045 DCHECK_EQ(gPositionedContainerMap->at(object), this); |
1046 positionedDescendants->erase(object); | 1046 positionedDescendants->erase(object); |
1047 gPositionedContainerMap->erase(object); | 1047 gPositionedContainerMap->erase(object); |
1048 } | 1048 } |
1049 if (positionedDescendants->isEmpty()) { | 1049 if (positionedDescendants->isEmpty()) { |
1050 gPositionedDescendantsMap->erase(this); | 1050 gPositionedDescendantsMap->erase(this); |
1051 m_hasPositionedObjects = false; | 1051 m_hasPositionedObjects = false; |
1052 } | 1052 } |
1053 } | 1053 } |
1054 | 1054 |
1055 void LayoutBlock::addPercentHeightDescendant(LayoutBox* descendant) { | 1055 void LayoutBlock::addPercentHeightDescendant(LayoutBox* descendant) { |
1056 if (descendant->percentHeightContainer()) { | 1056 if (descendant->percentHeightContainer()) { |
1057 if (descendant->percentHeightContainer() == this) { | 1057 if (descendant->percentHeightContainer() == this) { |
1058 ASSERT(hasPercentHeightDescendant(descendant)); | 1058 DCHECK(hasPercentHeightDescendant(descendant)); |
1059 return; | 1059 return; |
1060 } | 1060 } |
1061 descendant->removeFromPercentHeightContainer(); | 1061 descendant->removeFromPercentHeightContainer(); |
1062 } | 1062 } |
1063 descendant->setPercentHeightContainer(this); | 1063 descendant->setPercentHeightContainer(this); |
1064 | 1064 |
1065 if (!gPercentHeightDescendantsMap) | 1065 if (!gPercentHeightDescendantsMap) |
1066 gPercentHeightDescendantsMap = new TrackedDescendantsMap; | 1066 gPercentHeightDescendantsMap = new TrackedDescendantsMap; |
1067 TrackedLayoutBoxListHashSet* descendantSet = | 1067 TrackedLayoutBoxListHashSet* descendantSet = |
1068 gPercentHeightDescendantsMap->at(this); | 1068 gPercentHeightDescendantsMap->at(this); |
(...skipping 23 matching lines...) Expand all Loading... | |
1092 : nullptr; | 1092 : nullptr; |
1093 } | 1093 } |
1094 | 1094 |
1095 void LayoutBlock::dirtyForLayoutFromPercentageHeightDescendants( | 1095 void LayoutBlock::dirtyForLayoutFromPercentageHeightDescendants( |
1096 SubtreeLayoutScope& layoutScope) { | 1096 SubtreeLayoutScope& layoutScope) { |
1097 TrackedLayoutBoxListHashSet* descendants = percentHeightDescendants(); | 1097 TrackedLayoutBoxListHashSet* descendants = percentHeightDescendants(); |
1098 if (!descendants) | 1098 if (!descendants) |
1099 return; | 1099 return; |
1100 | 1100 |
1101 for (auto* box : *descendants) { | 1101 for (auto* box : *descendants) { |
1102 ASSERT(box->isDescendantOf(this)); | 1102 DCHECK(box->isDescendantOf(this)); |
1103 while (box != this) { | 1103 while (box != this) { |
1104 if (box->normalChildNeedsLayout()) | 1104 if (box->normalChildNeedsLayout()) |
1105 break; | 1105 break; |
1106 layoutScope.setChildNeedsLayout(box); | 1106 layoutScope.setChildNeedsLayout(box); |
1107 box = box->containingBlock(); | 1107 box = box->containingBlock(); |
1108 ASSERT(box); | 1108 DCHECK(box); |
1109 if (!box) | 1109 if (!box) |
1110 break; | 1110 break; |
1111 } | 1111 } |
1112 } | 1112 } |
1113 } | 1113 } |
1114 | 1114 |
1115 LayoutUnit LayoutBlock::textIndentOffset() const { | 1115 LayoutUnit LayoutBlock::textIndentOffset() const { |
1116 LayoutUnit cw; | 1116 LayoutUnit cw; |
1117 if (style()->textIndent().isPercentOrCalc()) | 1117 if (style()->textIndent().isPercentOrCalc()) |
1118 cw = containingBlock()->availableLogicalWidth(); | 1118 cw = containingBlock()->availableLogicalWidth(); |
(...skipping 26 matching lines...) Expand all Loading... | |
1145 nodeForHitTest(), locationInContainer) == StopHitTesting) | 1145 nodeForHitTest(), locationInContainer) == StopHitTesting) |
1146 return true; | 1146 return true; |
1147 } | 1147 } |
1148 return false; | 1148 return false; |
1149 } | 1149 } |
1150 | 1150 |
1151 bool LayoutBlock::hitTestChildren(HitTestResult& result, | 1151 bool LayoutBlock::hitTestChildren(HitTestResult& result, |
1152 const HitTestLocation& locationInContainer, | 1152 const HitTestLocation& locationInContainer, |
1153 const LayoutPoint& accumulatedOffset, | 1153 const LayoutPoint& accumulatedOffset, |
1154 HitTestAction hitTestAction) { | 1154 HitTestAction hitTestAction) { |
1155 ASSERT(!childrenInline()); | 1155 DCHECK(!childrenInline()); |
1156 LayoutPoint scrolledOffset(hasOverflowClip() | 1156 LayoutPoint scrolledOffset(hasOverflowClip() |
1157 ? accumulatedOffset - scrolledContentOffset() | 1157 ? accumulatedOffset - scrolledContentOffset() |
1158 : accumulatedOffset); | 1158 : accumulatedOffset); |
1159 HitTestAction childHitTest = hitTestAction; | 1159 HitTestAction childHitTest = hitTestAction; |
1160 if (hitTestAction == HitTestChildBlockBackgrounds) | 1160 if (hitTestAction == HitTestChildBlockBackgrounds) |
1161 childHitTest = HitTestChildBlockBackground; | 1161 childHitTest = HitTestChildBlockBackground; |
1162 for (LayoutBox* child = lastChildBox(); child; | 1162 for (LayoutBox* child = lastChildBox(); child; |
1163 child = child->previousSiblingBox()) { | 1163 child = child->previousSiblingBox()) { |
1164 LayoutPoint childPoint = flipForWritingModeForChild(child, scrolledOffset); | 1164 LayoutPoint childPoint = flipForWritingModeForChild(child, scrolledOffset); |
1165 if (!child->hasSelfPaintingLayer() && !child->isFloating() && | 1165 if (!child->hasSelfPaintingLayer() && !child->isFloating() && |
(...skipping 25 matching lines...) Expand all Loading... | |
1191 : box->getLineLayoutItem().caretMaxOffset()); | 1191 : box->getLineLayoutItem().caretMaxOffset()); |
1192 | 1192 |
1193 InlineTextBox* textBox = toInlineTextBox(box); | 1193 InlineTextBox* textBox = toInlineTextBox(box); |
1194 return Position::editingPositionOf( | 1194 return Position::editingPositionOf( |
1195 box->getLineLayoutItem().nonPseudoNode(), | 1195 box->getLineLayoutItem().nonPseudoNode(), |
1196 start ? textBox->start() : textBox->start() + textBox->len()); | 1196 start ? textBox->start() : textBox->start() + textBox->len()); |
1197 } | 1197 } |
1198 | 1198 |
1199 static inline bool isEditingBoundary(LayoutObject* ancestor, | 1199 static inline bool isEditingBoundary(LayoutObject* ancestor, |
1200 LineLayoutBox child) { | 1200 LineLayoutBox child) { |
1201 ASSERT(!ancestor || ancestor->nonPseudoNode()); | 1201 DCHECK(!ancestor || ancestor->nonPseudoNode()); |
1202 ASSERT(child && child.nonPseudoNode()); | 1202 DCHECK(child); |
1203 DCHECK(child.nonPseudoNode()); | |
1203 return !ancestor || !ancestor->parent() || | 1204 return !ancestor || !ancestor->parent() || |
1204 (ancestor->hasLayer() && ancestor->parent()->isLayoutView()) || | 1205 (ancestor->hasLayer() && ancestor->parent()->isLayoutView()) || |
1205 hasEditableStyle(*ancestor->nonPseudoNode()) == | 1206 hasEditableStyle(*ancestor->nonPseudoNode()) == |
1206 hasEditableStyle(*child.nonPseudoNode()); | 1207 hasEditableStyle(*child.nonPseudoNode()); |
1207 } | 1208 } |
1208 | 1209 |
1209 // FIXME: This function should go on LayoutObject. | 1210 // FIXME: This function should go on LayoutObject. |
1210 // Then all cases in which positionForPoint recurs could call this instead to | 1211 // Then all cases in which positionForPoint recurs could call this instead to |
1211 // prevent crossing editable boundaries. This would require many tests. | 1212 // prevent crossing editable boundaries. This would require many tests. |
1212 PositionWithAffinity LayoutBlock::positionForPointRespectingEditingBoundaries( | 1213 PositionWithAffinity LayoutBlock::positionForPointRespectingEditingBoundaries( |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1245 ? pointInChildCoordinates.x() | 1246 ? pointInChildCoordinates.x() |
1246 : pointInChildCoordinates.y(); | 1247 : pointInChildCoordinates.y(); |
1247 if (logicalLeft < childMiddle) | 1248 if (logicalLeft < childMiddle) |
1248 return ancestor->createPositionWithAffinity(childNode->nodeIndex()); | 1249 return ancestor->createPositionWithAffinity(childNode->nodeIndex()); |
1249 return ancestor->createPositionWithAffinity(childNode->nodeIndex() + 1, | 1250 return ancestor->createPositionWithAffinity(childNode->nodeIndex() + 1, |
1250 TextAffinity::Upstream); | 1251 TextAffinity::Upstream); |
1251 } | 1252 } |
1252 | 1253 |
1253 PositionWithAffinity LayoutBlock::positionForPointIfOutsideAtomicInlineLevel( | 1254 PositionWithAffinity LayoutBlock::positionForPointIfOutsideAtomicInlineLevel( |
1254 const LayoutPoint& point) { | 1255 const LayoutPoint& point) { |
1255 ASSERT(isAtomicInlineLevel()); | 1256 DCHECK(isAtomicInlineLevel()); |
1256 // FIXME: This seems wrong when the object's writing-mode doesn't match the | 1257 // FIXME: This seems wrong when the object's writing-mode doesn't match the |
1257 // line's writing-mode. | 1258 // line's writing-mode. |
1258 LayoutUnit pointLogicalLeft = | 1259 LayoutUnit pointLogicalLeft = |
1259 isHorizontalWritingMode() ? point.x() : point.y(); | 1260 isHorizontalWritingMode() ? point.x() : point.y(); |
1260 LayoutUnit pointLogicalTop = | 1261 LayoutUnit pointLogicalTop = |
1261 isHorizontalWritingMode() ? point.y() : point.x(); | 1262 isHorizontalWritingMode() ? point.y() : point.x(); |
1262 | 1263 |
1263 if (pointLogicalLeft < 0) | 1264 if (pointLogicalLeft < 0) |
1264 return createPositionWithAffinity(caretMinOffset()); | 1265 return createPositionWithAffinity(caretMinOffset()); |
1265 if (pointLogicalLeft >= logicalWidth()) | 1266 if (pointLogicalLeft >= logicalWidth()) |
(...skipping 21 matching lines...) Expand all Loading... | |
1287 if (!position.isNull()) | 1288 if (!position.isNull()) |
1288 return position; | 1289 return position; |
1289 } | 1290 } |
1290 | 1291 |
1291 LayoutPoint pointInContents = point; | 1292 LayoutPoint pointInContents = point; |
1292 offsetForContents(pointInContents); | 1293 offsetForContents(pointInContents); |
1293 LayoutPoint pointInLogicalContents(pointInContents); | 1294 LayoutPoint pointInLogicalContents(pointInContents); |
1294 if (!isHorizontalWritingMode()) | 1295 if (!isHorizontalWritingMode()) |
1295 pointInLogicalContents = pointInLogicalContents.transposedPoint(); | 1296 pointInLogicalContents = pointInLogicalContents.transposedPoint(); |
1296 | 1297 |
1297 ASSERT(!childrenInline()); | 1298 DCHECK(!childrenInline()); |
1298 | 1299 |
1299 LayoutBox* lastCandidateBox = lastChildBox(); | 1300 LayoutBox* lastCandidateBox = lastChildBox(); |
1300 while (lastCandidateBox && !isChildHitTestCandidate(lastCandidateBox)) | 1301 while (lastCandidateBox && !isChildHitTestCandidate(lastCandidateBox)) |
1301 lastCandidateBox = lastCandidateBox->previousSiblingBox(); | 1302 lastCandidateBox = lastCandidateBox->previousSiblingBox(); |
1302 | 1303 |
1303 bool blocksAreFlipped = style()->isFlippedBlocksWritingMode(); | 1304 bool blocksAreFlipped = style()->isFlippedBlocksWritingMode(); |
1304 if (lastCandidateBox) { | 1305 if (lastCandidateBox) { |
1305 if (pointInLogicalContents.y() > logicalTopForChild(*lastCandidateBox) || | 1306 if (pointInLogicalContents.y() > logicalTopForChild(*lastCandidateBox) || |
1306 (!blocksAreFlipped && | 1307 (!blocksAreFlipped && |
1307 pointInLogicalContents.y() == logicalTopForChild(*lastCandidateBox))) | 1308 pointInLogicalContents.y() == logicalTopForChild(*lastCandidateBox))) |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1383 LayoutUnit(tableCellWidth.value()))); | 1384 LayoutUnit(tableCellWidth.value()))); |
1384 } | 1385 } |
1385 | 1386 |
1386 int scrollbarWidth = scrollbarLogicalWidth(); | 1387 int scrollbarWidth = scrollbarLogicalWidth(); |
1387 maxLogicalWidth += scrollbarWidth; | 1388 maxLogicalWidth += scrollbarWidth; |
1388 minLogicalWidth += scrollbarWidth; | 1389 minLogicalWidth += scrollbarWidth; |
1389 } | 1390 } |
1390 | 1391 |
1391 DISABLE_CFI_PERF | 1392 DISABLE_CFI_PERF |
1392 void LayoutBlock::computePreferredLogicalWidths() { | 1393 void LayoutBlock::computePreferredLogicalWidths() { |
1393 ASSERT(preferredLogicalWidthsDirty()); | 1394 DCHECK(preferredLogicalWidthsDirty()); |
1394 | 1395 |
1395 m_minPreferredLogicalWidth = LayoutUnit(); | 1396 m_minPreferredLogicalWidth = LayoutUnit(); |
1396 m_maxPreferredLogicalWidth = LayoutUnit(); | 1397 m_maxPreferredLogicalWidth = LayoutUnit(); |
1397 | 1398 |
1398 // FIXME: The isFixed() calls here should probably be checking for isSpecified | 1399 // FIXME: The isFixed() calls here should probably be checking for isSpecified |
1399 // since you should be able to use percentage, calc or viewport relative | 1400 // since you should be able to use percentage, calc or viewport relative |
1400 // values for width. | 1401 // values for width. |
1401 const ComputedStyle& styleToUse = styleRef(); | 1402 const ComputedStyle& styleToUse = styleRef(); |
1402 if (!isTableCell() && styleToUse.logicalWidth().isFixed() && | 1403 if (!isTableCell() && styleToUse.logicalWidth().isFixed() && |
1403 styleToUse.logicalWidth().value() >= 0 && | 1404 styleToUse.logicalWidth().value() >= 0 && |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1664 if (baselinePos != -1) | 1665 if (baselinePos != -1) |
1665 return beforeMarginInLineDirection(direction) + baselinePos; | 1666 return beforeMarginInLineDirection(direction) + baselinePos; |
1666 | 1667 |
1667 return LayoutBox::baselinePosition(baselineType, firstLine, direction, | 1668 return LayoutBox::baselinePosition(baselineType, firstLine, direction, |
1668 linePositionMode); | 1669 linePositionMode); |
1669 } | 1670 } |
1670 | 1671 |
1671 // If we're not replaced, we'll only get called with | 1672 // If we're not replaced, we'll only get called with |
1672 // PositionOfInteriorLineBoxes. | 1673 // PositionOfInteriorLineBoxes. |
1673 // Note that inline-block counts as replaced here. | 1674 // Note that inline-block counts as replaced here. |
1674 ASSERT(linePositionMode == PositionOfInteriorLineBoxes); | 1675 DCHECK_EQ(linePositionMode, PositionOfInteriorLineBoxes); |
1675 | 1676 |
1676 const SimpleFontData* fontData = style(firstLine)->font().primaryFont(); | 1677 const SimpleFontData* fontData = style(firstLine)->font().primaryFont(); |
1677 DCHECK(fontData); | 1678 DCHECK(fontData); |
1678 if (!fontData) | 1679 if (!fontData) |
1679 return -1; | 1680 return -1; |
1680 | 1681 |
1681 const FontMetrics& fontMetrics = fontData->getFontMetrics(); | 1682 const FontMetrics& fontMetrics = fontData->getFontMetrics(); |
1682 return (fontMetrics.ascent(baselineType) + | 1683 return (fontMetrics.ascent(baselineType) + |
1683 (lineHeight(firstLine, direction, linePositionMode) - | 1684 (lineHeight(firstLine, direction, linePositionMode) - |
1684 fontMetrics.height()) / | 1685 fontMetrics.height()) / |
(...skipping 14 matching lines...) Expand all Loading... | |
1699 PositionOfInteriorLineBoxes)); | 1700 PositionOfInteriorLineBoxes)); |
1700 } | 1701 } |
1701 | 1702 |
1702 // TODO(mstensho): Figure out if all of this baseline code is needed here, or if | 1703 // TODO(mstensho): Figure out if all of this baseline code is needed here, or if |
1703 // it should be moved down to LayoutBlockFlow. LayoutDeprecatedFlexibleBox and | 1704 // it should be moved down to LayoutBlockFlow. LayoutDeprecatedFlexibleBox and |
1704 // LayoutGrid lack baseline calculation overrides, so the code is here just for | 1705 // LayoutGrid lack baseline calculation overrides, so the code is here just for |
1705 // them. Just walking the block children in logical order seems rather wrong for | 1706 // them. Just walking the block children in logical order seems rather wrong for |
1706 // those two layout modes, though. | 1707 // those two layout modes, though. |
1707 | 1708 |
1708 int LayoutBlock::firstLineBoxBaseline() const { | 1709 int LayoutBlock::firstLineBoxBaseline() const { |
1709 ASSERT(!childrenInline()); | 1710 DCHECK(!childrenInline()); |
1710 if (isWritingModeRoot() && !isRubyRun()) | 1711 if (isWritingModeRoot() && !isRubyRun()) |
1711 return -1; | 1712 return -1; |
1712 | 1713 |
1713 for (LayoutBox* curr = firstChildBox(); curr; curr = curr->nextSiblingBox()) { | 1714 for (LayoutBox* curr = firstChildBox(); curr; curr = curr->nextSiblingBox()) { |
1714 if (!curr->isFloatingOrOutOfFlowPositioned()) { | 1715 if (!curr->isFloatingOrOutOfFlowPositioned()) { |
1715 int result = curr->firstLineBoxBaseline(); | 1716 int result = curr->firstLineBoxBaseline(); |
1716 if (result != -1) | 1717 if (result != -1) |
1717 return (curr->logicalTop() + result) | 1718 return (curr->logicalTop() + result) |
1718 .toInt(); // Translate to our coordinate space. | 1719 .toInt(); // Translate to our coordinate space. |
1719 } | 1720 } |
1720 } | 1721 } |
1721 return -1; | 1722 return -1; |
1722 } | 1723 } |
1723 | 1724 |
1724 int LayoutBlock::inlineBlockBaseline(LineDirectionMode lineDirection) const { | 1725 int LayoutBlock::inlineBlockBaseline(LineDirectionMode lineDirection) const { |
1725 ASSERT(!childrenInline()); | 1726 DCHECK(!childrenInline()); |
1726 if ((!style()->isOverflowVisible() && | 1727 if ((!style()->isOverflowVisible() && |
1727 !shouldIgnoreOverflowPropertyForInlineBlockBaseline()) || | 1728 !shouldIgnoreOverflowPropertyForInlineBlockBaseline()) || |
1728 style()->containsSize()) { | 1729 style()->containsSize()) { |
1729 // We are not calling LayoutBox::baselinePosition here because the caller | 1730 // We are not calling LayoutBox::baselinePosition here because the caller |
1730 // should add the margin-top/margin-right, not us. | 1731 // should add the margin-top/margin-right, not us. |
1731 return (lineDirection == HorizontalLine ? size().height() + marginBottom() | 1732 return (lineDirection == HorizontalLine ? size().height() + marginBottom() |
1732 : size().width() + marginLeft()) | 1733 : size().width() + marginLeft()) |
1733 .toInt(); | 1734 .toInt(); |
1734 } | 1735 } |
1735 | 1736 |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1975 newBox->setStyle(std::move(newStyle)); | 1976 newBox->setStyle(std::move(newStyle)); |
1976 return newBox; | 1977 return newBox; |
1977 } | 1978 } |
1978 | 1979 |
1979 bool LayoutBlock::recalcNormalFlowChildOverflowIfNeeded( | 1980 bool LayoutBlock::recalcNormalFlowChildOverflowIfNeeded( |
1980 LayoutObject* layoutObject) { | 1981 LayoutObject* layoutObject) { |
1981 if (layoutObject->isOutOfFlowPositioned() || | 1982 if (layoutObject->isOutOfFlowPositioned() || |
1982 !layoutObject->needsOverflowRecalcAfterStyleChange()) | 1983 !layoutObject->needsOverflowRecalcAfterStyleChange()) |
1983 return false; | 1984 return false; |
1984 | 1985 |
1985 ASSERT(layoutObject->isLayoutBlock()); | 1986 DCHECK(layoutObject->isLayoutBlock()); |
1986 return toLayoutBlock(layoutObject)->recalcOverflowAfterStyleChange(); | 1987 return toLayoutBlock(layoutObject)->recalcOverflowAfterStyleChange(); |
1987 } | 1988 } |
1988 | 1989 |
1989 bool LayoutBlock::recalcChildOverflowAfterStyleChange() { | 1990 bool LayoutBlock::recalcChildOverflowAfterStyleChange() { |
1990 ASSERT(childNeedsOverflowRecalcAfterStyleChange()); | 1991 DCHECK(childNeedsOverflowRecalcAfterStyleChange()); |
1991 clearChildNeedsOverflowRecalcAfterStyleChange(); | 1992 clearChildNeedsOverflowRecalcAfterStyleChange(); |
1992 | 1993 |
1993 bool childrenOverflowChanged = false; | 1994 bool childrenOverflowChanged = false; |
1994 | 1995 |
1995 if (childrenInline()) { | 1996 if (childrenInline()) { |
1996 SECURITY_DCHECK(isLayoutBlockFlow()); | 1997 SECURITY_DCHECK(isLayoutBlockFlow()); |
1997 childrenOverflowChanged = | 1998 childrenOverflowChanged = |
1998 toLayoutBlockFlow(this)->recalcInlineChildrenOverflowAfterStyleChange(); | 1999 toLayoutBlockFlow(this)->recalcInlineChildrenOverflowAfterStyleChange(); |
1999 } else { | 2000 } else { |
2000 for (LayoutBox* box = firstChildBox(); box; box = box->nextSiblingBox()) { | 2001 for (LayoutBox* box = firstChildBox(); box; box = box->nextSiblingBox()) { |
(...skipping 20 matching lines...) Expand all Loading... | |
2021 if (!block->recalcOverflowAfterStyleChange() || | 2022 if (!block->recalcOverflowAfterStyleChange() || |
2022 box->style()->position() == EPosition::kFixed) | 2023 box->style()->position() == EPosition::kFixed) |
2023 continue; | 2024 continue; |
2024 | 2025 |
2025 childrenOverflowChanged = true; | 2026 childrenOverflowChanged = true; |
2026 } | 2027 } |
2027 return childrenOverflowChanged; | 2028 return childrenOverflowChanged; |
2028 } | 2029 } |
2029 | 2030 |
2030 bool LayoutBlock::recalcOverflowAfterStyleChange() { | 2031 bool LayoutBlock::recalcOverflowAfterStyleChange() { |
2031 ASSERT(needsOverflowRecalcAfterStyleChange()); | 2032 DCHECK(needsOverflowRecalcAfterStyleChange()); |
2032 | 2033 |
2033 bool childrenOverflowChanged = false; | 2034 bool childrenOverflowChanged = false; |
2034 if (childNeedsOverflowRecalcAfterStyleChange()) | 2035 if (childNeedsOverflowRecalcAfterStyleChange()) |
2035 childrenOverflowChanged = recalcChildOverflowAfterStyleChange(); | 2036 childrenOverflowChanged = recalcChildOverflowAfterStyleChange(); |
2036 | 2037 |
2037 if (!selfNeedsOverflowRecalcAfterStyleChange() && !childrenOverflowChanged) | 2038 if (!selfNeedsOverflowRecalcAfterStyleChange() && !childrenOverflowChanged) |
2038 return false; | 2039 return false; |
2039 | 2040 |
2040 clearSelfNeedsOverflowRecalcAfterStyleChange(); | 2041 clearSelfNeedsOverflowRecalcAfterStyleChange(); |
2041 // If the current block needs layout, overflow will be recalculated during | 2042 // If the current block needs layout, overflow will be recalculated during |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2096 return; | 2097 return; |
2097 | 2098 |
2098 if (TrackedLayoutBoxListHashSet* positionedDescendantSet = | 2099 if (TrackedLayoutBoxListHashSet* positionedDescendantSet = |
2099 positionedObjects()) { | 2100 positionedObjects()) { |
2100 TrackedLayoutBoxListHashSet::const_iterator end = | 2101 TrackedLayoutBoxListHashSet::const_iterator end = |
2101 positionedDescendantSet->end(); | 2102 positionedDescendantSet->end(); |
2102 for (TrackedLayoutBoxListHashSet::const_iterator it = | 2103 for (TrackedLayoutBoxListHashSet::const_iterator it = |
2103 positionedDescendantSet->begin(); | 2104 positionedDescendantSet->begin(); |
2104 it != end; ++it) { | 2105 it != end; ++it) { |
2105 LayoutBox* currBox = *it; | 2106 LayoutBox* currBox = *it; |
2106 ASSERT(!currBox->needsLayout()); | 2107 DCHECK(!currBox->needsLayout()); |
2107 } | 2108 } |
2108 } | 2109 } |
2109 } | 2110 } |
2110 | 2111 |
2111 #endif | 2112 #endif |
2112 | 2113 |
2113 LayoutUnit LayoutBlock::availableLogicalHeightForPercentageComputation() const { | 2114 LayoutUnit LayoutBlock::availableLogicalHeightForPercentageComputation() const { |
2114 LayoutUnit availableHeight(-1); | 2115 LayoutUnit availableHeight(-1); |
2115 | 2116 |
2116 // For anonymous blocks that are skipped during percentage height calculation, | 2117 // For anonymous blocks that are skipped during percentage height calculation, |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2174 } | 2175 } |
2175 | 2176 |
2176 return availableHeight; | 2177 return availableHeight; |
2177 } | 2178 } |
2178 | 2179 |
2179 bool LayoutBlock::hasDefiniteLogicalHeight() const { | 2180 bool LayoutBlock::hasDefiniteLogicalHeight() const { |
2180 return availableLogicalHeightForPercentageComputation() != LayoutUnit(-1); | 2181 return availableLogicalHeightForPercentageComputation() != LayoutUnit(-1); |
2181 } | 2182 } |
2182 | 2183 |
2183 } // namespace blink | 2184 } // namespace blink |
OLD | NEW |