| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef ScrollbarManager_h | |
| 6 #define ScrollbarManager_h | |
| 7 | |
| 8 #include "core/CoreExport.h" | |
| 9 #include "platform/scroll/ScrollableArea.h" | |
| 10 | |
| 11 namespace blink { | |
| 12 | |
| 13 class CORE_EXPORT ScrollbarManager { | |
| 14 DISALLOW_NEW(); | |
| 15 | |
| 16 // Helper class to manage the life cycle of Scrollbar objects. | |
| 17 public: | |
| 18 ScrollbarManager(ScrollableArea&); | |
| 19 | |
| 20 void Dispose(); | |
| 21 | |
| 22 Scrollbar* HorizontalScrollbar() const { | |
| 23 return h_bar_is_attached_ ? h_bar_.Get() : nullptr; | |
| 24 } | |
| 25 Scrollbar* VerticalScrollbar() const { | |
| 26 return v_bar_is_attached_ ? v_bar_.Get() : nullptr; | |
| 27 } | |
| 28 bool HasHorizontalScrollbar() const { return HorizontalScrollbar(); } | |
| 29 bool HasVerticalScrollbar() const { return VerticalScrollbar(); } | |
| 30 | |
| 31 // These functions are used to create/destroy scrollbars. | |
| 32 virtual void SetHasHorizontalScrollbar(bool has_scrollbar) = 0; | |
| 33 virtual void SetHasVerticalScrollbar(bool has_scrollbar) = 0; | |
| 34 | |
| 35 DECLARE_VIRTUAL_TRACE(); | |
| 36 | |
| 37 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; | |
| 41 virtual void DestroyScrollbar(ScrollbarOrientation) = 0; | |
| 42 | |
| 43 protected: | |
| 44 Member<ScrollableArea> scrollable_area_; | |
| 45 | |
| 46 // The scrollbars associated with m_scrollableArea. Both can nullptr. | |
| 47 Member<Scrollbar> h_bar_; | |
| 48 Member<Scrollbar> v_bar_; | |
| 49 | |
| 50 unsigned h_bar_is_attached_ : 1; | |
| 51 unsigned v_bar_is_attached_ : 1; | |
| 52 }; | |
| 53 | |
| 54 } // namespace blink | |
| 55 | |
| 56 #endif // ScrollbarManager_h | |
| OLD | NEW |