Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Unified Diff: third_party/WebKit/Source/core/frame/LocalFrameView.cpp

Issue 2942163002: [Refactor] Moved scrollbar creation and deletion to ScrollbarManager (Closed)
Patch Set: change ShouldUseCustomScrollbars Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 7f2a73a612771758a0c6b7deceec0e5ce85a2e3b..ec749c61e52f9fda8765fed91bb50e1181ba5192 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,18 @@ 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;
-
+LayoutObject* LocalFrameView::LayoutObjectForScrollbars() const {
if (Settings* settings = frame_->GetSettings()) {
if (!settings->GetAllowCustomScrollbarInMainFrame() &&
frame_->IsMainFrame())
- return false;
+ return nullptr;
bokan 2017/06/27 17:48:52 No need to have this case here, PLSA::LayoutObject
}
- 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;
- }
+ LayoutViewItem layout_view_item = GetLayoutViewItem();
+ if (layout_view_item.IsNull())
+ return nullptr;
- return false;
+ return layout_view_item.GetScrollableArea()->LayoutObjectForScrollbars();
}
Scrollbar* LocalFrameView::CreateScrollbar(ScrollbarOrientation orientation) {
@@ -2191,11 +2144,10 @@ void LocalFrameView::ScrollbarExistenceMaybeChanged() {
if (!GetFrame().View())
return;
- Element* custom_scrollbar_element = nullptr;
-
+ LayoutObject* style_source = nullptr;
bool uses_overlay_scrollbars =
ScrollbarTheme::GetTheme().UsesOverlayScrollbars() &&
- !ShouldUseCustomScrollbars(custom_scrollbar_element);
+ !ShouldUseCustomScrollbars(style_source);
if (!uses_overlay_scrollbars && NeedsLayout())
UpdateLayout();
@@ -4361,10 +4313,10 @@ bool LocalFrameView::AdjustScrollbarExistence(
if (scrollbars_suppressed_)
return true;
- Element* custom_scrollbar_element = nullptr;
+ LayoutObject* style_source = nullptr;
bool uses_overlay_scrollbars =
ScrollbarTheme::GetTheme().UsesOverlayScrollbars() &&
- !ShouldUseCustomScrollbars(custom_scrollbar_element);
+ !ShouldUseCustomScrollbars(style_source);
if (!uses_overlay_scrollbars)
SetNeedsLayout();
@@ -4381,7 +4333,8 @@ bool LocalFrameView::NeedsScrollbarReconstruction() const {
// We have no scrollbar to reconstruct.
return false;
}
- Element* style_source = nullptr;
+ LayoutObject* style_source = nullptr;
+
bool needs_custom = ShouldUseCustomScrollbars(style_source);
bool is_custom = scrollbar->IsCustomScrollbar();
if (needs_custom != is_custom) {
@@ -4394,8 +4347,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;
}

Powered by Google App Engine
This is Rietveld 408576698