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_EQ(gPositionedContainerMap->at(descendant), this); |
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_EQ(descendant->percentHeightContainer(), this); |
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()); |
| 947 DCHECK(positionedObjects()->contains(o)); |
947 return; | 948 return; |
948 } | 949 } |
949 removePositionedObject(o); | 950 removePositionedObject(o); |
950 } | 951 } |
951 } else { | 952 } else { |
952 gPositionedContainerMap = new TrackedContainerMap; | 953 gPositionedContainerMap = new TrackedContainerMap; |
953 } | 954 } |
954 gPositionedContainerMap->set(o, this); | 955 gPositionedContainerMap->set(o, this); |
955 | 956 |
956 if (!gPositionedDescendantsMap) | 957 if (!gPositionedDescendantsMap) |
(...skipping 12 matching lines...) Expand all Loading... |
969 void LayoutBlock::removePositionedObject(LayoutBox* o) { | 970 void LayoutBlock::removePositionedObject(LayoutBox* o) { |
970 if (!gPositionedContainerMap) | 971 if (!gPositionedContainerMap) |
971 return; | 972 return; |
972 | 973 |
973 LayoutBlock* container = gPositionedContainerMap->take(o); | 974 LayoutBlock* container = gPositionedContainerMap->take(o); |
974 if (!container) | 975 if (!container) |
975 return; | 976 return; |
976 | 977 |
977 TrackedLayoutBoxListHashSet* positionedDescendants = | 978 TrackedLayoutBoxListHashSet* positionedDescendants = |
978 gPositionedDescendantsMap->at(container); | 979 gPositionedDescendantsMap->at(container); |
979 ASSERT(positionedDescendants && positionedDescendants->contains(o)); | 980 DCHECK(positionedDescendants); |
| 981 DCHECK(positionedDescendants->contains(o)); |
980 positionedDescendants->erase(o); | 982 positionedDescendants->erase(o); |
981 if (positionedDescendants->isEmpty()) { | 983 if (positionedDescendants->isEmpty()) { |
982 gPositionedDescendantsMap->erase(container); | 984 gPositionedDescendantsMap->erase(container); |
983 container->m_hasPositionedObjects = false; | 985 container->m_hasPositionedObjects = false; |
984 } | 986 } |
985 } | 987 } |
986 | 988 |
987 PaintInvalidationReason LayoutBlock::invalidatePaintIfNeeded( | 989 PaintInvalidationReason LayoutBlock::invalidatePaintIfNeeded( |
988 const PaintInvalidationState& paintInvalidationState) { | 990 const PaintInvalidationState& paintInvalidationState) { |
989 return LayoutBox::invalidatePaintIfNeeded(paintInvalidationState); | 991 return LayoutBox::invalidatePaintIfNeeded(paintInvalidationState); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1035 while (p && !p->isLayoutBlock()) | 1037 while (p && !p->isLayoutBlock()) |
1036 p = p->parent(); | 1038 p = p->parent(); |
1037 if (p) | 1039 if (p) |
1038 p->setChildNeedsLayout(); | 1040 p->setChildNeedsLayout(); |
1039 | 1041 |
1040 deadObjects.push_back(positionedObject); | 1042 deadObjects.push_back(positionedObject); |
1041 } | 1043 } |
1042 } | 1044 } |
1043 | 1045 |
1044 for (auto object : deadObjects) { | 1046 for (auto object : deadObjects) { |
1045 ASSERT(gPositionedContainerMap->at(object) == this); | 1047 DCHECK_EQ(gPositionedContainerMap->at(object), this); |
1046 positionedDescendants->erase(object); | 1048 positionedDescendants->erase(object); |
1047 gPositionedContainerMap->erase(object); | 1049 gPositionedContainerMap->erase(object); |
1048 } | 1050 } |
1049 if (positionedDescendants->isEmpty()) { | 1051 if (positionedDescendants->isEmpty()) { |
1050 gPositionedDescendantsMap->erase(this); | 1052 gPositionedDescendantsMap->erase(this); |
1051 m_hasPositionedObjects = false; | 1053 m_hasPositionedObjects = false; |
1052 } | 1054 } |
1053 } | 1055 } |
1054 | 1056 |
1055 void LayoutBlock::addPercentHeightDescendant(LayoutBox* descendant) { | 1057 void LayoutBlock::addPercentHeightDescendant(LayoutBox* descendant) { |
1056 if (descendant->percentHeightContainer()) { | 1058 if (descendant->percentHeightContainer()) { |
1057 if (descendant->percentHeightContainer() == this) { | 1059 if (descendant->percentHeightContainer() == this) { |
1058 ASSERT(hasPercentHeightDescendant(descendant)); | 1060 DCHECK(hasPercentHeightDescendant(descendant)); |
1059 return; | 1061 return; |
1060 } | 1062 } |
1061 descendant->removeFromPercentHeightContainer(); | 1063 descendant->removeFromPercentHeightContainer(); |
1062 } | 1064 } |
1063 descendant->setPercentHeightContainer(this); | 1065 descendant->setPercentHeightContainer(this); |
1064 | 1066 |
1065 if (!gPercentHeightDescendantsMap) | 1067 if (!gPercentHeightDescendantsMap) |
1066 gPercentHeightDescendantsMap = new TrackedDescendantsMap; | 1068 gPercentHeightDescendantsMap = new TrackedDescendantsMap; |
1067 TrackedLayoutBoxListHashSet* descendantSet = | 1069 TrackedLayoutBoxListHashSet* descendantSet = |
1068 gPercentHeightDescendantsMap->at(this); | 1070 gPercentHeightDescendantsMap->at(this); |
(...skipping 23 matching lines...) Expand all Loading... |
1092 : nullptr; | 1094 : nullptr; |
1093 } | 1095 } |
1094 | 1096 |
1095 void LayoutBlock::dirtyForLayoutFromPercentageHeightDescendants( | 1097 void LayoutBlock::dirtyForLayoutFromPercentageHeightDescendants( |
1096 SubtreeLayoutScope& layoutScope) { | 1098 SubtreeLayoutScope& layoutScope) { |
1097 TrackedLayoutBoxListHashSet* descendants = percentHeightDescendants(); | 1099 TrackedLayoutBoxListHashSet* descendants = percentHeightDescendants(); |
1098 if (!descendants) | 1100 if (!descendants) |
1099 return; | 1101 return; |
1100 | 1102 |
1101 for (auto* box : *descendants) { | 1103 for (auto* box : *descendants) { |
1102 ASSERT(box->isDescendantOf(this)); | 1104 DCHECK(box->isDescendantOf(this)); |
1103 while (box != this) { | 1105 while (box != this) { |
1104 if (box->normalChildNeedsLayout()) | 1106 if (box->normalChildNeedsLayout()) |
1105 break; | 1107 break; |
1106 layoutScope.setChildNeedsLayout(box); | 1108 layoutScope.setChildNeedsLayout(box); |
1107 box = box->containingBlock(); | 1109 box = box->containingBlock(); |
1108 ASSERT(box); | 1110 DCHECK(box); |
1109 if (!box) | 1111 if (!box) |
1110 break; | 1112 break; |
1111 } | 1113 } |
1112 } | 1114 } |
1113 } | 1115 } |
1114 | 1116 |
1115 LayoutUnit LayoutBlock::textIndentOffset() const { | 1117 LayoutUnit LayoutBlock::textIndentOffset() const { |
1116 LayoutUnit cw; | 1118 LayoutUnit cw; |
1117 if (style()->textIndent().isPercentOrCalc()) | 1119 if (style()->textIndent().isPercentOrCalc()) |
1118 cw = containingBlock()->availableLogicalWidth(); | 1120 cw = containingBlock()->availableLogicalWidth(); |
(...skipping 26 matching lines...) Expand all Loading... |
1145 nodeForHitTest(), locationInContainer) == StopHitTesting) | 1147 nodeForHitTest(), locationInContainer) == StopHitTesting) |
1146 return true; | 1148 return true; |
1147 } | 1149 } |
1148 return false; | 1150 return false; |
1149 } | 1151 } |
1150 | 1152 |
1151 bool LayoutBlock::hitTestChildren(HitTestResult& result, | 1153 bool LayoutBlock::hitTestChildren(HitTestResult& result, |
1152 const HitTestLocation& locationInContainer, | 1154 const HitTestLocation& locationInContainer, |
1153 const LayoutPoint& accumulatedOffset, | 1155 const LayoutPoint& accumulatedOffset, |
1154 HitTestAction hitTestAction) { | 1156 HitTestAction hitTestAction) { |
1155 ASSERT(!childrenInline()); | 1157 DCHECK(!childrenInline()); |
1156 LayoutPoint scrolledOffset(hasOverflowClip() | 1158 LayoutPoint scrolledOffset(hasOverflowClip() |
1157 ? accumulatedOffset - scrolledContentOffset() | 1159 ? accumulatedOffset - scrolledContentOffset() |
1158 : accumulatedOffset); | 1160 : accumulatedOffset); |
1159 HitTestAction childHitTest = hitTestAction; | 1161 HitTestAction childHitTest = hitTestAction; |
1160 if (hitTestAction == HitTestChildBlockBackgrounds) | 1162 if (hitTestAction == HitTestChildBlockBackgrounds) |
1161 childHitTest = HitTestChildBlockBackground; | 1163 childHitTest = HitTestChildBlockBackground; |
1162 for (LayoutBox* child = lastChildBox(); child; | 1164 for (LayoutBox* child = lastChildBox(); child; |
1163 child = child->previousSiblingBox()) { | 1165 child = child->previousSiblingBox()) { |
1164 LayoutPoint childPoint = flipForWritingModeForChild(child, scrolledOffset); | 1166 LayoutPoint childPoint = flipForWritingModeForChild(child, scrolledOffset); |
1165 if (!child->hasSelfPaintingLayer() && !child->isFloating() && | 1167 if (!child->hasSelfPaintingLayer() && !child->isFloating() && |
(...skipping 25 matching lines...) Expand all Loading... |
1191 : box->getLineLayoutItem().caretMaxOffset()); | 1193 : box->getLineLayoutItem().caretMaxOffset()); |
1192 | 1194 |
1193 InlineTextBox* textBox = toInlineTextBox(box); | 1195 InlineTextBox* textBox = toInlineTextBox(box); |
1194 return Position::editingPositionOf( | 1196 return Position::editingPositionOf( |
1195 box->getLineLayoutItem().nonPseudoNode(), | 1197 box->getLineLayoutItem().nonPseudoNode(), |
1196 start ? textBox->start() : textBox->start() + textBox->len()); | 1198 start ? textBox->start() : textBox->start() + textBox->len()); |
1197 } | 1199 } |
1198 | 1200 |
1199 static inline bool isEditingBoundary(LayoutObject* ancestor, | 1201 static inline bool isEditingBoundary(LayoutObject* ancestor, |
1200 LineLayoutBox child) { | 1202 LineLayoutBox child) { |
1201 ASSERT(!ancestor || ancestor->nonPseudoNode()); | 1203 DCHECK(!ancestor || ancestor->nonPseudoNode()); |
1202 ASSERT(child && child.nonPseudoNode()); | 1204 DCHECK(child); |
| 1205 DCHECK(child.nonPseudoNode()); |
1203 return !ancestor || !ancestor->parent() || | 1206 return !ancestor || !ancestor->parent() || |
1204 (ancestor->hasLayer() && ancestor->parent()->isLayoutView()) || | 1207 (ancestor->hasLayer() && ancestor->parent()->isLayoutView()) || |
1205 hasEditableStyle(*ancestor->nonPseudoNode()) == | 1208 hasEditableStyle(*ancestor->nonPseudoNode()) == |
1206 hasEditableStyle(*child.nonPseudoNode()); | 1209 hasEditableStyle(*child.nonPseudoNode()); |
1207 } | 1210 } |
1208 | 1211 |
1209 // FIXME: This function should go on LayoutObject. | 1212 // FIXME: This function should go on LayoutObject. |
1210 // Then all cases in which positionForPoint recurs could call this instead to | 1213 // Then all cases in which positionForPoint recurs could call this instead to |
1211 // prevent crossing editable boundaries. This would require many tests. | 1214 // prevent crossing editable boundaries. This would require many tests. |
1212 PositionWithAffinity LayoutBlock::positionForPointRespectingEditingBoundaries( | 1215 PositionWithAffinity LayoutBlock::positionForPointRespectingEditingBoundaries( |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1245 ? pointInChildCoordinates.x() | 1248 ? pointInChildCoordinates.x() |
1246 : pointInChildCoordinates.y(); | 1249 : pointInChildCoordinates.y(); |
1247 if (logicalLeft < childMiddle) | 1250 if (logicalLeft < childMiddle) |
1248 return ancestor->createPositionWithAffinity(childNode->nodeIndex()); | 1251 return ancestor->createPositionWithAffinity(childNode->nodeIndex()); |
1249 return ancestor->createPositionWithAffinity(childNode->nodeIndex() + 1, | 1252 return ancestor->createPositionWithAffinity(childNode->nodeIndex() + 1, |
1250 TextAffinity::Upstream); | 1253 TextAffinity::Upstream); |
1251 } | 1254 } |
1252 | 1255 |
1253 PositionWithAffinity LayoutBlock::positionForPointIfOutsideAtomicInlineLevel( | 1256 PositionWithAffinity LayoutBlock::positionForPointIfOutsideAtomicInlineLevel( |
1254 const LayoutPoint& point) { | 1257 const LayoutPoint& point) { |
1255 ASSERT(isAtomicInlineLevel()); | 1258 DCHECK(isAtomicInlineLevel()); |
1256 // FIXME: This seems wrong when the object's writing-mode doesn't match the | 1259 // FIXME: This seems wrong when the object's writing-mode doesn't match the |
1257 // line's writing-mode. | 1260 // line's writing-mode. |
1258 LayoutUnit pointLogicalLeft = | 1261 LayoutUnit pointLogicalLeft = |
1259 isHorizontalWritingMode() ? point.x() : point.y(); | 1262 isHorizontalWritingMode() ? point.x() : point.y(); |
1260 LayoutUnit pointLogicalTop = | 1263 LayoutUnit pointLogicalTop = |
1261 isHorizontalWritingMode() ? point.y() : point.x(); | 1264 isHorizontalWritingMode() ? point.y() : point.x(); |
1262 | 1265 |
1263 if (pointLogicalLeft < 0) | 1266 if (pointLogicalLeft < 0) |
1264 return createPositionWithAffinity(caretMinOffset()); | 1267 return createPositionWithAffinity(caretMinOffset()); |
1265 if (pointLogicalLeft >= logicalWidth()) | 1268 if (pointLogicalLeft >= logicalWidth()) |
(...skipping 21 matching lines...) Expand all Loading... |
1287 if (!position.isNull()) | 1290 if (!position.isNull()) |
1288 return position; | 1291 return position; |
1289 } | 1292 } |
1290 | 1293 |
1291 LayoutPoint pointInContents = point; | 1294 LayoutPoint pointInContents = point; |
1292 offsetForContents(pointInContents); | 1295 offsetForContents(pointInContents); |
1293 LayoutPoint pointInLogicalContents(pointInContents); | 1296 LayoutPoint pointInLogicalContents(pointInContents); |
1294 if (!isHorizontalWritingMode()) | 1297 if (!isHorizontalWritingMode()) |
1295 pointInLogicalContents = pointInLogicalContents.transposedPoint(); | 1298 pointInLogicalContents = pointInLogicalContents.transposedPoint(); |
1296 | 1299 |
1297 ASSERT(!childrenInline()); | 1300 DCHECK(!childrenInline()); |
1298 | 1301 |
1299 LayoutBox* lastCandidateBox = lastChildBox(); | 1302 LayoutBox* lastCandidateBox = lastChildBox(); |
1300 while (lastCandidateBox && !isChildHitTestCandidate(lastCandidateBox)) | 1303 while (lastCandidateBox && !isChildHitTestCandidate(lastCandidateBox)) |
1301 lastCandidateBox = lastCandidateBox->previousSiblingBox(); | 1304 lastCandidateBox = lastCandidateBox->previousSiblingBox(); |
1302 | 1305 |
1303 bool blocksAreFlipped = style()->isFlippedBlocksWritingMode(); | 1306 bool blocksAreFlipped = style()->isFlippedBlocksWritingMode(); |
1304 if (lastCandidateBox) { | 1307 if (lastCandidateBox) { |
1305 if (pointInLogicalContents.y() > logicalTopForChild(*lastCandidateBox) || | 1308 if (pointInLogicalContents.y() > logicalTopForChild(*lastCandidateBox) || |
1306 (!blocksAreFlipped && | 1309 (!blocksAreFlipped && |
1307 pointInLogicalContents.y() == logicalTopForChild(*lastCandidateBox))) | 1310 pointInLogicalContents.y() == logicalTopForChild(*lastCandidateBox))) |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1383 LayoutUnit(tableCellWidth.value()))); | 1386 LayoutUnit(tableCellWidth.value()))); |
1384 } | 1387 } |
1385 | 1388 |
1386 int scrollbarWidth = scrollbarLogicalWidth(); | 1389 int scrollbarWidth = scrollbarLogicalWidth(); |
1387 maxLogicalWidth += scrollbarWidth; | 1390 maxLogicalWidth += scrollbarWidth; |
1388 minLogicalWidth += scrollbarWidth; | 1391 minLogicalWidth += scrollbarWidth; |
1389 } | 1392 } |
1390 | 1393 |
1391 DISABLE_CFI_PERF | 1394 DISABLE_CFI_PERF |
1392 void LayoutBlock::computePreferredLogicalWidths() { | 1395 void LayoutBlock::computePreferredLogicalWidths() { |
1393 ASSERT(preferredLogicalWidthsDirty()); | 1396 DCHECK(preferredLogicalWidthsDirty()); |
1394 | 1397 |
1395 m_minPreferredLogicalWidth = LayoutUnit(); | 1398 m_minPreferredLogicalWidth = LayoutUnit(); |
1396 m_maxPreferredLogicalWidth = LayoutUnit(); | 1399 m_maxPreferredLogicalWidth = LayoutUnit(); |
1397 | 1400 |
1398 // FIXME: The isFixed() calls here should probably be checking for isSpecified | 1401 // FIXME: The isFixed() calls here should probably be checking for isSpecified |
1399 // since you should be able to use percentage, calc or viewport relative | 1402 // since you should be able to use percentage, calc or viewport relative |
1400 // values for width. | 1403 // values for width. |
1401 const ComputedStyle& styleToUse = styleRef(); | 1404 const ComputedStyle& styleToUse = styleRef(); |
1402 if (!isTableCell() && styleToUse.logicalWidth().isFixed() && | 1405 if (!isTableCell() && styleToUse.logicalWidth().isFixed() && |
1403 styleToUse.logicalWidth().value() >= 0 && | 1406 styleToUse.logicalWidth().value() >= 0 && |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1664 if (baselinePos != -1) | 1667 if (baselinePos != -1) |
1665 return beforeMarginInLineDirection(direction) + baselinePos; | 1668 return beforeMarginInLineDirection(direction) + baselinePos; |
1666 | 1669 |
1667 return LayoutBox::baselinePosition(baselineType, firstLine, direction, | 1670 return LayoutBox::baselinePosition(baselineType, firstLine, direction, |
1668 linePositionMode); | 1671 linePositionMode); |
1669 } | 1672 } |
1670 | 1673 |
1671 // If we're not replaced, we'll only get called with | 1674 // If we're not replaced, we'll only get called with |
1672 // PositionOfInteriorLineBoxes. | 1675 // PositionOfInteriorLineBoxes. |
1673 // Note that inline-block counts as replaced here. | 1676 // Note that inline-block counts as replaced here. |
1674 ASSERT(linePositionMode == PositionOfInteriorLineBoxes); | 1677 DCHECK_EQ(linePositionMode, PositionOfInteriorLineBoxes); |
1675 | 1678 |
1676 const SimpleFontData* fontData = style(firstLine)->font().primaryFont(); | 1679 const SimpleFontData* fontData = style(firstLine)->font().primaryFont(); |
1677 DCHECK(fontData); | 1680 DCHECK(fontData); |
1678 if (!fontData) | 1681 if (!fontData) |
1679 return -1; | 1682 return -1; |
1680 | 1683 |
1681 const FontMetrics& fontMetrics = fontData->getFontMetrics(); | 1684 const FontMetrics& fontMetrics = fontData->getFontMetrics(); |
1682 return (fontMetrics.ascent(baselineType) + | 1685 return (fontMetrics.ascent(baselineType) + |
1683 (lineHeight(firstLine, direction, linePositionMode) - | 1686 (lineHeight(firstLine, direction, linePositionMode) - |
1684 fontMetrics.height()) / | 1687 fontMetrics.height()) / |
(...skipping 14 matching lines...) Expand all Loading... |
1699 PositionOfInteriorLineBoxes)); | 1702 PositionOfInteriorLineBoxes)); |
1700 } | 1703 } |
1701 | 1704 |
1702 // TODO(mstensho): Figure out if all of this baseline code is needed here, or if | 1705 // 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 | 1706 // it should be moved down to LayoutBlockFlow. LayoutDeprecatedFlexibleBox and |
1704 // LayoutGrid lack baseline calculation overrides, so the code is here just for | 1707 // 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 | 1708 // them. Just walking the block children in logical order seems rather wrong for |
1706 // those two layout modes, though. | 1709 // those two layout modes, though. |
1707 | 1710 |
1708 int LayoutBlock::firstLineBoxBaseline() const { | 1711 int LayoutBlock::firstLineBoxBaseline() const { |
1709 ASSERT(!childrenInline()); | 1712 DCHECK(!childrenInline()); |
1710 if (isWritingModeRoot() && !isRubyRun()) | 1713 if (isWritingModeRoot() && !isRubyRun()) |
1711 return -1; | 1714 return -1; |
1712 | 1715 |
1713 for (LayoutBox* curr = firstChildBox(); curr; curr = curr->nextSiblingBox()) { | 1716 for (LayoutBox* curr = firstChildBox(); curr; curr = curr->nextSiblingBox()) { |
1714 if (!curr->isFloatingOrOutOfFlowPositioned()) { | 1717 if (!curr->isFloatingOrOutOfFlowPositioned()) { |
1715 int result = curr->firstLineBoxBaseline(); | 1718 int result = curr->firstLineBoxBaseline(); |
1716 if (result != -1) | 1719 if (result != -1) |
1717 return (curr->logicalTop() + result) | 1720 return (curr->logicalTop() + result) |
1718 .toInt(); // Translate to our coordinate space. | 1721 .toInt(); // Translate to our coordinate space. |
1719 } | 1722 } |
1720 } | 1723 } |
1721 return -1; | 1724 return -1; |
1722 } | 1725 } |
1723 | 1726 |
1724 int LayoutBlock::inlineBlockBaseline(LineDirectionMode lineDirection) const { | 1727 int LayoutBlock::inlineBlockBaseline(LineDirectionMode lineDirection) const { |
1725 ASSERT(!childrenInline()); | 1728 DCHECK(!childrenInline()); |
1726 if ((!style()->isOverflowVisible() && | 1729 if ((!style()->isOverflowVisible() && |
1727 !shouldIgnoreOverflowPropertyForInlineBlockBaseline()) || | 1730 !shouldIgnoreOverflowPropertyForInlineBlockBaseline()) || |
1728 style()->containsSize()) { | 1731 style()->containsSize()) { |
1729 // We are not calling LayoutBox::baselinePosition here because the caller | 1732 // We are not calling LayoutBox::baselinePosition here because the caller |
1730 // should add the margin-top/margin-right, not us. | 1733 // should add the margin-top/margin-right, not us. |
1731 return (lineDirection == HorizontalLine ? size().height() + marginBottom() | 1734 return (lineDirection == HorizontalLine ? size().height() + marginBottom() |
1732 : size().width() + marginLeft()) | 1735 : size().width() + marginLeft()) |
1733 .toInt(); | 1736 .toInt(); |
1734 } | 1737 } |
1735 | 1738 |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1975 newBox->setStyle(std::move(newStyle)); | 1978 newBox->setStyle(std::move(newStyle)); |
1976 return newBox; | 1979 return newBox; |
1977 } | 1980 } |
1978 | 1981 |
1979 bool LayoutBlock::recalcNormalFlowChildOverflowIfNeeded( | 1982 bool LayoutBlock::recalcNormalFlowChildOverflowIfNeeded( |
1980 LayoutObject* layoutObject) { | 1983 LayoutObject* layoutObject) { |
1981 if (layoutObject->isOutOfFlowPositioned() || | 1984 if (layoutObject->isOutOfFlowPositioned() || |
1982 !layoutObject->needsOverflowRecalcAfterStyleChange()) | 1985 !layoutObject->needsOverflowRecalcAfterStyleChange()) |
1983 return false; | 1986 return false; |
1984 | 1987 |
1985 ASSERT(layoutObject->isLayoutBlock()); | 1988 DCHECK(layoutObject->isLayoutBlock()); |
1986 return toLayoutBlock(layoutObject)->recalcOverflowAfterStyleChange(); | 1989 return toLayoutBlock(layoutObject)->recalcOverflowAfterStyleChange(); |
1987 } | 1990 } |
1988 | 1991 |
1989 bool LayoutBlock::recalcChildOverflowAfterStyleChange() { | 1992 bool LayoutBlock::recalcChildOverflowAfterStyleChange() { |
1990 ASSERT(childNeedsOverflowRecalcAfterStyleChange()); | 1993 DCHECK(childNeedsOverflowRecalcAfterStyleChange()); |
1991 clearChildNeedsOverflowRecalcAfterStyleChange(); | 1994 clearChildNeedsOverflowRecalcAfterStyleChange(); |
1992 | 1995 |
1993 bool childrenOverflowChanged = false; | 1996 bool childrenOverflowChanged = false; |
1994 | 1997 |
1995 if (childrenInline()) { | 1998 if (childrenInline()) { |
1996 SECURITY_DCHECK(isLayoutBlockFlow()); | 1999 SECURITY_DCHECK(isLayoutBlockFlow()); |
1997 childrenOverflowChanged = | 2000 childrenOverflowChanged = |
1998 toLayoutBlockFlow(this)->recalcInlineChildrenOverflowAfterStyleChange(); | 2001 toLayoutBlockFlow(this)->recalcInlineChildrenOverflowAfterStyleChange(); |
1999 } else { | 2002 } else { |
2000 for (LayoutBox* box = firstChildBox(); box; box = box->nextSiblingBox()) { | 2003 for (LayoutBox* box = firstChildBox(); box; box = box->nextSiblingBox()) { |
(...skipping 20 matching lines...) Expand all Loading... |
2021 if (!block->recalcOverflowAfterStyleChange() || | 2024 if (!block->recalcOverflowAfterStyleChange() || |
2022 box->style()->position() == EPosition::kFixed) | 2025 box->style()->position() == EPosition::kFixed) |
2023 continue; | 2026 continue; |
2024 | 2027 |
2025 childrenOverflowChanged = true; | 2028 childrenOverflowChanged = true; |
2026 } | 2029 } |
2027 return childrenOverflowChanged; | 2030 return childrenOverflowChanged; |
2028 } | 2031 } |
2029 | 2032 |
2030 bool LayoutBlock::recalcOverflowAfterStyleChange() { | 2033 bool LayoutBlock::recalcOverflowAfterStyleChange() { |
2031 ASSERT(needsOverflowRecalcAfterStyleChange()); | 2034 DCHECK(needsOverflowRecalcAfterStyleChange()); |
2032 | 2035 |
2033 bool childrenOverflowChanged = false; | 2036 bool childrenOverflowChanged = false; |
2034 if (childNeedsOverflowRecalcAfterStyleChange()) | 2037 if (childNeedsOverflowRecalcAfterStyleChange()) |
2035 childrenOverflowChanged = recalcChildOverflowAfterStyleChange(); | 2038 childrenOverflowChanged = recalcChildOverflowAfterStyleChange(); |
2036 | 2039 |
2037 if (!selfNeedsOverflowRecalcAfterStyleChange() && !childrenOverflowChanged) | 2040 if (!selfNeedsOverflowRecalcAfterStyleChange() && !childrenOverflowChanged) |
2038 return false; | 2041 return false; |
2039 | 2042 |
2040 clearSelfNeedsOverflowRecalcAfterStyleChange(); | 2043 clearSelfNeedsOverflowRecalcAfterStyleChange(); |
2041 // If the current block needs layout, overflow will be recalculated during | 2044 // 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; | 2099 return; |
2097 | 2100 |
2098 if (TrackedLayoutBoxListHashSet* positionedDescendantSet = | 2101 if (TrackedLayoutBoxListHashSet* positionedDescendantSet = |
2099 positionedObjects()) { | 2102 positionedObjects()) { |
2100 TrackedLayoutBoxListHashSet::const_iterator end = | 2103 TrackedLayoutBoxListHashSet::const_iterator end = |
2101 positionedDescendantSet->end(); | 2104 positionedDescendantSet->end(); |
2102 for (TrackedLayoutBoxListHashSet::const_iterator it = | 2105 for (TrackedLayoutBoxListHashSet::const_iterator it = |
2103 positionedDescendantSet->begin(); | 2106 positionedDescendantSet->begin(); |
2104 it != end; ++it) { | 2107 it != end; ++it) { |
2105 LayoutBox* currBox = *it; | 2108 LayoutBox* currBox = *it; |
2106 ASSERT(!currBox->needsLayout()); | 2109 DCHECK(!currBox->needsLayout()); |
2107 } | 2110 } |
2108 } | 2111 } |
2109 } | 2112 } |
2110 | 2113 |
2111 #endif | 2114 #endif |
2112 | 2115 |
2113 LayoutUnit LayoutBlock::availableLogicalHeightForPercentageComputation() const { | 2116 LayoutUnit LayoutBlock::availableLogicalHeightForPercentageComputation() const { |
2114 LayoutUnit availableHeight(-1); | 2117 LayoutUnit availableHeight(-1); |
2115 | 2118 |
2116 // For anonymous blocks that are skipped during percentage height calculation, | 2119 // For anonymous blocks that are skipped during percentage height calculation, |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2174 } | 2177 } |
2175 | 2178 |
2176 return availableHeight; | 2179 return availableHeight; |
2177 } | 2180 } |
2178 | 2181 |
2179 bool LayoutBlock::hasDefiniteLogicalHeight() const { | 2182 bool LayoutBlock::hasDefiniteLogicalHeight() const { |
2180 return availableLogicalHeightForPercentageComputation() != LayoutUnit(-1); | 2183 return availableLogicalHeightForPercentageComputation() != LayoutUnit(-1); |
2181 } | 2184 } |
2182 | 2185 |
2183 } // namespace blink | 2186 } // namespace blink |
OLD | NEW |