From b94de096af8cd5a6e7b6000d763e0d9798c2fafc Mon Sep 17 00:00:00 2001 From: "masayuki%d-toybox.com" Date: Wed, 1 Feb 2006 19:55:35 +0000 Subject: [PATCH] Bug 258006 Mouse-wheel scroll events does not propagate to viewport from fixed pos. elements r+sr=roc git-svn-id: svn://10.0.0.236/trunk@188690 18797224-902f-48f8-a5cc-f745e15eee43 --- .../events/src/nsEventStateManager.cpp | 15 ++++++++- mozilla/layout/base/nsIPresShell.h | 9 +++-- mozilla/layout/base/nsPresShell.cpp | 33 +++++++++---------- 3 files changed, 37 insertions(+), 20 deletions(-) diff --git a/mozilla/content/events/src/nsEventStateManager.cpp b/mozilla/content/events/src/nsEventStateManager.cpp index c5a14cc3fd4..1bed7a568a7 100644 --- a/mozilla/content/events/src/nsEventStateManager.cpp +++ b/mozilla/content/events/src/nsEventStateManager.cpp @@ -1644,6 +1644,18 @@ ShouldScrollRootView(nsPresContext* aPresContext) return (aPresContext->Type() == nsPresContext::eContext_PrintPreview); } +static nsIFrame* +GetParentFrameToScroll(nsPresContext* aPresContext, nsIFrame* aFrame) +{ + if (!aPresContext || !aFrame) + return nsnull; + + if (aFrame->GetStyleDisplay()->mPosition == NS_STYLE_POSITION_FIXED) + return aPresContext->GetPresShell()->GetRootScrollFrame(); + + return aFrame->GetParent(); +} + nsresult nsEventStateManager::DoScrollText(nsPresContext* aPresContext, nsIFrame* aTargetFrame, @@ -1750,7 +1762,8 @@ nsEventStateManager::DoScrollText(nsPresContext* aPresContext, nsIFrame* scrollFrame = aTargetFrame; PRBool passToParent = !scrollRootView; - for( ; scrollFrame && passToParent; scrollFrame = scrollFrame->GetParent()) { + for (; scrollFrame && passToParent; + scrollFrame = GetParentFrameToScroll(aPresContext, scrollFrame)) { // Check whether the frame wants to provide us with a scrollable view. scrollView = nsnull; nsCOMPtr svp = do_QueryInterface(scrollFrame); diff --git a/mozilla/layout/base/nsIPresShell.h b/mozilla/layout/base/nsIPresShell.h index 35aba583ca8..99f569f8d51 100644 --- a/mozilla/layout/base/nsIPresShell.h +++ b/mozilla/layout/base/nsIPresShell.h @@ -93,8 +93,8 @@ class nsCSSFrameConstructor; class nsISelection; #define NS_IPRESSHELL_IID \ -{ 0x775a6c25, 0x326f, 0x4a99, \ - { 0xbb, 0x9d, 0x65, 0xdf, 0x15, 0xb3, 0x06, 0xa3 } } +{ 0xcd6d6c1d, 0x4180, 0x432a, \ + { 0x83, 0xbb, 0x1f, 0xc6, 0x50, 0xd2, 0x11, 0xa7 } } // Constants uses for ScrollFrameIntoView() function #define NS_PRESSHELL_SCROLL_TOP 0 @@ -291,6 +291,11 @@ public: */ virtual NS_HIDDEN_(nsIFrame*) GetRootFrame() const; + /* + * Get root scroll frame from FrameManager()->GetRootFrame(). + */ + nsIFrame* GetRootScrollFrame() const; + /** * Returns the page sequence frame associated with the frame hierarchy. * Returns NULL if not a paginated view. diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index 6b9f1e350b7..fdb1f7f9638 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -2658,19 +2658,6 @@ static void CheckForFocus(nsPIDOMWindow* aOurWindow, aFocusController->SetFocusedWindow(ourWin); } -static nsIFrame* -GetRootScrollFrame(nsIFrame* aRootFrame) { - // Ensure root frame is a viewport frame - if (aRootFrame && nsLayoutAtoms::viewportFrame == aRootFrame->GetType()) { - nsIFrame* theFrame = aRootFrame->GetFirstChild(nsnull); - if (theFrame && nsLayoutAtoms::scrollFrame == theFrame->GetType()) { - return theFrame; - } - } - - return nsnull; -} - NS_IMETHODIMP PresShell::GetDidInitialReflow(PRBool *aDidInitialReflow) { @@ -3409,6 +3396,19 @@ nsIPresShell::GetRootFrame() const return FrameManager()->GetRootFrame(); } +nsIFrame* +nsIPresShell::GetRootScrollFrame() const +{ + nsIFrame* rootFrame = FrameManager()->GetRootFrame(); + // Ensure root frame is a viewport frame + if (!rootFrame || nsLayoutAtoms::viewportFrame != rootFrame->GetType()) + return nsnull; + nsIFrame* theFrame = rootFrame->GetFirstChild(nsnull); + if (!theFrame || nsLayoutAtoms::scrollFrame != theFrame->GetType()) + return nsnull; + return theFrame; +} + NS_IMETHODIMP PresShell::GetPageSequenceFrame(nsIPageSequenceFrame** aResult) const { @@ -3469,7 +3469,6 @@ PresShell::EndLoad(nsIDocument *aDocument) { // Restore frame state for the root scroll frame - nsIFrame* rootFrame = FrameManager()->GetRootFrame(); nsCOMPtr historyState = aDocument->GetLayoutHistoryState(); // Make sure we don't reenter reflow via the sync paint that happens while @@ -3478,8 +3477,8 @@ PresShell::EndLoad(nsIDocument *aDocument) // it'll get all confused. ++mChangeNestCount; - if (rootFrame && historyState) { - nsIFrame* scrollFrame = GetRootScrollFrame(rootFrame); + if (historyState) { + nsIFrame* scrollFrame = GetRootScrollFrame(); if (scrollFrame) { nsIScrollableFrame* scrollableFrame; CallQueryInterface(scrollFrame, &scrollableFrame); @@ -4545,7 +4544,7 @@ PresShell::CaptureHistoryState(nsILayoutHistoryState** aState, PRBool aLeavingPa // As the scroll position is 0 and this will cause us to loose // our previously saved place! if (aLeavingPage) { - nsIFrame* scrollFrame = GetRootScrollFrame(rootFrame); + nsIFrame* scrollFrame = GetRootScrollFrame(); if (scrollFrame) { FrameManager()->CaptureFrameStateFor(scrollFrame, historyState, nsIStatefulFrame::eDocumentScrollState);