mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backout a7d1108f70fb, e32603f16465, 142b9df4d021,
This commit is contained in:
parent
5291985f25
commit
1c845a94d4
@ -282,9 +282,7 @@ nsEventListenerManager::AddEventListener(nsIDOMEventListener *aListener,
|
|||||||
aTypeAtom == nsGkAtoms::ontouchcancel)) {
|
aTypeAtom == nsGkAtoms::ontouchcancel)) {
|
||||||
mMayHaveTouchEventListener = true;
|
mMayHaveTouchEventListener = true;
|
||||||
nsPIDOMWindow* window = GetInnerWindowForTarget();
|
nsPIDOMWindow* window = GetInnerWindowForTarget();
|
||||||
// we don't want touchevent listeners added by scrollbars to flip this flag
|
if (window)
|
||||||
// so we ignore listeners created with system event flag
|
|
||||||
if (window && !(aFlags & NS_EVENT_FLAG_SYSTEM_EVENT))
|
|
||||||
window->SetHasTouchEventListeners();
|
window->SetHasTouchEventListeners();
|
||||||
} else if (aTypeAtom == nsGkAtoms::onmouseenter ||
|
} else if (aTypeAtom == nsGkAtoms::onmouseenter ||
|
||||||
aTypeAtom == nsGkAtoms::onmouseleave) {
|
aTypeAtom == nsGkAtoms::onmouseleave) {
|
||||||
|
@ -5901,47 +5901,6 @@ PresShell::HandleEvent(nsIFrame *aFrame,
|
|||||||
PresShell* shell =
|
PresShell* shell =
|
||||||
static_cast<PresShell*>(frame->PresContext()->PresShell());
|
static_cast<PresShell*>(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<nsTouchEvent*>(aEvent);
|
|
||||||
nsTArray<nsCOMPtr<nsIDOMTouch> > &touches = touchEvent->touches;
|
|
||||||
for (PRUint32 i = 0; i < touches.Length(); ++i) {
|
|
||||||
nsIDOMTouch *touch = touches[i];
|
|
||||||
if (!touch) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
PRInt32 id;
|
|
||||||
touch->GetIdentifier(&id);
|
|
||||||
nsCOMPtr<nsIDOMTouch> oldTouch;
|
|
||||||
gCaptureTouchList.Get(id, getter_AddRefs(oldTouch));
|
|
||||||
if (!oldTouch) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsCOMPtr<nsPIDOMEventTarget> targetPtr;
|
|
||||||
oldTouch->GetTarget(getter_AddRefs(targetPtr));
|
|
||||||
nsCOMPtr<nsIContent> content = do_QueryInterface(targetPtr);
|
|
||||||
if (!content) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsIFrame* contentFrame = content->GetPrimaryFrame();
|
|
||||||
if (!contentFrame) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
shell = static_cast<PresShell*>(
|
|
||||||
contentFrame->PresContext()->PresShell());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if we have an active EventStateManager which isn't the
|
// Check if we have an active EventStateManager which isn't the
|
||||||
// EventStateManager of the current PresContext.
|
// EventStateManager of the current PresContext.
|
||||||
// If that is the case, and mouse is over some ancestor document,
|
// If that is the case, and mouse is over some ancestor document,
|
||||||
@ -6518,22 +6477,7 @@ PresShell::DispatchTouchEvent(nsEvent *aEvent,
|
|||||||
touchEvent);
|
touchEvent);
|
||||||
newEvent.target = targetPtr;
|
newEvent.target = targetPtr;
|
||||||
|
|
||||||
// If someone is capturing, all touch events are filtered to their target
|
nsCOMPtr<nsIContent> content(do_QueryInterface(targetPtr));
|
||||||
nsCOMPtr<nsIContent> 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<PresShell*>
|
|
||||||
(content->OwnerDoc()->GetShell());
|
|
||||||
if (contentPresShell) {
|
|
||||||
contentPresShell->PushCurrentEventInfo(
|
|
||||||
content->GetPrimaryFrame(), content);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
nsPresContext *context = nsContentUtils::GetContextForContent(content);
|
nsPresContext *context = nsContentUtils::GetContextForContent(content);
|
||||||
if (!context) {
|
if (!context) {
|
||||||
context = mPresContext;
|
context = mPresContext;
|
||||||
@ -6544,9 +6488,6 @@ PresShell::DispatchTouchEvent(nsEvent *aEvent,
|
|||||||
if (nsEventStatus_eConsumeNoDefault == tmpStatus) {
|
if (nsEventStatus_eConsumeNoDefault == tmpStatus) {
|
||||||
preventDefault = true;
|
preventDefault = true;
|
||||||
}
|
}
|
||||||
if (contentPresShell) {
|
|
||||||
contentPresShell->PopCurrentEventInfo();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// touchevents need to have the target attribute set on each touch
|
// touchevents need to have the target attribute set on each touch
|
||||||
|
@ -2257,16 +2257,15 @@ nsFrame::HandleEvent(nsPresContext* aPresContext,
|
|||||||
nsEventStatus* aEventStatus)
|
nsEventStatus* aEventStatus)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (aEvent->message == NS_MOUSE_MOVE || aEvent->message == NS_TOUCH_MOVE) {
|
if (aEvent->message == NS_MOUSE_MOVE) {
|
||||||
return HandleDrag(aPresContext, aEvent, aEventStatus);
|
return HandleDrag(aPresContext, aEvent, aEventStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((aEvent->eventStructType == NS_MOUSE_EVENT &&
|
if (aEvent->eventStructType == NS_MOUSE_EVENT &&
|
||||||
static_cast<nsMouseEvent*>(aEvent)->button == nsMouseEvent::eLeftButton) ||
|
static_cast<nsMouseEvent*>(aEvent)->button == nsMouseEvent::eLeftButton) {
|
||||||
aEvent->eventStructType == NS_TOUCH_EVENT) {
|
if (aEvent->message == NS_MOUSE_BUTTON_DOWN) {
|
||||||
if (aEvent->message == NS_MOUSE_BUTTON_DOWN || aEvent->message == NS_TOUCH_START) {
|
|
||||||
HandlePress(aPresContext, aEvent, aEventStatus);
|
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);
|
HandleRelease(aPresContext, aEvent, aEventStatus);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
#include "nsHTMLParts.h"
|
#include "nsHTMLParts.h"
|
||||||
#include "nsIPresShell.h"
|
#include "nsIPresShell.h"
|
||||||
#include "nsCSSRendering.h"
|
#include "nsCSSRendering.h"
|
||||||
#include "nsDOMTouchEvent.h"
|
|
||||||
#include "nsEventListenerManager.h"
|
#include "nsEventListenerManager.h"
|
||||||
#include "nsIDOMEventTarget.h"
|
#include "nsIDOMEventTarget.h"
|
||||||
#include "nsIDOMMouseEvent.h"
|
#include "nsIDOMMouseEvent.h"
|
||||||
@ -438,12 +437,9 @@ nsSliderFrame::HandleEvent(nsPresContext* aPresContext,
|
|||||||
if (isDraggingThumb())
|
if (isDraggingThumb())
|
||||||
{
|
{
|
||||||
switch (aEvent->message) {
|
switch (aEvent->message) {
|
||||||
case NS_TOUCH_MOVE:
|
|
||||||
case NS_MOUSE_MOVE: {
|
case NS_MOUSE_MOVE: {
|
||||||
nsPoint eventPoint;
|
nsPoint eventPoint = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent,
|
||||||
if (!GetEventPoint(aEvent, eventPoint)) {
|
this);
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (mChange) {
|
if (mChange) {
|
||||||
// We're in the process of moving the thumb to the mouse,
|
// We're in the process of moving the thumb to the mouse,
|
||||||
// but the mouse just moved. Make sure to update our
|
// but the mouse just moved. Make sure to update our
|
||||||
@ -483,9 +479,6 @@ nsSliderFrame::HandleEvent(nsPresContext* aPresContext,
|
|||||||
isMouseOutsideThumb = true;
|
isMouseOutsideThumb = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (aEvent->eventStructType == NS_TOUCH_EVENT) {
|
|
||||||
*aEventStatus = nsEventStatus_eConsumeNoDefault;
|
|
||||||
}
|
|
||||||
if (isMouseOutsideThumb)
|
if (isMouseOutsideThumb)
|
||||||
{
|
{
|
||||||
SetCurrentThumbPosition(scrollbar, mThumbStart, false, true, false);
|
SetCurrentThumbPosition(scrollbar, mThumbStart, false, true, false);
|
||||||
@ -497,10 +490,8 @@ nsSliderFrame::HandleEvent(nsPresContext* aPresContext,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NS_TOUCH_END:
|
|
||||||
case NS_MOUSE_BUTTON_UP:
|
case NS_MOUSE_BUTTON_UP:
|
||||||
if (aEvent->message == NS_TOUCH_END ||
|
if (static_cast<nsMouseEvent*>(aEvent)->button == nsMouseEvent::eLeftButton ||
|
||||||
static_cast<nsMouseEvent*>(aEvent)->button == nsMouseEvent::eLeftButton ||
|
|
||||||
(static_cast<nsMouseEvent*>(aEvent)->button == nsMouseEvent::eMiddleButton &&
|
(static_cast<nsMouseEvent*>(aEvent)->button == nsMouseEvent::eMiddleButton &&
|
||||||
gMiddlePref)) {
|
gMiddlePref)) {
|
||||||
// stop capturing
|
// stop capturing
|
||||||
@ -528,13 +519,10 @@ nsSliderFrame::HandleEvent(nsPresContext* aPresContext,
|
|||||||
#endif
|
#endif
|
||||||
(gMiddlePref && aEvent->message == NS_MOUSE_BUTTON_DOWN &&
|
(gMiddlePref && aEvent->message == NS_MOUSE_BUTTON_DOWN &&
|
||||||
static_cast<nsMouseEvent*>(aEvent)->button ==
|
static_cast<nsMouseEvent*>(aEvent)->button ==
|
||||||
nsMouseEvent::eMiddleButton) ||
|
nsMouseEvent::eMiddleButton)) {
|
||||||
(aEvent->message == NS_TOUCH_START && GetScrollToClick())) {
|
|
||||||
|
|
||||||
nsPoint eventPoint;
|
nsPoint eventPoint = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent,
|
||||||
if (!GetEventPoint(aEvent, eventPoint)) {
|
this);
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
nscoord pos = isHorizontal ? eventPoint.x : eventPoint.y;
|
nscoord pos = isHorizontal ? eventPoint.x : eventPoint.y;
|
||||||
|
|
||||||
// adjust so that the middle of the thumb is placed under the click
|
// 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);
|
NS_ENSURE_TRUE(weakFrame.IsAlive(), NS_OK);
|
||||||
|
|
||||||
DragThumb(true);
|
DragThumb(true);
|
||||||
if (aEvent->eventStructType == NS_TOUCH_EVENT) {
|
|
||||||
*aEventStatus = nsEventStatus_eConsumeNoDefault;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isHorizontal)
|
if (isHorizontal)
|
||||||
mThumbStart = thumbFrame->GetPosition().x;
|
mThumbStart = thumbFrame->GetPosition().x;
|
||||||
@ -574,40 +559,6 @@ nsSliderFrame::HandleEvent(nsPresContext* aPresContext,
|
|||||||
return nsFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
|
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<nsTouchEvent*>(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<nsDOMTouch*>(touch);
|
|
||||||
aPoint = domtouch->mRefPoint;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Helper function to collect the "scroll to click" metric. Beware of
|
// Helper function to collect the "scroll to click" metric. Beware of
|
||||||
// caching this, users expect to be able to change the system preference
|
// caching this, users expect to be able to change the system preference
|
||||||
// and see the browser change its behavior immediately.
|
// 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.
|
// Only process the event if the thumb is not being dragged.
|
||||||
if (mSlider && !mSlider->isDraggingThumb())
|
if (mSlider && !mSlider->isDraggingThumb())
|
||||||
return mSlider->StartDrag(aEvent);
|
return mSlider->MouseDown(aEvent);
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsSliderFrame::StartDrag(nsIDOMEvent* aEvent)
|
nsSliderFrame::MouseDown(nsIDOMEvent* aMouseEvent)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_SLIDER
|
#ifdef DEBUG_SLIDER
|
||||||
printf("Begin dragging\n");
|
printf("Begin dragging\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
nsCOMPtr<nsIDOMMouseEvent> mouseEvent(do_QueryInterface(aMouseEvent));
|
||||||
|
if (!mouseEvent)
|
||||||
|
return NS_OK;
|
||||||
|
|
||||||
if (mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::disabled,
|
if (mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::disabled,
|
||||||
nsGkAtoms::_true, eCaseMatters))
|
nsGkAtoms::_true, eCaseMatters))
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
||||||
bool isHorizontal = IsHorizontal();
|
PRUint16 button = 0;
|
||||||
bool scrollToClick = false;
|
mouseEvent->GetButton(&button);
|
||||||
|
if (!(button == 0 || (button == 1 && gMiddlePref)))
|
||||||
nsCOMPtr<nsIDOMMouseEvent> 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<nsGUIEvent*>(aEvent->GetInternalNSEvent());
|
|
||||||
|
|
||||||
nsPoint pt;
|
|
||||||
if (!GetEventPoint(event, pt)) {
|
|
||||||
return NS_OK;
|
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;
|
nscoord pos = isHorizontal ? pt.x : pt.y;
|
||||||
|
|
||||||
// If shift click or middle button, first
|
// If shift click or middle button, first
|
||||||
@ -998,9 +946,6 @@ nsSliderFrame::AddListener()
|
|||||||
thumbFrame->GetContent()->
|
thumbFrame->GetContent()->
|
||||||
AddSystemEventListener(NS_LITERAL_STRING("mousedown"), mMediator,
|
AddSystemEventListener(NS_LITERAL_STRING("mousedown"), mMediator,
|
||||||
false, false);
|
false, false);
|
||||||
thumbFrame->GetContent()->
|
|
||||||
AddSystemEventListener(NS_LITERAL_STRING("touchstart"), mMediator,
|
|
||||||
false, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1021,21 +966,13 @@ nsSliderFrame::HandlePress(nsPresContext* aPresContext,
|
|||||||
nsGUIEvent* aEvent,
|
nsGUIEvent* aEvent,
|
||||||
nsEventStatus* aEventStatus)
|
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
|
#ifdef XP_MACOSX
|
||||||
// On Mac the option key inverts the scroll-to-here preference.
|
// On Mac the option key inverts the scroll-to-here preference.
|
||||||
if (((nsMouseEvent *)aEvent)->IsAlt() != GetScrollToClick()) {
|
if (((nsMouseEvent *)aEvent)->IsAlt() != GetScrollToClick())
|
||||||
#else
|
#else
|
||||||
if (((nsMouseEvent *)aEvent)->IsShift() != GetScrollToClick()) {
|
if (((nsMouseEvent *)aEvent)->IsShift() != GetScrollToClick())
|
||||||
#endif
|
#endif
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
nsIFrame* thumbFrame = mFrames.FirstChild();
|
nsIFrame* thumbFrame = mFrames.FirstChild();
|
||||||
if (!thumbFrame) // display:none?
|
if (!thumbFrame) // display:none?
|
||||||
@ -1048,10 +985,8 @@ nsSliderFrame::HandlePress(nsPresContext* aPresContext,
|
|||||||
nsRect thumbRect = thumbFrame->GetRect();
|
nsRect thumbRect = thumbFrame->GetRect();
|
||||||
|
|
||||||
nscoord change = 1;
|
nscoord change = 1;
|
||||||
nsPoint eventPoint;
|
nsPoint eventPoint = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent,
|
||||||
if (!GetEventPoint(aEvent, eventPoint)) {
|
this);
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
if (IsHorizontal() ? eventPoint.x < thumbRect.x
|
if (IsHorizontal() ? eventPoint.x < thumbRect.x
|
||||||
: eventPoint.y < thumbRect.y)
|
: eventPoint.y < thumbRect.y)
|
||||||
change = -1;
|
change = -1;
|
||||||
|
@ -97,7 +97,7 @@ public:
|
|||||||
|
|
||||||
virtual nsIAtom* GetType() const;
|
virtual nsIAtom* GetType() const;
|
||||||
|
|
||||||
nsresult StartDrag(nsIDOMEvent* aEvent);
|
nsresult MouseDown(nsIDOMEvent* aMouseEvent);
|
||||||
|
|
||||||
static PRInt32 GetCurrentPosition(nsIContent* content);
|
static PRInt32 GetCurrentPosition(nsIContent* content);
|
||||||
static PRInt32 GetMinPosition(nsIContent* content);
|
static PRInt32 GetMinPosition(nsIContent* content);
|
||||||
@ -138,16 +138,6 @@ private:
|
|||||||
bool aIsSmooth, bool aImmediateRedraw);
|
bool aIsSmooth, bool aImmediateRedraw);
|
||||||
nsresult CurrentPositionChanged(nsPresContext* aPresContext,
|
nsresult CurrentPositionChanged(nsPresContext* aPresContext,
|
||||||
bool aImmediateRedraw);
|
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 DragThumb(bool aGrabMouseEvents);
|
||||||
void AddListener();
|
void AddListener();
|
||||||
void RemoveListener();
|
void RemoveListener();
|
||||||
|
@ -100,7 +100,6 @@ MOCHITEST_CHROME_FILES = findbar_window.xul \
|
|||||||
test_popup_preventdefault.xul \
|
test_popup_preventdefault.xul \
|
||||||
test_notificationbox.xul \
|
test_notificationbox.xul \
|
||||||
test_scale.xul \
|
test_scale.xul \
|
||||||
test_scaledrag.xul \
|
|
||||||
test_radio.xul \
|
test_radio.xul \
|
||||||
test_tabbox.xul \
|
test_tabbox.xul \
|
||||||
test_progressmeter.xul \
|
test_progressmeter.xul \
|
||||||
|
@ -1,197 +0,0 @@
|
|||||||
<?xml version="1.0"?>
|
|
||||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
|
||||||
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
|
|
||||||
<!--
|
|
||||||
XUL <scale> dragging tests
|
|
||||||
-->
|
|
||||||
<window title="Dragging XUL scale tests" width="500" height="600"
|
|
||||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
|
||||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
|
||||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
|
|
||||||
|
|
||||||
<hbox flex="1">
|
|
||||||
<scale id="scale1" orient="horizontal" flex="1" min="0" max="4" value="2"/>
|
|
||||||
<scale id="scale2" orient="vertical" flex="1" min="0" max="4" value="2"/>
|
|
||||||
<scale id="scale3" orient="horizontal" flex="1" movetoclick="true" min="0" max="4" value="2"/>
|
|
||||||
</hbox>
|
|
||||||
|
|
||||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
|
||||||
<p id="display"></p>
|
|
||||||
<div id="content" style="display: none">
|
|
||||||
</div>
|
|
||||||
<pre id="test">
|
|
||||||
</pre>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
<![CDATA[
|
|
||||||
|
|
||||||
SimpleTest.waitForExplicitFinish();
|
|
||||||
function getThumb(aScale) {
|
|
||||||
return document.getAnonymousElementByAttribute(aScale, "class", "scale-thumb");
|
|
||||||
}
|
|
||||||
|
|
||||||
function sendTouch(aType, aRect, aDX, aDY, aMods) {
|
|
||||||
var cwu = SpecialPowers.getDOMWindowUtils(window);
|
|
||||||
var x = aRect.left + aRect.width/2 + aDX;
|
|
||||||
var y = aRect.top + aRect.height/2 + aDY;
|
|
||||||
if (/mouse/.test(aType))
|
|
||||||
cwu.sendMouseEvent(aType, x, y, 0, 1, aMods || 0, false);
|
|
||||||
else
|
|
||||||
cwu.sendTouchEvent(aType, [0], [x], [y], [1], [1], [0], [1], 1, aMods || 0, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getOffset(aScale, aDir) {
|
|
||||||
var rect = aScale.getBoundingClientRect();
|
|
||||||
var d = aScale.orient == "horizontal" ? rect.width/4 : rect.height/4;
|
|
||||||
switch (aDir) {
|
|
||||||
case "right": return [ d, 0];
|
|
||||||
case "left": return [-1*d, 0];
|
|
||||||
case "up": return [ 0,-1*d];
|
|
||||||
case "down": return [ 0, d];
|
|
||||||
case "downleft": return [ -1*d, d];
|
|
||||||
case "upleft": return [ -1*d,-1*d];
|
|
||||||
case "downright": return [d, d];
|
|
||||||
case "upright": return [d,-1*d];
|
|
||||||
}
|
|
||||||
return [0,0];
|
|
||||||
}
|
|
||||||
|
|
||||||
function testTouchDragThumb(aDesc, aId, aDir, aVal1, aVal2, aMods) {
|
|
||||||
info(aDesc);
|
|
||||||
var scale = document.getElementById(aId);
|
|
||||||
var [x,y] = getOffset(scale, aDir);
|
|
||||||
|
|
||||||
sendTouch("touchstart", getThumb(scale).getBoundingClientRect(), 0, 0, aMods);
|
|
||||||
is(scale.value, aVal1, "Touchstart on thumb has correct value");
|
|
||||||
sendTouch("touchmove", getThumb(scale).getBoundingClientRect(), x, y, aMods);
|
|
||||||
sendTouch("touchend", getThumb(scale).getBoundingClientRect(), 0, 0, aMods);
|
|
||||||
is(scale.value, aVal2, "After touch " + (aDir ? ("and drag " + aDir + " ") : "") + "on thumb, scale has correct value");
|
|
||||||
|
|
||||||
scale.value = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
function testMouseDragThumb(aDesc, aId, aDir, aVal1, aVal2, aMods) {
|
|
||||||
info(aDesc);
|
|
||||||
var scale = document.getElementById(aId);
|
|
||||||
var [x,y] = getOffset(scale, aDir);
|
|
||||||
|
|
||||||
sendTouch("mousedown", getThumb(scale).getBoundingClientRect(), 0, 0, aMods);
|
|
||||||
is(scale.value, aVal1, "Mousedown on thumb has correct value");
|
|
||||||
sendTouch("mousemove", getThumb(scale).getBoundingClientRect(), x, y, aMods);
|
|
||||||
sendTouch("mouseup", getThumb(scale).getBoundingClientRect(), 0, 0, aMods);
|
|
||||||
is(scale.value, aVal2, "After mouseup " + (aDir ? ("and drag " + aDir + " ") : "") + "on thumb, scale has correct value");
|
|
||||||
|
|
||||||
scale.value = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
function testTouchDragSlider(aDesc, aId, aDir, aVal1, aVal2, aMods) {
|
|
||||||
info(aDesc);
|
|
||||||
var scale = document.getElementById(aId);
|
|
||||||
var [x,y] = getOffset(scale, aDir);
|
|
||||||
|
|
||||||
sendTouch("touchstart", getThumb(scale).getBoundingClientRect(), x, y, aMods);
|
|
||||||
is(scale.value, aVal1, "Touchstart on slider has correct value");
|
|
||||||
sendTouch("touchmove", getThumb(scale).getBoundingClientRect(), -x, -y, aMods);
|
|
||||||
sendTouch("touchend", getThumb(scale).getBoundingClientRect(), 0, 0, aMods);
|
|
||||||
is(scale.value, aVal2, "After touch " + (aDir ? ("and drag " + aDir + " ") : "") + "on slider, scale has correct value");
|
|
||||||
|
|
||||||
scale.value = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
function testMouseDragSlider(aDesc, aId, aDir, aVal1, aVal2, aMods) {
|
|
||||||
info(aDesc);
|
|
||||||
var scale = document.getElementById(aId);
|
|
||||||
var [x,y] = getOffset(scale, aDir);
|
|
||||||
|
|
||||||
sendTouch("mousedown", getThumb(scale).getBoundingClientRect(), x, y, aMods);
|
|
||||||
is(scale.value, aVal1, "Mousedown on slider has correct value");
|
|
||||||
sendTouch("mousemove", getThumb(scale).getBoundingClientRect(), -x, -y, aMods);
|
|
||||||
sendTouch("mouseup", getThumb(scale).getBoundingClientRect(), 0, 0, aMods);
|
|
||||||
is(scale.value, aVal2, "After mouseup " + (aDir ? ("and drag " + aDir + " ") : "") + "on slider, scale has correct value");
|
|
||||||
|
|
||||||
scale.value = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
function runTests() {
|
|
||||||
// test dragging a horizontal slider with touch events by tapping on the thumb
|
|
||||||
testTouchDragThumb("Touch Horizontal Thumb", "scale1", "", 2, 2);
|
|
||||||
testTouchDragThumb("TouchDrag Horizontal Thumb Left", "scale1", "left", 2, 1);
|
|
||||||
testTouchDragThumb("TouchDrag Horizontal Thumb Right", "scale1", "right", 2, 3);
|
|
||||||
testTouchDragThumb("TouchDrag Horizontal Thumb Up", "scale1", "up", 2, 2);
|
|
||||||
testTouchDragThumb("TouchDrag Horizontal Thumb Down", "scale1", "down", 2, 2);
|
|
||||||
testTouchDragThumb("TouchDrag Horizontal Thumb Downleft", "scale1", "downleft", 2, 1);
|
|
||||||
testTouchDragThumb("TouchDrag Horizontal Thumb Upleft", "scale1", "upleft", 2, 1);
|
|
||||||
testTouchDragThumb("TouchDrag Horizontal Thumb Upright", "scale1", "upright", 2, 3);
|
|
||||||
testTouchDragThumb("TouchDrag Horizontal Thumb Downright", "scale1", "downright", 2, 3);
|
|
||||||
|
|
||||||
// test dragging a horizontal slider with mouse events by clicking on the thumb
|
|
||||||
testMouseDragThumb("Click Horizontal Thumb", "scale1", "", 2, 2);
|
|
||||||
testMouseDragThumb("MouseDrag Horizontal Thumb Left", "scale1", "left", 2, 1);
|
|
||||||
testMouseDragThumb("MouseDrag Horizontal Thumb Right", "scale1", "right", 2, 3);
|
|
||||||
testMouseDragThumb("MouseDrag Horizontal Thumb Up", "scale1", "up", 2, 2);
|
|
||||||
testMouseDragThumb("MouseDrag Horizontal Thumb Down", "scale1", "down", 2, 2);
|
|
||||||
testMouseDragThumb("MouseDrag Horizontal Thumb Downleft", "scale1", "downleft", 2, 1);
|
|
||||||
testMouseDragThumb("MouseDrag Horizontal Thumb Upleft", "scale1", "upleft", 2, 1);
|
|
||||||
testMouseDragThumb("MouseDrag Horizontal Thumb Upright", "scale1", "upright", 2, 3);
|
|
||||||
testMouseDragThumb("MouseDrag Horizontal Thumb Downright", "scale1", "downright", 2, 3);
|
|
||||||
|
|
||||||
// test dragging a vertical slider with touch events by tapping on the thumb
|
|
||||||
testTouchDragThumb("Touch Vertical Thumb", "scale2", "", 2, 2);
|
|
||||||
testTouchDragThumb("TouchDrag Vertical Thumb Left", "scale2", "left", 2, 2);
|
|
||||||
testTouchDragThumb("TouchDrag Vertical Thumb Right", "scale2", "right", 2, 2);
|
|
||||||
testTouchDragThumb("TouchDrag Vertical Thumb Up", "scale2", "up", 2, 1);
|
|
||||||
testTouchDragThumb("TouchDrag Vertical Thumb Down", "scale2", "down", 2, 3);
|
|
||||||
testTouchDragThumb("TouchDrag Vertical Thumb Downleft", "scale2", "downleft", 2, 3);
|
|
||||||
testTouchDragThumb("TouchDrag Vertical Thumb Upleft", "scale2", "upleft", 2, 1);
|
|
||||||
testTouchDragThumb("TouchDrag Vertical Thumb Upright", "scale2", "upright", 2, 1);
|
|
||||||
testTouchDragThumb("TouchDrag Vertical Thumb Downright", "scale2", "downright", 2, 3);
|
|
||||||
|
|
||||||
// test dragging a vertical slider with mouse events by clicking on the thumb
|
|
||||||
testMouseDragThumb("Click Vertical Thumb", "scale2", "", 2, 2);
|
|
||||||
testMouseDragThumb("MouseDrag Vertical Thumb Left", "scale2", "left", 2, 2);
|
|
||||||
testMouseDragThumb("MouseDrag Vertical Thumb Right", "scale2", "right", 2, 2);
|
|
||||||
testMouseDragThumb("MouseDrag Vertical Thumb Up", "scale2", "up", 2, 1);
|
|
||||||
testMouseDragThumb("MouseDrag Vertical Thumb Down", "scale2", "down", 2, 3);
|
|
||||||
testMouseDragThumb("MouseDrag Vertical Thumb Downleft", "scale2", "downleft", 2, 3);
|
|
||||||
testMouseDragThumb("MouseDrag Vertical Thumb Upleft", "scale2", "upleft", 2, 1);
|
|
||||||
testMouseDragThumb("MouseDrag Vertical Thumb Upright", "scale2", "upright", 2, 1);
|
|
||||||
testMouseDragThumb("MouseDrag Vertical Thumb Downright", "scale2", "downright", 2, 3);
|
|
||||||
|
|
||||||
var isMac = /Mac/.test(navigator.platform);
|
|
||||||
|
|
||||||
// test dragging a slider by tapping off the thumb
|
|
||||||
testTouchDragSlider("TouchDrag Slider Left", "scale1", "left", isMac ? 1 : 0, isMac ? 2 : 0);
|
|
||||||
testTouchDragSlider("TouchDrag Slider Right", "scale1", "right", isMac ? 3 : 4, isMac ? 2 : 4);
|
|
||||||
testMouseDragSlider("MouseDrag Slider Left", "scale1", "left", isMac ? 1 : 0, isMac ? 2 : 0);
|
|
||||||
testMouseDragSlider("MouseDrag Slider Right", "scale1", "right", isMac ? 3 : 4, isMac ? 2 : 4);
|
|
||||||
|
|
||||||
// test dragging a slider by tapping off the thumb and holding shift
|
|
||||||
// modifiers don't affect touch events
|
|
||||||
var mods = /Mac/.test(navigator.platform) ? Components.interfaces.nsIDOMNSEvent.ALT_MASK :
|
|
||||||
Components.interfaces.nsIDOMNSEvent.SHIFT_MASK;
|
|
||||||
testTouchDragSlider("TouchDrag Slider Left+Shift", "scale1", "left", isMac ? 1 : 0, isMac ? 2 : 0, mods);
|
|
||||||
testTouchDragSlider("TouchDrag Slider Right+Shift", "scale1", "right", isMac ? 3 : 4, isMac ? 2 : 4, mods);
|
|
||||||
testMouseDragSlider("MouseDrag Slider Left+Shift", "scale1", "left", isMac ? 0 : 1, isMac ? 0 : 2, mods);
|
|
||||||
testMouseDragSlider("MouseDrag Slider Right+Shift", "scale1", "right", isMac ? 4 : 3, isMac ? 4 : 2, mods);
|
|
||||||
|
|
||||||
// test dragging a slider with movetoclick="true" by tapping off the thumb
|
|
||||||
testTouchDragSlider("TouchDrag Slider Left+MoveToClick", "scale3", "left", 1, 2);
|
|
||||||
testTouchDragSlider("TouchDrag Slider Right+MoveToClick", "scale3", "right", 3, 2);
|
|
||||||
testMouseDragSlider("MouseDrag Slider Left+MoveToClick", "scale3", "left", 1, 2);
|
|
||||||
testMouseDragSlider("MouseDrag Slider Right+MoveToClick", "scale3", "right", 3, 2);
|
|
||||||
|
|
||||||
// test dragging a slider by tapping off the thumb and holding shift
|
|
||||||
// modifiers don't affect touch events
|
|
||||||
testTouchDragSlider("MouseDrag Slider Left+MoveToClick+Shift", "scale3", "left", 1, 2, mods);
|
|
||||||
testTouchDragSlider("MouseDrag Slider Right+MoveToClick+Shift", "scale3", "right", 3, 2, mods);
|
|
||||||
testMouseDragSlider("MouseDrag Slider Left+MoveToClick+Shift", "scale3", "left", 0, 0, mods);
|
|
||||||
testMouseDragSlider("MouseDrag Slider Right+MoveToClick+Shift", "scale3", "right", 4, 4, mods);
|
|
||||||
|
|
||||||
SimpleTest.finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
addLoadEvent(function() { SimpleTest.executeSoon(runTests); });
|
|
||||||
]]></script>
|
|
||||||
|
|
||||||
</window>
|
|
@ -133,7 +133,6 @@
|
|||||||
if (this.type == "scrubber") {
|
if (this.type == "scrubber") {
|
||||||
// Update the time shown in the thumb.
|
// Update the time shown in the thumb.
|
||||||
this.thumb.setTime(newValue);
|
this.thumb.setTime(newValue);
|
||||||
this.Utils.positionLabel.setAttribute("value", this.thumb.timeLabel.value);
|
|
||||||
// Update the value bar to match the thumb position.
|
// Update the value bar to match the thumb position.
|
||||||
var percent = newValue / this.max;
|
var percent = newValue / this.max;
|
||||||
this.valueBar.value = Math.round(percent * 10000); // has max=10000
|
this.valueBar.value = Math.round(percent * 10000); // has max=10000
|
||||||
@ -1552,15 +1551,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
clearTimer: function() {
|
delayHideControls : function(aTimeout) {
|
||||||
if (this.controlsTimer) {
|
if (this.controlsTimer) {
|
||||||
clearTimeout(this.controlsTimer);
|
clearTimeout(this.controlsTimer);
|
||||||
this.controlsTimer = null;
|
this.controlsTimer = null;
|
||||||
}
|
}
|
||||||
},
|
|
||||||
|
|
||||||
delayHideControls : function(aTimeout) {
|
|
||||||
this.clearTimer();
|
|
||||||
let self = this;
|
let self = this;
|
||||||
this.controlsTimer = setTimeout(function() {
|
this.controlsTimer = setTimeout(function() {
|
||||||
self.hideControls();
|
self.hideControls();
|
||||||
@ -1603,12 +1598,7 @@
|
|||||||
else
|
else
|
||||||
self.showControls();
|
self.showControls();
|
||||||
}, false);
|
}, false);
|
||||||
this.Utils.scrubber.addEventListener("touchstart", function() {
|
this.Utils.scrubber.addEventListener("click", function() { self.delayHideControls(self.controlsTimeout); }, false);
|
||||||
self.clearTimer();
|
|
||||||
}, false);
|
|
||||||
this.Utils.scrubber.addEventListener("touchend", function() {
|
|
||||||
self.delayHideControls(self.controlsTimeout);
|
|
||||||
}, false);
|
|
||||||
this.Utils.muteButton.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)
|
if (!video.autoplay && this.Utils.dynamicControls)
|
||||||
|
Loading…
Reference in New Issue
Block a user