Chromium Code Reviews| 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 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 711 | 711 |
| 712 // We already know the newBlockBox isn't going to contain inline kids, so av oid wasting | 712 // We already know the newBlockBox isn't going to contain inline kids, so av oid wasting |
| 713 // time in makeChildrenNonInline by just setting this explicitly up front. | 713 // time in makeChildrenNonInline by just setting this explicitly up front. |
| 714 newBlockBox->setChildrenInline(false); | 714 newBlockBox->setChildrenInline(false); |
| 715 | 715 |
| 716 newBlockBox->addChild(newChild); | 716 newBlockBox->addChild(newChild); |
| 717 | 717 |
| 718 // Always just do a full layout in order to ensure that line boxes (especial ly wrappers for images) | 718 // Always just do a full layout in order to ensure that line boxes (especial ly wrappers for images) |
| 719 // get deleted properly. Because objects moves from the pre block into the post block, we want to | 719 // get deleted properly. Because objects moves from the pre block into the post block, we want to |
| 720 // make new line boxes instead of leaving the old line boxes around. | 720 // make new line boxes instead of leaving the old line boxes around. |
| 721 pre->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(); | 721 pre->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(LayoutInvalid ationReason::ColumnsChanged); |
| 722 block->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(); | 722 block->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(LayoutInval idationReason::ColumnsChanged); |
| 723 post->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(); | 723 post->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(LayoutInvali dationReason::ColumnsChanged); |
| 724 } | 724 } |
| 725 | 725 |
| 726 void LayoutBlock::makeChildrenAnonymousColumnBlocks(LayoutObject* beforeChild, L ayoutBlockFlow* newBlockBox, LayoutObject* newChild) | 726 void LayoutBlock::makeChildrenAnonymousColumnBlocks(LayoutObject* beforeChild, L ayoutBlockFlow* newBlockBox, LayoutObject* newChild) |
| 727 { | 727 { |
| 728 LayoutBlockFlow* pre = 0; | 728 LayoutBlockFlow* pre = 0; |
| 729 LayoutBlockFlow* post = 0; | 729 LayoutBlockFlow* post = 0; |
| 730 LayoutBlock* block = this; // Eventually block will not just be |this|, but will also be a block nested inside |this|. Assign to a variable | 730 LayoutBlock* block = this; // Eventually block will not just be |this|, but will also be a block nested inside |this|. Assign to a variable |
| 731 // so that we don't have to patch all of the rest of the code later on. | 731 // so that we don't have to patch all of the rest of the code later on. |
| 732 | 732 |
| 733 // Delete the block's line boxes before we do the split. | 733 // Delete the block's line boxes before we do the split. |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 761 // We already know the newBlockBox isn't going to contain inline kids, so av oid wasting | 761 // We already know the newBlockBox isn't going to contain inline kids, so av oid wasting |
| 762 // time in makeChildrenNonInline by just setting this explicitly up front. | 762 // time in makeChildrenNonInline by just setting this explicitly up front. |
| 763 newBlockBox->setChildrenInline(false); | 763 newBlockBox->setChildrenInline(false); |
| 764 | 764 |
| 765 newBlockBox->addChild(newChild); | 765 newBlockBox->addChild(newChild); |
| 766 | 766 |
| 767 // Always just do a full layout in order to ensure that line boxes (especial ly wrappers for images) | 767 // Always just do a full layout in order to ensure that line boxes (especial ly wrappers for images) |
| 768 // get deleted properly. Because objects moved from the pre block into the post block, we want to | 768 // get deleted properly. Because objects moved from the pre block into the post block, we want to |
| 769 // make new line boxes instead of leaving the old line boxes around. | 769 // make new line boxes instead of leaving the old line boxes around. |
| 770 if (pre) | 770 if (pre) |
| 771 pre->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(); | 771 pre->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(LayoutInv alidationReason::ColumnsChanged); |
| 772 block->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(); | 772 block->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(LayoutInval idationReason::ColumnsChanged); |
| 773 if (post) | 773 if (post) |
| 774 post->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(); | 774 post->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(LayoutIn validationReason::ColumnsChanged); |
| 775 } | 775 } |
| 776 | 776 |
| 777 LayoutBlockFlow* LayoutBlock::columnsBlockForSpanningElement(LayoutObject* newCh ild) | 777 LayoutBlockFlow* LayoutBlock::columnsBlockForSpanningElement(LayoutObject* newCh ild) |
| 778 { | 778 { |
| 779 // FIXME: This function is the gateway for the addition of column-span suppo rt. It will | 779 // FIXME: This function is the gateway for the addition of column-span suppo rt. It will |
| 780 // be added to in three stages: | 780 // be added to in three stages: |
| 781 // (1) Immediate children of a multi-column block can span. | 781 // (1) Immediate children of a multi-column block can span. |
| 782 // (2) Nested block-level children with only block-level ancestors between t hem and the multi-column block can span. | 782 // (2) Nested block-level children with only block-level ancestors between t hem and the multi-column block can span. |
| 783 // (3) Nested children with block or inline ancestors between them and the m ulti-column block can span (this is when we | 783 // (3) Nested children with block or inline ancestors between them and the m ulti-column block can span (this is when we |
| 784 // cross the streams and have to cope with both types of continuations mixed together). | 784 // cross the streams and have to cope with both types of continuations mixed together). |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1115 collapseAnonymousBlockChild(this, toLayoutBlock(blocksToRemove[i])); | 1115 collapseAnonymousBlockChild(this, toLayoutBlock(blocksToRemove[i])); |
| 1116 } | 1116 } |
| 1117 | 1117 |
| 1118 void LayoutBlock::collapseAnonymousBlockChild(LayoutBlock* parent, LayoutBlock* child) | 1118 void LayoutBlock::collapseAnonymousBlockChild(LayoutBlock* parent, LayoutBlock* child) |
| 1119 { | 1119 { |
| 1120 // It's possible that this block's destruction may have been triggered by th e | 1120 // It's possible that this block's destruction may have been triggered by th e |
| 1121 // child's removal. Just bail if the anonymous child block is already being | 1121 // child's removal. Just bail if the anonymous child block is already being |
| 1122 // destroyed. See crbug.com/282088 | 1122 // destroyed. See crbug.com/282088 |
| 1123 if (child->beingDestroyed()) | 1123 if (child->beingDestroyed()) |
| 1124 return; | 1124 return; |
| 1125 parent->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(); | 1125 parent->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(LayoutInva lidationReason::ChildAnonymousBlockChanged); |
| 1126 parent->setChildrenInline(child->childrenInline()); | 1126 parent->setChildrenInline(child->childrenInline()); |
| 1127 LayoutObject* nextSibling = child->nextSibling(); | 1127 LayoutObject* nextSibling = child->nextSibling(); |
| 1128 | 1128 |
| 1129 parent->children()->removeChildNode(parent, child, child->hasLayer()); | 1129 parent->children()->removeChildNode(parent, child, child->hasLayer()); |
| 1130 // FIXME: Get rid of the temporary disabling of continuations. This is neede d by the old | 1130 // FIXME: Get rid of the temporary disabling of continuations. This is neede d by the old |
| 1131 // multicol implementation, because of buggy block continuation handling (wh ich is hard and | 1131 // multicol implementation, because of buggy block continuation handling (wh ich is hard and |
| 1132 // rather pointless to fix at this point). Support for block continuations c an be removed | 1132 // rather pointless to fix at this point). Support for block continuations c an be removed |
| 1133 // together with the old multicol implementation. crbug.com/408123 | 1133 // together with the old multicol implementation. crbug.com/408123 |
| 1134 LayoutBoxModelObject* temporarilyInactiveContinuation = parent->continuation (); | 1134 LayoutBoxModelObject* temporarilyInactiveContinuation = parent->continuation (); |
| 1135 if (temporarilyInactiveContinuation) | 1135 if (temporarilyInactiveContinuation) |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 1155 // This protects against column split flows when anonymous blocks are gettin g merged. | 1155 // This protects against column split flows when anonymous blocks are gettin g merged. |
| 1156 TemporaryChange<bool> columnFlowSplitEnabled(gColumnFlowSplitEnabled, false) ; | 1156 TemporaryChange<bool> columnFlowSplitEnabled(gColumnFlowSplitEnabled, false) ; |
| 1157 | 1157 |
| 1158 // If this child is a block, and if our previous and next siblings are | 1158 // If this child is a block, and if our previous and next siblings are |
| 1159 // both anonymous blocks with inline content, then we can go ahead and | 1159 // both anonymous blocks with inline content, then we can go ahead and |
| 1160 // fold the inline content back together. | 1160 // fold the inline content back together. |
| 1161 LayoutObject* prev = oldChild->previousSibling(); | 1161 LayoutObject* prev = oldChild->previousSibling(); |
| 1162 LayoutObject* next = oldChild->nextSibling(); | 1162 LayoutObject* next = oldChild->nextSibling(); |
| 1163 bool canMergeAnonymousBlocks = canMergeContiguousAnonymousBlocks(oldChild, p rev, next); | 1163 bool canMergeAnonymousBlocks = canMergeContiguousAnonymousBlocks(oldChild, p rev, next); |
| 1164 if (canMergeAnonymousBlocks && prev && next) { | 1164 if (canMergeAnonymousBlocks && prev && next) { |
| 1165 prev->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(); | 1165 prev->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(LayoutIn validationReason::AnonymousBlockChange); |
| 1166 LayoutBlockFlow* nextBlock = toLayoutBlockFlow(next); | 1166 LayoutBlockFlow* nextBlock = toLayoutBlockFlow(next); |
| 1167 LayoutBlockFlow* prevBlock = toLayoutBlockFlow(prev); | 1167 LayoutBlockFlow* prevBlock = toLayoutBlockFlow(prev); |
| 1168 | 1168 |
| 1169 if (prev->childrenInline() != next->childrenInline()) { | 1169 if (prev->childrenInline() != next->childrenInline()) { |
| 1170 LayoutBlock* inlineChildrenBlock = prev->childrenInline() ? prevBloc k : nextBlock; | 1170 LayoutBlock* inlineChildrenBlock = prev->childrenInline() ? prevBloc k : nextBlock; |
| 1171 LayoutBlock* blockChildrenBlock = prev->childrenInline() ? nextBlock : prevBlock; | 1171 LayoutBlock* blockChildrenBlock = prev->childrenInline() ? nextBlock : prevBlock; |
| 1172 | 1172 |
| 1173 // Place the inline children block inside of the block children bloc k instead of deleting it. | 1173 // Place the inline children block inside of the block children bloc k instead of deleting it. |
| 1174 // In order to reuse it, we have to reset it to just be a generic an onymous block. Make sure | 1174 // In order to reuse it, we have to reset it to just be a generic an onymous block. Make sure |
| 1175 // to clear out inherited column properties by just making a new sty le, and to also clear the | 1175 // to clear out inherited column properties by just making a new sty le, and to also clear the |
| 1176 // column span flag if it is set. | 1176 // column span flag if it is set. |
| 1177 ASSERT(!inlineChildrenBlock->continuation()); | 1177 ASSERT(!inlineChildrenBlock->continuation()); |
| 1178 RefPtr<LayoutStyle> newStyle = LayoutStyle::createAnonymousStyleWith Display(styleRef(), BLOCK); | 1178 RefPtr<LayoutStyle> newStyle = LayoutStyle::createAnonymousStyleWith Display(styleRef(), BLOCK); |
| 1179 // Cache this value as it might get changed in setStyle() call. | 1179 // Cache this value as it might get changed in setStyle() call. |
| 1180 bool inlineChildrenBlockHasLayer = inlineChildrenBlock->hasLayer(); | 1180 bool inlineChildrenBlockHasLayer = inlineChildrenBlock->hasLayer(); |
| 1181 inlineChildrenBlock->setStyle(newStyle); | 1181 inlineChildrenBlock->setStyle(newStyle); |
| 1182 children()->removeChildNode(this, inlineChildrenBlock, inlineChildre nBlockHasLayer); | 1182 children()->removeChildNode(this, inlineChildrenBlock, inlineChildre nBlockHasLayer); |
| 1183 | 1183 |
| 1184 // Now just put the inlineChildrenBlock inside the blockChildrenBloc k. | 1184 // Now just put the inlineChildrenBlock inside the blockChildrenBloc k. |
| 1185 blockChildrenBlock->children()->insertChildNode(blockChildrenBlock, inlineChildrenBlock, prev == inlineChildrenBlock ? blockChildrenBlock->firstChil d() : 0, | 1185 blockChildrenBlock->children()->insertChildNode(blockChildrenBlock, inlineChildrenBlock, prev == inlineChildrenBlock ? blockChildrenBlock->firstChil d() : 0, |
| 1186 inlineChildrenBlockHasLayer || blockChildrenBlock->hasLayer()); | 1186 inlineChildrenBlockHasLayer || blockChildrenBlock->hasLayer()); |
| 1187 next->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(); | 1187 next->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(Layo utInvalidationReason::AnonymousBlockChange); |
| 1188 | 1188 |
| 1189 // inlineChildrenBlock got reparented to blockChildrenBlock, so it i s no longer a child | 1189 // inlineChildrenBlock got reparented to blockChildrenBlock, so it i s no longer a child |
| 1190 // of "this". we null out prev or next so that is not used later in the function. | 1190 // of "this". we null out prev or next so that is not used later in the function. |
| 1191 if (inlineChildrenBlock == prevBlock) | 1191 if (inlineChildrenBlock == prevBlock) |
| 1192 prev = 0; | 1192 prev = 0; |
| 1193 else | 1193 else |
| 1194 next = 0; | 1194 next = 0; |
| 1195 } else { | 1195 } else { |
| 1196 // Take all the children out of the |next| block and put them in | 1196 // Take all the children out of the |next| block and put them in |
| 1197 // the |prev| block. | 1197 // the |prev| block. |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1723 if (isHorizontalWritingMode() == r->isHorizontalWritingMode()) | 1723 if (isHorizontalWritingMode() == r->isHorizontalWritingMode()) |
| 1724 r->updateLogicalHeight(); | 1724 r->updateLogicalHeight(); |
| 1725 else | 1725 else |
| 1726 r->updateLogicalWidth(); | 1726 r->updateLogicalWidth(); |
| 1727 oldLogicalTop = logicalTopForChild(*r); | 1727 oldLogicalTop = logicalTopForChild(*r); |
| 1728 } | 1728 } |
| 1729 | 1729 |
| 1730 // FIXME: We should be able to do a r->setNeedsPositionedMovementLayout( ) here instead of a full layout. Need | 1730 // FIXME: We should be able to do a r->setNeedsPositionedMovementLayout( ) here instead of a full layout. Need |
| 1731 // to investigate why it does not trigger the correct invalidations in t hat case. crbug.com/350756 | 1731 // to investigate why it does not trigger the correct invalidations in t hat case. crbug.com/350756 |
| 1732 if (info == ForcedLayoutAfterContainingBlockMoved) | 1732 if (info == ForcedLayoutAfterContainingBlockMoved) |
| 1733 r->setNeedsLayout(MarkOnlyThis); | 1733 r->setNeedsLayout(LayoutInvalidationReason::AncestorMoved, MarkOnlyT his); |
|
esprehn
2015/03/23 20:19:43
Just like with setNeedsStyleRecalc I'd prefer the
pdr.
2015/03/24 03:56:18
setNeedsLayout takes 2 optional arguments so if we
| |
| 1734 | 1734 |
| 1735 r->layoutIfNeeded(); | 1735 r->layoutIfNeeded(); |
| 1736 | 1736 |
| 1737 // Lay out again if our estimate was wrong. | 1737 // Lay out again if our estimate was wrong. |
| 1738 if (needsBlockDirectionLocationSetBeforeLayout && logicalTopForChild(*r) != oldLogicalTop) | 1738 if (needsBlockDirectionLocationSetBeforeLayout && logicalTopForChild(*r) != oldLogicalTop) |
| 1739 r->forceChildLayout(); | 1739 r->forceChildLayout(); |
| 1740 } | 1740 } |
| 1741 | 1741 |
| 1742 if (hasColumns()) | 1742 if (hasColumns()) |
| 1743 view()->layoutState()->setColumnInfo(columnInfo()); // FIXME: Kind of gr oss. We just put this back into the layout state so that pop() will work. | 1743 view()->layoutState()->setColumnInfo(columnInfo()); // FIXME: Kind of gr oss. We just put this back into the layout state so that pop() will work. |
| (...skipping 2178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3922 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout Object* obj) const | 3922 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout Object* obj) const |
| 3923 { | 3923 { |
| 3924 showLayoutObject(); | 3924 showLayoutObject(); |
| 3925 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) | 3925 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) |
| 3926 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); | 3926 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); |
| 3927 } | 3927 } |
| 3928 | 3928 |
| 3929 #endif | 3929 #endif |
| 3930 | 3930 |
| 3931 } // namespace blink | 3931 } // namespace blink |
| OLD | NEW |