OLD | NEW |
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 class PlatformEvent; | 60 class PlatformEvent; |
61 class LayoutBox; | 61 class LayoutBox; |
62 class DeprecatedPaintLayer; | 62 class DeprecatedPaintLayer; |
63 class LayoutScrollbarPart; | 63 class LayoutScrollbarPart; |
64 | 64 |
65 class CORE_EXPORT DeprecatedPaintLayerScrollableArea final : public NoBaseWillBe
GarbageCollectedFinalized<DeprecatedPaintLayerScrollableArea>, public Scrollable
Area { | 65 class CORE_EXPORT DeprecatedPaintLayerScrollableArea final : public NoBaseWillBe
GarbageCollectedFinalized<DeprecatedPaintLayerScrollableArea>, public Scrollable
Area { |
66 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED(DeprecatedPaintLayerScrollableArea); | 66 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED(DeprecatedPaintLayerScrollableArea); |
67 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(DeprecatedPaintLayerScrollableArea); | 67 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(DeprecatedPaintLayerScrollableArea); |
68 friend class Internals; | 68 friend class Internals; |
69 | 69 |
| 70 private: |
| 71 class ScrollbarManager { |
| 72 // Helper class to manage the life cycle of Scrollbar objects. Some lay
out containers |
| 73 // (e.g., flexbox, table) run multi-pass layout on their children, apply
ing different |
| 74 // constraints. If a child has overflow:auto, it may gain and lose scro
llbars multiple |
| 75 // times during multi-pass layout, causing pointless allocation/dealloca
tion thrashing, |
| 76 // and potentially leading to other problems (crbug.com/528940). |
| 77 |
| 78 // ScrollbarManager allows a ScrollableArea to delay the destruction of
a scrollbar that |
| 79 // is no longer needed, until the end of multi-pass layout. If the scro
llbar is then |
| 80 // re-added before multi-pass layout finishes, the previously "deleted"
scrollbar will |
| 81 // be restored, rather than constructing a new one. |
| 82 public: |
| 83 ScrollbarManager(DeprecatedPaintLayerScrollableArea&); |
| 84 |
| 85 void dispose(); |
| 86 |
| 87 bool supressScrollbars() const { return m_suppressScrollbars; } |
| 88 void setSuppressScrollbars(bool); |
| 89 Scrollbar* horizontalScrollbar() const { return m_hBarIsSuppressed ? nul
lptr : m_hBar.get(); } |
| 90 Scrollbar* verticalScrollbar() const { return m_vBarIsSuppressed ? nullp
tr : m_vBar.get(); } |
| 91 bool hasHorizontalScrollbar() const { return horizontalScrollbar(); } |
| 92 bool hasVerticalScrollbar() const { return verticalScrollbar(); } |
| 93 |
| 94 void setHasHorizontalScrollbar(bool hasScrollbar); |
| 95 void setHasVerticalScrollbar(bool hasScrollbar); |
| 96 |
| 97 DECLARE_TRACE(); |
| 98 |
| 99 private: |
| 100 PassRefPtrWillBeRawPtr<Scrollbar> createScrollbar(ScrollbarOrientation); |
| 101 void destroyScrollbar(ScrollbarOrientation); |
| 102 |
| 103 private: |
| 104 DeprecatedPaintLayerScrollableArea& m_scrollableArea; |
| 105 RefPtrWillBeMember<Scrollbar> m_hBar; |
| 106 RefPtrWillBeMember<Scrollbar> m_vBar; |
| 107 unsigned m_suppressScrollbars: 1; |
| 108 unsigned m_hBarIsSuppressed: 1; |
| 109 unsigned m_vBarIsSuppressed: 1; |
| 110 }; |
| 111 |
70 public: | 112 public: |
71 // FIXME: We should pass in the LayoutBox but this opens a window | 113 // FIXME: We should pass in the LayoutBox but this opens a window |
72 // for crashers during DeprecatedPaintLayer setup (see crbug.com/368062). | 114 // for crashers during DeprecatedPaintLayer setup (see crbug.com/368062). |
73 static PassOwnPtrWillBeRawPtr<DeprecatedPaintLayerScrollableArea> create(Dep
recatedPaintLayer& layer) | 115 static PassOwnPtrWillBeRawPtr<DeprecatedPaintLayerScrollableArea> create(Dep
recatedPaintLayer& layer) |
74 { | 116 { |
75 return adoptPtrWillBeNoop(new DeprecatedPaintLayerScrollableArea(layer))
; | 117 return adoptPtrWillBeNoop(new DeprecatedPaintLayerScrollableArea(layer))
; |
76 } | 118 } |
77 | 119 |
78 ~DeprecatedPaintLayerScrollableArea() override; | 120 ~DeprecatedPaintLayerScrollableArea() override; |
79 void dispose(); | 121 void dispose(); |
80 | 122 |
81 bool hasHorizontalScrollbar() const { return horizontalScrollbar(); } | 123 bool hasHorizontalScrollbar() const { return horizontalScrollbar(); } |
82 bool hasVerticalScrollbar() const { return verticalScrollbar(); } | 124 bool hasVerticalScrollbar() const { return verticalScrollbar(); } |
83 | 125 |
84 Scrollbar* horizontalScrollbar() const override { return m_hBar.get(); } | 126 Scrollbar* horizontalScrollbar() const override { return m_scrollbarManager.
horizontalScrollbar(); } |
85 Scrollbar* verticalScrollbar() const override { return m_vBar.get(); } | 127 Scrollbar* verticalScrollbar() const override { return m_scrollbarManager.ve
rticalScrollbar(); } |
86 | 128 |
87 HostWindow* hostWindow() const override; | 129 HostWindow* hostWindow() const override; |
88 | 130 |
89 GraphicsLayer* layerForScrolling() const override; | 131 GraphicsLayer* layerForScrolling() const override; |
90 GraphicsLayer* layerForHorizontalScrollbar() const override; | 132 GraphicsLayer* layerForHorizontalScrollbar() const override; |
91 GraphicsLayer* layerForVerticalScrollbar() const override; | 133 GraphicsLayer* layerForVerticalScrollbar() const override; |
92 GraphicsLayer* layerForScrollCorner() const override; | 134 GraphicsLayer* layerForScrollCorner() const override; |
93 bool usesCompositedScrolling() const override; | 135 bool usesCompositedScrolling() const override; |
94 void invalidateScrollbarRect(Scrollbar*, const IntRect&) override; | 136 void invalidateScrollbarRect(Scrollbar*, const IntRect&) override; |
95 void invalidateScrollCornerRect(const IntRect&) override; | 137 void invalidateScrollCornerRect(const IntRect&) override; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 | 197 |
156 void updateScrollDimensions(DoubleSize& scrollOffset, bool& autoHorizontalSc
rollBarChanged, bool& autoVerticalScrollBarChanged); | 198 void updateScrollDimensions(DoubleSize& scrollOffset, bool& autoHorizontalSc
rollBarChanged, bool& autoVerticalScrollBarChanged); |
157 void finalizeScrollDimensions(const DoubleSize& originalScrollOffset, bool a
utoHorizontalScrollBarChanged, bool autoVerticalScrollBarChanged); | 199 void finalizeScrollDimensions(const DoubleSize& originalScrollOffset, bool a
utoHorizontalScrollBarChanged, bool autoVerticalScrollBarChanged); |
158 | 200 |
159 void updateAfterLayout(); | 201 void updateAfterLayout(); |
160 void updateAfterStyleChange(const ComputedStyle*); | 202 void updateAfterStyleChange(const ComputedStyle*); |
161 void updateAfterOverflowRecalc(); | 203 void updateAfterOverflowRecalc(); |
162 | 204 |
163 bool updateAfterCompositingChange() override; | 205 bool updateAfterCompositingChange() override; |
164 | 206 |
165 bool hasScrollbar() const { return m_hBar || m_vBar; } | 207 bool hasScrollbar() const { return hasHorizontalScrollbar() || hasVerticalSc
rollbar(); } |
166 | 208 |
167 LayoutScrollbarPart* scrollCorner() const { return m_scrollCorner; } | 209 LayoutScrollbarPart* scrollCorner() const { return m_scrollCorner; } |
168 | 210 |
169 void resize(const PlatformEvent&, const LayoutSize&); | 211 void resize(const PlatformEvent&, const LayoutSize&); |
170 IntSize offsetFromResizeCorner(const IntPoint& absolutePoint) const; | 212 IntSize offsetFromResizeCorner(const IntPoint& absolutePoint) const; |
171 | 213 |
172 bool inResizeMode() const { return m_inResizeMode; } | 214 bool inResizeMode() const { return m_inResizeMode; } |
173 void setInResizeMode(bool inResizeMode) { m_inResizeMode = inResizeMode; } | 215 void setInResizeMode(bool inResizeMode) { m_inResizeMode = inResizeMode; } |
174 | 216 |
175 IntRect touchResizerCornerRect(const IntRect& bounds) const | 217 IntRect touchResizerCornerRect(const IntRect& bounds) const |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 | 289 |
248 void computeScrollDimensions(); | 290 void computeScrollDimensions(); |
249 | 291 |
250 void setScrollOffset(const IntPoint&, ScrollType) override; | 292 void setScrollOffset(const IntPoint&, ScrollType) override; |
251 void setScrollOffset(const DoublePoint&, ScrollType) override; | 293 void setScrollOffset(const DoublePoint&, ScrollType) override; |
252 | 294 |
253 LayoutUnit verticalScrollbarStart(int minX, int maxX) const; | 295 LayoutUnit verticalScrollbarStart(int minX, int maxX) const; |
254 LayoutUnit horizontalScrollbarStart(int minX) const; | 296 LayoutUnit horizontalScrollbarStart(int minX) const; |
255 IntSize scrollbarOffset(const Scrollbar*) const; | 297 IntSize scrollbarOffset(const Scrollbar*) const; |
256 | 298 |
257 PassRefPtrWillBeRawPtr<Scrollbar> createScrollbar(ScrollbarOrientation); | |
258 void destroyScrollbar(ScrollbarOrientation); | |
259 | |
260 void setHasHorizontalScrollbar(bool hasScrollbar); | 299 void setHasHorizontalScrollbar(bool hasScrollbar); |
261 void setHasVerticalScrollbar(bool hasScrollbar); | 300 void setHasVerticalScrollbar(bool hasScrollbar); |
262 | 301 |
263 void updateScrollCornerStyle(); | 302 void updateScrollCornerStyle(); |
264 | 303 |
265 // See comments on isPointInResizeControl. | 304 // See comments on isPointInResizeControl. |
266 void updateResizerAreaSet(); | 305 void updateResizerAreaSet(); |
267 void updateResizerStyle(); | 306 void updateResizerStyle(); |
268 | 307 |
269 | 308 |
(...skipping 12 matching lines...) Expand all Loading... |
282 DeprecatedPaintLayer* m_nextTopmostScrollChild; | 321 DeprecatedPaintLayer* m_nextTopmostScrollChild; |
283 DeprecatedPaintLayer* m_topmostScrollChild; | 322 DeprecatedPaintLayer* m_topmostScrollChild; |
284 | 323 |
285 // FIXME: once cc can handle composited scrolling with clip paths, we will | 324 // FIXME: once cc can handle composited scrolling with clip paths, we will |
286 // no longer need this bit. | 325 // no longer need this bit. |
287 unsigned m_needsCompositedScrolling : 1; | 326 unsigned m_needsCompositedScrolling : 1; |
288 | 327 |
289 // The width/height of our scrolled area. | 328 // The width/height of our scrolled area. |
290 LayoutRect m_overflowRect; | 329 LayoutRect m_overflowRect; |
291 | 330 |
| 331 // ScrollbarManager holds the Scrollbar instances. |
| 332 ScrollbarManager m_scrollbarManager; |
| 333 |
292 // This is the (scroll) offset from scrollOrigin(). | 334 // This is the (scroll) offset from scrollOrigin(). |
293 DoubleSize m_scrollOffset; | 335 DoubleSize m_scrollOffset; |
294 | 336 |
295 IntPoint m_cachedOverlayScrollbarOffset; | 337 IntPoint m_cachedOverlayScrollbarOffset; |
296 | 338 |
297 // For areas with overflow, we have a pair of scrollbars. | |
298 RefPtrWillBeMember<Scrollbar> m_hBar; | |
299 RefPtrWillBeMember<Scrollbar> m_vBar; | |
300 | |
301 // LayoutObject to hold our custom scroll corner. | 339 // LayoutObject to hold our custom scroll corner. |
302 LayoutScrollbarPart* m_scrollCorner; | 340 LayoutScrollbarPart* m_scrollCorner; |
303 | 341 |
304 // LayoutObject to hold our custom resizer. | 342 // LayoutObject to hold our custom resizer. |
305 LayoutScrollbarPart* m_resizer; | 343 LayoutScrollbarPart* m_resizer; |
306 | 344 |
307 #if ENABLE(ASSERT) | 345 #if ENABLE(ASSERT) |
308 bool m_hasBeenDisposed; | 346 bool m_hasBeenDisposed; |
309 #endif | 347 #endif |
310 }; | 348 }; |
311 | 349 |
312 } // namespace blink | 350 } // namespace blink |
313 | 351 |
314 #endif // LayerScrollableArea_h | 352 #endif // LayerScrollableArea_h |
OLD | NEW |