Merge mozilla-inbound to mozilla-central. a=merge

This commit is contained in:
Dorel Luca 2018-04-21 02:00:04 +03:00
commit 65669dae30
678 changed files with 3252 additions and 6095 deletions

View File

@ -21,7 +21,7 @@
#endif
#include "mozilla/EventListenerManager.h"
#include "mozilla/dom/Event.h" // for nsIDOMEvent::InternalDOMEvent()
#include "mozilla/dom/Event.h" // for Event
#include "nsCURILoader.h"
#include "nsDocShellLoadTypes.h"
#include "nsIChannel.h"
@ -354,13 +354,12 @@ DocManager::OnSecurityChange(nsIWebProgress* aWebProgress,
// nsIDOMEventListener
NS_IMETHODIMP
DocManager::HandleEvent(nsIDOMEvent* aEvent)
DocManager::HandleEvent(Event* aEvent)
{
nsAutoString type;
aEvent->GetType(type);
nsCOMPtr<nsIDocument> document =
do_QueryInterface(aEvent->InternalDOMEvent()->GetTarget());
nsCOMPtr<nsIDocument> document = do_QueryInterface(aEvent->GetTarget());
NS_ASSERTION(document, "pagehide or DOMContentLoaded for non document!");
if (!document)
return NS_OK;

View File

@ -829,7 +829,7 @@ logging::Node(const char* aDescr, nsINode* aNode)
return;
}
if (aNode->IsNodeOfType(nsINode::eDOCUMENT)) {
if (aNode->IsDocument()) {
printf("%s: %p, document\n", aDescr, static_cast<void*>(aNode));
return;
}
@ -908,7 +908,7 @@ logging::AccessibleInfo(const char* aDescr, Accessible* aAccessible)
if (!node) {
printf(", node: null\n");
}
else if (node->IsNodeOfType(nsINode::eDOCUMENT)) {
else if (node->IsDocument()) {
printf(", document node: %p\n", static_cast<void*>(node));
}
else if (node->IsText()) {

View File

@ -68,6 +68,7 @@
#include "nsXBLBinding.h"
#include "mozilla/ArrayUtils.h"
#include "mozilla/dom/DOMStringList.h"
#include "mozilla/dom/EventTarget.h"
#include "mozilla/Preferences.h"
#include "mozilla/Services.h"
#include "nsDeckFrame.h"
@ -375,7 +376,7 @@ nsAccessibilityService::ListenersChanged(nsIArray* aEventChanges)
for (uint32_t i = 0 ; i < targetCount ; i++) {
nsCOMPtr<nsIEventListenerChange> change = do_QueryElementAt(aEventChanges, i);
nsCOMPtr<nsIDOMEventTarget> target;
RefPtr<EventTarget> target;
change->GetTarget(getter_AddRefs(target));
nsCOMPtr<nsIContent> node(do_QueryInterface(target));
if (!node || !node->IsHTMLElement()) {
@ -1044,11 +1045,10 @@ nsAccessibilityService::CreateAccessible(nsINode* aNode,
MOZ_ASSERT(!document->GetAccessible(aNode),
"We already have an accessible for this node.");
if (aNode->IsNodeOfType(nsINode::eDOCUMENT)) {
if (aNode->IsDocument()) {
// If it's document node then ask accessible document loader for
// document accessible, otherwise return null.
nsCOMPtr<nsIDocument> document(do_QueryInterface(aNode));
return GetDocAccessible(document);
return GetDocAccessible(aNode->AsDocument());
}
// We have a content node.

View File

@ -561,6 +561,11 @@ Accessible::ChildAtPoint(int32_t aX, int32_t aY,
nsRect screenRect = startFrame->GetScreenRectInAppUnits();
nsPoint offset(presContext->DevPixelsToAppUnits(aX) - screenRect.X(),
presContext->DevPixelsToAppUnits(aY) - screenRect.Y());
// We need to take into account a non-1 resolution set on the presshell.
// This happens in mobile platforms with async pinch zooming.
offset = offset.RemoveResolution(presContext->PresShell()->GetResolution());
nsIFrame* foundFrame = nsLayoutUtils::GetFrameForPoint(startFrame, offset);
nsIContent* content = nullptr;
@ -679,6 +684,10 @@ Accessible::Bounds() const
presContext->AppUnitsToDevPixels(unionRectTwips.Width()),
presContext->AppUnitsToDevPixels(unionRectTwips.Height()));
// We need to take into account a non-1 resolution set on the presshell.
// This happens in mobile platforms with async pinch zooming. Here we
// scale the bounds before adding the screen-relative offset.
screenRect.ScaleRoundOut(presContext->PresShell()->GetResolution());
// We have the union of the rectangle, now we need to put it in absolute
// screen coords.
nsIntRect orgRectPixels = boundingFrame->GetScreenRectInAppUnits().

View File

@ -1272,6 +1272,16 @@ HyperTextAccessible::TextBounds(int32_t aStartOffset, int32_t aEndOffset,
offset1 = 0;
}
// This document may have a resolution set, we will need to multiply
// the document-relative coordinates by that value and re-apply the doc's
// screen coordinates.
nsPresContext* presContext = mDoc->PresContext();
nsIFrame* rootFrame = presContext->PresShell()->GetRootFrame();
nsIntRect orgRectPixels = rootFrame->GetScreenRectInAppUnits().ToNearestPixels(presContext->AppUnitsPerDevPixel());
bounds.MoveBy(-orgRectPixels.X(), -orgRectPixels.Y());
bounds.ScaleRoundOut(presContext->PresShell()->GetResolution());
bounds.MoveBy(orgRectPixels.X(), orgRectPixels.Y());
auto boundsX = bounds.X();
auto boundsY = bounds.Y();
nsAccUtils::ConvertScreenCoordsTo(&boundsX, &boundsY, aCoordType, this);

View File

@ -230,11 +230,10 @@ RootAccessible::DocumentActivated(DocAccessible* aDocument)
// nsIDOMEventListener
NS_IMETHODIMP
RootAccessible::HandleEvent(nsIDOMEvent* aDOMEvent)
RootAccessible::HandleEvent(Event* aDOMEvent)
{
MOZ_ASSERT(aDOMEvent);
Event* event = aDOMEvent->InternalDOMEvent();
nsCOMPtr<nsINode> origTargetNode = do_QueryInterface(event->GetOriginalTarget());
nsCOMPtr<nsINode> origTargetNode = do_QueryInterface(aDOMEvent->GetOriginalTarget());
if (!origTargetNode)
return NS_OK;
@ -253,7 +252,7 @@ RootAccessible::HandleEvent(nsIDOMEvent* aDOMEvent)
// Root accessible exists longer than any of its descendant documents so
// that we are guaranteed notification is processed before root accessible
// is destroyed.
document->HandleNotification<RootAccessible, nsIDOMEvent>
document->HandleNotification<RootAccessible, Event>
(this, &RootAccessible::ProcessDOMEvent, aDOMEvent);
}
@ -262,11 +261,11 @@ RootAccessible::HandleEvent(nsIDOMEvent* aDOMEvent)
// RootAccessible protected
void
RootAccessible::ProcessDOMEvent(nsIDOMEvent* aDOMEvent)
RootAccessible::ProcessDOMEvent(Event* aDOMEvent)
{
MOZ_ASSERT(aDOMEvent);
Event* event = aDOMEvent->InternalDOMEvent();
nsCOMPtr<nsINode> origTargetNode = do_QueryInterface(event->GetOriginalTarget());
nsCOMPtr<nsINode> origTargetNode =
do_QueryInterface(aDOMEvent->GetOriginalTarget());
nsAutoString eventType;
aDOMEvent->GetType(eventType);
@ -652,11 +651,11 @@ RootAccessible::HandlePopupHidingEvent(nsINode* aPopupNode)
#ifdef MOZ_XUL
static void
GetPropertyBagFromEvent(nsIDOMEvent* aEvent, nsIPropertyBag2** aPropertyBag)
GetPropertyBagFromEvent(Event* aEvent, nsIPropertyBag2** aPropertyBag)
{
*aPropertyBag = nullptr;
CustomEvent* customEvent = aEvent->InternalDOMEvent()->AsCustomEvent();
CustomEvent* customEvent = aEvent->AsCustomEvent();
if (!customEvent)
return;
@ -682,7 +681,7 @@ GetPropertyBagFromEvent(nsIDOMEvent* aEvent, nsIPropertyBag2** aPropertyBag)
}
void
RootAccessible::HandleTreeRowCountChangedEvent(nsIDOMEvent* aEvent,
RootAccessible::HandleTreeRowCountChangedEvent(Event* aEvent,
XULTreeAccessible* aAccessible)
{
nsCOMPtr<nsIPropertyBag2> propBag;
@ -704,7 +703,7 @@ RootAccessible::HandleTreeRowCountChangedEvent(nsIDOMEvent* aEvent,
}
void
RootAccessible::HandleTreeInvalidatedEvent(nsIDOMEvent* aEvent,
RootAccessible::HandleTreeInvalidatedEvent(Event* aEvent,
XULTreeAccessible* aAccessible)
{
nsCOMPtr<nsIPropertyBag2> propBag;

View File

@ -25,7 +25,7 @@ public:
RootAccessible(nsIDocument* aDocument, nsIPresShell* aPresShell);
// nsIDOMEventListener
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) override;
NS_DECL_NSIDOMEVENTLISTENER
// Accessible
virtual void Shutdown() override;
@ -58,7 +58,7 @@ protected:
/**
* Process the DOM event.
*/
void ProcessDOMEvent(nsIDOMEvent* aEvent);
void ProcessDOMEvent(dom::Event* aEvent);
/**
* Process "popupshown" event. Used by HandleEvent().
@ -71,10 +71,10 @@ protected:
void HandlePopupHidingEvent(nsINode* aNode);
#ifdef MOZ_XUL
void HandleTreeRowCountChangedEvent(nsIDOMEvent* aEvent,
XULTreeAccessible* aAccessible);
void HandleTreeInvalidatedEvent(nsIDOMEvent* aEvent,
XULTreeAccessible* aAccessible);
void HandleTreeRowCountChangedEvent(dom::Event* aEvent,
XULTreeAccessible* aAccessible);
void HandleTreeInvalidatedEvent(dom::Event* aEvent,
XULTreeAccessible* aAccessible);
uint32_t GetChromeFlags();
#endif

View File

@ -320,8 +320,7 @@ HTMLSelectOptGroupAccessible::NativeInteractiveState() const
bool
HTMLSelectOptGroupAccessible::IsAcceptableChild(nsIContent* aEl) const
{
return aEl->IsNodeOfType(nsINode::eDATA_NODE) ||
aEl->IsHTMLElement(nsGkAtoms::option);
return aEl->IsCharacterData() || aEl->IsHTMLElement(nsGkAtoms::option);
}
uint8_t

View File

@ -13,9 +13,6 @@ if (Utils.MozBuildApp === "mobile/android") {
ChromeUtils.import("resource://gre/modules/Messaging.jsm");
}
const QUICKNAV_MODES_PREF = "accessibility.accessfu.quicknav_modes";
const QUICKNAV_INDEX_PREF = "accessibility.accessfu.quicknav_index";
const GECKOVIEW_MESSAGE = {
ACTIVATE: "GeckoView:AccessibilityActivate",
VIEW_FOCUSED: "GeckoView:AccessibilityViewFocused",
@ -25,6 +22,7 @@ const GECKOVIEW_MESSAGE = {
PREVIOUS: "GeckoView:AccessibilityPrevious",
SCROLL_BACKWARD: "GeckoView:AccessibilityScrollBackward",
SCROLL_FORWARD: "GeckoView:AccessibilityScrollForward",
EXPLORE_BY_TOUCH: "GeckoView:AccessibilityExploreByTouch"
};
var AccessFu = {
@ -73,7 +71,6 @@ var AccessFu = {
this._enabled = true;
ChromeUtils.import("resource://gre/modules/accessibility/Utils.jsm");
ChromeUtils.import("resource://gre/modules/accessibility/PointerAdapter.jsm");
ChromeUtils.import("resource://gre/modules/accessibility/Presentation.jsm");
for (let mm of Utils.AllMessageManagers) {
@ -88,30 +85,11 @@ var AccessFu = {
Utils.win.document.insertBefore(stylesheet, Utils.win.document.firstChild);
this.stylesheet = Cu.getWeakReference(stylesheet);
// Populate quicknav modes
this._quicknavModesPref =
new PrefCache(QUICKNAV_MODES_PREF, (aName, aValue, aFirstRun) => {
this.Input.quickNavMode.updateModes(aValue);
if (!aFirstRun) {
// If the modes change, reset the current mode index to 0.
Services.prefs.setIntPref(QUICKNAV_INDEX_PREF, 0);
}
}, true);
this._quicknavCurrentModePref =
new PrefCache(QUICKNAV_INDEX_PREF, (aName, aValue) => {
this.Input.quickNavMode.updateCurrentMode(Number(aValue));
}, true);
// Check for output notification
this._notifyOutputPref =
new PrefCache("accessibility.accessfu.notify_output");
this.Input.start();
Output.start();
PointerAdapter.start();
if (Utils.MozBuildApp === "mobile/android") {
Utils.win.WindowEventDispatcher.registerListener(this,
@ -149,9 +127,7 @@ var AccessFu = {
this._removeMessageListeners(mm);
}
this.Input.stop();
Output.stop();
PointerAdapter.stop();
Utils.win.removeEventListener("TabOpen", this);
Utils.win.removeEventListener("TabClose", this);
@ -165,7 +141,6 @@ var AccessFu = {
Object.values(GECKOVIEW_MESSAGE));
}
delete this._quicknavModesPref;
delete this._notifyOutputPref;
if (this.doneCallback) {
@ -282,7 +257,7 @@ var AccessFu = {
this.Input.activateCurrent(data);
break;
case GECKOVIEW_MESSAGE.LONG_PRESS:
this.Input.sendContextMenuMessage();
// XXX: Advertize long press on supported objects and implement action
break;
case GECKOVIEW_MESSAGE.SCROLL_FORWARD:
this.Input.androidScroll("forward");
@ -299,6 +274,9 @@ var AccessFu = {
case GECKOVIEW_MESSAGE.BY_GRANULARITY:
this.Input.moveByGranularity(data);
break;
case GECKOVIEW_MESSAGE.EXPLORE_BY_TOUCH:
this.Input.moveToPoint("Simple", ...data.coordinates);
break;
}
},
@ -375,30 +353,19 @@ var AccessFu = {
_processedMessageManagers: [],
/**
* Adjusts the given bounds relative to the given browser.
* Adjusts the given bounds that are defined in device display pixels
* to client-relative CSS pixels of the chrome window.
* @param {Rect} aJsonBounds the bounds to adjust
* @param {browser} aBrowser the browser we want the bounds relative to
* @param {bool} aToCSSPixels whether to convert to CSS pixels (as opposed to
* device pixels)
*/
adjustContentBounds(aJsonBounds, aBrowser, aToCSSPixels) {
screenToClientBounds(aJsonBounds) {
let bounds = new Rect(aJsonBounds.left, aJsonBounds.top,
aJsonBounds.right - aJsonBounds.left,
aJsonBounds.bottom - aJsonBounds.top);
let win = Utils.win;
let dpr = win.devicePixelRatio;
let offset = { left: -win.mozInnerScreenX, top: -win.mozInnerScreenY };
// Add the offset; the offset is in CSS pixels, so multiply the
// devicePixelRatio back in before adding to preserve unit consistency.
bounds = bounds.translate(offset.left * dpr, offset.top * dpr);
// If we want to get to CSS pixels from device pixels, this needs to be
// further divided by the devicePixelRatio due to widget scaling.
if (aToCSSPixels) {
bounds = bounds.scale(1 / dpr, 1 / dpr);
}
bounds = bounds.scale(1 / dpr, 1 / dpr);
bounds = bounds.translate(-win.mozInnerScreenX, -win.mozInnerScreenY);
return bounds.expandToIntegers();
}
};
@ -517,7 +484,7 @@ var Output = {
}
let padding = aDetail.padding;
let r = AccessFu.adjustContentBounds(aDetail.bounds, aBrowser, true);
let r = AccessFu.screenToClientBounds(aDetail.bounds);
// First hide it to avoid flickering when changing the style.
highlightBox.classList.remove("show");
@ -546,10 +513,6 @@ var Output = {
for (let androidEvent of aDetails) {
androidEvent.type = "GeckoView:AccessibilityEvent";
if (androidEvent.bounds) {
androidEvent.bounds = AccessFu.adjustContentBounds(
androidEvent.bounds, aBrowser);
}
switch (androidEvent.eventType) {
case ANDROID_VIEW_TEXT_CHANGED:
@ -578,207 +541,6 @@ var Output = {
var Input = {
editState: {},
start: function start() {
// XXX: This is too disruptive on desktop for now.
// Might need to add special modifiers.
if (Utils.MozBuildApp != "browser") {
Utils.win.document.addEventListener("keypress", this, true);
}
Utils.win.addEventListener("mozAccessFuGesture", this, true);
},
stop: function stop() {
if (Utils.MozBuildApp != "browser") {
Utils.win.document.removeEventListener("keypress", this, true);
}
Utils.win.removeEventListener("mozAccessFuGesture", this, true);
},
handleEvent: function Input_handleEvent(aEvent) {
try {
switch (aEvent.type) {
case "keypress":
this._handleKeypress(aEvent);
break;
case "mozAccessFuGesture":
this._handleGesture(aEvent.detail);
break;
}
} catch (x) {
Logger.logException(x);
}
},
_handleGesture: function _handleGesture(aGesture) {
let gestureName = aGesture.type + aGesture.touches.length;
Logger.debug("Gesture", aGesture.type,
"(fingers: " + aGesture.touches.length + ")");
switch (gestureName) {
case "dwell1":
case "explore1":
this.moveToPoint("Simple", aGesture.touches[0].x,
aGesture.touches[0].y);
break;
case "doubletap1":
this.activateCurrent();
break;
case "doubletaphold1":
Utils.dispatchChromeEvent("accessibility-control", "quicknav-menu");
break;
case "swiperight1":
this.moveCursor("moveNext", "Simple", "gestures");
break;
case "swipeleft1":
this.moveCursor("movePrevious", "Simple", "gesture");
break;
case "swipeup1":
this.moveCursor(
"movePrevious", this.quickNavMode.current, "gesture", true);
break;
case "swipedown1":
this.moveCursor("moveNext", this.quickNavMode.current, "gesture", true);
break;
case "exploreend1":
case "dwellend1":
this.activateCurrent(null, true);
break;
case "swiperight2":
if (aGesture.edge) {
Utils.dispatchChromeEvent("accessibility-control",
"edge-swipe-right");
break;
}
this.sendScrollMessage(-1, true);
break;
case "swipedown2":
if (aGesture.edge) {
Utils.dispatchChromeEvent("accessibility-control", "edge-swipe-down");
break;
}
this.sendScrollMessage(-1);
break;
case "swipeleft2":
if (aGesture.edge) {
Utils.dispatchChromeEvent("accessibility-control", "edge-swipe-left");
break;
}
this.sendScrollMessage(1, true);
break;
case "swipeup2":
if (aGesture.edge) {
Utils.dispatchChromeEvent("accessibility-control", "edge-swipe-up");
break;
}
this.sendScrollMessage(1);
break;
case "explore2":
Utils.CurrentBrowser.contentWindow.scrollBy(
-aGesture.deltaX, -aGesture.deltaY);
break;
case "swiperight3":
this.moveCursor("moveNext", this.quickNavMode.current, "gesture");
break;
case "swipeleft3":
this.moveCursor("movePrevious", this.quickNavMode.current, "gesture");
break;
case "swipedown3":
this.quickNavMode.next();
AccessFu.announce("quicknav_" + this.quickNavMode.current);
break;
case "swipeup3":
this.quickNavMode.previous();
AccessFu.announce("quicknav_" + this.quickNavMode.current);
break;
case "tripletap3":
Utils.dispatchChromeEvent("accessibility-control", "toggle-shade");
break;
case "tap2":
Utils.dispatchChromeEvent("accessibility-control", "toggle-pause");
break;
}
},
_handleKeypress: function _handleKeypress(aEvent) {
let target = aEvent.target;
// Ignore keys with modifiers so the content could take advantage of them.
if (aEvent.ctrlKey || aEvent.altKey || aEvent.metaKey) {
return;
}
switch (aEvent.keyCode) {
case 0:
// an alphanumeric key was pressed, handle it separately.
// If it was pressed with either alt or ctrl, just pass through.
// If it was pressed with meta, pass the key on without the meta.
if (this.editState.editing) {
return;
}
let key = String.fromCharCode(aEvent.charCode);
try {
let [methodName, rule] = this.keyMap[key];
this.moveCursor(methodName, rule, "keyboard");
} catch (x) {
return;
}
break;
case aEvent.DOM_VK_RIGHT:
if (this.editState.editing) {
if (!this.editState.atEnd) {
// Don't move forward if caret is not at end of entry.
// XXX: Fix for rtl
return;
}
target.blur();
}
this.moveCursor(aEvent.shiftKey ?
"moveLast" : "moveNext", "Simple", "keyboard");
break;
case aEvent.DOM_VK_LEFT:
if (this.editState.editing) {
if (!this.editState.atStart) {
// Don't move backward if caret is not at start of entry.
// XXX: Fix for rtl
return;
}
target.blur();
}
this.moveCursor(aEvent.shiftKey ?
"moveFirst" : "movePrevious", "Simple", "keyboard");
break;
case aEvent.DOM_VK_UP:
if (this.editState.multiline) {
if (!this.editState.atStart) {
// Don't blur content if caret is not at start of text area.
return;
}
target.blur();
}
if (Utils.MozBuildApp == "mobile/android") {
// Return focus to native Android browser chrome.
Utils.win.WindowEventDispatcher.dispatch("ToggleChrome:Focus");
}
break;
case aEvent.DOM_VK_RETURN:
if (this.editState.editing) {
return;
}
this.activateCurrent();
break;
default:
return;
}
aEvent.preventDefault();
aEvent.stopPropagation();
},
moveToPoint: function moveToPoint(aRule, aX, aY) {
// XXX: Bug 1013408 - There is no alignment between the chrome window's
// viewport size and the content viewport size in Android. This makes
@ -837,11 +599,6 @@ var Input = {
{offset, activateIfKey: aActivateIfKey});
},
sendContextMenuMessage: function sendContextMenuMessage() {
let mm = Utils.getMessageManager(Utils.CurrentBrowser);
mm.sendAsyncMessage("AccessFu:ContextMenu", {});
},
setEditState: function setEditState(aEditState) {
Logger.debug(() => { return ["setEditState", JSON.stringify(aEditState)]; });
this.editState = aEditState;
@ -862,82 +619,10 @@ var Input = {
doScroll: function doScroll(aDetails) {
let horizontal = aDetails.horizontal;
let page = aDetails.page;
let p = AccessFu.adjustContentBounds(
aDetails.bounds, Utils.CurrentBrowser, true).center();
let p = AccessFu.screenToClientBounds(aDetails.bounds).center();
Utils.winUtils.sendWheelEvent(p.x, p.y,
horizontal ? page : 0, horizontal ? 0 : page, 0,
Utils.win.WheelEvent.DOM_DELTA_PAGE, 0, 0, 0, 0);
},
get keyMap() {
delete this.keyMap;
this.keyMap = {
a: ["moveNext", "Anchor"],
A: ["movePrevious", "Anchor"],
b: ["moveNext", "Button"],
B: ["movePrevious", "Button"],
c: ["moveNext", "Combobox"],
C: ["movePrevious", "Combobox"],
d: ["moveNext", "Landmark"],
D: ["movePrevious", "Landmark"],
e: ["moveNext", "Entry"],
E: ["movePrevious", "Entry"],
f: ["moveNext", "FormElement"],
F: ["movePrevious", "FormElement"],
g: ["moveNext", "Graphic"],
G: ["movePrevious", "Graphic"],
h: ["moveNext", "Heading"],
H: ["movePrevious", "Heading"],
i: ["moveNext", "ListItem"],
I: ["movePrevious", "ListItem"],
k: ["moveNext", "Link"],
K: ["movePrevious", "Link"],
l: ["moveNext", "List"],
L: ["movePrevious", "List"],
p: ["moveNext", "PageTab"],
P: ["movePrevious", "PageTab"],
r: ["moveNext", "RadioButton"],
R: ["movePrevious", "RadioButton"],
s: ["moveNext", "Separator"],
S: ["movePrevious", "Separator"],
t: ["moveNext", "Table"],
T: ["movePrevious", "Table"],
x: ["moveNext", "Checkbox"],
X: ["movePrevious", "Checkbox"]
};
return this.keyMap;
},
quickNavMode: {
get current() {
return this.modes[this._currentIndex];
},
previous: function quickNavMode_previous() {
Services.prefs.setIntPref(QUICKNAV_INDEX_PREF,
this._currentIndex > 0 ?
this._currentIndex - 1 : this.modes.length - 1);
},
next: function quickNavMode_next() {
Services.prefs.setIntPref(QUICKNAV_INDEX_PREF,
this._currentIndex + 1 >= this.modes.length ?
0 : this._currentIndex + 1);
},
updateModes: function updateModes(aModes) {
if (aModes) {
this.modes = aModes.split(",");
} else {
this.modes = [];
}
},
updateCurrentMode: function updateCurrentMode(aModeIndex) {
Logger.debug("Quicknav mode:", this.modes[aModeIndex]);
this._currentIndex = aModeIndex;
}
}
};
AccessFu.Input = Input;

View File

@ -44,7 +44,6 @@ this.ContentControl.prototype = {
for (let message of this.messagesOfInterest) {
cs.addMessageListener(message, this);
}
cs.addEventListener("mousemove", this);
},
stop: function cc_stop() {
@ -52,7 +51,6 @@ this.ContentControl.prototype = {
for (let message of this.messagesOfInterest) {
cs.removeMessageListener(message, this);
}
cs.removeEventListener("mousemove", this);
},
get document() {
@ -106,7 +104,7 @@ this.ContentControl.prototype = {
}
this._contentScope.get().sendAsyncMessage("AccessFu:DoScroll",
{ bounds: Utils.getBounds(position, true),
{ bounds: Utils.getBounds(position),
page: aMessage.json.direction === "forward" ? 1 : -1,
horizontal: false });
},
@ -158,24 +156,11 @@ this.ContentControl.prototype = {
}
},
handleEvent: function cc_handleEvent(aEvent) {
if (aEvent.type === "mousemove") {
this.handleMoveToPoint(
{ json: { x: aEvent.screenX, y: aEvent.screenY, rule: "Simple" } });
}
if (!Utils.getMessageManager(aEvent.target)) {
aEvent.preventDefault();
} else {
aEvent.target.focus();
}
},
handleMoveToPoint: function cc_handleMoveToPoint(aMessage) {
let [x, y] = [aMessage.json.x, aMessage.json.y];
let rule = TraversalRules[aMessage.json.rule];
let dpr = this.window.devicePixelRatio;
this.vc.moveToPoint(rule, x * dpr, y * dpr, true);
this.vc.moveToPoint(rule, x, y, true);
},
handleClearCursor: function cc_handleClearCursor(aMessage) {

View File

@ -1,951 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
/* exported GestureSettings, GestureTracker */
/** ****************************************************************************
All gestures have the following pathways when being resolved(v)/rejected(x):
Tap -> DoubleTap (x)
-> Dwell (x)
-> Swipe (x)
DoubleTap -> TripleTap (x)
-> TapHold (x)
TripleTap -> DoubleTapHold (x)
Dwell -> DwellEnd (v)
Swipe -> Explore (x)
TapHold -> TapHoldEnd (v)
DoubleTapHold -> DoubleTapHoldEnd (v)
DwellEnd -> Explore (x)
TapHoldEnd -> Explore (x)
DoubleTapHoldEnd -> Explore (x)
ExploreEnd -> Explore (x)
Explore -> ExploreEnd (v)
******************************************************************************/
"use strict";
var EXPORTED_SYMBOLS = ["GestureSettings", "GestureTracker"]; // jshint ignore:line
ChromeUtils.defineModuleGetter(this, "Utils", // jshint ignore:line
"resource://gre/modules/accessibility/Utils.jsm");
ChromeUtils.defineModuleGetter(this, "Logger", // jshint ignore:line
"resource://gre/modules/accessibility/Utils.jsm");
ChromeUtils.defineModuleGetter(this, "setTimeout", // jshint ignore:line
"resource://gre/modules/Timer.jsm");
ChromeUtils.defineModuleGetter(this, "clearTimeout", // jshint ignore:line
"resource://gre/modules/Timer.jsm");
ChromeUtils.defineModuleGetter(this, "PromiseUtils", // jshint ignore:line
"resource://gre/modules/PromiseUtils.jsm");
// Default maximum duration of swipe
const SWIPE_MAX_DURATION = 200;
// Default maximum amount of time allowed for a gesture to be considered a
// multitouch
const MAX_MULTITOUCH = 125;
// Default maximum consecutive pointer event timeout
const MAX_CONSECUTIVE_GESTURE_DELAY = 200;
// Default delay before tap turns into dwell
const DWELL_THRESHOLD = 250;
// Minimal swipe distance in inches
const SWIPE_MIN_DISTANCE = 0.4;
// Maximum distance the pointer could move during a tap in inches
const TAP_MAX_RADIUS = 0.2;
// Directness coefficient. It is based on the maximum 15 degree angle between
// consequent pointer move lines.
const DIRECTNESS_COEFF = 1.44;
// Amount in inches from the edges of the screen for it to be an edge swipe
const EDGE = 0.1;
// Multiply timeouts by this constant, x2 works great too for slower users.
const TIMEOUT_MULTIPLIER = 1;
// A single pointer down/up sequence periodically precedes the tripple swipe
// gesture on Android. This delay acounts for that.
const IS_ANDROID = Utils.MozBuildApp === "mobile/android" &&
Utils.AndroidSdkVersion >= 14;
/**
* A point object containing distance travelled data.
* @param {Object} aPoint A point object that looks like: {
* x: x coordinate in pixels,
* y: y coordinate in pixels
* }
*/
function Point(aPoint) {
this.startX = this.x = aPoint.x;
this.startY = this.y = aPoint.y;
this.distanceTraveled = 0;
this.totalDistanceTraveled = 0;
}
Point.prototype = {
/**
* Update the current point coordiates.
* @param {Object} aPoint A new point coordinates.
*/
update: function Point_update(aPoint) {
let lastX = this.x;
let lastY = this.y;
this.x = aPoint.x;
this.y = aPoint.y;
this.distanceTraveled = this.getDistanceToCoord(lastX, lastY);
this.totalDistanceTraveled += this.distanceTraveled;
},
reset: function Point_reset() {
this.distanceTraveled = 0;
this.totalDistanceTraveled = 0;
},
/**
* Get distance between the current point coordinates and the given ones.
* @param {Number} aX A pixel value for the x coordinate.
* @param {Number} aY A pixel value for the y coordinate.
* @return {Number} A distance between point's current and the given
* coordinates.
*/
getDistanceToCoord: function Point_getDistanceToCoord(aX, aY) {
return Math.hypot(this.x - aX, this.y - aY);
},
/**
* Get the direct distance travelled by the point so far.
*/
get directDistanceTraveled() {
return this.getDistanceToCoord(this.startX, this.startY);
}
};
/**
* An externally accessible collection of settings used in gesture resolition.
* @type {Object}
*/
var GestureSettings = { // jshint ignore:line
/**
* Maximum duration of swipe
* @type {Number}
*/
swipeMaxDuration: SWIPE_MAX_DURATION * TIMEOUT_MULTIPLIER,
/**
* Maximum amount of time allowed for a gesture to be considered a multitouch.
* @type {Number}
*/
maxMultitouch: MAX_MULTITOUCH * TIMEOUT_MULTIPLIER,
/**
* Maximum consecutive pointer event timeout.
* @type {Number}
*/
maxConsecutiveGestureDelay:
MAX_CONSECUTIVE_GESTURE_DELAY * TIMEOUT_MULTIPLIER,
/**
* A maximum time we wait for a next pointer down event to consider a sequence
* a multi-action gesture.
* @type {Number}
*/
maxGestureResolveTimeout:
MAX_CONSECUTIVE_GESTURE_DELAY * TIMEOUT_MULTIPLIER,
/**
* Delay before tap turns into dwell
* @type {Number}
*/
dwellThreshold: DWELL_THRESHOLD * TIMEOUT_MULTIPLIER,
/**
* Minimum distance that needs to be travelled for the pointer move to be
* fired.
* @type {Number}
*/
travelThreshold: 0.025
};
/**
* An interface that handles the pointer events and calculates the appropriate
* gestures.
* @type {Object}
*/
var GestureTracker = { // jshint ignore:line
/**
* Reset GestureTracker to its initial state.
* @return {[type]} [description]
*/
reset: function GestureTracker_reset() {
if (this.current) {
this.current.clearTimer();
}
delete this.current;
},
/**
* Create a new gesture object and attach resolution handler to it as well as
* handle the incoming pointer event.
* @param {Object} aDetail A new pointer event detail.
* @param {Number} aTimeStamp A new pointer event timeStamp.
* @param {Function} aGesture A gesture constructor (default: Tap).
*/
_init: function GestureTracker__init(aDetail, aTimeStamp, aGesture) {
// Only create a new gesture on |pointerdown| event.
if (aDetail.type !== "pointerdown") {
return;
}
let GestureConstructor = aGesture || (IS_ANDROID ? DoubleTap : Tap);
this._create(GestureConstructor);
this._update(aDetail, aTimeStamp);
},
/**
* Handle the incoming pointer event with the existing gesture object(if
* present) or with the newly created one.
* @param {Object} aDetail A new pointer event detail.
* @param {Number} aTimeStamp A new pointer event timeStamp.
*/
handle: function GestureTracker_handle(aDetail, aTimeStamp) {
Logger.gesture(() => {
return ["Pointer event", Utils.dpi, "at:", aTimeStamp, JSON.stringify(aDetail)];
});
this[this.current ? "_update" : "_init"](aDetail, aTimeStamp);
},
/**
* Create a new gesture object and attach resolution handler to it.
* @param {Function} aGesture A gesture constructor.
* @param {Number} aTimeStamp An original pointer event timeStamp.
* @param {Array} aPoints All changed points associated with the new pointer
* event.
* @param {?String} aLastEvent Last pointer event type.
*/
_create: function GestureTracker__create(aGesture, aTimeStamp, aPoints, aLastEvent) {
this.current = new aGesture(aTimeStamp, aPoints, aLastEvent); /* A constructor name should start with an uppercase letter. */ // jshint ignore:line
this.current.then(this._onFulfill.bind(this));
},
/**
* Handle the incoming pointer event with the existing gesture object.
* @param {Object} aDetail A new pointer event detail.
* @param {Number} aTimeStamp A new pointer event timeStamp.
*/
_update: function GestureTracker_update(aDetail, aTimeStamp) {
this.current[aDetail.type](aDetail.points, aTimeStamp);
},
/**
* A resolution handler function for the current gesture promise.
* @param {Object} aResult A resolution payload with the relevant gesture id
* and an optional new gesture contructor.
*/
_onFulfill: function GestureTracker__onFulfill(aResult) {
let {id, gestureType} = aResult;
let current = this.current;
// Do nothing if there's no existing gesture or there's already a newer
// gesture.
if (!current || current.id !== id) {
return;
}
// Only create a gesture if we got a constructor.
if (gestureType) {
this._create(gestureType, current.startTime, current.points,
current.lastEvent);
} else {
this.current.clearTimer();
delete this.current;
}
}
};
/**
* Compile a mozAccessFuGesture detail structure.
* @param {String} aType A gesture type.
* @param {Object} aPoints Gesture's points.
* @param {String} xKey A default key for the x coordinate. Default is
* 'startX'.
* @param {String} yKey A default key for the y coordinate. Default is
* 'startY'.
* @return {Object} a mozAccessFuGesture detail structure.
*/
function compileDetail(aType, aPoints, keyMap = {x: "startX", y: "startY"}) {
let touches = [];
let maxDeltaX = 0;
let maxDeltaY = 0;
for (let identifier in aPoints) {
let point = aPoints[identifier];
let touch = {};
for (let key in keyMap) {
touch[key] = point[keyMap[key]];
}
touches.push(touch);
let deltaX = point.x - point.startX;
let deltaY = point.y - point.startY;
// Determine the maximum x and y travel intervals.
if (Math.abs(maxDeltaX) < Math.abs(deltaX)) {
maxDeltaX = deltaX;
}
if (Math.abs(maxDeltaY) < Math.abs(deltaY)) {
maxDeltaY = deltaY;
}
// Since the gesture is resolving, reset the points' distance information
// since they are passed to the next potential gesture.
point.reset();
}
return {
type: aType,
touches,
deltaX: maxDeltaX,
deltaY: maxDeltaY
};
}
/**
* A general gesture object.
* @param {Number} aTimeStamp An original pointer event's timeStamp that started
* the gesture resolution sequence.
* @param {Object} aPoints An existing set of points (from previous events).
* Default is an empty object.
* @param {?String} aLastEvent Last pointer event type.
*/
function Gesture(aTimeStamp, aPoints = {}, aLastEvent = undefined) {
this.startTime = Date.now();
Logger.gesture("Creating", this.id, "gesture.");
this.points = aPoints;
this.lastEvent = aLastEvent;
this._deferred = PromiseUtils.defer();
// Call this._handleResolve or this._handleReject when the promise is
// fulfilled with either resolve or reject.
this.promise = this._deferred.promise.then(this._handleResolve.bind(this),
this._handleReject.bind(this));
this.startTimer(aTimeStamp);
}
Gesture.prototype = {
/**
* Get the gesture timeout delay.
* @return {Number}
*/
_getDelay: function Gesture__getDelay() {
// If nothing happens withing the
// GestureSettings.maxConsecutiveGestureDelay, we should not wait for any
// more pointer events and consider them the part of the same gesture -
// reject this gesture promise.
return GestureSettings.maxConsecutiveGestureDelay;
},
/**
* Clear the existing timer.
*/
clearTimer: function Gesture_clearTimer() {
Logger.gesture("clearTimeout", this.type);
clearTimeout(this._timer);
delete this._timer;
},
/**
* Start the timer for gesture timeout.
* @param {Number} aTimeStamp An original pointer event's timeStamp that
* started the gesture resolution sequence.
*/
startTimer: function Gesture_startTimer(aTimeStamp) {
Logger.gesture("startTimer", this.type);
this.clearTimer();
let delay = this._getDelay(aTimeStamp);
let handler = () => {
Logger.gesture("timer handler");
this.clearTimer();
if (!this._inProgress) {
this._deferred.reject();
} else if (this._rejectToOnWait) {
this._deferred.reject(this._rejectToOnWait);
}
};
if (delay <= 0) {
handler();
} else {
this._timer = setTimeout(handler, delay);
}
},
/**
* Add a gesture promise resolution callback.
* @param {Function} aCallback
*/
then: function Gesture_then(aCallback) {
this.promise.then(aCallback);
},
/**
* Update gesture's points. Test the points set with the optional gesture test
* function.
* @param {Array} aPoints An array with the changed points from the new
* pointer event.
* @param {String} aType Pointer event type.
* @param {Boolean} aCanCreate A flag that enables including the new points.
* Default is false.
* @param {Boolean} aNeedComplete A flag that indicates that the gesture is
* completing. Default is false.
* @return {Boolean} Indicates whether the gesture can be complete (it is
* set to true iff the aNeedComplete is true and there was a change to at
* least one point that belongs to the gesture).
*/
_update: function Gesture__update(aPoints, aType, aCanCreate = false, aNeedComplete = false) {
let complete;
let lastEvent;
for (let point of aPoints) {
let identifier = point.identifier;
let gesturePoint = this.points[identifier];
if (gesturePoint) {
if (aType === "pointerdown" && aCanCreate) {
// scratch the previous pointer with that id.
this.points[identifier] = new Point(point);
} else {
gesturePoint.update(point);
}
if (aNeedComplete) {
// Since the gesture is completing and at least one of the gesture
// points is updated, set the return value to true.
complete = true;
}
lastEvent = lastEvent || aType;
} else if (aCanCreate) {
// Only create a new point if aCanCreate is true.
this.points[identifier] =
new Point(point);
lastEvent = lastEvent || aType;
}
}
this.lastEvent = lastEvent || this.lastEvent;
// If test function is defined test the points.
if (this.test) {
this.test(complete);
}
return complete;
},
/**
* Emit a mozAccessFuGesture (when the gesture is resolved).
* @param {Object} aDetail a compiled mozAccessFuGesture detail structure.
*/
_emit: function Gesture__emit(aDetail) {
let evt = new Utils.win.CustomEvent("mozAccessFuGesture", {
bubbles: true,
cancelable: true,
detail: aDetail
});
Utils.win.dispatchEvent(evt);
},
/**
* Handle the pointer down event.
* @param {Array} aPoints A new pointer down points.
* @param {Number} aTimeStamp A new pointer down timeStamp.
*/
pointerdown: function Gesture_pointerdown(aPoints, aTimeStamp) {
this._inProgress = true;
this._update(aPoints, "pointerdown",
aTimeStamp - this.startTime < GestureSettings.maxMultitouch);
},
/**
* Handle the pointer move event.
* @param {Array} aPoints A new pointer move points.
*/
pointermove: function Gesture_pointermove(aPoints) {
this._update(aPoints, "pointermove");
},
/**
* Handle the pointer up event.
* @param {Array} aPoints A new pointer up points.
*/
pointerup: function Gesture_pointerup(aPoints) {
let complete = this._update(aPoints, "pointerup", false, true);
if (complete) {
this._deferred.resolve();
}
},
/**
* A subsequent gesture constructor to resolve the current one to. E.g.
* tap->doubletap, dwell->dwellend, etc.
* @type {Function}
*/
resolveTo: null,
/**
* A unique id for the gesture. Composed of the type + timeStamp.
*/
get id() {
delete this._id;
this._id = this.type + this.startTime;
return this._id;
},
/**
* A gesture promise resolve callback. Compile and emit the gesture.
* @return {Object} Returns a structure to the gesture handler that looks like
* this: {
* id: current gesture id,
* gestureType: an optional subsequent gesture constructor.
* }
*/
_handleResolve: function Gesture__handleResolve() {
if (this.isComplete) {
return;
}
Logger.gesture("Resolving", this.id, "gesture.");
this.isComplete = true;
this.clearTimer();
let detail = this.compile();
if (detail) {
this._emit(detail);
}
return {
id: this.id,
gestureType: this.resolveTo
};
},
/**
* A gesture promise reject callback.
* @return {Object} Returns a structure to the gesture handler that looks like
* this: {
* id: current gesture id,
* gestureType: an optional subsequent gesture constructor.
* }
*/
_handleReject: function Gesture__handleReject(aRejectTo) {
if (this.isComplete) {
return;
}
Logger.gesture("Rejecting", this.id, "gesture.");
this.isComplete = true;
this.clearTimer();
return {
id: this.id,
gestureType: aRejectTo
};
},
/**
* A default compilation function used to build the mozAccessFuGesture event
* detail. The detail always includes the type and the touches associated
* with the gesture.
* @return {Object} Gesture event detail.
*/
compile: function Gesture_compile() {
return compileDetail(this.type, this.points);
}
};
/**
* A mixin for an explore related object.
*/
function ExploreGesture() {
this.compile = () => {
// Unlike most of other gestures explore based gestures compile using the
// current point position and not the start one.
return compileDetail(this.type, this.points, {x: "x", y: "y"});
};
}
/**
* Check the in progress gesture for completion.
*/
function checkProgressGesture(aGesture) {
aGesture._inProgress = true;
if (aGesture.lastEvent === "pointerup") {
if (aGesture.test) {
aGesture.test(true);
}
aGesture._deferred.resolve();
}
}
/**
* A common travel gesture. When the travel gesture is created, all subsequent
* pointer events' points are tested for their total distance traveled. If that
* distance exceeds the _threshold distance, the gesture will be rejected to a
* _travelTo gesture.
* @param {Number} aTimeStamp An original pointer event's timeStamp that started
* the gesture resolution sequence.
* @param {Object} aPoints An existing set of points (from previous events).
* @param {?String} aLastEvent Last pointer event type.
* @param {Function} aTravelTo A contructor for the gesture to reject to when
* travelling (default: Explore).
* @param {Number} aThreshold Travel threshold (default:
* GestureSettings.travelThreshold).
*/
function TravelGesture(aTimeStamp, aPoints, aLastEvent, aTravelTo = Explore, aThreshold = GestureSettings.travelThreshold) {
Gesture.call(this, aTimeStamp, aPoints, aLastEvent);
this._travelTo = aTravelTo;
this._threshold = aThreshold;
}
TravelGesture.prototype = Object.create(Gesture.prototype);
/**
* Test the gesture points for travel. The gesture will be rejected to
* this._travelTo gesture iff at least one point crosses this._threshold.
*/
TravelGesture.prototype.test = function TravelGesture_test() {
if (!this._travelTo) {
return;
}
for (let identifier in this.points) {
let point = this.points[identifier];
if (point.totalDistanceTraveled / Utils.dpi > this._threshold) {
this._deferred.reject(this._travelTo);
return;
}
}
};
/**
* DwellEnd gesture.
* @param {Number} aTimeStamp An original pointer event's timeStamp that started
* the gesture resolution sequence.
* @param {Object} aPoints An existing set of points (from previous events).
* @param {?String} aLastEvent Last pointer event type.
*/
function DwellEnd(aTimeStamp, aPoints, aLastEvent) {
this._inProgress = true;
// If the pointer travels, reject to Explore.
TravelGesture.call(this, aTimeStamp, aPoints, aLastEvent);
checkProgressGesture(this);
}
DwellEnd.prototype = Object.create(TravelGesture.prototype);
DwellEnd.prototype.type = "dwellend";
/**
* TapHoldEnd gesture. This gesture can be represented as the following diagram:
* pointerdown-pointerup-pointerdown-*wait*-pointerup.
* @param {Number} aTimeStamp An original pointer event's timeStamp that started
* the gesture resolution sequence.
* @param {Object} aPoints An existing set of points (from previous events).
* @param {?String} aLastEvent Last pointer event type.
*/
function TapHoldEnd(aTimeStamp, aPoints, aLastEvent) {
this._inProgress = true;
// If the pointer travels, reject to Explore.
TravelGesture.call(this, aTimeStamp, aPoints, aLastEvent);
checkProgressGesture(this);
}
TapHoldEnd.prototype = Object.create(TravelGesture.prototype);
TapHoldEnd.prototype.type = "tapholdend";
/**
* DoubleTapHoldEnd gesture. This gesture can be represented as the following
* diagram:
* pointerdown-pointerup-pointerdown-pointerup-pointerdown-*wait*-pointerup.
* @param {Number} aTimeStamp An original pointer event's timeStamp that started
* the gesture resolution sequence.
* @param {Object} aPoints An existing set of points (from previous events).
* @param {?String} aLastEvent Last pointer event type.
*/
function DoubleTapHoldEnd(aTimeStamp, aPoints, aLastEvent) {
this._inProgress = true;
// If the pointer travels, reject to Explore.
TravelGesture.call(this, aTimeStamp, aPoints, aLastEvent);
checkProgressGesture(this);
}
DoubleTapHoldEnd.prototype = Object.create(TravelGesture.prototype);
DoubleTapHoldEnd.prototype.type = "doubletapholdend";
/**
* A common tap gesture object.
* @param {Number} aTimeStamp An original pointer event's timeStamp that started
* the gesture resolution sequence.
* @param {Object} aPoints An existing set of points (from previous events).
* @param {?String} aLastEvent Last pointer event type.
* @param {Function} aRejectToOnWait A constructor for the next gesture to
* reject to in case no pointermove or pointerup happens within the
* GestureSettings.dwellThreshold.
* @param {Function} aTravelTo An optional constuctor for the next gesture to
* reject to in case the the TravelGesture test fails.
* @param {Function} aRejectToOnPointerDown A constructor for the gesture to
* reject to if a finger comes down immediately after the tap.
*/
function TapGesture(aTimeStamp, aPoints, aLastEvent, aRejectToOnWait, aTravelTo, aRejectToOnPointerDown) {
this._rejectToOnWait = aRejectToOnWait;
this._rejectToOnPointerDown = aRejectToOnPointerDown;
// If the pointer travels, reject to aTravelTo.
TravelGesture.call(this, aTimeStamp, aPoints, aLastEvent, aTravelTo,
TAP_MAX_RADIUS);
}
TapGesture.prototype = Object.create(TravelGesture.prototype);
TapGesture.prototype._getDelay = function TapGesture__getDelay() {
// If, for TapGesture, no pointermove or pointerup happens within the
// GestureSettings.dwellThreshold, reject.
// Note: the original pointer event's timeStamp is irrelevant here.
return GestureSettings.dwellThreshold;
};
TapGesture.prototype.pointerup = function TapGesture_pointerup(aPoints) {
if (this._rejectToOnPointerDown) {
let complete = this._update(aPoints, "pointerup", false, true);
if (complete) {
this.clearTimer();
if (GestureSettings.maxGestureResolveTimeout) {
this._pointerUpTimer = setTimeout(() => {
clearTimeout(this._pointerUpTimer);
delete this._pointerUpTimer;
this._deferred.resolve();
}, GestureSettings.maxGestureResolveTimeout);
} else {
this._deferred.resolve();
}
}
} else {
TravelGesture.prototype.pointerup.call(this, aPoints);
}
};
TapGesture.prototype.pointerdown = function TapGesture_pointerdown(aPoints, aTimeStamp) {
if (this._pointerUpTimer) {
clearTimeout(this._pointerUpTimer);
delete this._pointerUpTimer;
this._deferred.reject(this._rejectToOnPointerDown);
} else {
TravelGesture.prototype.pointerdown.call(this, aPoints, aTimeStamp);
}
};
/**
* Tap gesture.
* @param {Number} aTimeStamp An original pointer event's timeStamp that started
* the gesture resolution sequence.
* @param {Object} aPoints An existing set of points (from previous events).
* @param {?String} aLastEvent Last pointer event type.
*/
function Tap(aTimeStamp, aPoints, aLastEvent) {
// If the pointer travels, reject to Swipe.
TapGesture.call(this, aTimeStamp, aPoints, aLastEvent, Dwell, Swipe, DoubleTap);
}
Tap.prototype = Object.create(TapGesture.prototype);
Tap.prototype.type = "tap";
/**
* Double Tap gesture.
* @param {Number} aTimeStamp An original pointer event's timeStamp that started
* the gesture resolution sequence.
* @param {Object} aPoints An existing set of points (from previous events).
* @param {?String} aLastEvent Last pointer event type.
*/
function DoubleTap(aTimeStamp, aPoints, aLastEvent) {
this._inProgress = true;
TapGesture.call(this, aTimeStamp, aPoints, aLastEvent, TapHold, null, TripleTap);
}
DoubleTap.prototype = Object.create(TapGesture.prototype);
DoubleTap.prototype.type = "doubletap";
/**
* Triple Tap gesture.
* @param {Number} aTimeStamp An original pointer event's timeStamp that started
* the gesture resolution sequence.
* @param {Object} aPoints An existing set of points (from previous events).
* @param {?String} aLastEvent Last pointer event type.
*/
function TripleTap(aTimeStamp, aPoints, aLastEvent) {
this._inProgress = true;
TapGesture.call(this, aTimeStamp, aPoints, aLastEvent, DoubleTapHold, null, null);
}
TripleTap.prototype = Object.create(TapGesture.prototype);
TripleTap.prototype.type = "tripletap";
/**
* Common base object for gestures that are created as resolved.
* @param {Number} aTimeStamp An original pointer event's timeStamp that started
* the gesture resolution sequence.
* @param {Object} aPoints An existing set of points (from previous events).
* @param {?String} aLastEvent Last pointer event type.
*/
function ResolvedGesture(aTimeStamp, aPoints, aLastEvent) {
Gesture.call(this, aTimeStamp, aPoints, aLastEvent);
// Resolve the guesture right away.
this._deferred.resolve();
}
ResolvedGesture.prototype = Object.create(Gesture.prototype);
/**
* Dwell gesture
* @param {Number} aTimeStamp An original pointer event's timeStamp that started
* the gesture resolution sequence.
* @param {Object} aPoints An existing set of points (from previous events).
* @param {?String} aLastEvent Last pointer event type.
*/
function Dwell(aTimeStamp, aPoints, aLastEvent) {
ResolvedGesture.call(this, aTimeStamp, aPoints, aLastEvent);
}
Dwell.prototype = Object.create(ResolvedGesture.prototype);
Dwell.prototype.type = "dwell";
Dwell.prototype.resolveTo = DwellEnd;
/**
* TapHold gesture
* @param {Number} aTimeStamp An original pointer event's timeStamp that started
* the gesture resolution sequence.
* @param {Object} aPoints An existing set of points (from previous events).
* @param {?String} aLastEvent Last pointer event type.
*/
function TapHold(aTimeStamp, aPoints, aLastEvent) {
ResolvedGesture.call(this, aTimeStamp, aPoints, aLastEvent);
}
TapHold.prototype = Object.create(ResolvedGesture.prototype);
TapHold.prototype.type = "taphold";
TapHold.prototype.resolveTo = TapHoldEnd;
/**
* DoubleTapHold gesture
* @param {Number} aTimeStamp An original pointer event's timeStamp that started
* the gesture resolution sequence.
* @param {Object} aPoints An existing set of points (from previous events).
* @param {?String} aLastEvent Last pointer event type.
*/
function DoubleTapHold(aTimeStamp, aPoints, aLastEvent) {
ResolvedGesture.call(this, aTimeStamp, aPoints, aLastEvent);
}
DoubleTapHold.prototype = Object.create(ResolvedGesture.prototype);
DoubleTapHold.prototype.type = "doubletaphold";
DoubleTapHold.prototype.resolveTo = DoubleTapHoldEnd;
/**
* Explore gesture
* @param {Number} aTimeStamp An original pointer event's timeStamp that started
* the gesture resolution sequence.
* @param {Object} aPoints An existing set of points (from previous events).
* @param {?String} aLastEvent Last pointer event type.
*/
function Explore(aTimeStamp, aPoints, aLastEvent) {
ExploreGesture.call(this);
ResolvedGesture.call(this, aTimeStamp, aPoints, aLastEvent);
}
Explore.prototype = Object.create(ResolvedGesture.prototype);
Explore.prototype.type = "explore";
Explore.prototype.resolveTo = ExploreEnd;
/**
* ExploreEnd gesture.
* @param {Number} aTimeStamp An original pointer event's timeStamp that started
* the gesture resolution sequence.
* @param {Object} aPoints An existing set of points (from previous events).
* @param {?String} aLastEvent Last pointer event type.
*/
function ExploreEnd(aTimeStamp, aPoints, aLastEvent) {
this._inProgress = true;
ExploreGesture.call(this);
// If the pointer travels, reject to Explore.
TravelGesture.call(this, aTimeStamp, aPoints, aLastEvent);
checkProgressGesture(this);
}
ExploreEnd.prototype = Object.create(TravelGesture.prototype);
ExploreEnd.prototype.type = "exploreend";
/**
* Swipe gesture.
* @param {Number} aTimeStamp An original pointer event's timeStamp that started
* the gesture resolution sequence.
* @param {Object} aPoints An existing set of points (from previous events).
* @param {?String} aLastEvent Last pointer event type.
*/
function Swipe(aTimeStamp, aPoints, aLastEvent) {
this._inProgress = true;
this._rejectToOnWait = Explore;
Gesture.call(this, aTimeStamp, aPoints, aLastEvent);
checkProgressGesture(this);
}
Swipe.prototype = Object.create(Gesture.prototype);
Swipe.prototype.type = "swipe";
Swipe.prototype._getDelay = function Swipe__getDelay(aTimeStamp) {
// Swipe should be completed within the GestureSettings.swipeMaxDuration from
// the initial pointer down event.
return GestureSettings.swipeMaxDuration - this.startTime + aTimeStamp;
};
/**
* Determine wither the gesture was Swipe or Explore.
* @param {Booler} aComplete A flag that indicates whether the gesture is and
* will be complete after the test.
*/
Swipe.prototype.test = function Swipe_test(aComplete) {
if (!aComplete) {
// No need to test if the gesture is not completing or can't be complete.
return;
}
let reject = true;
// If at least one point travelled for more than SWIPE_MIN_DISTANCE and it was
// direct enough, consider it a Swipe.
for (let identifier in this.points) {
let point = this.points[identifier];
let directDistance = point.directDistanceTraveled;
if (directDistance / Utils.dpi >= SWIPE_MIN_DISTANCE ||
directDistance * DIRECTNESS_COEFF >= point.totalDistanceTraveled) {
reject = false;
}
}
if (reject) {
this._deferred.reject(Explore);
}
};
/**
* Compile a swipe related mozAccessFuGesture event detail.
* @return {Object} A mozAccessFuGesture detail object.
*/
Swipe.prototype.compile = function Swipe_compile() {
let type = this.type;
let detail = compileDetail(type, this.points,
{x1: "startX", y1: "startY", x2: "x", y2: "y"});
let deltaX = detail.deltaX;
let deltaY = detail.deltaY;
let edge = EDGE * Utils.dpi;
if (Math.abs(deltaX) > Math.abs(deltaY)) {
// Horizontal swipe.
let startPoints = detail.touches.map(touch => touch.x1);
if (deltaX > 0) {
detail.type = type + "right";
detail.edge = Math.min.apply(null, startPoints) <= edge;
} else {
detail.type = type + "left";
detail.edge =
Utils.win.screen.width - Math.max.apply(null, startPoints) <= edge;
}
} else {
// Vertical swipe.
let startPoints = detail.touches.map(touch => touch.y1);
if (deltaY > 0) {
detail.type = type + "down";
detail.edge = Math.min.apply(null, startPoints) <= edge;
} else {
detail.type = type + "up";
detail.edge =
Utils.win.screen.height - Math.max.apply(null, startPoints) <= edge;
}
}
return detail;
};

View File

@ -1,158 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
/* exported PointerRelay, PointerAdapter */
"use strict";
var EXPORTED_SYMBOLS = ["PointerRelay", "PointerAdapter"]; // jshint ignore:line
ChromeUtils.defineModuleGetter(this, "Utils", // jshint ignore:line
"resource://gre/modules/accessibility/Utils.jsm");
ChromeUtils.defineModuleGetter(this, "Logger", // jshint ignore:line
"resource://gre/modules/accessibility/Utils.jsm");
ChromeUtils.defineModuleGetter(this, "GestureSettings", // jshint ignore:line
"resource://gre/modules/accessibility/Gestures.jsm");
ChromeUtils.defineModuleGetter(this, "GestureTracker", // jshint ignore:line
"resource://gre/modules/accessibility/Gestures.jsm");
// The virtual touch ID generated by a mouse event.
const MOUSE_ID = "mouse";
// Synthesized touch ID.
const SYNTH_ID = -1;
var PointerRelay = { // jshint ignore:line
/**
* A mapping of events we should be intercepting. Entries with a value of
* |true| are used for compiling high-level gesture events. Entries with a
* value of |false| are cancelled and do not propogate to content.
*/
get _eventsOfInterest() {
delete this._eventsOfInterest;
switch (Utils.widgetToolkit) {
case "android":
this._eventsOfInterest = {
"touchstart": true,
"touchmove": true,
"touchend": true };
break;
default:
// Desktop.
this._eventsOfInterest = {
"mousemove": true,
"mousedown": true,
"mouseup": true,
"click": false
};
if ("ontouchstart" in Utils.win) {
for (let eventType of ["touchstart", "touchmove", "touchend"]) {
this._eventsOfInterest[eventType] = true;
}
}
break;
}
return this._eventsOfInterest;
},
_eventMap: {
"touchstart": "pointerdown",
"mousedown": "pointerdown",
"touchmove": "pointermove",
"mousemove": "pointermove",
"touchend": "pointerup",
"mouseup": "pointerup"
},
start: function PointerRelay_start(aOnPointerEvent) {
Logger.debug("PointerRelay.start");
this.onPointerEvent = aOnPointerEvent;
for (let eventType in this._eventsOfInterest) {
Utils.win.addEventListener(eventType, this, true, true);
}
},
stop: function PointerRelay_stop() {
Logger.debug("PointerRelay.stop");
delete this.lastPointerMove;
delete this.onPointerEvent;
for (let eventType in this._eventsOfInterest) {
Utils.win.removeEventListener(eventType, this, true, true);
}
},
handleEvent: function PointerRelay_handleEvent(aEvent) {
// Don't bother with chrome mouse events.
if (Utils.MozBuildApp === "browser" && aEvent.view.top.isChromeWindow) {
return;
}
// aEvent might not be a mouse event here at all; don't do the
// mozInputSource check unless it is.
if (("mozInputSource" in aEvent &&
aEvent.mozInputSource === aEvent.MOZ_SOURCE_UNKNOWN) ||
aEvent.isSynthesized) {
// Ignore events that are scripted or clicks from the a11y API.
return;
}
let changedTouches = aEvent.changedTouches || [{
identifier: MOUSE_ID,
screenX: aEvent.screenX,
screenY: aEvent.screenY,
target: aEvent.target
}];
if (Utils.widgetToolkit === "android" &&
changedTouches.length === 1 && changedTouches[0].identifier === 1) {
return;
}
if (changedTouches.length === 1 &&
changedTouches[0].identifier === SYNTH_ID) {
return;
}
aEvent.preventDefault();
aEvent.stopImmediatePropagation();
let type = aEvent.type;
if (!this._eventsOfInterest[type]) {
return;
}
let pointerType = this._eventMap[type];
this.onPointerEvent({
type: pointerType,
points: Array.prototype.map.call(changedTouches,
function mapTouch(aTouch) {
return {
identifier: aTouch.identifier,
x: aTouch.screenX,
y: aTouch.screenY
};
}
)
});
}
};
var PointerAdapter = { // jshint ignore:line
start: function PointerAdapter_start() {
Logger.debug("PointerAdapter.start");
GestureTracker.reset();
PointerRelay.start(this.handleEvent);
},
stop: function PointerAdapter_stop() {
Logger.debug("PointerAdapter.stop");
PointerRelay.stop();
GestureTracker.reset();
},
handleEvent: function PointerAdapter_handleEvent(aDetail) {
let timeStamp = Date.now();
GestureTracker.handle(aDetail, timeStamp);
}
};

View File

@ -302,15 +302,11 @@ var Utils = { // jshint ignore:line
return res.value;
},
getBounds: function getBounds(aAccessible, aPreserveContentScale) {
getBounds: function getBounds(aAccessible) {
let objX = {}, objY = {}, objW = {}, objH = {};
aAccessible.getBounds(objX, objY, objW, objH);
let scale = aPreserveContentScale ? 1 :
this.getContentResolution(aAccessible);
return new Rect(objX.value, objY.value, objW.value, objH.value).scale(
scale, scale);
return new Rect(objX.value, objY.value, objW.value, objH.value);
},
getTextBounds: function getTextBounds(aAccessible, aStart, aEnd,
@ -320,11 +316,7 @@ var Utils = { // jshint ignore:line
accText.getRangeExtents(aStart, aEnd, objX, objY, objW, objH,
Ci.nsIAccessibleCoordinateType.COORDTYPE_SCREEN_RELATIVE);
let scale = aPreserveContentScale ? 1 :
this.getContentResolution(aAccessible);
return new Rect(objX.value, objY.value, objW.value, objH.value).scale(
scale, scale);
return new Rect(objX.value, objY.value, objW.value, objH.value);
},
/**

View File

@ -62,19 +62,6 @@ function forwardToChild(aMessage, aListener, aVCPosition) {
return true;
}
function activateContextMenu(aMessage) {
let position = Utils.getVirtualCursor(content.document).position;
if (!forwardToChild(aMessage, activateContextMenu, position)) {
let center = Utils.getBounds(position, true).center();
let evt = content.document.createEvent("HTMLEvents");
evt.initEvent("contextmenu", true, true);
evt.clientX = center.x;
evt.clientY = center.y;
position.DOMNode.dispatchEvent(evt);
}
}
function presentCaretChange(aText, aOldOffset, aNewOffset) {
if (aOldOffset !== aNewOffset) {
let msg = Presentation.textSelectionChanged(aText, aNewOffset, aNewOffset,
@ -87,7 +74,7 @@ function scroll(aMessage) {
let position = Utils.getVirtualCursor(content.document).position;
if (!forwardToChild(aMessage, scroll, position)) {
sendAsyncMessage("AccessFu:DoScroll",
{ bounds: Utils.getBounds(position, true),
{ bounds: Utils.getBounds(position),
page: aMessage.json.page,
horizontal: aMessage.json.horizontal });
}
@ -104,7 +91,6 @@ addMessageListener(
if (m.json.buildApp)
Utils.MozBuildApp = m.json.buildApp;
addMessageListener("AccessFu:ContextMenu", activateContextMenu);
addMessageListener("AccessFu:Scroll", scroll);
if (!contentControl) {
@ -139,7 +125,6 @@ addMessageListener(
function(m) {
Logger.debug("AccessFu:Stop");
removeMessageListener("AccessFu:ContextMenu", activateContextMenu);
removeMessageListener("AccessFu:Scroll", scroll);
eventManager.stop();

View File

@ -5,6 +5,3 @@
toolkit.jar:
content/global/accessibility/AccessFu.css (AccessFu.css)
content/global/accessibility/content-script.js (content-script.js)
content/global/accessibility/virtual_cursor_move.ogg (sounds/virtual_cursor_move.ogg)
content/global/accessibility/virtual_cursor_key.ogg (sounds/virtual_cursor_key.ogg)
content/global/accessibility/clicked.ogg (sounds/clicked.ogg)

View File

@ -9,12 +9,10 @@ EXTRA_JS_MODULES.accessibility += [
'Constants.jsm',
'ContentControl.jsm',
'EventManager.jsm',
'Gestures.jsm',
'OutputGenerator.jsm',
'PointerAdapter.jsm',
'Presentation.jsm',
'Traversal.jsm',
'Utils.jsm'
]
JAR_MANIFESTS += ['jar.mn']
JAR_MANIFESTS += ['jar.mn']

Binary file not shown.

View File

@ -6,6 +6,8 @@ support-files =
!/accessible/tests/mochitest/*.js
!/accessible/tests/mochitest/letters.gif
[browser_test_resolution.js]
skip-if = e10s && os == 'win' # bug 1372296
[browser_test_zoom.js]
[browser_test_zoom_text.js]
skip-if = e10s && os == 'win' # bug 1372296

View File

@ -0,0 +1,57 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
/* import-globals-from ../../mochitest/layout.js */
async function testScaledBounds(browser, accDoc, scale, id, type = "object") {
let acc = findAccessibleChildByID(accDoc, id);
// Get document offset
let [docX, docY] = getBounds(accDoc);
// Get the unscaled bounds of the accessible
let [x, y, width, height] = type == "text" ?
getRangeExtents(acc, 0, -1, COORDTYPE_SCREEN_RELATIVE) : getBounds(acc);
await ContentTask.spawn(browser, scale, _scale => {
setResolution(document, _scale);
});
let [scaledX, scaledY, scaledWidth, scaledHeight] = type == "text" ?
getRangeExtents(acc, 0, -1, COORDTYPE_SCREEN_RELATIVE) : getBounds(acc);
let name = prettyName(acc);
isWithin(scaledWidth, width * scale, 2, "Wrong scaled width of " + name);
isWithin(scaledHeight, height * scale, 2, "Wrong scaled height of " + name);
isWithin(scaledX - docX, (x - docX) * scale, 2, "Wrong scaled x of " + name);
isWithin(scaledY - docY, (y - docY) * scale, 2, "Wrong scaled y of " + name);
await ContentTask.spawn(browser, {}, () => {
setResolution(document, 1.0);
});
}
async function runTests(browser, accDoc) {
loadFrameScripts(browser, { name: "layout.js", dir: MOCHITESTS_DIR });
await testScaledBounds(browser, accDoc, 2.0, "p1");
await testScaledBounds(browser, accDoc, 0.5, "p2");
await testScaledBounds(browser, accDoc, 3.5, "b1");
await testScaledBounds(browser, accDoc, 2.0, "p1", "text");
await testScaledBounds(browser, accDoc, 0.75, "p2", "text");
}
/**
* Test accessible boundaries when page is zoomed
*/
addAccessibleTask(`
<p id='p1' style='font-family: monospace;'>Tilimilitryamdiya</p>
<p id="p2">para 2</p>
<button id="b1">Hello</button>
`,
runTests
);

View File

@ -45,7 +45,6 @@ const nsIAccessibleValue = Ci.nsIAccessibleValue;
const nsIObserverService = Ci.nsIObserverService;
const nsIDOMDocument = Ci.nsIDOMDocument;
const nsIDOMEvent = Ci.nsIDOMEvent;
const nsIDOMNode = Ci.nsIDOMNode;
const nsIDOMWindow = Ci.nsIDOMWindow;

View File

@ -829,7 +829,7 @@ const kInvokerCanceled = 2;
eventQueue.getEventTypeAsString =
function eventQueue_getEventTypeAsString(aEventOrChecker) {
if (aEventOrChecker instanceof nsIDOMEvent)
if (Event.isInstance(aEventOrChecker))
return aEventOrChecker.type;
if (aEventOrChecker instanceof nsIAccessibleEvent)
@ -841,10 +841,11 @@ eventQueue.getEventTypeAsString =
eventQueue.getEventTargetDescr =
function eventQueue_getEventTargetDescr(aEventOrChecker, aDontForceTarget) {
if (aEventOrChecker instanceof nsIDOMEvent)
if (Event.isInstance(aEventOrChecker))
return prettyName(aEventOrChecker.originalTarget);
if (aEventOrChecker instanceof nsIDOMEvent)
// XXXbz this block doesn't seem to be reachable...
if (Event.isInstance(aEventOrChecker))
return prettyName(aEventOrChecker.accessible);
var descr = aEventOrChecker.targetDescr;
@ -877,7 +878,7 @@ eventQueue.getEventTarget = function eventQueue_getEventTarget(aChecker) {
eventQueue.compareEventTypes =
function eventQueue_compareEventTypes(aChecker, aEvent) {
var eventType = (aEvent instanceof nsIDOMEvent) ?
var eventType = Event.isInstance(aEvent) ?
aEvent.type : aEvent.eventType;
return aChecker.type == eventType;
};
@ -893,7 +894,7 @@ eventQueue.compareEvents = function eventQueue_compareEvents(aChecker, aEvent) {
var target1 = aChecker.target;
if (target1 instanceof nsIAccessible) {
var target2 = (aEvent instanceof nsIDOMEvent) ?
var target2 = Event.isInstance(aEvent) ?
getAccessible(aEvent.target) : aEvent.accessible;
return target1 == target2;
@ -901,7 +902,7 @@ eventQueue.compareEvents = function eventQueue_compareEvents(aChecker, aEvent) {
// If original target isn't suitable then extend interface to support target
// (original target is used in test_elm_media.html).
var target2 = (aEvent instanceof nsIDOMEvent) ?
var target2 = Event.isInstance(aEvent) ?
aEvent.originalTarget : aEvent.DOMNode;
return target1 == target2;
};
@ -942,7 +943,7 @@ eventQueue.logEvent = function eventQueue_logEvent(aOrigEvent, aMatchedChecker,
aInvokerStatus) {
// Dump DOM event information. Skip a11y event since it is dumped by
// gA11yEventObserver.
if (aOrigEvent instanceof nsIDOMEvent) {
if (Event.isInstance(aOrigEvent)) {
var info = "Event type: " + eventQueue.getEventTypeAsString(aOrigEvent);
info += ". Target: " + eventQueue.getEventTargetDescr(aOrigEvent);
gLogger.logToDOM(info);

View File

@ -1,7 +1,5 @@
[DEFAULT]
support-files =
dom_helper.js
gestures.json
jsatcommon.js
output.js
doc_traversal.html
@ -17,14 +15,11 @@ skip-if = buildapp == 'mulet'
[test_content_text.html]
skip-if = buildapp == 'mulet'
[test_explicit_names.html]
[test_gesture_tracker.html]
[test_hints.html]
[test_landmarks.html]
[test_live_regions.html]
[test_output_mathml.html]
[test_output.html]
[test_quicknav_modes.html]
[test_tables.html]
[test_pointer_relay.html]
[test_traversal.html]
[test_traversal_helper.html]

View File

@ -1,204 +0,0 @@
"use strict";
/* exported loadJSON, eventMap */
ChromeUtils.import("resource://gre/modules/Geometry.jsm");
var win = getMainChromeWindow(window);
/**
* Convert inch based point coordinates into pixels.
* @param {Array} aPoints Array of coordinates in inches.
* @return {Array} Array of coordinates in pixels.
*/
function convertPointCoordinates(aPoints) {
var dpi = Utils.dpi;
return aPoints.map(function convert(aPoint) {
return {
x: aPoint.x * dpi,
y: aPoint.y * dpi,
identifier: aPoint.identifier
};
});
}
/**
* For a given list of points calculate their coordinates in relation to the
* document body.
* @param {Array} aTouchPoints An array of objects of the following format: {
* base: {String}, // Id of an element to server as a base for the touch.
* x: {Number}, // An optional x offset from the base element's geometric
* // centre.
* y: {Number} // An optional y offset from the base element's geometric
* // centre.
* }
* @return {JSON} An array of {x, y} coordinations.
*/
function calculateTouchListCoordinates(aTouchPoints) {
var coords = [];
for (var i = 0, target = aTouchPoints[i]; i < aTouchPoints.length; ++i) {
var bounds = getBoundsForDOMElm(target.base);
var parentBounds = getBoundsForDOMElm("root");
var point = new Point(target.x || 0, target.y || 0);
point.scale(Utils.dpi);
point.add(bounds[0], bounds[1]);
point.add(bounds[2] / 2, bounds[3] / 2);
point.subtract(parentBounds[0], parentBounds[0]);
coords.push({
x: point.x,
y: point.y
});
}
return coords;
}
/**
* Send a touch event with specified touchPoints.
* @param {Array} aTouchPoints An array of points to be associated with
* touches.
* @param {String} aName A name of the touch event.
*/
function sendTouchEvent(aTouchPoints, aName) {
var touchList = sendTouchEvent.touchList;
if (aName === "touchend") {
sendTouchEvent.touchList = null;
} else {
var coords = calculateTouchListCoordinates(aTouchPoints);
var touches = [];
for (var i = 0; i < coords.length; ++i) {
var {x, y} = coords[i];
var node = document.elementFromPoint(x, y);
var touch = document.createTouch(window, node, aName === "touchstart" ?
1 : touchList.item(i).identifier, x, y, x, y);
touches.push(touch);
}
touchList = document.createTouchList(touches);
sendTouchEvent.touchList = touchList;
}
var evt = document.createEvent("TouchEvent");
evt.initTouchEvent(aName, true, true, window, 0, false, false, false, false,
touchList, touchList, touchList);
document.dispatchEvent(evt);
}
sendTouchEvent.touchList = null;
/**
* A map of event names to the functions that actually send them.
* @type {Object}
*/
var eventMap = {
touchstart: sendTouchEvent,
touchend: sendTouchEvent,
touchmove: sendTouchEvent
};
/**
* Attach a listener for the mozAccessFuGesture event that tests its
* type.
* @param {Array} aExpectedGestures A stack of expected event types.
* @param {String} aTitle Title of this sequence, if any.
* Note: the listener is removed once the stack reaches 0.
*/
function testMozAccessFuGesture(aExpectedGestures, aTitle) {
var types = aExpectedGestures;
function handleGesture(aEvent) {
if (aEvent.detail.type !== types[0].type) {
info("Got " + aEvent.detail.type + " waiting for " + types[0].type);
// The is not the event of interest.
return;
}
is(!!aEvent.detail.edge, !!types[0].edge);
is(aEvent.detail.touches.length, types[0].fingers || 1,
"failed to count fingers: " + types[0].type);
ok(true, "Received correct mozAccessFuGesture: " +
JSON.stringify(types.shift()) + ". (" + aTitle + ")");
if (types.length === 0) {
win.removeEventListener("mozAccessFuGesture", handleGesture);
if (AccessFuTest.sequenceCleanup) {
AccessFuTest.sequenceCleanup();
}
AccessFuTest.nextTest();
}
}
win.addEventListener("mozAccessFuGesture", handleGesture);
}
/**
* Reset the thresholds and max delays that affect gesture rejection.
* @param {Number} aTimeStamp Gesture time stamp.
* @param {Boolean} aRemoveDwellThreshold An optional flag to reset dwell
* threshold.
* @param {Boolean} aRemoveSwipeMaxDuration An optional flag to reset swipe max
* duration.
*/
function setTimers(aTimeStamp, aRemoveDwellThreshold, aRemoveSwipeMaxDuration) {
if (!aRemoveDwellThreshold && !aRemoveSwipeMaxDuration) {
return;
}
if (aRemoveDwellThreshold) {
GestureSettings.dwellThreshold = 0;
}
if (aRemoveSwipeMaxDuration) {
GestureSettings.swipeMaxDuration = 0;
}
GestureTracker.current.clearTimer();
GestureTracker.current.startTimer(aTimeStamp);
}
function resetTimers(aRemoveGestureResolveDelay) {
GestureSettings.dwellThreshold = AccessFuTest.dwellThreshold;
GestureSettings.swipeMaxDuration = AccessFuTest.swipeMaxDuration;
GestureSettings.maxGestureResolveTimeout = aRemoveGestureResolveDelay ?
0 : AccessFuTest.maxGestureResolveTimeout;
}
/**
* An extention to AccessFuTest that adds an ability to test a sequence of
* pointer events and their expected mozAccessFuGesture events.
* @param {Object} aSequence An object that has a list of pointer events to be
* generated and the expected mozAccessFuGesture events.
*/
AccessFuTest.addSequence = function AccessFuTest_addSequence(aSequence) {
AccessFuTest.addFunc(function testSequence() {
testMozAccessFuGesture(aSequence.expectedGestures, aSequence.title);
var events = aSequence.events;
function fireEvent(aEvent) {
var event = {
points: convertPointCoordinates(aEvent.points),
type: aEvent.type
};
var timeStamp = Date.now();
resetTimers(aEvent.removeGestureResolveDelay);
GestureTracker.handle(event, timeStamp);
setTimers(timeStamp, aEvent.removeDwellThreshold,
aEvent.removeSwipeMaxDuration);
processEvents();
}
function processEvents() {
if (events.length === 0) {
return;
}
var event = events.shift();
SimpleTest.executeSoon(function() {
fireEvent(event);
});
}
processEvents();
});
};
/**
* A helper function that loads JSON files.
* @param {String} aPath A path to a JSON file.
* @param {Function} aCallback A callback to be called on success.
*/
function loadJSON(aPath, aCallback) {
var request = new XMLHttpRequest();
request.open("GET", aPath, true);
request.responseType = "json";
request.onload = function onload() {
aCallback(request.response);
};
request.send();
}

View File

@ -1,352 +0,0 @@
[
{
"events": [
{"type": "pointerdown", "points": [{"x": 1, "y": 1, "identifier": 1}]},
{"type": "pointerup", "points": [{"x": 1, "y": 1, "identifier": 1}],
"removeGestureResolveDelay": true }
],
"expectedGestures": [{ "type": "tap" }]
},
{
"events": [
{"type": "pointerdown", "points": [{"x": 1, "y": 1, "identifier": 1}]},
{"type": "pointermove",
"points": [{"x": 1.03, "y": 1.03, "identifier": 1}]},
{"type": "pointerup", "points": [{"x": 1.03, "y": 1.03, "identifier": 1}],
"removeGestureResolveDelay": true }
],
"expectedGestures": [{ "type": "tap" }]
},
{
"events": [
{"type": "pointerdown", "points": [{"x": 1, "y": 1, "identifier": 1}],
"removeDwellThreshold": true},
{"type": "pointerup", "points": [{"x": 1, "y": 1, "identifier": 1}]}
],
"expectedGestures": [{ "type": "dwell" }, { "type": "dwellend" }]
},
{
"events": [
{"type": "pointerdown", "points": [{"x": 1, "y": 1, "identifier": 1}]},
{"type": "pointermove",
"points": [{"x": 1.03, "y": 1.02, "identifier": 1}]},
{"type": "pointerup",
"points": [{"x": 1.03, "y": 1.02, "identifier": 1}]},
{"type": "pointerdown", "points": [{"x": 1, "y": 1, "identifier": 1}]},
{"type": "pointermove",
"points": [{"x": 0.97, "y": 1.01, "identifier": 1}]},
{"type": "pointerup",
"points": [{"x": 0.97, "y": 1.01, "identifier": 1}],
"removeGestureResolveDelay": true }
],
"expectedGestures": [{ "type": "doubletap" }]
},
{
"events": [
{"type": "pointerdown", "points": [{"x": 1, "y": 1, "identifier": 1}]},
{"type": "pointerup", "points": [{"x": 1, "y": 1, "identifier": 1}]},
{"type": "pointerdown", "points": [{"x": 1, "y": 1, "identifier": 1}]},
{"type": "pointerup", "points": [{"x": 1, "y": 1, "identifier": 1}]},
{"type": "pointerdown", "points": [{"x": 1, "y": 1, "identifier": 1}]},
{"type": "pointerup", "points": [{"x": 1, "y": 1, "identifier": 1}],
"removeGestureResolveDelay": true }
],
"expectedGestures": [{ "type": "tripletap" }]
},
{
"events": [
{"type": "pointerdown", "points": [{"x": 1, "y": 1, "identifier": 1}]},
{"type": "pointerup", "points": [{"x": 1, "y": 1, "identifier": 1}]},
{"type": "pointerdown", "points": [{"x": 1, "y": 1, "identifier": 1}]},
{"type": "pointerup", "points": [{"x": 1, "y": 1, "identifier": 1}]},
{"type": "pointerdown", "points": [{"x": 1, "y": 1, "identifier": 1}],
"removeDwellThreshold": true},
{"type": "pointerup", "points": [{"x": 1, "y": 1, "identifier": 1}]}
],
"expectedGestures": [{ "type": "doubletaphold" },
{ "type": "doubletapholdend" }]
},
{
"events": [
{"type": "pointerdown", "points": [{"x": 1, "y": 1, "identifier": 1}]},
{"type": "pointerup", "points": [{"x": 1, "y": 1, "identifier": 1}]},
{"type": "pointerdown", "points": [{"x": 1, "y": 1, "identifier": 1}],
"removeDwellThreshold": true},
{"type": "pointerup", "points": [{"x": 1, "y": 1, "identifier": 1}]}
],
"expectedGestures": [{ "type": "taphold" }, { "type": "tapholdend" }]
},
{
"events": [
{"type": "pointerdown", "points": [{"x": 1, "y": 1, "identifier": 1}]},
{"type": "pointermove", "points": [{"x": 1.5, "y": 1, "identifier": 1}]},
{"type": "pointerup", "points": [{"x": 1.5, "y": 1, "identifier": 1}]}
],
"expectedGestures": [{ "type": "swiperight" }]
},
{
"events": [
{"type": "pointerdown", "points": [{"x": 1, "y": 1, "identifier": 1}]},
{"type": "pointermove", "points": [{"x": 1.15, "y": 1, "identifier": 1}]},
{"type": "pointermove", "points": [{"x": 1.3, "y": 1, "identifier": 1}]},
{"type": "pointerup", "points": [{"x": 1.3, "y": 1, "identifier": 1}]}
],
"expectedGestures": [{ "type": "swiperight" }]
},
{
"events": [
{"type": "pointerdown", "points": [{"x": 1.5, "y": 1, "identifier": 1}]},
{"type": "pointermove", "points": [{"x": 1, "y": 1, "identifier": 1}]},
{"type": "pointerup", "points": [{"x": 1, "y": 1, "identifier": 1}]}
],
"expectedGestures": [{ "type": "swipeleft" }]
},
{
"events": [
{"type": "pointerdown", "points": [{"x": 1, "y": 1, "identifier": 1}]},
{"type": "pointermove", "points": [{"x": 1, "y": 1.5, "identifier": 1}]},
{"type": "pointerup", "points": [{"x": 1, "y": 1.5, "identifier": 1}]}
],
"expectedGestures": [{ "type": "swipedown" }]
},
{
"events": [
{"type": "pointerdown", "points": [{"x": 1, "y": 1.5, "identifier": 1}]},
{"type": "pointermove", "points": [{"x": 1, "y": 1, "identifier": 1}]},
{"type": "pointerup", "points": [{"x": 1, "y": 1, "identifier": 1}]}
],
"expectedGestures": [{ "type": "swipeup" }]
},
{
"events": [
{"type": "pointerdown", "points": [{"x": 1, "y": 1, "identifier": 1}]},
{"type": "pointermove",
"points": [{"x": 1.5, "y": 1.1, "identifier": 1}]},
{"type": "pointerup", "points": [{"x": 1.5, "y": 1.1, "identifier": 1}]}
],
"expectedGestures": [{ "type": "swiperight" }]
},
{
"events": [
{"type": "pointerdown",
"points": [{"x": 1.5, "y": 1.1, "identifier": 1}]},
{"type": "pointermove", "points": [{"x": 1, "y": 0.95, "identifier": 1}]},
{"type": "pointerup", "points": [{"x": 1, "y": 0.95, "identifier": 1}]}
],
"expectedGestures": [{ "type": "swipeleft" }]
},
{
"events": [
{"type": "pointerdown", "points": [{"x": 1, "y": 1, "identifier": 1}]},
{"type": "pointermove",
"points": [{"x": 0.9, "y": 1.5, "identifier": 1}]},
{"type": "pointerup", "points": [{"x": 0.9, "y": 1.5, "identifier": 1}]}
],
"expectedGestures": [{ "type": "swipedown" }]
},
{
"events": [
{"type": "pointerdown",
"points": [{"x": 1.1, "y": 1.5, "identifier": 1}]},
{"type": "pointermove", "points": [{"x": 1, "y": 1, "identifier": 1}]},
{"type": "pointerup", "points": [{"x": 1, "y": 1, "identifier": 1}]}
],
"expectedGestures": [{ "type": "swipeup" }]
},
{
"events": [
{"type": "pointerdown", "points": [{"x": 1, "y": 1, "identifier": 1},
{"x": 1, "y": 1.5, "identifier": 2}]},
{"type": "pointermove", "points": [{"x": 1.5, "y": 1, "identifier": 1},
{"x": 1.5, "y": 1.5, "identifier": 2}]},
{"type": "pointerup", "points": [{"x": 1.5, "y": 1, "identifier": 1},
{"x": 1.5, "y": 1.5, "identifier": 2}]}
],
"expectedGestures": [{ "type": "swiperight", "fingers": 2 }]
},
{
"events": [
{"type": "pointerdown", "points": [{"x": 1, "y": 1, "identifier": 1},
{"x": 1, "y": 1.5, "identifier": 2}]},
{"type": "pointermove", "points": [{"x": 1.5, "y": 1, "identifier": 1},
{"x": 1.5, "y": 1.5, "identifier": 2}]},
{"type": "pointerup", "points": [{"x": 1.5, "y": 1, "identifier": 1}]},
{"type": "pointerup", "points": [{"x": 1.5, "y": 1.5, "identifier": 2}]}
],
"expectedGestures": [{ "type": "swiperight", "fingers": 2 }]
},
{
"events": [
{"type": "pointerdown", "points": [{"x": 1, "y": 1, "identifier": 1},
{"x": 1, "y": 1.5, "identifier": 2},
{"x": 1, "y": 2, "identifier": 3}]},
{"type": "pointermove", "points": [{"x": 1.5, "y": 1, "identifier": 1},
{"x": 1.5, "y": 1.5, "identifier": 2},
{"x": 1.5, "y": 2, "identifier": 3}]},
{"type": "pointerup", "points": [{"x": 1.5, "y": 1, "identifier": 1},
{"x": 1.5, "y": 1.5, "identifier": 2},
{"x": 1.5, "y": 2, "identifier": 3}]}
],
"expectedGestures": [{ "type": "swiperight", "fingers": 3 }]
},
{
"events": [
{"type": "pointerdown",
"points": [{"x": 1.6, "y": 1.5, "identifier": 1}],
"removeDwellThreshold": true},
{"type": "pointermove", "points": [{"x": 1, "y": 1, "identifier": 1}]},
{"type": "pointerup", "points": [{"x": 1, "y": 1, "identifier": 1}]}
],
"expectedGestures": [{ "type": "dwell" }, { "type": "explore" },
{ "type": "exploreend" }]
},
{
"events": [
{"type": "pointerdown",
"points": [{"x": 1.6, "y": 1.5, "identifier": 1}],
"removeDwellThreshold": true},
{"type": "pointermove", "points": [{"x": 1, "y": 1, "identifier": 1}]},
{"type": "pointermove", "points": [{"x": 2, "y": 2, "identifier": 1}]},
{"type": "pointerup", "points": [{"x": 2, "y": 2, "identifier": 1}]}
],
"expectedGestures": [{ "type": "dwell" }, { "type": "explore" },
{ "type": "explore" }, { "type": "exploreend" }]
},
{
"events": [
{"type": "pointerdown",
"points": [{"x": 1.6, "y": 1.5, "identifier": 1}]},
{"type": "pointermove", "points": [{"x": 1, "y": 1, "identifier": 1}],
"removeSwipeMaxDuration": true},
{"type": "pointerup", "points": [{"x": 1, "y": 1, "identifier": 1}]}
],
"expectedGestures": [{ "type": "explore" }, { "type": "exploreend" }]
},
{
"events": [
{"type": "pointerdown", "points": [{"x": 1, "y": 1.5, "identifier": 1}]},
{"type": "pointermove", "points": [{"x": 1, "y": 1, "identifier": 1}],
"removeSwipeMaxDuration": true},
{"type": "pointermove", "points": [{"x": 1.5, "y": 1, "identifier": 1}]},
{"type": "pointerup", "points": [{"x": 1.5, "y": 1, "identifier": 1}]}
],
"expectedGestures": [{ "type": "explore" }, { "type": "explore" },
{ "type": "exploreend" }]
},
{
"events": [
{"type": "pointerdown", "points": [{"x": 1, "y": 1, "identifier": 1}],
"removeDwellThreshold": true},
{"type": "pointermove",
"points": [{"x": 1.5, "y": 1.5, "identifier": 1}]},
{"type": "pointermove",
"points": [{"x": 1.55, "y": 1.5, "identifier": 1}]},
{"type": "pointermove",
"points": [{"x": 1.6, "y": 1.5, "identifier": 1}]},
{"type": "pointermove",
"points": [{"x": 1.65, "y": 1.5, "identifier": 1}]},
{"type": "pointermove",
"points": [{"x": 1.7, "y": 1.5, "identifier": 1}]},
{"type": "pointermove",
"points": [{"x": 1.75, "y": 1.5, "identifier": 1}]},
{"type": "pointerup", "points": [{"x": 1.75, "y": 1.5, "identifier": 1}]}
],
"expectedGestures": [{ "type": "dwell" }, { "type": "explore" },
{ "type": "explore" }, { "type": "exploreend" }]
},
{
"events": [
{"type": "pointerdown", "points": [{"x": 0.075, "y": 1, "identifier": 1},
{"x": 1, "y": 1.5, "identifier": 2}]},
{"type": "pointermove", "points": [{"x": 1.5, "y": 1, "identifier": 1},
{"x": 1.5, "y": 1.5, "identifier": 2}]},
{"type": "pointerup", "points": [{"x": 1.5, "y": 1, "identifier": 1},
{"x": 1.5, "y": 1.5, "identifier": 2}]}
],
"expectedGestures": [{ "type": "swiperight", "edge": true, "fingers": 2 }]
},
{
"title": "Bug 1182311 - 3 finger triple tap is not reliable 1/2",
"events": [
{"points": [
{"y": 1.88467, "x": 0.89311, "identifier": 0},
{"y": 2.78481, "x": 0.56259, "identifier": 1},
{"y": 1.35021, "x": 1.37834, "identifier": 2}], "type": "pointerdown"},
{"points": [
{"y": 1.88467, "x": 0.89311, "identifier": 0},
{"y": 2.78481, "x": 0.56259, "identifier": 1},
{"y": 1.35021, "x": 1.37834, "identifier": 2}], "type": "pointerup"},
{"points": [
{"y": 1.76512, "x": 0.98453, "identifier": 0},
{"y": 1.1744, "x": 1.4346, "identifier": 1},
{"y": 2.5879, "x": 0.61181, "identifier": 2}], "type": "pointerdown"},
{"points": [
{"y": 1.76512, "x": 0.98453, "identifier": 0},
{"y": 1.1744, "x": 1.4346, "identifier": 1},
{"y": 2.5879, "x": 0.61181, "identifier": 2}], "type": "pointerup"},
{"points": [
{"y": 1.30098, "x": 1.52602, "identifier": 0},
{"y": 1.94093, "x": 1.02672, "identifier": 1},
{"y": 2.67229, "x": 0.75246, "identifier": 2}], "type": "pointerdown"},
{"points": [
{"y": 1.30098, "x": 1.52602, "identifier": 0},
{"y": 1.94093, "x": 1.02672, "identifier": 1},
{"y": 2.67229, "x": 0.75246, "identifier": 2}], "type": "pointerup",
"removeGestureResolveDelay": true}],
"expectedGestures": [{ "type": "tripletap", "fingers": 3 }]
},
{
"title": "Bug 1182311 - 3 finger triple tap is not reliable 2/2",
"events": [
{"type": "pointerdown",
"points": [{"identifier": 0, "x": 2.21875, "y": 1.510417}]},
{"type": "pointerdown",
"points": [{"identifier": 1, "x": 1.479167, "y": 2.53125}]},
{"type": "pointerdown",
"points": [{"identifier": 2, "x": 1.072917, "y": 3.739583}]},
{"type": "pointermove",
"points": [{"identifier": 1, "x": 1.46875, "y": 2.53125}]},
{"type": "pointermove",
"points": [{"identifier": 1, "x": 1.447917, "y": 2.46875}]},
{"type": "pointerup",
"points": [{"identifier": 0, "x": 2.21875, "y": 1.510417}]},
{"type": "pointerup",
"points": [{"identifier": 1, "x": 1.447917, "y": 2.489583}]},
{"type": "pointerup",
"points": [{"identifier": 2, "x": 1.072917, "y": 3.739583}]},
{"type": "pointerdown",
"points": [{"identifier": 0, "x": 2.114583, "y": 1.572917}]},
{"type": "pointerdown",
"points": [{"identifier": 1, "x": 1.364583, "y": 2.614583}]},
{"type": "pointerdown",
"points": [{"identifier": 2, "x": 0.927083, "y": 3.864583}]},
{"type": "pointermove",
"points": [{"identifier": 1, "x": 1.364583, "y": 2.614583}]},
{"type": "pointermove",
"points": [{"identifier": 0, "x": 2.114583, "y": 1.572917}]},
{"type": "pointerup",
"points": [{"identifier": 1, "x": 1.364583, "y": 2.614583}]},
{"type": "pointerup",
"points": [{"identifier": 2, "x": 0.927083, "y": 3.864583}]},
{"type": "pointerup",
"points": [{"identifier": 0, "x": 2.114583, "y": 1.572917}]},
{"type": "pointerdown",
"points": [{"identifier": 0, "x": 1.4375, "y": 2.59375}]},
{"type": "pointerdown",
"points": [{"identifier": 1, "x": 1.083333, "y": 3.71875}]},
{"type": "pointerdown",
"points": [{"identifier": 2, "x": 2.15625, "y": 1.489583}]},
{"type": "pointermove",
"points": [{"identifier": 0, "x": 1.4375, "y": 2.59375},
{"identifier": 2, "x": 2.15625, "y": 1.489583}]},
{"type": "pointermove",
"points": [{"identifier": 0, "x": 1.4375, "y": 2.59375},
{"identifier": 2, "x": 2.15625, "y": 1.489583}]},
{"type": "pointerup",
"points": [{"identifier": 1, "x": 1.083333, "y": 3.71875}],
"removeGestureResolveDelay": true}
],
"expectedGestures": [{ "type": "tripletap", "fingers": 3 }]
}
]

View File

@ -17,7 +17,6 @@ var gIterator;
ChromeUtils.import("resource://gre/modules/Services.jsm");
ChromeUtils.import("resource://gre/modules/accessibility/Utils.jsm");
ChromeUtils.import("resource://gre/modules/accessibility/EventManager.jsm");
ChromeUtils.import("resource://gre/modules/accessibility/Gestures.jsm");
var AccessFuTest = {
@ -99,14 +98,6 @@ var AccessFuTest = {
// Disable the console service logging.
Logger.test = false;
Logger.logLevel = Logger.INFO;
// Reset Gesture Settings.
GestureSettings.dwellThreshold = this.dwellThreshold =
this.originalDwellThreshold;
GestureSettings.swipeMaxDuration = this.swipeMaxDuration =
this.originalSwipeMaxDuration;
GestureSettings.maxGestureResolveTimeout =
this.maxGestureResolveTimeout =
this.originalMaxGestureResolveTimeout;
// Finish through idle callback to let AccessFu._disable complete.
SimpleTest.executeSoon(function() {
AccessFu.detach();
@ -158,20 +149,6 @@ var AccessFuTest = {
var prefs = [["accessibility.accessfu.notify_output", 1]];
prefs.push.apply(prefs, aAdditionalPrefs);
this.originalDwellThreshold = GestureSettings.dwellThreshold;
this.originalSwipeMaxDuration = GestureSettings.swipeMaxDuration;
this.originalMaxGestureResolveTimeout =
GestureSettings.maxGestureResolveTimeout;
// https://bugzilla.mozilla.org/show_bug.cgi?id=1001945 - sometimes
// SimpleTest.executeSoon timeout is bigger than the timer settings in
// GestureSettings that causes intermittents.
this.dwellThreshold = GestureSettings.dwellThreshold =
GestureSettings.dwellThreshold * 10;
this.swipeMaxDuration = GestureSettings.swipeMaxDuration =
GestureSettings.swipeMaxDuration * 10;
this.maxGestureResolveTimeout = GestureSettings.maxGestureResolveTimeout =
GestureSettings.maxGestureResolveTimeout * 10;
SpecialPowers.pushPrefEnv({ "set": prefs }, function() {
if (AccessFuTest._waitForExplicitFinish) {
// Run all test functions asynchronously.

View File

@ -1,51 +0,0 @@
<html>
<head>
<title>AccessFu tests for gesture tracker.</title>
<link rel="stylesheet" type="text/css"
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="../common.js"></script>
<script type="application/javascript" src="../layout.js"></script>
<script type="application/javascript" src="./jsatcommon.js"></script>
<script type="application/javascript" src="./dom_helper.js"></script>
<script type="application/javascript">
function startGestureTracker() {
GestureTracker.reset();
AccessFuTest.nextTest();
}
function stopGestureTracker() {
GestureTracker.reset();
AccessFuTest.finish();
}
function doTest() {
loadJSON("./gestures.json", function onSuccess(gestures) {
AccessFuTest.addFunc(startGestureTracker);
AccessFuTest.sequenceCleanup = GestureTracker.reset.bind(
GestureTracker);
gestures.forEach(AccessFuTest.addSequence);
AccessFuTest.addFunc(stopGestureTracker);
AccessFuTest.waitForExplicitFinish();
Logger.logLevel = Logger.GESTURE;
AccessFuTest.runTests();
});
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTest);
</script>
</head>
<body>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=981015"
title="AccessFu tests for gesture tracker.">
Mozilla Bug 981015
</a>
</body>
</html>

View File

@ -1,95 +0,0 @@
<html>
<head>
<title>AccessFu tests for pointer relay.</title>
<link rel="stylesheet" type="text/css"
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="../common.js"></script>
<script type="application/javascript" src="../layout.js"></script>
<script type="application/javascript" src="./jsatcommon.js"></script>
<script type="application/javascript" src="./dom_helper.js"></script>
<script type="application/javascript">
ChromeUtils.import(
"resource://gre/modules/accessibility/PointerAdapter.jsm");
var tests = [
{
type: "touchstart", target: [{base: "button"}],
expected: {type: "pointerdown", length: 1}
},
{
type: "touchmove", target: [{base: "button"}],
expected: {type: "pointermove", length: 1}
},
{
type: "touchend", target: [{base: "button"}],
expected: {type: "pointerup"}
},
{
type: "touchstart", target: [{base: "button"},
{base: "button", x: 0.5, y: 0.3}],
expected: {type: "pointerdown", length: 2}
},
{
type: "touchend", target: [{base: "button"},
{base: "button", x: 0.5, y: 0.3}],
expected: {type: "pointerup"}
},
{
type: "touchstart", target: [{base: "button"},
{base: "button", x: 0.5, y: 0.3},
{base: "button", x: 0.5, y: -0.3}],
expected: {type: "pointerdown", length: 3}
},
{
type: "touchend", target: [{base: "button"},
{base: "button", x: 0.5, y: 0.3},
{base: "button", x: 0.5, y: -0.3}],
expected: {type: "pointerup"}
}
];
function makeTestFromSpec(test) {
return function runTest() {
PointerRelay.start(function onPointerEvent(aDetail) {
is(aDetail.type, test.expected.type,
"mozAccessFuPointerEvent is correct.");
if (test.expected.length) {
is(aDetail.points.length, test.expected.length,
"mozAccessFuPointerEvent points length is correct.");
}
PointerRelay.stop();
AccessFuTest.nextTest();
});
eventMap[test.type](test.target, test.type);
};
}
function doTest() {
tests.forEach(function addTest(test) {
AccessFuTest.addFunc(makeTestFromSpec(test));
});
AccessFuTest.waitForExplicitFinish();
AccessFuTest.runTests();
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTest);
</script>
</head>
<body id="root">
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=976082"
title="[AccessFu] Provide tests for pointer relay.">
Mozilla Bug 981015
</a>
<div>
<button id="button">I am a button</button>
</div>
</body>
</html>

View File

@ -1,105 +0,0 @@
<html>
<head>
<title>AccessFu test for enabling</title>
<link rel="stylesheet" type="text/css"
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="../common.js"></script>
<script type="application/javascript"
src="./jsatcommon.js"></script>
<script type="application/javascript">
function startAccessFu() {
AccessFuTest.once_log("EventManager.start", AccessFuTest.nextTest);
AccessFu._enable();
}
function nextMode(aCurrentMode, aNextMode) {
return function() {
is(AccessFu.Input.quickNavMode.current, aCurrentMode,
"initial current mode is correct");
AccessFu.Input.quickNavMode.next();
_expectMode(aNextMode, AccessFuTest.nextTest);
};
}
function prevMode(aCurrentMode, aNextMode) {
return function() {
is(AccessFu.Input.quickNavMode.current, aCurrentMode,
"initial current mode is correct");
AccessFu.Input.quickNavMode.previous();
_expectMode(aNextMode, AccessFuTest.nextTest);
};
}
function setMode(aModeIndex, aExpectedMode) {
return function() {
SpecialPowers.pushPrefEnv(
{"set": [["accessibility.accessfu.quicknav_index", aModeIndex]]},
function() {
_expectMode(aExpectedMode, AccessFuTest.nextTest);
});
};
}
function reconfigureModes() {
SpecialPowers.pushPrefEnv(
{"set": [["accessibility.accessfu.quicknav_modes", "Landmark,Button,Entry,Graphic"]]},
function() {
// When the modes are reconfigured, the current mode should
// be set to the first in the new list.
_expectMode("Landmark", AccessFuTest.nextTest);
});
}
function _expectMode(aExpectedMode, aCallback) {
if (AccessFu.Input.quickNavMode.current === aExpectedMode) {
ok(true, "correct mode");
aCallback();
} else {
AccessFuTest.once_log("Quicknav mode: " + aExpectedMode, function() {
ok(true, "correct mode");
aCallback();
});
}
}
function stopAccessFu() {
ok(AccessFu._enabled, "AccessFu is enabled.");
AccessFuTest.once_log("EventManager.stop", () => AccessFuTest.finish());
AccessFu._disable();
}
function doTest() {
AccessFuTest.addFunc(startAccessFu);
AccessFuTest.addFunc(nextMode("Link", "Heading"));
AccessFuTest.addFunc(nextMode("Heading", "FormElement"));
AccessFuTest.addFunc(nextMode("FormElement", "Link"));
AccessFuTest.addFunc(nextMode("Link", "Heading"));
AccessFuTest.addFunc(prevMode("Heading", "Link"));
AccessFuTest.addFunc(prevMode("Link", "FormElement"));
AccessFuTest.addFunc(setMode(1, "Heading"));
AccessFuTest.addFunc(reconfigureModes);
AccessFuTest.addFunc(stopAccessFu);
AccessFuTest.waitForExplicitFinish();
AccessFuTest.runTests([ // Will call SimpleTest.finish();
["accessibility.accessfu.quicknav_modes", "Link,Heading,FormElement"]]);
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTest);
</script>
</head>
<body>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=811307"
title="[AccessFu] Add mochitest for enabling">
Mozilla Bug 811307
</a>
</body>
</html>

View File

@ -68,6 +68,18 @@ function zoomDocument(aDocument, aZoom) {
docViewer.fullZoom = aZoom;
}
/**
* Set the relative resolution of this document. This is what apz does.
* On non-mobile platforms you won't see a visible change.
*/
function setResolution(aDocument, aZoom) {
var windowUtils = aDocument.defaultView.
QueryInterface(Ci.nsIInterfaceRequestor).
getInterface(Ci.nsIDOMWindowUtils);
windowUtils.setResolutionAndScaleTo(aZoom);
}
/**
* Return child accessible at the given point.
*
@ -196,6 +208,14 @@ function getBounds(aID) {
return [x.value, y.value, width.value, height.value];
}
function getRangeExtents(aID, aStartOffset, aEndOffset, aCoordOrigin) {
var hyperText = getAccessible(aID, [nsIAccessibleText]);
var x = {}, y = {}, width = {}, height = {};
hyperText.getRangeExtents(aStartOffset, aEndOffset,
x, y, width, height, aCoordOrigin);
return [x.value, y.value, width.value, height.value];
}
/**
* Return DOM node coordinates relative the screen and its size in device
* pixels.

View File

@ -223,7 +223,7 @@ sdnAccessible::get_computedStyle(unsigned short aMaxStyleProperties,
*aNumStyleProperties = 0;
if (mNode->IsNodeOfType(nsINode::eDOCUMENT))
if (mNode->IsDocument())
return S_FALSE;
nsCOMPtr<nsICSSDeclaration> cssDecl =
@ -266,7 +266,7 @@ sdnAccessible::get_computedStyleForProperties(unsigned short aNumStyleProperties
if (IsDefunct())
return CO_E_OBJNOTCONNECTED;
if (mNode->IsNodeOfType(nsINode::eDOCUMENT))
if (mNode->IsDocument())
return S_FALSE;
nsCOMPtr<nsICSSDeclaration> cssDecl =

View File

@ -1,27 +1,28 @@
# This file has default permissions for the permission manager.
# The file-format is strict:
# * matchtype \t type \t permission \t host
# * "origin" should be used for matchtype, "host" is supported for legacy reasons
# * type is a string that identifies the type of permission (e.g. "cookie")
# * permission is an integer between 1 and 15
# See nsPermissionManager.cpp for more...
# UITour
origin uitour 1 https://www.mozilla.org
origin uitour 1 https://screenshots.firefox.com
origin uitour 1 https://support.mozilla.org
origin uitour 1 https://addons.mozilla.org
origin uitour 1 https://discovery.addons.mozilla.org
origin uitour 1 about:home
origin uitour 1 about:newtab
# XPInstall
origin install 1 https://addons.mozilla.org
origin install 1 https://testpilot.firefox.com
# Remote troubleshooting
origin remote-troubleshooting 1 https://input.mozilla.org
origin remote-troubleshooting 1 https://support.mozilla.org
# Hybrid Content Telemetry - https://firefox-source-docs.mozilla.org/toolkit/components/telemetry/telemetry/collection/hybrid-content.html
origin hc_telemetry 1 https://discovery.addons.mozilla.org
# This file has default permissions for the permission manager.
# The file-format is strict:
# * matchtype \t type \t permission \t host
# * "origin" should be used for matchtype, "host" is supported for legacy reasons
# * type is a string that identifies the type of permission (e.g. "cookie")
# * permission is an integer between 1 and 15
# See nsPermissionManager.cpp for more...
# UITour
origin uitour 1 https://www.mozilla.org
origin uitour 1 https://screenshots.firefox.com
origin uitour 1 https://support.mozilla.org
origin uitour 1 https://addons.mozilla.org
origin uitour 1 https://discovery.addons.mozilla.org
origin uitour 1 about:home
origin uitour 1 about:newtab
# XPInstall
origin install 1 https://addons.mozilla.org
origin install 1 https://testpilot.firefox.com
# Remote troubleshooting
origin remote-troubleshooting 1 https://input.mozilla.org
origin remote-troubleshooting 1 https://support.mozilla.org
# Hybrid Content Telemetry - https://firefox-source-docs.mozilla.org/toolkit/components/telemetry/telemetry/collection/hybrid-content.html
# Adding hc_telemetry permission to a new domain requires Data Collection Review: https://wiki.mozilla.org/Firefox/Data_Collection
origin hc_telemetry 1 https://discovery.addons.mozilla.org

View File

@ -65,13 +65,13 @@ function test_gestureListener(evt) {
is(evt.delta, test_expectedDelta,
"evt.delta (" + evt.delta + ") does not match expected value");
is(evt.shiftKey, (test_expectedModifiers & Ci.nsIDOMEvent.SHIFT_MASK) != 0,
is(evt.shiftKey, (test_expectedModifiers & Event.SHIFT_MASK) != 0,
"evt.shiftKey did not match expected value");
is(evt.ctrlKey, (test_expectedModifiers & Ci.nsIDOMEvent.CONTROL_MASK) != 0,
is(evt.ctrlKey, (test_expectedModifiers & Event.CONTROL_MASK) != 0,
"evt.ctrlKey did not match expected value");
is(evt.altKey, (test_expectedModifiers & Ci.nsIDOMEvent.ALT_MASK) != 0,
is(evt.altKey, (test_expectedModifiers & Event.ALT_MASK) != 0,
"evt.altKey did not match expected value");
is(evt.metaKey, (test_expectedModifiers & Ci.nsIDOMEvent.META_MASK) != 0,
is(evt.metaKey, (test_expectedModifiers & Event.META_MASK) != 0,
"evt.metaKey did not match expected value");
if (evt.type == "MozTapGesture") {
@ -163,19 +163,19 @@ function test_TestEventListeners() {
e("MozEdgeUICompleted", 0, 0, 0);
// event.shiftKey
let modifier = Ci.nsIDOMEvent.SHIFT_MASK;
let modifier = Event.SHIFT_MASK;
e("MozSwipeGesture", SimpleGestureEvent.DIRECTION_RIGHT, 0, modifier);
// event.metaKey
modifier = Ci.nsIDOMEvent.META_MASK;
modifier = Event.META_MASK;
e("MozSwipeGesture", SimpleGestureEvent.DIRECTION_RIGHT, 0, modifier);
// event.altKey
modifier = Ci.nsIDOMEvent.ALT_MASK;
modifier = Event.ALT_MASK;
e("MozSwipeGesture", SimpleGestureEvent.DIRECTION_RIGHT, 0, modifier);
// event.ctrlKey
modifier = Ci.nsIDOMEvent.CONTROL_MASK;
modifier = Event.CONTROL_MASK;
e("MozSwipeGesture", SimpleGestureEvent.DIRECTION_RIGHT, 0, modifier);
}

View File

@ -1,5 +1,8 @@
requestLongerTimeout(2);
const {PlacesTestUtils} =
ChromeUtils.import("resource://testing-common/PlacesTestUtils.jsm", {});
// Bug 453440 - Test the timespan-based logic of the sanitizer code
var now_mSec = Date.now();
var now_uSec = now_mSec * 1000;
@ -426,46 +429,37 @@ async function onHistoryReady() {
ok(!(await downloadExists(publicList, "fakefile-old")), "Year old download should now be deleted");
}
function setupHistory() {
return new Promise(resolve => {
async function setupHistory() {
let places = [];
let places = [];
function addPlace(aURI, aTitle, aVisitDate) {
places.push({
uri: aURI,
title: aTitle,
visits: [{
visitDate: aVisitDate,
transitionType: Ci.nsINavHistoryService.TRANSITION_LINK
}]
});
}
addPlace(makeURI("http://10minutes.com/"), "10 minutes ago", now_uSec - 10 * kUsecPerMin);
addPlace(makeURI("http://1hour.com/"), "Less than 1 hour ago", now_uSec - 45 * kUsecPerMin);
addPlace(makeURI("http://1hour10minutes.com/"), "1 hour 10 minutes ago", now_uSec - 70 * kUsecPerMin);
addPlace(makeURI("http://2hour.com/"), "Less than 2 hours ago", now_uSec - 90 * kUsecPerMin);
addPlace(makeURI("http://2hour10minutes.com/"), "2 hours 10 minutes ago", now_uSec - 130 * kUsecPerMin);
addPlace(makeURI("http://4hour.com/"), "Less than 4 hours ago", now_uSec - 180 * kUsecPerMin);
addPlace(makeURI("http://4hour10minutes.com/"), "4 hours 10 minutesago", now_uSec - 250 * kUsecPerMin);
let today = new Date();
today.setHours(0);
today.setMinutes(0);
today.setSeconds(1);
addPlace(makeURI("http://today.com/"), "Today", today.getTime() * 1000);
let lastYear = new Date();
lastYear.setFullYear(lastYear.getFullYear() - 1);
addPlace(makeURI("http://before-today.com/"), "Before Today", lastYear.getTime() * 1000);
PlacesUtils.asyncHistory.updatePlaces(places, {
handleError: () => ok(false, "Unexpected error in adding visit."),
handleResult: () => { },
handleCompletion: () => resolve()
function addPlace(aURI, aTitle, aVisitDate) {
places.push({
uri: aURI,
title: aTitle,
visitDate: aVisitDate,
transition: Ci.nsINavHistoryService.TRANSITION_LINK
});
}
});
addPlace("http://10minutes.com/", "10 minutes ago", now_uSec - 10 * kUsecPerMin);
addPlace("http://1hour.com/", "Less than 1 hour ago", now_uSec - 45 * kUsecPerMin);
addPlace("http://1hour10minutes.com/", "1 hour 10 minutes ago", now_uSec - 70 * kUsecPerMin);
addPlace("http://2hour.com/", "Less than 2 hours ago", now_uSec - 90 * kUsecPerMin);
addPlace("http://2hour10minutes.com/", "2 hours 10 minutes ago", now_uSec - 130 * kUsecPerMin);
addPlace("http://4hour.com/", "Less than 4 hours ago", now_uSec - 180 * kUsecPerMin);
addPlace("http://4hour10minutes.com/", "4 hours 10 minutesago", now_uSec - 250 * kUsecPerMin);
let today = new Date();
today.setHours(0);
today.setMinutes(0);
today.setSeconds(1);
addPlace("http://today.com/", "Today", today.getTime() * 1000);
let lastYear = new Date();
lastYear.setFullYear(lastYear.getFullYear() - 1);
addPlace("http://before-today.com/", "Before Today", lastYear.getTime() * 1000);
await PlacesTestUtils.addVisits(places);
}
async function setupFormHistory() {

View File

@ -4,7 +4,7 @@
<title>WebExtension test</title>
<meta charset="utf-8">
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/AddTask.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/ExtensionTestUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
</head>

View File

@ -10,59 +10,42 @@
* are shown in it.
*/
var now = Date.now();
add_task(async function test() {
// Add visits.
await PlacesTestUtils.addVisits([{
uri: "http://mozilla.org",
transition: PlacesUtils.history.TRANSITION_TYPED
}, {
uri: "http://google.com",
transition: PlacesUtils.history.TRANSITION_DOWNLOAD
}, {
uri: "http://en.wikipedia.org",
transition: PlacesUtils.history.TRANSITION_TYPED
}, {
uri: "http://ubuntu.org",
transition: PlacesUtils.history.TRANSITION_DOWNLOAD
}]);
function test() {
waitForExplicitFinish();
let library = await promiseLibrary("Downloads");
let onLibraryReady = function(win) {
// Add visits to compare contents with.
let places = [
{ uri: NetUtil.newURI("http://mozilla.com"),
visits: [ new VisitInfo(PlacesUtils.history.TRANSITION_TYPED) ]
},
{ uri: NetUtil.newURI("http://google.com"),
visits: [ new VisitInfo(PlacesUtils.history.TRANSITION_DOWNLOAD) ]
},
{ uri: NetUtil.newURI("http://en.wikipedia.org"),
visits: [ new VisitInfo(PlacesUtils.history.TRANSITION_TYPED) ]
},
{ uri: NetUtil.newURI("http://ubuntu.org"),
visits: [ new VisitInfo(PlacesUtils.history.TRANSITION_DOWNLOAD) ]
},
];
PlacesUtils.asyncHistory.updatePlaces(places, {
handleResult() {},
handleError() {
ok(false, "gHistory.updatePlaces() failed");
},
handleCompletion() {
// Make sure Downloads is present.
isnot(win.PlacesOrganizer._places.selectedNode, null,
"Downloads is present and selected");
registerCleanupFunction(async () => {
await library.close();
await PlacesUtils.history.clear();
});
// Make sure Downloads is present.
Assert.notEqual(library.PlacesOrganizer._places.selectedNode, null,
"Downloads is present and selected");
// Check results.
let testURIs = ["http://ubuntu.org/", "http://google.com/"];
for (let element of win.ContentArea.currentView
.associatedElement.children) {
is(element._shell.download.source.url, testURIs.shift(),
"URI matches");
}
// Check results.
let testURIs = ["http://ubuntu.org/", "http://google.com/"];
win.close();
PlacesUtils.history.clear().then(finish);
}
});
};
await BrowserTestUtils.waitForCondition(() =>
library.ContentArea.currentView.associatedElement.children.length == testURIs.length);
openLibrary(onLibraryReady, "Downloads");
}
function VisitInfo(aTransitionType) {
this.transitionType =
aTransitionType === undefined ?
PlacesUtils.history.TRANSITION_LINK : aTransitionType;
this.visitDate = now++ * 1000;
}
VisitInfo.prototype = {};
for (let element of library.ContentArea.currentView
.associatedElement.children) {
Assert.equal(element._shell.download.source.url, testURIs.shift(),
"URI matches");
}
});

View File

@ -1,7 +1,7 @@
<!DOCTYPE html>
<meta charset="utf8">
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/SpawnTask.js"></script>
<script src="/tests/SimpleTest/AddTask.js"></script>
<script>
/* global SimpleTest SpecialPowers add_task */

View File

@ -8,7 +8,7 @@ https://trac.torproject.org/projects/tor/ticket/1517
<meta charset="utf-8">
<title>Test for Tor Bug 1517 and Mozilla Bug 1424341</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/AddTask.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>

View File

@ -5,7 +5,7 @@
#include "nsISupports.idl"
interface mozIDOMWindowProxy;
interface nsIDOMEventTarget;
webidl EventTarget;
/**
* A callback passed to nsISessionStoreUtils.forEachNonDynamicChildFrame().
@ -43,11 +43,9 @@ interface nsISessionStoreUtils : nsISupports
*
* This is implemented as a native filter, rather than a JS-based one, for
* performance reasons.
*
* Once bug 1444991 is fixed, this should start taking an EventTarget.
*/
[implicit_jscontext]
nsISupports addDynamicFrameFilteredListener(in nsIDOMEventTarget target,
nsISupports addDynamicFrameFilteredListener(in EventTarget target,
in AString type,
in jsval listener,
in boolean useCapture);
@ -62,7 +60,7 @@ interface nsISessionStoreUtils : nsISupports
* caller doesn't actually have something that WebIDL considers an
* EventListener.
*/
void removeDynamicFrameFilteredListener(in nsIDOMEventTarget target,
void removeDynamicFrameFilteredListener(in EventTarget target,
in AString type,
in nsISupports listener,
in boolean useCapture);

View File

@ -25,10 +25,10 @@ public:
: mListener(aListener)
{ }
NS_IMETHODIMP HandleEvent(nsIDOMEvent* aEvent) override
NS_IMETHODIMP HandleEvent(Event* aEvent) override
{
if (mListener && TargetInNonDynamicDocShell(aEvent)) {
mListener->HandleEvent(*aEvent->InternalDOMEvent());
mListener->HandleEvent(*aEvent);
}
return NS_OK;
@ -37,9 +37,9 @@ public:
private:
~DynamicFrameEventFilter() { }
bool TargetInNonDynamicDocShell(nsIDOMEvent* aEvent)
bool TargetInNonDynamicDocShell(Event* aEvent)
{
EventTarget* target = aEvent->InternalDOMEvent()->GetTarget();
EventTarget* target = aEvent->GetTarget();
if (!target) {
return false;
}
@ -117,7 +117,7 @@ nsSessionStoreUtils::ForEachNonDynamicChildFrame(mozIDOMWindowProxy* aWindow,
}
NS_IMETHODIMP
nsSessionStoreUtils::AddDynamicFrameFilteredListener(nsIDOMEventTarget* aTarget,
nsSessionStoreUtils::AddDynamicFrameFilteredListener(EventTarget* aTarget,
const nsAString& aType,
JS::Handle<JS::Value> aListener,
bool aUseCapture,
@ -128,8 +128,7 @@ nsSessionStoreUtils::AddDynamicFrameFilteredListener(nsIDOMEventTarget* aTarget,
return NS_ERROR_INVALID_ARG;
}
nsCOMPtr<EventTarget> target = do_QueryInterface(aTarget);
NS_ENSURE_TRUE(target, NS_ERROR_NO_INTERFACE);
NS_ENSURE_TRUE(aTarget, NS_ERROR_NO_INTERFACE);
JS::Rooted<JSObject*> obj(aCx, &aListener.toObject());
RefPtr<EventListener> listener =
@ -137,7 +136,7 @@ nsSessionStoreUtils::AddDynamicFrameFilteredListener(nsIDOMEventTarget* aTarget,
nsCOMPtr<nsIDOMEventListener> filter(new DynamicFrameEventFilter(listener));
nsresult rv = target->AddEventListener(aType, filter, aUseCapture);
nsresult rv = aTarget->AddEventListener(aType, filter, aUseCapture);
NS_ENSURE_SUCCESS(rv, rv);
filter.forget(aResult);
@ -145,17 +144,16 @@ nsSessionStoreUtils::AddDynamicFrameFilteredListener(nsIDOMEventTarget* aTarget,
}
NS_IMETHODIMP
nsSessionStoreUtils::RemoveDynamicFrameFilteredListener(nsIDOMEventTarget* aTarget,
nsSessionStoreUtils::RemoveDynamicFrameFilteredListener(EventTarget* aTarget,
const nsAString& aType,
nsISupports* aListener,
bool aUseCapture)
{
nsCOMPtr<EventTarget> target = do_QueryInterface(aTarget);
NS_ENSURE_TRUE(target, NS_ERROR_NO_INTERFACE);
NS_ENSURE_TRUE(aTarget, NS_ERROR_NO_INTERFACE);
nsCOMPtr<nsIDOMEventListener> listener = do_QueryInterface(aListener);
NS_ENSURE_TRUE(listener, NS_ERROR_NO_INTERFACE);
target->RemoveEventListener(aType, listener, aUseCapture);
aTarget->RemoveEventListener(aType, listener, aUseCapture);
return NS_OK;
}

View File

@ -5,7 +5,7 @@
<title>Test basic autofill</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/AddTask.js"></script>
<script type="text/javascript" src="formautofill_common.js"></script>
<script type="text/javascript" src="satchel_common.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
@ -14,7 +14,7 @@
Form autofill test: autocomplete on an autofocus form
<script>
/* import-globals-from ../../../../../testing/mochitest/tests/SimpleTest/SpawnTask.js */
/* import-globals-from ../../../../../testing/mochitest/tests/SimpleTest/AddTask.js */
/* import-globals-from ../../../../../toolkit/components/satchel/test/satchel_common.js */
/* import-globals-from formautofill_common.js */

View File

@ -5,7 +5,7 @@
<title>Test basic autofill</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/AddTask.js"></script>
<script type="text/javascript" src="formautofill_common.js"></script>
<script type="text/javascript" src="satchel_common.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
@ -14,7 +14,7 @@
Form autofill test: simple form address autofill
<script>
/* import-globals-from ../../../../../testing/mochitest/tests/SimpleTest/SpawnTask.js */
/* import-globals-from ../../../../../testing/mochitest/tests/SimpleTest/AddTask.js */
/* import-globals-from ../../../../../toolkit/components/satchel/test/satchel_common.js */
/* import-globals-from formautofill_common.js */

View File

@ -5,7 +5,7 @@
<title>Test basic autofill</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/AddTask.js"></script>
<script type="text/javascript" src="formautofill_common.js"></script>
<script type="text/javascript" src="satchel_common.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
@ -14,7 +14,7 @@
Form autofill test: simple form credit card autofill
<script>
/* import-globals-from ../../../../../testing/mochitest/tests/SimpleTest/SpawnTask.js */
/* import-globals-from ../../../../../testing/mochitest/tests/SimpleTest/AddTask.js */
/* import-globals-from ../../../../../toolkit/components/satchel/test/satchel_common.js */
/* import-globals-from formautofill_common.js */

View File

@ -5,7 +5,7 @@
<title>Test form autofill - clear form button</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/AddTask.js"></script>
<script type="text/javascript" src="formautofill_common.js"></script>
<script type="text/javascript" src="satchel_common.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
@ -14,7 +14,7 @@
Form autofill test: clear form button
<script>
/* import-globals-from ../../../../../testing/mochitest/tests/SimpleTest/SpawnTask.js */
/* import-globals-from ../../../../../testing/mochitest/tests/SimpleTest/AddTask.js */
/* import-globals-from ../../../../../toolkit/components/satchel/test/satchel_common.js */
/* import-globals-from formautofill_common.js */

View File

@ -5,7 +5,7 @@
<title>Test basic autofill</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/AddTask.js"></script>
<script type="text/javascript" src="formautofill_common.js"></script>
<script type="text/javascript" src="satchel_common.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
@ -14,7 +14,7 @@
Form autofill test: simple form credit card autofill
<script>
/* import-globals-from ../../../../../testing/mochitest/tests/SimpleTest/SpawnTask.js */
/* import-globals-from ../../../../../testing/mochitest/tests/SimpleTest/AddTask.js */
/* import-globals-from ../../../../../toolkit/components/satchel/test/satchel_common.js */
/* import-globals-from formautofill_common.js */

View File

@ -5,7 +5,7 @@
<title>Test basic autofill</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/AddTask.js"></script>
<script type="text/javascript" src="formautofill_common.js"></script>
<script type="text/javascript" src="satchel_common.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
@ -14,7 +14,7 @@
Form autofill test: autocomplete on an autofocus form
<script>
/* import-globals-from ../../../../../testing/mochitest/tests/SimpleTest/SpawnTask.js */
/* import-globals-from ../../../../../testing/mochitest/tests/SimpleTest/AddTask.js */
/* import-globals-from ../../../../../toolkit/components/satchel/test/satchel_common.js */
/* import-globals-from formautofill_common.js */

View File

@ -5,7 +5,7 @@
<title>Test form autofill - preview and highlight</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/AddTask.js"></script>
<script type="text/javascript" src="formautofill_common.js"></script>
<script type="text/javascript" src="satchel_common.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
@ -14,7 +14,7 @@
Form autofill test: preview and highlight
<script>
/* import-globals-from ../../../../../testing/mochitest/tests/SimpleTest/SpawnTask.js */
/* import-globals-from ../../../../../testing/mochitest/tests/SimpleTest/AddTask.js */
/* import-globals-from ../../../../../toolkit/components/satchel/test/satchel_common.js */
/* import-globals-from formautofill_common.js */

View File

@ -5,7 +5,7 @@
<title>Test basic autofill</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/AddTask.js"></script>
<script type="text/javascript" src="formautofill_common.js"></script>
<script type="text/javascript" src="satchel_common.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
@ -14,7 +14,7 @@
Form autofill test: simple form address autofill
<script>
/* import-globals-from ../../../../../testing/mochitest/tests/SimpleTest/SpawnTask.js */
/* import-globals-from ../../../../../testing/mochitest/tests/SimpleTest/AddTask.js */
/* import-globals-from ../../../../../toolkit/components/satchel/test/satchel_common.js */
/* import-globals-from formautofill_common.js */

View File

@ -5,7 +5,7 @@
<title>Test autofill submit</title>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/AddTask.js"></script>
<script type="text/javascript" src="formautofill_common.js"></script>
<script type="text/javascript" src="satchel_common.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
@ -13,7 +13,7 @@
<body>
<script>
/* import-globals-from ../../../../../testing/mochitest/tests/SimpleTest/SpawnTask.js */
/* import-globals-from ../../../../../testing/mochitest/tests/SimpleTest/AddTask.js */
/* import-globals-from ../../../../../toolkit/components/satchel/test/satchel_common.js */
/* import-globals-from formautofill_common.js */

View File

@ -5,7 +5,7 @@
<title>Test autofill submit</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/AddTask.js"></script>
<script type="text/javascript" src="formautofill_common.js"></script>
<script type="text/javascript" src="satchel_common.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
@ -14,7 +14,7 @@
Form autofill test: check if address is saved/updated correctly
<script>
/* import-globals-from ../../../../../testing/mochitest/tests/SimpleTest/SpawnTask.js */
/* import-globals-from ../../../../../testing/mochitest/tests/SimpleTest/AddTask.js */
/* import-globals-from ../../../../../toolkit/components/satchel/test/satchel_common.js */
/* import-globals-from formautofill_common.js */

View File

@ -510,7 +510,7 @@ let BrowserUsageTelemetry = {
/**
* Records the method by which the user selected a urlbar result.
*
* @param {nsIDOMEvent} event
* @param {Event} event
* The event that triggered the selection.
* @param {string} userSelectionBehavior
* How the user cycled through results before picking the current match.
@ -534,7 +534,7 @@ let BrowserUsageTelemetry = {
/**
* Records the method by which the user selected a searchbar result.
*
* @param {nsIDOMEvent} event
* @param {Event} event
* The event that triggered the selection.
* @param {number} highlightedIndex
* The index that the user chose in the popup, or -1 if there wasn't a

View File

@ -223,7 +223,7 @@ var { helpers, assert } = (function () {
/**
* Navigate the current tab to a URL
*/
helpers.navigate = Task.async(function* (url, options) {
helpers.navigate = async function(url, options) {
options = options || {};
options.chromeWindow = options.chromeWindow || window;
options.tab = options.tab || options.chromeWindow.gBrowser.selectedTab;
@ -233,10 +233,10 @@ var { helpers, assert } = (function () {
let onLoaded = BrowserTestUtils.browserLoaded(options.browser);
options.browser.loadURI(url);
yield onLoaded;
await onLoaded;
return options;
});
};
/**
* Undo the effects of |helpers.openToolbar|
@ -419,15 +419,15 @@ var { helpers, assert } = (function () {
* 7. Tear down all the setup
*/
helpers.runTestModule = function (exports, name) {
return Task.spawn(function* () {
return (async function() {
const uri = "data:text/html;charset=utf-8," +
"<style>div{color:red;}</style>" +
"<div id='gcli-root'>" + name + "</div>";
const options = yield helpers.openTab(uri);
const options = await helpers.openTab(uri);
options.isRemote = true;
yield helpers.openToolbar(options);
await helpers.openToolbar(options);
const system = options.requisition.system;
@ -452,30 +452,30 @@ var { helpers, assert } = (function () {
});
// Send a message to add the commands to the content process
const front = yield GcliFront.create(options.target);
yield front._testOnlyAddItemsByModule(MOCK_COMMANDS_URI);
const front = await GcliFront.create(options.target);
await front._testOnlyAddItemsByModule(MOCK_COMMANDS_URI);
// This will cause the local set of commands to be updated with the
// command proxies, wait for that to complete.
yield addedDeferred.promise;
await addedDeferred.promise;
// Now we need to add the converters to the local GCLI
const converters = mockCommands.items.filter(item => item.item === "converter");
system.addItems(converters);
// Next run the tests
yield helpers.runTests(options, exports);
await helpers.runTests(options, exports);
// Finally undo the mock commands and converters
system.removeItems(converters);
const removePromise = system.commands.onCommandsChange.once();
yield front._testOnlyRemoveItemsByModule(MOCK_COMMANDS_URI);
yield removedDeferred.promise;
await front._testOnlyRemoveItemsByModule(MOCK_COMMANDS_URI);
await removedDeferred.promise;
// And close everything down
yield helpers.closeToolbar(options);
yield helpers.closeTab(options);
}).then(finish, helpers.handleError);
await helpers.closeToolbar(options);
await helpers.closeTab(options);
})().then(finish, helpers.handleError);
};
/**

View File

@ -1,9 +1,9 @@
This is the debugger.html project output.
See https://github.com/devtools-html/debugger.html
Version 40.0
Version 41.0
Comparison: https://github.com/devtools-html/debugger.html/compare/release-39...release-40
Comparison: https://github.com/devtools-html/debugger.html/compare/release-40...release-41
Packages:
- babel-plugin-transform-es2015-modules-commonjs @6.26.0

View File

@ -2939,13 +2939,14 @@ const {
isOriginalId
} = __webpack_require__(1389);
const { workerUtils: { WorkerDispatcher } } = __webpack_require__(1390);
const { workerUtils: { WorkerDispatcher } } = __webpack_require__(1363);
const dispatcher = new WorkerDispatcher();
const getOriginalURLs = dispatcher.task("getOriginalURLs");
const getGeneratedLocation = dispatcher.task("getGeneratedLocation");
const getAllGeneratedLocations = dispatcher.task("getAllGeneratedLocations");
const getGeneratedRanges = dispatcher.task("getGeneratedRanges", { queue: true });
const getGeneratedLocation = dispatcher.task("getGeneratedLocation", { queue: true });
const getAllGeneratedLocations = dispatcher.task("getAllGeneratedLocations", { queue: true });
const getOriginalLocation = dispatcher.task("getOriginalLocation");
const getLocationScopes = dispatcher.task("getLocationScopes");
const getOriginalSourceText = dispatcher.task("getOriginalSourceText");
@ -2960,6 +2961,7 @@ module.exports = {
isOriginalId,
hasMappedSource,
getOriginalURLs,
getGeneratedRanges,
getGeneratedLocation,
getAllGeneratedLocations,
getOriginalLocation,
@ -5465,184 +5467,6 @@ module.exports = {
/***/ }),
/***/ 1390:
/***/ (function(module, exports, __webpack_require__) {
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const networkRequest = __webpack_require__(1391);
const workerUtils = __webpack_require__(1392);
module.exports = {
networkRequest,
workerUtils
};
/***/ }),
/***/ 1391:
/***/ (function(module, exports) {
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
function networkRequest(url, opts) {
return fetch(url, {
cache: opts.loadFromCache ? "default" : "no-cache"
}).then(res => {
if (res.status >= 200 && res.status < 300) {
return res.text().then(text => ({ content: text }));
}
return Promise.reject(`request failed with status ${res.status}`);
});
}
module.exports = networkRequest;
/***/ }),
/***/ 1392:
/***/ (function(module, exports) {
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
function WorkerDispatcher() {
this.msgId = 1;
this.worker = null;
} /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
WorkerDispatcher.prototype = {
start(url) {
this.worker = new Worker(url);
this.worker.onerror = () => {
console.error(`Error in worker ${url}`);
};
},
stop() {
if (!this.worker) {
return;
}
this.worker.terminate();
this.worker = null;
},
task(method) {
return (...args) => {
return new Promise((resolve, reject) => {
const id = this.msgId++;
this.worker.postMessage({ id, method, args });
const listener = ({ data: result }) => {
if (result.id !== id) {
return;
}
if (!this.worker) {
return;
}
this.worker.removeEventListener("message", listener);
if (result.error) {
reject(result.error);
} else {
resolve(result.response);
}
};
this.worker.addEventListener("message", listener);
});
};
}
};
function workerHandler(publicInterface) {
return function (msg) {
const { id, method, args } = msg.data;
try {
const response = publicInterface[method].apply(undefined, args);
if (response instanceof Promise) {
response.then(val => self.postMessage({ id, response: val }),
// Error can't be sent via postMessage, so be sure to
// convert to string.
err => self.postMessage({ id, error: err.toString() }));
} else {
self.postMessage({ id, response });
}
} catch (error) {
// Error can't be sent via postMessage, so be sure to convert to
// string.
self.postMessage({ id, error: error.toString() });
}
};
}
function streamingWorkerHandler(publicInterface, { timeout = 100 } = {}, worker = self) {
let streamingWorker = (() => {
var _ref = _asyncToGenerator(function* (id, tasks) {
let isWorking = true;
const intervalId = setTimeout(function () {
isWorking = false;
}, timeout);
const results = [];
while (tasks.length !== 0 && isWorking) {
const { callback, context, args } = tasks.shift();
const result = yield callback.call(context, args);
results.push(result);
}
worker.postMessage({ id, status: "pending", data: results });
clearInterval(intervalId);
if (tasks.length !== 0) {
yield streamingWorker(id, tasks);
}
});
return function streamingWorker(_x, _x2) {
return _ref.apply(this, arguments);
};
})();
return (() => {
var _ref2 = _asyncToGenerator(function* (msg) {
const { id, method, args } = msg.data;
const workerMethod = publicInterface[method];
if (!workerMethod) {
console.error(`Could not find ${method} defined in worker.`);
}
worker.postMessage({ id, status: "start" });
try {
const tasks = workerMethod(args);
yield streamingWorker(id, tasks);
worker.postMessage({ id, status: "done" });
} catch (error) {
worker.postMessage({ id, status: "error", error });
}
});
return function (_x3) {
return _ref2.apply(this, arguments);
};
})();
}
module.exports = {
WorkerDispatcher,
workerHandler,
streamingWorkerHandler
};
/***/ }),
/***/ 1393:
/***/ (function(module, exports, __webpack_require__) {
@ -23504,7 +23328,7 @@ class Breakpoints extends _react.Component {
"div",
{ className: "breakpoint-heading", title: filename, key: filename },
filename
), ...groupedBreakpoints[filename].filter(bp => !bp.hidden && bp.text).map((bp, i) => this.renderBreakpoint(bp))];
), ...groupedBreakpoints[filename].filter(bp => !bp.hidden && bp.text).map(bp => this.renderBreakpoint(bp))];
})];
}
@ -26806,7 +26630,7 @@ function findEmptyLines(selectedSource, pausePoints) {
const breakpoints = pausePointsList.filter(point => point.types.break);
const breakpointLines = breakpoints.map(point => point.location.line);
if (!selectedSource.text) {
if (!selectedSource.text || breakpointLines.length == 0) {
return [];
}

View File

@ -778,13 +778,14 @@ const {
isOriginalId
} = __webpack_require__(1389);
const { workerUtils: { WorkerDispatcher } } = __webpack_require__(1390);
const { workerUtils: { WorkerDispatcher } } = __webpack_require__(1363);
const dispatcher = new WorkerDispatcher();
const getOriginalURLs = dispatcher.task("getOriginalURLs");
const getGeneratedLocation = dispatcher.task("getGeneratedLocation");
const getAllGeneratedLocations = dispatcher.task("getAllGeneratedLocations");
const getGeneratedRanges = dispatcher.task("getGeneratedRanges", { queue: true });
const getGeneratedLocation = dispatcher.task("getGeneratedLocation", { queue: true });
const getAllGeneratedLocations = dispatcher.task("getAllGeneratedLocations", { queue: true });
const getOriginalLocation = dispatcher.task("getOriginalLocation");
const getLocationScopes = dispatcher.task("getLocationScopes");
const getOriginalSourceText = dispatcher.task("getOriginalSourceText");
@ -799,6 +800,7 @@ module.exports = {
isOriginalId,
hasMappedSource,
getOriginalURLs,
getGeneratedRanges,
getGeneratedLocation,
getAllGeneratedLocations,
getOriginalLocation,
@ -1229,184 +1231,6 @@ module.exports = {
/***/ }),
/***/ 1390:
/***/ (function(module, exports, __webpack_require__) {
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const networkRequest = __webpack_require__(1391);
const workerUtils = __webpack_require__(1392);
module.exports = {
networkRequest,
workerUtils
};
/***/ }),
/***/ 1391:
/***/ (function(module, exports) {
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
function networkRequest(url, opts) {
return fetch(url, {
cache: opts.loadFromCache ? "default" : "no-cache"
}).then(res => {
if (res.status >= 200 && res.status < 300) {
return res.text().then(text => ({ content: text }));
}
return Promise.reject(`request failed with status ${res.status}`);
});
}
module.exports = networkRequest;
/***/ }),
/***/ 1392:
/***/ (function(module, exports) {
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
function WorkerDispatcher() {
this.msgId = 1;
this.worker = null;
} /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
WorkerDispatcher.prototype = {
start(url) {
this.worker = new Worker(url);
this.worker.onerror = () => {
console.error(`Error in worker ${url}`);
};
},
stop() {
if (!this.worker) {
return;
}
this.worker.terminate();
this.worker = null;
},
task(method) {
return (...args) => {
return new Promise((resolve, reject) => {
const id = this.msgId++;
this.worker.postMessage({ id, method, args });
const listener = ({ data: result }) => {
if (result.id !== id) {
return;
}
if (!this.worker) {
return;
}
this.worker.removeEventListener("message", listener);
if (result.error) {
reject(result.error);
} else {
resolve(result.response);
}
};
this.worker.addEventListener("message", listener);
});
};
}
};
function workerHandler(publicInterface) {
return function (msg) {
const { id, method, args } = msg.data;
try {
const response = publicInterface[method].apply(undefined, args);
if (response instanceof Promise) {
response.then(val => self.postMessage({ id, response: val }),
// Error can't be sent via postMessage, so be sure to
// convert to string.
err => self.postMessage({ id, error: err.toString() }));
} else {
self.postMessage({ id, response });
}
} catch (error) {
// Error can't be sent via postMessage, so be sure to convert to
// string.
self.postMessage({ id, error: error.toString() });
}
};
}
function streamingWorkerHandler(publicInterface, { timeout = 100 } = {}, worker = self) {
let streamingWorker = (() => {
var _ref = _asyncToGenerator(function* (id, tasks) {
let isWorking = true;
const intervalId = setTimeout(function () {
isWorking = false;
}, timeout);
const results = [];
while (tasks.length !== 0 && isWorking) {
const { callback, context, args } = tasks.shift();
const result = yield callback.call(context, args);
results.push(result);
}
worker.postMessage({ id, status: "pending", data: results });
clearInterval(intervalId);
if (tasks.length !== 0) {
yield streamingWorker(id, tasks);
}
});
return function streamingWorker(_x, _x2) {
return _ref.apply(this, arguments);
};
})();
return (() => {
var _ref2 = _asyncToGenerator(function* (msg) {
const { id, method, args } = msg.data;
const workerMethod = publicInterface[method];
if (!workerMethod) {
console.error(`Could not find ${method} defined in worker.`);
}
worker.postMessage({ id, status: "start" });
try {
const tasks = workerMethod(args);
yield streamingWorker(id, tasks);
worker.postMessage({ id, status: "done" });
} catch (error) {
worker.postMessage({ id, status: "error", error });
}
});
return function (_x3) {
return _ref2.apply(this, arguments);
};
})();
}
module.exports = {
WorkerDispatcher,
workerHandler,
streamingWorkerHandler
};
/***/ }),
/***/ 14:
/***/ (function(module, exports) {

View File

@ -61,7 +61,7 @@ function test() {
chrome: true
};
TargetFactory.forRemoteTab(options).then(Task.async(testTarget).bind(null, client));
TargetFactory.forRemoteTab(options).then(testTarget.bind(null, client));
});
}

View File

@ -31,7 +31,7 @@ function performChecks(target) {
}
function test() {
Task.spawn(async function() {
(async function() {
toggleAllTools(true);
let tab = await addTab("about:blank");
let target = TargetFactory.forTab(tab);
@ -40,5 +40,5 @@ function test() {
gBrowser.removeCurrentTab();
toggleAllTools(false);
finish();
}, console.error);
})();
}

View File

@ -88,7 +88,7 @@ function getTarget(client) {
}
function test() {
Task.spawn(async function() {
(async function() {
toggleAllTools(true);
await addTab("about:blank");
@ -122,5 +122,5 @@ function test() {
DebuggerServer.destroy();
toggleAllTools(false);
finish();
}, console.error);
})();
}

View File

@ -9,21 +9,21 @@
const TEST_URL = URL_ROOT + "doc_markup_toggle.html";
add_task(function* () {
let {inspector} = yield openInspectorForURL(TEST_URL);
add_task(async function() {
let {inspector} = await openInspectorForURL(TEST_URL);
info("Getting the container for the UL parent element");
let container = yield getContainerForSelector("ul", inspector);
let container = await getContainerForSelector("ul", inspector);
info("Alt-clicking on collapsed expander should expand all children");
let onUpdated = inspector.once("inspector-updated");
EventUtils.synthesizeMouseAtCenter(container.expander, {altKey: true},
inspector.markup.doc.defaultView);
yield onUpdated;
yield waitForMultipleChildrenUpdates(inspector);
await onUpdated;
await waitForMultipleChildrenUpdates(inspector);
info("Checking that all nodes exist and are expanded");
let nodeFronts = yield getNodeFronts(inspector);
let nodeFronts = await getNodeFronts(inspector);
for (let nodeFront of nodeFronts) {
let nodeContainer = getContainerForNodeFront(nodeFront, inspector);
ok(nodeContainer, "Container for node " + nodeFront.tagName + " exists");
@ -34,11 +34,11 @@ add_task(function* () {
info("Alt-clicking on expanded expander should collapse all children");
EventUtils.synthesizeMouseAtCenter(container.expander, {altKey: true},
inspector.markup.doc.defaultView);
yield waitForMultipleChildrenUpdates(inspector);
await waitForMultipleChildrenUpdates(inspector);
// No need to wait for inspector-updated here since we are not retrieving new nodes.
info("Checking that all nodes are collapsed");
nodeFronts = yield getNodeFronts(inspector);
nodeFronts = await getNodeFronts(inspector);
for (let nodeFront of nodeFronts) {
let nodeContainer = getContainerForNodeFront(nodeFront, inspector);
ok(!nodeContainer.expanded,
@ -46,8 +46,8 @@ add_task(function* () {
}
});
function* getNodeFronts(inspector) {
let nodeList = yield inspector.walker.querySelectorAll(
async function getNodeFronts(inspector) {
let nodeList = await inspector.walker.querySelectorAll(
inspector.walker.rootNode, "ul, li, span, em");
return nodeList.items();
}

View File

@ -22,7 +22,7 @@ main thread when debugging content.
Triggered when a DOM event occurs, like a click or a keypress.
* unsigned short eventPhase - a number indicating what phase this event is
in (target, bubbling, capturing, maps to Ci.nsIDOMEvent constants)
in (target, bubbling, capturing, maps to Event constants)
* DOMString type - the type of event, like "keypress" or "click"
## Reflow

View File

@ -7,7 +7,6 @@
* This file contains utilities for creating elements for markers to be displayed,
* and parsing out the blueprint to generate correct values for markers.
*/
const { Ci } = require("chrome");
const { L10N, PREFS } = require("devtools/client/performance/modules/global");
// String used to fill in platform data when it should be hidden.
@ -68,13 +67,13 @@ exports.Formatters = {
if ("eventPhase" in marker) {
let label;
switch (marker.eventPhase) {
case Ci.nsIDOMEvent.AT_TARGET:
case Event.AT_TARGET:
label = L10N.getStr("marker.value.DOMEventTargetPhase");
break;
case Ci.nsIDOMEvent.CAPTURING_PHASE:
case Event.CAPTURING_PHASE:
label = L10N.getStr("marker.value.DOMEventCapturingPhase");
break;
case Ci.nsIDOMEvent.BUBBLING_PHASE:
case Event.BUBBLING_PHASE:
label = L10N.getStr("marker.value.DOMEventBubblingPhase");
break;
}

View File

@ -44,7 +44,7 @@ add_task(function() {
"getMarkerFields() returns an array with proper value");
fields = MarkerBlueprintUtils.getMarkerFields(
{ name: "DOMEvent", eventPhase: Ci.nsIDOMEvent.AT_TARGET, type: "mouseclick" });
{ name: "DOMEvent", eventPhase: Event.AT_TARGET, type: "mouseclick" });
equal(fields.length, 2,
"getMarkerFields() returns multiple fields when using a fields function");
equal(fields[0].label, "Event Type:",

View File

@ -1591,7 +1591,7 @@ var Scratchpad = {
* The Scratchpad window load event handler. This method
* initializes the Scratchpad window and source editor.
*
* @param nsIDOMEvent aEvent
* @param Event aEvent
*/
onLoad: function SP_onLoad(aEvent) {
if (aEvent.target != document) {
@ -1728,7 +1728,7 @@ var Scratchpad = {
* The Scratchpad window unload event handler. This method unloads/destroys
* the source editor.
*
* @param nsIDOMEvent aEvent
* @param Event aEvent
*/
onUnload: function SP_onUnload(aEvent) {
if (aEvent.target != document) {
@ -1822,7 +1822,7 @@ var Scratchpad = {
* Handler for window close event. Prompts to save scratchpad if
* there are unsaved changes.
*
* @param nsIDOMEvent aEvent
* @param Event aEvent
* @param function aCallback
* Optional function you want to call when file is saved/closed.
* Used mainly for tests.

View File

@ -10,7 +10,7 @@ const completions = ["toExponential", "toFixed", "toString"];
function test() {
const options = { tabContent: "test scratchpad autocomplete" };
openTabAndScratchpad(options)
.then(Task.async(runTests))
.then(runTests)
.then(finish, console.error);
}

View File

@ -11,7 +11,7 @@ function test() {
tabContent: "test closing toolbox and then reusing scratchpad"
};
openTabAndScratchpad(options)
.then(Task.async(runTests))
.then(runTests)
.then(finish, console.error);
}

View File

@ -9,7 +9,7 @@ function test() {
tabContent: 'test if view menu items "Larger Font" and "Smaller Font" are enabled/disabled.'
};
openTabAndScratchpad(options)
.then(Task.async(runTests))
.then(runTests)
.then(finish, console.error);
}

View File

@ -9,7 +9,7 @@ function test() {
tabContent: "test inspecting primitive values"
};
openTabAndScratchpad(options)
.then(Task.async(runTests))
.then(runTests)
.then(finish, console.error);
}

View File

@ -10,7 +10,7 @@ Test the searchbox and autocomplete-popup components
<meta charset="utf-8">
<title>SearchBox component test</title>
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/AddTask.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>

View File

@ -10,7 +10,7 @@ Test the searchbox component
<meta charset="utf-8">
<title>SearchBox component test</title>
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/AddTask.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>

View File

@ -10,7 +10,7 @@ Test the rendering of a stack trace with source maps
<meta charset="utf-8">
<title>StackTrace component test</title>
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/AddTask.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>

View File

@ -10,7 +10,7 @@ Test the rendering of a stack trace
<meta charset="utf-8">
<title>StackTrace component test</title>
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/AddTask.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>

View File

@ -705,7 +705,7 @@ DeveloperToolbar.prototype._onPageError = function(tabId, pageError) {
* a different page starts loading.
*
* @private
* @param nsIDOMEvent ev the beforeunload DOM event.
* @param Event ev the beforeunload DOM event.
*/
DeveloperToolbar.prototype._onPageBeforeUnload = function(ev) {
let window = ev.target.defaultView;

View File

@ -619,7 +619,7 @@ class JSTerm extends Component {
* The inputNode "keypress" event handler.
*
* @private
* @param nsIDOMEvent event
* @param Event event
*/
_keyPress(event) {
let inputNode = this.inputNode;

View File

@ -646,7 +646,7 @@ previewers.Object = [
},
function DOMEvent({obj, hooks}, grip, rawObj) {
if (isWorker || !rawObj || !(rawObj instanceof Ci.nsIDOMEvent)) {
if (isWorker || !rawObj || !Event.isInstance(rawObj)) {
return false;
}

View File

@ -4,7 +4,7 @@
<meta charset="utf-8">
<title>Mozilla Bug</title>
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/AddTask.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>

View File

@ -7,7 +7,7 @@ Bug 1302702 - Test connect to a webextension addon
<meta charset="utf-8">
<title>Mozilla Bug</title>
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/AddTask.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script>
<script src="webextension-helpers.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">

View File

@ -7,7 +7,7 @@ Bug 1302702 - Test connect to a webextension addon
<meta charset="utf-8">
<title>Mozilla Bug</title>
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/AddTask.js"></script>
<script src="webextension-helpers.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>

View File

@ -32,6 +32,7 @@ const {
ChromeUtils,
CSS,
CSSRule,
Event,
FileReader,
FormData,
indexedDB,
@ -47,6 +48,7 @@ const {
"ChromeUtils",
"CSS",
"CSSRule",
"Event",
"FileReader",
"FormData",
"indexedDB",
@ -263,6 +265,7 @@ exports.globals = {
factory(this.require, this.exports, this.module);
},
Element: Ci.nsIDOMElement,
Event,
FormData,
isWorker: false,
loader: {

View File

@ -4,7 +4,7 @@
<meta charset="utf-8">
<title>Test the WebSocket debugger transport</title>
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/AddTask.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>

View File

@ -1385,11 +1385,10 @@ nsDocShell::GetContentViewer(nsIContentViewer** aContentViewer)
}
NS_IMETHODIMP
nsDocShell::SetChromeEventHandler(nsIDOMEventTarget* aChromeEventHandler)
nsDocShell::SetChromeEventHandler(EventTarget* aChromeEventHandler)
{
// Weak reference. Don't addref.
nsCOMPtr<EventTarget> handler = do_QueryInterface(aChromeEventHandler);
mChromeEventHandler = handler.get();
mChromeEventHandler = aChromeEventHandler;
if (mScriptGlobal) {
mScriptGlobal->SetChromeEventHandler(mChromeEventHandler);
@ -1399,7 +1398,7 @@ nsDocShell::SetChromeEventHandler(nsIDOMEventTarget* aChromeEventHandler)
}
NS_IMETHODIMP
nsDocShell::GetChromeEventHandler(nsIDOMEventTarget** aChromeEventHandler)
nsDocShell::GetChromeEventHandler(EventTarget** aChromeEventHandler)
{
NS_ENSURE_ARG_POINTER(aChromeEventHandler);
nsCOMPtr<EventTarget> handler = mChromeEventHandler;

View File

@ -32,7 +32,6 @@
#include "mozilla/dom/Element.h"
#include "mozilla/dom/MouseEvent.h"
#include "mozilla/dom/SVGTitleElement.h"
#include "nsIDOMEvent.h"
#include "nsIFormControl.h"
#include "nsIImageLoadingContent.h"
#include "nsIWebNavigation.h"
@ -57,7 +56,7 @@
#include "mozilla/Attributes.h"
#include "mozilla/EventListenerManager.h"
#include "mozilla/dom/DragEvent.h"
#include "mozilla/dom/Event.h" // for nsIDOMEvent::InternalDOMEvent()
#include "mozilla/dom/Event.h" // for Event
#include "mozilla/dom/File.h" // for input type=file
#include "mozilla/dom/FileList.h" // for input type=file
#include "mozilla/TextEvents.h"
@ -925,10 +924,9 @@ nsDocShellTreeOwner::RemoveChromeListeners()
}
NS_IMETHODIMP
nsDocShellTreeOwner::HandleEvent(nsIDOMEvent* aEvent)
nsDocShellTreeOwner::HandleEvent(Event* aEvent)
{
DragEvent* dragEvent =
aEvent ? aEvent->InternalDOMEvent()->AsDragEvent() : nullptr;
DragEvent* dragEvent = aEvent ? aEvent->AsDragEvent() : nullptr;
if (NS_WARN_IF(!dragEvent)) {
return NS_ERROR_INVALID_ARG;
}
@ -1150,7 +1148,7 @@ ChromeTooltipListener::RemoveTooltipListener()
}
NS_IMETHODIMP
ChromeTooltipListener::HandleEvent(nsIDOMEvent* aEvent)
ChromeTooltipListener::HandleEvent(Event* aEvent)
{
nsAutoString eventType;
aEvent->GetType(eventType);
@ -1179,9 +1177,9 @@ ChromeTooltipListener::HandleEvent(nsIDOMEvent* aEvent)
// If we're a tooltip, fire off a timer to see if a tooltip should be shown. If
// the timer fires, we cache the node in |mPossibleTooltipNode|.
nsresult
ChromeTooltipListener::MouseMove(nsIDOMEvent* aMouseEvent)
ChromeTooltipListener::MouseMove(Event* aMouseEvent)
{
MouseEvent* mouseEvent = aMouseEvent->InternalDOMEvent()->AsMouseEvent();
MouseEvent* mouseEvent = aMouseEvent->AsMouseEvent();
if (!mouseEvent) {
return NS_OK;
}
@ -1215,8 +1213,7 @@ ChromeTooltipListener::MouseMove(nsIDOMEvent* aMouseEvent)
if (!mShowingTooltip && !mTooltipShownOnce) {
nsIEventTarget* target = nullptr;
nsCOMPtr<EventTarget> eventTarget =
aMouseEvent->InternalDOMEvent()->GetTarget();
nsCOMPtr<EventTarget> eventTarget = aMouseEvent->GetTarget();
if (eventTarget) {
mPossibleTooltipNode = do_QueryInterface(eventTarget);
nsCOMPtr<nsIGlobalObject> global(eventTarget->GetOwnerGlobal());

View File

@ -31,6 +31,7 @@
namespace mozilla {
namespace dom {
class Event;
class EventTarget;
} // namespace dom
} // namespace mozilla
@ -141,8 +142,8 @@ public:
ChromeTooltipListener(nsWebBrowser* aInBrowser, nsIWebBrowserChrome* aInChrome);
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) override;
NS_IMETHOD MouseMove(nsIDOMEvent* aMouseEvent);
NS_DECL_NSIDOMEVENTLISTENER
NS_IMETHOD MouseMove(mozilla::dom::Event* aMouseEvent);
// Add/remove the relevant listeners, based on what interfaces the embedding
// chrome implements.

View File

@ -39,7 +39,6 @@ class ClientSource;
interface nsIURI;
interface nsIChannel;
interface nsIContentViewer;
interface nsIDOMEventTarget;
interface nsIDocShellLoadInfo;
interface nsIEditor;
interface nsIEditingSession;
@ -63,6 +62,8 @@ interface nsICommandParams;
interface nsILoadURIDelegate;
native TabChildRef(already_AddRefed<nsITabChild>);
webidl EventTarget;
[scriptable, builtinclass, uuid(049234fe-da10-478b-bc5d-bc6f9a1ba63d)]
interface nsIDocShell : nsIDocShellTreeItem
{
@ -286,7 +287,7 @@ interface nsIDocShell : nsIDocShellTreeItem
* This attribute allows chrome to tie in to handle DOM events that may
* be of interest to chrome.
*/
attribute nsIDOMEventTarget chromeEventHandler;
attribute EventTarget chromeEventHandler;
/**
* This allows chrome to set a custom User agent on a specific docshell

View File

@ -16,7 +16,7 @@ SimpleTest.finish = function finish() {
}
</script>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<script src="/tests/SimpleTest/SpawnTask.js"></script>
<script src="/tests/SimpleTest/AddTask.js"></script>
<script src="/tests/SimpleTest/paint_listener.js"></script>
<script src="../testcommon.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">

View File

@ -100,7 +100,7 @@ NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_END
NS_INTERFACE_TABLE_HEAD(Attr)
NS_WRAPPERCACHE_INTERFACE_TABLE_ENTRY
NS_INTERFACE_TABLE(Attr, nsINode, nsIAttribute, nsIDOMNode,
nsIDOMEventTarget, EventTarget)
EventTarget)
NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(Attr)
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsISupportsWeakReference,
new nsNodeSupportsWeakRefTearoff(this))
@ -262,7 +262,7 @@ Attr::SetTextContentInternal(const nsAString& aTextContent,
bool
Attr::IsNodeOfType(uint32_t aFlags) const
{
return !(aFlags & ~eATTRIBUTE);
return false;
}
uint32_t

View File

@ -13,6 +13,8 @@
#include "mozilla/Attributes.h"
#include "nsIAttribute.h"
#include "nsIContent.h" // For NS_IMPL_FROMNODE_HELPER, though looks like it
// should live in nsINode.h?
#include "nsIDOMNode.h"
#include "nsIDOMNodeList.h"
#include "nsString.h"
@ -40,6 +42,8 @@ public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_IMPL_FROMNODE_HELPER(Attr, IsAttr())
// nsINode interface
virtual void GetTextContentInternal(nsAString& aTextContent,
OOMReporter& aError) override;

View File

@ -23,7 +23,6 @@
#include "nsReadableUtils.h"
#include "mozilla/InternalMutationEvent.h"
#include "nsIURI.h"
#include "nsIDOMEvent.h"
#include "nsCOMPtr.h"
#include "nsDOMString.h"
#include "nsChangeHint.h"
@ -663,7 +662,7 @@ CharacterData::DoGetXBLBinding() const
bool
CharacterData::IsNodeOfType(uint32_t aFlags) const
{
return !(aFlags & ~eDATA_NODE);
return false;
}
void

View File

@ -25,12 +25,6 @@ Comment::~Comment()
NS_IMPL_ISUPPORTS_INHERITED(Comment, CharacterData, nsIDOMNode)
bool
Comment::IsNodeOfType(uint32_t aFlags) const
{
return !(aFlags & ~(eCOMMENT | eDATA_NODE));
}
already_AddRefed<CharacterData>
Comment::CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo, bool aCloneText) const
{

View File

@ -39,12 +39,11 @@ public:
Init();
}
NS_IMPL_FROMNODE_HELPER(Comment, IsComment())
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
// nsINode
virtual bool IsNodeOfType(uint32_t aFlags) const override;
virtual already_AddRefed<CharacterData>
CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo,
bool aCloneText) const override;

View File

@ -33,7 +33,7 @@ DocumentFragment::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
bool
DocumentFragment::IsNodeOfType(uint32_t aFlags) const
{
return !(aFlags & ~eDOCUMENT_FRAGMENT);
return false;
}
#ifdef DEBUG
@ -120,7 +120,6 @@ NS_INTERFACE_MAP_BEGIN(DocumentFragment)
NS_INTERFACE_MAP_ENTRY(nsIContent)
NS_INTERFACE_MAP_ENTRY(nsINode)
NS_INTERFACE_MAP_ENTRY(nsIDOMNode)
NS_INTERFACE_MAP_ENTRY(nsIDOMEventTarget)
NS_INTERFACE_MAP_ENTRY(mozilla::dom::EventTarget)
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsISupportsWeakReference,
new nsNodeSupportsWeakRefTearoff(this))

View File

@ -110,5 +110,18 @@ protected:
} // namespace dom
} // namespace mozilla
inline mozilla::dom::DocumentFragment*
nsINode::AsDocumentFragment()
{
MOZ_ASSERT(IsDocumentFragment());
return static_cast<mozilla::dom::DocumentFragment*>(this);
}
inline const mozilla::dom::DocumentFragment*
nsINode::AsDocumentFragment() const
{
MOZ_ASSERT(IsDocumentFragment());
return static_cast<const mozilla::dom::DocumentFragment*>(this);
}
#endif // mozilla_dom_DocumentFragment_h__

View File

@ -57,21 +57,16 @@ DocumentType::DocumentType(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
{
MOZ_ASSERT(mNodeInfo->NodeType() == DOCUMENT_TYPE_NODE,
"Bad NodeType in aNodeInfo");
MOZ_ASSERT(!IsCharacterData());
}
DocumentType::~DocumentType()
{
}
DocumentType::~DocumentType() = default;
NS_IMPL_ISUPPORTS_INHERITED(DocumentType, CharacterData, nsIDOMNode)
bool
DocumentType::IsNodeOfType(uint32_t aFlags) const
{
// Don't claim to be eDATA_NODE since we're just inheriting
// CharacterData for convenience. Doctypes aren't really
// data nodes (they have a null .nodeValue and don't implement
// the DOM CharacterData interface)
return false;
}

View File

@ -41,7 +41,6 @@
#include "nsStyleConsts.h"
#include "nsString.h"
#include "nsUnicharUtils.h"
#include "nsIDOMEvent.h"
#include "nsDOMCID.h"
#include "nsIServiceManager.h"
#include "nsDOMCSSAttrDeclaration.h"

View File

@ -2035,6 +2035,11 @@ inline const mozilla::dom::Element* nsINode::AsElement() const
return static_cast<const mozilla::dom::Element*>(this);
}
inline mozilla::dom::Element* nsINode::GetParentElement() const
{
return mParent && mParent->IsElement() ? mParent->AsElement() : nullptr;
}
/**
* Macros to implement Clone(). _elementName is the class for which to implement
* Clone.

View File

@ -48,7 +48,6 @@
#include "nsStyleConsts.h"
#include "nsString.h"
#include "nsUnicharUtils.h"
#include "nsIDOMEvent.h"
#include "nsDOMCID.h"
#include "nsIServiceManager.h"
#include "nsDOMCSSAttrDeclaration.h"
@ -150,7 +149,6 @@ NS_INTERFACE_MAP_BEGIN(nsIContent)
// not doing anything anyway.
NS_INTERFACE_MAP_ENTRY(nsIContent)
NS_INTERFACE_MAP_ENTRY(nsINode)
NS_INTERFACE_MAP_ENTRY(nsIDOMEventTarget)
NS_INTERFACE_MAP_ENTRY(mozilla::dom::EventTarget)
NS_INTERFACE_MAP_ENTRY_TEAROFF(nsISupportsWeakReference,
new nsNodeSupportsWeakRefTearoff(this))

View File

@ -52,7 +52,7 @@
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/StaticPtr.h"
#include "Connection.h"
#include "mozilla/dom/Event.h" // for nsIDOMEvent::InternalDOMEvent()
#include "mozilla/dom/Event.h" // for Event
#include "nsGlobalWindow.h"
#include "nsIIdleObserver.h"
#include "nsIPermissionManager.h"
@ -702,10 +702,10 @@ MayVibrate(nsIDocument* doc) {
}
NS_IMETHODIMP
VibrateWindowListener::HandleEvent(nsIDOMEvent* aEvent)
VibrateWindowListener::HandleEvent(Event* aEvent)
{
nsCOMPtr<nsIDocument> doc =
do_QueryInterface(aEvent->InternalDOMEvent()->GetTarget());
do_QueryInterface(aEvent->GetTarget());
if (!MayVibrate(doc)) {
// It's important that we call CancelVibrate(), not Vibrate() with an

View File

@ -16,6 +16,7 @@
#include "mozilla/Hal.h"
#include "mozilla/Preferences.h"
#include "mozilla/dom/Event.h"
#include "mozilla/dom/Promise.h"
#include "nsContentUtils.h"
@ -599,11 +600,11 @@ ScreenOrientation::ShouldResistFingerprinting() const
NS_IMPL_ISUPPORTS(ScreenOrientation::VisibleEventListener, nsIDOMEventListener)
NS_IMETHODIMP
ScreenOrientation::VisibleEventListener::HandleEvent(nsIDOMEvent* aEvent)
ScreenOrientation::VisibleEventListener::HandleEvent(Event* aEvent)
{
// Document may have become visible, if the page is visible, run the steps
// following the "now visible algorithm" as specified.
nsCOMPtr<EventTarget> target = aEvent->InternalDOMEvent()->GetCurrentTarget();
nsCOMPtr<EventTarget> target = aEvent->GetCurrentTarget();
MOZ_ASSERT(target);
nsCOMPtr<nsIDocument> doc = do_QueryInterface(target);
@ -655,7 +656,7 @@ ScreenOrientation::VisibleEventListener::HandleEvent(nsIDOMEvent* aEvent)
NS_IMPL_ISUPPORTS(ScreenOrientation::FullScreenEventListener, nsIDOMEventListener)
NS_IMETHODIMP
ScreenOrientation::FullScreenEventListener::HandleEvent(nsIDOMEvent* aEvent)
ScreenOrientation::FullScreenEventListener::HandleEvent(Event* aEvent)
{
#ifdef DEBUG
nsAutoString eventType;
@ -664,7 +665,7 @@ ScreenOrientation::FullScreenEventListener::HandleEvent(nsIDOMEvent* aEvent)
MOZ_ASSERT(eventType.EqualsLiteral("fullscreenchange"));
#endif
nsCOMPtr<EventTarget> target = aEvent->InternalDOMEvent()->GetCurrentTarget();
nsCOMPtr<EventTarget> target = aEvent->GetCurrentTarget();
MOZ_ASSERT(target);
nsCOMPtr<nsIDocument> doc = do_QueryInterface(target);

View File

@ -3215,7 +3215,7 @@ Selection::ContainsNode(nsINode& aNode, bool aAllowPartial, ErrorResult& aRv)
// XXXbz this duplicates the GetNodeLength code in nsRange.cpp
uint32_t nodeLength;
bool isData = aNode.IsNodeOfType(nsINode::eDATA_NODE);
bool isData = aNode.IsCharacterData();
if (isData) {
nodeLength = aNode.AsText()->TextLength();
} else {

View File

@ -18,6 +18,7 @@
#include "nsPIDOMWindow.h"
#include "nsPresContext.h"
using mozilla::dom::Event;
using mozilla::dom::KeyboardEvent;
using namespace mozilla::widget;
@ -603,7 +604,7 @@ TextInputProcessor::PrepareKeyboardEventForComposition(
}
NS_IMETHODIMP
TextInputProcessor::StartComposition(nsIDOMEvent* aDOMKeyEvent,
TextInputProcessor::StartComposition(Event* aDOMKeyEvent,
uint32_t aKeyFlags,
uint8_t aOptionalArgc,
bool* aSucceeded)
@ -614,7 +615,7 @@ TextInputProcessor::StartComposition(nsIDOMEvent* aDOMKeyEvent,
RefPtr<KeyboardEvent> keyEvent;
if (aDOMKeyEvent) {
keyEvent = aDOMKeyEvent->InternalDOMEvent()->AsKeyboardEvent();
keyEvent = aDOMKeyEvent->AsKeyboardEvent();
if (NS_WARN_IF(!keyEvent)) {
return NS_ERROR_INVALID_ARG;
}
@ -701,7 +702,7 @@ TextInputProcessor::SetCaretInPendingComposition(uint32_t aOffset)
}
NS_IMETHODIMP
TextInputProcessor::FlushPendingComposition(nsIDOMEvent* aDOMKeyEvent,
TextInputProcessor::FlushPendingComposition(Event* aDOMKeyEvent,
uint32_t aKeyFlags,
uint8_t aOptionalArgc,
bool* aSucceeded)
@ -719,7 +720,7 @@ TextInputProcessor::FlushPendingComposition(nsIDOMEvent* aDOMKeyEvent,
RefPtr<KeyboardEvent> keyEvent;
if (aDOMKeyEvent) {
keyEvent = aDOMKeyEvent->InternalDOMEvent()->AsKeyboardEvent();
keyEvent = aDOMKeyEvent->AsKeyboardEvent();
if (NS_WARN_IF(!keyEvent)) {
return NS_ERROR_INVALID_ARG;
}
@ -761,7 +762,7 @@ TextInputProcessor::FlushPendingComposition(nsIDOMEvent* aDOMKeyEvent,
}
NS_IMETHODIMP
TextInputProcessor::CommitComposition(nsIDOMEvent* aDOMKeyEvent,
TextInputProcessor::CommitComposition(Event* aDOMKeyEvent,
uint32_t aKeyFlags,
uint8_t aOptionalArgc)
{
@ -769,7 +770,7 @@ TextInputProcessor::CommitComposition(nsIDOMEvent* aDOMKeyEvent,
RefPtr<KeyboardEvent> keyEvent;
if (aDOMKeyEvent) {
keyEvent = aDOMKeyEvent->InternalDOMEvent()->AsKeyboardEvent();
keyEvent = aDOMKeyEvent->AsKeyboardEvent();
if (NS_WARN_IF(!keyEvent)) {
return NS_ERROR_INVALID_ARG;
}
@ -788,7 +789,7 @@ TextInputProcessor::CommitComposition(nsIDOMEvent* aDOMKeyEvent,
NS_IMETHODIMP
TextInputProcessor::CommitCompositionWith(const nsAString& aCommitString,
nsIDOMEvent* aDOMKeyEvent,
Event* aDOMKeyEvent,
uint32_t aKeyFlags,
uint8_t aOptionalArgc,
bool* aSucceeded)
@ -798,7 +799,7 @@ TextInputProcessor::CommitCompositionWith(const nsAString& aCommitString,
RefPtr<KeyboardEvent> keyEvent;
if (aDOMKeyEvent) {
keyEvent = aDOMKeyEvent->InternalDOMEvent()->AsKeyboardEvent();
keyEvent = aDOMKeyEvent->AsKeyboardEvent();
if (NS_WARN_IF(!keyEvent)) {
return NS_ERROR_INVALID_ARG;
}
@ -860,7 +861,7 @@ TextInputProcessor::CommitCompositionInternal(
}
NS_IMETHODIMP
TextInputProcessor::CancelComposition(nsIDOMEvent* aDOMKeyEvent,
TextInputProcessor::CancelComposition(Event* aDOMKeyEvent,
uint32_t aKeyFlags,
uint8_t aOptionalArgc)
{
@ -868,7 +869,7 @@ TextInputProcessor::CancelComposition(nsIDOMEvent* aDOMKeyEvent,
RefPtr<KeyboardEvent> keyEvent;
if (aDOMKeyEvent) {
keyEvent = aDOMKeyEvent->InternalDOMEvent()->AsKeyboardEvent();
keyEvent = aDOMKeyEvent->AsKeyboardEvent();
if (NS_WARN_IF(!keyEvent)) {
return NS_ERROR_INVALID_ARG;
}
@ -1076,7 +1077,7 @@ TextInputProcessor::PrepareKeyboardEventToDispatch(
}
NS_IMETHODIMP
TextInputProcessor::Keydown(nsIDOMEvent* aDOMKeyEvent,
TextInputProcessor::Keydown(Event* aDOMKeyEvent,
uint32_t aKeyFlags,
uint8_t aOptionalArgc,
uint32_t* aConsumedFlags)
@ -1090,7 +1091,7 @@ TextInputProcessor::Keydown(nsIDOMEvent* aDOMKeyEvent,
return NS_ERROR_INVALID_ARG;
}
WidgetKeyboardEvent* originalKeyEvent =
aDOMKeyEvent->InternalDOMEvent()->WidgetEventPtr()->AsKeyboardEvent();
aDOMKeyEvent->WidgetEventPtr()->AsKeyboardEvent();
if (NS_WARN_IF(!originalKeyEvent)) {
return NS_ERROR_INVALID_ARG;
}
@ -1169,7 +1170,7 @@ TextInputProcessor::KeydownInternal(const WidgetKeyboardEvent& aKeyboardEvent,
}
NS_IMETHODIMP
TextInputProcessor::Keyup(nsIDOMEvent* aDOMKeyEvent,
TextInputProcessor::Keyup(Event* aDOMKeyEvent,
uint32_t aKeyFlags,
uint8_t aOptionalArgc,
bool* aDoDefault)
@ -1183,7 +1184,7 @@ TextInputProcessor::Keyup(nsIDOMEvent* aDOMKeyEvent,
return NS_ERROR_INVALID_ARG;
}
WidgetKeyboardEvent* originalKeyEvent =
aDOMKeyEvent->InternalDOMEvent()->WidgetEventPtr()->AsKeyboardEvent();
aDOMKeyEvent->WidgetEventPtr()->AsKeyboardEvent();
if (NS_WARN_IF(!originalKeyEvent)) {
return NS_ERROR_INVALID_ARG;
}

Some files were not shown because too many files have changed in this diff Show More