forked from mirrors/gecko-dev
Bug 1561435 - Format toolkit/actors, a=automatic-formatting
# ignore-this-changeset Differential Revision: https://phabricator.services.mozilla.com/D36050 --HG-- extra : source : 2540803fff7587f65dd5d6253b6fb544647e5e20
This commit is contained in:
parent
57a6febcec
commit
d3a1b5aeaa
31 changed files with 1105 additions and 556 deletions
|
|
@ -45,7 +45,6 @@ module.exports = {
|
||||||
"overrides": [{
|
"overrides": [{
|
||||||
"files": [
|
"files": [
|
||||||
"devtools/**",
|
"devtools/**",
|
||||||
"toolkit/**",
|
|
||||||
"tools/**",
|
"tools/**",
|
||||||
"uriloader/**",
|
"uriloader/**",
|
||||||
"view/**",
|
"view/**",
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,6 @@ toolkit/components/telemetry/datareporting-prefs.js
|
||||||
toolkit/components/telemetry/healthreport-prefs.js
|
toolkit/components/telemetry/healthreport-prefs.js
|
||||||
|
|
||||||
# Ignore all top-level directories for now.
|
# Ignore all top-level directories for now.
|
||||||
toolkit/**
|
|
||||||
tools/**
|
tools/**
|
||||||
uriloader/**
|
uriloader/**
|
||||||
view/**
|
view/**
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,9 @@
|
||||||
|
|
||||||
var EXPORTED_SYMBOLS = ["AudioPlaybackChild"];
|
var EXPORTED_SYMBOLS = ["AudioPlaybackChild"];
|
||||||
|
|
||||||
const {ActorChild} = ChromeUtils.import("resource://gre/modules/ActorChild.jsm");
|
const { ActorChild } = ChromeUtils.import(
|
||||||
|
"resource://gre/modules/ActorChild.jsm"
|
||||||
|
);
|
||||||
|
|
||||||
class AudioPlaybackChild extends ActorChild {
|
class AudioPlaybackChild extends ActorChild {
|
||||||
handleMediaControlMessage(msg) {
|
handleMediaControlMessage(msg) {
|
||||||
|
|
@ -49,14 +51,14 @@ class AudioPlaybackChild extends ActorChild {
|
||||||
} else if (data === "activeMediaBlockStop") {
|
} else if (data === "activeMediaBlockStop") {
|
||||||
name += "ActiveMediaBlockStop";
|
name += "ActiveMediaBlockStop";
|
||||||
} else {
|
} else {
|
||||||
name += (data === "active") ? "Start" : "Stop";
|
name += data === "active" ? "Start" : "Stop";
|
||||||
}
|
}
|
||||||
this.mm.sendAsyncMessage(name);
|
this.mm.sendAsyncMessage(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
receiveMessage({name, data}) {
|
receiveMessage({ name, data }) {
|
||||||
switch (name) {
|
switch (name) {
|
||||||
case "AudioPlayback":
|
case "AudioPlayback":
|
||||||
this.handleMediaControlMessage(data.type);
|
this.handleMediaControlMessage(data.type);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/* vim: set ts=2 sw=2 sts=2 et tw=80: */
|
/* vim: set ts=2 sw=2 sts=2 et tw=80: */
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
/* 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
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var EXPORTED_SYMBOLS = ["AutoplayParent"];
|
var EXPORTED_SYMBOLS = ["AutoplayParent"];
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,10 @@ var EXPORTED_SYMBOLS = ["BrowserElementChild"];
|
||||||
|
|
||||||
class BrowserElementChild extends JSWindowActorChild {
|
class BrowserElementChild extends JSWindowActorChild {
|
||||||
handleEvent(event) {
|
handleEvent(event) {
|
||||||
if (event.type == "DOMWindowClose" &&
|
if (
|
||||||
!this.manager.browsingContext.parent) {
|
event.type == "DOMWindowClose" &&
|
||||||
|
!this.manager.browsingContext.parent
|
||||||
|
) {
|
||||||
this.sendAsyncMessage("DOMWindowClose", {});
|
this.sendAsyncMessage("DOMWindowClose", {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -24,7 +26,9 @@ class BrowserElementChild extends JSWindowActorChild {
|
||||||
|
|
||||||
let permitUnload = true;
|
let permitUnload = true;
|
||||||
if (docShell && docShell.contentViewer) {
|
if (docShell && docShell.contentViewer) {
|
||||||
permitUnload = docShell.contentViewer.permitUnload(message.data.flags);
|
permitUnload = docShell.contentViewer.permitUnload(
|
||||||
|
message.data.flags
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.sendAsyncMessage("Done", { permitUnload });
|
this.sendAsyncMessage("Done", { permitUnload });
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,20 @@
|
||||||
|
|
||||||
var EXPORTED_SYMBOLS = ["BrowserElementParent", "PermitUnloader"];
|
var EXPORTED_SYMBOLS = ["BrowserElementParent", "PermitUnloader"];
|
||||||
|
|
||||||
ChromeUtils.defineModuleGetter(this, "Services",
|
ChromeUtils.defineModuleGetter(
|
||||||
"resource://gre/modules/Services.jsm");
|
this,
|
||||||
|
"Services",
|
||||||
|
"resource://gre/modules/Services.jsm"
|
||||||
|
);
|
||||||
|
|
||||||
let {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
let { XPCOMUtils } = ChromeUtils.import(
|
||||||
XPCOMUtils.defineLazyPreferenceGetter(this, "unloadTimeoutMs",
|
"resource://gre/modules/XPCOMUtils.jsm"
|
||||||
"dom.beforeunload_timeout_ms");
|
);
|
||||||
|
XPCOMUtils.defineLazyPreferenceGetter(
|
||||||
|
this,
|
||||||
|
"unloadTimeoutMs",
|
||||||
|
"dom.beforeunload_timeout_ms"
|
||||||
|
);
|
||||||
|
|
||||||
// Out-of-process subframes might be in the following states following a request
|
// Out-of-process subframes might be in the following states following a request
|
||||||
// to permit closing:
|
// to permit closing:
|
||||||
|
|
@ -74,9 +82,11 @@ class BrowserElementParent extends JSWindowActorParent {
|
||||||
// If this is a non-remote browser, the DOMWindowClose event will bubble
|
// If this is a non-remote browser, the DOMWindowClose event will bubble
|
||||||
// up naturally, and doesn't need to be re-dispatched.
|
// up naturally, and doesn't need to be re-dispatched.
|
||||||
if (browser.isRemoteBrowser) {
|
if (browser.isRemoteBrowser) {
|
||||||
browser.dispatchEvent(new win.CustomEvent("DOMWindowClose", {
|
browser.dispatchEvent(
|
||||||
bubbles: true,
|
new win.CustomEvent("DOMWindowClose", {
|
||||||
}));
|
bubbles: true,
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -203,9 +213,13 @@ var PermitUnloader = {
|
||||||
actor.sendPermitUnload(flags);
|
actor.sendPermitUnload(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
timer.initWithCallback(() => {
|
timer.initWithCallback(
|
||||||
this._onTimeout(frameLoader);
|
() => {
|
||||||
}, unloadTimeoutMs, timer.TYPE_ONE_SHOT);
|
this._onTimeout(frameLoader);
|
||||||
|
},
|
||||||
|
unloadTimeoutMs,
|
||||||
|
timer.TYPE_ONE_SHOT
|
||||||
|
);
|
||||||
|
|
||||||
Services.tm.spinEventLoopUntilOrShutdown(() => {
|
Services.tm.spinEventLoopUntilOrShutdown(() => {
|
||||||
return this._finishedPermitUnload(frameStates);
|
return this._finishedPermitUnload(frameStates);
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,17 @@
|
||||||
|
|
||||||
var EXPORTED_SYMBOLS = ["ControllersChild"];
|
var EXPORTED_SYMBOLS = ["ControllersChild"];
|
||||||
|
|
||||||
const {ActorChild} = ChromeUtils.import("resource://gre/modules/ActorChild.jsm");
|
const { ActorChild } = ChromeUtils.import(
|
||||||
|
"resource://gre/modules/ActorChild.jsm"
|
||||||
|
);
|
||||||
|
|
||||||
class ControllersChild extends ActorChild {
|
class ControllersChild extends ActorChild {
|
||||||
receiveMessage(message) {
|
receiveMessage(message) {
|
||||||
switch (message.name) {
|
switch (message.name) {
|
||||||
case "ControllerCommands:Do":
|
case "ControllerCommands:Do":
|
||||||
if (this.docShell.isCommandEnabled(message.data))
|
if (this.docShell.isCommandEnabled(message.data)) {
|
||||||
this.docShell.doCommand(message.data);
|
this.docShell.doCommand(message.data);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "ControllerCommands:DoWithParams":
|
case "ControllerCommands:DoWithParams":
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,12 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
ChromeUtils.defineModuleGetter(this, "BrowserUtils",
|
ChromeUtils.defineModuleGetter(
|
||||||
"resource://gre/modules/BrowserUtils.jsm");
|
this,
|
||||||
|
"BrowserUtils",
|
||||||
|
"resource://gre/modules/BrowserUtils.jsm"
|
||||||
|
);
|
||||||
|
|
||||||
var EXPORTED_SYMBOLS = ["DateTimePickerChild"];
|
var EXPORTED_SYMBOLS = ["DateTimePickerChild"];
|
||||||
|
|
||||||
|
|
@ -39,7 +42,8 @@ class DateTimePickerChild extends JSWindowActorChild {
|
||||||
// An event dispatch to it can't be accessed by document.
|
// An event dispatch to it can't be accessed by document.
|
||||||
let win = this._inputElement.ownerGlobal;
|
let win = this._inputElement.ownerGlobal;
|
||||||
dateTimeBoxElement.dispatchEvent(
|
dateTimeBoxElement.dispatchEvent(
|
||||||
new win.CustomEvent("MozSetDateTimePickerState", { detail: false }));
|
new win.CustomEvent("MozSetDateTimePickerState", { detail: false })
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._inputElement = null;
|
this._inputElement = null;
|
||||||
|
|
@ -64,7 +68,8 @@ class DateTimePickerChild extends JSWindowActorChild {
|
||||||
* Helper function that returns the CSS direction property of the element.
|
* Helper function that returns the CSS direction property of the element.
|
||||||
*/
|
*/
|
||||||
getComputedDirection(aElement) {
|
getComputedDirection(aElement) {
|
||||||
return aElement.ownerGlobal.getComputedStyle(aElement)
|
return aElement.ownerGlobal
|
||||||
|
.getComputedStyle(aElement)
|
||||||
.getPropertyValue("direction");
|
.getPropertyValue("direction");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -105,8 +110,10 @@ class DateTimePickerChild extends JSWindowActorChild {
|
||||||
// dateTimeBoxElement is within UA Widget Shadow DOM.
|
// dateTimeBoxElement is within UA Widget Shadow DOM.
|
||||||
// An event dispatch to it can't be accessed by document.
|
// An event dispatch to it can't be accessed by document.
|
||||||
dateTimeBoxElement.dispatchEvent(
|
dateTimeBoxElement.dispatchEvent(
|
||||||
new win.CustomEvent("MozPickerValueChanged",
|
new win.CustomEvent("MozPickerValueChanged", {
|
||||||
{ detail: Cu.cloneInto(aMessage.data, win) }));
|
detail: Cu.cloneInto(aMessage.data, win),
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -123,8 +130,13 @@ class DateTimePickerChild extends JSWindowActorChild {
|
||||||
switch (aEvent.type) {
|
switch (aEvent.type) {
|
||||||
case "MozOpenDateTimePicker": {
|
case "MozOpenDateTimePicker": {
|
||||||
// Time picker is disabled when preffed off
|
// Time picker is disabled when preffed off
|
||||||
if (!(aEvent.originalTarget instanceof aEvent.originalTarget.ownerGlobal.HTMLInputElement) ||
|
if (
|
||||||
(aEvent.originalTarget.type == "time" && !this.getTimePickerPref())) {
|
!(
|
||||||
|
aEvent.originalTarget instanceof
|
||||||
|
aEvent.originalTarget.ownerGlobal.HTMLInputElement
|
||||||
|
) ||
|
||||||
|
(aEvent.originalTarget.type == "time" && !this.getTimePickerPref())
|
||||||
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -139,7 +151,9 @@ class DateTimePickerChild extends JSWindowActorChild {
|
||||||
|
|
||||||
let dateTimeBoxElement = this._inputElement.dateTimeBoxElement;
|
let dateTimeBoxElement = this._inputElement.dateTimeBoxElement;
|
||||||
if (!dateTimeBoxElement) {
|
if (!dateTimeBoxElement) {
|
||||||
throw new Error("How do we get this event without a UA Widget or XBL binding?");
|
throw new Error(
|
||||||
|
"How do we get this event without a UA Widget or XBL binding?"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._inputElement.openOrClosedShadowRoot) {
|
if (this._inputElement.openOrClosedShadowRoot) {
|
||||||
|
|
@ -148,7 +162,8 @@ class DateTimePickerChild extends JSWindowActorChild {
|
||||||
// the event is not composed.
|
// the event is not composed.
|
||||||
let win = this._inputElement.ownerGlobal;
|
let win = this._inputElement.ownerGlobal;
|
||||||
dateTimeBoxElement.dispatchEvent(
|
dateTimeBoxElement.dispatchEvent(
|
||||||
new win.CustomEvent("MozSetDateTimePickerState", { detail: true }));
|
new win.CustomEvent("MozSetDateTimePickerState", { detail: true })
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.addListeners(this._inputElement);
|
this.addListeners(this._inputElement);
|
||||||
|
|
@ -161,8 +176,8 @@ class DateTimePickerChild extends JSWindowActorChild {
|
||||||
detail: {
|
detail: {
|
||||||
// Pass partial value if it's available, otherwise pass input
|
// Pass partial value if it's available, otherwise pass input
|
||||||
// element's value.
|
// element's value.
|
||||||
value: Object.keys(value).length > 0 ? value
|
value:
|
||||||
: this._inputElement.value,
|
Object.keys(value).length > 0 ? value : this._inputElement.value,
|
||||||
min: this._inputElement.getMinimum(),
|
min: this._inputElement.getMinimum(),
|
||||||
max: this._inputElement.getMaximum(),
|
max: this._inputElement.getMaximum(),
|
||||||
step: this._inputElement.getStep(),
|
step: this._inputElement.getStep(),
|
||||||
|
|
@ -183,8 +198,10 @@ class DateTimePickerChild extends JSWindowActorChild {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "pagehide": {
|
case "pagehide": {
|
||||||
if (this._inputElement &&
|
if (
|
||||||
this._inputElement.ownerDocument == aEvent.target) {
|
this._inputElement &&
|
||||||
|
this._inputElement.ownerDocument == aEvent.target
|
||||||
|
) {
|
||||||
this.sendAsyncMessage("FormDateTime:ClosePicker", {});
|
this.sendAsyncMessage("FormDateTime:ClosePicker", {});
|
||||||
this.close();
|
this.close();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,12 @@ function debug(aStr) {
|
||||||
|
|
||||||
var EXPORTED_SYMBOLS = ["DateTimePickerParent"];
|
var EXPORTED_SYMBOLS = ["DateTimePickerParent"];
|
||||||
|
|
||||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
ChromeUtils.defineModuleGetter(this, "DateTimePickerPanel", "resource://gre/modules/DateTimePickerPanel.jsm");
|
ChromeUtils.defineModuleGetter(
|
||||||
|
this,
|
||||||
|
"DateTimePickerPanel",
|
||||||
|
"resource://gre/modules/DateTimePickerPanel.jsm"
|
||||||
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DateTimePickerParent receives message from content side (input box) and
|
* DateTimePickerParent receives message from content side (input box) and
|
||||||
|
|
@ -78,7 +82,9 @@ class DateTimePickerParent extends JSWindowActorParent {
|
||||||
|
|
||||||
this._anchor = aBrowser.popupAnchor;
|
this._anchor = aBrowser.popupAnchor;
|
||||||
if (!this._anchor) {
|
if (!this._anchor) {
|
||||||
throw new Error("No popup anchor for this browser, cannot show date picker");
|
throw new Error(
|
||||||
|
"No popup anchor for this browser, cannot show date picker"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._anchor.left = rect.left;
|
this._anchor.left = rect.left;
|
||||||
|
|
@ -91,8 +97,10 @@ class DateTimePickerParent extends JSWindowActorParent {
|
||||||
|
|
||||||
let window = aBrowser.ownerGlobal;
|
let window = aBrowser.ownerGlobal;
|
||||||
let tabbrowser = window.gBrowser;
|
let tabbrowser = window.gBrowser;
|
||||||
if (Services.focus.activeWindow != window ||
|
if (
|
||||||
(tabbrowser && tabbrowser.selectedBrowser != aBrowser)) {
|
Services.focus.activeWindow != window ||
|
||||||
|
(tabbrowser && tabbrowser.selectedBrowser != aBrowser)
|
||||||
|
) {
|
||||||
// We were sent a message from a window or tab that went into the
|
// We were sent a message from a window or tab that went into the
|
||||||
// background, so we'll ignore it for now.
|
// background, so we'll ignore it for now.
|
||||||
return;
|
return;
|
||||||
|
|
@ -132,6 +140,9 @@ class DateTimePickerParent extends JSWindowActorParent {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._picker.element.removeEventListener("popuphidden", this);
|
this._picker.element.removeEventListener("popuphidden", this);
|
||||||
this._picker.element.removeEventListener("DateTimePickerValueChanged", this);
|
this._picker.element.removeEventListener(
|
||||||
|
"DateTimePickerValueChanged",
|
||||||
|
this
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,15 @@
|
||||||
|
|
||||||
var EXPORTED_SYMBOLS = ["ExtFindChild"];
|
var EXPORTED_SYMBOLS = ["ExtFindChild"];
|
||||||
|
|
||||||
const {ActorChild} = ChromeUtils.import("resource://gre/modules/ActorChild.jsm");
|
const { ActorChild } = ChromeUtils.import(
|
||||||
|
"resource://gre/modules/ActorChild.jsm"
|
||||||
|
);
|
||||||
|
|
||||||
ChromeUtils.defineModuleGetter(this, "FindContent",
|
ChromeUtils.defineModuleGetter(
|
||||||
"resource://gre/modules/FindContent.jsm");
|
this,
|
||||||
|
"FindContent",
|
||||||
|
"resource://gre/modules/FindContent.jsm"
|
||||||
|
);
|
||||||
|
|
||||||
class ExtFindChild extends ActorChild {
|
class ExtFindChild extends ActorChild {
|
||||||
async receiveMessage(message) {
|
async receiveMessage(message) {
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,19 @@
|
||||||
|
|
||||||
var EXPORTED_SYMBOLS = ["FindBarChild"];
|
var EXPORTED_SYMBOLS = ["FindBarChild"];
|
||||||
|
|
||||||
const {ActorChild} = ChromeUtils.import("resource://gre/modules/ActorChild.jsm");
|
const { ActorChild } = ChromeUtils.import(
|
||||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
"resource://gre/modules/ActorChild.jsm"
|
||||||
const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
);
|
||||||
|
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
|
const { XPCOMUtils } = ChromeUtils.import(
|
||||||
|
"resource://gre/modules/XPCOMUtils.jsm"
|
||||||
|
);
|
||||||
|
|
||||||
ChromeUtils.defineModuleGetter(this, "BrowserUtils",
|
ChromeUtils.defineModuleGetter(
|
||||||
"resource://gre/modules/BrowserUtils.jsm");
|
this,
|
||||||
|
"BrowserUtils",
|
||||||
|
"resource://gre/modules/BrowserUtils.jsm"
|
||||||
|
);
|
||||||
|
|
||||||
class FindBarChild extends ActorChild {
|
class FindBarChild extends ActorChild {
|
||||||
constructor(dispatcher) {
|
constructor(dispatcher) {
|
||||||
|
|
@ -19,11 +26,16 @@ class FindBarChild extends ActorChild {
|
||||||
|
|
||||||
this._findKey = null;
|
this._findKey = null;
|
||||||
|
|
||||||
XPCOMUtils.defineLazyProxy(this, "FindBarContent", () => {
|
XPCOMUtils.defineLazyProxy(
|
||||||
let tmp = {};
|
this,
|
||||||
ChromeUtils.import("resource://gre/modules/FindBarContent.jsm", tmp);
|
"FindBarContent",
|
||||||
return new tmp.FindBarContent(this.mm);
|
() => {
|
||||||
}, {inQuickFind: false, inPassThrough: false});
|
let tmp = {};
|
||||||
|
ChromeUtils.import("resource://gre/modules/FindBarContent.jsm", tmp);
|
||||||
|
return new tmp.FindBarContent(this.mm);
|
||||||
|
},
|
||||||
|
{ inQuickFind: false, inPassThrough: false }
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -54,10 +66,9 @@ class FindBarChild extends ActorChild {
|
||||||
}
|
}
|
||||||
|
|
||||||
onKeypress(event) {
|
onKeypress(event) {
|
||||||
let {FindBarContent} = this;
|
let { FindBarContent } = this;
|
||||||
|
|
||||||
if (!FindBarContent.inPassThrough &&
|
if (!FindBarContent.inPassThrough && this.eventMatchesFindShortcut(event)) {
|
||||||
this.eventMatchesFindShortcut(event)) {
|
|
||||||
return FindBarContent.start(event);
|
return FindBarContent.start(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -67,9 +78,14 @@ class FindBarChild extends ActorChild {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.ctrlKey || event.altKey || event.metaKey || event.defaultPrevented ||
|
if (
|
||||||
!BrowserUtils.mimeTypeIsTextBased(this.content.document.contentType) ||
|
event.ctrlKey ||
|
||||||
!BrowserUtils.canFindInPage(location)) {
|
event.altKey ||
|
||||||
|
event.metaKey ||
|
||||||
|
event.defaultPrevented ||
|
||||||
|
!BrowserUtils.mimeTypeIsTextBased(this.content.document.contentType) ||
|
||||||
|
!BrowserUtils.canFindInPage(location)
|
||||||
|
) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -90,8 +106,13 @@ class FindBarChild extends ActorChild {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
XPCOMUtils.defineLazyPreferenceGetter(FindBarChild, "findAsYouType",
|
XPCOMUtils.defineLazyPreferenceGetter(
|
||||||
"accessibility.typeaheadfind");
|
FindBarChild,
|
||||||
XPCOMUtils.defineLazyPreferenceGetter(FindBarChild, "manualFAYT",
|
"findAsYouType",
|
||||||
"accessibility.typeaheadfind.manual");
|
"accessibility.typeaheadfind"
|
||||||
|
);
|
||||||
|
XPCOMUtils.defineLazyPreferenceGetter(
|
||||||
|
FindBarChild,
|
||||||
|
"manualFAYT",
|
||||||
|
"accessibility.typeaheadfind.manual"
|
||||||
|
);
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,15 @@
|
||||||
|
|
||||||
var EXPORTED_SYMBOLS = ["FinderChild"];
|
var EXPORTED_SYMBOLS = ["FinderChild"];
|
||||||
|
|
||||||
const {ActorChild} = ChromeUtils.import("resource://gre/modules/ActorChild.jsm");
|
const { ActorChild } = ChromeUtils.import(
|
||||||
|
"resource://gre/modules/ActorChild.jsm"
|
||||||
|
);
|
||||||
|
|
||||||
ChromeUtils.defineModuleGetter(this, "Finder",
|
ChromeUtils.defineModuleGetter(
|
||||||
"resource://gre/modules/Finder.jsm");
|
this,
|
||||||
|
"Finder",
|
||||||
|
"resource://gre/modules/Finder.jsm"
|
||||||
|
);
|
||||||
|
|
||||||
const MESSAGES = [
|
const MESSAGES = [
|
||||||
"Finder:CaseSensitive",
|
"Finder:CaseSensitive",
|
||||||
|
|
@ -70,26 +75,36 @@ class FinderChild extends ActorChild {
|
||||||
|
|
||||||
case "Finder:SetSearchStringToSelection": {
|
case "Finder:SetSearchStringToSelection": {
|
||||||
let selection = this._finder.setSearchStringToSelection();
|
let selection = this._finder.setSearchStringToSelection();
|
||||||
this.mm.sendAsyncMessage("Finder:CurrentSelectionResult",
|
this.mm.sendAsyncMessage("Finder:CurrentSelectionResult", {
|
||||||
{ selection,
|
selection,
|
||||||
initial: false });
|
initial: false,
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case "Finder:GetInitialSelection": {
|
case "Finder:GetInitialSelection": {
|
||||||
let selection = this._finder.getActiveSelectionText();
|
let selection = this._finder.getActiveSelectionText();
|
||||||
this.mm.sendAsyncMessage("Finder:CurrentSelectionResult",
|
this.mm.sendAsyncMessage("Finder:CurrentSelectionResult", {
|
||||||
{ selection,
|
selection,
|
||||||
initial: true });
|
initial: true,
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case "Finder:FastFind":
|
case "Finder:FastFind":
|
||||||
this._finder.fastFind(data.searchString, data.linksOnly, data.drawOutline);
|
this._finder.fastFind(
|
||||||
|
data.searchString,
|
||||||
|
data.linksOnly,
|
||||||
|
data.drawOutline
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "Finder:FindAgain":
|
case "Finder:FindAgain":
|
||||||
this._finder.findAgain(data.findBackwards, data.linksOnly, data.drawOutline);
|
this._finder.findAgain(
|
||||||
|
data.findBackwards,
|
||||||
|
data.linksOnly,
|
||||||
|
data.drawOutline
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "Finder:Highlight":
|
case "Finder:Highlight":
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,11 @@
|
||||||
|
|
||||||
var EXPORTED_SYMBOLS = ["InlineSpellCheckerChild"];
|
var EXPORTED_SYMBOLS = ["InlineSpellCheckerChild"];
|
||||||
|
|
||||||
ChromeUtils.defineModuleGetter(this, "InlineSpellCheckerContent",
|
ChromeUtils.defineModuleGetter(
|
||||||
"resource://gre/modules/InlineSpellCheckerContent.jsm");
|
this,
|
||||||
|
"InlineSpellCheckerContent",
|
||||||
|
"resource://gre/modules/InlineSpellCheckerContent.jsm"
|
||||||
|
);
|
||||||
|
|
||||||
class InlineSpellCheckerChild extends JSWindowActorChild {
|
class InlineSpellCheckerChild extends JSWindowActorChild {
|
||||||
receiveMessage(msg) {
|
receiveMessage(msg) {
|
||||||
|
|
|
||||||
|
|
@ -10,13 +10,13 @@ var EXPORTED_SYMBOLS = ["InlineSpellCheckerParent"];
|
||||||
|
|
||||||
class InlineSpellCheckerParent extends JSWindowActorParent {
|
class InlineSpellCheckerParent extends JSWindowActorParent {
|
||||||
selectDictionary({ localeCode }) {
|
selectDictionary({ localeCode }) {
|
||||||
this.sendAsyncMessage("InlineSpellChecker:selectDictionary",
|
this.sendAsyncMessage("InlineSpellChecker:selectDictionary", {
|
||||||
{ localeCode });
|
localeCode,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
replaceMisspelling({ index }) {
|
replaceMisspelling({ index }) {
|
||||||
this.sendAsyncMessage("InlineSpellChecker:replaceMisspelling",
|
this.sendAsyncMessage("InlineSpellChecker:replaceMisspelling", { index });
|
||||||
{ index });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleEnabled() {
|
toggleEnabled() {
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,13 @@
|
||||||
|
|
||||||
var EXPORTED_SYMBOLS = ["KeyPressEventModelCheckerChild"];
|
var EXPORTED_SYMBOLS = ["KeyPressEventModelCheckerChild"];
|
||||||
|
|
||||||
const {ActorChild} = ChromeUtils.import("resource://gre/modules/ActorChild.jsm");
|
const { ActorChild } = ChromeUtils.import(
|
||||||
const {AppConstants} = ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
|
"resource://gre/modules/ActorChild.jsm"
|
||||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
);
|
||||||
|
const { AppConstants } = ChromeUtils.import(
|
||||||
|
"resource://gre/modules/AppConstants.jsm"
|
||||||
|
);
|
||||||
|
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
|
|
||||||
class KeyPressEventModelCheckerChild extends ActorChild {
|
class KeyPressEventModelCheckerChild extends ActorChild {
|
||||||
// Currently, the event is dispatched only when the document becomes editable
|
// Currently, the event is dispatched only when the document becomes editable
|
||||||
|
|
@ -29,27 +33,33 @@ class KeyPressEventModelCheckerChild extends ActorChild {
|
||||||
// here, conflated model isn't used forcibly. If you need it, you need
|
// here, conflated model isn't used forcibly. If you need it, you need
|
||||||
// to change WidgetKeyboardEvent, dom::KeyboardEvent and PresShell.
|
// to change WidgetKeyboardEvent, dom::KeyboardEvent and PresShell.
|
||||||
let model = Document.KEYPRESS_EVENT_MODEL_DEFAULT;
|
let model = Document.KEYPRESS_EVENT_MODEL_DEFAULT;
|
||||||
if (this._isOldOfficeOnlineServer(aEvent.target) ||
|
if (
|
||||||
this._isOldConfluence(aEvent.target.ownerGlobal)) {
|
this._isOldOfficeOnlineServer(aEvent.target) ||
|
||||||
|
this._isOldConfluence(aEvent.target.ownerGlobal)
|
||||||
|
) {
|
||||||
model = Document.KEYPRESS_EVENT_MODEL_SPLIT;
|
model = Document.KEYPRESS_EVENT_MODEL_SPLIT;
|
||||||
}
|
}
|
||||||
aEvent.target.setKeyPressEventModel(model);
|
aEvent.target.setKeyPressEventModel(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
_isOldOfficeOnlineServer(aDocument) {
|
_isOldOfficeOnlineServer(aDocument) {
|
||||||
let editingElement =
|
let editingElement = aDocument.getElementById(
|
||||||
aDocument.getElementById("WACViewPanel_EditingElement");
|
"WACViewPanel_EditingElement"
|
||||||
|
);
|
||||||
// If it's not Office Online Server, don't include it into the telemetry
|
// If it's not Office Online Server, don't include it into the telemetry
|
||||||
// because we just need to collect percentage of old version in all loaded
|
// because we just need to collect percentage of old version in all loaded
|
||||||
// Office Online Server instances.
|
// Office Online Server instances.
|
||||||
if (!editingElement) {
|
if (!editingElement) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let isOldVersion =
|
let isOldVersion = !editingElement.classList.contains(
|
||||||
!editingElement.classList.contains(
|
"WACViewPanel_DisableLegacyKeyCodeAndCharCode"
|
||||||
"WACViewPanel_DisableLegacyKeyCodeAndCharCode");
|
);
|
||||||
Services.telemetry.keyedScalarAdd("dom.event.office_online_load_count",
|
Services.telemetry.keyedScalarAdd(
|
||||||
isOldVersion ? "old" : "new", 1);
|
"dom.event.office_online_load_count",
|
||||||
|
isOldVersion ? "old" : "new",
|
||||||
|
1
|
||||||
|
);
|
||||||
return isOldVersion;
|
return isOldVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -85,8 +95,10 @@ class KeyPressEventModelCheckerChild extends ActorChild {
|
||||||
// instance. So, let's check the version whether it allows conflated
|
// instance. So, let's check the version whether it allows conflated
|
||||||
// keypress event model.
|
// keypress event model.
|
||||||
try {
|
try {
|
||||||
let {author, version} =
|
let {
|
||||||
new tinyMCEObject.plugins.CursorTargetPlugin().getInfo();
|
author,
|
||||||
|
version,
|
||||||
|
} = new tinyMCEObject.plugins.CursorTargetPlugin().getInfo();
|
||||||
// If it's not Confluence, don't include it into the telemetry because
|
// If it's not Confluence, don't include it into the telemetry because
|
||||||
// we just need to collect percentage of old version in all loaded
|
// we just need to collect percentage of old version in all loaded
|
||||||
// Confluence instances.
|
// Confluence instances.
|
||||||
|
|
@ -94,8 +106,11 @@ class KeyPressEventModelCheckerChild extends ActorChild {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let isOldVersion = version === "1.0";
|
let isOldVersion = version === "1.0";
|
||||||
Services.telemetry.keyedScalarAdd("dom.event.confluence_load_count",
|
Services.telemetry.keyedScalarAdd(
|
||||||
isOldVersion ? "old" : "new", 1);
|
"dom.event.confluence_load_count",
|
||||||
|
isOldVersion ? "old" : "new",
|
||||||
|
1
|
||||||
|
);
|
||||||
return isOldVersion;
|
return isOldVersion;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -6,13 +6,23 @@
|
||||||
|
|
||||||
var EXPORTED_SYMBOLS = ["PictureInPictureChild", "PictureInPictureToggleChild"];
|
var EXPORTED_SYMBOLS = ["PictureInPictureChild", "PictureInPictureToggleChild"];
|
||||||
|
|
||||||
const {ActorChild} = ChromeUtils.import("resource://gre/modules/ActorChild.jsm");
|
const { ActorChild } = ChromeUtils.import(
|
||||||
const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
"resource://gre/modules/ActorChild.jsm"
|
||||||
|
);
|
||||||
|
const { XPCOMUtils } = ChromeUtils.import(
|
||||||
|
"resource://gre/modules/XPCOMUtils.jsm"
|
||||||
|
);
|
||||||
|
|
||||||
ChromeUtils.defineModuleGetter(this, "DeferredTask",
|
ChromeUtils.defineModuleGetter(
|
||||||
"resource://gre/modules/DeferredTask.jsm");
|
this,
|
||||||
ChromeUtils.defineModuleGetter(this, "Services",
|
"DeferredTask",
|
||||||
"resource://gre/modules/Services.jsm");
|
"resource://gre/modules/DeferredTask.jsm"
|
||||||
|
);
|
||||||
|
ChromeUtils.defineModuleGetter(
|
||||||
|
this,
|
||||||
|
"Services",
|
||||||
|
"resource://gre/modules/Services.jsm"
|
||||||
|
);
|
||||||
|
|
||||||
XPCOMUtils.defineLazyGlobalGetters(this, ["InspectorUtils"]);
|
XPCOMUtils.defineLazyGlobalGetters(this, ["InspectorUtils"]);
|
||||||
|
|
||||||
|
|
@ -97,10 +107,12 @@ class PictureInPictureToggleChild extends ActorChild {
|
||||||
|
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case "canplay": {
|
case "canplay": {
|
||||||
if (this.toggleEnabled &&
|
if (
|
||||||
event.target instanceof this.content.HTMLVideoElement &&
|
this.toggleEnabled &&
|
||||||
!event.target.controls &&
|
event.target instanceof this.content.HTMLVideoElement &&
|
||||||
event.target.ownerDocument == this.content.document) {
|
!event.target.controls &&
|
||||||
|
event.target.ownerDocument == this.content.document
|
||||||
|
) {
|
||||||
this.registerVideo(event.target);
|
this.registerVideo(event.target);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -229,29 +241,37 @@ class PictureInPictureToggleChild extends ActorChild {
|
||||||
// part of the outer window, we need to also remove it in a
|
// part of the outer window, we need to also remove it in a
|
||||||
// pagehide event listener in the event that the page unloads
|
// pagehide event listener in the event that the page unloads
|
||||||
// before stopTrackingMouseOverVideos fires.
|
// before stopTrackingMouseOverVideos fires.
|
||||||
this.content.windowRoot.addEventListener("pointerdown", this,
|
this.content.windowRoot.addEventListener("pointerdown", this, {
|
||||||
{ capture: true });
|
capture: true,
|
||||||
this.content.windowRoot.addEventListener("mousedown", this,
|
});
|
||||||
{ capture: true });
|
this.content.windowRoot.addEventListener("mousedown", this, {
|
||||||
this.content.windowRoot.addEventListener("mouseup", this,
|
capture: true,
|
||||||
{ capture: true });
|
});
|
||||||
this.content.windowRoot.addEventListener("pointerup", this,
|
this.content.windowRoot.addEventListener("mouseup", this, {
|
||||||
{ capture: true });
|
capture: true,
|
||||||
this.content.windowRoot.addEventListener("click", this,
|
});
|
||||||
{ capture: true });
|
this.content.windowRoot.addEventListener("pointerup", this, {
|
||||||
|
capture: true,
|
||||||
|
});
|
||||||
|
this.content.windowRoot.addEventListener("click", this, { capture: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
removeMouseButtonListeners() {
|
removeMouseButtonListeners() {
|
||||||
this.content.windowRoot.removeEventListener("pointerdown", this,
|
this.content.windowRoot.removeEventListener("pointerdown", this, {
|
||||||
{ capture: true });
|
capture: true,
|
||||||
this.content.windowRoot.removeEventListener("mousedown", this,
|
});
|
||||||
{ capture: true });
|
this.content.windowRoot.removeEventListener("mousedown", this, {
|
||||||
this.content.windowRoot.removeEventListener("mouseup", this,
|
capture: true,
|
||||||
{ capture: true });
|
});
|
||||||
this.content.windowRoot.removeEventListener("pointerup", this,
|
this.content.windowRoot.removeEventListener("mouseup", this, {
|
||||||
{ capture: true });
|
capture: true,
|
||||||
this.content.windowRoot.removeEventListener("click", this,
|
});
|
||||||
{ capture: true });
|
this.content.windowRoot.removeEventListener("pointerup", this, {
|
||||||
|
capture: true,
|
||||||
|
});
|
||||||
|
this.content.windowRoot.removeEventListener("click", this, {
|
||||||
|
capture: true,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -274,8 +294,10 @@ class PictureInPictureToggleChild extends ActorChild {
|
||||||
this.checkLastMouseMove();
|
this.checkLastMouseMove();
|
||||||
}, MOUSEMOVE_PROCESSING_DELAY_MS);
|
}, MOUSEMOVE_PROCESSING_DELAY_MS);
|
||||||
}
|
}
|
||||||
this.content.document.addEventListener("mousemove", this,
|
this.content.document.addEventListener("mousemove", this, {
|
||||||
{ mozSystemGroup: true, capture: true });
|
mozSystemGroup: true,
|
||||||
|
capture: true,
|
||||||
|
});
|
||||||
this.addMouseButtonListeners();
|
this.addMouseButtonListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -287,8 +309,10 @@ class PictureInPictureToggleChild extends ActorChild {
|
||||||
stopTrackingMouseOverVideos() {
|
stopTrackingMouseOverVideos() {
|
||||||
let state = this.docState;
|
let state = this.docState;
|
||||||
state.mousemoveDeferredTask.disarm();
|
state.mousemoveDeferredTask.disarm();
|
||||||
this.content.document.removeEventListener("mousemove", this,
|
this.content.document.removeEventListener("mousemove", this, {
|
||||||
{ mozSystemGroup: true, capture: true });
|
mozSystemGroup: true,
|
||||||
|
capture: true,
|
||||||
|
});
|
||||||
this.removeMouseButtonListeners();
|
this.removeMouseButtonListeners();
|
||||||
let oldOverVideo = state.weakOverVideo && state.weakOverVideo.get();
|
let oldOverVideo = state.weakOverVideo && state.weakOverVideo.get();
|
||||||
if (oldOverVideo) {
|
if (oldOverVideo) {
|
||||||
|
|
@ -329,8 +353,17 @@ class PictureInPictureToggleChild extends ActorChild {
|
||||||
// We pass the aOnlyVisible boolean argument to check that the video isn't
|
// We pass the aOnlyVisible boolean argument to check that the video isn't
|
||||||
// occluded by anything visible at the point of mousedown. If it is, we'll
|
// occluded by anything visible at the point of mousedown. If it is, we'll
|
||||||
// ignore the mousedown.
|
// ignore the mousedown.
|
||||||
let elements = winUtils.nodesFromRect(clientX, clientY, 1, 1, 1, 1, true,
|
let elements = winUtils.nodesFromRect(
|
||||||
false, true /* aOnlyVisible */);
|
clientX,
|
||||||
|
clientY,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
true /* aOnlyVisible */
|
||||||
|
);
|
||||||
if (!Array.from(elements).includes(video)) {
|
if (!Array.from(elements).includes(video)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -341,12 +374,15 @@ class PictureInPictureToggleChild extends ActorChild {
|
||||||
state.clickedElement = Cu.getWeakReference(event.originalTarget);
|
state.clickedElement = Cu.getWeakReference(event.originalTarget);
|
||||||
event.stopImmediatePropagation();
|
event.stopImmediatePropagation();
|
||||||
|
|
||||||
Services.telemetry.keyedScalarAdd("pictureinpicture.opened_method", "toggle", 1);
|
Services.telemetry.keyedScalarAdd(
|
||||||
|
"pictureinpicture.opened_method",
|
||||||
|
"toggle",
|
||||||
|
1
|
||||||
|
);
|
||||||
|
|
||||||
let pipEvent =
|
let pipEvent = new this.content.CustomEvent("MozTogglePictureInPicture", {
|
||||||
new this.content.CustomEvent("MozTogglePictureInPicture", {
|
bubbles: true,
|
||||||
bubbles: true,
|
});
|
||||||
});
|
|
||||||
video.dispatchEvent(pipEvent);
|
video.dispatchEvent(pipEvent);
|
||||||
|
|
||||||
// Since we've initiated Picture-in-Picture, we can go ahead and
|
// Since we've initiated Picture-in-Picture, we can go ahead and
|
||||||
|
|
@ -379,7 +415,7 @@ class PictureInPictureToggleChild extends ActorChild {
|
||||||
let isMouseUpOnOtherElement =
|
let isMouseUpOnOtherElement =
|
||||||
event.type == "mouseup" &&
|
event.type == "mouseup" &&
|
||||||
(!state.clickedElement ||
|
(!state.clickedElement ||
|
||||||
state.clickedElement.get() != event.originalTarget);
|
state.clickedElement.get() != event.originalTarget);
|
||||||
|
|
||||||
if (isMouseUpOnOtherElement || event.type == "click") {
|
if (isMouseUpOnOtherElement || event.type == "click") {
|
||||||
// The click is complete, so now we reset the state so that
|
// The click is complete, so now we reset the state so that
|
||||||
|
|
@ -416,12 +452,23 @@ class PictureInPictureToggleChild extends ActorChild {
|
||||||
// We use winUtils.nodesFromRect instead of document.elementsFromPoint,
|
// We use winUtils.nodesFromRect instead of document.elementsFromPoint,
|
||||||
// since document.elementsFromPoint always flushes layout. The 1's in that
|
// since document.elementsFromPoint always flushes layout. The 1's in that
|
||||||
// function call are for the size of the rect that we want, which is 1x1.
|
// function call are for the size of the rect that we want, which is 1x1.
|
||||||
let elements = winUtils.nodesFromRect(clientX, clientY, 1, 1, 1, 1, true,
|
let elements = winUtils.nodesFromRect(
|
||||||
false, false);
|
clientX,
|
||||||
|
clientY,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
1,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
for (let element of elements) {
|
for (let element of elements) {
|
||||||
if (state.weakVisibleVideos.has(element) &&
|
if (
|
||||||
!element.isCloningElementVisually) {
|
state.weakVisibleVideos.has(element) &&
|
||||||
|
!element.isCloningElementVisually
|
||||||
|
) {
|
||||||
this.onMouseOverVideo(element, event);
|
this.onMouseOverVideo(element, event);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -527,13 +574,16 @@ class PictureInPictureToggleChild extends ActorChild {
|
||||||
* @return {Boolean}
|
* @return {Boolean}
|
||||||
*/
|
*/
|
||||||
isMouseOverToggle(toggle, event) {
|
isMouseOverToggle(toggle, event) {
|
||||||
let toggleRect =
|
let toggleRect = toggle.ownerGlobal.windowUtils.getBoundsWithoutFlushing(
|
||||||
toggle.ownerGlobal.windowUtils.getBoundsWithoutFlushing(toggle);
|
toggle
|
||||||
|
);
|
||||||
let { clientX, clientY } = event;
|
let { clientX, clientY } = event;
|
||||||
return clientX >= toggleRect.left &&
|
return (
|
||||||
clientX <= toggleRect.right &&
|
clientX >= toggleRect.left &&
|
||||||
clientY >= toggleRect.top &&
|
clientX <= toggleRect.right &&
|
||||||
clientY <= toggleRect.bottom;
|
clientY >= toggleRect.top &&
|
||||||
|
clientY <= toggleRect.bottom
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -547,7 +597,12 @@ class PictureInPictureToggleChild extends ActorChild {
|
||||||
|
|
||||||
class PictureInPictureChild extends ActorChild {
|
class PictureInPictureChild extends ActorChild {
|
||||||
static videoIsPlaying(video) {
|
static videoIsPlaying(video) {
|
||||||
return !!(video.currentTime > 0 && !video.paused && !video.ended && video.readyState > 2);
|
return !!(
|
||||||
|
video.currentTime > 0 &&
|
||||||
|
!video.paused &&
|
||||||
|
!video.ended &&
|
||||||
|
video.readyState > 2
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleEvent(event) {
|
handleEvent(event) {
|
||||||
|
|
@ -660,8 +715,9 @@ class PictureInPictureChild extends ActorChild {
|
||||||
if (this.weakPlayerContent) {
|
if (this.weakPlayerContent) {
|
||||||
if (!this.weakPlayerContent.closed) {
|
if (!this.weakPlayerContent.closed) {
|
||||||
await new Promise(resolve => {
|
await new Promise(resolve => {
|
||||||
this.weakPlayerContent.addEventListener("unload", resolve,
|
this.weakPlayerContent.addEventListener("unload", resolve, {
|
||||||
{ once: true });
|
once: true,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// Nothing should be holding a reference to the Picture-in-Picture
|
// Nothing should be holding a reference to the Picture-in-Picture
|
||||||
|
|
@ -740,9 +796,9 @@ class PictureInPictureChild extends ActorChild {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let webProgress = this.mm
|
let webProgress = this.mm.docShell
|
||||||
.docShell.QueryInterface(Ci.nsIInterfaceRequestor)
|
.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||||
.getInterface(Ci.nsIWebProgress);
|
.getInterface(Ci.nsIWebProgress);
|
||||||
if (webProgress.isLoadingDocument) {
|
if (webProgress.isLoadingDocument) {
|
||||||
await new Promise(resolve => {
|
await new Promise(resolve => {
|
||||||
this.mm.addEventListener("load", resolve, {
|
this.mm.addEventListener("load", resolve, {
|
||||||
|
|
@ -777,12 +833,16 @@ class PictureInPictureChild extends ActorChild {
|
||||||
|
|
||||||
this.trackOriginatingVideo(originatingVideo);
|
this.trackOriginatingVideo(originatingVideo);
|
||||||
|
|
||||||
this.content.addEventListener("unload", () => {
|
this.content.addEventListener(
|
||||||
if (this.weakVideo) {
|
"unload",
|
||||||
this.weakVideo.stopCloningElementVisually();
|
() => {
|
||||||
}
|
if (this.weakVideo) {
|
||||||
gWeakVideo = null;
|
this.weakVideo.stopCloningElementVisually();
|
||||||
}, { once: true });
|
}
|
||||||
|
gWeakVideo = null;
|
||||||
|
},
|
||||||
|
{ once: true }
|
||||||
|
);
|
||||||
|
|
||||||
gWeakPlayerContent = Cu.getWeakReference(this.content);
|
gWeakPlayerContent = Cu.getWeakReference(this.content);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,12 @@
|
||||||
|
|
||||||
var EXPORTED_SYMBOLS = ["PopupBlockingChild"];
|
var EXPORTED_SYMBOLS = ["PopupBlockingChild"];
|
||||||
|
|
||||||
const {ActorChild} = ChromeUtils.import("resource://gre/modules/ActorChild.jsm");
|
const { ActorChild } = ChromeUtils.import(
|
||||||
const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
"resource://gre/modules/ActorChild.jsm"
|
||||||
|
);
|
||||||
|
const { XPCOMUtils } = ChromeUtils.import(
|
||||||
|
"resource://gre/modules/XPCOMUtils.jsm"
|
||||||
|
);
|
||||||
|
|
||||||
class PopupBlockingChild extends ActorChild {
|
class PopupBlockingChild extends ActorChild {
|
||||||
constructor(dispatcher) {
|
constructor(dispatcher) {
|
||||||
|
|
@ -36,7 +40,11 @@ class PopupBlockingChild extends ActorChild {
|
||||||
// If we have a requesting window and the requesting document is
|
// If we have a requesting window and the requesting document is
|
||||||
// still the current document, open the popup.
|
// still the current document, open the popup.
|
||||||
if (dwi && dwi.document == internals.requestingDocument) {
|
if (dwi && dwi.document == internals.requestingDocument) {
|
||||||
dwi.open(data.popupWindowURIspec, data.popupWindowName, data.popupWindowFeatures);
|
dwi.open(
|
||||||
|
data.popupWindowURIspec,
|
||||||
|
data.popupWindowName,
|
||||||
|
data.popupWindowFeatures
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -60,10 +68,12 @@ class PopupBlockingChild extends ActorChild {
|
||||||
popupWindowURIspec = popupWindowURIspec.substring(0, 500);
|
popupWindowURIspec = popupWindowURIspec.substring(0, 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
popupData.push({popupWindowURIspec});
|
popupData.push({ popupWindowURIspec });
|
||||||
}
|
}
|
||||||
|
|
||||||
this.mm.sendAsyncMessage("PopupBlocking:ReplyGetBlockedPopupList", {popupData});
|
this.mm.sendAsyncMessage("PopupBlocking:ReplyGetBlockedPopupList", {
|
||||||
|
popupData,
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -93,7 +103,9 @@ class PopupBlockingChild extends ActorChild {
|
||||||
}
|
}
|
||||||
|
|
||||||
let obj = {
|
let obj = {
|
||||||
popupWindowURIspec: ev.popupWindowURI ? ev.popupWindowURI.spec : "about:blank",
|
popupWindowURIspec: ev.popupWindowURI
|
||||||
|
? ev.popupWindowURI.spec
|
||||||
|
: "about:blank",
|
||||||
popupWindowFeatures: ev.popupWindowFeatures,
|
popupWindowFeatures: ev.popupWindowFeatures,
|
||||||
popupWindowName: ev.popupWindowName,
|
popupWindowName: ev.popupWindowName,
|
||||||
};
|
};
|
||||||
|
|
@ -113,10 +125,15 @@ class PopupBlockingChild extends ActorChild {
|
||||||
let i = 0;
|
let i = 0;
|
||||||
let oldLength = this.popupData.length;
|
let oldLength = this.popupData.length;
|
||||||
while (i < this.popupData.length) {
|
while (i < this.popupData.length) {
|
||||||
let {requestingWindow, requestingDocument} = this.popupDataInternal[i];
|
let { requestingWindow, requestingDocument } = this.popupDataInternal[
|
||||||
|
i
|
||||||
|
];
|
||||||
// Filter out irrelevant reports.
|
// Filter out irrelevant reports.
|
||||||
if (requestingWindow && requestingWindow.document == requestingDocument &&
|
if (
|
||||||
requestingDocument != removedDoc) {
|
requestingWindow &&
|
||||||
|
requestingWindow.document == requestingDocument &&
|
||||||
|
requestingDocument != removedDoc
|
||||||
|
) {
|
||||||
i++;
|
i++;
|
||||||
} else {
|
} else {
|
||||||
this.popupData.splice(i, 1);
|
this.popupData.splice(i, 1);
|
||||||
|
|
@ -134,13 +151,15 @@ class PopupBlockingChild extends ActorChild {
|
||||||
}
|
}
|
||||||
|
|
||||||
updateBlockedPopups(freshPopup) {
|
updateBlockedPopups(freshPopup) {
|
||||||
this.mm.sendAsyncMessage("PopupBlocking:UpdateBlockedPopups",
|
this.mm.sendAsyncMessage("PopupBlocking:UpdateBlockedPopups", {
|
||||||
{
|
count: this.popupData ? this.popupData.length : 0,
|
||||||
count: this.popupData ? this.popupData.length : 0,
|
freshPopup,
|
||||||
freshPopup,
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
XPCOMUtils.defineLazyPreferenceGetter(PopupBlockingChild, "maxReportedPopups",
|
XPCOMUtils.defineLazyPreferenceGetter(
|
||||||
"privacy.popups.maxReported");
|
PopupBlockingChild,
|
||||||
|
"maxReportedPopups",
|
||||||
|
"privacy.popups.maxReported"
|
||||||
|
);
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,16 @@
|
||||||
|
|
||||||
var EXPORTED_SYMBOLS = ["PrintingChild"];
|
var EXPORTED_SYMBOLS = ["PrintingChild"];
|
||||||
|
|
||||||
const {ActorChild} = ChromeUtils.import("resource://gre/modules/ActorChild.jsm");
|
const { ActorChild } = ChromeUtils.import(
|
||||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
"resource://gre/modules/ActorChild.jsm"
|
||||||
|
);
|
||||||
|
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
|
|
||||||
ChromeUtils.defineModuleGetter(this, "ReaderMode",
|
ChromeUtils.defineModuleGetter(
|
||||||
"resource://gre/modules/ReaderMode.jsm");
|
this,
|
||||||
|
"ReaderMode",
|
||||||
|
"resource://gre/modules/ReaderMode.jsm"
|
||||||
|
);
|
||||||
|
|
||||||
class PrintingChild extends ActorChild {
|
class PrintingChild extends ActorChild {
|
||||||
// Bug 1088061: nsPrintJob's DoCommonPrint currently expects the
|
// Bug 1088061: nsPrintJob's DoCommonPrint currently expects the
|
||||||
|
|
@ -21,8 +26,10 @@ class PrintingChild extends ActorChild {
|
||||||
// this hackery.
|
// this hackery.
|
||||||
|
|
||||||
get shouldSavePrintSettings() {
|
get shouldSavePrintSettings() {
|
||||||
return Services.prefs.getBoolPref("print.use_global_printsettings") &&
|
return (
|
||||||
Services.prefs.getBoolPref("print.save_print_settings");
|
Services.prefs.getBoolPref("print.use_global_printsettings") &&
|
||||||
|
Services.prefs.getBoolPref("print.save_print_settings")
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleEvent(event) {
|
handleEvent(event) {
|
||||||
|
|
@ -72,10 +79,12 @@ class PrintingChild extends ActorChild {
|
||||||
let data = message.data;
|
let data = message.data;
|
||||||
switch (message.name) {
|
switch (message.name) {
|
||||||
case "Printing:Preview:Enter": {
|
case "Printing:Preview:Enter": {
|
||||||
this.enterPrintPreview(Services.wm.getOuterWindowWithId(data.windowID),
|
this.enterPrintPreview(
|
||||||
data.simplifiedMode,
|
Services.wm.getOuterWindowWithId(data.windowID),
|
||||||
data.changingBrowsers,
|
data.simplifiedMode,
|
||||||
data.defaultPrinterName);
|
data.changingBrowsers,
|
||||||
|
data.defaultPrinterName
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -90,14 +99,19 @@ class PrintingChild extends ActorChild {
|
||||||
}
|
}
|
||||||
|
|
||||||
case "Printing:Preview:ParseDocument": {
|
case "Printing:Preview:ParseDocument": {
|
||||||
this.parseDocument(data.URL, Services.wm.getOuterWindowWithId(data.windowID));
|
this.parseDocument(
|
||||||
|
data.URL,
|
||||||
|
Services.wm.getOuterWindowWithId(data.windowID)
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case "Printing:Print": {
|
case "Printing:Print": {
|
||||||
this.print(Services.wm.getOuterWindowWithId(data.windowID),
|
this.print(
|
||||||
data.simplifiedMode,
|
Services.wm.getOuterWindowWithId(data.windowID),
|
||||||
data.defaultPrinterName);
|
data.simplifiedMode,
|
||||||
|
data.defaultPrinterName
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -105,19 +119,25 @@ class PrintingChild extends ActorChild {
|
||||||
|
|
||||||
getPrintSettings(defaultPrinterName) {
|
getPrintSettings(defaultPrinterName) {
|
||||||
try {
|
try {
|
||||||
let PSSVC = Cc["@mozilla.org/gfx/printsettings-service;1"]
|
let PSSVC = Cc["@mozilla.org/gfx/printsettings-service;1"].getService(
|
||||||
.getService(Ci.nsIPrintSettingsService);
|
Ci.nsIPrintSettingsService
|
||||||
|
);
|
||||||
|
|
||||||
let printSettings = PSSVC.globalPrintSettings;
|
let printSettings = PSSVC.globalPrintSettings;
|
||||||
if (!printSettings.printerName) {
|
if (!printSettings.printerName) {
|
||||||
printSettings.printerName = defaultPrinterName;
|
printSettings.printerName = defaultPrinterName;
|
||||||
}
|
}
|
||||||
// First get any defaults from the printer
|
// First get any defaults from the printer
|
||||||
PSSVC.initPrintSettingsFromPrinter(printSettings.printerName,
|
PSSVC.initPrintSettingsFromPrinter(
|
||||||
printSettings);
|
printSettings.printerName,
|
||||||
|
printSettings
|
||||||
|
);
|
||||||
// now augment them with any values from last time
|
// now augment them with any values from last time
|
||||||
PSSVC.initPrintSettingsFromPrefs(printSettings, true,
|
PSSVC.initPrintSettingsFromPrefs(
|
||||||
printSettings.kInitSaveAll);
|
printSettings,
|
||||||
|
true,
|
||||||
|
printSettings.kInitSaveAll
|
||||||
|
);
|
||||||
|
|
||||||
return printSettings;
|
return printSettings;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
@ -130,12 +150,14 @@ class PrintingChild extends ActorChild {
|
||||||
parseDocument(URL, contentWindow) {
|
parseDocument(URL, contentWindow) {
|
||||||
// By using ReaderMode primitives, we parse given document and place the
|
// By using ReaderMode primitives, we parse given document and place the
|
||||||
// resulting JS object into the DOM of current browser.
|
// resulting JS object into the DOM of current browser.
|
||||||
let articlePromise = ReaderMode.parseDocument(contentWindow.document).catch(Cu.reportError);
|
let articlePromise = ReaderMode.parseDocument(contentWindow.document).catch(
|
||||||
articlePromise.then((article) => {
|
Cu.reportError
|
||||||
|
);
|
||||||
|
articlePromise.then(article => {
|
||||||
// We make use of a web progress listener in order to know when the content we inject
|
// We make use of a web progress listener in order to know when the content we inject
|
||||||
// into the DOM has finished rendering. If our layout engine is still painting, we
|
// into the DOM has finished rendering. If our layout engine is still painting, we
|
||||||
// will wait for MozAfterPaint event to be fired.
|
// will wait for MozAfterPaint event to be fired.
|
||||||
let {mm} = this;
|
let { mm } = this;
|
||||||
let webProgressListener = {
|
let webProgressListener = {
|
||||||
onStateChange(webProgress, req, flags, status) {
|
onStateChange(webProgress, req, flags, status) {
|
||||||
if (flags & Ci.nsIWebProgressListener.STATE_STOP) {
|
if (flags & Ci.nsIWebProgressListener.STATE_STOP) {
|
||||||
|
|
@ -167,12 +189,16 @@ class PrintingChild extends ActorChild {
|
||||||
]),
|
]),
|
||||||
};
|
};
|
||||||
|
|
||||||
const {content, docShell} = this.mm;
|
const { content, docShell } = this.mm;
|
||||||
|
|
||||||
// Here we QI the docShell into a nsIWebProgress passing our web progress listener in.
|
// Here we QI the docShell into a nsIWebProgress passing our web progress listener in.
|
||||||
let webProgress = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
|
let webProgress = docShell
|
||||||
.getInterface(Ci.nsIWebProgress);
|
.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||||
webProgress.addProgressListener(webProgressListener, Ci.nsIWebProgress.NOTIFY_STATE_REQUEST);
|
.getInterface(Ci.nsIWebProgress);
|
||||||
|
webProgress.addProgressListener(
|
||||||
|
webProgressListener,
|
||||||
|
Ci.nsIWebProgress.NOTIFY_STATE_REQUEST
|
||||||
|
);
|
||||||
|
|
||||||
content.document.head.innerHTML = "";
|
content.document.head.innerHTML = "";
|
||||||
|
|
||||||
|
|
@ -186,14 +212,20 @@ class PrintingChild extends ActorChild {
|
||||||
// Create link element referencing aboutReader.css and append it to head
|
// Create link element referencing aboutReader.css and append it to head
|
||||||
let headStyleElement = content.document.createElement("link");
|
let headStyleElement = content.document.createElement("link");
|
||||||
headStyleElement.setAttribute("rel", "stylesheet");
|
headStyleElement.setAttribute("rel", "stylesheet");
|
||||||
headStyleElement.setAttribute("href", "chrome://global/skin/aboutReader.css");
|
headStyleElement.setAttribute(
|
||||||
|
"href",
|
||||||
|
"chrome://global/skin/aboutReader.css"
|
||||||
|
);
|
||||||
headStyleElement.setAttribute("type", "text/css");
|
headStyleElement.setAttribute("type", "text/css");
|
||||||
content.document.head.appendChild(headStyleElement);
|
content.document.head.appendChild(headStyleElement);
|
||||||
|
|
||||||
// Create link element referencing simplifyMode.css and append it to head
|
// Create link element referencing simplifyMode.css and append it to head
|
||||||
headStyleElement = content.document.createElement("link");
|
headStyleElement = content.document.createElement("link");
|
||||||
headStyleElement.setAttribute("rel", "stylesheet");
|
headStyleElement.setAttribute("rel", "stylesheet");
|
||||||
headStyleElement.setAttribute("href", "chrome://global/content/simplifyMode.css");
|
headStyleElement.setAttribute(
|
||||||
|
"href",
|
||||||
|
"chrome://global/content/simplifyMode.css"
|
||||||
|
);
|
||||||
headStyleElement.setAttribute("type", "text/css");
|
headStyleElement.setAttribute("type", "text/css");
|
||||||
content.document.head.appendChild(headStyleElement);
|
content.document.head.appendChild(headStyleElement);
|
||||||
|
|
||||||
|
|
@ -242,18 +274,29 @@ class PrintingChild extends ActorChild {
|
||||||
contentElement.appendChild(readerContent);
|
contentElement.appendChild(readerContent);
|
||||||
|
|
||||||
let articleUri = Services.io.newURI(article.url);
|
let articleUri = Services.io.newURI(article.url);
|
||||||
let parserUtils = Cc["@mozilla.org/parserutils;1"].getService(Ci.nsIParserUtils);
|
let parserUtils = Cc["@mozilla.org/parserutils;1"].getService(
|
||||||
let contentFragment = parserUtils.parseFragment(article.content,
|
Ci.nsIParserUtils
|
||||||
Ci.nsIParserUtils.SanitizerDropForms | Ci.nsIParserUtils.SanitizerAllowStyle,
|
);
|
||||||
false, articleUri, readerContent);
|
let contentFragment = parserUtils.parseFragment(
|
||||||
|
article.content,
|
||||||
|
Ci.nsIParserUtils.SanitizerDropForms |
|
||||||
|
Ci.nsIParserUtils.SanitizerAllowStyle,
|
||||||
|
false,
|
||||||
|
articleUri,
|
||||||
|
readerContent
|
||||||
|
);
|
||||||
|
|
||||||
readerContent.appendChild(contentFragment);
|
readerContent.appendChild(contentFragment);
|
||||||
|
|
||||||
// Display reader content element
|
// Display reader content element
|
||||||
readerContent.style.display = "block";
|
readerContent.style.display = "block";
|
||||||
} else {
|
} else {
|
||||||
let aboutReaderStrings = Services.strings.createBundle("chrome://global/locale/aboutReader.properties");
|
let aboutReaderStrings = Services.strings.createBundle(
|
||||||
let errorMessage = aboutReaderStrings.GetStringFromName("aboutReader.loadError");
|
"chrome://global/locale/aboutReader.properties"
|
||||||
|
);
|
||||||
|
let errorMessage = aboutReaderStrings.GetStringFromName(
|
||||||
|
"aboutReader.loadError"
|
||||||
|
);
|
||||||
|
|
||||||
content.document.title = errorMessage;
|
content.document.title = errorMessage;
|
||||||
|
|
||||||
|
|
@ -269,16 +312,22 @@ class PrintingChild extends ActorChild {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
enterPrintPreview(contentWindow, simplifiedMode, changingBrowsers, defaultPrinterName) {
|
enterPrintPreview(
|
||||||
const {docShell} = this;
|
contentWindow,
|
||||||
|
simplifiedMode,
|
||||||
|
changingBrowsers,
|
||||||
|
defaultPrinterName
|
||||||
|
) {
|
||||||
|
const { docShell } = this;
|
||||||
try {
|
try {
|
||||||
let printSettings = this.getPrintSettings(defaultPrinterName);
|
let printSettings = this.getPrintSettings(defaultPrinterName);
|
||||||
|
|
||||||
// If we happen to be on simplified mode, we need to set docURL in order
|
// If we happen to be on simplified mode, we need to set docURL in order
|
||||||
// to generate header/footer content correctly, since simplified tab has
|
// to generate header/footer content correctly, since simplified tab has
|
||||||
// "about:blank" as its URI.
|
// "about:blank" as its URI.
|
||||||
if (printSettings && simplifiedMode)
|
if (printSettings && simplifiedMode) {
|
||||||
printSettings.docURL = contentWindow.document.baseURI;
|
printSettings.docURL = contentWindow.document.baseURI;
|
||||||
|
}
|
||||||
|
|
||||||
// The print preview docshell will be in a different TabGroup, so
|
// The print preview docshell will be in a different TabGroup, so
|
||||||
// printPreviewInitialize must be run in a separate runnable to avoid
|
// printPreviewInitialize must be run in a separate runnable to avoid
|
||||||
|
|
@ -288,13 +337,17 @@ class PrintingChild extends ActorChild {
|
||||||
let listener = new PrintingListener(this.mm);
|
let listener = new PrintingListener(this.mm);
|
||||||
|
|
||||||
this.printPreviewInitializingInfo = { changingBrowsers };
|
this.printPreviewInitializingInfo = { changingBrowsers };
|
||||||
docShell.initOrReusePrintPreviewViewer().printPreview(printSettings, contentWindow, listener);
|
docShell
|
||||||
|
.initOrReusePrintPreviewViewer()
|
||||||
|
.printPreview(printSettings, contentWindow, listener);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// This might fail if we, for example, attempt to print a XUL document.
|
// This might fail if we, for example, attempt to print a XUL document.
|
||||||
// In that case, we inform the parent to bail out of print preview.
|
// In that case, we inform the parent to bail out of print preview.
|
||||||
Cu.reportError(error);
|
Cu.reportError(error);
|
||||||
this.printPreviewInitializingInfo = null;
|
this.printPreviewInitializingInfo = null;
|
||||||
this.mm.sendAsyncMessage("Printing:Preview:Entered", { failed: true });
|
this.mm.sendAsyncMessage("Printing:Preview:Entered", {
|
||||||
|
failed: true,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -302,8 +355,10 @@ class PrintingChild extends ActorChild {
|
||||||
// initial setup of a previous preview request. We delay this one until
|
// initial setup of a previous preview request. We delay this one until
|
||||||
// that has finished because running them at the same time will almost
|
// that has finished because running them at the same time will almost
|
||||||
// certainly cause failures.
|
// certainly cause failures.
|
||||||
if (this.printPreviewInitializingInfo &&
|
if (
|
||||||
!this.printPreviewInitializingInfo.entered) {
|
this.printPreviewInitializingInfo &&
|
||||||
|
!this.printPreviewInitializingInfo.entered
|
||||||
|
) {
|
||||||
this.printPreviewInitializingInfo.nextRequest = printPreviewInitialize;
|
this.printPreviewInitializingInfo.nextRequest = printPreviewInitialize;
|
||||||
} else {
|
} else {
|
||||||
Services.tm.dispatchToMainThread(printPreviewInitialize);
|
Services.tm.dispatchToMainThread(printPreviewInitialize);
|
||||||
|
|
@ -367,15 +422,24 @@ class PrintingChild extends ActorChild {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!printCancelled || printSettings.saveOnCancel) &&
|
if (
|
||||||
this.shouldSavePrintSettings) {
|
(!printCancelled || printSettings.saveOnCancel) &&
|
||||||
let PSSVC = Cc["@mozilla.org/gfx/printsettings-service;1"]
|
this.shouldSavePrintSettings
|
||||||
.getService(Ci.nsIPrintSettingsService);
|
) {
|
||||||
|
let PSSVC = Cc["@mozilla.org/gfx/printsettings-service;1"].getService(
|
||||||
|
Ci.nsIPrintSettingsService
|
||||||
|
);
|
||||||
|
|
||||||
PSSVC.savePrintSettingsToPrefs(printSettings, true,
|
PSSVC.savePrintSettingsToPrefs(
|
||||||
printSettings.kInitSaveAll);
|
printSettings,
|
||||||
PSSVC.savePrintSettingsToPrefs(printSettings, false,
|
true,
|
||||||
printSettings.kInitSavePrinterName);
|
printSettings.kInitSaveAll
|
||||||
|
);
|
||||||
|
PSSVC.savePrintSettingsToPrefs(
|
||||||
|
printSettings,
|
||||||
|
false,
|
||||||
|
printSettings.kInitSavePrinterName
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -385,19 +449,23 @@ class PrintingChild extends ActorChild {
|
||||||
}
|
}
|
||||||
|
|
||||||
updatePageCount() {
|
updatePageCount() {
|
||||||
let numPages = this.docShell.initOrReusePrintPreviewViewer().printPreviewNumPages;
|
let numPages = this.docShell.initOrReusePrintPreviewViewer()
|
||||||
|
.printPreviewNumPages;
|
||||||
this.mm.sendAsyncMessage("Printing:Preview:UpdatePageCount", {
|
this.mm.sendAsyncMessage("Printing:Preview:UpdatePageCount", {
|
||||||
numPages,
|
numPages,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
navigate(navType, pageNum) {
|
navigate(navType, pageNum) {
|
||||||
this.docShell.initOrReusePrintPreviewViewer().printPreviewScrollToPage(navType, pageNum);
|
this.docShell
|
||||||
|
.initOrReusePrintPreviewViewer()
|
||||||
|
.printPreviewScrollToPage(navType, pageNum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintingChild.prototype.QueryInterface =
|
PrintingChild.prototype.QueryInterface = ChromeUtils.generateQI([
|
||||||
ChromeUtils.generateQI([Ci.nsIPrintingPromptService]);
|
Ci.nsIPrintingPromptService,
|
||||||
|
]);
|
||||||
|
|
||||||
function PrintingListener(global) {
|
function PrintingListener(global) {
|
||||||
this.global = global;
|
this.global = global;
|
||||||
|
|
@ -412,9 +480,14 @@ PrintingListener.prototype = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onProgressChange(aWebProgress, aRequest, aCurSelfProgress,
|
onProgressChange(
|
||||||
aMaxSelfProgress, aCurTotalProgress,
|
aWebProgress,
|
||||||
aMaxTotalProgress) {
|
aRequest,
|
||||||
|
aCurSelfProgress,
|
||||||
|
aMaxSelfProgress,
|
||||||
|
aCurTotalProgress,
|
||||||
|
aMaxTotalProgress
|
||||||
|
) {
|
||||||
this.global.sendAsyncMessage("Printing:Preview:ProgressChange", {
|
this.global.sendAsyncMessage("Printing:Preview:ProgressChange", {
|
||||||
curSelfProgress: aCurSelfProgress,
|
curSelfProgress: aCurSelfProgress,
|
||||||
maxSelfProgress: aMaxSelfProgress,
|
maxSelfProgress: aMaxSelfProgress,
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,17 @@
|
||||||
|
|
||||||
var EXPORTED_SYMBOLS = ["PurgeSessionHistoryChild"];
|
var EXPORTED_SYMBOLS = ["PurgeSessionHistoryChild"];
|
||||||
|
|
||||||
const {ActorChild} = ChromeUtils.import("resource://gre/modules/ActorChild.jsm");
|
const { ActorChild } = ChromeUtils.import(
|
||||||
|
"resource://gre/modules/ActorChild.jsm"
|
||||||
|
);
|
||||||
|
|
||||||
class PurgeSessionHistoryChild extends ActorChild {
|
class PurgeSessionHistoryChild extends ActorChild {
|
||||||
receiveMessage(message) {
|
receiveMessage(message) {
|
||||||
if (message.name != "Browser:PurgeSessionHistory") {
|
if (message.name != "Browser:PurgeSessionHistory") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let sessionHistory = this.docShell.QueryInterface(Ci.nsIWebNavigation).sessionHistory;
|
let sessionHistory = this.docShell.QueryInterface(Ci.nsIWebNavigation)
|
||||||
|
.sessionHistory;
|
||||||
if (!sessionHistory) {
|
if (!sessionHistory) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,20 @@
|
||||||
|
|
||||||
var EXPORTED_SYMBOLS = ["SelectChild"];
|
var EXPORTED_SYMBOLS = ["SelectChild"];
|
||||||
|
|
||||||
const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
const { XPCOMUtils } = ChromeUtils.import(
|
||||||
|
"resource://gre/modules/XPCOMUtils.jsm"
|
||||||
|
);
|
||||||
|
|
||||||
ChromeUtils.defineModuleGetter(this, "BrowserUtils",
|
ChromeUtils.defineModuleGetter(
|
||||||
"resource://gre/modules/BrowserUtils.jsm");
|
this,
|
||||||
ChromeUtils.defineModuleGetter(this, "DeferredTask",
|
"BrowserUtils",
|
||||||
"resource://gre/modules/DeferredTask.jsm");
|
"resource://gre/modules/BrowserUtils.jsm"
|
||||||
|
);
|
||||||
|
ChromeUtils.defineModuleGetter(
|
||||||
|
this,
|
||||||
|
"DeferredTask",
|
||||||
|
"resource://gre/modules/DeferredTask.jsm"
|
||||||
|
);
|
||||||
|
|
||||||
XPCOMUtils.defineLazyGlobalGetters(this, ["InspectorUtils"]);
|
XPCOMUtils.defineLazyGlobalGetters(this, ["InspectorUtils"]);
|
||||||
|
|
||||||
|
|
@ -60,7 +68,9 @@ this.SelectContentHelper.prototype = {
|
||||||
let win = this.element.ownerGlobal;
|
let win = this.element.ownerGlobal;
|
||||||
win.addEventListener("pagehide", this, { mozSystemGroup: true });
|
win.addEventListener("pagehide", this, { mozSystemGroup: true });
|
||||||
this.element.addEventListener("blur", this, { mozSystemGroup: true });
|
this.element.addEventListener("blur", this, { mozSystemGroup: true });
|
||||||
this.element.addEventListener("transitionend", this, { mozSystemGroup: true });
|
this.element.addEventListener("transitionend", this, {
|
||||||
|
mozSystemGroup: true,
|
||||||
|
});
|
||||||
let MutationObserver = this.element.ownerGlobal.MutationObserver;
|
let MutationObserver = this.element.ownerGlobal.MutationObserver;
|
||||||
this.mut = new MutationObserver(mutations => {
|
this.mut = new MutationObserver(mutations => {
|
||||||
// Something changed the <select> while it was open, so
|
// Something changed the <select> while it was open, so
|
||||||
|
|
@ -68,7 +78,11 @@ this.SelectContentHelper.prototype = {
|
||||||
// in the very near future.
|
// in the very near future.
|
||||||
this._updateTimer.arm();
|
this._updateTimer.arm();
|
||||||
});
|
});
|
||||||
this.mut.observe(this.element, {childList: true, subtree: true, attributes: true});
|
this.mut.observe(this.element, {
|
||||||
|
childList: true,
|
||||||
|
subtree: true,
|
||||||
|
attributes: true,
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
uninit() {
|
uninit() {
|
||||||
|
|
@ -76,7 +90,9 @@ this.SelectContentHelper.prototype = {
|
||||||
let win = this.element.ownerGlobal;
|
let win = this.element.ownerGlobal;
|
||||||
win.removeEventListener("pagehide", this, { mozSystemGroup: true });
|
win.removeEventListener("pagehide", this, { mozSystemGroup: true });
|
||||||
this.element.removeEventListener("blur", this, { mozSystemGroup: true });
|
this.element.removeEventListener("blur", this, { mozSystemGroup: true });
|
||||||
this.element.removeEventListener("transitionend", this, { mozSystemGroup: true });
|
this.element.removeEventListener("transitionend", this, {
|
||||||
|
mozSystemGroup: true,
|
||||||
|
});
|
||||||
this.element = null;
|
this.element = null;
|
||||||
this.actor = null;
|
this.actor = null;
|
||||||
this.mut.disconnect();
|
this.mut.disconnect();
|
||||||
|
|
@ -91,7 +107,9 @@ this.SelectContentHelper.prototype = {
|
||||||
let rect = this._getBoundingContentRect();
|
let rect = this._getBoundingContentRect();
|
||||||
let computedStyles = getComputedStyles(this.element);
|
let computedStyles = getComputedStyles(this.element);
|
||||||
let options = this._buildOptionList();
|
let options = this._buildOptionList();
|
||||||
let defaultStyles = this.element.ownerGlobal.getDefaultComputedStyle(this.element);
|
let defaultStyles = this.element.ownerGlobal.getDefaultComputedStyle(
|
||||||
|
this.element
|
||||||
|
);
|
||||||
this.actor.sendAsyncMessage("Forms:ShowDropDown", {
|
this.actor.sendAsyncMessage("Forms:ShowDropDown", {
|
||||||
isOpenedViaTouch: this.isOpenedViaTouch,
|
isOpenedViaTouch: this.isOpenedViaTouch,
|
||||||
options,
|
options,
|
||||||
|
|
@ -112,7 +130,9 @@ this.SelectContentHelper.prototype = {
|
||||||
// any styles.
|
// any styles.
|
||||||
this._pseudoStylesSetup = true;
|
this._pseudoStylesSetup = true;
|
||||||
InspectorUtils.addPseudoClassLock(this.element, ":focus");
|
InspectorUtils.addPseudoClassLock(this.element, ":focus");
|
||||||
let lockedDescendants = this._lockedDescendants = this.element.querySelectorAll(":checked");
|
let lockedDescendants = (this._lockedDescendants = this.element.querySelectorAll(
|
||||||
|
":checked"
|
||||||
|
));
|
||||||
for (let child of lockedDescendants) {
|
for (let child of lockedDescendants) {
|
||||||
// Selected options have the :checked pseudo-class, which
|
// Selected options have the :checked pseudo-class, which
|
||||||
// we want to disable before calculating the computed
|
// we want to disable before calculating the computed
|
||||||
|
|
@ -158,7 +178,9 @@ this.SelectContentHelper.prototype = {
|
||||||
// have :focus, though it is here for belt-and-suspenders.
|
// have :focus, though it is here for belt-and-suspenders.
|
||||||
this._setupPseudoClassStyles();
|
this._setupPseudoClassStyles();
|
||||||
let computedStyles = getComputedStyles(this.element);
|
let computedStyles = getComputedStyles(this.element);
|
||||||
let defaultStyles = this.element.ownerGlobal.getDefaultComputedStyle(this.element);
|
let defaultStyles = this.element.ownerGlobal.getDefaultComputedStyle(
|
||||||
|
this.element
|
||||||
|
);
|
||||||
this.actor.sendAsyncMessage("Forms:UpdateDropDown", {
|
this.actor.sendAsyncMessage("Forms:UpdateDropDown", {
|
||||||
options: this._buildOptionList(),
|
options: this._buildOptionList(),
|
||||||
selectedIndex: this.element.selectedIndex,
|
selectedIndex: this.element.selectedIndex,
|
||||||
|
|
@ -185,52 +207,55 @@ this.SelectContentHelper.prototype = {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "Forms:DismissedDropDown": {
|
case "Forms:DismissedDropDown": {
|
||||||
if (!this.element) {
|
if (!this.element) {
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
let win = this.element.ownerGlobal;
|
|
||||||
let selectedOption = this.element.item(this.element.selectedIndex);
|
|
||||||
|
|
||||||
// For ordering of events, we're using non-e10s as our guide here,
|
|
||||||
// since the spec isn't exactly clear. In non-e10s:
|
|
||||||
// - If the user clicks on an element in the dropdown, we fire
|
|
||||||
// mousedown, mouseup, input, change, and click events.
|
|
||||||
// - If the user uses the keyboard to select an element in the
|
|
||||||
// dropdown, we only fire input and change events.
|
|
||||||
// - If the user pressed ESC key or clicks outside the dropdown,
|
|
||||||
// we fire nothing as the selected option is unchanged.
|
|
||||||
if (this.closedWithClickOn) {
|
|
||||||
this.dispatchMouseEvent(win, selectedOption, "mousedown");
|
|
||||||
this.dispatchMouseEvent(win, selectedOption, "mouseup");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clear active document no matter user selects via keyboard or mouse
|
|
||||||
InspectorUtils.removeContentState(this.element, kStateActive,
|
|
||||||
/* aClearActiveDocument */ true);
|
|
||||||
|
|
||||||
// Fire input and change events when selected option changes
|
|
||||||
if (this.initialSelection !== selectedOption) {
|
|
||||||
let inputEvent = new win.Event("input", {
|
|
||||||
bubbles: true,
|
|
||||||
});
|
|
||||||
this.element.dispatchEvent(inputEvent);
|
|
||||||
|
|
||||||
let changeEvent = new win.Event("change", {
|
|
||||||
bubbles: true,
|
|
||||||
});
|
|
||||||
this.element.dispatchEvent(changeEvent);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fire click event
|
|
||||||
if (this.closedWithClickOn) {
|
|
||||||
this.dispatchMouseEvent(win, selectedOption, "click");
|
|
||||||
}
|
|
||||||
|
|
||||||
this.uninit();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let win = this.element.ownerGlobal;
|
||||||
|
let selectedOption = this.element.item(this.element.selectedIndex);
|
||||||
|
|
||||||
|
// For ordering of events, we're using non-e10s as our guide here,
|
||||||
|
// since the spec isn't exactly clear. In non-e10s:
|
||||||
|
// - If the user clicks on an element in the dropdown, we fire
|
||||||
|
// mousedown, mouseup, input, change, and click events.
|
||||||
|
// - If the user uses the keyboard to select an element in the
|
||||||
|
// dropdown, we only fire input and change events.
|
||||||
|
// - If the user pressed ESC key or clicks outside the dropdown,
|
||||||
|
// we fire nothing as the selected option is unchanged.
|
||||||
|
if (this.closedWithClickOn) {
|
||||||
|
this.dispatchMouseEvent(win, selectedOption, "mousedown");
|
||||||
|
this.dispatchMouseEvent(win, selectedOption, "mouseup");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear active document no matter user selects via keyboard or mouse
|
||||||
|
InspectorUtils.removeContentState(
|
||||||
|
this.element,
|
||||||
|
kStateActive,
|
||||||
|
/* aClearActiveDocument */ true
|
||||||
|
);
|
||||||
|
|
||||||
|
// Fire input and change events when selected option changes
|
||||||
|
if (this.initialSelection !== selectedOption) {
|
||||||
|
let inputEvent = new win.Event("input", {
|
||||||
|
bubbles: true,
|
||||||
|
});
|
||||||
|
this.element.dispatchEvent(inputEvent);
|
||||||
|
|
||||||
|
let changeEvent = new win.Event("change", {
|
||||||
|
bubbles: true,
|
||||||
|
});
|
||||||
|
this.element.dispatchEvent(changeEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fire click event
|
||||||
|
if (this.closedWithClickOn) {
|
||||||
|
this.dispatchMouseEvent(win, selectedOption, "click");
|
||||||
|
}
|
||||||
|
|
||||||
|
this.uninit();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case "Forms:MouseOver":
|
case "Forms:MouseOver":
|
||||||
InspectorUtils.setContentState(this.element, kStateHover);
|
InspectorUtils.setContentState(this.element, kStateHover);
|
||||||
break;
|
break;
|
||||||
|
|
@ -342,8 +367,7 @@ function buildOptionListForChildren(node, uniqueStyles) {
|
||||||
}
|
}
|
||||||
|
|
||||||
let textContent =
|
let textContent =
|
||||||
tagName == "OPTGROUP" ? child.getAttribute("label")
|
tagName == "OPTGROUP" ? child.getAttribute("label") : child.text;
|
||||||
: child.text;
|
|
||||||
if (textContent == null) {
|
if (textContent == null) {
|
||||||
textContent = "";
|
textContent = "";
|
||||||
}
|
}
|
||||||
|
|
@ -356,9 +380,10 @@ function buildOptionListForChildren(node, uniqueStyles) {
|
||||||
disabled: child.disabled,
|
disabled: child.disabled,
|
||||||
display: cs.display,
|
display: cs.display,
|
||||||
tooltip: child.title,
|
tooltip: child.title,
|
||||||
children: tagName == "OPTGROUP"
|
children:
|
||||||
? buildOptionListForChildren(child, uniqueStyles)
|
tagName == "OPTGROUP"
|
||||||
: [],
|
? buildOptionListForChildren(child, uniqueStyles)
|
||||||
|
: [],
|
||||||
// Most options have the same style. In order to reduce the size of the
|
// Most options have the same style. In order to reduce the size of the
|
||||||
// IPC message, coalesce them in uniqueStyles.
|
// IPC message, coalesce them in uniqueStyles.
|
||||||
styleIndex: uniqueStylesIndex(cs, uniqueStyles),
|
styleIndex: uniqueStylesIndex(cs, uniqueStyles),
|
||||||
|
|
@ -370,7 +395,6 @@ function buildOptionListForChildren(node, uniqueStyles) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Hold the instance of SelectContentHelper created
|
// Hold the instance of SelectContentHelper created
|
||||||
// when the dropdown list is opened. This variable helps
|
// when the dropdown list is opened. This variable helps
|
||||||
// re-route the received message from SelectChild to SelectContentHelper object.
|
// re-route the received message from SelectChild to SelectContentHelper object.
|
||||||
|
|
@ -389,19 +413,25 @@ class SelectChild extends JSWindowActorChild {
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case "mozshowdropdown":
|
case "mozshowdropdown": {
|
||||||
{
|
let contentHelper = new SelectContentHelper(
|
||||||
let contentHelper = new SelectContentHelper(event.target, {isOpenedViaTouch: false}, this);
|
event.target,
|
||||||
currentSelectContentHelper.set(this, contentHelper);
|
{ isOpenedViaTouch: false },
|
||||||
break;
|
this
|
||||||
}
|
);
|
||||||
|
currentSelectContentHelper.set(this, contentHelper);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case "mozshowdropdown-sourcetouch":
|
case "mozshowdropdown-sourcetouch": {
|
||||||
{
|
let contentHelper = new SelectContentHelper(
|
||||||
let contentHelper = new SelectContentHelper(event.target, {isOpenedViaTouch: true}, this);
|
event.target,
|
||||||
currentSelectContentHelper.set(this, contentHelper);
|
{ isOpenedViaTouch: true },
|
||||||
break;
|
this
|
||||||
}
|
);
|
||||||
|
currentSelectContentHelper.set(this, contentHelper);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,13 +4,12 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var EXPORTED_SYMBOLS = [
|
var EXPORTED_SYMBOLS = ["SelectParent", "SelectParentHelper"];
|
||||||
"SelectParent",
|
|
||||||
"SelectParentHelper",
|
|
||||||
];
|
|
||||||
|
|
||||||
const {AppConstants} = ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
|
const { AppConstants } = ChromeUtils.import(
|
||||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
"resource://gre/modules/AppConstants.jsm"
|
||||||
|
);
|
||||||
|
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
|
|
||||||
// Maximum number of rows to display in the select dropdown.
|
// Maximum number of rows to display in the select dropdown.
|
||||||
const MAX_ROWS = 20;
|
const MAX_ROWS = 20;
|
||||||
|
|
@ -25,7 +24,9 @@ const PROPERTIES_RESET_WHEN_ACTIVE = [
|
||||||
"text-shadow",
|
"text-shadow",
|
||||||
];
|
];
|
||||||
|
|
||||||
const customStylingEnabled = Services.prefs.getBoolPref("dom.forms.select.customstyling");
|
const customStylingEnabled = Services.prefs.getBoolPref(
|
||||||
|
"dom.forms.select.customstyling"
|
||||||
|
);
|
||||||
|
|
||||||
var SelectParentHelper = {
|
var SelectParentHelper = {
|
||||||
/**
|
/**
|
||||||
|
|
@ -59,8 +60,15 @@ var SelectParentHelper = {
|
||||||
* FIXME(emilio, bug 1530709): At the very least we should use CSSOM to avoid
|
* FIXME(emilio, bug 1530709): At the very least we should use CSSOM to avoid
|
||||||
* trusting the IPC message too much.
|
* trusting the IPC message too much.
|
||||||
*/
|
*/
|
||||||
populate(menulist, items, uniqueItemStyles, selectedIndex, zoom,
|
populate(
|
||||||
uaStyle, selectStyle) {
|
menulist,
|
||||||
|
items,
|
||||||
|
uniqueItemStyles,
|
||||||
|
selectedIndex,
|
||||||
|
zoom,
|
||||||
|
uaStyle,
|
||||||
|
selectStyle
|
||||||
|
) {
|
||||||
// Clear the current contents of the popup
|
// Clear the current contents of the popup
|
||||||
menulist.menupopup.textContent = "";
|
menulist.menupopup.textContent = "";
|
||||||
let stylesheet = menulist.querySelector("#ContentSelectDropdownStylesheet");
|
let stylesheet = menulist.querySelector("#ContentSelectDropdownStylesheet");
|
||||||
|
|
@ -88,8 +96,10 @@ var SelectParentHelper = {
|
||||||
|
|
||||||
// Some webpages set the <select> backgroundColor to transparent,
|
// Some webpages set the <select> backgroundColor to transparent,
|
||||||
// but they don't intend to change the popup to transparent.
|
// but they don't intend to change the popup to transparent.
|
||||||
if (customStylingEnabled &&
|
if (
|
||||||
selectStyle["background-color"] != uaStyle["background-color"]) {
|
customStylingEnabled &&
|
||||||
|
selectStyle["background-color"] != uaStyle["background-color"]
|
||||||
|
) {
|
||||||
let color = selectStyle["background-color"];
|
let color = selectStyle["background-color"];
|
||||||
selectStyle["background-image"] = `linear-gradient(${color}, ${color});`;
|
selectStyle["background-image"] = `linear-gradient(${color}, ${color});`;
|
||||||
selectBackgroundSet = true;
|
selectBackgroundSet = true;
|
||||||
|
|
@ -101,26 +111,36 @@ var SelectParentHelper = {
|
||||||
|
|
||||||
if (customStylingEnabled) {
|
if (customStylingEnabled) {
|
||||||
if (selectStyle["text-shadow"] != "none") {
|
if (selectStyle["text-shadow"] != "none") {
|
||||||
sheet.insertRule(`#ContentSelectDropdown > menupopup > [_moz-menuactive="true"] {
|
sheet.insertRule(
|
||||||
|
`#ContentSelectDropdown > menupopup > [_moz-menuactive="true"] {
|
||||||
text-shadow: none;
|
text-shadow: none;
|
||||||
}`, 0);
|
}`,
|
||||||
|
0
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let ruleBody = "";
|
let ruleBody = "";
|
||||||
for (let property in selectStyle) {
|
for (let property in selectStyle) {
|
||||||
if (property == "background-color" || property == "direction")
|
if (property == "background-color" || property == "direction") {
|
||||||
continue; // Handled above, or before.
|
continue;
|
||||||
|
} // Handled above, or before.
|
||||||
if (selectStyle[property] != uaStyle[property]) {
|
if (selectStyle[property] != uaStyle[property]) {
|
||||||
ruleBody += `${property}: ${selectStyle[property]};`;
|
ruleBody += `${property}: ${selectStyle[property]};`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ruleBody) {
|
if (ruleBody) {
|
||||||
sheet.insertRule(`#ContentSelectDropdown > menupopup {
|
sheet.insertRule(
|
||||||
|
`#ContentSelectDropdown > menupopup {
|
||||||
${ruleBody}
|
${ruleBody}
|
||||||
}`, 0);
|
}`,
|
||||||
sheet.insertRule(`#ContentSelectDropdown > menupopup > :not([_moz-menuactive="true"]) {
|
0
|
||||||
|
);
|
||||||
|
sheet.insertRule(
|
||||||
|
`#ContentSelectDropdown > menupopup > :not([_moz-menuactive="true"]) {
|
||||||
color: inherit;
|
color: inherit;
|
||||||
}`, 0);
|
}`,
|
||||||
|
0
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -135,8 +155,16 @@ var SelectParentHelper = {
|
||||||
|
|
||||||
this._currentZoom = zoom;
|
this._currentZoom = zoom;
|
||||||
this._currentMenulist = menulist;
|
this._currentMenulist = menulist;
|
||||||
this.populateChildren(menulist, items, uniqueItemStyles, selectedIndex, zoom,
|
this.populateChildren(
|
||||||
selectStyle, selectBackgroundSet, sheet);
|
menulist,
|
||||||
|
items,
|
||||||
|
uniqueItemStyles,
|
||||||
|
selectedIndex,
|
||||||
|
zoom,
|
||||||
|
selectStyle,
|
||||||
|
selectBackgroundSet,
|
||||||
|
sheet
|
||||||
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
open(browser, menulist, rect, isOpenedViaTouch, selectParentActor) {
|
open(browser, menulist, rect, isOpenedViaTouch, selectParentActor) {
|
||||||
|
|
@ -161,23 +189,37 @@ var SelectParentHelper = {
|
||||||
|
|
||||||
// Include the padding and border on the popup.
|
// Include the padding and border on the popup.
|
||||||
let cs = win.getComputedStyle(menupopup);
|
let cs = win.getComputedStyle(menupopup);
|
||||||
let bpHeight = parseFloat(cs.borderTopWidth) + parseFloat(cs.borderBottomWidth) +
|
let bpHeight =
|
||||||
parseFloat(cs.paddingTop) + parseFloat(cs.paddingBottom);
|
parseFloat(cs.borderTopWidth) +
|
||||||
menupopup.style.maxHeight = (itemHeight * MAX_ROWS + bpHeight) + "px";
|
parseFloat(cs.borderBottomWidth) +
|
||||||
|
parseFloat(cs.paddingTop) +
|
||||||
|
parseFloat(cs.paddingBottom);
|
||||||
|
menupopup.style.maxHeight = itemHeight * MAX_ROWS + bpHeight + "px";
|
||||||
}
|
}
|
||||||
|
|
||||||
menupopup.classList.toggle("isOpenedViaTouch", isOpenedViaTouch);
|
menupopup.classList.toggle("isOpenedViaTouch", isOpenedViaTouch);
|
||||||
|
|
||||||
if (browser.getAttribute("selectmenuconstrained") != "false") {
|
if (browser.getAttribute("selectmenuconstrained") != "false") {
|
||||||
let constraintRect = browser.getBoundingClientRect();
|
let constraintRect = browser.getBoundingClientRect();
|
||||||
constraintRect = new win.DOMRect(constraintRect.left + win.mozInnerScreenX,
|
constraintRect = new win.DOMRect(
|
||||||
constraintRect.top + win.mozInnerScreenY,
|
constraintRect.left + win.mozInnerScreenX,
|
||||||
constraintRect.width, constraintRect.height);
|
constraintRect.top + win.mozInnerScreenY,
|
||||||
|
constraintRect.width,
|
||||||
|
constraintRect.height
|
||||||
|
);
|
||||||
menupopup.setConstraintRect(constraintRect);
|
menupopup.setConstraintRect(constraintRect);
|
||||||
} else {
|
} else {
|
||||||
menupopup.setConstraintRect(new win.DOMRect(0, 0, 0, 0));
|
menupopup.setConstraintRect(new win.DOMRect(0, 0, 0, 0));
|
||||||
}
|
}
|
||||||
menupopup.openPopupAtScreenRect(AppConstants.platform == "macosx" ? "selection" : "after_start", rect.left, rect.top, rect.width, rect.height, false, false);
|
menupopup.openPopupAtScreenRect(
|
||||||
|
AppConstants.platform == "macosx" ? "selection" : "after_start",
|
||||||
|
rect.left,
|
||||||
|
rect.top,
|
||||||
|
rect.width,
|
||||||
|
rect.height,
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
hide(menulist, browser) {
|
hide(menulist, browser) {
|
||||||
|
|
@ -190,12 +232,20 @@ var SelectParentHelper = {
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case "mouseup":
|
case "mouseup":
|
||||||
function inRect(rect, x, y) {
|
function inRect(rect, x, y) {
|
||||||
return x >= rect.left && x <= rect.left + rect.width && y >= rect.top && y <= rect.top + rect.height;
|
return (
|
||||||
|
x >= rect.left &&
|
||||||
|
x <= rect.left + rect.width &&
|
||||||
|
y >= rect.top &&
|
||||||
|
y <= rect.top + rect.height
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let x = event.screenX, y = event.screenY;
|
let x = event.screenX,
|
||||||
let onAnchor = !inRect(this._currentMenulist.menupopup.getOuterScreenRect(), x, y) &&
|
y = event.screenY;
|
||||||
inRect(this._selectRect, x, y) && this._currentMenulist.menupopup.state == "open";
|
let onAnchor =
|
||||||
|
!inRect(this._currentMenulist.menupopup.getOuterScreenRect(), x, y) &&
|
||||||
|
inRect(this._selectRect, x, y) &&
|
||||||
|
this._currentMenulist.menupopup.state == "open";
|
||||||
this._actor.sendAsyncMessage("Forms:MouseUp", { onAnchor });
|
this._actor.sendAsyncMessage("Forms:MouseUp", { onAnchor });
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -260,9 +310,15 @@ var SelectParentHelper = {
|
||||||
|
|
||||||
let options = msg.data.options;
|
let options = msg.data.options;
|
||||||
let selectedIndex = msg.data.selectedIndex;
|
let selectedIndex = msg.data.selectedIndex;
|
||||||
this.populate(this._currentMenulist, options.options, options.uniqueStyles,
|
this.populate(
|
||||||
selectedIndex, this._currentZoom, msg.data.defaultStyle,
|
this._currentMenulist,
|
||||||
msg.data.style);
|
options.options,
|
||||||
|
options.uniqueStyles,
|
||||||
|
selectedIndex,
|
||||||
|
this._currentZoom,
|
||||||
|
msg.data.defaultStyle,
|
||||||
|
msg.data.style
|
||||||
|
);
|
||||||
|
|
||||||
// Restore scroll position to what it was prior to the update.
|
// Restore scroll position to what it was prior to the update.
|
||||||
scrollBox.scrollTop = scrollTop;
|
scrollBox.scrollTop = scrollTop;
|
||||||
|
|
@ -315,21 +371,34 @@ var SelectParentHelper = {
|
||||||
*
|
*
|
||||||
* FIXME(emilio): Again, using a stylesheet + :nth-child is not really efficient.
|
* FIXME(emilio): Again, using a stylesheet + :nth-child is not really efficient.
|
||||||
*/
|
*/
|
||||||
populateChildren(menulist, options, uniqueOptionStyles, selectedIndex,
|
populateChildren(
|
||||||
zoom, selectStyle, selectBackgroundSet, sheet,
|
menulist,
|
||||||
parentElement = null, isGroupDisabled = false,
|
options,
|
||||||
addSearch = true, nthChildIndex = 1) {
|
uniqueOptionStyles,
|
||||||
|
selectedIndex,
|
||||||
|
zoom,
|
||||||
|
selectStyle,
|
||||||
|
selectBackgroundSet,
|
||||||
|
sheet,
|
||||||
|
parentElement = null,
|
||||||
|
isGroupDisabled = false,
|
||||||
|
addSearch = true,
|
||||||
|
nthChildIndex = 1
|
||||||
|
) {
|
||||||
let element = menulist.menupopup;
|
let element = menulist.menupopup;
|
||||||
|
|
||||||
for (let option of options) {
|
for (let option of options) {
|
||||||
let isOptGroup = (option.tagName == "OPTGROUP");
|
let isOptGroup = option.tagName == "OPTGROUP";
|
||||||
let item = element.ownerDocument.createXULElement(isOptGroup ? "menucaption" : "menuitem");
|
let item = element.ownerDocument.createXULElement(
|
||||||
|
isOptGroup ? "menucaption" : "menuitem"
|
||||||
|
);
|
||||||
let style = uniqueOptionStyles[option.styleIndex];
|
let style = uniqueOptionStyles[option.styleIndex];
|
||||||
|
|
||||||
item.setAttribute("label", option.textContent);
|
item.setAttribute("label", option.textContent);
|
||||||
item.style.direction = style.direction;
|
item.style.direction = style.direction;
|
||||||
item.style.fontSize = (zoom * parseFloat(style["font-size"], 10)) + "px";
|
item.style.fontSize = zoom * parseFloat(style["font-size"], 10) + "px";
|
||||||
item.hidden = option.display == "none" || (parentElement && parentElement.hidden);
|
item.hidden =
|
||||||
|
option.display == "none" || (parentElement && parentElement.hidden);
|
||||||
// Keep track of which options are hidden by page content, so we can avoid showing
|
// Keep track of which options are hidden by page content, so we can avoid showing
|
||||||
// them on search input
|
// them on search input
|
||||||
item.hiddenByContent = item.hidden;
|
item.hiddenByContent = item.hidden;
|
||||||
|
|
@ -339,7 +408,8 @@ var SelectParentHelper = {
|
||||||
style["background-color"] = selectStyle["background-color"];
|
style["background-color"] = selectStyle["background-color"];
|
||||||
}
|
}
|
||||||
|
|
||||||
let optionBackgroundSet = style["background-color"] != selectStyle["background-color"];
|
let optionBackgroundSet =
|
||||||
|
style["background-color"] != selectStyle["background-color"];
|
||||||
|
|
||||||
if (style.color == style["background-color"]) {
|
if (style.color == style["background-color"]) {
|
||||||
style.color = selectStyle.color;
|
style.color = selectStyle.color;
|
||||||
|
|
@ -348,10 +418,12 @@ var SelectParentHelper = {
|
||||||
if (customStylingEnabled) {
|
if (customStylingEnabled) {
|
||||||
let ruleBody = "";
|
let ruleBody = "";
|
||||||
for (let property in style) {
|
for (let property in style) {
|
||||||
if (property == "direction" || property == "font-size")
|
if (property == "direction" || property == "font-size") {
|
||||||
continue; // handled above
|
|
||||||
if (style[property] == selectStyle[property])
|
|
||||||
continue;
|
continue;
|
||||||
|
} // handled above
|
||||||
|
if (style[property] == selectStyle[property]) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (PROPERTIES_RESET_WHEN_ACTIVE.includes(property)) {
|
if (PROPERTIES_RESET_WHEN_ACTIVE.includes(property)) {
|
||||||
ruleBody += `${property}: ${style[property]};`;
|
ruleBody += `${property}: ${style[property]};`;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -360,23 +432,34 @@ var SelectParentHelper = {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ruleBody) {
|
if (ruleBody) {
|
||||||
sheet.insertRule(`#ContentSelectDropdown > menupopup > :nth-child(${nthChildIndex}):not([_moz-menuactive="true"]) {
|
sheet.insertRule(
|
||||||
|
`#ContentSelectDropdown > menupopup > :nth-child(${nthChildIndex}):not([_moz-menuactive="true"]) {
|
||||||
${ruleBody}
|
${ruleBody}
|
||||||
}`, 0);
|
}`,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
|
||||||
if (style["text-shadow"] != "none" &&
|
if (
|
||||||
style["text-shadow"] != selectStyle["text-shadow"]) {
|
style["text-shadow"] != "none" &&
|
||||||
|
style["text-shadow"] != selectStyle["text-shadow"]
|
||||||
|
) {
|
||||||
// Need to explicitly disable the possibly inherited
|
// Need to explicitly disable the possibly inherited
|
||||||
// text-shadow rule when _moz-menuactive=true since
|
// text-shadow rule when _moz-menuactive=true since
|
||||||
// _moz-menuactive=true disables custom option styling.
|
// _moz-menuactive=true disables custom option styling.
|
||||||
sheet.insertRule(`#ContentSelectDropdown > menupopup > :nth-child(${nthChildIndex})[_moz-menuactive="true"] {
|
sheet.insertRule(
|
||||||
|
`#ContentSelectDropdown > menupopup > :nth-child(${nthChildIndex})[_moz-menuactive="true"] {
|
||||||
text-shadow: none;
|
text-shadow: none;
|
||||||
}`, 0);
|
}`,
|
||||||
|
0
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (customStylingEnabled && (optionBackgroundSet || selectBackgroundSet)) {
|
if (
|
||||||
|
customStylingEnabled &&
|
||||||
|
(optionBackgroundSet || selectBackgroundSet)
|
||||||
|
) {
|
||||||
item.setAttribute("customoptionstyling", "true");
|
item.setAttribute("customoptionstyling", "true");
|
||||||
} else {
|
} else {
|
||||||
item.removeAttribute("customoptionstyling");
|
item.removeAttribute("customoptionstyling");
|
||||||
|
|
@ -392,11 +475,20 @@ var SelectParentHelper = {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isOptGroup) {
|
if (isOptGroup) {
|
||||||
nthChildIndex =
|
nthChildIndex = this.populateChildren(
|
||||||
this.populateChildren(menulist, option.children, uniqueOptionStyles,
|
menulist,
|
||||||
selectedIndex, zoom, selectStyle,
|
option.children,
|
||||||
selectBackgroundSet, sheet, item, isDisabled, false,
|
uniqueOptionStyles,
|
||||||
nthChildIndex);
|
selectedIndex,
|
||||||
|
zoom,
|
||||||
|
selectStyle,
|
||||||
|
selectBackgroundSet,
|
||||||
|
sheet,
|
||||||
|
item,
|
||||||
|
isDisabled,
|
||||||
|
false,
|
||||||
|
nthChildIndex
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
if (option.index == selectedIndex) {
|
if (option.index == selectedIndex) {
|
||||||
// We expect the parent element of the popup to be a <xul:menulist> that
|
// We expect the parent element of the popup to be a <xul:menulist> that
|
||||||
|
|
@ -424,22 +516,32 @@ var SelectParentHelper = {
|
||||||
|
|
||||||
// Check if search pref is enabled, if this is the first time iterating through
|
// Check if search pref is enabled, if this is the first time iterating through
|
||||||
// the dropdown, and if the list is long enough for a search element to be added.
|
// the dropdown, and if the list is long enough for a search element to be added.
|
||||||
if (Services.prefs.getBoolPref("dom.forms.selectSearch") && addSearch
|
if (
|
||||||
&& element.childElementCount > SEARCH_MINIMUM_ELEMENTS) {
|
Services.prefs.getBoolPref("dom.forms.selectSearch") &&
|
||||||
|
addSearch &&
|
||||||
|
element.childElementCount > SEARCH_MINIMUM_ELEMENTS
|
||||||
|
) {
|
||||||
// Add a search text field as the first element of the dropdown
|
// Add a search text field as the first element of the dropdown
|
||||||
let searchbox = element.ownerDocument.createXULElement("textbox", {
|
let searchbox = element.ownerDocument.createXULElement("textbox", {
|
||||||
is: "search-textbox",
|
is: "search-textbox",
|
||||||
});
|
});
|
||||||
searchbox.className = "contentSelectDropdown-searchbox";
|
searchbox.className = "contentSelectDropdown-searchbox";
|
||||||
searchbox.addEventListener("input", this.onSearchInput);
|
searchbox.addEventListener("input", this.onSearchInput);
|
||||||
searchbox.inputField.addEventListener("focus", this.onSearchFocus.bind(this));
|
searchbox.inputField.addEventListener(
|
||||||
|
"focus",
|
||||||
|
this.onSearchFocus.bind(this)
|
||||||
|
);
|
||||||
searchbox.inputField.addEventListener("blur", this.onSearchBlur);
|
searchbox.inputField.addEventListener("blur", this.onSearchBlur);
|
||||||
searchbox.addEventListener("command", this.onSearchInput);
|
searchbox.addEventListener("command", this.onSearchInput);
|
||||||
|
|
||||||
// Handle special keys for exiting search
|
// Handle special keys for exiting search
|
||||||
searchbox.addEventListener("keydown", (event) => {
|
searchbox.addEventListener(
|
||||||
this.onSearchKeydown(event, menulist);
|
"keydown",
|
||||||
}, true);
|
event => {
|
||||||
|
this.onSearchKeydown(event, menulist);
|
||||||
|
},
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
element.insertBefore(searchbox, element.children[0]);
|
element.insertBefore(searchbox, element.children[0]);
|
||||||
}
|
}
|
||||||
|
|
@ -461,13 +563,17 @@ var SelectParentHelper = {
|
||||||
case "Enter":
|
case "Enter":
|
||||||
case "Tab":
|
case "Tab":
|
||||||
searchbox.blur();
|
searchbox.blur();
|
||||||
if (searchbox.nextElementSibling.localName == "menuitem" &&
|
if (
|
||||||
!searchbox.nextElementSibling.hidden) {
|
searchbox.nextElementSibling.localName == "menuitem" &&
|
||||||
|
!searchbox.nextElementSibling.hidden
|
||||||
|
) {
|
||||||
menulist.activeChild = searchbox.nextElementSibling;
|
menulist.activeChild = searchbox.nextElementSibling;
|
||||||
} else {
|
} else {
|
||||||
let currentOption = searchbox.nextElementSibling;
|
let currentOption = searchbox.nextElementSibling;
|
||||||
while (currentOption && (currentOption.localName != "menuitem" ||
|
while (
|
||||||
currentOption.hidden)) {
|
currentOption &&
|
||||||
|
(currentOption.localName != "menuitem" || currentOption.hidden)
|
||||||
|
) {
|
||||||
currentOption = currentOption.nextElementSibling;
|
currentOption = currentOption.nextElementSibling;
|
||||||
}
|
}
|
||||||
if (currentOption) {
|
if (currentOption) {
|
||||||
|
|
@ -517,8 +623,12 @@ var SelectParentHelper = {
|
||||||
prevCaption = currentItem;
|
prevCaption = currentItem;
|
||||||
allHidden = true;
|
allHidden = true;
|
||||||
} else {
|
} else {
|
||||||
if (!currentItem.classList.contains("contentSelectDropdown-ingroup") &&
|
if (
|
||||||
currentItem.previousElementSibling.classList.contains("contentSelectDropdown-ingroup")) {
|
!currentItem.classList.contains("contentSelectDropdown-ingroup") &&
|
||||||
|
currentItem.previousElementSibling.classList.contains(
|
||||||
|
"contentSelectDropdown-ingroup"
|
||||||
|
)
|
||||||
|
) {
|
||||||
if (prevCaption != null) {
|
if (prevCaption != null) {
|
||||||
prevCaption.hidden = allHidden;
|
prevCaption.hidden = allHidden;
|
||||||
}
|
}
|
||||||
|
|
@ -557,8 +667,7 @@ var SelectParentHelper = {
|
||||||
class SelectParent extends JSWindowActorParent {
|
class SelectParent extends JSWindowActorParent {
|
||||||
receiveMessage(message) {
|
receiveMessage(message) {
|
||||||
switch (message.name) {
|
switch (message.name) {
|
||||||
case "Forms:ShowDropDown":
|
case "Forms:ShowDropDown": {
|
||||||
{
|
|
||||||
let topBrowsingContext = this.manager.browsingContext.top;
|
let topBrowsingContext = this.manager.browsingContext.top;
|
||||||
let browser = topBrowsingContext.embedderElement;
|
let browser = topBrowsingContext.embedderElement;
|
||||||
|
|
||||||
|
|
@ -567,7 +676,9 @@ class SelectParent extends JSWindowActorParent {
|
||||||
}
|
}
|
||||||
|
|
||||||
let document = browser.ownerDocument;
|
let document = browser.ownerDocument;
|
||||||
let menulist = document.getElementById(browser.getAttribute("selectmenulist"));
|
let menulist = document.getElementById(
|
||||||
|
browser.getAttribute("selectmenulist")
|
||||||
|
);
|
||||||
|
|
||||||
if (!this._menulist) {
|
if (!this._menulist) {
|
||||||
// Cache the menulist to have access to it
|
// Cache the menulist to have access to it
|
||||||
|
|
@ -578,25 +689,37 @@ class SelectParent extends JSWindowActorParent {
|
||||||
let data = message.data;
|
let data = message.data;
|
||||||
menulist.menupopup.style.direction = data.style.direction;
|
menulist.menupopup.style.direction = data.style.direction;
|
||||||
|
|
||||||
let useFullZoom = !browser.isRemoteBrowser ||
|
let useFullZoom =
|
||||||
Services.prefs.getBoolPref("browser.zoom.full") ||
|
!browser.isRemoteBrowser ||
|
||||||
browser.isSyntheticDocument;
|
Services.prefs.getBoolPref("browser.zoom.full") ||
|
||||||
|
browser.isSyntheticDocument;
|
||||||
let zoom = useFullZoom ? browser._fullZoom : browser._textZoom;
|
let zoom = useFullZoom ? browser._fullZoom : browser._textZoom;
|
||||||
|
|
||||||
SelectParentHelper.populate(menulist, data.options.options,
|
SelectParentHelper.populate(
|
||||||
data.options.uniqueStyles, data.selectedIndex, zoom,
|
menulist,
|
||||||
data.defaultStyle, data.style);
|
data.options.options,
|
||||||
SelectParentHelper.open(browser, menulist, data.rect, data.isOpenedViaTouch, this);
|
data.options.uniqueStyles,
|
||||||
|
data.selectedIndex,
|
||||||
|
zoom,
|
||||||
|
data.defaultStyle,
|
||||||
|
data.style
|
||||||
|
);
|
||||||
|
SelectParentHelper.open(
|
||||||
|
browser,
|
||||||
|
menulist,
|
||||||
|
data.rect,
|
||||||
|
data.isOpenedViaTouch,
|
||||||
|
this
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case "Forms:HideDropDown":
|
case "Forms:HideDropDown": {
|
||||||
{
|
let topBrowsingContext = this.manager.browsingContext.top;
|
||||||
let topBrowsingContext = this.manager.browsingContext.top;
|
let browser = topBrowsingContext.embedderElement;
|
||||||
let browser = topBrowsingContext.embedderElement;
|
SelectParentHelper.hide(this._menulist, browser);
|
||||||
SelectParentHelper.hide(this._menulist, browser);
|
break;
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
SelectParentHelper.receiveMessage(message);
|
SelectParentHelper.receiveMessage(message);
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,10 @@
|
||||||
|
|
||||||
var EXPORTED_SYMBOLS = ["SelectionSourceChild"];
|
var EXPORTED_SYMBOLS = ["SelectionSourceChild"];
|
||||||
|
|
||||||
const {ActorChild} = ChromeUtils.import("resource://gre/modules/ActorChild.jsm");
|
const { ActorChild } = ChromeUtils.import(
|
||||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
"resource://gre/modules/ActorChild.jsm"
|
||||||
|
);
|
||||||
|
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
|
|
||||||
class SelectionSourceChild extends ActorChild {
|
class SelectionSourceChild extends ActorChild {
|
||||||
receiveMessage(message) {
|
receiveMessage(message) {
|
||||||
|
|
@ -17,7 +19,10 @@ class SelectionSourceChild extends ActorChild {
|
||||||
try {
|
try {
|
||||||
selectionDetails = this.getSelection(global);
|
selectionDetails = this.getSelection(global);
|
||||||
} finally {
|
} finally {
|
||||||
global.sendAsyncMessage("ViewSource:GetSelectionDone", selectionDetails);
|
global.sendAsyncMessage(
|
||||||
|
"ViewSource:GetSelectionDone",
|
||||||
|
selectionDetails
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -30,11 +35,13 @@ class SelectionSourceChild extends ActorChild {
|
||||||
getPath(ancestor, node) {
|
getPath(ancestor, node) {
|
||||||
var n = node;
|
var n = node;
|
||||||
var p = n.parentNode;
|
var p = n.parentNode;
|
||||||
if (n == ancestor || !p)
|
if (n == ancestor || !p) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
var path = [];
|
var path = [];
|
||||||
if (!path)
|
if (!path) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
do {
|
do {
|
||||||
for (var i = 0; i < p.childNodes.length; i++) {
|
for (var i = 0; i < p.childNodes.length; i++) {
|
||||||
if (p.childNodes.item(i) == n) {
|
if (p.childNodes.item(i) == n) {
|
||||||
|
|
@ -49,7 +56,7 @@ class SelectionSourceChild extends ActorChild {
|
||||||
}
|
}
|
||||||
|
|
||||||
getSelection(global) {
|
getSelection(global) {
|
||||||
const {content} = global;
|
const { content } = global;
|
||||||
|
|
||||||
// These are markers used to delimit the selection during processing. They
|
// These are markers used to delimit the selection during processing. They
|
||||||
// are removed from the final rendering.
|
// are removed from the final rendering.
|
||||||
|
|
@ -73,16 +80,20 @@ class SelectionSourceChild extends ActorChild {
|
||||||
|
|
||||||
// let the ancestor be an element
|
// let the ancestor be an element
|
||||||
var Node = doc.defaultView.Node;
|
var Node = doc.defaultView.Node;
|
||||||
if (ancestorContainer.nodeType == Node.TEXT_NODE ||
|
if (
|
||||||
ancestorContainer.nodeType == Node.CDATA_SECTION_NODE)
|
ancestorContainer.nodeType == Node.TEXT_NODE ||
|
||||||
|
ancestorContainer.nodeType == Node.CDATA_SECTION_NODE
|
||||||
|
) {
|
||||||
ancestorContainer = ancestorContainer.parentNode;
|
ancestorContainer = ancestorContainer.parentNode;
|
||||||
|
}
|
||||||
|
|
||||||
// for selectAll, let's use the entire document, including <html>...</html>
|
// for selectAll, let's use the entire document, including <html>...</html>
|
||||||
// @see nsDocumentViewer::SelectAll() for how selectAll is implemented
|
// @see nsDocumentViewer::SelectAll() for how selectAll is implemented
|
||||||
try {
|
try {
|
||||||
if (ancestorContainer == doc.body)
|
if (ancestorContainer == doc.body) {
|
||||||
ancestorContainer = doc.documentElement;
|
ancestorContainer = doc.documentElement;
|
||||||
} catch (e) { }
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
// each path is a "child sequence" (a.k.a. "tumbler") that
|
// each path is a "child sequence" (a.k.a. "tumbler") that
|
||||||
// descends from the ancestor down to the boundary point
|
// descends from the ancestor down to the boundary point
|
||||||
|
|
@ -95,10 +106,14 @@ class SelectionSourceChild extends ActorChild {
|
||||||
// loading and the like. The use of importNode here, as opposed to adoptNode,
|
// loading and the like. The use of importNode here, as opposed to adoptNode,
|
||||||
// is _very_ important.
|
// is _very_ important.
|
||||||
// XXXbz wish there were a less hacky way to create an untrusted document here
|
// XXXbz wish there were a less hacky way to create an untrusted document here
|
||||||
var isHTML = (doc.createElement("div").tagName == "DIV");
|
var isHTML = doc.createElement("div").tagName == "DIV";
|
||||||
var dataDoc = isHTML ?
|
var dataDoc = isHTML
|
||||||
ancestorContainer.ownerDocument.implementation.createHTMLDocument("") :
|
? ancestorContainer.ownerDocument.implementation.createHTMLDocument("")
|
||||||
ancestorContainer.ownerDocument.implementation.createDocument("", "", null);
|
: ancestorContainer.ownerDocument.implementation.createDocument(
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
null
|
||||||
|
);
|
||||||
ancestorContainer = dataDoc.importNode(ancestorContainer, true);
|
ancestorContainer = dataDoc.importNode(ancestorContainer, true);
|
||||||
startContainer = ancestorContainer;
|
startContainer = ancestorContainer;
|
||||||
endContainer = ancestorContainer;
|
endContainer = ancestorContainer;
|
||||||
|
|
@ -121,51 +136,75 @@ class SelectionSourceChild extends ActorChild {
|
||||||
// note: |startOffset| and |endOffset| are interpreted either as
|
// note: |startOffset| and |endOffset| are interpreted either as
|
||||||
// offsets in the text data or as child indices (see the Range spec)
|
// offsets in the text data or as child indices (see the Range spec)
|
||||||
// (here, munging the end point first to keep the start point safe...)
|
// (here, munging the end point first to keep the start point safe...)
|
||||||
if (endContainer.nodeType == Node.TEXT_NODE ||
|
if (
|
||||||
endContainer.nodeType == Node.CDATA_SECTION_NODE) {
|
endContainer.nodeType == Node.TEXT_NODE ||
|
||||||
|
endContainer.nodeType == Node.CDATA_SECTION_NODE
|
||||||
|
) {
|
||||||
// do some extra tweaks to try to avoid the view-source output to look like
|
// do some extra tweaks to try to avoid the view-source output to look like
|
||||||
// ...<tag>]... or ...]</tag>... (where ']' marks the end of the selection).
|
// ...<tag>]... or ...]</tag>... (where ']' marks the end of the selection).
|
||||||
// To get a neat output, the idea here is to remap the end point from:
|
// To get a neat output, the idea here is to remap the end point from:
|
||||||
// 1. ...<tag>]... to ...]<tag>...
|
// 1. ...<tag>]... to ...]<tag>...
|
||||||
// 2. ...]</tag>... to ...</tag>]...
|
// 2. ...]</tag>... to ...</tag>]...
|
||||||
if ((endOffset > 0 && endOffset < endContainer.data.length) ||
|
if (
|
||||||
!endContainer.parentNode || !endContainer.parentNode.parentNode) {
|
(endOffset > 0 && endOffset < endContainer.data.length) ||
|
||||||
|
!endContainer.parentNode ||
|
||||||
|
!endContainer.parentNode.parentNode
|
||||||
|
) {
|
||||||
endContainer.insertData(endOffset, MARK_SELECTION_END);
|
endContainer.insertData(endOffset, MARK_SELECTION_END);
|
||||||
} else {
|
} else {
|
||||||
tmpNode = dataDoc.createTextNode(MARK_SELECTION_END);
|
tmpNode = dataDoc.createTextNode(MARK_SELECTION_END);
|
||||||
endContainer = endContainer.parentNode;
|
endContainer = endContainer.parentNode;
|
||||||
if (endOffset === 0)
|
if (endOffset === 0) {
|
||||||
endContainer.parentNode.insertBefore(tmpNode, endContainer);
|
endContainer.parentNode.insertBefore(tmpNode, endContainer);
|
||||||
else
|
} else {
|
||||||
endContainer.parentNode.insertBefore(tmpNode, endContainer.nextSibling);
|
endContainer.parentNode.insertBefore(
|
||||||
|
tmpNode,
|
||||||
|
endContainer.nextSibling
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tmpNode = dataDoc.createTextNode(MARK_SELECTION_END);
|
tmpNode = dataDoc.createTextNode(MARK_SELECTION_END);
|
||||||
endContainer.insertBefore(tmpNode, endContainer.childNodes.item(endOffset));
|
endContainer.insertBefore(
|
||||||
|
tmpNode,
|
||||||
|
endContainer.childNodes.item(endOffset)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (startContainer.nodeType == Node.TEXT_NODE ||
|
if (
|
||||||
startContainer.nodeType == Node.CDATA_SECTION_NODE) {
|
startContainer.nodeType == Node.TEXT_NODE ||
|
||||||
|
startContainer.nodeType == Node.CDATA_SECTION_NODE
|
||||||
|
) {
|
||||||
// do some extra tweaks to try to avoid the view-source output to look like
|
// do some extra tweaks to try to avoid the view-source output to look like
|
||||||
// ...<tag>[... or ...[</tag>... (where '[' marks the start of the selection).
|
// ...<tag>[... or ...[</tag>... (where '[' marks the start of the selection).
|
||||||
// To get a neat output, the idea here is to remap the start point from:
|
// To get a neat output, the idea here is to remap the start point from:
|
||||||
// 1. ...<tag>[... to ...[<tag>...
|
// 1. ...<tag>[... to ...[<tag>...
|
||||||
// 2. ...[</tag>... to ...</tag>[...
|
// 2. ...[</tag>... to ...</tag>[...
|
||||||
if ((startOffset > 0 && startOffset < startContainer.data.length) ||
|
if (
|
||||||
!startContainer.parentNode || !startContainer.parentNode.parentNode ||
|
(startOffset > 0 && startOffset < startContainer.data.length) ||
|
||||||
startContainer != startContainer.parentNode.lastChild) {
|
!startContainer.parentNode ||
|
||||||
|
!startContainer.parentNode.parentNode ||
|
||||||
|
startContainer != startContainer.parentNode.lastChild
|
||||||
|
) {
|
||||||
startContainer.insertData(startOffset, MARK_SELECTION_START);
|
startContainer.insertData(startOffset, MARK_SELECTION_START);
|
||||||
} else {
|
} else {
|
||||||
tmpNode = dataDoc.createTextNode(MARK_SELECTION_START);
|
tmpNode = dataDoc.createTextNode(MARK_SELECTION_START);
|
||||||
startContainer = startContainer.parentNode;
|
startContainer = startContainer.parentNode;
|
||||||
if (startOffset === 0)
|
if (startOffset === 0) {
|
||||||
startContainer.parentNode.insertBefore(tmpNode, startContainer);
|
startContainer.parentNode.insertBefore(tmpNode, startContainer);
|
||||||
else
|
} else {
|
||||||
startContainer.parentNode.insertBefore(tmpNode, startContainer.nextSibling);
|
startContainer.parentNode.insertBefore(
|
||||||
|
tmpNode,
|
||||||
|
startContainer.nextSibling
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tmpNode = dataDoc.createTextNode(MARK_SELECTION_START);
|
tmpNode = dataDoc.createTextNode(MARK_SELECTION_START);
|
||||||
startContainer.insertBefore(tmpNode, startContainer.childNodes.item(startOffset));
|
startContainer.insertBefore(
|
||||||
|
tmpNode,
|
||||||
|
startContainer.childNodes.item(startOffset)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -173,11 +212,15 @@ class SelectionSourceChild extends ActorChild {
|
||||||
tmpNode = dataDoc.createElementNS("http://www.w3.org/1999/xhtml", "div");
|
tmpNode = dataDoc.createElementNS("http://www.w3.org/1999/xhtml", "div");
|
||||||
tmpNode.appendChild(ancestorContainer);
|
tmpNode.appendChild(ancestorContainer);
|
||||||
|
|
||||||
return { uri: (isHTML ? "view-source:data:text/html;charset=utf-8," :
|
return {
|
||||||
"view-source:data:application/xml;charset=utf-8,")
|
uri:
|
||||||
+ encodeURIComponent(tmpNode.innerHTML),
|
(isHTML
|
||||||
drawSelection: canDrawSelection,
|
? "view-source:data:text/html;charset=utf-8,"
|
||||||
baseURI: doc.baseURI };
|
: "view-source:data:application/xml;charset=utf-8,") +
|
||||||
|
encodeURIComponent(tmpNode.innerHTML),
|
||||||
|
drawSelection: canDrawSelection,
|
||||||
|
baseURI: doc.baseURI,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
get wrapLongLines() {
|
get wrapLongLines() {
|
||||||
|
|
|
||||||
|
|
@ -4,13 +4,13 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
|
|
||||||
var EXPORTED_SYMBOLS = ["TestChild"];
|
var EXPORTED_SYMBOLS = ["TestChild"];
|
||||||
|
|
||||||
class TestChild extends JSWindowActorChild {
|
class TestChild extends JSWindowActorChild {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
receiveMessage(aMessage) {
|
receiveMessage(aMessage) {
|
||||||
|
|
@ -20,7 +20,7 @@ class TestChild extends JSWindowActorChild {
|
||||||
this.sendAsyncMessage("toParent", aMessage.data);
|
this.sendAsyncMessage("toParent", aMessage.data);
|
||||||
break;
|
break;
|
||||||
case "asyncAdd":
|
case "asyncAdd":
|
||||||
let {a, b} = aMessage.data;
|
let { a, b } = aMessage.data;
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
resolve({ result: a + b });
|
resolve({ result: a + b });
|
||||||
});
|
});
|
||||||
|
|
@ -37,7 +37,7 @@ class TestChild extends JSWindowActorChild {
|
||||||
}
|
}
|
||||||
|
|
||||||
observe(subject, topic, data) {
|
observe(subject, topic, data) {
|
||||||
this.lastObserved = {subject, topic, data};
|
this.lastObserved = { subject, topic, data };
|
||||||
}
|
}
|
||||||
|
|
||||||
show() {
|
show() {
|
||||||
|
|
@ -46,11 +46,13 @@ class TestChild extends JSWindowActorChild {
|
||||||
|
|
||||||
willDestroy() {
|
willDestroy() {
|
||||||
Services.obs.notifyObservers(
|
Services.obs.notifyObservers(
|
||||||
this, "test-js-window-actor-willdestroy", true);
|
this,
|
||||||
|
"test-js-window-actor-willdestroy",
|
||||||
|
true
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
didDestroy() {
|
didDestroy() {
|
||||||
Services.obs.notifyObservers(
|
Services.obs.notifyObservers(this, "test-js-window-actor-diddestroy", true);
|
||||||
this, "test-js-window-actor-diddestroy", true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
|
|
||||||
var EXPORTED_SYMBOLS = ["TestParent"];
|
var EXPORTED_SYMBOLS = ["TestParent"];
|
||||||
|
|
||||||
|
|
@ -17,7 +17,7 @@ class TestParent extends JSWindowActorParent {
|
||||||
receiveMessage(aMessage) {
|
receiveMessage(aMessage) {
|
||||||
switch (aMessage.name) {
|
switch (aMessage.name) {
|
||||||
case "init":
|
case "init":
|
||||||
aMessage.data.initial = true;
|
aMessage.data.initial = true;
|
||||||
this.sendAsyncMessage("toChild", aMessage.data);
|
this.sendAsyncMessage("toChild", aMessage.data);
|
||||||
break;
|
break;
|
||||||
case "toParent":
|
case "toParent":
|
||||||
|
|
@ -25,12 +25,15 @@ class TestParent extends JSWindowActorParent {
|
||||||
this.sendAsyncMessage("done", aMessage.data);
|
this.sendAsyncMessage("done", aMessage.data);
|
||||||
break;
|
break;
|
||||||
case "asyncMul":
|
case "asyncMul":
|
||||||
let {a, b} = aMessage.data;
|
let { a, b } = aMessage.data;
|
||||||
return { result: a * b };
|
return { result: a * b };
|
||||||
|
|
||||||
case "event":
|
case "event":
|
||||||
Services.obs.notifyObservers(
|
Services.obs.notifyObservers(
|
||||||
this, "test-js-window-actor-parent-event", aMessage.data.type);
|
this,
|
||||||
|
"test-js-window-actor-parent-event",
|
||||||
|
aMessage.data.type
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,16 @@
|
||||||
|
|
||||||
var EXPORTED_SYMBOLS = ["ThumbnailsChild"];
|
var EXPORTED_SYMBOLS = ["ThumbnailsChild"];
|
||||||
|
|
||||||
const {ActorChild} = ChromeUtils.import("resource://gre/modules/ActorChild.jsm");
|
const { ActorChild } = ChromeUtils.import(
|
||||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
"resource://gre/modules/ActorChild.jsm"
|
||||||
|
);
|
||||||
|
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
|
|
||||||
ChromeUtils.defineModuleGetter(this, "PageThumbUtils",
|
ChromeUtils.defineModuleGetter(
|
||||||
"resource://gre/modules/PageThumbUtils.jsm");
|
this,
|
||||||
|
"PageThumbUtils",
|
||||||
|
"resource://gre/modules/PageThumbUtils.jsm"
|
||||||
|
);
|
||||||
|
|
||||||
class ThumbnailsChild extends ActorChild {
|
class ThumbnailsChild extends ActorChild {
|
||||||
receiveMessage(message) {
|
receiveMessage(message) {
|
||||||
|
|
@ -22,16 +27,23 @@ class ThumbnailsChild extends ActorChild {
|
||||||
let args = message.data.additionalArgs;
|
let args = message.data.additionalArgs;
|
||||||
let fullScale = args ? args.fullScale : false;
|
let fullScale = args ? args.fullScale : false;
|
||||||
if (fullScale) {
|
if (fullScale) {
|
||||||
snapshot = PageThumbUtils.createSnapshotThumbnail(this.content, null, args);
|
snapshot = PageThumbUtils.createSnapshotThumbnail(
|
||||||
|
this.content,
|
||||||
|
null,
|
||||||
|
args
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
let snapshotWidth = message.data.canvasWidth;
|
let snapshotWidth = message.data.canvasWidth;
|
||||||
let snapshotHeight = message.data.canvasHeight;
|
let snapshotHeight = message.data.canvasHeight;
|
||||||
snapshot =
|
snapshot = PageThumbUtils.createCanvas(
|
||||||
PageThumbUtils.createCanvas(this.content, snapshotWidth, snapshotHeight);
|
this.content,
|
||||||
|
snapshotWidth,
|
||||||
|
snapshotHeight
|
||||||
|
);
|
||||||
PageThumbUtils.createSnapshotThumbnail(this.content, snapshot, args);
|
PageThumbUtils.createSnapshotThumbnail(this.content, snapshot, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
snapshot.toBlob((aBlob) => {
|
snapshot.toBlob(aBlob => {
|
||||||
this.mm.sendAsyncMessage("Browser:Thumbnail:Response", {
|
this.mm.sendAsyncMessage("Browser:Thumbnail:Response", {
|
||||||
thumbnail: aBlob,
|
thumbnail: aBlob,
|
||||||
id: message.data.id,
|
id: message.data.id,
|
||||||
|
|
@ -42,7 +54,10 @@ class ThumbnailsChild extends ActorChild {
|
||||||
* Remote isSafeForCapture request handler for PageThumbs.
|
* Remote isSafeForCapture request handler for PageThumbs.
|
||||||
*/
|
*/
|
||||||
Services.tm.idleDispatchToMainThread(() => {
|
Services.tm.idleDispatchToMainThread(() => {
|
||||||
let result = PageThumbUtils.shouldStoreContentThumbnail(this.content, this.mm.docShell);
|
let result = PageThumbUtils.shouldStoreContentThumbnail(
|
||||||
|
this.content,
|
||||||
|
this.mm.docShell
|
||||||
|
);
|
||||||
this.mm.sendAsyncMessage("Browser:Thumbnail:CheckState:Response", {
|
this.mm.sendAsyncMessage("Browser:Thumbnail:CheckState:Response", {
|
||||||
result,
|
result,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,17 @@
|
||||||
/* vim: set ts=2 sw=2 sts=2 et tw=80: */
|
/* vim: set ts=2 sw=2 sts=2 et tw=80: */
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
/* 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
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var EXPORTED_SYMBOLS = ["UAWidgetsChild"];
|
var EXPORTED_SYMBOLS = ["UAWidgetsChild"];
|
||||||
|
|
||||||
const {ActorChild} = ChromeUtils.import("resource://gre/modules/ActorChild.jsm");
|
const { ActorChild } = ChromeUtils.import(
|
||||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
"resource://gre/modules/ActorChild.jsm"
|
||||||
|
);
|
||||||
|
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
|
|
||||||
const HANDLED_ELEMENTS = [
|
const HANDLED_ELEMENTS = ["video", "audio", "embed", "object", "marquee"];
|
||||||
"video",
|
|
||||||
"audio",
|
|
||||||
"embed",
|
|
||||||
"object",
|
|
||||||
"marquee",
|
|
||||||
];
|
|
||||||
|
|
||||||
class UAWidgetsChild extends ActorChild {
|
class UAWidgetsChild extends ActorChild {
|
||||||
constructor(dispatcher) {
|
constructor(dispatcher) {
|
||||||
|
|
@ -83,25 +79,33 @@ class UAWidgetsChild extends ActorChild {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!uri || !widgetName) {
|
if (!uri || !widgetName) {
|
||||||
Cu.reportError("Getting a UAWidgetSetupOrChange event on undefined element.");
|
Cu.reportError(
|
||||||
|
"Getting a UAWidgetSetupOrChange event on undefined element."
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let shadowRoot = aElement.openOrClosedShadowRoot;
|
let shadowRoot = aElement.openOrClosedShadowRoot;
|
||||||
if (!shadowRoot) {
|
if (!shadowRoot) {
|
||||||
Cu.reportError("Getting a UAWidgetSetupOrChange event without the Shadow Root.");
|
Cu.reportError(
|
||||||
|
"Getting a UAWidgetSetupOrChange event without the Shadow Root."
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let isSystemPrincipal = aElement.nodePrincipal.isSystemPrincipal;
|
let isSystemPrincipal = aElement.nodePrincipal.isSystemPrincipal;
|
||||||
let sandbox = isSystemPrincipal ?
|
let sandbox = isSystemPrincipal
|
||||||
Object.create(null) : Cu.getUAWidgetScope(aElement.nodePrincipal);
|
? Object.create(null)
|
||||||
|
: Cu.getUAWidgetScope(aElement.nodePrincipal);
|
||||||
|
|
||||||
if (!sandbox[widgetName]) {
|
if (!sandbox[widgetName]) {
|
||||||
Services.scriptloader.loadSubScript(uri, sandbox);
|
Services.scriptloader.loadSubScript(uri, sandbox);
|
||||||
}
|
}
|
||||||
|
|
||||||
let prefs = Cu.cloneInto(this.getPrefsForUAWidget(widgetName, prefKeys), sandbox);
|
let prefs = Cu.cloneInto(
|
||||||
|
this.getPrefsForUAWidget(widgetName, prefKeys),
|
||||||
|
sandbox
|
||||||
|
);
|
||||||
|
|
||||||
let widget = new sandbox[widgetName](shadowRoot, prefs);
|
let widget = new sandbox[widgetName](shadowRoot, prefs);
|
||||||
if (!isSystemPrincipal) {
|
if (!isSystemPrincipal) {
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
/* vim: set ts=2 sw=2 sts=2 et tw=80: */
|
/* vim: set ts=2 sw=2 sts=2 et tw=80: */
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
/* 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
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var EXPORTED_SYMBOLS = ["UAWidgetsDateTimeBoxChild"];
|
var EXPORTED_SYMBOLS = ["UAWidgetsDateTimeBoxChild"];
|
||||||
|
|
||||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
|
|
||||||
const HANDLED_ELEMENTS = ["input"];
|
const HANDLED_ELEMENTS = ["input"];
|
||||||
|
|
||||||
|
|
@ -62,25 +62,33 @@ class UAWidgetsDateTimeBoxChild extends JSWindowActorChild {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!uri || !widgetName) {
|
if (!uri || !widgetName) {
|
||||||
Cu.reportError("Getting a UAWidgetSetupOrChange event on undefined element.");
|
Cu.reportError(
|
||||||
|
"Getting a UAWidgetSetupOrChange event on undefined element."
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let shadowRoot = aElement.openOrClosedShadowRoot;
|
let shadowRoot = aElement.openOrClosedShadowRoot;
|
||||||
if (!shadowRoot) {
|
if (!shadowRoot) {
|
||||||
Cu.reportError("Getting a UAWidgetSetupOrChange event without the Shadow Root.");
|
Cu.reportError(
|
||||||
|
"Getting a UAWidgetSetupOrChange event without the Shadow Root."
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let isSystemPrincipal = aElement.nodePrincipal.isSystemPrincipal;
|
let isSystemPrincipal = aElement.nodePrincipal.isSystemPrincipal;
|
||||||
let sandbox = isSystemPrincipal ?
|
let sandbox = isSystemPrincipal
|
||||||
Object.create(null) : Cu.getUAWidgetScope(aElement.nodePrincipal);
|
? Object.create(null)
|
||||||
|
: Cu.getUAWidgetScope(aElement.nodePrincipal);
|
||||||
|
|
||||||
if (!sandbox[widgetName]) {
|
if (!sandbox[widgetName]) {
|
||||||
Services.scriptloader.loadSubScript(uri, sandbox);
|
Services.scriptloader.loadSubScript(uri, sandbox);
|
||||||
}
|
}
|
||||||
|
|
||||||
let prefs = Cu.cloneInto(this.getPrefsForUAWidget(widgetName, prefKeys), sandbox);
|
let prefs = Cu.cloneInto(
|
||||||
|
this.getPrefsForUAWidget(widgetName, prefKeys),
|
||||||
|
sandbox
|
||||||
|
);
|
||||||
|
|
||||||
let widget = new sandbox[widgetName](shadowRoot, prefs);
|
let widget = new sandbox[widgetName](shadowRoot, prefs);
|
||||||
if (!isSystemPrincipal) {
|
if (!isSystemPrincipal) {
|
||||||
|
|
|
||||||
|
|
@ -6,17 +6,23 @@
|
||||||
|
|
||||||
var EXPORTED_SYMBOLS = ["UnselectedTabHoverChild"];
|
var EXPORTED_SYMBOLS = ["UnselectedTabHoverChild"];
|
||||||
|
|
||||||
const {ActorChild} = ChromeUtils.import("resource://gre/modules/ActorChild.jsm");
|
const { ActorChild } = ChromeUtils.import(
|
||||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
"resource://gre/modules/ActorChild.jsm"
|
||||||
|
);
|
||||||
|
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
|
|
||||||
class UnselectedTabHoverChild extends ActorChild {
|
class UnselectedTabHoverChild extends ActorChild {
|
||||||
receiveMessage(message) {
|
receiveMessage(message) {
|
||||||
Services.obs.notifyObservers(this.content, "unselected-tab-hover",
|
Services.obs.notifyObservers(
|
||||||
message.data.hovered);
|
this.content,
|
||||||
|
"unselected-tab-hover",
|
||||||
|
message.data.hovered
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleEvent(event) {
|
handleEvent(event) {
|
||||||
this.mm.sendAsyncMessage("UnselectedTabHover:Toggle",
|
this.mm.sendAsyncMessage("UnselectedTabHover:Toggle", {
|
||||||
{ enable: event.type == "UnselectedTabHover:Enable" });
|
enable: event.type == "UnselectedTabHover:Enable",
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,10 @@
|
||||||
|
|
||||||
var EXPORTED_SYMBOLS = ["WebChannelChild"];
|
var EXPORTED_SYMBOLS = ["WebChannelChild"];
|
||||||
|
|
||||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
const {ActorChild} = ChromeUtils.import("resource://gre/modules/ActorChild.jsm");
|
const { ActorChild } = ChromeUtils.import(
|
||||||
|
"resource://gre/modules/ActorChild.jsm"
|
||||||
|
);
|
||||||
|
|
||||||
function getMessageManager(event) {
|
function getMessageManager(event) {
|
||||||
let window = Cu.getGlobalForObject(event.target);
|
let window = Cu.getGlobalForObject(event.target);
|
||||||
|
|
@ -46,14 +48,17 @@ class WebChannelChild extends ActorChild {
|
||||||
if (whitelist != _lastWhitelistValue) {
|
if (whitelist != _lastWhitelistValue) {
|
||||||
let urls = whitelist.split(/\s+/);
|
let urls = whitelist.split(/\s+/);
|
||||||
_cachedWhitelist = urls.map(origin =>
|
_cachedWhitelist = urls.map(origin =>
|
||||||
Services.scriptSecurityManager.createCodebasePrincipalFromOrigin(origin));
|
Services.scriptSecurityManager.createCodebasePrincipalFromOrigin(origin)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return _cachedWhitelist;
|
return _cachedWhitelist;
|
||||||
}
|
}
|
||||||
|
|
||||||
_onMessageToChrome(e) {
|
_onMessageToChrome(e) {
|
||||||
// If target is window then we want the document principal, otherwise fallback to target itself.
|
// If target is window then we want the document principal, otherwise fallback to target itself.
|
||||||
let principal = e.target.nodePrincipal ? e.target.nodePrincipal : e.target.document.nodePrincipal;
|
let principal = e.target.nodePrincipal
|
||||||
|
? e.target.nodePrincipal
|
||||||
|
: e.target.document.nodePrincipal;
|
||||||
|
|
||||||
if (e.detail) {
|
if (e.detail) {
|
||||||
if (typeof e.detail != "string") {
|
if (typeof e.detail != "string") {
|
||||||
|
|
@ -61,17 +66,25 @@ class WebChannelChild extends ActorChild {
|
||||||
// non-string values for e.detail. They're whitelisted by site origin,
|
// non-string values for e.detail. They're whitelisted by site origin,
|
||||||
// so we compare on originNoSuffix in order to avoid other origin attributes
|
// so we compare on originNoSuffix in order to avoid other origin attributes
|
||||||
// that are not relevant here, such as containers or private browsing.
|
// that are not relevant here, such as containers or private browsing.
|
||||||
let objectsAllowed = this._getWhitelistedPrincipals().some(whitelisted =>
|
let objectsAllowed = this._getWhitelistedPrincipals().some(
|
||||||
principal.originNoSuffix == whitelisted.originNoSuffix);
|
whitelisted => principal.originNoSuffix == whitelisted.originNoSuffix
|
||||||
|
);
|
||||||
if (!objectsAllowed) {
|
if (!objectsAllowed) {
|
||||||
Cu.reportError("WebChannelMessageToChrome sent with an object from a non-whitelisted principal");
|
Cu.reportError(
|
||||||
|
"WebChannelMessageToChrome sent with an object from a non-whitelisted principal"
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mm = getMessageManager(e);
|
let mm = getMessageManager(e);
|
||||||
|
|
||||||
mm.sendAsyncMessage("WebChannelMessageToChrome", e.detail, { eventTarget: e.target }, principal);
|
mm.sendAsyncMessage(
|
||||||
|
"WebChannelMessageToChrome",
|
||||||
|
e.detail,
|
||||||
|
{ eventTarget: e.target },
|
||||||
|
principal
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
Cu.reportError("WebChannel message failed. No message detail.");
|
Cu.reportError("WebChannel message failed. No message detail.");
|
||||||
}
|
}
|
||||||
|
|
@ -86,19 +99,30 @@ class WebChannelChild extends ActorChild {
|
||||||
let eventTarget = msg.objects.eventTarget || msg.target.content;
|
let eventTarget = msg.objects.eventTarget || msg.target.content;
|
||||||
|
|
||||||
// Use nodePrincipal if available, otherwise fallback to document principal.
|
// Use nodePrincipal if available, otherwise fallback to document principal.
|
||||||
let targetPrincipal = eventTarget instanceof Ci.nsIDOMWindow ? eventTarget.document.nodePrincipal : eventTarget.nodePrincipal;
|
let targetPrincipal =
|
||||||
|
eventTarget instanceof Ci.nsIDOMWindow
|
||||||
|
? eventTarget.document.nodePrincipal
|
||||||
|
: eventTarget.nodePrincipal;
|
||||||
|
|
||||||
if (msg.principal.subsumes(targetPrincipal)) {
|
if (msg.principal.subsumes(targetPrincipal)) {
|
||||||
// If eventTarget is a window, use it as the targetWindow, otherwise
|
// If eventTarget is a window, use it as the targetWindow, otherwise
|
||||||
// find the window that owns the eventTarget.
|
// find the window that owns the eventTarget.
|
||||||
let targetWindow = eventTarget instanceof Ci.nsIDOMWindow ? eventTarget : eventTarget.ownerGlobal;
|
let targetWindow =
|
||||||
|
eventTarget instanceof Ci.nsIDOMWindow
|
||||||
|
? eventTarget
|
||||||
|
: eventTarget.ownerGlobal;
|
||||||
|
|
||||||
eventTarget.dispatchEvent(new targetWindow.CustomEvent("WebChannelMessageToContent", {
|
eventTarget.dispatchEvent(
|
||||||
detail: Cu.cloneInto({
|
new targetWindow.CustomEvent("WebChannelMessageToContent", {
|
||||||
id: msg.data.id,
|
detail: Cu.cloneInto(
|
||||||
message: msg.data.message,
|
{
|
||||||
}, targetWindow),
|
id: msg.data.id,
|
||||||
}));
|
message: msg.data.message,
|
||||||
|
},
|
||||||
|
targetWindow
|
||||||
|
),
|
||||||
|
})
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
Cu.reportError("WebChannel message failed. Principal mismatch.");
|
Cu.reportError("WebChannel message failed. Principal mismatch.");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,18 +6,31 @@
|
||||||
|
|
||||||
var EXPORTED_SYMBOLS = ["WebNavigationChild"];
|
var EXPORTED_SYMBOLS = ["WebNavigationChild"];
|
||||||
|
|
||||||
const {ActorChild} = ChromeUtils.import("resource://gre/modules/ActorChild.jsm");
|
const { ActorChild } = ChromeUtils.import(
|
||||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
"resource://gre/modules/ActorChild.jsm"
|
||||||
const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
);
|
||||||
|
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
|
const { XPCOMUtils } = ChromeUtils.import(
|
||||||
|
"resource://gre/modules/XPCOMUtils.jsm"
|
||||||
|
);
|
||||||
|
|
||||||
ChromeUtils.defineModuleGetter(this, "AppConstants",
|
ChromeUtils.defineModuleGetter(
|
||||||
"resource://gre/modules/AppConstants.jsm");
|
this,
|
||||||
ChromeUtils.defineModuleGetter(this, "E10SUtils",
|
"AppConstants",
|
||||||
"resource://gre/modules/E10SUtils.jsm");
|
"resource://gre/modules/AppConstants.jsm"
|
||||||
|
);
|
||||||
|
ChromeUtils.defineModuleGetter(
|
||||||
|
this,
|
||||||
|
"E10SUtils",
|
||||||
|
"resource://gre/modules/E10SUtils.jsm"
|
||||||
|
);
|
||||||
|
|
||||||
XPCOMUtils.defineLazyServiceGetter(this, "CrashReporter",
|
XPCOMUtils.defineLazyServiceGetter(
|
||||||
"@mozilla.org/xre/app-info;1",
|
this,
|
||||||
"nsICrashReporter");
|
"CrashReporter",
|
||||||
|
"@mozilla.org/xre/app-info;1",
|
||||||
|
"nsICrashReporter"
|
||||||
|
);
|
||||||
|
|
||||||
class WebNavigationChild extends ActorChild {
|
class WebNavigationChild extends ActorChild {
|
||||||
get webNavigation() {
|
get webNavigation() {
|
||||||
|
|
@ -54,7 +67,8 @@ class WebNavigationChild extends ActorChild {
|
||||||
try {
|
try {
|
||||||
fn();
|
fn();
|
||||||
} finally {
|
} finally {
|
||||||
this.mm.docShell.QueryInterface(Ci.nsIInterfaceRequestor)
|
this.mm.docShell
|
||||||
|
.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||||
.getInterface(Ci.nsIBrowserChild)
|
.getInterface(Ci.nsIBrowserChild)
|
||||||
.notifyNavigationFinished();
|
.notifyNavigationFinished();
|
||||||
}
|
}
|
||||||
|
|
@ -75,10 +89,7 @@ class WebNavigationChild extends ActorChild {
|
||||||
}
|
}
|
||||||
|
|
||||||
gotoIndex(params) {
|
gotoIndex(params) {
|
||||||
let {
|
let { index, cancelContentJSEpoch } = params || {};
|
||||||
index,
|
|
||||||
cancelContentJSEpoch,
|
|
||||||
} = params || {};
|
|
||||||
this.mm.docShell.setCancelContentJSEpoch(cancelContentJSEpoch);
|
this.mm.docShell.setCancelContentJSEpoch(cancelContentJSEpoch);
|
||||||
this._wrapURIChangeCall(() => this.webNavigation.gotoIndex(index));
|
this._wrapURIChangeCall(() => this.webNavigation.gotoIndex(index));
|
||||||
}
|
}
|
||||||
|
|
@ -101,26 +112,43 @@ class WebNavigationChild extends ActorChild {
|
||||||
try {
|
try {
|
||||||
let url = Services.io.newURI(uri);
|
let url = Services.io.newURI(uri);
|
||||||
// If the current URI contains a username/password, remove it.
|
// If the current URI contains a username/password, remove it.
|
||||||
url = url.mutate()
|
url = url
|
||||||
.setUserPass("")
|
.mutate()
|
||||||
.finalize();
|
.setUserPass("")
|
||||||
|
.finalize();
|
||||||
annotation = url.spec;
|
annotation = url.spec;
|
||||||
} catch (ex) { /* Ignore failures to parse and failures
|
} catch (ex) {
|
||||||
on about: URIs. */ }
|
/* Ignore failures to parse and failures
|
||||||
|
on about: URIs. */
|
||||||
|
}
|
||||||
CrashReporter.annotateCrashReport("URL", annotation);
|
CrashReporter.annotateCrashReport("URL", annotation);
|
||||||
}
|
}
|
||||||
if (postData)
|
if (postData) {
|
||||||
postData = E10SUtils.makeInputStream(postData);
|
postData = E10SUtils.makeInputStream(postData);
|
||||||
if (headers)
|
}
|
||||||
|
if (headers) {
|
||||||
headers = E10SUtils.makeInputStream(headers);
|
headers = E10SUtils.makeInputStream(headers);
|
||||||
if (baseURI)
|
}
|
||||||
|
if (baseURI) {
|
||||||
baseURI = Services.io.newURI(baseURI);
|
baseURI = Services.io.newURI(baseURI);
|
||||||
this._assert(triggeringPrincipal, "We need a triggering principal to continue loading", new Error().lineNumber);
|
}
|
||||||
|
this._assert(
|
||||||
|
triggeringPrincipal,
|
||||||
|
"We need a triggering principal to continue loading",
|
||||||
|
new Error().lineNumber
|
||||||
|
);
|
||||||
|
|
||||||
triggeringPrincipal = E10SUtils.deserializePrincipal(triggeringPrincipal, () => {
|
triggeringPrincipal = E10SUtils.deserializePrincipal(
|
||||||
this._assert(false, "Unable to deserialize passed triggering principal", new Error().lineNumber);
|
triggeringPrincipal,
|
||||||
return Services.scriptSecurityManager.getSystemPrincipal({});
|
() => {
|
||||||
});
|
this._assert(
|
||||||
|
false,
|
||||||
|
"Unable to deserialize passed triggering principal",
|
||||||
|
new Error().lineNumber
|
||||||
|
);
|
||||||
|
return Services.scriptSecurityManager.getSystemPrincipal({});
|
||||||
|
}
|
||||||
|
);
|
||||||
if (csp) {
|
if (csp) {
|
||||||
csp = E10SUtils.deserializeCSP(csp);
|
csp = E10SUtils.deserializeCSP(csp);
|
||||||
}
|
}
|
||||||
|
|
@ -143,7 +171,11 @@ class WebNavigationChild extends ActorChild {
|
||||||
_assert(condition, msg, line = 0) {
|
_assert(condition, msg, line = 0) {
|
||||||
let debug = Cc["@mozilla.org/xpcom/debug;1"].getService(Ci.nsIDebug2);
|
let debug = Cc["@mozilla.org/xpcom/debug;1"].getService(Ci.nsIDebug2);
|
||||||
if (!condition && debug.isDebugBuild) {
|
if (!condition && debug.isDebugBuild) {
|
||||||
debug.warning(`${msg} - ${new Error().stack}`, "WebNavigationChild.js", line);
|
debug.warning(
|
||||||
|
`${msg} - ${new Error().stack}`,
|
||||||
|
"WebNavigationChild.js",
|
||||||
|
line
|
||||||
|
);
|
||||||
debug.abort("WebNavigationChild.js", line);
|
debug.abort("WebNavigationChild.js", line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,32 +16,28 @@ class ZoomParent extends JSWindowActorParent {
|
||||||
let document = browser.ownerGlobal.document;
|
let document = browser.ownerGlobal.document;
|
||||||
|
|
||||||
switch (message.name) {
|
switch (message.name) {
|
||||||
case "FullZoomChange":
|
case "FullZoomChange": {
|
||||||
{
|
browser._fullZoom = message.data.value;
|
||||||
browser._fullZoom = message.data.value;
|
let event = document.createEvent("Events");
|
||||||
let event = document.createEvent("Events");
|
event.initEvent("FullZoomChange", true, false);
|
||||||
event.initEvent("FullZoomChange", true, false);
|
browser.dispatchEvent(event);
|
||||||
browser.dispatchEvent(event);
|
break;
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
case "TextZoomChange":
|
case "TextZoomChange": {
|
||||||
{
|
browser._textZoom = message.data.value;
|
||||||
browser._textZoom = message.data.value;
|
let event = document.createEvent("Events");
|
||||||
let event = document.createEvent("Events");
|
event.initEvent("TextZoomChange", true, false);
|
||||||
event.initEvent("TextZoomChange", true, false);
|
browser.dispatchEvent(event);
|
||||||
browser.dispatchEvent(event);
|
break;
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
case "ZoomChangeUsingMouseWheel":
|
case "ZoomChangeUsingMouseWheel": {
|
||||||
{
|
let event = document.createEvent("Events");
|
||||||
let event = document.createEvent("Events");
|
event.initEvent("ZoomChangeUsingMouseWheel", true, false);
|
||||||
event.initEvent("ZoomChangeUsingMouseWheel", true, false);
|
browser.dispatchEvent(event);
|
||||||
browser.dispatchEvent(event);
|
break;
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue