Commit 05677fa5 authored by Xiaocheng Hu's avatar Xiaocheng Hu Committed by Commit Bot

Cache ::-webkit-scrollbar-* styles on source ComputedStyle

This patch caches the pseudo style of custom scrollbar parts on the
ComputedStyle of the originating element, so that it's easier to inspect
these pseudo styles.

Before: Element -> LayoutObject -> PaintLayer -> ScrollableArea ->
        CustomScrollbar -> ComputedStyle

After: Element -> ComputedStyle

This is preparation for crrev.com/c/1952189

Bug: 441925
Change-Id: Ibbb4876d4e01af7c37db9b390937af76a217855e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2026694Reviewed-by: default avatarRune Lillesveen <futhark@chromium.org>
Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#736493}
parent a79b996a
...@@ -142,14 +142,18 @@ void CustomScrollbar::SetPressedPart(ScrollbarPart part, ...@@ -142,14 +142,18 @@ void CustomScrollbar::SetPressedPart(ScrollbarPart part,
UpdateScrollbarPart(kTrackBGPart); UpdateScrollbarPart(kTrackBGPart);
} }
scoped_refptr<ComputedStyle> CustomScrollbar::GetScrollbarPseudoElementStyle( scoped_refptr<const ComputedStyle>
ScrollbarPart part_type, CustomScrollbar::GetScrollbarPseudoElementStyle(ScrollbarPart part_type,
PseudoId pseudo_id) { PseudoId pseudo_id) {
if (!StyleSource()->GetLayoutObject()) if (!StyleSource()->GetLayoutObject())
return nullptr; return nullptr;
return StyleSource()->StyleForPseudoElement( const ComputedStyle* source_style = StyleSource()->GetLayoutObject()->Style();
PseudoElementStyleRequest(pseudo_id, this, part_type), scoped_refptr<const ComputedStyle> part_style =
StyleSource()->GetLayoutObject()->Style()); StyleSource()->StyleForPseudoElement(
PseudoElementStyleRequest(pseudo_id, this, part_type), source_style);
if (!part_style)
return nullptr;
return source_style->AddCachedPseudoElementStyle(std::move(part_style));
} }
void CustomScrollbar::UpdateScrollbarParts(bool destroy) { void CustomScrollbar::UpdateScrollbarParts(bool destroy) {
...@@ -228,10 +232,10 @@ void CustomScrollbar::UpdateScrollbarPart(ScrollbarPart part_type, ...@@ -228,10 +232,10 @@ void CustomScrollbar::UpdateScrollbarPart(ScrollbarPart part_type,
if (part_type == kNoPart) if (part_type == kNoPart)
return; return;
scoped_refptr<ComputedStyle> part_style = scoped_refptr<const ComputedStyle> part_style =
!destroy ? GetScrollbarPseudoElementStyle( !destroy ? GetScrollbarPseudoElementStyle(
part_type, PseudoForScrollbarPart(part_type)) part_type, PseudoForScrollbarPart(part_type))
: scoped_refptr<ComputedStyle>(nullptr); : scoped_refptr<const ComputedStyle>(nullptr);
bool need_layout_object = bool need_layout_object =
!destroy && part_style && part_style->Display() != EDisplay::kNone; !destroy && part_style && part_style->Display() != EDisplay::kNone;
......
...@@ -90,8 +90,9 @@ class CustomScrollbar final : public Scrollbar { ...@@ -90,8 +90,9 @@ class CustomScrollbar final : public Scrollbar {
void UpdateScrollbarParts(bool destroy = false); void UpdateScrollbarParts(bool destroy = false);
scoped_refptr<ComputedStyle> GetScrollbarPseudoElementStyle(ScrollbarPart, scoped_refptr<const ComputedStyle> GetScrollbarPseudoElementStyle(
PseudoId); ScrollbarPart,
PseudoId);
void UpdateScrollbarPart(ScrollbarPart, bool destroy = false); void UpdateScrollbarPart(ScrollbarPart, bool destroy = false);
HashMap<unsigned, LayoutCustomScrollbarPart*> parts_; HashMap<unsigned, LayoutCustomScrollbarPart*> parts_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment