diff --git a/content/events/src/nsEventListenerManager.cpp b/content/events/src/nsEventListenerManager.cpp index 1e9422de3ff..8e7267c1625 100644 --- a/content/events/src/nsEventListenerManager.cpp +++ b/content/events/src/nsEventListenerManager.cpp @@ -282,9 +282,7 @@ nsEventListenerManager::AddEventListener(nsIDOMEventListener *aListener, aTypeAtom == nsGkAtoms::ontouchcancel)) { mMayHaveTouchEventListener = true; nsPIDOMWindow* window = GetInnerWindowForTarget(); - // we don't want touchevent listeners added by scrollbars to flip this flag - // so we ignore listeners created with system event flag - if (window && !(aFlags & NS_EVENT_FLAG_SYSTEM_EVENT)) + if (window) window->SetHasTouchEventListeners(); } else if (aTypeAtom == nsGkAtoms::onmouseenter || aTypeAtom == nsGkAtoms::onmouseleave) { diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index d7bfb30faf1..f1f1bab0a7f 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -5901,47 +5901,6 @@ PresShell::HandleEvent(nsIFrame *aFrame, PresShell* shell = static_cast(frame->PresContext()->PresShell()); - switch (aEvent->message) { - case NS_TOUCH_MOVE: - case NS_TOUCH_CANCEL: - case NS_TOUCH_END: { - // Remove the changed touches - // need to make sure we only remove touches that are ending here - nsTouchEvent* touchEvent = static_cast(aEvent); - nsTArray > &touches = touchEvent->touches; - for (PRUint32 i = 0; i < touches.Length(); ++i) { - nsIDOMTouch *touch = touches[i]; - if (!touch) { - break; - } - - PRInt32 id; - touch->GetIdentifier(&id); - nsCOMPtr oldTouch; - gCaptureTouchList.Get(id, getter_AddRefs(oldTouch)); - if (!oldTouch) { - break; - } - - nsCOMPtr targetPtr; - oldTouch->GetTarget(getter_AddRefs(targetPtr)); - nsCOMPtr content = do_QueryInterface(targetPtr); - if (!content) { - break; - } - - nsIFrame* contentFrame = content->GetPrimaryFrame(); - if (!contentFrame) { - break; - } - - shell = static_cast( - contentFrame->PresContext()->PresShell()); - } - break; - } - } - // Check if we have an active EventStateManager which isn't the // EventStateManager of the current PresContext. // If that is the case, and mouse is over some ancestor document, @@ -6518,22 +6477,7 @@ PresShell::DispatchTouchEvent(nsEvent *aEvent, touchEvent); newEvent.target = targetPtr; - // If someone is capturing, all touch events are filtered to their target - nsCOMPtr content = GetCapturingContent(); - - // if no one is capturing, set the capturing target - if (!content) { - content = do_QueryInterface(targetPtr); - } - PresShell* contentPresShell = nsnull; - if (content && content->OwnerDoc() == mDocument) { - contentPresShell = static_cast - (content->OwnerDoc()->GetShell()); - if (contentPresShell) { - contentPresShell->PushCurrentEventInfo( - content->GetPrimaryFrame(), content); - } - } + nsCOMPtr content(do_QueryInterface(targetPtr)); nsPresContext *context = nsContentUtils::GetContextForContent(content); if (!context) { context = mPresContext; @@ -6544,9 +6488,6 @@ PresShell::DispatchTouchEvent(nsEvent *aEvent, if (nsEventStatus_eConsumeNoDefault == tmpStatus) { preventDefault = true; } - if (contentPresShell) { - contentPresShell->PopCurrentEventInfo(); - } } } else { // touchevents need to have the target attribute set on each touch diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index 304d564247b..87dd6490f2d 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -2257,16 +2257,15 @@ nsFrame::HandleEvent(nsPresContext* aPresContext, nsEventStatus* aEventStatus) { - if (aEvent->message == NS_MOUSE_MOVE || aEvent->message == NS_TOUCH_MOVE) { + if (aEvent->message == NS_MOUSE_MOVE) { return HandleDrag(aPresContext, aEvent, aEventStatus); } - if ((aEvent->eventStructType == NS_MOUSE_EVENT && - static_cast(aEvent)->button == nsMouseEvent::eLeftButton) || - aEvent->eventStructType == NS_TOUCH_EVENT) { - if (aEvent->message == NS_MOUSE_BUTTON_DOWN || aEvent->message == NS_TOUCH_START) { + if (aEvent->eventStructType == NS_MOUSE_EVENT && + static_cast(aEvent)->button == nsMouseEvent::eLeftButton) { + if (aEvent->message == NS_MOUSE_BUTTON_DOWN) { HandlePress(aPresContext, aEvent, aEventStatus); - } else if (aEvent->message == NS_MOUSE_BUTTON_UP || aEvent->message == NS_TOUCH_END) { + } else if (aEvent->message == NS_MOUSE_BUTTON_UP) { HandleRelease(aPresContext, aEvent, aEventStatus); } } diff --git a/layout/xul/base/src/nsSliderFrame.cpp b/layout/xul/base/src/nsSliderFrame.cpp index 32585012191..e38263db5f6 100644 --- a/layout/xul/base/src/nsSliderFrame.cpp +++ b/layout/xul/base/src/nsSliderFrame.cpp @@ -20,7 +20,6 @@ #include "nsHTMLParts.h" #include "nsIPresShell.h" #include "nsCSSRendering.h" -#include "nsDOMTouchEvent.h" #include "nsEventListenerManager.h" #include "nsIDOMEventTarget.h" #include "nsIDOMMouseEvent.h" @@ -438,12 +437,9 @@ nsSliderFrame::HandleEvent(nsPresContext* aPresContext, if (isDraggingThumb()) { switch (aEvent->message) { - case NS_TOUCH_MOVE: case NS_MOUSE_MOVE: { - nsPoint eventPoint; - if (!GetEventPoint(aEvent, eventPoint)) { - break; - } + nsPoint eventPoint = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, + this); if (mChange) { // We're in the process of moving the thumb to the mouse, // but the mouse just moved. Make sure to update our @@ -483,9 +479,6 @@ nsSliderFrame::HandleEvent(nsPresContext* aPresContext, isMouseOutsideThumb = true; } } - if (aEvent->eventStructType == NS_TOUCH_EVENT) { - *aEventStatus = nsEventStatus_eConsumeNoDefault; - } if (isMouseOutsideThumb) { SetCurrentThumbPosition(scrollbar, mThumbStart, false, true, false); @@ -497,10 +490,8 @@ nsSliderFrame::HandleEvent(nsPresContext* aPresContext, } break; - case NS_TOUCH_END: case NS_MOUSE_BUTTON_UP: - if (aEvent->message == NS_TOUCH_END || - static_cast(aEvent)->button == nsMouseEvent::eLeftButton || + if (static_cast(aEvent)->button == nsMouseEvent::eLeftButton || (static_cast(aEvent)->button == nsMouseEvent::eMiddleButton && gMiddlePref)) { // stop capturing @@ -528,13 +519,10 @@ nsSliderFrame::HandleEvent(nsPresContext* aPresContext, #endif (gMiddlePref && aEvent->message == NS_MOUSE_BUTTON_DOWN && static_cast(aEvent)->button == - nsMouseEvent::eMiddleButton) || - (aEvent->message == NS_TOUCH_START && GetScrollToClick())) { + nsMouseEvent::eMiddleButton)) { - nsPoint eventPoint; - if (!GetEventPoint(aEvent, eventPoint)) { - return NS_OK; - } + nsPoint eventPoint = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, + this); nscoord pos = isHorizontal ? eventPoint.x : eventPoint.y; // adjust so that the middle of the thumb is placed under the click @@ -552,9 +540,6 @@ nsSliderFrame::HandleEvent(nsPresContext* aPresContext, NS_ENSURE_TRUE(weakFrame.IsAlive(), NS_OK); DragThumb(true); - if (aEvent->eventStructType == NS_TOUCH_EVENT) { - *aEventStatus = nsEventStatus_eConsumeNoDefault; - } if (isHorizontal) mThumbStart = thumbFrame->GetPosition().x; @@ -574,40 +559,6 @@ nsSliderFrame::HandleEvent(nsPresContext* aPresContext, return nsFrame::HandleEvent(aPresContext, aEvent, aEventStatus); } -bool -nsSliderFrame::GetEventPoint(nsGUIEvent* aEvent, nsPoint &aPoint) { - nsIntPoint refPoint; - nsresult rv; - if (aEvent->eventStructType == NS_TOUCH_EVENT) { - rv = GetTouchPoint(static_cast(aEvent), refPoint); - if (NS_FAILED(rv)) - return false; - } else { - refPoint = aEvent->refPoint; - } - aPoint = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, refPoint, this); - return true; -} - -bool -nsSliderFrame::GetTouchPoint(nsTouchEvent* aEvent, nsIntPoint &aPoint) -{ - NS_ENSURE_ARG_POINTER(aEvent); - // return false if there is more than one touch on the page, or if - // we can't find a touch point - if (aEvent->touches.Length() != 1) { - return false; - } - - nsIDOMTouch *touch = aEvent->touches.SafeElementAt(0); - if (!touch) { - return false; - } - nsDOMTouch* domtouch = static_cast(touch); - aPoint = domtouch->mRefPoint; - return true; -} - // Helper function to collect the "scroll to click" metric. Beware of // caching this, users expect to be able to change the system preference // and see the browser change its behavior immediately. @@ -873,47 +824,44 @@ nsSliderMediator::HandleEvent(nsIDOMEvent* aEvent) { // Only process the event if the thumb is not being dragged. if (mSlider && !mSlider->isDraggingThumb()) - return mSlider->StartDrag(aEvent); + return mSlider->MouseDown(aEvent); return NS_OK; } nsresult -nsSliderFrame::StartDrag(nsIDOMEvent* aEvent) +nsSliderFrame::MouseDown(nsIDOMEvent* aMouseEvent) { #ifdef DEBUG_SLIDER printf("Begin dragging\n"); #endif + nsCOMPtr mouseEvent(do_QueryInterface(aMouseEvent)); + if (!mouseEvent) + return NS_OK; + if (mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::disabled, nsGkAtoms::_true, eCaseMatters)) return NS_OK; - bool isHorizontal = IsHorizontal(); - bool scrollToClick = false; - - nsCOMPtr mouseEvent(do_QueryInterface(aEvent)); - if (mouseEvent) { - PRUint16 button = 0; - mouseEvent->GetButton(&button); - if (!(button == 0 || (button == 1 && gMiddlePref))) - return NS_OK; - -#ifndef XP_MACOSX - // On Mac there's no scroll-to-here when clicking the thumb - mouseEvent->GetShiftKey(&scrollToClick); - if (button != 0) { - scrollToClick = true; - } -#endif - } - - nsGUIEvent *event = static_cast(aEvent->GetInternalNSEvent()); - - nsPoint pt; - if (!GetEventPoint(event, pt)) { + PRUint16 button = 0; + mouseEvent->GetButton(&button); + if (!(button == 0 || (button == 1 && gMiddlePref))) return NS_OK; + + bool isHorizontal = IsHorizontal(); + + bool scrollToClick = false; +#ifndef XP_MACOSX + // On Mac there's no scroll-to-here when clicking the thumb + mouseEvent->GetShiftKey(&scrollToClick); + if (button != 0) { + scrollToClick = true; } +#endif + + nsPoint pt = nsLayoutUtils::GetDOMEventCoordinatesRelativeTo(mouseEvent, + this); nscoord pos = isHorizontal ? pt.x : pt.y; // If shift click or middle button, first @@ -998,9 +946,6 @@ nsSliderFrame::AddListener() thumbFrame->GetContent()-> AddSystemEventListener(NS_LITERAL_STRING("mousedown"), mMediator, false, false); - thumbFrame->GetContent()-> - AddSystemEventListener(NS_LITERAL_STRING("touchstart"), mMediator, - false, false); } void @@ -1021,21 +966,13 @@ nsSliderFrame::HandlePress(nsPresContext* aPresContext, nsGUIEvent* aEvent, nsEventStatus* aEventStatus) { - if (aEvent->message == NS_TOUCH_START && GetScrollToClick()) { - printf("Bailing for touch\n"); - return NS_OK; - } - - if (aEvent->message == NS_MOUSE_BUTTON_DOWN) { #ifdef XP_MACOSX - // On Mac the option key inverts the scroll-to-here preference. - if (((nsMouseEvent *)aEvent)->IsAlt() != GetScrollToClick()) { + // On Mac the option key inverts the scroll-to-here preference. + if (((nsMouseEvent *)aEvent)->IsAlt() != GetScrollToClick()) #else - if (((nsMouseEvent *)aEvent)->IsShift() != GetScrollToClick()) { + if (((nsMouseEvent *)aEvent)->IsShift() != GetScrollToClick()) #endif - return NS_OK; - } - } + return NS_OK; nsIFrame* thumbFrame = mFrames.FirstChild(); if (!thumbFrame) // display:none? @@ -1048,10 +985,8 @@ nsSliderFrame::HandlePress(nsPresContext* aPresContext, nsRect thumbRect = thumbFrame->GetRect(); nscoord change = 1; - nsPoint eventPoint; - if (!GetEventPoint(aEvent, eventPoint)) { - return NS_OK; - } + nsPoint eventPoint = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, + this); if (IsHorizontal() ? eventPoint.x < thumbRect.x : eventPoint.y < thumbRect.y) change = -1; diff --git a/layout/xul/base/src/nsSliderFrame.h b/layout/xul/base/src/nsSliderFrame.h index 03d707ff0e2..270b375535b 100644 --- a/layout/xul/base/src/nsSliderFrame.h +++ b/layout/xul/base/src/nsSliderFrame.h @@ -97,7 +97,7 @@ public: virtual nsIAtom* GetType() const; - nsresult StartDrag(nsIDOMEvent* aEvent); + nsresult MouseDown(nsIDOMEvent* aMouseEvent); static PRInt32 GetCurrentPosition(nsIContent* content); static PRInt32 GetMinPosition(nsIContent* content); @@ -138,16 +138,6 @@ private: bool aIsSmooth, bool aImmediateRedraw); nsresult CurrentPositionChanged(nsPresContext* aPresContext, bool aImmediateRedraw); - - // Get the point associated with this event. Returns true if a valid point - // was found. Otherwise false. - bool GetEventPoint(nsGUIEvent *aEvent, nsPoint &aPoint); - - // Get the point associated with this touch event. Returns true if a valid point - // was found. False if there is more than one touch present on the page, or - // if a point could not be found for the given touch. - bool GetTouchPoint(nsTouchEvent *aEvent, nsIntPoint &aPoint); - void DragThumb(bool aGrabMouseEvents); void AddListener(); void RemoveListener(); diff --git a/toolkit/content/tests/chrome/Makefile.in b/toolkit/content/tests/chrome/Makefile.in index 70c1d083481..df14b7b8c68 100644 --- a/toolkit/content/tests/chrome/Makefile.in +++ b/toolkit/content/tests/chrome/Makefile.in @@ -100,7 +100,6 @@ MOCHITEST_CHROME_FILES = findbar_window.xul \ test_popup_preventdefault.xul \ test_notificationbox.xul \ test_scale.xul \ - test_scaledrag.xul \ test_radio.xul \ test_tabbox.xul \ test_progressmeter.xul \ diff --git a/toolkit/content/tests/chrome/test_scaledrag.xul b/toolkit/content/tests/chrome/test_scaledrag.xul deleted file mode 100644 index 82356ca1ec3..00000000000 --- a/toolkit/content/tests/chrome/test_scaledrag.xul +++ /dev/null @@ -1,197 +0,0 @@ - - - - - - - - - - - - - - - -

- -
-
- - - - -
diff --git a/toolkit/content/widgets/videocontrols.xml b/toolkit/content/widgets/videocontrols.xml index dc48f2fc2af..16581b74b15 100644 --- a/toolkit/content/widgets/videocontrols.xml +++ b/toolkit/content/widgets/videocontrols.xml @@ -133,7 +133,6 @@ if (this.type == "scrubber") { // Update the time shown in the thumb. this.thumb.setTime(newValue); - this.Utils.positionLabel.setAttribute("value", this.thumb.timeLabel.value); // Update the value bar to match the thumb position. var percent = newValue / this.max; this.valueBar.value = Math.round(percent * 10000); // has max=10000 @@ -1552,15 +1551,11 @@ } }, - clearTimer: function() { + delayHideControls : function(aTimeout) { if (this.controlsTimer) { clearTimeout(this.controlsTimer); this.controlsTimer = null; } - }, - - delayHideControls : function(aTimeout) { - this.clearTimer(); let self = this; this.controlsTimer = setTimeout(function() { self.hideControls(); @@ -1603,12 +1598,7 @@ else self.showControls(); }, false); - this.Utils.scrubber.addEventListener("touchstart", function() { - self.clearTimer(); - }, false); - this.Utils.scrubber.addEventListener("touchend", function() { - self.delayHideControls(self.controlsTimeout); - }, false); + this.Utils.scrubber.addEventListener("click", function() { self.delayHideControls(self.controlsTimeout); }, false); this.Utils.muteButton.addEventListener("click", function() { self.delayHideControls(self.controlsTimeout); }, false); if (!video.autoplay && this.Utils.dynamicControls)