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

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

Issue 2088323003: Don't invalidate width for children unless scrollbars have changed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: nits Created 4 years, 5 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 Member<Scrollbar> m_vBar; 161 Member<Scrollbar> m_vBar;
162 162
163 unsigned m_hBarIsAttached: 1; 163 unsigned m_hBarIsAttached: 1;
164 unsigned m_vBarIsAttached: 1; 164 unsigned m_vBarIsAttached: 1;
165 }; 165 };
166 166
167 public: 167 public:
168 168
169 // If a PreventRelayoutScope object is alive, updateAfterLayout() will not 169 // If a PreventRelayoutScope object is alive, updateAfterLayout() will not
170 // re-run box layout as a result of adding or removing scrollbars. 170 // re-run box layout as a result of adding or removing scrollbars.
171 // Instead, it will mark the PLSA as needing relayout of its box.
172 // When the last PreventRelayoutScope object is popped off the stack,
173 // box().setNeedsLayout(), and box().scrollbarsChanged() for LayoutBlock's,
174 // will be called as appropriate for all marked PLSA's.
skobes 2016/06/23 19:08:22 thanks, this helps a lot
171 class PreventRelayoutScope { 175 class PreventRelayoutScope {
172 STACK_ALLOCATED(); 176 STACK_ALLOCATED();
173 public: 177 public:
174 PreventRelayoutScope(SubtreeLayoutScope&); 178 PreventRelayoutScope(SubtreeLayoutScope&);
175 ~PreventRelayoutScope(); 179 ~PreventRelayoutScope();
176 180
177 static bool relayoutIsPrevented() { return s_count; } 181 static bool relayoutIsPrevented() { return s_count; }
178 static void setNeedsLayout(LayoutObject&); 182 static void setBoxNeedsLayout(PaintLayerScrollableArea&, bool hadHorizon talScrollbar, bool hadVerticalScrollbar);
179 static bool relayoutNeeded() { return s_count == 0 && s_relayoutNeeded; } 183 static bool relayoutNeeded() { return s_count == 0 && s_relayoutNeeded; }
180 static void resetRelayoutNeeded(); 184 static void resetRelayoutNeeded();
181 185
182 private: 186 private:
183 static int s_count; 187 static int s_count;
184 static SubtreeLayoutScope* s_layoutScope; 188 static SubtreeLayoutScope* s_layoutScope;
185 static bool s_relayoutNeeded; 189 static bool s_relayoutNeeded;
186 static WTF::Vector<LayoutObject*>* s_needsRelayout; 190 static PersistentHeapVector<Member<PaintLayerScrollableArea>>* s_needsRe layout;
187 }; 191 };
188 192
189 // If a FreezeScrollbarScope object is alive, updateAfterLayout() will not 193 // If a FreezeScrollbarScope object is alive, updateAfterLayout() will not
190 // recompute the existence of overflow:auto scrollbars. 194 // recompute the existence of overflow:auto scrollbars.
191 class FreezeScrollbarsScope { 195 class FreezeScrollbarsScope {
192 STACK_ALLOCATED(); 196 STACK_ALLOCATED();
193 public: 197 public:
194 FreezeScrollbarsScope() { s_count++; } 198 FreezeScrollbarsScope() { s_count++; }
195 ~FreezeScrollbarsScope() { s_count--; } 199 ~FreezeScrollbarsScope() { s_count--; }
196 200
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 IntRect rectForVerticalScrollbar(const IntRect& borderBoxRect) const; 405 IntRect rectForVerticalScrollbar(const IntRect& borderBoxRect) const;
402 406
403 Widget* getWidget() override; 407 Widget* getWidget() override;
404 ScrollAnchor& scrollAnchor() { return m_scrollAnchor; } 408 ScrollAnchor& scrollAnchor() { return m_scrollAnchor; }
405 bool isPaintLayerScrollableArea() const override { return true; } 409 bool isPaintLayerScrollableArea() const override { return true; }
406 410
407 bool shouldRebuildHorizontalScrollbarLayer() const { return m_rebuildHorizon talScrollbarLayer; } 411 bool shouldRebuildHorizontalScrollbarLayer() const { return m_rebuildHorizon talScrollbarLayer; }
408 bool shouldRebuildVerticalScrollbarLayer() const { return m_rebuildVerticalS crollbarLayer; } 412 bool shouldRebuildVerticalScrollbarLayer() const { return m_rebuildVerticalS crollbarLayer; }
409 void resetRebuildScrollbarLayerFlags(); 413 void resetRebuildScrollbarLayerFlags();
410 414
415 // Did DelayScrollPositionClampScope prevent us from running clampScrollPosi tionsAfterLayout()
416 // in updateAfterLayout()?
411 bool needsScrollPositionClamp() const { return m_needsScrollPositionClamp; } 417 bool needsScrollPositionClamp() const { return m_needsScrollPositionClamp; }
412 void setNeedsScrollPositionClamp(bool val) { m_needsScrollPositionClamp = va l; } 418 void setNeedsScrollPositionClamp(bool val) { m_needsScrollPositionClamp = va l; }
413 419
420 // Did PreventRelayoutScope prevent us from running re-layout due to adding/ subtracting
421 // scrollbars in updateAfterLayout()?
422 bool needsRelayout() const { return m_needsRelayout; }
423 void setNeedsRelayout(bool val) { m_needsRelayout = val; }
424
425 // Were we laid out with a horizontal scrollbar at the time we were marked a s
426 // needing relayout by PreventRelayoutScope?
427 bool hadHorizontalScrollbarBeforeRelayout() const { return m_hadHorizontalSc rollbarBeforeRelayout; }
428 void setHadHorizontalScrollbarBeforeRelayout(bool val) { m_hadHorizontalScro llbarBeforeRelayout = val; }
429
430 // Were we laid out with a vertical scrollbar at the time we were marked as
431 // needing relayout by PreventRelayoutScope?
432 bool hadVerticalScrollbarBeforeRelayout() const { return m_hadVerticalScroll barBeforeRelayout; }
433 void setHadVerticalScrollbarBeforeRelayout(bool val) { m_hadVerticalScrollba rBeforeRelayout = val; }
434
414 StickyConstraintsMap& stickyConstraintsMap() { return ensureRareData().m_sti ckyConstraintsMap; } 435 StickyConstraintsMap& stickyConstraintsMap() { return ensureRareData().m_sti ckyConstraintsMap; }
415 void invalidateAllStickyConstraints(); 436 void invalidateAllStickyConstraints();
416 void invalidateStickyConstraintsFor(PaintLayer*, bool needsCompositingUpdate = true); 437 void invalidateStickyConstraintsFor(PaintLayer*, bool needsCompositingUpdate = true);
417 438
418 DECLARE_VIRTUAL_TRACE(); 439 DECLARE_VIRTUAL_TRACE();
419 440
420 private: 441 private:
421 explicit PaintLayerScrollableArea(PaintLayer&); 442 explicit PaintLayerScrollableArea(PaintLayer&);
422 443
423 bool hasHorizontalOverflow() const; 444 bool hasHorizontalOverflow() const;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 if (!m_rareData) 482 if (!m_rareData)
462 m_rareData = wrapUnique(new PaintLayerScrollableAreaRareData()); 483 m_rareData = wrapUnique(new PaintLayerScrollableAreaRareData());
463 return *m_rareData.get(); 484 return *m_rareData.get();
464 } 485 }
465 486
466 // PaintInvalidationCapableScrollableArea 487 // PaintInvalidationCapableScrollableArea
467 LayoutBox& boxForScrollControlPaintInvalidation() const { return box(); } 488 LayoutBox& boxForScrollControlPaintInvalidation() const { return box(); }
468 489
469 PaintLayer& m_layer; 490 PaintLayer& m_layer;
470 491
492 PaintLayer* m_nextTopmostScrollChild;
493 PaintLayer* m_topmostScrollChild;
494
471 // Keeps track of whether the layer is currently resizing, so events can cau se resizing to start and stop. 495 // Keeps track of whether the layer is currently resizing, so events can cau se resizing to start and stop.
472 unsigned m_inResizeMode : 1; 496 unsigned m_inResizeMode : 1;
473 unsigned m_scrollsOverflow : 1; 497 unsigned m_scrollsOverflow : 1;
474 498
475 unsigned m_inOverflowRelayout : 1; 499 unsigned m_inOverflowRelayout : 1;
476 500
477 PaintLayer* m_nextTopmostScrollChild;
478 PaintLayer* m_topmostScrollChild;
479
480 // FIXME: once cc can handle composited scrolling with clip paths, we will 501 // FIXME: once cc can handle composited scrolling with clip paths, we will
481 // no longer need this bit. 502 // no longer need this bit.
482 unsigned m_needsCompositedScrolling : 1; 503 unsigned m_needsCompositedScrolling : 1;
483 504
484 // Set to indicate that a scrollbar layer, if present, needs to be rebuilt 505 // Set to indicate that a scrollbar layer, if present, needs to be rebuilt
485 // in the next compositing update because the underlying blink::Scrollbar 506 // in the next compositing update because the underlying blink::Scrollbar
486 // instance has been reconstructed. 507 // instance has been reconstructed.
487 unsigned m_rebuildHorizontalScrollbarLayer : 1; 508 unsigned m_rebuildHorizontalScrollbarLayer : 1;
488 unsigned m_rebuildVerticalScrollbarLayer : 1; 509 unsigned m_rebuildVerticalScrollbarLayer : 1;
489 510
490 unsigned m_needsScrollPositionClamp : 1; 511 unsigned m_needsScrollPositionClamp : 1;
512 unsigned m_needsRelayout : 1;
513 unsigned m_hadHorizontalScrollbarBeforeRelayout : 1;
514 unsigned m_hadVerticalScrollbarBeforeRelayout : 1;
491 515
492 // The width/height of our scrolled area. 516 // The width/height of our scrolled area.
493 // This is OverflowModel's layout overflow translated to physical 517 // This is OverflowModel's layout overflow translated to physical
494 // coordinates. See OverflowModel for the different overflow and 518 // coordinates. See OverflowModel for the different overflow and
495 // LayoutBoxModelObject for the coordinate systems. 519 // LayoutBoxModelObject for the coordinate systems.
496 LayoutRect m_overflowRect; 520 LayoutRect m_overflowRect;
497 521
498 // ScrollbarManager holds the Scrollbar instances. 522 // ScrollbarManager holds the Scrollbar instances.
499 ScrollbarManager m_scrollbarManager; 523 ScrollbarManager m_scrollbarManager;
500 524
(...skipping 17 matching lines...) Expand all
518 #endif 542 #endif
519 }; 543 };
520 544
521 DEFINE_TYPE_CASTS(PaintLayerScrollableArea, ScrollableArea, scrollableArea, 545 DEFINE_TYPE_CASTS(PaintLayerScrollableArea, ScrollableArea, scrollableArea,
522 scrollableArea->isPaintLayerScrollableArea(), 546 scrollableArea->isPaintLayerScrollableArea(),
523 scrollableArea.isPaintLayerScrollableArea()); 547 scrollableArea.isPaintLayerScrollableArea());
524 548
525 } // namespace blink 549 } // namespace blink
526 550
527 #endif // LayerScrollableArea_h 551 #endif // LayerScrollableArea_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698