diff --git a/mozilla/layout/base/nsIPresShell.h b/mozilla/layout/base/nsIPresShell.h index 0e61a289bbc..b093e5e702e 100644 --- a/mozilla/layout/base/nsIPresShell.h +++ b/mozilla/layout/base/nsIPresShell.h @@ -97,10 +97,10 @@ class nsWeakFrame; typedef short SelectionType; -// b6cf677a-aa50-47c2-b381-5a82e7e792da +// 56719ada-52e9-4d81-b23d-acba10c5c1e2 #define NS_IPRESSHELL_IID \ -{ 0xb6cf677a, 0xaa50, 0x47c2, \ - { 0xb3, 0x81, 0x5a, 0x82, 0xe7, 0xe7, 0x92, 0xda } } +{ 0x56719ada, 0x52e9, 0x4d81, \ + { 0xb2, 0x3d, 0xac, 0xba, 0x10, 0xc5, 0xc1, 0xe2 } } // Constants uses for ScrollFrameIntoView() function #define NS_PRESSHELL_SCROLL_TOP 0 @@ -376,11 +376,6 @@ public: */ NS_IMETHOD FlushPendingNotifications(mozFlushType aType) = 0; - /** - * Post a request to handle a DOM event after Reflow has finished. - */ - NS_IMETHOD PostDOMEvent(nsIContent* aContent, nsEvent* aEvent)=0; - /** * Post a request to set and attribute after reflow has finished. */ diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index 841ad8d2418..0da230e0944 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -844,11 +844,6 @@ public: */ NS_IMETHOD RecreateFramesFor(nsIContent* aContent); - /** - * Post a request to handle a DOM event after Reflow has finished. - */ - NS_IMETHOD PostDOMEvent(nsIContent* aContent, nsEvent* aEvent); - /** * Post a request to set and attribute after reflow has finished. */ @@ -1156,10 +1151,7 @@ protected: nsRevocableEventPtr mReflowEvent; - // used for list of posted events and attribute changes. To be done - // after reflow. - nsDOMEventRequest* mFirstDOMEventRequest; - nsDOMEventRequest* mLastDOMEventRequest; + // used for list of posted attribute changes. To be done after reflow. nsAttributeChangeRequest* mFirstAttributeRequest; nsAttributeChangeRequest* mLastAttributeRequest; nsCallbackEventRequest* mFirstCallbackEventRequest; @@ -1426,9 +1418,7 @@ PresShell::~PresShell() NS_ASSERTION(mCurrentEventContentStack.Count() == 0, "Huh, event content left on the stack in pres shell dtor!"); - NS_ASSERTION(mFirstDOMEventRequest == nsnull && - mLastDOMEventRequest == nsnull && - mFirstAttributeRequest == nsnull && + NS_ASSERTION(mFirstAttributeRequest == nsnull && mLastAttributeRequest == nsnull && mFirstCallbackEventRequest == nsnull && mLastCallbackEventRequest == nsnull, @@ -4671,39 +4661,6 @@ PresShell::CancelReflowCallback(nsIReflowCallback* aCallback) return NS_OK; } -/** -* Post a request to handle a DOM event after Reflow has finished. -* The event must have been created with the "new" operator. -*/ -NS_IMETHODIMP -PresShell::PostDOMEvent(nsIContent* aContent, nsEvent* aEvent) -{ - // ok we have a list of events to handle. Queue them up and handle them - // after we finish reflow. - - void* result = AllocateFrame(sizeof(nsDOMEventRequest)); - if (NS_UNLIKELY(!result)) { - return NS_ERROR_OUT_OF_MEMORY; - } - nsDOMEventRequest* request = (nsDOMEventRequest*)result; - - request->content = aContent; - NS_ADDREF(aContent); - - request->event = aEvent; - request->next = nsnull; - - if (mLastDOMEventRequest) { - mLastDOMEventRequest = mLastDOMEventRequest->next = request; - } else { - mFirstDOMEventRequest = request; - mLastDOMEventRequest = request; - } - - return NS_OK; -} - - /** * Post a request to set and attribute after reflow has finished. */ @@ -4767,30 +4724,6 @@ PresShell::HandlePostedReflowCallbacks() FlushPendingNotifications(Flush_Layout); } -void -PresShell::HandlePostedDOMEvents() -{ - while(mFirstDOMEventRequest) - { - /* pull the node from the event request list. Be prepared for reentrant access to the list - from within Dispatch and its callees! */ - nsDOMEventRequest* node = mFirstDOMEventRequest; - nsEventStatus status = nsEventStatus_eIgnore; - - mFirstDOMEventRequest = node->next; - if (nsnull == mFirstDOMEventRequest) { - mLastDOMEventRequest = nsnull; - } - - nsEventDispatcher::Dispatch(node->content, mPresContext, node->event, - nsnull, &status); - NS_RELEASE(node->content); - delete node->event; - node->nsDOMEventRequest::~nsDOMEventRequest(); // doesn't do anything, but just in case - FreeFrame(sizeof(nsDOMEventRequest), node); - } -} - void PresShell::HandlePostedAttributeChanges() { @@ -6174,7 +6107,6 @@ PresShell::WillDoReflow() void PresShell::DidDoReflow() { - HandlePostedDOMEvents(); HandlePostedAttributeChanges(); HandlePostedReflowCallbacks(); // Null-check mViewManager in case this happens during Destroy. See diff --git a/mozilla/layout/generic/nsGfxScrollFrame.cpp b/mozilla/layout/generic/nsGfxScrollFrame.cpp index 0b7899bddb9..81c00f78528 100644 --- a/mozilla/layout/generic/nsGfxScrollFrame.cpp +++ b/mozilla/layout/generic/nsGfxScrollFrame.cpp @@ -1532,6 +1532,24 @@ nsGfxScrollFrameInner::ScrollToRestoredPosition() } } +class nsAsyncScrollPortEvent : public nsRunnable +{ +public: + // nsAsyncScrollPortEvent owns aEvent. + nsAsyncScrollPortEvent(nsIContent* aTarget, nsPresContext* aPresContext, + nsScrollPortEvent* aEvent) + : mTarget(aTarget), mPresContext(aPresContext), mEvent(aEvent) {} + + NS_IMETHOD Run() { + nsEventDispatcher::Dispatch(mTarget, mPresContext, mEvent); + return NS_OK; + } +private: + nsCOMPtr mTarget; + nsRefPtr mPresContext; + nsAutoPtr mEvent; +}; + void nsGfxScrollFrameInner::PostScrollPortEvent(PRBool aOverflow, nsScrollPortEvent::orientType aType) { @@ -1539,8 +1557,12 @@ nsGfxScrollFrameInner::PostScrollPortEvent(PRBool aOverflow, nsScrollPortEvent:: NS_SCROLLPORT_OVERFLOW : NS_SCROLLPORT_UNDERFLOW, nsnull); + ENSURE_TRUE(event); event->orient = aType; - mOuter->GetPresContext()->PresShell()->PostDOMEvent(mOuter->GetContent(), event); + nsCOMPtr ev = new nsAsyncScrollPortEvent(mOuter->GetContent(), + mOuter->GetPresContext(), + event); + NS_DispatchToCurrentThread(ev); } void