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

Unified Diff: third_party/WebKit/Source/core/paint/ScrollbarManager.cpp

Issue 2942163002: [Refactor] Moved scrollbar creation and deletion to ScrollbarManager (Closed)
Patch Set: bokan and skobes comments addressed 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/paint/ScrollbarManager.cpp
diff --git a/third_party/WebKit/Source/core/paint/ScrollbarManager.cpp b/third_party/WebKit/Source/core/paint/ScrollbarManager.cpp
index 4b270c2fdc07abcc787922c4bb576e195c49fb24..efc464becca6ab2a34e31839962c8b5ddf288d13 100644
--- a/third_party/WebKit/Source/core/paint/ScrollbarManager.cpp
+++ b/third_party/WebKit/Source/core/paint/ScrollbarManager.cpp
@@ -4,6 +4,16 @@
#include "core/paint/ScrollbarManager.h"
+#include "core/frame/LocalFrame.h"
+#include "core/frame/LocalFrameView.h"
+#include "core/layout/LayoutBox.h"
+#include "core/layout/LayoutObject.h"
+#include "core/layout/LayoutScrollbar.h"
+#include "core/layout/LayoutTheme.h"
+#include "core/page/ChromeClient.h"
+#include "core/page/Page.h"
+#include "core/paint/PaintLayerScrollableArea.h"
+
namespace blink {
ScrollbarManager::ScrollbarManager(ScrollableArea& scrollable_area)
@@ -23,4 +33,59 @@ void ScrollbarManager::Dispose() {
DestroyScrollbar(kVerticalScrollbar);
}
+Scrollbar* ScrollbarManager::CreateScrollbar(ScrollbarOrientation orientation) {
+ DCHECK(scrollable_area_->GetLayoutBox());
+ DCHECK(orientation == kHorizontalScrollbar ? !h_bar_is_attached_
+ : !v_bar_is_attached_);
+ LayoutObject* layout_object_for_style =
+ scrollable_area_->LayoutObjectForScrollbarStyle();
+
+ Scrollbar* scrollbar = nullptr;
+ if (layout_object_for_style &&
+ layout_object_for_style->HasCustomScrollbarStyle()) {
+ DCHECK(!layout_object_for_style->IsLayoutView());
+ scrollbar = LayoutScrollbar::CreateCustomScrollbar(
+ scrollable_area_.Get(), orientation,
+ ToElement(layout_object_for_style->GetNode()));
+ } else {
+ ScrollbarControlSize scrollbar_size = kRegularScrollbar;
+
+ if (layout_object_for_style &&
+ layout_object_for_style->StyleRef().HasAppearance() &&
+ scrollable_area_->IsPaintLayerScrollableArea()) {
+ scrollbar_size = LayoutTheme::GetTheme().ScrollbarControlSizeForPart(
+ layout_object_for_style->StyleRef().Appearance());
+ }
+
+ scrollbar =
+ Scrollbar::Create(scrollable_area_.Get(), orientation, scrollbar_size,
+ &scrollable_area_->GetLayoutBox()
+ ->GetFrame()
+ ->GetPage()
+ ->GetChromeClient());
+ }
+
+ scrollable_area_->GetLayoutBox()->GetDocument().View()->AddScrollbar(
+ scrollbar);
+
+ return scrollbar;
+}
+
+void 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);
+
+ scrollable_area_->GetLayoutBox()->GetDocument().View()->RemoveScrollbar(
+ scrollbar);
+
+ scrollbar->DisconnectFromScrollableArea();
+ scrollbar = nullptr;
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/paint/ScrollbarManager.h ('k') | third_party/WebKit/Source/platform/scroll/ScrollableArea.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698