| 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 // When canDetachScrollbars is true, calls to setHas*Scrollbar(false) wi
ll NOT destroy |
| 88 // an existing scrollbar, but instead detach it without destroying it.
If, subsequently, |
| 89 // setHas*Scrollbar(true) is called, the existing scrollbar will be reat
tached. When |
| 90 // setCanDetachScrollbars(false) is called, any detached scrollbars will
be destructed. |
| 91 bool canDetachScrollbars() const { return m_canDetachScrollbars; } |
| 92 void setCanDetachScrollbars(bool); |
| 93 |
| 94 Scrollbar* horizontalScrollbar() const { return m_hBarIsAttached ? m_hBa
r.get(): nullptr; } |
| 95 Scrollbar* verticalScrollbar() const { return m_vBarIsAttached ? m_vBar.
get() : nullptr; } |
| 96 bool hasHorizontalScrollbar() const { return horizontalScrollbar(); } |
| 97 bool hasVerticalScrollbar() const { return verticalScrollbar(); } |
| 98 |
| 99 void setHasHorizontalScrollbar(bool hasScrollbar); |
| 100 void setHasVerticalScrollbar(bool hasScrollbar); |
| 101 |
| 102 DECLARE_TRACE(); |
| 103 |
| 104 private: |
| 105 PassRefPtrWillBeRawPtr<Scrollbar> createScrollbar(ScrollbarOrientation); |
| 106 void destroyScrollbar(ScrollbarOrientation, bool invalidate = false); |
| 107 |
| 108 private: |
| 109 DeprecatedPaintLayerScrollableArea& m_scrollableArea; |
| 110 RefPtrWillBeMember<Scrollbar> m_hBar; |
| 111 RefPtrWillBeMember<Scrollbar> m_vBar; |
| 112 unsigned m_canDetachScrollbars: 1; |
| 113 unsigned m_hBarIsAttached: 1; |
| 114 unsigned m_vBarIsAttached: 1; |
| 115 }; |
| 116 |
| 70 public: | 117 public: |
| 71 // FIXME: We should pass in the LayoutBox but this opens a window | 118 // FIXME: We should pass in the LayoutBox but this opens a window |
| 72 // for crashers during DeprecatedPaintLayer setup (see crbug.com/368062). | 119 // for crashers during DeprecatedPaintLayer setup (see crbug.com/368062). |
| 73 static PassOwnPtrWillBeRawPtr<DeprecatedPaintLayerScrollableArea> create(Dep
recatedPaintLayer& layer) | 120 static PassOwnPtrWillBeRawPtr<DeprecatedPaintLayerScrollableArea> create(Dep
recatedPaintLayer& layer) |
| 74 { | 121 { |
| 75 return adoptPtrWillBeNoop(new DeprecatedPaintLayerScrollableArea(layer))
; | 122 return adoptPtrWillBeNoop(new DeprecatedPaintLayerScrollableArea(layer))
; |
| 76 } | 123 } |
| 77 | 124 |
| 78 ~DeprecatedPaintLayerScrollableArea() override; | 125 ~DeprecatedPaintLayerScrollableArea() override; |
| 79 void dispose(); | 126 void dispose(); |
| 80 | 127 |
| 81 bool hasHorizontalScrollbar() const { return horizontalScrollbar(); } | 128 bool hasHorizontalScrollbar() const { return horizontalScrollbar(); } |
| 82 bool hasVerticalScrollbar() const { return verticalScrollbar(); } | 129 bool hasVerticalScrollbar() const { return verticalScrollbar(); } |
| 83 | 130 |
| 84 Scrollbar* horizontalScrollbar() const override { return m_hBar.get(); } | 131 Scrollbar* horizontalScrollbar() const override { return m_scrollbarManager.
horizontalScrollbar(); } |
| 85 Scrollbar* verticalScrollbar() const override { return m_vBar.get(); } | 132 Scrollbar* verticalScrollbar() const override { return m_scrollbarManager.ve
rticalScrollbar(); } |
| 86 | 133 |
| 87 HostWindow* hostWindow() const override; | 134 HostWindow* hostWindow() const override; |
| 88 | 135 |
| 89 GraphicsLayer* layerForScrolling() const override; | 136 GraphicsLayer* layerForScrolling() const override; |
| 90 GraphicsLayer* layerForHorizontalScrollbar() const override; | 137 GraphicsLayer* layerForHorizontalScrollbar() const override; |
| 91 GraphicsLayer* layerForVerticalScrollbar() const override; | 138 GraphicsLayer* layerForVerticalScrollbar() const override; |
| 92 GraphicsLayer* layerForScrollCorner() const override; | 139 GraphicsLayer* layerForScrollCorner() const override; |
| 93 bool usesCompositedScrolling() const override; | 140 bool usesCompositedScrolling() const override; |
| 94 void invalidateScrollbarRect(Scrollbar*, const IntRect&) override; | 141 void invalidateScrollbarRect(Scrollbar*, const IntRect&) override; |
| 95 void invalidateScrollCornerRect(const IntRect&) override; | 142 void invalidateScrollCornerRect(const IntRect&) override; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 | 202 |
| 156 void updateScrollDimensions(DoubleSize& scrollOffset, bool& autoHorizontalSc
rollBarChanged, bool& autoVerticalScrollBarChanged); | 203 void updateScrollDimensions(DoubleSize& scrollOffset, bool& autoHorizontalSc
rollBarChanged, bool& autoVerticalScrollBarChanged); |
| 157 void finalizeScrollDimensions(const DoubleSize& originalScrollOffset, bool a
utoHorizontalScrollBarChanged, bool autoVerticalScrollBarChanged); | 204 void finalizeScrollDimensions(const DoubleSize& originalScrollOffset, bool a
utoHorizontalScrollBarChanged, bool autoVerticalScrollBarChanged); |
| 158 | 205 |
| 159 void updateAfterLayout(); | 206 void updateAfterLayout(); |
| 160 void updateAfterStyleChange(const ComputedStyle*); | 207 void updateAfterStyleChange(const ComputedStyle*); |
| 161 void updateAfterOverflowRecalc(); | 208 void updateAfterOverflowRecalc(); |
| 162 | 209 |
| 163 bool updateAfterCompositingChange() override; | 210 bool updateAfterCompositingChange() override; |
| 164 | 211 |
| 165 bool hasScrollbar() const { return m_hBar || m_vBar; } | 212 bool hasScrollbar() const { return hasHorizontalScrollbar() || hasVerticalSc
rollbar(); } |
| 166 | 213 |
| 167 LayoutScrollbarPart* scrollCorner() const { return m_scrollCorner; } | 214 LayoutScrollbarPart* scrollCorner() const { return m_scrollCorner; } |
| 168 | 215 |
| 169 void resize(const PlatformEvent&, const LayoutSize&); | 216 void resize(const PlatformEvent&, const LayoutSize&); |
| 170 IntSize offsetFromResizeCorner(const IntPoint& absolutePoint) const; | 217 IntSize offsetFromResizeCorner(const IntPoint& absolutePoint) const; |
| 171 | 218 |
| 172 bool inResizeMode() const { return m_inResizeMode; } | 219 bool inResizeMode() const { return m_inResizeMode; } |
| 173 void setInResizeMode(bool inResizeMode) { m_inResizeMode = inResizeMode; } | 220 void setInResizeMode(bool inResizeMode) { m_inResizeMode = inResizeMode; } |
| 174 | 221 |
| 175 IntRect touchResizerCornerRect(const IntRect& bounds) const | 222 IntRect touchResizerCornerRect(const IntRect& bounds) const |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 | 294 |
| 248 void computeScrollDimensions(); | 295 void computeScrollDimensions(); |
| 249 | 296 |
| 250 void setScrollOffset(const IntPoint&, ScrollType) override; | 297 void setScrollOffset(const IntPoint&, ScrollType) override; |
| 251 void setScrollOffset(const DoublePoint&, ScrollType) override; | 298 void setScrollOffset(const DoublePoint&, ScrollType) override; |
| 252 | 299 |
| 253 LayoutUnit verticalScrollbarStart(int minX, int maxX) const; | 300 LayoutUnit verticalScrollbarStart(int minX, int maxX) const; |
| 254 LayoutUnit horizontalScrollbarStart(int minX) const; | 301 LayoutUnit horizontalScrollbarStart(int minX) const; |
| 255 IntSize scrollbarOffset(const Scrollbar*) const; | 302 IntSize scrollbarOffset(const Scrollbar*) const; |
| 256 | 303 |
| 257 PassRefPtrWillBeRawPtr<Scrollbar> createScrollbar(ScrollbarOrientation); | |
| 258 void destroyScrollbar(ScrollbarOrientation); | |
| 259 | |
| 260 void setHasHorizontalScrollbar(bool hasScrollbar); | 304 void setHasHorizontalScrollbar(bool hasScrollbar); |
| 261 void setHasVerticalScrollbar(bool hasScrollbar); | 305 void setHasVerticalScrollbar(bool hasScrollbar); |
| 262 | 306 |
| 263 void updateScrollCornerStyle(); | 307 void updateScrollCornerStyle(); |
| 264 | 308 |
| 265 // See comments on isPointInResizeControl. | 309 // See comments on isPointInResizeControl. |
| 266 void updateResizerAreaSet(); | 310 void updateResizerAreaSet(); |
| 267 void updateResizerStyle(); | 311 void updateResizerStyle(); |
| 268 | 312 |
| 269 | 313 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 282 DeprecatedPaintLayer* m_nextTopmostScrollChild; | 326 DeprecatedPaintLayer* m_nextTopmostScrollChild; |
| 283 DeprecatedPaintLayer* m_topmostScrollChild; | 327 DeprecatedPaintLayer* m_topmostScrollChild; |
| 284 | 328 |
| 285 // FIXME: once cc can handle composited scrolling with clip paths, we will | 329 // FIXME: once cc can handle composited scrolling with clip paths, we will |
| 286 // no longer need this bit. | 330 // no longer need this bit. |
| 287 unsigned m_needsCompositedScrolling : 1; | 331 unsigned m_needsCompositedScrolling : 1; |
| 288 | 332 |
| 289 // The width/height of our scrolled area. | 333 // The width/height of our scrolled area. |
| 290 LayoutRect m_overflowRect; | 334 LayoutRect m_overflowRect; |
| 291 | 335 |
| 336 // ScrollbarManager holds the Scrollbar instances. |
| 337 ScrollbarManager m_scrollbarManager; |
| 338 |
| 292 // This is the (scroll) offset from scrollOrigin(). | 339 // This is the (scroll) offset from scrollOrigin(). |
| 293 DoubleSize m_scrollOffset; | 340 DoubleSize m_scrollOffset; |
| 294 | 341 |
| 295 IntPoint m_cachedOverlayScrollbarOffset; | 342 IntPoint m_cachedOverlayScrollbarOffset; |
| 296 | 343 |
| 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. | 344 // LayoutObject to hold our custom scroll corner. |
| 302 LayoutScrollbarPart* m_scrollCorner; | 345 LayoutScrollbarPart* m_scrollCorner; |
| 303 | 346 |
| 304 // LayoutObject to hold our custom resizer. | 347 // LayoutObject to hold our custom resizer. |
| 305 LayoutScrollbarPart* m_resizer; | 348 LayoutScrollbarPart* m_resizer; |
| 306 | 349 |
| 307 #if ENABLE(ASSERT) | 350 #if ENABLE(ASSERT) |
| 308 bool m_hasBeenDisposed; | 351 bool m_hasBeenDisposed; |
| 309 #endif | 352 #endif |
| 310 }; | 353 }; |
| 311 | 354 |
| 312 } // namespace blink | 355 } // namespace blink |
| 313 | 356 |
| 314 #endif // LayerScrollableArea_h | 357 #endif // LayerScrollableArea_h |
| OLD | NEW |