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

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: 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 123
124 return NoPaintLayer; 124 return NoPaintLayer;
125 } 125 }
126 126
127 void LayoutBox::willBeDestroyed() 127 void LayoutBox::willBeDestroyed()
128 { 128 {
129 clearOverrideSize(); 129 clearOverrideSize();
130 clearContainingBlockOverrideSize(); 130 clearContainingBlockOverrideSize();
131 clearExtraInlineAndBlockOffests(); 131 clearExtraInlineAndBlockOffests();
132 132
133 LayoutBlock::removePercentHeightDescendantIfNeeded(this); 133 if (isOutOfFlowPositioned())
134 LayoutBlock::removePositionedObject(this);
135 removeFromPercentHeightContainer();
134 136
135 ShapeOutsideInfo::removeInfo(*this); 137 ShapeOutsideInfo::removeInfo(*this);
136 138
137 LayoutBoxModelObject::willBeDestroyed(); 139 LayoutBoxModelObject::willBeDestroyed();
138 } 140 }
139 141
140 void LayoutBox::removeFloatingOrPositionedChildFromBlockLists() 142 void LayoutBox::removeFloatingOrPositionedChildFromBlockLists()
141 { 143 {
142 ASSERT(isFloatingOrOutOfFlowPositioned()); 144 ASSERT(isFloatingOrOutOfFlowPositioned());
143 145
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 { 214 {
213 // Horizontal writing mode definition is updated in LayoutBoxModelObject::up dateFromStyle, 215 // Horizontal writing mode definition is updated in LayoutBoxModelObject::up dateFromStyle,
214 // (as part of the LayoutBoxModelObject::styleDidChange call below). So, we can safely cache the horizontal 216 // (as part of the LayoutBoxModelObject::styleDidChange call below). So, we can safely cache the horizontal
215 // writing mode value before style change here. 217 // writing mode value before style change here.
216 bool oldHorizontalWritingMode = isHorizontalWritingMode(); 218 bool oldHorizontalWritingMode = isHorizontalWritingMode();
217 219
218 LayoutBoxModelObject::styleDidChange(diff, oldStyle); 220 LayoutBoxModelObject::styleDidChange(diff, oldStyle);
219 221
220 const ComputedStyle& newStyle = styleRef(); 222 const ComputedStyle& newStyle = styleRef();
221 if (needsLayout() && oldStyle) 223 if (needsLayout() && oldStyle)
222 LayoutBlock::removePercentHeightDescendantIfNeeded(this); 224 removeFromPercentHeightContainer();
223 225
224 if (LayoutBlock::hasPercentHeightContainerMap() && slowFirstChild() 226 if (oldHorizontalWritingMode != isHorizontalWritingMode())
225 && oldHorizontalWritingMode != isHorizontalWritingMode()) 227 clearPercentHeightDescendants();
226 LayoutBlock::clearPercentHeightDescendantsFrom(this);
227 228
228 // If our zoom factor changes and we have a defined scrollLeft/Top, we need to adjust that value into the 229 // If our zoom factor changes and we have a defined scrollLeft/Top, we need to adjust that value into the
229 // new zoomed coordinate space. 230 // new zoomed coordinate space.
230 if (hasOverflowClip() && oldStyle && oldStyle->effectiveZoom() != newStyle.e ffectiveZoom() && layer()) { 231 if (hasOverflowClip() && oldStyle && oldStyle->effectiveZoom() != newStyle.e ffectiveZoom() && layer()) {
231 if (int left = layer()->scrollableArea()->scrollXOffset()) { 232 if (int left = layer()->scrollableArea()->scrollXOffset()) {
232 left = (left / oldStyle->effectiveZoom()) * newStyle.effectiveZoom() ; 233 left = (left / oldStyle->effectiveZoom()) * newStyle.effectiveZoom() ;
233 layer()->scrollableArea()->scrollToXOffset(left); 234 layer()->scrollableArea()->scrollToXOffset(left);
234 } 235 }
235 if (int top = layer()->scrollableArea()->scrollYOffset()) { 236 if (int top = layer()->scrollableArea()->scrollYOffset()) {
236 top = (top / oldStyle->effectiveZoom()) * newStyle.effectiveZoom(); 237 top = (top / oldStyle->effectiveZoom()) * newStyle.effectiveZoom();
(...skipping 4671 matching lines...) Expand 10 before | Expand all | Expand 10 after
4908 return ShapeOutsideInfo::isEnabledFor(*this) ? ShapeOutsideInfo::info(*this) : nullptr; 4909 return ShapeOutsideInfo::isEnabledFor(*this) ? ShapeOutsideInfo::info(*this) : nullptr;
4909 } 4910 }
4910 4911
4911 void LayoutBox::clearPreviousPaintInvalidationRects() 4912 void LayoutBox::clearPreviousPaintInvalidationRects()
4912 { 4913 {
4913 LayoutBoxModelObject::clearPreviousPaintInvalidationRects(); 4914 LayoutBoxModelObject::clearPreviousPaintInvalidationRects();
4914 if (PaintLayerScrollableArea* scrollableArea = this->scrollableArea()) 4915 if (PaintLayerScrollableArea* scrollableArea = this->scrollableArea())
4915 scrollableArea->clearPreviousPaintInvalidationRects(); 4916 scrollableArea->clearPreviousPaintInvalidationRects();
4916 } 4917 }
4917 4918
4919 void LayoutBox::setPercentHeightContainer(LayoutBlock* container)
4920 {
4921 ASSERT(!container || !percentHeightContainer());
4922 if (!container && !m_rareData)
4923 return;
4924 ensureRareData().m_percentHeightContainer = container;
4925 }
4926
4927 void LayoutBox::removeFromPercentHeightContainer()
4928 {
4929 if (!percentHeightContainer())
4930 return;
4931
4932 ASSERT(percentHeightContainer()->hasPercentHeightDescendant(this));
4933 percentHeightContainer()->removePercentHeightDescendant(this);
4934 // The above call should call this object's setPercentHeightContainer(nullpt r).
4935 ASSERT(!percentHeightContainer());
4936 }
4937
4938 void LayoutBox::clearPercentHeightDescendants()
4939 {
4940 for (LayoutObject* curr = slowFirstChild(); curr; curr = curr->nextInPreOrde r(this)) {
4941 if (curr->isBox())
4942 toLayoutBox(curr)->removeFromPercentHeightContainer();
4943 }
4944 }
4945
4918 } // namespace blink 4946 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698