Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1121)

Side by Side Diff: Source/core/layout/LayoutBlock.cpp

Issue 1025213002: Begin tracking why layout is invalidated (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/inspector/InspectorTraceEvents.cpp ('k') | Source/core/layout/LayoutBlockFlow.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 713
714 // We already know the newBlockBox isn't going to contain inline kids, so av oid wasting 714 // We already know the newBlockBox isn't going to contain inline kids, so av oid wasting
715 // time in makeChildrenNonInline by just setting this explicitly up front. 715 // time in makeChildrenNonInline by just setting this explicitly up front.
716 newBlockBox->setChildrenInline(false); 716 newBlockBox->setChildrenInline(false);
717 717
718 newBlockBox->addChild(newChild); 718 newBlockBox->addChild(newChild);
719 719
720 // Always just do a full layout in order to ensure that line boxes (especial ly wrappers for images) 720 // Always just do a full layout in order to ensure that line boxes (especial ly wrappers for images)
721 // get deleted properly. Because objects moves from the pre block into the post block, we want to 721 // get deleted properly. Because objects moves from the pre block into the post block, we want to
722 // make new line boxes instead of leaving the old line boxes around. 722 // make new line boxes instead of leaving the old line boxes around.
723 pre->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(); 723 pre->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(LayoutInvalid ationReason::ColumnsChanged);
724 block->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(); 724 block->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(LayoutInval idationReason::ColumnsChanged);
725 post->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(); 725 post->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(LayoutInvali dationReason::ColumnsChanged);
726 } 726 }
727 727
728 void LayoutBlock::makeChildrenAnonymousColumnBlocks(LayoutObject* beforeChild, L ayoutBlockFlow* newBlockBox, LayoutObject* newChild) 728 void LayoutBlock::makeChildrenAnonymousColumnBlocks(LayoutObject* beforeChild, L ayoutBlockFlow* newBlockBox, LayoutObject* newChild)
729 { 729 {
730 LayoutBlockFlow* pre = 0; 730 LayoutBlockFlow* pre = 0;
731 LayoutBlockFlow* post = 0; 731 LayoutBlockFlow* post = 0;
732 LayoutBlock* block = this; // Eventually block will not just be |this|, but will also be a block nested inside |this|. Assign to a variable 732 LayoutBlock* block = this; // Eventually block will not just be |this|, but will also be a block nested inside |this|. Assign to a variable
733 // so that we don't have to patch all of the rest of the code later on. 733 // so that we don't have to patch all of the rest of the code later on.
734 734
735 // Delete the block's line boxes before we do the split. 735 // Delete the block's line boxes before we do the split.
(...skipping 27 matching lines...) Expand all
763 // We already know the newBlockBox isn't going to contain inline kids, so av oid wasting 763 // We already know the newBlockBox isn't going to contain inline kids, so av oid wasting
764 // time in makeChildrenNonInline by just setting this explicitly up front. 764 // time in makeChildrenNonInline by just setting this explicitly up front.
765 newBlockBox->setChildrenInline(false); 765 newBlockBox->setChildrenInline(false);
766 766
767 newBlockBox->addChild(newChild); 767 newBlockBox->addChild(newChild);
768 768
769 // Always just do a full layout in order to ensure that line boxes (especial ly wrappers for images) 769 // Always just do a full layout in order to ensure that line boxes (especial ly wrappers for images)
770 // get deleted properly. Because objects moved from the pre block into the post block, we want to 770 // get deleted properly. Because objects moved from the pre block into the post block, we want to
771 // make new line boxes instead of leaving the old line boxes around. 771 // make new line boxes instead of leaving the old line boxes around.
772 if (pre) 772 if (pre)
773 pre->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(); 773 pre->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(LayoutInv alidationReason::ColumnsChanged);
774 block->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(); 774 block->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(LayoutInval idationReason::ColumnsChanged);
775 if (post) 775 if (post)
776 post->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(); 776 post->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(LayoutIn validationReason::ColumnsChanged);
777 } 777 }
778 778
779 LayoutBlockFlow* LayoutBlock::columnsBlockForSpanningElement(LayoutObject* newCh ild) 779 LayoutBlockFlow* LayoutBlock::columnsBlockForSpanningElement(LayoutObject* newCh ild)
780 { 780 {
781 // FIXME: This function is the gateway for the addition of column-span suppo rt. It will 781 // FIXME: This function is the gateway for the addition of column-span suppo rt. It will
782 // be added to in three stages: 782 // be added to in three stages:
783 // (1) Immediate children of a multi-column block can span. 783 // (1) Immediate children of a multi-column block can span.
784 // (2) Nested block-level children with only block-level ancestors between t hem and the multi-column block can span. 784 // (2) Nested block-level children with only block-level ancestors between t hem and the multi-column block can span.
785 // (3) Nested children with block or inline ancestors between them and the m ulti-column block can span (this is when we 785 // (3) Nested children with block or inline ancestors between them and the m ulti-column block can span (this is when we
786 // cross the streams and have to cope with both types of continuations mixed together). 786 // 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
1117 collapseAnonymousBlockChild(this, toLayoutBlock(blocksToRemove[i])); 1117 collapseAnonymousBlockChild(this, toLayoutBlock(blocksToRemove[i]));
1118 } 1118 }
1119 1119
1120 void LayoutBlock::collapseAnonymousBlockChild(LayoutBlock* parent, LayoutBlock* child) 1120 void LayoutBlock::collapseAnonymousBlockChild(LayoutBlock* parent, LayoutBlock* child)
1121 { 1121 {
1122 // It's possible that this block's destruction may have been triggered by th e 1122 // It's possible that this block's destruction may have been triggered by th e
1123 // child's removal. Just bail if the anonymous child block is already being 1123 // child's removal. Just bail if the anonymous child block is already being
1124 // destroyed. See crbug.com/282088 1124 // destroyed. See crbug.com/282088
1125 if (child->beingDestroyed()) 1125 if (child->beingDestroyed())
1126 return; 1126 return;
1127 parent->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(); 1127 parent->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(LayoutInva lidationReason::ChildAnonymousBlockChanged);
1128 parent->setChildrenInline(child->childrenInline()); 1128 parent->setChildrenInline(child->childrenInline());
1129 LayoutObject* nextSibling = child->nextSibling(); 1129 LayoutObject* nextSibling = child->nextSibling();
1130 1130
1131 parent->children()->removeChildNode(parent, child, child->hasLayer()); 1131 parent->children()->removeChildNode(parent, child, child->hasLayer());
1132 // FIXME: Get rid of the temporary disabling of continuations. This is neede d by the old 1132 // FIXME: Get rid of the temporary disabling of continuations. This is neede d by the old
1133 // multicol implementation, because of buggy block continuation handling (wh ich is hard and 1133 // multicol implementation, because of buggy block continuation handling (wh ich is hard and
1134 // rather pointless to fix at this point). Support for block continuations c an be removed 1134 // rather pointless to fix at this point). Support for block continuations c an be removed
1135 // together with the old multicol implementation. crbug.com/408123 1135 // together with the old multicol implementation. crbug.com/408123
1136 LayoutBoxModelObject* temporarilyInactiveContinuation = parent->continuation (); 1136 LayoutBoxModelObject* temporarilyInactiveContinuation = parent->continuation ();
1137 if (temporarilyInactiveContinuation) 1137 if (temporarilyInactiveContinuation)
(...skipping 19 matching lines...) Expand all
1157 // This protects against column split flows when anonymous blocks are gettin g merged. 1157 // This protects against column split flows when anonymous blocks are gettin g merged.
1158 TemporaryChange<bool> columnFlowSplitEnabled(gColumnFlowSplitEnabled, false) ; 1158 TemporaryChange<bool> columnFlowSplitEnabled(gColumnFlowSplitEnabled, false) ;
1159 1159
1160 // If this child is a block, and if our previous and next siblings are 1160 // If this child is a block, and if our previous and next siblings are
1161 // both anonymous blocks with inline content, then we can go ahead and 1161 // both anonymous blocks with inline content, then we can go ahead and
1162 // fold the inline content back together. 1162 // fold the inline content back together.
1163 LayoutObject* prev = oldChild->previousSibling(); 1163 LayoutObject* prev = oldChild->previousSibling();
1164 LayoutObject* next = oldChild->nextSibling(); 1164 LayoutObject* next = oldChild->nextSibling();
1165 bool canMergeAnonymousBlocks = canMergeContiguousAnonymousBlocks(oldChild, p rev, next); 1165 bool canMergeAnonymousBlocks = canMergeContiguousAnonymousBlocks(oldChild, p rev, next);
1166 if (canMergeAnonymousBlocks && prev && next) { 1166 if (canMergeAnonymousBlocks && prev && next) {
1167 prev->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(); 1167 prev->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(LayoutIn validationReason::AnonymousBlockChange);
1168 LayoutBlockFlow* nextBlock = toLayoutBlockFlow(next); 1168 LayoutBlockFlow* nextBlock = toLayoutBlockFlow(next);
1169 LayoutBlockFlow* prevBlock = toLayoutBlockFlow(prev); 1169 LayoutBlockFlow* prevBlock = toLayoutBlockFlow(prev);
1170 1170
1171 if (prev->childrenInline() != next->childrenInline()) { 1171 if (prev->childrenInline() != next->childrenInline()) {
1172 LayoutBlock* inlineChildrenBlock = prev->childrenInline() ? prevBloc k : nextBlock; 1172 LayoutBlock* inlineChildrenBlock = prev->childrenInline() ? prevBloc k : nextBlock;
1173 LayoutBlock* blockChildrenBlock = prev->childrenInline() ? nextBlock : prevBlock; 1173 LayoutBlock* blockChildrenBlock = prev->childrenInline() ? nextBlock : prevBlock;
1174 1174
1175 // Place the inline children block inside of the block children bloc k instead of deleting it. 1175 // Place the inline children block inside of the block children bloc k instead of deleting it.
1176 // In order to reuse it, we have to reset it to just be a generic an onymous block. Make sure 1176 // In order to reuse it, we have to reset it to just be a generic an onymous block. Make sure
1177 // to clear out inherited column properties by just making a new sty le, and to also clear the 1177 // to clear out inherited column properties by just making a new sty le, and to also clear the
1178 // column span flag if it is set. 1178 // column span flag if it is set.
1179 ASSERT(!inlineChildrenBlock->continuation()); 1179 ASSERT(!inlineChildrenBlock->continuation());
1180 RefPtr<ComputedStyle> newStyle = ComputedStyle::createAnonymousStyle WithDisplay(styleRef(), BLOCK); 1180 RefPtr<ComputedStyle> newStyle = ComputedStyle::createAnonymousStyle WithDisplay(styleRef(), BLOCK);
1181 // Cache this value as it might get changed in setStyle() call. 1181 // Cache this value as it might get changed in setStyle() call.
1182 bool inlineChildrenBlockHasLayer = inlineChildrenBlock->hasLayer(); 1182 bool inlineChildrenBlockHasLayer = inlineChildrenBlock->hasLayer();
1183 inlineChildrenBlock->setStyle(newStyle); 1183 inlineChildrenBlock->setStyle(newStyle);
1184 children()->removeChildNode(this, inlineChildrenBlock, inlineChildre nBlockHasLayer); 1184 children()->removeChildNode(this, inlineChildrenBlock, inlineChildre nBlockHasLayer);
1185 1185
1186 // Now just put the inlineChildrenBlock inside the blockChildrenBloc k. 1186 // Now just put the inlineChildrenBlock inside the blockChildrenBloc k.
1187 blockChildrenBlock->children()->insertChildNode(blockChildrenBlock, inlineChildrenBlock, prev == inlineChildrenBlock ? blockChildrenBlock->firstChil d() : 0, 1187 blockChildrenBlock->children()->insertChildNode(blockChildrenBlock, inlineChildrenBlock, prev == inlineChildrenBlock ? blockChildrenBlock->firstChil d() : 0,
1188 inlineChildrenBlockHasLayer || blockChildrenBlock->hasLayer()); 1188 inlineChildrenBlockHasLayer || blockChildrenBlock->hasLayer());
1189 next->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(); 1189 next->setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation(Layo utInvalidationReason::AnonymousBlockChange);
1190 1190
1191 // inlineChildrenBlock got reparented to blockChildrenBlock, so it i s no longer a child 1191 // inlineChildrenBlock got reparented to blockChildrenBlock, so it i s no longer a child
1192 // of "this". we null out prev or next so that is not used later in the function. 1192 // of "this". we null out prev or next so that is not used later in the function.
1193 if (inlineChildrenBlock == prevBlock) 1193 if (inlineChildrenBlock == prevBlock)
1194 prev = 0; 1194 prev = 0;
1195 else 1195 else
1196 next = 0; 1196 next = 0;
1197 } else { 1197 } else {
1198 // Take all the children out of the |next| block and put them in 1198 // Take all the children out of the |next| block and put them in
1199 // the |prev| block. 1199 // the |prev| block.
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
1731 if (isHorizontalWritingMode() == r->isHorizontalWritingMode()) 1731 if (isHorizontalWritingMode() == r->isHorizontalWritingMode())
1732 r->updateLogicalHeight(); 1732 r->updateLogicalHeight();
1733 else 1733 else
1734 r->updateLogicalWidth(); 1734 r->updateLogicalWidth();
1735 oldLogicalTop = logicalTopForChild(*r); 1735 oldLogicalTop = logicalTopForChild(*r);
1736 } 1736 }
1737 1737
1738 // FIXME: We should be able to do a r->setNeedsPositionedMovementLayout( ) here instead of a full layout. Need 1738 // FIXME: We should be able to do a r->setNeedsPositionedMovementLayout( ) here instead of a full layout. Need
1739 // to investigate why it does not trigger the correct invalidations in t hat case. crbug.com/350756 1739 // to investigate why it does not trigger the correct invalidations in t hat case. crbug.com/350756
1740 if (info == ForcedLayoutAfterContainingBlockMoved) 1740 if (info == ForcedLayoutAfterContainingBlockMoved)
1741 r->setNeedsLayout(MarkOnlyThis); 1741 r->setNeedsLayout(LayoutInvalidationReason::AncestorMoved, MarkOnlyT his);
1742 1742
1743 r->layoutIfNeeded(); 1743 r->layoutIfNeeded();
1744 1744
1745 // Lay out again if our estimate was wrong. 1745 // Lay out again if our estimate was wrong.
1746 if (needsBlockDirectionLocationSetBeforeLayout && logicalTopForChild(*r) != oldLogicalTop) 1746 if (needsBlockDirectionLocationSetBeforeLayout && logicalTopForChild(*r) != oldLogicalTop)
1747 r->forceChildLayout(); 1747 r->forceChildLayout();
1748 } 1748 }
1749 1749
1750 if (hasColumns()) 1750 if (hasColumns())
1751 view()->layoutState()->setColumnInfo(columnInfo()); // FIXME: Kind of gr oss. We just put this back into the layout state so that pop() will work. 1751 view()->layoutState()->setColumnInfo(columnInfo()); // FIXME: Kind of gr oss. We just put this back into the layout state so that pop() will work.
(...skipping 2192 matching lines...) Expand 10 before | Expand all | Expand 10 after
3944 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout Object* obj) const 3944 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout Object* obj) const
3945 { 3945 {
3946 showLayoutObject(); 3946 showLayoutObject();
3947 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) 3947 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box())
3948 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); 3948 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1);
3949 } 3949 }
3950 3950
3951 #endif 3951 #endif
3952 3952
3953 } // namespace blink 3953 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorTraceEvents.cpp ('k') | Source/core/layout/LayoutBlockFlow.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698