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

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

Issue 2392443009: reflow comments in core/paint (Closed)
Patch Set: Created 4 years, 2 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>
11 * Roland Mainz <roland.mainz@informatik.med.uni-giessen.de> 11 * Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
12 * Josh Soref <timeless@mac.com> 12 * Josh Soref <timeless@mac.com>
13 * Boris Zbarsky <bzbarsky@mit.edu> 13 * Boris Zbarsky <bzbarsky@mit.edu>
14 * 14 *
15 * This library is free software; you can redistribute it and/or 15 * This library is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU Lesser General Public 16 * modify it under the terms of the GNU Lesser General Public
17 * License as published by the Free Software Foundation; either 17 * License as published by the Free Software Foundation; either
18 * version 2.1 of the License, or (at your option) any later version. 18 * version 2.1 of the License, or (at your option) any later version.
19 * 19 *
20 * This library is distributed in the hope that it will be useful, 20 * This library is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 * Lesser General Public License for more details. 23 * Lesser General Public License for more details.
24 * 24 *
25 * You should have received a copy of the GNU Lesser General Public 25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software 26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 US A 27 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
28 * 28 *
29 * Alternatively, the contents of this file may be used under the terms 29 * Alternatively, the contents of this file may be used under the terms
30 * of either the Mozilla Public License Version 1.1, found at 30 * of either the Mozilla Public License Version 1.1, found at
31 * http://www.mozilla.org/MPL/ (the "MPL") or the GNU General Public 31 * http://www.mozilla.org/MPL/ (the "MPL") or the GNU General Public
32 * License Version 2.0, found at http://www.fsf.org/copyleft/gpl.html 32 * License Version 2.0, found at http://www.fsf.org/copyleft/gpl.html
33 * (the "GPL"), in which case the provisions of the MPL or the GPL are 33 * (the "GPL"), in which case the provisions of the MPL or the GPL are
34 * applicable instead of those above. If you wish to allow use of your 34 * applicable instead of those above. If you wish to allow use of your
35 * version of this file only under the terms of one of those two 35 * version of this file only under the terms of one of those two
36 * licenses (the MPL or the GPL) and not to allow others to use your 36 * licenses (the MPL or the GPL) and not to allow others to use your
37 * version of this file under the LGPL, indicate your decision by 37 * version of this file under the LGPL, indicate your decision by
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 class CORE_EXPORT PaintLayerScrollableArea final 118 class CORE_EXPORT PaintLayerScrollableArea final
119 : public GarbageCollectedFinalized<PaintLayerScrollableArea>, 119 : public GarbageCollectedFinalized<PaintLayerScrollableArea>,
120 public PaintInvalidationCapableScrollableArea { 120 public PaintInvalidationCapableScrollableArea {
121 USING_GARBAGE_COLLECTED_MIXIN(PaintLayerScrollableArea); 121 USING_GARBAGE_COLLECTED_MIXIN(PaintLayerScrollableArea);
122 friend class Internals; 122 friend class Internals;
123 123
124 private: 124 private:
125 class ScrollbarManager { 125 class ScrollbarManager {
126 DISALLOW_NEW(); 126 DISALLOW_NEW();
127 127
128 // Helper class to manage the life cycle of Scrollbar objects. Some layout containers 128 // Helper class to manage the life cycle of Scrollbar objects. Some layout
129 // (e.g., flexbox, table) run multi-pass layout on their children, applying different 129 // containers (e.g., flexbox, table) run multi-pass layout on their
130 // constraints. If a child has overflow:auto, it may gain and lose scrollba rs multiple 130 // children, applying different constraints. If a child has overflow:auto,
131 // times during multi-pass layout, causing pointless allocation/deallocation thrashing, 131 // it may gain and lose scrollbars multiple times during multi-pass layout,
132 // and potentially leading to other problems (crbug.com/528940). 132 // causing pointless allocation/deallocation thrashing, and potentially
133 // leading to other problems (crbug.com/528940).
133 134
134 // ScrollbarManager allows a ScrollableArea to delay the destruction of a sc rollbar that 135 // ScrollbarManager allows a ScrollableArea to delay the destruction of a
135 // is no longer needed, until the end of multi-pass layout. If the scrollba r is then 136 // scrollbar that is no longer needed, until the end of multi-pass layout.
136 // re-added before multi-pass layout finishes, the previously "deleted" scro llbar will 137 // If the scrollbar is then re-added before multi-pass layout finishes, the
137 // be restored, rather than constructing a new one. 138 // previously "deleted" scrollbar will be restored, rather than constructing
139 // a new one.
138 public: 140 public:
139 ScrollbarManager(PaintLayerScrollableArea&); 141 ScrollbarManager(PaintLayerScrollableArea&);
140 142
141 void dispose(); 143 void dispose();
142 144
143 Scrollbar* horizontalScrollbar() const { 145 Scrollbar* horizontalScrollbar() const {
144 return m_hBarIsAttached ? m_hBar.get() : nullptr; 146 return m_hBarIsAttached ? m_hBar.get() : nullptr;
145 } 147 }
146 Scrollbar* verticalScrollbar() const { 148 Scrollbar* verticalScrollbar() const {
147 return m_vBarIsAttached ? m_vBar.get() : nullptr; 149 return m_vBarIsAttached ? m_vBar.get() : nullptr;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 public: 209 public:
208 FreezeScrollbarsScope() { s_count++; } 210 FreezeScrollbarsScope() { s_count++; }
209 ~FreezeScrollbarsScope() { s_count--; } 211 ~FreezeScrollbarsScope() { s_count--; }
210 212
211 static bool scrollbarsAreFrozen() { return s_count; } 213 static bool scrollbarsAreFrozen() { return s_count; }
212 214
213 private: 215 private:
214 static int s_count; 216 static int s_count;
215 }; 217 };
216 218
217 // If a DelayScrollPositionClampScope object is alive, updateAfterLayout() wil l not 219 // If a DelayScrollPositionClampScope object is alive, updateAfterLayout()
218 // clamp scroll positions to ensure they are in the valid range. When 220 // will not clamp scroll positions to ensure they are in the valid range.
219 // the last DelayScrollPositionClampScope object is destructed, all PaintLayer ScrollableArea's 221 // When the last DelayScrollPositionClampScope object is destructed, all
220 // that delayed clamping their positions will immediately clamp them. 222 // PaintLayerScrollableArea's that delayed clamping their positions will
223 // immediately clamp them.
221 class DelayScrollPositionClampScope { 224 class DelayScrollPositionClampScope {
222 STACK_ALLOCATED(); 225 STACK_ALLOCATED();
223 226
224 public: 227 public:
225 DelayScrollPositionClampScope(); 228 DelayScrollPositionClampScope();
226 ~DelayScrollPositionClampScope(); 229 ~DelayScrollPositionClampScope();
227 230
228 static bool clampingIsDelayed() { return s_count; } 231 static bool clampingIsDelayed() { return s_count; }
229 static void setNeedsClamp(PaintLayerScrollableArea*); 232 static void setNeedsClamp(PaintLayerScrollableArea*);
230 233
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 ScrollType scrollType, 330 ScrollType scrollType,
328 ScrollBehavior scrollBehavior = ScrollBehaviorInstant) override { 331 ScrollBehavior scrollBehavior = ScrollBehaviorInstant) override {
329 scrollToOffset(toDoubleSize(position), scrollBehavior, scrollType); 332 scrollToOffset(toDoubleSize(position), scrollBehavior, scrollType);
330 } 333 }
331 334
332 // This will set the scroll position without clamping, and it will do all 335 // This will set the scroll position without clamping, and it will do all
333 // post-update work even if the scroll position didn't change. 336 // post-update work even if the scroll position didn't change.
334 void setScrollPositionUnconditionally(const DoublePoint&, 337 void setScrollPositionUnconditionally(const DoublePoint&,
335 ScrollType = ProgrammaticScroll); 338 ScrollType = ProgrammaticScroll);
336 339
337 // TODO(szager): Actually run these after all of layout is finished. Currentl y, they 340 // TODO(szager): Actually run these after all of layout is finished.
338 // run at the end of box()'es layout (or after all flexbox layout has finished ) but while 341 // Currently, they run at the end of box()'es layout (or after all flexbox
339 // document layout is still happening. 342 // layout has finished) but while document layout is still happening.
340 void updateAfterLayout(); 343 void updateAfterLayout();
341 void clampScrollPositionsAfterLayout(); 344 void clampScrollPositionsAfterLayout();
342 345
343 void updateAfterStyleChange(const ComputedStyle*); 346 void updateAfterStyleChange(const ComputedStyle*);
344 void updateAfterOverflowRecalc(); 347 void updateAfterOverflowRecalc();
345 348
346 bool updateAfterCompositingChange() override; 349 bool updateAfterCompositingChange() override;
347 350
348 bool hasScrollbar() const { 351 bool hasScrollbar() const {
349 return hasHorizontalScrollbar() || hasVerticalScrollbar(); 352 return hasHorizontalScrollbar() || hasVerticalScrollbar();
(...skipping 23 matching lines...) Expand all
373 OverlayScrollbarClipBehavior = IgnoreOverlayScrollbarSize) const; 376 OverlayScrollbarClipBehavior = IgnoreOverlayScrollbarSize) const;
374 int horizontalScrollbarHeight( 377 int horizontalScrollbarHeight(
375 OverlayScrollbarClipBehavior = IgnoreOverlayScrollbarSize) const; 378 OverlayScrollbarClipBehavior = IgnoreOverlayScrollbarSize) const;
376 379
377 DoubleSize adjustedScrollOffset() const { 380 DoubleSize adjustedScrollOffset() const {
378 return toDoubleSize(DoublePoint(scrollOrigin()) + m_scrollOffset); 381 return toDoubleSize(DoublePoint(scrollOrigin()) + m_scrollOffset);
379 } 382 }
380 383
381 void positionOverflowControls(); 384 void positionOverflowControls();
382 385
383 // isPointInResizeControl() is used for testing if a pointer/touch position is in the resize control 386 // isPointInResizeControl() is used for testing if a pointer/touch position is
384 // area. 387 // in the resize control area.
385 bool isPointInResizeControl(const IntPoint& absolutePoint, 388 bool isPointInResizeControl(const IntPoint& absolutePoint,
386 ResizerHitTestType) const; 389 ResizerHitTestType) const;
387 bool hitTestOverflowControls(HitTestResult&, const IntPoint& localPoint); 390 bool hitTestOverflowControls(HitTestResult&, const IntPoint& localPoint);
388 391
389 bool hitTestResizerInFragments(const PaintLayerFragments&, 392 bool hitTestResizerInFragments(const PaintLayerFragments&,
390 const HitTestLocation&) const; 393 const HitTestLocation&) const;
391 394
392 // Returns the new position, after scrolling, of the given rect in absolute 395 // Returns the new position, after scrolling, of the given rect in absolute
393 // coordinates, clipped by the parent's client rect. 396 // coordinates, clipped by the parent's client rect.
394 LayoutRect scrollIntoView(const LayoutRect&, 397 LayoutRect scrollIntoView(const LayoutRect&,
395 const ScrollAlignment& alignX, 398 const ScrollAlignment& alignX,
396 const ScrollAlignment& alignY, 399 const ScrollAlignment& alignY,
397 ScrollType = ProgrammaticScroll) override; 400 ScrollType = ProgrammaticScroll) override;
398 401
399 // Returns true if scrollable area is in the FrameView's collection of scrolla ble areas. This can 402 // Returns true if scrollable area is in the FrameView's collection of
400 // only happen if we're scrollable, visible to hit test, and do in fact overfl ow. This means that 403 // scrollable areas. This can only happen if we're scrollable, visible to hit
401 // 'overflow: hidden' or 'pointer-events: none' layers never get added to the FrameView's collection. 404 // test, and do in fact overflow. This means that 'overflow: hidden' or
405 // 'pointer-events: none' layers never get added to the FrameView's
406 // collection.
402 bool scrollsOverflow() const { return m_scrollsOverflow; } 407 bool scrollsOverflow() const { return m_scrollsOverflow; }
403 408
404 // Rectangle encompassing the scroll corner and resizer rect. 409 // Rectangle encompassing the scroll corner and resizer rect.
405 IntRect scrollCornerAndResizerRect() const final; 410 IntRect scrollCornerAndResizerRect() const final;
406 411
407 enum LCDTextMode { ConsiderLCDText, IgnoreLCDText }; 412 enum LCDTextMode { ConsiderLCDText, IgnoreLCDText };
408 413
409 void updateNeedsCompositedScrolling(LCDTextMode = ConsiderLCDText); 414 void updateNeedsCompositedScrolling(LCDTextMode = ConsiderLCDText);
410 bool needsCompositedScrolling() const { return m_needsCompositedScrolling; } 415 bool needsCompositedScrolling() const { return m_needsCompositedScrolling; }
411 416
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 LayoutBox* layoutBox() const override { return &box(); } 448 LayoutBox* layoutBox() const override { return &box(); }
444 449
445 bool shouldRebuildHorizontalScrollbarLayer() const { 450 bool shouldRebuildHorizontalScrollbarLayer() const {
446 return m_rebuildHorizontalScrollbarLayer; 451 return m_rebuildHorizontalScrollbarLayer;
447 } 452 }
448 bool shouldRebuildVerticalScrollbarLayer() const { 453 bool shouldRebuildVerticalScrollbarLayer() const {
449 return m_rebuildVerticalScrollbarLayer; 454 return m_rebuildVerticalScrollbarLayer;
450 } 455 }
451 void resetRebuildScrollbarLayerFlags(); 456 void resetRebuildScrollbarLayerFlags();
452 457
453 // Did DelayScrollPositionClampScope prevent us from running clampScrollPositi onsAfterLayout() 458 // Did DelayScrollPositionClampScope prevent us from running
459 // clampScrollPositionsAfterLayout()
454 // in updateAfterLayout()? 460 // in updateAfterLayout()?
455 bool needsScrollPositionClamp() const { return m_needsScrollPositionClamp; } 461 bool needsScrollPositionClamp() const { return m_needsScrollPositionClamp; }
456 void setNeedsScrollPositionClamp(bool val) { 462 void setNeedsScrollPositionClamp(bool val) {
457 m_needsScrollPositionClamp = val; 463 m_needsScrollPositionClamp = val;
458 } 464 }
459 465
460 // Did PreventRelayoutScope prevent us from running re-layout due to adding/su btracting 466 // Did PreventRelayoutScope prevent us from running re-layout due to
461 // scrollbars in updateAfterLayout()? 467 // adding/subtracting scrollbars in updateAfterLayout()?
462 bool needsRelayout() const { return m_needsRelayout; } 468 bool needsRelayout() const { return m_needsRelayout; }
463 void setNeedsRelayout(bool val) { m_needsRelayout = val; } 469 void setNeedsRelayout(bool val) { m_needsRelayout = val; }
464 470
465 // Were we laid out with a horizontal scrollbar at the time we were marked as 471 // Were we laid out with a horizontal scrollbar at the time we were marked as
466 // needing relayout by PreventRelayoutScope? 472 // needing relayout by PreventRelayoutScope?
467 bool hadHorizontalScrollbarBeforeRelayout() const { 473 bool hadHorizontalScrollbarBeforeRelayout() const {
468 return m_hadHorizontalScrollbarBeforeRelayout; 474 return m_hadHorizontalScrollbarBeforeRelayout;
469 } 475 }
470 void setHadHorizontalScrollbarBeforeRelayout(bool val) { 476 void setHadHorizontalScrollbarBeforeRelayout(bool val) {
471 m_hadHorizontalScrollbarBeforeRelayout = val; 477 m_hadHorizontalScrollbarBeforeRelayout = val;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 if (!m_rareData) 536 if (!m_rareData)
531 m_rareData = wrapUnique(new PaintLayerScrollableAreaRareData()); 537 m_rareData = wrapUnique(new PaintLayerScrollableAreaRareData());
532 return *m_rareData.get(); 538 return *m_rareData.get();
533 } 539 }
534 540
535 PaintLayer& m_layer; 541 PaintLayer& m_layer;
536 542
537 PaintLayer* m_nextTopmostScrollChild; 543 PaintLayer* m_nextTopmostScrollChild;
538 PaintLayer* m_topmostScrollChild; 544 PaintLayer* m_topmostScrollChild;
539 545
540 // Keeps track of whether the layer is currently resizing, so events can cause resizing to start and stop. 546 // Keeps track of whether the layer is currently resizing, so events can cause
547 // resizing to start and stop.
541 unsigned m_inResizeMode : 1; 548 unsigned m_inResizeMode : 1;
542 unsigned m_scrollsOverflow : 1; 549 unsigned m_scrollsOverflow : 1;
543 550
544 unsigned m_inOverflowRelayout : 1; 551 unsigned m_inOverflowRelayout : 1;
545 552
546 // FIXME: once cc can handle composited scrolling with clip paths, we will 553 // FIXME: once cc can handle composited scrolling with clip paths, we will
547 // no longer need this bit. 554 // no longer need this bit.
548 unsigned m_needsCompositedScrolling : 1; 555 unsigned m_needsCompositedScrolling : 1;
549 556
550 // Set to indicate that a scrollbar layer, if present, needs to be rebuilt 557 // Set to indicate that a scrollbar layer, if present, needs to be rebuilt
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 596
590 DEFINE_TYPE_CASTS(PaintLayerScrollableArea, 597 DEFINE_TYPE_CASTS(PaintLayerScrollableArea,
591 ScrollableArea, 598 ScrollableArea,
592 scrollableArea, 599 scrollableArea,
593 scrollableArea->isPaintLayerScrollableArea(), 600 scrollableArea->isPaintLayerScrollableArea(),
594 scrollableArea.isPaintLayerScrollableArea()); 601 scrollableArea.isPaintLayerScrollableArea());
595 602
596 } // namespace blink 603 } // namespace blink
597 604
598 #endif // LayerScrollableArea_h 605 #endif // LayerScrollableArea_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698