| Index: third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp
|
| diff --git a/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp b/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp
|
| index 6f8b3ff91f6e5b678bde3572716519b3f3b5be7c..535acd97bb3b5f3f9aa17c1d31ad713d6a52d3d5 100644
|
| --- a/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp
|
| +++ b/third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.cpp
|
| @@ -1213,51 +1213,52 @@ IntSize PaintLayerScrollableArea::ScrollbarOffset(
|
| return IntSize();
|
| }
|
|
|
| -static inline const LayoutObject& ScrollbarStyleSource(
|
| - const LayoutObject& layout_object) {
|
| - if (Node* node = layout_object.GetNode()) {
|
| - if (layout_object.IsLayoutView()) {
|
| - Document& doc = node->GetDocument();
|
| - if (Settings* settings = doc.GetSettings()) {
|
| - if (!settings->GetAllowCustomScrollbarInMainFrame() &&
|
| - layout_object.GetFrame() && layout_object.GetFrame()->IsMainFrame())
|
| - return layout_object;
|
| - }
|
| +LayoutObject* PaintLayerScrollableArea::LayoutObjectForScrollbarStyle() const {
|
| + LayoutObject* layout_object = GetLayoutBox();
|
| + Node* node = layout_object->GetNode();
|
| +
|
| + if (!node)
|
| + return nullptr;
|
|
|
| - // Try the <body> element first as a scrollbar source.
|
| - Element* body = doc.body();
|
| - if (body && body->GetLayoutObject() &&
|
| - body->GetLayoutObject()->Style()->HasPseudoStyle(kPseudoIdScrollbar))
|
| - return *body->GetLayoutObject();
|
| -
|
| - // If the <body> didn't have a custom style, then the root element might.
|
| - Element* doc_element = doc.documentElement();
|
| - if (doc_element && doc_element->GetLayoutObject() &&
|
| - doc_element->GetLayoutObject()->Style()->HasPseudoStyle(
|
| - kPseudoIdScrollbar))
|
| - return *doc_element->GetLayoutObject();
|
| + if (layout_object->IsLayoutView()) {
|
| + Document& doc = node->GetDocument();
|
| + if (Settings* settings = doc.GetSettings()) {
|
| + if (!settings->GetAllowCustomScrollbarInMainFrame() &&
|
| + layout_object->GetFrame() && layout_object->GetFrame()->IsMainFrame())
|
| + return nullptr;
|
| }
|
|
|
| - if (layout_object.StyleRef().HasPseudoStyle(kPseudoIdScrollbar))
|
| - return layout_object;
|
| + // Try the <body> element first as a scrollbar source.
|
| + Element* body = doc.body();
|
| + if (body && body->GetLayoutObject() &&
|
| + body->GetLayoutObject()->HasCustomScrollbarStyle())
|
| + return body->GetLayoutObject();
|
|
|
| - if (ShadowRoot* shadow_root = node->ContainingShadowRoot()) {
|
| - if (shadow_root->GetType() == ShadowRootType::kUserAgent) {
|
| - if (LayoutObject* host_layout_object =
|
| - shadow_root->host().GetLayoutObject())
|
| - return *host_layout_object;
|
| - }
|
| + // If the <body> didn't have a custom style, then the root element might.
|
| + Element* doc_element = doc.documentElement();
|
| + if (doc_element && doc_element->GetLayoutObject() &&
|
| + doc_element->GetLayoutObject()->HasCustomScrollbarStyle())
|
| + return doc_element->GetLayoutObject();
|
| + }
|
| +
|
| + if (layout_object->HasCustomScrollbarStyle())
|
| + return layout_object;
|
| +
|
| + if (ShadowRoot* shadow_root = node->ContainingShadowRoot()) {
|
| + if (shadow_root->GetType() == ShadowRootType::kUserAgent) {
|
| + LayoutObject* host_layout_object = shadow_root->host().GetLayoutObject();
|
| + if (host_layout_object && host_layout_object->HasCustomScrollbarStyle())
|
| + return host_layout_object;
|
| }
|
| }
|
|
|
| - return layout_object;
|
| + return nullptr;
|
| }
|
|
|
| bool PaintLayerScrollableArea::NeedsScrollbarReconstruction() const {
|
| - const LayoutObject& style_source = ScrollbarStyleSource(Box());
|
| + LayoutObject* style_source = LayoutObjectForScrollbarStyle();
|
| bool should_use_custom =
|
| - style_source.IsBox() &&
|
| - style_source.StyleRef().HasPseudoStyle(kPseudoIdScrollbar);
|
| + style_source && style_source->HasCustomScrollbarStyle();
|
| bool has_any_scrollbar = HasScrollbar();
|
| bool has_custom =
|
| (HasHorizontalScrollbar() &&
|
| @@ -1266,12 +1267,15 @@ bool PaintLayerScrollableArea::NeedsScrollbarReconstruction() const {
|
| bool did_custom_scrollbar_owner_changed = false;
|
|
|
| if (HasHorizontalScrollbar() && HorizontalScrollbar()->IsCustomScrollbar()) {
|
| - if (style_source != ToLayoutScrollbar(HorizontalScrollbar())->StyleSource())
|
| + if (style_source &&
|
| + *style_source !=
|
| + ToLayoutScrollbar(HorizontalScrollbar())->StyleSource())
|
| did_custom_scrollbar_owner_changed = true;
|
| }
|
|
|
| if (HasVerticalScrollbar() && VerticalScrollbar()->IsCustomScrollbar()) {
|
| - if (style_source != ToLayoutScrollbar(VerticalScrollbar())->StyleSource())
|
| + if (style_source &&
|
| + *style_source != ToLayoutScrollbar(VerticalScrollbar())->StyleSource())
|
| did_custom_scrollbar_owner_changed = true;
|
| }
|
|
|
| @@ -1462,12 +1466,13 @@ void PaintLayerScrollableArea::UpdateScrollCornerStyle() {
|
| if (!scroll_corner_ && HasOverlayScrollbars())
|
| return;
|
|
|
| - const LayoutObject& style_source = ScrollbarStyleSource(Box());
|
| + const LayoutObject* style_source = LayoutObjectForScrollbarStyle();
|
| +
|
| RefPtr<ComputedStyle> corner =
|
| - Box().HasOverflowClip()
|
| - ? style_source.GetUncachedPseudoStyle(
|
| + Box().HasOverflowClip() && style_source
|
| + ? style_source->GetUncachedPseudoStyle(
|
| PseudoStyleRequest(kPseudoIdScrollbarCorner),
|
| - style_source.Style())
|
| + style_source->Style())
|
| : PassRefPtr<ComputedStyle>(nullptr);
|
| if (corner) {
|
| if (!scroll_corner_) {
|
| @@ -1625,11 +1630,12 @@ void PaintLayerScrollableArea::UpdateResizerStyle() {
|
| if (!resizer_ && !Box().CanResize())
|
| return;
|
|
|
| - const LayoutObject& style_source = ScrollbarStyleSource(Box());
|
| + const LayoutObject* style_source = LayoutObjectForScrollbarStyle();
|
| +
|
| RefPtr<ComputedStyle> resizer =
|
| - Box().HasOverflowClip()
|
| - ? style_source.GetUncachedPseudoStyle(
|
| - PseudoStyleRequest(kPseudoIdResizer), style_source.Style())
|
| + Box().HasOverflowClip() && style_source
|
| + ? style_source->GetUncachedPseudoStyle(
|
| + PseudoStyleRequest(kPseudoIdResizer), style_source->Style())
|
| : PassRefPtr<ComputedStyle>(nullptr);
|
| if (resizer) {
|
| if (!resizer_) {
|
| @@ -2055,8 +2061,7 @@ void PaintLayerScrollableArea::ScrollbarManager::SetHasHorizontalScrollbar(
|
| if (!h_bar_) {
|
| h_bar_ = CreateScrollbar(kHorizontalScrollbar);
|
| h_bar_is_attached_ = 1;
|
| - if (!h_bar_->IsCustomScrollbar())
|
| - ScrollableArea()->DidAddScrollbar(*h_bar_, kHorizontalScrollbar);
|
| + ScrollableArea()->DidAddScrollbar(*h_bar_, kHorizontalScrollbar);
|
| } else {
|
| h_bar_is_attached_ = 1;
|
| }
|
| @@ -2074,8 +2079,7 @@ void PaintLayerScrollableArea::ScrollbarManager::SetHasVerticalScrollbar(
|
| if (!v_bar_) {
|
| v_bar_ = CreateScrollbar(kVerticalScrollbar);
|
| v_bar_is_attached_ = 1;
|
| - if (!v_bar_->IsCustomScrollbar())
|
| - ScrollableArea()->DidAddScrollbar(*v_bar_, kVerticalScrollbar);
|
| + ScrollableArea()->DidAddScrollbar(*v_bar_, kVerticalScrollbar);
|
| } else {
|
| v_bar_is_attached_ = 1;
|
| }
|
| @@ -2086,55 +2090,17 @@ void PaintLayerScrollableArea::ScrollbarManager::SetHasVerticalScrollbar(
|
| }
|
| }
|
|
|
| -Scrollbar* PaintLayerScrollableArea::ScrollbarManager::CreateScrollbar(
|
| +void PaintLayerScrollableArea::WillRemoveScrollbar(
|
| + Scrollbar& scrollbar,
|
| ScrollbarOrientation orientation) {
|
| - DCHECK(orientation == kHorizontalScrollbar ? !h_bar_is_attached_
|
| - : !v_bar_is_attached_);
|
| - Scrollbar* scrollbar = nullptr;
|
| - const LayoutObject& style_source =
|
| - ScrollbarStyleSource(ScrollableArea()->Box());
|
| - bool has_custom_scrollbar_style =
|
| - style_source.IsBox() &&
|
| - style_source.StyleRef().HasPseudoStyle(kPseudoIdScrollbar);
|
| - if (has_custom_scrollbar_style) {
|
| - DCHECK(style_source.GetNode() && style_source.GetNode()->IsElementNode());
|
| - scrollbar = LayoutScrollbar::CreateCustomScrollbar(
|
| - ScrollableArea(), orientation, ToElement(style_source.GetNode()));
|
| - } else {
|
| - ScrollbarControlSize scrollbar_size = kRegularScrollbar;
|
| - if (style_source.StyleRef().HasAppearance()) {
|
| - scrollbar_size = LayoutTheme::GetTheme().ScrollbarControlSizeForPart(
|
| - style_source.StyleRef().Appearance());
|
| - }
|
| - scrollbar = Scrollbar::Create(
|
| - ScrollableArea(), orientation, scrollbar_size,
|
| - &ScrollableArea()->Box().GetFrame()->GetPage()->GetChromeClient());
|
| - }
|
| - ScrollableArea()->Box().GetDocument().View()->AddScrollbar(scrollbar);
|
| - return scrollbar;
|
| -}
|
| -
|
| -void PaintLayerScrollableArea::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;
|
| -
|
| - ScrollableArea()->SetScrollbarNeedsPaintInvalidation(orientation);
|
| + SetScrollbarNeedsPaintInvalidation(orientation);
|
| if (orientation == kHorizontalScrollbar)
|
| - ScrollableArea()->rebuild_horizontal_scrollbar_layer_ = true;
|
| + rebuild_horizontal_scrollbar_layer_ = true;
|
| else
|
| - ScrollableArea()->rebuild_vertical_scrollbar_layer_ = true;
|
| -
|
| - if (!scrollbar->IsCustomScrollbar())
|
| - ScrollableArea()->WillRemoveScrollbar(*scrollbar, orientation);
|
| + rebuild_vertical_scrollbar_layer_ = true;
|
|
|
| - ScrollableArea()->Box().GetDocument().View()->RemoveScrollbar(scrollbar);
|
| - scrollbar->DisconnectFromScrollableArea();
|
| - scrollbar = nullptr;
|
| + PaintInvalidationCapableScrollableArea::WillRemoveScrollbar(scrollbar,
|
| + orientation);
|
| }
|
|
|
| uint64_t PaintLayerScrollableArea::Id() const {
|
|
|