| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef ScrollbarManager_h | 5 #ifndef ScrollbarManager_h |
| 6 #define ScrollbarManager_h | 6 #define ScrollbarManager_h |
| 7 | 7 |
| 8 #include "core/CoreExport.h" | 8 #include "platform/PlatformExport.h" |
| 9 #include "platform/scroll/ScrollableArea.h" | 9 #include "platform/heap/Handle.h" |
| 10 #include "platform/scroll/ScrollTypes.h" |
| 11 #include "platform/scroll/Scrollbar.h" |
| 10 | 12 |
| 11 namespace blink { | 13 namespace blink { |
| 12 | 14 |
| 13 class CORE_EXPORT ScrollbarManager { | 15 class PLATFORM_EXPORT ScrollbarManager |
| 16 : public GarbageCollectedFinalized<ScrollbarManager> { |
| 14 DISALLOW_NEW(); | 17 DISALLOW_NEW(); |
| 15 | 18 |
| 16 // Helper class to manage the life cycle of Scrollbar objects. | 19 // Helper class to manage the life cycle of Scrollbar objects. |
| 17 public: | 20 public: |
| 18 ScrollbarManager(ScrollableArea&); | 21 ScrollbarManager(); |
| 22 virtual ~ScrollbarManager(); |
| 19 | 23 |
| 20 void Dispose(); | 24 void Dispose(); |
| 21 | 25 |
| 22 Scrollbar* HorizontalScrollbar() const { | 26 Scrollbar* HorizontalScrollbar() const { |
| 23 return h_bar_is_attached_ ? h_bar_.Get() : nullptr; | 27 return h_bar_is_attached_ ? h_bar_ : nullptr; |
| 24 } | 28 } |
| 25 Scrollbar* VerticalScrollbar() const { | 29 Scrollbar* VerticalScrollbar() const { |
| 26 return v_bar_is_attached_ ? v_bar_.Get() : nullptr; | 30 return v_bar_is_attached_ ? v_bar_ : nullptr; |
| 27 } | 31 } |
| 28 bool HasHorizontalScrollbar() const { return HorizontalScrollbar(); } | 32 bool HasHorizontalScrollbar() const { return HorizontalScrollbar(); } |
| 29 bool HasVerticalScrollbar() const { return VerticalScrollbar(); } | 33 bool HasVerticalScrollbar() const { return VerticalScrollbar(); } |
| 30 | 34 |
| 31 // These functions are used to create/destroy scrollbars. | 35 // These functions are used to create/destroy scrollbars. |
| 32 virtual void SetHasHorizontalScrollbar(bool has_scrollbar) = 0; | 36 virtual void SetHasHorizontalScrollbar(bool has_scrollbar) = 0; |
| 33 virtual void SetHasVerticalScrollbar(bool has_scrollbar) = 0; | 37 virtual void SetHasVerticalScrollbar(bool has_scrollbar) = 0; |
| 34 | 38 |
| 35 DECLARE_VIRTUAL_TRACE(); | 39 DECLARE_VIRTUAL_TRACE(); |
| 36 | 40 |
| 37 protected: | 41 protected: |
| 38 // TODO(ymalik): This can be made non-virtual since there's a lot of | |
| 39 // common code in subclasses. | |
| 40 virtual Scrollbar* CreateScrollbar(ScrollbarOrientation) = 0; | 42 virtual Scrollbar* CreateScrollbar(ScrollbarOrientation) = 0; |
| 41 virtual void DestroyScrollbar(ScrollbarOrientation) = 0; | 43 virtual void DestroyScrollbar(ScrollbarOrientation) = 0; |
| 42 | 44 |
| 43 protected: | 45 protected: |
| 44 Member<ScrollableArea> scrollable_area_; | |
| 45 | |
| 46 // The scrollbars associated with m_scrollableArea. Both can nullptr. | 46 // The scrollbars associated with m_scrollableArea. Both can nullptr. |
| 47 Member<Scrollbar> h_bar_; | 47 Member<Scrollbar> h_bar_; |
| 48 Member<Scrollbar> v_bar_; | 48 Member<Scrollbar> v_bar_; |
| 49 | 49 |
| 50 unsigned h_bar_is_attached_ : 1; | 50 bool h_bar_is_attached_; |
| 51 unsigned v_bar_is_attached_ : 1; | 51 bool v_bar_is_attached_; |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 } // namespace blink | 54 } // namespace blink |
| 55 | 55 |
| 56 #endif // ScrollbarManager_h | 56 #endif // ScrollbarManager_h |
| OLD | NEW |