Chromium Code Reviews| 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 #include "core/paint/ScrollbarManager.h" | 5 #include "core/paint/ScrollbarManager.h" |
| 6 | 6 |
| 7 #include "core/frame/LocalFrame.h" | |
| 8 #include "core/frame/LocalFrameView.h" | |
| 9 #include "core/layout/LayoutBox.h" | |
| 10 #include "core/layout/LayoutObject.h" | |
| 11 #include "core/layout/LayoutScrollbar.h" | |
| 12 #include "core/layout/LayoutTheme.h" | |
| 13 #include "core/page/ChromeClient.h" | |
| 14 #include "core/page/Page.h" | |
| 15 #include "core/paint/PaintLayerScrollableArea.h" | |
| 16 | |
| 7 namespace blink { | 17 namespace blink { |
| 8 | 18 |
| 9 ScrollbarManager::ScrollbarManager(ScrollableArea& scrollable_area) | 19 ScrollbarManager::ScrollbarManager(ScrollableArea& scrollable_area) |
| 10 : scrollable_area_(&scrollable_area), | 20 : scrollable_area_(&scrollable_area), |
| 11 h_bar_is_attached_(0), | 21 h_bar_is_attached_(0), |
| 12 v_bar_is_attached_(0) {} | 22 v_bar_is_attached_(0) {} |
| 13 | 23 |
| 14 DEFINE_TRACE(ScrollbarManager) { | 24 DEFINE_TRACE(ScrollbarManager) { |
| 15 visitor->Trace(scrollable_area_); | 25 visitor->Trace(scrollable_area_); |
| 16 visitor->Trace(h_bar_); | 26 visitor->Trace(h_bar_); |
| 17 visitor->Trace(v_bar_); | 27 visitor->Trace(v_bar_); |
| 18 } | 28 } |
| 19 | 29 |
| 20 void ScrollbarManager::Dispose() { | 30 void ScrollbarManager::Dispose() { |
| 21 h_bar_is_attached_ = v_bar_is_attached_ = 0; | 31 h_bar_is_attached_ = v_bar_is_attached_ = 0; |
| 22 DestroyScrollbar(kHorizontalScrollbar); | 32 DestroyScrollbar(kHorizontalScrollbar); |
| 23 DestroyScrollbar(kVerticalScrollbar); | 33 DestroyScrollbar(kVerticalScrollbar); |
| 24 } | 34 } |
| 25 | 35 |
| 36 Scrollbar* ScrollbarManager::CreateScrollbar(ScrollbarOrientation orientation) { | |
|
szager1
2017/06/27 20:42:13
All of this logic could be moved into PLSA and Fra
| |
| 37 DCHECK(scrollable_area_->GetLayoutBox()); | |
| 38 DCHECK(orientation == kHorizontalScrollbar ? !h_bar_is_attached_ | |
| 39 : !v_bar_is_attached_); | |
| 40 LayoutObject* actual_layout_object = nullptr; | |
|
bokan
2017/06/27 17:48:52
layout_object_for_style
| |
| 41 | |
| 42 Scrollbar* scrollbar = nullptr; | |
| 43 if (scrollable_area_->ShouldUseCustomScrollbars(actual_layout_object)) { | |
| 44 scrollbar = LayoutScrollbar::CreateCustomScrollbar( | |
| 45 scrollable_area_.Get(), orientation, | |
| 46 ToElement(actual_layout_object->GetNode())); | |
|
bokan
2017/06/27 17:48:52
Add a DCHECK that if we're using custom scrollbars
| |
| 47 } else { | |
| 48 ScrollbarControlSize scrollbar_size = kRegularScrollbar; | |
| 49 | |
| 50 if (actual_layout_object && | |
| 51 actual_layout_object->StyleRef().HasAppearance() && | |
| 52 scrollable_area_->IsPaintLayerScrollableArea()) { | |
| 53 scrollbar_size = LayoutTheme::GetTheme().ScrollbarControlSizeForPart( | |
| 54 actual_layout_object->StyleRef().Appearance()); | |
| 55 } | |
| 56 | |
| 57 scrollbar = | |
| 58 Scrollbar::Create(scrollable_area_.Get(), orientation, scrollbar_size, | |
| 59 &scrollable_area_->GetLayoutBox() | |
| 60 ->GetFrame() | |
| 61 ->GetPage() | |
| 62 ->GetChromeClient()); | |
| 63 } | |
| 64 | |
| 65 scrollable_area_->GetLayoutBox()->GetDocument().View()->AddScrollbar( | |
| 66 scrollbar); | |
| 67 | |
| 68 return scrollbar; | |
| 69 } | |
| 70 | |
| 71 void ScrollbarManager::DestroyScrollbar(ScrollbarOrientation orientation) { | |
| 72 Member<Scrollbar>& scrollbar = | |
| 73 orientation == kHorizontalScrollbar ? h_bar_ : v_bar_; | |
| 74 DCHECK(orientation == kHorizontalScrollbar ? !h_bar_is_attached_ | |
| 75 : !v_bar_is_attached_); | |
| 76 if (!scrollbar) | |
| 77 return; | |
| 78 | |
| 79 scrollable_area_->WillRemoveScrollbar(*scrollbar, orientation); | |
|
bokan
2017/06/27 17:48:52
This used to only be called only for non-custom sc
| |
| 80 | |
| 81 scrollable_area_->GetLayoutBox()->GetDocument().View()->RemoveScrollbar( | |
| 82 scrollbar); | |
| 83 | |
| 84 scrollbar->DisconnectFromScrollableArea(); | |
| 85 scrollbar = nullptr; | |
| 86 } | |
| 87 | |
| 26 } // namespace blink | 88 } // namespace blink |
| OLD | NEW |