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

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

Issue 1930183002: Refactor scroll updates during flexbox layout. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@rtl-scroll-origin
Patch Set: nits Created 4 years, 6 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) 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 // the middle of recomputing the style so we can't rely on any of its 76 // the middle of recomputing the style so we can't rely on any of its
77 // information), which is why it's easier to just update it for every layout. 77 // information), which is why it's easier to just update it for every layout.
78 static TrackedDescendantsMap* gPositionedDescendantsMap = nullptr; 78 static TrackedDescendantsMap* gPositionedDescendantsMap = nullptr;
79 static TrackedContainerMap* gPositionedContainerMap = nullptr; 79 static TrackedContainerMap* gPositionedContainerMap = nullptr;
80 80
81 // This map keeps track of the descendants whose 'height' is percentage associat ed 81 // This map keeps track of the descendants whose 'height' is percentage associat ed
82 // with a containing block. Like |gPositionedDescendantsMap|, it is also recompu ted 82 // with a containing block. Like |gPositionedDescendantsMap|, it is also recompu ted
83 // for every layout (see the comment above about why). 83 // for every layout (see the comment above about why).
84 static TrackedDescendantsMap* gPercentHeightDescendantsMap = nullptr; 84 static TrackedDescendantsMap* gPercentHeightDescendantsMap = nullptr;
85 85
86 typedef WTF::HashSet<LayoutBlock*> DelayedUpdateScrollInfoSet;
87 static int gDelayUpdateScrollInfo = 0;
88 static DelayedUpdateScrollInfoSet* gDelayedUpdateScrollInfoSet = nullptr;
89
90 LayoutBlock::LayoutBlock(ContainerNode* node) 86 LayoutBlock::LayoutBlock(ContainerNode* node)
91 : LayoutBox(node) 87 : LayoutBox(node)
92 , m_hasMarginBeforeQuirk(false) 88 , m_hasMarginBeforeQuirk(false)
93 , m_hasMarginAfterQuirk(false) 89 , m_hasMarginAfterQuirk(false)
94 , m_beingDestroyed(false) 90 , m_beingDestroyed(false)
95 , m_hasMarkupTruncation(false) 91 , m_hasMarkupTruncation(false)
96 , m_widthAvailableToChildrenChanged(false) 92 , m_widthAvailableToChildrenChanged(false)
97 , m_heightAvailableToChildrenChanged(false) 93 , m_heightAvailableToChildrenChanged(false)
98 , m_isSelfCollapsing(false) 94 , m_isSelfCollapsing(false)
99 , m_descendantsWithFloatsMarkedForLayout(false) 95 , m_descendantsWithFloatsMarkedForLayout(false)
(...skipping 27 matching lines...) Expand all
127 LayoutBlock::~LayoutBlock() 123 LayoutBlock::~LayoutBlock()
128 { 124 {
129 removeFromGlobalMaps(); 125 removeFromGlobalMaps();
130 } 126 }
131 127
132 void LayoutBlock::willBeDestroyed() 128 void LayoutBlock::willBeDestroyed()
133 { 129 {
134 if (!documentBeingDestroyed() && parent()) 130 if (!documentBeingDestroyed() && parent())
135 parent()->dirtyLinesFromChangedChild(this); 131 parent()->dirtyLinesFromChangedChild(this);
136 132
137 if (UNLIKELY(gDelayedUpdateScrollInfoSet != 0))
138 gDelayedUpdateScrollInfoSet->remove(this);
139
140 if (TextAutosizer* textAutosizer = document().textAutosizer()) 133 if (TextAutosizer* textAutosizer = document().textAutosizer())
141 textAutosizer->destroy(this); 134 textAutosizer->destroy(this);
142 135
143 LayoutBox::willBeDestroyed(); 136 LayoutBox::willBeDestroyed();
144 } 137 }
145 138
146 void LayoutBlock::styleWillChange(StyleDifference diff, const ComputedStyle& new Style) 139 void LayoutBlock::styleWillChange(StyleDifference diff, const ComputedStyle& new Style)
147 { 140 {
148 const ComputedStyle* oldStyle = style(); 141 const ComputedStyle* oldStyle = style();
149 142
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 if (child->parent()->isLayoutGrid()) 329 if (child->parent()->isLayoutGrid())
337 toLayoutGrid(child->parent())->dirtyGrid(); 330 toLayoutGrid(child->parent())->dirtyGrid();
338 331
339 // Now remove the leftover anonymous block from the tree, and destroy it. We 'll rip it out 332 // Now remove the leftover anonymous block from the tree, and destroy it. We 'll rip it out
340 // manually from the tree before destroying it, because we don't want to tri gger any tree 333 // manually from the tree before destroying it, because we don't want to tri gger any tree
341 // adjustments with regards to anonymous blocks (or any other kind of undesi red chain-reaction). 334 // adjustments with regards to anonymous blocks (or any other kind of undesi red chain-reaction).
342 children()->removeChildNode(this, child, false); 335 children()->removeChildNode(this, child, false);
343 child->destroy(); 336 child->destroy();
344 } 337 }
345 338
346 void LayoutBlock::startDelayUpdateScrollInfo()
347 {
348 if (gDelayUpdateScrollInfo == 0) {
349 ASSERT(!gDelayedUpdateScrollInfoSet);
350 gDelayedUpdateScrollInfoSet = new DelayedUpdateScrollInfoSet;
351 }
352 ASSERT(gDelayedUpdateScrollInfoSet);
353 ++gDelayUpdateScrollInfo;
354 }
355
356 bool LayoutBlock::finishDelayUpdateScrollInfo(SubtreeLayoutScope* layoutScope, S crollPositionMap* scrollMap)
357 {
358 bool childrenMarkedForRelayout = false;
359
360 --gDelayUpdateScrollInfo;
361 ASSERT(gDelayUpdateScrollInfo >= 0);
362 if (gDelayUpdateScrollInfo == 0) {
363 ASSERT(gDelayedUpdateScrollInfoSet);
364
365 OwnPtr<DelayedUpdateScrollInfoSet> infoSet(adoptPtr(gDelayedUpdateScroll InfoSet));
366 gDelayedUpdateScrollInfoSet = nullptr;
367
368 for (auto* block : *infoSet) {
369 if (block->hasOverflowClip()) {
370 PaintLayerScrollableArea* scrollableArea = block->layer()->getSc rollableArea();
371 if (scrollMap)
372 scrollMap->add(scrollableArea, scrollableArea->scrollPositio nDouble());
373 childrenMarkedForRelayout |= scrollableArea->updateAfterLayout(l ayoutScope);
374 }
375 }
376 }
377 return childrenMarkedForRelayout;
378 }
379
380 void LayoutBlock::updateAfterLayout() 339 void LayoutBlock::updateAfterLayout()
381 { 340 {
382 invalidateStickyConstraints(); 341 invalidateStickyConstraints();
383 342
384 // Update our scroll information if we're overflow:auto/scroll/hidden now th at we know if 343 // Update our scroll information if we're overflow:auto/scroll/hidden now th at we know if
385 // we overflow or not. 344 // we overflow or not.
386 if (hasOverflowClip()) { 345 if (hasOverflowClip())
387 if (style()->isFlippedBlocksWritingMode()) { 346 layer()->getScrollableArea()->updateAfterLayout();
388 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=97937
389 // Workaround for now. We cannot delay the scroll info for overflow
390 // for items with opposite writing directions, as the contents needs
391 // to overflow in that direction
392 layer()->getScrollableArea()->updateAfterLayout();
393 return;
394 }
395
396 if (gDelayUpdateScrollInfo)
397 gDelayedUpdateScrollInfoSet->add(this);
398 else
399 layer()->getScrollableArea()->updateAfterLayout();
400 }
401 } 347 }
402 348
403 void LayoutBlock::layout() 349 void LayoutBlock::layout()
404 { 350 {
405 LayoutAnalyzer::Scope analyzer(*this); 351 LayoutAnalyzer::Scope analyzer(*this);
406 352
407 bool needsScrollAnchoring = RuntimeEnabledFeatures::scrollAnchoringEnabled() && hasOverflowClip(); 353 bool needsScrollAnchoring = RuntimeEnabledFeatures::scrollAnchoringEnabled() && hasOverflowClip();
408 if (needsScrollAnchoring) 354 if (needsScrollAnchoring)
409 getScrollableArea()->scrollAnchor().save(); 355 getScrollableArea()->scrollAnchor().save();
410 356
(...skipping 1484 matching lines...) Expand 10 before | Expand all | Expand 10 after
1895 for (TrackedLayoutBoxListHashSet::const_iterator it = positionedDescenda ntSet->begin(); it != end; ++it) { 1841 for (TrackedLayoutBoxListHashSet::const_iterator it = positionedDescenda ntSet->begin(); it != end; ++it) {
1896 LayoutBox* currBox = *it; 1842 LayoutBox* currBox = *it;
1897 ASSERT(!currBox->needsLayout()); 1843 ASSERT(!currBox->needsLayout());
1898 } 1844 }
1899 } 1845 }
1900 } 1846 }
1901 1847
1902 #endif 1848 #endif
1903 1849
1904 } // namespace blink 1850 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698