From a1a1d61fae7c0f2e8fd81777d58c9abfd85543ac Mon Sep 17 00:00:00 2001 From: "Kearwood (Kip) Gilbert" Date: Thu, 25 Sep 2014 15:52:00 +0200 Subject: [PATCH] Bug 1010538 - Part 7 - Add support to Element.ScrollLeft and Element.ScrollTop. r=mstange - Setting Element.ScrollLeft or Element.ScrollRight will now scroll smoothly if the scroll-behavior CSS property is set to "smooth". --- content/base/public/Element.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/content/base/public/Element.h b/content/base/public/Element.h index a9fa985a1910..e44a88feacf2 100644 --- a/content/base/public/Element.h +++ b/content/base/public/Element.h @@ -747,8 +747,13 @@ public: { nsIScrollableFrame* sf = GetScrollFrame(); if (sf) { + nsIScrollableFrame::ScrollMode scrollMode = nsIScrollableFrame::INSTANT; + if (sf->GetScrollbarStyles().mScrollBehavior == NS_STYLE_SCROLL_BEHAVIOR_SMOOTH) { + scrollMode = nsIScrollableFrame::SMOOTH_MSD; + } sf->ScrollToCSSPixels(CSSIntPoint(sf->GetScrollPositionCSSPixels().x, - aScrollTop)); + aScrollTop), + scrollMode); } } int32_t ScrollLeft() @@ -760,8 +765,14 @@ public: { nsIScrollableFrame* sf = GetScrollFrame(); if (sf) { + nsIScrollableFrame::ScrollMode scrollMode = nsIScrollableFrame::INSTANT; + if (sf->GetScrollbarStyles().mScrollBehavior == NS_STYLE_SCROLL_BEHAVIOR_SMOOTH) { + scrollMode = nsIScrollableFrame::SMOOTH_MSD; + } + sf->ScrollToCSSPixels(CSSIntPoint(aScrollLeft, - sf->GetScrollPositionCSSPixels().y)); + sf->GetScrollPositionCSSPixels().y), + scrollMode); } } /* Scrolls without flushing the layout.