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

Unified Diff: third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.h

Issue 1930183002: Refactor scroll updates during flexbox layout. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@rtl-scroll-origin
Patch Set: Fix layout invalidation reason Created 4 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.h
diff --git a/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.h b/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.h
index 01cd11701d8f5fe931d6d1ac336278f87b19f0c8..bc789fb0a033f916d595ee808b6287f9fe4fe905 100644
--- a/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.h
+++ b/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.h
@@ -132,20 +132,18 @@ private:
void dispose();
- // When canDetachScrollbars is true, calls to setHas*Scrollbar(false) will NOT destroy
- // an existing scrollbar, but instead detach it without destroying it. If, subsequently,
- // setHas*Scrollbar(true) is called, the existing scrollbar will be reattached. When
- // setCanDetachScrollbars(false) is called, any detached scrollbars will be destructed.
- bool canDetachScrollbars() const { return m_canDetachScrollbars; }
- void setCanDetachScrollbars(bool);
-
Scrollbar* horizontalScrollbar() const { return m_hBarIsAttached ? m_hBar.get(): nullptr; }
Scrollbar* verticalScrollbar() const { return m_vBarIsAttached ? m_vBar.get() : nullptr; }
bool hasHorizontalScrollbar() const { return horizontalScrollbar(); }
bool hasVerticalScrollbar() const { return verticalScrollbar(); }
- void setHasHorizontalScrollbar(bool hasScrollbar);
- void setHasVerticalScrollbar(bool hasScrollbar);
+ // setHas*Scrollbar(false, true) will NOT destroy an existing scrollbar, but instead
+ // detach it without destroying it. If, subsequently, setHas*Scrollbar(true, [true|false])
+ // is called, the existing scrollbar will be reattached. When destroyDetachedScrollbars
+ // is called, any detached scrollbars will be immediately destroyed.
+ void setHasHorizontalScrollbar(bool hasScrollbar, bool canDetach = false);
+ void setHasVerticalScrollbar(bool hasScrollbar, bool canDetach = false);
+ void destroyDetachedScrollbars();
DECLARE_TRACE();
@@ -160,12 +158,68 @@ private:
Member<Scrollbar> m_hBar;
Member<Scrollbar> m_vBar;
- unsigned m_canDetachScrollbars: 1;
unsigned m_hBarIsAttached: 1;
unsigned m_vBarIsAttached: 1;
};
public:
+
+ // If a PreventRelayoutScope object is alive, updateAfterLayout() will not
+ // re-run box layout as a result of adding or removing scrollbars.
+ class PreventRelayoutScope {
+ public:
+ PreventRelayoutScope(SubtreeLayoutScope&);
+ ~PreventRelayoutScope();
+
+ static bool relayoutIsPrevented() { return m_count; }
+ static void setNeedsLayout(LayoutObject&);
+ static bool relayoutNeeded() { return m_count == 0 && m_relayoutNeeded; }
+ static void resetRelayoutNeeded();
+
+ private:
+ static void increment();
+ static void decrement();
+
+ static int m_count;
+ static SubtreeLayoutScope* m_layoutScope;
+ static bool m_relayoutNeeded;
+ static WTF::Vector<LayoutObject*>* m_needsRelayout;
+ };
+
+ // If a FreezeScrollbarScope object is alive, updateAfterLayout() will not
+ // recompute the existence of overflow:auto scrollbars.
+ class FreezeScrollbarsScope {
+ public:
+ FreezeScrollbarsScope() { m_count++; }
+ ~FreezeScrollbarsScope() { m_count--; }
+
+ static bool scrollbarsAreFrozen() { return m_count; }
+
+ private:
+ static int m_count;
+ };
+
+ // If a DelayScrollPositionClampScope object is alive, updateAfterLayout() will not
+ // clamp scroll positions to ensure they are in the valid range. When
+ // the last DelayScrollPositionClampScope object is destructed, all PaintLayerScrollableArea's
+ // that delayed clamping their positions will immediately clamp them.
+ class DelayScrollPositionClampScope {
+ public:
+ DelayScrollPositionClampScope();
+ ~DelayScrollPositionClampScope();
+
+ static bool clampingIsDelayed() { return m_count; }
+ static void setNeedsClamp(PaintLayerScrollableArea*);
+
+ private:
+ static void increment();
+ static void decrement();
+ static void clampScrollableAreas();
+
+ static int m_count;
+ static PersistentHeapVector<Member<PaintLayerScrollableArea>>* m_needsClamp;
+ };
+
// FIXME: We should pass in the LayoutBox but this opens a window
// for crashers during PaintLayer setup (see crbug.com/368062).
static PaintLayerScrollableArea* create(PaintLayer& layer)
@@ -266,9 +320,8 @@ public:
scrollToOffset(toDoubleSize(position), ScrollOffsetClamped, scrollBehavior, scrollType);
}
- // Returns true if a layout object was marked for layout. In such a case, the layout scope's root
- // should be laid out again.
- bool updateAfterLayout(SubtreeLayoutScope* = nullptr);
+ void updateAfterLayout();
leviw_travelin_and_unemployed 2016/04/28 22:50:04 Can you add a TODO or comment about how this is ra
szager1 2016/05/12 20:44:51 Done.
+ void clampScrollPositionsAfterLayout();
leviw_travelin_and_unemployed 2016/04/28 22:50:04 Is there a reason we can't do this in the layer up
szager1 2016/05/12 20:44:51 It's not totally clear to me that this value isn't
void updateAfterStyleChange(const ComputedStyle*);
void updateAfterOverflowRecalc();
@@ -353,6 +406,9 @@ public:
bool shouldRebuildVerticalScrollbarLayer() const { return m_rebuildVerticalScrollbarLayer; }
void resetRebuildScrollbarLayerFlags();
+ bool needsScrollPositionClamp() const { return m_needsScrollPositionClamp; }
+ void setNeedsScrollPositionClamp(bool val) { m_needsScrollPositionClamp = val; }
+
StickyConstraintsMap& stickyConstraintsMap() { return ensureRareData().m_stickyConstraintsMap; }
void invalidateAllStickyConstraints();
void invalidateStickyConstraintsFor(PaintLayer*, bool needsCompositingUpdate = true);
@@ -370,7 +426,8 @@ private:
bool needsScrollbarReconstruction() const;
- void computeScrollDimensions();
+ void updateScrollOrigin();
+ void updateScrollDimensions();
void setScrollOffset(const DoublePoint&, ScrollType) override;
@@ -428,6 +485,8 @@ private:
unsigned m_rebuildHorizontalScrollbarLayer : 1;
unsigned m_rebuildVerticalScrollbarLayer : 1;
+ unsigned m_needsScrollPositionClamp : 1;
+
// The width/height of our scrolled area.
// This is OverflowModel's layout overflow translated to physical
// coordinates. See OverflowModel for the different overflow and

Powered by Google App Engine
This is Rietveld 408576698