Bug 1315245 - Part 2: StopTrackingDragGesture when preventDefault is called. r=smaug
authorStone Shih <sshih@mozilla.com>
Tue, 29 Nov 2016 15:04:37 +0800
changeset 326078 0b69c1a656b339ee90fb391ae5c384482a850531
parent 326077 42954e822c47f7ab9107279fb05db56f459e41cf
child 326079 3ae78eda5a0c2f2b0f57650e9b62656e11818a3c
push id84875
push userryanvm@gmail.com
push dateFri, 16 Dec 2016 02:48:21 +0000
treeherdermozilla-inbound@016b87fe9145 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1315245
milestone53.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 1315245 - Part 2: StopTrackingDragGesture when preventDefault is called. r=smaug
dom/events/EventStateManager.cpp
--- a/dom/events/EventStateManager.cpp
+++ b/dom/events/EventStateManager.cpp
@@ -2943,17 +2943,24 @@ EventStateManager::PostHandleEvent(nsPre
       // events will continue to be dispatched to this element and therefore forwarded
       // to the child.
       if (dispatchedToContentProcess && !nsIPresShell::GetCapturingContent()) {
         nsIContent* content = mCurrentTarget ? mCurrentTarget->GetContent() : nullptr;
         nsIPresShell::SetCapturingContent(content, 0);
       }
 
       nsCOMPtr<nsIContent> activeContent;
-      if (nsEventStatus_eConsumeNoDefault != *aStatus) {
+      // When content calls PreventDefault on pointerdown, we also call
+      // PreventDefault on the subsequent mouse events to suppress default
+      // behaviors. Normally, aStatus should be nsEventStatus_eConsumeNoDefault
+      // when the event is DefaultPrevented but it's reset to
+      // nsEventStatus_eIgnore in EventStateManager::PreHandleEvent. So we also
+      // check if the event is DefaultPrevented.
+      if (nsEventStatus_eConsumeNoDefault != *aStatus &&
+          !aEvent->DefaultPrevented()) {
         nsCOMPtr<nsIContent> newFocus;      
         bool suppressBlur = false;
         if (mCurrentTarget) {
           mCurrentTarget->GetContentForEvent(aEvent, getter_AddRefs(newFocus));
           const nsStyleUserInterface* ui = mCurrentTarget->StyleUserInterface();
           activeContent = mCurrentTarget->GetContent();
 
           // In some cases, we do not want to even blur the current focused