зеркало из https://github.com/mozilla/gecko-dev.git
Merge m-c to b2g-inbound.
This commit is contained in:
Коммит
f826d1a97f
2
CLOBBER
2
CLOBBER
|
@ -22,4 +22,4 @@
|
|||
# changes to stick? As of bug 928195, this shouldn't be necessary! Please
|
||||
# don't change CLOBBER for WebIDL changes any more.
|
||||
|
||||
Bug 1004726 requires a clobber for B2G Emulator builds
|
||||
Bug 994964 apparently requires a clobber, unclear why
|
||||
|
|
|
@ -408,8 +408,7 @@ logging::DocLoad(const char* aMsg, nsIWebProgress* aWebProgress,
|
|||
|
||||
LogDocInfo(documentNode, document);
|
||||
|
||||
nsCOMPtr<nsIWebNavigation> webNav(do_GetInterface(DOMWindow));
|
||||
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(webNav));
|
||||
nsCOMPtr<nsIDocShell> docShell = window->GetDocShell();
|
||||
printf("\n ");
|
||||
LogShellLoadType(docShell);
|
||||
printf("\n");
|
||||
|
|
|
@ -151,8 +151,19 @@ this.Utils = {
|
|||
get AllMessageManagers() {
|
||||
let messageManagers = [];
|
||||
|
||||
for (let i = 0; i < this.win.messageManager.childCount; i++)
|
||||
messageManagers.push(this.win.messageManager.getChildAt(i));
|
||||
function collectLeafMessageManagers(mm) {
|
||||
for (let i = 0; i < mm.childCount; i++) {
|
||||
let childMM = mm.getChildAt(i);
|
||||
|
||||
if ("sendAsyncMessage" in childMM) {
|
||||
messageManagers.push(childMM);
|
||||
} else {
|
||||
collectLeafMessageManagers(childMM);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
collectLeafMessageManagers(this.win.messageManager);
|
||||
|
||||
let document = this.CurrentContentDoc;
|
||||
|
||||
|
|
|
@ -946,6 +946,11 @@ pref("apz.enlarge_displayport_when_clipped", true);
|
|||
pref("apz.axis_lock_mode", 2);
|
||||
pref("apz.subframe.enabled", true);
|
||||
|
||||
// Overscroll-related settings
|
||||
pref("apz.overscroll.enabled", false);
|
||||
pref("apz.overscroll.snap_back_accel", "0.003");
|
||||
pref("apz.overscroll.snap_back_init_vel", "1");
|
||||
|
||||
// This preference allows FirefoxOS apps (and content, I think) to force
|
||||
// the use of software (instead of hardware accelerated) 2D canvases by
|
||||
// creating a context like this:
|
||||
|
|
|
@ -643,6 +643,7 @@ let settingsToObserve = {
|
|||
prefName: 'dom.browser_frames.useAsyncPanZoom',
|
||||
defaultValue: false
|
||||
},
|
||||
'apz.overscroll.enabled': false,
|
||||
'debug.fps.enabled': {
|
||||
prefName: 'layers.acceleration.draw-fps',
|
||||
defaultValue: false
|
||||
|
|
|
@ -1340,6 +1340,7 @@ pref("devtools.scratchpad.enableAutocompletion", true);
|
|||
pref("devtools.styleeditor.enabled", true);
|
||||
pref("devtools.styleeditor.source-maps-enabled", false);
|
||||
pref("devtools.styleeditor.autocompletion-enabled", true);
|
||||
pref("devtools.styleeditor.showMediaSidebar", false);
|
||||
|
||||
// Enable the Shader Editor.
|
||||
pref("devtools.shadereditor.enabled", false);
|
||||
|
|
|
@ -425,8 +425,8 @@
|
|||
<key id="key_sanitize" command="Tools:Sanitize" keycode="VK_DELETE" modifiers="accel,shift"/>
|
||||
#ifdef XP_MACOSX
|
||||
<key id="key_sanitize_mac" command="Tools:Sanitize" keycode="VK_BACK" modifiers="accel,shift"/>
|
||||
#endif
|
||||
#ifdef XP_UNIX
|
||||
<key id="key_quitApplication" key="&quitApplicationCmdUnix.key;" modifiers="accel"/>
|
||||
#elifdef XP_UNIX
|
||||
<key id="key_quitApplication" key="&quitApplicationCmdUnix.key;" command="cmd_quitApplication" modifiers="accel"/>
|
||||
#endif
|
||||
|
||||
|
|
|
@ -19,6 +19,11 @@ window.sawEvent = function(event, isattr) {
|
|||
|
||||
registerCleanupFunction(() => {
|
||||
delete window.sawEvent;
|
||||
|
||||
// Ensure sidebar is hidden after each test:
|
||||
if (!document.getElementById("sidebar-box").hidden) {
|
||||
toggleSidebar("", false);
|
||||
}
|
||||
});
|
||||
|
||||
function checkExpectedEvents(expected) {
|
||||
|
@ -84,7 +89,7 @@ add_task(function*() {
|
|||
document.getElementById("customizationui-widget-panel").hidePopup();
|
||||
yield subviewHiddenPromise;
|
||||
|
||||
yield resetCustomization();
|
||||
return resetCustomization();
|
||||
});
|
||||
|
||||
function add_sidebar_task(description, setup, teardown) {
|
||||
|
|
|
@ -96,7 +96,12 @@ add_task(function*() {
|
|||
},
|
||||
onWindowClosed: function(aWindow) {
|
||||
if (aWindow == otherWin) {
|
||||
info("Got window closed notification for correct window.");
|
||||
windowClosed = aWindow;
|
||||
} else {
|
||||
info("Other window was closed!");
|
||||
info("Other window title: " + (aWindow.document && aWindow.document.title));
|
||||
info("Our window title: " + (otherWin.document && otherWin.document.title));
|
||||
}
|
||||
},
|
||||
};
|
||||
|
@ -105,7 +110,6 @@ add_task(function*() {
|
|||
|
||||
is(windowClosed, otherWin, "Window should have sent onWindowClosed notification.");
|
||||
ok(wasInformedCorrectlyOfAreaDisappearing, "Should be told about window closing.");
|
||||
CustomizableUI.removeListener(listener);
|
||||
// Closing the other window should not be counted against this window's customize mode:
|
||||
is(syncButton.parentNode.localName, "toolbarpaletteitem", "Sync button's parent node should still be a wrapper.");
|
||||
isnot(gCustomizeMode.areas.indexOf(toolbar), -1, "Toolbar should still be a customizable area for this customize mode instance.");
|
||||
|
@ -114,6 +118,7 @@ add_task(function*() {
|
|||
|
||||
yield endCustomizing();
|
||||
|
||||
CustomizableUI.removeListener(listener);
|
||||
wasInformedCorrectlyOfAreaDisappearing = false;
|
||||
listener = {
|
||||
onAreaNodeUnregistered: function(aArea, aNode, aReason) {
|
||||
|
|
|
@ -915,24 +915,24 @@ nsWindowsShellService::SetDesktopBackground(nsIDOMElement* aElement,
|
|||
nsAutoString style;
|
||||
switch (aPosition) {
|
||||
case BACKGROUND_TILE:
|
||||
style.AssignLiteral("0");
|
||||
tile.AssignLiteral("1");
|
||||
style.Assign('0');
|
||||
tile.Assign('1');
|
||||
break;
|
||||
case BACKGROUND_CENTER:
|
||||
style.AssignLiteral("0");
|
||||
tile.AssignLiteral("0");
|
||||
style.Assign('0');
|
||||
tile.Assign('0');
|
||||
break;
|
||||
case BACKGROUND_STRETCH:
|
||||
style.AssignLiteral("2");
|
||||
tile.AssignLiteral("0");
|
||||
style.Assign('2');
|
||||
tile.Assign('0');
|
||||
break;
|
||||
case BACKGROUND_FILL:
|
||||
style.AssignLiteral("10");
|
||||
tile.AssignLiteral("0");
|
||||
tile.Assign('0');
|
||||
break;
|
||||
case BACKGROUND_FIT:
|
||||
style.AssignLiteral("6");
|
||||
tile.AssignLiteral("0");
|
||||
style.Assign('6');
|
||||
tile.Assign('0');
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -990,7 +990,7 @@ nsWindowsShellService::OpenApplication(int32_t aApplication)
|
|||
::RegCloseKey(theKey);
|
||||
|
||||
// Find the "open" command
|
||||
application.AppendLiteral("\\");
|
||||
application.Append('\\');
|
||||
application.Append(buf);
|
||||
application.AppendLiteral("\\shell\\open\\command");
|
||||
|
||||
|
|
|
@ -69,6 +69,13 @@ TranslationUI.prototype = {
|
|||
STATE_ERROR: 3,
|
||||
|
||||
translate: function(aFrom, aTo) {
|
||||
if (aFrom == aTo ||
|
||||
(this.state == this.STATE_TRANSLATED &&
|
||||
this.translatedFrom == aFrom && this.translatedTo == aTo)) {
|
||||
// Nothing to do.
|
||||
return;
|
||||
}
|
||||
|
||||
this.state = this.STATE_TRANSLATING;
|
||||
this.translatedFrom = aFrom;
|
||||
this.translatedTo = aTo;
|
||||
|
@ -127,7 +134,7 @@ TranslationUI.prototype = {
|
|||
this.browser.messageManager.sendAsyncMessage("Translation:ShowTranslation");
|
||||
},
|
||||
|
||||
get notificationBox() this.browser.ownerGlobal.gBrowser.getNotificationBox(),
|
||||
get notificationBox() this.browser.ownerGlobal.gBrowser.getNotificationBox(this.browser),
|
||||
|
||||
showTranslationInfoBar: function() {
|
||||
let notificationBox = this.notificationBox;
|
||||
|
|
|
@ -94,6 +94,7 @@ support-files =
|
|||
[browser_dbg_addon-modules-unpacked.js]
|
||||
[browser_dbg_addon-panels.js]
|
||||
[browser_dbg_addon-console.js]
|
||||
skip-if = os == 'win' # bug 1005274
|
||||
[browser_dbg_auto-pretty-print-01.js]
|
||||
[browser_dbg_auto-pretty-print-02.js]
|
||||
[browser_dbg_bfcache.js]
|
||||
|
|
|
@ -107,7 +107,7 @@ let onConnectionReady = Task.async(function*(aType, aTraits) {
|
|||
parent = document.getElementById("tabActors");
|
||||
|
||||
// Add Global Process debugging...
|
||||
let globals = JSON.parse(JSON.stringify(response));
|
||||
let globals = Cu.cloneInto(response, {});
|
||||
delete globals.tabs;
|
||||
delete globals.selected;
|
||||
// ...only if there are appropriate actors (a 'from' property will always
|
||||
|
|
|
@ -429,7 +429,7 @@ let ParserHelpers = {
|
|||
parentType == "FunctionExpression") {
|
||||
// e.g. "function foo() {}" or "{ bar: function foo() {} }"
|
||||
// The location is unavailable for the identifier node "foo".
|
||||
let loc = JSON.parse(JSON.stringify(parentLocation));
|
||||
let loc = Cu.cloneInto(parentLocation, {});
|
||||
loc.end.line = loc.start.line;
|
||||
loc.end.column = loc.start.column + aNode.name.length;
|
||||
return loc;
|
||||
|
@ -437,7 +437,7 @@ let ParserHelpers = {
|
|||
if (parentType == "MemberExpression") {
|
||||
// e.g. "foo.bar"
|
||||
// The location is unavailable for the identifier node "bar".
|
||||
let loc = JSON.parse(JSON.stringify(parentLocation));
|
||||
let loc = Cu.cloneInto(parentLocation, {});
|
||||
loc.start.line = loc.end.line;
|
||||
loc.start.column = loc.end.column - aNode.name.length;
|
||||
return loc;
|
||||
|
@ -445,7 +445,7 @@ let ParserHelpers = {
|
|||
if (parentType == "LabeledStatement") {
|
||||
// e.g. label: ...
|
||||
// The location is unavailable for the identifier node "label".
|
||||
let loc = JSON.parse(JSON.stringify(parentLocation));
|
||||
let loc = Cu.cloneInto(parentLocation, {});
|
||||
loc.end.line = loc.start.line;
|
||||
loc.end.column = loc.start.column + aNode.name.length;
|
||||
return loc;
|
||||
|
@ -453,7 +453,7 @@ let ParserHelpers = {
|
|||
if (parentType == "ContinueStatement") {
|
||||
// e.g. continue label
|
||||
// The location is unavailable for the identifier node "label".
|
||||
let loc = JSON.parse(JSON.stringify(parentLocation));
|
||||
let loc = Cu.cloneInto(parentLocation, {});
|
||||
loc.start.line = loc.end.line;
|
||||
loc.start.column = loc.end.column - aNode.name.length;
|
||||
return loc;
|
||||
|
@ -463,7 +463,7 @@ let ParserHelpers = {
|
|||
// e.g. "let foo = 42"
|
||||
// The location incorrectly spans across the whole variable declaration,
|
||||
// not just the identifier node "foo".
|
||||
let loc = JSON.parse(JSON.stringify(nodeLocation));
|
||||
let loc = Cu.cloneInto(nodeLocation, {});
|
||||
loc.end.line = loc.start.line;
|
||||
loc.end.column = loc.start.column + aNode.name.length;
|
||||
return loc;
|
||||
|
|
|
@ -33,6 +33,7 @@ const console = require("resource://gre/modules/devtools/Console.jsm").console;
|
|||
|
||||
const LOAD_ERROR = "error-load";
|
||||
const STYLE_EDITOR_TEMPLATE = "stylesheet";
|
||||
const PREF_MEDIA_SIDEBAR = "devtools.styleeditor.showMediaSidebar";
|
||||
|
||||
/**
|
||||
* StyleEditorUI is controls and builds the UI of the Style Editor, including
|
||||
|
@ -63,14 +64,17 @@ function StyleEditorUI(debuggee, target, panelDoc) {
|
|||
this.selectedEditor = null;
|
||||
this.savedLocations = {};
|
||||
|
||||
this._updateSourcesLabel = this._updateSourcesLabel.bind(this);
|
||||
this._updateContextMenu = this._updateContextMenu.bind(this);
|
||||
this._onStyleSheetCreated = this._onStyleSheetCreated.bind(this);
|
||||
this._onNewDocument = this._onNewDocument.bind(this);
|
||||
this._onMediaPrefChanged = this._onMediaPrefChanged.bind(this);
|
||||
this._updateMediaList = this._updateMediaList.bind(this);
|
||||
this._clear = this._clear.bind(this);
|
||||
this._onError = this._onError.bind(this);
|
||||
|
||||
this._prefObserver = new PrefObserver("devtools.styleeditor.");
|
||||
this._prefObserver.on(PREF_ORIG_SOURCES, this._onNewDocument);
|
||||
this._prefObserver.on(PREF_MEDIA_SIDEBAR, this._onMediaPrefChanged);
|
||||
}
|
||||
|
||||
StyleEditorUI.prototype = {
|
||||
|
@ -140,24 +144,34 @@ StyleEditorUI.prototype = {
|
|||
|
||||
this._contextMenu = this._panelDoc.getElementById("sidebar-context");
|
||||
this._contextMenu.addEventListener("popupshowing",
|
||||
this._updateSourcesLabel);
|
||||
this._updateContextMenu);
|
||||
|
||||
this._sourcesItem = this._panelDoc.getElementById("context-origsources");
|
||||
this._sourcesItem.addEventListener("command",
|
||||
this._toggleOrigSources);
|
||||
this._mediaItem = this._panelDoc.getElementById("context-show-media");
|
||||
this._mediaItem.addEventListener("command",
|
||||
this._toggleMediaSidebar);
|
||||
},
|
||||
|
||||
/**
|
||||
* Update text of context menu option to reflect whether we're showing
|
||||
* original sources (e.g. Sass files) or not.
|
||||
* Update text of context menu option to reflect current preference
|
||||
* settings
|
||||
*/
|
||||
_updateSourcesLabel: function() {
|
||||
let string = "showOriginalSources";
|
||||
_updateContextMenu: function() {
|
||||
let sourceString = "showOriginalSources";
|
||||
if (Services.prefs.getBoolPref(PREF_ORIG_SOURCES)) {
|
||||
string = "showCSSSources";
|
||||
sourceString = "showCSSSources";
|
||||
}
|
||||
this._sourcesItem.setAttribute("label", _(string + ".label"));
|
||||
this._sourcesItem.setAttribute("accesskey", _(string + ".accesskey"));
|
||||
this._sourcesItem.setAttribute("label", _(sourceString + ".label"));
|
||||
this._sourcesItem.setAttribute("accesskey", _(sourceString + ".accesskey"));
|
||||
|
||||
let mediaString = "showMediaSidebar"
|
||||
if (Services.prefs.getBoolPref(PREF_MEDIA_SIDEBAR)) {
|
||||
mediaString = "hideMediaSidebar";
|
||||
}
|
||||
this._mediaItem.setAttribute("label", _(mediaString + ".label"));
|
||||
this._mediaItem.setAttribute("accesskey", _(mediaString + ".accesskey"));
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -202,7 +216,7 @@ StyleEditorUI.prototype = {
|
|||
let {line, ch} = this.selectedEditor.sourceEditor.getCursor();
|
||||
|
||||
this._styleSheetToSelect = {
|
||||
href: href,
|
||||
stylesheet: href,
|
||||
line: line,
|
||||
col: ch
|
||||
};
|
||||
|
@ -274,6 +288,7 @@ StyleEditorUI.prototype = {
|
|||
new StyleSheetEditor(styleSheet, this._window, file, isNew, this._walker);
|
||||
|
||||
editor.on("property-change", this._summaryChange.bind(this, editor));
|
||||
editor.on("media-rules-changed", this._updateMediaList.bind(this, editor));
|
||||
editor.on("linked-css-file", this._summaryChange.bind(this, editor));
|
||||
editor.on("linked-css-file-error", this._summaryChange.bind(this, editor));
|
||||
editor.on("error", this._onError);
|
||||
|
@ -302,7 +317,7 @@ StyleEditorUI.prototype = {
|
|||
}
|
||||
NetUtil.asyncFetch(file, (stream, status) => {
|
||||
if (!Components.isSuccessCode(status)) {
|
||||
this.emit("error", LOAD_ERROR);
|
||||
this.emit("error", { key: LOAD_ERROR });
|
||||
return;
|
||||
}
|
||||
let source = NetUtil.readInputStreamToString(stream, stream.available());
|
||||
|
@ -332,23 +347,36 @@ StyleEditorUI.prototype = {
|
|||
*
|
||||
* @param {string} event
|
||||
* Event name
|
||||
* @param {string} errorCode
|
||||
* Code represeting type of error
|
||||
* @param {string} message
|
||||
* The full error message
|
||||
* @param {data} data
|
||||
* The event data
|
||||
*/
|
||||
_onError: function(event, errorCode, message) {
|
||||
this.emit("error", errorCode, message);
|
||||
_onError: function(event, data) {
|
||||
this.emit("error", data);
|
||||
},
|
||||
|
||||
/**
|
||||
* Toggle the original sources pref.
|
||||
* Toggle the original sources pref.
|
||||
*/
|
||||
_toggleOrigSources: function() {
|
||||
let isEnabled = Services.prefs.getBoolPref(PREF_ORIG_SOURCES);
|
||||
Services.prefs.setBoolPref(PREF_ORIG_SOURCES, !isEnabled);
|
||||
},
|
||||
|
||||
/**
|
||||
* Toggle the pref for showing a @media rules sidebar in each editor.
|
||||
*/
|
||||
_toggleMediaSidebar: function() {
|
||||
let isEnabled = Services.prefs.getBoolPref(PREF_MEDIA_SIDEBAR);
|
||||
Services.prefs.setBoolPref(PREF_MEDIA_SIDEBAR, !isEnabled);
|
||||
},
|
||||
|
||||
/**
|
||||
* Toggle the @media sidebar in each editor depending on the setting.
|
||||
*/
|
||||
_onMediaPrefChanged: function() {
|
||||
this.editors.forEach(this._updateMediaList);
|
||||
},
|
||||
|
||||
/**
|
||||
* Remove a particular stylesheet editor from the UI
|
||||
*
|
||||
|
@ -401,6 +429,7 @@ StyleEditorUI.prototype = {
|
|||
onCreate: function(summary, details, data) {
|
||||
let editor = data.editor;
|
||||
editor.summary = summary;
|
||||
editor.details = details;
|
||||
|
||||
wire(summary, ".stylesheet-enabled", function onToggleDisabled(event) {
|
||||
event.stopPropagation();
|
||||
|
@ -442,7 +471,7 @@ StyleEditorUI.prototype = {
|
|||
}
|
||||
|
||||
if (this._styleSheetToSelect
|
||||
&& this._styleSheetToSelect.href == editor.styleSheet.href) {
|
||||
&& this._styleSheetToSelect.stylesheet == editor.styleSheet.href) {
|
||||
yield this.switchToSelectedSheet();
|
||||
}
|
||||
|
||||
|
@ -470,15 +499,29 @@ StyleEditorUI.prototype = {
|
|||
|
||||
editor.onShow();
|
||||
|
||||
this.emit("editor-selected", editor);
|
||||
|
||||
// Is there any CSS coverage markup to include?
|
||||
csscoverage.getUsage(this._target).then(usage => {
|
||||
let href = editor.styleSheet.href || editor.styleSheet.nodeHref;
|
||||
usage.createEditorReport(href).then(data => {
|
||||
editor.removeAllUnusedRegions();
|
||||
editor.addUnusedRegions(data.reports);
|
||||
|
||||
if (data.reports.length > 0) {
|
||||
// So there is some coverage markup, but can we apply it?
|
||||
let text = editor.sourceEditor.getText() + "\r";
|
||||
// If the CSS text contains a '}' with some non-whitespace
|
||||
// after then we assume this is compressed CSS and stop
|
||||
// marking-up.
|
||||
if (!/}\s*\S+\s*\r/.test(text)) {
|
||||
editor.addUnusedRegions(data.reports);
|
||||
}
|
||||
else {
|
||||
this.emit("error", { key: "error-compressed", level: "info" });
|
||||
}
|
||||
}
|
||||
});
|
||||
}, console.error);
|
||||
|
||||
this.emit("editor-selected", editor);
|
||||
}.bind(this)).then(null, Cu.reportError);
|
||||
}.bind(this)
|
||||
});
|
||||
|
@ -492,9 +535,11 @@ StyleEditorUI.prototype = {
|
|||
*/
|
||||
switchToSelectedSheet: function() {
|
||||
let sheet = this._styleSheetToSelect;
|
||||
let isHref = sheet.stylesheet === null || typeof sheet.stylesheet == "string";
|
||||
|
||||
for (let editor of this.editors) {
|
||||
if (editor.styleSheet.href == sheet.href) {
|
||||
if ((isHref && editor.styleSheet.href == sheet.stylesheet) ||
|
||||
sheet.stylesheet == editor.styleSheet) {
|
||||
// The _styleSheetBoundToSelect will always hold the latest pending
|
||||
// requested style sheet (with line and column) which is not yet
|
||||
// selected by the source editor. Only after we select that particular
|
||||
|
@ -554,6 +599,24 @@ StyleEditorUI.prototype = {
|
|||
return deferred.promise;
|
||||
},
|
||||
|
||||
getEditorDetails: function(editor) {
|
||||
if (editor.details) {
|
||||
return promise.resolve(editor.details);
|
||||
}
|
||||
|
||||
let deferred = promise.defer();
|
||||
let self = this;
|
||||
|
||||
this.on("editor-added", function onAdd(e, selected) {
|
||||
if (selected == editor) {
|
||||
self.off("editor-added", onAdd);
|
||||
deferred.resolve(editor.details);
|
||||
}
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns an identifier for the given style sheet.
|
||||
*
|
||||
|
@ -569,19 +632,16 @@ StyleEditorUI.prototype = {
|
|||
/**
|
||||
* selects a stylesheet and optionally moves the cursor to a selected line
|
||||
*
|
||||
* @param {string} [href]
|
||||
* Href of stylesheet that should be selected. If a stylesheet is not passed
|
||||
* and the editor is not initialized we focus the first stylesheet. If
|
||||
* a stylesheet is not passed and the editor is initialized we ignore
|
||||
* the call.
|
||||
* @param {StyleSheetFront} [stylesheet]
|
||||
* Stylesheet to select or href of stylesheet to select
|
||||
* @param {Number} [line]
|
||||
* Line to which the caret should be moved (zero-indexed).
|
||||
* @param {Number} [col]
|
||||
* Column to which the caret should be moved (zero-indexed).
|
||||
*/
|
||||
selectStyleSheet: function(href, line, col) {
|
||||
selectStyleSheet: function(stylesheet, line, col) {
|
||||
this._styleSheetToSelect = {
|
||||
href: href,
|
||||
stylesheet: stylesheet,
|
||||
line: line,
|
||||
col: col,
|
||||
};
|
||||
|
@ -653,10 +713,66 @@ StyleEditorUI.prototype = {
|
|||
PluralForm.get(ruleCount, _("ruleCount.label")).replace("#1", ruleCount));
|
||||
},
|
||||
|
||||
/**
|
||||
* Update the @media rules sidebar for an editor. Hide if there are no rules
|
||||
* Display a list of the @media rules in the editor's associated style sheet.
|
||||
* Emits a 'media-list-changed' event after updating the UI.
|
||||
*
|
||||
* @param {StyleSheetEditor} editor
|
||||
* Editor to update @media sidebar of
|
||||
*/
|
||||
_updateMediaList: function(editor) {
|
||||
this.getEditorDetails(editor).then((details) => {
|
||||
let list = details.querySelector(".stylesheet-media-list");
|
||||
|
||||
while (list.firstChild) {
|
||||
list.removeChild(list.firstChild);
|
||||
}
|
||||
|
||||
let rules = editor.mediaRules;
|
||||
let showSidebar = Services.prefs.getBoolPref(PREF_MEDIA_SIDEBAR);
|
||||
let sidebar = details.querySelector(".stylesheet-sidebar");
|
||||
sidebar.hidden = !showSidebar || !rules.length;
|
||||
|
||||
for (let rule of rules) {
|
||||
let div = this._panelDoc.createElement("div");
|
||||
div.className = "media-rule-label";
|
||||
div.addEventListener("click", this._jumpToMediaRule.bind(this, rule));
|
||||
|
||||
let cond = this._panelDoc.createElement("div");
|
||||
cond.textContent = rule.conditionText;
|
||||
cond.className = "media-rule-condition"
|
||||
if (!rule.matches) {
|
||||
cond.classList.add("media-condition-unmatched");
|
||||
}
|
||||
div.appendChild(cond);
|
||||
|
||||
let line = this._panelDoc.createElement("div");
|
||||
line.className = "media-rule-line theme-link";
|
||||
line.textContent = ":" + rule.line;
|
||||
div.appendChild(line);
|
||||
|
||||
list.appendChild(div);
|
||||
}
|
||||
this.emit("media-list-changed", editor);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Jump cursor to the editor for a stylesheet and line number for a rule.
|
||||
*
|
||||
* @param {MediaRuleFront} rule
|
||||
* Rule to jump to.
|
||||
*/
|
||||
_jumpToMediaRule: function(rule) {
|
||||
this.selectStyleSheet(rule.parentStyleSheet, rule.line - 1, rule.column - 1);
|
||||
},
|
||||
|
||||
destroy: function() {
|
||||
this._clearStyleSheetEditors();
|
||||
|
||||
this._prefObserver.off(PREF_ORIG_SOURCES, this._onNewDocument);
|
||||
this._prefObserver.off(PREF_MEDIA_SIDEBAR, this._onMediaPrefChanged);
|
||||
this._prefObserver.destroy();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,8 @@ Cu.import("resource://gre/modules/Services.jsm");
|
|||
|
||||
const PROPERTIES_URL = "chrome://browser/locale/devtools/styleeditor.properties";
|
||||
|
||||
const console = Services.console;
|
||||
const require = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}).devtools.require;
|
||||
const console = require("resource://gre/modules/devtools/Console.jsm").console;
|
||||
const gStringBundle = Services.strings.createBundle(PROPERTIES_URL);
|
||||
|
||||
|
||||
|
@ -36,12 +37,17 @@ const gStringBundle = Services.strings.createBundle(PROPERTIES_URL);
|
|||
*/
|
||||
this._ = function _(aName)
|
||||
{
|
||||
|
||||
if (arguments.length == 1) {
|
||||
return gStringBundle.GetStringFromName(aName);
|
||||
try {
|
||||
if (arguments.length == 1) {
|
||||
return gStringBundle.GetStringFromName(aName);
|
||||
}
|
||||
let rest = Array.prototype.slice.call(arguments, 1);
|
||||
return gStringBundle.formatStringFromName(aName, rest, rest.length);
|
||||
}
|
||||
catch (ex) {
|
||||
console.error(ex);
|
||||
throw new Error("L10N error. '" + aName + "' is missing from " + PROPERTIES_URL);
|
||||
}
|
||||
let rest = Array.prototype.slice.call(arguments, 1);
|
||||
return gStringBundle.formatStringFromName(aName, rest, rest.length);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -91,9 +91,17 @@ function StyleSheetEditor(styleSheet, win, file, isNew, walker) {
|
|||
|
||||
this._onPropertyChange = this._onPropertyChange.bind(this);
|
||||
this._onError = this._onError.bind(this);
|
||||
this._onMediaRuleMatchesChange = this._onMediaRuleMatchesChange.bind(this);
|
||||
this._onMediaRulesChanged = this._onMediaRulesChanged.bind(this)
|
||||
this.checkLinkedFileForChanges = this.checkLinkedFileForChanges.bind(this);
|
||||
this.markLinkedFileBroken = this.markLinkedFileBroken.bind(this);
|
||||
|
||||
this.mediaRules = [];
|
||||
if (this.styleSheet.getMediaRules) {
|
||||
this.styleSheet.getMediaRules().then(this._onMediaRulesChanged);
|
||||
}
|
||||
this.styleSheet.on("media-rules-changed", this._onMediaRulesChanged);
|
||||
|
||||
this._focusOnSourceEditorReady = false;
|
||||
|
||||
let relatedSheet = this.styleSheet.relatedStyleSheet;
|
||||
|
@ -223,7 +231,7 @@ StyleSheetEditor.prototype = {
|
|||
return source;
|
||||
});
|
||||
}, e => {
|
||||
this.emit("error", LOAD_ERROR, this.styleSheet.href);
|
||||
this.emit("error", { key: LOAD_ERROR, append: this.styleSheet.href });
|
||||
throw e;
|
||||
})
|
||||
},
|
||||
|
@ -275,6 +283,36 @@ StyleSheetEditor.prototype = {
|
|||
this.emit("property-change", property, value);
|
||||
},
|
||||
|
||||
/**
|
||||
* Handles changes to the list of @media rules in the stylesheet.
|
||||
* Emits 'media-rules-changed' if the list has changed.
|
||||
*
|
||||
* @param {array} rules
|
||||
* Array of MediaRuleFronts for new media rules of sheet.
|
||||
*/
|
||||
_onMediaRulesChanged: function(rules) {
|
||||
if (!rules.length && !this.mediaRules.length) {
|
||||
return;
|
||||
}
|
||||
for (let rule of this.mediaRules) {
|
||||
rule.off("matches-change", this._onMediaRuleMatchesChange);
|
||||
rule.destroy();
|
||||
}
|
||||
this.mediaRules = rules;
|
||||
|
||||
for (let rule of rules) {
|
||||
rule.on("matches-change", this._onMediaRuleMatchesChange);
|
||||
}
|
||||
this.emit("media-rules-changed", rules);
|
||||
},
|
||||
|
||||
/**
|
||||
* Forward media-rules-changed event from stylesheet.
|
||||
*/
|
||||
_onMediaRuleMatchesChange: function() {
|
||||
this.emit("media-rules-changed", this.mediaRules);
|
||||
},
|
||||
|
||||
/**
|
||||
* Forward error event from stylesheet.
|
||||
*
|
||||
|
@ -282,8 +320,8 @@ StyleSheetEditor.prototype = {
|
|||
* Event type
|
||||
* @param {string} errorCode
|
||||
*/
|
||||
_onError: function(event, errorCode) {
|
||||
this.emit("error", errorCode);
|
||||
_onError: function(event, data) {
|
||||
this.emit("error", data);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -464,7 +502,7 @@ StyleSheetEditor.prototype = {
|
|||
if (callback) {
|
||||
callback(null);
|
||||
}
|
||||
this.emit("error", SAVE_ERROR);
|
||||
this.emit("error", { key: SAVE_ERROR });
|
||||
return;
|
||||
}
|
||||
FileUtils.closeSafeFileOutputStream(ostream);
|
||||
|
@ -590,6 +628,7 @@ StyleSheetEditor.prototype = {
|
|||
if (this.sourceEditor) {
|
||||
this.sourceEditor.destroy();
|
||||
}
|
||||
this.styleSheet.off("media-rules-changed", this._onMediaRulesChanged);
|
||||
this.styleSheet.off("property-change", this._onPropertyChange);
|
||||
this.styleSheet.off("error", this._onError);
|
||||
}
|
||||
|
|
|
@ -83,27 +83,29 @@ StyleEditorPanel.prototype = {
|
|||
*
|
||||
* @param {string} event
|
||||
* Type of event
|
||||
* @param {string} code
|
||||
* Error code of error to report
|
||||
* @param {string} message
|
||||
* Extra message to append to error message
|
||||
* @param {string} data
|
||||
* The parameters to customize the error message
|
||||
*/
|
||||
_showError: function(event, code, message) {
|
||||
_showError: function(event, data) {
|
||||
if (!this._toolbox) {
|
||||
// could get an async error after we've been destroyed
|
||||
return;
|
||||
}
|
||||
|
||||
let errorMessage = _(code);
|
||||
if (message) {
|
||||
errorMessage += " " + message;
|
||||
let errorMessage = _(data.key);
|
||||
if (data.append) {
|
||||
errorMessage += " " + data.append;
|
||||
}
|
||||
|
||||
let notificationBox = this._toolbox.getNotificationBox();
|
||||
let notification = notificationBox.getNotificationWithValue("styleeditor-error");
|
||||
let level = (data.level === "info") ?
|
||||
notificationBox.PRIORITY_INFO_LOW :
|
||||
notificationBox.PRIORITY_CRITICAL_LOW;
|
||||
|
||||
if (!notification) {
|
||||
notificationBox.appendNotification(errorMessage,
|
||||
"styleeditor-error", "", notificationBox.PRIORITY_CRITICAL_LOW);
|
||||
notificationBox.appendNotification(errorMessage, "styleeditor-error",
|
||||
"", level);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -7,19 +7,6 @@
|
|||
-moz-box-flex: 1;
|
||||
}
|
||||
|
||||
.csscoverage-report-container {
|
||||
-moz-box-flex: 1;
|
||||
}
|
||||
|
||||
.csscoverage-report {
|
||||
-moz-box-orient: horizontal;
|
||||
}
|
||||
|
||||
.csscoverage-report-container {
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.stylesheet-error-message {
|
||||
display: none;
|
||||
}
|
||||
|
@ -34,6 +21,25 @@ li.error > .stylesheet-info > .stylesheet-more > .stylesheet-error-message {
|
|||
display: -moz-box;
|
||||
}
|
||||
|
||||
.stylesheet-details-container {
|
||||
-moz-box-flex: 1;
|
||||
}
|
||||
|
||||
.stylesheet-media-list {
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
-moz-box-flex: 1;
|
||||
}
|
||||
|
||||
.media-rule-label {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.media-rule-condition {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.splitview-nav > li {
|
||||
-moz-box-orient: horizontal;
|
||||
}
|
||||
|
@ -123,3 +129,21 @@ li:hover > hgroup > .stylesheet-more > h3 > .stylesheet-saveButton {
|
|||
-moz-box-flex: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.csscoverage-report-container {
|
||||
-moz-box-flex: 1;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.csscoverage-report-content > * {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.csscoverage-report {
|
||||
-moz-box-orient: horizontal;
|
||||
}
|
||||
|
||||
.csscoverage-report .pie-table-chart-container {
|
||||
-moz-box-orient: vertical;
|
||||
}
|
||||
|
|
|
@ -14,8 +14,10 @@
|
|||
]>
|
||||
|
||||
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://browser/content/devtools/widgets.css" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://browser/content/devtools/splitview.css" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://browser/skin/devtools/common.css" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://browser/skin/devtools/widgets.css" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://browser/skin/devtools/splitview.css" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://browser/content/devtools/styleeditor.css" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://browser/skin/devtools/styleeditor.css" type="text/css"?>
|
||||
|
@ -61,6 +63,7 @@
|
|||
</xul:menupopup>
|
||||
<xul:menupopup id="sidebar-context">
|
||||
<xul:menuitem id="context-origsources"/>
|
||||
<xul:menuitem id="context-show-media"/>
|
||||
</xul:menupopup>
|
||||
</xul:popupset>
|
||||
|
||||
|
@ -128,8 +131,16 @@
|
|||
<xul:resizer class="splitview-portrait-resizer"
|
||||
dir="bottom"
|
||||
element="splitview-resizer-target"/>
|
||||
<xul:box class="stylesheet-editor-input textbox"
|
||||
data-placeholder="&editorTextbox.placeholder;"/>
|
||||
<xul:hbox class="stylesheet-details-container">
|
||||
<xul:box class="stylesheet-editor-input textbox"
|
||||
data-placeholder="&editorTextbox.placeholder;"/>
|
||||
<xul:vbox class="stylesheet-sidebar theme-sidebar" hidden="true">
|
||||
<xul:toolbar class="devtools-toolbar">
|
||||
&mediaRules.label;
|
||||
</xul:toolbar>
|
||||
<xul:vbox class="stylesheet-media-list"/>
|
||||
</xul:vbox>
|
||||
</xul:hbox>
|
||||
</xul:box>
|
||||
</div> <!-- #splitview-templates -->
|
||||
</xul:box> <!-- .splitview-root -->
|
||||
|
@ -143,39 +154,43 @@
|
|||
<!-- The data for this comes from UsageReportActor.createPageReport -->
|
||||
<div class="csscoverage-report-container">
|
||||
<div class="csscoverage-report-content">
|
||||
<h2>&csscoverage.unused;</h2>
|
||||
<p>&csscoverage.noMatch;</p>
|
||||
<ul>
|
||||
<li foreach="rule in ${unusedRules}">
|
||||
<code>${rule.selectorText}</code>
|
||||
<span class="link"
|
||||
title="${rule.url}">(${rule.shortHref} : ${rule.start.line})</span>
|
||||
</li>
|
||||
</ul>
|
||||
<h2>&csscoverage.optimize;</h2>
|
||||
<p>
|
||||
&csscoverage.preload1;
|
||||
<code><link ...></code>
|
||||
&csscoverage.preload2;
|
||||
<code><style>...</code>
|
||||
&csscoverage.preload3;
|
||||
</p>
|
||||
<div if="${pages.length == 0}">
|
||||
&csscoverage.noPreload;
|
||||
<div class="csscoverage-report-summary">
|
||||
<div class="csscoverage-report-chart"/>
|
||||
</div>
|
||||
<div if="${pages.length > 0}">
|
||||
<div foreach="page in ${pages}">
|
||||
<div class="csscoverage-report-unused">
|
||||
<h2>&csscoverage.unused;</h2>
|
||||
<p>&csscoverage.noMatch;</p>
|
||||
<div foreach="page in ${unused}">
|
||||
<h3>${page.url}</h3>
|
||||
<textarea><style>
|
||||
<loop foreach="rule in ${page.preloadRules}"
|
||||
onclick="${rule.onclick}">${rule.formattedCssText}</loop></style></textarea>
|
||||
<code foreach="rule in ${page.rules}"
|
||||
href="${rule.url}"
|
||||
class="csscoverage-list">${rule.selectorText}</code>
|
||||
</div>
|
||||
</div>
|
||||
<p>
|
||||
&csscoverage.footer1;
|
||||
<a target="_blank" href="&csscoverage.footer2;">&csscoverage.footer3;</a>
|
||||
&csscoverage.footer4;
|
||||
</p>
|
||||
<div class="csscoverage-report-optimize">
|
||||
<h2>&csscoverage.optimize.header;</h2>
|
||||
<p>
|
||||
&csscoverage.optimize.body1;
|
||||
<code><link ...></code>
|
||||
&csscoverage.optimize.body2;
|
||||
<code><style>...</code>
|
||||
&csscoverage.optimize.body3;
|
||||
</p>
|
||||
<div if="${preload.length == 0}">&csscoverage.optimize.bodyX;</div>
|
||||
<div if="${preload.length > 0}">
|
||||
<div foreach="page in ${preload}">
|
||||
<h3>${page.url}</h3>
|
||||
<textarea><style>
|
||||
<loop foreach="rule in ${page.rules}"
|
||||
onclick="${rule.onclick}">${rule.formattedCssText}</loop></style></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<p>
|
||||
&csscoverage.footer1;
|
||||
<a target="_blank" href="&csscoverage.footer2;">&csscoverage.footer3;</a>
|
||||
&csscoverage.footer4;
|
||||
</p>
|
||||
</div>
|
||||
<p> </p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -14,6 +14,8 @@ support-files =
|
|||
longload.html
|
||||
media-small.css
|
||||
media.html
|
||||
media-rules.html
|
||||
media-rules.css
|
||||
minified.html
|
||||
nostyle.html
|
||||
pretty.css
|
||||
|
@ -46,6 +48,7 @@ skip-if = os == "linux" || "mac" # bug 949355
|
|||
[browser_styleeditor_init.js]
|
||||
[browser_styleeditor_inline_friendly_names.js]
|
||||
[browser_styleeditor_loading.js]
|
||||
[browser_styleeditor_media_sidebar.js]
|
||||
[browser_styleeditor_new.js]
|
||||
[browser_styleeditor_nostyle.js]
|
||||
[browser_styleeditor_pretty.js]
|
||||
|
|
|
@ -0,0 +1,102 @@
|
|||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
// https rather than chrome to improve coverage
|
||||
const TESTCASE_URI = TEST_BASE_HTTPS + "media-rules.html";
|
||||
const PREF = "devtools.styleeditor.showMediaSidebar";
|
||||
|
||||
const RESIZE = 300;
|
||||
const LABELS = ["not all", "all", "(max-width: 400px)"];
|
||||
const LINE_NOS = [2, 8, 20];
|
||||
|
||||
waitForExplicitFinish();
|
||||
|
||||
let test = asyncTest(function*() {
|
||||
Services.prefs.setBoolPref(PREF, true);
|
||||
|
||||
let {UI} = yield addTabAndOpenStyleEditors(2, null, TESTCASE_URI);
|
||||
|
||||
is(UI.editors.length, 2, "correct number of editors");
|
||||
|
||||
// Test first plain css editor
|
||||
let plainEditor = UI.editors[0];
|
||||
yield openEditor(plainEditor);
|
||||
testPlainEditor(plainEditor);
|
||||
|
||||
// Test editor with @media rules
|
||||
let mediaEditor = UI.editors[1];
|
||||
yield openEditor(mediaEditor);
|
||||
testMediaEditor(mediaEditor);
|
||||
|
||||
// Test resizing and seeing @media matching state change
|
||||
let originalWidth = window.outerWidth;
|
||||
let originalHeight = window.outerHeight;
|
||||
|
||||
let onMatchesChange = listenForMatchesChange(UI);
|
||||
window.resizeTo(RESIZE, RESIZE);
|
||||
yield onMatchesChange;
|
||||
|
||||
testMediaMatchChanged(mediaEditor);
|
||||
|
||||
window.resizeTo(originalWidth, originalHeight);
|
||||
Services.prefs.clearUserPref(PREF);
|
||||
});
|
||||
|
||||
function testPlainEditor(editor) {
|
||||
let sidebar = editor.details.querySelector(".stylesheet-sidebar");
|
||||
is(sidebar.hidden, true, "sidebar is hidden on editor without @media");
|
||||
}
|
||||
|
||||
function testMediaEditor(editor) {
|
||||
let sidebar = editor.details.querySelector(".stylesheet-sidebar");
|
||||
is(sidebar.hidden, false, "sidebar is showing on editor with @media");
|
||||
|
||||
let entries = [...sidebar.querySelectorAll(".media-rule-label")];
|
||||
is(entries.length, 3, "three @media rules displayed in sidebar");
|
||||
|
||||
testRule(entries[0], LABELS[0], false, LINE_NOS[0]);
|
||||
testRule(entries[1], LABELS[1], true, LINE_NOS[1]);
|
||||
testRule(entries[2], LABELS[2], false, LINE_NOS[2]);
|
||||
}
|
||||
|
||||
function testMediaMatchChanged(editor) {
|
||||
let sidebar = editor.details.querySelector(".stylesheet-sidebar");
|
||||
|
||||
let cond = sidebar.querySelectorAll(".media-rule-condition")[2];
|
||||
is(cond.textContent, "(max-width: 400px)", "third rule condition text is correct");
|
||||
ok(!cond.classList.contains("media-condition-unmatched"),
|
||||
"media rule is now matched after resizing");
|
||||
}
|
||||
|
||||
function testRule(rule, text, matches, lineno) {
|
||||
let cond = rule.querySelector(".media-rule-condition");
|
||||
is(cond.textContent, text, "media label is correct for " + text);
|
||||
|
||||
let matched = !cond.classList.contains("media-condition-unmatched");
|
||||
ok(matches ? matched : !matched,
|
||||
"media rule is " + (matches ? "matched" : "unmatched"));
|
||||
|
||||
let line = rule.querySelector(".media-rule-line");
|
||||
is(line.textContent, ":" + lineno, "correct line number shown");
|
||||
}
|
||||
|
||||
/* Helpers */
|
||||
|
||||
function openEditor(editor) {
|
||||
getLinkFor(editor).click();
|
||||
|
||||
return editor.getSourceEditor();
|
||||
}
|
||||
|
||||
function listenForMatchesChange(UI) {
|
||||
let deferred = promise.defer();
|
||||
UI.once("media-list-changed", () => {
|
||||
deferred.resolve();
|
||||
})
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function getLinkFor(editor) {
|
||||
return editor.summary.querySelector(".stylesheet-name");
|
||||
}
|
|
@ -34,7 +34,7 @@ function runTests()
|
|||
editor.getSourceEditor().then(() => {
|
||||
is(gUI.selectedEditor, gUI.editors[1], "second editor is selected");
|
||||
let {line, ch} = gUI.selectedEditor.sourceEditor.getCursor();
|
||||
|
||||
|
||||
is(line, LINE_NO, "correct line selected");
|
||||
is(ch, COL_NO, "correct column selected");
|
||||
|
||||
|
@ -42,6 +42,5 @@ function runTests()
|
|||
finish();
|
||||
});
|
||||
});
|
||||
|
||||
gUI.selectStyleSheet(gUI.editors[1].styleSheet.href, LINE_NO);
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
@media not all {
|
||||
div {
|
||||
color: blue;
|
||||
}
|
||||
}
|
||||
|
||||
@media all {
|
||||
div {
|
||||
color: red;
|
||||
}
|
||||
}
|
||||
|
||||
div {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
background-color: ghostwhite;
|
||||
}
|
||||
|
||||
@media (max-width: 400px) {
|
||||
div {
|
||||
color: green;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<link rel="stylesheet" href="simple.css"/>
|
||||
<link rel="stylesheet" href="media-rules.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
Testing style editor media sidebar
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -191,7 +191,7 @@ HUD_SERVICE.prototype =
|
|||
client.connect(() =>
|
||||
client.listTabs((aResponse) => {
|
||||
// Add Global Process debugging...
|
||||
let globals = JSON.parse(JSON.stringify(aResponse));
|
||||
let globals = Cu.cloneInto(aResponse, {});
|
||||
delete globals.tabs;
|
||||
delete globals.selected;
|
||||
// ...only if there are appropriate actors (a 'from' property will
|
||||
|
|
|
@ -24,6 +24,10 @@
|
|||
<!ENTITY saveButton.tooltip "Save this style sheet to a file">
|
||||
<!ENTITY saveButton.accesskey "S">
|
||||
|
||||
<!-- LOCALICATION NOTE (mediaRules.label): This is shown above the list of @media rules
|
||||
in each stylesheet editor sidebar. -->
|
||||
<!ENTITY mediaRules.label "@media rules">
|
||||
|
||||
<!ENTITY editorTextbox.placeholder "Type CSS here.">
|
||||
|
||||
<!-- LOCALICATION NOTE (noStyleSheet.label): This is shown when a page has no
|
||||
|
|
|
@ -38,6 +38,10 @@ error-load=Style sheet could not be loaded.
|
|||
# LOCALIZATION NOTE (error-save): This is shown when saving fails.
|
||||
error-save=Style sheet could not be saved.
|
||||
|
||||
# LOCALIZATION NOTE (error-compressed): This is shown when we can't show
|
||||
# coverage information because the css source is compressed.
|
||||
error-compressed=Can't show coverage information for compressed stylesheets
|
||||
|
||||
# LOCALIZATION NOTE (importStyleSheet.title): This is the file picker title,
|
||||
# when you import a style sheet into the Style Editor.
|
||||
importStyleSheet.title=Import style sheet
|
||||
|
@ -80,6 +84,22 @@ showCSSSources.label=Show CSS sources
|
|||
# menu item to toggle back to showing only CSS sources in the editor.
|
||||
showCSSSources.accesskey=C
|
||||
|
||||
# LOCALIZATION NOTE (showMediaSidebar.label): This is the label on the context
|
||||
# menu item to toggle showing @media rule shortcuts in a sidebar.
|
||||
showMediaSidebar.label=Show @media sidebar
|
||||
|
||||
# LOCALIZATION NOTE (showMediaSidebar.accesskey): This is the access key for
|
||||
# the menu item to toggle showing the @media sidebar.
|
||||
showMediaSidebar.accesskey=M
|
||||
|
||||
# LOCALIZATION NOTE (hideMediaSidebar.label): This is the label on the context
|
||||
# menu item to stop showing @media rule shortcuts in a sidebar.
|
||||
hideMediaSidebar.label=Hide @media sidebar
|
||||
|
||||
# LOCALIZATION NOTE (hideMediaSidebar.accesskey): This is the access key for
|
||||
# the menu item to stop showing the @media sidebar.
|
||||
hideMediaSidebar.accesskey=H
|
||||
|
||||
# LOCALIZATION NOTE (ToolboxStyleEditor.label):
|
||||
# This string is displayed in the title of the tab when the style editor is
|
||||
# displayed inside the developer tools window and in the Developer Tools Menu.
|
||||
|
|
|
@ -103,7 +103,7 @@
|
|||
|
||||
.cm-s-mozilla .cm-unused-line {
|
||||
text-decoration: line-through;
|
||||
-moz-text-decoration-color: red;
|
||||
-moz-text-decoration-color: #5f88b0;
|
||||
}
|
||||
|
||||
.cm-s-mozilla .cm-executed-line {
|
||||
|
|
|
@ -76,7 +76,7 @@
|
|||
|
||||
.cm-s-mozilla .cm-unused-line {
|
||||
text-decoration: line-through;
|
||||
-moz-text-decoration-color: red;
|
||||
-moz-text-decoration-color: #5f88b0;
|
||||
}
|
||||
|
||||
.cm-s-mozilla .cm-executed-line {
|
||||
|
|
|
@ -3,54 +3,6 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
.theme-light .csscoverage-report {
|
||||
background: url(background-noise-toolbar.png), #f0f1f2; /* Toolbars */
|
||||
}
|
||||
|
||||
.theme-dark .csscoverage-report {
|
||||
background: url(background-noise-toolbar.png), #343c45; /* Toolbars */
|
||||
}
|
||||
|
||||
.csscoverage-report-container {
|
||||
height: 100vh;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.csscoverage-report-content {
|
||||
font-size: 13px;
|
||||
margin: 0 auto;
|
||||
max-width: 600px;
|
||||
padding: 0 10px;
|
||||
}
|
||||
|
||||
.csscoverage-report h1,
|
||||
.csscoverage-report h2,
|
||||
.csscoverage-report h3 {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.csscoverage-report textarea {
|
||||
width: 100%;
|
||||
height: 100px;
|
||||
}
|
||||
|
||||
.csscoverage-report > .csscoverage-toolbar {
|
||||
border: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.csscoverage-report > .csscoverage-toolbarbutton {
|
||||
min-width: 4em;
|
||||
min-height: 100vh;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border-radius: 0;
|
||||
border-top: none;
|
||||
border-bottom: none;
|
||||
-moz-border-start: none;
|
||||
}
|
||||
|
||||
.stylesheet-title,
|
||||
.stylesheet-name {
|
||||
text-decoration: none;
|
||||
|
@ -112,6 +64,39 @@
|
|||
padding: 0 10px;
|
||||
}
|
||||
|
||||
.stylesheet-sidebar {
|
||||
width: 230px;
|
||||
}
|
||||
|
||||
.theme-light .stylesheet-sidebar {
|
||||
border-left: 1px solid #A6A6A6;
|
||||
}
|
||||
|
||||
.theme-dark .stylesheet-sidebar {
|
||||
border-left: 1px solid #606C75;
|
||||
}
|
||||
|
||||
.theme-light .media-rule-label {
|
||||
border-bottom: 1px solid #CCC;
|
||||
}
|
||||
|
||||
.theme-dark .media-rule-label {
|
||||
border-bottom: 1px solid #343C45;
|
||||
}
|
||||
|
||||
.media-rule-label {
|
||||
padding: 4px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.theme-light .media-condition-unmatched {
|
||||
color: grey;
|
||||
}
|
||||
|
||||
.theme-dark .media-condition-unmatched {
|
||||
color: #606C75;
|
||||
}
|
||||
|
||||
.stylesheet-enabled {
|
||||
padding: 8px 0;
|
||||
margin: 0 8px;
|
||||
|
@ -172,6 +157,12 @@ h3 {
|
|||
padding: 0;
|
||||
}
|
||||
|
||||
@media (max-width: 700px) {
|
||||
.stylesheet-sidebar {
|
||||
width: 150px;
|
||||
}
|
||||
}
|
||||
|
||||
/* portrait mode */
|
||||
@media (max-width: 550px) {
|
||||
.splitview-nav {
|
||||
|
@ -195,4 +186,126 @@ h3 {
|
|||
.splitview-nav > li > hgroup.stylesheet-info {
|
||||
-moz-box-align: baseline;
|
||||
}
|
||||
|
||||
.stylesheet-sidebar {
|
||||
width: 180px;
|
||||
}
|
||||
}
|
||||
|
||||
.theme-light .csscoverage-report {
|
||||
background: url(background-noise-toolbar.png), #f0f1f2; /* Toolbars */
|
||||
}
|
||||
|
||||
.theme-dark .csscoverage-report {
|
||||
background: url(background-noise-toolbar.png), #343c45; /* Toolbars */
|
||||
}
|
||||
|
||||
.csscoverage-report-container {
|
||||
height: 100vh;
|
||||
padding: 0 30px;
|
||||
}
|
||||
|
||||
.csscoverage-report-content {
|
||||
margin: 20px auto;
|
||||
-moz-column-width: 300px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.csscoverage-report h1 {
|
||||
font-size: 120%;
|
||||
}
|
||||
|
||||
.csscoverage-report h2 {
|
||||
font-size: 110%;
|
||||
}
|
||||
|
||||
.csscoverage-report h1,
|
||||
.csscoverage-report h2,
|
||||
.csscoverage-report h3 {
|
||||
font-weight: bold;
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
||||
.csscoverage-list:after {
|
||||
content: ', ';
|
||||
}
|
||||
|
||||
.csscoverage-list:last-child:after {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.csscoverage-report textarea {
|
||||
width: 100%;
|
||||
height: 100px;
|
||||
}
|
||||
|
||||
.csscoverage-report a {
|
||||
cursor: pointer;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.csscoverage-report > .csscoverage-toolbar {
|
||||
border: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.csscoverage-report > .csscoverage-toolbarbutton {
|
||||
min-width: 4em;
|
||||
min-height: 100vh;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border-radius: 0;
|
||||
border-top: none;
|
||||
border-bottom: none;
|
||||
-moz-border-start: none;
|
||||
}
|
||||
|
||||
.theme-dark .chart-colored-blob[name="Used Preload"] {
|
||||
fill: #df80ff; /* Pink highlight */
|
||||
background: #df80ff;
|
||||
}
|
||||
|
||||
.theme-light .chart-colored-blob[name="Used Preload"] {
|
||||
fill: #b82ee5; /* Pink highlight */
|
||||
background: #b82ee5;
|
||||
}
|
||||
|
||||
.theme-dark .chart-colored-blob[name=Used] {
|
||||
fill: #70bf53; /* Green highlight */
|
||||
background: #70bf53;
|
||||
}
|
||||
|
||||
.theme-light .chart-colored-blob[name=Used] {
|
||||
fill: #2cbb0f; /* Green highlight */
|
||||
background: #2cbb0f;
|
||||
}
|
||||
|
||||
.theme-dark .chart-colored-blob[name=Unused] {
|
||||
fill: #d99b28; /* Light Orange highlight */
|
||||
background: #d99b28;
|
||||
}
|
||||
|
||||
.theme-light .chart-colored-blob[name=Unused] {
|
||||
fill: #d97e00; /* Light Orange highlight */
|
||||
background: #d97e00;
|
||||
}
|
||||
|
||||
/* Undo 'largest' customization */
|
||||
.theme-dark .pie-chart-slice[largest] {
|
||||
stroke-width: 1px;
|
||||
stroke: rgba(0,0,0,0.2);
|
||||
}
|
||||
|
||||
.theme-light .pie-chart-slice[largest] {
|
||||
stroke-width: 1px;
|
||||
stroke: rgba(255,255,255,0.8);
|
||||
}
|
||||
|
||||
.csscoverage-report .pie-chart-slice {
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.csscoverage-report-chart {
|
||||
margin: 0 50px;
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@
|
|||
|
||||
@media (-moz-os-version: windows-vista),
|
||||
(-moz-os-version: windows-win7) {
|
||||
#navigator-toolbox > toolbar:not(:-moz-lwtheme),
|
||||
#navigator-toolbox > toolbar:not(#toolbar-menubar):not(#TabsToolbar):not(:-moz-lwtheme),
|
||||
#browser-bottombox:not(:-moz-lwtheme),
|
||||
.browserContainer > findbar {
|
||||
background-color: @customToolbarColor@;
|
||||
|
@ -139,7 +139,6 @@
|
|||
@media (-moz-windows-default-theme) {
|
||||
#toolbar-menubar:not(:-moz-lwtheme),
|
||||
#TabsToolbar:not(:-moz-lwtheme) {
|
||||
background-color: transparent !important;
|
||||
color: black;
|
||||
}
|
||||
|
||||
|
@ -281,7 +280,7 @@
|
|||
/* End Glass Fog */
|
||||
}
|
||||
|
||||
|
||||
/* Aero Basic */
|
||||
@media not all and (-moz-windows-compositor) {
|
||||
@media (-moz-windows-default-theme) {
|
||||
#main-window {
|
||||
|
@ -294,10 +293,6 @@
|
|||
#toolbar-menubar:not([autohide=true]):not(:-moz-lwtheme),
|
||||
#TabsToolbar:not(:-moz-lwtheme) {
|
||||
-moz-binding: url("chrome://browser/content/customizableui/toolbar.xml#toolbar-drag");
|
||||
background-color: transparent;
|
||||
}
|
||||
#toolbar-menubar[autohide=true] {
|
||||
background-color: transparent !important;
|
||||
}
|
||||
|
||||
/* Render a window top border for lwthemes: */
|
||||
|
|
|
@ -72,6 +72,9 @@
|
|||
#navigator-toolbox > toolbar:not(:-moz-lwtheme) {
|
||||
-moz-appearance: none;
|
||||
border-style: none;
|
||||
}
|
||||
|
||||
#navigator-toolbox > toolbar:not(#toolbar-menubar):not(#TabsToolbar):not(:-moz-lwtheme) {
|
||||
background-color: -moz-Dialog;
|
||||
}
|
||||
|
||||
|
@ -79,10 +82,6 @@
|
|||
@media not all and (-moz-windows-compositor),
|
||||
not all and (-moz-windows-default-theme) {
|
||||
%endif
|
||||
#toolbar-menubar {
|
||||
background-color: transparent !important;
|
||||
}
|
||||
|
||||
#main-window[tabsintitlebar]:not([inFullscreen]) #toolbar-menubar:not(:-moz-lwtheme),
|
||||
#main-window[tabsintitlebar]:not([inFullscreen]) #TabsToolbar:not(:-moz-lwtheme) {
|
||||
color: CaptionText;
|
||||
|
@ -133,7 +132,6 @@
|
|||
}
|
||||
|
||||
#main-window[tabsintitlebar] #TabsToolbar:not(:-moz-lwtheme) {
|
||||
background-image: none;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
|
@ -1757,10 +1755,6 @@ toolbarbutton[type="socialmark"] > .toolbarbutton-icon {
|
|||
margin-bottom: -@tabToolbarNavbarOverlap@; /* overlap the nav-bar's top border */
|
||||
}
|
||||
|
||||
#main-window[tabsintitlebar] #TabsToolbar {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
%ifndef WINDOWS_AERO
|
||||
@media (-moz-windows-default-theme) {
|
||||
#main-window[sizemode=normal] #TabsToolbar {
|
||||
|
@ -2234,7 +2228,6 @@ toolbarbutton.bookmark-item[dragover="true"][open="true"] {
|
|||
|
||||
.notification-anchor-icon:-moz-focusring {
|
||||
outline: 1px dotted -moz-DialogText;
|
||||
outline-offset: -3px;
|
||||
}
|
||||
|
||||
.default-notification-icon,
|
||||
|
|
|
@ -2262,7 +2262,7 @@ Element::DescribeAttribute(uint32_t index, nsAString& aOutDescription) const
|
|||
value.Insert(char16_t('\\'), uint32_t(i));
|
||||
}
|
||||
aOutDescription.Append(value);
|
||||
aOutDescription.AppendLiteral("\"");
|
||||
aOutDescription.Append('"');
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
|
|
@ -992,7 +992,7 @@ WebSocket::ParseURL(const nsString& aURL)
|
|||
nsAutoCString filePath;
|
||||
rv = parsedURL->GetFilePath(filePath);
|
||||
if (filePath.IsEmpty()) {
|
||||
filePath.AssignLiteral("/");
|
||||
filePath.Assign('/');
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_SYNTAX_ERR);
|
||||
|
||||
|
|
|
@ -93,6 +93,56 @@ MarkUserDataHandler(void* aNode, nsIAtom* aKey, void* aValue, void* aData)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
MarkChildMessageManagers(nsIMessageBroadcaster* aMM)
|
||||
{
|
||||
aMM->MarkForCC();
|
||||
|
||||
uint32_t tabChildCount = 0;
|
||||
aMM->GetChildCount(&tabChildCount);
|
||||
for (uint32_t j = 0; j < tabChildCount; ++j) {
|
||||
nsCOMPtr<nsIMessageListenerManager> childMM;
|
||||
aMM->GetChildAt(j, getter_AddRefs(childMM));
|
||||
if (!childMM) {
|
||||
continue;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIMessageBroadcaster> strongNonLeafMM = do_QueryInterface(childMM);
|
||||
nsIMessageBroadcaster* nonLeafMM = strongNonLeafMM;
|
||||
|
||||
nsCOMPtr<nsIMessageSender> strongTabMM = do_QueryInterface(childMM);
|
||||
nsIMessageSender* tabMM = strongTabMM;
|
||||
|
||||
strongNonLeafMM = nullptr;
|
||||
strongTabMM = nullptr;
|
||||
childMM = nullptr;
|
||||
|
||||
if (nonLeafMM) {
|
||||
MarkChildMessageManagers(nonLeafMM);
|
||||
continue;
|
||||
}
|
||||
|
||||
tabMM->MarkForCC();
|
||||
|
||||
//XXX hack warning, but works, since we know that
|
||||
// callback is frameloader.
|
||||
mozilla::dom::ipc::MessageManagerCallback* cb =
|
||||
static_cast<nsFrameMessageManager*>(tabMM)->GetCallback();
|
||||
if (cb) {
|
||||
nsFrameLoader* fl = static_cast<nsFrameLoader*>(cb);
|
||||
EventTarget* et = fl->GetTabChildGlobalAsEventTarget();
|
||||
if (!et) {
|
||||
continue;
|
||||
}
|
||||
static_cast<nsInProcessTabChildGlobal*>(et)->MarkForCC();
|
||||
EventListenerManager* elm = et->GetExistingListenerManager();
|
||||
if (elm) {
|
||||
elm->MarkForCC();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
MarkMessageManagers()
|
||||
{
|
||||
|
@ -107,52 +157,8 @@ MarkMessageManagers()
|
|||
}
|
||||
nsIMessageBroadcaster* globalMM = strongGlobalMM;
|
||||
strongGlobalMM = nullptr;
|
||||
MarkChildMessageManagers(globalMM);
|
||||
|
||||
globalMM->MarkForCC();
|
||||
uint32_t childCount = 0;
|
||||
globalMM->GetChildCount(&childCount);
|
||||
for (uint32_t i = 0; i < childCount; ++i) {
|
||||
nsCOMPtr<nsIMessageListenerManager> childMM;
|
||||
globalMM->GetChildAt(i, getter_AddRefs(childMM));
|
||||
if (!childMM) {
|
||||
continue;
|
||||
}
|
||||
nsCOMPtr<nsIMessageBroadcaster> strongWindowMM = do_QueryInterface(childMM);
|
||||
nsIMessageBroadcaster* windowMM = strongWindowMM;
|
||||
childMM = nullptr;
|
||||
strongWindowMM = nullptr;
|
||||
windowMM->MarkForCC();
|
||||
uint32_t tabChildCount = 0;
|
||||
windowMM->GetChildCount(&tabChildCount);
|
||||
for (uint32_t j = 0; j < tabChildCount; ++j) {
|
||||
nsCOMPtr<nsIMessageListenerManager> childMM;
|
||||
windowMM->GetChildAt(j, getter_AddRefs(childMM));
|
||||
if (!childMM) {
|
||||
continue;
|
||||
}
|
||||
nsCOMPtr<nsIMessageSender> strongTabMM = do_QueryInterface(childMM);
|
||||
nsIMessageSender* tabMM = strongTabMM;
|
||||
childMM = nullptr;
|
||||
strongTabMM = nullptr;
|
||||
tabMM->MarkForCC();
|
||||
//XXX hack warning, but works, since we know that
|
||||
// callback is frameloader.
|
||||
mozilla::dom::ipc::MessageManagerCallback* cb =
|
||||
static_cast<nsFrameMessageManager*>(tabMM)->GetCallback();
|
||||
if (cb) {
|
||||
nsFrameLoader* fl = static_cast<nsFrameLoader*>(cb);
|
||||
EventTarget* et = fl->GetTabChildGlobalAsEventTarget();
|
||||
if (!et) {
|
||||
continue;
|
||||
}
|
||||
static_cast<nsInProcessTabChildGlobal*>(et)->MarkForCC();
|
||||
EventListenerManager* elm = et->GetExistingListenerManager();
|
||||
if (elm) {
|
||||
elm->MarkForCC();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (nsFrameMessageManager::sParentProcessManager) {
|
||||
nsFrameMessageManager::sParentProcessManager->MarkForCC();
|
||||
uint32_t childCount = 0;
|
||||
|
|
|
@ -406,8 +406,7 @@ DragDataProducer::Produce(DataTransfer* aDataTransfer,
|
|||
// if set, serialize the content under this node
|
||||
nsCOMPtr<nsIContent> nodeToSerialize;
|
||||
|
||||
nsCOMPtr<nsIWebNavigation> webnav = do_GetInterface(mWindow);
|
||||
nsCOMPtr<nsIDocShellTreeItem> dsti = do_QueryInterface(webnav);
|
||||
nsCOMPtr<nsIDocShellTreeItem> dsti = mWindow->GetDocShell();
|
||||
const bool isChromeShell =
|
||||
dsti && dsti->ItemType() == nsIDocShellTreeItem::typeChrome;
|
||||
|
||||
|
|
|
@ -5053,8 +5053,12 @@ nsContentUtils::CheckForSubFrameDrop(nsIDragSession* aDragSession,
|
|||
}
|
||||
|
||||
nsIDocument* targetDoc = target->OwnerDoc();
|
||||
nsCOMPtr<nsIWebNavigation> twebnav = do_GetInterface(targetDoc->GetWindow());
|
||||
nsCOMPtr<nsIDocShellTreeItem> tdsti = do_QueryInterface(twebnav);
|
||||
nsPIDOMWindow* targetWin = targetDoc->GetWindow();
|
||||
if (!targetWin) {
|
||||
return true;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeItem> tdsti = targetWin->GetDocShell();
|
||||
if (!tdsti) {
|
||||
return true;
|
||||
}
|
||||
|
@ -5896,7 +5900,7 @@ nsContentUtils::FlushLayoutForTree(nsIDOMWindow* aWindow)
|
|||
for (; i < i_end; ++i) {
|
||||
nsCOMPtr<nsIDocShellTreeItem> item;
|
||||
docShell->GetChildAt(i, getter_AddRefs(item));
|
||||
nsCOMPtr<nsIDOMWindow> win = do_GetInterface(item);
|
||||
nsCOMPtr<nsIDOMWindow> win = item->GetWindow();
|
||||
if (win) {
|
||||
FlushLayoutForTree(win);
|
||||
}
|
||||
|
|
|
@ -637,7 +637,7 @@ nsCopySupport::FireClipboardEvent(int32_t aType, int32_t aClipboardType, nsIPres
|
|||
if (!nsContentUtils::IsSafeToRunScript())
|
||||
return false;
|
||||
|
||||
nsCOMPtr<nsIDocShell> docShell = do_GetInterface(piWindow);
|
||||
nsCOMPtr<nsIDocShell> docShell = piWindow->GetDocShell();
|
||||
const bool chromeShell =
|
||||
docShell && docShell->ItemType() == nsIDocShellTreeItem::typeChrome;
|
||||
|
||||
|
|
|
@ -2970,7 +2970,7 @@ nsIDocument::GetLastModified(nsAString& aLastModified) const
|
|||
} else {
|
||||
// If we for whatever reason failed to find the last modified time
|
||||
// (or even the current time), fall back to what NS4.x returned.
|
||||
aLastModified.AssignLiteral("01/01/1970 00:00:00");
|
||||
aLastModified.AssignLiteral(MOZ_UTF16("01/01/1970 00:00:00"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4572,10 +4572,10 @@ nsDocument::GetWindowInternal() const
|
|||
// the docshell, the outer window might be still obtainable from the it.
|
||||
nsCOMPtr<nsPIDOMWindow> win;
|
||||
if (mRemovedFromDocShell) {
|
||||
nsCOMPtr<nsIInterfaceRequestor> requestor(mDocumentContainer);
|
||||
if (requestor) {
|
||||
// The docshell returns the outer window we are done.
|
||||
win = do_GetInterface(requestor);
|
||||
// The docshell returns the outer window we are done.
|
||||
nsCOMPtr<nsIDocShell> kungfuDeathGrip(mDocumentContainer);
|
||||
if (mDocumentContainer) {
|
||||
win = mDocumentContainer->GetWindow();
|
||||
}
|
||||
} else {
|
||||
win = do_QueryInterface(mScriptGlobalObject);
|
||||
|
@ -7362,8 +7362,7 @@ nsIDocument::AdoptNode(nsINode& aAdoptedNode, ErrorResult& rv)
|
|||
do {
|
||||
nsPIDOMWindow *win = doc->GetWindow();
|
||||
if (win) {
|
||||
nsCOMPtr<nsINode> node =
|
||||
do_QueryInterface(win->GetFrameElementInternal());
|
||||
nsCOMPtr<nsINode> node = win->GetFrameElementInternal();
|
||||
if (node &&
|
||||
nsContentUtils::ContentIsDescendantOf(node, adoptedNode)) {
|
||||
rv.Throw(NS_ERROR_DOM_HIERARCHY_REQUEST_ERR);
|
||||
|
@ -9173,16 +9172,16 @@ nsIDocument::GetReadyState(nsAString& aReadyState) const
|
|||
{
|
||||
switch(mReadyState) {
|
||||
case READYSTATE_LOADING :
|
||||
aReadyState.AssignLiteral("loading");
|
||||
aReadyState.AssignLiteral(MOZ_UTF16("loading"));
|
||||
break;
|
||||
case READYSTATE_INTERACTIVE :
|
||||
aReadyState.AssignLiteral("interactive");
|
||||
aReadyState.AssignLiteral(MOZ_UTF16("interactive"));
|
||||
break;
|
||||
case READYSTATE_COMPLETE :
|
||||
aReadyState.AssignLiteral("complete");
|
||||
aReadyState.AssignLiteral(MOZ_UTF16("complete"));
|
||||
break;
|
||||
default:
|
||||
aReadyState.AssignLiteral("uninitialized");
|
||||
aReadyState.AssignLiteral(MOZ_UTF16("uninitialized"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10986,7 +10985,7 @@ IsInActiveTab(nsIDocument* aDoc)
|
|||
if (!rootItem) {
|
||||
return false;
|
||||
}
|
||||
nsCOMPtr<nsIDOMWindow> rootWin = do_GetInterface(rootItem);
|
||||
nsCOMPtr<nsIDOMWindow> rootWin = rootItem->GetWindow();
|
||||
if (!rootWin) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -653,9 +653,9 @@ static void
|
|||
FirePageHideEvent(nsIDocShellTreeItem* aItem,
|
||||
EventTarget* aChromeEventHandler)
|
||||
{
|
||||
nsCOMPtr<nsIDocument> internalDoc = do_GetInterface(aItem);
|
||||
NS_ASSERTION(internalDoc, "What happened here?");
|
||||
internalDoc->OnPageHide(true, aChromeEventHandler);
|
||||
nsCOMPtr<nsIDocument> doc = aItem->GetDocument();
|
||||
NS_ASSERTION(doc, "What happened here?");
|
||||
doc->OnPageHide(true, aChromeEventHandler);
|
||||
|
||||
int32_t childCount = 0;
|
||||
aItem->GetChildCount(&childCount);
|
||||
|
@ -695,10 +695,10 @@ FirePageShowEvent(nsIDocShellTreeItem* aItem,
|
|||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocument> internalDoc = do_GetInterface(aItem);
|
||||
NS_ASSERTION(internalDoc, "What happened here?");
|
||||
if (internalDoc->IsShowing() == aFireIfShowing) {
|
||||
internalDoc->OnPageShow(true, aChromeEventHandler);
|
||||
nsCOMPtr<nsIDocument> doc = aItem->GetDocument();
|
||||
NS_ASSERTION(doc, "What happened here?");
|
||||
if (doc->IsShowing() == aFireIfShowing) {
|
||||
doc->OnPageShow(true, aChromeEventHandler);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1156,8 +1156,8 @@ nsFrameLoader::SwapWithOtherLoader(nsFrameLoader* aOther,
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> ourWindow = do_GetInterface(ourDocshell);
|
||||
nsCOMPtr<nsPIDOMWindow> otherWindow = do_GetInterface(otherDocshell);
|
||||
nsCOMPtr<nsPIDOMWindow> ourWindow = ourDocshell->GetWindow();
|
||||
nsCOMPtr<nsPIDOMWindow> otherWindow = otherDocshell->GetWindow();
|
||||
|
||||
nsCOMPtr<Element> ourFrameElement =
|
||||
ourWindow->GetFrameElementInternal();
|
||||
|
@ -1411,9 +1411,11 @@ nsFrameLoader::Destroy()
|
|||
}
|
||||
|
||||
// Let our window know that we are gone
|
||||
nsCOMPtr<nsPIDOMWindow> win_private(do_GetInterface(mDocShell));
|
||||
if (win_private) {
|
||||
win_private->SetFrameElementInternal(nullptr);
|
||||
if (mDocShell) {
|
||||
nsCOMPtr<nsPIDOMWindow> win_private(mDocShell->GetWindow());
|
||||
if (win_private) {
|
||||
win_private->SetFrameElementInternal(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
if ((mNeedsAsyncDestroy || !doc ||
|
||||
|
@ -1677,7 +1679,7 @@ nsFrameLoader::MaybeCreateDocShell()
|
|||
|
||||
mDocShell->SetChromeEventHandler(chromeEventHandler);
|
||||
|
||||
// This is nasty, this code (the do_GetInterface(mDocShell) below)
|
||||
// This is nasty, this code (the mDocShell->GetWindow() below)
|
||||
// *must* come *after* the above call to
|
||||
// mDocShell->SetChromeEventHandler() for the global window to get
|
||||
// the right chrome event handler.
|
||||
|
@ -1686,7 +1688,7 @@ nsFrameLoader::MaybeCreateDocShell()
|
|||
nsCOMPtr<Element> frame_element = mOwnerContent;
|
||||
NS_ASSERTION(frame_element, "frame loader owner element not a DOM element!");
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> win_private(do_GetInterface(mDocShell));
|
||||
nsCOMPtr<nsPIDOMWindow> win_private(mDocShell->GetWindow());
|
||||
nsCOMPtr<nsIBaseWindow> base_win(do_QueryInterface(mDocShell));
|
||||
if (win_private) {
|
||||
win_private->SetFrameElementInternal(frame_element);
|
||||
|
@ -1878,14 +1880,15 @@ nsFrameLoader::GetWindowDimensions(nsRect& aRect)
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWebNavigation> parentAsWebNav =
|
||||
do_GetInterface(doc->GetWindow());
|
||||
|
||||
if (!parentAsWebNav) {
|
||||
nsCOMPtr<nsPIDOMWindow> win = doc->GetWindow();
|
||||
if (!win) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeItem> parentAsItem(do_QueryInterface(parentAsWebNav));
|
||||
nsCOMPtr<nsIDocShellTreeItem> parentAsItem(win->GetDocShell());
|
||||
if (!parentAsItem) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeOwner> parentOwner;
|
||||
if (NS_FAILED(parentAsItem->GetTreeOwner(getter_AddRefs(parentOwner))) ||
|
||||
|
@ -2052,14 +2055,15 @@ nsFrameLoader::TryRemoteBrowser()
|
|||
return false;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWebNavigation> parentAsWebNav =
|
||||
do_GetInterface(doc->GetWindow());
|
||||
|
||||
if (!parentAsWebNav) {
|
||||
nsCOMPtr<nsPIDOMWindow> parentWin = doc->GetWindow();
|
||||
if (!parentWin) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeItem> parentAsItem(do_QueryInterface(parentAsWebNav));
|
||||
nsCOMPtr<nsIDocShellTreeItem> parentAsItem(parentWin->GetDocShell());
|
||||
if (!parentAsItem) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// <iframe mozbrowser> gets to skip these checks.
|
||||
if (!OwnerIsBrowserOrAppFrame()) {
|
||||
|
@ -2127,7 +2131,7 @@ nsFrameLoader::TryRemoteBrowser()
|
|||
mChildID = mRemoteBrowser->Manager()->ChildID();
|
||||
nsCOMPtr<nsIDocShellTreeItem> rootItem;
|
||||
parentAsItem->GetRootTreeItem(getter_AddRefs(rootItem));
|
||||
nsCOMPtr<nsIDOMWindow> rootWin = do_GetInterface(rootItem);
|
||||
nsCOMPtr<nsIDOMWindow> rootWin = rootItem->GetWindow();
|
||||
nsCOMPtr<nsIDOMChromeWindow> rootChromeWin = do_QueryInterface(rootWin);
|
||||
NS_ABORT_IF_FALSE(rootChromeWin, "How did we not get a chrome window here?");
|
||||
|
||||
|
@ -2222,15 +2226,18 @@ nsFrameLoader::CreateStaticClone(nsIFrameLoader* aDest)
|
|||
dest->MaybeCreateDocShell();
|
||||
NS_ENSURE_STATE(dest->mDocShell);
|
||||
|
||||
nsCOMPtr<nsIDocument> dummy = do_GetInterface(dest->mDocShell);
|
||||
nsCOMPtr<nsIDocument> dummy = dest->mDocShell->GetDocument();
|
||||
nsCOMPtr<nsIContentViewer> viewer;
|
||||
dest->mDocShell->GetContentViewer(getter_AddRefs(viewer));
|
||||
NS_ENSURE_STATE(viewer);
|
||||
|
||||
nsCOMPtr<nsIDocShell> origDocShell;
|
||||
GetDocShell(getter_AddRefs(origDocShell));
|
||||
nsCOMPtr<nsIDocument> doc = do_GetInterface(origDocShell);
|
||||
NS_ENSURE_STATE(origDocShell);
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = origDocShell->GetDocument();
|
||||
NS_ENSURE_STATE(doc);
|
||||
|
||||
nsCOMPtr<nsIDocument> clonedDoc = doc->CreateStaticClone(dest->mDocShell);
|
||||
nsCOMPtr<nsIDOMDocument> clonedDOMDoc = do_QueryInterface(clonedDoc);
|
||||
|
||||
|
@ -2425,8 +2432,19 @@ nsFrameLoader::EnsureMessageManager()
|
|||
nsCOMPtr<nsIDOMChromeWindow> chromeWindow =
|
||||
do_QueryInterface(GetOwnerDoc()->GetWindow());
|
||||
nsCOMPtr<nsIMessageBroadcaster> parentManager;
|
||||
|
||||
if (chromeWindow) {
|
||||
chromeWindow->GetMessageManager(getter_AddRefs(parentManager));
|
||||
nsAutoString messagemanagergroup;
|
||||
if (mOwnerContent->IsXUL() &&
|
||||
mOwnerContent->GetAttr(kNameSpaceID_None,
|
||||
nsGkAtoms::messagemanagergroup,
|
||||
messagemanagergroup)) {
|
||||
chromeWindow->GetGroupMessageManager(messagemanagergroup, getter_AddRefs(parentManager));
|
||||
}
|
||||
|
||||
if (!parentManager) {
|
||||
chromeWindow->GetMessageManager(getter_AddRefs(parentManager));
|
||||
}
|
||||
}
|
||||
|
||||
if (ShouldUseRemoteProcess()) {
|
||||
|
|
|
@ -431,7 +431,7 @@ nsFrameMessageManager::LoadFrameScript(const nsAString& aURL,
|
|||
aRunInGlobalScope = true;
|
||||
|
||||
if (aAllowDelayedLoad) {
|
||||
if (IsGlobal() || IsWindowLevel()) {
|
||||
if (IsGlobal() || IsBroadcaster()) {
|
||||
// Cache for future windows or frames
|
||||
mPendingScripts.AppendElement(aURL);
|
||||
mPendingScriptsGlobalStates.AppendElement(aRunInGlobalScope);
|
||||
|
@ -481,7 +481,7 @@ nsFrameMessageManager::GetDelayedFrameScripts(JSContext* aCx, JS::MutableHandle<
|
|||
{
|
||||
// Frame message managers may return an incomplete list because scripts
|
||||
// that were loaded after it was connected are not added to the list.
|
||||
if (!IsGlobal() && !IsWindowLevel()) {
|
||||
if (!IsGlobal() && !IsBroadcaster()) {
|
||||
NS_WARNING("Cannot retrieve list of pending frame scripts for frame"
|
||||
"message managers as it may be incomplete");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
@ -590,7 +590,7 @@ nsFrameMessageManager::SendMessage(const nsAString& aMessageName,
|
|||
bool aIsSync)
|
||||
{
|
||||
NS_ASSERTION(!IsGlobal(), "Should not call SendSyncMessage in chrome");
|
||||
NS_ASSERTION(!IsWindowLevel(), "Should not call SendSyncMessage in chrome");
|
||||
NS_ASSERTION(!IsBroadcaster(), "Should not call SendSyncMessage in chrome");
|
||||
NS_ASSERTION(!mParentManager, "Should not have parent manager in content!");
|
||||
|
||||
aRetval.setUndefined();
|
||||
|
@ -1069,7 +1069,7 @@ nsFrameMessageManager::ReceiveMessage(nsISupports* aTarget,
|
|||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
if (!JS_CallFunctionValue(cx, thisObject, funval, argv, &rval)) {
|
||||
if (!JS_CallFunctionValue(cx, thisObject, funval, JS::HandleValueArray(argv), &rval)) {
|
||||
nsJSUtils::ReportPendingException(cx);
|
||||
continue;
|
||||
}
|
||||
|
@ -1099,19 +1099,26 @@ nsFrameMessageManager::AddChildManager(nsFrameMessageManager* aManager)
|
|||
|
||||
nsRefPtr<nsFrameMessageManager> kungfuDeathGrip = this;
|
||||
nsRefPtr<nsFrameMessageManager> kungfuDeathGrip2 = aManager;
|
||||
// We have parent manager if we're a window message manager.
|
||||
// In that case we want to load the pending scripts from global
|
||||
// message manager.
|
||||
if (mParentManager) {
|
||||
nsRefPtr<nsFrameMessageManager> globalMM = mParentManager;
|
||||
for (uint32_t i = 0; i < globalMM->mPendingScripts.Length(); ++i) {
|
||||
aManager->LoadFrameScript(globalMM->mPendingScripts[i], false,
|
||||
globalMM->mPendingScriptsGlobalStates[i]);
|
||||
}
|
||||
|
||||
LoadPendingScripts(this, aManager);
|
||||
}
|
||||
|
||||
void
|
||||
nsFrameMessageManager::LoadPendingScripts(nsFrameMessageManager* aManager,
|
||||
nsFrameMessageManager* aChildMM)
|
||||
{
|
||||
// We have parent manager if we're a message broadcaster.
|
||||
// In that case we want to load the pending scripts from all parent
|
||||
// message managers in the hierarchy. Process the parent first so
|
||||
// that pending scripts higher up in the hierarchy are loaded before others.
|
||||
if (aManager->mParentManager) {
|
||||
LoadPendingScripts(aManager->mParentManager, aChildMM);
|
||||
}
|
||||
for (uint32_t i = 0; i < mPendingScripts.Length(); ++i) {
|
||||
aManager->LoadFrameScript(mPendingScripts[i], false,
|
||||
mPendingScriptsGlobalStates[i]);
|
||||
|
||||
for (uint32_t i = 0; i < aManager->mPendingScripts.Length(); ++i) {
|
||||
aChildMM->LoadFrameScript(aManager->mPendingScripts[i],
|
||||
false,
|
||||
aManager->mPendingScriptsGlobalStates[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1138,7 +1145,7 @@ nsFrameMessageManager::InitWithCallback(MessageManagerCallback* aCallback)
|
|||
|
||||
SetCallback(aCallback);
|
||||
|
||||
// First load global scripts by adding this to parent manager.
|
||||
// First load parent scripts by adding this to parent manager.
|
||||
if (mParentManager) {
|
||||
mParentManager->AddChildManager(this);
|
||||
}
|
||||
|
|
|
@ -173,10 +173,10 @@ public:
|
|||
NS_ASSERTION(!mIsBroadcaster || !mCallback,
|
||||
"Broadcasters cannot have callbacks!");
|
||||
// This is a bit hackish. When parent manager is global, we want
|
||||
// to attach the window message manager to it immediately.
|
||||
// to attach the message manager to it immediately.
|
||||
// Is it just the frame message manager which waits until the
|
||||
// content process is running.
|
||||
if (mParentManager && (mCallback || IsWindowLevel())) {
|
||||
if (mParentManager && (mCallback || IsBroadcaster())) {
|
||||
mParentManager->AddChildManager(this);
|
||||
}
|
||||
if (mOwnsCallback) {
|
||||
|
@ -258,7 +258,7 @@ public:
|
|||
mParentManager = aParent;
|
||||
}
|
||||
bool IsGlobal() { return mGlobal; }
|
||||
bool IsWindowLevel() { return mParentManager && mParentManager->IsGlobal(); }
|
||||
bool IsBroadcaster() { return mIsBroadcaster; }
|
||||
|
||||
static nsFrameMessageManager* GetParentProcessManager()
|
||||
{
|
||||
|
@ -296,6 +296,9 @@ protected:
|
|||
nsFrameMessageManager* mParentManager;
|
||||
nsTArray<nsString> mPendingScripts;
|
||||
nsTArray<bool> mPendingScriptsGlobalStates;
|
||||
|
||||
void LoadPendingScripts(nsFrameMessageManager* aManager,
|
||||
nsFrameMessageManager* aChildMM);
|
||||
public:
|
||||
static nsFrameMessageManager* sParentProcessManager;
|
||||
static nsFrameMessageManager* sChildProcessManager;
|
||||
|
|
|
@ -583,6 +583,7 @@ GK_ATOM(minpos, "minpos")
|
|||
GK_ATOM(minusSign, "minus-sign")
|
||||
GK_ATOM(minwidth, "minwidth")
|
||||
GK_ATOM(_mixed, "mixed")
|
||||
GK_ATOM(messagemanagergroup, "messagemanagergroup")
|
||||
GK_ATOM(mod, "mod")
|
||||
GK_ATOM(mode, "mode")
|
||||
GK_ATOM(modifiers, "modifiers")
|
||||
|
|
|
@ -157,9 +157,9 @@ nsHTMLContentSerializer::SerializeHTMLAttributes(nsIContent* aContent,
|
|||
nsDependentAtomString nameStr(attrName);
|
||||
nsAutoString prefix;
|
||||
if (namespaceID == kNameSpaceID_XML) {
|
||||
prefix.AssignLiteral("xml");
|
||||
prefix.AssignLiteral(MOZ_UTF16("xml"));
|
||||
} else if (namespaceID == kNameSpaceID_XLink) {
|
||||
prefix.AssignLiteral("xlink");
|
||||
prefix.AssignLiteral(MOZ_UTF16("xlink"));
|
||||
}
|
||||
|
||||
// Expand shorthand attribute.
|
||||
|
|
|
@ -167,7 +167,11 @@ NS_IMETHODIMP
|
|||
nsInProcessTabChildGlobal::GetContent(nsIDOMWindow** aContent)
|
||||
{
|
||||
*aContent = nullptr;
|
||||
nsCOMPtr<nsIDOMWindow> window = do_GetInterface(mDocShell);
|
||||
if (!mDocShell) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> window = mDocShell->GetWindow();
|
||||
window.swap(*aContent);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -220,10 +224,12 @@ nsInProcessTabChildGlobal::DelayedDisconnect()
|
|||
DOMEventTargetHelper::DispatchTrustedEvent(NS_LITERAL_STRING("unload"));
|
||||
|
||||
// Continue with the Disconnect cleanup
|
||||
nsCOMPtr<nsPIDOMWindow> win = do_GetInterface(mDocShell);
|
||||
if (win) {
|
||||
MOZ_ASSERT(win->IsOuterWindow());
|
||||
win->SetChromeEventHandler(win->GetChromeEventHandler());
|
||||
if (mDocShell) {
|
||||
nsCOMPtr<nsPIDOMWindow> win = mDocShell->GetWindow();
|
||||
if (win) {
|
||||
MOZ_ASSERT(win->IsOuterWindow());
|
||||
win->SetChromeEventHandler(win->GetChromeEventHandler());
|
||||
}
|
||||
}
|
||||
mDocShell = nullptr;
|
||||
mChromeMessageManager = nullptr;
|
||||
|
|
|
@ -1532,14 +1532,14 @@ nsObjectLoadingContent::UpdateObjectParameters(bool aJavaURI)
|
|||
|
||||
if (isJava && hasCodebase && codebaseStr.IsEmpty()) {
|
||||
// Java treats codebase="" as "/"
|
||||
codebaseStr.AssignLiteral("/");
|
||||
codebaseStr.Assign('/');
|
||||
// XXX(johns): This doesn't cover the case of "https:" which java would
|
||||
// interpret as "https:///" but we interpret as this document's
|
||||
// URI but with a changed scheme.
|
||||
} else if (isJava && !hasCodebase) {
|
||||
// Java expects a directory as the codebase, or else it will construct
|
||||
// relative URIs incorrectly :(
|
||||
codebaseStr.AssignLiteral(".");
|
||||
codebaseStr.Assign('.');
|
||||
}
|
||||
|
||||
if (!codebaseStr.IsEmpty()) {
|
||||
|
|
|
@ -1603,7 +1603,7 @@ nsPlainTextSerializer::Write(const nsAString& aStr)
|
|||
}
|
||||
}
|
||||
|
||||
mCurrentLine.AssignLiteral("");
|
||||
mCurrentLine.Truncate();
|
||||
if (mFlags & nsIDocumentEncoder::OutputFormatFlowed) {
|
||||
if ((outputLineBreak || !spacesOnly) && // bugs 261467,125928
|
||||
!stringpart.EqualsLiteral("-- ") &&
|
||||
|
|
|
@ -98,10 +98,10 @@ nsXMLContentSerializer::Init(uint32_t aFlags, uint32_t aWrapColumn,
|
|||
mLineBreak.AssignLiteral("\r\n");
|
||||
}
|
||||
else if (mFlags & nsIDocumentEncoder::OutputCRLineBreak) { // Mac
|
||||
mLineBreak.AssignLiteral("\r");
|
||||
mLineBreak.Assign('\r');
|
||||
}
|
||||
else if (mFlags & nsIDocumentEncoder::OutputLFLineBreak) { // Unix/DOM
|
||||
mLineBreak.AssignLiteral("\n");
|
||||
mLineBreak.Assign('\n');
|
||||
}
|
||||
else {
|
||||
mLineBreak.AssignLiteral(NS_LINEBREAK); // Platform/default
|
||||
|
@ -600,7 +600,7 @@ nsXMLContentSerializer::ConfirmPrefix(nsAString& aPrefix,
|
|||
void
|
||||
nsXMLContentSerializer::GenerateNewPrefix(nsAString& aPrefix)
|
||||
{
|
||||
aPrefix.AssignLiteral("a");
|
||||
aPrefix.Assign('a');
|
||||
char buf[128];
|
||||
PR_snprintf(buf, sizeof(buf), "%d", mPrefixIndex++);
|
||||
AppendASCIItoUTF16(buf, aPrefix);
|
||||
|
|
|
@ -71,7 +71,7 @@ const isData = document => document.URL.startsWith("data:");
|
|||
|
||||
const uri1 = "data:text/html;charset=utf-8,<h1>1</h1>";
|
||||
// For whatever reason going back on load event doesn't work so timeout it is :(
|
||||
const uri2 = "data:text/html;charset=utf-8,<h1>2</h1><script>setTimeout(back,100)</script>";
|
||||
const uri2 = "data:text/html;charset=utf-8,<h1>2</h1><script>setTimeout(SpecialPowers.wrap(window).back,100)</script>";
|
||||
const uri3 = "data:text/html;charset=utf-8,<h1>3</h1>";
|
||||
|
||||
const uri4 = "chrome://browser/content/license.html";
|
||||
|
|
|
@ -9,6 +9,11 @@ support-files =
|
|||
file_bug549682.xul
|
||||
file_bug616841.xul
|
||||
file_bug816340.xul
|
||||
file_bug990812-1.xul
|
||||
file_bug990812-2.xul
|
||||
file_bug990812-3.xul
|
||||
file_bug990812-4.xul
|
||||
file_bug990812-5.xul
|
||||
fileconstructor_file.png
|
||||
frame_bug814638.xul
|
||||
host_bug814638.xul
|
||||
|
@ -45,6 +50,7 @@ support-files =
|
|||
[test_bug814638.xul]
|
||||
[test_bug816340.xul]
|
||||
[test_bug914381.html]
|
||||
[test_bug990812.xul]
|
||||
[test_cpows.xul]
|
||||
skip-if = toolkit == "cocoa"
|
||||
[test_document_register.xul]
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
|
||||
type="text/css"?>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=990812
|
||||
-->
|
||||
<window title="Mozilla Bug 990812"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
onload="start();">
|
||||
<label value="Mozilla Bug 990812"/>
|
||||
<!-- test code goes here -->
|
||||
<script type="application/javascript"><![CDATA[
|
||||
|
||||
var FRAME_SCRIPT_GLOBAL = "data:,sendSyncMessage('test', 'global')";
|
||||
var FRAME_SCRIPT_WINDOW = "data:,sendSyncMessage('test', 'window')";
|
||||
var FRAME_SCRIPT_GROUP = "data:,sendSyncMessage('test', 'group')";
|
||||
|
||||
var Cc = Components.classes;
|
||||
var Ci = Components.interfaces;
|
||||
var globalMM = Cc["@mozilla.org/globalmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageListenerManager);
|
||||
|
||||
function is(val, exp, msg) {
|
||||
opener.wrappedJSObject.is(val, exp, msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that delayed frame scripts are loaded in the expected order.
|
||||
* Global frame scripts will be loaded before delayed frame scripts from
|
||||
* window message managers. The latter will be loaded before group message
|
||||
* manager frame scripts.
|
||||
*/
|
||||
function start() {
|
||||
globalMM.loadFrameScript(FRAME_SCRIPT_GLOBAL, true);
|
||||
messageManager.loadFrameScript(FRAME_SCRIPT_WINDOW, true);
|
||||
getGroupMessageManager("test").loadFrameScript(FRAME_SCRIPT_GROUP, true);
|
||||
|
||||
var order = ["global", "window", "group"];
|
||||
|
||||
messageManager.addMessageListener("test", function onMessage(msg) {
|
||||
var next = order.shift();
|
||||
opener.wrappedJSObject.is(msg.data, next, "received test:" + next);
|
||||
|
||||
if (order.length == 0) {
|
||||
opener.setTimeout("next()");
|
||||
window.close();
|
||||
}
|
||||
});
|
||||
|
||||
var browser = document.createElement("browser");
|
||||
browser.setAttribute("messagemanagergroup", "test");
|
||||
browser.setAttribute("src", "about:mozilla");
|
||||
browser.setAttribute("type", "content-targetable");
|
||||
document.documentElement.appendChild(browser);
|
||||
|
||||
globalMM.removeDelayedFrameScript(FRAME_SCRIPT_GLOBAL);
|
||||
messageManager.removeDelayedFrameScript(FRAME_SCRIPT_WINDOW);
|
||||
getGroupMessageManager("test").removeDelayedFrameScript(FRAME_SCRIPT_GROUP);
|
||||
}
|
||||
|
||||
]]></script>
|
||||
|
||||
</window>
|
|
@ -0,0 +1,59 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
|
||||
type="text/css"?>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=990812
|
||||
-->
|
||||
<window title="Mozilla Bug 990812"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
onload="start();">
|
||||
<label value="Mozilla Bug 990812"/>
|
||||
<!-- test code goes here -->
|
||||
<script type="application/javascript"><![CDATA[
|
||||
|
||||
var FRAME_SCRIPT = "data:,sendAsyncMessage('test')";
|
||||
var order = ["group", "window", "global"];
|
||||
|
||||
var Cc = Components.classes;
|
||||
var Ci = Components.interfaces;
|
||||
var globalMM = Cc["@mozilla.org/globalmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageListenerManager);
|
||||
|
||||
function is(val, exp, msg) {
|
||||
opener.wrappedJSObject.is(val, exp, msg);
|
||||
}
|
||||
|
||||
function promiseMessage(type, mm) {
|
||||
return new Promise(function (resolve) {
|
||||
mm.addMessageListener("test", function onMessage() {
|
||||
mm.removeMessageListener("test", onMessage);
|
||||
is(type, order.shift(), "correct type " + type);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that async messages sent by frame scripts bubble up as expected,
|
||||
* passing the group, window, and global message managers in that order.
|
||||
*/
|
||||
function start() {
|
||||
var global = promiseMessage("global", globalMM);
|
||||
var window = promiseMessage("window", messageManager);
|
||||
var group = promiseMessage("group", getGroupMessageManager("test"));
|
||||
|
||||
var browser = document.querySelector("browser");
|
||||
browser.messageManager.loadFrameScript(FRAME_SCRIPT, true);
|
||||
|
||||
Promise.all([global, window, group]).then(function () {
|
||||
opener.setTimeout("next()");
|
||||
window.close();
|
||||
});
|
||||
}
|
||||
|
||||
]]></script>
|
||||
|
||||
<browser messagemanagergroup="test" type="content-targetable" src="about:mozilla" />
|
||||
|
||||
</window>
|
|
@ -0,0 +1,71 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
|
||||
type="text/css"?>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=990812
|
||||
-->
|
||||
<window title="Mozilla Bug 990812"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
onload="start();">
|
||||
<label value="Mozilla Bug 990812"/>
|
||||
<!-- test code goes here -->
|
||||
<script type="application/javascript"><![CDATA[
|
||||
|
||||
var FRAME_SCRIPT = "data:,addMessageListener('test', function (msg) {" +
|
||||
"sendSyncMessage('test', msg.data)})";
|
||||
|
||||
var Cc = Components.classes;
|
||||
var Ci = Components.interfaces;
|
||||
var globalMM = Cc["@mozilla.org/globalmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageListenerManager);
|
||||
|
||||
function is(val, exp, msg) {
|
||||
opener.wrappedJSObject.is(val, exp, msg);
|
||||
}
|
||||
|
||||
function promiseMessage(type, mm) {
|
||||
var order = [type, "window", "global"];
|
||||
|
||||
return new Promise(function (resolve) {
|
||||
mm.addMessageListener("test", function onMessage(msg) {
|
||||
is(msg.data, order.shift(), "correct message " + msg.data);
|
||||
|
||||
if (order.length == 0) {
|
||||
mm.removeMessageListener("test", onMessage);
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that broadcasting an async message does only reach descendants
|
||||
* of a specific message manager and respects message manager groups.
|
||||
*/
|
||||
function start() {
|
||||
var mm1 = document.querySelector("browser").messageManager;
|
||||
var promise1 = promiseMessage("group1", mm1);
|
||||
mm1.loadFrameScript(FRAME_SCRIPT, true);
|
||||
|
||||
var mm2 = document.querySelector("browser + browser").messageManager;
|
||||
var promise2 = promiseMessage("group2", mm2);
|
||||
mm2.loadFrameScript(FRAME_SCRIPT, true);
|
||||
|
||||
getGroupMessageManager("test1").broadcastAsyncMessage("test", "group1");
|
||||
getGroupMessageManager("test2").broadcastAsyncMessage("test", "group2");
|
||||
messageManager.broadcastAsyncMessage("test", "window");
|
||||
globalMM.broadcastAsyncMessage("test", "global");
|
||||
|
||||
Promise.all([promise1, promise2]).then(function () {
|
||||
opener.setTimeout("next()");
|
||||
window.close();
|
||||
});
|
||||
}
|
||||
|
||||
]]></script>
|
||||
|
||||
<browser messagemanagergroup="test1" type="content-targetable" src="about:mozilla" />
|
||||
<browser messagemanagergroup="test2" type="content-targetable" src="about:mozilla" />
|
||||
|
||||
</window>
|
|
@ -0,0 +1,68 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
|
||||
type="text/css"?>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=990812
|
||||
-->
|
||||
<window title="Mozilla Bug 990812"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
onload="start();">
|
||||
<label value="Mozilla Bug 990812"/>
|
||||
<!-- test code goes here -->
|
||||
<script type="application/javascript"><![CDATA[
|
||||
|
||||
var FRAME_SCRIPT1 = "data:,addMessageListener('test', function () {" +
|
||||
"sendSyncMessage('test', 'frame1')})";
|
||||
var FRAME_SCRIPT2 = "data:,addMessageListener('test', function () {" +
|
||||
"sendSyncMessage('test', 'frame2')})";
|
||||
|
||||
var Cc = Components.classes;
|
||||
var Ci = Components.interfaces;
|
||||
var globalMM = Cc["@mozilla.org/globalmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageListenerManager);
|
||||
|
||||
function is(val, exp, msg) {
|
||||
opener.wrappedJSObject.is(val, exp, msg);
|
||||
}
|
||||
|
||||
function promiseMessage(type, mm) {
|
||||
return new Promise(function (resolve) {
|
||||
mm.addMessageListener("test", function onMessage(msg) {
|
||||
mm.removeMessageListener("test", onMessage);
|
||||
is(msg.data, type, "correct message " + type);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that swapping docShells works as expected wrt to groups.
|
||||
*/
|
||||
function start() {
|
||||
var browser1 = document.querySelector("browser");
|
||||
browser1.messageManager.loadFrameScript(FRAME_SCRIPT1, true);
|
||||
|
||||
var browser2 = document.querySelector("browser + browser");
|
||||
browser2.messageManager.loadFrameScript(FRAME_SCRIPT2, true);
|
||||
|
||||
var promise1 = promiseMessage("frame2", getGroupMessageManager("test1"));
|
||||
var promise2 = promiseMessage("frame1", getGroupMessageManager("test2"));
|
||||
|
||||
var flo1 = browser1.QueryInterface(Ci.nsIFrameLoaderOwner);
|
||||
var flo2 = browser2.QueryInterface(Ci.nsIFrameLoaderOwner);
|
||||
flo1.swapFrameLoaders(flo2);
|
||||
messageManager.broadcastAsyncMessage("test");
|
||||
|
||||
Promise.all([promise1, promise2]).then(function () {
|
||||
opener.setTimeout("next()");
|
||||
window.close();
|
||||
});
|
||||
}
|
||||
|
||||
]]></script>
|
||||
|
||||
<browser messagemanagergroup="test1" type="content-targetable" src="about:mozilla" />
|
||||
<browser messagemanagergroup="test2" type="content-targetable" src="about:mozilla" />
|
||||
|
||||
</window>
|
|
@ -0,0 +1,77 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
|
||||
type="text/css"?>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=990812
|
||||
-->
|
||||
<window title="Mozilla Bug 990812"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
onload="start();">
|
||||
<label value="Mozilla Bug 990812"/>
|
||||
<!-- test code goes here -->
|
||||
<script type="application/javascript"><![CDATA[
|
||||
|
||||
var FRAME_SCRIPT1 = "data:,addMessageListener('test', function () {" +
|
||||
"sendSyncMessage('test', 'group1')})";
|
||||
var FRAME_SCRIPT2 = "data:,addMessageListener('test', function () {" +
|
||||
"sendSyncMessage('test', 'group2')})";
|
||||
|
||||
var Cc = Components.classes;
|
||||
var Ci = Components.interfaces;
|
||||
var globalMM = Cc["@mozilla.org/globalmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageListenerManager);
|
||||
|
||||
function is(val, exp, msg) {
|
||||
opener.wrappedJSObject.is(val, exp, msg);
|
||||
}
|
||||
|
||||
function promiseTwoMessages(type, mm) {
|
||||
var numLeft = 2;
|
||||
|
||||
return new Promise(function (resolve) {
|
||||
mm.addMessageListener("test", function onMessage(msg) {
|
||||
is(msg.data, type, "correct message " + type);
|
||||
|
||||
if (--numLeft == 0) {
|
||||
mm.removeMessageListener("test", onMessage);
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* This test ensures that having multiple message manager groups with
|
||||
* multiple frame loaders in those works as expected. For a specific
|
||||
* group message manager, frame scripts should only be loaded by its
|
||||
* descendants and messages should only be received by and from those
|
||||
* child message managers.
|
||||
*/
|
||||
function start() {
|
||||
var gmm1 = getGroupMessageManager("test1");
|
||||
gmm1.loadFrameScript(FRAME_SCRIPT1, true);
|
||||
|
||||
var gmm2 = getGroupMessageManager("test2");
|
||||
gmm2.loadFrameScript(FRAME_SCRIPT2, true);
|
||||
|
||||
var promise1 = promiseTwoMessages("group1", gmm1);
|
||||
var promise2 = promiseTwoMessages("group2", gmm2);
|
||||
|
||||
messageManager.broadcastAsyncMessage("test");
|
||||
|
||||
Promise.all([promise1, promise2]).then(function () {
|
||||
opener.setTimeout("next()");
|
||||
window.close();
|
||||
});
|
||||
}
|
||||
|
||||
]]></script>
|
||||
|
||||
<browser messagemanagergroup="test1" type="content-targetable" src="about:mozilla" />
|
||||
<browser messagemanagergroup="test1" type="content-targetable" src="about:mozilla" />
|
||||
|
||||
<browser messagemanagergroup="test2" type="content-targetable" src="about:mozilla" />
|
||||
<browser messagemanagergroup="test2" type="content-targetable" src="about:mozilla" />
|
||||
|
||||
</window>
|
|
@ -0,0 +1,58 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
|
||||
type="text/css"?>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=990812
|
||||
-->
|
||||
<window title="Mozilla Bug 990812"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
onload="start();">
|
||||
<label value="Mozilla Bug 990812"/>
|
||||
<!-- test code goes here -->
|
||||
<script type="application/javascript"><![CDATA[
|
||||
|
||||
var FRAME_SCRIPT_GLOBAL = "data:,sendSyncMessage('test', 'global')";
|
||||
var FRAME_SCRIPT_WINDOW = "data:,sendSyncMessage('test', 'window')";
|
||||
var FRAME_SCRIPT_GROUP = "data:,sendSyncMessage('test', 'group')";
|
||||
|
||||
var Cc = Components.classes;
|
||||
var Ci = Components.interfaces;
|
||||
var globalMM = Cc["@mozilla.org/globalmessagemanager;1"]
|
||||
.getService(Ci.nsIMessageListenerManager);
|
||||
|
||||
function is(val, exp, msg) {
|
||||
opener.wrappedJSObject.is(val, exp, msg);
|
||||
}
|
||||
|
||||
function start() {
|
||||
globalMM.loadFrameScript(FRAME_SCRIPT_GLOBAL, true);
|
||||
messageManager.loadFrameScript(FRAME_SCRIPT_WINDOW, true);
|
||||
getGroupMessageManager("test").loadFrameScript(FRAME_SCRIPT_GROUP, true);
|
||||
|
||||
var order = ["global", "window", "group"];
|
||||
|
||||
messageManager.addMessageListener("test", function onMessage(msg) {
|
||||
var next = order.shift();
|
||||
opener.wrappedJSObject.is(msg.data, next, "received test:" + next);
|
||||
|
||||
if (order.length == 0) {
|
||||
opener.setTimeout("next()");
|
||||
window.close();
|
||||
}
|
||||
});
|
||||
|
||||
var browser = document.createElement("browser");
|
||||
browser.setAttribute("messagemanagergroup", "test");
|
||||
browser.setAttribute("src", "about:mozilla");
|
||||
browser.setAttribute("type", "content-targetable");
|
||||
document.documentElement.appendChild(browser);
|
||||
|
||||
globalMM.removeDelayedFrameScript(FRAME_SCRIPT_GLOBAL);
|
||||
messageManager.removeDelayedFrameScript(FRAME_SCRIPT_WINDOW);
|
||||
getGroupMessageManager("test").removeDelayedFrameScript(FRAME_SCRIPT_GROUP);
|
||||
}
|
||||
|
||||
]]></script>
|
||||
|
||||
</window>
|
|
@ -0,0 +1,43 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
|
||||
type="text/css"?>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=990812
|
||||
-->
|
||||
<window title="Mozilla Bug 990812"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
|
||||
<!-- test results are displayed in the html:body -->
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=990812"
|
||||
target="_blank">Mozilla Bug 990812</a>
|
||||
</body>
|
||||
|
||||
<!-- test code goes here -->
|
||||
<script type="application/javascript"><![CDATA[
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var tests = [
|
||||
"file_bug990812-1.xul",
|
||||
"file_bug990812-2.xul",
|
||||
"file_bug990812-3.xul",
|
||||
"file_bug990812-4.xul",
|
||||
"file_bug990812-5.xul",
|
||||
];
|
||||
|
||||
function next() {
|
||||
if (tests.length > 0) {
|
||||
var file = tests.shift();
|
||||
info("-- running " + file);
|
||||
window.open(file, "", "chrome");
|
||||
} else {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
|
||||
addLoadEvent(next);
|
||||
]]></script>
|
||||
</window>
|
|
@ -2313,6 +2313,7 @@ CanvasRenderingContext2D::SetFont(const nsAString& font,
|
|||
fontStyle->mFont.sizeAdjust,
|
||||
fontStyle->mFont.systemFont,
|
||||
printerFont,
|
||||
fontStyle->mFont.variant == NS_STYLE_FONT_VARIANT_SMALL_CAPS,
|
||||
fontStyle->mFont.languageOverride);
|
||||
|
||||
fontStyle->mFont.AddFontFeaturesToStyle(&style);
|
||||
|
@ -3726,8 +3727,13 @@ CanvasRenderingContext2D::AsyncDrawXULElement(nsXULElement& elem,
|
|||
|
||||
PBrowserParent *child = frameloader->GetRemoteBrowser();
|
||||
if (!child) {
|
||||
nsCOMPtr<nsIDOMWindow> window =
|
||||
do_GetInterface(frameloader->GetExistingDocShell());
|
||||
nsIDocShell* docShell = frameLoader->GetExistingDocShell();
|
||||
if (!docShell) {
|
||||
error.Throw(NS_ERROR_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> window = docShell->GetWindow();
|
||||
if (!window) {
|
||||
error.Throw(NS_ERROR_FAILURE);
|
||||
return;
|
||||
|
|
|
@ -7277,44 +7277,6 @@ HTMLInputElement::SetFilePickerFiltersFromAccept(nsIFilePicker* filePicker)
|
|||
}
|
||||
}
|
||||
|
||||
int32_t
|
||||
HTMLInputElement::GetFilterFromAccept()
|
||||
{
|
||||
NS_ASSERTION(HasAttr(kNameSpaceID_None, nsGkAtoms::accept),
|
||||
"You should not call GetFileFiltersFromAccept if the element"
|
||||
" has no accept attribute!");
|
||||
|
||||
int32_t filter = 0;
|
||||
nsAutoString accept;
|
||||
GetAttr(kNameSpaceID_None, nsGkAtoms::accept, accept);
|
||||
|
||||
HTMLSplitOnSpacesTokenizer tokenizer(accept, ',');
|
||||
|
||||
while (tokenizer.hasMoreTokens()) {
|
||||
const nsDependentSubstring token = tokenizer.nextToken();
|
||||
|
||||
int32_t tokenFilter = 0;
|
||||
if (token.EqualsLiteral("image/*")) {
|
||||
tokenFilter = nsIFilePicker::filterImages;
|
||||
} else if (token.EqualsLiteral("audio/*")) {
|
||||
tokenFilter = nsIFilePicker::filterAudio;
|
||||
} else if (token.EqualsLiteral("video/*")) {
|
||||
tokenFilter = nsIFilePicker::filterVideo;
|
||||
}
|
||||
|
||||
if (tokenFilter) {
|
||||
// We do not want to set more than one filter so if we found two different
|
||||
// kwown tokens, we will return 0 (no filter).
|
||||
if (filter && filter != tokenFilter) {
|
||||
return 0;
|
||||
}
|
||||
filter = tokenFilter;
|
||||
}
|
||||
}
|
||||
|
||||
return filter;
|
||||
}
|
||||
|
||||
Decimal
|
||||
HTMLInputElement::GetStepScaleFactor() const
|
||||
{
|
||||
|
|
|
@ -303,21 +303,6 @@ public:
|
|||
*/
|
||||
void SetFilePickerFiltersFromAccept(nsIFilePicker* filePicker);
|
||||
|
||||
/**
|
||||
* Returns the filter which should be used for the file picker according to
|
||||
* the accept attribute value.
|
||||
*
|
||||
* See:
|
||||
* http://dev.w3.org/html5/spec/forms.html#attr-input-accept
|
||||
*
|
||||
* @return Filter to use on the file picker with AppendFilters, 0 if none.
|
||||
*
|
||||
* @note You should not call this function if the element has no @accept.
|
||||
* @note This will only filter for one type of file. If more than one filter
|
||||
* is specified by the accept attribute they will *all* be ignored.
|
||||
*/
|
||||
int32_t GetFilterFromAccept();
|
||||
|
||||
/**
|
||||
* The form might need to request an update of the UI bits
|
||||
* (BF_CAN_SHOW_INVALID_UI and BF_CAN_SHOW_VALID_UI) when an invalid form
|
||||
|
|
|
@ -51,14 +51,14 @@ MediaEngineDefaultVideoSource::~MediaEngineDefaultVideoSource()
|
|||
void
|
||||
MediaEngineDefaultVideoSource::GetName(nsAString& aName)
|
||||
{
|
||||
aName.AssignLiteral("Default Video Device");
|
||||
aName.AssignLiteral(MOZ_UTF16("Default Video Device"));
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
MediaEngineDefaultVideoSource::GetUUID(nsAString& aUUID)
|
||||
{
|
||||
aUUID.AssignLiteral("1041FCBD-3F12-4F7B-9E9B-1EC556DD5676");
|
||||
aUUID.AssignLiteral(MOZ_UTF16("1041FCBD-3F12-4F7B-9E9B-1EC556DD5676"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -362,14 +362,14 @@ MediaEngineDefaultAudioSource::~MediaEngineDefaultAudioSource()
|
|||
void
|
||||
MediaEngineDefaultAudioSource::GetName(nsAString& aName)
|
||||
{
|
||||
aName.AssignLiteral("Default Audio Device");
|
||||
aName.AssignLiteral(MOZ_UTF16("Default Audio Device"));
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
MediaEngineDefaultAudioSource::GetUUID(nsAString& aUUID)
|
||||
{
|
||||
aUUID.AssignLiteral("B7CBD7C1-53EF-42F9-8353-73F61C70C092");
|
||||
aUUID.AssignLiteral(MOZ_UTF16("B7CBD7C1-53EF-42F9-8353-73F61C70C092"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -109,13 +109,13 @@ MediaEngineTabVideoSource::InitRunnable::Run()
|
|||
void
|
||||
MediaEngineTabVideoSource::GetName(nsAString_internal& aName)
|
||||
{
|
||||
aName.AssignLiteral("&getUserMedia.videoDevice.tabShare;");
|
||||
aName.AssignLiteral(MOZ_UTF16("&getUserMedia.videoDevice.tabShare;"));
|
||||
}
|
||||
|
||||
void
|
||||
MediaEngineTabVideoSource::GetUUID(nsAString_internal& aUuid)
|
||||
{
|
||||
aUuid.AssignLiteral("uuid");
|
||||
aUuid.AssignLiteral(MOZ_UTF16("uuid"));
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
|
|
@ -203,4 +203,14 @@ SVGAnimatedPathSegList::SMILAnimatedPathSegList::ClearAnimValue()
|
|||
}
|
||||
}
|
||||
|
||||
size_t
|
||||
SVGAnimatedPathSegList::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
|
||||
{
|
||||
size_t total = mBaseVal.SizeOfExcludingThis(aMallocSizeOf);
|
||||
if (mAnimVal) {
|
||||
mAnimVal->SizeOfIncludingThis(aMallocSizeOf);
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#define MOZILLA_SVGANIMATEDPATHSEGLIST_H__
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsISMILAttr.h"
|
||||
#include "SVGPathData.h"
|
||||
|
@ -35,7 +36,7 @@ class SVGAnimationElement;
|
|||
* DOMSVGPathSegList::InternalListWillChangeTo) and frees consumers from having
|
||||
* to know or worry about wrappers (or forget about them!) for the most part.
|
||||
*/
|
||||
class SVGAnimatedPathSegList
|
||||
class SVGAnimatedPathSegList MOZ_FINAL
|
||||
{
|
||||
// friends so that they can get write access to mBaseVal and mAnimVal
|
||||
friend class DOMSVGPathSeg;
|
||||
|
@ -88,6 +89,8 @@ public:
|
|||
/// Callers own the returned nsISMILAttr
|
||||
nsISMILAttr* ToSMILAttr(nsSVGElement* aElement);
|
||||
|
||||
size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const;
|
||||
|
||||
private:
|
||||
|
||||
// mAnimVal is a pointer to allow us to determine if we're being animated or
|
||||
|
|
|
@ -1164,3 +1164,15 @@ SVGPathData::GetMarkerPositioningData(nsTArray<nsSVGMark> *aMarks) const
|
|||
}
|
||||
}
|
||||
|
||||
size_t
|
||||
SVGPathData::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
|
||||
{
|
||||
return mData.SizeOfExcludingThis(aMallocSizeOf);
|
||||
}
|
||||
|
||||
size_t
|
||||
SVGPathData::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const
|
||||
{
|
||||
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "nsIWeakReferenceUtils.h"
|
||||
#include "mozilla/gfx/2D.h"
|
||||
#include "mozilla/gfx/Types.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "nsSVGElement.h"
|
||||
#include "nsTArray.h"
|
||||
|
@ -173,6 +174,10 @@ public:
|
|||
const_iterator begin() const { return mData.Elements(); }
|
||||
const_iterator end() const { return mData.Elements() + mData.Length(); }
|
||||
|
||||
// memory reporting methods
|
||||
size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
||||
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
||||
|
||||
// Access to methods that can modify objects of this type is deliberately
|
||||
// limited. This is to reduce the chances of someone modifying objects of
|
||||
// this type without taking the necessary steps to keep DOM wrappers in sync.
|
||||
|
@ -232,7 +237,7 @@ protected:
|
|||
* sync, so we can safely expose any protected base class methods required by
|
||||
* the SMIL code.
|
||||
*/
|
||||
class SVGPathDataAndInfo : public SVGPathData
|
||||
class SVGPathDataAndInfo MOZ_FINAL : public SVGPathData
|
||||
{
|
||||
public:
|
||||
SVGPathDataAndInfo(nsSVGElement *aElement = nullptr)
|
||||
|
|
|
@ -46,6 +46,16 @@ SVGPathElement::SVGPathElement(already_AddRefed<nsINodeInfo>& aNodeInfo)
|
|||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// memory reporting methods
|
||||
|
||||
size_t
|
||||
SVGPathElement::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
|
||||
{
|
||||
return SVGPathElementBase::SizeOfExcludingThis(aMallocSizeOf) +
|
||||
mD.SizeOfExcludingThis(aMallocSizeOf);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// nsIDOMNode methods
|
||||
|
||||
|
|
|
@ -39,6 +39,9 @@ protected:
|
|||
SVGPathElement(already_AddRefed<nsINodeInfo>& aNodeInfo);
|
||||
|
||||
public:
|
||||
// DOM memory reporter participant
|
||||
NS_DECL_SIZEOF_EXCLUDING_THIS
|
||||
|
||||
// nsIContent interface
|
||||
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* name) const MOZ_OVERRIDE;
|
||||
|
||||
|
|
|
@ -4249,7 +4249,7 @@ XULDocument::BroadcasterHookup::~BroadcasterHookup()
|
|||
}
|
||||
else {
|
||||
mObservesElement->GetAttr(kNameSpaceID_None, nsGkAtoms::observes, broadcasterID);
|
||||
attribute.AssignLiteral("*");
|
||||
attribute.Assign('*');
|
||||
}
|
||||
|
||||
nsAutoCString attributeC,broadcasteridC;
|
||||
|
@ -4398,7 +4398,7 @@ XULDocument::FindBroadcaster(Element* aElement,
|
|||
*aListener = aElement;
|
||||
NS_ADDREF(*aListener);
|
||||
|
||||
aAttribute.AssignLiteral("*");
|
||||
aAttribute.Assign('*');
|
||||
}
|
||||
|
||||
// Make sure we got a valid listener.
|
||||
|
@ -4700,9 +4700,11 @@ XULDocument::ParserObserver::OnStopRequest(nsIRequest *request,
|
|||
already_AddRefed<nsPIWindowRoot>
|
||||
XULDocument::GetWindowRoot()
|
||||
{
|
||||
nsCOMPtr<nsIInterfaceRequestor> ir(mDocumentContainer);
|
||||
nsCOMPtr<nsIDOMWindow> window(do_GetInterface(ir));
|
||||
nsCOMPtr<nsPIDOMWindow> piWin(do_QueryInterface(window));
|
||||
if (!mDocumentContainer) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> piWin = mDocumentContainer->GetWindow();
|
||||
return piWin ? piWin->GetTopWindowRoot() : nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -438,13 +438,13 @@ nsXULContentUtils::SetCommandUpdater(nsIDocument* aDocument, nsIContent* aElemen
|
|||
nsAutoString events;
|
||||
aElement->GetAttr(kNameSpaceID_None, nsGkAtoms::events, events);
|
||||
if (events.IsEmpty())
|
||||
events.AssignLiteral("*");
|
||||
events.Assign('*');
|
||||
|
||||
nsAutoString targets;
|
||||
aElement->GetAttr(kNameSpaceID_None, nsGkAtoms::targets, targets);
|
||||
|
||||
if (targets.IsEmpty())
|
||||
targets.AssignLiteral("*");
|
||||
targets.Assign('*');
|
||||
|
||||
nsCOMPtr<nsIDOMElement> domelement = do_QueryInterface(aElement);
|
||||
NS_ASSERTION(domelement != nullptr, "not a DOM element");
|
||||
|
|
|
@ -251,7 +251,7 @@ nsXULTemplateQueryProcessorXML::CompileQuery(nsIXULTemplateBuilder* aBuilder,
|
|||
// if an expression is not specified, then the default is to
|
||||
// just take all of the children
|
||||
if (expr.IsEmpty())
|
||||
expr.AssignLiteral("*");
|
||||
expr.Assign('*');
|
||||
|
||||
nsCOMPtr<nsIDOMXPathExpression> compiledexpr;
|
||||
rv = CreateExpression(expr, aQueryNode, getter_AddRefs(compiledexpr));
|
||||
|
|
|
@ -134,7 +134,8 @@ nsDSURIContentListener::DoContent(const char* aContentType,
|
|||
}
|
||||
|
||||
if (loadFlags & nsIChannel::LOAD_RETARGETED_DOCUMENT_URI) {
|
||||
nsCOMPtr<nsIDOMWindow> domWindow = do_GetInterface(static_cast<nsIDocShell*>(mDocShell));
|
||||
nsCOMPtr<nsIDOMWindow> domWindow = mDocShell ? mDocShell->GetWindow()
|
||||
: nullptr;
|
||||
NS_ENSURE_TRUE(domWindow, NS_ERROR_FAILURE);
|
||||
domWindow->Focus();
|
||||
}
|
||||
|
@ -286,7 +287,7 @@ bool nsDSURIContentListener::CheckOneFrameOptionsPolicy(nsIHttpChannel *httpChan
|
|||
// window, if we're not the top. X-F-O: SAMEORIGIN requires that the
|
||||
// document must be same-origin with top window. X-F-O: DENY requires that
|
||||
// the document must never be framed.
|
||||
nsCOMPtr<nsIDOMWindow> thisWindow = do_GetInterface(static_cast<nsIDocShell*>(mDocShell));
|
||||
nsCOMPtr<nsIDOMWindow> thisWindow = mDocShell->GetWindow();
|
||||
// If we don't have DOMWindow there is no risk of clickjacking
|
||||
if (!thisWindow)
|
||||
return true;
|
||||
|
@ -328,7 +329,7 @@ bool nsDSURIContentListener::CheckOneFrameOptionsPolicy(nsIHttpChannel *httpChan
|
|||
}
|
||||
|
||||
bool system = false;
|
||||
topDoc = do_GetInterface(parentDocShellItem);
|
||||
topDoc = parentDocShellItem->GetDocument();
|
||||
if (topDoc) {
|
||||
if (NS_SUCCEEDED(ssm->IsSystemPrincipal(topDoc->NodePrincipal(),
|
||||
&system)) && system) {
|
||||
|
@ -355,7 +356,7 @@ bool nsDSURIContentListener::CheckOneFrameOptionsPolicy(nsIHttpChannel *httpChan
|
|||
return false;
|
||||
}
|
||||
|
||||
topDoc = do_GetInterface(curDocShellItem);
|
||||
topDoc = curDocShellItem->GetDocument();
|
||||
nsCOMPtr<nsIURI> topUri;
|
||||
topDoc->NodePrincipal()->GetURI(getter_AddRefs(topUri));
|
||||
|
||||
|
@ -452,9 +453,9 @@ nsDSURIContentListener::ReportXFOViolation(nsIDocShellTreeItem* aTopDocShellItem
|
|||
nsIURI* aThisURI,
|
||||
XFOHeader aHeader)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
MOZ_ASSERT(aTopDocShellItem, "Need a top docshell");
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> topOuterWindow = do_GetInterface(aTopDocShellItem);
|
||||
nsCOMPtr<nsPIDOMWindow> topOuterWindow = aTopDocShellItem->GetWindow();
|
||||
if (!topOuterWindow)
|
||||
return;
|
||||
|
||||
|
@ -465,10 +466,8 @@ nsDSURIContentListener::ReportXFOViolation(nsIDocShellTreeItem* aTopDocShellItem
|
|||
|
||||
nsCOMPtr<nsIURI> topURI;
|
||||
|
||||
nsCOMPtr<nsIDocument> document;
|
||||
|
||||
document = do_GetInterface(aTopDocShellItem);
|
||||
rv = document->NodePrincipal()->GetURI(getter_AddRefs(topURI));
|
||||
nsCOMPtr<nsIDocument> document = aTopDocShellItem->GetDocument();
|
||||
nsresult rv = document->NodePrincipal()->GetURI(getter_AddRefs(topURI));
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
|
||||
|
|
|
@ -1125,8 +1125,7 @@ NS_IMETHODIMP nsDocShell::GetInterface(const nsIID & aIID, void **aSink)
|
|||
tabChild->
|
||||
GetMessageManager(getter_AddRefs(mm));
|
||||
} else {
|
||||
nsCOMPtr<nsPIDOMWindow> win =
|
||||
do_GetInterface(static_cast<nsIDocShell*>(this));
|
||||
nsCOMPtr<nsPIDOMWindow> win = GetWindow();
|
||||
if (win) {
|
||||
mm = do_QueryInterface(win->GetParentTarget());
|
||||
}
|
||||
|
@ -1748,12 +1747,14 @@ nsDocShell::ValidateOrigin(nsIDocShellTreeItem* aOriginTreeItem,
|
|||
return true;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(aOriginTreeItem && aTargetTreeItem, "need two docshells");
|
||||
|
||||
// Get origin document principal
|
||||
nsCOMPtr<nsIDocument> originDocument(do_GetInterface(aOriginTreeItem));
|
||||
nsCOMPtr<nsIDocument> originDocument = aOriginTreeItem->GetDocument();
|
||||
NS_ENSURE_TRUE(originDocument, false);
|
||||
|
||||
// Get target principal
|
||||
nsCOMPtr<nsIDocument> targetDocument(do_GetInterface(aTargetTreeItem));
|
||||
nsCOMPtr<nsIDocument> targetDocument = aTargetTreeItem->GetDocument();
|
||||
NS_ENSURE_TRUE(targetDocument, false);
|
||||
|
||||
bool equal;
|
||||
|
@ -2093,7 +2094,7 @@ nsDocShell::GetChannelIsUnsafe(bool *aUnsafe)
|
|||
NS_IMETHODIMP
|
||||
nsDocShell::GetHasMixedActiveContentLoaded(bool* aHasMixedActiveContentLoaded)
|
||||
{
|
||||
nsCOMPtr<nsIDocument> doc(do_GetInterface(GetAsSupports(this)));
|
||||
nsCOMPtr<nsIDocument> doc(GetDocument());
|
||||
*aHasMixedActiveContentLoaded = doc && doc->GetHasMixedActiveContentLoaded();
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -2101,7 +2102,7 @@ nsDocShell::GetHasMixedActiveContentLoaded(bool* aHasMixedActiveContentLoaded)
|
|||
NS_IMETHODIMP
|
||||
nsDocShell::GetHasMixedActiveContentBlocked(bool* aHasMixedActiveContentBlocked)
|
||||
{
|
||||
nsCOMPtr<nsIDocument> doc(do_GetInterface(GetAsSupports(this)));
|
||||
nsCOMPtr<nsIDocument> doc(GetDocument());
|
||||
*aHasMixedActiveContentBlocked = doc && doc->GetHasMixedActiveContentBlocked();
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -2109,7 +2110,7 @@ nsDocShell::GetHasMixedActiveContentBlocked(bool* aHasMixedActiveContentBlocked)
|
|||
NS_IMETHODIMP
|
||||
nsDocShell::GetHasMixedDisplayContentLoaded(bool* aHasMixedDisplayContentLoaded)
|
||||
{
|
||||
nsCOMPtr<nsIDocument> doc(do_GetInterface(GetAsSupports(this)));
|
||||
nsCOMPtr<nsIDocument> doc(GetDocument());
|
||||
*aHasMixedDisplayContentLoaded = doc && doc->GetHasMixedDisplayContentLoaded();
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -2117,7 +2118,7 @@ nsDocShell::GetHasMixedDisplayContentLoaded(bool* aHasMixedDisplayContentLoaded)
|
|||
NS_IMETHODIMP
|
||||
nsDocShell::GetHasMixedDisplayContentBlocked(bool* aHasMixedDisplayContentBlocked)
|
||||
{
|
||||
nsCOMPtr<nsIDocument> doc(do_GetInterface(GetAsSupports(this)));
|
||||
nsCOMPtr<nsIDocument> doc(GetDocument());
|
||||
*aHasMixedDisplayContentBlocked = doc && doc->GetHasMixedDisplayContentBlocked();
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -2451,11 +2452,11 @@ nsDocShell::GetFullscreenAllowed(bool* aFullscreenAllowed)
|
|||
// has the allowfullscreen attribute set to true. If any ancestor
|
||||
// iframe does not have mozallowfullscreen=true, then fullscreen is
|
||||
// prohibited.
|
||||
nsCOMPtr<nsPIDOMWindow> win = do_GetInterface(GetAsSupports(this));
|
||||
nsCOMPtr<nsPIDOMWindow> win = GetWindow();
|
||||
if (!win) {
|
||||
return NS_OK;
|
||||
}
|
||||
nsCOMPtr<nsIContent> frameElement = do_QueryInterface(win->GetFrameElementInternal());
|
||||
nsCOMPtr<Element> frameElement = win->GetFrameElementInternal();
|
||||
if (frameElement &&
|
||||
frameElement->IsHTML(nsGkAtoms::iframe) &&
|
||||
!frameElement->HasAttr(kNameSpaceID_None, nsGkAtoms::allowfullscreen) &&
|
||||
|
@ -2466,11 +2467,8 @@ nsDocShell::GetFullscreenAllowed(bool* aFullscreenAllowed)
|
|||
// If we have no parent then we're the root docshell; no ancestor of the
|
||||
// original docshell doesn't have a allowfullscreen attribute, so
|
||||
// report fullscreen as allowed.
|
||||
nsCOMPtr<nsIDocShellTreeItem> dsti = do_GetInterface(GetAsSupports(this));
|
||||
NS_ENSURE_TRUE(dsti, NS_OK);
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeItem> parentTreeItem;
|
||||
dsti->GetParent(getter_AddRefs(parentTreeItem));
|
||||
GetParent(getter_AddRefs(parentTreeItem));
|
||||
if (!parentTreeItem) {
|
||||
*aFullscreenAllowed = true;
|
||||
return NS_OK;
|
||||
|
@ -3248,7 +3246,7 @@ nsDocShell::CanAccessItem(nsIDocShellTreeItem* aTargetItem,
|
|||
return false;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> targetWindow = do_GetInterface(aTargetItem);
|
||||
nsCOMPtr<nsIDOMWindow> targetWindow = aTargetItem->GetWindow();
|
||||
if (!targetWindow) {
|
||||
NS_ERROR("This should not happen, really");
|
||||
return false;
|
||||
|
@ -3269,7 +3267,7 @@ nsDocShell::CanAccessItem(nsIDocShellTreeItem* aTargetItem,
|
|||
static bool
|
||||
ItemIsActive(nsIDocShellTreeItem *aItem)
|
||||
{
|
||||
nsCOMPtr<nsIDOMWindow> window(do_GetInterface(aItem));
|
||||
nsCOMPtr<nsIDOMWindow> window = aItem->GetWindow();
|
||||
|
||||
if (window) {
|
||||
bool isClosed;
|
||||
|
@ -4126,6 +4124,20 @@ nsDocShell::GetScriptGlobalObject()
|
|||
return mScriptGlobal;
|
||||
}
|
||||
|
||||
nsIDocument*
|
||||
nsDocShell::GetDocument()
|
||||
{
|
||||
NS_ENSURE_SUCCESS(EnsureContentViewer(), nullptr);
|
||||
return mContentViewer->GetDocument();
|
||||
}
|
||||
|
||||
nsPIDOMWindow*
|
||||
nsDocShell::GetWindow()
|
||||
{
|
||||
NS_ENSURE_SUCCESS(EnsureScriptEnvironment(), nullptr);
|
||||
return mScriptGlobal;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::SetDeviceSizeIsPageSize(bool aValue)
|
||||
{
|
||||
|
@ -4612,7 +4624,7 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI *aURI,
|
|||
// If the page doesn't have a title, we will use a blank space which will be trimmed
|
||||
// and thus treated as empty by the front-end.
|
||||
if (messageStr.IsEmpty()) {
|
||||
messageStr.Assign(' ');
|
||||
messageStr.AssignLiteral(MOZ_UTF16(" "));
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -4699,7 +4711,7 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI *aURI,
|
|||
if (aURI) {
|
||||
aURI->GetHostPort(hostport);
|
||||
} else {
|
||||
hostport.AssignLiteral("?");
|
||||
hostport.Assign('?');
|
||||
}
|
||||
CopyUTF8toUTF16(hostport, formatStrs[formatStrCount++]);
|
||||
}
|
||||
|
@ -4725,7 +4737,7 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI *aURI,
|
|||
rv = textToSubURI->UnEscapeURIForUI(charset, spec, formatStrs[formatStrCount]);
|
||||
}
|
||||
} else {
|
||||
spec.AssignLiteral("?");
|
||||
spec.Assign('?');
|
||||
}
|
||||
if (NS_FAILED(rv))
|
||||
CopyUTF8toUTF16(spec, formatStrs[formatStrCount]);
|
||||
|
@ -4925,7 +4937,7 @@ nsDocShell::Reload(uint32_t aReloadFlags)
|
|||
rv = LoadHistoryEntry(mLSHE, loadType);
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<nsIDocument> doc(do_GetInterface(GetAsSupports(this)));
|
||||
nsCOMPtr<nsIDocument> doc(GetDocument());
|
||||
|
||||
// Do not inherit owner from document
|
||||
uint32_t flags = INTERNAL_LOAD_FLAGS_NONE;
|
||||
|
@ -5769,7 +5781,7 @@ nsDocShell::GetAllowMixedContentAndConnectionData(bool* aRootHasSecureConnection
|
|||
*aIsRootDocShell = sameTypeRoot.get() == static_cast<nsIDocShellTreeItem *>(this);
|
||||
|
||||
// now get the document from sameTypeRoot
|
||||
nsCOMPtr<nsIDocument> rootDoc = do_GetInterface(sameTypeRoot);
|
||||
nsCOMPtr<nsIDocument> rootDoc = sameTypeRoot->GetDocument();
|
||||
if (rootDoc) {
|
||||
nsCOMPtr<nsIPrincipal> rootPrincipal = rootDoc->NodePrincipal();
|
||||
|
||||
|
@ -7215,12 +7227,12 @@ nsDocShell::EnsureContentViewer()
|
|||
nsCOMPtr<nsIDocShellTreeItem> parentItem;
|
||||
GetSameTypeParent(getter_AddRefs(parentItem));
|
||||
if (parentItem) {
|
||||
nsCOMPtr<nsPIDOMWindow> domWin = do_GetInterface(GetAsSupports(this));
|
||||
nsCOMPtr<nsPIDOMWindow> domWin = GetWindow();
|
||||
if (domWin) {
|
||||
nsCOMPtr<nsIContent> parentContent =
|
||||
do_QueryInterface(domWin->GetFrameElementInternal());
|
||||
if (parentContent) {
|
||||
baseURI = parentContent->GetBaseURI();
|
||||
nsCOMPtr<Element> parentElement =
|
||||
domWin->GetFrameElementInternal();
|
||||
if (parentElement) {
|
||||
baseURI = parentElement->GetBaseURI();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7228,7 +7240,7 @@ nsDocShell::EnsureContentViewer()
|
|||
nsresult rv = CreateAboutBlankContentViewer(principal, baseURI);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIDocument> doc(do_GetInterface(GetAsSupports(this)));
|
||||
nsCOMPtr<nsIDocument> doc(GetDocument());
|
||||
NS_ASSERTION(doc,
|
||||
"Should have doc if CreateAboutBlankContentViewer "
|
||||
"succeeded!");
|
||||
|
@ -7618,7 +7630,7 @@ nsDocShell::FinishRestore()
|
|||
ReattachEditorToWindow(mOSHE);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = do_GetInterface(GetAsSupports(this));
|
||||
nsCOMPtr<nsIDocument> doc = GetDocument();
|
||||
if (doc) {
|
||||
// Finally, we remove the request from the loadgroup. This will
|
||||
// cause onStateChange(STATE_STOP) to fire, which will fire the
|
||||
|
@ -7981,8 +7993,9 @@ nsDocShell::RestoreFromHistory()
|
|||
if (document) {
|
||||
nsCOMPtr<nsIDocShellTreeItem> parent;
|
||||
GetParent(getter_AddRefs(parent));
|
||||
nsCOMPtr<nsIDocument> d = do_GetInterface(parent);
|
||||
if (d) {
|
||||
if (parent) {
|
||||
nsCOMPtr<nsIDocument> d = parent->GetDocument();
|
||||
if (d) {
|
||||
if (d->EventHandlingSuppressed()) {
|
||||
document->SuppressEventHandling(nsIDocument::eEvents,
|
||||
d->EventHandlingSuppressed());
|
||||
|
@ -7996,8 +8009,9 @@ nsDocShell::RestoreFromHistory()
|
|||
|
||||
nsCOMPtr<nsPIDOMWindow> parentWindow = d->GetWindow();
|
||||
if (parentWindow) {
|
||||
parentSuspendCount = parentWindow->TimeoutSuspendCount();
|
||||
parentSuspendCount = parentWindow->TimeoutSuspendCount();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Use the uri from the mLSHE we had when we entered this function
|
||||
|
@ -8013,8 +8027,7 @@ nsDocShell::RestoreFromHistory()
|
|||
// This is the end of our CreateContentViewer() replacement.
|
||||
// Now we simulate a load. First, we restore the state of the javascript
|
||||
// window object.
|
||||
nsCOMPtr<nsPIDOMWindow> privWin =
|
||||
do_GetInterface(static_cast<nsIInterfaceRequestor*>(this));
|
||||
nsCOMPtr<nsPIDOMWindow> privWin = GetWindow();
|
||||
NS_ASSERTION(privWin, "could not get nsPIDOMWindow interface");
|
||||
|
||||
rv = privWin->RestoreWindowState(windowState);
|
||||
|
@ -8604,7 +8617,7 @@ nsDocShell::SetupNewViewer(nsIContentViewer * aNewViewer)
|
|||
nsresult
|
||||
nsDocShell::SetDocCurrentStateObj(nsISHEntry *shEntry)
|
||||
{
|
||||
nsCOMPtr<nsIDocument> document = do_GetInterface(GetAsSupports(this));
|
||||
nsCOMPtr<nsIDocument> document = GetDocument();
|
||||
NS_ENSURE_TRUE(document, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIStructuredCloneContainer> scContainer;
|
||||
|
@ -8650,7 +8663,7 @@ nsDocShell::CheckLoadingPermissions()
|
|||
// or any of its ancestors.
|
||||
nsCOMPtr<nsIDocShellTreeItem> item(this);
|
||||
do {
|
||||
nsCOMPtr<nsIScriptGlobalObject> sgo(do_GetInterface(item));
|
||||
nsCOMPtr<nsIScriptGlobalObject> sgo = do_GetInterface(item);
|
||||
nsCOMPtr<nsIScriptObjectPrincipal> sop(do_QueryInterface(sgo));
|
||||
|
||||
nsIPrincipal *p;
|
||||
|
@ -9037,8 +9050,7 @@ nsDocShell::InternalLoad(nsIURI * aURI,
|
|||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> win =
|
||||
do_GetInterface(GetAsSupports(this));
|
||||
nsCOMPtr<nsPIDOMWindow> win = GetWindow();
|
||||
NS_ENSURE_TRUE(win, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
nsDependentString name(aWindowTarget);
|
||||
|
@ -9099,8 +9111,7 @@ nsDocShell::InternalLoad(nsIURI * aURI,
|
|||
// So, the best we can do, is to tear down the new window
|
||||
// that was just created!
|
||||
//
|
||||
nsCOMPtr<nsIDOMWindow> domWin =
|
||||
do_GetInterface(targetDocShell);
|
||||
nsCOMPtr<nsIDOMWindow> domWin = targetDocShell->GetWindow();
|
||||
if (domWin) {
|
||||
domWin->Close();
|
||||
}
|
||||
|
@ -9411,8 +9422,7 @@ nsDocShell::InternalLoad(nsIURI * aURI,
|
|||
}
|
||||
|
||||
// Set the doc's URI according to the new history entry's URI.
|
||||
nsCOMPtr<nsIDocument> doc =
|
||||
do_GetInterface(GetAsSupports(this));
|
||||
nsCOMPtr<nsIDocument> doc = GetDocument();
|
||||
NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
|
||||
doc->SetDocumentURI(aURI);
|
||||
|
||||
|
@ -9623,7 +9633,7 @@ nsDocShell::GetInheritedPrincipal(bool aConsiderCurrentDocument)
|
|||
nsCOMPtr<nsIDocShellTreeItem> parentItem;
|
||||
GetSameTypeParent(getter_AddRefs(parentItem));
|
||||
if (parentItem) {
|
||||
document = do_GetInterface(parentItem);
|
||||
document = parentItem->GetDocument();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9710,15 +9720,17 @@ nsDocShell::DoURILoad(nsIURI * aURI,
|
|||
nsCOMPtr<nsIContentSecurityPolicy> csp;
|
||||
nsCOMPtr<nsIDocShellTreeItem> parentItem;
|
||||
GetSameTypeParent(getter_AddRefs(parentItem));
|
||||
nsCOMPtr<nsIDocument> doc = do_GetInterface(parentItem);
|
||||
if (doc) {
|
||||
if (parentItem) {
|
||||
nsCOMPtr<nsIDocument> doc = parentItem->GetDocument();
|
||||
if (doc) {
|
||||
rv = doc->NodePrincipal()->GetCsp(getter_AddRefs(csp));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (csp) {
|
||||
channelPolicy = do_CreateInstance("@mozilla.org/nschannelpolicy;1");
|
||||
channelPolicy->SetContentSecurityPolicy(csp);
|
||||
channelPolicy->SetLoadType(nsIContentPolicy::TYPE_SUBDOCUMENT);
|
||||
channelPolicy = do_CreateInstance("@mozilla.org/nschannelpolicy;1");
|
||||
channelPolicy->SetContentSecurityPolicy(csp);
|
||||
channelPolicy->SetLoadType(nsIContentPolicy::TYPE_SUBDOCUMENT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Only allow view-source scheme in top-level docshells. view-source is
|
||||
|
@ -10631,7 +10643,7 @@ nsDocShell::AddState(JS::Handle<JS::Value> aData, const nsAString& aTitle,
|
|||
aReplace = true;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocument> document = do_GetInterface(GetAsSupports(this));
|
||||
nsCOMPtr<nsIDocument> document = GetDocument();
|
||||
NS_ENSURE_TRUE(document, NS_ERROR_FAILURE);
|
||||
|
||||
// Step 1: Serialize aData using structured clone.
|
||||
|
@ -10642,8 +10654,7 @@ nsDocShell::AddState(JS::Handle<JS::Value> aData, const nsAString& aTitle,
|
|||
// 634834) To protect against this, we abort if our principal changes due
|
||||
// to the InitFromJSVal() call.
|
||||
{
|
||||
nsCOMPtr<nsIDocument> origDocument =
|
||||
do_GetInterface(GetAsSupports(this));
|
||||
nsCOMPtr<nsIDocument> origDocument = GetDocument();
|
||||
if (!origDocument)
|
||||
return NS_ERROR_DOM_SECURITY_ERR;
|
||||
nsCOMPtr<nsIPrincipal> origPrincipal = origDocument->NodePrincipal();
|
||||
|
@ -10664,8 +10675,7 @@ nsDocShell::AddState(JS::Handle<JS::Value> aData, const nsAString& aTitle,
|
|||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDocument> newDocument =
|
||||
do_GetInterface(GetAsSupports(this));
|
||||
nsCOMPtr<nsIDocument> newDocument = GetDocument();
|
||||
if (!newDocument)
|
||||
return NS_ERROR_DOM_SECURITY_ERR;
|
||||
nsCOMPtr<nsIPrincipal> newPrincipal = newDocument->NodePrincipal();
|
||||
|
@ -12216,7 +12226,7 @@ nsDocShell::GetAssociatedWindow(nsIDOMWindow** aWindow)
|
|||
NS_IMETHODIMP
|
||||
nsDocShell::GetTopWindow(nsIDOMWindow** aWindow)
|
||||
{
|
||||
nsCOMPtr<nsIDOMWindow> win = do_GetInterface(GetAsSupports(this));
|
||||
nsCOMPtr<nsIDOMWindow> win = GetWindow();
|
||||
if (win) {
|
||||
win->GetTop(aWindow);
|
||||
}
|
||||
|
@ -12227,7 +12237,7 @@ NS_IMETHODIMP
|
|||
nsDocShell::GetTopFrameElement(nsIDOMElement** aElement)
|
||||
{
|
||||
*aElement = nullptr;
|
||||
nsCOMPtr<nsIDOMWindow> win = do_GetInterface(GetAsSupports(this));
|
||||
nsCOMPtr<nsIDOMWindow> win = GetWindow();
|
||||
if (!win) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -12345,9 +12355,7 @@ nsDocShell::EnsureCommandHandler()
|
|||
do_CreateInstance("@mozilla.org/embedcomp/command-manager;1");
|
||||
if (!commandUpdater) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> domWindow =
|
||||
do_GetInterface(static_cast<nsIInterfaceRequestor *>(this));
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> domWindow = GetWindow();
|
||||
nsresult rv = commandUpdater->Init(domWindow);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
mCommandManager = do_QueryInterface(commandUpdater);
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "nsDocShellEditorData.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIEditor.h"
|
||||
#include "nsIEditingSession.h"
|
||||
|
@ -102,8 +102,9 @@ nsDocShellEditorData::CreateEditor()
|
|||
nsCOMPtr<nsIEditingSession> editingSession;
|
||||
nsresult rv = GetEditingSession(getter_AddRefs(editingSession));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> domWindow = do_GetInterface(mDocShell);
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> domWindow =
|
||||
mDocShell ? mDocShell->GetWindow() : nullptr;
|
||||
rv = editingSession->SetupEditorOnWindow(domWindow);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
|
@ -201,7 +202,8 @@ nsDocShellEditorData::DetachFromWindow()
|
|||
NS_ASSERTION(mEditingSession,
|
||||
"Can't detach when we don't have a session to detach!");
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> domWindow = do_GetInterface(mDocShell);
|
||||
nsCOMPtr<nsIDOMWindow> domWindow =
|
||||
mDocShell ? mDocShell->GetWindow() : nullptr;
|
||||
nsresult rv = mEditingSession->DetachFromWindow(domWindow);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
@ -225,7 +227,8 @@ nsDocShellEditorData::ReattachToWindow(nsIDocShell* aDocShell)
|
|||
{
|
||||
mDocShell = aDocShell;
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> domWindow = do_GetInterface(mDocShell);
|
||||
nsCOMPtr<nsIDOMWindow> domWindow =
|
||||
mDocShell ? mDocShell->GetWindow() : nullptr;
|
||||
nsresult rv = mEditingSession->ReattachToWindow(domWindow);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ interface nsIScrollObserver;
|
|||
|
||||
typedef unsigned long nsLoadFlags;
|
||||
|
||||
[scriptable, builtinclass, uuid(e46d924d-c20f-4add-8cf5-1e1c817b2181)]
|
||||
[scriptable, builtinclass, uuid(3ca96c12-b69d-4b54-83c5-25a18d32a22b)]
|
||||
interface nsIDocShell : nsIDocShellTreeItem
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIDocShellTreeOwner;
|
||||
interface nsIDocument;
|
||||
interface nsPIDOMWindow;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -15,7 +17,7 @@ interface nsIDocShellTreeOwner;
|
|||
* node or a leaf.
|
||||
*/
|
||||
|
||||
[scriptable, uuid(f897f4af-f67e-4115-9d37-ce09f71122e2)]
|
||||
[scriptable, uuid(edb99640-8378-4106-8673-e701a086eb1c)]
|
||||
interface nsIDocShellTreeItem : nsISupports
|
||||
{
|
||||
/*
|
||||
|
@ -175,5 +177,8 @@ interface nsIDocShellTreeItem : nsISupports
|
|||
in boolean aSameType,
|
||||
in nsIDocShellTreeItem aRequestor,
|
||||
in nsIDocShellTreeItem aOriginalRequestor);
|
||||
|
||||
[noscript,nostdcall,notxpcom] nsIDocument getDocument();
|
||||
[noscript,nostdcall,notxpcom] nsPIDOMWindow getWindow();
|
||||
};
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ function test()
|
|||
// Step 5 - Go back. This should result in another onload (because the file is
|
||||
// not in bfcache) and should be the fourth time we've requested the sjs file.
|
||||
checkPopupLoadCount();
|
||||
popup.back();
|
||||
SpecialPowers.wrap(popup).back();
|
||||
yield undefined;
|
||||
|
||||
// This is the check which was failing before we fixed the bug.
|
||||
|
@ -110,7 +110,7 @@ function test()
|
|||
popup.location = 'file_bug669671.sjs?navigated-2';
|
||||
yield undefined;
|
||||
checkPopupLoadCount();
|
||||
popup.back();
|
||||
SpecialPowers.wrap(popup).back();
|
||||
yield undefined;
|
||||
checkPopupLoadCount();
|
||||
popup.close();
|
||||
|
@ -124,7 +124,7 @@ function test()
|
|||
popup.location = 'file_bug669671.sjs?navigated-3';
|
||||
yield undefined;
|
||||
checkPopupLoadCount();
|
||||
popup.back();
|
||||
SpecialPowers.wrap(popup).back();
|
||||
yield undefined;
|
||||
is(popup.document.body.innerHTML, initialCount + '',
|
||||
'Load count (should be cached)');
|
||||
|
|
|
@ -8,10 +8,10 @@ const Cu = Components.utils;
|
|||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
|
||||
// This module exposes a subset of the functionalities of the parent DOM
|
||||
// Registry to content processes, to be used from the AppsService component.
|
||||
// This module exposes a subset of the functionnalities of the parent DOM
|
||||
// Registry to content processes, to be be used from the AppsService component.
|
||||
|
||||
this.EXPORTED_SYMBOLS = ["DOMApplicationRegistry", "WrappedManifestCache"];
|
||||
this.EXPORTED_SYMBOLS = ["DOMApplicationRegistry"];
|
||||
|
||||
Cu.import("resource://gre/modules/AppsUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
@ -20,315 +20,54 @@ function debug(s) {
|
|||
//dump("-*- AppsServiceChild.jsm: " + s + "\n");
|
||||
}
|
||||
|
||||
const APPS_IPC_MSG_NAMES = [
|
||||
"Webapps:AddApp",
|
||||
"Webapps:RemoveApp",
|
||||
"Webapps:UpdateApp",
|
||||
"Webapps:CheckForUpdate:Return:KO",
|
||||
"Webapps:FireEvent",
|
||||
"Webapps:UpdateState"
|
||||
];
|
||||
|
||||
// A simple cache for the wrapped manifests.
|
||||
this.WrappedManifestCache = {
|
||||
_cache: { },
|
||||
|
||||
// Gets an entry from the cache, and populates the cache if needed.
|
||||
get: function mcache_get(aManifestURL, aManifest, aWindow, aInnerWindowID) {
|
||||
if (!(aManifestURL in this._cache)) {
|
||||
this._cache[aManifestURL] = { };
|
||||
}
|
||||
|
||||
let winObjs = this._cache[aManifestURL];
|
||||
if (!(aInnerWindowID in winObjs)) {
|
||||
winObjs[aInnerWindowID] = Cu.cloneInto(aManifest, aWindow);
|
||||
}
|
||||
|
||||
return winObjs[aInnerWindowID];
|
||||
},
|
||||
|
||||
// Invalidates an entry in the cache.
|
||||
evict: function mcache_evict(aManifestURL, aInnerWindowID) {
|
||||
debug("Evicting manifest " + aManifestURL + " window ID " +
|
||||
aInnerWindowID);
|
||||
if (aManifestURL in this._cache) {
|
||||
let winObjs = this._cache[aManifestURL];
|
||||
if (aInnerWindowID in winObjs) {
|
||||
delete winObjs[aInnerWindowID];
|
||||
}
|
||||
|
||||
if (Object.keys(winObjs).length == 0) {
|
||||
delete this._cache[aManifestURL];
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
// Clear the cache on memory pressure.
|
||||
this._cache = { };
|
||||
Cu.forceGC();
|
||||
},
|
||||
|
||||
init: function() {
|
||||
Services.obs.addObserver(this, "memory-pressure", false);
|
||||
}
|
||||
};
|
||||
|
||||
this.WrappedManifestCache.init();
|
||||
|
||||
|
||||
// DOMApplicationRegistry keeps a cache containing a list of apps in the device.
|
||||
// This information is updated with the data received from the main process and
|
||||
// it is queried by the DOM objects to set their state.
|
||||
// This module handle all the messages broadcasted from the parent process,
|
||||
// including DOM events, which are dispatched to the corresponding DOM objects.
|
||||
|
||||
this.DOMApplicationRegistry = {
|
||||
// DOMApps will hold a list of arrays of weak references to
|
||||
// mozIDOMApplication objects indexed by manifest URL.
|
||||
DOMApps: {},
|
||||
|
||||
init: function init() {
|
||||
debug("init");
|
||||
this.cpmm = Cc["@mozilla.org/childprocessmessagemanager;1"]
|
||||
.getService(Ci.nsISyncMessageSender);
|
||||
|
||||
APPS_IPC_MSG_NAMES.forEach((function(aMsgName) {
|
||||
["Webapps:AddApp", "Webapps:RemoveApp"].forEach((function(aMsgName) {
|
||||
this.cpmm.addMessageListener(aMsgName, this);
|
||||
}).bind(this));
|
||||
|
||||
this.cpmm.sendAsyncMessage("Webapps:RegisterForMessages", {
|
||||
messages: APPS_IPC_MSG_NAMES
|
||||
});
|
||||
|
||||
// We need to prime the cache with the list of apps.
|
||||
// XXX should we do this async and block callers if it's not yet there?
|
||||
let list = this.cpmm.sendSyncMessage("Webapps:GetList", { })[0];
|
||||
this.webapps = list.webapps;
|
||||
// XXX shoud we do this async and block callers if it's not yet there?
|
||||
this.webapps = this.cpmm.sendSyncMessage("Webapps:GetList", { })[0];
|
||||
|
||||
// We need a fast mapping from localId -> app, so we add an index.
|
||||
// And add the manifest to the app object.
|
||||
this.localIdIndex = { };
|
||||
for (let id in this.webapps) {
|
||||
let app = this.webapps[id];
|
||||
this.localIdIndex[app.localId] = app;
|
||||
app.manifest = list.manifests[id];
|
||||
}
|
||||
|
||||
Services.obs.addObserver(this, "xpcom-shutdown", false);
|
||||
},
|
||||
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
// cpmm.addMessageListener causes the DOMApplicationRegistry object to
|
||||
// live forever if we don't clean up properly.
|
||||
// cpmm.addMessageListener causes the DOMApplicationRegistry object to live
|
||||
// forever if we don't clean up properly.
|
||||
this.webapps = null;
|
||||
this.DOMApps = null;
|
||||
|
||||
APPS_IPC_MSG_NAMES.forEach((aMsgName) => {
|
||||
["Webapps:AddApp", "Webapps:RemoveApp"].forEach((function(aMsgName) {
|
||||
this.cpmm.removeMessageListener(aMsgName, this);
|
||||
});
|
||||
|
||||
this.cpmm.sendAsyncMessage("Webapps:UnregisterForMessages",
|
||||
APPS_IPC_MSG_NAMES)
|
||||
}).bind(this));
|
||||
},
|
||||
|
||||
receiveMessage: function receiveMessage(aMessage) {
|
||||
debug("Received " + aMessage.name + " message.");
|
||||
let msg = aMessage.data;
|
||||
let msg = aMessage.json;
|
||||
switch (aMessage.name) {
|
||||
case "Webapps:AddApp":
|
||||
this.webapps[msg.id] = msg.app;
|
||||
this.localIdIndex[msg.app.localId] = msg.app;
|
||||
break;
|
||||
case "Webapps:RemoveApp":
|
||||
delete this.DOMApps[this.webapps[msg.id].manifestURL];
|
||||
delete this.localIdIndex[this.webapps[msg.id].localId];
|
||||
delete this.webapps[msg.id];
|
||||
break;
|
||||
case "Webapps:UpdateApp":
|
||||
let app = this.webapps[msg.oldId];
|
||||
if (!app) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg.app) {
|
||||
for (let prop in msg.app) {
|
||||
app[prop] = msg.app[prop];
|
||||
}
|
||||
}
|
||||
|
||||
this.webapps[msg.newId] = app;
|
||||
this.localIdIndex[app.localId] = app;
|
||||
delete this.webapps[msg.oldId];
|
||||
|
||||
let apps = this.DOMApps[msg.app.manifestURL];
|
||||
if (!apps) {
|
||||
return;
|
||||
}
|
||||
for (let i = 0; i < apps.length; i++) {
|
||||
let domApp = apps[i].get();
|
||||
if (!domApp) {
|
||||
apps.splice(i);
|
||||
continue;
|
||||
}
|
||||
domApp._proxy = new Proxy(domApp, {
|
||||
get: function(target, prop) {
|
||||
if (!DOMApplicationRegistry.webapps[msg.newId]) {
|
||||
return;
|
||||
}
|
||||
return DOMApplicationRegistry.webapps[msg.newId][prop];
|
||||
},
|
||||
set: function(target, prop, val) {
|
||||
if (!DOMApplicationRegistry.webapps[msg.newId]) {
|
||||
return;
|
||||
}
|
||||
DOMApplicationRegistry.webapps[msg.newId][prop] = val;
|
||||
return;
|
||||
},
|
||||
});
|
||||
}
|
||||
break;
|
||||
case "Webapps:FireEvent":
|
||||
this._fireEvent(aMessage);
|
||||
break;
|
||||
case "Webapps:UpdateState":
|
||||
this._updateState(msg);
|
||||
break;
|
||||
case "Webapps:CheckForUpdate:Return:KO":
|
||||
let DOMApps = this.DOMApps[msg.manifestURL];
|
||||
if (!DOMApps || !msg.requestID) {
|
||||
return;
|
||||
}
|
||||
DOMApps.forEach((DOMApp) => {
|
||||
let domApp = DOMApp.get();
|
||||
if (domApp && msg.requestID) {
|
||||
domApp._fireRequestResult(aMessage, true /* aIsError */);
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* mozIDOMApplication management
|
||||
*/
|
||||
|
||||
// Every time a DOM app is created, we save a weak reference to it that will
|
||||
// be used to dispatch events and fire request results.
|
||||
addDOMApp: function(aApp, aManifestURL, aId) {
|
||||
let weakRef = Cu.getWeakReference(aApp);
|
||||
|
||||
if (!this.DOMApps[aManifestURL]) {
|
||||
this.DOMApps[aManifestURL] = [];
|
||||
}
|
||||
|
||||
let apps = this.DOMApps[aManifestURL];
|
||||
|
||||
// Get rid of dead weak references.
|
||||
for (let i = 0; i < apps.length; i++) {
|
||||
if (!apps[i].get()) {
|
||||
apps.splice(i);
|
||||
}
|
||||
}
|
||||
|
||||
apps.push(weakRef);
|
||||
|
||||
// Each DOM app contains a proxy object used to build their state. We
|
||||
// return the handler for this proxy object with traps to get and set
|
||||
// app properties kept in the DOMApplicationRegistry app cache.
|
||||
return {
|
||||
get: function(target, prop) {
|
||||
if (!DOMApplicationRegistry.webapps[aId]) {
|
||||
return;
|
||||
}
|
||||
return DOMApplicationRegistry.webapps[aId][prop];
|
||||
},
|
||||
set: function(target, prop, val) {
|
||||
if (!DOMApplicationRegistry.webapps[aId]) {
|
||||
return;
|
||||
}
|
||||
DOMApplicationRegistry.webapps[aId][prop] = val;
|
||||
return;
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
_fireEvent: function(aMessage) {
|
||||
let msg = aMessage.data;
|
||||
debug("_fireEvent " + JSON.stringify(msg));
|
||||
if (!this.DOMApps || !msg.manifestURL || !msg.eventType) {
|
||||
return;
|
||||
}
|
||||
|
||||
let DOMApps = this.DOMApps[msg.manifestURL];
|
||||
if (!DOMApps) {
|
||||
return;
|
||||
}
|
||||
|
||||
// The parent might ask childs to trigger more than one event in one
|
||||
// shot, so in order to avoid needless IPC we allow an array for the
|
||||
// 'eventType' IPC message field.
|
||||
if (!Array.isArray(msg.eventType)) {
|
||||
msg.eventType = [msg.eventType];
|
||||
}
|
||||
|
||||
DOMApps.forEach((DOMApp) => {
|
||||
let domApp = DOMApp.get();
|
||||
if (!domApp) {
|
||||
return;
|
||||
}
|
||||
msg.eventType.forEach((aEventType) => {
|
||||
if ('on' + aEventType in domApp) {
|
||||
domApp._fireEvent(aEventType);
|
||||
}
|
||||
});
|
||||
|
||||
if (msg.requestID) {
|
||||
aMessage.data.result = msg.manifestURL;
|
||||
domApp._fireRequestResult(aMessage);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
_updateState: function(aMessage) {
|
||||
if (!this.DOMApps || !aMessage.id) {
|
||||
return;
|
||||
}
|
||||
|
||||
let app = this.webapps[aMessage.id];
|
||||
if (!app) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (aMessage.app) {
|
||||
for (let prop in aMessage.app) {
|
||||
app[prop] = aMessage.app[prop];
|
||||
}
|
||||
}
|
||||
|
||||
if (aMessage.error) {
|
||||
app.downloadError = aMessage.error;
|
||||
}
|
||||
|
||||
if (aMessage.manifest) {
|
||||
app.manifest = aMessage.manifest;
|
||||
// Evict the wrapped manifest cache for all the affected DOM objects.
|
||||
let DOMApps = this.DOMApps[app.manifestURL];
|
||||
if (!DOMApps) {
|
||||
return;
|
||||
}
|
||||
DOMApps.forEach((DOMApp) => {
|
||||
let domApp = DOMApp.get();
|
||||
if (!domApp) {
|
||||
return;
|
||||
}
|
||||
WrappedManifestCache.evict(app.manifestURL, domApp.innerWindowID);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* nsIAppsService API
|
||||
*/
|
||||
getAppByManifestURL: function getAppByManifestURL(aManifestURL) {
|
||||
debug("getAppByManifestURL " + aManifestURL);
|
||||
return AppsUtils.getAppByManifestURL(this.webapps, aManifestURL);
|
||||
|
|
|
@ -12,7 +12,6 @@ Cu.import("resource://gre/modules/Services.jsm");
|
|||
Cu.import("resource://gre/modules/DOMRequestHelper.jsm");
|
||||
Cu.import("resource://gre/modules/AppsUtils.jsm");
|
||||
Cu.import("resource://gre/modules/BrowserElementPromptService.jsm");
|
||||
Cu.import("resource://gre/modules/AppsServiceChild.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
|
||||
"@mozilla.org/childprocessmessagemanager;1",
|
||||
|
@ -265,9 +264,50 @@ WebappsRegistry.prototype = {
|
|||
* mozIDOMApplication object
|
||||
*/
|
||||
|
||||
// A simple cache for the wrapped manifests.
|
||||
let manifestCache = {
|
||||
_cache: { },
|
||||
|
||||
// Gets an entry from the cache, and populates the cache if needed.
|
||||
get: function mcache_get(aManifestURL, aManifest, aWindow, aInnerWindowID) {
|
||||
if (!(aManifestURL in this._cache)) {
|
||||
this._cache[aManifestURL] = { };
|
||||
}
|
||||
|
||||
let winObjs = this._cache[aManifestURL];
|
||||
if (!(aInnerWindowID in winObjs)) {
|
||||
winObjs[aInnerWindowID] = Cu.cloneInto(aManifest, aWindow);
|
||||
}
|
||||
|
||||
return winObjs[aInnerWindowID];
|
||||
},
|
||||
|
||||
// Invalidates an entry in the cache.
|
||||
evict: function mcache_evict(aManifestURL, aInnerWindowID) {
|
||||
if (aManifestURL in this._cache) {
|
||||
let winObjs = this._cache[aManifestURL];
|
||||
if (aInnerWindowID in winObjs) {
|
||||
delete winObjs[aInnerWindowID];
|
||||
}
|
||||
|
||||
if (Object.keys(winObjs).length == 0) {
|
||||
delete this._cache[aManifestURL];
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
// Clear the cache on memory pressure.
|
||||
this._cache = { };
|
||||
},
|
||||
|
||||
init: function() {
|
||||
Services.obs.addObserver(this, "memory-pressure", false);
|
||||
}
|
||||
};
|
||||
|
||||
function createApplicationObject(aWindow, aApp) {
|
||||
let app = Cc["@mozilla.org/webapps/application;1"]
|
||||
.createInstance(Ci.mozIDOMApplication);
|
||||
let app = Cc["@mozilla.org/webapps/application;1"].createInstance(Ci.mozIDOMApplication);
|
||||
app.wrappedJSObject.init(aWindow, aApp);
|
||||
return app;
|
||||
}
|
||||
|
@ -280,12 +320,27 @@ WebappsApplication.prototype = {
|
|||
__proto__: DOMRequestIpcHelper.prototype,
|
||||
|
||||
init: function(aWindow, aApp) {
|
||||
let proxyHandler = DOMApplicationRegistry.addDOMApp(this,
|
||||
aApp.manifestURL,
|
||||
aApp.id);
|
||||
this._proxy = new Proxy(this, proxyHandler);
|
||||
|
||||
this._window = aWindow;
|
||||
let principal = this._window.document.nodePrincipal;
|
||||
this._appStatus = principal.appStatus;
|
||||
this.origin = aApp.origin;
|
||||
this._manifest = aApp.manifest;
|
||||
this._updateManifest = aApp.updateManifest;
|
||||
this.manifestURL = aApp.manifestURL;
|
||||
this.receipts = aApp.receipts;
|
||||
this.installOrigin = aApp.installOrigin;
|
||||
this.installTime = aApp.installTime;
|
||||
this.installState = aApp.installState || "installed";
|
||||
this.removable = aApp.removable;
|
||||
this.lastUpdateCheck = aApp.lastUpdateCheck ? aApp.lastUpdateCheck
|
||||
: Date.now();
|
||||
this.updateTime = aApp.updateTime ? aApp.updateTime
|
||||
: aApp.installTime;
|
||||
this.progress = NaN;
|
||||
this.downloadAvailable = aApp.downloadAvailable;
|
||||
this.downloading = aApp.downloading;
|
||||
this.readyToApplyDownload = aApp.readyToApplyDownload;
|
||||
this.downloadSize = aApp.downloadSize || 0;
|
||||
|
||||
this._onprogress = null;
|
||||
this._ondownloadsuccess = null;
|
||||
|
@ -293,83 +348,40 @@ WebappsApplication.prototype = {
|
|||
this._ondownloadavailable = null;
|
||||
this._ondownloadapplied = null;
|
||||
|
||||
this.initDOMRequestHelper(aWindow);
|
||||
},
|
||||
this._downloadError = null;
|
||||
|
||||
get _appStatus() {
|
||||
return this._proxy.appStatus;
|
||||
},
|
||||
this.initDOMRequestHelper(aWindow, [
|
||||
{ name: "Webapps:CheckForUpdate:Return:KO", weakRef: true },
|
||||
{ name: "Webapps:Connect:Return:OK", weakRef: true },
|
||||
{ name: "Webapps:Connect:Return:KO", weakRef: true },
|
||||
{ name: "Webapps:FireEvent", weakRef: true },
|
||||
{ name: "Webapps:GetConnections:Return:OK", weakRef: true },
|
||||
{ name: "Webapps:UpdateState", weakRef: true }
|
||||
]);
|
||||
|
||||
get downloadAvailable() {
|
||||
return this._proxy.downloadAvailable;
|
||||
},
|
||||
|
||||
get downloading() {
|
||||
return this._proxy.downloading;
|
||||
},
|
||||
|
||||
get downloadSize() {
|
||||
return this._proxy.downloadSize;
|
||||
},
|
||||
|
||||
get installOrigin() {
|
||||
return this._proxy.installOrigin;
|
||||
},
|
||||
|
||||
get installState() {
|
||||
return this._proxy.installState;
|
||||
},
|
||||
|
||||
get installTime() {
|
||||
return this._proxy.installTime;
|
||||
},
|
||||
|
||||
get lastUpdateCheck() {
|
||||
return this._proxy.lastUpdateCheck;
|
||||
},
|
||||
|
||||
get manifestURL() {
|
||||
return this._proxy.manifestURL;
|
||||
},
|
||||
|
||||
get origin() {
|
||||
return this._proxy.origin;
|
||||
},
|
||||
|
||||
get progress() {
|
||||
return this._proxy.progress;
|
||||
},
|
||||
|
||||
get readyToApplyDownload() {
|
||||
return this._proxy.readyToApplyDownload;
|
||||
},
|
||||
|
||||
get receipts() {
|
||||
return this._proxy.receipts;
|
||||
},
|
||||
|
||||
set receipts(aReceipts) {
|
||||
this._proxy.receipts = aReceipts;
|
||||
},
|
||||
|
||||
get removable() {
|
||||
return this._proxy.removable;
|
||||
},
|
||||
|
||||
get updateTime() {
|
||||
return this._proxy.updateTime;
|
||||
cpmm.sendAsyncMessage("Webapps:RegisterForMessages", {
|
||||
messages: ["Webapps:FireEvent",
|
||||
"Webapps:UpdateState"],
|
||||
app: {
|
||||
id: this.id,
|
||||
manifestURL: this.manifestURL,
|
||||
installState: this.installState,
|
||||
downloading: this.downloading
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
get manifest() {
|
||||
return WrappedManifestCache.get(this.manifestURL,
|
||||
this._proxy.manifest,
|
||||
this._window,
|
||||
this.innerWindowID);
|
||||
return manifestCache.get(this.manifestURL,
|
||||
this._manifest,
|
||||
this._window,
|
||||
this.innerWindowID);
|
||||
},
|
||||
|
||||
get updateManifest() {
|
||||
return this._proxy.updateManifest ?
|
||||
Cu.cloneInto(this._proxy.updateManifest, this._window) : null;
|
||||
return this.updateManifest =
|
||||
this._updateManifest ? Cu.cloneInto(this._updateManifest, this._window)
|
||||
: null;
|
||||
},
|
||||
|
||||
set onprogress(aCallback) {
|
||||
|
@ -413,7 +425,7 @@ WebappsApplication.prototype = {
|
|||
},
|
||||
|
||||
get downloadError() {
|
||||
return new this._window.DOMError(this._proxy.downloadError || '');
|
||||
return new this._window.DOMError(this._downloadError || '');
|
||||
},
|
||||
|
||||
download: function() {
|
||||
|
@ -455,11 +467,12 @@ WebappsApplication.prototype = {
|
|||
BrowserElementPromptService.getBrowserElementChildForWindow(this._window);
|
||||
if (browserChild) {
|
||||
this.addMessageListeners("Webapps:ClearBrowserData:Return");
|
||||
browserChild.messageManager.sendAsyncMessage("Webapps:ClearBrowserData", {
|
||||
manifestURL: this.manifestURL,
|
||||
oid: this._id,
|
||||
requestID: this.getRequestId(request)
|
||||
});
|
||||
browserChild.messageManager.sendAsyncMessage(
|
||||
"Webapps:ClearBrowserData",
|
||||
{ manifestURL: this.manifestURL,
|
||||
oid: this._id,
|
||||
requestID: this.getRequestId(request) }
|
||||
);
|
||||
} else {
|
||||
Services.DOMRequest.fireErrorAsync(request, "NO_CLEARABLE_BROWSER");
|
||||
}
|
||||
|
@ -467,33 +480,28 @@ WebappsApplication.prototype = {
|
|||
},
|
||||
|
||||
connect: function(aKeyword, aRules) {
|
||||
this.addMessageListeners(["Webapps:Connect:Return:OK",
|
||||
"Webapps:Connect:Return:KO"]);
|
||||
return this.createPromise(function (aResolve, aReject) {
|
||||
cpmm.sendAsyncMessage("Webapps:Connect", {
|
||||
keyword: aKeyword,
|
||||
rules: aRules,
|
||||
manifestURL: this.manifestURL,
|
||||
outerWindowID: this._id,
|
||||
requestID: this.getPromiseResolverId({
|
||||
resolve: aResolve,
|
||||
reject: aReject
|
||||
})
|
||||
});
|
||||
cpmm.sendAsyncMessage("Webapps:Connect",
|
||||
{ keyword: aKeyword,
|
||||
rules: aRules,
|
||||
manifestURL: this.manifestURL,
|
||||
outerWindowID: this._id,
|
||||
requestID: this.getPromiseResolverId({
|
||||
resolve: aResolve,
|
||||
reject: aReject
|
||||
})});
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
getConnections: function() {
|
||||
this.addMessageListeners("Webapps:GetConnections:Return:OK");
|
||||
return this.createPromise(function (aResolve, aReject) {
|
||||
cpmm.sendAsyncMessage("Webapps:GetConnections", {
|
||||
manifestURL: this.manifestURL,
|
||||
outerWindowID: this._id,
|
||||
requestID: this.getPromiseResolverId({
|
||||
resolve: aResolve,
|
||||
reject: aReject
|
||||
})
|
||||
});
|
||||
cpmm.sendAsyncMessage("Webapps:GetConnections",
|
||||
{ manifestURL: this.manifestURL,
|
||||
outerWindowID: this._id,
|
||||
requestID: this.getPromiseResolverId({
|
||||
resolve: aResolve,
|
||||
reject: aReject
|
||||
})});
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
|
@ -542,7 +550,12 @@ WebappsApplication.prototype = {
|
|||
|
||||
uninit: function() {
|
||||
this._onprogress = null;
|
||||
WrappedManifestCache.evict(this.manifestURL, this.innerWindowID);
|
||||
cpmm.sendAsyncMessage("Webapps:UnregisterForMessages", [
|
||||
"Webapps:FireEvent",
|
||||
"Webapps:UpdateState"
|
||||
]);
|
||||
|
||||
manifestCache.evict(this.manifestURL, this.innerWindowID);
|
||||
},
|
||||
|
||||
_fireEvent: function(aName) {
|
||||
|
@ -559,15 +572,21 @@ WebappsApplication.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
_fireRequestResult: function(aMessage, aIsError) {
|
||||
let req;
|
||||
let msg = aMessage.data;
|
||||
req = this.takeRequest(msg.requestID);
|
||||
if (!req) {
|
||||
return;
|
||||
_updateState: function(aMsg) {
|
||||
if (aMsg.app) {
|
||||
for (let prop in aMsg.app) {
|
||||
this[prop] = aMsg.app[prop];
|
||||
}
|
||||
}
|
||||
|
||||
if (aMsg.error) {
|
||||
this._downloadError = aMsg.error;
|
||||
}
|
||||
|
||||
if (aMsg.manifest) {
|
||||
this._manifest = aMsg.manifest;
|
||||
manifestCache.evict(this.manifestURL, this.innerWindowID);
|
||||
}
|
||||
aIsError ? Services.DOMRequest.fireError(req, msg.error)
|
||||
: Services.DOMRequest.fireSuccess(req, msg.result);
|
||||
},
|
||||
|
||||
receiveMessage: function(aMessage) {
|
||||
|
@ -581,7 +600,10 @@ WebappsApplication.prototype = {
|
|||
req = this.takeRequest(msg.requestID);
|
||||
}
|
||||
|
||||
if (msg.oid != this._id || !req) {
|
||||
// ondownload* callbacks should be triggered on all app instances
|
||||
if ((msg.oid != this._id || !req) &&
|
||||
aMessage.name !== "Webapps:FireEvent" &&
|
||||
aMessage.name !== "Webapps:UpdateState") {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -596,13 +618,45 @@ WebappsApplication.prototype = {
|
|||
"Webapps:Launch:Return:KO"]);
|
||||
Services.DOMRequest.fireSuccess(req, null);
|
||||
break;
|
||||
case "Webapps:CheckForUpdate:Return:KO":
|
||||
Services.DOMRequest.fireError(req, msg.error);
|
||||
break;
|
||||
case "Webapps:FireEvent":
|
||||
if (msg.manifestURL != this.manifestURL) {
|
||||
return;
|
||||
}
|
||||
|
||||
// The parent might ask childs to trigger more than one event in one
|
||||
// shot, so in order to avoid needless IPC we allow an array for the
|
||||
// 'eventType' IPC message field.
|
||||
if (!Array.isArray(msg.eventType)) {
|
||||
msg.eventType = [msg.eventType];
|
||||
}
|
||||
|
||||
msg.eventType.forEach((aEventType) => {
|
||||
if ("_on" + aEventType in this) {
|
||||
this._fireEvent(aEventType);
|
||||
} else {
|
||||
dump("Unsupported event type " + aEventType + "\n");
|
||||
}
|
||||
});
|
||||
|
||||
if (req) {
|
||||
Services.DOMRequest.fireSuccess(req, this.manifestURL);
|
||||
}
|
||||
break;
|
||||
case "Webapps:UpdateState":
|
||||
if (msg.manifestURL != this.manifestURL) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._updateState(msg);
|
||||
break;
|
||||
case "Webapps:ClearBrowserData:Return":
|
||||
this.removeMessageListeners(aMessage.name);
|
||||
Services.DOMRequest.fireSuccess(req, null);
|
||||
break;
|
||||
case "Webapps:Connect:Return:OK":
|
||||
this.removeMessageListeners(["Webapps:Connect:Return:OK",
|
||||
"Webapps:Connect:Return:KO"]);
|
||||
let messagePorts = [];
|
||||
msg.messagePortIDs.forEach((aPortID) => {
|
||||
let port = new this._window.MozInterAppMessagePort(aPortID);
|
||||
|
@ -611,12 +665,9 @@ WebappsApplication.prototype = {
|
|||
req.resolve(messagePorts);
|
||||
break;
|
||||
case "Webapps:Connect:Return:KO":
|
||||
this.removeMessageListeners(["Webapps:Connect:Return:OK",
|
||||
"Webapps:Connect:Return:KO"]);
|
||||
req.reject("No connections registered");
|
||||
break;
|
||||
case "Webapps:GetConnections:Return:OK":
|
||||
this.removeMessageListeners(aMessage.name);
|
||||
let connections = [];
|
||||
msg.connections.forEach((aConnection) => {
|
||||
let connection =
|
||||
|
@ -798,8 +849,12 @@ WebappsApplicationMgmt.prototype = {
|
|||
break;
|
||||
case "Webapps:Uninstall:Broadcast:Return:OK":
|
||||
if (this._onuninstall) {
|
||||
let detail = {
|
||||
manifestURL: msg.manifestURL,
|
||||
origin: msg.origin
|
||||
};
|
||||
let event = new this._window.MozApplicationEvent("applicationuninstall",
|
||||
{ application : createApplicationObject(this._window, msg) });
|
||||
{ application : createApplicationObject(this._window, detail) });
|
||||
this._onuninstall.handleEvent(event);
|
||||
}
|
||||
break;
|
||||
|
@ -828,5 +883,7 @@ WebappsApplicationMgmt.prototype = {
|
|||
classDescription: "Webapps Application Mgmt"})
|
||||
}
|
||||
|
||||
manifestCache.init();
|
||||
|
||||
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([WebappsRegistry,
|
||||
WebappsApplication]);
|
||||
|
|
|
@ -1121,7 +1121,8 @@ this.DOMApplicationRegistry = {
|
|||
this.removeMessageListener(["Webapps:Internal:AllMessages"], mm);
|
||||
break;
|
||||
case "Webapps:GetList":
|
||||
return { webapps: this.webapps, manifests: this._manifestCache };
|
||||
this.addMessageListener(["Webapps:AddApp", "Webapps:RemoveApp"], null, mm);
|
||||
return this.webapps;
|
||||
case "Webapps:Download":
|
||||
this.startDownload(msg.manifestURL);
|
||||
break;
|
||||
|
@ -1303,7 +1304,7 @@ this.DOMApplicationRegistry = {
|
|||
downloading: false
|
||||
},
|
||||
error: error,
|
||||
id: app.id
|
||||
manifestURL: app.manifestURL,
|
||||
})
|
||||
this.broadcastMessage("Webapps:FireEvent", {
|
||||
eventType: "downloaderror",
|
||||
|
@ -1333,7 +1334,7 @@ this.DOMApplicationRegistry = {
|
|||
if (!app.downloadAvailable) {
|
||||
this.broadcastMessage("Webapps:UpdateState", {
|
||||
error: "NO_DOWNLOAD_AVAILABLE",
|
||||
id: app.id
|
||||
manifestURL: app.manifestURL
|
||||
});
|
||||
this.broadcastMessage("Webapps:FireEvent", {
|
||||
eventType: "downloaderror",
|
||||
|
@ -1381,7 +1382,7 @@ this.DOMApplicationRegistry = {
|
|||
this.broadcastMessage("Webapps:UpdateState", {
|
||||
app: app,
|
||||
manifest: jsonManifest,
|
||||
id: app.id
|
||||
manifestURL: aManifestURL
|
||||
});
|
||||
this.broadcastMessage("Webapps:FireEvent", {
|
||||
eventType: "downloadsuccess",
|
||||
|
@ -1425,7 +1426,7 @@ this.DOMApplicationRegistry = {
|
|||
|
||||
this.broadcastMessage("Webapps:UpdateState", {
|
||||
app: app,
|
||||
id: app.id
|
||||
manifestURL: aManifestURL
|
||||
});
|
||||
this.broadcastMessage("Webapps:FireEvent", {
|
||||
eventType: "downloadsuccess",
|
||||
|
@ -1525,7 +1526,7 @@ this.DOMApplicationRegistry = {
|
|||
this.broadcastMessage("Webapps:UpdateState", {
|
||||
app: app,
|
||||
manifest: aData,
|
||||
id: app.id
|
||||
manifestURL: app.manifestURL
|
||||
});
|
||||
this.broadcastMessage("Webapps:FireEvent", {
|
||||
eventType: "downloadapplied",
|
||||
|
@ -1565,7 +1566,7 @@ this.DOMApplicationRegistry = {
|
|||
installState: aApp.installState,
|
||||
progress: 0
|
||||
},
|
||||
id: aApp.id
|
||||
manifestURL: aApp.manifestURL
|
||||
});
|
||||
let cacheUpdate = updateSvc.scheduleAppUpdate(
|
||||
appcacheURI, docURI, aApp.localId, false, aProfileDir);
|
||||
|
@ -1615,7 +1616,6 @@ this.DOMApplicationRegistry = {
|
|||
debug("checkForUpdate for " + aData.manifestURL);
|
||||
|
||||
function sendError(aError) {
|
||||
debug("checkForUpdate error " + aError);
|
||||
aData.error = aError;
|
||||
aMm.sendAsyncMessage("Webapps:CheckForUpdate:Return:KO", aData);
|
||||
}
|
||||
|
@ -1645,7 +1645,8 @@ this.DOMApplicationRegistry = {
|
|||
// then we can't have an update.
|
||||
if (app.origin.startsWith("app://") &&
|
||||
app.manifestURL.startsWith("app://")) {
|
||||
sendError("NOT_UPDATABLE");
|
||||
aData.error = "NOT_UPDATABLE";
|
||||
aMm.sendAsyncMessage("Webapps:CheckForUpdate:Return:KO", aData);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1662,7 +1663,8 @@ this.DOMApplicationRegistry = {
|
|||
if (onlyCheckAppCache) {
|
||||
// Bail out for packaged apps.
|
||||
if (app.origin.startsWith("app://")) {
|
||||
sendError("NOT_UPDATABLE");
|
||||
aData.error = "NOT_UPDATABLE";
|
||||
aMm.sendAsyncMessage("Webapps:CheckForUpdate:Return:KO", aData);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1670,7 +1672,8 @@ this.DOMApplicationRegistry = {
|
|||
this._readManifests([{ id: id }]).then((aResult) => {
|
||||
let manifest = aResult[0].manifest;
|
||||
if (!manifest.appcache_path) {
|
||||
sendError("NOT_UPDATABLE");
|
||||
aData.error = "NOT_UPDATABLE";
|
||||
aMm.sendAsyncMessage("Webapps:CheckForUpdate:Return:KO", aData);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1686,7 +1689,7 @@ this.DOMApplicationRegistry = {
|
|||
this._saveApps().then(() => {
|
||||
this.broadcastMessage("Webapps:UpdateState", {
|
||||
app: app,
|
||||
id: app.id
|
||||
manifestURL: app.manifestURL
|
||||
});
|
||||
this.broadcastMessage("Webapps:FireEvent", {
|
||||
eventType: "downloadavailable",
|
||||
|
@ -1695,7 +1698,8 @@ this.DOMApplicationRegistry = {
|
|||
});
|
||||
});
|
||||
} else {
|
||||
sendError("NOT_UPDATABLE");
|
||||
aData.error = "NOT_UPDATABLE";
|
||||
aMm.sendAsyncMessage("Webapps:CheckForUpdate:Return:KO", aData);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -1755,7 +1759,7 @@ this.DOMApplicationRegistry = {
|
|||
: "downloadapplied";
|
||||
aMm.sendAsyncMessage("Webapps:UpdateState", {
|
||||
app: app,
|
||||
id: app.id
|
||||
manifestURL: app.manifestURL
|
||||
});
|
||||
aMm.sendAsyncMessage("Webapps:FireEvent", {
|
||||
eventType: eventType,
|
||||
|
@ -1782,7 +1786,7 @@ this.DOMApplicationRegistry = {
|
|||
: "downloadapplied";
|
||||
aMm.sendAsyncMessage("Webapps:UpdateState", {
|
||||
app: app,
|
||||
id: app.id
|
||||
manifestURL: app.manifestURL
|
||||
});
|
||||
aMm.sendAsyncMessage("Webapps:FireEvent", {
|
||||
eventType: eventType,
|
||||
|
@ -1891,7 +1895,7 @@ this.DOMApplicationRegistry = {
|
|||
|
||||
this.broadcastMessage("Webapps:UpdateState", {
|
||||
app: aApp,
|
||||
id: aApp.id
|
||||
manifestURL: aApp.manifestURL
|
||||
});
|
||||
this.broadcastMessage("Webapps:FireEvent", {
|
||||
eventType: "downloadavailable",
|
||||
|
@ -1957,7 +1961,7 @@ this.DOMApplicationRegistry = {
|
|||
this.broadcastMessage("Webapps:UpdateState", {
|
||||
app: aApp,
|
||||
manifest: aApp.manifest,
|
||||
id: aApp.id
|
||||
manifestURL: aApp.manifestURL
|
||||
});
|
||||
this.broadcastMessage("Webapps:FireEvent", {
|
||||
eventType: "downloadapplied",
|
||||
|
@ -1991,7 +1995,7 @@ this.DOMApplicationRegistry = {
|
|||
this.broadcastMessage("Webapps:UpdateState", {
|
||||
app: aApp,
|
||||
manifest: aApp.manifest,
|
||||
id: aApp.id
|
||||
manifestURL: aApp.manifestURL
|
||||
});
|
||||
this.broadcastMessage("Webapps:FireEvent", {
|
||||
eventType: eventType,
|
||||
|
@ -2519,8 +2523,6 @@ this.DOMApplicationRegistry = {
|
|||
// saved in the registry.
|
||||
yield this._saveApps();
|
||||
|
||||
aData.isPackage ? appObject.updateManifest = jsonManifest :
|
||||
appObject.manifest = jsonManifest;
|
||||
this.broadcastMessage("Webapps:AddApp", { id: id, app: appObject });
|
||||
if (aData.isPackage && aData.autoInstall) {
|
||||
// Skip directly to onInstallSuccessAck, since there isn't
|
||||
|
@ -2614,7 +2616,7 @@ this.DOMApplicationRegistry = {
|
|||
this.broadcastMessage("Webapps:UpdateState", {
|
||||
app: app,
|
||||
manifest: aManifest,
|
||||
id: app.id
|
||||
manifestURL: aNewApp.manifestURL
|
||||
});
|
||||
|
||||
// Check if we have asm.js code to preload for this application.
|
||||
|
@ -2728,11 +2730,14 @@ this.DOMApplicationRegistry = {
|
|||
oldApp,
|
||||
aNewApp);
|
||||
|
||||
AppDownloadManager.add(aNewApp.manifestURL, {
|
||||
channel: requestChannel,
|
||||
appId: id,
|
||||
previousState: aIsUpdate ? "installed" : "pending"
|
||||
});
|
||||
AppDownloadManager.add(
|
||||
aNewApp.manifestURL,
|
||||
{
|
||||
channel: requestChannel,
|
||||
appId: id,
|
||||
previousState: aIsUpdate ? "installed" : "pending"
|
||||
}
|
||||
);
|
||||
|
||||
// We set the 'downloading' flag to true right before starting the fetch.
|
||||
oldApp.downloading = true;
|
||||
|
@ -2755,7 +2760,7 @@ this.DOMApplicationRegistry = {
|
|||
debug("package's etag or hash unchanged; sending 'applied' event");
|
||||
// The package's Etag or hash has not changed.
|
||||
// We send a "applied" event right away.
|
||||
this._sendAppliedEvent(oldApp);
|
||||
this._sendAppliedEvent(aNewApp, oldApp, id);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2895,7 +2900,7 @@ this.DOMApplicationRegistry = {
|
|||
app: {
|
||||
progress: aProgress
|
||||
},
|
||||
id: aNewApp.id
|
||||
manifestURL: aNewApp.manifestURL
|
||||
});
|
||||
this.broadcastMessage("Webapps:FireEvent", {
|
||||
eventType: "progress",
|
||||
|
@ -3012,24 +3017,27 @@ this.DOMApplicationRegistry = {
|
|||
* something similar after updating the app, and we could refactor both cases
|
||||
* to use the same code to send the "applied" event.
|
||||
*
|
||||
* @param aApp {Object} app data
|
||||
* @param aNewApp {Object} the new app data
|
||||
* @param aOldApp {Object} the currently stored app data
|
||||
* @param aId {String} the unique id of the app
|
||||
*/
|
||||
_sendAppliedEvent: function(aApp) {
|
||||
aApp.downloading = false;
|
||||
aApp.downloadAvailable = false;
|
||||
aApp.downloadSize = 0;
|
||||
aApp.installState = "installed";
|
||||
aApp.readyToApplyDownload = false;
|
||||
if (aApp.staged && aApp.staged.manifestHash) {
|
||||
_sendAppliedEvent: function(aNewApp, aOldApp, aId) {
|
||||
aOldApp.downloading = false;
|
||||
aOldApp.downloadAvailable = false;
|
||||
aOldApp.downloadSize = 0;
|
||||
aOldApp.installState = "installed";
|
||||
aOldApp.readyToApplyDownload = false;
|
||||
if (aOldApp.staged && aOldApp.staged.manifestHash) {
|
||||
// If we're here then the manifest has changed but the package
|
||||
// hasn't. Let's clear this, so we don't keep offering
|
||||
// a bogus update to the user
|
||||
aApp.manifestHash = aApp.staged.manifestHash;
|
||||
aApp.etag = aApp.staged.etag || aApp.etag;
|
||||
aApp.staged = {};
|
||||
// Move the staged update manifest to a non staged one.
|
||||
aOldApp.manifestHash = aOldApp.staged.manifestHash;
|
||||
aOldApp.etag = aOldApp.staged.etag || aOldApp.etag;
|
||||
aOldApp.staged = {};
|
||||
|
||||
// Move the staged update manifest to a non staged one.
|
||||
try {
|
||||
let staged = this._getAppDir(aApp.id);
|
||||
let staged = this._getAppDir(aId);
|
||||
staged.append("staged-update.webapp");
|
||||
staged.moveTo(staged.parent, "update.webapp");
|
||||
} catch (ex) {
|
||||
|
@ -3040,15 +3048,15 @@ this.DOMApplicationRegistry = {
|
|||
// Save the updated registry, and cleanup the tmp directory.
|
||||
this._saveApps().then(() => {
|
||||
this.broadcastMessage("Webapps:UpdateState", {
|
||||
app: aApp,
|
||||
id: aApp.id
|
||||
app: aOldApp,
|
||||
manifestURL: aNewApp.manifestURL
|
||||
});
|
||||
this.broadcastMessage("Webapps:FireEvent", {
|
||||
manifestURL: aApp.manifestURL,
|
||||
manifestURL: aNewApp.manifestURL,
|
||||
eventType: ["downloadsuccess", "downloadapplied"]
|
||||
});
|
||||
});
|
||||
let file = FileUtils.getFile("TmpD", ["webapps", aApp.id], false);
|
||||
let file = FileUtils.getFile("TmpD", ["webapps", aId], false);
|
||||
if (file && file.exists()) {
|
||||
file.remove(true);
|
||||
}
|
||||
|
@ -3353,10 +3361,9 @@ this.DOMApplicationRegistry = {
|
|||
dir.moveTo(parent, newId);
|
||||
});
|
||||
// Signals that we need to swap the old id with the new app.
|
||||
this.broadcastMessage("Webapps:UpdateApp", { oldId: oldId,
|
||||
newId: newId,
|
||||
app: aOldApp });
|
||||
|
||||
this.broadcastMessage("Webapps:RemoveApp", { id: oldId });
|
||||
this.broadcastMessage("Webapps:AddApp", { id: newId,
|
||||
app: aOldApp });
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -3459,7 +3466,7 @@ this.DOMApplicationRegistry = {
|
|||
this.broadcastMessage("Webapps:UpdateState", {
|
||||
app: aOldApp,
|
||||
error: aError,
|
||||
id: aNewApp.id
|
||||
manifestURL: aNewApp.manifestURL
|
||||
});
|
||||
this.broadcastMessage("Webapps:FireEvent", {
|
||||
eventType: "downloaderror",
|
||||
|
@ -4009,7 +4016,7 @@ AppcacheObserver.prototype = {
|
|||
let app = this.app;
|
||||
DOMApplicationRegistry.broadcastMessage("Webapps:UpdateState", {
|
||||
app: app,
|
||||
id: app.id
|
||||
manifestURL: app.manifestURL
|
||||
});
|
||||
DOMApplicationRegistry.broadcastMessage("Webapps:FireEvent", {
|
||||
eventType: "progress",
|
||||
|
@ -4041,7 +4048,7 @@ AppcacheObserver.prototype = {
|
|||
app.downloadAvailable = false;
|
||||
DOMApplicationRegistry.broadcastMessage("Webapps:UpdateState", {
|
||||
app: app,
|
||||
id: app.id
|
||||
manifestURL: app.manifestURL
|
||||
});
|
||||
DOMApplicationRegistry.broadcastMessage("Webapps:FireEvent", {
|
||||
eventType: ["downloadsuccess", "downloadapplied"],
|
||||
|
@ -4055,7 +4062,7 @@ AppcacheObserver.prototype = {
|
|||
DOMApplicationRegistry.broadcastMessage("Webapps:UpdateState", {
|
||||
app: app,
|
||||
error: aError,
|
||||
id: app.id
|
||||
manifestURL: app.manifestURL
|
||||
});
|
||||
DOMApplicationRegistry.broadcastMessage("Webapps:FireEvent", {
|
||||
eventType: "downloaderror",
|
||||
|
|
|
@ -98,7 +98,6 @@ var PackagedTestHelper = (function PackagedTestHelper() {
|
|||
var aApp = evt.application;
|
||||
aApp.ondownloaderror = function(evt) {
|
||||
var error = aApp.downloadError.name;
|
||||
ok(true, "Got downloaderror " + error);
|
||||
if (error == aExpectedError) {
|
||||
ok(true, "Got expected " + aExpectedError);
|
||||
var expected = {
|
||||
|
|
|
@ -79,15 +79,16 @@ function updateApp(aExpectedReady, aPreviousVersion, aNextVersion) {
|
|||
checkLastAppState.bind(PackagedTestHelper, miniManifestURL, false, false,
|
||||
aNextVersion, PackagedTestHelper.next);
|
||||
|
||||
var ondownloadsuccesshandler =
|
||||
checkLastAppState.bind(undefined, miniManifestURL,
|
||||
aExpectedReady, false, aPreviousVersion,
|
||||
function() {
|
||||
navigator.mozApps.mgmt.applyDownload(lApp);
|
||||
});
|
||||
var ondownloadsuccesshandler =
|
||||
checkLastAppState.bind(undefined, miniManifestURL,
|
||||
aExpectedReady, false, aPreviousVersion,
|
||||
function() {
|
||||
navigator.mozApps.mgmt.applyDownload(lApp);
|
||||
});
|
||||
|
||||
checkForUpdate(true, ondownloadsuccesshandler, ondownloadappliedhandler, null,
|
||||
true);
|
||||
|
||||
checkForUpdate(true, ondownloadsuccesshandler, ondownloadappliedhandler, null,
|
||||
true);
|
||||
}
|
||||
|
||||
|
||||
|
@ -173,7 +174,7 @@ var steps = [
|
|||
"&appName=arandomname" +
|
||||
"&appToFail1";
|
||||
PackagedTestHelper.checkAppDownloadError(miniManifestURL,
|
||||
"MANIFEST_MISMATCH", 1, false, true,
|
||||
"MANIFEST_MISMATCH", 2, false, true,
|
||||
"arandomname",
|
||||
function () {
|
||||
checkForUpdate(false, null, null, null, false,
|
||||
|
|
|
@ -243,4 +243,4 @@ addLoadEvent(go);
|
|||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
|
@ -91,7 +91,7 @@ nsDOMWindowList::IndexedGetter(uint32_t aIndex, bool& aFound)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> window = do_GetInterface(item);
|
||||
nsCOMPtr<nsIDOMWindow> window = item->GetWindow();
|
||||
MOZ_ASSERT(window);
|
||||
|
||||
aFound = true;
|
||||
|
|
|
@ -377,12 +377,11 @@ NS_IMETHODIMP nsFocusManager::SetFocusedWindow(nsIDOMWindow* aWindowToFocus)
|
|||
|
||||
windowToFocus = windowToFocus->GetOuterWindow();
|
||||
|
||||
nsCOMPtr<nsIContent> frameContent =
|
||||
do_QueryInterface(windowToFocus->GetFrameElementInternal());
|
||||
if (frameContent) {
|
||||
nsCOMPtr<Element> frameElement = windowToFocus->GetFrameElementInternal();
|
||||
if (frameElement) {
|
||||
// pass false for aFocusChanged so that the caret does not get updated
|
||||
// and scrolling does not occur.
|
||||
SetFocusInner(frameContent, 0, false, true);
|
||||
SetFocusInner(frameElement, 0, false, true);
|
||||
}
|
||||
else {
|
||||
// this is a top-level window. If the window has a child frame focused,
|
||||
|
@ -662,8 +661,7 @@ nsFocusManager::WindowRaised(nsIDOMWindow* aWindow)
|
|||
if (mActiveWindow)
|
||||
WindowLowered(mActiveWindow);
|
||||
|
||||
nsCOMPtr<nsIWebNavigation> webnav(do_GetInterface(aWindow));
|
||||
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(webnav));
|
||||
nsCOMPtr<nsIDocShellTreeItem> docShellAsItem = window->GetDocShell();
|
||||
// If there's no docShellAsItem, this window must have been closed,
|
||||
// in that case there is no tree owner.
|
||||
NS_ENSURE_TRUE(docShellAsItem, NS_OK);
|
||||
|
@ -805,10 +803,12 @@ nsFocusManager::ContentRemoved(nsIDocument* aDocument, nsIContent* aContent)
|
|||
// so that no element is focused.
|
||||
nsIDocument* subdoc = aDocument->GetSubDocumentFor(content);
|
||||
if (subdoc) {
|
||||
nsCOMPtr<nsISupports> container = subdoc->GetContainer();
|
||||
nsCOMPtr<nsPIDOMWindow> childWindow = do_GetInterface(container);
|
||||
if (childWindow && IsSameOrAncestor(childWindow, mFocusedWindow)) {
|
||||
ClearFocus(mActiveWindow);
|
||||
nsCOMPtr<nsIDocShell> docShell = subdoc->GetDocShell();
|
||||
if (docShell) {
|
||||
nsCOMPtr<nsPIDOMWindow> childWindow = docShell->GetWindow();
|
||||
if (childWindow && IsSameOrAncestor(childWindow, mFocusedWindow)) {
|
||||
ClearFocus(mActiveWindow);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -968,14 +968,16 @@ nsFocusManager::WindowHidden(nsIDOMWindow* aWindow)
|
|||
// ensures that the focused window isn't in a chain of frames that doesn't
|
||||
// exist any more.
|
||||
if (window != mFocusedWindow) {
|
||||
nsCOMPtr<nsIWebNavigation> webnav(do_GetInterface(mFocusedWindow));
|
||||
nsCOMPtr<nsIDocShellTreeItem> dsti = do_QueryInterface(webnav);
|
||||
nsCOMPtr<nsIDocShellTreeItem> dsti =
|
||||
mFocusedWindow ? mFocusedWindow->GetDocShell() : nullptr;
|
||||
if (dsti) {
|
||||
nsCOMPtr<nsIDocShellTreeItem> parentDsti;
|
||||
dsti->GetParent(getter_AddRefs(parentDsti));
|
||||
nsCOMPtr<nsPIDOMWindow> parentWindow = do_GetInterface(parentDsti);
|
||||
if (parentWindow)
|
||||
parentWindow->SetFocusedNode(nullptr);
|
||||
if (parentDsti) {
|
||||
nsCOMPtr<nsPIDOMWindow> parentWindow = parentDsti->GetWindow();
|
||||
if (parentWindow)
|
||||
parentWindow->SetFocusedNode(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
SetFocusedWindowInternal(window);
|
||||
|
@ -1144,13 +1146,12 @@ nsFocusManager::SetFocusInner(nsIContent* aNewContent, int32_t aFlags,
|
|||
// new root docshell for the new element with the active window's docshell.
|
||||
bool isElementInActiveWindow = false;
|
||||
|
||||
nsCOMPtr<nsIWebNavigation> webnav = do_GetInterface(newWindow);
|
||||
nsCOMPtr<nsIDocShellTreeItem> dsti = do_QueryInterface(webnav);
|
||||
nsCOMPtr<nsIDocShellTreeItem> dsti = newWindow->GetDocShell();
|
||||
nsCOMPtr<nsPIDOMWindow> newRootWindow;
|
||||
if (dsti) {
|
||||
nsCOMPtr<nsIDocShellTreeItem> root;
|
||||
dsti->GetRootTreeItem(getter_AddRefs(root));
|
||||
newRootWindow = do_GetInterface(root);
|
||||
newRootWindow = root ? root->GetWindow() : nullptr;
|
||||
|
||||
isElementInActiveWindow = (mActiveWindow && newRootWindow == mActiveWindow);
|
||||
}
|
||||
|
@ -1276,11 +1277,12 @@ bool
|
|||
nsFocusManager::IsSameOrAncestor(nsPIDOMWindow* aPossibleAncestor,
|
||||
nsPIDOMWindow* aWindow)
|
||||
{
|
||||
nsCOMPtr<nsIWebNavigation> awebnav(do_GetInterface(aPossibleAncestor));
|
||||
nsCOMPtr<nsIDocShellTreeItem> ancestordsti = do_QueryInterface(awebnav);
|
||||
if (!aWindow || !aPossibleAncestor) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIWebNavigation> fwebnav(do_GetInterface(aWindow));
|
||||
nsCOMPtr<nsIDocShellTreeItem> dsti = do_QueryInterface(fwebnav);
|
||||
nsCOMPtr<nsIDocShellTreeItem> ancestordsti = aPossibleAncestor->GetDocShell();
|
||||
nsCOMPtr<nsIDocShellTreeItem> dsti = aWindow->GetDocShell();
|
||||
while (dsti) {
|
||||
if (dsti == ancestordsti)
|
||||
return true;
|
||||
|
@ -1296,12 +1298,12 @@ already_AddRefed<nsPIDOMWindow>
|
|||
nsFocusManager::GetCommonAncestor(nsPIDOMWindow* aWindow1,
|
||||
nsPIDOMWindow* aWindow2)
|
||||
{
|
||||
nsCOMPtr<nsIWebNavigation> webnav(do_GetInterface(aWindow1));
|
||||
nsCOMPtr<nsIDocShellTreeItem> dsti1 = do_QueryInterface(webnav);
|
||||
NS_ENSURE_TRUE(aWindow1 && aWindow2, nullptr);
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeItem> dsti1 = aWindow1->GetDocShell();
|
||||
NS_ENSURE_TRUE(dsti1, nullptr);
|
||||
|
||||
webnav = do_GetInterface(aWindow2);
|
||||
nsCOMPtr<nsIDocShellTreeItem> dsti2 = do_QueryInterface(webnav);
|
||||
nsCOMPtr<nsIDocShellTreeItem> dsti2 = aWindow2->GetDocShell();
|
||||
NS_ENSURE_TRUE(dsti2, nullptr);
|
||||
|
||||
nsAutoTArray<nsIDocShellTreeItem*, 30> parents1, parents2;
|
||||
|
@ -1331,7 +1333,7 @@ nsFocusManager::GetCommonAncestor(nsPIDOMWindow* aWindow1,
|
|||
parent = child1;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(parent);
|
||||
nsCOMPtr<nsPIDOMWindow> window = parent ? parent->GetWindow() : nullptr;
|
||||
return window.forget();
|
||||
}
|
||||
|
||||
|
@ -1345,17 +1347,18 @@ nsFocusManager::AdjustWindowFocus(nsPIDOMWindow* aWindow,
|
|||
while (window) {
|
||||
// get the containing <iframe> or equivalent element so that it can be
|
||||
// focused below.
|
||||
nsCOMPtr<nsIContent> frameContent =
|
||||
do_QueryInterface(window->GetFrameElementInternal());
|
||||
nsCOMPtr<Element> frameElement = window->GetFrameElementInternal();
|
||||
|
||||
nsCOMPtr<nsIWebNavigation> webnav(do_GetInterface(window));
|
||||
nsCOMPtr<nsIDocShellTreeItem> dsti = do_QueryInterface(webnav);
|
||||
nsCOMPtr<nsIDocShellTreeItem> dsti = window->GetDocShell();
|
||||
if (!dsti)
|
||||
return;
|
||||
nsCOMPtr<nsIDocShellTreeItem> parentDsti;
|
||||
dsti->GetParent(getter_AddRefs(parentDsti));
|
||||
if (!parentDsti) {
|
||||
return;
|
||||
}
|
||||
|
||||
window = do_GetInterface(parentDsti);
|
||||
window = parentDsti->GetWindow();
|
||||
if (window) {
|
||||
// if the parent window is visible but aWindow was not, then we have
|
||||
// likely moved up and out from a hidden tab to the browser window, or a
|
||||
|
@ -1369,7 +1372,7 @@ nsFocusManager::AdjustWindowFocus(nsPIDOMWindow* aWindow,
|
|||
if (aCheckPermission && !nsContentUtils::CanCallerAccess(window))
|
||||
break;
|
||||
|
||||
window->SetFocusedNode(frameContent);
|
||||
window->SetFocusedNode(frameElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2005,8 +2008,8 @@ nsFocusManager::RaiseWindow(nsPIDOMWindow* aWindow)
|
|||
widget->SetFocus(true);
|
||||
}
|
||||
#else
|
||||
nsCOMPtr<nsIWebNavigation> webnav = do_GetInterface(aWindow);
|
||||
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = do_QueryInterface(webnav);
|
||||
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin =
|
||||
do_QueryInterface(aWindow->GetDocShell());
|
||||
if (treeOwnerAsWin) {
|
||||
nsCOMPtr<nsIWidget> widget;
|
||||
treeOwnerAsWin->GetMainWidget(getter_AddRefs(widget));
|
||||
|
@ -2079,10 +2082,10 @@ nsFocusManager::UpdateCaret(bool aMoveCaretToFocus,
|
|||
// on the nearest ancestor frame which is a chrome frame. But this is
|
||||
// what the existing code does, so just leave it for now.
|
||||
if (!browseWithCaret) {
|
||||
nsCOMPtr<nsIContent> docContent =
|
||||
do_QueryInterface(mFocusedWindow->GetFrameElementInternal());
|
||||
if (docContent)
|
||||
browseWithCaret = docContent->AttrValueIs(kNameSpaceID_None,
|
||||
nsCOMPtr<Element> docElement =
|
||||
mFocusedWindow->GetFrameElementInternal();
|
||||
if (docElement)
|
||||
browseWithCaret = docElement->AttrValueIs(kNameSpaceID_None,
|
||||
nsGkAtoms::showcaret,
|
||||
NS_LITERAL_STRING("true"),
|
||||
eCaseMatters);
|
||||
|
@ -2581,14 +2584,14 @@ nsFocusManager::DetermineElementToMoveFocus(nsPIDOMWindow* aWindow,
|
|||
// move up to the parent shell and try again from there.
|
||||
|
||||
// first, get the frame element this window is inside.
|
||||
nsCOMPtr<nsPIDOMWindow> piWindow = do_GetInterface(docShell);
|
||||
nsCOMPtr<nsPIDOMWindow> piWindow = docShell->GetWindow();
|
||||
NS_ENSURE_TRUE(piWindow, NS_ERROR_FAILURE);
|
||||
|
||||
// Next, retrieve the parent docshell, document and presshell.
|
||||
docShell = do_QueryInterface(docShellParent);
|
||||
NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> piParentWindow = do_GetInterface(docShellParent);
|
||||
nsCOMPtr<nsPIDOMWindow> piParentWindow = docShellParent->GetWindow();
|
||||
NS_ENSURE_TRUE(piParentWindow, NS_ERROR_FAILURE);
|
||||
doc = piParentWindow->GetExtantDoc();
|
||||
NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
|
||||
|
@ -2596,7 +2599,7 @@ nsFocusManager::DetermineElementToMoveFocus(nsPIDOMWindow* aWindow,
|
|||
presShell = doc->GetShell();
|
||||
|
||||
rootContent = doc->GetRootElement();
|
||||
startContent = do_QueryInterface(piWindow->GetFrameElementInternal());
|
||||
startContent = piWindow->GetFrameElementInternal();
|
||||
if (startContent) {
|
||||
nsIFrame* frame = startContent->GetPrimaryFrame();
|
||||
if (!frame)
|
||||
|
@ -2632,7 +2635,7 @@ nsFocusManager::DetermineElementToMoveFocus(nsPIDOMWindow* aWindow,
|
|||
docShell->TabToTreeOwner(forward, &tookFocus);
|
||||
// if the tree owner, took the focus, blur the current content
|
||||
if (tookFocus) {
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(docShell);
|
||||
nsCOMPtr<nsPIDOMWindow> window = docShell->GetWindow();
|
||||
if (window->GetFocusedNode() == mFocusedContent)
|
||||
Blur(mFocusedWindow, nullptr, true, true);
|
||||
else
|
||||
|
@ -2975,14 +2978,13 @@ nsFocusManager::GetRootForFocus(nsPIDOMWindow* aWindow,
|
|||
// the root element's canvas may be focused as long as the document is in a
|
||||
// a non-chrome shell and does not contain a frameset.
|
||||
if (aIsForDocNavigation) {
|
||||
nsCOMPtr<nsIContent> docContent =
|
||||
do_QueryInterface(aWindow->GetFrameElementInternal());
|
||||
nsCOMPtr<Element> docElement = aWindow->GetFrameElementInternal();
|
||||
// document navigation skips iframes and frames that are specifically non-focusable
|
||||
if (docContent) {
|
||||
if (docContent->Tag() == nsGkAtoms::iframe)
|
||||
if (docElement) {
|
||||
if (docElement->Tag() == nsGkAtoms::iframe)
|
||||
return nullptr;
|
||||
|
||||
nsIFrame* frame = docContent->GetPrimaryFrame();
|
||||
nsIFrame* frame = docElement->GetPrimaryFrame();
|
||||
if (!frame || !frame->IsFocusable(nullptr, 0))
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -3184,14 +3186,9 @@ nsFocusManager::GetNextTabbableDocument(nsIContent* aStartContent, bool aForward
|
|||
else if (mFocusedWindow) {
|
||||
startDocShell = mFocusedWindow->GetDocShell();
|
||||
doc = mFocusedWindow->GetExtantDoc();
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<nsIWebNavigation> webnav = do_GetInterface(mActiveWindow);
|
||||
startDocShell = do_QueryInterface(webnav);
|
||||
|
||||
if (mActiveWindow) {
|
||||
doc = mActiveWindow->GetExtantDoc();
|
||||
}
|
||||
} else if (mActiveWindow) {
|
||||
startDocShell = mActiveWindow->GetDocShell();
|
||||
doc = mActiveWindow->GetExtantDoc();
|
||||
}
|
||||
|
||||
if (!startDocShell)
|
||||
|
@ -3251,7 +3248,7 @@ nsFocusManager::GetNextTabbableDocument(nsIContent* aStartContent, bool aForward
|
|||
}
|
||||
|
||||
curItem = nextItem;
|
||||
nextFrame = do_GetInterface(nextItem);
|
||||
nextFrame = nextItem ? nextItem->GetWindow() : nullptr;
|
||||
}
|
||||
|
||||
if (!nextFrame)
|
||||
|
|
|
@ -3378,7 +3378,7 @@ nsPIDOMWindow::MaybeCreateDoc()
|
|||
// Note that |document| here is the same thing as our mDoc, but we
|
||||
// don't have to explicitly set the member variable because the docshell
|
||||
// has already called SetNewDocument().
|
||||
nsCOMPtr<nsIDocument> document = do_GetInterface(docShell);
|
||||
nsCOMPtr<nsIDocument> document = docShell->GetDocument();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3801,9 +3801,8 @@ nsGlobalWindow::GetRealParent(nsIDOMWindow** aParent)
|
|||
mDocShell->GetSameTypeParentIgnoreBrowserAndAppBoundaries(getter_AddRefs(parent));
|
||||
|
||||
if (parent) {
|
||||
nsCOMPtr<nsIScriptGlobalObject> globalObject(do_GetInterface(parent));
|
||||
NS_ENSURE_SUCCESS(CallQueryInterface(globalObject.get(), aParent),
|
||||
NS_ERROR_FAILURE);
|
||||
nsCOMPtr<nsPIDOMWindow> win = parent->GetWindow();
|
||||
win.forget(aParent);
|
||||
}
|
||||
else {
|
||||
*aParent = static_cast<nsIDOMWindow*>(this);
|
||||
|
@ -3968,7 +3967,11 @@ nsGlobalWindow::GetContentInternal(ErrorResult& aError)
|
|||
treeOwner->GetPrimaryContentShell(getter_AddRefs(primaryContent));
|
||||
}
|
||||
|
||||
domWindow = do_GetInterface(primaryContent);
|
||||
if (!primaryContent) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
domWindow = primaryContent->GetWindow();
|
||||
return domWindow.forget();
|
||||
}
|
||||
|
||||
|
@ -5709,7 +5712,7 @@ nsGlobalWindow::GetLength(uint32_t* aLength)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMWindow>
|
||||
nsPIDOMWindow*
|
||||
nsGlobalWindow::GetChildWindow(const nsAString& aName)
|
||||
{
|
||||
nsCOMPtr<nsIDocShell> docShell(GetDocShell());
|
||||
|
@ -5720,8 +5723,7 @@ nsGlobalWindow::GetChildWindow(const nsAString& aName)
|
|||
false, true, nullptr, nullptr,
|
||||
getter_AddRefs(child));
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> child_win(do_GetInterface(child));
|
||||
return child_win.forget();
|
||||
return child ? child->GetWindow() : nullptr;
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -5888,7 +5890,7 @@ nsGlobalWindow::SetFullScreenInternal(bool aFullScreen, bool aRequireTrust)
|
|||
// call SetFullScreen on that window instead.
|
||||
nsCOMPtr<nsIDocShellTreeItem> rootItem;
|
||||
mDocShell->GetRootTreeItem(getter_AddRefs(rootItem));
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(rootItem);
|
||||
nsCOMPtr<nsPIDOMWindow> window = rootItem ? rootItem->GetWindow() : nullptr;
|
||||
if (!window)
|
||||
return NS_ERROR_FAILURE;
|
||||
if (rootItem != mDocShell)
|
||||
|
@ -5972,7 +5974,7 @@ nsGlobalWindow::GetFullScreen(ErrorResult& aError)
|
|||
nsCOMPtr<nsIDocShellTreeItem> rootItem;
|
||||
mDocShell->GetRootTreeItem(getter_AddRefs(rootItem));
|
||||
if (rootItem != mDocShell) {
|
||||
nsCOMPtr<nsIDOMWindow> window = do_GetInterface(rootItem);
|
||||
nsCOMPtr<nsIDOMWindow> window = rootItem->GetWindow();
|
||||
if (window) {
|
||||
bool fullScreen = false;
|
||||
aError = window->GetFullScreen(&fullScreen);
|
||||
|
@ -6445,7 +6447,7 @@ nsGlobalWindow::Focus(ErrorResult& aError)
|
|||
|
||||
nsCOMPtr<nsIDocShellTreeItem> rootItem;
|
||||
mDocShell->GetRootTreeItem(getter_AddRefs(rootItem));
|
||||
nsCOMPtr<nsIDOMWindow> rootWin = do_GetInterface(rootItem);
|
||||
nsCOMPtr<nsIDOMWindow> rootWin = rootItem ? rootItem->GetWindow() : nullptr;
|
||||
bool isActive = (rootWin == activeWindow);
|
||||
|
||||
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = GetTreeOwnerWindow();
|
||||
|
@ -6488,7 +6490,8 @@ nsGlobalWindow::Focus(ErrorResult& aError)
|
|||
mDocShell->GetParent(getter_AddRefs(parentDsti));
|
||||
|
||||
// set the parent's current focus to the frame containing this window.
|
||||
nsCOMPtr<nsPIDOMWindow> parent = do_GetInterface(parentDsti);
|
||||
nsCOMPtr<nsPIDOMWindow> parent =
|
||||
parentDsti ? parentDsti->GetWindow() : nullptr;
|
||||
if (parent) {
|
||||
nsCOMPtr<nsIDocument> parentdoc = parent->GetDoc();
|
||||
if (!parentdoc) {
|
||||
|
@ -8419,7 +8422,8 @@ nsGlobalWindow::ReallyCloseWindow()
|
|||
nsCOMPtr<nsIBrowserDOMWindow> bwin;
|
||||
nsCOMPtr<nsIDocShellTreeItem> rootItem;
|
||||
mDocShell->GetRootTreeItem(getter_AddRefs(rootItem));
|
||||
nsCOMPtr<nsIDOMWindow> rootWin(do_GetInterface(rootItem));
|
||||
nsCOMPtr<nsIDOMWindow> rootWin =
|
||||
rootItem ? rootItem->GetWindow() : nullptr;
|
||||
nsCOMPtr<nsIDOMChromeWindow> chromeWin(do_QueryInterface(rootWin));
|
||||
if (chromeWin)
|
||||
chromeWin->GetBrowserDOMWindow(getter_AddRefs(bwin));
|
||||
|
@ -9784,7 +9788,11 @@ nsGlobalWindow::SetKeyboardIndicators(UIStateChangeType aShowAccelerators,
|
|||
for (int32_t i = 0; i < childCount; ++i) {
|
||||
nsCOMPtr<nsIDocShellTreeItem> childShell;
|
||||
docShell->GetChildAt(i, getter_AddRefs(childShell));
|
||||
nsCOMPtr<nsPIDOMWindow> childWindow = do_GetInterface(childShell);
|
||||
if (!childShell) {
|
||||
continue;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> childWindow = childShell->GetWindow();
|
||||
if (childWindow) {
|
||||
childWindow->SetKeyboardIndicators(aShowAccelerators, aShowFocusRings);
|
||||
}
|
||||
|
@ -11378,7 +11386,7 @@ nsGlobalWindow::FireDelayedDOMEvents()
|
|||
docShell->GetChildAt(i, getter_AddRefs(childShell));
|
||||
NS_ASSERTION(childShell, "null child shell");
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> pWin = do_GetInterface(childShell);
|
||||
nsCOMPtr<nsPIDOMWindow> pWin = childShell->GetWindow();
|
||||
if (pWin) {
|
||||
nsGlobalWindow *win =
|
||||
static_cast<nsGlobalWindow*>
|
||||
|
@ -12748,7 +12756,7 @@ nsGlobalWindow::SuspendTimeouts(uint32_t aIncrease,
|
|||
docShell->GetChildAt(i, getter_AddRefs(childShell));
|
||||
NS_ASSERTION(childShell, "null child shell");
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> pWin = do_GetInterface(childShell);
|
||||
nsCOMPtr<nsPIDOMWindow> pWin = childShell->GetWindow();
|
||||
if (pWin) {
|
||||
nsGlobalWindow *win =
|
||||
static_cast<nsGlobalWindow*>
|
||||
|
@ -12856,7 +12864,7 @@ nsGlobalWindow::ResumeTimeouts(bool aThawChildren)
|
|||
docShell->GetChildAt(i, getter_AddRefs(childShell));
|
||||
NS_ASSERTION(childShell, "null child shell");
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> pWin = do_GetInterface(childShell);
|
||||
nsCOMPtr<nsPIDOMWindow> pWin = childShell->GetWindow();
|
||||
if (pWin) {
|
||||
nsGlobalWindow *win =
|
||||
static_cast<nsGlobalWindow*>
|
||||
|
@ -13115,6 +13123,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsGlobalChromeWindow,
|
|||
nsGlobalWindow)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mBrowserDOMWindow)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMessageManager)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mGroupMessageManagers)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
|
||||
|
@ -13126,6 +13135,10 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsGlobalChromeWindow,
|
|||
tmp->mMessageManager.get())->Disconnect();
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mMessageManager)
|
||||
}
|
||||
|
||||
tmp->mGroupMessageManagers.EnumerateRead(DisconnectGroupMessageManager, nullptr);
|
||||
tmp->mGroupMessageManagers.Clear();
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mGroupMessageManagers)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
DOMCI_DATA(ChromeWindow, nsGlobalChromeWindow)
|
||||
|
@ -13494,6 +13507,39 @@ nsGlobalWindow::GetMessageManager(ErrorResult& aError)
|
|||
return myself->mMessageManager;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGlobalChromeWindow::GetGroupMessageManager(const nsAString& aGroup,
|
||||
nsIMessageBroadcaster** aManager)
|
||||
{
|
||||
ErrorResult rv;
|
||||
NS_IF_ADDREF(*aManager = GetGroupMessageManager(aGroup, rv));
|
||||
return rv.ErrorCode();
|
||||
}
|
||||
|
||||
nsIMessageBroadcaster*
|
||||
nsGlobalWindow::GetGroupMessageManager(const nsAString& aGroup,
|
||||
ErrorResult& aError)
|
||||
{
|
||||
FORWARD_TO_INNER_OR_THROW(GetGroupMessageManager, (aGroup, aError), aError, nullptr);
|
||||
MOZ_ASSERT(IsChromeWindow());
|
||||
|
||||
nsGlobalChromeWindow* myself = static_cast<nsGlobalChromeWindow*>(this);
|
||||
nsCOMPtr<nsIMessageBroadcaster> messageManager =
|
||||
myself->mGroupMessageManagers.Get(aGroup);
|
||||
|
||||
if (!messageManager) {
|
||||
nsFrameMessageManager* parent =
|
||||
static_cast<nsFrameMessageManager*>(GetMessageManager(aError));
|
||||
|
||||
messageManager = new nsFrameMessageManager(nullptr,
|
||||
parent,
|
||||
MM_CHROME | MM_BROADCASTER);
|
||||
myself->mGroupMessageManagers.Put(aGroup, messageManager);
|
||||
}
|
||||
|
||||
return messageManager;
|
||||
}
|
||||
|
||||
// nsGlobalModalWindow implementation
|
||||
|
||||
// QueryInterface implementation for nsGlobalModalWindow
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "nsTHashtable.h"
|
||||
#include "nsHashKeys.h"
|
||||
#include "nsRefPtrHashtable.h"
|
||||
#include "nsInterfaceHashtable.h"
|
||||
|
||||
// Local Includes
|
||||
// Helper Classes
|
||||
|
@ -546,7 +547,7 @@ public:
|
|||
return static_cast<nsGlobalWindow *>(top.get());
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDOMWindow> GetChildWindow(const nsAString& aName);
|
||||
nsPIDOMWindow* GetChildWindow(const nsAString& aName);
|
||||
|
||||
// These return true if we've reached the state in this top level window
|
||||
// where we ask the user if further dialogs should be blocked.
|
||||
|
@ -1007,6 +1008,8 @@ public:
|
|||
void NotifyDefaultButtonLoaded(mozilla::dom::Element& aDefaultButton,
|
||||
mozilla::ErrorResult& aError);
|
||||
nsIMessageBroadcaster* GetMessageManager(mozilla::ErrorResult& aError);
|
||||
nsIMessageBroadcaster* GetGroupMessageManager(const nsAString& aGroup,
|
||||
mozilla::ErrorResult& aError);
|
||||
void BeginWindowMove(mozilla::dom::Event& aMouseDownEvent,
|
||||
mozilla::dom::Element* aPanel,
|
||||
mozilla::ErrorResult& aError);
|
||||
|
@ -1622,16 +1625,32 @@ public:
|
|||
NS_DECL_NSIDOMCHROMEWINDOW
|
||||
|
||||
nsGlobalChromeWindow(nsGlobalWindow *aOuterWindow)
|
||||
: nsGlobalWindow(aOuterWindow)
|
||||
: nsGlobalWindow(aOuterWindow),
|
||||
mGroupMessageManagers(1)
|
||||
{
|
||||
mIsChrome = true;
|
||||
mCleanMessageManager = true;
|
||||
}
|
||||
|
||||
static PLDHashOperator
|
||||
DisconnectGroupMessageManager(const nsAString& aKey,
|
||||
nsIMessageBroadcaster* aMM,
|
||||
void* aUserArg)
|
||||
{
|
||||
if (aMM) {
|
||||
static_cast<nsFrameMessageManager*>(aMM)->Disconnect();
|
||||
}
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
~nsGlobalChromeWindow()
|
||||
{
|
||||
NS_ABORT_IF_FALSE(mCleanMessageManager,
|
||||
"chrome windows may always disconnect the msg manager");
|
||||
|
||||
mGroupMessageManagers.EnumerateRead(DisconnectGroupMessageManager, nullptr);
|
||||
mGroupMessageManagers.Clear();
|
||||
|
||||
if (mMessageManager) {
|
||||
static_cast<nsFrameMessageManager *>(
|
||||
mMessageManager.get())->Disconnect();
|
||||
|
@ -1653,10 +1672,12 @@ public:
|
|||
using nsGlobalWindow::Restore;
|
||||
using nsGlobalWindow::NotifyDefaultButtonLoaded;
|
||||
using nsGlobalWindow::GetMessageManager;
|
||||
using nsGlobalWindow::GetGroupMessageManager;
|
||||
using nsGlobalWindow::BeginWindowMove;
|
||||
|
||||
nsCOMPtr<nsIBrowserDOMWindow> mBrowserDOMWindow;
|
||||
nsCOMPtr<nsIMessageBroadcaster> mMessageManager;
|
||||
nsInterfaceHashtable<nsStringHashKey, nsIMessageBroadcaster> mGroupMessageManagers;
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
@ -153,7 +153,10 @@ nsHistory::Go(int32_t aDelta, ErrorResult& aRv)
|
|||
}
|
||||
|
||||
if (!aDelta) {
|
||||
nsCOMPtr<nsPIDOMWindow> window(do_GetInterface(GetDocShell()));
|
||||
nsCOMPtr<nsPIDOMWindow> window;
|
||||
if (nsIDocShell* docShell = GetDocShell()) {
|
||||
window = docShell->GetWindow();
|
||||
}
|
||||
|
||||
if (window && window->IsHandlingResizeEvent()) {
|
||||
// history.go(0) (aka location.reload()) was called on a window
|
||||
|
|
|
@ -54,8 +54,10 @@ GetDocumentCharacterSetForURI(const nsAString& aHref, nsACString& aCharset)
|
|||
|
||||
nsLocation::nsLocation(nsIDocShell *aDocShell)
|
||||
{
|
||||
MOZ_ASSERT(aDocShell);
|
||||
|
||||
mDocShell = do_GetWeakReference(aDocShell);
|
||||
nsCOMPtr<nsIDOMWindow> outer = do_GetInterface(aDocShell);
|
||||
nsCOMPtr<nsIDOMWindow> outer = aDocShell->GetWindow();
|
||||
mOuter = do_GetWeakReference(outer);
|
||||
}
|
||||
|
||||
|
@ -535,7 +537,8 @@ nsLocation::SetHrefWithBase(const nsAString& aHref, nsIURI* aBase,
|
|||
// Now check to make sure that the script is running in our window,
|
||||
// since we only want to replace if the location is set by a
|
||||
// <script> tag in the same window. See bug 178729.
|
||||
nsCOMPtr<nsIScriptGlobalObject> ourGlobal(do_GetInterface(docShell));
|
||||
nsCOMPtr<nsIScriptGlobalObject> ourGlobal =
|
||||
docShell ? docShell->GetScriptGlobalObject() : nullptr;
|
||||
inScriptTag = (ourGlobal == scriptContext->GetGlobalObject());
|
||||
}
|
||||
}
|
||||
|
@ -786,7 +789,7 @@ nsLocation::Reload(bool aForceget)
|
|||
nsresult rv;
|
||||
nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mDocShell));
|
||||
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(docShell));
|
||||
nsCOMPtr<nsPIDOMWindow> window(do_GetInterface(docShell));
|
||||
nsCOMPtr<nsPIDOMWindow> window = docShell ? docShell->GetWindow() : nullptr;
|
||||
|
||||
if (window && window->IsHandlingResizeEvent()) {
|
||||
// location.reload() was called on a window that is handling a
|
||||
|
@ -901,7 +904,7 @@ nsLocation::GetSourceBaseURL(JSContext* cx, nsIURI** sourceURL)
|
|||
// the docshell. If that fails, just return null and hope that the caller passed
|
||||
// an absolute URI.
|
||||
if (!sgo && GetDocShell()) {
|
||||
sgo = do_GetInterface(GetDocShell());
|
||||
sgo = GetDocShell()->GetScriptGlobalObject();
|
||||
}
|
||||
NS_ENSURE_TRUE(sgo, NS_OK);
|
||||
nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(sgo);
|
||||
|
|
|
@ -270,7 +270,7 @@ nsPluginArray::Observe(nsISupports *aSubject, const char *aTopic,
|
|||
bool
|
||||
nsPluginArray::AllowPlugins() const
|
||||
{
|
||||
nsCOMPtr<nsIDocShell> docShell = do_GetInterface(mWindow);
|
||||
nsCOMPtr<nsIDocShell> docShell = mWindow ? mWindow->GetDocShell() : nullptr;
|
||||
|
||||
return docShell && docShell->PluginsAllowedInCurrentDoc();
|
||||
}
|
||||
|
|
|
@ -16,11 +16,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=931768
|
|||
openDialog("chrome://browser/content/browser.xul");
|
||||
ok(false, "Calling openDialog from unprivileged script should throw.");
|
||||
} catch (e) {
|
||||
// FIXME e should be a ReferenceError once we switch Window to new WebIDL bindings
|
||||
ok(e.name == "SecurityError",
|
||||
"openDialog shouldn't be callable to unprivileged script.");
|
||||
todo(e instanceof ReferenceError,
|
||||
"openDialog shouldn't be available to unprivileged script.");
|
||||
ok(e instanceof ReferenceError,
|
||||
"openDialog shouldn't be available to unprivileged script.");
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
@ -214,7 +214,6 @@ DOMInterfaces = {
|
|||
|
||||
'ChromeWindow': {
|
||||
'concrete': False,
|
||||
'register': False,
|
||||
},
|
||||
|
||||
'ChromeWorker': {
|
||||
|
@ -1565,10 +1564,7 @@ DOMInterfaces = {
|
|||
|
||||
'Window': {
|
||||
'nativeType': 'nsGlobalWindow',
|
||||
# When turning on Window, remember to drop the "'register': False"
|
||||
# from ChromeWindow.
|
||||
'hasXPConnectImpls': True,
|
||||
'register': False,
|
||||
'binaryNames': {
|
||||
'postMessage': 'postMessageMoz',
|
||||
},
|
||||
|
|
|
@ -107,7 +107,7 @@ BluetoothManager::BluetoothManager(nsPIDOMWindow *aWindow)
|
|||
MOZ_ASSERT(aWindow);
|
||||
MOZ_ASSERT(IsDOMBinding());
|
||||
|
||||
mPath.AssignLiteral("/");
|
||||
mPath.Assign('/');
|
||||
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
NS_ENSURE_TRUE_VOID(bs);
|
||||
|
|
|
@ -811,7 +811,7 @@ BluetoothHfpManager::ReceiveSocketData(BluetoothSocket* aSocket,
|
|||
message.AppendInt(mNetworkSelectionMode);
|
||||
message.AppendLiteral(",0,\"");
|
||||
message.Append(NS_ConvertUTF16toUTF8(mOperatorName));
|
||||
message.AppendLiteral("\"");
|
||||
message.Append('"');
|
||||
SendLine(message.get());
|
||||
} else if (msg.Find("AT+VTS=") != -1) {
|
||||
ParseAtCommand(msg, 7, atCommandValues);
|
||||
|
@ -1529,7 +1529,7 @@ BluetoothHfpManager::HandleCallStateChanged(uint32_t aCallIndex,
|
|||
|
||||
nsAutoString number(aNumber);
|
||||
if (!mCLIP) {
|
||||
number.AssignLiteral("");
|
||||
number.Truncate();
|
||||
}
|
||||
|
||||
MessageLoop::current()->PostDelayedTask(
|
||||
|
|
|
@ -107,7 +107,7 @@ BluetoothManager::BluetoothManager(nsPIDOMWindow *aWindow)
|
|||
MOZ_ASSERT(aWindow);
|
||||
MOZ_ASSERT(IsDOMBinding());
|
||||
|
||||
mPath.AssignLiteral("/");
|
||||
mPath.Assign('/');
|
||||
|
||||
BluetoothService* bs = BluetoothService::Get();
|
||||
NS_ENSURE_TRUE_VOID(bs);
|
||||
|
|
|
@ -716,7 +716,7 @@ BluetoothOppManager::RetrieveSentFileName()
|
|||
EmptyCString(),
|
||||
extension);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mFileName.AppendLiteral(".");
|
||||
mFileName.Append('.');
|
||||
AppendUTF8toUTF16(extension, mFileName);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -811,7 +811,7 @@ BluetoothHfpManager::ReceiveSocketData(BluetoothSocket* aSocket,
|
|||
message.AppendInt(mNetworkSelectionMode);
|
||||
message.AppendLiteral(",0,\"");
|
||||
message.Append(NS_ConvertUTF16toUTF8(mOperatorName));
|
||||
message.AppendLiteral("\"");
|
||||
message.Append('"');
|
||||
SendLine(message.get());
|
||||
} else if (msg.Find("AT+VTS=") != -1) {
|
||||
ParseAtCommand(msg, 7, atCommandValues);
|
||||
|
@ -1211,9 +1211,9 @@ BluetoothHfpManager::SendCLCC(const Call& aCall, int aIndex)
|
|||
|
||||
nsAutoCString message(RESPONSE_CLCC);
|
||||
message.AppendInt(aIndex);
|
||||
message.AppendLiteral(",");
|
||||
message.Append(',');
|
||||
message.AppendInt(aCall.mDirection);
|
||||
message.AppendLiteral(",");
|
||||
message.Append(',');
|
||||
|
||||
int status = 0;
|
||||
switch (aCall.mState) {
|
||||
|
@ -1290,7 +1290,7 @@ BluetoothHfpManager::SendCommand(const char* aCommand, uint32_t aValue)
|
|||
}
|
||||
|
||||
message.AppendInt(aValue);
|
||||
message.AppendLiteral(",");
|
||||
message.Append(',');
|
||||
message.AppendInt(sCINDItems[aValue].value);
|
||||
} else if (!strcmp(aCommand, RESPONSE_CIND)) {
|
||||
if (!aValue) {
|
||||
|
@ -1300,9 +1300,9 @@ BluetoothHfpManager::SendCommand(const char* aCommand, uint32_t aValue)
|
|||
message.Append(sCINDItems[i].name);
|
||||
message.AppendLiteral("\",(");
|
||||
message.Append(sCINDItems[i].range);
|
||||
message.AppendLiteral(")");
|
||||
message.Append(')');
|
||||
if (i == (ArrayLength(sCINDItems) - 1)) {
|
||||
message.AppendLiteral(")");
|
||||
message.Append(')');
|
||||
break;
|
||||
}
|
||||
message.AppendLiteral("),");
|
||||
|
@ -1314,7 +1314,7 @@ BluetoothHfpManager::SendCommand(const char* aCommand, uint32_t aValue)
|
|||
if (i == (ArrayLength(sCINDItems) - 1)) {
|
||||
break;
|
||||
}
|
||||
message.AppendLiteral(",");
|
||||
message.Append(',');
|
||||
}
|
||||
}
|
||||
#ifdef MOZ_B2G_RIL
|
||||
|
@ -1529,7 +1529,7 @@ BluetoothHfpManager::HandleCallStateChanged(uint32_t aCallIndex,
|
|||
|
||||
nsAutoString number(aNumber);
|
||||
if (!mCLIP) {
|
||||
number.AssignLiteral("");
|
||||
number.Truncate();
|
||||
}
|
||||
|
||||
MessageLoop::current()->PostDelayedTask(
|
||||
|
|
|
@ -738,7 +738,7 @@ BluetoothOppManager::RetrieveSentFileName()
|
|||
EmptyCString(),
|
||||
extension);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mFileName.AppendLiteral(".");
|
||||
mFileName.Append('.');
|
||||
AppendUTF8toUTF16(extension, mFileName);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -283,7 +283,7 @@ BrowserElementParent::OpenWindowInProcess(nsIDOMWindow* aOpenerWindow,
|
|||
frameLoader->GetDocShell(getter_AddRefs(docshell));
|
||||
NS_ENSURE_TRUE(docshell, BrowserElementParent::OPEN_WINDOW_IGNORED);
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> window = do_GetInterface(docshell);
|
||||
nsCOMPtr<nsIDOMWindow> window = docshell->GetWindow();
|
||||
window.forget(aReturnWindow);
|
||||
|
||||
return !!*aReturnWindow ? opened : BrowserElementParent::OPEN_WINDOW_CANCELLED;
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче