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

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.h

Issue 1958363002: IntersectionObserver: check for constructed Frame. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Fixed intrinsic width for overflow:auto, added test Created 4 years, 7 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) 2003, 2009, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2003, 2009, 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Portions are Copyright (C) 1998 Netscape Communications Corporation. 4 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
5 * 5 *
6 * Other contributors: 6 * Other contributors:
7 * Robert O'Callahan <roc+@cs.cmu.edu> 7 * Robert O'Callahan <roc+@cs.cmu.edu>
8 * David Baron <dbaron@fas.harvard.edu> 8 * David Baron <dbaron@fas.harvard.edu>
9 * Christian Biesinger <cbiesinger@web.de> 9 * Christian Biesinger <cbiesinger@web.de>
10 * Randall Jesup <rjesup@wgate.com> 10 * Randall Jesup <rjesup@wgate.com>
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 125
126 // ScrollbarManager allows a ScrollableArea to delay the destruction of a scrollbar that 126 // ScrollbarManager allows a ScrollableArea to delay the destruction of a scrollbar that
127 // is no longer needed, until the end of multi-pass layout. If the scro llbar is then 127 // is no longer needed, until the end of multi-pass layout. If the scro llbar is then
128 // re-added before multi-pass layout finishes, the previously "deleted" scrollbar will 128 // re-added before multi-pass layout finishes, the previously "deleted" scrollbar will
129 // be restored, rather than constructing a new one. 129 // be restored, rather than constructing a new one.
130 public: 130 public:
131 ScrollbarManager(PaintLayerScrollableArea&); 131 ScrollbarManager(PaintLayerScrollableArea&);
132 132
133 void dispose(); 133 void dispose();
134 134
135 // When canDetachScrollbars is true, calls to setHas*Scrollbar(false) wi ll NOT destroy
136 // an existing scrollbar, but instead detach it without destroying it. If, subsequently,
137 // setHas*Scrollbar(true) is called, the existing scrollbar will be reat tached. When
138 // setCanDetachScrollbars(false) is called, any detached scrollbars will be destructed.
139 bool canDetachScrollbars() const { return m_canDetachScrollbars; }
140 void setCanDetachScrollbars(bool);
141
142 Scrollbar* horizontalScrollbar() const { return m_hBarIsAttached ? m_hBa r.get(): nullptr; } 135 Scrollbar* horizontalScrollbar() const { return m_hBarIsAttached ? m_hBa r.get(): nullptr; }
143 Scrollbar* verticalScrollbar() const { return m_vBarIsAttached ? m_vBar. get() : nullptr; } 136 Scrollbar* verticalScrollbar() const { return m_vBarIsAttached ? m_vBar. get() : nullptr; }
144 bool hasHorizontalScrollbar() const { return horizontalScrollbar(); } 137 bool hasHorizontalScrollbar() const { return horizontalScrollbar(); }
145 bool hasVerticalScrollbar() const { return verticalScrollbar(); } 138 bool hasVerticalScrollbar() const { return verticalScrollbar(); }
146 139
147 void setHasHorizontalScrollbar(bool hasScrollbar); 140 // setHas*Scrollbar(false, true) will NOT destroy an existing scrollbar, but instead
148 void setHasVerticalScrollbar(bool hasScrollbar); 141 // detach it without destroying it. If, subsequently, setHas*Scrollbar( true, [true|false])
142 // is called, the existing scrollbar will be reattached. When destroyDe tachedScrollbars
143 // is called, any detached scrollbars will be immediately destroyed.
144 void setHasHorizontalScrollbar(bool hasScrollbar, bool canDetach = false );
145 void setHasVerticalScrollbar(bool hasScrollbar, bool canDetach = false);
146 void destroyDetachedScrollbars();
149 147
150 DECLARE_TRACE(); 148 DECLARE_TRACE();
151 149
152 private: 150 private:
153 Scrollbar* createScrollbar(ScrollbarOrientation); 151 Scrollbar* createScrollbar(ScrollbarOrientation);
154 void destroyScrollbar(ScrollbarOrientation); 152 void destroyScrollbar(ScrollbarOrientation);
155 153
156 private: 154 private:
157 Member<PaintLayerScrollableArea> m_scrollableArea; 155 Member<PaintLayerScrollableArea> m_scrollableArea;
158 156
159 // The scrollbars associated with m_scrollableArea. Both can nullptr. 157 // The scrollbars associated with m_scrollableArea. Both can nullptr.
160 Member<Scrollbar> m_hBar; 158 Member<Scrollbar> m_hBar;
161 Member<Scrollbar> m_vBar; 159 Member<Scrollbar> m_vBar;
162 160
163 unsigned m_canDetachScrollbars: 1;
164 unsigned m_hBarIsAttached: 1; 161 unsigned m_hBarIsAttached: 1;
165 unsigned m_vBarIsAttached: 1; 162 unsigned m_vBarIsAttached: 1;
166 }; 163 };
167 164
168 public: 165 public:
166
167 // If a PreventRelayoutScope object is alive, updateAfterLayout() will not
168 // re-run box layout as a result of adding or removing scrollbars.
169 class PreventRelayoutScope {
170 public:
171 PreventRelayoutScope(SubtreeLayoutScope&);
172 ~PreventRelayoutScope();
173
174 static bool relayoutIsPrevented() { return m_count; }
175 static void setNeedsLayout(LayoutObject&);
176 static bool relayoutNeeded() { return m_count == 0 && m_relayoutNeeded; }
177 static void resetRelayoutNeeded();
178
179 private:
180 static void increment();
181 static void decrement();
182
183 static int m_count;
184 static SubtreeLayoutScope* m_layoutScope;
185 static bool m_relayoutNeeded;
186 static WTF::Vector<LayoutObject*>* m_needsRelayout;
187 };
188
189 // If a FreezeScrollbarScope object is alive, updateAfterLayout() will not
190 // recompute the existence of overflow:auto scrollbars.
191 class FreezeScrollbarsScope {
192 public:
193 FreezeScrollbarsScope() { m_count++; }
194 ~FreezeScrollbarsScope() { m_count--; }
195
196 static bool scrollbarsAreFrozen() { return m_count; }
197
198 private:
199 static int m_count;
200 };
201
202 // If a DelayScrollPositionClampScope object is alive, updateAfterLayout() w ill not
203 // clamp scroll positions to ensure they are in the valid range. When
204 // the last DelayScrollPositionClampScope object is destructed, all PaintLay erScrollableArea's
205 // that delayed clamping their positions will immediately clamp them.
206 class DelayScrollPositionClampScope {
207 public:
208 DelayScrollPositionClampScope();
209 ~DelayScrollPositionClampScope();
210
211 static bool clampingIsDelayed() { return m_count; }
212 static void setNeedsClamp(PaintLayerScrollableArea*);
213
214 private:
215 static void increment();
216 static void decrement();
217 static void clampScrollableAreas();
218
219 static int m_count;
220 static PersistentHeapVector<Member<PaintLayerScrollableArea>>* m_needsCl amp;
221 };
222
169 // FIXME: We should pass in the LayoutBox but this opens a window 223 // FIXME: We should pass in the LayoutBox but this opens a window
170 // for crashers during PaintLayer setup (see crbug.com/368062). 224 // for crashers during PaintLayer setup (see crbug.com/368062).
171 static PaintLayerScrollableArea* create(PaintLayer& layer) 225 static PaintLayerScrollableArea* create(PaintLayer& layer)
172 { 226 {
173 return new PaintLayerScrollableArea(layer); 227 return new PaintLayerScrollableArea(layer);
174 } 228 }
175 229
176 ~PaintLayerScrollableArea() override; 230 ~PaintLayerScrollableArea() override;
177 void dispose(); 231 void dispose();
178 232
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 void scrollToYOffset(double y, ScrollOffsetClamping clamp = ScrollOffsetUncl amped, ScrollBehavior scrollBehavior = ScrollBehaviorInstant) 311 void scrollToYOffset(double y, ScrollOffsetClamping clamp = ScrollOffsetUncl amped, ScrollBehavior scrollBehavior = ScrollBehaviorInstant)
258 { 312 {
259 scrollToOffset(DoubleSize(scrollXOffset(), y), clamp, scrollBehavior); 313 scrollToOffset(DoubleSize(scrollXOffset(), y), clamp, scrollBehavior);
260 } 314 }
261 315
262 void setScrollPosition(const DoublePoint& position, ScrollType scrollType, S crollBehavior scrollBehavior = ScrollBehaviorInstant) override 316 void setScrollPosition(const DoublePoint& position, ScrollType scrollType, S crollBehavior scrollBehavior = ScrollBehaviorInstant) override
263 { 317 {
264 scrollToOffset(toDoubleSize(position), ScrollOffsetClamped, scrollBehavi or, scrollType); 318 scrollToOffset(toDoubleSize(position), ScrollOffsetClamped, scrollBehavi or, scrollType);
265 } 319 }
266 320
267 // Returns true if a layout object was marked for layout. In such a case, th e layout scope's root 321 void updateAfterLayout();
268 // should be laid out again. 322 void clampScrollPositionsAfterLayout();
269 bool updateAfterLayout(SubtreeLayoutScope* = nullptr);
270 void updateAfterStyleChange(const ComputedStyle*); 323 void updateAfterStyleChange(const ComputedStyle*);
271 void updateAfterOverflowRecalc(); 324 void updateAfterOverflowRecalc();
272 325
273 bool updateAfterCompositingChange() override; 326 bool updateAfterCompositingChange() override;
274 327
275 bool hasScrollbar() const { return hasHorizontalScrollbar() || hasVerticalSc rollbar(); } 328 bool hasScrollbar() const { return hasHorizontalScrollbar() || hasVerticalSc rollbar(); }
276 bool hasOverflowControls() const { return hasScrollbar() || scrollCorner() | | resizer(); } 329 bool hasOverflowControls() const { return hasScrollbar() || scrollCorner() | | resizer(); }
277 330
278 LayoutScrollbarPart* scrollCorner() const override { return m_scrollCorner; } 331 LayoutScrollbarPart* scrollCorner() const override { return m_scrollCorner; }
279 332
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 IntRect rectForVerticalScrollbar(const IntRect& borderBoxRect) const; 397 IntRect rectForVerticalScrollbar(const IntRect& borderBoxRect) const;
345 398
346 Widget* getWidget() override; 399 Widget* getWidget() override;
347 ScrollAnchor& scrollAnchor() { return m_scrollAnchor; } 400 ScrollAnchor& scrollAnchor() { return m_scrollAnchor; }
348 bool isPaintLayerScrollableArea() const override { return true; } 401 bool isPaintLayerScrollableArea() const override { return true; }
349 402
350 bool shouldRebuildHorizontalScrollbarLayer() const { return m_rebuildHorizon talScrollbarLayer; } 403 bool shouldRebuildHorizontalScrollbarLayer() const { return m_rebuildHorizon talScrollbarLayer; }
351 bool shouldRebuildVerticalScrollbarLayer() const { return m_rebuildVerticalS crollbarLayer; } 404 bool shouldRebuildVerticalScrollbarLayer() const { return m_rebuildVerticalS crollbarLayer; }
352 void resetRebuildScrollbarLayerFlags(); 405 void resetRebuildScrollbarLayerFlags();
353 406
407 bool needsScrollPositionClamp() const { return m_needsScrollPositionClamp; }
408 void setNeedsScrollPositionClamp(bool val) { m_needsScrollPositionClamp = va l; }
409
354 StickyConstraintsMap& stickyConstraintsMap() { return ensureRareData().m_sti ckyConstraintsMap; } 410 StickyConstraintsMap& stickyConstraintsMap() { return ensureRareData().m_sti ckyConstraintsMap; }
355 void invalidateAllStickyConstraints(); 411 void invalidateAllStickyConstraints();
356 void invalidateStickyConstraintsFor(PaintLayer*, bool needsCompositingUpdate = true); 412 void invalidateStickyConstraintsFor(PaintLayer*, bool needsCompositingUpdate = true);
357 413
358 DECLARE_VIRTUAL_TRACE(); 414 DECLARE_VIRTUAL_TRACE();
359 415
360 private: 416 private:
361 explicit PaintLayerScrollableArea(PaintLayer&); 417 explicit PaintLayerScrollableArea(PaintLayer&);
362 418
363 bool hasHorizontalOverflow() const; 419 bool hasHorizontalOverflow() const;
364 bool hasVerticalOverflow() const; 420 bool hasVerticalOverflow() const;
365 bool hasScrollableHorizontalOverflow() const; 421 bool hasScrollableHorizontalOverflow() const;
366 bool hasScrollableVerticalOverflow() const; 422 bool hasScrollableVerticalOverflow() const;
367 bool visualViewportSuppliesScrollbars() const; 423 bool visualViewportSuppliesScrollbars() const;
368 424
369 bool needsScrollbarReconstruction() const; 425 bool needsScrollbarReconstruction() const;
370 426
371 void computeScrollDimensions(); 427 void updateScrollOrigin();
428 void updateScrollDimensions();
372 429
373 void setScrollOffset(const DoublePoint&, ScrollType) override; 430 void setScrollOffset(const DoublePoint&, ScrollType) override;
374 431
375 int verticalScrollbarStart(int minX, int maxX) const; 432 int verticalScrollbarStart(int minX, int maxX) const;
376 int horizontalScrollbarStart(int minX) const; 433 int horizontalScrollbarStart(int minX) const;
377 IntSize scrollbarOffset(const Scrollbar&) const; 434 IntSize scrollbarOffset(const Scrollbar&) const;
378 435
379 void setHasHorizontalScrollbar(bool hasScrollbar); 436 void setHasHorizontalScrollbar(bool hasScrollbar);
380 void setHasVerticalScrollbar(bool hasScrollbar); 437 void setHasVerticalScrollbar(bool hasScrollbar);
381 438
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 // FIXME: once cc can handle composited scrolling with clip paths, we will 476 // FIXME: once cc can handle composited scrolling with clip paths, we will
420 // no longer need this bit. 477 // no longer need this bit.
421 unsigned m_needsCompositedScrolling : 1; 478 unsigned m_needsCompositedScrolling : 1;
422 479
423 // Set to indicate that a scrollbar layer, if present, needs to be rebuilt 480 // Set to indicate that a scrollbar layer, if present, needs to be rebuilt
424 // in the next compositing update because the underlying blink::Scrollbar 481 // in the next compositing update because the underlying blink::Scrollbar
425 // instance has been reconstructed. 482 // instance has been reconstructed.
426 unsigned m_rebuildHorizontalScrollbarLayer : 1; 483 unsigned m_rebuildHorizontalScrollbarLayer : 1;
427 unsigned m_rebuildVerticalScrollbarLayer : 1; 484 unsigned m_rebuildVerticalScrollbarLayer : 1;
428 485
486 unsigned m_needsScrollPositionClamp : 1;
487
429 // The width/height of our scrolled area. 488 // The width/height of our scrolled area.
430 // This is OverflowModel's layout overflow translated to physical 489 // This is OverflowModel's layout overflow translated to physical
431 // coordinates. See OverflowModel for the different overflow and 490 // coordinates. See OverflowModel for the different overflow and
432 // LayoutBoxModelObject for the coordinate systems. 491 // LayoutBoxModelObject for the coordinate systems.
433 LayoutRect m_overflowRect; 492 LayoutRect m_overflowRect;
434 493
435 // ScrollbarManager holds the Scrollbar instances. 494 // ScrollbarManager holds the Scrollbar instances.
436 ScrollbarManager m_scrollbarManager; 495 ScrollbarManager m_scrollbarManager;
437 496
438 // This is the (scroll) offset from scrollOrigin(). 497 // This is the (scroll) offset from scrollOrigin().
(...skipping 16 matching lines...) Expand all
455 #endif 514 #endif
456 }; 515 };
457 516
458 DEFINE_TYPE_CASTS(PaintLayerScrollableArea, ScrollableArea, scrollableArea, 517 DEFINE_TYPE_CASTS(PaintLayerScrollableArea, ScrollableArea, scrollableArea,
459 scrollableArea->isPaintLayerScrollableArea(), 518 scrollableArea->isPaintLayerScrollableArea(),
460 scrollableArea.isPaintLayerScrollableArea()); 519 scrollableArea.isPaintLayerScrollableArea());
461 520
462 } // namespace blink 521 } // namespace blink
463 522
464 #endif // LayerScrollableArea_h 523 #endif // LayerScrollableArea_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698