Bug 732052 - Allow slide frames to use touch events. r=smaug,enn

This commit is contained in:
Wes Johnston 2012-07-09 09:55:35 -07:00
parent 94e57b473f
commit b8fc760a2e
6 changed files with 375 additions and 42 deletions

View File

@ -5901,6 +5901,47 @@ PresShell::HandleEvent(nsIFrame *aFrame,
PresShell* shell =
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
// EventStateManager of the current PresContext.
// If that is the case, and mouse is over some ancestor document,
@ -6477,7 +6518,22 @@ PresShell::DispatchTouchEvent(nsEvent *aEvent,
touchEvent);
newEvent.target = targetPtr;
nsCOMPtr<nsIContent> content(do_QueryInterface(targetPtr));
// If someone is capturing, all touch events are filtered to their target
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);
if (!context) {
context = mPresContext;
@ -6488,6 +6544,9 @@ 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

View File

@ -2257,15 +2257,16 @@ nsFrame::HandleEvent(nsPresContext* aPresContext,
nsEventStatus* aEventStatus)
{
if (aEvent->message == NS_MOUSE_MOVE) {
if (aEvent->message == NS_MOUSE_MOVE || aEvent->message == NS_TOUCH_MOVE) {
return HandleDrag(aPresContext, aEvent, aEventStatus);
}
if (aEvent->eventStructType == NS_MOUSE_EVENT &&
static_cast<nsMouseEvent*>(aEvent)->button == nsMouseEvent::eLeftButton) {
if (aEvent->message == NS_MOUSE_BUTTON_DOWN) {
if ((aEvent->eventStructType == NS_MOUSE_EVENT &&
static_cast<nsMouseEvent*>(aEvent)->button == nsMouseEvent::eLeftButton) ||
aEvent->eventStructType == NS_TOUCH_EVENT) {
if (aEvent->message == NS_MOUSE_BUTTON_DOWN || aEvent->message == NS_TOUCH_START) {
HandlePress(aPresContext, aEvent, aEventStatus);
} else if (aEvent->message == NS_MOUSE_BUTTON_UP) {
} else if (aEvent->message == NS_MOUSE_BUTTON_UP || aEvent->message == NS_TOUCH_END) {
HandleRelease(aPresContext, aEvent, aEventStatus);
}
}

View File

@ -20,6 +20,7 @@
#include "nsHTMLParts.h"
#include "nsIPresShell.h"
#include "nsCSSRendering.h"
#include "nsDOMTouchEvent.h"
#include "nsEventListenerManager.h"
#include "nsIDOMEventTarget.h"
#include "nsIDOMMouseEvent.h"
@ -437,9 +438,12 @@ nsSliderFrame::HandleEvent(nsPresContext* aPresContext,
if (isDraggingThumb())
{
switch (aEvent->message) {
case NS_TOUCH_MOVE:
case NS_MOUSE_MOVE: {
nsPoint eventPoint = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent,
this);
nsPoint eventPoint;
if (!GetEventPoint(aEvent, eventPoint)) {
break;
}
if (mChange) {
// We're in the process of moving the thumb to the mouse,
// but the mouse just moved. Make sure to update our
@ -479,6 +483,9 @@ nsSliderFrame::HandleEvent(nsPresContext* aPresContext,
isMouseOutsideThumb = true;
}
}
if (aEvent->eventStructType == NS_TOUCH_EVENT) {
*aEventStatus = nsEventStatus_eConsumeNoDefault;
}
if (isMouseOutsideThumb)
{
SetCurrentThumbPosition(scrollbar, mThumbStart, false, true, false);
@ -490,8 +497,10 @@ nsSliderFrame::HandleEvent(nsPresContext* aPresContext,
}
break;
case NS_TOUCH_END:
case NS_MOUSE_BUTTON_UP:
if (static_cast<nsMouseEvent*>(aEvent)->button == nsMouseEvent::eLeftButton ||
if (aEvent->message == NS_TOUCH_END ||
static_cast<nsMouseEvent*>(aEvent)->button == nsMouseEvent::eLeftButton ||
(static_cast<nsMouseEvent*>(aEvent)->button == nsMouseEvent::eMiddleButton &&
gMiddlePref)) {
// stop capturing
@ -519,10 +528,13 @@ nsSliderFrame::HandleEvent(nsPresContext* aPresContext,
#endif
(gMiddlePref && aEvent->message == NS_MOUSE_BUTTON_DOWN &&
static_cast<nsMouseEvent*>(aEvent)->button ==
nsMouseEvent::eMiddleButton)) {
nsMouseEvent::eMiddleButton) ||
(aEvent->message == NS_TOUCH_START && GetScrollToClick())) {
nsPoint eventPoint = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent,
this);
nsPoint eventPoint;
if (!GetEventPoint(aEvent, eventPoint)) {
return NS_OK;
}
nscoord pos = isHorizontal ? eventPoint.x : eventPoint.y;
// adjust so that the middle of the thumb is placed under the click
@ -540,6 +552,9 @@ 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;
@ -559,6 +574,40 @@ 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<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
// caching this, users expect to be able to change the system preference
// and see the browser change its behavior immediately.
@ -824,44 +873,47 @@ nsSliderMediator::HandleEvent(nsIDOMEvent* aEvent)
{
// Only process the event if the thumb is not being dragged.
if (mSlider && !mSlider->isDraggingThumb())
return mSlider->MouseDown(aEvent);
return mSlider->StartDrag(aEvent);
return NS_OK;
}
nsresult
nsSliderFrame::MouseDown(nsIDOMEvent* aMouseEvent)
nsSliderFrame::StartDrag(nsIDOMEvent* aEvent)
{
#ifdef DEBUG_SLIDER
printf("Begin dragging\n");
#endif
nsCOMPtr<nsIDOMMouseEvent> mouseEvent(do_QueryInterface(aMouseEvent));
if (!mouseEvent)
return NS_OK;
if (mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::disabled,
nsGkAtoms::_true, eCaseMatters))
return NS_OK;
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);
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;
}
nscoord pos = isHorizontal ? pt.x : pt.y;
// If shift click or middle button, first
@ -946,6 +998,9 @@ nsSliderFrame::AddListener()
thumbFrame->GetContent()->
AddSystemEventListener(NS_LITERAL_STRING("mousedown"), mMediator,
false, false);
thumbFrame->GetContent()->
AddSystemEventListener(NS_LITERAL_STRING("touchstart"), mMediator,
false, false);
}
void
@ -966,13 +1021,21 @@ nsSliderFrame::HandlePress(nsPresContext* aPresContext,
nsGUIEvent* aEvent,
nsEventStatus* aEventStatus)
{
#ifdef XP_MACOSX
// On Mac the option key inverts the scroll-to-here preference.
if (((nsMouseEvent *)aEvent)->IsAlt() != GetScrollToClick())
#else
if (((nsMouseEvent *)aEvent)->IsShift() != GetScrollToClick())
#endif
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()) {
#else
if (((nsMouseEvent *)aEvent)->IsShift() != GetScrollToClick()) {
#endif
return NS_OK;
}
}
nsIFrame* thumbFrame = mFrames.FirstChild();
if (!thumbFrame) // display:none?
@ -985,8 +1048,10 @@ nsSliderFrame::HandlePress(nsPresContext* aPresContext,
nsRect thumbRect = thumbFrame->GetRect();
nscoord change = 1;
nsPoint eventPoint = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent,
this);
nsPoint eventPoint;
if (!GetEventPoint(aEvent, eventPoint)) {
return NS_OK;
}
if (IsHorizontal() ? eventPoint.x < thumbRect.x
: eventPoint.y < thumbRect.y)
change = -1;

View File

@ -97,7 +97,7 @@ public:
virtual nsIAtom* GetType() const;
nsresult MouseDown(nsIDOMEvent* aMouseEvent);
nsresult StartDrag(nsIDOMEvent* aEvent);
static PRInt32 GetCurrentPosition(nsIContent* content);
static PRInt32 GetMinPosition(nsIContent* content);
@ -138,6 +138,16 @@ 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();

View File

@ -101,6 +101,7 @@ _TEST_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 \

View File

@ -0,0 +1,197 @@
<?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>