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.
All rights reserved. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. |
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 using namespace HTMLNames; | 79 using namespace HTMLNames; |
80 | 80 |
81 struct SameSizeAsLayoutBlock : public LayoutBox { | 81 struct SameSizeAsLayoutBlock : public LayoutBox { |
82 LayoutObjectChildList children; | 82 LayoutObjectChildList children; |
83 LineBoxList lineBoxes; | 83 LineBoxList lineBoxes; |
84 uint32_t bitfields; | 84 uint32_t bitfields; |
85 }; | 85 }; |
86 | 86 |
87 static_assert(sizeof(LayoutBlock) == sizeof(SameSizeAsLayoutBlock), "LayoutBlock
should stay small"); | 87 static_assert(sizeof(LayoutBlock) == sizeof(SameSizeAsLayoutBlock), "LayoutBlock
should stay small"); |
88 | 88 |
89 static TrackedDescendantsMap* gPositionedDescendantsMap = 0; | 89 static TrackedDescendantsMap* gPositionedDescendantsMap = nullptr; |
90 static TrackedDescendantsMap* gPercentHeightDescendantsMap = 0; | 90 static TrackedDescendantsMap* gPercentHeightDescendantsMap = nullptr; |
91 | 91 |
92 static TrackedContainerMap* gPositionedContainerMap = 0; | 92 static TrackedContainerMap* gPositionedContainerMap = nullptr; |
93 static TrackedContainerMap* gPercentHeightContainerMap = 0; | 93 static TrackedContainerMap* gPercentHeightContainerMap = nullptr; |
94 | 94 |
95 typedef WTF::HashSet<LayoutBlock*> DelayedUpdateScrollInfoSet; | 95 typedef WTF::HashSet<LayoutBlock*> DelayedUpdateScrollInfoSet; |
96 static int gDelayUpdateScrollInfo = 0; | 96 static int gDelayUpdateScrollInfo = 0; |
97 static DelayedUpdateScrollInfoSet* gDelayedUpdateScrollInfoSet = 0; | 97 static DelayedUpdateScrollInfoSet* gDelayedUpdateScrollInfoSet = nullptr; |
98 | 98 |
99 // This class helps dispatching the 'overflow' event on layout change. overflow
can be set on LayoutBoxes, yet the existing code | 99 // This class helps dispatching the 'overflow' event on layout change. overflow
can be set on LayoutBoxes, yet the existing code |
100 // only works on LayoutBlocks. If this changes, this class should be shared with
other LayoutBoxes. | 100 // only works on LayoutBlocks. If this changes, this class should be shared with
other LayoutBoxes. |
101 class OverflowEventDispatcher { | 101 class OverflowEventDispatcher { |
102 WTF_MAKE_NONCOPYABLE(OverflowEventDispatcher); | 102 WTF_MAKE_NONCOPYABLE(OverflowEventDispatcher); |
103 public: | 103 public: |
104 OverflowEventDispatcher(const LayoutBlock* block) | 104 OverflowEventDispatcher(const LayoutBlock* block) |
105 : m_block(block) | 105 : m_block(block) |
106 , m_hadHorizontalLayoutOverflow(false) | 106 , m_hadHorizontalLayoutOverflow(false) |
107 , m_hadVerticalLayoutOverflow(false) | 107 , m_hadVerticalLayoutOverflow(false) |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 // Make sure to destroy anonymous children first while they are still connec
ted to the rest of the tree, so that they will | 223 // Make sure to destroy anonymous children first while they are still connec
ted to the rest of the tree, so that they will |
224 // properly dirty line boxes that they are removed from. Effects that do :be
fore/:after only on hover could crash otherwise. | 224 // properly dirty line boxes that they are removed from. Effects that do :be
fore/:after only on hover could crash otherwise. |
225 children()->destroyLeftoverChildren(); | 225 children()->destroyLeftoverChildren(); |
226 | 226 |
227 // Destroy our continuation before anything other than anonymous children. | 227 // Destroy our continuation before anything other than anonymous children. |
228 // The reason we don't destroy it before anonymous children is that they may | 228 // The reason we don't destroy it before anonymous children is that they may |
229 // have continuations of their own that are anonymous children of our contin
uation. | 229 // have continuations of their own that are anonymous children of our contin
uation. |
230 LayoutBoxModelObject* continuation = this->continuation(); | 230 LayoutBoxModelObject* continuation = this->continuation(); |
231 if (continuation) { | 231 if (continuation) { |
232 continuation->destroy(); | 232 continuation->destroy(); |
233 setContinuation(0); | 233 setContinuation(nullptr); |
234 } | 234 } |
235 | 235 |
236 if (!documentBeingDestroyed()) { | 236 if (!documentBeingDestroyed()) { |
237 if (firstLineBox()) { | 237 if (firstLineBox()) { |
238 // We can't wait for LayoutBox::destroy to clear the selection, | 238 // We can't wait for LayoutBox::destroy to clear the selection, |
239 // because by then we will have nuked the line boxes. | 239 // because by then we will have nuked the line boxes. |
240 // FIXME: The FrameSelection should be responsible for this when it | 240 // FIXME: The FrameSelection should be responsible for this when it |
241 // is notified of DOM mutations. | 241 // is notified of DOM mutations. |
242 if (isSelectionBorder()) | 242 if (isSelectionBorder()) |
243 view()->clearSelection(); | 243 view()->clearSelection(); |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 children()->removeChildNode(this, inlineChildrenBlock, inlineChildre
nBlockHasLayer); | 705 children()->removeChildNode(this, inlineChildrenBlock, inlineChildre
nBlockHasLayer); |
706 | 706 |
707 // Now just put the inlineChildrenBlock inside the blockChildrenBloc
k. | 707 // Now just put the inlineChildrenBlock inside the blockChildrenBloc
k. |
708 blockChildrenBlock->children()->insertChildNode(blockChildrenBlock,
inlineChildrenBlock, prev == inlineChildrenBlock ? blockChildrenBlock->firstChil
d() : 0, | 708 blockChildrenBlock->children()->insertChildNode(blockChildrenBlock,
inlineChildrenBlock, prev == inlineChildrenBlock ? blockChildrenBlock->firstChil
d() : 0, |
709 inlineChildrenBlockHasLayer || blockChildrenBlock->hasLayer()); | 709 inlineChildrenBlockHasLayer || blockChildrenBlock->hasLayer()); |
710 next->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(Layo
utInvalidationReason::AnonymousBlockChange); | 710 next->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(Layo
utInvalidationReason::AnonymousBlockChange); |
711 | 711 |
712 // inlineChildrenBlock got reparented to blockChildrenBlock, so it i
s no longer a child | 712 // inlineChildrenBlock got reparented to blockChildrenBlock, so it i
s no longer a child |
713 // of "this". we null out prev or next so that is not used later in
the function. | 713 // of "this". we null out prev or next so that is not used later in
the function. |
714 if (inlineChildrenBlock == prevBlock) | 714 if (inlineChildrenBlock == prevBlock) |
715 prev = 0; | 715 prev = nullptr; |
716 else | 716 else |
717 next = 0; | 717 next = nullptr; |
718 } else { | 718 } else { |
719 // Take all the children out of the |next| block and put them in | 719 // Take all the children out of the |next| block and put them in |
720 // the |prev| block. | 720 // the |prev| block. |
721 nextBlock->moveAllChildrenIncludingFloatsTo(prevBlock, nextBlock->ha
sLayer() || prevBlock->hasLayer()); | 721 nextBlock->moveAllChildrenIncludingFloatsTo(prevBlock, nextBlock->ha
sLayer() || prevBlock->hasLayer()); |
722 | 722 |
723 // Delete the now-empty block's lines and nuke it. | 723 // Delete the now-empty block's lines and nuke it. |
724 nextBlock->deleteLineBoxTree(); | 724 nextBlock->deleteLineBoxTree(); |
725 nextBlock->destroy(); | 725 nextBlock->destroy(); |
726 next = 0; | 726 next = nullptr; |
727 } | 727 } |
728 } | 728 } |
729 | 729 |
730 LayoutBox::removeChild(oldChild); | 730 LayoutBox::removeChild(oldChild); |
731 | 731 |
732 LayoutObject* child = prev ? prev : next; | 732 LayoutObject* child = prev ? prev : next; |
733 if (canMergeAnonymousBlocks && child && !child->previousSibling() && !child-
>nextSibling() && canCollapseAnonymousBlockChild()) { | 733 if (canMergeAnonymousBlocks && child && !child->previousSibling() && !child-
>nextSibling() && canCollapseAnonymousBlockChild()) { |
734 // The removal has knocked us down to containing only a single anonymous | 734 // The removal has knocked us down to containing only a single anonymous |
735 // box. We can go ahead and pull the content right back up into our | 735 // box. We can go ahead and pull the content right back up into our |
736 // box. | 736 // box. |
(...skipping 30 matching lines...) Expand all Loading... |
767 LayoutBoxModelObject* nextContinuation = continuation(); | 767 LayoutBoxModelObject* nextContinuation = continuation(); |
768 if (curr->isLayoutInline()) | 768 if (curr->isLayoutInline()) |
769 toLayoutInline(curr)->setContinuation(nextContinuation); | 769 toLayoutInline(curr)->setContinuation(nextContinuation); |
770 else if (curr->isLayoutBlock()) | 770 else if (curr->isLayoutBlock()) |
771 toLayoutBlock(curr)->setContinuation(nextContinuation); | 771 toLayoutBlock(curr)->setContinuation(nextContinuation); |
772 else | 772 else |
773 ASSERT_NOT_REACHED(); | 773 ASSERT_NOT_REACHED(); |
774 | 774 |
775 break; | 775 break; |
776 } | 776 } |
777 setContinuation(0); | 777 setContinuation(nullptr); |
778 destroy(); | 778 destroy(); |
779 } | 779 } |
780 } | 780 } |
781 } | 781 } |
782 | 782 |
783 bool LayoutBlock::isSelfCollapsingBlock() const | 783 bool LayoutBlock::isSelfCollapsingBlock() const |
784 { | 784 { |
785 // We are not self-collapsing if we | 785 // We are not self-collapsing if we |
786 // (a) have a non-zero height according to layout (an optimization to avoid
wasting time) | 786 // (a) have a non-zero height according to layout (an optimization to avoid
wasting time) |
787 // (b) are a table, | 787 // (b) are a table, |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 } | 853 } |
854 | 854 |
855 void LayoutBlock::finishDelayUpdateScrollInfo() | 855 void LayoutBlock::finishDelayUpdateScrollInfo() |
856 { | 856 { |
857 --gDelayUpdateScrollInfo; | 857 --gDelayUpdateScrollInfo; |
858 ASSERT(gDelayUpdateScrollInfo >= 0); | 858 ASSERT(gDelayUpdateScrollInfo >= 0); |
859 if (gDelayUpdateScrollInfo == 0) { | 859 if (gDelayUpdateScrollInfo == 0) { |
860 ASSERT(gDelayedUpdateScrollInfoSet); | 860 ASSERT(gDelayedUpdateScrollInfoSet); |
861 | 861 |
862 OwnPtr<DelayedUpdateScrollInfoSet> infoSet(adoptPtr(gDelayedUpdateScroll
InfoSet)); | 862 OwnPtr<DelayedUpdateScrollInfoSet> infoSet(adoptPtr(gDelayedUpdateScroll
InfoSet)); |
863 gDelayedUpdateScrollInfoSet = 0; | 863 gDelayedUpdateScrollInfoSet = nullptr; |
864 | 864 |
865 for (auto* block : *infoSet) { | 865 for (auto* block : *infoSet) { |
866 if (block->hasOverflowClip()) { | 866 if (block->hasOverflowClip()) { |
867 block->layer()->scrollableArea()->updateAfterLayout(); | 867 block->layer()->scrollableArea()->updateAfterLayout(); |
868 } | 868 } |
869 } | 869 } |
870 } | 870 } |
871 } | 871 } |
872 | 872 |
873 void LayoutBlock::updateScrollInfoAfterLayout() | 873 void LayoutBlock::updateScrollInfoAfterLayout() |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1382 { | 1382 { |
1383 // The border can potentially be further extended by our containingBlock(). | 1383 // The border can potentially be further extended by our containingBlock(). |
1384 if (rootBlock != this) | 1384 if (rootBlock != this) |
1385 return containingBlock()->logicalRightSelectionOffset(rootBlock, positio
n + logicalTop()); | 1385 return containingBlock()->logicalRightSelectionOffset(rootBlock, positio
n + logicalTop()); |
1386 return logicalRightOffsetForContent(); | 1386 return logicalRightOffsetForContent(); |
1387 } | 1387 } |
1388 | 1388 |
1389 LayoutBlock* LayoutBlock::blockBeforeWithinSelectionRoot(LayoutSize& offset) con
st | 1389 LayoutBlock* LayoutBlock::blockBeforeWithinSelectionRoot(LayoutSize& offset) con
st |
1390 { | 1390 { |
1391 if (isSelectionRoot()) | 1391 if (isSelectionRoot()) |
1392 return 0; | 1392 return nullptr; |
1393 | 1393 |
1394 const LayoutObject* object = this; | 1394 const LayoutObject* object = this; |
1395 LayoutObject* sibling; | 1395 LayoutObject* sibling; |
1396 do { | 1396 do { |
1397 sibling = object->previousSibling(); | 1397 sibling = object->previousSibling(); |
1398 while (sibling && (!sibling->isLayoutBlock() || toLayoutBlock(sibling)->
isSelectionRoot())) | 1398 while (sibling && (!sibling->isLayoutBlock() || toLayoutBlock(sibling)->
isSelectionRoot())) |
1399 sibling = sibling->previousSibling(); | 1399 sibling = sibling->previousSibling(); |
1400 | 1400 |
1401 offset -= LayoutSize(toLayoutBlock(object)->logicalLeft(), toLayoutBlock
(object)->logicalTop()); | 1401 offset -= LayoutSize(toLayoutBlock(object)->logicalLeft(), toLayoutBlock
(object)->logicalTop()); |
1402 object = object->parent(); | 1402 object = object->parent(); |
1403 } while (!sibling && object && object->isLayoutBlock() && !toLayoutBlock(obj
ect)->isSelectionRoot()); | 1403 } while (!sibling && object && object->isLayoutBlock() && !toLayoutBlock(obj
ect)->isSelectionRoot()); |
1404 | 1404 |
1405 if (!sibling) | 1405 if (!sibling) |
1406 return 0; | 1406 return nullptr; |
1407 | 1407 |
1408 LayoutBlock* beforeBlock = toLayoutBlock(sibling); | 1408 LayoutBlock* beforeBlock = toLayoutBlock(sibling); |
1409 | 1409 |
1410 offset += LayoutSize(beforeBlock->logicalLeft(), beforeBlock->logicalTop()); | 1410 offset += LayoutSize(beforeBlock->logicalLeft(), beforeBlock->logicalTop()); |
1411 | 1411 |
1412 LayoutObject* child = beforeBlock->lastChild(); | 1412 LayoutObject* child = beforeBlock->lastChild(); |
1413 while (child && child->isLayoutBlock()) { | 1413 while (child && child->isLayoutBlock()) { |
1414 beforeBlock = toLayoutBlock(child); | 1414 beforeBlock = toLayoutBlock(child); |
1415 offset += LayoutSize(beforeBlock->logicalLeft(), beforeBlock->logicalTop
()); | 1415 offset += LayoutSize(beforeBlock->logicalLeft(), beforeBlock->logicalTop
()); |
1416 child = beforeBlock->lastChild(); | 1416 child = beforeBlock->lastChild(); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1478 descendantSet->remove(descendant); | 1478 descendantSet->remove(descendant); |
1479 if (descendantSet->isEmpty()) | 1479 if (descendantSet->isEmpty()) |
1480 descendantsMap->remove(descendantsMapIterator); | 1480 descendantsMap->remove(descendantsMapIterator); |
1481 } | 1481 } |
1482 } | 1482 } |
1483 | 1483 |
1484 TrackedLayoutBoxListHashSet* LayoutBlock::positionedObjects() const | 1484 TrackedLayoutBoxListHashSet* LayoutBlock::positionedObjects() const |
1485 { | 1485 { |
1486 if (gPositionedDescendantsMap) | 1486 if (gPositionedDescendantsMap) |
1487 return gPositionedDescendantsMap->get(this); | 1487 return gPositionedDescendantsMap->get(this); |
1488 return 0; | 1488 return nullptr; |
1489 } | 1489 } |
1490 | 1490 |
1491 void LayoutBlock::insertPositionedObject(LayoutBox* o) | 1491 void LayoutBlock::insertPositionedObject(LayoutBox* o) |
1492 { | 1492 { |
1493 ASSERT(!isAnonymousBlock()); | 1493 ASSERT(!isAnonymousBlock()); |
1494 insertIntoTrackedLayoutBoxMaps(o, gPositionedDescendantsMap, gPositionedCont
ainerMap); | 1494 insertIntoTrackedLayoutBoxMaps(o, gPositionedDescendantsMap, gPositionedCont
ainerMap); |
1495 } | 1495 } |
1496 | 1496 |
1497 void LayoutBlock::removePositionedObject(LayoutBox* o) | 1497 void LayoutBlock::removePositionedObject(LayoutBox* o) |
1498 { | 1498 { |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1826 { | 1826 { |
1827 ASSERT(childrenInline()); | 1827 ASSERT(childrenInline()); |
1828 | 1828 |
1829 if (!firstRootBox()) | 1829 if (!firstRootBox()) |
1830 return createPositionWithAffinity(0, DOWNSTREAM); | 1830 return createPositionWithAffinity(0, DOWNSTREAM); |
1831 | 1831 |
1832 bool linesAreFlipped = style()->isFlippedLinesWritingMode(); | 1832 bool linesAreFlipped = style()->isFlippedLinesWritingMode(); |
1833 bool blocksAreFlipped = style()->isFlippedBlocksWritingMode(); | 1833 bool blocksAreFlipped = style()->isFlippedBlocksWritingMode(); |
1834 | 1834 |
1835 // look for the closest line box in the root box which is at the passed-in y
coordinate | 1835 // look for the closest line box in the root box which is at the passed-in y
coordinate |
1836 InlineBox* closestBox = 0; | 1836 InlineBox* closestBox = nullptr; |
1837 RootInlineBox* firstRootBoxWithChildren = 0; | 1837 RootInlineBox* firstRootBoxWithChildren = nullptr; |
1838 RootInlineBox* lastRootBoxWithChildren = 0; | 1838 RootInlineBox* lastRootBoxWithChildren = nullptr; |
1839 for (RootInlineBox* root = firstRootBox(); root; root = root->nextRootBox())
{ | 1839 for (RootInlineBox* root = firstRootBox(); root; root = root->nextRootBox())
{ |
1840 if (!root->firstLeafChild()) | 1840 if (!root->firstLeafChild()) |
1841 continue; | 1841 continue; |
1842 if (!firstRootBoxWithChildren) | 1842 if (!firstRootBoxWithChildren) |
1843 firstRootBoxWithChildren = root; | 1843 firstRootBoxWithChildren = root; |
1844 | 1844 |
1845 if (!linesAreFlipped && root->isFirstAfterPageBreak() && (pointInLogical
Contents.y() < root->lineTopWithLeading() | 1845 if (!linesAreFlipped && root->isFirstAfterPageBreak() && (pointInLogical
Contents.y() < root->lineTopWithLeading() |
1846 || (blocksAreFlipped && pointInLogicalContents.y() == root->lineTopW
ithLeading()))) | 1846 || (blocksAreFlipped && pointInLogicalContents.y() == root->lineTopW
ithLeading()))) |
1847 break; | 1847 break; |
1848 | 1848 |
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2326 || !parentBlock | 2326 || !parentBlock |
2327 || !isLayoutBlockFlowOrLayoutButton(parentBlock)) | 2327 || !isLayoutBlockFlowOrLayoutButton(parentBlock)) |
2328 break; | 2328 break; |
2329 ASSERT_WITH_SECURITY_IMPLICATION(parentBlock->isLayoutBlock()); | 2329 ASSERT_WITH_SECURITY_IMPLICATION(parentBlock->isLayoutBlock()); |
2330 if (toLayoutBlock(parentBlock)->firstChild() != firstLineBlock) | 2330 if (toLayoutBlock(parentBlock)->firstChild() != firstLineBlock) |
2331 break; | 2331 break; |
2332 firstLineBlock = toLayoutBlock(parentBlock); | 2332 firstLineBlock = toLayoutBlock(parentBlock); |
2333 } | 2333 } |
2334 | 2334 |
2335 if (!hasPseudo) | 2335 if (!hasPseudo) |
2336 return 0; | 2336 return nullptr; |
2337 | 2337 |
2338 return firstLineBlock; | 2338 return firstLineBlock; |
2339 } | 2339 } |
2340 | 2340 |
2341 // Helper methods for obtaining the last line, computing line counts and heights
for line counts | 2341 // Helper methods for obtaining the last line, computing line counts and heights
for line counts |
2342 // (crawling into blocks). | 2342 // (crawling into blocks). |
2343 static bool shouldCheckLines(LayoutObject* obj) | 2343 static bool shouldCheckLines(LayoutObject* obj) |
2344 { | 2344 { |
2345 return !obj->isFloatingOrOutOfFlowPositioned() | 2345 return !obj->isFloatingOrOutOfFlowPositioned() |
2346 && obj->isLayoutBlock() && obj->style()->height().isAuto() | 2346 && obj->isLayoutBlock() && obj->style()->height().isAuto() |
2347 && (!obj->isDeprecatedFlexibleBox() || obj->style()->boxOrient() == VERT
ICAL); | 2347 && (!obj->isDeprecatedFlexibleBox() || obj->style()->boxOrient() == VERT
ICAL); |
2348 } | 2348 } |
2349 | 2349 |
2350 static int getHeightForLineCount(LayoutBlock* block, int l, bool includeBottom,
int& count) | 2350 static int getHeightForLineCount(LayoutBlock* block, int l, bool includeBottom,
int& count) |
2351 { | 2351 { |
2352 if (block->style()->visibility() == VISIBLE) { | 2352 if (block->style()->visibility() == VISIBLE) { |
2353 if (block->isLayoutBlockFlow() && block->childrenInline()) { | 2353 if (block->isLayoutBlockFlow() && block->childrenInline()) { |
2354 for (RootInlineBox* box = toLayoutBlockFlow(block)->firstRootBox();
box; box = box->nextRootBox()) { | 2354 for (RootInlineBox* box = toLayoutBlockFlow(block)->firstRootBox();
box; box = box->nextRootBox()) { |
2355 if (++count == l) | 2355 if (++count == l) |
2356 return box->lineBottom() + (includeBottom ? (block->borderBo
ttom() + block->paddingBottom()) : LayoutUnit()); | 2356 return box->lineBottom() + (includeBottom ? (block->borderBo
ttom() + block->paddingBottom()) : LayoutUnit()); |
2357 } | 2357 } |
2358 } else { | 2358 } else { |
2359 LayoutBox* normalFlowChildWithoutLines = 0; | 2359 LayoutBox* normalFlowChildWithoutLines = nullptr; |
2360 for (LayoutBox* obj = block->firstChildBox(); obj; obj = obj->nextSi
blingBox()) { | 2360 for (LayoutBox* obj = block->firstChildBox(); obj; obj = obj->nextSi
blingBox()) { |
2361 if (shouldCheckLines(obj)) { | 2361 if (shouldCheckLines(obj)) { |
2362 int result = getHeightForLineCount(toLayoutBlock(obj), l, fa
lse, count); | 2362 int result = getHeightForLineCount(toLayoutBlock(obj), l, fa
lse, count); |
2363 if (result != -1) | 2363 if (result != -1) |
2364 return result + obj->location().y() + (includeBottom ? (
block->borderBottom() + block->paddingBottom()) : LayoutUnit()); | 2364 return result + obj->location().y() + (includeBottom ? (
block->borderBottom() + block->paddingBottom()) : LayoutUnit()); |
2365 } else if (!obj->isFloatingOrOutOfFlowPositioned()) { | 2365 } else if (!obj->isFloatingOrOutOfFlowPositioned()) { |
2366 normalFlowChildWithoutLines = obj; | 2366 normalFlowChildWithoutLines = obj; |
2367 } | 2367 } |
2368 } | 2368 } |
2369 if (normalFlowChildWithoutLines && l == 0) | 2369 if (normalFlowChildWithoutLines && l == 0) |
2370 return normalFlowChildWithoutLines->location().y() + normalFlowC
hildWithoutLines->size().height(); | 2370 return normalFlowChildWithoutLines->location().y() + normalFlowC
hildWithoutLines->size().height(); |
2371 } | 2371 } |
2372 } | 2372 } |
2373 | 2373 |
2374 return -1; | 2374 return -1; |
2375 } | 2375 } |
2376 | 2376 |
2377 RootInlineBox* LayoutBlock::lineAtIndex(int i) const | 2377 RootInlineBox* LayoutBlock::lineAtIndex(int i) const |
2378 { | 2378 { |
2379 ASSERT(i >= 0); | 2379 ASSERT(i >= 0); |
2380 | 2380 |
2381 if (style()->visibility() != VISIBLE) | 2381 if (style()->visibility() != VISIBLE) |
2382 return 0; | 2382 return nullptr; |
2383 | 2383 |
2384 if (childrenInline()) { | 2384 if (childrenInline()) { |
2385 for (RootInlineBox* box = firstRootBox(); box; box = box->nextRootBox())
{ | 2385 for (RootInlineBox* box = firstRootBox(); box; box = box->nextRootBox())
{ |
2386 if (!i--) | 2386 if (!i--) |
2387 return box; | 2387 return box; |
2388 } | 2388 } |
2389 } else { | 2389 } else { |
2390 for (LayoutObject* child = firstChild(); child; child = child->nextSibli
ng()) { | 2390 for (LayoutObject* child = firstChild(); child; child = child->nextSibli
ng()) { |
2391 if (!shouldCheckLines(child)) | 2391 if (!shouldCheckLines(child)) |
2392 continue; | 2392 continue; |
2393 if (RootInlineBox* box = toLayoutBlock(child)->lineAtIndex(i)) | 2393 if (RootInlineBox* box = toLayoutBlock(child)->lineAtIndex(i)) |
2394 return box; | 2394 return box; |
2395 } | 2395 } |
2396 } | 2396 } |
2397 | 2397 |
2398 return 0; | 2398 return nullptr; |
2399 } | 2399 } |
2400 | 2400 |
2401 int LayoutBlock::lineCount(const RootInlineBox* stopRootInlineBox, bool* found)
const | 2401 int LayoutBlock::lineCount(const RootInlineBox* stopRootInlineBox, bool* found)
const |
2402 { | 2402 { |
2403 int count = 0; | 2403 int count = 0; |
2404 | 2404 |
2405 if (style()->visibility() == VISIBLE) { | 2405 if (style()->visibility() == VISIBLE) { |
2406 if (childrenInline()) { | 2406 if (childrenInline()) { |
2407 for (RootInlineBox* box = firstRootBox(); box; box = box->nextRootBo
x()) { | 2407 for (RootInlineBox* box = firstRootBox(); box; box = box->nextRootBo
x()) { |
2408 count++; | 2408 count++; |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2734 const char* LayoutBlock::name() const | 2734 const char* LayoutBlock::name() const |
2735 { | 2735 { |
2736 ASSERT_NOT_REACHED(); | 2736 ASSERT_NOT_REACHED(); |
2737 return "LayoutBlock"; | 2737 return "LayoutBlock"; |
2738 } | 2738 } |
2739 | 2739 |
2740 LayoutBlock* LayoutBlock::createAnonymousWithParentAndDisplay(const LayoutObject
* parent, EDisplay display) | 2740 LayoutBlock* LayoutBlock::createAnonymousWithParentAndDisplay(const LayoutObject
* parent, EDisplay display) |
2741 { | 2741 { |
2742 // FIXME: Do we need to convert all our inline displays to block-type in the
anonymous logic ? | 2742 // FIXME: Do we need to convert all our inline displays to block-type in the
anonymous logic ? |
2743 EDisplay newDisplay; | 2743 EDisplay newDisplay; |
2744 LayoutBlock* newBox = 0; | 2744 LayoutBlock* newBox = nullptr; |
2745 if (display == FLEX || display == INLINE_FLEX) { | 2745 if (display == FLEX || display == INLINE_FLEX) { |
2746 newBox = LayoutFlexibleBox::createAnonymous(&parent->document()); | 2746 newBox = LayoutFlexibleBox::createAnonymous(&parent->document()); |
2747 newDisplay = FLEX; | 2747 newDisplay = FLEX; |
2748 } else { | 2748 } else { |
2749 newBox = LayoutBlockFlow::createAnonymous(&parent->document()); | 2749 newBox = LayoutBlockFlow::createAnonymous(&parent->document()); |
2750 newDisplay = BLOCK; | 2750 newDisplay = BLOCK; |
2751 } | 2751 } |
2752 | 2752 |
2753 RefPtr<ComputedStyle> newStyle = ComputedStyle::createAnonymousStyleWithDisp
lay(parent->styleRef(), newDisplay); | 2753 RefPtr<ComputedStyle> newStyle = ComputedStyle::createAnonymousStyleWithDisp
lay(parent->styleRef(), newDisplay); |
2754 parent->updateAnonymousChildStyle(*newBox, *newStyle); | 2754 parent->updateAnonymousChildStyle(*newBox, *newStyle); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2907 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m
arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout
Object* obj) const | 2907 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m
arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout
Object* obj) const |
2908 { | 2908 { |
2909 showLayoutObject(); | 2909 showLayoutObject(); |
2910 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot
Box()) | 2910 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot
Box()) |
2911 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa
bel2, obj, 1); | 2911 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa
bel2, obj, 1); |
2912 } | 2912 } |
2913 | 2913 |
2914 #endif | 2914 #endif |
2915 | 2915 |
2916 } // namespace blink | 2916 } // namespace blink |
OLD | NEW |