Bug 758179. Part 1: Flush layout before calling nsFrame::HandlePress/HandleRelease. r=mats
authorRobert O'Callahan <robert@ocallahan.org>
Wed, 30 May 2012 01:13:36 +1200
changeset 95176 e10eadfc8734a8ee97db9b7c09370ab1029d4432
parent 95175 5a1073bd1865b415513d0be548adedc946c41484
child 95177 d8688d0836cf6d6eac8ac6acdc3d7e57fb4d60f6
push id22791
push useremorley@mozilla.com
push dateWed, 30 May 2012 11:23:53 +0000
treeherdermozilla-central@b5af439f1717 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats
bugs758179
milestone15.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 758179. Part 1: Flush layout before calling nsFrame::HandlePress/HandleRelease. r=mats
layout/base/nsPresShell.cpp
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -457,16 +457,25 @@ public:
 class NS_STACK_CLASS nsPresShellEventCB : public nsDispatchingCallback
 {
 public:
   nsPresShellEventCB(PresShell* aPresShell) : mPresShell(aPresShell) {}
 
   virtual void HandleEvent(nsEventChainPostVisitor& aVisitor)
   {
     if (aVisitor.mPresContext && aVisitor.mEvent->eventStructType != NS_EVENT) {
+      if (aVisitor.mEvent->message == NS_MOUSE_BUTTON_DOWN ||
+          aVisitor.mEvent->message == NS_MOUSE_BUTTON_UP) {
+        // Mouse-up and mouse-down events call nsFrame::HandlePress/Release
+        // which call GetContentOffsetsFromPoint which requires up-to-date layout.
+        // Bring layout up-to-date now so that GetCurrentEventFrame() below
+        // will return a real frame and we don't have to worry about
+        // destroying it by flushing later.
+        mPresShell->FlushPendingNotifications(Flush_Layout);
+      }
       nsIFrame* frame = mPresShell->GetCurrentEventFrame();
       if (frame) {
         frame->HandleEvent(aVisitor.mPresContext,
                            (nsGUIEvent*) aVisitor.mEvent,
                            &aVisitor.mEventStatus);
       }
     }
   }