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