summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/scroll
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/blink/renderer/core/scroll')
-rw-r--r--chromium/third_party/blink/renderer/core/scroll/programmatic_scroll_animator.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/scroll/programmatic_scroll_animator.h2
-rw-r--r--chromium/third_party/blink/renderer/core/scroll/scroll_animator.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/scroll/scroll_animator.h2
-rw-r--r--chromium/third_party/blink/renderer/core/scroll/scroll_animator_base.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/scroll/scroll_animator_base.h2
-rw-r--r--chromium/third_party/blink/renderer/core/scroll/scroll_animator_compositor_coordinator.h2
-rw-r--r--chromium/third_party/blink/renderer/core/scroll/scroll_animator_mac.h4
-rw-r--r--chromium/third_party/blink/renderer/core/scroll/scroll_animator_test.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/scroll/scroll_test.cc8
-rw-r--r--chromium/third_party/blink/renderer/core/scroll/scrollable_area.cc51
-rw-r--r--chromium/third_party/blink/renderer/core/scroll/scrollable_area.h6
-rw-r--r--chromium/third_party/blink/renderer/core/scroll/scrollbar.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/scroll/scrollbar.h4
-rw-r--r--chromium/third_party/blink/renderer/core/scroll/scrollbar_layer_delegate.cc4
-rw-r--r--chromium/third_party/blink/renderer/core/scroll/scrollbar_layer_delegate.h1
-rw-r--r--chromium/third_party/blink/renderer/core/scroll/scrollbar_test_suite.h2
-rw-r--r--chromium/third_party/blink/renderer/core/scroll/scrollbar_theme.h1
-rw-r--r--chromium/third_party/blink/renderer/core/scroll/scrollbar_theme_mac.h1
-rw-r--r--chromium/third_party/blink/renderer/core/scroll/scrollbar_theme_mac.mm104
-rw-r--r--chromium/third_party/blink/renderer/core/scroll/smooth_scroll_sequencer.cc4
-rw-r--r--chromium/third_party/blink/renderer/core/scroll/smooth_scroll_sequencer.h4
22 files changed, 145 insertions, 67 deletions
diff --git a/chromium/third_party/blink/renderer/core/scroll/programmatic_scroll_animator.cc b/chromium/third_party/blink/renderer/core/scroll/programmatic_scroll_animator.cc
index f4d02dacf88..683df2318be 100644
--- a/chromium/third_party/blink/renderer/core/scroll/programmatic_scroll_animator.cc
+++ b/chromium/third_party/blink/renderer/core/scroll/programmatic_scroll_animator.cc
@@ -202,7 +202,7 @@ void ProgrammaticScrollAnimator::AnimationFinished() {
}
}
-void ProgrammaticScrollAnimator::Trace(Visitor* visitor) {
+void ProgrammaticScrollAnimator::Trace(Visitor* visitor) const {
visitor->Trace(scrollable_area_);
ScrollAnimatorCompositorCoordinator::Trace(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/scroll/programmatic_scroll_animator.h b/chromium/third_party/blink/renderer/core/scroll/programmatic_scroll_animator.h
index 5bf0f85eca8..4b90b1fb982 100644
--- a/chromium/third_party/blink/renderer/core/scroll/programmatic_scroll_animator.h
+++ b/chromium/third_party/blink/renderer/core/scroll/programmatic_scroll_animator.h
@@ -52,7 +52,7 @@ class ProgrammaticScrollAnimator : public ScrollAnimatorCompositorCoordinator {
void LayerForCompositedScrollingDidChange(
CompositorAnimationTimeline*) override;
- void Trace(Visitor*) override;
+ void Trace(Visitor*) const override;
private:
void NotifyOffsetChanged(const ScrollOffset&);
diff --git a/chromium/third_party/blink/renderer/core/scroll/scroll_animator.cc b/chromium/third_party/blink/renderer/core/scroll/scroll_animator.cc
index d2dc57d9b30..cda134a8f21 100644
--- a/chromium/third_party/blink/renderer/core/scroll/scroll_animator.cc
+++ b/chromium/third_party/blink/renderer/core/scroll/scroll_animator.cc
@@ -407,7 +407,7 @@ bool ScrollAnimator::RegisterAndScheduleAnimation() {
return true;
}
-void ScrollAnimator::Trace(Visitor* visitor) {
+void ScrollAnimator::Trace(Visitor* visitor) const {
ScrollAnimatorBase::Trace(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/scroll/scroll_animator.h b/chromium/third_party/blink/renderer/core/scroll/scroll_animator.h
index c4366bd6c44..7a87645e920 100644
--- a/chromium/third_party/blink/renderer/core/scroll/scroll_animator.h
+++ b/chromium/third_party/blink/renderer/core/scroll/scroll_animator.h
@@ -131,7 +131,7 @@ class CORE_EXPORT ScrollAnimator : public ScrollAnimatorBase {
void LayerForCompositedScrollingDidChange(
CompositorAnimationTimeline*) override;
- void Trace(Visitor*) override;
+ void Trace(Visitor*) const override;
protected:
// Returns whether or not the animation was sent to the compositor.
diff --git a/chromium/third_party/blink/renderer/core/scroll/scroll_animator_base.cc b/chromium/third_party/blink/renderer/core/scroll/scroll_animator_base.cc
index 3b9e3cb4915..c40dd121b87 100644
--- a/chromium/third_party/blink/renderer/core/scroll/scroll_animator_base.cc
+++ b/chromium/third_party/blink/renderer/core/scroll/scroll_animator_base.cc
@@ -87,7 +87,7 @@ void ScrollAnimatorBase::NotifyOffsetChanged() {
ScrollOffsetChanged(current_offset_, mojom::blink::ScrollType::kUser);
}
-void ScrollAnimatorBase::Trace(Visitor* visitor) {
+void ScrollAnimatorBase::Trace(Visitor* visitor) const {
visitor->Trace(scrollable_area_);
ScrollAnimatorCompositorCoordinator::Trace(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/scroll/scroll_animator_base.h b/chromium/third_party/blink/renderer/core/scroll/scroll_animator_base.h
index 272f188e19a..be126476aac 100644
--- a/chromium/third_party/blink/renderer/core/scroll/scroll_animator_base.h
+++ b/chromium/third_party/blink/renderer/core/scroll/scroll_animator_base.h
@@ -116,7 +116,7 @@ class CORE_EXPORT ScrollAnimatorBase
virtual bool SetScrollbarsVisibleForTesting(bool) { return false; }
- void Trace(Visitor*) override;
+ void Trace(Visitor*) const override;
protected:
virtual void NotifyOffsetChanged();
diff --git a/chromium/third_party/blink/renderer/core/scroll/scroll_animator_compositor_coordinator.h b/chromium/third_party/blink/renderer/core/scroll/scroll_animator_compositor_coordinator.h
index 03517d90b8c..48c6b27a280 100644
--- a/chromium/third_party/blink/renderer/core/scroll/scroll_animator_compositor_coordinator.h
+++ b/chromium/third_party/blink/renderer/core/scroll/scroll_animator_compositor_coordinator.h
@@ -111,7 +111,7 @@ class CORE_EXPORT ScrollAnimatorCompositorCoordinator
RunState RunStateForTesting() { return run_state_; }
- virtual void Trace(Visitor* visitor) {}
+ virtual void Trace(Visitor* visitor) const {}
protected:
explicit ScrollAnimatorCompositorCoordinator();
diff --git a/chromium/third_party/blink/renderer/core/scroll/scroll_animator_mac.h b/chromium/third_party/blink/renderer/core/scroll/scroll_animator_mac.h
index a5b81033633..3138cef9228 100644
--- a/chromium/third_party/blink/renderer/core/scroll/scroll_animator_mac.h
+++ b/chromium/third_party/blink/renderer/core/scroll/scroll_animator_mac.h
@@ -114,7 +114,9 @@ class CORE_EXPORT ScrollAnimatorMac : public ScrollAnimatorBase {
void SendContentAreaScrolledSoon(const ScrollOffset& scroll_delta);
- void Trace(Visitor* visitor) override { ScrollAnimatorBase::Trace(visitor); }
+ void Trace(Visitor* visitor) const override {
+ ScrollAnimatorBase::Trace(visitor);
+ }
private:
base::scoped_nsobject<id> scroll_animation_helper_;
diff --git a/chromium/third_party/blink/renderer/core/scroll/scroll_animator_test.cc b/chromium/third_party/blink/renderer/core/scroll/scroll_animator_test.cc
index f1a21a1ea30..fe724fdddaf 100644
--- a/chromium/third_party/blink/renderer/core/scroll/scroll_animator_test.cc
+++ b/chromium/third_party/blink/renderer/core/scroll/scroll_animator_test.cc
@@ -137,7 +137,7 @@ class MockScrollableAreaForAnimatorTest
return ScrollbarTheme::GetTheme();
}
- void Trace(Visitor* visitor) override {
+ void Trace(Visitor* visitor) const override {
visitor->Trace(animator);
ScrollableArea::Trace(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/scroll/scroll_test.cc b/chromium/third_party/blink/renderer/core/scroll/scroll_test.cc
index 11bd7a2e223..c4a6d27d25d 100644
--- a/chromium/third_party/blink/renderer/core/scroll/scroll_test.cc
+++ b/chromium/third_party/blink/renderer/core/scroll/scroll_test.cc
@@ -270,7 +270,13 @@ TEST_F(ScrollAnimatorSimTest, TestRootFrameBothViewportsUserScrollCallBack) {
// Test that the callback of user scroll will be executed when the animation
// finishes at ScrollAnimator::TickAnimation for div user scroll.
-TEST_F(ScrollAnimatorSimTest, TestDivUserScrollCallBack) {
+#if defined(ADDRESS_SANITIZER) || defined(THREAD_SANITIZER)
+// Flaky under sanitizers, see http://crbug.com/1092550
+#define MAYBE_TestDivUserScrollCallBack DISABLED_TestDivUserScrollCallBack
+#else
+#define MAYBE_TestDivUserScrollCallBack TestDivUserScrollCallBack
+#endif
+TEST_F(ScrollAnimatorSimTest, MAYBE_TestDivUserScrollCallBack) {
GetDocument().GetSettings()->SetScrollAnimatorEnabled(true);
WebView().MainFrameWidget()->Resize(WebSize(800, 500));
SimRequest request("https://example.com/test.html", "text/html");
diff --git a/chromium/third_party/blink/renderer/core/scroll/scrollable_area.cc b/chromium/third_party/blink/renderer/core/scroll/scrollable_area.cc
index fdadcbb9872..05af54e8c57 100644
--- a/chromium/third_party/blink/renderer/core/scroll/scrollable_area.cc
+++ b/chromium/third_party/blink/renderer/core/scroll/scrollable_area.cc
@@ -33,12 +33,14 @@
#include "build/build_config.h"
#include "cc/input/main_thread_scrolling_reason.h"
+#include "cc/input/scroll_utils.h"
#include "cc/input/scrollbar.h"
#include "cc/input/snap_selection_strategy.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/renderer/core/animation/scroll_timeline.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/local_frame_view.h"
+#include "third_party/blink/renderer/core/frame/visual_viewport.h"
#include "third_party/blink/renderer/core/input/event_handler.h"
#include "third_party/blink/renderer/core/layout/layout_box.h"
#include "third_party/blink/renderer/core/layout/layout_shift_tracker.h"
@@ -58,13 +60,13 @@ namespace blink {
int ScrollableArea::PixelsPerLineStep(LocalFrame* frame) {
if (!frame)
- return kPixelsPerLineStep;
+ return cc::kPixelsPerLineStep;
return frame->GetPage()->GetChromeClient().WindowToViewportScalar(
- frame, kPixelsPerLineStep);
+ frame, cc::kPixelsPerLineStep);
}
float ScrollableArea::MinFractionToStepWhenPaging() {
- return kMinFractionToStepWhenPaging;
+ return cc::kMinFractionToStepWhenPaging;
}
int ScrollableArea::MaxOverlapBetweenPages() const {
@@ -74,7 +76,7 @@ int ScrollableArea::MaxOverlapBetweenPages() const {
// static
float ScrollableArea::DirectionBasedScrollDelta(ScrollGranularity granularity) {
return (granularity == ScrollGranularity::kScrollByPercentage)
- ? kPercentDeltaForDirectionalScroll
+ ? cc::kPercentDeltaForDirectionalScroll
: 1;
}
@@ -172,6 +174,34 @@ float ScrollableArea::ScrollStep(ScrollGranularity granularity,
}
}
+ScrollOffset ScrollableArea::ResolveScrollDelta(ScrollGranularity granularity,
+ const ScrollOffset& delta) {
+ gfx::SizeF step(ScrollStep(granularity, kHorizontalScrollbar),
+ ScrollStep(granularity, kVerticalScrollbar));
+
+ if (granularity == ScrollGranularity::kScrollByPercentage) {
+ LocalFrame* local_frame = GetLayoutBox()->GetFrame();
+ DCHECK(local_frame);
+ gfx::SizeF viewport = gfx::SizeF(
+ FloatSize(local_frame->GetPage()->GetVisualViewport().Size()));
+
+ // Convert to screen coordinates (physical pixels).
+ float page_scale_factor = local_frame->GetPage()->PageScaleFactor();
+ step.Scale(page_scale_factor);
+
+ gfx::Vector2dF pixel_delta =
+ cc::ScrollUtils::ResolveScrollPercentageToPixels(gfx::Vector2dF(delta),
+ step, viewport);
+
+ // Rescale back to rootframe coordinates.
+ pixel_delta.Scale(1 / page_scale_factor);
+
+ return ScrollOffset(pixel_delta.x(), pixel_delta.y());
+ }
+
+ return delta.ScaledBy(step.width(), step.height());
+}
+
ScrollResult ScrollableArea::UserScroll(ScrollGranularity granularity,
const ScrollOffset& delta,
ScrollCallback on_finish) {
@@ -184,11 +214,7 @@ ScrollResult ScrollableArea::UserScroll(ScrollGranularity granularity,
base::ScopedClosureRunner run_on_return(WTF::Bind(
&ScrollableArea::RunScrollCompleteCallbacks, WrapWeakPersistent(this)));
- float step_x = ScrollStep(granularity, kHorizontalScrollbar);
- float step_y = ScrollStep(granularity, kVerticalScrollbar);
-
- ScrollOffset pixel_delta(delta);
- pixel_delta.Scale(step_x, step_y);
+ ScrollOffset pixel_delta = ResolveScrollDelta(granularity, delta);
ScrollOffset scrollable_axis_delta(
UserInputScrollable(kHorizontalScrollbar) ? pixel_delta.Width() : 0,
@@ -350,7 +376,10 @@ PhysicalRect ScrollableArea::ScrollIntoView(
void ScrollableArea::ScrollOffsetChanged(const ScrollOffset& offset,
mojom::blink::ScrollType scroll_type) {
- TRACE_EVENT0("blink", "ScrollableArea::scrollOffsetChanged");
+ TRACE_EVENT2("input", "ScrollableArea::scrollOffsetChanged", "x",
+ offset.Width(), "y", offset.Height());
+ TRACE_EVENT_INSTANT1("input", "Type", TRACE_EVENT_SCOPE_THREAD, "type",
+ scroll_type);
ScrollOffset old_offset = GetScrollOffset();
ScrollOffset truncated_offset = ShouldUseIntegerScrollOffset()
@@ -929,7 +958,7 @@ bool ScrollableArea::PerformSnapping(
return true;
}
-void ScrollableArea::Trace(Visitor* visitor) {
+void ScrollableArea::Trace(Visitor* visitor) const {
visitor->Trace(scroll_animator_);
visitor->Trace(programmatic_scroll_animator_);
}
diff --git a/chromium/third_party/blink/renderer/core/scroll/scrollable_area.h b/chromium/third_party/blink/renderer/core/scroll/scrollable_area.h
index 56c34cab314..f0eb978ce51 100644
--- a/chromium/third_party/blink/renderer/core/scroll/scrollable_area.h
+++ b/chromium/third_party/blink/renderer/core/scroll/scrollable_area.h
@@ -478,7 +478,7 @@ class CORE_EXPORT ScrollableArea : public GarbageCollectedMixin {
// for layout movements (bit.ly/scroll-anchoring).
virtual bool ShouldPerformScrollAnchoring() const { return false; }
- void Trace(Visitor*) override;
+ void Trace(Visitor*) const override;
virtual void ClearScrollableArea();
@@ -551,6 +551,10 @@ class CORE_EXPORT ScrollableArea : public GarbageCollectedMixin {
virtual const Document* GetDocument() const;
+ // Resolves into un-zoomed physical pixels a scroll |delta| based on its
+ // ScrollGranularity units.
+ ScrollOffset ResolveScrollDelta(ScrollGranularity, const ScrollOffset& delta);
+
private:
FRIEND_TEST_ALL_PREFIXES(ScrollableAreaTest,
PopupOverlayScrollbarShouldNotFadeOut);
diff --git a/chromium/third_party/blink/renderer/core/scroll/scrollbar.cc b/chromium/third_party/blink/renderer/core/scroll/scrollbar.cc
index 8c67ff69697..ef2efa584da 100644
--- a/chromium/third_party/blink/renderer/core/scroll/scrollbar.cc
+++ b/chromium/third_party/blink/renderer/core/scroll/scrollbar.cc
@@ -93,7 +93,7 @@ Scrollbar::Scrollbar(ScrollableArea* scrollable_area,
Scrollbar::~Scrollbar() = default;
-void Scrollbar::Trace(Visitor* visitor) {
+void Scrollbar::Trace(Visitor* visitor) const {
visitor->Trace(scrollable_area_);
visitor->Trace(chrome_client_);
visitor->Trace(style_source_);
diff --git a/chromium/third_party/blink/renderer/core/scroll/scrollbar.h b/chromium/third_party/blink/renderer/core/scroll/scrollbar.h
index 0c90f64ec9e..bf3475fc0d4 100644
--- a/chromium/third_party/blink/renderer/core/scroll/scrollbar.h
+++ b/chromium/third_party/blink/renderer/core/scroll/scrollbar.h
@@ -111,7 +111,7 @@ class CORE_EXPORT Scrollbar : public GarbageCollected<Scrollbar>,
// Called by the ScrollableArea when the scroll offset changes.
// Will trigger paint invalidation if required.
- void OffsetDidChange(mojom::blink::ScrollType scroll_type);
+ virtual void OffsetDidChange(mojom::blink::ScrollType scroll_type);
virtual void DisconnectFromScrollableArea();
ScrollableArea* GetScrollableArea() const { return scrollable_area_; }
@@ -204,7 +204,7 @@ class CORE_EXPORT Scrollbar : public GarbageCollected<Scrollbar>,
WebColorScheme UsedColorScheme() const;
- virtual void Trace(Visitor*);
+ virtual void Trace(Visitor*) const;
protected:
void AutoscrollTimerFired(TimerBase*);
diff --git a/chromium/third_party/blink/renderer/core/scroll/scrollbar_layer_delegate.cc b/chromium/third_party/blink/renderer/core/scroll/scrollbar_layer_delegate.cc
index 340cd67b2aa..e9332965fee 100644
--- a/chromium/third_party/blink/renderer/core/scroll/scrollbar_layer_delegate.cc
+++ b/chromium/third_party/blink/renderer/core/scroll/scrollbar_layer_delegate.cc
@@ -88,6 +88,10 @@ bool ScrollbarLayerDelegate::SupportsDragSnapBack() const {
return scrollbar_->GetTheme().SupportsDragSnapBack();
}
+bool ScrollbarLayerDelegate::JumpOnTrackClick() const {
+ return scrollbar_->GetTheme().JumpOnTrackClick();
+}
+
gfx::Rect ScrollbarLayerDelegate::BackButtonRect() const {
IntRect back_button_rect = scrollbar_->GetTheme().BackButtonRect(*scrollbar_);
if (!back_button_rect.IsEmpty())
diff --git a/chromium/third_party/blink/renderer/core/scroll/scrollbar_layer_delegate.h b/chromium/third_party/blink/renderer/core/scroll/scrollbar_layer_delegate.h
index 3eafffa8643..dcdb884fb7f 100644
--- a/chromium/third_party/blink/renderer/core/scroll/scrollbar_layer_delegate.h
+++ b/chromium/third_party/blink/renderer/core/scroll/scrollbar_layer_delegate.h
@@ -29,6 +29,7 @@ class CORE_EXPORT ScrollbarLayerDelegate : public cc::Scrollbar {
bool IsSolidColor() const override;
bool IsOverlay() const override;
bool SupportsDragSnapBack() const override;
+ bool JumpOnTrackClick() const override;
// The following rects are all relative to the scrollbar's origin.
gfx::Rect ThumbRect() const override;
diff --git a/chromium/third_party/blink/renderer/core/scroll/scrollbar_test_suite.h b/chromium/third_party/blink/renderer/core/scroll/scrollbar_test_suite.h
index 8871777f578..47f4e26870c 100644
--- a/chromium/third_party/blink/renderer/core/scroll/scrollbar_test_suite.h
+++ b/chromium/third_party/blink/renderer/core/scroll/scrollbar_test_suite.h
@@ -125,7 +125,7 @@ class MockScrollableArea : public GarbageCollected<MockScrollableArea>,
using ScrollableArea::ShowNonMacOverlayScrollbars;
using ScrollableArea::VerticalScrollbarNeedsPaintInvalidation;
- void Trace(Visitor* visitor) override {
+ void Trace(Visitor* visitor) const override {
visitor->Trace(chrome_client_);
ScrollableArea::Trace(visitor);
}
diff --git a/chromium/third_party/blink/renderer/core/scroll/scrollbar_theme.h b/chromium/third_party/blink/renderer/core/scroll/scrollbar_theme.h
index acbfd1d3912..5e26b132bfa 100644
--- a/chromium/third_party/blink/renderer/core/scroll/scrollbar_theme.h
+++ b/chromium/third_party/blink/renderer/core/scroll/scrollbar_theme.h
@@ -120,6 +120,7 @@ class CORE_EXPORT ScrollbarTheme {
}
virtual bool SupportsDragSnapBack() const { return false; }
+ virtual bool JumpOnTrackClick() const { return false; }
// The position of the thumb relative to the track.
int ThumbPosition(const Scrollbar& scrollbar) {
diff --git a/chromium/third_party/blink/renderer/core/scroll/scrollbar_theme_mac.h b/chromium/third_party/blink/renderer/core/scroll/scrollbar_theme_mac.h
index c34380e4696..102fe79adb5 100644
--- a/chromium/third_party/blink/renderer/core/scroll/scrollbar_theme_mac.h
+++ b/chromium/third_party/blink/renderer/core/scroll/scrollbar_theme_mac.h
@@ -65,6 +65,7 @@ class PLATFORM_EXPORT ScrollbarThemeMac : public ScrollbarTheme {
const IntRect&) override;
bool ShouldCenterOnThumb(const Scrollbar&, const WebMouseEvent&) override;
+ bool JumpOnTrackClick() const override;
bool ShouldRepaintAllPartsOnInvalidation() const override { return false; }
ScrollbarPart PartsToInvalidateOnThumbPositionChange(
diff --git a/chromium/third_party/blink/renderer/core/scroll/scrollbar_theme_mac.mm b/chromium/third_party/blink/renderer/core/scroll/scrollbar_theme_mac.mm
index 368227b5a29..58612701d4c 100644
--- a/chromium/third_party/blink/renderer/core/scroll/scrollbar_theme_mac.mm
+++ b/chromium/third_party/blink/renderer/core/scroll/scrollbar_theme_mac.mm
@@ -43,9 +43,6 @@
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/wtf/hash_set.h"
#include "third_party/blink/renderer/platform/wtf/std_lib_extras.h"
-#include "ui/gfx/mac/cocoa_scrollbar_painter.h"
-
-using gfx::CocoaScrollbarPainter;
@interface BlinkScrollbarObserver : NSObject {
blink::Scrollbar* _scrollbar;
@@ -227,21 +224,34 @@ ScrollbarPainter ScrollbarThemeMac::PainterForScrollbar(
[GetScrollbarPainterMap().at(const_cast<Scrollbar*>(&scrollbar)) painter];
}
-CocoaScrollbarPainter::Params GetPaintParams(const Scrollbar& scrollbar,
- bool overlay) {
- CocoaScrollbarPainter::Params params;
- params.orientation = CocoaScrollbarPainter::Orientation::kVerticalOnRight;
- if (scrollbar.Orientation() == kHorizontalScrollbar)
- params.orientation = CocoaScrollbarPainter::Orientation::kHorizontal;
- if (scrollbar.IsLeftSideVerticalScrollbar())
- params.orientation = CocoaScrollbarPainter::Orientation::kVerticalOnLeft;
-
- params.dark_mode = scrollbar.UsedColorScheme() == WebColorScheme::kDark;
- params.overlay = overlay;
- if (overlay)
- params.dark_mode = scrollbar.GetScrollbarOverlayColorTheme() ==
- kScrollbarOverlayColorThemeLight;
- params.hovered = scrollbar.HoveredPart() != ScrollbarPart::kNoPart;
+WebThemeEngine::ExtraParams GetPaintParams(const Scrollbar& scrollbar,
+ bool overlay) {
+ WebThemeEngine::ExtraParams params;
+
+ params.scrollbar_extra.orientation =
+ WebThemeEngine::ScrollbarOrientation::kVerticalOnRight;
+ if (scrollbar.Orientation() == kHorizontalScrollbar) {
+ params.scrollbar_extra.orientation =
+ WebThemeEngine::ScrollbarOrientation::kHorizontal;
+ } else if (scrollbar.IsLeftSideVerticalScrollbar()) {
+ params.scrollbar_extra.orientation =
+ WebThemeEngine::ScrollbarOrientation::kVerticalOnLeft;
+ }
+
+ params.scrollbar_extra.scrollbar_theme =
+ (scrollbar.UsedColorScheme() == WebColorScheme::kDark) ? kDark : kLight;
+ params.scrollbar_extra.is_overlay = overlay;
+
+ if (overlay) {
+ params.scrollbar_extra.scrollbar_theme =
+ (scrollbar.GetScrollbarOverlayColorTheme() ==
+ kScrollbarOverlayColorThemeLight)
+ ? kDark
+ : kLight;
+ }
+
+ params.scrollbar_extra.is_hovering =
+ scrollbar.HoveredPart() != ScrollbarPart::kNoPart;
return params;
}
@@ -271,11 +281,18 @@ void ScrollbarThemeMac::PaintTrack(GraphicsContext& context,
if (opacity != 1)
context.BeginLayer(opacity);
- CocoaScrollbarPainter::Params params =
+ WebThemeEngine::ExtraParams params =
GetPaintParams(scrollbar, UsesOverlayScrollbars());
- SkIRect bounds = SkIRect::MakeXYWH(0, 0, scrollbar.FrameRect().Width(),
- scrollbar.FrameRect().Height());
- CocoaScrollbarPainter::PaintTrack(context.Canvas(), bounds, params);
+ IntRect bounds(0, 0, scrollbar.FrameRect().Width(),
+ scrollbar.FrameRect().Height());
+ WebThemeEngine::Part track_part =
+ params.scrollbar_extra.orientation ==
+ WebThemeEngine::ScrollbarOrientation::kHorizontal
+ ? WebThemeEngine::Part::kPartScrollbarHorizontalTrack
+ : WebThemeEngine::Part::kPartScrollbarVerticalTrack;
+ Platform::Current()->ThemeEngine()->Paint(
+ context.Canvas(), track_part, WebThemeEngine::State::kStateNormal,
+ WebRect(bounds), &params, params.scrollbar_extra.scrollbar_theme);
if (opacity != 1)
context.EndLayer();
}
@@ -298,10 +315,13 @@ void ScrollbarThemeMac::PaintScrollCorner(GraphicsContext& context,
GraphicsContextStateSaver state_saver(context);
context.Translate(rect.X(), rect.Y());
- SkIRect bounds = SkIRect::MakeXYWH(0, 0, rect.Width(), rect.Height());
- CocoaScrollbarPainter::Params params =
+ IntRect bounds(0, 0, rect.Width(), rect.Height());
+ WebThemeEngine::ExtraParams params =
GetPaintParams(*vertical_scrollbar, UsesOverlayScrollbars());
- CocoaScrollbarPainter::PaintCorner(context.Canvas(), bounds, params);
+ Platform::Current()->ThemeEngine()->Paint(
+ context.Canvas(), WebThemeEngine::Part::kPartScrollbarCorner,
+ WebThemeEngine::State::kStateNormal, WebRect(bounds), &params,
+ params.scrollbar_extra.scrollbar_theme);
}
void ScrollbarThemeMac::PaintThumbInternal(GraphicsContext& context,
@@ -360,22 +380,20 @@ void ScrollbarThemeMac::PaintThumbInternal(GraphicsContext& context,
if (!scrollbar.Enabled())
return;
- CocoaScrollbarPainter::Params params =
+ WebThemeEngine::ExtraParams params =
GetPaintParams(scrollbar, UsesOverlayScrollbars());
// Compute the bounds for the thumb, accounting for lack of engorgement.
- SkIRect bounds;
- switch (params.orientation) {
- case CocoaScrollbarPainter::Orientation::kVerticalOnRight:
- bounds = SkIRect::MakeXYWH(rect.Width() - thumb_size, 0, thumb_size,
- rect.Height());
+ IntRect bounds;
+ switch (params.scrollbar_extra.orientation) {
+ case WebThemeEngine::ScrollbarOrientation::kVerticalOnRight:
+ bounds = IntRect(rect.Width() - thumb_size, 0, thumb_size, rect.Height());
break;
- case CocoaScrollbarPainter::Orientation::kVerticalOnLeft:
- bounds = SkIRect::MakeXYWH(0, 0, thumb_size, rect.Height());
+ case WebThemeEngine::ScrollbarOrientation::kVerticalOnLeft:
+ bounds = IntRect(0, 0, thumb_size, rect.Height());
break;
- case CocoaScrollbarPainter::Orientation::kHorizontal:
- bounds = SkIRect::MakeXYWH(0, rect.Height() - thumb_size, rect.Width(),
- thumb_size);
+ case WebThemeEngine::ScrollbarOrientation::kHorizontal:
+ bounds = IntRect(0, rect.Height() - thumb_size, rect.Width(), thumb_size);
break;
}
@@ -383,7 +401,15 @@ void ScrollbarThemeMac::PaintThumbInternal(GraphicsContext& context,
FloatRect float_local_rect(local_rect);
context.BeginLayer(opacity, SkBlendMode::kSrcOver, &float_local_rect);
}
- CocoaScrollbarPainter::PaintThumb(context.Canvas(), bounds, params);
+
+ WebThemeEngine::Part thumb_part =
+ params.scrollbar_extra.orientation ==
+ WebThemeEngine::ScrollbarOrientation::kHorizontal
+ ? WebThemeEngine::Part::kPartScrollbarHorizontalThumb
+ : WebThemeEngine::Part::kPartScrollbarVerticalThumb;
+ Platform::Current()->ThemeEngine()->Paint(
+ context.Canvas(), thumb_part, WebThemeEngine::State::kStateNormal,
+ WebRect(bounds), &params, params.scrollbar_extra.scrollbar_theme);
if (opacity != 1.0f)
context.EndLayer();
}
@@ -460,6 +486,10 @@ float ScrollbarThemeMac::Opacity(const Scrollbar& scrollbar) const {
return [scrollbar_painter knobAlpha];
}
+bool ScrollbarThemeMac::JumpOnTrackClick() const {
+ return s_jump_on_track_click;
+}
+
// static
void ScrollbarThemeMac::UpdateScrollbarsWithNSDefaults(
base::Optional<float> initial_button_delay,
diff --git a/chromium/third_party/blink/renderer/core/scroll/smooth_scroll_sequencer.cc b/chromium/third_party/blink/renderer/core/scroll/smooth_scroll_sequencer.cc
index 707905fc146..cc4a299ec11 100644
--- a/chromium/third_party/blink/renderer/core/scroll/smooth_scroll_sequencer.cc
+++ b/chromium/third_party/blink/renderer/core/scroll/smooth_scroll_sequencer.cc
@@ -9,7 +9,7 @@
namespace blink {
-void SequencedScroll::Trace(Visitor* visitor) {
+void SequencedScroll::Trace(Visitor* visitor) const {
visitor->Trace(scrollable_area);
}
@@ -76,7 +76,7 @@ void SmoothScrollSequencer::DidDisposeScrollableArea(
}
}
-void SmoothScrollSequencer::Trace(Visitor* visitor) {
+void SmoothScrollSequencer::Trace(Visitor* visitor) const {
visitor->Trace(queue_);
visitor->Trace(current_scrollable_);
}
diff --git a/chromium/third_party/blink/renderer/core/scroll/smooth_scroll_sequencer.h b/chromium/third_party/blink/renderer/core/scroll/smooth_scroll_sequencer.h
index 3d120d4cff1..98b5f196207 100644
--- a/chromium/third_party/blink/renderer/core/scroll/smooth_scroll_sequencer.h
+++ b/chromium/third_party/blink/renderer/core/scroll/smooth_scroll_sequencer.h
@@ -33,7 +33,7 @@ struct SequencedScroll final : public GarbageCollected<SequencedScroll> {
ScrollOffset scroll_offset;
mojom::blink::ScrollBehavior scroll_behavior;
- void Trace(Visitor*);
+ void Trace(Visitor*) const;
};
// A sequencer that queues the nested scrollers from inside to outside,
@@ -63,7 +63,7 @@ class CORE_EXPORT SmoothScrollSequencer final
void DidDisposeScrollableArea(const ScrollableArea&);
- void Trace(Visitor*);
+ void Trace(Visitor*) const;
private:
HeapVector<Member<SequencedScroll>> queue_;