diff --git a/accessible/base/DocManager.cpp b/accessible/base/DocManager.cpp index a9450d533b08..c01adf98d721 100644 --- a/accessible/base/DocManager.cpp +++ b/accessible/base/DocManager.cpp @@ -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 document = - do_QueryInterface(aEvent->InternalDOMEvent()->GetTarget()); + nsCOMPtr document = do_QueryInterface(aEvent->GetTarget()); NS_ASSERTION(document, "pagehide or DOMContentLoaded for non document!"); if (!document) return NS_OK; diff --git a/accessible/base/Logging.cpp b/accessible/base/Logging.cpp index 9f2d7c7ee0a4..8c96f6d30dca 100644 --- a/accessible/base/Logging.cpp +++ b/accessible/base/Logging.cpp @@ -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(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(node)); } else if (node->IsText()) { diff --git a/accessible/base/nsAccessibilityService.cpp b/accessible/base/nsAccessibilityService.cpp index 03987ac697c1..a41dc163a2be 100644 --- a/accessible/base/nsAccessibilityService.cpp +++ b/accessible/base/nsAccessibilityService.cpp @@ -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 change = do_QueryElementAt(aEventChanges, i); - nsCOMPtr target; + RefPtr target; change->GetTarget(getter_AddRefs(target)); nsCOMPtr 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 document(do_QueryInterface(aNode)); - return GetDocAccessible(document); + return GetDocAccessible(aNode->AsDocument()); } // We have a content node. diff --git a/accessible/generic/Accessible.cpp b/accessible/generic/Accessible.cpp index f15e63ad43db..6a27f9d7e3a7 100644 --- a/accessible/generic/Accessible.cpp +++ b/accessible/generic/Accessible.cpp @@ -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(). diff --git a/accessible/generic/HyperTextAccessible.cpp b/accessible/generic/HyperTextAccessible.cpp index 83540e5d4208..1f7932ec0ee0 100644 --- a/accessible/generic/HyperTextAccessible.cpp +++ b/accessible/generic/HyperTextAccessible.cpp @@ -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); diff --git a/accessible/generic/RootAccessible.cpp b/accessible/generic/RootAccessible.cpp index 40bd3bee92cd..bbd94cb7324e 100644 --- a/accessible/generic/RootAccessible.cpp +++ b/accessible/generic/RootAccessible.cpp @@ -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 origTargetNode = do_QueryInterface(event->GetOriginalTarget()); + nsCOMPtr 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 + document->HandleNotification (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 origTargetNode = do_QueryInterface(event->GetOriginalTarget()); + nsCOMPtr 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 propBag; @@ -704,7 +703,7 @@ RootAccessible::HandleTreeRowCountChangedEvent(nsIDOMEvent* aEvent, } void -RootAccessible::HandleTreeInvalidatedEvent(nsIDOMEvent* aEvent, +RootAccessible::HandleTreeInvalidatedEvent(Event* aEvent, XULTreeAccessible* aAccessible) { nsCOMPtr propBag; diff --git a/accessible/generic/RootAccessible.h b/accessible/generic/RootAccessible.h index beb74cf4b603..a53a3a08b178 100644 --- a/accessible/generic/RootAccessible.h +++ b/accessible/generic/RootAccessible.h @@ -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 diff --git a/accessible/html/HTMLSelectAccessible.cpp b/accessible/html/HTMLSelectAccessible.cpp index 54d3cbd3e8c7..eb53f7612c39 100644 --- a/accessible/html/HTMLSelectAccessible.cpp +++ b/accessible/html/HTMLSelectAccessible.cpp @@ -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 diff --git a/accessible/jsat/AccessFu.jsm b/accessible/jsat/AccessFu.jsm index 8db6e51d2231..66b4511e8717 100644 --- a/accessible/jsat/AccessFu.jsm +++ b/accessible/jsat/AccessFu.jsm @@ -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; diff --git a/accessible/jsat/ContentControl.jsm b/accessible/jsat/ContentControl.jsm index 02993d78f848..06a0c9576986 100644 --- a/accessible/jsat/ContentControl.jsm +++ b/accessible/jsat/ContentControl.jsm @@ -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) { diff --git a/accessible/jsat/Gestures.jsm b/accessible/jsat/Gestures.jsm deleted file mode 100644 index e3dbe7c73b77..000000000000 --- a/accessible/jsat/Gestures.jsm +++ /dev/null @@ -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; -}; diff --git a/accessible/jsat/PointerAdapter.jsm b/accessible/jsat/PointerAdapter.jsm deleted file mode 100644 index bc65d3f5416e..000000000000 --- a/accessible/jsat/PointerAdapter.jsm +++ /dev/null @@ -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); - } -}; diff --git a/accessible/jsat/Utils.jsm b/accessible/jsat/Utils.jsm index d27c9b97bbd3..2546d72c66bf 100644 --- a/accessible/jsat/Utils.jsm +++ b/accessible/jsat/Utils.jsm @@ -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); }, /** diff --git a/accessible/jsat/content-script.js b/accessible/jsat/content-script.js index 0cc7b493fac6..d7199ba3e4a9 100644 --- a/accessible/jsat/content-script.js +++ b/accessible/jsat/content-script.js @@ -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(); diff --git a/accessible/jsat/jar.mn b/accessible/jsat/jar.mn index 970fb9a9bdd9..aa989ff006cd 100644 --- a/accessible/jsat/jar.mn +++ b/accessible/jsat/jar.mn @@ -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) diff --git a/accessible/jsat/moz.build b/accessible/jsat/moz.build index b9051f532cda..2296b53a645f 100644 --- a/accessible/jsat/moz.build +++ b/accessible/jsat/moz.build @@ -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'] \ No newline at end of file +JAR_MANIFESTS += ['jar.mn'] diff --git a/accessible/jsat/sounds/clicked.ogg b/accessible/jsat/sounds/clicked.ogg deleted file mode 100644 index 68388018e5e3..000000000000 Binary files a/accessible/jsat/sounds/clicked.ogg and /dev/null differ diff --git a/accessible/jsat/sounds/virtual_cursor_key.ogg b/accessible/jsat/sounds/virtual_cursor_key.ogg deleted file mode 100644 index b29b55b44951..000000000000 Binary files a/accessible/jsat/sounds/virtual_cursor_key.ogg and /dev/null differ diff --git a/accessible/jsat/sounds/virtual_cursor_move.ogg b/accessible/jsat/sounds/virtual_cursor_move.ogg deleted file mode 100644 index da97934605c8..000000000000 Binary files a/accessible/jsat/sounds/virtual_cursor_move.ogg and /dev/null differ diff --git a/accessible/tests/browser/bounds/browser.ini b/accessible/tests/browser/bounds/browser.ini index 1170dbcd1b01..b9ec8f1c77d6 100644 --- a/accessible/tests/browser/bounds/browser.ini +++ b/accessible/tests/browser/bounds/browser.ini @@ -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 diff --git a/accessible/tests/browser/bounds/browser_test_resolution.js b/accessible/tests/browser/bounds/browser_test_resolution.js new file mode 100644 index 000000000000..0833ba08f3a0 --- /dev/null +++ b/accessible/tests/browser/bounds/browser_test_resolution.js @@ -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(` +

Tilimilitryamdiya

+

para 2

+ +`, + runTests +); diff --git a/accessible/tests/mochitest/common.js b/accessible/tests/mochitest/common.js index 359c957521c3..5fdf629e8cfd 100644 --- a/accessible/tests/mochitest/common.js +++ b/accessible/tests/mochitest/common.js @@ -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; diff --git a/accessible/tests/mochitest/events.js b/accessible/tests/mochitest/events.js index e62b16fbd889..04e55888778e 100644 --- a/accessible/tests/mochitest/events.js +++ b/accessible/tests/mochitest/events.js @@ -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); diff --git a/accessible/tests/mochitest/jsat/a11y.ini b/accessible/tests/mochitest/jsat/a11y.ini index 5acc3df907b5..a2cb084b043e 100644 --- a/accessible/tests/mochitest/jsat/a11y.ini +++ b/accessible/tests/mochitest/jsat/a11y.ini @@ -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] diff --git a/accessible/tests/mochitest/jsat/dom_helper.js b/accessible/tests/mochitest/jsat/dom_helper.js deleted file mode 100644 index d486cd2739ad..000000000000 --- a/accessible/tests/mochitest/jsat/dom_helper.js +++ /dev/null @@ -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(); -} diff --git a/accessible/tests/mochitest/jsat/gestures.json b/accessible/tests/mochitest/jsat/gestures.json deleted file mode 100644 index 1119943424c4..000000000000 --- a/accessible/tests/mochitest/jsat/gestures.json +++ /dev/null @@ -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 }] - } - -] diff --git a/accessible/tests/mochitest/jsat/jsatcommon.js b/accessible/tests/mochitest/jsat/jsatcommon.js index 31bd7cb685b3..2f015d4353c9 100644 --- a/accessible/tests/mochitest/jsat/jsatcommon.js +++ b/accessible/tests/mochitest/jsat/jsatcommon.js @@ -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. diff --git a/accessible/tests/mochitest/jsat/test_gesture_tracker.html b/accessible/tests/mochitest/jsat/test_gesture_tracker.html deleted file mode 100644 index af27554552f3..000000000000 --- a/accessible/tests/mochitest/jsat/test_gesture_tracker.html +++ /dev/null @@ -1,51 +0,0 @@ - - - - AccessFu tests for gesture tracker. - - - - - - - - - - - - - Mozilla Bug 981015 - - - diff --git a/accessible/tests/mochitest/jsat/test_pointer_relay.html b/accessible/tests/mochitest/jsat/test_pointer_relay.html deleted file mode 100644 index 868e285b3ab7..000000000000 --- a/accessible/tests/mochitest/jsat/test_pointer_relay.html +++ /dev/null @@ -1,95 +0,0 @@ - - - - AccessFu tests for pointer relay. - - - - - - - - - - - - - Mozilla Bug 981015 - -
- -
- - diff --git a/accessible/tests/mochitest/jsat/test_quicknav_modes.html b/accessible/tests/mochitest/jsat/test_quicknav_modes.html deleted file mode 100644 index 2430a061dbdc..000000000000 --- a/accessible/tests/mochitest/jsat/test_quicknav_modes.html +++ /dev/null @@ -1,105 +0,0 @@ - - - - AccessFu test for enabling - - - - - - - - - - - Mozilla Bug 811307 - - - diff --git a/accessible/tests/mochitest/layout.js b/accessible/tests/mochitest/layout.js index ea663e97384d..330093aa2f99 100644 --- a/accessible/tests/mochitest/layout.js +++ b/accessible/tests/mochitest/layout.js @@ -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. diff --git a/accessible/windows/sdn/sdnAccessible.cpp b/accessible/windows/sdn/sdnAccessible.cpp index dc35c0f2cbf2..948e3b702715 100644 --- a/accessible/windows/sdn/sdnAccessible.cpp +++ b/accessible/windows/sdn/sdnAccessible.cpp @@ -223,7 +223,7 @@ sdnAccessible::get_computedStyle(unsigned short aMaxStyleProperties, *aNumStyleProperties = 0; - if (mNode->IsNodeOfType(nsINode::eDOCUMENT)) + if (mNode->IsDocument()) return S_FALSE; nsCOMPtr 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 cssDecl = diff --git a/browser/app/permissions b/browser/app/permissions index 5f4612570457..2bbb17332d57 100644 --- a/browser/app/permissions +++ b/browser/app/permissions @@ -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 diff --git a/browser/base/content/test/general/browser_gestureSupport.js b/browser/base/content/test/general/browser_gestureSupport.js index add8187e812d..cc3a2bea2969 100644 --- a/browser/base/content/test/general/browser_gestureSupport.js +++ b/browser/base/content/test/general/browser_gestureSupport.js @@ -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); } diff --git a/browser/base/content/test/sanitize/browser_sanitize-timespans.js b/browser/base/content/test/sanitize/browser_sanitize-timespans.js index 428cc059bbf1..2599caf1cbc2 100644 --- a/browser/base/content/test/sanitize/browser_sanitize-timespans.js +++ b/browser/base/content/test/sanitize/browser_sanitize-timespans.js @@ -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() { diff --git a/browser/components/extensions/test/mochitest/test_ext_all_apis.html b/browser/components/extensions/test/mochitest/test_ext_all_apis.html index 8ca69e8e83aa..0cf5cab37489 100644 --- a/browser/components/extensions/test/mochitest/test_ext_all_apis.html +++ b/browser/components/extensions/test/mochitest/test_ext_all_apis.html @@ -4,7 +4,7 @@ WebExtension test - + diff --git a/browser/components/places/tests/browser/browser_library_downloads.js b/browser/components/places/tests/browser/browser_library_downloads.js index 55bbbecf5994..13df53d78a5e 100644 --- a/browser/components/places/tests/browser/browser_library_downloads.js +++ b/browser/components/places/tests/browser/browser_library_downloads.js @@ -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"); + } +}); diff --git a/browser/components/resistfingerprinting/test/mochitest/test_bug863246_resource_uri.html b/browser/components/resistfingerprinting/test/mochitest/test_bug863246_resource_uri.html index 13dad300ff05..e2ed4ebc86d9 100644 --- a/browser/components/resistfingerprinting/test/mochitest/test_bug863246_resource_uri.html +++ b/browser/components/resistfingerprinting/test/mochitest/test_bug863246_resource_uri.html @@ -1,7 +1,7 @@ - + - + diff --git a/browser/components/sessionstore/nsISessionStoreUtils.idl b/browser/components/sessionstore/nsISessionStoreUtils.idl index 01fdb37ae332..24c86a1d1851 100644 --- a/browser/components/sessionstore/nsISessionStoreUtils.idl +++ b/browser/components/sessionstore/nsISessionStoreUtils.idl @@ -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); diff --git a/browser/components/sessionstore/nsSessionStoreUtils.cpp b/browser/components/sessionstore/nsSessionStoreUtils.cpp index ad374957c0af..965df3fb2464 100644 --- a/browser/components/sessionstore/nsSessionStoreUtils.cpp +++ b/browser/components/sessionstore/nsSessionStoreUtils.cpp @@ -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 aListener, bool aUseCapture, @@ -128,8 +128,7 @@ nsSessionStoreUtils::AddDynamicFrameFilteredListener(nsIDOMEventTarget* aTarget, return NS_ERROR_INVALID_ARG; } - nsCOMPtr target = do_QueryInterface(aTarget); - NS_ENSURE_TRUE(target, NS_ERROR_NO_INTERFACE); + NS_ENSURE_TRUE(aTarget, NS_ERROR_NO_INTERFACE); JS::Rooted obj(aCx, &aListener.toObject()); RefPtr listener = @@ -137,7 +136,7 @@ nsSessionStoreUtils::AddDynamicFrameFilteredListener(nsIDOMEventTarget* aTarget, nsCOMPtr 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 target = do_QueryInterface(aTarget); - NS_ENSURE_TRUE(target, NS_ERROR_NO_INTERFACE); + NS_ENSURE_TRUE(aTarget, NS_ERROR_NO_INTERFACE); nsCOMPtr 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; } diff --git a/browser/extensions/formautofill/test/mochitest/test_autofocus_form.html b/browser/extensions/formautofill/test/mochitest/test_autofocus_form.html index 401d151b6979..092a8a4b4620 100644 --- a/browser/extensions/formautofill/test/mochitest/test_autofocus_form.html +++ b/browser/extensions/formautofill/test/mochitest/test_autofocus_form.html @@ -5,7 +5,7 @@ Test basic autofill - + @@ -14,7 +14,7 @@ Form autofill test: autocomplete on an autofocus form - + @@ -14,7 +14,7 @@ Form autofill test: simple form address autofill - + @@ -14,7 +14,7 @@ Form autofill test: simple form credit card autofill - + @@ -14,7 +14,7 @@ Form autofill test: clear form button - + @@ -14,7 +14,7 @@ Form autofill test: simple form credit card autofill - + @@ -14,7 +14,7 @@ Form autofill test: autocomplete on an autofocus form - + @@ -14,7 +14,7 @@ Form autofill test: preview and highlight - + @@ -14,7 +14,7 @@ Form autofill test: simple form address autofill - + @@ -13,7 +13,7 @@ - + @@ -14,7 +14,7 @@ Form autofill test: check if address is saved/updated correctly - + diff --git a/devtools/client/shared/components/test/mochitest/test_searchbox.html b/devtools/client/shared/components/test/mochitest/test_searchbox.html index e643af71e2b9..c9ce020f7628 100644 --- a/devtools/client/shared/components/test/mochitest/test_searchbox.html +++ b/devtools/client/shared/components/test/mochitest/test_searchbox.html @@ -10,7 +10,7 @@ Test the searchbox component SearchBox component test - + diff --git a/devtools/client/shared/components/test/mochitest/test_stack-trace-source-maps.html b/devtools/client/shared/components/test/mochitest/test_stack-trace-source-maps.html index 20124c104bb4..16b255583aad 100644 --- a/devtools/client/shared/components/test/mochitest/test_stack-trace-source-maps.html +++ b/devtools/client/shared/components/test/mochitest/test_stack-trace-source-maps.html @@ -10,7 +10,7 @@ Test the rendering of a stack trace with source maps StackTrace component test - + diff --git a/devtools/client/shared/components/test/mochitest/test_stack-trace.html b/devtools/client/shared/components/test/mochitest/test_stack-trace.html index 091f800dd749..1a0a2bcd018c 100644 --- a/devtools/client/shared/components/test/mochitest/test_stack-trace.html +++ b/devtools/client/shared/components/test/mochitest/test_stack-trace.html @@ -10,7 +10,7 @@ Test the rendering of a stack trace StackTrace component test - + diff --git a/devtools/client/shared/developer-toolbar.js b/devtools/client/shared/developer-toolbar.js index 4c7843f7d46a..6b2de8885927 100644 --- a/devtools/client/shared/developer-toolbar.js +++ b/devtools/client/shared/developer-toolbar.js @@ -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; diff --git a/devtools/client/webconsole/components/JSTerm.js b/devtools/client/webconsole/components/JSTerm.js index ec67f101fdb9..7839f712508d 100644 --- a/devtools/client/webconsole/components/JSTerm.js +++ b/devtools/client/webconsole/components/JSTerm.js @@ -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; diff --git a/devtools/server/actors/object/previewers.js b/devtools/server/actors/object/previewers.js index 7190e9510d50..717731d1cf97 100644 --- a/devtools/server/actors/object/previewers.js +++ b/devtools/server/actors/object/previewers.js @@ -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; } diff --git a/devtools/server/socket/tests/test_websocket-server.html b/devtools/server/socket/tests/test_websocket-server.html index e61a12effb19..2842357a654f 100644 --- a/devtools/server/socket/tests/test_websocket-server.html +++ b/devtools/server/socket/tests/test_websocket-server.html @@ -4,7 +4,7 @@ Mozilla Bug - + diff --git a/devtools/server/tests/mochitest/test_webextension-addon-debugging-connect.html b/devtools/server/tests/mochitest/test_webextension-addon-debugging-connect.html index 24bbd9440eca..d0ca0ac04861 100644 --- a/devtools/server/tests/mochitest/test_webextension-addon-debugging-connect.html +++ b/devtools/server/tests/mochitest/test_webextension-addon-debugging-connect.html @@ -7,7 +7,7 @@ Bug 1302702 - Test connect to a webextension addon Mozilla Bug - + diff --git a/devtools/server/tests/mochitest/test_webextension-addon-debugging-reload.html b/devtools/server/tests/mochitest/test_webextension-addon-debugging-reload.html index 534fb46faa0c..6900b748bd39 100644 --- a/devtools/server/tests/mochitest/test_webextension-addon-debugging-reload.html +++ b/devtools/server/tests/mochitest/test_webextension-addon-debugging-reload.html @@ -7,7 +7,7 @@ Bug 1302702 - Test connect to a webextension addon Mozilla Bug - + diff --git a/devtools/shared/builtin-modules.js b/devtools/shared/builtin-modules.js index a8a879457ac6..6965553d189d 100644 --- a/devtools/shared/builtin-modules.js +++ b/devtools/shared/builtin-modules.js @@ -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: { diff --git a/devtools/shared/security/tests/chrome/test_websocket-transport.html b/devtools/shared/security/tests/chrome/test_websocket-transport.html index 2ddd83785377..58ce2ba516cb 100644 --- a/devtools/shared/security/tests/chrome/test_websocket-transport.html +++ b/devtools/shared/security/tests/chrome/test_websocket-transport.html @@ -4,7 +4,7 @@ Test the WebSocket debugger transport - + diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index c06611a79a50..52e8e2be9b8d 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -1385,11 +1385,10 @@ nsDocShell::GetContentViewer(nsIContentViewer** aContentViewer) } NS_IMETHODIMP -nsDocShell::SetChromeEventHandler(nsIDOMEventTarget* aChromeEventHandler) +nsDocShell::SetChromeEventHandler(EventTarget* aChromeEventHandler) { // Weak reference. Don't addref. - nsCOMPtr 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 handler = mChromeEventHandler; diff --git a/docshell/base/nsDocShellTreeOwner.cpp b/docshell/base/nsDocShellTreeOwner.cpp index dc32cfa2c867..d11ac8370407 100644 --- a/docshell/base/nsDocShellTreeOwner.cpp +++ b/docshell/base/nsDocShellTreeOwner.cpp @@ -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 = - aMouseEvent->InternalDOMEvent()->GetTarget(); + nsCOMPtr eventTarget = aMouseEvent->GetTarget(); if (eventTarget) { mPossibleTooltipNode = do_QueryInterface(eventTarget); nsCOMPtr global(eventTarget->GetOwnerGlobal()); diff --git a/docshell/base/nsDocShellTreeOwner.h b/docshell/base/nsDocShellTreeOwner.h index 4e9f0c47482a..304dcf646a3f 100644 --- a/docshell/base/nsDocShellTreeOwner.h +++ b/docshell/base/nsDocShellTreeOwner.h @@ -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. diff --git a/docshell/base/nsIDocShell.idl b/docshell/base/nsIDocShell.idl index bc18c1286273..4c3035c3ae9b 100644 --- a/docshell/base/nsIDocShell.idl +++ b/docshell/base/nsIDocShell.idl @@ -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); +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 diff --git a/dom/animation/test/mozilla/file_restyles.html b/dom/animation/test/mozilla/file_restyles.html index f7f18429a7c7..5da72fc75165 100644 --- a/dom/animation/test/mozilla/file_restyles.html +++ b/dom/animation/test/mozilla/file_restyles.html @@ -16,7 +16,7 @@ SimpleTest.finish = function finish() { } - + diff --git a/dom/base/Attr.cpp b/dom/base/Attr.cpp index ad35f13cf6e0..9d23a6fb03b5 100644 --- a/dom/base/Attr.cpp +++ b/dom/base/Attr.cpp @@ -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 diff --git a/dom/base/Attr.h b/dom/base/Attr.h index 2f2e442c1f19..6b8970029734 100644 --- a/dom/base/Attr.h +++ b/dom/base/Attr.h @@ -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; diff --git a/dom/base/CharacterData.cpp b/dom/base/CharacterData.cpp index 7e9a4e00f982..2f69c789ae1a 100644 --- a/dom/base/CharacterData.cpp +++ b/dom/base/CharacterData.cpp @@ -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 diff --git a/dom/base/Comment.cpp b/dom/base/Comment.cpp index 310f9fa15249..9cfcb2e7944e 100644 --- a/dom/base/Comment.cpp +++ b/dom/base/Comment.cpp @@ -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 Comment::CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo, bool aCloneText) const { diff --git a/dom/base/Comment.h b/dom/base/Comment.h index ad0040815d06..727892778cd2 100644 --- a/dom/base/Comment.h +++ b/dom/base/Comment.h @@ -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 CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo, bool aCloneText) const override; diff --git a/dom/base/DocumentFragment.cpp b/dom/base/DocumentFragment.cpp index dccd68af71fa..e72d6bd4d817 100644 --- a/dom/base/DocumentFragment.cpp +++ b/dom/base/DocumentFragment.cpp @@ -33,7 +33,7 @@ DocumentFragment::WrapNode(JSContext *aCx, JS::Handle 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)) diff --git a/dom/base/DocumentFragment.h b/dom/base/DocumentFragment.h index e487dc0e734d..5a7c78e5d002 100644 --- a/dom/base/DocumentFragment.h +++ b/dom/base/DocumentFragment.h @@ -110,5 +110,18 @@ protected: } // namespace dom } // namespace mozilla +inline mozilla::dom::DocumentFragment* +nsINode::AsDocumentFragment() +{ + MOZ_ASSERT(IsDocumentFragment()); + return static_cast(this); +} + +inline const mozilla::dom::DocumentFragment* +nsINode::AsDocumentFragment() const +{ + MOZ_ASSERT(IsDocumentFragment()); + return static_cast(this); +} #endif // mozilla_dom_DocumentFragment_h__ diff --git a/dom/base/DocumentType.cpp b/dom/base/DocumentType.cpp index 0cf2346bbd15..f6f89ae8b046 100644 --- a/dom/base/DocumentType.cpp +++ b/dom/base/DocumentType.cpp @@ -57,21 +57,16 @@ DocumentType::DocumentType(already_AddRefed& 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; } diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp index 31836373005a..84b4235fb415 100644 --- a/dom/base/Element.cpp +++ b/dom/base/Element.cpp @@ -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" diff --git a/dom/base/Element.h b/dom/base/Element.h index 8eaf254ef569..9c61f0cc077a 100644 --- a/dom/base/Element.h +++ b/dom/base/Element.h @@ -2035,6 +2035,11 @@ inline const mozilla::dom::Element* nsINode::AsElement() const return static_cast(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. diff --git a/dom/base/FragmentOrElement.cpp b/dom/base/FragmentOrElement.cpp index 8847a9c66662..98f00494d61d 100644 --- a/dom/base/FragmentOrElement.cpp +++ b/dom/base/FragmentOrElement.cpp @@ -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)) diff --git a/dom/base/Navigator.cpp b/dom/base/Navigator.cpp index fe1d3cf22668..0f5ccaac7ed0 100644 --- a/dom/base/Navigator.cpp +++ b/dom/base/Navigator.cpp @@ -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 doc = - do_QueryInterface(aEvent->InternalDOMEvent()->GetTarget()); + do_QueryInterface(aEvent->GetTarget()); if (!MayVibrate(doc)) { // It's important that we call CancelVibrate(), not Vibrate() with an diff --git a/dom/base/ScreenOrientation.cpp b/dom/base/ScreenOrientation.cpp index d43a15666aaa..0378b6b18181 100644 --- a/dom/base/ScreenOrientation.cpp +++ b/dom/base/ScreenOrientation.cpp @@ -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 target = aEvent->InternalDOMEvent()->GetCurrentTarget(); + nsCOMPtr target = aEvent->GetCurrentTarget(); MOZ_ASSERT(target); nsCOMPtr 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 target = aEvent->InternalDOMEvent()->GetCurrentTarget(); + nsCOMPtr target = aEvent->GetCurrentTarget(); MOZ_ASSERT(target); nsCOMPtr doc = do_QueryInterface(target); diff --git a/dom/base/Selection.cpp b/dom/base/Selection.cpp index c43dafad7e19..bff114fbf527 100644 --- a/dom/base/Selection.cpp +++ b/dom/base/Selection.cpp @@ -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 { diff --git a/dom/base/TextInputProcessor.cpp b/dom/base/TextInputProcessor.cpp index 73fac8e57539..b0bde6a80d18 100644 --- a/dom/base/TextInputProcessor.cpp +++ b/dom/base/TextInputProcessor.cpp @@ -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 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 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 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 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 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; } diff --git a/dom/base/nsContentAreaDragDrop.cpp b/dom/base/nsContentAreaDragDrop.cpp index 6eac77c5b8e4..51b0dfc0d8b2 100644 --- a/dom/base/nsContentAreaDragDrop.cpp +++ b/dom/base/nsContentAreaDragDrop.cpp @@ -18,7 +18,6 @@ #include "nsISelectionController.h" #include "nsIDOMNode.h" #include "nsIDOMNodeList.h" -#include "nsIDOMEvent.h" #include "nsPIDOMWindow.h" #include "nsIDOMRange.h" #include "nsIFormControl.h" diff --git a/dom/base/nsContentIterator.cpp b/dom/base/nsContentIterator.cpp index 7f0939ffc619..9bbdb17e9d9f 100644 --- a/dom/base/nsContentIterator.cpp +++ b/dom/base/nsContentIterator.cpp @@ -40,7 +40,7 @@ NodeIsInTraversalRange(nsINode* aNode, bool aIsPreMode, // If a leaf node contains an end point of the traversal range, it is // always in the traversal range. if (aNode == aStart.Container() || aNode == aEnd.Container()) { - if (aNode->IsNodeOfType(nsINode::eDATA_NODE)) { + if (aNode->IsCharacterData()) { return true; // text node or something } if (!aNode->HasChildren()) { @@ -317,7 +317,7 @@ nsContentIterator::InitInternal(const RawRangeBoundary& aStart, return NS_ERROR_FAILURE; } - bool startIsData = aStart.Container()->IsNodeOfType(nsINode::eDATA_NODE); + bool startIsData = aStart.Container()->IsCharacterData(); // Check to see if we have a collapsed range, if so, there is nothing to // iterate over. @@ -410,7 +410,7 @@ nsContentIterator::InitInternal(const RawRangeBoundary& aStart, // Find last node in range. - bool endIsData = aEnd.Container()->IsNodeOfType(nsINode::eDATA_NODE); + bool endIsData = aEnd.Container()->IsCharacterData(); if (endIsData || !aEnd.Container()->HasChildren() || aEnd.IsStartOfContainer()) { if (mPre) { diff --git a/dom/base/nsContentList.cpp b/dom/base/nsContentList.cpp index 34a9d9c14008..32e2ab58439a 100644 --- a/dom/base/nsContentList.cpp +++ b/dom/base/nsContentList.cpp @@ -993,13 +993,9 @@ nsContentList::AssertInSync() // XXX This code will need to change if nsContentLists can ever match // elements that are outside of the document element. - nsIContent *root; - if (mRootNode->IsNodeOfType(nsINode::eDOCUMENT)) { - root = static_cast(mRootNode)->GetRootElement(); - } - else { - root = static_cast(mRootNode); - } + nsIContent* root = mRootNode->IsDocument() + ? mRootNode->AsDocument()->GetRootElement() + : mRootNode->AsContent(); nsCOMPtr iter; if (mDeep) { diff --git a/dom/base/nsContentPermissionHelper.cpp b/dom/base/nsContentPermissionHelper.cpp index fe033c9a334d..a9e39b37dbba 100644 --- a/dom/base/nsContentPermissionHelper.cpp +++ b/dom/base/nsContentPermissionHelper.cpp @@ -28,7 +28,6 @@ #include "nsISupportsPrimitives.h" #include "nsServiceManagerUtils.h" #include "nsIDocument.h" -#include "nsIDOMEvent.h" #include "nsWeakPtr.h" using mozilla::Unused; // @@ -74,7 +73,7 @@ VisibilityChangeListener::VisibilityChangeListener(nsPIDOMWindowInner* aWindow) } NS_IMETHODIMP -VisibilityChangeListener::HandleEvent(nsIDOMEvent* aEvent) +VisibilityChangeListener::HandleEvent(Event* aEvent) { nsAutoString type; aEvent->GetType(type); @@ -82,8 +81,7 @@ VisibilityChangeListener::HandleEvent(nsIDOMEvent* aEvent) return NS_ERROR_FAILURE; } - nsCOMPtr doc = - do_QueryInterface(aEvent->InternalDOMEvent()->GetTarget()); + nsCOMPtr doc = do_QueryInterface(aEvent->GetTarget()); MOZ_ASSERT(doc); if (mCallback) { diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index 17f6f6b2b31e..06c5ed451897 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -2210,11 +2210,11 @@ nsContentUtils::InProlog(nsINode *aNode) NS_PRECONDITION(aNode, "missing node to nsContentUtils::InProlog"); nsINode* parent = aNode->GetParentNode(); - if (!parent || !parent->IsNodeOfType(nsINode::eDOCUMENT)) { + if (!parent || !parent->IsDocument()) { return false; } - nsIDocument* doc = static_cast(parent); + nsIDocument* doc = parent->AsDocument(); nsIContent* root = doc->GetRootElement(); return !root || doc->ComputeIndexOf(aNode) < doc->ComputeIndexOf(root); @@ -2412,10 +2412,11 @@ nsContentUtils::GetCrossDocParentNode(nsINode* aChild) parent = aChild->AsContent()->GetFlattenedTreeParent(); } - if (parent || !aChild->IsNodeOfType(nsINode::eDOCUMENT)) + if (parent || !aChild->IsDocument()) { return parent; + } - nsIDocument* doc = static_cast(aChild); + nsIDocument* doc = aChild->AsDocument(); nsIDocument* parentDoc = doc->GetParentDocument(); return parentDoc ? parentDoc->FindContentForSubDocument(doc) : nullptr; } @@ -2447,9 +2448,9 @@ nsContentUtils::ContentIsHostIncludingDescendantOf( do { if (aPossibleDescendant == aPossibleAncestor) return true; - if (aPossibleDescendant->NodeType() == nsINode::DOCUMENT_FRAGMENT_NODE) { + if (aPossibleDescendant->IsDocumentFragment()) { aPossibleDescendant = - static_cast(aPossibleDescendant)->GetHost(); + aPossibleDescendant->AsDocumentFragment()->GetHost(); } else { aPossibleDescendant = aPossibleDescendant->GetParentNode(); } @@ -4438,8 +4439,7 @@ nsresult GetEventAndTarget(nsIDocument* aDoc, nsISupports* aTarget, event->InitEvent(aEventName, aCanBubble, aCancelable); event->SetTrusted(aTrusted); - nsresult rv = event->SetTarget(target); - NS_ENSURE_SUCCESS(rv, rv); + event->SetTarget(target); event.forget(aEvent); target.forget(aTargetOut); @@ -6521,7 +6521,7 @@ nsContentUtils::CanAccessNativeAnon() /* static */ nsresult nsContentUtils::DispatchXULCommand(nsIContent* aTarget, bool aTrusted, - nsIDOMEvent* aSourceEvent, + Event* aSourceEvent, nsIPresShell* aShell, bool aCtrl, bool aAlt, @@ -6539,8 +6539,7 @@ nsContentUtils::DispatchXULCommand(nsIContent* aTarget, nsGlobalWindowInner::Cast(doc->GetInnerWindow()), 0, aCtrl, aAlt, aShift, aMeta, - aSourceEvent ? - aSourceEvent->InternalDOMEvent() : nullptr, + aSourceEvent, aInputSource, IgnoreErrors()); if (aShell) { diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h index fd9dbab41104..c23baee2dd10 100644 --- a/dom/base/nsContentUtils.h +++ b/dom/base/nsContentUtils.h @@ -70,7 +70,6 @@ class nsIContentSecurityPolicy; class nsIDocShellTreeItem; class nsIDocumentLoaderFactory; class nsIDOMDocument; -class nsIDOMEvent; class nsIDOMNode; class nsIDragSession; class nsIEventTarget; @@ -131,6 +130,7 @@ class ChromeMessageBroadcaster; struct CustomElementDefinition; class DocumentFragment; class Element; +class Event; class EventTarget; class HTMLInputElement; class IPCDataTransfer; @@ -1356,12 +1356,12 @@ public: * nsIDOMDocument::CreateEvent() with parameter "Events". * @param aDoc The document which will be used to create the event. * @param aTarget The target of the event, should be QIable to - * nsIDOMEventTarget. + * EventTarget. * @param aEventName The name of the event. * @param aCanBubble Whether the event can bubble. * @param aCancelable Is the event cancelable. * @param aDefaultAction Set to true if default action should be taken, - * see nsIDOMEventTarget::DispatchEvent. + * see EventTarget::DispatchEvent. */ static nsresult DispatchTrustedEvent(nsIDocument* aDoc, nsISupports* aTarget, @@ -1379,7 +1379,7 @@ public: * @param aCanBubble Whether the event can bubble. * @param aCancelable Is the event cancelable. * @param aDefaultAction Set to true if default action should be taken, - * see nsIDOMEventTarget::DispatchEvent. + * see EventTarget::DispatchEvent. */ template static nsresult DispatchTrustedEvent(nsIDocument* aDoc, @@ -1403,12 +1403,12 @@ public: * nsIDOMDocument::CreateEvent() with parameter "Events". * @param aDoc The document which will be used to create the event. * @param aTarget The target of the event, should be QIable to - * nsIDOMEventTarget. + * EventTarget. * @param aEventName The name of the event. * @param aCanBubble Whether the event can bubble. * @param aCancelable Is the event cancelable. * @param aDefaultAction Set to true if default action should be taken, - * see nsIDOMEventTarget::DispatchEvent. + * see EventTarget::DispatchEvent. */ static nsresult DispatchUntrustedEvent(nsIDocument* aDoc, nsISupports* aTarget, @@ -1427,7 +1427,7 @@ public: * @param aCanBubble Whether the event can bubble. * @param aCancelable Is the event cancelable. * @param aDefaultAction Set to true if default action should be taken, - * see nsIDOMEventTarget::DispatchEvent. + * see EventTarget::DispatchEvent. */ template static nsresult DispatchUntrustedEvent(nsIDocument* aDoc, @@ -1461,7 +1461,7 @@ public: * @param aCanBubble Whether the event can bubble. * @param aCancelable Is the event cancelable. * @param aDefaultAction Set to true if default action should be taken, - * see nsIDOMEventTarget::DispatchEvent. + * see EventTarget::DispatchEvent. */ static nsresult DispatchChromeEvent(nsIDocument* aDoc, nsISupports* aTarget, @@ -1489,12 +1489,12 @@ public: * nsIDOMDocument::CreateEvent() with parameter "Events". * @param aDoc The document which will be used to create the event. * @param aTarget The target of the event, should be QIable to - * nsIDOMEventTarget. + * EventTarget. * @param aEventName The name of the event. * @param aCanBubble Whether the event can bubble. * @param aCancelable Is the event cancelable. * @param aDefaultAction Set to true if default action should be taken, - * see nsIDOMEventTarget::DispatchEvent. + * see EventTarget::DispatchEvent. */ static nsresult DispatchEventOnlyToChrome(nsIDocument* aDoc, nsISupports* aTarget, @@ -2104,7 +2104,7 @@ public: */ static nsresult DispatchXULCommand(nsIContent* aTarget, bool aTrusted, - nsIDOMEvent* aSourceEvent = nullptr, + mozilla::dom::Event* aSourceEvent = nullptr, nsIPresShell* aShell = nullptr, bool aCtrl = false, bool aAlt = false, diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index 9be6338cdee9..8e17742a7950 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -10,7 +10,6 @@ #include "mozilla/layers/LayerTransactionChild.h" #include "nsPresContext.h" #include "nsError.h" -#include "nsIDOMEvent.h" #include "nsQueryContentEventResult.h" #include "nsGlobalWindow.h" #include "nsIDocument.h" @@ -19,6 +18,7 @@ #include "nsRefreshDriver.h" #include "mozilla/dom/BindingDeclarations.h" #include "mozilla/dom/BlobBinding.h" +#include "mozilla/dom/Event.h" #include "mozilla/dom/Touch.h" #include "mozilla/PendingAnimationTracker.h" #include "nsIObjectLoadingContent.h" @@ -1851,7 +1851,7 @@ nsDOMWindowUtils::GetFullZoom(float* aFullZoom) NS_IMETHODIMP nsDOMWindowUtils::DispatchDOMEventViaPresShell(nsIDOMNode* aTarget, - nsIDOMEvent* aEvent, + Event* aEvent, bool aTrusted, bool* aRetVal) { @@ -3651,15 +3651,15 @@ nsDOMWindowUtils::GetPaintFlashing(bool* aRetVal) } NS_IMETHODIMP -nsDOMWindowUtils::DispatchEventToChromeOnly(nsIDOMEventTarget* aTarget, - nsIDOMEvent* aEvent, +nsDOMWindowUtils::DispatchEventToChromeOnly(EventTarget* aTarget, + Event* aEvent, bool* aRetVal) { *aRetVal = false; NS_ENSURE_STATE(aTarget && aEvent); aEvent->WidgetEventPtr()->mFlags.mOnlyChromeDispatch = true; - *aRetVal = EventTarget::From(aTarget)-> - DispatchEvent(*aEvent->InternalDOMEvent(), CallerType::System, IgnoreErrors()); + *aRetVal = aTarget-> + DispatchEvent(*aEvent, CallerType::System, IgnoreErrors()); return NS_OK; } diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp index 1c3a0185511b..e6a40174d1aa 100644 --- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -60,6 +60,7 @@ #include "mozilla/dom/Attr.h" #include "mozilla/dom/BindingDeclarations.h" #include "mozilla/dom/Element.h" +#include "mozilla/dom/Event.h" #include "mozilla/dom/FramingChecker.h" #include "mozilla/dom/HTMLSharedElement.h" #include "nsGenericHTMLElement.h" @@ -1740,7 +1741,6 @@ NS_INTERFACE_TABLE_HEAD(nsDocument) NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOMDocument) NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOMNode) NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIScriptObjectPrincipal) - NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIDOMEventTarget) NS_INTERFACE_TABLE_ENTRY(nsDocument, mozilla::dom::EventTarget) NS_INTERFACE_TABLE_ENTRY(nsDocument, nsISupportsWeakReference) NS_INTERFACE_TABLE_ENTRY(nsDocument, nsIRadioGroupContainer) @@ -4160,7 +4160,7 @@ nsIDocument::FindContentForSubDocument(nsIDocument *aDocument) const bool nsIDocument::IsNodeOfType(uint32_t aFlags) const { - return !(aFlags & ~eDOCUMENT); + return false; } Element* diff --git a/dom/base/nsDocumentEncoder.cpp b/dom/base/nsDocumentEncoder.cpp index 4867e5ff3e7e..fd9930172b70 100644 --- a/dom/base/nsDocumentEncoder.cpp +++ b/dom/base/nsDocumentEncoder.cpp @@ -543,10 +543,8 @@ nsDocumentEncoder::SerializeToStringIterative(nsINode* aNode, // Handle template element. If the parent is a template's content, // then adjust the parent to be the template element. - if (current && current != aNode && - current->NodeType() == nsINode::DOCUMENT_FRAGMENT_NODE) { - DocumentFragment* frag = static_cast(current); - nsIContent* host = frag->GetHost(); + if (current && current != aNode && current->IsDocumentFragment()) { + nsIContent* host = current->AsDocumentFragment()->GetHost(); if (host && host->IsHTMLElement(nsGkAtoms::_template)) { current = host; } diff --git a/dom/base/nsFrameLoader.cpp b/dom/base/nsFrameLoader.cpp index 7722fc5653a7..a43880b451b8 100644 --- a/dom/base/nsFrameLoader.cpp +++ b/dom/base/nsFrameLoader.cpp @@ -35,7 +35,6 @@ #include "nsIScriptSecurityManager.h" #include "nsIScrollable.h" #include "nsFrameLoader.h" -#include "nsIDOMEventTarget.h" #include "nsIFrame.h" #include "nsIScrollableFrame.h" #include "nsSubDocumentFrame.h" @@ -2054,13 +2053,13 @@ nsFrameLoader::MaybeCreateDocShell() // Make sure all shells have links back to the content element // in the nearest enclosing chrome shell. - nsCOMPtr chromeEventHandler; + RefPtr chromeEventHandler; if (parentType == nsIDocShellTreeItem::typeChrome) { // Our parent shell is a chrome shell. It is therefore our nearest // enclosing chrome shell. - chromeEventHandler = do_QueryInterface(mOwnerContent); + chromeEventHandler = mOwnerContent; NS_ASSERTION(chromeEventHandler, "This mContent should implement this."); } else { diff --git a/dom/base/nsGlobalWindowInner.cpp b/dom/base/nsGlobalWindowInner.cpp index b2bb9ac5121c..088459cb007f 100644 --- a/dom/base/nsGlobalWindowInner.cpp +++ b/dom/base/nsGlobalWindowInner.cpp @@ -19,6 +19,7 @@ #include "nsIDOMStorageManager.h" #include "mozilla/dom/DOMJSProxyHandler.h" #include "mozilla/dom/DOMPrefs.h" +#include "mozilla/dom/EventTarget.h" #include "mozilla/dom/LocalStorage.h" #include "mozilla/dom/Storage.h" #include "mozilla/dom/IdleRequest.h" @@ -111,7 +112,6 @@ #include "Crypto.h" #include "nsIDOMDocument.h" #include "nsIDOMElement.h" -#include "nsIDOMEvent.h" #include "nsIDOMOfflineResourceList.h" #include "nsDOMString.h" #include "nsIEmbeddingSiteWindow.h" @@ -1331,13 +1331,11 @@ nsGlobalWindowInner::FreeInnerObjects() // QueryInterface implementation for nsGlobalWindowInner NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsGlobalWindowInner) NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY - // Make sure this matches the cast in nsGlobalWindowInner::FromWrapper() - NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMEventTarget) + NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, EventTarget) NS_INTERFACE_MAP_ENTRY(nsIDOMWindow) NS_INTERFACE_MAP_ENTRY(nsIGlobalObject) NS_INTERFACE_MAP_ENTRY(nsIScriptGlobalObject) NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal) - NS_INTERFACE_MAP_ENTRY(nsIDOMEventTarget) NS_INTERFACE_MAP_ENTRY(mozilla::dom::EventTarget) if (aIID.Equals(NS_GET_IID(nsPIDOMWindowInner))) { foundInterface = static_cast(this); @@ -1617,7 +1615,7 @@ nsGlobalWindowInner::IsBlackForCC(bool aTracingNeeded) return (nsCCUncollectableMarker::InGeneration(GetMarkedCCGeneration()) || HasKnownLiveWrapper()) && (!aTracingNeeded || - HasNothingToTrace(static_cast(this))); + HasNothingToTrace(ToSupports(this))); } //***************************************************************************** @@ -2046,7 +2044,7 @@ nsGlobalWindowInner::PostHandleEvent(EventChainPostVisitor& aVisitor) /* mChromeEventHandler and mContext go dangling in the middle of this function under some circumstances (events that destroy the window) without this addref. */ - nsCOMPtr kungFuDeathGrip1(mChromeEventHandler); + RefPtr kungFuDeathGrip1(mChromeEventHandler); mozilla::Unused << kungFuDeathGrip1; // These aren't referred to through the function nsCOMPtr kungFuDeathGrip2(GetContextInternal()); mozilla::Unused << kungFuDeathGrip2; // These aren't referred to through the function @@ -4486,7 +4484,7 @@ nsGlobalWindowInner::Btoa(const nsAString& aBinaryData, } //***************************************************************************** -// nsGlobalWindowInner::nsIDOMEventTarget +// EventTarget //***************************************************************************** nsPIDOMWindowOuter* diff --git a/dom/base/nsGlobalWindowInner.h b/dom/base/nsGlobalWindowInner.h index 503ddd0f1fc3..b71efeaecaeb 100644 --- a/dom/base/nsGlobalWindowInner.h +++ b/dom/base/nsGlobalWindowInner.h @@ -24,7 +24,6 @@ // Interfaces Needed #include "nsIBrowserDOMWindow.h" -#include "nsIDOMEventTarget.h" #include "nsIInterfaceRequestor.h" #include "nsIDOMChromeWindow.h" #include "nsIScriptGlobalObject.h" @@ -315,9 +314,6 @@ public: void Dump(const nsAString& aStr); void SetResizable(bool aResizable) const; - // nsIDOMEventTarget - NS_DECL_NSIDOMEVENTTARGET - virtual mozilla::EventListenerManager* GetExistingListenerManager() const override; @@ -481,7 +477,7 @@ public: friend class WindowStateHolder; NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsGlobalWindowInner, - nsIDOMEventTarget) + mozilla::dom::EventTarget) #ifdef DEBUG // Call Unlink on this window. This may cause bad things to happen, so use @@ -1509,13 +1505,13 @@ protected: inline nsISupports* ToSupports(nsGlobalWindowInner *p) { - return static_cast(p); + return static_cast(p); } inline nsISupports* ToCanonicalSupports(nsGlobalWindowInner *p) { - return static_cast(p); + return static_cast(p); } // XXX: EWW - This is an awful hack - let's not do this diff --git a/dom/base/nsGlobalWindowOuter.cpp b/dom/base/nsGlobalWindowOuter.cpp index c0b1c1a3823d..055b35c07826 100644 --- a/dom/base/nsGlobalWindowOuter.cpp +++ b/dom/base/nsGlobalWindowOuter.cpp @@ -17,6 +17,7 @@ #include "nsHistory.h" #include "nsDOMNavigationTiming.h" #include "nsIDOMStorageManager.h" +#include "mozilla/dom/EventTarget.h" #include "mozilla/dom/LocalStorage.h" #include "mozilla/dom/Storage.h" #include "mozilla/dom/IdleRequest.h" @@ -108,7 +109,6 @@ #include "Crypto.h" #include "nsIDOMDocument.h" #include "nsIDOMElement.h" -#include "nsIDOMEvent.h" #include "nsIDOMOfflineResourceList.h" #include "nsDOMString.h" #include "nsIEmbeddingSiteWindow.h" @@ -1085,13 +1085,11 @@ nsGlobalWindowOuter::ClearControllers() // QueryInterface implementation for nsGlobalWindowOuter NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsGlobalWindowOuter) NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY - // Make sure this matches the cast in nsGlobalWindowOuter::FromWrapper() - NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMEventTarget) + NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, EventTarget) NS_INTERFACE_MAP_ENTRY(nsIDOMWindow) NS_INTERFACE_MAP_ENTRY(nsIGlobalObject) NS_INTERFACE_MAP_ENTRY(nsIScriptGlobalObject) NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal) - NS_INTERFACE_MAP_ENTRY(nsIDOMEventTarget) NS_INTERFACE_MAP_ENTRY(mozilla::dom::EventTarget) if (aIID.Equals(NS_GET_IID(nsPIDOMWindowOuter))) { foundInterface = static_cast(this); @@ -1219,7 +1217,7 @@ nsGlobalWindowOuter::IsBlackForCC(bool aTracingNeeded) return (nsCCUncollectableMarker::InGeneration(GetMarkedCCGeneration()) || HasKnownLiveWrapper()) && (!aTracingNeeded || - HasNothingToTrace(static_cast(this))); + HasNothingToTrace(ToSupports(this))); } //***************************************************************************** @@ -2134,7 +2132,7 @@ nsGlobalWindowOuter::SetDocShell(nsIDocShell* aDocShell) // Get our enclosing chrome shell and retrieve its global window impl, so // that we can do some forwarding to the chrome document. - nsCOMPtr chromeEventHandler; + RefPtr chromeEventHandler; mDocShell->GetChromeEventHandler(getter_AddRefs(chromeEventHandler)); mChromeEventHandler = do_QueryInterface(chromeEventHandler); if (!mChromeEventHandler) { @@ -6401,7 +6399,7 @@ nsGlobalWindowOuter::FindOuter(const nsAString& aString, bool aCaseSensitive, } //***************************************************************************** -// nsGlobalWindowOuter::nsIDOMEventTarget +// EventTarget //***************************************************************************** nsPIDOMWindowOuter* diff --git a/dom/base/nsGlobalWindowOuter.h b/dom/base/nsGlobalWindowOuter.h index bac9067a61a3..b9e930d15299 100644 --- a/dom/base/nsGlobalWindowOuter.h +++ b/dom/base/nsGlobalWindowOuter.h @@ -25,7 +25,6 @@ // Interfaces Needed #include "nsIBrowserDOMWindow.h" -#include "nsIDOMEventTarget.h" #include "nsIInterfaceRequestor.h" #include "nsIDOMChromeWindow.h" #include "nsIScriptGlobalObject.h" @@ -272,9 +271,6 @@ public: OpenJS(const nsAString& aUrl, const nsAString& aName, const nsAString& aOptions, nsPIDOMWindowOuter **_retval); - // nsIDOMEventTarget - NS_DECL_NSIDOMEVENTTARGET - virtual mozilla::EventListenerManager* GetExistingListenerManager() const override; @@ -459,7 +455,7 @@ public: friend class WindowStateHolder; NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsGlobalWindowOuter, - nsIDOMEventTarget) + mozilla::dom::EventTarget) virtual bool TakeFocus(bool aFocus, uint32_t aFocusMethod) override; virtual void SetReadyForFocus() override; @@ -1174,13 +1170,13 @@ protected: inline nsISupports* ToSupports(nsGlobalWindowOuter *p) { - return static_cast(p); + return static_cast(p); } inline nsISupports* ToCanonicalSupports(nsGlobalWindowOuter *p) { - return static_cast(p); + return static_cast(p); } inline nsIGlobalObject* diff --git a/dom/base/nsIContent.h b/dom/base/nsIContent.h index ea30fecc9332..20b68ea76388 100644 --- a/dom/base/nsIContent.h +++ b/dom/base/nsIContent.h @@ -940,6 +940,11 @@ inline nsIContent* nsINode::AsContent() return static_cast(this); } +inline const nsIContent* nsINode::AsContent() const +{ + return const_cast(this)->AsContent(); +} + // Some checks are faster to do on nsIContent or Element than on // nsINode, so spit out FromNode versions taking those types too. #define NS_IMPL_FROMNODE_HELPER(_class, _check) \ diff --git a/dom/base/nsIDocument.h b/dom/base/nsIDocument.h index 498aade6a8f8..b5f1ab8827ba 100644 --- a/dom/base/nsIDocument.h +++ b/dom/base/nsIDocument.h @@ -4607,4 +4607,18 @@ nsINode::GetParentObject() const return p; } +inline nsIDocument* +nsINode::AsDocument() +{ + MOZ_ASSERT(IsDocument()); + return static_cast(this); +} + +inline const nsIDocument* +nsINode::AsDocument() const +{ + MOZ_ASSERT(IsDocument()); + return static_cast(this); +} + #endif /* nsIDocument_h___ */ diff --git a/dom/base/nsIDroppedLinkHandler.idl b/dom/base/nsIDroppedLinkHandler.idl index 7964811f54d1..8b4f5242406a 100644 --- a/dom/base/nsIDroppedLinkHandler.idl +++ b/dom/base/nsIDroppedLinkHandler.idl @@ -5,8 +5,6 @@ #include "nsISupports.idl" #include "nsIPrincipal.idl" -interface nsIDOMEvent; - webidl DragEvent; webidl DataTransfer; diff --git a/dom/base/nsINode.cpp b/dom/base/nsINode.cpp index ed2a19096019..b90419c57d15 100644 --- a/dom/base/nsINode.cpp +++ b/dom/base/nsINode.cpp @@ -61,7 +61,6 @@ #include "nsIControllers.h" #include "nsIDocument.h" #include "nsIDOMDocument.h" -#include "nsIDOMEvent.h" #include "nsIDOMEventListener.h" #include "nsIDOMNodeList.h" #include "nsILinkHandler.h" @@ -344,8 +343,8 @@ nsINode::GetSelectionRootContent(nsIPresShell* aPresShell) { NS_ENSURE_TRUE(aPresShell, nullptr); - if (IsNodeOfType(eDOCUMENT)) - return static_cast(this)->GetRootElement(); + if (IsDocument()) + return AsDocument()->GetRootElement(); if (!IsContent()) return nullptr; @@ -413,11 +412,9 @@ nsINode::ChildNodes() { nsSlots* slots = Slots(); if (!slots->mChildNodes) { - // Check |!IsElement()| first to catch the common case - // without virtual call |IsNodeOfType| - slots->mChildNodes = !IsElement() && IsNodeOfType(nsINode::eATTRIBUTE) ? - new nsAttrChildContentList(this) : - new nsParentNodeChildContentList(this); + slots->mChildNodes = IsAttr() + ? new nsAttrChildContentList(this) + : new nsParentNodeChildContentList(this); } return slots->mChildNodes; @@ -426,7 +423,7 @@ nsINode::ChildNodes() void nsINode::InvalidateChildNodes() { - MOZ_ASSERT(IsElement() || !IsNodeOfType(nsINode::eATTRIBUTE)); + MOZ_ASSERT(!IsAttr()); nsSlots* slots = GetExistingSlots(); if (!slots || !slots->mChildNodes) { @@ -529,7 +526,7 @@ nsINode::GetNodeValueInternal(nsAString& aNodeValue) nsINode* nsINode::RemoveChild(nsINode& aOldChild, ErrorResult& aError) { - if (IsNodeOfType(eDATA_NODE)) { + if (IsCharacterData()) { // aOldChild can't be one of our children. aError.Throw(NS_ERROR_DOM_NOT_FOUND_ERR); return nullptr; @@ -741,12 +738,12 @@ nsINode::CompareDocumentPosition(nsINode& aOtherNode) const AutoTArray parents1, parents2; - const nsINode *node1 = &aOtherNode, *node2 = this; + const nsINode* node1 = &aOtherNode; + const nsINode* node2 = this; // Check if either node is an attribute - const Attr* attr1 = nullptr; - if (node1->IsNodeOfType(nsINode::eATTRIBUTE)) { - attr1 = static_cast(node1); + const Attr* attr1 = Attr::FromNode(node1); + if (attr1) { const Element* elem = attr1->GetElement(); // If there is an owner element add the attribute // to the chain and walk up to the element @@ -755,8 +752,7 @@ nsINode::CompareDocumentPosition(nsINode& aOtherNode) const parents1.AppendElement(attr1); } } - if (node2->IsNodeOfType(nsINode::eATTRIBUTE)) { - const Attr* attr2 = static_cast(node2); + if (auto* attr2 = Attr::FromNode(node2)) { const Element* elem = attr2->GetElement(); if (elem == node1 && attr1) { // Both nodes are attributes on the same element. @@ -1295,7 +1291,7 @@ nsINode::doInsertChildAt(nsIContent* aKid, uint32_t aIndex, bool aNotify, nsAttrAndChildArray& aChildArray) { MOZ_ASSERT(!aKid->GetParentNode(), "Inserting node that already has parent"); - MOZ_ASSERT(!IsNodeOfType(nsINode::eATTRIBUTE)); + MOZ_ASSERT(!IsAttr()); // The id-handling code, and in the future possibly other code, need to // react to unexpected attribute changes. @@ -1339,8 +1335,7 @@ nsINode::doInsertChildAt(nsIContent* aKid, uint32_t aIndex, mFirstChild = aKid; } - nsIContent* parent = - IsNodeOfType(eDOCUMENT) ? nullptr : static_cast(this); + nsIContent* parent = IsContent() ? AsContent() : nullptr; rv = aKid->BindToTree(doc, parent, parent ? parent->GetBindingParent() : nullptr, @@ -1650,7 +1645,7 @@ nsINode::doRemoveChildAt(uint32_t aIndex, bool aNotify, MOZ_ASSERT(aKid && aKid->GetParentNode() == this && aKid == GetChildAt_Deprecated(aIndex) && ComputeIndexOf(aKid) == (int32_t)aIndex, "Bogus aKid"); - MOZ_ASSERT(!IsNodeOfType(nsINode::eATTRIBUTE)); + MOZ_ASSERT(!IsAttr()); nsMutationGuard::DidMutate(); mozAutoDocUpdate updateBatch(GetComposedDoc(), UPDATE_CONTENT_MODEL, aNotify); @@ -1683,8 +1678,8 @@ bool IsAllowedAsChild(nsIContent* aNewChild, nsINode* aParent, MOZ_ASSERT(aNewChild, "Must have new child"); MOZ_ASSERT_IF(aIsReplace, aRefChild); MOZ_ASSERT(aParent); - MOZ_ASSERT(aParent->IsNodeOfType(nsINode::eDOCUMENT) || - aParent->IsNodeOfType(nsINode::eDOCUMENT_FRAGMENT) || + MOZ_ASSERT(aParent->IsDocument() || + aParent->IsDocumentFragment() || aParent->IsElement(), "Nodes that are not documents, document fragments or elements " "can't be parents!"); @@ -1718,12 +1713,12 @@ bool IsAllowedAsChild(nsIContent* aNewChild, nsINode* aParent, return aParent->NodeType() != nsINode::DOCUMENT_NODE; case nsINode::ELEMENT_NODE : { - if (!aParent->IsNodeOfType(nsINode::eDOCUMENT)) { + if (!aParent->IsDocument()) { // Always ok to have elements under other elements or document fragments return true; } - nsIDocument* parentDocument = static_cast(aParent); + nsIDocument* parentDocument = aParent->AsDocument(); Element* rootElement = parentDocument->GetRootElement(); if (rootElement) { // Already have a documentElement, so this is only OK if we're @@ -1755,12 +1750,12 @@ bool IsAllowedAsChild(nsIContent* aNewChild, nsINode* aParent, } case nsINode::DOCUMENT_TYPE_NODE : { - if (!aParent->IsNodeOfType(nsINode::eDOCUMENT)) { + if (!aParent->IsDocument()) { // doctypes only allowed under documents return false; } - nsIDocument* parentDocument = static_cast(aParent); + nsIDocument* parentDocument = aParent->AsDocument(); nsIContent* docTypeContent = parentDocument->GetDoctype(); if (docTypeContent) { // Already have a doctype, so this is only OK if we're replacing it @@ -1795,7 +1790,7 @@ bool IsAllowedAsChild(nsIContent* aNewChild, nsINode* aParent, // doctype nodes in document fragments, we'll need to update this code. // Also, there's a version of this code in ReplaceOrInsertBefore. If you // change this code, change that too. - if (!aParent->IsNodeOfType(nsINode::eDOCUMENT)) { + if (!aParent->IsDocument()) { // All good here return true; } @@ -1846,9 +1841,7 @@ void nsINode::EnsurePreInsertionValidity1(nsINode& aNewChild, nsINode* aRefChild, ErrorResult& aError) { - if ((!IsNodeOfType(eDOCUMENT) && - !IsNodeOfType(eDOCUMENT_FRAGMENT) && - !IsElement()) || + if ((!IsDocument() && !IsDocumentFragment() && !IsElement()) || !aNewChild.IsContent()) { aError.Throw(NS_ERROR_DOM_HIERARCHY_REQUEST_ERR); return; @@ -2105,7 +2098,7 @@ nsINode::ReplaceOrInsertBefore(bool aReplace, nsINode* aNewChild, // need to reimplement the relevant part of IsAllowedAsChild() because // now our nodes are in an array and all. If you change this code, // change the code there. - if (IsNodeOfType(nsINode::eDOCUMENT)) { + if (IsDocument()) { bool sawElement = false; for (uint32_t i = 0; i < count; ++i) { nsIContent* child = fragChildren->ElementAt(i); @@ -2202,8 +2195,7 @@ nsINode::ReplaceOrInsertBefore(bool aReplace, nsINode* aNewChild, return result; } - bool appending = - !IsNodeOfType(eDOCUMENT) && uint32_t(insPos) == GetChildCount(); + bool appending = !IsDocument() && uint32_t(insPos) == GetChildCount(); nsIContent* firstInsertedContent = fragChildren->ElementAt(0); // Iterate through the fragment's children, and insert them in the new @@ -2364,12 +2356,11 @@ nsINode::Contains(const nsINode* aOther) const return !other->IsInAnonymousSubtree(); } - if (!IsElement() && !IsNodeOfType(nsINode::eDOCUMENT_FRAGMENT)) { + if (!IsElement() && !IsDocumentFragment()) { return false; } - const nsIContent* thisContent = static_cast(this); - if (thisContent->GetBindingParent() != other->GetBindingParent()) { + if (AsContent()->GetBindingParent() != other->GetBindingParent()) { return false; } @@ -2449,7 +2440,8 @@ FindMatchingElementsWithId(const nsAString& aId, nsINode* aRoot, { MOZ_ASSERT(aRoot->IsInUncomposedDoc(), "Don't call me if the root is not in the document"); - MOZ_ASSERT(aRoot->IsElement() || aRoot->IsNodeOfType(nsINode::eDOCUMENT), + // FIXME(emilio): It'd be nice to optimize this for shadow roots too. + MOZ_ASSERT(aRoot->IsElement() || aRoot->IsDocument(), "The optimization below to check ContentIsDescendantOf only for " "elements depends on aRoot being either an element or a " "document if it's in the document. Note that document fragments " @@ -2524,7 +2516,7 @@ nsINode::QuerySelectorAll(const nsAString& aSelector, ErrorResult& aResult) Element* nsINode::GetElementById(const nsAString& aId) { - MOZ_ASSERT(IsElement() || IsNodeOfType(eDOCUMENT_FRAGMENT), + MOZ_ASSERT(IsElement() || IsDocumentFragment(), "Bogus this object for GetElementById call"); if (IsInUncomposedDoc()) { ElementHolder holder; diff --git a/dom/base/nsINode.h b/dom/base/nsINode.h index 9b0fb6158ba3..1f4fcc24d6ac 100644 --- a/dom/base/nsINode.h +++ b/dom/base/nsINode.h @@ -77,6 +77,7 @@ class AccessibleNode; struct BoxQuadOptions; struct ConvertCoordinateOptions; class DocGroup; +class DocumentFragment; class DOMPoint; class DOMQuad; class DOMRectReadOnly; @@ -411,22 +412,8 @@ public: * Bit-flags to pass (or'ed together) to IsNodeOfType() */ enum { - /** nsIDocument nodes */ - eDOCUMENT = 1 << 1, - /** nsIAttribute nodes */ - eATTRIBUTE = 1 << 2, - /** xml processing instructions */ - ePROCESSING_INSTRUCTION = 1 << 4, - /** comment nodes */ - eCOMMENT = 1 << 5, /** form control elements */ eHTML_FORM_CONTROL = 1 << 6, - /** document fragments */ - eDOCUMENT_FRAGMENT = 1 << 7, - /** character data nodes (comments, PIs, text). */ - eDATA_NODE = 1 << 8, - /** HTMLMediaElement */ - eMEDIA = 1 << 9, /** animation elements */ eANIMATION = 1 << 10, /** filter elements that implement SVGFilterPrimitiveStandardAttributes */ @@ -445,18 +432,49 @@ public: */ virtual bool IsNodeOfType(uint32_t aFlags) const = 0; - bool - IsContainerNode() const + bool IsContainerNode() const { return IsElement() || !IsCharacterData(); } - bool - IsSlotable() const + bool IsSlotable() const { return IsElement() || IsText(); } + /** + * Returns true if this is a document node. + */ + bool IsDocument() const + { + // One less pointer-chase than checking NodeType(). + return !GetParentNode() && IsInUncomposedDoc(); + } + + /** + * Return this node as a document. Asserts IsDocument(). + * + * This is defined inline in nsIDocument.h. + */ + inline nsIDocument* AsDocument(); + inline const nsIDocument* AsDocument() const; + + /** + * Returns true if this is a document fragment node. + */ + bool IsDocumentFragment() const + { + return NodeType() == DOCUMENT_FRAGMENT_NODE; + } + + /** + * Return this node as a document fragment. Asserts IsDocumentFragment(). + * + * This is defined inline in DocumentFragment.h. + */ + inline mozilla::dom::DocumentFragment* AsDocumentFragment(); + inline const mozilla::dom::DocumentFragment* AsDocumentFragment() const; + virtual JSObject* WrapObject(JSContext *aCx, JS::Handle aGivenProto) override; /** @@ -490,7 +508,8 @@ public: /** * Return whether the node is an Element node */ - bool IsElement() const { + bool IsElement() const + { return GetBoolFlag(NodeIsElement); } @@ -498,18 +517,15 @@ public: * Return this node as an Element. Should only be used for nodes * for which IsElement() is true. This is defined inline in Element.h. */ - mozilla::dom::Element* AsElement(); - const mozilla::dom::Element* AsElement() const; + inline mozilla::dom::Element* AsElement(); + inline const mozilla::dom::Element* AsElement() const; /** * Return this node as nsIContent. Should only be used for nodes for which * IsContent() is true. This is defined inline in nsIContent.h. */ - nsIContent* AsContent(); - const nsIContent* AsContent() const - { - return const_cast(this)->AsContent(); - } + inline nsIContent* AsContent(); + inline const nsIContent* AsContent() const; /* * Return whether the node is a Text node (which might be an actual @@ -525,15 +541,15 @@ public: * Return this node as Text if it is one, otherwise null. This is defined * inline in Text.h. */ - mozilla::dom::Text* GetAsText(); - const mozilla::dom::Text* GetAsText() const; + inline mozilla::dom::Text* GetAsText(); + inline const mozilla::dom::Text* GetAsText() const; /** * Return this node as Text. Asserts IsText(). This is defined inline in * Text.h. */ - mozilla::dom::Text* AsText(); - const mozilla::dom::Text* AsText() const; + inline mozilla::dom::Text* AsText(); + inline const mozilla::dom::Text* AsText() const; /* * Return whether the node is a ProcessingInstruction node. @@ -556,6 +572,22 @@ public: nodeType == COMMENT_NODE; } + /** + * Return whether the node is a Comment node. + */ + bool IsComment() const + { + return NodeType() == COMMENT_NODE; + } + + /** + * Return whether the node is an Attr node. + */ + bool IsAttr() const + { + return NodeType() == ATTRIBUTE_NODE; + } + virtual nsIDOMNode* AsDOMNode() = 0; /** @@ -781,7 +813,7 @@ public: bool IsShadowRoot() const { const bool isShadowRoot = IsInShadowTree() && !GetParentNode(); - MOZ_ASSERT_IF(isShadowRoot, NodeType() == DOCUMENT_FRAGMENT_NODE); + MOZ_ASSERT_IF(isShadowRoot, IsDocumentFragment()); return isShadowRoot; } @@ -1011,12 +1043,12 @@ public: /** * Get the parent nsINode for this node if it is an Element. + * + * Defined inline in Element.h + * * @return the parent node */ - mozilla::dom::Element* GetParentElement() const - { - return mParent && mParent->IsElement() ? mParent->AsElement() : nullptr; - } + inline mozilla::dom::Element* GetParentElement() const; /** * Get the parent Element of this node, traversing over a ShadowRoot @@ -1037,11 +1069,6 @@ public: */ nsINode* GetRootNode(const mozilla::dom::GetRootNodeOptions& aOptions); - /** - * See nsIDOMEventTarget - */ - NS_DECL_NSIDOMEVENTTARGET - virtual mozilla::EventListenerManager* GetExistingListenerManager() const override; virtual mozilla::EventListenerManager* diff --git a/dom/base/nsISlowScriptDebug.idl b/dom/base/nsISlowScriptDebug.idl index ddb53684fa8c..39cbc8206e30 100644 --- a/dom/base/nsISlowScriptDebug.idl +++ b/dom/base/nsISlowScriptDebug.idl @@ -5,7 +5,8 @@ #include "nsISupports.idl" interface nsIDOMWindow; -interface nsIDOMEventTarget; + +webidl EventTarget; [scriptable, function, uuid(f7dbb80c-5d1e-4fd9-b55c-a9ffda4a75b1)] interface nsISlowScriptDebugCallback : nsISupports @@ -22,7 +23,7 @@ interface nsISlowScriptDebuggerStartupCallback : nsISupports [scriptable, function, uuid(dbee14b0-8fa0-11e4-b4a9-0800200c9a66)] interface nsISlowScriptDebugRemoteCallback : nsISupports { - void handleSlowScriptDebug(in nsIDOMEventTarget aBrowser, + void handleSlowScriptDebug(in EventTarget aBrowser, in nsISlowScriptDebuggerStartupCallback aCallback); }; diff --git a/dom/base/nsNodeUtils.cpp b/dom/base/nsNodeUtils.cpp index 9badcf43d18c..2e47452a623e 100644 --- a/dom/base/nsNodeUtils.cpp +++ b/dom/base/nsNodeUtils.cpp @@ -210,8 +210,7 @@ void nsNodeUtils::ContentInserted(nsINode* aContainer, nsIContent* aChild) { - NS_PRECONDITION(aContainer->IsContent() || - aContainer->IsNodeOfType(nsINode::eDOCUMENT), + NS_PRECONDITION(aContainer->IsContent() || aContainer->IsDocument(), "container must be an nsIContent or an nsIDocument"); nsIDocument* doc = aContainer->OwnerDoc(); IMPL_MUTATION_NOTIFICATION(ContentInserted, aContainer, (aChild), @@ -223,8 +222,7 @@ nsNodeUtils::ContentRemoved(nsINode* aContainer, nsIContent* aChild, nsIContent* aPreviousSibling) { - NS_PRECONDITION(aContainer->IsContent() || - aContainer->IsNodeOfType(nsINode::eDOCUMENT), + NS_PRECONDITION(aContainer->IsContent() || aContainer->IsDocument(), "container must be an nsIContent or an nsIDocument"); nsIDocument* doc = aContainer->OwnerDoc(); MOZ_ASSERT(aChild->GetParentNode() == aContainer, @@ -309,11 +307,11 @@ nsNodeUtils::LastRelease(nsINode* aNode) // Kill properties first since that may run external code, so we want to // be in as complete state as possible at that time. - if (aNode->IsNodeOfType(nsINode::eDOCUMENT)) { + if (aNode->IsDocument()) { // Delete all properties before tearing down the document. Some of the // properties are bound to nsINode objects and the destructor functions of // the properties may want to use the owner document of the nsINode. - static_cast(aNode)->DeleteAllProperties(); + aNode->AsDocument()->DeleteAllProperties(); } else { if (aNode->HasProperties()) { @@ -489,7 +487,7 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, bool aClone, bool aDeep, return nullptr; } } - else if (aDeep && clone->IsNodeOfType(nsINode::eDOCUMENT)) { + else if (aDeep && clone->IsDocument()) { // After cloning the document itself, we want to clone the children into // the cloned document (somewhat like cloning and importing them into the // cloned document). @@ -615,7 +613,7 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, bool aClone, bool aDeep, } } - if (aDeep && (!aClone || !aNode->IsNodeOfType(nsINode::eATTRIBUTE))) { + if (aDeep && (!aClone || !aNode->IsAttr())) { // aNode's children. for (nsIContent* cloneChild = aNode->GetFirstChild(); cloneChild; diff --git a/dom/base/nsRange.cpp b/dom/base/nsRange.cpp index b43afc1f3bb6..0fa7f816b35f 100644 --- a/dom/base/nsRange.cpp +++ b/dom/base/nsRange.cpp @@ -981,9 +981,9 @@ nsRange::DoSetRange(const RawRangeBoundary& aStart, aRoot == static_cast(aEnd.Container())->GetBindingParent()) || (!aRoot->GetParentNode() && - (aRoot->IsNodeOfType(nsINode::eDOCUMENT) || - aRoot->IsNodeOfType(nsINode::eATTRIBUTE) || - aRoot->IsNodeOfType(nsINode::eDOCUMENT_FRAGMENT) || + (aRoot->IsDocument() || + aRoot->IsAttr() || + aRoot->IsDocumentFragment() || /*For backward compatibility*/ aRoot->IsContent())), "Bad root"); @@ -1208,7 +1208,7 @@ nsRange::ComputeRootNode(nsINode* aNode, bool aMaySpanAnonymousSubtrees) root = aNode->SubtreeRoot(); - NS_ASSERTION(!root->IsNodeOfType(nsINode::eDOCUMENT), + NS_ASSERTION(!root->IsDocument(), "GetUncomposedDoc should have returned a doc"); // We allow this because of backward compatibility. diff --git a/dom/base/nsScreen.cpp b/dom/base/nsScreen.cpp index ceb41e19fa67..5172e4352054 100644 --- a/dom/base/nsScreen.cpp +++ b/dom/base/nsScreen.cpp @@ -4,7 +4,6 @@ * 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/. */ -#include "mozilla/dom/Event.h" // for nsIDOMEvent::InternalDOMEvent() #include "mozilla/dom/ScreenBinding.h" #include "nsContentUtils.h" #include "nsScreen.h" diff --git a/dom/base/nsTextNode.cpp b/dom/base/nsTextNode.cpp index 2623de5c0803..eaacc8b1bb71 100644 --- a/dom/base/nsTextNode.cpp +++ b/dom/base/nsTextNode.cpp @@ -110,7 +110,7 @@ nsTextNode::WrapNode(JSContext *aCx, JS::Handle aGivenProto) bool nsTextNode::IsNodeOfType(uint32_t aFlags) const { - return !(aFlags & ~eDATA_NODE); + return false; } already_AddRefed diff --git a/dom/base/nsTreeSanitizer.cpp b/dom/base/nsTreeSanitizer.cpp index 72557904fad9..883290dcf7c6 100644 --- a/dom/base/nsTreeSanitizer.cpp +++ b/dom/base/nsTreeSanitizer.cpp @@ -14,6 +14,7 @@ #include "mozilla/StyleSheetInlines.h" #include "mozilla/css/Rule.h" #include "mozilla/dom/CSSRuleList.h" +#include "mozilla/dom/DocumentFragment.h" #include "mozilla/dom/SRIMetadata.h" #include "nsCSSParser.h" #include "nsCSSPropertyID.h" @@ -1350,13 +1351,11 @@ nsTreeSanitizer::SanitizeURL(mozilla::dom::Element* aElement, } void -nsTreeSanitizer::Sanitize(nsIContent* aFragment) +nsTreeSanitizer::Sanitize(DocumentFragment* aFragment) { // If you want to relax these preconditions, be sure to check the code in // here that notifies / does not notify or that fires mutation events if // in tree. - NS_PRECONDITION(aFragment->IsNodeOfType(nsINode::eDOCUMENT_FRAGMENT), - "Argument was not DOM fragment."); NS_PRECONDITION(!aFragment->IsInUncomposedDoc(), "The fragment is in doc?"); mFullDocument = false; @@ -1500,7 +1499,7 @@ nsTreeSanitizer::SanitizeChildren(nsINode* aRoot) } NS_ASSERTION(!node->GetFirstChild(), "How come non-element node had kids?"); nsIContent* next = node->GetNextNonChildNode(aRoot); - if (!mAllowComments && node->IsNodeOfType(nsINode::eCOMMENT)) { + if (!mAllowComments && node->IsComment()) { node->RemoveFromParent(); } node = next; diff --git a/dom/base/nsTreeSanitizer.h b/dom/base/nsTreeSanitizer.h index 370a94d97f37..dd28ca60db59 100644 --- a/dom/base/nsTreeSanitizer.h +++ b/dom/base/nsTreeSanitizer.h @@ -30,12 +30,10 @@ class MOZ_STACK_CLASS nsTreeSanitizer { /** * Sanitizes a disconnected DOM fragment freshly obtained from a parser. - * The argument must be of type nsINode::eDOCUMENT_FRAGMENT and, - * consequently, must not be in the document. Furthermore, the fragment - * must have just come from a parser so that it can't have mutation - * event listeners set on it. + * The fragment must have just come from a parser so that it can't have + * mutation event listeners set on it. */ - void Sanitize(nsIContent* aFragment); + void Sanitize(mozilla::dom::DocumentFragment* aFragment); /** * Sanitizes a disconnected (not in a docshell) document freshly obtained diff --git a/dom/base/nsWindowMemoryReporter.cpp b/dom/base/nsWindowMemoryReporter.cpp index 02f6dc1b33dd..242d9af39049 100644 --- a/dom/base/nsWindowMemoryReporter.cpp +++ b/dom/base/nsWindowMemoryReporter.cpp @@ -735,7 +735,7 @@ nsWindowMemoryReporter::Observe(nsISupports *aSubject, const char *aTopic, void nsWindowMemoryReporter::ObserveDOMWindowDetached(nsGlobalWindowInner* aWindow) { - nsWeakPtr weakWindow = do_GetWeakReference(static_cast(aWindow)); + nsWeakPtr weakWindow = do_GetWeakReference(aWindow); if (!weakWindow) { NS_WARNING("Couldn't take weak reference to a window?"); return; diff --git a/dom/base/nsWindowRoot.cpp b/dom/base/nsWindowRoot.cpp index e18c32fe52aa..883b01c57222 100644 --- a/dom/base/nsWindowRoot.cpp +++ b/dom/base/nsWindowRoot.cpp @@ -61,9 +61,8 @@ NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(nsWindowRoot, NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsWindowRoot) NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY - NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMEventTarget) + NS_INTERFACE_MAP_ENTRY(nsISupports) NS_INTERFACE_MAP_ENTRY(nsPIWindowRoot) - NS_INTERFACE_MAP_ENTRY(nsIDOMEventTarget) NS_INTERFACE_MAP_ENTRY(mozilla::dom::EventTarget) NS_INTERFACE_MAP_END diff --git a/dom/base/nsWindowRoot.h b/dom/base/nsWindowRoot.h index 4b468c77f4f0..5a5bcf023ec8 100644 --- a/dom/base/nsWindowRoot.h +++ b/dom/base/nsWindowRoot.h @@ -7,12 +7,10 @@ #ifndef nsWindowRoot_h__ #define nsWindowRoot_h__ -class nsIDOMEvent; class nsIGlobalObject; #include "mozilla/Attributes.h" #include "mozilla/EventListenerManager.h" -#include "nsIDOMEventTarget.h" #include "nsIWeakReferenceUtils.h" #include "nsPIWindowRoot.h" #include "nsCycleCollectionParticipant.h" @@ -25,7 +23,6 @@ public: explicit nsWindowRoot(nsPIDOMWindowOuter* aWindow); NS_DECL_CYCLE_COLLECTING_ISUPPORTS - NS_DECL_NSIDOMEVENTTARGET virtual mozilla::EventListenerManager* GetExistingListenerManager() const override; @@ -70,8 +67,7 @@ public: virtual JSObject* WrapObject(JSContext* aCx, JS::Handle aGivenProto) override; - NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsWindowRoot, - nsIDOMEventTarget) + NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsWindowRoot) virtual void AddBrowser(mozilla::dom::TabParent* aBrowser) override; virtual void RemoveBrowser(mozilla::dom::TabParent* aBrowser) override; diff --git a/dom/base/nsXMLContentSerializer.cpp b/dom/base/nsXMLContentSerializer.cpp index 7acb251960b3..ed4d825a2565 100644 --- a/dom/base/nsXMLContentSerializer.cpp +++ b/dom/base/nsXMLContentSerializer.cpp @@ -1272,7 +1272,7 @@ nsXMLContentSerializer::MaybeFlagNewlineForRootNode(nsINode* aNode) { nsINode* parent = aNode->GetParentNode(); if (parent) { - mAddNewlineForRootNode = parent->IsNodeOfType(nsINode::eDOCUMENT); + mAddNewlineForRootNode = parent->IsDocument(); } } diff --git a/dom/base/test/chrome/window_swapFrameLoaders.xul b/dom/base/test/chrome/window_swapFrameLoaders.xul index 9a9e69380abd..8b87f9f704de 100644 --- a/dom/base/test/chrome/window_swapFrameLoaders.xul +++ b/dom/base/test/chrome/window_swapFrameLoaders.xul @@ -7,7 +7,7 @@ Test swapFrameLoaders with different frame types and remoteness --> - + - + diff --git a/dom/base/test/test_bug1281963.html b/dom/base/test/test_bug1281963.html index 9cc04fadec4a..58f84d554849 100644 --- a/dom/base/test/test_bug1281963.html +++ b/dom/base/test/test_bug1281963.html @@ -7,7 +7,7 @@ https://bugzilla.mozilla.org/1281963 Test for Bug 1281963 - + diff --git a/dom/base/test/test_bug352728.html b/dom/base/test/test_bug352728.html index 56699e4e8262..c52175c83cdd 100644 --- a/dom/base/test/test_bug352728.html +++ b/dom/base/test/test_bug352728.html @@ -51,7 +51,7 @@ function testComment(aText) var types = [ Comment, CharacterData, Node ]; checkTypes(comment, "comment", types); - var interfaces = [ "nsIDOMNode", "nsIDOMEventTarget" ]; + var interfaces = [ "nsIDOMNode" ]; checkInterfaces(comment, "comment", interfaces); testCharacterData(comment, aText); @@ -81,7 +81,7 @@ function testPI(aTarget, aData, aShouldSucceed, aReason) var types = [ ProcessingInstruction, Node ]; checkTypes(pi, "processing instruction", types); - var interfaces = [ "nsIDOMNode", "nsIDOMEventTarget" ]; + var interfaces = [ "nsIDOMNode" ]; checkInterfaces(pi, "processing instruction", interfaces); is(pi.target, aTarget, "Check target"); diff --git a/dom/base/test/test_bug352728.xhtml b/dom/base/test/test_bug352728.xhtml index 0d03bfda903e..0851b6706fd7 100644 --- a/dom/base/test/test_bug352728.xhtml +++ b/dom/base/test/test_bug352728.xhtml @@ -75,7 +75,7 @@ function testComment(aText) var types = [ Comment, CharacterData, Node ]; checkTypes(comment, "comment", types); - var interfaces = [ "nsIDOMNode", "nsIDOMEventTarget" ]; + var interfaces = [ "nsIDOMNode" ]; checkInterfaces(comment, "comment", interfaces); testCharacterData(comment, aText); @@ -93,7 +93,7 @@ function testCDATASection(aText, aShouldSucceed) var types = [ CDATASection, CharacterData, Node ]; checkTypes(cdataSection, "CDATA section", types); - var interfaces = [ "nsIDOMNode", "nsIDOMEventTarget" ]; + var interfaces = [ "nsIDOMNode" ]; checkInterfaces(cdataSection, "CDATA section", interfaces); testCharacterData(cdataSection, aText); @@ -124,7 +124,7 @@ function testPI(aTarget, aData, aShouldSucceed, aReason) var types = [ ProcessingInstruction, Node ]; checkTypes(pi, "processing instruction", types); - var interfaces = [ "nsIDOMNode", "nsIDOMEventTarget" ]; + var interfaces = [ "nsIDOMNode" ]; checkInterfaces(pi, "processing instruction", interfaces); is(pi.target, aTarget, "Check target"); diff --git a/dom/base/test/test_copypaste.html b/dom/base/test/test_copypaste.html index ea81284b38fd..f8b491c31b26 100644 --- a/dom/base/test/test_copypaste.html +++ b/dom/base/test/test_copypaste.html @@ -6,7 +6,7 @@ Test for copy/paste - + diff --git a/dom/base/test/test_copypaste.xhtml b/dom/base/test/test_copypaste.xhtml index 1a3d193aa070..89b036608a44 100644 --- a/dom/base/test/test_copypaste.xhtml +++ b/dom/base/test/test_copypaste.xhtml @@ -16,7 +16,7 @@ This test is different from test_copypaste.html in two ways: Test for copy/paste with XHTML - + diff --git a/dom/base/test/test_explicit_user_agent.html b/dom/base/test/test_explicit_user_agent.html index 80e92b01649d..35313db730dc 100644 --- a/dom/base/test/test_explicit_user_agent.html +++ b/dom/base/test/test_explicit_user_agent.html @@ -3,7 +3,7 @@ Test for XMLHttpRequest.GetResponseHeader(foo) byte-inflates the output - + diff --git a/dom/base/test/test_fragment_sanitization.xul b/dom/base/test/test_fragment_sanitization.xul index 5296290971c6..48c76c9fae13 100644 --- a/dom/base/test/test_fragment_sanitization.xul +++ b/dom/base/test/test_fragment_sanitization.xul @@ -7,7 +7,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1432966 - + diff --git a/dom/base/test/test_mozbrowser_apis_blocked.html b/dom/base/test/test_mozbrowser_apis_blocked.html index f04191177309..ad987ee55aee 100644 --- a/dom/base/test/test_mozbrowser_apis_blocked.html +++ b/dom/base/test/test_mozbrowser_apis_blocked.html @@ -3,7 +3,7 @@ Verify mozbrowser APIs are blocked without browser permission - + diff --git a/dom/base/test/test_postMessage_originAttributes.html b/dom/base/test/test_postMessage_originAttributes.html index fdc9216124b5..9a03a2f8a21e 100644 --- a/dom/base/test/test_postMessage_originAttributes.html +++ b/dom/base/test/test_postMessage_originAttributes.html @@ -3,7 +3,7 @@ Test window.postMessages from system principal to window with non-default originAttributes - + diff --git a/dom/canvas/ImageBitmap.cpp b/dom/canvas/ImageBitmap.cpp index 3f3d5b32115e..3c7bd74a2d75 100644 --- a/dom/canvas/ImageBitmap.cpp +++ b/dom/canvas/ImageBitmap.cpp @@ -436,9 +436,7 @@ private: static bool CheckSecurityForHTMLElements(bool aIsWriteOnly, bool aCORSUsed, nsIPrincipal* aPrincipal) { - MOZ_ASSERT(aPrincipal); - - if (aIsWriteOnly) { + if (aIsWriteOnly || !aPrincipal) { return false; } diff --git a/dom/canvas/WebGLContext.cpp b/dom/canvas/WebGLContext.cpp index 056152a7e81d..9280bec5c7bd 100644 --- a/dom/canvas/WebGLContext.cpp +++ b/dom/canvas/WebGLContext.cpp @@ -40,7 +40,6 @@ #include "nsError.h" #include "nsIClassInfoImpl.h" #include "nsIConsoleService.h" -#include "nsIDOMEvent.h" #include "nsIGfxInfo.h" #include "nsIObserverService.h" #include "nsIVariant.h" diff --git a/dom/canvas/WebGLContextUtils.cpp b/dom/canvas/WebGLContextUtils.cpp index 70eb14aa72b4..9a5cd4403975 100644 --- a/dom/canvas/WebGLContextUtils.cpp +++ b/dom/canvas/WebGLContextUtils.cpp @@ -12,7 +12,6 @@ #include "mozilla/gfx/Logging.h" #include "mozilla/Preferences.h" #include "mozilla/Sprintf.h" -#include "nsIDOMEvent.h" #include "nsIScriptSecurityManager.h" #include "nsIVariant.h" #include "nsPrintfCString.h" diff --git a/dom/credentialmanagement/tests/mochitest/test_credman_iframes.html b/dom/credentialmanagement/tests/mochitest/test_credman_iframes.html index 0153b07c6b70..81ff3e2c6e3f 100644 --- a/dom/credentialmanagement/tests/mochitest/test_credman_iframes.html +++ b/dom/credentialmanagement/tests/mochitest/test_credman_iframes.html @@ -2,7 +2,7 @@ Credential Management: Prohibit use in cross-origin iframes - + diff --git a/dom/events/AsyncEventDispatcher.cpp b/dom/events/AsyncEventDispatcher.cpp index 6d83a6659db5..683d811d48b4 100644 --- a/dom/events/AsyncEventDispatcher.cpp +++ b/dom/events/AsyncEventDispatcher.cpp @@ -7,10 +7,9 @@ #include "mozilla/AsyncEventDispatcher.h" #include "mozilla/BasicEvents.h" #include "mozilla/EventDispatcher.h" -#include "mozilla/dom/Event.h" // for nsIDOMEvent::InternalDOMEvent() +#include "mozilla/dom/Event.h" #include "mozilla/dom/EventTarget.h" #include "nsContentUtils.h" -#include "nsIDOMEvent.h" namespace mozilla { @@ -56,7 +55,7 @@ AsyncEventDispatcher::Run() false /* aCancelable */, nullptr /* aDefaultAction */, mOnlyChromeDispatch); } - RefPtr event = mEvent ? mEvent->InternalDOMEvent() : nullptr; + RefPtr event = mEvent; if (!event) { event = NS_NewDOMEvent(mTarget, nullptr, nullptr); event->InitEvent(mEventType, mBubbles, false); diff --git a/dom/events/AsyncEventDispatcher.h b/dom/events/AsyncEventDispatcher.h index 70a623ef2753..fb75fbb586a9 100644 --- a/dom/events/AsyncEventDispatcher.h +++ b/dom/events/AsyncEventDispatcher.h @@ -8,9 +8,10 @@ #define mozilla_AsyncEventDispatcher_h_ #include "mozilla/Attributes.h" +#include "mozilla/RefPtr.h" +#include "mozilla/dom/Event.h" #include "nsCOMPtr.h" #include "nsIDocument.h" -#include "nsIDOMEvent.h" #include "nsString.h" #include "nsThreadUtils.h" @@ -88,7 +89,7 @@ public: MOZ_ASSERT(mEventMessage != eUnidentifiedEvent); } - AsyncEventDispatcher(dom::EventTarget* aTarget, nsIDOMEvent* aEvent) + AsyncEventDispatcher(dom::EventTarget* aTarget, dom::Event* aEvent) : CancelableRunnable("AsyncEventDispatcher") , mTarget(aTarget) , mEvent(aEvent) @@ -109,7 +110,7 @@ public: void RequireNodeInDocument(); nsCOMPtr mTarget; - nsCOMPtr mEvent; + RefPtr mEvent; // If mEventType is set, mEventMessage will be eUnidentifiedEvent. // If mEventMessage is set, mEventType will be void. // They can never both be set at the same time. @@ -136,7 +137,7 @@ public: } } - LoadBlockingAsyncEventDispatcher(nsINode* aEventNode, nsIDOMEvent* aEvent) + LoadBlockingAsyncEventDispatcher(nsINode* aEventNode, dom::Event* aEvent) : AsyncEventDispatcher(aEventNode, aEvent) , mBlockedDoc(aEventNode->OwnerDoc()) { diff --git a/dom/events/DOMEventTargetHelper.cpp b/dom/events/DOMEventTargetHelper.cpp index ed5c6cc5e3f9..535daa5f3dea 100644 --- a/dom/events/DOMEventTargetHelper.cpp +++ b/dom/events/DOMEventTargetHelper.cpp @@ -8,6 +8,7 @@ #include "nsIDocument.h" #include "mozilla/Sprintf.h" #include "nsGlobalWindow.h" +#include "mozilla/dom/Event.h" #include "mozilla/dom/ScriptSettings.h" #include "mozilla/DOMEventTargetHelper.h" #include "mozilla/EventDispatcher.h" @@ -76,7 +77,6 @@ NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_END NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMEventTargetHelper) NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY NS_INTERFACE_MAP_ENTRY(nsISupports) - NS_INTERFACE_MAP_ENTRY(nsIDOMEventTarget) NS_INTERFACE_MAP_ENTRY(dom::EventTarget) NS_INTERFACE_MAP_ENTRY(DOMEventTargetHelper) NS_INTERFACE_MAP_END @@ -200,12 +200,12 @@ DOMEventTargetHelper::DispatchTrustedEvent(const nsAString& aEventName) } nsresult -DOMEventTargetHelper::DispatchTrustedEvent(nsIDOMEvent* event) +DOMEventTargetHelper::DispatchTrustedEvent(Event* event) { event->SetTrusted(true); ErrorResult rv; - DispatchEvent(*event->InternalDOMEvent(), rv); + DispatchEvent(*event, rv); return rv.StealNSResult(); } diff --git a/dom/events/DOMEventTargetHelper.h b/dom/events/DOMEventTargetHelper.h index be182f0aa7be..0dd6e2c8dacd 100644 --- a/dom/events/DOMEventTargetHelper.h +++ b/dom/events/DOMEventTargetHelper.h @@ -26,6 +26,10 @@ namespace mozilla { class ErrorResult; +namespace dom { +class Event; +} // namespace dom + #define NS_DOMEVENTTARGETHELPER_IID \ { 0xa28385c6, 0x9451, 0x4d7e, \ { 0xa3, 0xdd, 0xf4, 0xb6, 0x87, 0x2f, 0xa4, 0x76 } } @@ -80,8 +84,6 @@ public: NS_DECL_CYCLE_COLLECTING_ISUPPORTS NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS(DOMEventTargetHelper) - NS_DECL_NSIDOMEVENTTARGET - virtual EventListenerManager* GetExistingListenerManager() const override; virtual EventListenerManager* GetOrCreateListenerManager() override; @@ -202,7 +204,7 @@ protected: RefPtr mListenerManager; // Make |event| trusted and dispatch |aEvent| to |this|. - nsresult DispatchTrustedEvent(nsIDOMEvent* aEvent); + nsresult DispatchTrustedEvent(dom::Event* aEvent); virtual void LastRelease() {} diff --git a/dom/events/DataTransferItem.cpp b/dom/events/DataTransferItem.cpp index 0cf53e83a36f..aea429a6810e 100644 --- a/dom/events/DataTransferItem.cpp +++ b/dom/events/DataTransferItem.cpp @@ -326,10 +326,9 @@ DataTransferItem::GetAsEntry(nsIPrincipal& aSubjectPrincipal, if (target) { global = target->GetOwnerGlobal(); } else { - nsCOMPtr event = - do_QueryInterface(mDataTransfer->GetParentObject()); + RefPtr event = do_QueryObject(mDataTransfer->GetParentObject()); if (event) { - global = event->InternalDOMEvent()->GetParentObject(); + global = event->GetParentObject(); } } @@ -469,8 +468,8 @@ DataTransferItem::GetAsString(FunctionStringCallback* aCallback, if (parent && !global) { if (nsCOMPtr target = do_QueryInterface(parent)) { global = target->GetOwnerGlobal(); - } else if (nsCOMPtr event = do_QueryInterface(parent)) { - global = event->InternalDOMEvent()->GetParentObject(); + } else if (RefPtr event = do_QueryObject(parent)) { + global = event->GetParentObject(); } } if (global) { diff --git a/dom/events/Event.cpp b/dom/events/Event.cpp index 4659a8adb650..9e88d3e948e4 100644 --- a/dom/events/Event.cpp +++ b/dom/events/Event.cpp @@ -137,7 +137,7 @@ Event::~Event() NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Event) NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY NS_INTERFACE_MAP_ENTRY(nsISupports) - NS_INTERFACE_MAP_ENTRY(nsIDOMEvent) + NS_INTERFACE_MAP_ENTRY(Event) NS_INTERFACE_MAP_END NS_IMPL_CYCLE_COLLECTING_ADDREF(Event) @@ -222,16 +222,14 @@ Event::WrapObjectInternal(JSContext* aCx, JS::Handle aGivenProto) return EventBinding::Wrap(aCx, this, aGivenProto); } -// nsIDOMEventInterface -NS_IMETHODIMP -Event::GetType(nsAString& aType) +void +Event::GetType(nsAString& aType) const { if (!mIsMainThreadEvent) { aType = mEvent->mSpecifiedEventTypeString; - return NS_OK; + return; } GetWidgetEventType(mEvent, aType); - return NS_OK; } EventTarget* @@ -240,13 +238,6 @@ Event::GetTarget() const return mEvent->GetDOMEventTarget(); } -NS_IMETHODIMP -Event::GetTarget(nsIDOMEventTarget** aTarget) -{ - NS_IF_ADDREF(*aTarget = GetTarget()); - return NS_OK; -} - bool Event::IsSrcElementEnabled(JSContext* /* unused */, JSObject* /* unused */) { @@ -270,13 +261,6 @@ Event::ComposedPath(nsTArray>& aPath) EventDispatcher::GetComposedPathFor(mEvent, aPath); } -NS_IMETHODIMP -Event::GetCurrentTarget(nsIDOMEventTarget** aCurrentTarget) -{ - NS_IF_ADDREF(*aCurrentTarget = GetCurrentTarget()); - return NS_OK; -} - // // Get the actual event target node (may have been retargeted for mouse events) // @@ -304,26 +288,12 @@ Event::GetExplicitOriginalTarget() const return GetTarget(); } -NS_IMETHODIMP -Event::GetExplicitOriginalTarget(nsIDOMEventTarget** aRealEventTarget) -{ - NS_IF_ADDREF(*aRealEventTarget = GetExplicitOriginalTarget()); - return NS_OK; -} - EventTarget* Event::GetOriginalTarget() const { return mEvent->GetOriginalDOMEventTarget(); } -NS_IMETHODIMP -Event::GetOriginalTarget(nsIDOMEventTarget** aOriginalTarget) -{ - NS_IF_ADDREF(*aOriginalTarget = GetOriginalTarget()); - return NS_OK; -} - EventTarget* Event::GetComposedTarget() const { @@ -338,7 +308,7 @@ Event::GetComposedTarget() const static_cast(content->GetComposedDoc()); } -NS_IMETHODIMP_(void) +void Event::SetTrusted(bool aTrusted) { mEvent->mFlags.mIsTrusted = aTrusted; @@ -398,80 +368,41 @@ Event::EventPhase() const if ((mEvent->mCurrentTarget && mEvent->mCurrentTarget == mEvent->mTarget) || mEvent->mFlags.InTargetPhase()) { - return nsIDOMEvent::AT_TARGET; + return EventBinding::AT_TARGET; } if (mEvent->mFlags.mInCapturePhase) { - return nsIDOMEvent::CAPTURING_PHASE; + return EventBinding::CAPTURING_PHASE; } if (mEvent->mFlags.mInBubblingPhase) { - return nsIDOMEvent::BUBBLING_PHASE; + return EventBinding::BUBBLING_PHASE; } - return nsIDOMEvent::NONE; + return EventBinding::NONE; } -NS_IMETHODIMP -Event::GetEventPhase(uint16_t* aEventPhase) -{ - *aEventPhase = EventPhase(); - return NS_OK; -} - -NS_IMETHODIMP -Event::GetBubbles(bool* aBubbles) -{ - *aBubbles = Bubbles(); - return NS_OK; -} - -NS_IMETHODIMP -Event::GetCancelable(bool* aCancelable) -{ - *aCancelable = Cancelable(); - return NS_OK; -} - -NS_IMETHODIMP -Event::GetTimeStamp(uint64_t* aTimeStamp) -{ - *aTimeStamp = mEvent->mTime; - return NS_OK; -} - -NS_IMETHODIMP +void Event::StopPropagation() { mEvent->StopPropagation(); - return NS_OK; } -NS_IMETHODIMP +void Event::StopImmediatePropagation() { mEvent->StopImmediatePropagation(); - return NS_OK; } -NS_IMETHODIMP +void Event::StopCrossProcessForwarding() { mEvent->StopCrossProcessForwarding(); - return NS_OK; } -NS_IMETHODIMP -Event::GetIsTrusted(bool* aIsTrusted) -{ - *aIsTrusted = IsTrusted(); - return NS_OK; -} - -NS_IMETHODIMP +void Event::PreventDefault() { // This method is called only from C++ code which must handle default action // of this event. So, pass true always. PreventDefaultInternal(true); - return NS_OK; } void @@ -603,47 +534,38 @@ Event::InitEvent(const nsAString& aEventTypeArg, mEvent->mOriginalTarget = nullptr; } -NS_IMETHODIMP +void Event::DuplicatePrivateData() { NS_ASSERTION(mEvent, "No WidgetEvent for Event duplication!"); if (mEventIsInternal) { - return NS_OK; + return; } mEvent = mEvent->Duplicate(); mPresContext = nullptr; mEventIsInternal = true; mPrivateDataDuplicated = true; - - return NS_OK; } -NS_IMETHODIMP -Event::SetTarget(nsIDOMEventTarget* aTarget) +void +Event::SetTarget(EventTarget* aTarget) { - mEvent->mTarget = do_QueryInterface(aTarget); - return NS_OK; + mEvent->mTarget = aTarget; } -NS_IMETHODIMP_(bool) +bool Event::IsDispatchStopped() { return mEvent->PropagationStopped(); } -NS_IMETHODIMP_(WidgetEvent*) +WidgetEvent* Event::WidgetEventPtr() { return mEvent; } -NS_IMETHODIMP_(Event*) -Event::InternalDOMEvent() -{ - return this; -} - // return true if eventName is contained within events, delimited by // spaces static bool @@ -686,13 +608,13 @@ PopupAllowedForEvent(const char *eventName) // static PopupControlState -Event::GetEventPopupControlState(WidgetEvent* aEvent, nsIDOMEvent* aDOMEvent) +Event::GetEventPopupControlState(WidgetEvent* aEvent, Event* aDOMEvent) { // generally if an event handler is running, new windows are disallowed. // check for exceptions: PopupControlState abuse = openAbused; - if (aDOMEvent && aDOMEvent->InternalDOMEvent()->GetWantsPopupControlCheck()) { + if (aDOMEvent && aDOMEvent->GetWantsPopupControlCheck()) { nsAutoString type; aDOMEvent->GetType(type); if (PopupAllowedForEvent(NS_ConvertUTF16toUTF8(type).get())) { @@ -1146,18 +1068,7 @@ Event::TimeStamp() workerPrivate->GetRandomTimelineSeed()); } -NS_IMETHODIMP -Event::GetDefaultPrevented(bool* aReturn) -{ - NS_ENSURE_ARG_POINTER(aReturn); - // This method must be called by only event handlers implemented by C++. - // Then, the handlers must handle default action. So, this method don't need - // to check if preventDefault() has been called by content or chrome. - *aReturn = DefaultPrevented(); - return NS_OK; -} - -NS_IMETHODIMP_(void) +void Event::Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType) { if (aSerializeInterfaceType) { @@ -1176,7 +1087,7 @@ Event::Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType) // No timestamp serialization for now! } -NS_IMETHODIMP_(bool) +bool Event::Deserialize(const IPC::Message* aMsg, PickleIterator* aIter) { nsString type; @@ -1201,7 +1112,7 @@ Event::Deserialize(const IPC::Message* aMsg, PickleIterator* aIter) return true; } -NS_IMETHODIMP_(void) +void Event::SetOwner(EventTarget* aOwner) { mOwner = nullptr; @@ -1258,23 +1169,6 @@ Event::GetWidgetEventType(WidgetEvent* aEvent, nsAString& aType) aType.Truncate(); } -NS_IMETHODIMP -Event::GetCancelBubble(bool* aCancelBubble) -{ - NS_ENSURE_ARG_POINTER(aCancelBubble); - *aCancelBubble = CancelBubble(); - return NS_OK; -} - -NS_IMETHODIMP -Event::SetCancelBubble(bool aCancelBubble) -{ - if (aCancelBubble) { - mEvent->StopPropagation(); - } - return NS_OK; -} - } // namespace dom } // namespace mozilla diff --git a/dom/events/Event.h b/dom/events/Event.h index 605f8100adad..19516579f706 100755 --- a/dom/events/Event.h +++ b/dom/events/Event.h @@ -9,7 +9,6 @@ #include "mozilla/Attributes.h" #include "mozilla/BasicEvents.h" -#include "nsIDOMEvent.h" #include "nsISupports.h" #include "nsCOMPtr.h" #include "nsPIDOMWindow.h" @@ -23,8 +22,12 @@ #include "nsIGlobalObject.h" class nsIContent; -class nsIDOMEventTarget; class nsPresContext; +class PickleIterator; + +namespace IPC { +class Message; +} // namespace IPC namespace mozilla { namespace dom { @@ -47,10 +50,17 @@ class XULCommandEvent; #include "mozilla/dom/GeneratedEventList.h" #undef GENERATED_EVENT -class Event : public nsIDOMEvent, - public nsWrapperCache +// IID for Event +#define NS_EVENT_IID \ + { 0x71139716, 0x4d91, 0x4dee, \ + { 0xba, 0xf9, 0xe3, 0x3b, 0x80, 0xc1, 0x61, 0x61 } } + +class Event : public nsISupports + , public nsWrapperCache { public: + NS_DECLARE_STATIC_IID_ACCESSOR(NS_EVENT_IID) + Event(EventTarget* aOwner, nsPresContext* aPresContext, WidgetEvent* aEvent); @@ -65,24 +75,6 @@ private: WidgetEvent* aEvent); public: - static Event* FromSupports(nsISupports* aSupports) - { - nsIDOMEvent* event = - static_cast(aSupports); -#ifdef DEBUG - { - nsCOMPtr target_qi = - do_QueryInterface(aSupports); - - // If this assertion fires the QI implementation for the object in - // question doesn't use the nsIDOMEvent pointer as the - // nsISupports pointer. That must be fixed, or we'll crash... - MOZ_ASSERT(target_qi == event, "Uh, fix QI!"); - } -#endif - return static_cast(event); - } - NS_DECL_CYCLE_COLLECTING_ISUPPORTS NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Event) @@ -155,8 +147,18 @@ public: return nullptr; } - // nsIDOMEvent Interface - NS_DECL_NSIDOMEVENT + void InitEvent(const nsAString& aEventTypeArg, + bool aCanBubbleArg, + bool aCancelableArg); + void SetTarget(EventTarget* aTarget); + virtual void DuplicatePrivateData(); + bool IsDispatchStopped(); + WidgetEvent* WidgetEventPtr(); + virtual void Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType); + virtual bool Deserialize(const IPC::Message* aMsg, PickleIterator* aIter); + void SetOwner(EventTarget* aOwner); + void StopCrossProcessForwarding(); + void SetTrusted(bool aTrusted); void InitPresContextData(nsPresContext* aPresContext); @@ -164,7 +166,7 @@ public: bool Init(EventTarget* aGlobal); static PopupControlState GetEventPopupControlState(WidgetEvent* aEvent, - nsIDOMEvent* aDOMEvent = nullptr); + Event* aDOMEvent = nullptr); static void PopupAllowedEventsChanged(); @@ -196,8 +198,7 @@ public: const EventInit& aParam, ErrorResult& aRv); - // Implemented as xpidl method - // void GetType(nsString& aRetval) {} + void GetType(nsAString& aType) const; EventTarget* GetTarget() const; static bool IsSrcElementEnabled(JSContext* /* unused */, JSObject* /* unused */); @@ -207,11 +208,9 @@ public: uint16_t EventPhase() const; - // xpidl implementation - // void StopPropagation(); + void StopPropagation(); - // xpidl implementation - // void StopImmediatePropagation(); + void StopImmediatePropagation(); bool Bubbles() const { @@ -232,9 +231,15 @@ public: { return mEvent->PropagationStopped(); } + void SetCancelBubble(bool aCancelBubble) + { + if (aCancelBubble) { + mEvent->StopPropagation(); + } + } - // xpidl implementation - // void PreventDefault(); + // For C++ consumers only! + void PreventDefault(); // You MUST NOT call PreventDefault(JSContext*, CallerType) from C++ code. A // call of this method always sets Event.defaultPrevented true for web @@ -358,14 +363,14 @@ protected: * Notable requirements: * - The original & overriding messages must be known (not eUnidentifiedEvent). * - The original & overriding messages must be different. - * - The passed-in nsIDOMEvent must outlive this RAII helper. + * - The passed-in Event must outlive this RAII helper. */ class MOZ_RAII EventMessageAutoOverride { public: - explicit EventMessageAutoOverride(nsIDOMEvent* aEvent, + explicit EventMessageAutoOverride(Event* aEvent, EventMessage aOverridingMessage) - : mEvent(aEvent->InternalDOMEvent()), + : mEvent(aEvent), mOrigMessage(mEvent->mEvent->mMessage) { MOZ_ASSERT(aOverridingMessage != mOrigMessage, @@ -395,8 +400,8 @@ protected: class MOZ_STACK_CLASS WantsPopupControlCheck { public: - explicit WantsPopupControlCheck(nsIDOMEvent* aEvent) : - mEvent(aEvent->InternalDOMEvent()) + explicit WantsPopupControlCheck(Event* aEvent) : + mEvent(aEvent) { mOriginalWantsPopupControlCheck = mEvent->GetWantsPopupControlCheck(); mEvent->SetWantsPopupControlCheck(mEvent->IsTrusted()); @@ -412,21 +417,11 @@ private: bool mOriginalWantsPopupControlCheck; }; +NS_DEFINE_STATIC_IID_ACCESSOR(Event, NS_EVENT_IID) + } // namespace dom } // namespace mozilla -inline nsISupports* -ToSupports(mozilla::dom::Event* e) -{ - return static_cast(e); -} - -inline nsISupports* -ToCanonicalSupports(mozilla::dom::Event* e) -{ - return static_cast(e); -} - already_AddRefed NS_NewDOMEvent(mozilla::dom::EventTarget* aOwner, nsPresContext* aPresContext, diff --git a/dom/events/EventDispatcher.cpp b/dom/events/EventDispatcher.cpp index aa6026622372..eda2a5f31a5c 100644 --- a/dom/events/EventDispatcher.cpp +++ b/dom/events/EventDispatcher.cpp @@ -660,7 +660,7 @@ MayRetargetToChromeIfCanNotHandleEvent( EventDispatcher::Dispatch(nsISupports* aTarget, nsPresContext* aPresContext, WidgetEvent* aEvent, - nsIDOMEvent* aDOMEvent, + Event* aDOMEvent, nsEventStatus* aEventStatus, EventDispatchingCallback* aCallback, nsTArray* aTargets) @@ -809,7 +809,7 @@ EventDispatcher::Dispatch(nsISupports* aTarget, return NS_ERROR_FAILURE; } - // Make sure that nsIDOMEvent::target and nsIDOMEvent::originalTarget + // Make sure that Event::target and Event::originalTarget // point to the last item in the chain. if (!aEvent->mTarget) { // Note, CurrentTarget() points always to the object returned by @@ -987,7 +987,7 @@ EventDispatcher::Dispatch(nsISupports* aTarget, /* static */ nsresult EventDispatcher::DispatchDOMEvent(nsISupports* aTarget, WidgetEvent* aEvent, - nsIDOMEvent* aDOMEvent, + Event* aDOMEvent, nsPresContext* aPresContext, nsEventStatus* aEventStatus) { @@ -1000,7 +1000,7 @@ EventDispatcher::DispatchDOMEvent(nsISupports* aTarget, innerEvent->mTarget = nullptr; innerEvent->mOriginalTarget = nullptr; } else { - aDOMEvent->GetIsTrusted(&dontResetTrusted); + dontResetTrusted = aDOMEvent->IsTrusted(); } if (!dontResetTrusted) { diff --git a/dom/events/EventDispatcher.h b/dom/events/EventDispatcher.h index 435768886caa..71229a2db1c4 100644 --- a/dom/events/EventDispatcher.h +++ b/dom/events/EventDispatcher.h @@ -17,7 +17,6 @@ #undef CreateEvent class nsIContent; -class nsIDOMEvent; class nsPresContext; template class nsCOMArray; @@ -53,7 +52,7 @@ class EventChainVisitor public: EventChainVisitor(nsPresContext* aPresContext, WidgetEvent* aEvent, - nsIDOMEvent* aDOMEvent, + dom::Event* aDOMEvent, nsEventStatus aEventStatus = nsEventStatus_eIgnore) : mPresContext(aPresContext) , mEvent(aEvent) @@ -77,7 +76,7 @@ public: * The DOM Event assiciated with the mEvent. Possibly nullptr if a DOM Event * is not (yet) created. */ - nsIDOMEvent* mDOMEvent; + dom::Event* mDOMEvent; /** * The status of the event. @@ -113,7 +112,7 @@ class EventChainPreVisitor : public EventChainVisitor public: EventChainPreVisitor(nsPresContext* aPresContext, WidgetEvent* aEvent, - nsIDOMEvent* aDOMEvent, + dom::Event* aDOMEvent, nsEventStatus aEventStatus, bool aIsInAnon, dom::EventTarget* aTargetInKnownToBeHandledScope) @@ -327,7 +326,7 @@ public: static nsresult Dispatch(nsISupports* aTarget, nsPresContext* aPresContext, WidgetEvent* aEvent, - nsIDOMEvent* aDOMEvent = nullptr, + dom::Event* aDOMEvent = nullptr, nsEventStatus* aEventStatus = nullptr, EventDispatchingCallback* aCallback = nullptr, nsTArray* aTargets = nullptr); @@ -338,11 +337,11 @@ public: * (aEvent can then be nullptr) and (if aDOMEvent is not |trusted| already), * the |trusted| flag is set based on the UniversalXPConnect capability. * Otherwise this works like EventDispatcher::Dispatch. - * @note Use this method when dispatching nsIDOMEvent. + * @note Use this method when dispatching a dom::Event. */ static nsresult DispatchDOMEvent(nsISupports* aTarget, WidgetEvent* aEvent, - nsIDOMEvent* aDOMEvent, + dom::Event* aDOMEvent, nsPresContext* aPresContext, nsEventStatus* aEventStatus); diff --git a/dom/events/EventListenerManager.cpp b/dom/events/EventListenerManager.cpp index f6d0c93e76cb..fba256bca3f2 100644 --- a/dom/events/EventListenerManager.cpp +++ b/dom/events/EventListenerManager.cpp @@ -1093,7 +1093,7 @@ EventListenerManager::CompileEventHandlerInternal(Listener* aListener, nsresult EventListenerManager::HandleEventSubType(Listener* aListener, - nsIDOMEvent* aDOMEvent, + Event* aDOMEvent, EventTarget* aCurrentTarget) { nsresult result = NS_OK; @@ -1111,14 +1111,14 @@ EventListenerManager::HandleEventSubType(Listener* aListener, if (NS_SUCCEEDED(result)) { nsAutoMicroTask mt; - // nsIDOMEvent::currentTarget is set in EventDispatcher. + // Event::currentTarget is set in EventDispatcher. if (listenerHolder.HasWebIDLCallback()) { ErrorResult rv; listenerHolder.GetWebIDLCallback()-> - HandleEvent(aCurrentTarget, *(aDOMEvent->InternalDOMEvent()), rv); + HandleEvent(aCurrentTarget, *aDOMEvent, rv); result = rv.StealNSResult(); } else { - result = listenerHolder.GetXPCOMCallback()->HandleEvent(aDOMEvent); + result = listenerHolder.GetXPCOMCallback()-> HandleEvent(aDOMEvent); } } @@ -1166,7 +1166,7 @@ EventListenerManager::GetLegacyEventMessage(EventMessage aEventMessage) const void EventListenerManager::HandleEventInternal(nsPresContext* aPresContext, WidgetEvent* aEvent, - nsIDOMEvent** aDOMEvent, + Event** aDOMEvent, EventTarget* aCurrentTarget, nsEventStatus* aEventStatus) { @@ -1241,8 +1241,7 @@ EventListenerManager::HandleEventInternal(nsPresContext* aPresContext, needsEndEventMarker = true; nsAutoString typeStr; (*aDOMEvent)->GetType(typeStr); - uint16_t phase; - (*aDOMEvent)->GetEventPhase(&phase); + uint16_t phase = (*aDOMEvent)->EventPhase(); timelines->AddMarkerForDocShell(docShell, Move( MakeUnique( typeStr, phase, MarkerTracingType::START))); @@ -1277,8 +1276,7 @@ EventListenerManager::HandleEventInternal(nsPresContext* aPresContext, rv = HandleEventSubType(listener, *aDOMEvent, aCurrentTarget); TimeStamp endTime = TimeStamp::Now(); - uint16_t phase; - (*aDOMEvent)->GetEventPhase(&phase); + uint16_t phase = (*aDOMEvent)->EventPhase(); profiler_add_marker( "DOMEvent", MakeUnique(typeStr, phase, diff --git a/dom/events/EventListenerManager.h b/dom/events/EventListenerManager.h index 7ac5e0181ad1..bda7de3120a7 100644 --- a/dom/events/EventListenerManager.h +++ b/dom/events/EventListenerManager.h @@ -18,7 +18,6 @@ #include "nsTObserverArray.h" class nsIDocShell; -class nsIDOMEvent; class nsIEventListenerInfo; class nsPIDOMWindowInner; class JSTracer; @@ -33,6 +32,7 @@ class ELMCreationDetector; class EventListenerManager; namespace dom { +class Event; class EventTarget; class Element; } // namespace dom @@ -367,7 +367,7 @@ public: void HandleEvent(nsPresContext* aPresContext, WidgetEvent* aEvent, - nsIDOMEvent** aDOMEvent, + dom::Event** aDOMEvent, dom::EventTarget* aCurrentTarget, nsEventStatus* aEventStatus) { @@ -497,12 +497,12 @@ public: protected: void HandleEventInternal(nsPresContext* aPresContext, WidgetEvent* aEvent, - nsIDOMEvent** aDOMEvent, + dom::Event** aDOMEvent, dom::EventTarget* aCurrentTarget, nsEventStatus* aEventStatus); nsresult HandleEventSubType(Listener* aListener, - nsIDOMEvent* aDOMEvent, + dom::Event* aDOMEvent, dom::EventTarget* aCurrentTarget); /** diff --git a/dom/events/EventListenerService.cpp b/dom/events/EventListenerService.cpp index e0f814b12f8d..8ab16e6ee58e 100644 --- a/dom/events/EventListenerService.cpp +++ b/dom/events/EventListenerService.cpp @@ -35,7 +35,7 @@ EventListenerChange::~EventListenerChange() { } -EventListenerChange::EventListenerChange(dom::EventTarget* aTarget) : +EventListenerChange::EventListenerChange(EventTarget* aTarget) : mTarget(aTarget) { } @@ -47,7 +47,7 @@ EventListenerChange::AddChangedListenerName(nsAtom* aEventName) } NS_IMETHODIMP -EventListenerChange::GetTarget(nsIDOMEventTarget** aTarget) +EventListenerChange::GetTarget(EventTarget** aTarget) { NS_ENSURE_ARG_POINTER(aTarget); NS_ADDREF(*aTarget = mTarget); @@ -214,7 +214,7 @@ EventListenerService::~EventListenerService() } NS_IMETHODIMP -EventListenerService::GetListenerInfoFor(nsIDOMEventTarget* aEventTarget, +EventListenerService::GetListenerInfoFor(EventTarget* aEventTarget, uint32_t* aCount, nsIEventListenerInfo*** aOutArray) { @@ -223,10 +223,7 @@ EventListenerService::GetListenerInfoFor(nsIDOMEventTarget* aEventTarget, *aOutArray = nullptr; nsCOMArray listenerInfos; - nsCOMPtr eventTarget = do_QueryInterface(aEventTarget); - NS_ENSURE_TRUE(eventTarget, NS_ERROR_NO_INTERFACE); - - EventListenerManager* elm = eventTarget->GetExistingListenerManager(); + EventListenerManager* elm = aEventTarget->GetExistingListenerManager(); if (elm) { elm->GetListenerInfo(&listenerInfos); } @@ -242,10 +239,10 @@ EventListenerService::GetListenerInfoFor(nsIDOMEventTarget* aEventTarget, } NS_IMETHODIMP -EventListenerService::GetEventTargetChainFor(nsIDOMEventTarget* aEventTarget, +EventListenerService::GetEventTargetChainFor(EventTarget* aEventTarget, bool aComposed, uint32_t* aCount, - nsIDOMEventTarget*** aOutArray) + EventTarget*** aOutArray) { *aCount = 0; *aOutArray = nullptr; @@ -262,8 +259,8 @@ EventListenerService::GetEventTargetChainFor(nsIDOMEventTarget* aEventTarget, } *aOutArray = - static_cast( - moz_xmalloc(sizeof(nsIDOMEventTarget*) * count)); + static_cast( + moz_xmalloc(sizeof(EventTarget*) * count)); NS_ENSURE_TRUE(*aOutArray, NS_ERROR_OUT_OF_MEMORY); for (int32_t i = 0; i < count; ++i) { @@ -275,14 +272,13 @@ EventListenerService::GetEventTargetChainFor(nsIDOMEventTarget* aEventTarget, } NS_IMETHODIMP -EventListenerService::HasListenersFor(nsIDOMEventTarget* aEventTarget, +EventListenerService::HasListenersFor(EventTarget* aEventTarget, const nsAString& aType, bool* aRetVal) { - nsCOMPtr eventTarget = do_QueryInterface(aEventTarget); - NS_ENSURE_TRUE(eventTarget, NS_ERROR_NO_INTERFACE); + NS_ENSURE_TRUE(aEventTarget, NS_ERROR_UNEXPECTED); - EventListenerManager* elm = eventTarget->GetExistingListenerManager(); + EventListenerManager* elm = aEventTarget->GetExistingListenerManager(); *aRetVal = elm && elm->HasListenersFor(aType); return NS_OK; } @@ -301,7 +297,7 @@ ToEventListener(JSContext* aCx, JS::Handle aValue) } NS_IMETHODIMP -EventListenerService::AddSystemEventListener(nsIDOMEventTarget *aTarget, +EventListenerService::AddSystemEventListener(EventTarget *aTarget, const nsAString& aType, JS::Handle aListener, bool aUseCapture, @@ -309,15 +305,14 @@ EventListenerService::AddSystemEventListener(nsIDOMEventTarget *aTarget, { NS_PRECONDITION(aTarget, "Missing target"); - nsCOMPtr eventTarget = do_QueryInterface(aTarget); - NS_ENSURE_TRUE(eventTarget, NS_ERROR_NO_INTERFACE); + NS_ENSURE_TRUE(aTarget, NS_ERROR_UNEXPECTED); RefPtr listener = ToEventListener(aCx, aListener); if (!listener) { return NS_ERROR_UNEXPECTED; } - EventListenerManager* manager = eventTarget->GetOrCreateListenerManager(); + EventListenerManager* manager = aTarget->GetOrCreateListenerManager(); NS_ENSURE_STATE(manager); EventListenerFlags flags = @@ -328,7 +323,7 @@ EventListenerService::AddSystemEventListener(nsIDOMEventTarget *aTarget, } NS_IMETHODIMP -EventListenerService::RemoveSystemEventListener(nsIDOMEventTarget *aTarget, +EventListenerService::RemoveSystemEventListener(EventTarget *aTarget, const nsAString& aType, JS::Handle aListener, bool aUseCapture, @@ -336,15 +331,14 @@ EventListenerService::RemoveSystemEventListener(nsIDOMEventTarget *aTarget, { NS_PRECONDITION(aTarget, "Missing target"); - nsCOMPtr eventTarget = do_QueryInterface(aTarget); - NS_ENSURE_TRUE(eventTarget, NS_ERROR_NO_INTERFACE); + NS_ENSURE_TRUE(aTarget, NS_ERROR_UNEXPECTED); RefPtr listener = ToEventListener(aCx, aListener); if (!listener) { return NS_ERROR_UNEXPECTED; } - EventListenerManager* manager = eventTarget->GetExistingListenerManager(); + EventListenerManager* manager = aTarget->GetExistingListenerManager(); if (manager) { EventListenerFlags flags = aUseCapture ? TrustedEventsAtSystemGroupCapture() : @@ -356,7 +350,7 @@ EventListenerService::RemoveSystemEventListener(nsIDOMEventTarget *aTarget, } NS_IMETHODIMP -EventListenerService::AddListenerForAllEvents(nsIDOMEventTarget* aTarget, +EventListenerService::AddListenerForAllEvents(EventTarget* aTarget, JS::Handle aListener, bool aUseCapture, bool aWantsUntrusted, @@ -365,15 +359,12 @@ EventListenerService::AddListenerForAllEvents(nsIDOMEventTarget* aTarget, { NS_ENSURE_STATE(aTarget); - nsCOMPtr eventTarget = do_QueryInterface(aTarget); - NS_ENSURE_TRUE(eventTarget, NS_ERROR_NO_INTERFACE); - RefPtr listener = ToEventListener(aCx, aListener); if (!listener) { return NS_ERROR_UNEXPECTED; } - EventListenerManager* manager = eventTarget->GetOrCreateListenerManager(); + EventListenerManager* manager = aTarget->GetOrCreateListenerManager(); NS_ENSURE_STATE(manager); manager->AddListenerForAllEvents(listener, aUseCapture, aWantsUntrusted, aSystemEventGroup); @@ -381,7 +372,7 @@ EventListenerService::AddListenerForAllEvents(nsIDOMEventTarget* aTarget, } NS_IMETHODIMP -EventListenerService::RemoveListenerForAllEvents(nsIDOMEventTarget* aTarget, +EventListenerService::RemoveListenerForAllEvents(EventTarget* aTarget, JS::Handle aListener, bool aUseCapture, bool aSystemEventGroup, @@ -389,15 +380,12 @@ EventListenerService::RemoveListenerForAllEvents(nsIDOMEventTarget* aTarget, { NS_ENSURE_STATE(aTarget); - nsCOMPtr eventTarget = do_QueryInterface(aTarget); - NS_ENSURE_TRUE(eventTarget, NS_ERROR_NO_INTERFACE); - RefPtr listener = ToEventListener(aCx, aListener); if (!listener) { return NS_ERROR_UNEXPECTED; } - EventListenerManager* manager = eventTarget->GetExistingListenerManager(); + EventListenerManager* manager = aTarget->GetExistingListenerManager(); if (manager) { manager->RemoveListenerForAllEvents(listener, aUseCapture, aSystemEventGroup); } diff --git a/dom/events/EventTarget.h b/dom/events/EventTarget.h index 82a0355391ca..2543ba9fb704 100644 --- a/dom/events/EventTarget.h +++ b/dom/events/EventTarget.h @@ -9,12 +9,13 @@ #include "mozilla/dom/BindingDeclarations.h" #include "mozilla/dom/Nullable.h" -#include "nsIDOMEventTarget.h" +#include "nsISupports.h" #include "nsWrapperCache.h" #include "nsAtom.h" class nsPIDOMWindowOuter; class nsIGlobalObject; +class nsIDOMEventListener; namespace mozilla { @@ -39,17 +40,12 @@ class GlobalObject; { 0xde651c36, 0x0053, 0x4c67, \ { 0xb1, 0x3d, 0x67, 0xb9, 0x40, 0xfc, 0x82, 0xe4 } } -class EventTarget : public nsIDOMEventTarget, +class EventTarget : public nsISupports, public nsWrapperCache { public: NS_DECLARE_STATIC_IID_ACCESSOR(NS_EVENTTARGET_IID) - static EventTarget* From(nsIDOMEventTarget* aTarget) - { - return static_cast(aTarget); - } - // WebIDL API static already_AddRefed Constructor(const GlobalObject& aGlobal, ErrorResult& aRv); diff --git a/dom/events/IMEContentObserver.cpp b/dom/events/IMEContentObserver.cpp index 3fd64d0d19b6..13105157fcea 100644 --- a/dom/events/IMEContentObserver.cpp +++ b/dom/events/IMEContentObserver.cpp @@ -364,7 +364,7 @@ IMEContentObserver::InitWithEditor(nsPresContext* aPresContext, } else { mRootContent = mEditableNode->GetSelectionRootContent(presShell); } - if (!mRootContent && mEditableNode->IsNodeOfType(nsINode::eDOCUMENT)) { + if (!mRootContent && mEditableNode->IsDocument()) { // The document node is editable, but there are no contents, this document // is not editable. return false; diff --git a/dom/events/JSEventHandler.cpp b/dom/events/JSEventHandler.cpp index aae6448d24e6..c1a79e4887b5 100644 --- a/dom/events/JSEventHandler.cpp +++ b/dom/events/JSEventHandler.cpp @@ -111,7 +111,7 @@ JSEventHandler::IsBlackForCC() } nsresult -JSEventHandler::HandleEvent(nsIDOMEvent* aEvent) +JSEventHandler::HandleEvent(Event* aEvent) { nsCOMPtr target = do_QueryInterface(mTarget); if (!target || !mTypedHandler.HasEventHandler() || @@ -119,8 +119,7 @@ JSEventHandler::HandleEvent(nsIDOMEvent* aEvent) return NS_ERROR_FAILURE; } - Event* event = aEvent->InternalDOMEvent(); - bool isMainThread = event->IsMainThreadEvent(); + bool isMainThread = aEvent->IsMainThreadEvent(); bool isChromeHandler = isMainThread ? nsContentUtils::ObjectPrincipal( @@ -139,7 +138,7 @@ JSEventHandler::HandleEvent(nsIDOMEvent* aEvent) Optional> error; NS_ENSURE_TRUE(aEvent, NS_ERROR_UNEXPECTED); - ErrorEvent* scriptEvent = aEvent->InternalDOMEvent()->AsErrorEvent(); + ErrorEvent* scriptEvent = aEvent->AsErrorEvent(); if (scriptEvent) { scriptEvent->GetMessage(errorMsg); msgOrEvent.SetAsString().ShareOrDependUpon(errorMsg); @@ -156,7 +155,7 @@ JSEventHandler::HandleEvent(nsIDOMEvent* aEvent) error.Construct(RootingCx()); scriptEvent->GetError(&error.Value()); } else { - msgOrEvent.SetAsEvent() = aEvent->InternalDOMEvent(); + msgOrEvent.SetAsEvent() = aEvent; } RefPtr handler = @@ -171,7 +170,7 @@ JSEventHandler::HandleEvent(nsIDOMEvent* aEvent) if (retval.isBoolean() && retval.toBoolean() == bool(scriptEvent)) { - event->PreventDefaultInternal(isChromeHandler); + aEvent->PreventDefaultInternal(isChromeHandler); } return NS_OK; } @@ -183,16 +182,16 @@ JSEventHandler::HandleEvent(nsIDOMEvent* aEvent) mTypedHandler.OnBeforeUnloadEventHandler(); ErrorResult rv; nsString retval; - handler->Call(mTarget, *(aEvent->InternalDOMEvent()), retval, rv); + handler->Call(mTarget, *aEvent, retval, rv); if (rv.Failed()) { return rv.StealNSResult(); } - BeforeUnloadEvent* beforeUnload = event->AsBeforeUnloadEvent(); + BeforeUnloadEvent* beforeUnload = aEvent->AsBeforeUnloadEvent(); NS_ENSURE_STATE(beforeUnload); if (!DOMStringIsNull(retval)) { - event->PreventDefaultInternal(isChromeHandler); + aEvent->PreventDefaultInternal(isChromeHandler); nsAutoString text; beforeUnload->GetReturnValue(text); @@ -212,14 +211,14 @@ JSEventHandler::HandleEvent(nsIDOMEvent* aEvent) ErrorResult rv; RefPtr handler = mTypedHandler.NormalEventHandler(); JS::Rooted retval(RootingCx()); - handler->Call(mTarget, *(aEvent->InternalDOMEvent()), &retval, rv); + handler->Call(mTarget, *aEvent, &retval, rv); if (rv.Failed()) { return rv.StealNSResult(); } // If the handler returned false, then prevent default. if (retval.isBoolean() && !retval.toBoolean()) { - event->PreventDefaultInternal(isChromeHandler); + aEvent->PreventDefaultInternal(isChromeHandler); } return NS_OK; diff --git a/dom/events/KeyboardEvent.cpp b/dom/events/KeyboardEvent.cpp index 6335bb2da552..407532c6a823 100644 --- a/dom/events/KeyboardEvent.cpp +++ b/dom/events/KeyboardEvent.cpp @@ -331,7 +331,7 @@ already_AddRefed KeyboardEvent::GetDocument() { nsCOMPtr doc; - nsCOMPtr eventTarget = InternalDOMEvent()->GetTarget(); + nsCOMPtr eventTarget = GetTarget(); if (eventTarget) { nsCOMPtr win = diff --git a/dom/events/NotifyPaintEvent.cpp b/dom/events/NotifyPaintEvent.cpp index 60b785ec012a..4bd6b49a613d 100644 --- a/dom/events/NotifyPaintEvent.cpp +++ b/dom/events/NotifyPaintEvent.cpp @@ -89,7 +89,7 @@ NotifyPaintEvent::PaintRequests(SystemCallerGuarantee) return requests.forget(); } -NS_IMETHODIMP_(void) +void NotifyPaintEvent::Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType) { @@ -106,7 +106,7 @@ NotifyPaintEvent::Serialize(IPC::Message* aMsg, } } -NS_IMETHODIMP_(bool) +bool NotifyPaintEvent::Deserialize(const IPC::Message* aMsg, PickleIterator* aIter) { NS_ENSURE_TRUE(Event::Deserialize(aMsg, aIter), false); diff --git a/dom/events/NotifyPaintEvent.h b/dom/events/NotifyPaintEvent.h index 845a22363fc7..515a9d189d39 100644 --- a/dom/events/NotifyPaintEvent.h +++ b/dom/events/NotifyPaintEvent.h @@ -34,8 +34,8 @@ public: NS_INLINE_DECL_REFCOUNTING_INHERITED(NotifyPaintEvent, Event) - NS_IMETHOD_(void) Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType) override; - NS_IMETHOD_(bool) Deserialize(const IPC::Message* aMsg, PickleIterator* aIter) override; + void Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType) override; + bool Deserialize(const IPC::Message* aMsg, PickleIterator* aIter) override; virtual JSObject* WrapObjectInternal(JSContext* aCx, JS::Handle aGivenProto) override { diff --git a/dom/events/PaintRequest.h b/dom/events/PaintRequest.h index 9d2d1b2081ad..57bcc472eccf 100644 --- a/dom/events/PaintRequest.h +++ b/dom/events/PaintRequest.h @@ -8,8 +8,9 @@ #define mozilla_dom_PaintRequest_h_ #include "nsPresContext.h" -#include "nsIDOMEvent.h" #include "mozilla/Attributes.h" +#include "mozilla/RefPtr.h" +#include "mozilla/dom/Event.h" #include "nsWrapperCache.h" namespace mozilla { @@ -21,7 +22,7 @@ class PaintRequest final : public nsISupports , public nsWrapperCache { public: - explicit PaintRequest(nsIDOMEvent* aParent) + explicit PaintRequest(Event* aParent) : mParent(aParent) { } @@ -31,7 +32,7 @@ public: virtual JSObject* WrapObject(JSContext* aCx, JS::Handle aGivenProto) override; - nsIDOMEvent* GetParentObject() const + Event* GetParentObject() const { return mParent; } @@ -48,7 +49,7 @@ public: private: ~PaintRequest() {} - nsCOMPtr mParent; + RefPtr mParent; nsRect mRequest; }; @@ -56,7 +57,7 @@ class PaintRequestList final : public nsISupports, public nsWrapperCache { public: - explicit PaintRequestList(nsIDOMEvent *aParent) : mParent(aParent) + explicit PaintRequestList(Event *aParent) : mParent(aParent) { } @@ -96,7 +97,7 @@ private: ~PaintRequestList() {} nsTArray< RefPtr > mArray; - nsCOMPtr mParent; + RefPtr mParent; }; } // namespace dom diff --git a/dom/events/PointerEventHandler.cpp b/dom/events/PointerEventHandler.cpp index cb97dccbf53d..75cc53aecb9d 100644 --- a/dom/events/PointerEventHandler.cpp +++ b/dom/events/PointerEventHandler.cpp @@ -645,7 +645,7 @@ PointerEventHandler::DispatchGotOrLostPointerCaptureEvent( event = PointerEvent::Constructor(aCaptureTarget, NS_LITERAL_STRING("lostpointercapture"), init); - targetDoc->DispatchEvent(*event->InternalDOMEvent()); + targetDoc->DispatchEvent(*event); return; } nsEventStatus status = nsEventStatus_eIgnore; diff --git a/dom/events/ScrollAreaEvent.cpp b/dom/events/ScrollAreaEvent.cpp index 7049ee65e425..218c995e89a5 100644 --- a/dom/events/ScrollAreaEvent.cpp +++ b/dom/events/ScrollAreaEvent.cpp @@ -48,7 +48,7 @@ ScrollAreaEvent::InitScrollAreaEvent(const nsAString& aEventType, mClientArea->SetRect(aX, aY, aWidth, aHeight); } -NS_IMETHODIMP_(void) +void ScrollAreaEvent::Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType) { @@ -64,7 +64,7 @@ ScrollAreaEvent::Serialize(IPC::Message* aMsg, IPC::WriteParam(aMsg, Height()); } -NS_IMETHODIMP_(bool) +bool ScrollAreaEvent::Deserialize(const IPC::Message* aMsg, PickleIterator* aIter) { NS_ENSURE_TRUE(Event::Deserialize(aMsg, aIter), false); diff --git a/dom/events/ScrollAreaEvent.h b/dom/events/ScrollAreaEvent.h index f8f2ac6f87e8..926c2a8c6dcd 100644 --- a/dom/events/ScrollAreaEvent.h +++ b/dom/events/ScrollAreaEvent.h @@ -26,8 +26,8 @@ public: NS_DECL_ISUPPORTS_INHERITED NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ScrollAreaEvent, UIEvent) - NS_IMETHOD_(void) Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType) override; - NS_IMETHOD_(bool) Deserialize(const IPC::Message* aMsg, PickleIterator* aIter) override; + void Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType) override; + bool Deserialize(const IPC::Message* aMsg, PickleIterator* aIter) override; virtual JSObject* WrapObjectInternal(JSContext* aCx, JS::Handle aGivenProto) override { diff --git a/dom/events/UIEvent.cpp b/dom/events/UIEvent.cpp index dc96c839c741..b9580d43db23 100644 --- a/dom/events/UIEvent.cpp +++ b/dom/events/UIEvent.cpp @@ -264,7 +264,7 @@ UIEvent::GetLayerPoint() const nsPresContext::AppUnitsToIntCSSPixels(pt.y)); } -NS_IMETHODIMP +void UIEvent::DuplicatePrivateData() { mClientPoint = @@ -277,16 +277,15 @@ UIEvent::DuplicatePrivateData() // GetScreenPoint converts mEvent->mRefPoint to right coordinates. CSSIntPoint screenPoint = Event::GetScreenCoords(mPresContext, mEvent, mEvent->mRefPoint); - nsresult rv = Event::DuplicatePrivateData(); - if (NS_SUCCEEDED(rv)) { - CSSToLayoutDeviceScale scale = mPresContext ? mPresContext->CSSToDevPixelScale() - : CSSToLayoutDeviceScale(1); - mEvent->mRefPoint = RoundedToInt(screenPoint * scale); - } - return rv; + + Event::DuplicatePrivateData(); + + CSSToLayoutDeviceScale scale = mPresContext ? mPresContext->CSSToDevPixelScale() + : CSSToLayoutDeviceScale(1); + mEvent->mRefPoint = RoundedToInt(screenPoint * scale); } -NS_IMETHODIMP_(void) +void UIEvent::Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType) { if (aSerializeInterfaceType) { @@ -298,7 +297,7 @@ UIEvent::Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType) IPC::WriteParam(aMsg, Detail()); } -NS_IMETHODIMP_(bool) +bool UIEvent::Deserialize(const IPC::Message* aMsg, PickleIterator* aIter) { NS_ENSURE_TRUE(Event::Deserialize(aMsg, aIter), false); diff --git a/dom/events/UIEvent.h b/dom/events/UIEvent.h index 6ef0f22fdae1..12b88bc737e5 100644 --- a/dom/events/UIEvent.h +++ b/dom/events/UIEvent.h @@ -29,10 +29,9 @@ public: NS_DECL_ISUPPORTS_INHERITED NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(UIEvent, Event) - NS_IMETHOD DuplicatePrivateData() override; - NS_IMETHOD_(void) Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType) override; - NS_IMETHOD_(bool) Deserialize(const IPC::Message* aMsg, PickleIterator* aIter) override; - + void DuplicatePrivateData() override; + void Serialize(IPC::Message* aMsg, bool aSerializeInterfaceType) override; + bool Deserialize(const IPC::Message* aMsg, PickleIterator* aIter) override; static already_AddRefed Constructor(const GlobalObject& aGlobal, const nsAString& aType, diff --git a/dom/events/XULCommandEvent.h b/dom/events/XULCommandEvent.h index 8741134fce2c..498aca740164 100644 --- a/dom/events/XULCommandEvent.h +++ b/dom/events/XULCommandEvent.h @@ -9,6 +9,7 @@ #ifndef mozilla_dom_XULCommandEvent_h_ #define mozilla_dom_XULCommandEvent_h_ +#include "mozilla/RefPtr.h" #include "mozilla/dom/UIEvent.h" #include "mozilla/dom/XULCommandEventBinding.h" @@ -43,8 +44,7 @@ public: already_AddRefed GetSourceEvent() { - RefPtr e = - mSourceEvent ? mSourceEvent->InternalDOMEvent() : nullptr; + RefPtr e = mSourceEvent; return e.forget(); } @@ -61,7 +61,7 @@ public: protected: ~XULCommandEvent() {} - nsCOMPtr mSourceEvent; + RefPtr mSourceEvent; uint16_t mInputSource; }; diff --git a/dom/events/nsIEventListenerService.idl b/dom/events/nsIEventListenerService.idl index 6009ae237812..3427154e215d 100644 --- a/dom/events/nsIEventListenerService.idl +++ b/dom/events/nsIEventListenerService.idl @@ -5,7 +5,8 @@ #include "nsISupports.idl" -interface nsIDOMEventTarget; +webidl EventTarget; + interface nsIArray; /** @@ -15,7 +16,7 @@ interface nsIArray; [scriptable, uuid(07222b02-da12-4cf4-b2f7-761da007a8d8)] interface nsIEventListenerChange : nsISupports { - readonly attribute nsIDOMEventTarget target; + readonly attribute EventTarget target; [noscript] readonly attribute uint32_t countOfEventListenerChangesAffectingAccessibility; @@ -65,7 +66,7 @@ interface nsIEventListenerService : nsISupports * Returns an array of nsIEventListenerInfo objects. * If aEventTarget doesn't have any listeners, this returns null. */ - void getListenerInfoFor(in nsIDOMEventTarget aEventTarget, + void getListenerInfoFor(in EventTarget aEventTarget, [optional] out unsigned long aCount, [retval, array, size_is(aCount)] out nsIEventListenerInfo aOutArray); @@ -78,23 +79,23 @@ interface nsIEventListenerService : nsISupports * @note Some events, especially 'load', may actually have a shorter * event target chain than what this methods returns. */ - void getEventTargetChainFor(in nsIDOMEventTarget aEventTarget, + void getEventTargetChainFor(in EventTarget aEventTarget, in boolean composed, [optional] out unsigned long aCount, [retval, array, size_is(aCount)] out - nsIDOMEventTarget aOutArray); + EventTarget aOutArray); /** * Returns true if a event target has any listener for the given type. */ - boolean hasListenersFor(in nsIDOMEventTarget aEventTarget, + boolean hasListenersFor(in EventTarget aEventTarget, in DOMString aType); /** * Add a system-group eventlistener to a event target. */ [implicit_jscontext] - void addSystemEventListener(in nsIDOMEventTarget target, + void addSystemEventListener(in EventTarget target, in DOMString type, in jsval listener, in boolean useCapture); @@ -103,20 +104,20 @@ interface nsIEventListenerService : nsISupports * Remove a system-group eventlistener from a event target. */ [implicit_jscontext] - void removeSystemEventListener(in nsIDOMEventTarget target, + void removeSystemEventListener(in EventTarget target, in DOMString type, in jsval listener, in boolean useCapture); [implicit_jscontext] - void addListenerForAllEvents(in nsIDOMEventTarget target, + void addListenerForAllEvents(in EventTarget target, in jsval listener, [optional] in boolean aUseCapture, [optional] in boolean aWantsUntrusted, [optional] in boolean aSystemEventGroup); [implicit_jscontext] - void removeListenerForAllEvents(in nsIDOMEventTarget target, + void removeListenerForAllEvents(in EventTarget target, in jsval listener, [optional] in boolean aUseCapture, [optional] in boolean aSystemEventGroup); diff --git a/dom/events/test/test_DataTransferItemList.html b/dom/events/test/test_DataTransferItemList.html index 9958c41ddd9d..e0866c8abdba 100644 --- a/dom/events/test/test_DataTransferItemList.html +++ b/dom/events/test/test_DataTransferItemList.html @@ -3,7 +3,7 @@ Tests for the DatTransferItemList object - + diff --git a/dom/events/test/test_bug617528.xul b/dom/events/test/test_bug617528.xul index bc17fd6c21d1..6ee007789e60 100644 --- a/dom/events/test/test_bug617528.xul +++ b/dom/events/test/test_bug617528.xul @@ -81,7 +81,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=617528 browser.removeEventListener("contextmenu", onContextMenu1, false); browser.addEventListener("contextmenu", onContextMenu2, false); - var shiftMask = Ci.nsIDOMEvent.SHIFT_MASK; + var shiftMask = Event.SHIFT_MASK; wu.sendMouseEvent("contextmenu", left, top, 2, 1, shiftMask); browser.removeEventListener("contextmenu", onContextMenu2, false); diff --git a/dom/fetch/Request.cpp b/dom/fetch/Request.cpp index 9f1971997754..0e3e7105707e 100644 --- a/dom/fetch/Request.cpp +++ b/dom/fetch/Request.cpp @@ -329,7 +329,7 @@ Request::Constructor(const GlobalObject& aGlobal, RequestCache fallbackCache = RequestCache::EndGuard_; if (aInput.IsUSVString()) { fallbackMode = RequestMode::Cors; - fallbackCredentials = RequestCredentials::Omit; + fallbackCredentials = RequestCredentials::Same_origin; fallbackCache = RequestCache::Default; } diff --git a/dom/gamepad/GamepadManager.cpp b/dom/gamepad/GamepadManager.cpp index 19597516d536..571de63b7a17 100644 --- a/dom/gamepad/GamepadManager.cpp +++ b/dom/gamepad/GamepadManager.cpp @@ -22,7 +22,6 @@ #include "nsAutoPtr.h" #include "nsContentUtils.h" #include "nsGlobalWindow.h" -#include "nsIDOMEvent.h" #include "nsIDOMDocument.h" #include "nsIDOMWindow.h" #include "nsIObserver.h" diff --git a/dom/html/HTMLButtonElement.cpp b/dom/html/HTMLButtonElement.cpp index b37fbdc86bf2..792f697e0f34 100644 --- a/dom/html/HTMLButtonElement.cpp +++ b/dom/html/HTMLButtonElement.cpp @@ -18,7 +18,6 @@ #include "nsIURL.h" #include "nsIFrame.h" #include "nsIFormControlFrame.h" -#include "nsIDOMEvent.h" #include "nsIDocument.h" #include "mozilla/ContentEvents.h" #include "mozilla/EventDispatcher.h" diff --git a/dom/html/HTMLCanvasElement.cpp b/dom/html/HTMLCanvasElement.cpp index 44c9ba80941f..a79b1997bb4b 100644 --- a/dom/html/HTMLCanvasElement.cpp +++ b/dom/html/HTMLCanvasElement.cpp @@ -17,6 +17,7 @@ #include "mozilla/CheckedInt.h" #include "mozilla/dom/CanvasCaptureMediaStream.h" #include "mozilla/dom/CanvasRenderingContext2D.h" +#include "mozilla/dom/Event.h" #include "mozilla/dom/File.h" #include "mozilla/dom/HTMLCanvasElementBinding.h" #include "mozilla/dom/MediaStreamTrack.h" @@ -375,7 +376,7 @@ HTMLCanvasElementObserver::Observe(nsISupports*, const char* aTopic, const char1 } NS_IMETHODIMP -HTMLCanvasElementObserver::HandleEvent(nsIDOMEvent* aEvent) +HTMLCanvasElementObserver::HandleEvent(Event* aEvent) { nsAutoString type; aEvent->GetType(type); diff --git a/dom/html/HTMLEmbedElement.h b/dom/html/HTMLEmbedElement.h index 8e0e8dc2681f..845bbf585783 100644 --- a/dom/html/HTMLEmbedElement.h +++ b/dom/html/HTMLEmbedElement.h @@ -29,7 +29,7 @@ public: virtual int32_t TabIndexDefault() override; #ifdef XP_MACOSX - // nsIDOMEventTarget + // EventTarget NS_IMETHOD PostHandleEvent(EventChainPostVisitor& aVisitor) override; #endif diff --git a/dom/html/HTMLInputElement.cpp b/dom/html/HTMLInputElement.cpp index 5a3d7cd01e78..072fe72bd4f7 100644 --- a/dom/html/HTMLInputElement.cpp +++ b/dom/html/HTMLInputElement.cpp @@ -55,7 +55,6 @@ #include "nsDateTimeControlFrame.h" #include "mozilla/PresState.h" -#include "nsIDOMEvent.h" #include "nsIDOMNodeList.h" #include "nsLinebreakConverter.h" //to strip out carriage returns #include "nsReadableUtils.h" diff --git a/dom/html/HTMLLinkElement.cpp b/dom/html/HTMLLinkElement.cpp index 93c07639049b..d51f99ea7650 100644 --- a/dom/html/HTMLLinkElement.cpp +++ b/dom/html/HTMLLinkElement.cpp @@ -19,7 +19,6 @@ #include "nsDOMTokenList.h" #include "nsIContentInlines.h" #include "nsIDocument.h" -#include "nsIDOMEvent.h" #include "nsINode.h" #include "nsIStyleSheetLinkingElement.h" #include "nsIURL.h" diff --git a/dom/html/HTMLMediaElement.cpp b/dom/html/HTMLMediaElement.cpp index ea023c972aae..ccf9e7d5063f 100644 --- a/dom/html/HTMLMediaElement.cpp +++ b/dom/html/HTMLMediaElement.cpp @@ -6532,12 +6532,6 @@ void HTMLMediaElement::NotifyShutdownEvent() AddRemoveSelfReference(); } -bool -HTMLMediaElement::IsNodeOfType(uint32_t aFlags) const -{ - return !(aFlags & ~eMEDIA); -} - void HTMLMediaElement::DispatchAsyncSourceError(nsIContent* aSourceElement) { LOG_EVENT(LogLevel::Debug, ("%p Queuing simple source error event", this)); diff --git a/dom/html/HTMLMediaElement.h b/dom/html/HTMLMediaElement.h index ce3ebc591347..116e5ff64637 100644 --- a/dom/html/HTMLMediaElement.h +++ b/dom/html/HTMLMediaElement.h @@ -379,8 +379,6 @@ public: void NotifyOutputTrackStopped(DOMMediaStream* aOwningStream, TrackID aDestinationTrackID); - virtual bool IsNodeOfType(uint32_t aFlags) const override; - /** * Returns the current load ID. Asynchronous events store the ID that was * current when they were enqueued, and if it has changed when they come to diff --git a/dom/html/HTMLObjectElement.h b/dom/html/HTMLObjectElement.h index 4e2e137db745..469eaa342985 100644 --- a/dom/html/HTMLObjectElement.h +++ b/dom/html/HTMLObjectElement.h @@ -32,7 +32,7 @@ public: virtual int32_t TabIndexDefault() override; #ifdef XP_MACOSX - // nsIDOMEventTarget + // EventTarget NS_IMETHOD PostHandleEvent(EventChainPostVisitor& aVisitor) override; // Helper methods static void OnFocusBlurPlugin(Element* aElement, bool aFocus); diff --git a/dom/html/HTMLSourceElement.cpp b/dom/html/HTMLSourceElement.cpp index c916f94be89e..cc3c6a462ecb 100644 --- a/dom/html/HTMLSourceElement.cpp +++ b/dom/html/HTMLSourceElement.cpp @@ -8,6 +8,7 @@ #include "mozilla/dom/HTMLSourceElementBinding.h" #include "mozilla/dom/HTMLImageElement.h" +#include "mozilla/dom/HTMLMediaElement.h" #include "mozilla/dom/ResponsiveImageSelector.h" #include "mozilla/dom/MediaList.h" #include "mozilla/dom/MediaSource.h" @@ -152,8 +153,7 @@ HTMLSourceElement::BindToTree(nsIDocument *aDocument, aCompileEventHandlers); NS_ENSURE_SUCCESS(rv, rv); - if (aParent && aParent->IsNodeOfType(nsINode::eMEDIA)) { - HTMLMediaElement* media = static_cast(aParent); + if (auto* media = HTMLMediaElement::FromNodeOrNull(aParent)) { media->NotifyAddedSource(); } diff --git a/dom/html/HTMLTrackElement.cpp b/dom/html/HTMLTrackElement.cpp index a6eaaabda3ff..1b98af2b10a6 100644 --- a/dom/html/HTMLTrackElement.cpp +++ b/dom/html/HTMLTrackElement.cpp @@ -25,7 +25,6 @@ #include "nsIContentPolicy.h" #include "nsIContentSecurityPolicy.h" #include "nsIDocument.h" -#include "nsIDOMEventTarget.h" #include "nsIHttpChannel.h" #include "nsIInterfaceRequestor.h" #include "nsILoadGroup.h" @@ -361,13 +360,14 @@ HTMLTrackElement::BindToTree(nsIDocument* aDocument, NS_ENSURE_SUCCESS(rv, rv); LOG(LogLevel::Debug, ("Track Element bound to tree.")); - if (!aParent || !aParent->IsNodeOfType(nsINode::eMEDIA)) { + auto* parent = HTMLMediaElement::FromNodeOrNull(aParent); + if (!parent) { return NS_OK; } // Store our parent so we can look up its frame for display. if (!mMediaParent) { - mMediaParent = static_cast(aParent); + mMediaParent = parent; // TODO: separate notification for 'alternate' tracks? mMediaParent->NotifyAddedSource(); diff --git a/dom/html/HTMLTrackElement.h b/dom/html/HTMLTrackElement.h index 0732c6535454..e7fcfb74f8d9 100644 --- a/dom/html/HTMLTrackElement.h +++ b/dom/html/HTMLTrackElement.h @@ -13,7 +13,6 @@ #include "nsCycleCollectionParticipant.h" #include "nsGenericHTMLElement.h" #include "nsGkAtoms.h" -#include "nsIDOMEventTarget.h" #include "nsIHttpChannel.h" class nsIContent; diff --git a/dom/html/ImageDocument.cpp b/dom/html/ImageDocument.cpp index ab18ff12ed8b..e291280314b8 100644 --- a/dom/html/ImageDocument.cpp +++ b/dom/html/ImageDocument.cpp @@ -8,6 +8,7 @@ #include "mozilla/ComputedStyle.h" #include "mozilla/dom/DOMPrefs.h" #include "mozilla/dom/Element.h" +#include "mozilla/dom/Event.h" #include "mozilla/dom/ImageDocumentBinding.h" #include "mozilla/dom/HTMLImageElement.h" #include "mozilla/dom/MouseEvent.h" @@ -17,7 +18,6 @@ #include "nsDocShell.h" #include "nsIDocumentInlines.h" #include "nsDOMTokenList.h" -#include "nsIDOMEvent.h" #include "nsIDOMEventListener.h" #include "nsIFrame.h" #include "nsGkAtoms.h" @@ -632,7 +632,7 @@ ImageDocument::OnLoadComplete(imgIRequest* aRequest, nsresult aStatus) } NS_IMETHODIMP -ImageDocument::HandleEvent(nsIDOMEvent* aEvent) +ImageDocument::HandleEvent(Event* aEvent) { nsAutoString eventType; aEvent->GetType(eventType); @@ -644,7 +644,7 @@ ImageDocument::HandleEvent(nsIDOMEvent* aEvent) mShouldResize = true; if (mImageIsResized) { int32_t x = 0, y = 0; - MouseEvent* event = aEvent->InternalDOMEvent()->AsMouseEvent(); + MouseEvent* event = aEvent->AsMouseEvent(); if (event) { RefPtr img = HTMLImageElement::FromNode(mImageContent); diff --git a/dom/html/ImageDocument.h b/dom/html/ImageDocument.h index f6a3602799ff..ea4a87327d5d 100644 --- a/dom/html/ImageDocument.h +++ b/dom/html/ImageDocument.h @@ -44,7 +44,7 @@ public: NS_DECL_IMGINOTIFICATIONOBSERVER // nsIDOMEventListener - NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) override; + NS_DECL_NSIDOMEVENTLISTENER NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ImageDocument, MediaDocument) diff --git a/dom/html/TextTrackManager.cpp b/dom/html/TextTrackManager.cpp index 14b1030976a1..7c785453025f 100644 --- a/dom/html/TextTrackManager.cpp +++ b/dom/html/TextTrackManager.cpp @@ -289,7 +289,7 @@ TextTrackManager::UpdateCueDisplay() RefPtr jsCues = new nsVariantCC(); jsCues->SetAsArray(nsIDataType::VTYPE_INTERFACE, - &NS_GET_IID(nsIDOMEventTarget), + &NS_GET_IID(EventTarget), showingCues.Length(), static_cast(showingCues.Elements())); nsPIDOMWindowInner* window = mMediaElement->OwnerDoc()->GetInnerWindow(); @@ -460,7 +460,7 @@ TextTrackManager::GetTextTracksOfKind(TextTrackKind aTextTrackKind, } NS_IMETHODIMP -TextTrackManager::HandleEvent(nsIDOMEvent* aEvent) +TextTrackManager::HandleEvent(Event* aEvent) { if (!mTextTracks) { return NS_OK; diff --git a/dom/html/nsGenericHTMLElement.cpp b/dom/html/nsGenericHTMLElement.cpp index 212b06e218b4..e83e54be96c4 100644 --- a/dom/html/nsGenericHTMLElement.cpp +++ b/dom/html/nsGenericHTMLElement.cpp @@ -57,7 +57,6 @@ #include "nsString.h" #include "nsUnicharUtils.h" #include "nsGkAtoms.h" -#include "nsIDOMEvent.h" #include "nsDOMCSSDeclaration.h" #include "nsITextControlFrame.h" #include "nsIForm.h" diff --git a/dom/html/nsTextEditorState.cpp b/dom/html/nsTextEditorState.cpp index 2a3692171983..a58390c947b0 100644 --- a/dom/html/nsTextEditorState.cpp +++ b/dom/html/nsTextEditorState.cpp @@ -39,6 +39,7 @@ #include "nsIController.h" #include "mozilla/AutoRestore.h" #include "mozilla/TextEvents.h" +#include "mozilla/dom/Event.h" #include "mozilla/dom/ScriptSettings.h" #include "mozilla/dom/HTMLInputElement.h" #include "mozilla/dom/HTMLTextAreaElement.h" @@ -924,19 +925,13 @@ DoCommandCallback(Command aCommand, void* aData) } NS_IMETHODIMP -TextInputListener::HandleEvent(nsIDOMEvent* aEvent) +TextInputListener::HandleEvent(Event* aEvent) { - bool defaultPrevented = false; - nsresult rv = aEvent->GetDefaultPrevented(&defaultPrevented); - NS_ENSURE_SUCCESS(rv, rv); - if (defaultPrevented) { + if (aEvent->DefaultPrevented()) { return NS_OK; } - bool isTrusted = false; - rv = aEvent->GetIsTrusted(&isTrusted); - NS_ENSURE_SUCCESS(rv, rv); - if (!isTrusted) { + if (!aEvent->IsTrusted()) { return NS_OK; } diff --git a/dom/html/test/forms/test_autocompleteinfo.html b/dom/html/test/forms/test_autocompleteinfo.html index 39059b8321c7..82f65a5a1d2b 100644 --- a/dom/html/test/forms/test_autocompleteinfo.html +++ b/dom/html/test/forms/test_autocompleteinfo.html @@ -6,7 +6,7 @@ Test getAutocompleteInfo() on and diff --git a/editor/libeditor/tests/test_pasteImgTextarea.xul b/editor/libeditor/tests/test_pasteImgTextarea.xul index 5809d7f9fd60..436cb040d0eb 100644 --- a/editor/libeditor/tests/test_pasteImgTextarea.xul +++ b/editor/libeditor/tests/test_pasteImgTextarea.xul @@ -4,7 +4,7 @@ - + diff --git a/editor/libeditor/tests/test_selection_move_commands.html b/editor/libeditor/tests/test_selection_move_commands.html index af03bc95d053..0dcfadfa4735 100644 --- a/editor/libeditor/tests/test_selection_move_commands.html +++ b/editor/libeditor/tests/test_selection_move_commands.html @@ -2,7 +2,7 @@ Test for nsSelectionMoveCommands - + Mozilla Bug 454004 @@ -13,8 +13,8 @@ SimpleTest.requestFlakyTimeout("Legacy test, possibly no good reason"); var winUtils = SpecialPowers.getDOMWindowUtils(window); -function* setup() { - yield SpecialPowers.pushPrefEnv({set: [["general.smoothScroll", false]]}); +async function setup() { + await SpecialPowers.pushPrefEnv({set: [["general.smoothScroll", false]]}); winUtils.advanceTimeAndRefresh(100); } @@ -205,8 +205,8 @@ async function testRunner() { } } -spawn_task(setup) - .then(() => spawn_task(testRunner)) - .then(() => spawn_task(cleanup)) +setup() + .then(() => testRunner()) + .then(() => cleanup()) .catch(err => ok(false, err)); diff --git a/extensions/spellcheck/src/mozInlineSpellChecker.cpp b/extensions/spellcheck/src/mozInlineSpellChecker.cpp index b5d51a0afb80..1a005c412b2c 100644 --- a/extensions/spellcheck/src/mozInlineSpellChecker.cpp +++ b/extensions/spellcheck/src/mozInlineSpellChecker.cpp @@ -39,6 +39,7 @@ #include "mozilla/EditorUtils.h" #include "mozilla/Services.h" #include "mozilla/TextEditor.h" +#include "mozilla/dom/Event.h" #include "mozilla/dom/KeyboardEvent.h" #include "mozilla/dom/KeyboardEventBinding.h" #include "mozilla/dom/MouseEvent.h" @@ -53,7 +54,6 @@ #include "nsIDOMElement.h" #include "nsIDOMNode.h" #include "nsIDOMNodeList.h" -#include "nsIDOMEvent.h" #include "nsGenericHTMLElement.h" #include "nsRange.h" #include "nsIPlaintextEditor.h" @@ -1834,7 +1834,7 @@ mozInlineSpellChecker::HandleNavigationEvent(bool aForceWordSpellCheck, } NS_IMETHODIMP -mozInlineSpellChecker::HandleEvent(nsIDOMEvent* aEvent) +mozInlineSpellChecker::HandleEvent(Event* aEvent) { nsAutoString eventType; aEvent->GetType(eventType); @@ -1853,7 +1853,7 @@ mozInlineSpellChecker::HandleEvent(nsIDOMEvent* aEvent) } nsresult -mozInlineSpellChecker::OnBlur(nsIDOMEvent* aEvent) +mozInlineSpellChecker::OnBlur(Event* aEvent) { // force spellcheck on blur, for instance when tabbing out of a textbox HandleNavigationEvent(true); @@ -1861,9 +1861,9 @@ mozInlineSpellChecker::OnBlur(nsIDOMEvent* aEvent) } nsresult -mozInlineSpellChecker::OnMouseClick(nsIDOMEvent *aMouseEvent) +mozInlineSpellChecker::OnMouseClick(Event *aMouseEvent) { - MouseEvent* mouseEvent = aMouseEvent->InternalDOMEvent()->AsMouseEvent(); + MouseEvent* mouseEvent = aMouseEvent->AsMouseEvent(); NS_ENSURE_TRUE(mouseEvent, NS_OK); // ignore any errors from HandleNavigationEvent as we don't want to prevent @@ -1873,10 +1873,9 @@ mozInlineSpellChecker::OnMouseClick(nsIDOMEvent *aMouseEvent) } nsresult -mozInlineSpellChecker::OnKeyPress(nsIDOMEvent* aKeyEvent) +mozInlineSpellChecker::OnKeyPress(Event* aKeyEvent) { - RefPtr keyEvent = - aKeyEvent->InternalDOMEvent()->AsKeyboardEvent(); + RefPtr keyEvent = aKeyEvent->AsKeyboardEvent(); NS_ENSURE_TRUE(keyEvent, NS_OK); uint32_t keyCode = keyEvent->KeyCode(); diff --git a/extensions/spellcheck/src/mozInlineSpellChecker.h b/extensions/spellcheck/src/mozInlineSpellChecker.h index 18f80e191f99..de47bb4139f2 100644 --- a/extensions/spellcheck/src/mozInlineSpellChecker.h +++ b/extensions/spellcheck/src/mozInlineSpellChecker.h @@ -24,6 +24,10 @@ namespace mozilla { class EditorSpellCheck; class TextEditor; enum class EditAction : int32_t; + +namespace dom { +class Event; +} // namespace dom } // namespace mozilla class mozInlineSpellStatus @@ -190,9 +194,9 @@ public: // update the cached value whenever the list of available dictionaries changes static void UpdateCanEnableInlineSpellChecking(); - nsresult OnBlur(nsIDOMEvent* aEvent); - nsresult OnMouseClick(nsIDOMEvent* aMouseEvent); - nsresult OnKeyPress(nsIDOMEvent* aKeyEvent); + nsresult OnBlur(mozilla::dom::Event* aEvent); + nsresult OnMouseClick(mozilla::dom::Event* aMouseEvent); + nsresult OnKeyPress(mozilla::dom::Event* aKeyEvent); mozInlineSpellChecker(); diff --git a/extensions/spellcheck/tests/mochitest/test_bug1272623.html b/extensions/spellcheck/tests/mochitest/test_bug1272623.html index 6bf3ace66263..dd5caa566982 100644 --- a/extensions/spellcheck/tests/mochitest/test_bug1272623.html +++ b/extensions/spellcheck/tests/mochitest/test_bug1272623.html @@ -8,7 +8,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1272623 Test for Bug 1272623 - + diff --git a/gfx/2d/ScaledFontMac.cpp b/gfx/2d/ScaledFontMac.cpp index 64c236f98f04..5fd48c38e8ec 100644 --- a/gfx/2d/ScaledFontMac.cpp +++ b/gfx/2d/ScaledFontMac.cpp @@ -75,7 +75,8 @@ bool ScaledFontMac::sSymbolLookupDone = false; // Helper to create a CTFont from a CGFont, copying any variations that were // set on the original CGFont. static CTFontRef -CreateCTFontFromCGFontWithVariations(CGFontRef aCGFont, CGFloat aSize) +CreateCTFontFromCGFontWithVariations(CGFontRef aCGFont, CGFloat aSize, + bool aInstalledFont) { // Avoid calling potentially buggy variation APIs on pre-Sierra macOS // versions (see bug 1331683). @@ -85,30 +86,50 @@ CreateCTFontFromCGFontWithVariations(CGFontRef aCGFont, CGFloat aSize) // the extra work here -- and this seems to avoid Core Text crashiness // seen in bug 1454094. // - // So we only need to do this "the hard way" on Sierra; on other releases, - // just let the standard CTFont function do its thing. - if (!nsCocoaFeatures::OnSierraExactly()) { - return CTFontCreateWithGraphicsFont(aCGFont, aSize, nullptr, nullptr); - } + // However, for installed fonts it seems we DO need to copy the variations + // explicitly even on 10.13, otherwise fonts fail to render (as in bug + // 1455494) when non-default values are used. Fortunately, the crash + // mentioned above occurs with data fonts, not (AFAICT) with system- + // installed fonts. + // + // So we only need to do this "the hard way" on Sierra, and for installed + // fonts on HighSierra+; otherwise, just let the standard CTFont function + // do its thing. + // + // NOTE in case this ever needs further adjustment: there is similar logic + // in four places in the tree (sadly): + // CreateCTFontFromCGFontWithVariations in gfxMacFont.cpp + // CreateCTFontFromCGFontWithVariations in ScaledFontMac.cpp + // CreateCTFontFromCGFontWithVariations in cairo-quartz-font.c + // ctfont_create_exact_copy in SkFontHost_mac.cpp - CFDictionaryRef vars = CGFontCopyVariations(aCGFont); CTFontRef ctFont; - if (vars) { - CFDictionaryRef varAttr = - CFDictionaryCreate(nullptr, - (const void**)&kCTFontVariationAttribute, - (const void**)&vars, 1, - &kCFTypeDictionaryKeyCallBacks, - &kCFTypeDictionaryValueCallBacks); - CFRelease(vars); + if (nsCocoaFeatures::OnSierraExactly() || + (aInstalledFont && nsCocoaFeatures::OnHighSierraOrLater())) { + CFDictionaryRef vars = CGFontCopyVariations(aCGFont); + if (vars) { + CFDictionaryRef varAttr = + CFDictionaryCreate(nullptr, + (const void**)&kCTFontVariationAttribute, + (const void**)&vars, 1, + &kCFTypeDictionaryKeyCallBacks, + &kCFTypeDictionaryValueCallBacks); + CFRelease(vars); - CTFontDescriptorRef varDesc = CTFontDescriptorCreateWithAttributes(varAttr); - CFRelease(varAttr); + CTFontDescriptorRef varDesc = + CTFontDescriptorCreateWithAttributes(varAttr); + CFRelease(varAttr); - ctFont = CTFontCreateWithGraphicsFont(aCGFont, aSize, nullptr, varDesc); - CFRelease(varDesc); + ctFont = CTFontCreateWithGraphicsFont(aCGFont, aSize, nullptr, + varDesc); + CFRelease(varDesc); + } else { + ctFont = CTFontCreateWithGraphicsFont(aCGFont, aSize, nullptr, + nullptr); + } } else { - ctFont = CTFontCreateWithGraphicsFont(aCGFont, aSize, nullptr, nullptr); + ctFont = CTFontCreateWithGraphicsFont(aCGFont, aSize, nullptr, + nullptr); } return ctFont; } @@ -139,7 +160,9 @@ ScaledFontMac::ScaledFontMac(CGFontRef aFont, if (CTFontDrawGlyphsPtr != nullptr) { // only create mCTFont if we're going to be using the CTFontDrawGlyphs API - mCTFont = CreateCTFontFromCGFontWithVariations(aFont, aSize); + auto unscaledMac = static_cast(aUnscaledFont.get()); + bool dataFont = unscaledMac->IsDataFont(); + mCTFont = CreateCTFontFromCGFontWithVariations(aFont, aSize, !dataFont); } else { mCTFont = nullptr; } @@ -160,7 +183,10 @@ SkTypeface* ScaledFontMac::GetSkTypeface() if (mCTFont) { mTypeface = SkCreateTypefaceFromCTFont(mCTFont); } else { - CTFontRef fontFace = CreateCTFontFromCGFontWithVariations(mFont, mSize); + auto unscaledMac = static_cast(GetUnscaledFont().get()); + bool dataFont = unscaledMac->IsDataFont(); + CTFontRef fontFace = + CreateCTFontFromCGFontWithVariations(mFont, mSize, !dataFont); mTypeface = SkCreateTypefaceFromCTFont(fontFace); CFRelease(fontFace); } diff --git a/gfx/2d/UnscaledFontMac.h b/gfx/2d/UnscaledFontMac.h index 8b2c4dbfaf27..d5d3aa2f3652 100644 --- a/gfx/2d/UnscaledFontMac.h +++ b/gfx/2d/UnscaledFontMac.h @@ -40,6 +40,8 @@ public: bool GetFontFileData(FontFileDataOutput aDataCallback, void *aBaton) override; + bool IsDataFont() const { return mIsDataFont; } + already_AddRefed CreateScaledFont(Float aGlyphSize, const uint8_t* aInstanceData, diff --git a/gfx/cairo/cairo/src/cairo-quartz-font.c b/gfx/cairo/cairo/src/cairo-quartz-font.c index 10b58b003a7d..78a1b0dcb767 100644 --- a/gfx/cairo/cairo/src/cairo-quartz-font.c +++ b/gfx/cairo/cairo/src/cairo-quartz-font.c @@ -353,6 +353,17 @@ CreateCTFontFromCGFontWithVariations(CGFontRef aCGFont, CGFloat aSize) // // So we only need to do this "the hard way" on Sierra; on other releases, // just let the standard CTFont function do its thing. + // + // NOTE in case this ever needs further adjustment: there is similar logic + // in four places in the tree (sadly): + // CreateCTFontFromCGFontWithVariations in gfxMacFont.cpp + // CreateCTFontFromCGFontWithVariations in ScaledFontMac.cpp + // CreateCTFontFromCGFontWithVariations in cairo-quartz-font.c + // ctfont_create_exact_copy in SkFontHost_mac.cpp + // + // XXX Does this need to behave differently for installed fonts on High + // Sierra, as in other similar places (bug 1455569)? + if (!Gecko_OnSierraExactly()) { return CTFontCreateWithGraphicsFont(aCGFont, aSize, NULL, NULL); } diff --git a/gfx/skia/skia/src/ports/SkFontHost_mac.cpp b/gfx/skia/skia/src/ports/SkFontHost_mac.cpp index 302d351cb9e8..4e7341c858e2 100644 --- a/gfx/skia/skia/src/ports/SkFontHost_mac.cpp +++ b/gfx/skia/skia/src/ports/SkFontHost_mac.cpp @@ -757,6 +757,7 @@ private: // CGFont. #ifdef MOZ_SKIA extern "C" bool Gecko_OnSierraExactly(); +extern "C" bool Gecko_OnHighSierraOrLater(); #endif static UniqueCFRef ctfont_create_exact_copy(CTFontRef baseFont, CGFloat textSize, const CGAffineTransform* transform) @@ -781,9 +782,41 @@ static UniqueCFRef ctfont_create_exact_copy(CTFontRef baseFont, CGFlo // the extra work here -- and this seems to avoid Core Text crashiness // seen in bug 1454094. // - // So we only need to do this "the hard way" on Sierra; on other releases, - // just let the standard CTFont function do its thing. - if (Gecko_OnSierraExactly()) + // However, for installed fonts it seems we DO need to copy the variations + // explicitly even on 10.13, otherwise fonts fail to render (as in bug + // 1455494) when non-default values are used. Fortunately, the crash + // mentioned above occurs with data fonts, not (AFAICT) with system- + // installed fonts. + // + // So we only need to do this "the hard way" on Sierra, and for installed + // fonts on HighSierra+; otherwise, just let the standard CTFont function + // do its thing. + // + // NOTE in case this ever needs further adjustment: there is similar logic + // in four places in the tree (sadly): + // CreateCTFontFromCGFontWithVariations in gfxMacFont.cpp + // CreateCTFontFromCGFontWithVariations in ScaledFontMac.cpp + // CreateCTFontFromCGFontWithVariations in cairo-quartz-font.c + // ctfont_create_exact_copy in SkFontHost_mac.cpp + + // To figure out if a font is installed locally or used from a @font-face + // resource, we check whether its descriptor can provide a URL. This will + // be present for installed fonts, but not for those activated from an + // in-memory resource. + auto IsInstalledFont = [](CTFontRef aFont) { + CTFontDescriptorRef desc = CTFontCopyFontDescriptor(aFont); + CFTypeRef attr = CTFontDescriptorCopyAttribute(desc, kCTFontURLAttribute); + CFRelease(desc); + bool result = false; + if (attr) { + result = true; + CFRelease(attr); + } + return result; + }; + + if (Gecko_OnSierraExactly() || + (Gecko_OnHighSierraOrLater() && IsInstalledFont(baseFont))) #endif { // Not UniqueCFRef<> because CGFontCopyVariations can return null! diff --git a/gfx/tests/mochitest/test_font_whitelist.html b/gfx/tests/mochitest/test_font_whitelist.html index 23869ee05c16..40ddcabdfb60 100644 --- a/gfx/tests/mochitest/test_font_whitelist.html +++ b/gfx/tests/mochitest/test_font_whitelist.html @@ -6,7 +6,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1121643 Test for Bug 1121643 - + diff --git a/gfx/thebes/gfxCoreTextShaper.cpp b/gfx/thebes/gfxCoreTextShaper.cpp index f696ce95fff2..ad8f7f3b6c00 100644 --- a/gfx/thebes/gfxCoreTextShaper.cpp +++ b/gfx/thebes/gfxCoreTextShaper.cpp @@ -666,8 +666,11 @@ CTFontRef gfxCoreTextShaper::CreateCTFontWithFeatures(CGFloat aSize, CTFontDescriptorRef aDescriptor) { + const gfxFontEntry* fe = mFont->GetFontEntry(); + bool isInstalledFont = !fe->IsUserFont() || fe->IsLocalUserFont(); CGFontRef cgFont = static_cast(mFont)->GetCGFontRef(); return gfxMacFont::CreateCTFontFromCGFontWithVariations(cgFont, aSize, + isInstalledFont, aDescriptor); } diff --git a/gfx/thebes/gfxMacFont.cpp b/gfx/thebes/gfxMacFont.cpp index d27d7056b6cf..69e7a67093a4 100644 --- a/gfx/thebes/gfxMacFont.cpp +++ b/gfx/thebes/gfxMacFont.cpp @@ -421,6 +421,7 @@ gfxMacFont::GetCharWidth(CFDataRef aCmap, char16_t aUniChar, CTFontRef gfxMacFont::CreateCTFontFromCGFontWithVariations(CGFontRef aCGFont, CGFloat aSize, + bool aInstalledFont, CTFontDescriptorRef aFontDesc) { // Avoid calling potentially buggy variation APIs on pre-Sierra macOS @@ -431,34 +432,53 @@ gfxMacFont::CreateCTFontFromCGFontWithVariations(CGFontRef aCGFont, // the extra work here -- and this seems to avoid Core Text crashiness // seen in bug 1454094. // - // So we only need to do this "the hard way" on Sierra; on other releases, - // just let the standard CTFont function do its thing. - if (!nsCocoaFeatures::OnSierraExactly()) { - return CTFontCreateWithGraphicsFont(aCGFont, aSize, nullptr, aFontDesc); - } + // However, for installed fonts it seems we DO need to copy the variations + // explicitly even on 10.13, otherwise fonts fail to render (as in bug + // 1455494) when non-default values are used. Fortunately, the crash + // mentioned above occurs with data fonts, not (AFAICT) with system- + // installed fonts. + // + // So we only need to do this "the hard way" on Sierra, and on HighSierra + // for system-installed fonts; in other cases just let the standard CTFont + // function do its thing. + // + // NOTE in case this ever needs further adjustment: there is similar logic + // in four places in the tree (sadly): + // CreateCTFontFromCGFontWithVariations in gfxMacFont.cpp + // CreateCTFontFromCGFontWithVariations in ScaledFontMac.cpp + // CreateCTFontFromCGFontWithVariations in cairo-quartz-font.c + // ctfont_create_exact_copy in SkFontHost_mac.cpp - CFDictionaryRef variations = ::CGFontCopyVariations(aCGFont); CTFontRef ctFont; - if (variations) { - CFDictionaryRef varAttr = - ::CFDictionaryCreate(nullptr, - (const void**)&kCTFontVariationAttribute, - (const void**)&variations, 1, - &kCFTypeDictionaryKeyCallBacks, - &kCFTypeDictionaryValueCallBacks); - ::CFRelease(variations); + if (nsCocoaFeatures::OnSierraExactly() || + (aInstalledFont && nsCocoaFeatures::OnHighSierraOrLater())) { + CFDictionaryRef variations = ::CGFontCopyVariations(aCGFont); + if (variations) { + CFDictionaryRef varAttr = + ::CFDictionaryCreate(nullptr, + (const void**)&kCTFontVariationAttribute, + (const void**)&variations, 1, + &kCFTypeDictionaryKeyCallBacks, + &kCFTypeDictionaryValueCallBacks); + ::CFRelease(variations); - CTFontDescriptorRef varDesc = aFontDesc - ? ::CTFontDescriptorCreateCopyWithAttributes(aFontDesc, varAttr) - : ::CTFontDescriptorCreateWithAttributes(varAttr); - ::CFRelease(varAttr); + CTFontDescriptorRef varDesc = aFontDesc + ? ::CTFontDescriptorCreateCopyWithAttributes(aFontDesc, varAttr) + : ::CTFontDescriptorCreateWithAttributes(varAttr); + ::CFRelease(varAttr); - ctFont = ::CTFontCreateWithGraphicsFont(aCGFont, aSize, nullptr, varDesc); - ::CFRelease(varDesc); + ctFont = ::CTFontCreateWithGraphicsFont(aCGFont, aSize, nullptr, + varDesc); + ::CFRelease(varDesc); + } else { + ctFont = ::CTFontCreateWithGraphicsFont(aCGFont, aSize, nullptr, + aFontDesc); + } } else { ctFont = ::CTFontCreateWithGraphicsFont(aCGFont, aSize, nullptr, aFontDesc); } + return ctFont; } @@ -476,7 +496,10 @@ gfxMacFont::GetGlyphWidth(DrawTarget& aDrawTarget, uint16_t aGID) } if (!mCTFont) { - mCTFont = CreateCTFontFromCGFontWithVariations(mCGFont, mAdjustedSize); + bool isInstalledFont = + !mFontEntry->IsUserFont() || mFontEntry->IsLocalUserFont(); + mCTFont = CreateCTFontFromCGFontWithVariations(mCGFont, mAdjustedSize, + isInstalledFont); if (!mCTFont) { // shouldn't happen, but let's be safe NS_WARNING("failed to create CTFontRef to measure glyph width"); return 0; diff --git a/gfx/thebes/gfxMacFont.h b/gfx/thebes/gfxMacFont.h index 9b79577eba08..44514da88d8f 100644 --- a/gfx/thebes/gfxMacFont.h +++ b/gfx/thebes/gfxMacFont.h @@ -68,6 +68,7 @@ public: static CTFontRef CreateCTFontFromCGFontWithVariations(CGFontRef aCGFont, CGFloat aSize, + bool aInstalledFont, CTFontDescriptorRef aFontDesc = nullptr); protected: diff --git a/image/VectorImage.cpp b/image/VectorImage.cpp index 861db40a60b1..7a32be7c4523 100644 --- a/image/VectorImage.cpp +++ b/image/VectorImage.cpp @@ -13,11 +13,11 @@ #include "imgFrame.h" #include "mozilla/AutoRestore.h" #include "mozilla/MemoryReporting.h" +#include "mozilla/dom/Event.h" #include "mozilla/dom/SVGSVGElement.h" #include "mozilla/gfx/2D.h" #include "mozilla/RefPtr.h" #include "mozilla/Tuple.h" -#include "nsIDOMEvent.h" #include "nsIPresShell.h" #include "nsIStreamListener.h" #include "nsMimeTypes.h" @@ -209,7 +209,7 @@ private: } public: - NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) override + NS_IMETHOD HandleEvent(Event* aEvent) override { MOZ_ASSERT(mDocument, "Need an SVG document. Received multiple events?"); diff --git a/js/public/Proxy.h b/js/public/Proxy.h index 4f103aba2644..eb2306fa4caa 100644 --- a/js/public/Proxy.h +++ b/js/public/Proxy.h @@ -463,6 +463,24 @@ GetProxyDataLayout(const JSObject* obj) return reinterpret_cast(reinterpret_cast(obj) + ProxyDataOffset); } + +JS_FRIEND_API(void) +SetValueInProxy(Value* slot, const Value& value); + +inline void +SetProxyReservedSlotUnchecked(JSObject* obj, size_t n, const Value& extra) +{ + MOZ_ASSERT(n < JSCLASS_RESERVED_SLOTS(GetObjectClass(obj))); + + Value* vp = &GetProxyDataLayout(obj)->reservedSlots->slots[n]; + + // Trigger a barrier before writing the slot. + if (vp->isGCThing() || extra.isGCThing()) + SetValueInProxy(vp, extra); + else + *vp = extra; +} + } // namespace detail inline const BaseProxyHandler* @@ -496,22 +514,11 @@ SetProxyHandler(JSObject* obj, const BaseProxyHandler* handler) detail::GetProxyDataLayout(obj)->handler = handler; } -JS_FRIEND_API(void) -SetValueInProxy(Value* slot, const Value& value); - inline void SetProxyReservedSlot(JSObject* obj, size_t n, const Value& extra) { - MOZ_ASSERT(n < JSCLASS_RESERVED_SLOTS(GetObjectClass(obj))); MOZ_ASSERT_IF(gc::detail::ObjectIsMarkedBlack(obj), JS::ValueIsNotGray(extra)); - - Value* vp = &detail::GetProxyDataLayout(obj)->reservedSlots->slots[n]; - - // Trigger a barrier before writing the slot. - if (vp->isGCThing() || extra.isGCThing()) - SetValueInProxy(vp, extra); - else - *vp = extra; + detail::SetProxyReservedSlotUnchecked(obj, n, extra); } inline void @@ -523,7 +530,7 @@ SetProxyPrivate(JSObject* obj, const Value& value) // Trigger a barrier before writing the slot. if (vp->isGCThing() || value.isGCThing()) - SetValueInProxy(vp, value); + detail::SetValueInProxy(vp, value); else *vp = value; } diff --git a/js/public/TrackedOptimizationInfo.h b/js/public/TrackedOptimizationInfo.h index 693ac48e0fce..8ad9afe05193 100644 --- a/js/public/TrackedOptimizationInfo.h +++ b/js/public/TrackedOptimizationInfo.h @@ -37,6 +37,7 @@ namespace JS { _(SetProp_InlineCache) \ \ _(GetElem_TypedObject) \ + _(GetElem_CallSiteObject) \ _(GetElem_Dense) \ _(GetElem_TypedArray) \ _(GetElem_String) \ diff --git a/js/src/gc/GC.cpp b/js/src/gc/GC.cpp index cec34be307f6..eb8db772c55d 100644 --- a/js/src/gc/GC.cpp +++ b/js/src/gc/GC.cpp @@ -5168,6 +5168,7 @@ void js::gc::DelayCrossCompartmentGrayMarking(JSObject* src) { MOZ_ASSERT(IsGrayListObject(src)); + MOZ_ASSERT(src->isMarkedGray()); AutoTouchingGrayThings tgt; @@ -5269,7 +5270,7 @@ RemoveFromGrayList(JSObject* wrapper) unsigned slot = ProxyObject::grayLinkReservedSlot(obj); JSObject* next = GetProxyReservedSlot(obj, slot).toObjectOrNull(); if (next == wrapper) { - SetProxyReservedSlot(obj, slot, ObjectOrNullValue(tail)); + js::detail::SetProxyReservedSlotUnchecked(obj, slot, ObjectOrNullValue(tail)); return true; } obj = next; diff --git a/js/src/jit-test/tests/ion/template-tag-callsiteobject.js b/js/src/jit-test/tests/ion/template-tag-callsiteobject.js new file mode 100644 index 000000000000..4d1cdcbf41e3 --- /dev/null +++ b/js/src/jit-test/tests/ion/template-tag-callsiteobject.js @@ -0,0 +1,26 @@ +function tagA(strings) { + assertEq(strings.length, 2); + assertEq(strings[0], "a"); + assertEq(strings[1], ""); +} + +function tagAB(strings) { + assertEq(strings.length, 2); + assertEq(strings[0], "a"); + assertEq(strings[1], "b"); +} + +var data = [1, 2, 3]; +function tag(strings, value1, value2) { + return strings[0] + value1 + strings[1] + value2 + strings[2]; +} + +function complex() { + return tag`${data[0]} ${data[1] + data[2]}`; +} + +for (var i = 0; i < 20; i++) { + tagA`a${0}`; + tagAB`a${0}b`; + assertEq(complex(), "1 5"); +} diff --git a/js/src/jit/IonBuilder.cpp b/js/src/jit/IonBuilder.cpp index 010f6a1c0ca9..6ce6fd524850 100644 --- a/js/src/jit/IonBuilder.cpp +++ b/js/src/jit/IonBuilder.cpp @@ -7796,6 +7796,11 @@ IonBuilder::jsop_getelem() if (emitted) return Ok(); + trackOptimizationAttempt(TrackedStrategy::GetElem_CallSiteObject); + MOZ_TRY(getElemTryCallSiteObject(&emitted, obj, index)); + if (emitted) + return Ok(); + trackOptimizationAttempt(TrackedStrategy::GetElem_Dense); MOZ_TRY(getElemTryDense(&emitted, obj, index)); if (emitted) @@ -8243,6 +8248,52 @@ IonBuilder::getElemTryTypedArray(bool* emitted, MDefinition* obj, MDefinition* i return Ok(); } +AbortReasonOr +IonBuilder::getElemTryCallSiteObject(bool* emitted, MDefinition* obj, MDefinition* index) +{ + MOZ_ASSERT(*emitted == false); + + if (!obj->isConstant() || obj->type() != MIRType::Object) { + trackOptimizationOutcome(TrackedOutcome::NotObject); + return Ok(); + } + + if (!index->isConstant() || index->type() != MIRType::Int32) { + trackOptimizationOutcome(TrackedOutcome::IndexType); + return Ok(); + } + + JSObject* cst = &obj->toConstant()->toObject(); + if (!cst->is()) { + trackOptimizationOutcome(TrackedOutcome::GenericFailure); + return Ok(); + } + + // Technically this code would work with any kind of frozen array, + // in pratice only CallSiteObjects can be constant and frozen. + + ArrayObject* array = &cst->as(); + if (array->lengthIsWritable() || array->hasEmptyElements() || !array->denseElementsAreFrozen()) { + trackOptimizationOutcome(TrackedOutcome::GenericFailure); + return Ok(); + } + + int32_t idx = index->toConstant()->toInt32(); + if (idx < 0 || !array->containsDenseElement(uint32_t(idx))) { + trackOptimizationOutcome(TrackedOutcome::OutOfBounds); + return Ok(); + } + + obj->setImplicitlyUsedUnchecked(); + index->setImplicitlyUsedUnchecked(); + + pushConstant(array->getDenseElement(uint32_t(idx))); + + trackOptimizationSuccess(); + *emitted = true; + return Ok(); +} + AbortReasonOr IonBuilder::getElemTryString(bool* emitted, MDefinition* obj, MDefinition* index) { diff --git a/js/src/jit/IonBuilder.h b/js/src/jit/IonBuilder.h index 2ce921db7cad..47cf0b15d52c 100644 --- a/js/src/jit/IonBuilder.h +++ b/js/src/jit/IonBuilder.h @@ -420,6 +420,7 @@ class IonBuilder AbortReasonOr getElemTryDense(bool* emitted, MDefinition* obj, MDefinition* index); AbortReasonOr getElemTryGetProp(bool* emitted, MDefinition* obj, MDefinition* index); AbortReasonOr getElemTryTypedArray(bool* emitted, MDefinition* obj, MDefinition* index); + AbortReasonOr getElemTryCallSiteObject(bool* emitted, MDefinition* obj, MDefinition* index); AbortReasonOr getElemTryTypedObject(bool* emitted, MDefinition* obj, MDefinition* index); AbortReasonOr getElemTryString(bool* emitted, MDefinition* obj, MDefinition* index); AbortReasonOr getElemTryArguments(bool* emitted, MDefinition* obj, MDefinition* index); diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp index 42bdb3e1647f..62d10a6df591 100644 --- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -5810,13 +5810,6 @@ EnsureLatin1CharsLinearString(JSContext* cx, HandleValue value, JS::MutableHandl static bool ConsumeBufferSource(JSContext* cx, JS::HandleObject obj, JS::MimeType, JS::StreamConsumer* consumer) { - SharedMem dataPointer; - size_t byteLength; - if (!IsBufferSource(obj, &dataPointer, &byteLength)) { - JS_ReportErrorASCII(cx, "shell streaming consumes a buffer source (buffer or view)"); - return false; - } - { RootedValue url(cx); if (!JS_GetProperty(cx, obj, "url", &url)) @@ -5841,6 +5834,13 @@ ConsumeBufferSource(JSContext* cx, JS::HandleObject obj, JS::MimeType, JS::Strea : nullptr); } + SharedMem dataPointer; + size_t byteLength; + if (!IsBufferSource(obj, &dataPointer, &byteLength)) { + JS_ReportErrorASCII(cx, "shell streaming consumes a buffer source (buffer or view)"); + return false; + } + auto job = cx->make_unique(consumer); if (!job || !job->bytes.resize(byteLength)) return false; diff --git a/js/src/tests/lib/jittests.py b/js/src/tests/lib/jittests.py index d5d763f57097..4c7275cbf934 100755 --- a/js/src/tests/lib/jittests.py +++ b/js/src/tests/lib/jittests.py @@ -700,12 +700,19 @@ def push_libs(options, device): if file in required_libs: remote_file = posixpath.join(options.remote_test_root, file) device.push(os.path.join(options.local_lib, file), remote_file) + device.chmod(remote_file, root=True) def push_progs(options, device, progs): for local_file in progs: remote_file = posixpath.join(options.remote_test_root, os.path.basename(local_file)) device.push(local_file, remote_file) + device.chmod(remote_file, root=True) + +def init_remote_dir(device, path, root=True): + device.rm(path, recursive=True, force=True, root=root) + device.mkdir(path, parents=True, root=root) + device.chmod(path, recursive=True, root=root) def run_tests_remote(tests, num_tests, prefix, options, slog): # Setup device with everything needed to run our tests. @@ -713,25 +720,29 @@ def run_tests_remote(tests, num_tests, prefix, options, slog): device = ADBAndroid(device=options.device_serial, test_root=options.remote_test_root) + init_remote_dir(device, options.remote_test_root) + # Update the test root to point to our test directory. jit_tests_dir = posixpath.join(options.remote_test_root, 'jit-tests') options.remote_test_root = posixpath.join(jit_tests_dir, 'jit-tests') # Push js shell and libraries. - device.rm(jit_tests_dir, force=True, recursive=True) - device.mkdir(options.remote_test_root, parents=True) + init_remote_dir(device, jit_tests_dir) push_libs(options, device) push_progs(options, device, [prefix[0]]) device.chmod(options.remote_test_root, recursive=True, root=True) JitTest.CacheDir = posixpath.join(options.remote_test_root, '.js-cache') - device.mkdir(JitTest.CacheDir) + init_remote_dir(device, JitTest.CacheDir) - device.push(JS_TESTS_DIR, posixpath.join(jit_tests_dir, 'tests'), - timeout=600) + jtd_tests = posixpath.join(jit_tests_dir, 'tests') + init_remote_dir(device, jtd_tests) + device.push(JS_TESTS_DIR, jtd_tests, timeout=600) + device.chmod(jtd_tests, recursive=True, root=True) device.push(os.path.dirname(TEST_DIR), options.remote_test_root, timeout=600) + device.chmod(options.remote_test_root, recursive=True, root=True) prefix[0] = os.path.join(options.remote_test_root, 'js') # Run all tests. diff --git a/js/src/vm/ProxyObject.cpp b/js/src/vm/ProxyObject.cpp index e482fa5c0792..ac64397bdf5a 100644 --- a/js/src/vm/ProxyObject.cpp +++ b/js/src/vm/ProxyObject.cpp @@ -204,7 +204,7 @@ ProxyObject::create(JSContext* cx, const Class* clasp, Handle proto } JS_FRIEND_API(void) -js::SetValueInProxy(Value* slot, const Value& value) +js::detail::SetValueInProxy(Value* slot, const Value& value) { // Slots in proxies are not GCPtrValues, so do a cast whenever assigning // values to them which might trigger a barrier. diff --git a/js/src/vm/TypedArrayObject.cpp b/js/src/vm/TypedArrayObject.cpp index 5830f0523ef2..c1757eed427c 100644 --- a/js/src/vm/TypedArrayObject.cpp +++ b/js/src/vm/TypedArrayObject.cpp @@ -2140,6 +2140,7 @@ js::IsBufferSource(JSObject* object, SharedMem* dataPointer, size_t* b DataViewObject& view = object->as(); *dataPointer = view.dataPointerEither().cast(); *byteLength = view.byteLength(); + return true; } if (object->is()) { diff --git a/js/xpconnect/src/Sandbox.cpp b/js/xpconnect/src/Sandbox.cpp index 57652fce4e0d..a32b0d816eaf 100644 --- a/js/xpconnect/src/Sandbox.cpp +++ b/js/xpconnect/src/Sandbox.cpp @@ -35,6 +35,7 @@ #include "mozilla/dom/CSSRuleBinding.h" #include "mozilla/dom/DirectoryBinding.h" #include "mozilla/dom/DOMPrefs.h" +#include "mozilla/dom/EventBinding.h" #include "mozilla/dom/IndexedDatabaseManager.h" #include "mozilla/dom/Fetch.h" #include "mozilla/dom/FileBinding.h" @@ -811,6 +812,8 @@ xpc::GlobalProperties::Parse(JSContext* cx, JS::HandleObject obj) CSSRule = true; } else if (!strcmp(name.ptr(), "Directory")) { Directory = true; + } else if (!strcmp(name.ptr(), "Event")) { + Event = true; } else if (!strcmp(name.ptr(), "File")) { File = true; } else if (!strcmp(name.ptr(), "FileReader")) { @@ -885,6 +888,10 @@ xpc::GlobalProperties::Define(JSContext* cx, JS::HandleObject obj) !dom::DirectoryBinding::GetConstructorObject(cx)) return false; + if (Event && + !dom::EventBinding::GetConstructorObject(cx)) + return false; + if (File && !dom::FileBinding::GetConstructorObject(cx)) return false; diff --git a/js/xpconnect/src/xpcprivate.h b/js/xpconnect/src/xpcprivate.h index cda7561869a4..76416c1e2d98 100644 --- a/js/xpconnect/src/xpcprivate.h +++ b/js/xpconnect/src/xpcprivate.h @@ -2612,6 +2612,7 @@ struct GlobalProperties { bool CSS : 1; bool CSSRule : 1; bool Directory : 1; + bool Event : 1; bool File : 1; bool FileReader: 1; bool FormData : 1; diff --git a/js/xpconnect/tests/mochitest/test_bug790732.html b/js/xpconnect/tests/mochitest/test_bug790732.html index 558067c1b34a..3adad3f50900 100644 --- a/js/xpconnect/tests/mochitest/test_bug790732.html +++ b/js/xpconnect/tests/mochitest/test_bug790732.html @@ -26,8 +26,6 @@ async function doTest() { // same. is(Ci.nsIXMLHttpRequest.HEADERS_RECEIVED, XMLHttpRequest.HEADERS_RECEIVED); is(Ci.nsIDOMNode.DOCUMENT_NODE, Node.DOCUMENT_NODE); - is(Ci.nsIDOMEvent.FOCUS, Event.FOCUS); - is(Ci.nsIDOMNSEvent.CLICK, Event.CLICK); is(Ci.nsIDOMKeyEvent, KeyEvent); is(Ci.nsIDOMMouseEvent, MouseEvent); is(Ci.nsIDOMMouseScrollEvent, MouseScrollEvent); diff --git a/js/xpconnect/tests/mochitest/test_nukeContentWindow.html b/js/xpconnect/tests/mochitest/test_nukeContentWindow.html index 022ccda8e986..92b04630afc6 100644 --- a/js/xpconnect/tests/mochitest/test_nukeContentWindow.html +++ b/js/xpconnect/tests/mochitest/test_nukeContentWindow.html @@ -7,7 +7,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1322273 Test for Bug 1322273 - + diff --git a/layout/base/AccessibleCaret.h b/layout/base/AccessibleCaret.h index 42e5bb38643e..a809cd6f19d8 100644 --- a/layout/base/AccessibleCaret.h +++ b/layout/base/AccessibleCaret.h @@ -26,6 +26,10 @@ struct nsPoint; namespace mozilla { +namespace dom { +class Event; +} // namespace dom + // ----------------------------------------------------------------------------- // Upon the creation of AccessibleCaret, it will insert DOM Element as an // anonymous content containing the caret image. The caret appearance and @@ -203,7 +207,7 @@ protected: { public: NS_DECL_ISUPPORTS - NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) override + NS_IMETHOD HandleEvent(mozilla::dom::Event* aEvent) override { return NS_OK; } diff --git a/layout/base/MobileViewportManager.cpp b/layout/base/MobileViewportManager.cpp index 340cfa1dee4e..c069a6410fee 100644 --- a/layout/base/MobileViewportManager.cpp +++ b/layout/base/MobileViewportManager.cpp @@ -9,8 +9,8 @@ #include "gfxPrefs.h" #include "LayersLogging.h" #include "mozilla/PresShell.h" +#include "mozilla/dom/Event.h" #include "mozilla/dom/EventTarget.h" -#include "nsIDOMEvent.h" #include "nsIFrame.h" #include "nsLayoutUtils.h" #include "nsViewManager.h" @@ -122,7 +122,7 @@ MobileViewportManager::ResolutionUpdated() } NS_IMETHODIMP -MobileViewportManager::HandleEvent(nsIDOMEvent* event) +MobileViewportManager::HandleEvent(dom::Event* event) { nsAutoString type; event->GetType(type); diff --git a/layout/base/PresShell.cpp b/layout/base/PresShell.cpp index e4fb8c7ff6e2..e9d23424e7d2 100644 --- a/layout/base/PresShell.cpp +++ b/layout/base/PresShell.cpp @@ -8100,7 +8100,7 @@ PresShell::HandleDOMEventWithTarget(nsIContent* aTargetContent, // See the method above. nsresult PresShell::HandleDOMEventWithTarget(nsIContent* aTargetContent, - nsIDOMEvent* aEvent, + Event* aEvent, nsEventStatus* aStatus) { nsresult rv = NS_OK; diff --git a/layout/base/PresShell.h b/layout/base/PresShell.h index 467f423eb6d5..65f5e03f4cbd 100644 --- a/layout/base/PresShell.h +++ b/layout/base/PresShell.h @@ -237,7 +237,7 @@ public: WidgetEvent* aEvent, nsEventStatus* aStatus) override; nsresult HandleDOMEventWithTarget(nsIContent* aTargetContent, - nsIDOMEvent* aEvent, + dom::Event* aEvent, nsEventStatus* aStatus) override; bool ShouldIgnoreInvalidation() override; void WillPaint() override; diff --git a/layout/base/ZoomConstraintsClient.cpp b/layout/base/ZoomConstraintsClient.cpp index a174667d676e..ed1fc94e950a 100644 --- a/layout/base/ZoomConstraintsClient.cpp +++ b/layout/base/ZoomConstraintsClient.cpp @@ -129,7 +129,7 @@ ZoomConstraintsClient::Init(nsIPresShell* aPresShell, nsIDocument* aDocument) } NS_IMETHODIMP -ZoomConstraintsClient::HandleEvent(nsIDOMEvent* event) +ZoomConstraintsClient::HandleEvent(dom::Event* event) { nsAutoString type; event->GetType(type); diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index db0bdb883cc5..d7d60e8042f2 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -332,6 +332,32 @@ static int32_t FFWC_recursions=0; static int32_t FFWC_nextInFlows=0; #endif +#ifdef MOZ_XUL + +static bool +IsXULListBox(nsIContent* aContainer) +{ + return aContainer->IsXULElement(nsGkAtoms::listbox); +} + +static +nsListBoxBodyFrame* +MaybeGetListBoxBodyFrame(nsIContent* aChild) +{ + if (aChild->IsXULElement(nsGkAtoms::listitem) && aChild->GetParent() && + IsXULListBox(aChild->GetParent())) { + RefPtr xulElement = + nsXULElement::FromNode(aChild->GetParent()); + nsCOMPtr boxObject = xulElement->GetBoxObject(IgnoreErrors()); + nsCOMPtr listBoxObject = do_QueryInterface(boxObject); + if (listBoxObject) { + return listBoxObject->GetListBoxBody(false); + } + } + + return nullptr; +} +#endif // MOZ_XUL // Returns true if aFrame is an anonymous flex/grid item. static inline bool @@ -5474,6 +5500,11 @@ nsCSSFrameConstructor::ShouldCreateItemsForChild(nsFrameConstructorState& aState if (aContent->GetPrimaryFrame() && aContent->GetPrimaryFrame()->GetContent() == aContent && !aState.mCreatingExtraFrames) { + // This condition is known to be reachable for listitems, assert fatally + // elsewhere. + MOZ_ASSERT(MaybeGetListBoxBodyFrame(aContent), + "asked to create frame construction item for a node that " + "already has a frame"); NS_ERROR("asked to create frame construction item for a node that already " "has a frame"); return false; @@ -5485,8 +5516,7 @@ nsCSSFrameConstructor::ShouldCreateItemsForChild(nsFrameConstructorState& aState } // never create frames for comments or PIs - if (aContent->IsNodeOfType(nsINode::eCOMMENT) || - aContent->IsNodeOfType(nsINode::ePROCESSING_INSTRUCTION)) { + if (aContent->IsComment() || aContent->IsProcessingInstruction()) { return false; } @@ -6349,8 +6379,7 @@ nsCSSFrameConstructor::IsValidSibling(nsIFrame* aSibling, // if we haven't already, resolve a style to find the display type of // aContent. if (UNSET_DISPLAY == aDisplay) { - if (aContent->IsNodeOfType(nsINode::eCOMMENT) || - aContent->IsNodeOfType(nsINode::ePROCESSING_INSTRUCTION)) { + if (aContent->IsComment() || aContent->IsProcessingInstruction()) { // Comments and processing instructions never have frames, so we should // not try to generate styles for them. return false; @@ -6695,33 +6724,6 @@ IsSpecialFramesetChild(nsIContent* aContent) static void InvalidateCanvasIfNeeded(nsIPresShell* presShell, nsIContent* node); -#ifdef MOZ_XUL - -static bool -IsXULListBox(nsIContent* aContainer) -{ - return aContainer->IsXULElement(nsGkAtoms::listbox); -} - -static -nsListBoxBodyFrame* -MaybeGetListBoxBodyFrame(nsIContent* aChild) -{ - if (aChild->IsXULElement(nsGkAtoms::listitem) && aChild->GetParent() && - IsXULListBox(aChild->GetParent())) { - RefPtr xulElement = - nsXULElement::FromNode(aChild->GetParent()); - nsCOMPtr boxObject = xulElement->GetBoxObject(IgnoreErrors()); - nsCOMPtr listBoxObject = do_QueryInterface(boxObject); - if (listBoxObject) { - return listBoxObject->GetListBoxBody(false); - } - } - - return nullptr; -} -#endif // MOZ_XUL - void nsCSSFrameConstructor::AddTextItemIfNeeded(nsFrameConstructorState& aState, const InsertionPoint& aInsertion, @@ -7073,19 +7075,18 @@ nsCSSFrameConstructor::ContentAppended(nsIContent* aFirstNewContent, return; } - if (aInsertionKind == InsertionKind::Async && - MaybeConstructLazily(CONTENTAPPEND, aFirstNewContent)) { - LazilyStyleNewChildRange(aFirstNewContent, nullptr); - return; - } - - // We couldn't construct lazily. Make Servo eagerly traverse the new content - // if needed (when aInsertionKind == InsertionKind::Sync, we know that the - // styles are up-to-date already). if (aInsertionKind == InsertionKind::Async) { + if (MaybeConstructLazily(CONTENTAPPEND, aFirstNewContent)) { + LazilyStyleNewChildRange(aFirstNewContent, nullptr); + return; + } + // We couldn't construct lazily. Make Servo eagerly traverse the new content + // if needed (when aInsertionKind == InsertionKind::Sync, we know that the + // styles are up-to-date already). StyleNewChildRange(aFirstNewContent, nullptr); } + LAYOUT_PHASE_TEMP_EXIT(); if (MaybeRecreateForFrameset(parentFrame, aFirstNewContent, nullptr)) { LAYOUT_PHASE_TEMP_REENTER(); @@ -7423,14 +7424,6 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aStartChild, } #endif - auto styleNewChildRangeEagerly = - [this, aInsertionKind, aStartChild, aEndChild]() { - // When aInsertionKind == InsertionKind::Sync, we know that the - // styles are up-to-date already. - if (aInsertionKind == InsertionKind::Async) { - StyleNewChildRange(aStartChild, aEndChild); - } - }; bool isSingleInsert = (aStartChild->GetNextSibling() == aEndChild); NS_ASSERTION(isSingleInsert || @@ -7441,8 +7434,6 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aStartChild, #ifdef MOZ_XUL if (aStartChild->GetParent() && IsXULListBox(aStartChild->GetParent())) { - // For XUL list box, we need to style the new children eagerly. - styleNewChildRangeEagerly(); if (isSingleInsert) { // The insert case in NotifyListBoxBody doesn't use "old next sibling". if (NotifyListBoxBody(mPresShell->GetPresContext(), @@ -7528,16 +7519,17 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aStartChild, return; } - if (aInsertionKind == InsertionKind::Async && - MaybeConstructLazily(CONTENTINSERT, aStartChild)) { - LazilyStyleNewChildRange(aStartChild, aEndChild); - return; + if (aInsertionKind == InsertionKind::Async) { + if (MaybeConstructLazily(CONTENTINSERT, aStartChild)) { + LazilyStyleNewChildRange(aStartChild, aEndChild); + return; + } + // We couldn't construct lazily. Make Servo eagerly traverse the new content + // if needed (when aInsertionKind == InsertionKind::Sync, we know that the + // styles are up-to-date already). + StyleNewChildRange(aStartChild, aEndChild); } - // We couldn't construct lazily. Make Servo eagerly traverse the new content - // if needed. - styleNewChildRangeEagerly(); - bool isAppend, isRangeInsertSafe; nsIFrame* prevSibling = GetInsertionPrevSibling(&insertion, aStartChild, &isAppend, &isRangeInsertSafe); @@ -10143,8 +10135,7 @@ nsCSSFrameConstructor::AddFCItemsForAnonymousContent( "Should not be marked as needing frames"); MOZ_ASSERT(!content->GetPrimaryFrame(), "Should have no existing frame"); - MOZ_ASSERT(!content->IsNodeOfType(nsINode::eCOMMENT) && - !content->IsNodeOfType(nsINode::ePROCESSING_INSTRUCTION), + MOZ_ASSERT(!content->IsComment() && !content->IsProcessingInstruction(), "Why is someone creating garbage anonymous content"); // Make sure we eagerly performed the servo cascade when the anonymous @@ -11118,6 +11109,10 @@ nsCSSFrameConstructor::CreateListBoxContent(nsContainerFrame* aParentFrame, GetFloatContainingBlock(aParentFrame), do_AddRef(mTempFrameTreeState)); + if (aChild->IsElement() && !aChild->AsElement()->HasServoData()) { + mPresShell->StyleSet()->StyleNewSubtree(aChild->AsElement()); + } + RefPtr computedStyle = ResolveComputedStyle(aChild); // Pre-check for display "none" - only if we find that, do we create @@ -11486,8 +11481,7 @@ nsCSSFrameConstructor::BuildInlineChildItems(nsFrameConstructorState& aState, // AddFrameConstructionItems. We know our parent is a non-replaced inline, // so there is no need to do the NeedFrameFor check. content->UnsetFlags(NODE_DESCENDANTS_NEED_FRAMES | NODE_NEEDS_FRAME); - if (content->IsNodeOfType(nsINode::eCOMMENT) || - content->IsNodeOfType(nsINode::ePROCESSING_INSTRUCTION)) { + if (content->IsComment() || content->IsProcessingInstruction()) { continue; } diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index 647ab1f3f3b6..14e15f011e0c 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -104,7 +104,6 @@ #endif // NS_PRINTING //focus -#include "nsIDOMEventTarget.h" #include "nsIDOMEventListener.h" #include "nsISelectionController.h" @@ -119,6 +118,7 @@ #include #include "mozilla/dom/Element.h" +#include "mozilla/dom/Event.h" #include "mozilla/Telemetry.h" #include "mozilla/dom/ScriptLoader.h" @@ -3705,7 +3705,7 @@ nsDocViewerFocusListener::nsDocViewerFocusListener() nsDocViewerFocusListener::~nsDocViewerFocusListener(){} nsresult -nsDocViewerFocusListener::HandleEvent(nsIDOMEvent* aEvent) +nsDocViewerFocusListener::HandleEvent(Event* aEvent) { NS_ENSURE_STATE(mDocViewer); diff --git a/layout/base/nsIPresShell.h b/layout/base/nsIPresShell.h index 0644e3c8a252..3afb9678a51e 100644 --- a/layout/base/nsIPresShell.h +++ b/layout/base/nsIPresShell.h @@ -70,7 +70,6 @@ template class nsCOMArray; class AutoWeakFrame; class WeakFrame; class nsIScrollableFrame; -class nsIDOMEvent; class nsDisplayList; class nsDisplayListBuilder; class nsPIDOMWindowOuter; @@ -96,6 +95,7 @@ class EventStates; namespace dom { class Element; +class Event; class HTMLSlotElement; class Touch; class Selection; @@ -945,8 +945,8 @@ public: * @note The caller must have a strong reference to the PresShell. */ virtual nsresult HandleDOMEventWithTarget(nsIContent* aTargetContent, - nsIDOMEvent* aEvent, - nsEventStatus* aStatus) = 0; + mozilla::dom::Event* aEvent, + nsEventStatus* aStatus) = 0; /** * Return whether or not the event is valid to be dispatched diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index b7fb7a9ca079..4f81c3276429 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -40,7 +40,6 @@ #include "nsPlaceholderFrame.h" #include "nsIScrollableFrame.h" #include "nsSubDocumentFrame.h" -#include "nsIDOMEvent.h" #include "nsDisplayList.h" #include "nsRegion.h" #include "nsCSSFrameConstructor.h" @@ -2221,7 +2220,7 @@ nsLayoutUtils::HasPseudoStyle(nsIContent* aContent, } nsPoint -nsLayoutUtils::GetDOMEventCoordinatesRelativeTo(nsIDOMEvent* aDOMEvent, nsIFrame* aFrame) +nsLayoutUtils::GetDOMEventCoordinatesRelativeTo(Event* aDOMEvent, nsIFrame* aFrame) { if (!aDOMEvent) return nsPoint(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE); diff --git a/layout/base/nsLayoutUtils.h b/layout/base/nsLayoutUtils.h index 3783f1d0df48..2eacac5cf2a0 100644 --- a/layout/base/nsLayoutUtils.h +++ b/layout/base/nsLayoutUtils.h @@ -44,7 +44,6 @@ class nsPresContext; class nsIContent; class nsAtom; class nsIScrollableFrame; -class nsIDOMEvent; class nsRegion; class nsDisplayListBuilder; enum class nsDisplayListBuilderMode : uint8_t; @@ -80,6 +79,7 @@ namespace dom { class CanvasRenderingContext2D; class DOMRectList; class Element; +class Event; class HTMLImageElement; class HTMLCanvasElement; class HTMLVideoElement; @@ -709,7 +709,7 @@ public: * for some reason the coordinates for the mouse are not known (e.g., * the event is not a GUI event). */ - static nsPoint GetDOMEventCoordinatesRelativeTo(nsIDOMEvent* aDOMEvent, + static nsPoint GetDOMEventCoordinatesRelativeTo(mozilla::dom::Event* aDOMEvent, nsIFrame* aFrame); /** diff --git a/layout/forms/nsComboboxControlFrame.cpp b/layout/forms/nsComboboxControlFrame.cpp index 6f91c44458b3..cee756a8a479 100644 --- a/layout/forms/nsComboboxControlFrame.cpp +++ b/layout/forms/nsComboboxControlFrame.cpp @@ -29,6 +29,7 @@ #include "nsIDOMNode.h" #include "nsISelectControlFrame.h" #include "nsContentUtils.h" +#include "mozilla/dom/Event.h" #include "mozilla/dom/HTMLSelectElement.h" #include "nsIDocument.h" #include "nsIScrollableFrame.h" @@ -97,7 +98,7 @@ private: public: NS_DECL_ISUPPORTS - NS_IMETHOD HandleEvent(nsIDOMEvent*) override + NS_IMETHOD HandleEvent(dom::Event*) override { mComboBox->ShowDropDown(!mComboBox->IsDroppedDown()); return NS_OK; diff --git a/layout/forms/nsFileControlFrame.cpp b/layout/forms/nsFileControlFrame.cpp index be998b64fb44..2f2240a3f366 100644 --- a/layout/forms/nsFileControlFrame.cpp +++ b/layout/forms/nsFileControlFrame.cpp @@ -16,6 +16,7 @@ #include "mozilla/dom/DataTransfer.h" #include "mozilla/dom/Directory.h" #include "mozilla/dom/DragEvent.h" +#include "mozilla/dom/Event.h" #include "mozilla/dom/FileList.h" #include "mozilla/dom/HTMLButtonElement.h" #include "mozilla/dom/HTMLInputElement.h" @@ -233,16 +234,15 @@ AppendBlobImplAsDirectory(nsTArray& aArray, * This is called when we receive a drop or a dragover. */ NS_IMETHODIMP -nsFileControlFrame::DnDListener::HandleEvent(nsIDOMEvent* aEvent) +nsFileControlFrame::DnDListener::HandleEvent(Event* aEvent) { NS_ASSERTION(mFrame, "We should have been unregistered"); - Event* event = aEvent->InternalDOMEvent(); - if (event->DefaultPrevented()) { + if (aEvent->DefaultPrevented()) { return NS_OK; } - DragEvent* dragEvent = event->AsDragEvent(); + DragEvent* dragEvent = aEvent->AsDragEvent(); if (!dragEvent) { return NS_OK; } diff --git a/layout/forms/nsListControlFrame.cpp b/layout/forms/nsListControlFrame.cpp index cd8709f7a732..79edd0a4e9d4 100644 --- a/layout/forms/nsListControlFrame.cpp +++ b/layout/forms/nsListControlFrame.cpp @@ -21,6 +21,7 @@ #include "nsDisplayList.h" #include "nsContentUtils.h" #include "mozilla/Attributes.h" +#include "mozilla/dom/Event.h" #include "mozilla/dom/HTMLOptGroupElement.h" #include "mozilla/dom/HTMLOptionsCollection.h" #include "mozilla/dom/HTMLSelectElement.h" @@ -843,10 +844,10 @@ nsListControlFrame::PerformSelection(int32_t aClickedIndex, //--------------------------------------------------------- bool -nsListControlFrame::HandleListSelection(nsIDOMEvent* aEvent, +nsListControlFrame::HandleListSelection(dom::Event* aEvent, int32_t aClickedIndex) { - MouseEvent* mouseEvent = aEvent->InternalDOMEvent()->AsMouseEvent(); + MouseEvent* mouseEvent = aEvent->AsMouseEvent(); bool isControl; #ifdef XP_MACOSX isControl = mouseEvent->MetaKey(); @@ -1561,10 +1562,10 @@ nsListControlFrame::IsOptionDisabled(int32_t anIndex, bool &aIsDisabled) // helper //---------------------------------------------------------------------- bool -nsListControlFrame::IsLeftButton(nsIDOMEvent* aMouseEvent) +nsListControlFrame::IsLeftButton(dom::Event* aMouseEvent) { // only allow selection with the left button - MouseEvent* mouseEvent = aMouseEvent->InternalDOMEvent()->AsMouseEvent(); + MouseEvent* mouseEvent = aMouseEvent->AsMouseEvent(); return mouseEvent && mouseEvent->Button() == 0; } @@ -1602,11 +1603,11 @@ nsListControlFrame::CalcIntrinsicBSize(nscoord aBSizeOfARow, // nsIDOMMouseListener //---------------------------------------------------------------------- nsresult -nsListControlFrame::MouseUp(nsIDOMEvent* aMouseEvent) +nsListControlFrame::MouseUp(dom::Event* aMouseEvent) { NS_ASSERTION(aMouseEvent != nullptr, "aMouseEvent is null."); - MouseEvent* mouseEvent = aMouseEvent->InternalDOMEvent()->AsMouseEvent(); + MouseEvent* mouseEvent = aMouseEvent->AsMouseEvent(); NS_ENSURE_TRUE(mouseEvent, NS_ERROR_FAILURE); UpdateInListState(aMouseEvent); @@ -1701,7 +1702,7 @@ nsListControlFrame::MouseUp(nsIDOMEvent* aMouseEvent) } void -nsListControlFrame::UpdateInListState(nsIDOMEvent* aEvent) +nsListControlFrame::UpdateInListState(dom::Event* aEvent) { if (!mComboboxFrame || !mComboboxFrame->IsDroppedDown()) return; @@ -1713,7 +1714,7 @@ nsListControlFrame::UpdateInListState(nsIDOMEvent* aEvent) } } -bool nsListControlFrame::IgnoreMouseEventForSelection(nsIDOMEvent* aEvent) +bool nsListControlFrame::IgnoreMouseEventForSelection(dom::Event* aEvent) { if (!mComboboxFrame) return false; @@ -1744,8 +1745,8 @@ nsListControlFrame::FireMenuItemActiveEvent() #endif nsresult -nsListControlFrame::GetIndexFromDOMEvent(nsIDOMEvent* aMouseEvent, - int32_t& aCurIndex) +nsListControlFrame::GetIndexFromDOMEvent(dom::Event* aMouseEvent, + int32_t& aCurIndex) { if (IgnoreMouseEventForSelection(aMouseEvent)) return NS_ERROR_FAILURE; @@ -1796,11 +1797,11 @@ FireShowDropDownEvent(nsIContent* aContent, bool aShow, bool aIsSourceTouchEvent } nsresult -nsListControlFrame::MouseDown(nsIDOMEvent* aMouseEvent) +nsListControlFrame::MouseDown(dom::Event* aMouseEvent) { NS_ASSERTION(aMouseEvent != nullptr, "aMouseEvent is null."); - MouseEvent* mouseEvent = aMouseEvent->InternalDOMEvent()->AsMouseEvent(); + MouseEvent* mouseEvent = aMouseEvent->AsMouseEvent(); NS_ENSURE_TRUE(mouseEvent, NS_ERROR_FAILURE); UpdateInListState(aMouseEvent); @@ -1845,9 +1846,8 @@ nsListControlFrame::MouseDown(nsIDOMEvent* aMouseEvent) // Ignore the click that occurs on the option element when one is // selected from the parent process popup. if (mComboboxFrame->IsOpenInParentProcess()) { - nsCOMPtr etarget; - aMouseEvent->GetTarget(getter_AddRefs(etarget)); - nsCOMPtr econtent = do_QueryInterface(etarget); + nsCOMPtr econtent = + do_QueryInterface(aMouseEvent->GetTarget()); HTMLOptionElement* option = HTMLOptionElement::FromNodeOrNull(econtent); if (option) { return NS_OK; @@ -1883,14 +1883,11 @@ nsListControlFrame::MouseDown(nsIDOMEvent* aMouseEvent) return NS_OK; } -//---------------------------------------------------------------------- -// nsIDOMMouseMotionListener -//---------------------------------------------------------------------- nsresult -nsListControlFrame::MouseMove(nsIDOMEvent* aMouseEvent) +nsListControlFrame::MouseMove(dom::Event* aMouseEvent) { NS_ASSERTION(aMouseEvent, "aMouseEvent is null."); - MouseEvent* mouseEvent = aMouseEvent->InternalDOMEvent()->AsMouseEvent(); + MouseEvent* mouseEvent = aMouseEvent->AsMouseEvent(); NS_ENSURE_TRUE(mouseEvent, NS_ERROR_FAILURE); UpdateInListState(aMouseEvent); @@ -1911,7 +1908,7 @@ nsListControlFrame::MouseMove(nsIDOMEvent* aMouseEvent) } nsresult -nsListControlFrame::DragMove(nsIDOMEvent* aMouseEvent) +nsListControlFrame::DragMove(dom::Event* aMouseEvent) { NS_ASSERTION(aMouseEvent, "aMouseEvent is null."); @@ -1924,7 +1921,7 @@ nsListControlFrame::DragMove(nsIDOMEvent* aMouseEvent) if (selectedIndex == mEndSelectionIndex) { return NS_OK; } - MouseEvent* mouseEvent = aMouseEvent->InternalDOMEvent()->AsMouseEvent(); + MouseEvent* mouseEvent = aMouseEvent->AsMouseEvent(); NS_ASSERTION(mouseEvent, "aMouseEvent is not a MouseEvent!"); bool isControl; #ifdef XP_MACOSX @@ -2093,7 +2090,7 @@ nsListControlFrame::Shutdown() } void -nsListControlFrame::DropDownToggleKey(nsIDOMEvent* aKeyEvent) +nsListControlFrame::DropDownToggleKey(dom::Event* aKeyEvent) { // Cocoa widgets do native popups, so don't try to show // dropdowns there. @@ -2115,7 +2112,7 @@ nsListControlFrame::DropDownToggleKey(nsIDOMEvent* aKeyEvent) } nsresult -nsListControlFrame::KeyDown(nsIDOMEvent* aKeyEvent) +nsListControlFrame::KeyDown(dom::Event* aKeyEvent) { MOZ_ASSERT(aKeyEvent, "aKeyEvent is null."); @@ -2306,7 +2303,7 @@ nsListControlFrame::KeyDown(nsIDOMEvent* aKeyEvent) } nsresult -nsListControlFrame::KeyPress(nsIDOMEvent* aKeyEvent) +nsListControlFrame::KeyPress(dom::Event* aKeyEvent) { MOZ_ASSERT(aKeyEvent, "aKeyEvent is null."); @@ -2523,7 +2520,7 @@ nsListControlFrame::PostHandleKeyEvent(int32_t aNewIndex, NS_IMPL_ISUPPORTS(nsListEventListener, nsIDOMEventListener) NS_IMETHODIMP -nsListEventListener::HandleEvent(nsIDOMEvent* aEvent) +nsListEventListener::HandleEvent(dom::Event* aEvent) { if (!mFrame) return NS_OK; @@ -2537,9 +2534,7 @@ nsListEventListener::HandleEvent(nsIDOMEvent* aEvent) return mFrame->nsListControlFrame::KeyPress(aEvent); } if (eventType.EqualsLiteral("mousedown")) { - bool defaultPrevented = false; - aEvent->GetDefaultPrevented(&defaultPrevented); - if (defaultPrevented) { + if (aEvent->DefaultPrevented()) { return NS_OK; } return mFrame->nsListControlFrame::MouseDown(aEvent); diff --git a/layout/forms/nsListControlFrame.h b/layout/forms/nsListControlFrame.h index f0df9e2ba86f..d7e8029e7476 100644 --- a/layout/forms/nsListControlFrame.h +++ b/layout/forms/nsListControlFrame.h @@ -35,6 +35,7 @@ class nsListEventListener; namespace mozilla { namespace dom { +class Event; class HTMLOptionElement; class HTMLOptionsCollection; } // namespace dom @@ -160,12 +161,12 @@ public: * Mouse event listeners. * @note These methods might destroy the frame, pres shell and other objects. */ - nsresult MouseDown(nsIDOMEvent* aMouseEvent); - nsresult MouseUp(nsIDOMEvent* aMouseEvent); - nsresult MouseMove(nsIDOMEvent* aMouseEvent); - nsresult DragMove(nsIDOMEvent* aMouseEvent); - nsresult KeyDown(nsIDOMEvent* aKeyEvent); - nsresult KeyPress(nsIDOMEvent* aKeyEvent); + nsresult MouseDown(mozilla::dom::Event* aMouseEvent); + nsresult MouseUp(mozilla::dom::Event* aMouseEvent); + nsresult MouseMove(mozilla::dom::Event* aMouseEvent); + nsresult DragMove(mozilla::dom::Event* aMouseEvent); + nsresult KeyDown(mozilla::dom::Event* aKeyEvent); + nsresult KeyPress(mozilla::dom::Event* aKeyEvent); /** * Returns the options collection for mContent, if any. @@ -272,7 +273,7 @@ protected: * Toggles (show/hide) the combobox dropdown menu. * @note This method might destroy the frame, pres shell and other objects. */ - void DropDownToggleKey(nsIDOMEvent* aKeyEvent); + void DropDownToggleKey(mozilla::dom::Event* aKeyEvent); nsresult IsOptionDisabled(int32_t anIndex, bool &aIsDisabled); /** @@ -294,13 +295,13 @@ protected: * * @param aPoint relative to this frame */ - bool IgnoreMouseEventForSelection(nsIDOMEvent* aEvent); + bool IgnoreMouseEventForSelection(mozilla::dom::Event* aEvent); /** * If the dropdown is showing and the mouse has moved below our * border-inner-edge, then set mItemSelectionStarted. */ - void UpdateInListState(nsIDOMEvent* aEvent); + void UpdateInListState(mozilla::dom::Event* aEvent); void AdjustIndexForDisabledOpt(int32_t aStartIndex, int32_t &anNewIndex, int32_t aNumOptions, int32_t aDoAdjustInc, int32_t aDoAdjustIncNext); @@ -319,10 +320,11 @@ protected: * @param aPoint the event point, in listcontrolframe coordinates * @return NS_OK if it successfully found the selection */ - nsresult GetIndexFromDOMEvent(nsIDOMEvent* aMouseEvent, int32_t& aCurIndex); + nsresult GetIndexFromDOMEvent(mozilla::dom::Event* aMouseEvent, + int32_t& aCurIndex); bool CheckIfAllFramesHere(); - bool IsLeftButton(nsIDOMEvent* aMouseEvent); + bool IsLeftButton(mozilla::dom::Event* aMouseEvent); // guess at a row block size based on our own style. nscoord CalcFallbackRowBSize(float aFontSizeInflation); @@ -365,7 +367,8 @@ protected: /** * @note This method might destroy the frame, pres shell and other objects. */ - bool HandleListSelection(nsIDOMEvent * aDOMEvent, int32_t selectedIndex); + bool HandleListSelection(mozilla::dom::Event * aDOMEvent, + int32_t selectedIndex); void InitSelectionRange(int32_t aClickedIndex); void PostHandleKeyEvent(int32_t aNewIndex, uint32_t aCharCode, bool aIsShift, bool aIsControlOrMeta); diff --git a/layout/forms/nsRangeFrame.h b/layout/forms/nsRangeFrame.h index 522e9b9b414a..24d87094fa51 100644 --- a/layout/forms/nsRangeFrame.h +++ b/layout/forms/nsRangeFrame.h @@ -17,6 +17,12 @@ class nsDisplayRangeFocusRing; +namespace mozilla { +namespace dom { +class Event; +} // namespace mozilla +} // namespace dom + class nsRangeFrame final : public nsContainerFrame, public nsIAnonymousContentCreator { @@ -195,7 +201,7 @@ private: public: NS_DECL_ISUPPORTS - NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) override + NS_IMETHOD HandleEvent(mozilla::dom::Event* aEvent) override { return NS_OK; } diff --git a/layout/generic/ScrollbarActivity.cpp b/layout/generic/ScrollbarActivity.cpp index 134b15c0c866..e21fbfdf1574 100644 --- a/layout/generic/ScrollbarActivity.cpp +++ b/layout/generic/ScrollbarActivity.cpp @@ -8,7 +8,6 @@ #include "nsIScrollbarMediator.h" #include "nsIContent.h" #include "nsICSSDeclaration.h" -#include "nsIDOMEvent.h" #include "nsIFrame.h" #include "nsContentUtils.h" #include "nsAString.h" @@ -16,6 +15,7 @@ #include "nsComponentManagerUtils.h" #include "nsStyledElement.h" #include "mozilla/dom/Element.h" +#include "mozilla/dom/Event.h" #include "mozilla/LookAndFeel.h" #include "mozilla/Preferences.h" @@ -107,7 +107,7 @@ ScrollbarActivity::ActivityStopped() } NS_IMETHODIMP -ScrollbarActivity::HandleEvent(nsIDOMEvent* aEvent) +ScrollbarActivity::HandleEvent(dom::Event* aEvent) { if (!mDisplayOnMouseMove && !mIsActive) return NS_OK; @@ -122,9 +122,8 @@ ScrollbarActivity::HandleEvent(nsIDOMEvent* aEvent) return NS_OK; } - nsCOMPtr target; - aEvent->GetOriginalTarget(getter_AddRefs(target)); - nsCOMPtr targetContent = do_QueryInterface(target); + nsCOMPtr targetContent = + do_QueryInterface(aEvent->GetOriginalTarget()); HandleEventForScrollbar(type, targetContent, GetHorizontalScrollbar(), &mHScrollbarHovered); diff --git a/layout/generic/nsFlexContainerFrame.cpp b/layout/generic/nsFlexContainerFrame.cpp index 4ba0f8b9e390..2db54283285c 100644 --- a/layout/generic/nsFlexContainerFrame.cpp +++ b/layout/generic/nsFlexContainerFrame.cpp @@ -1670,26 +1670,45 @@ nsFlexContainerFrame:: */ class nsFlexContainerFrame::CachedMeasuringReflowResult { - // Members that are part of the cache key: - const LogicalSize mAvailableSize; - const nscoord mComputedBSize; + struct Key + { + const LogicalSize mAvailableSize; + const nscoord mComputedBSize; + const nscoord mComputedMinBSize; + const nscoord mComputedMaxBSize; + + explicit Key(const ReflowInput& aRI) + : mAvailableSize(aRI.AvailableSize()) + , mComputedBSize(aRI.ComputedBSize()) + , mComputedMinBSize(aRI.ComputedMinBSize()) + , mComputedMaxBSize(aRI.ComputedMaxBSize()) + { } + + bool operator==(const Key& aOther) const + { + return mAvailableSize == aOther.mAvailableSize && + mComputedBSize == aOther.mComputedBSize && + mComputedMinBSize == aOther.mComputedMinBSize && + mComputedMaxBSize == aOther.mComputedMaxBSize; + } + }; + + const Key mKey; - // Members that are part of the cache value: const nscoord mBSize; const nscoord mAscent; public: CachedMeasuringReflowResult(const ReflowInput& aReflowInput, const ReflowOutput& aDesiredSize) - : mAvailableSize(aReflowInput.AvailableSize()) - , mComputedBSize(aReflowInput.ComputedBSize()) + : mKey(aReflowInput) , mBSize(aDesiredSize.BSize(aReflowInput.GetWritingMode())) , mAscent(aDesiredSize.BlockStartAscent()) - {} + { } - bool IsValidFor(const ReflowInput& aReflowInput) const { - return mAvailableSize == aReflowInput.AvailableSize() && - mComputedBSize == aReflowInput.ComputedBSize(); + bool IsValidFor(const ReflowInput& aReflowInput) const + { + return mKey == Key(aReflowInput); } nscoord BSize() const { return mBSize; } diff --git a/layout/generic/nsImageMap.cpp b/layout/generic/nsImageMap.cpp index ba159373945f..3a0ef5621a03 100644 --- a/layout/generic/nsImageMap.cpp +++ b/layout/generic/nsImageMap.cpp @@ -9,7 +9,7 @@ #include "nsImageMap.h" #include "mozilla/dom/Element.h" -#include "mozilla/dom/Event.h" // for nsIDOMEvent::InternalDOMEvent() +#include "mozilla/dom/Event.h" // for Event #include "mozilla/dom/HTMLAreaElement.h" #include "mozilla/gfx/PathHelpers.h" #include "mozilla/UniquePtr.h" @@ -977,7 +977,7 @@ nsImageMap::ParentChainChanged(nsIContent* aContent) } nsresult -nsImageMap::HandleEvent(nsIDOMEvent* aEvent) +nsImageMap::HandleEvent(Event* aEvent) { nsAutoString eventType; aEvent->GetType(eventType); @@ -986,8 +986,7 @@ nsImageMap::HandleEvent(nsIDOMEvent* aEvent) "Unexpected event type"); //Set which one of our areas changed focus - nsCOMPtr targetContent = do_QueryInterface( - aEvent->InternalDOMEvent()->GetTarget()); + nsCOMPtr targetContent = do_QueryInterface(aEvent->GetTarget()); if (!targetContent) { return NS_OK; } diff --git a/layout/inspector/InspectorUtils.cpp b/layout/inspector/InspectorUtils.cpp index 418bbcba2a73..230686799e75 100644 --- a/layout/inspector/InspectorUtils.cpp +++ b/layout/inspector/InspectorUtils.cpp @@ -126,9 +126,8 @@ InspectorUtils::GetParentForNode(nsINode& aNode, // First do the special cases -- document nodes and anonymous content nsINode* parent = nullptr; - if (aNode.IsNodeOfType(nsINode::eDOCUMENT)) { - auto& doc = static_cast(aNode); - parent = inLayoutUtils::GetContainerFor(doc); + if (aNode.IsDocument()) { + parent = inLayoutUtils::GetContainerFor(*aNode.AsDocument()); } else if (aShowingAnonymousContent) { if (aNode.IsContent()) { parent = aNode.AsContent()->GetFlattenedTreeParent(); diff --git a/layout/mathml/nsMathMLmactionFrame.cpp b/layout/mathml/nsMathMLmactionFrame.cpp index 0b87a695f461..324b8c96f1dd 100644 --- a/layout/mathml/nsMathMLmactionFrame.cpp +++ b/layout/mathml/nsMathMLmactionFrame.cpp @@ -13,8 +13,10 @@ #include "nsIWebBrowserChrome.h" #include "nsIInterfaceRequestorUtils.h" #include "nsTextFragment.h" -#include "nsIDOMEvent.h" #include "mozilla/gfx/2D.h" +#include "mozilla/dom/Event.h" + +using mozilla::dom::Event; // // -- bind actions to a subexpression - implementation @@ -263,7 +265,7 @@ ShowStatus(nsPresContext* aPresContext, nsString& aStatusMsg) } NS_IMETHODIMP -nsMathMLmactionFrame::MouseListener::HandleEvent(nsIDOMEvent* aEvent) +nsMathMLmactionFrame::MouseListener::HandleEvent(Event* aEvent) { nsAutoString eventType; aEvent->GetType(eventType); diff --git a/layout/mathml/tests/test_disabled_chrome.html b/layout/mathml/tests/test_disabled_chrome.html index 9b0b01a871c2..e5064b499c4f 100644 --- a/layout/mathml/tests/test_disabled_chrome.html +++ b/layout/mathml/tests/test_disabled_chrome.html @@ -8,7 +8,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=744830 - + diff --git a/layout/printing/nsPrintJob.cpp b/layout/printing/nsPrintJob.cpp index 2149335ff643..c910b48669dc 100644 --- a/layout/printing/nsPrintJob.cpp +++ b/layout/printing/nsPrintJob.cpp @@ -2540,7 +2540,7 @@ GetCorrespondingNodeInDocument(const nsINode* aNode, nsIDocument* aDoc) indexArray.AppendElement(index); child = parent; } - MOZ_ASSERT(child->IsNodeOfType(nsINode::eDOCUMENT)); + MOZ_ASSERT(child->IsDocument()); nsINode* correspondingNode = aDoc; for (int32_t i = indexArray.Length() - 1; i >= 0; --i) { diff --git a/layout/printing/nsPrintPreviewListener.cpp b/layout/printing/nsPrintPreviewListener.cpp index 994fc4ed0a16..0d19491e3212 100644 --- a/layout/printing/nsPrintPreviewListener.cpp +++ b/layout/printing/nsPrintPreviewListener.cpp @@ -8,11 +8,10 @@ #include "mozilla/TextEvents.h" #include "mozilla/dom/Element.h" -#include "mozilla/dom/Event.h" // for nsIDOMEvent::InternalDOMEvent() +#include "mozilla/dom/Event.h" // for Event #include "nsIDOMWindow.h" #include "nsPIDOMWindow.h" #include "nsIDOMElement.h" -#include "nsIDOMEvent.h" #include "nsIDocument.h" #include "nsIDocShell.h" #include "nsPresContext.h" @@ -108,7 +107,7 @@ enum eEventAction { }; static eEventAction -GetActionForEvent(nsIDOMEvent* aEvent) +GetActionForEvent(Event* aEvent) { WidgetKeyboardEvent* keyEvent = aEvent->WidgetEventPtr()->AsKeyboardEvent(); @@ -157,10 +156,10 @@ GetActionForEvent(nsIDOMEvent* aEvent) } NS_IMETHODIMP -nsPrintPreviewListener::HandleEvent(nsIDOMEvent* aEvent) +nsPrintPreviewListener::HandleEvent(Event* aEvent) { nsCOMPtr content = do_QueryInterface( - aEvent ? aEvent->InternalDOMEvent()->GetOriginalTarget() : nullptr); + aEvent ? aEvent->GetOriginalTarget() : nullptr); if (content && !content->IsXULElement()) { eEventAction action = ::GetActionForEvent(aEvent); switch (action) { diff --git a/layout/reftests/w3c-css/submitted/flexbox/flexbox-definite-sizes-001-ref.html b/layout/reftests/w3c-css/submitted/flexbox/flexbox-definite-sizes-001-ref.html new file mode 100644 index 000000000000..ed0cc575f56b --- /dev/null +++ b/layout/reftests/w3c-css/submitted/flexbox/flexbox-definite-sizes-001-ref.html @@ -0,0 +1,13 @@ + + +CSS Test Reference + + +

Test passes if you see a green 100px x 100px square, and no red

+
diff --git a/layout/reftests/w3c-css/submitted/flexbox/flexbox-definite-sizes-001.html b/layout/reftests/w3c-css/submitted/flexbox/flexbox-definite-sizes-001.html new file mode 100644 index 000000000000..5bff6146e0eb --- /dev/null +++ b/layout/reftests/w3c-css/submitted/flexbox/flexbox-definite-sizes-001.html @@ -0,0 +1,30 @@ + + +CSS Test: nested flex containers with height established by 'min-height' + + + + + +

Test passes if you see a green 100px x 100px square, and no red

+
+
+ +
+
diff --git a/layout/reftests/w3c-css/submitted/flexbox/flexbox-definite-sizes-002.html b/layout/reftests/w3c-css/submitted/flexbox/flexbox-definite-sizes-002.html new file mode 100644 index 000000000000..126fd5e50c25 --- /dev/null +++ b/layout/reftests/w3c-css/submitted/flexbox/flexbox-definite-sizes-002.html @@ -0,0 +1,31 @@ + + +CSS Test: nested flex containers with height established by 'min-height' + + + + + +

Test passes if you see a green 100px x 100px square, and no red

+
+
+ +
+
diff --git a/layout/reftests/w3c-css/submitted/flexbox/flexbox-definite-sizes-003.html b/layout/reftests/w3c-css/submitted/flexbox/flexbox-definite-sizes-003.html new file mode 100644 index 000000000000..bc5b0751dbe3 --- /dev/null +++ b/layout/reftests/w3c-css/submitted/flexbox/flexbox-definite-sizes-003.html @@ -0,0 +1,38 @@ + + +CSS Test: nested flex containers with definite max-height + + + + + + +

Test passes if you see a green 100px x 100px square, and no red

+
+
+
+
+
diff --git a/layout/reftests/w3c-css/submitted/flexbox/flexbox-definite-sizes-004.html b/layout/reftests/w3c-css/submitted/flexbox/flexbox-definite-sizes-004.html new file mode 100644 index 000000000000..cf54aabe9936 --- /dev/null +++ b/layout/reftests/w3c-css/submitted/flexbox/flexbox-definite-sizes-004.html @@ -0,0 +1,38 @@ + + +CSS Test: nested flex containers with definite max-height + + + + + + +

Test passes if you see a green 100px x 100px square, and no red

+
+
+
+
+
diff --git a/layout/reftests/w3c-css/submitted/flexbox/reftest.list b/layout/reftests/w3c-css/submitted/flexbox/reftest.list index f7c1eb534944..4121cfc26166 100644 --- a/layout/reftests/w3c-css/submitted/flexbox/reftest.list +++ b/layout/reftests/w3c-css/submitted/flexbox/reftest.list @@ -134,6 +134,12 @@ fuzzy-if(Android,158,32) == flexbox-align-self-vert-rtl-001.xhtml flexbox-align == flexbox-intrinsic-ratio-006.html flexbox-intrinsic-ratio-006-ref.html == flexbox-intrinsic-ratio-006v.html flexbox-intrinsic-ratio-006-ref.html +# Test for definite and indefinite sizes. +== flexbox-definite-sizes-001.html flexbox-definite-sizes-001-ref.html +== flexbox-definite-sizes-002.html flexbox-definite-sizes-001-ref.html +== flexbox-definite-sizes-003.html flexbox-definite-sizes-001-ref.html +== flexbox-definite-sizes-004.html flexbox-definite-sizes-001-ref.html + # Tests for flex items as (pseudo) stacking contexts == flexbox-items-as-stacking-contexts-001.xhtml flexbox-items-as-stacking-contexts-001-ref.xhtml == flexbox-items-as-stacking-contexts-002.html flexbox-items-as-stacking-contexts-002-ref.html diff --git a/layout/style/FontFaceSet.cpp b/layout/style/FontFaceSet.cpp index 128496437c97..c1f68ce8a97e 100644 --- a/layout/style/FontFaceSet.cpp +++ b/layout/style/FontFaceSet.cpp @@ -10,6 +10,7 @@ #include "gfxFontSrcPrincipal.h" #include "gfxFontSrcURI.h" #include "mozilla/css/Loader.h" +#include "mozilla/dom/Event.h" #include "mozilla/dom/FontFaceSetBinding.h" #include "mozilla/dom/FontFaceSetIterator.h" #include "mozilla/dom/FontFaceSetLoadEvent.h" @@ -1754,7 +1755,7 @@ FontFaceSet::DispatchLoadingFinishedEvent( // nsIDOMEventListener NS_IMETHODIMP -FontFaceSet::HandleEvent(nsIDOMEvent* aEvent) +FontFaceSet::HandleEvent(Event* aEvent) { nsString type; aEvent->GetType(type); diff --git a/layout/style/ServoStyleSet.cpp b/layout/style/ServoStyleSet.cpp index c52f2e7054e9..fa5c74b472c8 100644 --- a/layout/style/ServoStyleSet.cpp +++ b/layout/style/ServoStyleSet.cpp @@ -1520,7 +1520,7 @@ ServoStyleSet::MayTraverseFrom(const Element* aElement) } if (!parent->IsElement()) { - MOZ_ASSERT(parent->IsNodeOfType(nsINode::eDOCUMENT)); + MOZ_ASSERT(parent->IsDocument()); return true; } diff --git a/layout/style/nsCSSValue.cpp b/layout/style/nsCSSValue.cpp index 50434480deb4..27d29ab68834 100644 --- a/layout/style/nsCSSValue.cpp +++ b/layout/style/nsCSSValue.cpp @@ -785,7 +785,11 @@ nsCSSValue::AppendAlignJustifyValueToString(int32_t aValue, nsAString& aResult) auto legacy = aValue & NS_STYLE_ALIGN_LEGACY; if (legacy) { aValue &= ~legacy; - aResult.AppendLiteral("legacy "); + aResult.AppendLiteral("legacy"); + if (!aValue) { + return; + } + aResult.AppendLiteral(" "); } // Don't serialize the 'unsafe' keyword; it's the default. auto overflowPos = aValue & (NS_STYLE_ALIGN_SAFE | NS_STYLE_ALIGN_UNSAFE); diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index 284e8c39eb41..2b6ed5c8d03e 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -1513,7 +1513,7 @@ nsStylePosition::nsStylePosition(const nsPresContext* aContext) , mAlignItems(NS_STYLE_ALIGN_NORMAL) , mAlignSelf(NS_STYLE_ALIGN_AUTO) , mJustifyContent(NS_STYLE_JUSTIFY_NORMAL) - , mSpecifiedJustifyItems(NS_STYLE_JUSTIFY_AUTO) + , mSpecifiedJustifyItems(NS_STYLE_JUSTIFY_LEGACY) , mJustifyItems(NS_STYLE_JUSTIFY_NORMAL) , mJustifySelf(NS_STYLE_JUSTIFY_AUTO) , mFlexDirection(NS_STYLE_FLEX_DIRECTION_ROW) diff --git a/layout/style/nsStyleUtil.cpp b/layout/style/nsStyleUtil.cpp index 39893f476306..2480b1f6404a 100644 --- a/layout/style/nsStyleUtil.cpp +++ b/layout/style/nsStyleUtil.cpp @@ -746,8 +746,7 @@ nsStyleUtil::IsSignificantChild(nsIContent* aChild, { bool isText = aChild->IsText(); - if (!isText && !aChild->IsNodeOfType(nsINode::eCOMMENT) && - !aChild->IsNodeOfType(nsINode::ePROCESSING_INSTRUCTION)) { + if (!isText && !aChild->IsComment() && !aChild->IsProcessingInstruction()) { return true; } @@ -762,8 +761,7 @@ nsStyleUtil::ThreadSafeIsSignificantChild(const nsIContent* aChild, { bool isText = aChild->IsText(); - if (!isText && !aChild->IsNodeOfType(nsINode::eCOMMENT) && - !aChild->IsNodeOfType(nsINode::ePROCESSING_INSTRUCTION)) { + if (!isText && !aChild->IsComment() && !aChild->IsProcessingInstruction()) { return true; } diff --git a/layout/style/test/chrome/bug418986-2.js b/layout/style/test/chrome/bug418986-2.js index 03d17329689c..007cb2da05fa 100644 --- a/layout/style/test/chrome/bug418986-2.js +++ b/layout/style/test/chrome/bug418986-2.js @@ -286,8 +286,7 @@ var sleep = function (timeoutMs) { // __testMediaQueriesInPictureElements(resisting)__. // Test to see if media queries are properly spoofed in picture elements -// when we are resisting fingerprinting. A generator function -// to be used with SpawnTask.js. +// when we are resisting fingerprinting. var testMediaQueriesInPictureElements = async function(resisting) { let picture = document.createElementNS(HTML_NS, "picture"); for (let [key, offVal, onVal] of expected_values) { @@ -327,8 +326,7 @@ var pushPref = function (key, value) { }; // __test(isContent)__. -// Run all tests. A generator function to be used -// with SpawnTask.js. +// Run all tests. var test = async function(isContent) { for (prefValue of [false, true]) { await pushPref("privacy.resistFingerprinting", prefValue); diff --git a/layout/style/test/chrome/test_bug418986-2.xul b/layout/style/test/chrome/test_bug418986-2.xul index 1e9b2bc58c17..2992950c1c36 100644 --- a/layout/style/test/chrome/test_bug418986-2.xul +++ b/layout/style/test/chrome/test_bug418986-2.xul @@ -7,7 +7,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=418986 diff --git a/layout/style/test/chrome/test_display_mode.html b/layout/style/test/chrome/test_display_mode.html index ccbd82e68b29..96af1aded06e 100644 --- a/layout/style/test/chrome/test_display_mode.html +++ b/layout/style/test/chrome/test_display_mode.html @@ -8,7 +8,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1104916 Test for Display Mode - + - + - + diff --git a/layout/style/test/test_restyles_in_smil_animation.html b/layout/style/test/test_restyles_in_smil_animation.html index f984dc688b6d..d184899f51ea 100644 --- a/layout/style/test/test_restyles_in_smil_animation.html +++ b/layout/style/test/test_restyles_in_smil_animation.html @@ -3,7 +3,7 @@ Tests restyles in smil animation - + diff --git a/layout/svg/tests/test_disabled_chrome.html b/layout/svg/tests/test_disabled_chrome.html index 55b2ade0015f..b7bed3ff0fae 100644 --- a/layout/svg/tests/test_disabled_chrome.html +++ b/layout/svg/tests/test_disabled_chrome.html @@ -5,7 +5,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=744830 --> - + diff --git a/layout/xul/MenuBoxObject.cpp b/layout/xul/MenuBoxObject.cpp index 041b70599565..6e880765f355 100644 --- a/layout/xul/MenuBoxObject.cpp +++ b/layout/xul/MenuBoxObject.cpp @@ -84,9 +84,7 @@ bool MenuBoxObject::HandleKeyPress(KeyboardEvent& keyEvent) } // if event has already been handled, bail - bool eventHandled = false; - keyEvent.GetDefaultPrevented(&eventHandled); - if (eventHandled) { + if (keyEvent.DefaultPrevented()) { return false; } diff --git a/layout/xul/nsBoxFrame.cpp b/layout/xul/nsBoxFrame.cpp index 620d54504547..ae6c14de4678 100644 --- a/layout/xul/nsBoxFrame.cpp +++ b/layout/xul/nsBoxFrame.cpp @@ -61,7 +61,6 @@ #include "nsITheme.h" #include "nsTransform2D.h" #include "mozilla/EventStateManager.h" -#include "nsIDOMEvent.h" #include "nsDisplayList.h" #include "mozilla/Preferences.h" #include "nsThemeConstants.h" diff --git a/layout/xul/nsButtonBoxFrame.cpp b/layout/xul/nsButtonBoxFrame.cpp index 65679843e73b..f33a6378c137 100644 --- a/layout/xul/nsButtonBoxFrame.cpp +++ b/layout/xul/nsButtonBoxFrame.cpp @@ -6,7 +6,6 @@ #include "nsCOMPtr.h" #include "nsButtonBoxFrame.h" #include "nsIContent.h" -#include "nsIDOMEvent.h" #include "nsIDOMNodeList.h" #include "nsIDOMXULButtonElement.h" #include "nsGkAtoms.h" @@ -17,6 +16,7 @@ #include "nsDisplayList.h" #include "nsContentUtils.h" #include "mozilla/dom/Element.h" +#include "mozilla/dom/Event.h" #include "mozilla/dom/MouseEventBinding.h" #include "mozilla/EventStateManager.h" #include "mozilla/EventStates.h" @@ -29,7 +29,7 @@ using namespace mozilla; NS_IMPL_ISUPPORTS(nsButtonBoxFrame::nsButtonBoxListener, nsIDOMEventListener) nsresult -nsButtonBoxFrame::nsButtonBoxListener::HandleEvent(nsIDOMEvent* aEvent) +nsButtonBoxFrame::nsButtonBoxListener::HandleEvent(dom::Event* aEvent) { if (!mButtonBoxFrame) { return NS_OK; diff --git a/layout/xul/nsButtonBoxFrame.h b/layout/xul/nsButtonBoxFrame.h index d8dc8cfb1292..4ba72291c2a4 100644 --- a/layout/xul/nsButtonBoxFrame.h +++ b/layout/xul/nsButtonBoxFrame.h @@ -58,7 +58,7 @@ private: mButtonBoxFrame(aButtonBoxFrame) { } - NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) override; + NS_DECL_NSIDOMEVENTLISTENER NS_DECL_ISUPPORTS diff --git a/layout/xul/nsDocElementBoxFrame.cpp b/layout/xul/nsDocElementBoxFrame.cpp index 4ddbed2f6ff4..1bb5cc2f34f1 100644 --- a/layout/xul/nsDocElementBoxFrame.cpp +++ b/layout/xul/nsDocElementBoxFrame.cpp @@ -8,7 +8,6 @@ #include "nsCSSRendering.h" #include "nsIDocument.h" #include "nsPageFrame.h" -#include "nsIDOMEvent.h" #include "nsStyleConsts.h" #include "nsGkAtoms.h" #include "nsIPresShell.h" diff --git a/layout/xul/nsMenuBarListener.cpp b/layout/xul/nsMenuBarListener.cpp index 6287102c4a85..f056339bc0f7 100644 --- a/layout/xul/nsMenuBarListener.cpp +++ b/layout/xul/nsMenuBarListener.cpp @@ -7,7 +7,6 @@ #include "nsMenuBarListener.h" #include "nsMenuBarFrame.h" #include "nsMenuPopupFrame.h" -#include "nsIDOMEvent.h" #include "nsPIWindowRoot.h" // Drag & Drop, Clipboard @@ -22,10 +21,13 @@ #include "mozilla/BasicEvents.h" #include "mozilla/Preferences.h" #include "mozilla/TextEvents.h" +#include "mozilla/dom/Event.h" +#include "mozilla/dom/EventBinding.h" #include "mozilla/dom/KeyboardEvent.h" #include "mozilla/dom/KeyboardEventBinding.h" using namespace mozilla; +using mozilla::dom::Event; using mozilla::dom::KeyboardEvent; /* @@ -191,10 +193,9 @@ nsMenuBarListener::ToggleMenuActiveState() //////////////////////////////////////////////////////////////////////// nsresult -nsMenuBarListener::KeyUp(nsIDOMEvent* aKeyEvent) +nsMenuBarListener::KeyUp(Event* aKeyEvent) { - RefPtr keyEvent = - aKeyEvent->InternalDOMEvent()->AsKeyboardEvent(); + RefPtr keyEvent = aKeyEvent->AsKeyboardEvent(); if (!keyEvent) { return NS_OK; } @@ -256,24 +257,15 @@ nsMenuBarListener::KeyUp(nsIDOMEvent* aKeyEvent) //////////////////////////////////////////////////////////////////////// nsresult -nsMenuBarListener::KeyPress(nsIDOMEvent* aKeyEvent) +nsMenuBarListener::KeyPress(Event* aKeyEvent) { // if event has already been handled, bail - if (aKeyEvent) { - bool eventHandled = false; - aKeyEvent->GetDefaultPrevented(&eventHandled); - if (eventHandled) { - return NS_OK; // don't consume event - } + if (!aKeyEvent || aKeyEvent->DefaultPrevented()) { + return NS_OK; // don't consume event } //handlers shouldn't be triggered by non-trusted events. - bool trustedEvent = false; - if (aKeyEvent) { - aKeyEvent->GetIsTrusted(&trustedEvent); - } - - if (!trustedEvent) { + if (!aKeyEvent->IsTrusted()) { return NS_OK; } @@ -289,8 +281,7 @@ nsMenuBarListener::KeyPress(nsIDOMEvent* aKeyEvent) return NS_OK; } - RefPtr keyEvent = - aKeyEvent->InternalDOMEvent()->AsKeyboardEvent(); + RefPtr keyEvent = aKeyEvent->AsKeyboardEvent(); uint32_t keyCode = keyEvent->KeyCode(); // Cancel the access key flag unless we are pressing the access key. @@ -418,7 +409,7 @@ nsMenuBarListener::GetMenuForKeyEvent(KeyboardEvent* aKeyEvent, bool aPeek) } void -nsMenuBarListener::ReserveKeyIfNeeded(nsIDOMEvent* aKeyEvent) +nsMenuBarListener::ReserveKeyIfNeeded(Event* aKeyEvent) { WidgetKeyboardEvent* nativeKeyEvent = aKeyEvent->WidgetEventPtr()->AsKeyboardEvent(); @@ -429,22 +420,16 @@ nsMenuBarListener::ReserveKeyIfNeeded(nsIDOMEvent* aKeyEvent) //////////////////////////////////////////////////////////////////////// nsresult -nsMenuBarListener::KeyDown(nsIDOMEvent* aKeyEvent) +nsMenuBarListener::KeyDown(Event* aKeyEvent) { InitAccessKey(); //handlers shouldn't be triggered by non-trusted events. - bool trustedEvent = false; - if (aKeyEvent) { - aKeyEvent->GetIsTrusted(&trustedEvent); - } - - if (!trustedEvent) { + if (!aKeyEvent || !aKeyEvent->IsTrusted()) { return NS_OK; } - RefPtr keyEvent = - aKeyEvent->InternalDOMEvent()->AsKeyboardEvent(); + RefPtr keyEvent = aKeyEvent->AsKeyboardEvent(); if (!keyEvent) { return NS_OK; } @@ -452,7 +437,7 @@ nsMenuBarListener::KeyDown(nsIDOMEvent* aKeyEvent) uint32_t theChar = keyEvent->KeyCode(); uint16_t eventPhase = keyEvent->EventPhase(); - bool capturing = (eventPhase == nsIDOMEvent::CAPTURING_PHASE); + bool capturing = (eventPhase == dom::EventBinding::CAPTURING_PHASE); #ifndef XP_MACOSX if (capturing && !mAccessKeyDown && theChar == NS_VK_F10 && @@ -463,8 +448,7 @@ nsMenuBarListener::KeyDown(nsIDOMEvent* aKeyEvent) if (mAccessKey && mAccessKeyFocuses) { - bool defaultPrevented = false; - aKeyEvent->GetDefaultPrevented(&defaultPrevented); + bool defaultPrevented = aKeyEvent->DefaultPrevented(); // No other modifiers can be down. // Especially CTRL. CTRL+ALT == AltGR, and we'll fuck up on non-US @@ -511,7 +495,7 @@ nsMenuBarListener::KeyDown(nsIDOMEvent* aKeyEvent) //////////////////////////////////////////////////////////////////////// nsresult -nsMenuBarListener::Blur(nsIDOMEvent* aEvent) +nsMenuBarListener::Blur(Event* aEvent) { if (!mMenuBarFrame->IsMenuOpen() && mMenuBarFrame->IsActive()) { ToggleMenuActiveState(); @@ -524,7 +508,7 @@ nsMenuBarListener::Blur(nsIDOMEvent* aEvent) //////////////////////////////////////////////////////////////////////// nsresult -nsMenuBarListener::OnWindowDeactivated(nsIDOMEvent* aEvent) +nsMenuBarListener::OnWindowDeactivated(Event* aEvent) { // Reset the accesskey state because we cannot receive the keyup event for // the pressing accesskey. @@ -535,7 +519,7 @@ nsMenuBarListener::OnWindowDeactivated(nsIDOMEvent* aEvent) //////////////////////////////////////////////////////////////////////// nsresult -nsMenuBarListener::MouseDown(nsIDOMEvent* aMouseEvent) +nsMenuBarListener::MouseDown(Event* aMouseEvent) { // NOTE: MouseDown method listens all phases @@ -546,11 +530,8 @@ nsMenuBarListener::MouseDown(nsIDOMEvent* aMouseEvent) mAccessKeyDownCanceled = true; } - uint16_t phase = 0; - nsresult rv = aMouseEvent->GetEventPhase(&phase); - NS_ENSURE_SUCCESS(rv, rv); // Don't do anything at capturing phase, any behavior should be cancelable. - if (phase == nsIDOMEvent::CAPTURING_PHASE) { + if (aMouseEvent->EventPhase() == dom::EventBinding::CAPTURING_PHASE) { return NS_OK; } @@ -563,7 +544,7 @@ nsMenuBarListener::MouseDown(nsIDOMEvent* aMouseEvent) //////////////////////////////////////////////////////////////////////// nsresult -nsMenuBarListener::Fullscreen(nsIDOMEvent* aEvent) +nsMenuBarListener::Fullscreen(Event* aEvent) { if (mMenuBarFrame->IsActive()) { ToggleMenuActiveState(); @@ -573,7 +554,7 @@ nsMenuBarListener::Fullscreen(nsIDOMEvent* aEvent) //////////////////////////////////////////////////////////////////////// nsresult -nsMenuBarListener::HandleEvent(nsIDOMEvent* aEvent) +nsMenuBarListener::HandleEvent(Event* aEvent) { // If the menu bar is collapsed, don't do anything. if (!mMenuBarFrame->StyleVisibility()->IsVisible()) { diff --git a/layout/xul/nsMenuBarListener.h b/layout/xul/nsMenuBarListener.h index 9a5f08edc7f7..584f0edcabab 100644 --- a/layout/xul/nsMenuBarListener.h +++ b/layout/xul/nsMenuBarListener.h @@ -39,7 +39,7 @@ public: /** * nsIDOMEventListener interface method. */ - NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) override; + NS_DECL_NSIDOMEVENTLISTENER /** * When mMenuBarFrame is being destroyed, this should be called. @@ -63,13 +63,13 @@ public: protected: virtual ~nsMenuBarListener(); - nsresult KeyUp(nsIDOMEvent* aMouseEvent); - nsresult KeyDown(nsIDOMEvent* aMouseEvent); - nsresult KeyPress(nsIDOMEvent* aMouseEvent); - nsresult Blur(nsIDOMEvent* aEvent); - nsresult OnWindowDeactivated(nsIDOMEvent* aEvent); - nsresult MouseDown(nsIDOMEvent* aMouseEvent); - nsresult Fullscreen(nsIDOMEvent* aEvent); + nsresult KeyUp(mozilla::dom::Event* aMouseEvent); + nsresult KeyDown(mozilla::dom::Event* aMouseEvent); + nsresult KeyPress(mozilla::dom::Event* aMouseEvent); + nsresult Blur(mozilla::dom::Event* aEvent); + nsresult OnWindowDeactivated(mozilla::dom::Event* aEvent); + nsresult MouseDown(mozilla::dom::Event* aMouseEvent); + nsresult Fullscreen(mozilla::dom::Event* aEvent); static void InitAccessKey(); @@ -87,7 +87,7 @@ protected: * Call MarkAsReservedByChrome if the user's preferences indicate that * the key should be chrome-only. */ - void ReserveKeyIfNeeded(nsIDOMEvent* aKeyEvent); + void ReserveKeyIfNeeded(mozilla::dom::Event* aKeyEvent); // This should only be called by the nsMenuBarListener during event dispatch, // thus ensuring that this doesn't get destroyed during the process. diff --git a/layout/xul/nsMenuPopupFrame.cpp b/layout/xul/nsMenuPopupFrame.cpp index fd580886d9e2..2d83c08345fd 100644 --- a/layout/xul/nsMenuPopupFrame.cpp +++ b/layout/xul/nsMenuPopupFrame.cpp @@ -18,7 +18,6 @@ #include "nsMenuBarFrame.h" #include "nsPopupSetFrame.h" #include "nsPIDOMWindow.h" -#include "nsIDOMEvent.h" #include "nsIDOMXULMenuListElement.h" #include "nsIPresShell.h" #include "nsFrameManager.h" @@ -60,6 +59,7 @@ using namespace mozilla; using mozilla::dom::KeyboardEvent; +using mozilla::dom::Event; int8_t nsMenuPopupFrame::sDefaultLevelIsTop = -1; @@ -391,14 +391,12 @@ NS_IMETHODIMP nsXULPopupShownEvent::Run() return EventDispatcher::Dispatch(mPopup, mPresContext, &event); } -NS_IMETHODIMP nsXULPopupShownEvent::HandleEvent(nsIDOMEvent* aEvent) +NS_IMETHODIMP nsXULPopupShownEvent::HandleEvent(Event* aEvent) { nsMenuPopupFrame* popup = do_QueryFrame(mPopup->GetPrimaryFrame()); - nsCOMPtr eventTarget; - aEvent->GetTarget(getter_AddRefs(eventTarget)); // Ignore events not targeted at the popup itself (ie targeted at // descendants): - if (!SameCOMIdentity(mPopup, eventTarget)) { + if (mPopup != aEvent->GetTarget()) { return NS_OK; } if (popup) { diff --git a/layout/xul/nsSliderFrame.cpp b/layout/xul/nsSliderFrame.cpp index 693650cb28c8..364f4b9118e0 100644 --- a/layout/xul/nsSliderFrame.cpp +++ b/layout/xul/nsSliderFrame.cpp @@ -23,7 +23,6 @@ #include "nsHTMLParts.h" #include "nsIPresShell.h" #include "nsCSSRendering.h" -#include "nsIDOMEvent.h" #include "nsScrollbarButtonFrame.h" #include "nsISliderListener.h" #include "nsIScrollableFrame.h" @@ -44,6 +43,7 @@ #include "mozilla/LookAndFeel.h" #include "mozilla/MouseEvents.h" #include "mozilla/Telemetry.h" +#include "mozilla/dom/Event.h" #include "mozilla/layers/APZCCallbackHelper.h" #include "mozilla/layers/AsyncDragMetrics.h" #include "mozilla/layers/InputAPZContext.h" @@ -1002,7 +1002,7 @@ nsSliderFrame::SetInitialChildList(ChildListID aListID, } nsresult -nsSliderMediator::HandleEvent(nsIDOMEvent* aEvent) +nsSliderMediator::HandleEvent(dom::Event* aEvent) { // Only process the event if the thumb is not being dragged. if (mSlider && !mSlider->isDraggingThumb()) @@ -1162,7 +1162,7 @@ nsSliderFrame::StartAPZDrag(WidgetGUIEvent* aEvent) } nsresult -nsSliderFrame::StartDrag(nsIDOMEvent* aEvent) +nsSliderFrame::StartDrag(Event* aEvent) { #ifdef DEBUG_SLIDER printf("Begin dragging\n"); diff --git a/layout/xul/nsSliderFrame.h b/layout/xul/nsSliderFrame.h index cc837c4d7b6e..74505ca05b37 100644 --- a/layout/xul/nsSliderFrame.h +++ b/layout/xul/nsSliderFrame.h @@ -32,7 +32,7 @@ public: virtual void SetSlider(nsSliderFrame* aSlider) { mSlider = aSlider; } - NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) override; + NS_DECL_NSIDOMEVENTLISTENER protected: virtual ~nsSliderMediator() {} @@ -93,7 +93,7 @@ public: virtual void RemoveFrame(ChildListID aListID, nsIFrame* aOldFrame) override; - nsresult StartDrag(nsIDOMEvent* aEvent); + nsresult StartDrag(mozilla::dom::Event* aEvent); nsresult StopDrag(); void StartAPZDrag(mozilla::WidgetGUIEvent* aEvent); diff --git a/layout/xul/nsSplitterFrame.cpp b/layout/xul/nsSplitterFrame.cpp index 4cd3819b8a83..883cf0e293bd 100644 --- a/layout/xul/nsSplitterFrame.cpp +++ b/layout/xul/nsSplitterFrame.cpp @@ -70,9 +70,9 @@ public: void Disconnect() { mOuter = nullptr; } - nsresult MouseDown(nsIDOMEvent* aMouseEvent); - nsresult MouseUp(nsIDOMEvent* aMouseEvent); - nsresult MouseMove(nsIDOMEvent* aMouseEvent); + nsresult MouseDown(Event* aMouseEvent); + nsresult MouseUp(Event* aMouseEvent); + nsresult MouseMove(Event* aMouseEvent); void MouseDrag(nsPresContext* aPresContext, WidgetGUIEvent* aEvent); void MouseUp(nsPresContext* aPresContext, WidgetGUIEvent* aEvent); @@ -567,7 +567,7 @@ nsSplitterFrameInner::RemoveListener() } nsresult -nsSplitterFrameInner::HandleEvent(nsIDOMEvent* aEvent) +nsSplitterFrameInner::HandleEvent(dom::Event* aEvent) { nsAutoString eventType; aEvent->GetType(eventType); @@ -584,7 +584,7 @@ nsSplitterFrameInner::HandleEvent(nsIDOMEvent* aEvent) } nsresult -nsSplitterFrameInner::MouseUp(nsIDOMEvent* aMouseEvent) +nsSplitterFrameInner::MouseUp(Event* aMouseEvent) { NS_ENSURE_TRUE(mOuter, NS_OK); mPressed = false; @@ -595,10 +595,10 @@ nsSplitterFrameInner::MouseUp(nsIDOMEvent* aMouseEvent) } nsresult -nsSplitterFrameInner::MouseDown(nsIDOMEvent* aMouseEvent) +nsSplitterFrameInner::MouseDown(Event* aMouseEvent) { NS_ENSURE_TRUE(mOuter, NS_OK); - dom::MouseEvent* mouseEvent = aMouseEvent->InternalDOMEvent()->AsMouseEvent(); + dom::MouseEvent* mouseEvent = aMouseEvent->AsMouseEvent(); if (!mouseEvent) { return NS_OK; } @@ -762,7 +762,7 @@ nsSplitterFrameInner::MouseDown(nsIDOMEvent* aMouseEvent) } nsresult -nsSplitterFrameInner::MouseMove(nsIDOMEvent* aMouseEvent) +nsSplitterFrameInner::MouseMove(Event* aMouseEvent) { NS_ENSURE_TRUE(mOuter, NS_OK); if (!mPressed) diff --git a/layout/xul/nsXULPopupManager.cpp b/layout/xul/nsXULPopupManager.cpp index 8ab58c428b20..73d03e0e00ca 100644 --- a/layout/xul/nsXULPopupManager.cpp +++ b/layout/xul/nsXULPopupManager.cpp @@ -12,7 +12,6 @@ #include "nsMenuBarListener.h" #include "nsContentUtils.h" #include "nsIDOMDocument.h" -#include "nsIDOMEvent.h" #include "nsXULElement.h" #include "nsIDOMXULMenuListElement.h" #include "nsIDOMXULCommandDispatcher.h" @@ -34,7 +33,7 @@ #include "nsIObserverService.h" #include "XULDocument.h" #include "mozilla/dom/Element.h" -#include "mozilla/dom/Event.h" // for nsIDOMEvent::InternalDOMEvent() +#include "mozilla/dom/Event.h" // for Event #include "mozilla/dom/KeyboardEvent.h" #include "mozilla/dom/KeyboardEventBinding.h" #include "mozilla/dom/MouseEvent.h" @@ -618,7 +617,7 @@ nsXULPopupManager::MouseLocationOffset() } void -nsXULPopupManager::InitTriggerEvent(nsIDOMEvent* aEvent, nsIContent* aPopup, +nsXULPopupManager::InitTriggerEvent(Event* aEvent, nsIContent* aPopup, nsIContent** aTriggerContent) { mCachedMousePoint = LayoutDeviceIntPoint(0, 0); @@ -627,15 +626,14 @@ nsXULPopupManager::InitTriggerEvent(nsIDOMEvent* aEvent, nsIContent* aPopup, *aTriggerContent = nullptr; if (aEvent) { // get the trigger content from the event - nsCOMPtr target = do_QueryInterface( - aEvent->InternalDOMEvent()->GetTarget()); + nsCOMPtr target = do_QueryInterface(aEvent->GetTarget()); target.forget(aTriggerContent); } } mCachedModifiers = 0; - UIEvent* uiEvent = aEvent ? aEvent->InternalDOMEvent()->AsUIEvent() : nullptr; + UIEvent* uiEvent = aEvent ? aEvent->AsUIEvent() : nullptr; if (uiEvent) { mRangeParent = uiEvent->GetRangeParent(); mRangeOffset = uiEvent->RangeOffset(); @@ -665,7 +663,7 @@ nsXULPopupManager::InitTriggerEvent(nsIDOMEvent* aEvent, nsIContent* aPopup, event->mClass == eWheelEventClass) && !event->AsGUIEvent()->mWidget) { // no widget, so just use the client point if available - MouseEvent* mouseEvent = aEvent->InternalDOMEvent()->AsMouseEvent(); + MouseEvent* mouseEvent = aEvent->AsMouseEvent(); nsIntPoint clientPt(mouseEvent->ClientX(), mouseEvent->ClientY()); // XXX this doesn't handle IFRAMEs in transforms @@ -775,7 +773,7 @@ nsXULPopupManager::ShowPopup(nsIContent* aPopup, bool aIsContextMenu, bool aAttributesOverride, bool aSelectFirstItem, - nsIDOMEvent* aTriggerEvent) + Event* aTriggerEvent) { nsMenuPopupFrame* popupFrame = GetPopupFrameForContent(aPopup, true); if (!popupFrame || !MayShowPopup(popupFrame)) @@ -794,7 +792,7 @@ void nsXULPopupManager::ShowPopupAtScreen(nsIContent* aPopup, int32_t aXPos, int32_t aYPos, bool aIsContextMenu, - nsIDOMEvent* aTriggerEvent) + Event* aTriggerEvent) { nsMenuPopupFrame* popupFrame = GetPopupFrameForContent(aPopup, true); if (!popupFrame || !MayShowPopup(popupFrame)) @@ -813,7 +811,7 @@ nsXULPopupManager::ShowPopupAtScreenRect(nsIContent* aPopup, const nsIntRect& aRect, bool aIsContextMenu, bool aAttributesOverride, - nsIDOMEvent* aTriggerEvent) + Event* aTriggerEvent) { nsMenuPopupFrame* popupFrame = GetPopupFrameForContent(aPopup, true); if (!popupFrame || !MayShowPopup(popupFrame)) @@ -1113,7 +1111,7 @@ public: { } - NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) override + NS_IMETHOD HandleEvent(Event* aEvent) override { mContent->RemoveSystemEventListener(NS_LITERAL_STRING("transitionend"), this, false); @@ -1427,7 +1425,7 @@ void nsXULPopupManager::FirePopupShowingEvent(nsIContent* aPopup, bool aIsContextMenu, bool aSelectFirstItem, - nsIDOMEvent* aTriggerEvent) + Event* aTriggerEvent) { nsCOMPtr popup = aPopup; // keep a strong reference to the popup @@ -2612,10 +2610,9 @@ nsXULPopupManager::IsValidMenuItem(nsIContent* aContent, bool aOnPopup) } nsresult -nsXULPopupManager::HandleEvent(nsIDOMEvent* aEvent) +nsXULPopupManager::HandleEvent(Event* aEvent) { - RefPtr keyEvent = - aEvent->InternalDOMEvent()->AsKeyboardEvent(); + RefPtr keyEvent = aEvent->AsKeyboardEvent(); NS_ENSURE_TRUE(keyEvent, NS_ERROR_UNEXPECTED); //handlers shouldn't be triggered by non-trusted events. diff --git a/layout/xul/nsXULPopupManager.h b/layout/xul/nsXULPopupManager.h index d0bf97138fec..1bcbccee2170 100644 --- a/layout/xul/nsXULPopupManager.h +++ b/layout/xul/nsXULPopupManager.h @@ -58,6 +58,7 @@ class nsRefreshDriver; namespace mozilla { namespace dom { +class Event; class KeyboardEvent; } // namespace dom } // namespace mozilla @@ -458,7 +459,7 @@ public: bool aIsContextMenu, bool aAttributesOverride, bool aSelectFirstItem, - nsIDOMEvent* aTriggerEvent); + mozilla::dom::Event* aTriggerEvent); /** * Open a popup at a specific screen position specified by aXPos and aYPos, @@ -473,7 +474,7 @@ public: void ShowPopupAtScreen(nsIContent* aPopup, int32_t aXPos, int32_t aYPos, bool aIsContextMenu, - nsIDOMEvent* aTriggerEvent); + mozilla::dom::Event* aTriggerEvent); /* Open a popup anchored at a screen rectangle specified by aRect. * The remaining arguments are similar to ShowPopup. @@ -483,7 +484,7 @@ public: const nsIntRect& aRect, bool aIsContextMenu, bool aAttributesOverride, - nsIDOMEvent* aTriggerEvent); + mozilla::dom::Event* aTriggerEvent); /** * Open a tooltip at a specific screen position specified by aXPos and aYPos, @@ -725,7 +726,7 @@ protected: // set the event that was used to trigger the popup, or null to clear the // event details. aTriggerContent will be set to the target of the event. - void InitTriggerEvent(nsIDOMEvent* aEvent, nsIContent* aPopup, nsIContent** aTriggerContent); + void InitTriggerEvent(mozilla::dom::Event* aEvent, nsIContent* aPopup, nsIContent** aTriggerContent); // callbacks for ShowPopup and HidePopup as events may be done asynchronously void ShowPopupCallback(nsIContent* aPopup, @@ -752,7 +753,7 @@ protected: void FirePopupShowingEvent(nsIContent* aPopup, bool aIsContextMenu, bool aSelectFirstItem, - nsIDOMEvent* aTriggerEvent); + mozilla::dom::Event* aTriggerEvent); /** * Fire a popuphiding event and then hide the popup. This will be called diff --git a/layout/xul/nsXULTooltipListener.cpp b/layout/xul/nsXULTooltipListener.cpp index d26d36443073..b89b33ec27db 100644 --- a/layout/xul/nsXULTooltipListener.cpp +++ b/layout/xul/nsXULTooltipListener.cpp @@ -27,7 +27,7 @@ #include "mozilla/Preferences.h" #include "mozilla/LookAndFeel.h" #include "mozilla/dom/Element.h" -#include "mozilla/dom/Event.h" // for nsIDOMEvent::InternalDOMEvent() +#include "mozilla/dom/Event.h" // for Event #include "mozilla/dom/BoxObject.h" #include "mozilla/dom/MouseEvent.h" #include "mozilla/TextEvents.h" @@ -75,7 +75,7 @@ nsXULTooltipListener::~nsXULTooltipListener() NS_IMPL_ISUPPORTS(nsXULTooltipListener, nsIDOMEventListener) void -nsXULTooltipListener::MouseOut(nsIDOMEvent* aEvent) +nsXULTooltipListener::MouseOut(Event* aEvent) { // reset flag so that tooltip will display on the next MouseMove mTooltipShownOnce = false; @@ -100,8 +100,7 @@ nsXULTooltipListener::MouseOut(nsIDOMEvent* aEvent) // hide the tooltip if (currentTooltip) { // which node did the mouse leave? - nsCOMPtr targetNode = do_QueryInterface( - aEvent->InternalDOMEvent()->GetTarget()); + nsCOMPtr targetNode = do_QueryInterface(aEvent->GetTarget()); nsXULPopupManager* pm = nsXULPopupManager::GetInstance(); if (pm) { @@ -123,7 +122,7 @@ nsXULTooltipListener::MouseOut(nsIDOMEvent* aEvent) } void -nsXULTooltipListener::MouseMove(nsIDOMEvent* aEvent) +nsXULTooltipListener::MouseMove(Event* aEvent) { if (!sShowTooltips) return; @@ -132,7 +131,7 @@ nsXULTooltipListener::MouseMove(nsIDOMEvent* aEvent) // timer callback. On win32, we'll get a MouseMove event even when a popup goes away -- // even when the mouse doesn't change position! To get around this, we make sure the // mouse has really moved before proceeding. - MouseEvent* mouseEvent = aEvent->InternalDOMEvent()->AsMouseEvent(); + MouseEvent* mouseEvent = aEvent->AsMouseEvent(); if (!mouseEvent) { return; } @@ -154,8 +153,8 @@ nsXULTooltipListener::MouseMove(nsIDOMEvent* aEvent) mMouseScreenX = newMouseX; mMouseScreenY = newMouseY; - nsCOMPtr sourceContent = do_QueryInterface( - aEvent->InternalDOMEvent()->GetCurrentTarget()); + nsCOMPtr sourceContent = + do_QueryInterface(aEvent->GetCurrentTarget()); mSourceNode = do_GetWeakReference(sourceContent); #ifdef MOZ_XUL mIsSourceTree = sourceContent->IsXULElement(nsGkAtoms::treechildren); @@ -172,7 +171,7 @@ nsXULTooltipListener::MouseMove(nsIDOMEvent* aEvent) // showing and the tooltip hasn't been displayed since the mouse entered // the node, then start the timer to show the tooltip. if (!currentTooltip && !mTooltipShownOnce) { - nsCOMPtr eventTarget = aEvent->InternalDOMEvent()->GetTarget(); + nsCOMPtr eventTarget = aEvent->GetTarget(); // don't show tooltips attached to elements outside of a menu popup // when hovering over an element inside it. The popupsinherittooltip @@ -224,7 +223,7 @@ nsXULTooltipListener::MouseMove(nsIDOMEvent* aEvent) } NS_IMETHODIMP -nsXULTooltipListener::HandleEvent(nsIDOMEvent* aEvent) +nsXULTooltipListener::HandleEvent(Event* aEvent) { nsAutoString type; aEvent->GetType(type); diff --git a/layout/xul/nsXULTooltipListener.h b/layout/xul/nsXULTooltipListener.h index 48b36e6fdf85..0119ef6af441 100644 --- a/layout/xul/nsXULTooltipListener.h +++ b/layout/xul/nsXULTooltipListener.h @@ -23,6 +23,7 @@ class nsIContent; namespace mozilla { namespace dom { +class Event; class MouseEvent; } // namespace dom } // namespace mozilla @@ -33,8 +34,8 @@ public: NS_DECL_ISUPPORTS NS_DECL_NSIDOMEVENTLISTENER - void MouseOut(nsIDOMEvent* aEvent); - void MouseMove(nsIDOMEvent* aEvent); + void MouseOut(mozilla::dom::Event* aEvent); + void MouseMove(mozilla::dom::Event* aEvent); void AddTooltipSupport(nsIContent* aNode); void RemoveTooltipSupport(nsIContent* aNode); diff --git a/mobile/android/components/extensions/test/mochitest/test_ext_activeTab_permission.html b/mobile/android/components/extensions/test/mochitest/test_ext_activeTab_permission.html index 34634fe063f7..6b56b9306920 100644 --- a/mobile/android/components/extensions/test/mochitest/test_ext_activeTab_permission.html +++ b/mobile/android/components/extensions/test/mochitest/test_ext_activeTab_permission.html @@ -3,7 +3,7 @@ PageAction Test - + diff --git a/mobile/android/components/extensions/test/mochitest/test_ext_all_apis.html b/mobile/android/components/extensions/test/mochitest/test_ext_all_apis.html index db859bdfb393..cfa7299308ec 100644 --- a/mobile/android/components/extensions/test/mochitest/test_ext_all_apis.html +++ b/mobile/android/components/extensions/test/mochitest/test_ext_all_apis.html @@ -4,7 +4,7 @@ WebExtension test - + diff --git a/mobile/android/components/extensions/test/mochitest/test_ext_browserAction_getPopup_setPopup.html b/mobile/android/components/extensions/test/mochitest/test_ext_browserAction_getPopup_setPopup.html index a00fe3c853cc..3302db3ae0a9 100644 --- a/mobile/android/components/extensions/test/mochitest/test_ext_browserAction_getPopup_setPopup.html +++ b/mobile/android/components/extensions/test/mochitest/test_ext_browserAction_getPopup_setPopup.html @@ -3,7 +3,7 @@ BrowserAction Test - + diff --git a/mobile/android/components/extensions/test/mochitest/test_ext_browserAction_getTitle_setTitle.html b/mobile/android/components/extensions/test/mochitest/test_ext_browserAction_getTitle_setTitle.html index f9f39f2d1b62..5e7b47c3b0dd 100644 --- a/mobile/android/components/extensions/test/mochitest/test_ext_browserAction_getTitle_setTitle.html +++ b/mobile/android/components/extensions/test/mochitest/test_ext_browserAction_getTitle_setTitle.html @@ -3,7 +3,7 @@ BrowserAction Test - + diff --git a/mobile/android/components/extensions/test/mochitest/test_ext_browserAction_onClicked.html b/mobile/android/components/extensions/test/mochitest/test_ext_browserAction_onClicked.html index ec08dfb7b948..a72840fa2cd0 100644 --- a/mobile/android/components/extensions/test/mochitest/test_ext_browserAction_onClicked.html +++ b/mobile/android/components/extensions/test/mochitest/test_ext_browserAction_onClicked.html @@ -3,7 +3,7 @@ BrowserAction Test - + diff --git a/mobile/android/components/extensions/test/mochitest/test_ext_browsingData_cookies_cache.html b/mobile/android/components/extensions/test/mochitest/test_ext_browsingData_cookies_cache.html index 79504edb53b2..301629daabd5 100644 --- a/mobile/android/components/extensions/test/mochitest/test_ext_browsingData_cookies_cache.html +++ b/mobile/android/components/extensions/test/mochitest/test_ext_browsingData_cookies_cache.html @@ -3,7 +3,7 @@ BrowsingData Cookies test - + diff --git a/mobile/android/components/extensions/test/mochitest/test_ext_browsingData_downloads.html b/mobile/android/components/extensions/test/mochitest/test_ext_browsingData_downloads.html index 254b8c190161..df389c3f7c2b 100644 --- a/mobile/android/components/extensions/test/mochitest/test_ext_browsingData_downloads.html +++ b/mobile/android/components/extensions/test/mochitest/test_ext_browsingData_downloads.html @@ -3,7 +3,7 @@ BrowsingData Settings test - + diff --git a/mobile/android/components/extensions/test/mochitest/test_ext_browsingData_formdata.html b/mobile/android/components/extensions/test/mochitest/test_ext_browsingData_formdata.html index 73da8c738d97..cd18444b76d8 100644 --- a/mobile/android/components/extensions/test/mochitest/test_ext_browsingData_formdata.html +++ b/mobile/android/components/extensions/test/mochitest/test_ext_browsingData_formdata.html @@ -3,7 +3,7 @@ BrowsingData FormData test - + diff --git a/mobile/android/components/extensions/test/mochitest/test_ext_browsingData_settings.html b/mobile/android/components/extensions/test/mochitest/test_ext_browsingData_settings.html index ff8bc5089401..b603a625d118 100644 --- a/mobile/android/components/extensions/test/mochitest/test_ext_browsingData_settings.html +++ b/mobile/android/components/extensions/test/mochitest/test_ext_browsingData_settings.html @@ -3,7 +3,7 @@ BrowsingData Settings test - + diff --git a/mobile/android/components/extensions/test/mochitest/test_ext_options_ui.html b/mobile/android/components/extensions/test/mochitest/test_ext_options_ui.html index 8c4a925220fd..ebf4fff68842 100644 --- a/mobile/android/components/extensions/test/mochitest/test_ext_options_ui.html +++ b/mobile/android/components/extensions/test/mochitest/test_ext_options_ui.html @@ -3,7 +3,7 @@ PageAction Test - + diff --git a/mobile/android/components/extensions/test/mochitest/test_ext_pageAction_getPopup_setPopup.html b/mobile/android/components/extensions/test/mochitest/test_ext_pageAction_getPopup_setPopup.html index f786b7751437..8b7419301e29 100644 --- a/mobile/android/components/extensions/test/mochitest/test_ext_pageAction_getPopup_setPopup.html +++ b/mobile/android/components/extensions/test/mochitest/test_ext_pageAction_getPopup_setPopup.html @@ -3,7 +3,7 @@ PageAction Test - + diff --git a/mobile/android/components/extensions/test/mochitest/test_ext_pageAction_show_hide.html b/mobile/android/components/extensions/test/mochitest/test_ext_pageAction_show_hide.html index 9603f53f6ca2..e026312904fa 100644 --- a/mobile/android/components/extensions/test/mochitest/test_ext_pageAction_show_hide.html +++ b/mobile/android/components/extensions/test/mochitest/test_ext_pageAction_show_hide.html @@ -3,7 +3,7 @@ PageAction Test - + diff --git a/mobile/android/components/extensions/test/mochitest/test_ext_popup_behavior.html b/mobile/android/components/extensions/test/mochitest/test_ext_popup_behavior.html index 235faabea344..e2717a63c8fb 100644 --- a/mobile/android/components/extensions/test/mochitest/test_ext_popup_behavior.html +++ b/mobile/android/components/extensions/test/mochitest/test_ext_popup_behavior.html @@ -3,7 +3,7 @@ PageAction Test - + diff --git a/mobile/android/components/extensions/test/mochitest/test_ext_tab_runtimeConnect.html b/mobile/android/components/extensions/test/mochitest/test_ext_tab_runtimeConnect.html index d422f4d2c579..8c7e14da9ec7 100644 --- a/mobile/android/components/extensions/test/mochitest/test_ext_tab_runtimeConnect.html +++ b/mobile/android/components/extensions/test/mochitest/test_ext_tab_runtimeConnect.html @@ -3,7 +3,7 @@ Tabs runtimeConnect Test - + diff --git a/mobile/android/components/extensions/test/mochitest/test_ext_tabs_captureVisibleTab.html b/mobile/android/components/extensions/test/mochitest/test_ext_tabs_captureVisibleTab.html index c59fea1194b3..457919d3a274 100644 --- a/mobile/android/components/extensions/test/mochitest/test_ext_tabs_captureVisibleTab.html +++ b/mobile/android/components/extensions/test/mochitest/test_ext_tabs_captureVisibleTab.html @@ -3,7 +3,7 @@ Tabs captureVisibleTab Test - + diff --git a/mobile/android/components/extensions/test/mochitest/test_ext_tabs_create.html b/mobile/android/components/extensions/test/mochitest/test_ext_tabs_create.html index b8dbdf0e368c..ef44a863a4a3 100644 --- a/mobile/android/components/extensions/test/mochitest/test_ext_tabs_create.html +++ b/mobile/android/components/extensions/test/mochitest/test_ext_tabs_create.html @@ -3,7 +3,7 @@ Tabs create Test - + diff --git a/mobile/android/components/extensions/test/mochitest/test_ext_tabs_events.html b/mobile/android/components/extensions/test/mochitest/test_ext_tabs_events.html index d62177316264..63a5c1a329a2 100644 --- a/mobile/android/components/extensions/test/mochitest/test_ext_tabs_events.html +++ b/mobile/android/components/extensions/test/mochitest/test_ext_tabs_events.html @@ -3,7 +3,7 @@ Tabs Events Test - + diff --git a/mobile/android/components/extensions/test/mochitest/test_ext_tabs_executeScript.html b/mobile/android/components/extensions/test/mochitest/test_ext_tabs_executeScript.html index 2d1edf7b00fc..486ee16e04d2 100644 --- a/mobile/android/components/extensions/test/mochitest/test_ext_tabs_executeScript.html +++ b/mobile/android/components/extensions/test/mochitest/test_ext_tabs_executeScript.html @@ -3,7 +3,7 @@ Tabs executeScript Test - + diff --git a/mobile/android/components/extensions/test/mochitest/test_ext_tabs_executeScript_bad.html b/mobile/android/components/extensions/test/mochitest/test_ext_tabs_executeScript_bad.html index 2436c812eb8a..b8132e17ae5b 100644 --- a/mobile/android/components/extensions/test/mochitest/test_ext_tabs_executeScript_bad.html +++ b/mobile/android/components/extensions/test/mochitest/test_ext_tabs_executeScript_bad.html @@ -3,7 +3,7 @@ Tabs executeScript Bad Test - + diff --git a/mobile/android/components/extensions/test/mochitest/test_ext_tabs_executeScript_good.html b/mobile/android/components/extensions/test/mochitest/test_ext_tabs_executeScript_good.html index 04c8435c3ecc..975719e3c0f9 100644 --- a/mobile/android/components/extensions/test/mochitest/test_ext_tabs_executeScript_good.html +++ b/mobile/android/components/extensions/test/mochitest/test_ext_tabs_executeScript_good.html @@ -3,7 +3,7 @@ Tabs executeScript Good Test - + diff --git a/mobile/android/components/extensions/test/mochitest/test_ext_tabs_executeScript_no_create.html b/mobile/android/components/extensions/test/mochitest/test_ext_tabs_executeScript_no_create.html index d2e170d423f6..84da35cf48d8 100644 --- a/mobile/android/components/extensions/test/mochitest/test_ext_tabs_executeScript_no_create.html +++ b/mobile/android/components/extensions/test/mochitest/test_ext_tabs_executeScript_no_create.html @@ -3,7 +3,7 @@ Tabs executeScript noCreate Test - + diff --git a/mobile/android/components/extensions/test/mochitest/test_ext_tabs_executeScript_runAt.html b/mobile/android/components/extensions/test/mochitest/test_ext_tabs_executeScript_runAt.html index 0bc44ac973ca..16d6843e6fed 100644 --- a/mobile/android/components/extensions/test/mochitest/test_ext_tabs_executeScript_runAt.html +++ b/mobile/android/components/extensions/test/mochitest/test_ext_tabs_executeScript_runAt.html @@ -3,7 +3,7 @@ Tabs executeScript runAt Test - + diff --git a/mobile/android/components/extensions/test/mochitest/test_ext_tabs_getCurrent.html b/mobile/android/components/extensions/test/mochitest/test_ext_tabs_getCurrent.html index 69923ddce779..3f5e1ace3f7b 100644 --- a/mobile/android/components/extensions/test/mochitest/test_ext_tabs_getCurrent.html +++ b/mobile/android/components/extensions/test/mochitest/test_ext_tabs_getCurrent.html @@ -3,7 +3,7 @@ Tabs getCurrent Test - + diff --git a/mobile/android/components/extensions/test/mochitest/test_ext_tabs_insertCSS.html b/mobile/android/components/extensions/test/mochitest/test_ext_tabs_insertCSS.html index 2361e349fe1e..cf165e9f778b 100644 --- a/mobile/android/components/extensions/test/mochitest/test_ext_tabs_insertCSS.html +++ b/mobile/android/components/extensions/test/mochitest/test_ext_tabs_insertCSS.html @@ -3,7 +3,7 @@ Tabs executeScript Test - + diff --git a/mobile/android/components/extensions/test/mochitest/test_ext_tabs_lastAccessed.html b/mobile/android/components/extensions/test/mochitest/test_ext_tabs_lastAccessed.html index 0ec6d9c13df9..4bddd11cec6b 100644 --- a/mobile/android/components/extensions/test/mochitest/test_ext_tabs_lastAccessed.html +++ b/mobile/android/components/extensions/test/mochitest/test_ext_tabs_lastAccessed.html @@ -3,7 +3,7 @@ Tabs lastAccessed Test - + diff --git a/mobile/android/components/extensions/test/mochitest/test_ext_tabs_onUpdated.html b/mobile/android/components/extensions/test/mochitest/test_ext_tabs_onUpdated.html index 13c46d02dc3b..175e6fec0f35 100644 --- a/mobile/android/components/extensions/test/mochitest/test_ext_tabs_onUpdated.html +++ b/mobile/android/components/extensions/test/mochitest/test_ext_tabs_onUpdated.html @@ -3,7 +3,7 @@ Tabs onUpdated Test - + diff --git a/mobile/android/components/extensions/test/mochitest/test_ext_tabs_query.html b/mobile/android/components/extensions/test/mochitest/test_ext_tabs_query.html index 3d887dedc950..57917fdc0d51 100644 --- a/mobile/android/components/extensions/test/mochitest/test_ext_tabs_query.html +++ b/mobile/android/components/extensions/test/mochitest/test_ext_tabs_query.html @@ -3,7 +3,7 @@ Tabs create Test - + diff --git a/mobile/android/components/extensions/test/mochitest/test_ext_tabs_reload.html b/mobile/android/components/extensions/test/mochitest/test_ext_tabs_reload.html index 3ba7cc1146b3..852b9572841f 100644 --- a/mobile/android/components/extensions/test/mochitest/test_ext_tabs_reload.html +++ b/mobile/android/components/extensions/test/mochitest/test_ext_tabs_reload.html @@ -3,7 +3,7 @@ Tabs reload Test - + diff --git a/mobile/android/components/extensions/test/mochitest/test_ext_tabs_reload_bypass_cache.html b/mobile/android/components/extensions/test/mochitest/test_ext_tabs_reload_bypass_cache.html index 7c3c6cc59019..cf89d5cb1d8a 100644 --- a/mobile/android/components/extensions/test/mochitest/test_ext_tabs_reload_bypass_cache.html +++ b/mobile/android/components/extensions/test/mochitest/test_ext_tabs_reload_bypass_cache.html @@ -3,7 +3,7 @@ Tabs executeScript bypassCache Test - + diff --git a/mobile/android/components/extensions/test/mochitest/test_ext_tabs_sendMessage.html b/mobile/android/components/extensions/test/mochitest/test_ext_tabs_sendMessage.html index f6de3ab08829..5ccad57c6cd4 100644 --- a/mobile/android/components/extensions/test/mochitest/test_ext_tabs_sendMessage.html +++ b/mobile/android/components/extensions/test/mochitest/test_ext_tabs_sendMessage.html @@ -3,7 +3,7 @@ Tabs sendMessage Test - + diff --git a/mobile/android/components/extensions/test/mochitest/test_ext_tabs_update_url.html b/mobile/android/components/extensions/test/mochitest/test_ext_tabs_update_url.html index 7c40b8299560..174d4b20221b 100644 --- a/mobile/android/components/extensions/test/mochitest/test_ext_tabs_update_url.html +++ b/mobile/android/components/extensions/test/mochitest/test_ext_tabs_update_url.html @@ -3,7 +3,7 @@ Tabs update Test - + diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/PanZoomController.java b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/PanZoomController.java index 4a760b0321c8..bacfbd27cc2c 100644 --- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/PanZoomController.java +++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/PanZoomController.java @@ -228,6 +228,11 @@ public final class PanZoomController extends JNIObject { } else if ((action == MotionEvent.ACTION_HOVER_MOVE) || (action == MotionEvent.ACTION_HOVER_ENTER) || (action == MotionEvent.ACTION_HOVER_EXIT)) { + if (event.getSource() == InputDevice.SOURCE_TOUCHSCREEN) { + // A hover is not possible on a touchscreen unless via accessibility + // and we handle that elsewhere. + return false; + } return handleMouseEvent(event); } else { return false; diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoView.java b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoView.java index a996687d93ec..17e83a58fcdc 100644 --- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoView.java +++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoView.java @@ -516,15 +516,15 @@ public class GeckoView extends FrameLayout { @Override public boolean onHoverEvent(final MotionEvent event) { - // If we get a touchscreen hover event, and accessibility is not enabled, don't - // send it to Gecko. - if (event.getSource() == InputDevice.SOURCE_TOUCHSCREEN && - !SessionAccessibility.Settings.isEnabled()) { - return false; + // A touchscreen hover event is a screen reader doing explore-by-touch + if (SessionAccessibility.Settings.isEnabled() && + event.getSource() == InputDevice.SOURCE_TOUCHSCREEN && + mSession != null) { + mSession.getAccessibility().onExploreByTouch(event); + return true; } - return mSession != null && - mSession.getPanZoomController().onMotionEvent(event); + return false; } @Override diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/SessionAccessibility.java b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/SessionAccessibility.java index 8a19c08d2f74..c12db75df9ce 100644 --- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/SessionAccessibility.java +++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/SessionAccessibility.java @@ -19,6 +19,7 @@ import android.graphics.Rect; import android.os.Build; import android.os.Bundle; import android.util.Log; +import android.view.MotionEvent; import android.view.View; import android.view.ViewParent; import android.view.accessibility.AccessibilityEvent; @@ -366,17 +367,17 @@ public class SessionAccessibility { final GeckoBundle bounds = message.getBundle("bounds"); if (bounds != null) { - Rect relativeBounds = new Rect(bounds.getInt("left"), bounds.getInt("top"), - bounds.getInt("right"), bounds.getInt("bottom")); - node.setBoundsInParent(relativeBounds); + Rect screenBounds = new Rect(bounds.getInt("left"), bounds.getInt("top"), + bounds.getInt("right"), bounds.getInt("bottom")); + node.setBoundsInScreen(screenBounds); final Matrix matrix = new Matrix(); final float[] origin = new float[2]; mSession.getClientToScreenMatrix(matrix); matrix.mapPoints(origin); - relativeBounds.offset((int) origin[0], (int) origin[1]); - node.setBoundsInScreen(relativeBounds); + screenBounds.offset((int) -origin[0], (int) -origin[1]); + node.setBoundsInParent(screenBounds); } } @@ -419,4 +420,10 @@ public class SessionAccessibility { populateEventFromJSON(accessibilityEvent, message); ((ViewParent) mView).requestSendAccessibilityEvent(mView, accessibilityEvent); } + + public void onExploreByTouch(final MotionEvent event) { + final GeckoBundle data = new GeckoBundle(2); + data.putDoubleArray("coordinates", new double[] {event.getRawX(), event.getRawY()}); + mSession.getEventDispatcher().dispatch("GeckoView:AccessibilityExploreByTouch", data); + } } diff --git a/mobile/android/tests/browser/chrome/test_about_logins.html b/mobile/android/tests/browser/chrome/test_about_logins.html index a4f02bd6edaa..a9b742fcdbd7 100644 --- a/mobile/android/tests/browser/chrome/test_about_logins.html +++ b/mobile/android/tests/browser/chrome/test_about_logins.html @@ -8,7 +8,7 @@ Migrated from Robocop: https://bugzilla.mozilla.org/show_bug.cgi?id=1184186 Test for Bug 1136477 - + diff --git a/mobile/android/tests/browser/chrome/test_accounts.html b/mobile/android/tests/browser/chrome/test_accounts.html index cf254b66fb3a..9ee32588755e 100644 --- a/mobile/android/tests/browser/chrome/test_accounts.html +++ b/mobile/android/tests/browser/chrome/test_accounts.html @@ -8,7 +8,7 @@ Migrated from Robocop: https://bugzilla.mozilla.org/show_bug.cgi?id=1184186 Test for Bug 917942 - + - + diff --git a/mobile/android/tests/browser/chrome/test_get_last_visited.html b/mobile/android/tests/browser/chrome/test_get_last_visited.html index af05efbf76fa..ef0fcba6da94 100644 --- a/mobile/android/tests/browser/chrome/test_get_last_visited.html +++ b/mobile/android/tests/browser/chrome/test_get_last_visited.html @@ -7,7 +7,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1214366 Test for Bug 1214366 - + diff --git a/mobile/android/tests/browser/chrome/test_hidden_select_option.html b/mobile/android/tests/browser/chrome/test_hidden_select_option.html index 90bfdca7b786..6a86a4950893 100644 --- a/mobile/android/tests/browser/chrome/test_hidden_select_option.html +++ b/mobile/android/tests/browser/chrome/test_hidden_select_option.html @@ -10,7 +10,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1178722 .hideme {display:none} - + diff --git a/mobile/android/tests/browser/chrome/test_home_provider.html b/mobile/android/tests/browser/chrome/test_home_provider.html index 6121205bcc0f..6ad1dba36da4 100644 --- a/mobile/android/tests/browser/chrome/test_home_provider.html +++ b/mobile/android/tests/browser/chrome/test_home_provider.html @@ -8,7 +8,7 @@ Migrated from Robocop: https://bugzilla.mozilla.org/show_bug.cgi?id=1184186 Test for Bug 942288 - + - + diff --git a/mobile/android/tests/browser/chrome/test_media_playback.html b/mobile/android/tests/browser/chrome/test_media_playback.html index df89a044bb8f..574916ac4343 100644 --- a/mobile/android/tests/browser/chrome/test_media_playback.html +++ b/mobile/android/tests/browser/chrome/test_media_playback.html @@ -4,7 +4,7 @@ Test for media playback - + diff --git a/mobile/android/tests/browser/chrome/test_offline_page.html b/mobile/android/tests/browser/chrome/test_offline_page.html index eb763833480a..1451bd40eccf 100644 --- a/mobile/android/tests/browser/chrome/test_offline_page.html +++ b/mobile/android/tests/browser/chrome/test_offline_page.html @@ -8,7 +8,7 @@ Migrated from Robocop: https://bugzilla.mozilla.org/show_bug.cgi?id=1184186 Test for Bug 1089190 - + diff --git a/mobile/android/tests/browser/chrome/test_reader_view.html b/mobile/android/tests/browser/chrome/test_reader_view.html index 067b40820289..62da9de8734f 100644 --- a/mobile/android/tests/browser/chrome/test_reader_view.html +++ b/mobile/android/tests/browser/chrome/test_reader_view.html @@ -8,7 +8,7 @@ Migrated from Robocop: https://bugzilla.mozilla.org/show_bug.cgi?id=1184186 Test for Bug 1158885 - + diff --git a/mobile/android/tests/browser/chrome/test_resource_substitutions.html b/mobile/android/tests/browser/chrome/test_resource_substitutions.html index 3fc788b61c15..a575fb9de95d 100644 --- a/mobile/android/tests/browser/chrome/test_resource_substitutions.html +++ b/mobile/android/tests/browser/chrome/test_resource_substitutions.html @@ -8,7 +8,7 @@ Migrated from Robocop: https://bugzilla.mozilla.org/show_bug.cgi?id=1184186 Test for Bug 948465 - + - + diff --git a/mobile/android/tests/browser/chrome/test_selectoraddtab.html b/mobile/android/tests/browser/chrome/test_selectoraddtab.html index 7340b17c0894..3dd35f3871be 100644 --- a/mobile/android/tests/browser/chrome/test_selectoraddtab.html +++ b/mobile/android/tests/browser/chrome/test_selectoraddtab.html @@ -7,7 +7,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1216047 Test for Bug 1216047 - + diff --git a/mobile/android/tests/browser/chrome/test_session_clear_history.html b/mobile/android/tests/browser/chrome/test_session_clear_history.html index 53b2824b2c2d..ea3ec336d165 100644 --- a/mobile/android/tests/browser/chrome/test_session_clear_history.html +++ b/mobile/android/tests/browser/chrome/test_session_clear_history.html @@ -7,7 +7,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1343603 Test for Bug 1343603 - + diff --git a/mobile/android/tests/browser/chrome/test_session_form_data.html b/mobile/android/tests/browser/chrome/test_session_form_data.html index 718cec7e52c2..3716622c6981 100644 --- a/mobile/android/tests/browser/chrome/test_session_form_data.html +++ b/mobile/android/tests/browser/chrome/test_session_form_data.html @@ -9,7 +9,7 @@ Migrated from Robocop: https://bugzilla.mozilla.org/show_bug.cgi?id=1184186 Test for Bugs 671993, 1261225 - + diff --git a/mobile/android/tests/browser/chrome/test_session_parentid.html b/mobile/android/tests/browser/chrome/test_session_parentid.html index 904bca2d1610..2e03975ac9ad 100644 --- a/mobile/android/tests/browser/chrome/test_session_parentid.html +++ b/mobile/android/tests/browser/chrome/test_session_parentid.html @@ -7,7 +7,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1301160 Test for Bug 1301160 - + diff --git a/mobile/android/tests/browser/chrome/test_session_scroll_position.html b/mobile/android/tests/browser/chrome/test_session_scroll_position.html index 350c64a458eb..2caa21d9ee01 100644 --- a/mobile/android/tests/browser/chrome/test_session_scroll_position.html +++ b/mobile/android/tests/browser/chrome/test_session_scroll_position.html @@ -10,7 +10,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1265818 Tests for Bug 810981, 1282902, 1301016, 1265818 - + diff --git a/mobile/android/tests/browser/chrome/test_session_zombification.html b/mobile/android/tests/browser/chrome/test_session_zombification.html index 23b7c73e1175..c18f705eedef 100644 --- a/mobile/android/tests/browser/chrome/test_session_zombification.html +++ b/mobile/android/tests/browser/chrome/test_session_zombification.html @@ -7,7 +7,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1044556 Test for Bug 1044556 - + diff --git a/mobile/android/tests/browser/chrome/test_settings_fontinflation.html b/mobile/android/tests/browser/chrome/test_settings_fontinflation.html index 6135abe0a0d1..76daf1874d5d 100644 --- a/mobile/android/tests/browser/chrome/test_settings_fontinflation.html +++ b/mobile/android/tests/browser/chrome/test_settings_fontinflation.html @@ -7,7 +7,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1328868 Test for Bug 1328868 - + diff --git a/mobile/android/tests/browser/chrome/test_shared_preferences.html b/mobile/android/tests/browser/chrome/test_shared_preferences.html index 776067e02356..7c72b7f1eb7c 100644 --- a/mobile/android/tests/browser/chrome/test_shared_preferences.html +++ b/mobile/android/tests/browser/chrome/test_shared_preferences.html @@ -8,7 +8,7 @@ Migrated from Robocop: https://bugzilla.mozilla.org/show_bug.cgi?id=1184186 Test for Bug 866271 - + diff --git a/mobile/android/tests/browser/chrome/test_web_channel.html b/mobile/android/tests/browser/chrome/test_web_channel.html index 9351dd222f84..0a557c796013 100644 --- a/mobile/android/tests/browser/chrome/test_web_channel.html +++ b/mobile/android/tests/browser/chrome/test_web_channel.html @@ -8,7 +8,7 @@ Migrated from Robocop: https://bugzilla.mozilla.org/show_bug.cgi?id=1184186 Test for Bug 1174458 - + - + diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp index d85a6b562ef1..fe7d0ec4bb37 100644 --- a/netwerk/protocol/http/nsHttpChannel.cpp +++ b/netwerk/protocol/http/nsHttpChannel.cpp @@ -118,6 +118,10 @@ #include "GeckoTaskTracer.h" #endif +#ifdef MOZ_GECKO_PROFILER +#include "ProfilerMarkerPayload.h" +#endif + namespace mozilla { namespace net { namespace { @@ -388,6 +392,28 @@ nsHttpChannel::Init(nsIURI *uri, if (NS_FAILED(rv)) return rv; +#ifdef MOZ_GECKO_PROFILER + mLastStatusReported = TimeStamp::Now(); // in case we enable the profiler after Init() + if (profiler_is_active()) { + // These do allocations/frees/etc; avoid if not active + nsAutoCString spec; + if (uri) { + uri->GetAsciiSpec(spec); + } + // top 32 bits are process id of the load + int32_t id = static_cast(channelId & 0xFFFFFFFF); + char name[64]; + SprintfLiteral(name, "Load: %d", id); + rv = NS_OK; // ensure it's a fixed value (0) + profiler_add_marker(name, + MakeUnique(id, + PromiseFlatCString(spec).get(), + rv, // NS_OK means START + mLastStatusReported, + mLastStatusReported)); + } +#endif + LOG(("nsHttpChannel::Init [this=%p]\n", this)); return rv; @@ -7716,6 +7742,24 @@ nsHttpChannel::OnTransportStatus(nsITransport *trans, nsresult status, } } +#ifdef MOZ_GECKO_PROFILER + if (profiler_is_active()) { + // These do allocations/frees/etc; avoid if not active + mozilla::TimeStamp now = TimeStamp::Now(); + // top 32 bits are process id of the load + int32_t id = static_cast(mChannelId & 0xFFFFFFFF); + char name[64]; + SprintfLiteral(name, "Load: %d", id); + profiler_add_marker(name, + MakeUnique(static_cast(mChannelId), + nullptr, + status, + mLastStatusReported, + now)); + mLastStatusReported = now; + } +#endif + // block socket status event after Cancel or OnStopRequest has been called. if (mProgressSink && NS_SUCCEEDED(mStatus) && mIsPending) { LOG(("sending progress%s notification [this=%p status=%" PRIx32 diff --git a/netwerk/protocol/http/nsHttpChannel.h b/netwerk/protocol/http/nsHttpChannel.h index a74742e35f61..a1efccb7a61d 100644 --- a/netwerk/protocol/http/nsHttpChannel.h +++ b/netwerk/protocol/http/nsHttpChannel.h @@ -544,9 +544,13 @@ private: uint32_t mOfflineCacheLastModifiedTime; mozilla::TimeStamp mOnStartRequestTimestamp; - // Timestamp of the time the cnannel was suspended. + // Timestamp of the time the channel was suspended. mozilla::TimeStamp mSuspendTimestamp; mozilla::TimeStamp mOnCacheEntryCheckTimestamp; +#ifdef MOZ_GECKO_PROFILER + // For the profiler markers + mozilla::TimeStamp mLastStatusReported; +#endif // Total time the channel spent suspended. This value is reported to // telemetry in nsHttpChannel::OnStartRequest(). uint32_t mSuspendTotalTime; diff --git a/parser/html/nsHtml5TreeOperation.cpp b/parser/html/nsHtml5TreeOperation.cpp index 99e7bab24a4f..e210159e68bb 100644 --- a/parser/html/nsHtml5TreeOperation.cpp +++ b/parser/html/nsHtml5TreeOperation.cpp @@ -215,11 +215,10 @@ IsElementOrTemplateContent(nsINode* aNode) if (aNode) { if (aNode->IsElement()) { return true; - } else if (aNode->NodeType() == nsINode::DOCUMENT_FRAGMENT_NODE) { + } + if (aNode->IsDocumentFragment()) { // Check if the node is a template content. - mozilla::dom::DocumentFragment* frag = - static_cast(aNode); - nsIContent* fragHost = frag->GetHost(); + nsIContent* fragHost = aNode->AsDocumentFragment()->GetHost(); if (fragHost && nsNodeUtils::IsTemplateElement(fragHost)) { return true; } diff --git a/python/mozbuild/mozbuild/schedules.py b/python/mozbuild/mozbuild/schedules.py index 35afa289fe6f..e64aa7828006 100644 --- a/python/mozbuild/mozbuild/schedules.py +++ b/python/mozbuild/mozbuild/schedules.py @@ -24,6 +24,8 @@ INCLUSIVE_COMPONENTS = [ 'jittest', 'test-verify', 'test-verify-wpt', + 'test-coverage', + 'test-coverage-wpt', 'jsreftest', ] INCLUSIVE_COMPONENTS = sorted(INCLUSIVE_COMPONENTS) diff --git a/servo/components/style/properties/gecko.mako.rs b/servo/components/style/properties/gecko.mako.rs index 0b55820f1a5d..b6a473477a62 100644 --- a/servo/components/style/properties/gecko.mako.rs +++ b/servo/components/style/properties/gecko.mako.rs @@ -1806,7 +1806,7 @@ fn static_assert() { } pub fn set_computed_justify_items(&mut self, v: values::specified::JustifyItems) { - debug_assert_ne!(v.0, ::values::specified::align::AlignFlags::AUTO); + debug_assert_ne!(v.0, ::values::specified::align::AlignFlags::LEGACY); self.gecko.mJustifyItems = v.into(); } diff --git a/servo/components/style/properties/longhand/position.mako.rs b/servo/components/style/properties/longhand/position.mako.rs index 2f2a85920e03..cbff436e4bf2 100644 --- a/servo/components/style/properties/longhand/position.mako.rs +++ b/servo/components/style/properties/longhand/position.mako.rs @@ -128,11 +128,13 @@ ${helpers.single_keyword("flex-wrap", "nowrap wrap wrap-reverse", #[cfg(feature = "gecko")] impl_align_conversions!(::values::specified::align::AlignItems); - ${helpers.predefined_type(name="justify-items", - type="JustifyItems", - initial_value="computed::JustifyItems::auto()", - spec="https://drafts.csswg.org/css-align/#propdef-justify-items", - animation_value_type="discrete")} + ${helpers.predefined_type( + name="justify-items", + type="JustifyItems", + initial_value="computed::JustifyItems::legacy()", + spec="https://drafts.csswg.org/css-align/#propdef-justify-items", + animation_value_type="discrete", + )} #[cfg(feature = "gecko")] impl_align_conversions!(::values::specified::align::JustifyItems); diff --git a/servo/components/style/style_adjuster.rs b/servo/components/style/style_adjuster.rs index b7270976eadc..32bd68db52d0 100644 --- a/servo/components/style/style_adjuster.rs +++ b/servo/components/style/style_adjuster.rs @@ -673,17 +673,15 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> { } } - /// Resolves "justify-items: auto" based on the inherited style if needed to - /// comply with: + /// Resolves "justify-items: legacy" based on the inherited style if needed + /// to comply with: /// /// - /// - /// (Note that "auto" is being renamed to "legacy") #[cfg(feature = "gecko")] fn adjust_for_justify_items(&mut self) { use values::specified::align; let justify_items = self.style.get_position().clone_justify_items(); - if justify_items.specified.0 != align::AlignFlags::AUTO { + if justify_items.specified.0 != align::AlignFlags::LEGACY { return; } diff --git a/servo/components/style/values/computed/align.rs b/servo/components/style/values/computed/align.rs index 940e3f747b86..1a26e41fd243 100644 --- a/servo/components/style/values/computed/align.rs +++ b/servo/components/style/values/computed/align.rs @@ -20,10 +20,10 @@ pub use super::specified::{AlignSelf, JustifySelf}; /// In particular, `justify-items` is a reset property, so we ought to be able /// to share its computed representation across elements as long as they match /// the same rules. Except that it's not true if the specified value for -/// `justify-items` is `auto` and the computed value of the parent has the +/// `justify-items` is `legacy` and the computed value of the parent has the /// `legacy` modifier. /// -/// So instead of computing `auto` "normally" looking at get_parent_position(), +/// So instead of computing `legacy` "normally" looking at get_parent_position(), /// marking it as uncacheable, we carry the specified value around and handle /// the special case in `StyleAdjuster` instead, only when the result of the /// computation would vary. @@ -35,18 +35,21 @@ pub use super::specified::{AlignSelf, JustifySelf}; /// See the discussion in https://bugzil.la/1384542. #[derive(Clone, Copy, Debug, Eq, PartialEq, ToCss)] pub struct JustifyItems { - /// The specified value for the property. Can contain `auto`. + /// The specified value for the property. Can contain the bare `legacy` + /// keyword. #[css(skip)] pub specified: specified::JustifyItems, - /// The computed value for the property. Cannot contain `auto`. + /// The computed value for the property. Cannot contain the bare `legacy` + /// keyword, but note that it could contain it in combination with other + /// keywords like `left`, `right` or `center`. pub computed: specified::JustifyItems, } impl JustifyItems { - /// Returns the `auto` value. - pub fn auto() -> Self { + /// Returns the `legacy` value. + pub fn legacy() -> Self { Self { - specified: specified::JustifyItems::auto(), + specified: specified::JustifyItems::legacy(), computed: specified::JustifyItems::normal(), } } @@ -59,13 +62,13 @@ impl ToComputedValue for specified::JustifyItems { fn to_computed_value(&self, _context: &Context) -> JustifyItems { use values::specified::align; let specified = *self; - let computed = if self.0 != align::AlignFlags::AUTO { + let computed = if self.0 != align::AlignFlags::LEGACY { *self } else { // If the inherited value of `justify-items` includes the - // `legacy` keyword, `auto` computes to the inherited value, - // but we assume it computes to `normal`, and handle that - // special-case in StyleAdjuster. + // `legacy` keyword, `legacy` computes to the inherited value, but + // we assume it computes to `normal`, and handle that special-case + // in StyleAdjuster. Self::normal() }; diff --git a/servo/components/style/values/specified/align.rs b/servo/components/style/values/specified/align.rs index 918c4ddf8edf..7b9b003a50c4 100644 --- a/servo/components/style/values/specified/align.rs +++ b/servo/components/style/values/specified/align.rs @@ -9,9 +9,8 @@ use cssparser::Parser; use gecko_bindings::structs; use parser::{Parse, ParserContext}; -use selectors::parser::SelectorParseErrorKind; use std::fmt::{self, Write}; -use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss}; +use style_traits::{CssWriter, ParseError, ToCss}; bitflags! { /// Constants shared by multiple CSS Box Alignment properties @@ -81,14 +80,26 @@ impl ToCss for AlignFlags { where W: Write, { - match *self & AlignFlags::FLAG_BITS { - AlignFlags::LEGACY => dest.write_str("legacy ")?, + let extra_flags = *self & AlignFlags::FLAG_BITS; + let value = self.value(); + + match extra_flags { + AlignFlags::LEGACY => { + dest.write_str("legacy")?; + if value.is_empty() { + return Ok(()); + } + dest.write_char(' ')?; + }, AlignFlags::SAFE => dest.write_str("safe ")?, // Don't serialize "unsafe", since it's the default. - _ => {}, + AlignFlags::UNSAFE => {}, + _ => { + debug_assert_eq!(extra_flags, AlignFlags::empty()); + }, } - dest.write_str(match self.value() { + dest.write_str(match value { AlignFlags::AUTO => "auto", AlignFlags::NORMAL => "normal", AlignFlags::START => "start", @@ -436,10 +447,10 @@ impl Parse for AlignItems { pub struct JustifyItems(pub AlignFlags); impl JustifyItems { - /// The initial value 'auto' + /// The initial value 'legacy' #[inline] - pub fn auto() -> Self { - JustifyItems(AlignFlags::AUTO) + pub fn legacy() -> Self { + JustifyItems(AlignFlags::LEGACY) } /// The value 'normal' @@ -462,24 +473,12 @@ impl Parse for JustifyItems { return Ok(JustifyItems(baseline)); } - // auto | normal | stretch - // - // FIXME(emilio): auto is no longer a keyword in the current spec, and - // has been renamed to legacy, but that needs different changes because - // right now it's the initial value for both style systems, and has that - // weird behavior of "inheriting" into descendants. - // - // Fix this in both. - // - // See also: - // https://bugs.webkit.org/show_bug.cgi?id=172711 - // https://bugs.chromium.org/p/chromium/issues/detail?id=726148 - // - if let Ok(value) = input.try(parse_auto_normal_stretch) { + // normal | stretch + if let Ok(value) = input.try(parse_normal_stretch) { return Ok(JustifyItems(value)); } - // [ legacy || [ left | right | center ] ] + // legacy | [ legacy && [ left | right | center ] ] if let Ok(value) = input.try(parse_legacy) { return Ok(JustifyItems(value)); } @@ -567,29 +566,30 @@ fn parse_self_position<'i, 't>( }) } -// [ legacy && [ left | right | center ] ] -fn parse_legacy<'i, 't>(input: &mut Parser<'i, 't>) -> Result> { - let a_location = input.current_source_location(); - let a = input.expect_ident()?.clone(); - let b_location = input.current_source_location(); - let b = input.expect_ident()?; - if a.eq_ignore_ascii_case("legacy") { - (match_ignore_ascii_case! { &b, - "left" => Ok(AlignFlags::LEGACY | AlignFlags::LEFT), - "right" => Ok(AlignFlags::LEGACY | AlignFlags::RIGHT), - "center" => Ok(AlignFlags::LEGACY | AlignFlags::CENTER), - _ => Err(()) - }).map_err(|()| { - b_location.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(b.clone())) - }) - } else if b.eq_ignore_ascii_case("legacy") { - (match_ignore_ascii_case! { &a, - "left" => Ok(AlignFlags::LEGACY | AlignFlags::LEFT), - "right" => Ok(AlignFlags::LEGACY | AlignFlags::RIGHT), - "center" => Ok(AlignFlags::LEGACY | AlignFlags::CENTER), - _ => Err(()) - }).map_err(|()| a_location.new_custom_error(SelectorParseErrorKind::UnexpectedIdent(a))) - } else { - Err(a_location.new_custom_error(StyleParseErrorKind::UnspecifiedError)) - } +fn parse_left_right_center<'i, 't>( + input: &mut Parser<'i, 't>, +) -> Result> { + Ok(try_match_ident_ignore_ascii_case! { input, + "left" => AlignFlags::LEFT, + "right" => AlignFlags::RIGHT, + "center" => AlignFlags::CENTER, + }) +} + +// legacy | [ legacy && [ left | right | center ] ] +fn parse_legacy<'i, 't>(input: &mut Parser<'i, 't>) -> Result> { + let flags = try_match_ident_ignore_ascii_case! { input, + "legacy" => { + let flags = input.try(parse_left_right_center) + .unwrap_or(AlignFlags::empty()); + + return Ok(AlignFlags::LEGACY | flags) + } + "left" => AlignFlags::LEFT, + "right" => AlignFlags::RIGHT, + "center" => AlignFlags::CENTER, + }; + + input.expect_ident_matching("legacy")?; + Ok(AlignFlags::LEGACY | flags) } diff --git a/taskcluster/ci/test/misc.yml b/taskcluster/ci/test/misc.yml index 6f46cf1f85f7..b0b28ae9e8fc 100644 --- a/taskcluster/ci/test/misc.yml +++ b/taskcluster/ci/test/misc.yml @@ -97,3 +97,42 @@ test-verify: no-read-buildbot-config: true extra-options: - --verify + +test-coverage: + description: "Per-test coverage" + suite: test-coverage + treeherder-symbol: TC + loopback-video: true + instance-size: default + max-run-time: 10800 + allow-software-gl-layers: false + run-on-projects: + by-test-platform: + # only run on mozilla-central and try. + linux64-ccov/.*: ['mozilla-central', 'try'] + windows10-64-ccov/debug: ['mozilla-central', 'try'] + default: [] + tier: + by-test-platform: + windows10-64-asan.*: 3 + default: 2 + mozharness: + script: + by-test-platform: + android.*: android_emulator_unittest.py + default: desktop_unittest.py + config: + by-test-platform: + android.*: + - android/android_common.py + - android/androidarm_4_3.py + linux.*: + - unittests/linux_unittest.py + - remove_executables.py + macosx.*: + - unittests/mac_unittest.py + windows.*: + - unittests/win_taskcluster_unittest.py + no-read-buildbot-config: true + extra-options: + - --per-test-coverage diff --git a/taskcluster/ci/test/test-sets.yml b/taskcluster/ci/test/test-sets.yml index f960fca28a25..4c0a7754df18 100644 --- a/taskcluster/ci/test/test-sets.yml +++ b/taskcluster/ci/test/test-sets.yml @@ -37,6 +37,8 @@ common-tests: - reftest - reftest-no-accel - telemetry-tests-client + - test-coverage + - test-coverage-wpt - test-verify - test-verify-wpt - xpcshell @@ -185,6 +187,8 @@ windows-tests: - mochitest-webgl - reftest - reftest-no-accel + - test-coverage + - test-coverage-wpt - test-verify - test-verify-wpt - web-platform-tests diff --git a/taskcluster/ci/test/web-platform.yml b/taskcluster/ci/test/web-platform.yml index 4e953fa7365e..410bdac4d81b 100644 --- a/taskcluster/ci/test/web-platform.yml +++ b/taskcluster/ci/test/web-platform.yml @@ -163,3 +163,22 @@ test-verify-wpt: mozharness: extra-options: - --verify + +test-coverage-wpt: + description: "Per web-platform test coverage" + suite: test-coverage-wpt + treeherder-symbol: TCw + max-run-time: 10800 + run-on-projects: + by-test-platform: + # only run on mozilla-central and try. + linux64-ccov/.*: ['mozilla-central', 'try'] + windows10-64-ccov/debug: ['mozilla-central', 'try'] + default: [] + tier: + by-test-platform: + windows10-64-asan.*: 3 + default: 2 + mozharness: + extra-options: + - --per-test-coverage diff --git a/taskcluster/taskgraph/transforms/tests.py b/taskcluster/taskgraph/transforms/tests.py index 9a67df843ceb..72169ad88b68 100644 --- a/taskcluster/taskgraph/transforms/tests.py +++ b/taskcluster/taskgraph/transforms/tests.py @@ -673,7 +673,7 @@ def handle_suite_category(config, tests): script = test['mozharness']['script'] category_arg = None - if suite == 'test-verify': + if suite == 'test-verify' or suite == 'test-coverage': pass elif script == 'android_emulator_unittest.py': category_arg = '--test-suite' diff --git a/testing/mochitest/browser-test.js b/testing/mochitest/browser-test.js index c6cb4f283f75..836b72677c9a 100644 --- a/testing/mochitest/browser-test.js +++ b/testing/mochitest/browser-test.js @@ -5,7 +5,6 @@ var gConfig; var gSaveInstrumentationData = null; ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); -ChromeUtils.import("resource://gre/modules/Task.jsm"); ChromeUtils.import("resource://gre/modules/AppConstants.jsm"); ChromeUtils.import("resource://gre/modules/Services.jsm"); @@ -366,6 +365,10 @@ function takeInstrumentation() { }); } +function isGenerator(value) { + return value && typeof value === "object" && typeof value.next === "function"; +} + function Tester(aTests, structuredLogger, aCallback) { this.structuredLogger = structuredLogger; this.tests = aTests; @@ -405,11 +408,9 @@ function Tester(aTests, structuredLogger, aCallback) { this.SimpleTest.harnessParameters = gConfig; this.MemoryStats = simpleTestScope.MemoryStats; - this.Task = Task; this.ContentTask = ChromeUtils.import("resource://testing-common/ContentTask.jsm", null).ContentTask; this.BrowserTestUtils = ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm", null).BrowserTestUtils; this.TestUtils = ChromeUtils.import("resource://testing-common/TestUtils.jsm", null).TestUtils; - this.Task.Debugging.maintainStack = true; this.Promise = ChromeUtils.import("resource://gre/modules/Promise.jsm", null).Promise; this.PromiseTestUtils = ChromeUtils.import("resource://testing-common/PromiseTestUtils.jsm", null).PromiseTestUtils; this.Assert = ChromeUtils.import("resource://testing-common/Assert.jsm", null).Assert; @@ -452,7 +453,6 @@ function Tester(aTests, structuredLogger, aCallback) { Tester.prototype = { EventUtils: {}, SimpleTest: {}, - Task: null, ContentTask: null, ExtensionTestUtils: null, Assert: null, @@ -660,7 +660,7 @@ Tester.prototype = { } }, - nextTest: Task.async(function*() { + async nextTest() { if (this.currentTest) { if (this._coverageCollector) { this._coverageCollector.recordTestCoverage(this.currentTest.path); @@ -672,7 +672,10 @@ Tester.prototype = { while (testScope.__cleanupFunctions.length > 0) { let func = testScope.__cleanupFunctions.shift(); try { - yield func.apply(testScope); + let result = await func.apply(testScope); + if (isGenerator(result)) { + this.SimpleTest.ok(false, "Cleanup function returned a generator"); + } } catch (ex) { this.currentTest.addResult(new testResult({ @@ -738,7 +741,7 @@ Tester.prototype = { // behavior of returning the last opened popup. document.popupNode = null; - yield new Promise(resolve => SpecialPowers.flushPrefEnv(resolve)); + await new Promise(resolve => SpecialPowers.flushPrefEnv(resolve)); if (gConfig.cleanupCrashes) { let gdir = Services.dirsvc.get("UAppData", Ci.nsIFile); @@ -967,7 +970,7 @@ Tester.prototype = { this.execTest(); } }); - }), + }, execTest: function Tester_execTest() { this.structuredLogger.testStart(this.currentTest.path); @@ -983,7 +986,6 @@ Tester.prototype = { scope.EventUtils = this.currentTest.usesUnsafeCPOWs ? this.cpowEventUtils : this.EventUtils; scope.SimpleTest = this.SimpleTest; scope.gTestPath = this.currentTest.path; - scope.Task = this.Task; scope.ContentTask = this.ContentTask; scope.BrowserTestUtils = this.BrowserTestUtils; scope.TestUtils = this.TestUtils; @@ -1064,7 +1066,7 @@ Tester.prototype = { logger.activateBuffering(); }; - this.Task.spawn(function*() { + (async function() { let task; while ((task = this.__tasks.shift())) { if (task.__skipMe || (this.__runOnlyThisTask && task != this.__runOnlyThisTask)) { @@ -1073,7 +1075,10 @@ Tester.prototype = { } this.SimpleTest.info("Entering test " + task.name); try { - yield task(); + let result = await task(); + if (isGenerator(result)) { + this.SimpleTest.ok(false, "Task returned a generator"); + } } catch (ex) { if (currentTest.timedOut) { currentTest.addResult(new testResult({ @@ -1099,7 +1104,7 @@ Tester.prototype = { this.SimpleTest.info("Leaving test " + task.name); } this.finish(); - }.bind(currentScope)); + }).call(currentScope); } else if (typeof scope.test == "function") { scope.test(); } else { @@ -1246,7 +1251,7 @@ function testResult({ name, pass, todo, ex, stack, allowFailure }) { } else { normalized = "" + stack; } - this.msg += Task.Debugging.generateReadableStack(normalized, " "); + this.msg += normalized; } if (gConfig.debugOnFailure) { @@ -1414,7 +1419,6 @@ testScope.prototype = { EventUtils: {}, SimpleTest: {}, - Task: null, ContentTask: null, BrowserTestUtils: null, TestUtils: null, @@ -1445,31 +1449,27 @@ testScope.prototype = { }, /** - * Add a test function which is a Task function. + * Add a function which returns a promise (usually an async function) + * as a test task. * - * Task functions are functions fed into Task.jsm's Task.spawn(). They are - * generators that emit promises. - * - * If an exception is thrown, an assertion fails, or if a rejected - * promise is yielded, the test function aborts immediately and the test is - * reported as a failure. Execution continues with the next test function. - * - * To trigger premature (but successful) termination of the function, simply - * return or throw a Task.Result instance. + * The task ends when the promise returned by the function resolves or + * rejects. If the test function throws, or the promise it returns + * rejects, the test is reported as a failure. Execution continues + * with the next test function. * * Example usage: * - * add_task(function test() { + * add_task(async function test() { * let result = yield Promise.resolve(true); * * ok(result); * - * let secondary = yield someFunctionThatReturnsAPromise(result); + * let secondary = await someFunctionThatReturnsAPromise(result); * is(secondary, "expected value"); * }); * - * add_task(function test_early_return() { - * let result = yield somethingThatReturnsAPromise(); + * add_task(async function test_early_return() { + * let result = await somethingThatReturnsAPromise(); * * if (!result) { * // Test is ended immediately, with success. diff --git a/testing/mochitest/chrome/chrome.ini b/testing/mochitest/chrome/chrome.ini index e55e92ac6a1d..95c355b56b6f 100644 --- a/testing/mochitest/chrome/chrome.ini +++ b/testing/mochitest/chrome/chrome.ini @@ -3,7 +3,6 @@ skip-if = os == 'android' support-files = test-dir/test-file [test_sample.xul] -[test_sanityAddTask.xul] [test_sanityEventUtils.xul] [test_sanityPluginUtils.html] [test_sanityException.xul] @@ -12,7 +11,6 @@ support-files = test-dir/test-file fail-if = true [test_sanityManifest_pf.xul] fail-if = true -[test_sanitySpawnTask.xul] [test_chromeGetTestFile.xul] [test_tasks_skip.xul] [test_tasks_skipall.xul] diff --git a/testing/mochitest/chrome/test_sanityAddTask.xul b/testing/mochitest/chrome/test_sanityAddTask.xul deleted file mode 100644 index 0e7ce6772ee5..000000000000 --- a/testing/mochitest/chrome/test_sanityAddTask.xul +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - diff --git a/testing/mochitest/chrome/test_sanitySpawnTask.xul b/testing/mochitest/chrome/test_sanitySpawnTask.xul deleted file mode 100644 index d3f0ccc1f518..000000000000 --- a/testing/mochitest/chrome/test_sanitySpawnTask.xul +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - diff --git a/testing/mochitest/chrome/test_tasks_skip.xul b/testing/mochitest/chrome/test_tasks_skip.xul index 8239f037307a..4bf5284c5e75 100644 --- a/testing/mochitest/chrome/test_tasks_skip.xul +++ b/testing/mochitest/chrome/test_tasks_skip.xul @@ -6,7 +6,7 @@ - - - - -Mozilla Bug 1187701 -

- -
-
-
- - - diff --git a/testing/mochitest/tests/Harness_sanity/test_spawn_task.html b/testing/mochitest/tests/Harness_sanity/test_spawn_task.html deleted file mode 100644 index 326318746094..000000000000 --- a/testing/mochitest/tests/Harness_sanity/test_spawn_task.html +++ /dev/null @@ -1,73 +0,0 @@ - - - - Test for mochitest SpawnTask.js sanity - - - - - -Mozilla Bug 1078657 -

- -
-
-
- - - diff --git a/testing/mochitest/tests/SimpleTest/AddTask.js b/testing/mochitest/tests/SimpleTest/AddTask.js new file mode 100644 index 000000000000..36fbf0e3094a --- /dev/null +++ b/testing/mochitest/tests/SimpleTest/AddTask.js @@ -0,0 +1,83 @@ +// add_task(generatorFunction): +// Call `add_task(generatorFunction)` for each separate +// asynchronous task in a mochitest. Tasks are run consecutively. +// Before the first task, `SimpleTest.waitForExplicitFinish()` +// will be called automatically, and after the last task, +// `SimpleTest.finish()` will be called. +var add_task = (function () { + // The list of tasks to run. + var task_list = []; + var run_only_this_task = null; + + function isGenerator(value) { + return value && typeof value === "object" && typeof value.next === "function"; + } + + // The "add_task" function + return function (generatorFunction) { + if (task_list.length === 0) { + // This is the first time add_task has been called. + // First, confirm that SimpleTest is available. + if (!SimpleTest) { + throw new Error("SimpleTest not available."); + } + // Don't stop tests until asynchronous tasks are finished. + SimpleTest.waitForExplicitFinish(); + // Because the client is using add_task for this set of tests, + // we need to spawn a "master task" that calls each task in succesion. + // Use setTimeout to ensure the master task runs after the client + // script finishes. + setTimeout(function () { + (async () => { + // Allow for a task to be skipped; we need only use the structured logger + // for this, whilst deactivating log buffering to ensure that messages + // are always printed to stdout. + function skipTask(name) { + let logger = parentRunner && parentRunner.structuredLogger; + if (!logger) { + info("AddTask.js | Skipping test " + name); + return; + } + logger.deactivateBuffering(); + logger.testStatus(SimpleTest._getCurrentTestURL(), name, "SKIP"); + logger.warning("AddTask.js | Skipping test " + name); + logger.activateBuffering(); + } + + // We stop the entire test file at the first exception because this + // may mean that the state of subsequent tests may be corrupt. + try { + for (var task of task_list) { + var name = task.name || ""; + if (task.__skipMe || (run_only_this_task && task != run_only_this_task)) { + skipTask(name); + continue; + } + info("AddTask.js | Entering test " + name); + let result = await task(); + if (isGenerator(result)) { + ok(false, "Task returned a generator"); + } + info("AddTask.js | Leaving test " + name); + } + } catch (ex) { + try { + ok(false, "" + ex, "Should not throw any errors", ex.stack); + } catch (ex2) { + ok(false, "(The exception cannot be converted to string.)", + "Should not throw any errors", ex.stack); + } + } + // All tasks are finished. + SimpleTest.finish(); + })(); + }); + } + generatorFunction.skip = () => generatorFunction.__skipMe = true; + generatorFunction.only = () => run_only_this_task = generatorFunction; + // Add the task to the list of tasks to run after + // the main thread is finished. + task_list.push(generatorFunction); + return generatorFunction; + }; +})(); diff --git a/testing/mochitest/tests/SimpleTest/LICENSE_SpawnTask b/testing/mochitest/tests/SimpleTest/LICENSE_SpawnTask deleted file mode 100644 index 088c54c9d3df..000000000000 --- a/testing/mochitest/tests/SimpleTest/LICENSE_SpawnTask +++ /dev/null @@ -1,24 +0,0 @@ -LICENSE for SpawnTask.js (the co library): - -(The MIT License) - -Copyright (c) 2014 TJ Holowaychuk <tj@vision-media.ca> - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/testing/mochitest/tests/SimpleTest/SpawnTask.js b/testing/mochitest/tests/SimpleTest/SpawnTask.js deleted file mode 100644 index b197a97d30a2..000000000000 --- a/testing/mochitest/tests/SimpleTest/SpawnTask.js +++ /dev/null @@ -1,321 +0,0 @@ -// # SpawnTask.js -// Directly copied from the "co" library by TJ Holowaychuk. -// See https://github.com/tj/co/tree/4.6.0 -// For use with mochitest-plain and mochitest-chrome. - -// spawn_task(generatorFunction): -// Expose only the `co` function, which is very similar to Task.spawn in Task.jsm. -// We call this function spawn_task to make its purpose more plain, and to -// reduce the chance of name collisions. -var spawn_task = (function () { - -/** - * slice() reference. - */ - -var slice = Array.prototype.slice; - -/** - * Wrap the given generator `fn` into a - * function that returns a promise. - * This is a separate function so that - * every `co()` call doesn't create a new, - * unnecessary closure. - * - * @param {GeneratorFunction} fn - * @return {Function} - * @api public - */ - -co.wrap = function (fn) { - createPromise.__generatorFunction__ = fn; - return createPromise; - function createPromise() { - return co.call(this, fn.apply(this, arguments)); - } -}; - -/** - * Execute the generator function or a generator - * and return a promise. - * - * @param {Function} fn - * @return {Promise} - * @api public - */ - -function co(gen) { - var ctx = this; - var args = slice.call(arguments, 1) - - // we wrap everything in a promise to avoid promise chaining, - // which leads to memory leak errors. - // see https://github.com/tj/co/issues/180 - return new Promise(function(resolve, reject) { - if (typeof gen === 'function') gen = gen.apply(ctx, args); - if (!gen || typeof gen.next !== 'function') return resolve(gen); - - onFulfilled(); - - /** - * @param {Mixed} res - * @return {Promise} - * @api private - */ - - function onFulfilled(res) { - var ret; - try { - ret = gen.next(res); - } catch (e) { - return reject(e); - } - next(ret); - } - - /** - * @param {Error} err - * @return {Promise} - * @api private - */ - - function onRejected(err) { - var ret; - try { - ret = gen.throw(err); - } catch (e) { - return reject(e); - } - next(ret); - } - - /** - * Get the next value in the generator, - * return a promise. - * - * @param {Object} ret - * @return {Promise} - * @api private - */ - - function next(ret) { - if (ret.done) return resolve(ret.value); - var value = toPromise.call(ctx, ret.value); - if (value && isPromise(value)) return value.then(onFulfilled, onRejected); - return onRejected(new TypeError('You may only yield a function, promise, generator, array, or object, ' - + 'but the following object was passed: "' + String(ret.value) + '"')); - } - }); -} - -/** - * Convert a `yield`ed value into a promise. - * - * @param {Mixed} obj - * @return {Promise} - * @api private - */ - -function toPromise(obj) { - if (!obj) return obj; - if (isPromise(obj)) return obj; - if (isGeneratorFunction(obj) || isGenerator(obj)) return co.call(this, obj); - if ('function' == typeof obj) return thunkToPromise.call(this, obj); - if (Array.isArray(obj)) return arrayToPromise.call(this, obj); - if (isObject(obj)) return objectToPromise.call(this, obj); - return obj; -} - -/** - * Convert a thunk to a promise. - * - * @param {Function} - * @return {Promise} - * @api private - */ - -function thunkToPromise(fn) { - var ctx = this; - return new Promise(function (resolve, reject) { - fn.call(ctx, function (err, res) { - if (err) return reject(err); - if (arguments.length > 2) res = slice.call(arguments, 1); - resolve(res); - }); - }); -} - -/** - * Convert an array of "yieldables" to a promise. - * Uses `Promise.all()` internally. - * - * @param {Array} obj - * @return {Promise} - * @api private - */ - -function arrayToPromise(obj) { - return Promise.all(obj.map(toPromise, this)); -} - -/** - * Convert an object of "yieldables" to a promise. - * Uses `Promise.all()` internally. - * - * @param {Object} obj - * @return {Promise} - * @api private - */ - -function objectToPromise(obj){ - var results = new obj.constructor(); - var keys = Object.keys(obj); - var promises = []; - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - var promise = toPromise.call(this, obj[key]); - if (promise && isPromise(promise)) defer(promise, key); - else results[key] = obj[key]; - } - return Promise.all(promises).then(function () { - return results; - }); - - function defer(promise, key) { - // predefine the key in the result - results[key] = undefined; - promises.push(promise.then(function (res) { - results[key] = res; - })); - } -} - -/** - * Check if `obj` is a promise. - * - * @param {Object} obj - * @return {Boolean} - * @api private - */ - -function isPromise(obj) { - return 'function' == typeof obj.then; -} - -/** - * Check if `obj` is a generator. - * - * @param {Mixed} obj - * @return {Boolean} - * @api private - */ - -function isGenerator(obj) { - return 'function' == typeof obj.next && 'function' == typeof obj.throw; -} - -/** - * Check if `obj` is a generator function. - * - * @param {Mixed} obj - * @return {Boolean} - * @api private - */ -function isGeneratorFunction(obj) { - var constructor = obj.constructor; - if (!constructor) return false; - if ('GeneratorFunction' === constructor.name || 'GeneratorFunction' === constructor.displayName) return true; - return isGenerator(constructor.prototype); -} - -/** - * Check for plain object. - * - * @param {Mixed} val - * @return {Boolean} - * @api private - */ - -function isObject(val) { - return Object == val.constructor; -} - -return co; -})(); - -// add_task(generatorFunction): -// Call `add_task(generatorFunction)` for each separate -// asynchronous task in a mochitest. Tasks are run consecutively. -// Before the first task, `SimpleTest.waitForExplicitFinish()` -// will be called automatically, and after the last task, -// `SimpleTest.finish()` will be called. -var add_task = (function () { - // The list of tasks to run. - var task_list = []; - var run_only_this_task = null; - - // The "add_task" function - return function (generatorFunction) { - if (task_list.length === 0) { - // This is the first time add_task has been called. - // First, confirm that SimpleTest is available. - if (!SimpleTest) { - throw new Error("SimpleTest not available."); - } - // Don't stop tests until asynchronous tasks are finished. - SimpleTest.waitForExplicitFinish(); - // Because the client is using add_task for this set of tests, - // we need to spawn a "master task" that calls each task in succesion. - // Use setTimeout to ensure the master task runs after the client - // script finishes. - setTimeout(function () { - spawn_task(function* () { - // Allow for a task to be skipped; we need only use the structured logger - // for this, whilst deactivating log buffering to ensure that messages - // are always printed to stdout. - function skipTask(name) { - let logger = parentRunner && parentRunner.structuredLogger; - if (!logger) { - info("SpawnTask.js | Skipping test " + name); - return; - } - logger.deactivateBuffering(); - logger.testStatus(SimpleTest._getCurrentTestURL(), name, "SKIP"); - logger.warning("SpawnTask.js | Skipping test " + name); - logger.activateBuffering(); - } - - // We stop the entire test file at the first exception because this - // may mean that the state of subsequent tests may be corrupt. - try { - for (var task of task_list) { - var name = task.name || ""; - if (task.__skipMe || (run_only_this_task && task != run_only_this_task)) { - skipTask(name); - continue; - } - info("SpawnTask.js | Entering test " + name); - yield task(); - info("SpawnTask.js | Leaving test " + name); - } - } catch (ex) { - try { - ok(false, "" + ex, "Should not throw any errors", ex.stack); - } catch (ex2) { - ok(false, "(The exception cannot be converted to string.)", - "Should not throw any errors", ex.stack); - } - } - // All tasks are finished. - SimpleTest.finish(); - }); - }); - } - generatorFunction.skip = () => generatorFunction.__skipMe = true; - generatorFunction.only = () => run_only_this_task = generatorFunction; - // Add the task to the list of tasks to run after - // the main thread is finished. - task_list.push(generatorFunction); - return generatorFunction; - }; -})(); diff --git a/testing/mochitest/tests/SimpleTest/moz.build b/testing/mochitest/tests/SimpleTest/moz.build index 461a6f49b7fb..2ea92577e607 100644 --- a/testing/mochitest/tests/SimpleTest/moz.build +++ b/testing/mochitest/tests/SimpleTest/moz.build @@ -7,6 +7,7 @@ TEST_HARNESS_FILES.testing.mochitest.tests.SimpleTest += [ '/docshell/test/chrome/docshell_helpers.js', '/testing/specialpowers/content/MozillaLogger.js', + 'AddTask.js', 'EventUtils.js', 'ExtensionTestUtils.js', 'iframe-between-tests.html', @@ -17,7 +18,6 @@ TEST_HARNESS_FILES.testing.mochitest.tests.SimpleTest += [ 'paint_listener.js', 'setup.js', 'SimpleTest.js', - 'SpawnTask.js', 'test.css', 'TestRunner.js', 'WindowSnapshot.js', diff --git a/testing/mozharness/configs/web_platform_tests/prod_config.py b/testing/mozharness/configs/web_platform_tests/prod_config.py index fe1c905d9957..a195d8cf928d 100644 --- a/testing/mozharness/configs/web_platform_tests/prod_config.py +++ b/testing/mozharness/configs/web_platform_tests/prod_config.py @@ -36,6 +36,6 @@ config = { # this would normally be in "exes", but "exes" is clobbered by remove_executables "geckodriver": "%(abs_test_bin_dir)s/geckodriver", - "verify_category": "web-platform", + "per_test_category": "web-platform", } diff --git a/testing/mozharness/configs/web_platform_tests/prod_config_windows.py b/testing/mozharness/configs/web_platform_tests/prod_config_windows.py index 3cb77adc5896..576a74d0dc84 100644 --- a/testing/mozharness/configs/web_platform_tests/prod_config_windows.py +++ b/testing/mozharness/configs/web_platform_tests/prod_config_windows.py @@ -42,5 +42,5 @@ config = { "download_minidump_stackwalk": True, - "verify_category": "web-platform", + "per_test_category": "web-platform", } diff --git a/testing/mozharness/configs/web_platform_tests/prod_config_windows_taskcluster.py b/testing/mozharness/configs/web_platform_tests/prod_config_windows_taskcluster.py index b7d262986caa..ac5c69dca30a 100644 --- a/testing/mozharness/configs/web_platform_tests/prod_config_windows_taskcluster.py +++ b/testing/mozharness/configs/web_platform_tests/prod_config_windows_taskcluster.py @@ -64,5 +64,5 @@ config = { "download_minidump_stackwalk": True, - "verify_category": "web-platform", + "per_test_category": "web-platform", } diff --git a/testing/mozharness/mozharness/mozilla/testing/codecoverage.py b/testing/mozharness/mozharness/mozilla/testing/codecoverage.py index 68089c151bc5..b76984e06b6c 100644 --- a/testing/mozharness/mozharness/mozilla/testing/codecoverage.py +++ b/testing/mozharness/mozharness/mozilla/testing/codecoverage.py @@ -14,6 +14,8 @@ from mozharness.base.script import ( PreScriptAction, PostScriptAction, ) +from mozharness.mozilla.testing.per_test_base import SingleTestMixin + _here = os.path.abspath(os.path.dirname(__file__)) _tooltool_path = os.path.normpath(os.path.join(_here, '..', '..', '..', @@ -27,6 +29,12 @@ code_coverage_config_options = [ "default": False, "help": "Whether gcov c++ code coverage should be run." }], + [["--per-test-coverage"], + {"action": "store_true", + "dest": "per_test_coverage", + "default": False, + "help": "Whether per-test coverage should be collected." + }], [["--disable-ccov-upload"], {"action": "store_true", "dest": "disable_ccov_upload", @@ -42,7 +50,7 @@ code_coverage_config_options = [ ] -class CodeCoverageMixin(object): +class CodeCoverageMixin(SingleTestMixin): """ Mixin for setting GCOV_PREFIX during test execution, packaging up the resulting .gcda files and uploading them to blobber. @@ -51,6 +59,9 @@ class CodeCoverageMixin(object): jsvm_dir = None prefix = None + def __init__(self): + super(CodeCoverageMixin, self).__init__() + @property def code_coverage_enabled(self): try: @@ -62,6 +73,13 @@ class CodeCoverageMixin(object): except (AttributeError, KeyError, TypeError): return False + @property + def per_test_coverage(self): + try: + return bool(self.config.get('per_test_coverage')) + except (AttributeError, KeyError, TypeError): + return False + @property def ccov_upload_disabled(self): try: @@ -82,8 +100,8 @@ class CodeCoverageMixin(object): except (AttributeError, KeyError, TypeError): return False - @PreScriptAction('run-tests') - def _set_gcov_prefix(self, action): + @PostScriptAction('download-and-extract') + def setup_coverage_tools(self, action, success=None): if not self.code_coverage_enabled: return @@ -98,14 +116,6 @@ class CodeCoverageMixin(object): os.environ['GCOV_PREFIX_STRIP'] = str(strip_count) - # Set the GCOV directory. - self.gcov_dir = tempfile.mkdtemp() - os.environ['GCOV_PREFIX'] = self.gcov_dir - - # Set JSVM directory. - self.jsvm_dir = tempfile.mkdtemp() - os.environ['JS_CODE_COVERAGE_OUTPUT_DIR'] = self.jsvm_dir - # Install grcov on the test machine # Get the path to the build machines gcno files. self.url_to_gcno = self.query_build_dir_url('target.code-coverage-gcno.zip') @@ -133,6 +143,97 @@ class CodeCoverageMixin(object): with tarfile.open(os.path.join(self.grcov_dir, tar_file)) as tar: tar.extractall(self.grcov_dir) + # Download the gcno archive from the build machine. + self.download_file(self.url_to_gcno, parent_dir=self.grcov_dir) + + # Download the chrome-map.json file from the build machine. + self.download_file(self.url_to_chrome_map, parent_dir=self.grcov_dir) + + @PostScriptAction('download-and-extract') + def find_tests_for_coverage(self, action, success=None): + """ + For each file modified on this push, determine if the modified file + is a test, by searching test manifests. Populate self.verify_suites + with test files, organized by suite. + + This depends on test manifests, so can only run after test zips have + been downloaded and extracted. + """ + if not self.per_test_coverage: + return + + self.find_modified_tests() + # TODO: Add tests that haven't been run for a while (a week? N pushes?) + + @property + def coverage_args(self): + return [] + + def set_coverage_env(self, env): + # Set the GCOV directory. + gcov_dir = tempfile.mkdtemp() + env['GCOV_PREFIX'] = gcov_dir + + # Set JSVM directory. + jsvm_dir = tempfile.mkdtemp() + env['JS_CODE_COVERAGE_OUTPUT_DIR'] = jsvm_dir + + return (gcov_dir, jsvm_dir) + + @PreScriptAction('run-tests') + def _set_gcov_prefix(self, action): + if not self.code_coverage_enabled: + return + + if self.per_test_coverage: + return + + self.gcov_dir, self.jsvm_dir = self.set_coverage_env(os.environ) + + def parse_coverage_artifacts(self, gcov_dir, jsvm_dir): + jsvm_output_file = 'jsvm_lcov_output.info' + grcov_output_file = 'grcov_lcov_output.info' + + dirs = self.query_abs_dirs() + + # Zip gcda files (will be given in input to grcov). + file_path_gcda = os.path.join(os.getcwd(), 'code-coverage-gcda.zip') + self.run_command(['zip', '-q', '-0', '-r', file_path_gcda, '.'], cwd=gcov_dir) + + sys.path.append(dirs['abs_test_install_dir']) + sys.path.append(os.path.join(dirs['abs_test_install_dir'], 'mozbuild/codecoverage')) + + from lcov_rewriter import LcovFileRewriter + jsvm_files = [os.path.join(jsvm_dir, e) for e in os.listdir(jsvm_dir)] + rewriter = LcovFileRewriter(os.path.join(self.grcov_dir, 'chrome-map.json')) + rewriter.rewrite_files(jsvm_files, jsvm_output_file, '') + + # Run grcov on the zipped .gcno and .gcda files. + grcov_command = [ + os.path.join(self.grcov_dir, 'grcov'), + '-t', 'lcov', + '-p', self.prefix, + '--ignore-dir', 'gcc*', + '--ignore-dir', 'vs2017_*', + os.path.join(self.grcov_dir, 'target.code-coverage-gcno.zip'), file_path_gcda + ] + + if mozinfo.os == 'win': + grcov_command += ['--llvm'] + + # 'grcov_output' will be a tuple, the first variable is the path to the lcov output, + # the other is the path to the standard error output. + tmp_output_file, _ = self.get_output_from_command( + grcov_command, + silent=True, + save_tmpfiles=True, + return_type='files', + throw_exception=True, + ) + shutil.move(tmp_output_file, grcov_output_file) + + return grcov_output_file, jsvm_output_file + @PostScriptAction('run-tests') def _package_coverage_data(self, action, success=None): if self.jsd_code_coverage_enabled: @@ -156,65 +257,26 @@ class CodeCoverageMixin(object): if not self.code_coverage_enabled: return + if self.per_test_coverage: + return + del os.environ['GCOV_PREFIX_STRIP'] del os.environ['GCOV_PREFIX'] del os.environ['JS_CODE_COVERAGE_OUTPUT_DIR'] if not self.ccov_upload_disabled: + grcov_output_file, jsvm_output_file = self.parse_coverage_artifacts(self.gcov_dir, self.jsvm_dir) + dirs = self.query_abs_dirs() - # Zip gcda files (will be given in input to grcov). - file_path_gcda = os.path.join(os.getcwd(), 'code-coverage-gcda.zip') - self.run_command(['zip', '-q', '-0', '-r', file_path_gcda, '.'], cwd=self.gcov_dir) - - sys.path.append(dirs['abs_test_install_dir']) - sys.path.append(os.path.join(dirs['abs_test_install_dir'], 'mozbuild/codecoverage')) - - # Download the chrome-map.json file from the build machine. - self.download_file(self.url_to_chrome_map) - - from lcov_rewriter import LcovFileRewriter - jsvm_files = [os.path.join(self.jsvm_dir, e) for e in os.listdir(self.jsvm_dir)] - rewriter = LcovFileRewriter('chrome-map.json') - rewriter.rewrite_files(jsvm_files, 'jsvm_lcov_output.info', '') - - # Package JSVM coverage data. - file_path_jsvm = os.path.join(dirs['abs_blob_upload_dir'], 'code-coverage-jsvm.zip') - self.run_command(['zip', '-q', file_path_jsvm, 'jsvm_lcov_output.info']) - - # GRCOV post-processing - # Download the gcno from the build machine. - self.download_file(self.url_to_gcno, parent_dir=self.grcov_dir) - - # Run grcov on the zipped .gcno and .gcda files. - grcov_command = [ - os.path.join(self.grcov_dir, 'grcov'), - '-t', 'lcov', - '-p', self.prefix, - '--ignore-dir', 'gcc*', - '--ignore-dir', 'vs2017_*', - os.path.join(self.grcov_dir, 'target.code-coverage-gcno.zip'), file_path_gcda - ] - - if mozinfo.os == 'win': - grcov_command += ['--llvm'] - - # 'grcov_output' will be a tuple, the first variable is the path to the lcov output, - # the other is the path to the standard error output. - grcov_output, _ = self.get_output_from_command( - grcov_command, - silent=True, - save_tmpfiles=True, - return_type='files', - throw_exception=True, - ) - output_file_name = 'grcov_lcov_output.info' - shutil.move(grcov_output, os.path.join(self.grcov_dir, output_file_name)) - # Zip the grcov output and upload it. self.run_command( - ['zip', '-q', os.path.join(dirs['abs_blob_upload_dir'], 'code-coverage-grcov.zip'), output_file_name], - cwd=self.grcov_dir + ['zip', '-q', os.path.join(dirs['abs_blob_upload_dir'], 'code-coverage-grcov.zip'), grcov_output_file] + ) + + # Zip the JSVM coverage data and upload it. + self.run_command( + ['zip', '-q', os.path.join(dirs['abs_blob_upload_dir'], 'code-coverage-jsvm.zip'), jsvm_output_file] ) shutil.rmtree(self.gcov_dir) diff --git a/testing/mozharness/mozharness/mozilla/testing/per_test_base.py b/testing/mozharness/mozharness/mozilla/testing/per_test_base.py new file mode 100644 index 000000000000..5e9a2ceae2b4 --- /dev/null +++ b/testing/mozharness/mozharness/mozilla/testing/per_test_base.py @@ -0,0 +1,291 @@ +#!/usr/bin/env python +# ***** BEGIN LICENSE BLOCK ***** +# 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/. +# ***** END LICENSE BLOCK ***** + +import argparse +import os +import posixpath +import re +import sys +import mozinfo +from manifestparser import TestManifest +from mozharness.base.script import PostScriptAction + + +class SingleTestMixin(object): + """Utility functions for per-test testing like test verification and per-test coverage.""" + + def __init__(self): + self.suites = {} + self.tests_downloaded = False + self.reftest_test_dir = None + self.jsreftest_test_dir = None + + def _find_misc_tests(self, dirs, changed_files): + manifests = [ + (os.path.join(dirs['abs_mochitest_dir'], 'tests', 'mochitest.ini'), 'plain'), + (os.path.join(dirs['abs_mochitest_dir'], 'chrome', 'chrome.ini'), 'chrome'), + (os.path.join(dirs['abs_mochitest_dir'], 'browser', 'browser-chrome.ini'), 'browser-chrome'), + (os.path.join(dirs['abs_mochitest_dir'], 'a11y', 'a11y.ini'), 'a11y'), + (os.path.join(dirs['abs_xpcshell_dir'], 'tests', 'xpcshell.ini'), 'xpcshell'), + ] + tests_by_path = {} + for (path, suite) in manifests: + if os.path.exists(path): + man = TestManifest([path], strict=False) + active = man.active_tests(exists=False, disabled=True, filters=[], **mozinfo.info) + # Remove disabled tests. Also, remove tests with the same path as + # disabled tests, even if they are not disabled, since per-test mode + # specifies tests by path (it cannot distinguish between two or more + # tests with the same path specified in multiple manifests). + disabled = [t['relpath'] for t in active if 'disabled' in t] + new_by_path = {t['relpath']:(suite,t.get('subsuite')) \ + for t in active if 'disabled' not in t and \ + t['relpath'] not in disabled} + tests_by_path.update(new_by_path) + self.info("Per-test run updated with manifest %s" % path) + + ref_manifests = [ + (os.path.join(dirs['abs_reftest_dir'], 'tests', 'layout', 'reftests', 'reftest.list'), 'reftest'), + (os.path.join(dirs['abs_reftest_dir'], 'tests', 'testing', 'crashtest', 'crashtests.list'), 'crashtest'), + ] + sys.path.append(dirs['abs_reftest_dir']) + import manifest + self.reftest_test_dir = os.path.join(dirs['abs_reftest_dir'], 'tests') + for (path, suite) in ref_manifests: + if os.path.exists(path): + man = manifest.ReftestManifest() + man.load(path) + tests_by_path.update({os.path.relpath(t,self.reftest_test_dir):(suite,None) for t in man.files}) + self.info("Per-test run updated with manifest %s" % path) + + suite = 'jsreftest' + self.jsreftest_test_dir = os.path.join(dirs['abs_test_install_dir'], 'jsreftest', 'tests') + path = os.path.join(self.jsreftest_test_dir, 'jstests.list') + if os.path.exists(path): + man = manifest.ReftestManifest() + man.load(path) + for t in man.files: + # expect manifest test to look like: + # ".../tests/jsreftest/tests/jsreftest.html?test=test262/.../some_test.js" + # while the test is in mercurial at: + # js/src/tests/test262/.../some_test.js + epos = t.find('=') + if epos > 0: + relpath = t[epos+1:] + relpath = os.path.join('js', 'src', 'tests', relpath) + tests_by_path.update({relpath:(suite,None)}) + else: + self.warning("unexpected jsreftest test format: %s" % str(t)) + self.info("Per-test run updated with manifest %s" % path) + + # for each changed file, determine if it is a test file, and what suite it is in + for file in changed_files: + # manifest paths use os.sep (like backslash on Windows) but + # automation-relevance uses posixpath.sep + file = file.replace(posixpath.sep, os.sep) + entry = tests_by_path.get(file) + if entry: + self.info("Per-test run found test %s" % file) + subsuite_mapping = { + ('browser-chrome', 'clipboard') : 'browser-chrome-clipboard', + ('chrome', 'clipboard') : 'chrome-clipboard', + ('plain', 'clipboard') : 'plain-clipboard', + ('browser-chrome', 'devtools') : 'mochitest-devtools-chrome', + ('browser-chrome', 'gpu') : 'browser-chrome-gpu', + ('browser-chrome', 'screenshots') : 'browser-chrome-screenshots', + ('chrome', 'gpu') : 'chrome-gpu', + ('plain', 'gpu') : 'plain-gpu', + ('plain', 'media') : 'mochitest-media', + ('plain', 'webgl') : 'mochitest-gl', + } + if entry in subsuite_mapping: + suite = subsuite_mapping[entry] + else: + suite = entry[0] + suite_files = self.suites.get(suite) + if not suite_files: + suite_files = [] + suite_files.append(file) + self.suites[suite] = suite_files + + def _find_wpt_tests(self, dirs, changed_files): + # Setup sys.path to include all the dependencies required to import + # the web-platform-tests manifest parser. web-platform-tests provides + # the localpaths.py to do the path manipulation, which we load, + # providing the __file__ variable so it can resolve the relative + # paths correctly. + paths_file = os.path.join(dirs['abs_wpttest_dir'], + "tests", "tools", "localpaths.py") + execfile(paths_file, {"__file__": paths_file}) + import manifest as wptmanifest + tests_root = os.path.join(dirs['abs_wpttest_dir'], "tests") + man_path = os.path.join(dirs['abs_wpttest_dir'], "meta", "MANIFEST.json") + man = wptmanifest.manifest.load(tests_root, man_path) + + repo_tests_path = os.path.join("testing", "web-platform", "tests") + tests_path = os.path.join("tests", "web-platform", "tests") + for (type, path, test) in man: + if type not in ["testharness", "reftest", "wdspec"]: + continue + repo_path = os.path.join(repo_tests_path, path) + # manifest paths use os.sep (like backslash on Windows) but + # automation-relevance uses posixpath.sep + repo_path = repo_path.replace(os.sep, posixpath.sep) + if repo_path in changed_files: + self.info("found web-platform test file '%s', type %s" % (path, type)) + suite_files = self.suites.get(type) + if not suite_files: + suite_files = [] + path = os.path.join(tests_path, path) + suite_files.append(path) + self.suites[type] = suite_files + + def find_modified_tests(self): + """ + For each file modified on this push, determine if the modified file + is a test, by searching test manifests. Populate self.suites + with test files, organized by suite. + + This depends on test manifests, so can only run after test zips have + been downloaded and extracted. + """ + repository = os.environ.get("GECKO_HEAD_REPOSITORY") + revision = os.environ.get("GECKO_HEAD_REV") + if not repository or not revision: + self.warning("unable to run tests in per-test mode: no repo or revision!") + return [] + + def get_automationrelevance(): + response = self.load_json_url(url) + return response + + dirs = self.query_abs_dirs() + mozinfo.find_and_update_from_json(dirs['abs_test_install_dir']) + e10s = self.config.get('e10s', False) + mozinfo.update({"e10s": e10s}) + headless = self.config.get('headless', False) + mozinfo.update({"headless": headless}) + # FIXME(emilio): Need to update test expectations. + mozinfo.update({'stylo': True}) + mozinfo.update({'verify': True}) + self.info("Per-test run using mozinfo: %s" % str(mozinfo.info)) + + # determine which files were changed on this push + url = '%s/json-automationrelevance/%s' % (repository.rstrip('/'), revision) + contents = self.retry(get_automationrelevance, attempts=2, sleeptime=10) + changed_files = set() + for c in contents['changesets']: + self.info(" {cset} {desc}".format( + cset=c['node'][0:12], + desc=c['desc'].splitlines()[0].encode('ascii', 'ignore'))) + changed_files |= set(c['files']) + + if self.config.get('per_test_category') == "web-platform": + self._find_wpt_tests(dirs, changed_files) + else: + self._find_misc_tests(dirs, changed_files) + + self.tests_downloaded = True + + def query_args(self, suite): + """ + For the specified suite, return an array of command line arguments to + be passed to test harnesses when running in per-test mode. + + Each array element is an array of command line arguments for a modified + test in the suite. + """ + # not in verify or per-test coverage mode: run once, with no additional args + if not self.per_test_coverage and not self.verify_enabled: + return [[]] + + references = re.compile(r"(-ref|-notref|-noref|-noref.)\.") + files = [] + jsreftest_extra_dir = os.path.join('js', 'src', 'tests') + # For some suites, the test path needs to be updated before passing to + # the test harness. + for file in self.suites.get(suite): + if (self.config.get('per_test_category') != "web-platform" and + suite in ['reftest', 'crashtest']): + file = os.path.join(self.reftest_test_dir, file) + if suite == 'reftest': + # Special handling for modified reftest reference files: + # - if both test and reference modified, run the test file + # - if only reference modified, run the test file + nonref = references.sub('.', file) + if nonref != file: + file = None + if nonref not in files and os.path.exists(nonref): + file = nonref + elif (self.config.get('per_test_category') != "web-platform" and + suite == 'jsreftest'): + file = os.path.relpath(file, jsreftest_extra_dir) + file = os.path.join(self.jsreftest_test_dir, file) + + if file is None: + continue + + file = file.replace(os.sep, posixpath.sep) + files.append(file) + + self.info("Per-test file(s) for '%s': %s" % (suite, files)) + + args = [] + for file in files: + cur = [] + + cur.extend(self.coverage_args) + cur.extend(self.verify_args) + + cur.append(file) + args.append(cur) + + return args + + def query_per_test_category_suites(self, category, all_suites): + """ + In per-test mode, determine which suites are active, for the given + suite category. + """ + suites = None + if self.verify_enabled or self.per_test_coverage: + if self.config.get('per_test_category') == "web-platform": + suites = self.suites.keys() + elif all_suites and self.tests_downloaded: + suites = dict((key, all_suites.get(key)) for key in + self.suites if key in all_suites.keys()) + else: + # Until test zips are downloaded, manifests are not available, + # so it is not possible to determine which suites are active/ + # required for per-test mode; assume all suites from supported + # suite categories are required. + if category in ['mochitest', 'xpcshell', 'reftest']: + suites = all_suites + return suites + + def log_per_test_status(self, test_name, tbpl_status, log_level): + """ + Log status of a single test. This will display in the + Job Details pane in treeherder - a convenient summary of per-test mode. + Special test name formatting is needed because treeherder truncates + lines that are too long, and may remove duplicates after truncation. + """ + max_test_name_len = 40 + if len(test_name) > max_test_name_len: + head = test_name + new = "" + previous = None + max_test_name_len = max_test_name_len - len('.../') + while len(new) < max_test_name_len: + head, tail = os.path.split(head) + previous = new + new = os.path.join(tail, new) + test_name = os.path.join('...', previous or new) + test_name = test_name.rstrip(os.path.sep) + self.log("TinderboxPrint: Per-test run of %s
: %s" % + (test_name, tbpl_status), level=log_level) + diff --git a/testing/mozharness/mozharness/mozilla/testing/verify_tools.py b/testing/mozharness/mozharness/mozilla/testing/verify_tools.py index b37efa12bf3c..db60e14cc074 100644 --- a/testing/mozharness/mozharness/mozilla/testing/verify_tools.py +++ b/testing/mozharness/mozharness/mozilla/testing/verify_tools.py @@ -5,153 +5,32 @@ # You can obtain one at http://mozilla.org/MPL/2.0/. # ***** END LICENSE BLOCK ***** -import argparse -import os -import posixpath -import re -import sys -import mozinfo -from manifestparser import TestManifest from mozharness.base.script import PostScriptAction +from mozharness.mozilla.testing.per_test_base import SingleTestMixin + verify_config_options = [ [["--verify"], {"action": "store_true", "dest": "verify", - "default": "False", + "default": False, "help": "Run additional verification on modified tests." }], ] -class VerifyToolsMixin(object): +class VerifyToolsMixin(SingleTestMixin): """Utility functions for test verification.""" def __init__(self): - self.verify_suites = {} - self.verify_downloaded = False - self.reftest_test_dir = None - self.jsreftest_test_dir = None + super(VerifyToolsMixin, self).__init__() - def _find_misc_tests(self, dirs, changed_files): - manifests = [ - (os.path.join(dirs['abs_mochitest_dir'], 'tests', 'mochitest.ini'), 'plain'), - (os.path.join(dirs['abs_mochitest_dir'], 'chrome', 'chrome.ini'), 'chrome'), - (os.path.join(dirs['abs_mochitest_dir'], 'browser', 'browser-chrome.ini'), 'browser-chrome'), - (os.path.join(dirs['abs_mochitest_dir'], 'a11y', 'a11y.ini'), 'a11y'), - (os.path.join(dirs['abs_xpcshell_dir'], 'tests', 'xpcshell.ini'), 'xpcshell'), - ] - tests_by_path = {} - for (path, suite) in manifests: - if os.path.exists(path): - man = TestManifest([path], strict=False) - active = man.active_tests(exists=False, disabled=True, filters=[], **mozinfo.info) - # Remove disabled tests. Also, remove tests with the same path as - # disabled tests, even if they are not disabled, since test-verify - # specifies tests by path (it cannot distinguish between two or more - # tests with the same path specified in multiple manifests). - disabled = [t['relpath'] for t in active if 'disabled' in t] - new_by_path = {t['relpath']:(suite,t.get('subsuite')) \ - for t in active if 'disabled' not in t and \ - t['relpath'] not in disabled} - tests_by_path.update(new_by_path) - self.info("Verification updated with manifest %s" % path) - - ref_manifests = [ - (os.path.join(dirs['abs_reftest_dir'], 'tests', 'layout', 'reftests', 'reftest.list'), 'reftest'), - (os.path.join(dirs['abs_reftest_dir'], 'tests', 'testing', 'crashtest', 'crashtests.list'), 'crashtest'), - ] - sys.path.append(dirs['abs_reftest_dir']) - import manifest - self.reftest_test_dir = os.path.join(dirs['abs_reftest_dir'], 'tests') - for (path, suite) in ref_manifests: - if os.path.exists(path): - man = manifest.ReftestManifest() - man.load(path) - tests_by_path.update({os.path.relpath(t,self.reftest_test_dir):(suite,None) for t in man.files}) - self.info("Verification updated with manifest %s" % path) - - suite = 'jsreftest' - self.jsreftest_test_dir = os.path.join(dirs['abs_test_install_dir'], 'jsreftest', 'tests') - path = os.path.join(self.jsreftest_test_dir, 'jstests.list') - if os.path.exists(path): - man = manifest.ReftestManifest() - man.load(path) - for t in man.files: - # expect manifest test to look like: - # ".../tests/jsreftest/tests/jsreftest.html?test=test262/.../some_test.js" - # while the test is in mercurial at: - # js/src/tests/test262/.../some_test.js - epos = t.find('=') - if epos > 0: - relpath = t[epos+1:] - relpath = os.path.join('js', 'src', 'tests', relpath) - tests_by_path.update({relpath:(suite,None)}) - else: - self.warning("unexpected jsreftest test format: %s" % str(t)) - self.info("Verification updated with manifest %s" % path) - - # for each changed file, determine if it is a test file, and what suite it is in - for file in changed_files: - # manifest paths use os.sep (like backslash on Windows) but - # automation-relevance uses posixpath.sep - file = file.replace(posixpath.sep, os.sep) - entry = tests_by_path.get(file) - if entry: - self.info("Verification found test %s" % file) - subsuite_mapping = { - ('browser-chrome', 'clipboard') : 'browser-chrome-clipboard', - ('chrome', 'clipboard') : 'chrome-clipboard', - ('plain', 'clipboard') : 'plain-clipboard', - ('browser-chrome', 'devtools') : 'mochitest-devtools-chrome', - ('browser-chrome', 'gpu') : 'browser-chrome-gpu', - ('browser-chrome', 'screenshots') : 'browser-chrome-screenshots', - ('chrome', 'gpu') : 'chrome-gpu', - ('plain', 'gpu') : 'plain-gpu', - ('plain', 'media') : 'mochitest-media', - ('plain', 'webgl') : 'mochitest-gl', - } - if entry in subsuite_mapping: - suite = subsuite_mapping[entry] - else: - suite = entry[0] - suite_files = self.verify_suites.get(suite) - if not suite_files: - suite_files = [] - suite_files.append(file) - self.verify_suites[suite] = suite_files - - def _find_wpt_tests(self, dirs, changed_files): - # Setup sys.path to include all the dependencies required to import - # the web-platform-tests manifest parser. web-platform-tests provides - # the localpaths.py to do the path manipulation, which we load, - # providing the __file__ variable so it can resolve the relative - # paths correctly. - paths_file = os.path.join(dirs['abs_wpttest_dir'], - "tests", "tools", "localpaths.py") - execfile(paths_file, {"__file__": paths_file}) - import manifest as wptmanifest - tests_root = os.path.join(dirs['abs_wpttest_dir'], "tests") - man_path = os.path.join(dirs['abs_wpttest_dir'], "meta", "MANIFEST.json") - man = wptmanifest.manifest.load(tests_root, man_path) - - repo_tests_path = os.path.join("testing", "web-platform", "tests") - tests_path = os.path.join("tests", "web-platform", "tests") - for (type, path, test) in man: - if type not in ["testharness", "reftest", "wdspec"]: - continue - repo_path = os.path.join(repo_tests_path, path) - # manifest paths use os.sep (like backslash on Windows) but - # automation-relevance uses posixpath.sep - repo_path = repo_path.replace(os.sep, posixpath.sep) - if repo_path in changed_files: - self.info("found web-platform test file '%s', type %s" % (path, type)) - suite_files = self.verify_suites.get(type) - if not suite_files: - suite_files = [] - path = os.path.join(tests_path, path) - suite_files.append(path) - self.verify_suites[type] = suite_files + @property + def verify_enabled(self): + try: + return bool(self.config.get('verify')) + except (AttributeError, KeyError, TypeError): + return False @PostScriptAction('download-and-extract') def find_tests_for_verification(self, action, success=None): @@ -164,140 +43,25 @@ class VerifyToolsMixin(object): been downloaded and extracted. """ - if self.config.get('verify') != True: + if not self.verify_enabled: return - repository = os.environ.get("GECKO_HEAD_REPOSITORY") - revision = os.environ.get("GECKO_HEAD_REV") - if not repository or not revision: - self.warning("unable to verify tests: no repo or revision!") + self.find_modified_tests() + + @property + def verify_args(self): + if not self.verify_enabled: return [] - def get_automationrelevance(): - response = self.load_json_url(url) - return response - - dirs = self.query_abs_dirs() - mozinfo.find_and_update_from_json(dirs['abs_test_install_dir']) - e10s = self.config.get('e10s', False) - mozinfo.update({"e10s": e10s}) - headless = self.config.get('headless', False) - mozinfo.update({"headless": headless}) - # FIXME(emilio): Need to update test expectations. - mozinfo.update({'stylo': True}) - mozinfo.update({'verify': True}) - self.info("Verification using mozinfo: %s" % str(mozinfo.info)) - - # determine which files were changed on this push - url = '%s/json-automationrelevance/%s' % (repository.rstrip('/'), revision) - contents = self.retry(get_automationrelevance, attempts=2, sleeptime=10) - changed_files = set() - for c in contents['changesets']: - self.info(" {cset} {desc}".format( - cset=c['node'][0:12], - desc=c['desc'].splitlines()[0].encode('ascii', 'ignore'))) - changed_files |= set(c['files']) - - if self.config.get('verify_category') == "web-platform": - self._find_wpt_tests(dirs, changed_files) - else: - self._find_misc_tests(dirs, changed_files) - - self.verify_downloaded = True - - def query_verify_args(self, suite): - """ - For the specified suite, return an array of command line arguments to - be passed to test harnesses when running in verify mode. - - Each array element is an array of command line arguments for a modified - test in the suite. - """ - # Limit each test harness run to 15 minutes, to avoid task timeouts - # when verifying long-running tests. + # when executing long-running tests. MAX_TIME_PER_TEST = 900 - if self.config.get('verify') != True: - # not in verify mode: run once, with no additional args - args = [[]] + if self.config.get('per_test_category') == "web-platform": + args = ['--verify-log-full'] else: - # in verify mode, run nothing by default (unsupported suite or no files modified) - args = [] - # otherwise, run once for each file in requested suite - references = re.compile(r"(-ref|-notref|-noref|-noref.)\.") - files = [] - jsreftest_extra_dir = os.path.join('js', 'src', 'tests') - # For some suites, the test path needs to be updated before passing to - # the test harness. - for file in self.verify_suites.get(suite): - if (self.config.get('verify_category') != "web-platform" and - suite in ['reftest', 'crashtest']): - file = os.path.join(self.reftest_test_dir, file) - elif (self.config.get('verify_category') != "web-platform" and - suite == 'jsreftest'): - file = os.path.relpath(file, jsreftest_extra_dir) - file = os.path.join(self.jsreftest_test_dir, file) - file = file.replace(os.sep, posixpath.sep) - files.append(file) - for file in files: - if self.config.get('verify_category') == "web-platform": - args.append(['--verify-log-full', '--verify', file]) - else: - if suite == 'reftest': - # Special handling for modified reftest reference files: - # - if both test and reference modified, verify the test file - # - if only reference modified, verify the test file - nonref = references.sub('.', file) - if nonref != file: - file = None - if nonref not in files and os.path.exists(nonref): - file = nonref - if file: - args.append(['--verify-max-time=%d' % MAX_TIME_PER_TEST, '--verify', file]) - self.info("Verification file(s) for '%s': %s" % (suite, files)) + args = ['--verify-max-time=%d' % MAX_TIME_PER_TEST] + + args.append('--verify') + return args - - def query_verify_category_suites(self, category, all_suites): - """ - In verify mode, determine which suites are active, for the given - suite category. - """ - suites = None - if self.config.get('verify') == True: - if self.config.get('verify_category') == "web-platform": - suites = self.verify_suites.keys() - elif all_suites and self.verify_downloaded: - suites = dict((key, all_suites.get(key)) for key in - self.verify_suites if key in all_suites.keys()) - else: - # Until test zips are downloaded, manifests are not available, - # so it is not possible to determine which suites are active/ - # required for verification; assume all suites from supported - # suite categories are required. - if category in ['mochitest', 'xpcshell', 'reftest']: - suites = all_suites - return suites - - def log_verify_status(self, test_name, tbpl_status, log_level): - """ - Log verification status of a single test. This will display in the - Job Details pane in treeherder - a convenient summary of verification. - Special test name formatting is needed because treeherder truncates - lines that are too long, and may remove duplicates after truncation. - """ - max_test_name_len = 40 - if len(test_name) > max_test_name_len: - head = test_name - new = "" - previous = None - max_test_name_len = max_test_name_len - len('.../') - while len(new) < max_test_name_len: - head, tail = os.path.split(head) - previous = new - new = os.path.join(tail, new) - test_name = os.path.join('...', previous or new) - test_name = test_name.rstrip(os.path.sep) - self.log("TinderboxPrint: Verification of %s
: %s" % - (test_name, tbpl_status), level=log_level) - diff --git a/testing/mozharness/scripts/android_emulator_unittest.py b/testing/mozharness/scripts/android_emulator_unittest.py index 02a64d5d6600..af157b02c754 100644 --- a/testing/mozharness/scripts/android_emulator_unittest.py +++ b/testing/mozharness/scripts/android_emulator_unittest.py @@ -27,9 +27,11 @@ from mozharness.mozilla.buildbot import TBPL_RETRY, EXIT_STATUS_DICT from mozharness.mozilla.mozbase import MozbaseMixin from mozharness.mozilla.testing.testbase import TestingMixin, testing_config_options from mozharness.mozilla.testing.unittest import EmulatorMixin +from mozharness.mozilla.testing.codecoverage import CodeCoverageMixin -class AndroidEmulatorTest(TestingMixin, EmulatorMixin, BaseScript, MozbaseMixin): +class AndroidEmulatorTest(TestingMixin, EmulatorMixin, BaseScript, MozbaseMixin, + CodeCoverageMixin): config_options = [[ ["--test-suite"], {"action": "store", @@ -471,7 +473,7 @@ class AndroidEmulatorTest(TestingMixin, EmulatorMixin, BaseScript, MozbaseMixin) try_options, try_tests = self.try_args(self.test_suite) cmd.extend(try_options) - if self.config.get('verify') is not True: + if not self.verify_enabled and not self.per_test_coverage: cmd.extend(self.query_tests_args( self.config["suite_definitions"][self.test_suite].get("tests"), None, @@ -740,7 +742,7 @@ class AndroidEmulatorTest(TestingMixin, EmulatorMixin, BaseScript, MozbaseMixin) def _query_suites(self): if self.test_suite: return [(self.test_suite, self.test_suite)] - # test-verification: determine test suites to be verified + # per-test mode: determine test suites to run all = [('mochitest', {'plain': 'mochitest', 'chrome': 'mochitest-chrome', 'plain-clipboard': 'mochitest-plain-clipboard', @@ -749,7 +751,7 @@ class AndroidEmulatorTest(TestingMixin, EmulatorMixin, BaseScript, MozbaseMixin) ('xpcshell', {'xpcshell': 'xpcshell'})] suites = [] for (category, all_suites) in all: - cat_suites = self.query_verify_category_suites(category, all_suites) + cat_suites = self.query_per_test_category_suites(category, all_suites) for k in cat_suites.keys(): suites.append((k, cat_suites[k])) return suites @@ -758,7 +760,7 @@ class AndroidEmulatorTest(TestingMixin, EmulatorMixin, BaseScript, MozbaseMixin) if self.test_suite: categories = [self.test_suite] else: - # test-verification + # per-test mode categories = ['mochitest', 'reftest', 'xpcshell'] return categories @@ -767,12 +769,12 @@ class AndroidEmulatorTest(TestingMixin, EmulatorMixin, BaseScript, MozbaseMixin) Run the tests """ self.start_time = datetime.datetime.now() - max_verify_time = datetime.timedelta(minutes=60) + max_per_test_time = datetime.timedelta(minutes=60) - verify_args = [] + per_test_args = [] suites = self._query_suites() minidump = self.query_minidump_stackwalk() - for (verify_suite, suite) in suites: + for (per_test_suite, suite) in suites: self.test_suite = suite cmd = self._build_command() @@ -788,24 +790,24 @@ class AndroidEmulatorTest(TestingMixin, EmulatorMixin, BaseScript, MozbaseMixin) env['MINIDUMP_SAVE_PATH'] = self.query_abs_dirs()['abs_blob_upload_dir'] env['RUST_BACKTRACE'] = 'full' - for verify_args in self.query_verify_args(verify_suite): - if (datetime.datetime.now() - self.start_time) > max_verify_time: - # Verification has run out of time. That is okay! Stop running - # tests so that a task timeout is not triggered, and so that + for per_test_args in self.query_args(per_test_suite): + if (datetime.datetime.now() - self.start_time) > max_per_test_time: + # Running tests has run out of time. That is okay! Stop running + # them so that a task timeout is not triggered, and so that # (partial) results are made available in a timely manner. - self.info("TinderboxPrint: Verification too long: " - "Not all tests were verified.
") - # Signal verify time exceeded, to break out of suites and + self.info("TinderboxPrint: Running tests took too long: " + "Not all tests were executed.
") + # Signal per-test time exceeded, to break out of suites and # suite categories loops also. return False final_cmd = copy.copy(cmd) - if len(verify_args) > 0: - # in verify mode, remove any chunk arguments from command + if len(per_test_args) > 0: + # in per-test mode, remove any chunk arguments from command for arg in final_cmd: if 'total-chunk' in arg or 'this-chunk' in arg: final_cmd.remove(arg) - final_cmd.extend(verify_args) + final_cmd.extend(per_test_args) self.info("Running on %s the command %s" % (self.emulator["name"], subprocess.list2cmdline(final_cmd))) @@ -823,9 +825,9 @@ class AndroidEmulatorTest(TestingMixin, EmulatorMixin, BaseScript, MozbaseMixin) self.info("##### %s log ends" % self.test_suite) - if len(verify_args) > 0: + if len(per_test_args) > 0: self.buildbot_status(tbpl_status, level=log_level) - self.log_verify_status(verify_args[-1], tbpl_status, log_level) + self.log_per_test_status(per_test_args[-1], tbpl_status, log_level) else: self.buildbot_status(tbpl_status, level=log_level) self.log("The %s suite: %s ran with return status: %s" % diff --git a/testing/mozharness/scripts/desktop_unittest.py b/testing/mozharness/scripts/desktop_unittest.py index 3ba4a2ad419d..ae04993ea687 100755 --- a/testing/mozharness/scripts/desktop_unittest.py +++ b/testing/mozharness/scripts/desktop_unittest.py @@ -479,7 +479,7 @@ class DesktopUnittest(TestingMixin, MercurialScript, BlobUploadMixin, MozbaseMix if c.get('run_all_suites'): # needed if you dont specify any suites suites = all_suites else: - suites = self.query_verify_category_suites(category, all_suites) + suites = self.query_per_test_category_suites(category, all_suites) return suites @@ -767,9 +767,9 @@ class DesktopUnittest(TestingMixin, MercurialScript, BlobUploadMixin, MozbaseMix abs_app_dir = self.query_abs_app_dir() abs_res_dir = self.query_abs_res_dir() - max_verify_time = timedelta(minutes=60) - max_verify_tests = 10 - verified_tests = 0 + max_per_test_time = timedelta(minutes=60) + max_per_test_tests = 10 + executed_tests = 0 if suites: self.info('#### Running %s suites' % suite_category) @@ -789,7 +789,7 @@ class DesktopUnittest(TestingMixin, MercurialScript, BlobUploadMixin, MozbaseMix } if isinstance(suites[suite], dict): options_list = suites[suite].get('options', []) - if self.config.get('verify') is True: + if self.verify_enabled or self.per_test_coverage: tests_list = [] else: tests_list = suites[suite].get('tests', []) @@ -848,33 +848,56 @@ class DesktopUnittest(TestingMixin, MercurialScript, BlobUploadMixin, MozbaseMix env = self.query_env(partial_env=env, log_level=INFO) cmd_timeout = self.get_timeout_for_category(suite_category) - for verify_args in self.query_verify_args(suite): - if (datetime.now() - self.start_time) > max_verify_time: - # Verification has run out of time. That is okay! Stop running - # tests so that a task timeout is not triggered, and so that + # Run basic startup/shutdown test to collect baseline coverage. + # This way, after we run a test, we can generate a diff between the + # full coverage of the test and the baseline coverage and only get + # the coverage data specific to the test. + if self.per_test_coverage: + gcov_dir, jsvm_dir = self.set_coverage_env(env) + # TODO: Run basic startup/shutdown test to collect baseline coverage. + # grcov_file, jsvm_file = self.parse_coverage_artifacts(gcov_dir, jsvm_dir) + # shutil.rmtree(gcov_dir) + # shutil.rmtree(jsvm_dir) + # TODO: Parse coverage report + + for per_test_args in self.query_args(suite): + if (datetime.now() - self.start_time) > max_per_test_time: + # Running tests has run out of time. That is okay! Stop running + # them so that a task timeout is not triggered, and so that # (partial) results are made available in a timely manner. - self.info("TinderboxPrint: Verification too long: Not all tests " - "were verified.
") - # Signal verify time exceeded, to break out of suites and + self.info("TinderboxPrint: Running tests took too long: Not all tests " + "were executed.
") + # Signal per-test time exceeded, to break out of suites and # suite categories loops also. return False - if verified_tests >= max_verify_tests: + if executed_tests >= max_per_test_tests: # When changesets are merged between trees or many tests are # otherwise updated at once, there probably is not enough time - # to verify all tests, and attempting to do so may cause other + # to run all tests, and attempting to do so may cause other # problems, such as generating too much log output. self.info("TinderboxPrint: Too many modified tests: Not all tests " - "were verified.
") + "were executed.
") return False - verified_tests = verified_tests + 1 + executed_tests = executed_tests + 1 final_cmd = copy.copy(cmd) - final_cmd.extend(verify_args) + final_cmd.extend(per_test_args) + + if self.per_test_coverage: + gcov_dir, jsvm_dir = self.set_coverage_env(env) + return_code = self.run_command(final_cmd, cwd=dirs['abs_work_dir'], output_timeout=cmd_timeout, output_parser=parser, env=env) + if self.per_test_coverage: + grcov_file, jsvm_file = self.parse_coverage_artifacts(gcov_dir, jsvm_dir) + shutil.rmtree(gcov_dir) + shutil.rmtree(jsvm_dir) + # TODO: Parse coverage report + # TODO: Diff this coverage report with the baseline one + # mochitest, reftest, and xpcshell suites do not return # appropriate return codes. Therefore, we must parse the output # to determine what the tbpl_status and worst_log_level must @@ -895,8 +918,8 @@ class DesktopUnittest(TestingMixin, MercurialScript, BlobUploadMixin, MozbaseMix parser.append_tinderboxprint_line(suite_name) self.buildbot_status(tbpl_status, level=log_level) - if len(verify_args) > 0: - self.log_verify_status(verify_args[-1], tbpl_status, log_level) + if len(per_test_args) > 0: + self.log_per_test_status(per_test_args[-1], tbpl_status, log_level) else: self.log("The %s suite: %s ran with return status: %s" % (suite_category, suite, tbpl_status), level=log_level) diff --git a/testing/mozharness/scripts/web_platform_tests.py b/testing/mozharness/scripts/web_platform_tests.py index 53668cbce3ea..97f998bb5804 100755 --- a/testing/mozharness/scripts/web_platform_tests.py +++ b/testing/mozharness/scripts/web_platform_tests.py @@ -6,6 +6,7 @@ # ***** END LICENSE BLOCK ***** import copy import os +import shutil import sys from datetime import datetime, timedelta @@ -318,44 +319,60 @@ class WebPlatformTest(TestingMixin, MercurialScript, BlobUploadMixin, CodeCovera env = self.query_env(partial_env=env, log_level=INFO) start_time = datetime.now() - max_verify_time = timedelta(minutes=60) - max_verify_tests = 10 - verified_tests = 0 + max_per_test_time = timedelta(minutes=60) + max_per_test_tests = 10 + executed_tests = 0 - if self.config.get("verify") is True: - verify_suites = self.query_verify_category_suites(None, None) - if "wdspec" in verify_suites: + if self.per_test_coverage or self.verify_enabled: + suites = self.query_per_test_category_suites(None, None) + if "wdspec" in suites: # geckodriver is required for wdspec, but not always available geckodriver_path = self._query_geckodriver() if not geckodriver_path or not os.path.isfile(geckodriver_path): - verify_suites.remove("wdspec") - self.info("Test verification skipping 'wdspec' tests - no geckodriver") + suites.remove("wdspec") + self.info("Skipping 'wdspec' tests - no geckodriver") else: test_types = self.config.get("test_type", []) - verify_suites = [None] - for verify_suite in verify_suites: - if verify_suite: - test_types = [verify_suite] - for verify_args in self.query_verify_args(verify_suite): - if (datetime.now() - start_time) > max_verify_time: - # Verification has run out of time. That is okay! Stop running - # tests so that a task timeout is not triggered, and so that + suites = [None] + for suite in suites: + if suite: + test_types = [suite] + + # Run basic startup/shutdown test to collect baseline coverage. + # This way, after we run a test, we can generate a diff between the + # full coverage of the test and the baseline coverage and only get + # the coverage data specific to the test. + if self.per_test_coverage: + gcov_dir, jsvm_dir = self.set_coverage_env(env) + # TODO: Run basic startup/shutdown test to collect baseline coverage. + # grcov_file, jsvm_file = self.parse_coverage_artifacts(gcov_dir, jsvm_dir) + # shutil.rmtree(gcov_dir) + # shutil.rmtree(jsvm_dir) + # TODO: Parse coverage report + + for per_test_args in self.query_args(suite): + if (datetime.now() - start_time) > max_per_test_time: + # Running tests has run out of time. That is okay! Stop running + # them so that a task timeout is not triggered, and so that # (partial) results are made available in a timely manner. - self.info("TinderboxPrint: Verification too long: Not all tests " - "were verified.
") + self.info("TinderboxPrint: Running tests took too long: Not all tests " + "were executed.
") return - if verified_tests >= max_verify_tests: + if executed_tests >= max_per_test_tests: # When changesets are merged between trees or many tests are # otherwise updated at once, there probably is not enough time - # to verify all tests, and attempting to do so may cause other + # to run all tests, and attempting to do so may cause other # problems, such as generating too much log output. self.info("TinderboxPrint: Too many modified tests: Not all tests " - "were verified.
") + "were executed.
") return - verified_tests = verified_tests + 1 + executed_tests = executed_tests + 1 cmd = self._query_cmd(test_types) - cmd.extend(verify_args) + cmd.extend(per_test_args) + + if self.per_test_coverage: + gcov_dir, jsvm_dir = self.set_coverage_env(env) return_code = self.run_command(cmd, cwd=dirs['abs_work_dir'], @@ -363,11 +380,18 @@ class WebPlatformTest(TestingMixin, MercurialScript, BlobUploadMixin, CodeCovera output_parser=parser, env=env) + if self.per_test_coverage: + grcov_file, jsvm_file = self.parse_coverage_artifacts(gcov_dir, jsvm_dir) + shutil.rmtree(gcov_dir) + shutil.rmtree(jsvm_dir) + # TODO: Parse coverage report + # TODO: Diff this coverage report with the baseline one + tbpl_status, log_level = parser.evaluate_parser(return_code) self.buildbot_status(tbpl_status, level=log_level) - if len(verify_args) > 0: - self.log_verify_status(verify_args[-1], tbpl_status, log_level) + if len(per_test_args) > 0: + self.log_per_test_status(per_test_args[-1], tbpl_status, log_level) # main {{{1 diff --git a/testing/web-platform/meta/2dcontext/imagebitmap/createImageBitmap-invalid-args.html.ini b/testing/web-platform/meta/2dcontext/imagebitmap/createImageBitmap-invalid-args.html.ini index 5e964b7277f9..071591d14c46 100644 --- a/testing/web-platform/meta/2dcontext/imagebitmap/createImageBitmap-invalid-args.html.ini +++ b/testing/web-platform/meta/2dcontext/imagebitmap/createImageBitmap-invalid-args.html.ini @@ -1,12 +1,4 @@ [createImageBitmap-invalid-args.html] - expected: - if debug and not webrender and e10s and (os == "linux") and (version == "Ubuntu 16.04") and (processor == "x86") and (bits == 32): CRASH - if debug and not webrender and not e10s and (os == "linux") and (version == "Ubuntu 16.04") and (processor == "x86") and (bits == 32): CRASH - if debug and webrender and e10s and (os == "linux") and (version == "Ubuntu 16.04") and (processor == "x86_64") and (bits == 64): CRASH - if debug and not webrender and e10s and (os == "win") and (version == "6.1.7601") and (processor == "x86") and (bits == 32): CRASH - if debug and not webrender and e10s and (os == "win") and (version == "10.0.15063") and (processor == "x86_64") and (bits == 64): CRASH - if debug and not webrender and e10s and (os == "linux") and (version == "Ubuntu 16.04") and (processor == "x86_64") and (bits == 64): CRASH - if debug and not webrender and e10s and (os == "mac") and (version == "OS X 10.10.5") and (processor == "x86_64") and (bits == 64): CRASH [createImageBitmap with a HTMLImageElement source and sw set to 0 rejects with a RangeError.] expected: FAIL diff --git a/testing/web-platform/meta/MANIFEST.json b/testing/web-platform/meta/MANIFEST.json index 7f084fcbeb3d..f35aa82eb8e2 100644 --- a/testing/web-platform/meta/MANIFEST.json +++ b/testing/web-platform/meta/MANIFEST.json @@ -484888,7 +484888,7 @@ "testharness" ], "css/css-align/default-alignment/shorthand-serialization-001.html": [ - "6c85da43be475b680d5351bdb969d09b90a6d97e", + "6ac628c6278f7ae552c4a2a824dcd6ac52a10cc4", "testharness" ], "css/css-align/distribution-values/space-evenly-001.html": [ @@ -502040,7 +502040,7 @@ "testharness" ], "css/css-fonts/variations/font-parse-numeric-stretch-style-weight.html": [ - "b9aa593e5fcba0d7af8f66446d473608a7025f1c", + "1e116cfb42e4e52fd714ec07c5bce6b9d5dceeda", "testharness" ], "css/css-fonts/variations/font-shorthand.html": [ @@ -519140,11 +519140,11 @@ "reftest" ], "css/css-transforms/css-transform-animate-translate-implied-y-ref.html": [ - "be59175d0020cab7b6eef4473cf4c51695a3101e", + "48d0696cd6b9e9b7ae2b95ab9ada46a6437b3419", "support" ], "css/css-transforms/css-transform-animate-translate-implied-y.html": [ - "f0272619bd352b3870c4a6da1f2a99a6453f10aa", + "69be5da747b26e3ce762391dd5997a5bf697cd6e", "reftest" ], "css/css-transforms/css-transform-inherit-rotate.html": [ @@ -606128,7 +606128,7 @@ "testharness" ], "webmessaging/broadcastchannel/workers.html": [ - "483e03e9528f1e80fc1b250caee46f7f256d63c1", + "2ca289f36c001c15e64b849098e8f28b21178862", "testharness" ], "webmessaging/event.data.sub.htm": [ diff --git a/testing/web-platform/meta/css/css-align/default-alignment/parse-justify-items-004.html.ini b/testing/web-platform/meta/css/css-align/default-alignment/parse-justify-items-004.html.ini deleted file mode 100644 index 6d324d940701..000000000000 --- a/testing/web-platform/meta/css/css-align/default-alignment/parse-justify-items-004.html.ini +++ /dev/null @@ -1,4 +0,0 @@ -[parse-justify-items-004.html] - [Checking invalid combination - justify-items: auto] - expected: FAIL - diff --git a/testing/web-platform/meta/html/browsers/offline/application-cache-api/secure_context.html.ini b/testing/web-platform/meta/html/browsers/offline/application-cache-api/secure_context.html.ini new file mode 100644 index 000000000000..81243f247b6f --- /dev/null +++ b/testing/web-platform/meta/html/browsers/offline/application-cache-api/secure_context.html.ini @@ -0,0 +1,3 @@ +[secure_context.html] + prefs: [browser.cache.offline.insecure.enable:false] + diff --git a/testing/web-platform/meta/svg/historical.html.ini b/testing/web-platform/meta/svg/historical.html.ini index 6d66f5575efc..87582dda0921 100644 --- a/testing/web-platform/meta/svg/historical.html.ini +++ b/testing/web-platform/meta/svg/historical.html.ini @@ -20,15 +20,3 @@ [SVGViewElement.prototype.viewTarget must be removed] expected: FAIL - [SVGSVGElement.prototype.pixelUnitToMillimeterX must be removed] - expected: FAIL - - [SVGSVGElement.prototype.pixelUnitToMillimeterY must be removed] - expected: FAIL - - [SVGSVGElement.prototype.screenPixelToMillimeterX must be removed] - expected: FAIL - - [SVGSVGElement.prototype.screenPixelToMillimeterY must be removed] - expected: FAIL - diff --git a/testing/web-platform/tests/css/css-align/default-alignment/shorthand-serialization-001.html b/testing/web-platform/tests/css/css-align/default-alignment/shorthand-serialization-001.html index 0145ec171eae..730b2ad867ac 100644 --- a/testing/web-platform/tests/css/css-align/default-alignment/shorthand-serialization-001.html +++ b/testing/web-platform/tests/css/css-align/default-alignment/shorthand-serialization-001.html @@ -17,7 +17,7 @@ var initial_values = { alignItems: "normal", alignSelf: "auto", justifyContent: "normal", - justifyItems: "auto", + justifyItems: "legacy", justifySelf: "auto", }; @@ -52,11 +52,11 @@ var place_content_test_cases = [ var place_items_test_cases = [ { alignItems: "center", - shorthand: "center auto", + shorthand: "center legacy", }, { alignItems: "baseline", - shorthand: "baseline auto", + shorthand: "baseline legacy", }, { justifyItems: "safe start", diff --git a/testing/web-platform/tests/fetch/api/request/request-init-003.sub.html b/testing/web-platform/tests/fetch/api/request/request-init-003.sub.html index 507007f1f4c3..79c91cdfe82a 100644 --- a/testing/web-platform/tests/fetch/api/request/request-init-003.sub.html +++ b/testing/web-platform/tests/fetch/api/request/request-init-003.sub.html @@ -44,7 +44,7 @@ "referrer" : "about:client", "referrerPolicy" : "", "mode" : "cors", - "credentials" : "omit", + "credentials" : "same-origin", "cache" : "default", "redirect" : "follow", "integrity" : "", diff --git a/testing/web-platform/tests/fetch/api/request/request-structure.html b/testing/web-platform/tests/fetch/api/request/request-structure.html index 98c24517e66a..ccdb707795c1 100644 --- a/testing/web-platform/tests/fetch/api/request/request-structure.html +++ b/testing/web-platform/tests/fetch/api/request/request-structure.html @@ -76,7 +76,7 @@ break; case "credentials": - defaultValue = "omit"; + defaultValue = "same-origin"; newValue = "cors"; break; diff --git a/testing/xpcshell/selftest.py b/testing/xpcshell/selftest.py index 022202d17c14..6ac969e0c0c4 100755 --- a/testing/xpcshell/selftest.py +++ b/testing/xpcshell/selftest.py @@ -893,14 +893,13 @@ add_test({ """ Ensure a simple test with an uncaught rejection is reported. """ - self.writeFile("test_simple_uncaught_rejection.js", SIMPLE_UNCAUGHT_REJECTION_TEST) + self.writeFile("test_simple_uncaught_rejection.js", + SIMPLE_UNCAUGHT_REJECTION_TEST) self.writeManifest(["test_simple_uncaught_rejection.js"]) self.assertTestResult(False) self.assertInLog(TEST_FAIL_STRING) - if not substs.get('RELEASE_OR_BETA'): - # async stacks are currently not enabled in release builds. - self.assertInLog("test_simple_uncaught_rejection.js:3:3") + self.assertInLog("test_simple_uncaught_rejection.js:3:18") self.assertInLog("Test rejection.") self.assertEquals(1, self.x.testCount) self.assertEquals(0, self.x.passCount) diff --git a/toolkit/components/alerts/test/test_alerts_requireinteraction.html b/toolkit/components/alerts/test/test_alerts_requireinteraction.html index 1a862e659717..6725213863e5 100644 --- a/toolkit/components/alerts/test/test_alerts_requireinteraction.html +++ b/toolkit/components/alerts/test/test_alerts_requireinteraction.html @@ -3,7 +3,7 @@ Test for alerts with requireInteraction - + diff --git a/toolkit/components/alerts/test/test_image.html b/toolkit/components/alerts/test/test_image.html index e59286bdef1e..139a70644f63 100644 --- a/toolkit/components/alerts/test/test_image.html +++ b/toolkit/components/alerts/test/test_image.html @@ -3,7 +3,7 @@ Test for Bug 1233086 - + diff --git a/toolkit/components/alerts/test/test_multiple_alerts.html b/toolkit/components/alerts/test/test_multiple_alerts.html index de9d6ab3bb0e..a47641884228 100644 --- a/toolkit/components/alerts/test/test_multiple_alerts.html +++ b/toolkit/components/alerts/test/test_multiple_alerts.html @@ -3,7 +3,7 @@ Test for multiple alerts - + diff --git a/toolkit/components/alerts/test/test_principal.html b/toolkit/components/alerts/test/test_principal.html index ab0bd9f97107..74e5fada845e 100644 --- a/toolkit/components/alerts/test/test_principal.html +++ b/toolkit/components/alerts/test/test_principal.html @@ -3,7 +3,7 @@ Test for Bug 1202933 - + diff --git a/toolkit/components/autocomplete/nsAutoCompleteController.cpp b/toolkit/components/autocomplete/nsAutoCompleteController.cpp index 6ecc4ba65054..cbbf1305c035 100644 --- a/toolkit/components/autocomplete/nsAutoCompleteController.cpp +++ b/toolkit/components/autocomplete/nsAutoCompleteController.cpp @@ -19,6 +19,7 @@ #include "mozilla/ModuleUtils.h" #include "mozilla/Unused.h" #include "mozilla/dom/KeyboardEventBinding.h" +#include "mozilla/dom/Event.h" static const char *kAutoCompleteSearchCID = "@mozilla.org/autocomplete/search;1?name="; @@ -299,7 +300,7 @@ nsAutoCompleteController::HandleText(bool *_retval) NS_IMETHODIMP nsAutoCompleteController::HandleEnter(bool aIsPopupSelection, - nsIDOMEvent *aEvent, + dom::Event* aEvent, bool *_retval) { *_retval = false; @@ -1183,7 +1184,7 @@ nsAutoCompleteController::ClearSearchTimer() nsresult nsAutoCompleteController::EnterMatch(bool aIsPopupSelection, - nsIDOMEvent *aEvent) + dom::Event* aEvent) { nsCOMPtr input(mInput); nsCOMPtr popup; diff --git a/toolkit/components/autocomplete/nsAutoCompleteController.h b/toolkit/components/autocomplete/nsAutoCompleteController.h index d84ebea4e19e..443d0e368fa5 100644 --- a/toolkit/components/autocomplete/nsAutoCompleteController.h +++ b/toolkit/components/autocomplete/nsAutoCompleteController.h @@ -68,7 +68,7 @@ protected: nsresult PostSearchCleanup(); nsresult EnterMatch(bool aIsPopupSelection, - nsIDOMEvent *aEvent); + mozilla::dom::Event* aEvent); nsresult RevertTextValue(); nsresult CompleteDefaultIndex(int32_t aResultIndex); diff --git a/toolkit/components/autocomplete/nsIAutoCompleteController.idl b/toolkit/components/autocomplete/nsIAutoCompleteController.idl index 95fba3ea0cc9..07cf429cddd2 100644 --- a/toolkit/components/autocomplete/nsIAutoCompleteController.idl +++ b/toolkit/components/autocomplete/nsIAutoCompleteController.idl @@ -5,7 +5,8 @@ #include "nsISupports.idl" interface nsIAutoCompleteInput; -interface nsIDOMEvent; + +webidl Event; [scriptable, uuid(ff9f8465-204a-47a6-b3c9-0628b3856684)] interface nsIAutoCompleteController : nsISupports @@ -76,7 +77,7 @@ interface nsIAutoCompleteController : nsISupports * default event. */ boolean handleEnter(in boolean aIsPopupSelection, - [optional] in nsIDOMEvent aEvent); + [optional] in Event aEvent); /* * Notify the controller that the user wishes to revert autocomplete diff --git a/toolkit/components/autocomplete/nsIAutoCompleteInput.idl b/toolkit/components/autocomplete/nsIAutoCompleteInput.idl index eb47b09f0645..711f71e0a4a6 100644 --- a/toolkit/components/autocomplete/nsIAutoCompleteInput.idl +++ b/toolkit/components/autocomplete/nsIAutoCompleteInput.idl @@ -7,6 +7,8 @@ interface nsIAutoCompletePopup; +webidl Event; + [scriptable, uuid(B068E70F-F82C-4C12-AD87-82E271C5C180)] interface nsIAutoCompleteInput : nsISupports { @@ -135,7 +137,7 @@ interface nsIAutoCompleteInput : nsISupports * The event that triggered the enter. * @return True if the user wishes to prevent the enter */ - boolean onTextEntered([optional] in nsIDOMEvent aEvent); + boolean onTextEntered([optional] in Event aEvent); /* * Notification that the user cancelled the autocomplete session diff --git a/toolkit/components/contentprefs/tests/mochitest/test_remoteContentPrefs.html b/toolkit/components/contentprefs/tests/mochitest/test_remoteContentPrefs.html index 1091aca75486..7b5d594cc365 100644 --- a/toolkit/components/contentprefs/tests/mochitest/test_remoteContentPrefs.html +++ b/toolkit/components/contentprefs/tests/mochitest/test_remoteContentPrefs.html @@ -5,14 +5,14 @@ - + + diff --git a/toolkit/components/extensions/test/mochitest/test_chrome_ext_contentscript_telemetry.html b/toolkit/components/extensions/test/mochitest/test_chrome_ext_contentscript_telemetry.html index c6ecbd42fc65..9fa02d070ac1 100644 --- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_contentscript_telemetry.html +++ b/toolkit/components/extensions/test/mochitest/test_chrome_ext_contentscript_telemetry.html @@ -2,7 +2,7 @@ Test for telemetry for content script injection - + diff --git a/toolkit/components/extensions/test/mochitest/test_chrome_ext_contentscript_unrecognizedprop_warning.html b/toolkit/components/extensions/test/mochitest/test_chrome_ext_contentscript_unrecognizedprop_warning.html index a296de022fc3..1e79ed6e3201 100644 --- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_contentscript_unrecognizedprop_warning.html +++ b/toolkit/components/extensions/test/mochitest/test_chrome_ext_contentscript_unrecognizedprop_warning.html @@ -3,7 +3,7 @@ Test for content script unrecognized property on manifest - + diff --git a/toolkit/components/extensions/test/mochitest/test_chrome_ext_downloads_open.html b/toolkit/components/extensions/test/mochitest/test_chrome_ext_downloads_open.html index 564173ec82ed..960d23d6add2 100644 --- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_downloads_open.html +++ b/toolkit/components/extensions/test/mochitest/test_chrome_ext_downloads_open.html @@ -2,7 +2,7 @@ Test for permissions - + diff --git a/toolkit/components/extensions/test/mochitest/test_chrome_ext_downloads_saveAs.html b/toolkit/components/extensions/test/mochitest/test_chrome_ext_downloads_saveAs.html index 5bee14695c6b..05d259ca298f 100644 --- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_downloads_saveAs.html +++ b/toolkit/components/extensions/test/mochitest/test_chrome_ext_downloads_saveAs.html @@ -2,7 +2,7 @@ Test downloads.download() saveAs option - + diff --git a/toolkit/components/extensions/test/mochitest/test_chrome_ext_downloads_uniquify.html b/toolkit/components/extensions/test/mochitest/test_chrome_ext_downloads_uniquify.html index 29d9ff2df735..be5287d53fbd 100644 --- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_downloads_uniquify.html +++ b/toolkit/components/extensions/test/mochitest/test_chrome_ext_downloads_uniquify.html @@ -2,7 +2,7 @@ Test downloads.download() uniquify option - + diff --git a/toolkit/components/extensions/test/mochitest/test_chrome_ext_permissions.html b/toolkit/components/extensions/test/mochitest/test_chrome_ext_permissions.html index 8afea800d537..3accd36b3487 100644 --- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_permissions.html +++ b/toolkit/components/extensions/test/mochitest/test_chrome_ext_permissions.html @@ -2,7 +2,7 @@ Test for permissions - + diff --git a/toolkit/components/extensions/test/mochitest/test_chrome_ext_trackingprotection.html b/toolkit/components/extensions/test/mochitest/test_chrome_ext_trackingprotection.html index d62e89ba8bed..9ca49f2fd61c 100644 --- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_trackingprotection.html +++ b/toolkit/components/extensions/test/mochitest/test_chrome_ext_trackingprotection.html @@ -3,7 +3,7 @@ Test for simple WebExtension - + diff --git a/toolkit/components/extensions/test/mochitest/test_chrome_ext_webnavigation_resolved_urls.html b/toolkit/components/extensions/test/mochitest/test_chrome_ext_webnavigation_resolved_urls.html index 2231393fdf5b..47f9020ee123 100644 --- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_webnavigation_resolved_urls.html +++ b/toolkit/components/extensions/test/mochitest/test_chrome_ext_webnavigation_resolved_urls.html @@ -3,7 +3,7 @@ Test for simple WebExtension - + diff --git a/toolkit/components/extensions/test/mochitest/test_chrome_ext_webrequest_background_events.html b/toolkit/components/extensions/test/mochitest/test_chrome_ext_webrequest_background_events.html index 6fb9d3b89d5b..082133cd14fc 100644 --- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_webrequest_background_events.html +++ b/toolkit/components/extensions/test/mochitest/test_chrome_ext_webrequest_background_events.html @@ -3,7 +3,7 @@ Test for simple WebExtension - + diff --git a/toolkit/components/extensions/test/mochitest/test_chrome_ext_webrequest_host_permissions.html b/toolkit/components/extensions/test/mochitest/test_chrome_ext_webrequest_host_permissions.html index 5e9fcc572f91..dd8ad8c1a65d 100644 --- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_webrequest_host_permissions.html +++ b/toolkit/components/extensions/test/mochitest/test_chrome_ext_webrequest_host_permissions.html @@ -2,7 +2,7 @@ Test webRequest checks host permissions - + diff --git a/toolkit/components/extensions/test/mochitest/test_chrome_ext_webrequest_mozextension.html b/toolkit/components/extensions/test/mochitest/test_chrome_ext_webrequest_mozextension.html index 793b0e4e69c4..be36c6cb2826 100644 --- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_webrequest_mozextension.html +++ b/toolkit/components/extensions/test/mochitest/test_chrome_ext_webrequest_mozextension.html @@ -3,7 +3,7 @@ Test moz-extension protocol use - + diff --git a/toolkit/components/extensions/test/mochitest/test_chrome_native_messaging_paths.html b/toolkit/components/extensions/test/mochitest/test_chrome_native_messaging_paths.html index 6fcd0652bd0e..4c54b97457b1 100644 --- a/toolkit/components/extensions/test/mochitest/test_chrome_native_messaging_paths.html +++ b/toolkit/components/extensions/test/mochitest/test_chrome_native_messaging_paths.html @@ -3,7 +3,7 @@ WebExtension test - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_background_canvas.html b/toolkit/components/extensions/test/mochitest/test_ext_background_canvas.html index e29dc00ea05c..6b23e2f481f0 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_background_canvas.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_background_canvas.html @@ -3,7 +3,7 @@ Test for background page canvas rendering - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_background_page.html b/toolkit/components/extensions/test/mochitest/test_ext_background_page.html index d76a45af2196..160647244f94 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_background_page.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_background_page.html @@ -4,7 +4,7 @@ WebExtension test - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_clipboard.html b/toolkit/components/extensions/test/mochitest/test_ext_clipboard.html index 9d3c91bc1eee..01065d794201 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_clipboard.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_clipboard.html @@ -3,7 +3,7 @@ Clipboard permissions tests - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_clipboard_image.html b/toolkit/components/extensions/test/mochitest/test_ext_clipboard_image.html index 831965c84940..69ffbf8dfa0a 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_clipboard_image.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_clipboard_image.html @@ -3,7 +3,7 @@ Clipboard permissions tests - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_contentscript_about_blank.html b/toolkit/components/extensions/test/mochitest/test_ext_contentscript_about_blank.html index 3d71cc8a45d0..6274553f5f08 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_contentscript_about_blank.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_contentscript_about_blank.html @@ -2,7 +2,7 @@ Test content script match_about_blank option - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_contentscript_cache.html b/toolkit/components/extensions/test/mochitest/test_ext_contentscript_cache.html index b3d272bc359f..8f556adcc789 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_contentscript_cache.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_contentscript_cache.html @@ -3,7 +3,7 @@ Test for content script caching - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_contentscript_canvas.html b/toolkit/components/extensions/test/mochitest/test_ext_contentscript_canvas.html index fdbf3d8ad92b..b87cf49e4ded 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_contentscript_canvas.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_contentscript_canvas.html @@ -2,7 +2,7 @@ Test content script access to canvas drawWindow() - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_contentscript_devtools_metadata.html b/toolkit/components/extensions/test/mochitest/test_ext_contentscript_devtools_metadata.html index 5e8d593526db..e12c26eb008d 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_contentscript_devtools_metadata.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_contentscript_devtools_metadata.html @@ -3,7 +3,7 @@ Test for Sandbox metadata on WebExtensions ContentScripts - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_contentscript_incognito.html b/toolkit/components/extensions/test/mochitest/test_ext_contentscript_incognito.html index 17481fe56d6f..46f97d640082 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_contentscript_incognito.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_contentscript_incognito.html @@ -3,7 +3,7 @@ Test for content script private browsing ID - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_contentscript_permission.html b/toolkit/components/extensions/test/mochitest/test_ext_contentscript_permission.html index 452e87fa9f22..e450e81b2f18 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_contentscript_permission.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_contentscript_permission.html @@ -3,7 +3,7 @@ Test for content script - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_cookies.html b/toolkit/components/extensions/test/mochitest/test_ext_cookies.html index 924f2a2f0a01..c09a0b06980f 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_cookies.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_cookies.html @@ -3,7 +3,7 @@ WebExtension test - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_cookies_containers.html b/toolkit/components/extensions/test/mochitest/test_ext_cookies_containers.html index b6ade236003d..6c420d9f98c0 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_cookies_containers.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_cookies_containers.html @@ -4,7 +4,7 @@ WebExtension test - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_cookies_expiry.html b/toolkit/components/extensions/test/mochitest/test_ext_cookies_expiry.html index eb7d29092b7a..a94a6fa4c91b 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_cookies_expiry.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_cookies_expiry.html @@ -4,7 +4,7 @@ WebExtension cookies test - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_cookies_first_party.html b/toolkit/components/extensions/test/mochitest/test_ext_cookies_first_party.html index 64785c45e440..662dde2fd9dd 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_cookies_first_party.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_cookies_first_party.html @@ -1,7 +1,7 @@ - + - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_cookies_permissions_good.html b/toolkit/components/extensions/test/mochitest/test_ext_cookies_permissions_good.html index ee8bdea12bb3..493a29b3619f 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_cookies_permissions_good.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_cookies_permissions_good.html @@ -3,7 +3,7 @@ WebExtension test - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_exclude_include_globs.html b/toolkit/components/extensions/test/mochitest/test_ext_exclude_include_globs.html index f1858638b959..0fc2752a8af1 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_exclude_include_globs.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_exclude_include_globs.html @@ -3,7 +3,7 @@ Test for content script - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_external_messaging.html b/toolkit/components/extensions/test/mochitest/test_ext_external_messaging.html index 7b3fc76bcdb0..176045134b87 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_external_messaging.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_external_messaging.html @@ -3,7 +3,7 @@ WebExtension external messaging - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_generate.html b/toolkit/components/extensions/test/mochitest/test_ext_generate.html index 15d3d1b64c38..bda912fadf9f 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_generate.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_generate.html @@ -3,7 +3,7 @@ Test for generating WebExtensions - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_geolocation.html b/toolkit/components/extensions/test/mochitest/test_ext_geolocation.html index c056fdd9a0ad..f3bbe38be96a 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_geolocation.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_geolocation.html @@ -4,7 +4,7 @@ - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_identity.html b/toolkit/components/extensions/test/mochitest/test_ext_identity.html index 2ffa68c15dea..37558d2838d5 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_identity.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_identity.html @@ -3,7 +3,7 @@ Test for WebExtension Identity - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_idle.html b/toolkit/components/extensions/test/mochitest/test_ext_idle.html index f8ebefefca58..9912f003ca94 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_idle.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_idle.html @@ -3,7 +3,7 @@ WebExtension test - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_inIncognitoContext_window.html b/toolkit/components/extensions/test/mochitest/test_ext_inIncognitoContext_window.html index 3687dead14c4..c7bac8c205e7 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_inIncognitoContext_window.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_inIncognitoContext_window.html @@ -3,7 +3,7 @@ WebExtension test - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_listener_proxies.html b/toolkit/components/extensions/test/mochitest/test_ext_listener_proxies.html index 72e79627f844..981f5d73c318 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_listener_proxies.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_listener_proxies.html @@ -3,7 +3,7 @@ Test for content script - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_new_tab_processType.html b/toolkit/components/extensions/test/mochitest/test_ext_new_tab_processType.html index 3a2b9c069955..f678e3aa3a9c 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_new_tab_processType.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_new_tab_processType.html @@ -4,7 +4,7 @@ Test for opening links in new tabs from extension frames - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_notifications.html b/toolkit/components/extensions/test/mochitest/test_ext_notifications.html index bae182a95415..b26a01e56cc6 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_notifications.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_notifications.html @@ -3,7 +3,7 @@ Test for notifications - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_protocolHandlers.html b/toolkit/components/extensions/test/mochitest/test_ext_protocolHandlers.html index ec2776d11ded..f67aac708149 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_protocolHandlers.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_protocolHandlers.html @@ -3,7 +3,7 @@ Test for protocol handlers - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_redirect_jar.html b/toolkit/components/extensions/test/mochitest/test_ext_redirect_jar.html index 151b83fdd48e..65aaabaff655 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_redirect_jar.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_redirect_jar.html @@ -4,7 +4,7 @@ - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_runtime_connect.html b/toolkit/components/extensions/test/mochitest/test_ext_runtime_connect.html index 5202078210f3..f2da4ef34af4 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_runtime_connect.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_runtime_connect.html @@ -3,7 +3,7 @@ WebExtension test - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_runtime_connect2.html b/toolkit/components/extensions/test/mochitest/test_ext_runtime_connect2.html index 2757816dfb3f..906a8a328505 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_runtime_connect2.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_runtime_connect2.html @@ -3,7 +3,7 @@ WebExtension test - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_runtime_connect_twoway.html b/toolkit/components/extensions/test/mochitest/test_ext_runtime_connect_twoway.html index f7c7ae50517d..7173a2cebcb3 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_runtime_connect_twoway.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_runtime_connect_twoway.html @@ -3,7 +3,7 @@ WebExtension test - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_runtime_disconnect.html b/toolkit/components/extensions/test/mochitest/test_ext_runtime_disconnect.html index fdecbe53f6b7..993f14f75929 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_runtime_disconnect.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_runtime_disconnect.html @@ -3,7 +3,7 @@ WebExtension test - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_sendmessage_doublereply.html b/toolkit/components/extensions/test/mochitest/test_ext_sendmessage_doublereply.html index 092bb7c08ca2..db3fa38b90b9 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_sendmessage_doublereply.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_sendmessage_doublereply.html @@ -3,7 +3,7 @@ WebExtension test - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_sendmessage_frameId.html b/toolkit/components/extensions/test/mochitest/test_ext_sendmessage_frameId.html index 8d0dae6c7a29..845337a90410 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_sendmessage_frameId.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_sendmessage_frameId.html @@ -1,7 +1,7 @@ Test sendMessage frameId - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_sendmessage_no_receiver.html b/toolkit/components/extensions/test/mochitest/test_ext_sendmessage_no_receiver.html index 426e77b6ecd0..3612111519b5 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_sendmessage_no_receiver.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_sendmessage_no_receiver.html @@ -4,7 +4,7 @@ WebExtension test - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_sendmessage_reply.html b/toolkit/components/extensions/test/mochitest/test_ext_sendmessage_reply.html index 46528bd90c58..9de835e129e5 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_sendmessage_reply.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_sendmessage_reply.html @@ -3,7 +3,7 @@ WebExtension test - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_sendmessage_reply2.html b/toolkit/components/extensions/test/mochitest/test_ext_sendmessage_reply2.html index da16948fe08d..348c4ca54d6e 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_sendmessage_reply2.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_sendmessage_reply2.html @@ -3,7 +3,7 @@ WebExtension test - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_storage_cleanup.html b/toolkit/components/extensions/test/mochitest/test_ext_storage_cleanup.html index 52de11568cf0..6dcf345ff690 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_storage_cleanup.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_storage_cleanup.html @@ -3,7 +3,7 @@ WebExtension test - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_storage_manager_capabilities.html b/toolkit/components/extensions/test/mochitest/test_ext_storage_manager_capabilities.html index 6661c1657685..57e73863dba5 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_storage_manager_capabilities.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_storage_manager_capabilities.html @@ -3,7 +3,7 @@ Test Storage API - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_subframes_privileges.html b/toolkit/components/extensions/test/mochitest/test_ext_subframes_privileges.html index a56c7b3ddd15..9722929f8842 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_subframes_privileges.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_subframes_privileges.html @@ -3,7 +3,7 @@ WebExtension test - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_test.html b/toolkit/components/extensions/test/mochitest/test_ext_test.html index 81713e08be38..dfef67a42c82 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_test.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_test.html @@ -3,7 +3,7 @@ Testing test - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_unlimitedStorage.html b/toolkit/components/extensions/test/mochitest/test_ext_unlimitedStorage.html index c45d1231a5b9..d2da0c71284e 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_unlimitedStorage.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_unlimitedStorage.html @@ -3,7 +3,7 @@ Test for simple WebExtension - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_unlimitedStorage_legacy_persistent_indexedDB.html b/toolkit/components/extensions/test/mochitest/test_ext_unlimitedStorage_legacy_persistent_indexedDB.html index 14748cd3beb2..782b8f05e96a 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_unlimitedStorage_legacy_persistent_indexedDB.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_unlimitedStorage_legacy_persistent_indexedDB.html @@ -3,7 +3,7 @@ Test for simple WebExtension - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_web_accessible_resources.html b/toolkit/components/extensions/test/mochitest/test_ext_web_accessible_resources.html index eeb7853940aa..a4130afafb13 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_web_accessible_resources.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_web_accessible_resources.html @@ -3,7 +3,7 @@ Test the web_accessible_resources manifest directive - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_webnavigation.html b/toolkit/components/extensions/test/mochitest/test_ext_webnavigation.html index 2b549c0f2f13..5fa52e2c325e 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_webnavigation.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_webnavigation.html @@ -3,7 +3,7 @@ Test for simple WebExtension - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_webnavigation_filters.html b/toolkit/components/extensions/test/mochitest/test_ext_webnavigation_filters.html index 6997363f7bee..f9e4aea834c7 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_webnavigation_filters.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_webnavigation_filters.html @@ -3,7 +3,7 @@ Test for simple WebExtension - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_webrequest_auth.html b/toolkit/components/extensions/test/mochitest/test_ext_webrequest_auth.html index 7235746ab689..3643c481ea07 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_webrequest_auth.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_webrequest_auth.html @@ -4,7 +4,7 @@ - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_webrequest_background_events.html b/toolkit/components/extensions/test/mochitest/test_ext_webrequest_background_events.html index f0f26bec06e5..1a48fbe3fb42 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_webrequest_background_events.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_webrequest_background_events.html @@ -3,7 +3,7 @@ Test for simple WebExtension - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_webrequest_basic.html b/toolkit/components/extensions/test/mochitest/test_ext_webrequest_basic.html index 4cade9bd4037..1ed718e39696 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_webrequest_basic.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_webrequest_basic.html @@ -4,7 +4,7 @@ - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_webrequest_errors.html b/toolkit/components/extensions/test/mochitest/test_ext_webrequest_errors.html index 001da6362ef8..3bb6686170cf 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_webrequest_errors.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_webrequest_errors.html @@ -3,7 +3,7 @@ Test for WebRequest errors - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_webrequest_filter.html b/toolkit/components/extensions/test/mochitest/test_ext_webrequest_filter.html index 4b60365472ee..a465be957999 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_webrequest_filter.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_webrequest_filter.html @@ -4,7 +4,7 @@ - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_webrequest_frameId.html b/toolkit/components/extensions/test/mochitest/test_ext_webrequest_frameId.html index b1899b47c0fa..ee6d433ebb76 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_webrequest_frameId.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_webrequest_frameId.html @@ -4,7 +4,7 @@ - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_webrequest_hsts.html b/toolkit/components/extensions/test/mochitest/test_ext_webrequest_hsts.html index 4dce90cd377e..a6994e189b52 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_webrequest_hsts.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_webrequest_hsts.html @@ -4,7 +4,7 @@ - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_webrequest_redirect_data_uri.html b/toolkit/components/extensions/test/mochitest/test_ext_webrequest_redirect_data_uri.html index e4305648565b..94bd3deba21b 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_webrequest_redirect_data_uri.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_webrequest_redirect_data_uri.html @@ -3,7 +3,7 @@ Bug 1434357: Allow Web Request API to redirect to data: URI - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_webrequest_upgrade.html b/toolkit/components/extensions/test/mochitest/test_ext_webrequest_upgrade.html index 41c93619c41e..27678b565561 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_webrequest_upgrade.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_webrequest_upgrade.html @@ -3,7 +3,7 @@ Test for simple WebExtension - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_webrequest_upload.html b/toolkit/components/extensions/test/mochitest/test_ext_webrequest_upload.html index 7d77e47bc88d..a494bb46b6d6 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_webrequest_upload.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_webrequest_upload.html @@ -4,7 +4,7 @@ - + diff --git a/toolkit/components/extensions/test/mochitest/test_ext_window_postMessage.html b/toolkit/components/extensions/test/mochitest/test_ext_window_postMessage.html index d7a637e4ac0a..765273bc8599 100644 --- a/toolkit/components/extensions/test/mochitest/test_ext_window_postMessage.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_window_postMessage.html @@ -3,7 +3,7 @@ Test for content script - + diff --git a/toolkit/components/extensions/test/mochitest/test_same_site_cookies_webextension.html b/toolkit/components/extensions/test/mochitest/test_same_site_cookies_webextension.html index 7f52d19ad3a6..f01a8ed62c6f 100644 --- a/toolkit/components/extensions/test/mochitest/test_same_site_cookies_webextension.html +++ b/toolkit/components/extensions/test/mochitest/test_same_site_cookies_webextension.html @@ -3,7 +3,7 @@ Bug 1454914: Exempt web-extensions from same-site cookie policy - + diff --git a/toolkit/components/find/nsFind.cpp b/toolkit/components/find/nsFind.cpp index 1d7663302aef..33d28a08e75d 100644 --- a/toolkit/components/find/nsFind.cpp +++ b/toolkit/components/find/nsFind.cpp @@ -859,7 +859,7 @@ nsFind::SkipNode(nsIContent* aContent) #ifdef HAVE_BIDI_ITERATOR // We may not need to skip comment nodes, now that IsTextNode distinguishes // them from real text nodes. - return aContent->IsNodeOfType(nsINode::eCOMMENT) || + return aContent->IsComment() || aContent->IsAnyOfHTMLElements(sScriptAtom, sNoframesAtom, sSelectAtom); #else /* HAVE_BIDI_ITERATOR */ @@ -869,7 +869,7 @@ nsFind::SkipNode(nsIContent* aContent) nsIContent* content = aContent; while (content) { - if (aContent->IsNodeOfType(nsINode::eCOMMENT) || + if (aContent->IsComment() || content->IsAnyOfHTMLElements(nsGkAtoms::script, nsGkAtoms::noframes, nsGkAtoms::select)) { diff --git a/toolkit/components/passwordmgr/test/mochitest/test_autocomplete_https_upgrade.html b/toolkit/components/passwordmgr/test/mochitest/test_autocomplete_https_upgrade.html index d0b71243b83f..8242a6e3be39 100644 --- a/toolkit/components/passwordmgr/test/mochitest/test_autocomplete_https_upgrade.html +++ b/toolkit/components/passwordmgr/test/mochitest/test_autocomplete_https_upgrade.html @@ -5,7 +5,7 @@ Test autocomplete on an HTTPS page using upgraded HTTP logins - + diff --git a/toolkit/components/passwordmgr/test/mochitest/test_autofill_https_upgrade.html b/toolkit/components/passwordmgr/test/mochitest/test_autofill_https_upgrade.html index b231952dc941..0e5079c1709d 100644 --- a/toolkit/components/passwordmgr/test/mochitest/test_autofill_https_upgrade.html +++ b/toolkit/components/passwordmgr/test/mochitest/test_autofill_https_upgrade.html @@ -5,7 +5,7 @@ Test autocomplete on an HTTPS page using upgraded HTTP logins - + diff --git a/toolkit/components/passwordmgr/test/mochitest/test_autofocus_js.html b/toolkit/components/passwordmgr/test/mochitest/test_autofocus_js.html index 63f3087ec556..a05b34ae6942 100644 --- a/toolkit/components/passwordmgr/test/mochitest/test_autofocus_js.html +++ b/toolkit/components/passwordmgr/test/mochitest/test_autofocus_js.html @@ -5,7 +5,7 @@ Test login autocomplete is activated when focused by js on load - + diff --git a/toolkit/components/passwordmgr/test/mochitest/test_basic_form_autocomplete.html b/toolkit/components/passwordmgr/test/mochitest/test_basic_form_autocomplete.html index d22fad7250ad..538e028b21e3 100644 --- a/toolkit/components/passwordmgr/test/mochitest/test_basic_form_autocomplete.html +++ b/toolkit/components/passwordmgr/test/mochitest/test_basic_form_autocomplete.html @@ -5,7 +5,7 @@ Test basic login autocomplete - + diff --git a/toolkit/components/passwordmgr/test/mochitest/test_case_differences.html b/toolkit/components/passwordmgr/test/mochitest/test_case_differences.html index 9914bcf37c21..42e19cb141de 100644 --- a/toolkit/components/passwordmgr/test/mochitest/test_case_differences.html +++ b/toolkit/components/passwordmgr/test/mochitest/test_case_differences.html @@ -5,7 +5,7 @@ Test autocomplete due to multiple matching logins - + diff --git a/toolkit/components/passwordmgr/test/mochitest/test_formless_autofill.html b/toolkit/components/passwordmgr/test/mochitest/test_formless_autofill.html index 7cee96723799..02bd70b569a2 100644 --- a/toolkit/components/passwordmgr/test/mochitest/test_formless_autofill.html +++ b/toolkit/components/passwordmgr/test/mochitest/test_formless_autofill.html @@ -4,7 +4,7 @@ Test autofilling of fields outside of a form - + diff --git a/toolkit/components/passwordmgr/test/mochitest/test_formless_submit.html b/toolkit/components/passwordmgr/test/mochitest/test_formless_submit.html index ec6f4252c0bb..17400760fd3f 100644 --- a/toolkit/components/passwordmgr/test/mochitest/test_formless_submit.html +++ b/toolkit/components/passwordmgr/test/mochitest/test_formless_submit.html @@ -4,7 +4,7 @@ Test capturing of fields outside of a form - + diff --git a/toolkit/components/passwordmgr/test/mochitest/test_formless_submit_navigation.html b/toolkit/components/passwordmgr/test/mochitest/test_formless_submit_navigation.html index cb22db9c9bf6..d5492ce79b19 100644 --- a/toolkit/components/passwordmgr/test/mochitest/test_formless_submit_navigation.html +++ b/toolkit/components/passwordmgr/test/mochitest/test_formless_submit_navigation.html @@ -4,7 +4,7 @@ Test capturing of fields outside of a form due to navigation - + diff --git a/toolkit/components/passwordmgr/test/mochitest/test_formless_submit_navigation_negative.html b/toolkit/components/passwordmgr/test/mochitest/test_formless_submit_navigation_negative.html index 8d2416b0ae3d..dce21311f3c2 100644 --- a/toolkit/components/passwordmgr/test/mochitest/test_formless_submit_navigation_negative.html +++ b/toolkit/components/passwordmgr/test/mochitest/test_formless_submit_navigation_negative.html @@ -4,7 +4,7 @@ Test no capturing of fields outside of a form due to navigation - + diff --git a/toolkit/components/passwordmgr/test/mochitest/test_insecure_form_field_autocomplete.html b/toolkit/components/passwordmgr/test/mochitest/test_insecure_form_field_autocomplete.html index 7939e8b0fbf4..4f870d08275b 100644 --- a/toolkit/components/passwordmgr/test/mochitest/test_insecure_form_field_autocomplete.html +++ b/toolkit/components/passwordmgr/test/mochitest/test_insecure_form_field_autocomplete.html @@ -5,7 +5,7 @@ Test insecure form field autocomplete - + diff --git a/toolkit/components/passwordmgr/test/mochitest/test_insecure_form_field_no_saved_login.html b/toolkit/components/passwordmgr/test/mochitest/test_insecure_form_field_no_saved_login.html index c21d032ff9e1..bfb6ba2d0609 100644 --- a/toolkit/components/passwordmgr/test/mochitest/test_insecure_form_field_no_saved_login.html +++ b/toolkit/components/passwordmgr/test/mochitest/test_insecure_form_field_no_saved_login.html @@ -5,7 +5,7 @@ Test basic login, contextual inscure password warning without saved logins - + diff --git a/toolkit/components/passwordmgr/test/mochitest/test_onsubmit_value_change.html b/toolkit/components/passwordmgr/test/mochitest/test_onsubmit_value_change.html index bdf1dfd61bdd..bc924f8f685c 100644 --- a/toolkit/components/passwordmgr/test/mochitest/test_onsubmit_value_change.html +++ b/toolkit/components/passwordmgr/test/mochitest/test_onsubmit_value_change.html @@ -4,7 +4,7 @@ Test input value change right after onsubmit event - + diff --git a/toolkit/components/passwordmgr/test/mochitest/test_password_field_autocomplete.html b/toolkit/components/passwordmgr/test/mochitest/test_password_field_autocomplete.html index 7c8fd2e90217..b9d95022c533 100644 --- a/toolkit/components/passwordmgr/test/mochitest/test_password_field_autocomplete.html +++ b/toolkit/components/passwordmgr/test/mochitest/test_password_field_autocomplete.html @@ -5,7 +5,7 @@ Test basic login autocomplete - + diff --git a/toolkit/components/passwordmgr/test/mochitest/test_prompt.html b/toolkit/components/passwordmgr/test/mochitest/test_prompt.html index 7e94ac8438a6..a5a0fc6868b8 100644 --- a/toolkit/components/passwordmgr/test/mochitest/test_prompt.html +++ b/toolkit/components/passwordmgr/test/mochitest/test_prompt.html @@ -4,7 +4,7 @@ Test prompter.{prompt,promptPassword,promptUsernameAndPassword} - + diff --git a/toolkit/components/passwordmgr/test/mochitest/test_prompt_http.html b/toolkit/components/passwordmgr/test/mochitest/test_prompt_http.html index c43e160064d0..adfbc97eec35 100644 --- a/toolkit/components/passwordmgr/test/mochitest/test_prompt_http.html +++ b/toolkit/components/passwordmgr/test/mochitest/test_prompt_http.html @@ -4,7 +4,7 @@ Test HTTP auth prompts by loading authenticate.sjs - + diff --git a/toolkit/components/passwordmgr/test/mochitest/test_prompt_noWindow.html b/toolkit/components/passwordmgr/test/mochitest/test_prompt_noWindow.html index 0c6ce9e48dbe..941542a4d245 100644 --- a/toolkit/components/passwordmgr/test/mochitest/test_prompt_noWindow.html +++ b/toolkit/components/passwordmgr/test/mochitest/test_prompt_noWindow.html @@ -4,7 +4,7 @@ Test HTTP auth prompts by loading authenticate.sjs with no window - + diff --git a/toolkit/components/passwordmgr/test/mochitest/test_prompt_promptAuth.html b/toolkit/components/passwordmgr/test/mochitest/test_prompt_promptAuth.html index db9dca4b89b6..79fc6a8a1fd6 100644 --- a/toolkit/components/passwordmgr/test/mochitest/test_prompt_promptAuth.html +++ b/toolkit/components/passwordmgr/test/mochitest/test_prompt_promptAuth.html @@ -4,7 +4,7 @@ Test promptAuth prompts - + diff --git a/toolkit/components/passwordmgr/test/mochitest/test_prompt_promptAuth_proxy.html b/toolkit/components/passwordmgr/test/mochitest/test_prompt_promptAuth_proxy.html index e4c99bd963dd..b1edcae1dcd6 100644 --- a/toolkit/components/passwordmgr/test/mochitest/test_prompt_promptAuth_proxy.html +++ b/toolkit/components/passwordmgr/test/mochitest/test_prompt_promptAuth_proxy.html @@ -4,7 +4,7 @@ Test promptAuth proxy prompts - + diff --git a/toolkit/components/passwordmgr/test/mochitest/test_recipe_login_fields.html b/toolkit/components/passwordmgr/test/mochitest/test_recipe_login_fields.html index e01f5cf35a12..a773a8b113ff 100644 --- a/toolkit/components/passwordmgr/test/mochitest/test_recipe_login_fields.html +++ b/toolkit/components/passwordmgr/test/mochitest/test_recipe_login_fields.html @@ -4,7 +4,7 @@ Test for recipes overriding login fields - + diff --git a/toolkit/components/passwordmgr/test/mochitest/test_username_focus.html b/toolkit/components/passwordmgr/test/mochitest/test_username_focus.html index 5975a412e926..ba2609ee77a1 100644 --- a/toolkit/components/passwordmgr/test/mochitest/test_username_focus.html +++ b/toolkit/components/passwordmgr/test/mochitest/test_username_focus.html @@ -6,7 +6,7 @@ Test interaction between autocomplete and focus on username fields - + diff --git a/toolkit/components/payments/test/mochitest/formautofill/test_editCreditCard.html b/toolkit/components/payments/test/mochitest/formautofill/test_editCreditCard.html index 1889424a36d8..a028bf0a68bb 100644 --- a/toolkit/components/payments/test/mochitest/formautofill/test_editCreditCard.html +++ b/toolkit/components/payments/test/mochitest/formautofill/test_editCreditCard.html @@ -8,7 +8,7 @@ Test that editCreditCard.xhtml is accessible for tests in the parent directory. Test that editCreditCard.xhtml is accessible - + diff --git a/toolkit/components/payments/test/mochitest/test_ObservedPropertiesMixin.html b/toolkit/components/payments/test/mochitest/test_ObservedPropertiesMixin.html index 72aba59d0ccd..a8de2cbf9c3e 100644 --- a/toolkit/components/payments/test/mochitest/test_ObservedPropertiesMixin.html +++ b/toolkit/components/payments/test/mochitest/test_ObservedPropertiesMixin.html @@ -7,7 +7,7 @@ Test the ObservedPropertiesMixin Test the ObservedPropertiesMixin - + diff --git a/toolkit/components/payments/test/mochitest/test_PaymentStateSubscriberMixin.html b/toolkit/components/payments/test/mochitest/test_PaymentStateSubscriberMixin.html index 629b755e911b..e046b764f7f9 100644 --- a/toolkit/components/payments/test/mochitest/test_PaymentStateSubscriberMixin.html +++ b/toolkit/components/payments/test/mochitest/test_PaymentStateSubscriberMixin.html @@ -7,7 +7,7 @@ Test the PaymentStateSubscriberMixin Test the PaymentStateSubscriberMixin - + diff --git a/toolkit/components/payments/test/mochitest/test_PaymentsStore.html b/toolkit/components/payments/test/mochitest/test_PaymentsStore.html index 3284dfe21d1b..e1970ebec192 100644 --- a/toolkit/components/payments/test/mochitest/test_PaymentsStore.html +++ b/toolkit/components/payments/test/mochitest/test_PaymentsStore.html @@ -8,7 +8,7 @@ Test the PaymentsStore Test the PaymentsStore - + diff --git a/toolkit/components/payments/test/mochitest/test_address_picker.html b/toolkit/components/payments/test/mochitest/test_address_picker.html index bd47560bcfc7..ff8b34dca59f 100644 --- a/toolkit/components/payments/test/mochitest/test_address_picker.html +++ b/toolkit/components/payments/test/mochitest/test_address_picker.html @@ -7,7 +7,7 @@ Test the address-picker component Test the address-picker component - + diff --git a/toolkit/components/payments/test/mochitest/test_basic_card_form.html b/toolkit/components/payments/test/mochitest/test_basic_card_form.html index 745f8f484791..47ee8b0ffb82 100644 --- a/toolkit/components/payments/test/mochitest/test_basic_card_form.html +++ b/toolkit/components/payments/test/mochitest/test_basic_card_form.html @@ -8,7 +8,7 @@ Test the basic-card-form element Test the basic-card-form element - + diff --git a/toolkit/components/payments/test/mochitest/test_currency_amount.html b/toolkit/components/payments/test/mochitest/test_currency_amount.html index 224aa5005362..3955f43b2b53 100644 --- a/toolkit/components/payments/test/mochitest/test_currency_amount.html +++ b/toolkit/components/payments/test/mochitest/test_currency_amount.html @@ -7,7 +7,7 @@ Test the currency-amount component Test the currency-amount component - + diff --git a/toolkit/components/payments/test/mochitest/test_order_details.html b/toolkit/components/payments/test/mochitest/test_order_details.html index f1e63e08cbd5..3d9974941dee 100644 --- a/toolkit/components/payments/test/mochitest/test_order_details.html +++ b/toolkit/components/payments/test/mochitest/test_order_details.html @@ -7,7 +7,7 @@ Test the order-details component - + diff --git a/toolkit/components/payments/test/mochitest/test_payer_address_picker.html b/toolkit/components/payments/test/mochitest/test_payer_address_picker.html index 1372f8134c12..adfdb8112abb 100644 --- a/toolkit/components/payments/test/mochitest/test_payer_address_picker.html +++ b/toolkit/components/payments/test/mochitest/test_payer_address_picker.html @@ -7,7 +7,7 @@ Test the paymentOptions address-picker Test the paymentOptions address-picker - + diff --git a/toolkit/components/payments/test/mochitest/test_payment_details_item.html b/toolkit/components/payments/test/mochitest/test_payment_details_item.html index 595b0e49aa03..d9f95d3c172e 100644 --- a/toolkit/components/payments/test/mochitest/test_payment_details_item.html +++ b/toolkit/components/payments/test/mochitest/test_payment_details_item.html @@ -7,7 +7,7 @@ Test the payment-details-item component Test the payment-details-item component - + diff --git a/toolkit/components/payments/test/mochitest/test_payment_dialog.html b/toolkit/components/payments/test/mochitest/test_payment_dialog.html index 116ac4d259f8..5e506e9c61f9 100644 --- a/toolkit/components/payments/test/mochitest/test_payment_dialog.html +++ b/toolkit/components/payments/test/mochitest/test_payment_dialog.html @@ -7,7 +7,7 @@ Test the payment-dialog custom element Test the payment-dialog element - + diff --git a/toolkit/components/payments/test/mochitest/test_payment_method_picker.html b/toolkit/components/payments/test/mochitest/test_payment_method_picker.html index 7ed1d7288c2f..d5571ce2b2e4 100644 --- a/toolkit/components/payments/test/mochitest/test_payment_method_picker.html +++ b/toolkit/components/payments/test/mochitest/test_payment_method_picker.html @@ -7,7 +7,7 @@ Test the payment-method-picker component Test the payment-method-picker component - + diff --git a/toolkit/components/payments/test/mochitest/test_rich_select.html b/toolkit/components/payments/test/mochitest/test_rich_select.html index 2a7536587884..92b22a49f2a7 100644 --- a/toolkit/components/payments/test/mochitest/test_rich_select.html +++ b/toolkit/components/payments/test/mochitest/test_rich_select.html @@ -7,7 +7,7 @@ Test the rich-select component Test the rich-select component - + diff --git a/toolkit/components/payments/test/mochitest/test_shipping_option_picker.html b/toolkit/components/payments/test/mochitest/test_shipping_option_picker.html index d157cadd12d0..6e2b547e2d7d 100644 --- a/toolkit/components/payments/test/mochitest/test_shipping_option_picker.html +++ b/toolkit/components/payments/test/mochitest/test_shipping_option_picker.html @@ -7,7 +7,7 @@ Test the shipping-option-picker component Test the shipping-option-picker component - + diff --git a/toolkit/components/places/tests/chrome/browser_disableglobalhistory.xul b/toolkit/components/places/tests/chrome/browser_disableglobalhistory.xul index 62e046d27745..67e93f143458 100644 --- a/toolkit/components/places/tests/chrome/browser_disableglobalhistory.xul +++ b/toolkit/components/places/tests/chrome/browser_disableglobalhistory.xul @@ -2,12 +2,10 @@ + onload="run_test()" + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> - @@ -28,16 +26,15 @@ }); } - function run_test() { - spawn_task(function*() { - yield expectUseGlobalHistory("inprocess_disabled", false); - yield expectUseGlobalHistory("inprocess_enabled", true); + async function run_test() { + await expectUseGlobalHistory("inprocess_disabled", false); + await expectUseGlobalHistory("inprocess_enabled", true); - yield expectUseGlobalHistory("remote_disabled", false); - yield expectUseGlobalHistory("remote_enabled", true); - window.opener.done(); - }); - }; + await expectUseGlobalHistory("remote_disabled", false); + await expectUseGlobalHistory("remote_enabled", true); + window.opener.done(); + ok(true); + } diff --git a/toolkit/components/places/tests/chrome/test_browser_disableglobalhistory.xul b/toolkit/components/places/tests/chrome/test_browser_disableglobalhistory.xul index 771a1b39bbaa..cb53087152e5 100644 --- a/toolkit/components/places/tests/chrome/test_browser_disableglobalhistory.xul +++ b/toolkit/components/places/tests/chrome/test_browser_disableglobalhistory.xul @@ -23,4 +23,4 @@ } -
\ No newline at end of file +
diff --git a/toolkit/components/places/tests/unit/test_454977.js b/toolkit/components/places/tests/unit/test_454977.js index c9b915f5918c..d83af42751a3 100644 --- a/toolkit/components/places/tests/unit/test_454977.js +++ b/toolkit/components/places/tests/unit/test_454977.js @@ -9,25 +9,23 @@ var visit_count = 0; // Returns the Place ID corresponding to an added visit. async function task_add_visit(aURI, aVisitType) { - // Add the visit asynchronously, and save its visit ID. - let deferUpdatePlaces = new Promise((resolve, reject) => { - PlacesUtils.asyncHistory.updatePlaces({ - uri: aURI, - visits: [{ transitionType: aVisitType, visitDate: Date.now() * 1000 }] - }, { - handleError: function TAV_handleError() { - reject(new Error("Unexpected error in adding visit.")); - }, - handleResult(aPlaceInfo) { - this.visitId = aPlaceInfo.visits[0].visitId; - }, - handleCompletion: function TAV_handleCompletion() { - resolve(this.visitId); - } - }); - }); + // Wait for a visits notification and get the visitId. + let visitId; + let visitsPromise = PlacesTestUtils.waitForNotification("onVisits", visits => { + visitId = visits[0].visitId; + let {uri} = visits[0]; + return uri.equals(aURI); + }, "history"); - let visitId = await deferUpdatePlaces; + // Add visits. + await PlacesTestUtils.addVisits([{ + uri: aURI, + transition: aVisitType + }]); + + if (aVisitType != TRANSITION_EMBED) { + await visitsPromise; + } // Increase visit_count if applicable if (aVisitType != 0 && diff --git a/toolkit/components/places/tests/unit/test_download_history.js b/toolkit/components/places/tests/unit/test_download_history.js index e955719320a7..35576a790321 100644 --- a/toolkit/components/places/tests/unit/test_download_history.js +++ b/toolkit/components/places/tests/unit/test_download_history.js @@ -154,34 +154,41 @@ add_task(async function test_dh_addBookmarkRemoveDownload() { }); }); -add_test(function test_dh_addDownload_referrer() { - waitForOnVisit(function DHAD_prepareReferrer(aURI, aVisitID) { - Assert.ok(aURI.equals(REFERRER_URI)); - let referrerVisitId = aVisitID; +add_task(async function test_dh_addDownload_referrer() { + // Wait for visits notification and get the visit id. + let visitId; + let referrerPromise = PlacesTestUtils.waitForNotification("onVisits", visits => { + visitId = visits[0].visitId; + let {uri} = visits[0]; + return uri.equals(REFERRER_URI); + }, "history"); - waitForOnVisit(function DHAD_onVisit(aVisitedURI, unused, unused2, unused3, - aReferringID) { - Assert.ok(aVisitedURI.equals(DOWNLOAD_URI)); - Assert.equal(aReferringID, referrerVisitId); - - // Verify that the URI is already available in results at this time. - Assert.ok(!!page_in_database(DOWNLOAD_URI)); - - PlacesUtils.history.clear().then(run_next_test); - }); - - gDownloadHistory.addDownload(DOWNLOAD_URI, REFERRER_URI, Date.now() * 1000); - }); - - // Note that we don't pass the optional callback argument here because we must - // ensure that we receive the onVisits notification before we call addDownload. - PlacesUtils.asyncHistory.updatePlaces({ + await PlacesTestUtils.addVisits([{ uri: REFERRER_URI, - visits: [{ - transitionType: Ci.nsINavHistoryService.TRANSITION_TYPED, - visitDate: Date.now() * 1000 - }] - }); + transition: Ci.nsINavHistoryService.TRANSITION_TYPED + }]); + await referrerPromise; + + // Verify results for referrer uri. + Assert.ok(!!PlacesTestUtils.isPageInDB(REFERRER_URI)); + Assert.equal(visitId, 1); + + // Wait for visits notification and get the referrer Id. + let referrerId; + let downloadPromise = PlacesTestUtils.waitForNotification("onVisits", visits => { + referrerId = visits[0].referrerId; + let {uri} = visits[0]; + return uri.equals(DOWNLOAD_URI); + }, "history"); + + gDownloadHistory.addDownload(DOWNLOAD_URI, REFERRER_URI, Date.now() * 1000); + await downloadPromise; + + // Verify results for download uri. + Assert.ok(!!PlacesTestUtils.isPageInDB(DOWNLOAD_URI)); + Assert.equal(visitId, referrerId); + + await PlacesUtils.history.clear(); }); add_test(function test_dh_addDownload_disabledHistory() { diff --git a/toolkit/components/places/tests/unit/test_isURIVisited.js b/toolkit/components/places/tests/unit/test_isURIVisited.js index b70c24358479..a874828bb5dd 100644 --- a/toolkit/components/places/tests/unit/test_isURIVisited.js +++ b/toolkit/components/places/tests/unit/test_isURIVisited.js @@ -23,59 +23,46 @@ const SCHEMES = { "javascript:": false, }; -var gRunner; -function run_test() { - do_test_pending(); - gRunner = step(); - gRunner.next(); -} - -function* step() { +add_task(async function test_isURIVisited() { let history = Cc["@mozilla.org/browser/history;1"] .getService(Ci.mozIAsyncHistory); + function visitsPromise(uri) { + return new Promise(resolve => { + history.isURIVisited(uri, (receivedURI, visited) => { + resolve([receivedURI, visited]); + }); + }); + } + for (let scheme in SCHEMES) { info("Testing scheme " + scheme); for (let t in PlacesUtils.history.TRANSITIONS) { info("With transition " + t); - let transition = PlacesUtils.history.TRANSITIONS[t]; + let aTransition = PlacesUtils.history.TRANSITIONS[t]; - let uri = NetUtil.newURI(scheme + "mozilla.org/"); + let aURI = Services.io.newURI(scheme + "mozilla.org/"); - history.isURIVisited(uri, function(aURI, aIsVisited) { - Assert.ok(uri.equals(aURI)); - Assert.ok(!aIsVisited); + let [receivedURI1, visited1] = await visitsPromise(aURI); + Assert.ok(aURI.equals(receivedURI1)); + Assert.ok(!visited1); - let callback = { - handleError() {}, - handleResult() {}, - handleCompletion() { - info("Added visit to " + uri.spec); + if (PlacesUtils.history.canAddURI(aURI)) { + await PlacesTestUtils.addVisits([{ + uri: aURI, + transition: aTransition + }]); + info("Added visit for " + aURI.spec); + } - history.isURIVisited(uri, function(aURI2, aIsVisited2) { - Assert.ok(uri.equals(aURI2)); - Assert.ok(SCHEMES[scheme] ? aIsVisited2 : !aIsVisited2); + let [receivedURI2, visited2] = await visitsPromise(aURI); + Assert.ok(aURI.equals(receivedURI2)); + Assert.equal(SCHEMES[scheme], visited2); - PlacesUtils.history.clear().then(function() { - history.isURIVisited(uri, function(aURI3, aIsVisited3) { - Assert.ok(uri.equals(aURI3)); - Assert.ok(!aIsVisited3); - gRunner.next(); - }); - }); - }); - }, - }; - - history.updatePlaces({ uri, - visits: [ { transitionType: transition, - visitDate: Date.now() * 1000 - } ] - }, callback); - }); - yield undefined; + await PlacesUtils.history.clear(); + let [receivedURI3, visited3] = await visitsPromise(aURI); + Assert.ok(aURI.equals(receivedURI3)); + Assert.ok(!visited3); } } - - do_test_finished(); -} +}); diff --git a/toolkit/components/prompts/test/test_bug620145.html b/toolkit/components/prompts/test/test_bug620145.html index 1aa51c9905f0..5f30c451b8c6 100644 --- a/toolkit/components/prompts/test/test_bug620145.html +++ b/toolkit/components/prompts/test/test_bug620145.html @@ -3,7 +3,7 @@ Test for Bug 620145 - + diff --git a/toolkit/components/prompts/test/test_dom_prompts.html b/toolkit/components/prompts/test/test_dom_prompts.html index 31c61a0a85ca..ab8512e3247f 100644 --- a/toolkit/components/prompts/test/test_dom_prompts.html +++ b/toolkit/components/prompts/test/test_dom_prompts.html @@ -3,7 +3,7 @@ Test for DOM prompts - + diff --git a/toolkit/components/prompts/test/test_modal_prompts.html b/toolkit/components/prompts/test/test_modal_prompts.html index 03b9090d4440..854859f98458 100644 --- a/toolkit/components/prompts/test/test_modal_prompts.html +++ b/toolkit/components/prompts/test/test_modal_prompts.html @@ -3,7 +3,7 @@ Modal Prompts Test - + diff --git a/toolkit/components/prompts/test/test_modal_select.html b/toolkit/components/prompts/test/test_modal_select.html index 31ef9aececdb..f3f550607eee 100644 --- a/toolkit/components/prompts/test/test_modal_select.html +++ b/toolkit/components/prompts/test/test_modal_select.html @@ -3,7 +3,7 @@ Modal Prompts Test - + diff --git a/toolkit/components/prompts/test/test_subresources_prompts.html b/toolkit/components/prompts/test/test_subresources_prompts.html index 7e9e73745f8c..6fd4f4ae23f1 100644 --- a/toolkit/components/prompts/test/test_subresources_prompts.html +++ b/toolkit/components/prompts/test/test_subresources_prompts.html @@ -3,7 +3,7 @@ Test subresources prompts (Bug 625187 and bug 1230462) - + diff --git a/toolkit/components/satchel/nsFormFillController.cpp b/toolkit/components/satchel/nsFormFillController.cpp index 33bec352890a..e930c018f3fd 100644 --- a/toolkit/components/satchel/nsFormFillController.cpp +++ b/toolkit/components/satchel/nsFormFillController.cpp @@ -10,7 +10,7 @@ #include "mozilla/ErrorResult.h" #include "mozilla/EventListenerManager.h" #include "mozilla/dom/Element.h" -#include "mozilla/dom/Event.h" // for nsIDOMEvent::InternalDOMEvent() +#include "mozilla/dom/Event.h" // for Event #include "mozilla/dom/HTMLInputElement.h" #include "mozilla/dom/KeyboardEvent.h" #include "mozilla/dom/KeyboardEventBinding.h" @@ -644,7 +644,7 @@ nsFormFillController::OnSearchComplete() } NS_IMETHODIMP -nsFormFillController::OnTextEntered(nsIDOMEvent* aEvent, +nsFormFillController::OnTextEntered(Event* aEvent, bool* aPrevent) { NS_ENSURE_ARG(aPrevent); @@ -867,7 +867,7 @@ nsFormFillController::OnSearchCompletion(nsIAutoCompleteResult *aResult) //// nsIDOMEventListener NS_IMETHODIMP -nsFormFillController::HandleEvent(nsIDOMEvent* aEvent) +nsFormFillController::HandleEvent(Event* aEvent) { WidgetEvent* internalEvent = aEvent->WidgetEventPtr(); NS_ENSURE_STATE(internalEvent); @@ -881,8 +881,7 @@ nsFormFillController::HandleEvent(nsIDOMEvent* aEvent) return KeyPress(aEvent); case eEditorInput: { - nsCOMPtr input = do_QueryInterface( - aEvent->InternalDOMEvent()->GetTarget()); + nsCOMPtr input = do_QueryInterface(aEvent->GetTarget()); if (!IsTextControl(input)) { return NS_OK; } @@ -915,8 +914,7 @@ nsFormFillController::HandleEvent(nsIDOMEvent* aEvent) return NS_OK; case ePageHide: { - nsCOMPtr doc = do_QueryInterface( - aEvent->InternalDOMEvent()->GetTarget()); + nsCOMPtr doc = do_QueryInterface(aEvent->GetTarget()); if (!doc) { return NS_OK; } @@ -930,7 +928,7 @@ nsFormFillController::HandleEvent(nsIDOMEvent* aEvent) // Only remove the observer notifications and marked autofill and password // manager fields if the page isn't going to be persisted (i.e. it's being // unloaded) so that appropriate autocomplete handling works with bfcache. - bool persisted = aEvent->InternalDOMEvent()->AsPageTransitionEvent()->Persisted(); + bool persisted = aEvent->AsPageTransitionEvent()->Persisted(); if (!persisted) { RemoveForDocument(doc); } @@ -1028,10 +1026,9 @@ nsFormFillController::MaybeStartControllingInput(HTMLInputElement* aInput) } nsresult -nsFormFillController::Focus(nsIDOMEvent* aEvent) +nsFormFillController::Focus(Event* aEvent) { - nsCOMPtr input = do_QueryInterface( - aEvent->InternalDOMEvent()->GetTarget()); + nsCOMPtr input = do_QueryInterface(aEvent->GetTarget()); MaybeStartControllingInput(HTMLInputElement::FromNodeOrNull(input)); // Bail if we didn't start controlling the input. @@ -1068,15 +1065,14 @@ nsFormFillController::Focus(nsIDOMEvent* aEvent) } nsresult -nsFormFillController::KeyPress(nsIDOMEvent* aEvent) +nsFormFillController::KeyPress(Event* aEvent) { NS_ASSERTION(mController, "should have a controller!"); if (!mFocusedInput || !mController) { return NS_OK; } - RefPtr keyEvent = - aEvent->InternalDOMEvent()->AsKeyboardEvent(); + RefPtr keyEvent = aEvent->AsKeyboardEvent(); if (!keyEvent) { return NS_ERROR_FAILURE; } @@ -1177,15 +1173,15 @@ nsFormFillController::KeyPress(nsIDOMEvent* aEvent) } nsresult -nsFormFillController::MouseDown(nsIDOMEvent* aEvent) +nsFormFillController::MouseDown(Event* aEvent) { - MouseEvent* mouseEvent = aEvent->InternalDOMEvent()->AsMouseEvent(); + MouseEvent* mouseEvent = aEvent->AsMouseEvent(); if (!mouseEvent) { return NS_ERROR_FAILURE; } - nsCOMPtr targetInput = do_QueryInterface( - aEvent->InternalDOMEvent()->GetTarget()); + nsCOMPtr targetInput = + do_QueryInterface(aEvent->GetTarget()); if (!targetInput) { return NS_OK; } diff --git a/toolkit/components/satchel/nsFormFillController.h b/toolkit/components/satchel/nsFormFillController.h index c4c50366fded..b69e78e0becb 100644 --- a/toolkit/components/satchel/nsFormFillController.h +++ b/toolkit/components/satchel/nsFormFillController.h @@ -55,9 +55,9 @@ public: NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsFormFillController, nsIFormFillController) - nsresult Focus(nsIDOMEvent* aEvent); - nsresult KeyPress(nsIDOMEvent* aKeyEvent); - nsresult MouseDown(nsIDOMEvent* aMouseEvent); + nsresult Focus(mozilla::dom::Event* aEvent); + nsresult KeyPress(mozilla::dom::Event* aKeyEvent); + nsresult MouseDown(mozilla::dom::Event* aMouseEvent); nsFormFillController(); @@ -91,7 +91,6 @@ protected: void MaybeRemoveMutationObserver(nsINode* aNode); void RemoveForDocument(nsIDocument* aDoc); - bool IsEventTrusted(nsIDOMEvent *aEvent); bool IsTextControl(nsINode* aNode); diff --git a/toolkit/components/satchel/test/test_bug_511615.html b/toolkit/components/satchel/test/test_bug_511615.html index b0128f0a6d70..d81fe729b836 100644 --- a/toolkit/components/satchel/test/test_bug_511615.html +++ b/toolkit/components/satchel/test/test_bug_511615.html @@ -3,7 +3,7 @@ Test for Form History Autocomplete Untrusted Events: Bug 511615 - + diff --git a/toolkit/components/satchel/test/test_bug_787624.html b/toolkit/components/satchel/test/test_bug_787624.html index 66e9b589b1ac..b6656f384879 100644 --- a/toolkit/components/satchel/test/test_bug_787624.html +++ b/toolkit/components/satchel/test/test_bug_787624.html @@ -4,7 +4,7 @@ Test for Layout of Form History Autocomplete: Bug 787624 - +