Index: third_party/WebKit/Source/core/frame/LocalFrameView.cpp |
diff --git a/third_party/WebKit/Source/core/frame/LocalFrameView.cpp b/third_party/WebKit/Source/core/frame/LocalFrameView.cpp |
index a816e48dba6d190e37d8f8606c0d2192ddcc3439..e16c611dd3cc5a674d1bcff82cfab9fb0f16390d 100644 |
--- a/third_party/WebKit/Source/core/frame/LocalFrameView.cpp |
+++ b/third_party/WebKit/Source/core/frame/LocalFrameView.cpp |
@@ -477,36 +477,6 @@ void LocalFrameView::ScrollbarManager::SetHasVerticalScrollbar( |
scrollable_area_->SetScrollCornerNeedsPaintInvalidation(); |
} |
-Scrollbar* LocalFrameView::ScrollbarManager::CreateScrollbar( |
- ScrollbarOrientation orientation) { |
- Element* custom_scrollbar_element = nullptr; |
- LayoutBox* box = scrollable_area_->GetLayoutBox(); |
- if (box->GetDocument().View()->ShouldUseCustomScrollbars( |
- custom_scrollbar_element)) { |
- return LayoutScrollbar::CreateCustomScrollbar( |
- scrollable_area_.Get(), orientation, custom_scrollbar_element); |
- } |
- |
- // Nobody set a custom style, so we just use a native scrollbar. |
- return Scrollbar::Create(scrollable_area_.Get(), orientation, |
- kRegularScrollbar, |
- &box->GetFrame()->GetPage()->GetChromeClient()); |
-} |
- |
-void LocalFrameView::ScrollbarManager::DestroyScrollbar( |
- ScrollbarOrientation orientation) { |
- Member<Scrollbar>& scrollbar = |
- orientation == kHorizontalScrollbar ? h_bar_ : v_bar_; |
- DCHECK(orientation == kHorizontalScrollbar ? !h_bar_is_attached_ |
- : !v_bar_is_attached_); |
- if (!scrollbar) |
- return; |
- |
- scrollable_area_->WillRemoveScrollbar(*scrollbar, orientation); |
- scrollbar->DisconnectFromScrollableArea(); |
- scrollbar = nullptr; |
-} |
- |
void LocalFrameView::RecalculateCustomScrollbarStyle() { |
bool did_style_change = false; |
if (HorizontalScrollbar() && HorizontalScrollbar()->IsCustomScrollbar()) { |
@@ -681,35 +651,12 @@ void LocalFrameView::SetCanHaveScrollbars(bool can_have_scrollbars) { |
SetScrollbarModes(new_horizontal_mode, new_vertical_mode); |
} |
-bool LocalFrameView::ShouldUseCustomScrollbars( |
- Element*& custom_scrollbar_element) const { |
- custom_scrollbar_element = nullptr; |
- |
- if (Settings* settings = frame_->GetSettings()) { |
- if (!settings->GetAllowCustomScrollbarInMainFrame() && |
- frame_->IsMainFrame()) |
- return false; |
- } |
- Document* doc = frame_->GetDocument(); |
- |
- // Try the <body> element first as a scrollbar source. |
- Element* body = doc ? doc->body() : 0; |
- if (body && body->GetLayoutObject() && |
- body->GetLayoutObject()->Style()->HasPseudoStyle(kPseudoIdScrollbar)) { |
- custom_scrollbar_element = body; |
- return true; |
- } |
- |
- // If the <body> didn't have a custom style, then the root element might. |
- Element* doc_element = doc ? doc->documentElement() : 0; |
- if (doc_element && doc_element->GetLayoutObject() && |
- doc_element->GetLayoutObject()->Style()->HasPseudoStyle( |
- kPseudoIdScrollbar)) { |
- custom_scrollbar_element = doc_element; |
- return true; |
- } |
+LayoutObject* LocalFrameView::LayoutObjectForScrollbarStyle() const { |
+ LayoutViewItem layout_view_item = GetLayoutViewItem(); |
+ if (layout_view_item.IsNull()) |
+ return nullptr; |
- return false; |
+ return layout_view_item.GetScrollableArea()->LayoutObjectForScrollbarStyle(); |
} |
Scrollbar* LocalFrameView::CreateScrollbar(ScrollbarOrientation orientation) { |
@@ -2190,11 +2137,10 @@ void LocalFrameView::ScrollbarExistenceMaybeChanged() { |
if (!GetFrame().View()) |
return; |
- Element* custom_scrollbar_element = nullptr; |
- |
+ LayoutObject* style_source = LayoutObjectForScrollbarStyle(); |
bool uses_overlay_scrollbars = |
ScrollbarTheme::GetTheme().UsesOverlayScrollbars() && |
- !ShouldUseCustomScrollbars(custom_scrollbar_element); |
+ !(style_source && style_source->HasCustomScrollbarStyle()); |
if (!uses_overlay_scrollbars && NeedsLayout()) |
UpdateLayout(); |
@@ -4003,11 +3949,6 @@ void LocalFrameView::SetLayoutSizeInternal(const IntSize& size) { |
ContentsResized(); |
} |
-void LocalFrameView::DidAddScrollbar(Scrollbar& scrollbar, |
- ScrollbarOrientation orientation) { |
- ScrollableArea::DidAddScrollbar(scrollbar, orientation); |
-} |
- |
PaintLayer* LocalFrameView::Layer() const { |
LayoutViewItem layout_view = GetLayoutViewItem(); |
if (layout_view.IsNull() || !layout_view.Compositor()) |
@@ -4355,10 +4296,10 @@ bool LocalFrameView::AdjustScrollbarExistence( |
if (scrollbars_suppressed_) |
return true; |
- Element* custom_scrollbar_element = nullptr; |
+ LayoutObject* style_source = LayoutObjectForScrollbarStyle(); |
bool uses_overlay_scrollbars = |
ScrollbarTheme::GetTheme().UsesOverlayScrollbars() && |
- !ShouldUseCustomScrollbars(custom_scrollbar_element); |
+ !(style_source && style_source->HasCustomScrollbarStyle()); |
if (!uses_overlay_scrollbars) |
SetNeedsLayout(); |
@@ -4375,8 +4316,9 @@ bool LocalFrameView::NeedsScrollbarReconstruction() const { |
// We have no scrollbar to reconstruct. |
return false; |
} |
- Element* style_source = nullptr; |
- bool needs_custom = ShouldUseCustomScrollbars(style_source); |
+ LayoutObject* style_source = LayoutObjectForScrollbarStyle(); |
+ |
+ bool needs_custom = style_source && style_source->HasCustomScrollbarStyle(); |
bool is_custom = scrollbar->IsCustomScrollbar(); |
if (needs_custom != is_custom) { |
// We have a native scrollbar that should be custom, or vice versa. |
@@ -4388,8 +4330,7 @@ bool LocalFrameView::NeedsScrollbarReconstruction() const { |
} |
DCHECK(needs_custom && is_custom); |
DCHECK(style_source); |
- if (ToLayoutScrollbar(scrollbar)->StyleSource() != |
- style_source->GetLayoutObject()) { |
+ if (ToLayoutScrollbar(scrollbar)->StyleSource() != style_source) { |
// We have a custom scrollbar with a stale m_owner. |
return true; |
} |