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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutBox.cpp

Issue 1544423002: Improve positioned/percentHeight descendant/container tracking (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: virtual destructor Created 4 years, 11 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
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) 2005 Allan Sandfeld Jensen (kde@carewolf.com) 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com)
6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed. 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed.
7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 7 * Copyright (C) 2013 Adobe Systems Incorporated. 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 112
113 return NoPaintLayer; 113 return NoPaintLayer;
114 } 114 }
115 115
116 void LayoutBox::willBeDestroyed() 116 void LayoutBox::willBeDestroyed()
117 { 117 {
118 clearOverrideSize(); 118 clearOverrideSize();
119 clearContainingBlockOverrideSize(); 119 clearContainingBlockOverrideSize();
120 clearExtraInlineAndBlockOffests(); 120 clearExtraInlineAndBlockOffests();
121 121
122 LayoutBlock::removePercentHeightDescendantIfNeeded(this); 122 removeFromPositionedContainer();
123 removeFromPercentHeightContainer();
123 124
124 ShapeOutsideInfo::removeInfo(*this); 125 ShapeOutsideInfo::removeInfo(*this);
125 126
126 LayoutBoxModelObject::willBeDestroyed(); 127 LayoutBoxModelObject::willBeDestroyed();
127 } 128 }
128 129
129 void LayoutBox::removeFloatingOrPositionedChildFromBlockLists() 130 void LayoutBox::removeFloatingOrPositionedChildFromBlockLists()
130 { 131 {
131 ASSERT(isFloatingOrOutOfFlowPositioned()); 132 ASSERT(isFloatingOrOutOfFlowPositioned());
132 133
(...skipping 10 matching lines...) Expand all
143 } 144 }
144 } 145 }
145 146
146 if (parentBlockFlow) { 147 if (parentBlockFlow) {
147 parentBlockFlow->markSiblingsWithFloatsForLayout(this); 148 parentBlockFlow->markSiblingsWithFloatsForLayout(this);
148 parentBlockFlow->markAllDescendantsWithFloatsForLayout(this, false); 149 parentBlockFlow->markAllDescendantsWithFloatsForLayout(this, false);
149 } 150 }
150 } 151 }
151 152
152 if (isOutOfFlowPositioned()) 153 if (isOutOfFlowPositioned())
153 LayoutBlock::removePositionedObject(this); 154 removeFromPositionedContainer();
154 } 155 }
155 156
156 void LayoutBox::styleWillChange(StyleDifference diff, const ComputedStyle& newSt yle) 157 void LayoutBox::styleWillChange(StyleDifference diff, const ComputedStyle& newSt yle)
157 { 158 {
158 const ComputedStyle* oldStyle = style(); 159 const ComputedStyle* oldStyle = style();
159 if (oldStyle) { 160 if (oldStyle) {
160 LayoutFlowThread* flowThread = flowThreadContainingBlock(); 161 LayoutFlowThread* flowThread = flowThreadContainingBlock();
161 if (flowThread && flowThread != this) 162 if (flowThread && flowThread != this)
162 flowThread->flowThreadDescendantStyleWillChange(this, diff, newStyle ); 163 flowThread->flowThreadDescendantStyleWillChange(this, diff, newStyle );
163 164
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 { 202 {
202 // Horizontal writing mode definition is updated in LayoutBoxModelObject::up dateFromStyle, 203 // Horizontal writing mode definition is updated in LayoutBoxModelObject::up dateFromStyle,
203 // (as part of the LayoutBoxModelObject::styleDidChange call below). So, we can safely cache the horizontal 204 // (as part of the LayoutBoxModelObject::styleDidChange call below). So, we can safely cache the horizontal
204 // writing mode value before style change here. 205 // writing mode value before style change here.
205 bool oldHorizontalWritingMode = isHorizontalWritingMode(); 206 bool oldHorizontalWritingMode = isHorizontalWritingMode();
206 207
207 LayoutBoxModelObject::styleDidChange(diff, oldStyle); 208 LayoutBoxModelObject::styleDidChange(diff, oldStyle);
208 209
209 const ComputedStyle& newStyle = styleRef(); 210 const ComputedStyle& newStyle = styleRef();
210 if (needsLayout() && oldStyle) 211 if (needsLayout() && oldStyle)
211 LayoutBlock::removePercentHeightDescendantIfNeeded(this); 212 removeFromPercentHeightContainer();
212 213
213 if (LayoutBlock::hasPercentHeightContainerMap() && slowFirstChild() 214 if (oldHorizontalWritingMode != isHorizontalWritingMode())
214 && oldHorizontalWritingMode != isHorizontalWritingMode()) 215 clearPercentHeightDescendants();
215 LayoutBlock::clearPercentHeightDescendantsFrom(this);
216 216
217 // If our zoom factor changes and we have a defined scrollLeft/Top, we need to adjust that value into the 217 // If our zoom factor changes and we have a defined scrollLeft/Top, we need to adjust that value into the
218 // new zoomed coordinate space. 218 // new zoomed coordinate space.
219 if (hasOverflowClip() && oldStyle && oldStyle->effectiveZoom() != newStyle.e ffectiveZoom() && layer()) { 219 if (hasOverflowClip() && oldStyle && oldStyle->effectiveZoom() != newStyle.e ffectiveZoom() && layer()) {
220 if (int left = layer()->scrollableArea()->scrollXOffset()) { 220 if (int left = layer()->scrollableArea()->scrollXOffset()) {
221 left = (left / oldStyle->effectiveZoom()) * newStyle.effectiveZoom() ; 221 left = (left / oldStyle->effectiveZoom()) * newStyle.effectiveZoom() ;
222 layer()->scrollableArea()->scrollToXOffset(left); 222 layer()->scrollableArea()->scrollToXOffset(left);
223 } 223 }
224 if (int top = layer()->scrollableArea()->scrollYOffset()) { 224 if (int top = layer()->scrollableArea()->scrollYOffset()) {
225 top = (top / oldStyle->effectiveZoom()) * newStyle.effectiveZoom(); 225 top = (top / oldStyle->effectiveZoom()) * newStyle.effectiveZoom();
(...skipping 4662 matching lines...) Expand 10 before | Expand all | Expand 10 after
4888 return ShapeOutsideInfo::isEnabledFor(*this) ? ShapeOutsideInfo::info(*this) : nullptr; 4888 return ShapeOutsideInfo::isEnabledFor(*this) ? ShapeOutsideInfo::info(*this) : nullptr;
4889 } 4889 }
4890 4890
4891 void LayoutBox::clearPreviousPaintInvalidationRects() 4891 void LayoutBox::clearPreviousPaintInvalidationRects()
4892 { 4892 {
4893 LayoutBoxModelObject::clearPreviousPaintInvalidationRects(); 4893 LayoutBoxModelObject::clearPreviousPaintInvalidationRects();
4894 if (PaintLayerScrollableArea* scrollableArea = this->scrollableArea()) 4894 if (PaintLayerScrollableArea* scrollableArea = this->scrollableArea())
4895 scrollableArea->clearPreviousPaintInvalidationRects(); 4895 scrollableArea->clearPreviousPaintInvalidationRects();
4896 } 4896 }
4897 4897
4898 void LayoutBox::setPositionedContainer(LayoutBlock* container)
4899 {
4900 ASSERT(!container || !positionedContainer());
4901 if (!container && !m_rareData)
4902 return;
4903 ensureRareData().m_positionedContainer = container;
4904 }
4905
4906 void LayoutBox::removeFromPositionedContainer()
4907 {
4908 if (!positionedContainer())
4909 return;
4910
4911 ASSERT(positionedContainer()->positionedObjects()->contains(this));
4912 positionedContainer()->removePositionedObject(this);
4913 // The above call should call this object's setPositionedContainer(nullptr).
4914 ASSERT(!positionedContainer());
4915 }
4916
4917 void LayoutBox::setPercentHeightContainer(LayoutBlock* container)
4918 {
4919 ASSERT(!container || !percentHeightContainer());
4920 if (!container && !m_rareData)
4921 return;
4922 ensureRareData().m_percentHeightContainer = container;
4923 }
4924
4925 void LayoutBox::removeFromPercentHeightContainer()
4926 {
4927 if (!percentHeightContainer())
4928 return;
4929
4930 ASSERT(percentHeightContainer()->hasPercentHeightDescendant(this));
4931 percentHeightContainer()->removePercentHeightDescendant(this);
4932 // The above call should call this object's setPercentHeightContainer(nullpt r).
4933 ASSERT(!percentHeightContainer());
4934 }
4935
4936 void LayoutBox::clearPercentHeightDescendants()
4937 {
4938 for (LayoutObject* curr = slowFirstChild(); curr; curr = curr->nextInPreOrde r(this)) {
4939 if (curr->isBox())
4940 toLayoutBox(curr)->removeFromPercentHeightContainer();
4941 }
4942 }
4943
4898 } // namespace blink 4944 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698