From 05fec77aa1354e5d78a4f90aa8bb0c5a3d04095d Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Fri, 8 Apr 2011 12:06:36 -0700 Subject: [PATCH] Bug 279629. Allow scrolling to anchors to use smooth scrolling. r=mats --- layout/base/nsIPresShell.h | 7 ++++--- layout/base/nsPresShell.cpp | 12 ++++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/layout/base/nsIPresShell.h b/layout/base/nsIPresShell.h index 7a90912e51b..3b49d50f84c 100644 --- a/layout/base/nsIPresShell.h +++ b/layout/base/nsIPresShell.h @@ -139,8 +139,8 @@ typedef struct CapturingContentInfo { } CapturingContentInfo; #define NS_IPRESSHELL_IID \ - { 0x3a8030b5, 0x8d2c, 0x4cb3, \ - { 0xb5, 0xae, 0xb2, 0x43, 0xa9, 0x28, 0x02, 0x82 } } + { 0xfd4ba6e3, 0x921c, 0x4058, \ + { 0xa6, 0x1b, 0xc7, 0x14, 0x5e, 0x80, 0x50, 0x1f } } // Constants for ScrollContentIntoView() function #define NS_PRESSHELL_SCROLL_TOP 0 @@ -573,7 +573,8 @@ public: enum { SCROLL_FIRST_ANCESTOR_ONLY = 0x01, SCROLL_OVERFLOW_HIDDEN = 0x02, - SCROLL_NO_PARENT_FRAMES = 0x04 + SCROLL_NO_PARENT_FRAMES = 0x04, + SCROLL_ALLOW_SMOOTH = 0x08 }; /** * Scrolls the view of the document so that the given area of a frame diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 789c376f288..a954fab4173 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -224,7 +224,8 @@ #define NS_TIME_FUNCTION_WITH_DOCURL do{} while(0) #endif -#define ANCHOR_SCROLL_FLAGS (SCROLL_OVERFLOW_HIDDEN | SCROLL_NO_PARENT_FRAMES) +static const PRUint32 ANCHOR_SCROLL_FLAGS = + SCROLL_OVERFLOW_HIDDEN | SCROLL_NO_PARENT_FRAMES | SCROLL_ALLOW_SMOOTH; #include "nsContentCID.h" static NS_DEFINE_IID(kRangeCID, NS_RANGE_CID); @@ -1194,8 +1195,9 @@ protected: // Information needed to properly handle scrolling content into view if the // pre-scroll reflow flush can be interrupted. mContentToScrollTo is // non-null between the initial scroll attempt and the first time we finish - // processing all our dirty roots. mContentScrollVPosition and - // mContentScrollHPosition are only used when it's non-null. + // processing all our dirty roots. mContentScrollVPosition, + // mContentScrollHPosition and mContentToScrollToFlags are only used when + // it's non-null. nsCOMPtr mContentToScrollTo; PRIntn mContentScrollVPosition; PRIntn mContentScrollHPosition; @@ -4149,7 +4151,9 @@ static void ScrollToShowRect(nsIScrollableFrame* aScrollFrame, } } - aScrollFrame->ScrollTo(scrollPt, nsIScrollableFrame::INSTANT); + aScrollFrame->ScrollTo(scrollPt, + (aFlags & nsIPresShell::SCROLL_ALLOW_SMOOTH) ? nsIScrollableFrame::SMOOTH : + nsIScrollableFrame::INSTANT); } nsresult