mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1010538 - Part 5 - Enable automatic smooth scrolling for anchor links. r=mstange
- When an anchor link is clicked, the SCROLL_SMOOTH_AUTO flag is now set by PresShell::GoToAnchor when calling PresShell::ScrollContentIntoView. - Added an arguement, aAnimateScroll, to PresShell:GoToAnchor to indicate that the scroll may be animated. This will only be set to true when an anchor link is clicked. Opening a page with an anchor link will not trigger such animations.
This commit is contained in:
parent
233c40283c
commit
14bf556ab3
@ -10730,7 +10730,8 @@ nsDocShell::ScrollToAnchor(nsACString & aCurHash, nsACString & aNewHash,
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
NS_ConvertUTF8toUTF16 uStr(str);
|
||||
if (!uStr.IsEmpty()) {
|
||||
rv = shell->GoToAnchor(NS_ConvertUTF8toUTF16(str), scroll);
|
||||
rv = shell->GoToAnchor(NS_ConvertUTF8toUTF16(str), scroll,
|
||||
nsIPresShell::SCROLL_SMOOTH_AUTO);
|
||||
}
|
||||
nsMemory::Free(str);
|
||||
|
||||
@ -10764,7 +10765,8 @@ nsDocShell::ScrollToAnchor(nsACString & aCurHash, nsACString & aNewHash,
|
||||
//
|
||||
// When newHashName contains "%00", unescaped string may be empty.
|
||||
// And GoToAnchor asserts if we ask it to scroll to an empty ref.
|
||||
shell->GoToAnchor(uStr, scroll && !uStr.IsEmpty());
|
||||
shell->GoToAnchor(uStr, scroll && !uStr.IsEmpty(),
|
||||
nsIPresShell::SCROLL_SMOOTH_AUTO);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -591,9 +591,11 @@ public:
|
||||
* document so that the anchor with the specified name is displayed at
|
||||
* the top of the window. If |aAnchorName| is empty, then this informs
|
||||
* the pres shell that there is no current target, and |aScroll| must
|
||||
* be false.
|
||||
* be false. If |aAdditionalScrollFlags| is nsIPresShell::SCROLL_SMOOTH_AUTO
|
||||
* and |aScroll| is true, the scrolling may be performed with an animation.
|
||||
*/
|
||||
virtual nsresult GoToAnchor(const nsAString& aAnchorName, bool aScroll) = 0;
|
||||
virtual nsresult GoToAnchor(const nsAString& aAnchorName, bool aScroll,
|
||||
uint32_t aAdditionalScrollFlags = 0) = 0;
|
||||
|
||||
/**
|
||||
* Tells the presshell to scroll again to the last anchor scrolled to by
|
||||
|
@ -3081,7 +3081,8 @@ PresShell::CreateReferenceRenderingContext()
|
||||
}
|
||||
|
||||
nsresult
|
||||
PresShell::GoToAnchor(const nsAString& aAnchorName, bool aScroll)
|
||||
PresShell::GoToAnchor(const nsAString& aAnchorName, bool aScroll,
|
||||
uint32_t aAdditionalScrollFlags)
|
||||
{
|
||||
if (!mDocument) {
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -3188,7 +3189,7 @@ PresShell::GoToAnchor(const nsAString& aAnchorName, bool aScroll)
|
||||
rv = ScrollContentIntoView(content,
|
||||
ScrollAxis(SCROLL_TOP, SCROLL_ALWAYS),
|
||||
ScrollAxis(),
|
||||
ANCHOR_SCROLL_FLAGS);
|
||||
ANCHOR_SCROLL_FLAGS | aAdditionalScrollFlags);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsIScrollableFrame* rootScroll = GetRootScrollFrameAsScrollable();
|
||||
|
@ -123,7 +123,8 @@ public:
|
||||
|
||||
virtual void ClearFrameRefs(nsIFrame* aFrame) MOZ_OVERRIDE;
|
||||
virtual already_AddRefed<nsRenderingContext> CreateReferenceRenderingContext();
|
||||
virtual nsresult GoToAnchor(const nsAString& aAnchorName, bool aScroll) MOZ_OVERRIDE;
|
||||
virtual nsresult GoToAnchor(const nsAString& aAnchorName, bool aScroll,
|
||||
uint32_t aAdditionalScrollFlags = 0) MOZ_OVERRIDE;
|
||||
virtual nsresult ScrollToAnchor() MOZ_OVERRIDE;
|
||||
|
||||
virtual nsresult ScrollContentIntoView(nsIContent* aContent,
|
||||
|
Loading…
Reference in New Issue
Block a user