Merge mozilla-central to autoland

This commit is contained in:
arthur.iakab 2018-03-14 12:16:00 +02:00
Родитель d23a5323b4 8976abf9ca
Коммит 6153368440
299 изменённых файлов: 55867 добавлений и 46367 удалений

15
Cargo.lock сгенерированный
Просмотреть файл

@ -738,6 +738,7 @@ dependencies = [
"nserror 0.1.0", "nserror 0.1.0",
"nsstring 0.1.0", "nsstring 0.1.0",
"prefs_parser 0.0.1", "prefs_parser 0.0.1",
"rsdparsa_capi 0.1.0",
"rust_url_capi 0.0.1", "rust_url_capi 0.0.1",
"syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)",
"u2fhid 0.1.0", "u2fhid 0.1.0",
@ -1449,6 +1450,20 @@ dependencies = [
"serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "rsdparsa"
version = "0.1.0"
[[package]]
name = "rsdparsa_capi"
version = "0.1.0"
dependencies = [
"libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
"nserror 0.1.0",
"rsdparsa 0.1.0",
]
[[package]] [[package]]
name = "runloop" name = "runloop"
version = "0.1.0" version = "0.1.0"

Просмотреть файл

@ -725,7 +725,7 @@ static const nsRoleMapEntry sWAIRoleMaps[] =
states::LINKED states::LINKED
}, },
{ // list { // list
&nsGkAtoms::list, &nsGkAtoms::list_,
roles::LIST, roles::LIST,
kUseMapRole, kUseMapRole,
eNoValue, eNoValue,
@ -1064,7 +1064,7 @@ static const nsRoleMapEntry sWAIRoleMaps[] =
kNoReqStates kNoReqStates
}, },
{ // switch { // switch
&nsGkAtoms::_switch, &nsGkAtoms::svgSwitch,
roles::SWITCH, roles::SWITCH,
kUseMapRole, kUseMapRole,
eNoValue, eNoValue,

Просмотреть файл

@ -90,7 +90,7 @@ aria::MapToState(EStateRule aRule, dom::Element* aElement, uint64_t* aState)
static const EnumTypeData data = { static const EnumTypeData data = {
nsGkAtoms::aria_autocomplete, nsGkAtoms::aria_autocomplete,
{ &nsGkAtoms::inlinevalue, { &nsGkAtoms::inlinevalue,
&nsGkAtoms::list, &nsGkAtoms::list_,
&nsGkAtoms::both, nullptr }, &nsGkAtoms::both, nullptr },
{ states::SUPPORTS_AUTOCOMPLETION, { states::SUPPORTS_AUTOCOMPLETION,
states::HASPOPUP | states::SUPPORTS_AUTOCOMPLETION, states::HASPOPUP | states::SUPPORTS_AUTOCOMPLETION,

Просмотреть файл

@ -33,11 +33,11 @@ filters::GetSelectable(Accessible* aAccessible)
uint32_t uint32_t
filters::GetRow(Accessible* aAccessible) filters::GetRow(Accessible* aAccessible)
{ {
a11y::role role = aAccessible->Role(); if (aAccessible->IsTableRow())
if (role == roles::ROW)
return eMatch | eSkipSubtree; return eMatch | eSkipSubtree;
// Look for rows inside rowgroup. // Look for rows inside rowgroup.
a11y::role role = aAccessible->Role();
if (role == roles::GROUPING) if (role == roles::GROUPING)
return eSkip; return eSkip;

Просмотреть файл

@ -406,7 +406,7 @@ HTMLTextFieldAccessible::NativeState()
} }
// Expose autocomplete state if it has associated autocomplete list. // Expose autocomplete state if it has associated autocomplete list.
if (mContent->AsElement()->HasAttr(kNameSpaceID_None, nsGkAtoms::list)) if (mContent->AsElement()->HasAttr(kNameSpaceID_None, nsGkAtoms::list_))
return state | states::SUPPORTS_AUTOCOMPLETION | states::HASPOPUP; return state | states::SUPPORTS_AUTOCOMPLETION | states::HASPOPUP;
// Ordinal XUL textboxes don't support autocomplete. // Ordinal XUL textboxes don't support autocomplete.

Просмотреть файл

@ -67,6 +67,7 @@ skip-if = (os == 'win' && ccov) # Bug 1423667
subsuite = clipboard subsuite = clipboard
[browser_drag_bookmarks_on_toolbar.js] [browser_drag_bookmarks_on_toolbar.js]
[browser_enable_toolbar_sidebar.js] [browser_enable_toolbar_sidebar.js]
skip-if = (os == 'win' && ccov) # Bug 1423667
[browser_forgetthissite_single.js] [browser_forgetthissite_single.js]
[browser_history_sidebar_search.js] [browser_history_sidebar_search.js]
[browser_library_batch_delete.js] [browser_library_batch_delete.js]
@ -88,6 +89,8 @@ skip-if = (os == 'win' && ccov) # Bug 1423667
[browser_library_open_leak.js] [browser_library_open_leak.js]
[browser_library_openFlatContainer.js] [browser_library_openFlatContainer.js]
skip-if = (os == 'win' && ccov) # Bug 1423667 skip-if = (os == 'win' && ccov) # Bug 1423667
[browser_library_open_bookmark.js]
skip-if = (os == 'win' && ccov) # Bug 1423667
[browser_library_panel_leak.js] [browser_library_panel_leak.js]
skip-if = (os == 'win' && ccov) # Bug 1423667 skip-if = (os == 'win' && ccov) # Bug 1423667
[browser_library_search.js] [browser_library_search.js]

Просмотреть файл

@ -0,0 +1,38 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
/**
* Test that the a bookmark can be opened from the Library by mouse double click.
*/
"use strict";
const TEST_URL = "about:buildconfig";
add_task(async function test_open_bookmark_from_library() {
let bm = await PlacesUtils.bookmarks.insert({
parentGuid: PlacesUtils.bookmarks.unfiledGuid,
url: TEST_URL,
title: TEST_URL,
});
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:blank");
let gLibrary = await promiseLibrary("UnfiledBookmarks");
registerCleanupFunction(async function() {
await promiseLibraryClosed(gLibrary);
await PlacesUtils.bookmarks.eraseEverything();
await BrowserTestUtils.removeTab(tab);
});
let bmLibrary = gLibrary.ContentTree.view.view.nodeForTreeIndex(0);
Assert.equal(bmLibrary.title, bm.title, "Found bookmark in the right pane");
gLibrary.ContentTree.view.selectNode(bmLibrary);
synthesizeClickOnSelectedTreeCell(gLibrary.ContentTree.view,
{ clickCount: 2 });
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser, false, TEST_URL);
Assert.ok(true, "Expected tab was loaded");
});

Просмотреть файл

@ -216,10 +216,8 @@ var gPermissionManager = {
this._type = aParams.permissionType; this._type = aParams.permissionType;
this._manageCapability = aParams.manageCapability; this._manageCapability = aParams.manageCapability;
var permissionsText = document.getElementById("permissionsText"); let permissionsText = document.getElementById("permissionsText");
while (permissionsText.hasChildNodes()) permissionsText.textContent = aParams.introText;
permissionsText.firstChild.remove();
permissionsText.appendChild(document.createTextNode(aParams.introText));
document.title = aParams.windowTitle; document.title = aParams.windowTitle;

Просмотреть файл

@ -1,13 +1,12 @@
This is the debugger.html project output. This is the debugger.html project output.
See https://github.com/devtools-html/debugger.html See https://github.com/devtools-html/debugger.html
Version 19.2 Version 20.0
Comparison: https://github.com/devtools-html/debugger.html/compare/release-19-2...release-20
Comparison: https://github.com/devtools-html/debugger.html/compare/release-19-1...release-19-2
Packages: Packages:
- babel-plugin-transform-es2015-modules-commonjs @6.26.0 - babel-plugin-transform-es2015-modules-commonjs @6.26.0
- babel-preset-react @6.24.1 - babel-preset-react @6.24.1
- react @16.2.0 - react @15.6.2
- react-dom @16.2.0 - react-dom @15.6.2
- webpack @3.11.0 - webpack @3.10.0

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -162,15 +162,15 @@ add_task(async function() {
// The call-based ones work, but the single-identifier ones do not. // The call-based ones work, but the single-identifier ones do not.
await breakpointScopes(dbg, "imported-bindings", { line: 17, column: 2 }, [ await breakpointScopes(dbg, "imported-bindings", { line: 17, column: 2 }, [
"Module", "Module",
["aDefault", "(unmapped)"], ["aDefault", '"a-default"'],
["aDefault2", '"a-default2"'], ["aDefault2", '"a-default2"'],
["aDefault3", "(unmapped)"], ["aDefault3", '"a-default3"'],
["anAliased", "(unmapped)"], ["anAliased", '"an-original"'],
["anAliased2", '"an-original2"'], ["anAliased2", '"an-original2"'],
["anAliased3", "(unmapped)"], ["anAliased3", '"an-original3"'],
["aNamed", "(unmapped)"], ["aNamed", '"a-named"'],
["aNamed2", '"a-named2"'], ["aNamed2", '"a-named2"'],
["aNamed3", "(unmapped)"], ["aNamed3", '"a-named3"'],
["aNamespace", "{\u2026}"], ["aNamespace", "{\u2026}"],
["aNamespace2", "{\u2026}"], ["aNamespace2", "{\u2026}"],
["aNamespace3", "{\u2026}"], ["aNamespace3", "{\u2026}"],

Просмотреть файл

@ -1,56 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const Services = require("Services");
const { createFactory, PureComponent } = require("devtools/client/shared/vendor/react");
const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
const { connect } = require("devtools/client/shared/vendor/react-redux");
const { LocalizationHelper } = require("devtools/shared/l10n");
const Accordion =
createFactory(require("devtools/client/inspector/layout/components/Accordion"));
const BoxModel = createFactory(require("./BoxModel"));
const Types = require("../types");
const BOXMODEL_STRINGS_URI = "devtools/client/locales/boxmodel.properties";
const BOXMODEL_L10N = new LocalizationHelper(BOXMODEL_STRINGS_URI);
const BOXMODEL_OPENED_PREF = "devtools.computed.boxmodel.opened";
class BoxModelApp extends PureComponent {
static get propTypes() {
return {
boxModel: PropTypes.shape(Types.boxModel).isRequired,
setSelectedNode: PropTypes.func.isRequired,
showBoxModelProperties: PropTypes.bool.isRequired,
onHideBoxModelHighlighter: PropTypes.func.isRequired,
onShowBoxModelEditor: PropTypes.func.isRequired,
onShowBoxModelHighlighter: PropTypes.func.isRequired,
onShowBoxModelHighlighterForNode: PropTypes.func.isRequired,
onToggleGeometryEditor: PropTypes.func.isRequired,
};
}
render() {
return Accordion({
items: [
{
header: BOXMODEL_L10N.getStr("boxmodel.title"),
component: BoxModel,
componentProps: this.props,
opened: Services.prefs.getBoolPref(BOXMODEL_OPENED_PREF),
onToggled: () => {
let opened = Services.prefs.getBoolPref(BOXMODEL_OPENED_PREF);
Services.prefs.setBoolPref(BOXMODEL_OPENED_PREF, !opened);
}
}
]
});
}
}
module.exports = connect(state => state)(BoxModelApp);

Просмотреть файл

@ -6,7 +6,6 @@
DevToolsModules( DevToolsModules(
'BoxModel.js', 'BoxModel.js',
'BoxModelApp.js',
'BoxModelEditable.js', 'BoxModelEditable.js',
'BoxModelInfo.js', 'BoxModelInfo.js',
'BoxModelMain.js', 'BoxModelMain.js',

Просмотреть файл

@ -13,7 +13,6 @@ support-files =
!/devtools/client/shared/test/test-actor-registry.js !/devtools/client/shared/test/test-actor-registry.js
[browser_boxmodel.js] [browser_boxmodel.js]
[browser_boxmodel_computed-accordion-state.js]
[browser_boxmodel_edit-position-visible-position-change.js] [browser_boxmodel_edit-position-visible-position-change.js]
[browser_boxmodel_editablemodel.js] [browser_boxmodel_editablemodel.js]
[browser_boxmodel_editablemodel_allproperties.js] [browser_boxmodel_editablemodel_allproperties.js]

Просмотреть файл

@ -157,27 +157,27 @@ add_task(function* () {
let html = "<style>" + style + "</style><div></div>"; let html = "<style>" + style + "</style><div></div>";
yield addTab("data:text/html," + encodeURIComponent(html)); yield addTab("data:text/html," + encodeURIComponent(html));
let {inspector, view, testActor} = yield openBoxModelView(); let {inspector, boxmodel, testActor} = yield openLayoutView();
yield selectNode("div", inspector); yield selectNode("div", inspector);
yield testInitialValues(inspector, view); yield testInitialValues(inspector, boxmodel);
yield testChangingValues(inspector, view, testActor); yield testChangingValues(inspector, boxmodel, testActor);
}); });
function* testInitialValues(inspector, view) { function* testInitialValues(inspector, boxmodel) {
info("Test that the initial values of the box model are correct"); info("Test that the initial values of the box model are correct");
let viewdoc = view.document; let doc = boxmodel.document;
for (let i = 0; i < res1.length; i++) { for (let i = 0; i < res1.length; i++) {
let elt = viewdoc.querySelector(res1[i].selector); let elt = doc.querySelector(res1[i].selector);
is(elt.textContent, res1[i].value, is(elt.textContent, res1[i].value,
res1[i].selector + " has the right value."); res1[i].selector + " has the right value.");
} }
} }
function* testChangingValues(inspector, view, testActor) { function* testChangingValues(inspector, boxmodel, testActor) {
info("Test that changing the document updates the box model"); info("Test that changing the document updates the box model");
let viewdoc = view.document; let doc = boxmodel.document;
let onUpdated = waitForUpdate(inspector); let onUpdated = waitForUpdate(inspector);
yield testActor.setAttribute("div", "style", yield testActor.setAttribute("div", "style",
@ -185,7 +185,7 @@ function* testChangingValues(inspector, view, testActor) {
yield onUpdated; yield onUpdated;
for (let i = 0; i < res2.length; i++) { for (let i = 0; i < res2.length; i++) {
let elt = viewdoc.querySelector(res2[i].selector); let elt = doc.querySelector(res2[i].selector);
is(elt.textContent, res2[i].value, is(elt.textContent, res2[i].value,
res2[i].selector + " has the right value after style update."); res2[i].selector + " has the right value after style update.");
} }

Просмотреть файл

@ -1,89 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Tests that the box model's accordion state is persistent through hide/show in the
// computed view.
// There are shutdown issues for which multiple rejections are left uncaught.
// See bug 1018184 for resolving these issues.
const { PromiseTestUtils } = scopedCuImport("resource://testing-common/PromiseTestUtils.jsm");
PromiseTestUtils.whitelistRejectionsGlobally(/Connection closed/);
const TEST_URI = `
<style>
#div1 {
margin: 10px;
padding: 3px;
}
</style>
<div id="div1"></div>
`;
const BOXMODEL_OPENED_PREF = "devtools.computed.boxmodel.opened";
add_task(function* () {
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
let { inspector, view, toolbox } = yield openBoxModelView();
let { document: doc } = view;
yield testAccordionStateAfterClickingHeader(doc);
yield testAccordionStateAfterSwitchingSidebars(inspector, doc);
yield testAccordionStateAfterReopeningComputedView(toolbox);
Services.prefs.clearUserPref(BOXMODEL_OPENED_PREF);
});
function* testAccordionStateAfterClickingHeader(doc) {
let header = doc.querySelector("#computed-container .box-model-pane ._header");
let bContent = doc.querySelector("#computed-container .box-model-pane ._content");
info("Checking initial state of the box model panel.");
is(bContent.style.display, "block", "The box model panel content is 'display: block'.");
ok(Services.prefs.getBoolPref(BOXMODEL_OPENED_PREF),
`${BOXMODEL_OPENED_PREF} is pref on by default.`);
info("Clicking the box model header to hide the box model panel.");
header.click();
info("Checking the new state of the box model panel.");
is(bContent.style.display, "none", "The box model panel content is 'display: none'.");
ok(!Services.prefs.getBoolPref(BOXMODEL_OPENED_PREF),
`${BOXMODEL_OPENED_PREF} is pref off.`);
}
function* testAccordionStateAfterSwitchingSidebars(inspector, doc) {
info("Checking the box model accordion state is persistent after switching sidebars.");
let bContent = doc.querySelector("#computed-container .box-model-pane ._content");
info("Selecting the layout view.");
inspector.sidebar.select("layoutview");
info("Selecting the computed view.");
inspector.sidebar.select("computedview");
info("Checking the state of the box model panel.");
is(bContent.style.display, "none", "The box model panel content is 'display: none'.");
ok(!Services.prefs.getBoolPref(BOXMODEL_OPENED_PREF),
`${BOXMODEL_OPENED_PREF} is pref off.`);
}
function* testAccordionStateAfterReopeningComputedView(toolbox) {
info("Checking the box model accordion state is persistent after closing and "
+ "re-opening the layout view.");
info("Closing the toolbox.");
yield toolbox.destroy();
info("Re-opening the layout view.");
let { view } = yield openBoxModelView();
let { document: doc } = view;
let bContent = doc.querySelector("#computed-container .box-model-pane ._content");
info("Checking the state of the box model panel.");
ok(!bContent, "The box model panel content is not rendered.");
ok(!Services.prefs.getBoolPref(BOXMODEL_OPENED_PREF),
`${BOXMODEL_OPENED_PREF} is pref off.`);
}

Просмотреть файл

@ -18,26 +18,27 @@ const TEST_URI = `
add_task(function* () { add_task(function* () {
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
let {inspector, view} = yield openBoxModelView(); let {inspector, boxmodel} = yield openLayoutView();
yield selectNode("#mydiv", inspector); yield selectNode("#mydiv", inspector);
let editPositionButton = view.document.querySelector(".layout-geometry-editor"); let editPositionButton = boxmodel.document.querySelector(".layout-geometry-editor");
ok(isNodeVisible(editPositionButton), "Edit Position button is visible initially"); ok(isNodeVisible(editPositionButton), "Edit Position button is visible initially");
let positionLeftTextbox = view.document.querySelector( let positionLeftTextbox = boxmodel.document.querySelector(
".boxmodel-editable[title=position-left]" ".boxmodel-editable[title=position-left]"
); );
ok(isNodeVisible(positionLeftTextbox), "Position-left edit box exists"); ok(isNodeVisible(positionLeftTextbox), "Position-left edit box exists");
info("Change the value of position-left and submit"); info("Change the value of position-left and submit");
let onUpdate = waitForUpdate(inspector); let onUpdate = waitForUpdate(inspector);
EventUtils.synthesizeMouseAtCenter(positionLeftTextbox, {}, view.document.defaultView); EventUtils.synthesizeMouseAtCenter(positionLeftTextbox, {},
EventUtils.synthesizeKey("8", {}, view.document.defaultView); boxmodel.document.defaultView);
EventUtils.synthesizeKey("VK_RETURN", {}, view.document.defaultView); EventUtils.synthesizeKey("8", {}, boxmodel.document.defaultView);
EventUtils.synthesizeKey("VK_RETURN", {}, boxmodel.document.defaultView);
yield onUpdate; yield onUpdate;
editPositionButton = view.document.querySelector(".layout-geometry-editor"); editPositionButton = boxmodel.document.querySelector(".layout-geometry-editor");
ok(isNodeVisible(editPositionButton), ok(isNodeVisible(editPositionButton),
"Edit Position button is still visible after layout change"); "Edit Position button is still visible after layout change");
}); });

Просмотреть файл

@ -18,17 +18,21 @@ const TEST_URI = "<style>" +
"<div id='div3'></div><div id='div4'></div>"; "<div id='div3'></div><div id='div4'></div>";
add_task(function* () { add_task(function* () {
yield addTab("data:text/html," + encodeURIComponent(TEST_URI)); // Make sure the toolbox is tall enough to have empty space below the
let {inspector, view, testActor} = yield openBoxModelView(); // boxmodel-container.
yield pushPref("devtools.toolbox.footer.height", 500);
yield testEditingMargins(inspector, view, testActor); yield addTab("data:text/html," + encodeURIComponent(TEST_URI));
yield testKeyBindings(inspector, view, testActor); let {inspector, boxmodel, testActor} = yield openLayoutView();
yield testEscapeToUndo(inspector, view, testActor);
yield testDeletingValue(inspector, view, testActor); yield testEditingMargins(inspector, boxmodel, testActor);
yield testRefocusingOnClick(inspector, view, testActor); yield testKeyBindings(inspector, boxmodel, testActor);
yield testEscapeToUndo(inspector, boxmodel, testActor);
yield testDeletingValue(inspector, boxmodel, testActor);
yield testRefocusingOnClick(inspector, boxmodel, testActor);
}); });
function* testEditingMargins(inspector, view, testActor) { function* testEditingMargins(inspector, boxmodel, testActor) {
info("Test that editing margin dynamically updates the document, pressing " + info("Test that editing margin dynamically updates the document, pressing " +
"escape cancels the changes"); "escape cancels the changes");
@ -36,21 +40,21 @@ function* testEditingMargins(inspector, view, testActor) {
"Should be no margin-top on the element."); "Should be no margin-top on the element.");
yield selectNode("#div1", inspector); yield selectNode("#div1", inspector);
let span = view.document.querySelector(".boxmodel-margin.boxmodel-top > span"); let span = boxmodel.document.querySelector(".boxmodel-margin.boxmodel-top > span");
is(span.textContent, 5, "Should have the right value in the box model."); is(span.textContent, 5, "Should have the right value in the box model.");
EventUtils.synthesizeMouseAtCenter(span, {}, view.document.defaultView); EventUtils.synthesizeMouseAtCenter(span, {}, boxmodel.document.defaultView);
let editor = view.document.querySelector(".styleinspector-propertyeditor"); let editor = boxmodel.document.querySelector(".styleinspector-propertyeditor");
ok(editor, "Should have opened the editor."); ok(editor, "Should have opened the editor.");
is(editor.value, "5px", "Should have the right value in the editor."); is(editor.value, "5px", "Should have the right value in the editor.");
EventUtils.synthesizeKey("3", {}, view.document.defaultView); EventUtils.synthesizeKey("3", {}, boxmodel.document.defaultView);
yield waitForUpdate(inspector); yield waitForUpdate(inspector);
is((yield getStyle(testActor, "#div1", "margin-top")), "3px", is((yield getStyle(testActor, "#div1", "margin-top")), "3px",
"Should have updated the margin."); "Should have updated the margin.");
EventUtils.synthesizeKey("VK_ESCAPE", {}, view.document.defaultView); EventUtils.synthesizeKey("VK_ESCAPE", {}, boxmodel.document.defaultView);
yield waitForUpdate(inspector); yield waitForUpdate(inspector);
is((yield getStyle(testActor, "#div1", "margin-top")), "", is((yield getStyle(testActor, "#div1", "margin-top")), "",
@ -58,7 +62,7 @@ function* testEditingMargins(inspector, view, testActor) {
is(span.textContent, 5, "Should have the right value in the box model."); is(span.textContent, 5, "Should have the right value in the box model.");
} }
function* testKeyBindings(inspector, view, testActor) { function* testKeyBindings(inspector, boxmodel, testActor) {
info("Test that arrow keys work correctly and pressing enter commits the " + info("Test that arrow keys work correctly and pressing enter commits the " +
"changes"); "changes");
@ -66,42 +70,42 @@ function* testKeyBindings(inspector, view, testActor) {
"Should be no margin-top on the element."); "Should be no margin-top on the element.");
yield selectNode("#div1", inspector); yield selectNode("#div1", inspector);
let span = view.document.querySelector(".boxmodel-margin.boxmodel-left > span"); let span = boxmodel.document.querySelector(".boxmodel-margin.boxmodel-left > span");
is(span.textContent, 10, "Should have the right value in the box model."); is(span.textContent, 10, "Should have the right value in the box model.");
EventUtils.synthesizeMouseAtCenter(span, {}, view.document.defaultView); EventUtils.synthesizeMouseAtCenter(span, {}, boxmodel.document.defaultView);
let editor = view.document.querySelector(".styleinspector-propertyeditor"); let editor = boxmodel.document.querySelector(".styleinspector-propertyeditor");
ok(editor, "Should have opened the editor."); ok(editor, "Should have opened the editor.");
is(editor.value, "10px", "Should have the right value in the editor."); is(editor.value, "10px", "Should have the right value in the editor.");
EventUtils.synthesizeKey("VK_UP", {}, view.document.defaultView); EventUtils.synthesizeKey("VK_UP", {}, boxmodel.document.defaultView);
yield waitForUpdate(inspector); yield waitForUpdate(inspector);
is(editor.value, "11px", "Should have the right value in the editor."); is(editor.value, "11px", "Should have the right value in the editor.");
is((yield getStyle(testActor, "#div1", "margin-left")), "11px", is((yield getStyle(testActor, "#div1", "margin-left")), "11px",
"Should have updated the margin."); "Should have updated the margin.");
EventUtils.synthesizeKey("VK_DOWN", {}, view.document.defaultView); EventUtils.synthesizeKey("VK_DOWN", {}, boxmodel.document.defaultView);
yield waitForUpdate(inspector); yield waitForUpdate(inspector);
is(editor.value, "10px", "Should have the right value in the editor."); is(editor.value, "10px", "Should have the right value in the editor.");
is((yield getStyle(testActor, "#div1", "margin-left")), "10px", is((yield getStyle(testActor, "#div1", "margin-left")), "10px",
"Should have updated the margin."); "Should have updated the margin.");
EventUtils.synthesizeKey("VK_UP", { shiftKey: true }, view.document.defaultView); EventUtils.synthesizeKey("VK_UP", { shiftKey: true }, boxmodel.document.defaultView);
yield waitForUpdate(inspector); yield waitForUpdate(inspector);
is(editor.value, "20px", "Should have the right value in the editor."); is(editor.value, "20px", "Should have the right value in the editor.");
is((yield getStyle(testActor, "#div1", "margin-left")), "20px", is((yield getStyle(testActor, "#div1", "margin-left")), "20px",
"Should have updated the margin."); "Should have updated the margin.");
EventUtils.synthesizeKey("VK_RETURN", {}, view.document.defaultView); EventUtils.synthesizeKey("VK_RETURN", {}, boxmodel.document.defaultView);
is((yield getStyle(testActor, "#div1", "margin-left")), "20px", is((yield getStyle(testActor, "#div1", "margin-left")), "20px",
"Should be the right margin-top on the element."); "Should be the right margin-top on the element.");
is(span.textContent, 20, "Should have the right value in the box model."); is(span.textContent, 20, "Should have the right value in the box model.");
} }
function* testEscapeToUndo(inspector, view, testActor) { function* testEscapeToUndo(inspector, boxmodel, testActor) {
info("Test that deleting the value removes the property but escape undoes " + info("Test that deleting the value removes the property but escape undoes " +
"that"); "that");
@ -109,22 +113,22 @@ function* testEscapeToUndo(inspector, view, testActor) {
"Should be the right margin-top on the element."); "Should be the right margin-top on the element.");
yield selectNode("#div1", inspector); yield selectNode("#div1", inspector);
let span = view.document.querySelector(".boxmodel-margin.boxmodel-left > span"); let span = boxmodel.document.querySelector(".boxmodel-margin.boxmodel-left > span");
is(span.textContent, 20, "Should have the right value in the box model."); is(span.textContent, 20, "Should have the right value in the box model.");
EventUtils.synthesizeMouseAtCenter(span, {}, view.document.defaultView); EventUtils.synthesizeMouseAtCenter(span, {}, boxmodel.document.defaultView);
let editor = view.document.querySelector(".styleinspector-propertyeditor"); let editor = boxmodel.document.querySelector(".styleinspector-propertyeditor");
ok(editor, "Should have opened the editor."); ok(editor, "Should have opened the editor.");
is(editor.value, "20px", "Should have the right value in the editor."); is(editor.value, "20px", "Should have the right value in the editor.");
EventUtils.synthesizeKey("VK_DELETE", {}, view.document.defaultView); EventUtils.synthesizeKey("VK_DELETE", {}, boxmodel.document.defaultView);
yield waitForUpdate(inspector); yield waitForUpdate(inspector);
is(editor.value, "", "Should have the right value in the editor."); is(editor.value, "", "Should have the right value in the editor.");
is((yield getStyle(testActor, "#div1", "margin-left")), "", is((yield getStyle(testActor, "#div1", "margin-left")), "",
"Should have updated the margin."); "Should have updated the margin.");
EventUtils.synthesizeKey("VK_ESCAPE", {}, view.document.defaultView); EventUtils.synthesizeKey("VK_ESCAPE", {}, boxmodel.document.defaultView);
yield waitForUpdate(inspector); yield waitForUpdate(inspector);
is((yield getStyle(testActor, "#div1", "margin-left")), "20px", is((yield getStyle(testActor, "#div1", "margin-left")), "20px",
@ -132,7 +136,7 @@ function* testEscapeToUndo(inspector, view, testActor) {
is(span.textContent, 20, "Should have the right value in the box model."); is(span.textContent, 20, "Should have the right value in the box model.");
} }
function* testDeletingValue(inspector, view, testActor) { function* testDeletingValue(inspector, boxmodel, testActor) {
info("Test that deleting the value removes the property"); info("Test that deleting the value removes the property");
yield setStyle(testActor, "#div1", "marginRight", "15px"); yield setStyle(testActor, "#div1", "marginRight", "15px");
@ -140,53 +144,53 @@ function* testDeletingValue(inspector, view, testActor) {
yield selectNode("#div1", inspector); yield selectNode("#div1", inspector);
let span = view.document.querySelector(".boxmodel-margin.boxmodel-right > span"); let span = boxmodel.document.querySelector(".boxmodel-margin.boxmodel-right > span");
is(span.textContent, 15, "Should have the right value in the box model."); is(span.textContent, 15, "Should have the right value in the box model.");
EventUtils.synthesizeMouseAtCenter(span, {}, view.document.defaultView); EventUtils.synthesizeMouseAtCenter(span, {}, boxmodel.document.defaultView);
let editor = view.document.querySelector(".styleinspector-propertyeditor"); let editor = boxmodel.document.querySelector(".styleinspector-propertyeditor");
ok(editor, "Should have opened the editor."); ok(editor, "Should have opened the editor.");
is(editor.value, "15px", "Should have the right value in the editor."); is(editor.value, "15px", "Should have the right value in the editor.");
EventUtils.synthesizeKey("VK_DELETE", {}, view.document.defaultView); EventUtils.synthesizeKey("VK_DELETE", {}, boxmodel.document.defaultView);
yield waitForUpdate(inspector); yield waitForUpdate(inspector);
is(editor.value, "", "Should have the right value in the editor."); is(editor.value, "", "Should have the right value in the editor.");
is((yield getStyle(testActor, "#div1", "margin-right")), "", is((yield getStyle(testActor, "#div1", "margin-right")), "",
"Should have updated the margin."); "Should have updated the margin.");
EventUtils.synthesizeKey("VK_RETURN", {}, view.document.defaultView); EventUtils.synthesizeKey("VK_RETURN", {}, boxmodel.document.defaultView);
is((yield getStyle(testActor, "#div1", "margin-right")), "", is((yield getStyle(testActor, "#div1", "margin-right")), "",
"Should be the right margin-top on the element."); "Should be the right margin-top on the element.");
is(span.textContent, 10, "Should have the right value in the box model."); is(span.textContent, 10, "Should have the right value in the box model.");
} }
function* testRefocusingOnClick(inspector, view, testActor) { function* testRefocusingOnClick(inspector, boxmodel, testActor) {
info("Test that clicking in the editor input does not remove focus"); info("Test that clicking in the editor input does not remove focus");
yield selectNode("#div4", inspector); yield selectNode("#div4", inspector);
let span = view.document.querySelector(".boxmodel-margin.boxmodel-top > span"); let span = boxmodel.document.querySelector(".boxmodel-margin.boxmodel-top > span");
is(span.textContent, 1, "Should have the right value in the box model."); is(span.textContent, 1, "Should have the right value in the box model.");
EventUtils.synthesizeMouseAtCenter(span, {}, view.document.defaultView); EventUtils.synthesizeMouseAtCenter(span, {}, boxmodel.document.defaultView);
let editor = view.document.querySelector(".styleinspector-propertyeditor"); let editor = boxmodel.document.querySelector(".styleinspector-propertyeditor");
ok(editor, "Should have opened the editor."); ok(editor, "Should have opened the editor.");
info("Click in the already opened editor input"); info("Click in the already opened editor input");
EventUtils.synthesizeMouseAtCenter(editor, {}, view.document.defaultView); EventUtils.synthesizeMouseAtCenter(editor, {}, boxmodel.document.defaultView);
is(editor, view.document.activeElement, is(editor, boxmodel.document.activeElement,
"Inplace editor input should still have focus."); "Inplace editor input should still have focus.");
info("Check the input can still be used as expected"); info("Check the input can still be used as expected");
EventUtils.synthesizeKey("VK_UP", {}, view.document.defaultView); EventUtils.synthesizeKey("VK_UP", {}, boxmodel.document.defaultView);
yield waitForUpdate(inspector); yield waitForUpdate(inspector);
is(editor.value, "2px", "Should have the right value in the editor."); is(editor.value, "2px", "Should have the right value in the editor.");
is((yield getStyle(testActor, "#div4", "margin-top")), "2px", is((yield getStyle(testActor, "#div4", "margin-top")), "2px",
"Should have updated the margin."); "Should have updated the margin.");
EventUtils.synthesizeKey("VK_RETURN", {}, view.document.defaultView); EventUtils.synthesizeKey("VK_RETURN", {}, boxmodel.document.defaultView);
is((yield getStyle(testActor, "#div4", "margin-top")), "2px", is((yield getStyle(testActor, "#div4", "margin-top")), "2px",
"Should be the right margin-top on the element."); "Should be the right margin-top on the element.");

Просмотреть файл

@ -16,15 +16,15 @@ const TEST_URI = "<style>" +
add_task(function* () { add_task(function* () {
yield addTab("data:text/html," + encodeURIComponent(TEST_URI)); yield addTab("data:text/html," + encodeURIComponent(TEST_URI));
let {inspector, view, testActor} = yield openBoxModelView(); let {inspector, boxmodel, testActor} = yield openLayoutView();
yield testEditing(inspector, view, testActor); yield testEditing(inspector, boxmodel, testActor);
yield testEditingAndCanceling(inspector, view, testActor); yield testEditingAndCanceling(inspector, boxmodel, testActor);
yield testDeleting(inspector, view, testActor); yield testDeleting(inspector, boxmodel, testActor);
yield testDeletingAndCanceling(inspector, view, testActor); yield testDeletingAndCanceling(inspector, boxmodel, testActor);
}); });
function* testEditing(inspector, view, testActor) { function* testEditing(inspector, boxmodel, testActor) {
info("When all properties are set on the node editing one should work"); info("When all properties are set on the node editing one should work");
yield setStyle(testActor, "#div1", "padding", "5px"); yield setStyle(testActor, "#div1", "padding", "5px");
@ -32,29 +32,29 @@ function* testEditing(inspector, view, testActor) {
yield selectNode("#div1", inspector); yield selectNode("#div1", inspector);
let span = view.document.querySelector(".boxmodel-padding.boxmodel-bottom > span"); let span = boxmodel.document.querySelector(".boxmodel-padding.boxmodel-bottom > span");
is(span.textContent, 5, "Should have the right value in the box model."); is(span.textContent, 5, "Should have the right value in the box model.");
EventUtils.synthesizeMouseAtCenter(span, {}, view.document.defaultView); EventUtils.synthesizeMouseAtCenter(span, {}, boxmodel.document.defaultView);
let editor = view.document.querySelector(".styleinspector-propertyeditor"); let editor = boxmodel.document.querySelector(".styleinspector-propertyeditor");
ok(editor, "Should have opened the editor."); ok(editor, "Should have opened the editor.");
is(editor.value, "5px", "Should have the right value in the editor."); is(editor.value, "5px", "Should have the right value in the editor.");
EventUtils.synthesizeKey("7", {}, view.document.defaultView); EventUtils.synthesizeKey("7", {}, boxmodel.document.defaultView);
yield waitForUpdate(inspector); yield waitForUpdate(inspector);
is(editor.value, "7", "Should have the right value in the editor."); is(editor.value, "7", "Should have the right value in the editor.");
is((yield getStyle(testActor, "#div1", "padding-bottom")), "7px", is((yield getStyle(testActor, "#div1", "padding-bottom")), "7px",
"Should have updated the padding"); "Should have updated the padding");
EventUtils.synthesizeKey("VK_RETURN", {}, view.document.defaultView); EventUtils.synthesizeKey("VK_RETURN", {}, boxmodel.document.defaultView);
is((yield getStyle(testActor, "#div1", "padding-bottom")), "7px", is((yield getStyle(testActor, "#div1", "padding-bottom")), "7px",
"Should be the right padding."); "Should be the right padding.");
is(span.textContent, 7, "Should have the right value in the box model."); is(span.textContent, 7, "Should have the right value in the box model.");
} }
function* testEditingAndCanceling(inspector, view, testActor) { function* testEditingAndCanceling(inspector, boxmodel, testActor) {
info("When all properties are set on the node editing one and then " + info("When all properties are set on the node editing one and then " +
"cancelling with ESCAPE should work"); "cancelling with ESCAPE should work");
@ -63,22 +63,22 @@ function* testEditingAndCanceling(inspector, view, testActor) {
yield selectNode("#div1", inspector); yield selectNode("#div1", inspector);
let span = view.document.querySelector(".boxmodel-padding.boxmodel-left > span"); let span = boxmodel.document.querySelector(".boxmodel-padding.boxmodel-left > span");
is(span.textContent, 5, "Should have the right value in the box model."); is(span.textContent, 5, "Should have the right value in the box model.");
EventUtils.synthesizeMouseAtCenter(span, {}, view.document.defaultView); EventUtils.synthesizeMouseAtCenter(span, {}, boxmodel.document.defaultView);
let editor = view.document.querySelector(".styleinspector-propertyeditor"); let editor = boxmodel.document.querySelector(".styleinspector-propertyeditor");
ok(editor, "Should have opened the editor."); ok(editor, "Should have opened the editor.");
is(editor.value, "5px", "Should have the right value in the editor."); is(editor.value, "5px", "Should have the right value in the editor.");
EventUtils.synthesizeKey("8", {}, view.document.defaultView); EventUtils.synthesizeKey("8", {}, boxmodel.document.defaultView);
yield waitForUpdate(inspector); yield waitForUpdate(inspector);
is(editor.value, "8", "Should have the right value in the editor."); is(editor.value, "8", "Should have the right value in the editor.");
is((yield getStyle(testActor, "#div1", "padding-left")), "8px", is((yield getStyle(testActor, "#div1", "padding-left")), "8px",
"Should have updated the padding"); "Should have updated the padding");
EventUtils.synthesizeKey("VK_ESCAPE", {}, view.document.defaultView); EventUtils.synthesizeKey("VK_ESCAPE", {}, boxmodel.document.defaultView);
yield waitForUpdate(inspector); yield waitForUpdate(inspector);
is((yield getStyle(testActor, "#div1", "padding-left")), "5px", is((yield getStyle(testActor, "#div1", "padding-left")), "5px",
@ -86,34 +86,34 @@ function* testEditingAndCanceling(inspector, view, testActor) {
is(span.textContent, 5, "Should have the right value in the box model."); is(span.textContent, 5, "Should have the right value in the box model.");
} }
function* testDeleting(inspector, view, testActor) { function* testDeleting(inspector, boxmodel, testActor) {
info("When all properties are set on the node deleting one should work"); info("When all properties are set on the node deleting one should work");
yield selectNode("#div1", inspector); yield selectNode("#div1", inspector);
let span = view.document.querySelector(".boxmodel-padding.boxmodel-left > span"); let span = boxmodel.document.querySelector(".boxmodel-padding.boxmodel-left > span");
is(span.textContent, 5, "Should have the right value in the box model."); is(span.textContent, 5, "Should have the right value in the box model.");
EventUtils.synthesizeMouseAtCenter(span, {}, view.document.defaultView); EventUtils.synthesizeMouseAtCenter(span, {}, boxmodel.document.defaultView);
let editor = view.document.querySelector(".styleinspector-propertyeditor"); let editor = boxmodel.document.querySelector(".styleinspector-propertyeditor");
ok(editor, "Should have opened the editor."); ok(editor, "Should have opened the editor.");
is(editor.value, "5px", "Should have the right value in the editor."); is(editor.value, "5px", "Should have the right value in the editor.");
EventUtils.synthesizeKey("VK_DELETE", {}, view.document.defaultView); EventUtils.synthesizeKey("VK_DELETE", {}, boxmodel.document.defaultView);
yield waitForUpdate(inspector); yield waitForUpdate(inspector);
is(editor.value, "", "Should have the right value in the editor."); is(editor.value, "", "Should have the right value in the editor.");
is((yield getStyle(testActor, "#div1", "padding-left")), "", is((yield getStyle(testActor, "#div1", "padding-left")), "",
"Should have updated the padding"); "Should have updated the padding");
EventUtils.synthesizeKey("VK_RETURN", {}, view.document.defaultView); EventUtils.synthesizeKey("VK_RETURN", {}, boxmodel.document.defaultView);
is((yield getStyle(testActor, "#div1", "padding-left")), "", is((yield getStyle(testActor, "#div1", "padding-left")), "",
"Should be the right padding."); "Should be the right padding.");
is(span.textContent, 3, "Should have the right value in the box model."); is(span.textContent, 3, "Should have the right value in the box model.");
} }
function* testDeletingAndCanceling(inspector, view, testActor) { function* testDeletingAndCanceling(inspector, boxmodel, testActor) {
info("When all properties are set on the node deleting one then cancelling " + info("When all properties are set on the node deleting one then cancelling " +
"should work"); "should work");
@ -122,22 +122,22 @@ function* testDeletingAndCanceling(inspector, view, testActor) {
yield selectNode("#div1", inspector); yield selectNode("#div1", inspector);
let span = view.document.querySelector(".boxmodel-padding.boxmodel-left > span"); let span = boxmodel.document.querySelector(".boxmodel-padding.boxmodel-left > span");
is(span.textContent, 5, "Should have the right value in the box model."); is(span.textContent, 5, "Should have the right value in the box model.");
EventUtils.synthesizeMouseAtCenter(span, {}, view.document.defaultView); EventUtils.synthesizeMouseAtCenter(span, {}, boxmodel.document.defaultView);
let editor = view.document.querySelector(".styleinspector-propertyeditor"); let editor = boxmodel.document.querySelector(".styleinspector-propertyeditor");
ok(editor, "Should have opened the editor."); ok(editor, "Should have opened the editor.");
is(editor.value, "5px", "Should have the right value in the editor."); is(editor.value, "5px", "Should have the right value in the editor.");
EventUtils.synthesizeKey("VK_DELETE", {}, view.document.defaultView); EventUtils.synthesizeKey("VK_DELETE", {}, boxmodel.document.defaultView);
yield waitForUpdate(inspector); yield waitForUpdate(inspector);
is(editor.value, "", "Should have the right value in the editor."); is(editor.value, "", "Should have the right value in the editor.");
is((yield getStyle(testActor, "#div1", "padding-left")), "", is((yield getStyle(testActor, "#div1", "padding-left")), "",
"Should have updated the padding"); "Should have updated the padding");
EventUtils.synthesizeKey("VK_ESCAPE", {}, view.document.defaultView); EventUtils.synthesizeKey("VK_ESCAPE", {}, boxmodel.document.defaultView);
yield waitForUpdate(inspector); yield waitForUpdate(inspector);
is((yield getStyle(testActor, "#div1", "padding-left")), "5px", is((yield getStyle(testActor, "#div1", "padding-left")), "5px",

Просмотреть файл

@ -21,54 +21,54 @@ add_task(function* () {
yield pushPref("devtools.toolbox.footer.height", 500); yield pushPref("devtools.toolbox.footer.height", 500);
yield addTab("data:text/html," + encodeURIComponent(TEST_URI)); yield addTab("data:text/html," + encodeURIComponent(TEST_URI));
let {inspector, view} = yield openBoxModelView(); let {inspector, boxmodel} = yield openLayoutView();
yield selectNode("#div1", inspector); yield selectNode("#div1", inspector);
yield testClickingOutsideEditor(view); yield testClickingOutsideEditor(boxmodel);
yield testClickingBelowContainer(view); yield testClickingBelowContainer(boxmodel);
}); });
function* testClickingOutsideEditor(view) { function* testClickingOutsideEditor(boxmodel) {
info("Test that clicking outside the editor blurs it"); info("Test that clicking outside the editor blurs it");
let span = view.document.querySelector(".boxmodel-margin.boxmodel-top > span"); let span = boxmodel.document.querySelector(".boxmodel-margin.boxmodel-top > span");
is(span.textContent, 10, "Should have the right value in the box model."); is(span.textContent, 10, "Should have the right value in the box model.");
EventUtils.synthesizeMouseAtCenter(span, {}, view.document.defaultView); EventUtils.synthesizeMouseAtCenter(span, {}, boxmodel.document.defaultView);
let editor = view.document.querySelector(".styleinspector-propertyeditor"); let editor = boxmodel.document.querySelector(".styleinspector-propertyeditor");
ok(editor, "Should have opened the editor."); ok(editor, "Should have opened the editor.");
info("Click next to the opened editor input."); info("Click next to the opened editor input.");
let onBlur = once(editor, "blur"); let onBlur = once(editor, "blur");
let rect = editor.getBoundingClientRect(); let rect = editor.getBoundingClientRect();
EventUtils.synthesizeMouse(editor, rect.width + 10, rect.height / 2, {}, EventUtils.synthesizeMouse(editor, rect.width + 10, rect.height / 2, {},
view.document.defaultView); boxmodel.document.defaultView);
yield onBlur; yield onBlur;
is(view.document.querySelector(".styleinspector-propertyeditor"), null, is(boxmodel.document.querySelector(".styleinspector-propertyeditor"), null,
"Inplace editor has been removed."); "Inplace editor has been removed.");
} }
function* testClickingBelowContainer(view) { function* testClickingBelowContainer(boxmodel) {
info("Test that clicking below the box-model container blurs it"); info("Test that clicking below the box-model container blurs it");
let span = view.document.querySelector(".boxmodel-margin.boxmodel-top > span"); let span = boxmodel.document.querySelector(".boxmodel-margin.boxmodel-top > span");
is(span.textContent, 10, "Should have the right value in the box model."); is(span.textContent, 10, "Should have the right value in the box model.");
info("Test that clicking below the boxmodel-container blurs the opened editor"); info("Test that clicking below the boxmodel-container blurs the opened editor");
EventUtils.synthesizeMouseAtCenter(span, {}, view.document.defaultView); EventUtils.synthesizeMouseAtCenter(span, {}, boxmodel.document.defaultView);
let editor = view.document.querySelector(".styleinspector-propertyeditor"); let editor = boxmodel.document.querySelector(".styleinspector-propertyeditor");
ok(editor, "Should have opened the editor."); ok(editor, "Should have opened the editor.");
let onBlur = once(editor, "blur"); let onBlur = once(editor, "blur");
let container = view.document.querySelector(".boxmodel-container"); let container = boxmodel.document.querySelector(".boxmodel-container");
// Using getBoxQuads here because getBoundingClientRect (and therefore synthesizeMouse) // Using getBoxQuads here because getBoundingClientRect (and therefore synthesizeMouse)
// use an erroneous height of ~50px for the boxmodel-container. // use an erroneous height of ~50px for the boxmodel-container.
let bounds = container.getBoxQuads({relativeTo: view.doc})[0].bounds; let bounds = container.getBoxQuads({relativeTo: boxmodel.document})[0].bounds;
EventUtils.synthesizeMouseAtPoint( EventUtils.synthesizeMouseAtPoint(
bounds.left + 10, bounds.left + 10,
bounds.top + bounds.height + 10, bounds.top + bounds.height + 10,
{}, view.document.defaultView); {}, boxmodel.document.defaultView);
yield onBlur; yield onBlur;
is(view.document.querySelector(".styleinspector-propertyeditor"), null, is(boxmodel.document.querySelector(".styleinspector-propertyeditor"), null,
"Inplace editor has been removed."); "Inplace editor has been removed.");
} }

Просмотреть файл

@ -16,7 +16,7 @@ const TEST_URI = "<style>" +
add_task(function* () { add_task(function* () {
yield addTab("data:text/html," + encodeURIComponent(TEST_URI)); yield addTab("data:text/html," + encodeURIComponent(TEST_URI));
let {inspector, view, testActor} = yield openBoxModelView(); let {inspector, boxmodel, testActor} = yield openLayoutView();
is((yield getStyle(testActor, "#div1", "border-top-width")), "", is((yield getStyle(testActor, "#div1", "border-top-width")), "",
"Should have the right border"); "Should have the right border");
@ -24,15 +24,15 @@ add_task(function* () {
"Should have the right border"); "Should have the right border");
yield selectNode("#div1", inspector); yield selectNode("#div1", inspector);
let span = view.document.querySelector(".boxmodel-border.boxmodel-top > span"); let span = boxmodel.document.querySelector(".boxmodel-border.boxmodel-top > span");
is(span.textContent, 0, "Should have the right value in the box model."); is(span.textContent, 0, "Should have the right value in the box model.");
EventUtils.synthesizeMouseAtCenter(span, {}, view.document.defaultView); EventUtils.synthesizeMouseAtCenter(span, {}, boxmodel.document.defaultView);
let editor = view.document.querySelector(".styleinspector-propertyeditor"); let editor = boxmodel.document.querySelector(".styleinspector-propertyeditor");
ok(editor, "Should have opened the editor."); ok(editor, "Should have opened the editor.");
is(editor.value, "0", "Should have the right value in the editor."); is(editor.value, "0", "Should have the right value in the editor.");
EventUtils.synthesizeKey("1", {}, view.document.defaultView); EventUtils.synthesizeKey("1", {}, boxmodel.document.defaultView);
yield waitForUpdate(inspector); yield waitForUpdate(inspector);
is(editor.value, "1", "Should have the right value in the editor."); is(editor.value, "1", "Should have the right value in the editor.");
@ -41,7 +41,7 @@ add_task(function* () {
is((yield getStyle(testActor, "#div1", "border-top-style")), "solid", is((yield getStyle(testActor, "#div1", "border-top-style")), "solid",
"Should have the right border"); "Should have the right border");
EventUtils.synthesizeKey("VK_ESCAPE", {}, view.document.defaultView); EventUtils.synthesizeKey("VK_ESCAPE", {}, boxmodel.document.defaultView);
yield waitForUpdate(inspector); yield waitForUpdate(inspector);
is((yield getStyle(testActor, "#div1", "border-top-width")), "", is((yield getStyle(testActor, "#div1", "border-top-width")), "",

Просмотреть файл

@ -22,24 +22,25 @@ const TEST_URI =
add_task(function* () { add_task(function* () {
yield addTab("data:text/html," + encodeURIComponent(TEST_URI)); yield addTab("data:text/html," + encodeURIComponent(TEST_URI));
let {inspector, view, testActor} = yield openBoxModelView(); let {inspector, boxmodel, testActor} = yield openLayoutView();
yield selectNode(".test", inspector); yield selectNode(".test", inspector);
// No margin-top defined. // No margin-top defined.
info("Test that margins are not impacted by a pseudo element"); info("Test that margins are not impacted by a pseudo element");
is((yield getStyle(testActor, ".test", "margin-top")), "", "margin-top is correct"); is((yield getStyle(testActor, ".test", "margin-top")), "", "margin-top is correct");
yield checkValueInBoxModel(".boxmodel-margin.boxmodel-top", "0", view.document); yield checkValueInBoxModel(".boxmodel-margin.boxmodel-top", "0", boxmodel.document);
// No padding-top defined. // No padding-top defined.
info("Test that paddings are not impacted by a pseudo element"); info("Test that paddings are not impacted by a pseudo element");
is((yield getStyle(testActor, ".test", "padding-top")), "", "padding-top is correct"); is((yield getStyle(testActor, ".test", "padding-top")), "", "padding-top is correct");
yield checkValueInBoxModel(".boxmodel-padding.boxmodel-top", "0", view.document); yield checkValueInBoxModel(".boxmodel-padding.boxmodel-top", "0", boxmodel.document);
// Width should be driven by the parent div. // Width should be driven by the parent div.
info("Test that dimensions are not impacted by a pseudo element"); info("Test that dimensions are not impacted by a pseudo element");
is((yield getStyle(testActor, ".test", "width")), "", "width is correct"); is((yield getStyle(testActor, ".test", "width")), "", "width is correct");
yield checkValueInBoxModel(".boxmodel-content.boxmodel-width", "200", view.document); yield checkValueInBoxModel(".boxmodel-content.boxmodel-width", "200",
boxmodel.document);
}); });
function* checkValueInBoxModel(selector, expectedValue, doc) { function* checkValueInBoxModel(selector, expectedValue, doc) {

Просмотреть файл

@ -17,95 +17,95 @@ const TEST_URI = "<style>" +
add_task(function* () { add_task(function* () {
yield addTab("data:text/html," + encodeURIComponent(TEST_URI)); yield addTab("data:text/html," + encodeURIComponent(TEST_URI));
let {inspector, view, testActor} = yield openBoxModelView(); let {inspector, boxmodel, testActor} = yield openLayoutView();
yield testUnits(inspector, view, testActor); yield testUnits(inspector, boxmodel, testActor);
yield testValueComesFromStyleRule(inspector, view, testActor); yield testValueComesFromStyleRule(inspector, boxmodel, testActor);
yield testShorthandsAreParsed(inspector, view, testActor); yield testShorthandsAreParsed(inspector, boxmodel, testActor);
}); });
function* testUnits(inspector, view, testActor) { function* testUnits(inspector, boxmodel, testActor) {
info("Test that entering units works"); info("Test that entering units works");
is((yield getStyle(testActor, "#div1", "padding-top")), "", is((yield getStyle(testActor, "#div1", "padding-top")), "",
"Should have the right padding"); "Should have the right padding");
yield selectNode("#div1", inspector); yield selectNode("#div1", inspector);
let span = view.document.querySelector(".boxmodel-padding.boxmodel-top > span"); let span = boxmodel.document.querySelector(".boxmodel-padding.boxmodel-top > span");
is(span.textContent, 3, "Should have the right value in the box model."); is(span.textContent, 3, "Should have the right value in the box model.");
EventUtils.synthesizeMouseAtCenter(span, {}, view.document.defaultView); EventUtils.synthesizeMouseAtCenter(span, {}, boxmodel.document.defaultView);
let editor = view.document.querySelector(".styleinspector-propertyeditor"); let editor = boxmodel.document.querySelector(".styleinspector-propertyeditor");
ok(editor, "Should have opened the editor."); ok(editor, "Should have opened the editor.");
is(editor.value, "3px", "Should have the right value in the editor."); is(editor.value, "3px", "Should have the right value in the editor.");
EventUtils.synthesizeKey("1", {}, view.document.defaultView); EventUtils.synthesizeKey("1", {}, boxmodel.document.defaultView);
yield waitForUpdate(inspector); yield waitForUpdate(inspector);
EventUtils.synthesizeKey("e", {}, view.document.defaultView); EventUtils.synthesizeKey("e", {}, boxmodel.document.defaultView);
yield waitForUpdate(inspector); yield waitForUpdate(inspector);
is((yield getStyle(testActor, "#div1", "padding-top")), "", is((yield getStyle(testActor, "#div1", "padding-top")), "",
"An invalid value is handled cleanly"); "An invalid value is handled cleanly");
EventUtils.synthesizeKey("m", {}, view.document.defaultView); EventUtils.synthesizeKey("m", {}, boxmodel.document.defaultView);
yield waitForUpdate(inspector); yield waitForUpdate(inspector);
is(editor.value, "1em", "Should have the right value in the editor."); is(editor.value, "1em", "Should have the right value in the editor.");
is((yield getStyle(testActor, "#div1", "padding-top")), is((yield getStyle(testActor, "#div1", "padding-top")),
"1em", "Should have updated the padding."); "1em", "Should have updated the padding.");
EventUtils.synthesizeKey("VK_RETURN", {}, view.document.defaultView); EventUtils.synthesizeKey("VK_RETURN", {}, boxmodel.document.defaultView);
is((yield getStyle(testActor, "#div1", "padding-top")), "1em", is((yield getStyle(testActor, "#div1", "padding-top")), "1em",
"Should be the right padding."); "Should be the right padding.");
is(span.textContent, 16, "Should have the right value in the box model."); is(span.textContent, 16, "Should have the right value in the box model.");
} }
function* testValueComesFromStyleRule(inspector, view, testActor) { function* testValueComesFromStyleRule(inspector, boxmodel, testActor) {
info("Test that we pick up the value from a higher style rule"); info("Test that we pick up the value from a higher style rule");
is((yield getStyle(testActor, "#div2", "border-bottom-width")), "", is((yield getStyle(testActor, "#div2", "border-bottom-width")), "",
"Should have the right border-bottom-width"); "Should have the right border-bottom-width");
yield selectNode("#div2", inspector); yield selectNode("#div2", inspector);
let span = view.document.querySelector(".boxmodel-border.boxmodel-bottom > span"); let span = boxmodel.document.querySelector(".boxmodel-border.boxmodel-bottom > span");
is(span.textContent, 16, "Should have the right value in the box model."); is(span.textContent, 16, "Should have the right value in the box model.");
EventUtils.synthesizeMouseAtCenter(span, {}, view.document.defaultView); EventUtils.synthesizeMouseAtCenter(span, {}, boxmodel.document.defaultView);
let editor = view.document.querySelector(".styleinspector-propertyeditor"); let editor = boxmodel.document.querySelector(".styleinspector-propertyeditor");
ok(editor, "Should have opened the editor."); ok(editor, "Should have opened the editor.");
is(editor.value, "1em", "Should have the right value in the editor."); is(editor.value, "1em", "Should have the right value in the editor.");
EventUtils.synthesizeKey("0", {}, view.document.defaultView); EventUtils.synthesizeKey("0", {}, boxmodel.document.defaultView);
yield waitForUpdate(inspector); yield waitForUpdate(inspector);
is(editor.value, "0", "Should have the right value in the editor."); is(editor.value, "0", "Should have the right value in the editor.");
is((yield getStyle(testActor, "#div2", "border-bottom-width")), "0px", is((yield getStyle(testActor, "#div2", "border-bottom-width")), "0px",
"Should have updated the border."); "Should have updated the border.");
EventUtils.synthesizeKey("VK_RETURN", {}, view.document.defaultView); EventUtils.synthesizeKey("VK_RETURN", {}, boxmodel.document.defaultView);
is((yield getStyle(testActor, "#div2", "border-bottom-width")), "0px", is((yield getStyle(testActor, "#div2", "border-bottom-width")), "0px",
"Should be the right border-bottom-width."); "Should be the right border-bottom-width.");
is(span.textContent, 0, "Should have the right value in the box model."); is(span.textContent, 0, "Should have the right value in the box model.");
} }
function* testShorthandsAreParsed(inspector, view, testActor) { function* testShorthandsAreParsed(inspector, boxmodel, testActor) {
info("Test that shorthand properties are parsed correctly"); info("Test that shorthand properties are parsed correctly");
is((yield getStyle(testActor, "#div3", "padding-right")), "", is((yield getStyle(testActor, "#div3", "padding-right")), "",
"Should have the right padding"); "Should have the right padding");
yield selectNode("#div3", inspector); yield selectNode("#div3", inspector);
let span = view.document.querySelector(".boxmodel-padding.boxmodel-right > span"); let span = boxmodel.document.querySelector(".boxmodel-padding.boxmodel-right > span");
is(span.textContent, 32, "Should have the right value in the box model."); is(span.textContent, 32, "Should have the right value in the box model.");
EventUtils.synthesizeMouseAtCenter(span, {}, view.document.defaultView); EventUtils.synthesizeMouseAtCenter(span, {}, boxmodel.document.defaultView);
let editor = view.document.querySelector(".styleinspector-propertyeditor"); let editor = boxmodel.document.querySelector(".styleinspector-propertyeditor");
ok(editor, "Should have opened the editor."); ok(editor, "Should have opened the editor.");
is(editor.value, "2em", "Should have the right value in the editor."); is(editor.value, "2em", "Should have the right value in the editor.");
EventUtils.synthesizeKey("VK_RETURN", {}, view.document.defaultView); EventUtils.synthesizeKey("VK_RETURN", {}, boxmodel.document.defaultView);
is((yield getStyle(testActor, "#div3", "padding-right")), "", is((yield getStyle(testActor, "#div3", "padding-right")), "",
"Should be the right padding."); "Should be the right padding.");

Просмотреть файл

@ -19,7 +19,7 @@ var highlightedNodeFront, highlighterOptions;
add_task(async function() { add_task(async function() {
await addTab(TEST_URL); await addTab(TEST_URL);
let {toolbox, inspector, view} = await openBoxModelView(); let {toolbox, inspector, boxmodel} = await openLayoutView();
await selectNode("div", inspector); await selectNode("div", inspector);
// Mock the highlighter by replacing the showBoxModel method. // Mock the highlighter by replacing the showBoxModel method.
@ -28,17 +28,17 @@ add_task(async function() {
highlighterOptions = options; highlighterOptions = options;
}; };
let elt = view.document.querySelector(".boxmodel-margins"); let elt = boxmodel.document.querySelector(".boxmodel-margins");
await testGuideOnLayoutHover(elt, "margin", inspector, view); await testGuideOnLayoutHover(elt, "margin", inspector);
elt = view.document.querySelector(".boxmodel-borders"); elt = boxmodel.document.querySelector(".boxmodel-borders");
await testGuideOnLayoutHover(elt, "border", inspector, view); await testGuideOnLayoutHover(elt, "border", inspector);
elt = view.document.querySelector(".boxmodel-paddings"); elt = boxmodel.document.querySelector(".boxmodel-paddings");
await testGuideOnLayoutHover(elt, "padding", inspector, view); await testGuideOnLayoutHover(elt, "padding", inspector);
elt = view.document.querySelector(".boxmodel-content"); elt = boxmodel.document.querySelector(".boxmodel-content");
await testGuideOnLayoutHover(elt, "content", inspector, view); await testGuideOnLayoutHover(elt, "content", inspector);
}); });
async function testGuideOnLayoutHover(elt, expectedRegion, inspector) { async function testGuideOnLayoutHover(elt, expectedRegion, inspector) {

Просмотреть файл

@ -17,104 +17,104 @@ const TEST_URI = `
add_task(function* () { add_task(function* () {
yield addTab("data:text/html," + encodeURIComponent(TEST_URI)); yield addTab("data:text/html," + encodeURIComponent(TEST_URI));
let {inspector, view} = yield openBoxModelView(); let {inspector, boxmodel} = yield openLayoutView();
yield selectNode("div", inspector); yield selectNode("div", inspector);
yield testInitialFocus(inspector, view); yield testInitialFocus(inspector, boxmodel);
yield testChangingLevels(inspector, view); yield testChangingLevels(inspector, boxmodel);
yield testTabbingWrapAround(inspector, view); yield testTabbingWrapAround(inspector, boxmodel);
yield testChangingLevelsByClicking(inspector, view); yield testChangingLevelsByClicking(inspector, boxmodel);
}); });
function* testInitialFocus(inspector, view) { function* testInitialFocus(inspector, boxmodel) {
info("Test that the focus is on margin layout."); info("Test that the focus is(on margin layout.");
let viewdoc = view.document; let doc = boxmodel.document;
let boxmodel = viewdoc.querySelector(".boxmodel-container"); let container = doc.querySelector(".boxmodel-container");
boxmodel.focus(); container.focus();
EventUtils.synthesizeKey("KEY_Enter"); EventUtils.synthesizeKey("KEY_Enter");
is(boxmodel.getAttribute("activedescendant"), "boxmodel-main devtools-monospace", is(container.getAttribute("activedescendant"), "boxmodel-main devtools-monospace",
"Should be set to the position layout."); "Should be set to the position layout.");
} }
function* testChangingLevels(inspector, view) { function* testChangingLevels(inspector, boxmodel) {
info("Test that using arrow keys updates level."); info("Test that using arrow keys updates level.");
let viewdoc = view.document; let doc = boxmodel.document;
let boxmodel = viewdoc.querySelector(".boxmodel-container"); let container = doc.querySelector(".boxmodel-container");
boxmodel.focus(); container.focus();
EventUtils.synthesizeKey("KEY_Enter"); EventUtils.synthesizeKey("KEY_Enter");
EventUtils.synthesizeKey("KEY_Escape"); EventUtils.synthesizeKey("KEY_Escape");
EventUtils.synthesizeKey("KEY_ArrowDown"); EventUtils.synthesizeKey("KEY_ArrowDown");
is(boxmodel.getAttribute("activedescendant"), "boxmodel-margins", is(container.getAttribute("activedescendant"), "boxmodel-margins",
"Should be set to the margin layout."); "Should be set to the margin layout.");
EventUtils.synthesizeKey("KEY_ArrowDown"); EventUtils.synthesizeKey("KEY_ArrowDown");
is(boxmodel.getAttribute("activedescendant"), "boxmodel-borders", is(container.getAttribute("activedescendant"), "boxmodel-borders",
"Should be set to the border layout."); "Should be set to the border layout.");
EventUtils.synthesizeKey("KEY_ArrowDown"); EventUtils.synthesizeKey("KEY_ArrowDown");
is(boxmodel.getAttribute("activedescendant"), "boxmodel-paddings", is(container.getAttribute("activedescendant"), "boxmodel-paddings",
"Should be set to the padding layout."); "Should be set to the padding layout.");
EventUtils.synthesizeKey("KEY_ArrowDown"); EventUtils.synthesizeKey("KEY_ArrowDown");
is(boxmodel.getAttribute("activedescendant"), "boxmodel-contents", is(container.getAttribute("activedescendant"), "boxmodel-contents",
"Should be set to the content layout."); "Should be set to the content layout.");
EventUtils.synthesizeKey("KEY_ArrowUp"); EventUtils.synthesizeKey("KEY_ArrowUp");
is(boxmodel.getAttribute("activedescendant"), "boxmodel-paddings", is(container.getAttribute("activedescendant"), "boxmodel-paddings",
"Should be set to the padding layout."); "Should be set to the padding layout.");
EventUtils.synthesizeKey("KEY_ArrowUp"); EventUtils.synthesizeKey("KEY_ArrowUp");
is(boxmodel.getAttribute("activedescendant"), "boxmodel-borders", is(container.getAttribute("activedescendant"), "boxmodel-borders",
"Should be set to the border layout."); "Should be set to the border layout.");
EventUtils.synthesizeKey("KEY_ArrowUp"); EventUtils.synthesizeKey("KEY_ArrowUp");
is(boxmodel.getAttribute("activedescendant"), "boxmodel-margins", is(container.getAttribute("activedescendant"), "boxmodel-margins",
"Should be set to the margin layout."); "Should be set to the margin layout.");
EventUtils.synthesizeKey("KEY_ArrowUp"); EventUtils.synthesizeKey("KEY_ArrowUp");
is(boxmodel.getAttribute("activedescendant"), "boxmodel-main devtools-monospace", is(container.getAttribute("activedescendant"), "boxmodel-main devtools-monospace",
"Should be set to the position layout."); "Should be set to the position layout.");
} }
function* testTabbingWrapAround(inspector, view) { function* testTabbingWrapAround(inspector, boxmodel) {
info("Test that using arrow keys updates level."); info("Test that using arrow keys updates level.");
let viewdoc = view.document; let doc = boxmodel.document;
let boxmodel = viewdoc.querySelector(".boxmodel-container"); let container = doc.querySelector(".boxmodel-container");
boxmodel.focus(); container.focus();
EventUtils.synthesizeKey("KEY_Enter"); EventUtils.synthesizeKey("KEY_Enter");
let editLevel = boxmodel.getAttribute("activedescendant").split(" ")[0]; let editLevel = container.getAttribute("activedescendant").split(" ")[0];
let dataLevel = viewdoc.querySelector(`.${editLevel}`).getAttribute("data-box"); let dataLevel = doc.querySelector(`.${editLevel}`).getAttribute("data-box");
let editBoxes = [...viewdoc.querySelectorAll( let editBoxes = [...doc.querySelectorAll(
`[data-box="${dataLevel}"].boxmodel-editable`)]; `[data-box="${dataLevel}"].boxmodel-editable`)];
EventUtils.synthesizeKey("KEY_Escape"); EventUtils.synthesizeKey("KEY_Escape");
editBoxes[3].focus(); editBoxes[3].focus();
EventUtils.synthesizeKey("KEY_Tab"); EventUtils.synthesizeKey("KEY_Tab");
is(editBoxes[0], viewdoc.activeElement, "Top edit box should have focus."); is(editBoxes[0], doc.activeElement, "Top edit box should have focus.");
editBoxes[0].focus(); editBoxes[0].focus();
EventUtils.synthesizeKey("KEY_Tab", {shiftKey: true}); EventUtils.synthesizeKey("KEY_Tab", {shiftKey: true});
is(editBoxes[3], viewdoc.activeElement, "Left edit box should have focus."); is(editBoxes[3], doc.activeElement, "Left edit box should have focus.");
} }
function* testChangingLevelsByClicking(inspector, view) { function* testChangingLevelsByClicking(inspector, boxmodel) {
info("Test that clicking on levels updates level."); info("Test that clicking on levels updates level.");
let viewdoc = view.document; let doc = boxmodel.document;
let boxmodel = viewdoc.querySelector(".boxmodel-container"); let container = doc.querySelector(".boxmodel-container");
boxmodel.focus(); container.focus();
let marginLayout = viewdoc.querySelector(".boxmodel-margins"); let marginLayout = doc.querySelector(".boxmodel-margins");
let borderLayout = viewdoc.querySelector(".boxmodel-borders"); let borderLayout = doc.querySelector(".boxmodel-borders");
let paddingLayout = viewdoc.querySelector(".boxmodel-paddings"); let paddingLayout = doc.querySelector(".boxmodel-paddings");
let contentLayout = viewdoc.querySelector(".boxmodel-contents"); let contentLayout = doc.querySelector(".boxmodel-contents");
let layouts = [contentLayout, paddingLayout, borderLayout, marginLayout]; let layouts = [contentLayout, paddingLayout, borderLayout, marginLayout];
layouts.forEach(layout => { layouts.forEach(layout => {
layout.click(); layout.click();
is(boxmodel.getAttribute("activedescendant"), layout.className, is(container.getAttribute("activedescendant"), layout.className,
"Should be set to" + layout.getAttribute("data-box") + "layout."); "Should be set to" + layout.getAttribute("data-box") + "layout.");
}); });
} }

Просмотреть файл

@ -44,21 +44,21 @@ const res1 = [
add_task(function* () { add_task(function* () {
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
let {inspector, view} = yield openBoxModelView(); let {inspector, boxmodel} = yield openLayoutView();
let node = yield getNodeFront("div", inspector); let node = yield getNodeFront("div", inspector);
let children = yield inspector.markup.walker.children(node); let children = yield inspector.markup.walker.children(node);
let beforeElement = children.nodes[0]; let beforeElement = children.nodes[0];
yield selectNode(beforeElement, inspector); yield selectNode(beforeElement, inspector);
yield testPositionValues(inspector, view); yield testPositionValues(inspector, boxmodel);
}); });
function* testPositionValues(inspector, view) { function* testPositionValues(inspector, boxmodel) {
info("Test that the position values of the box model are correct"); info("Test that the position values of the box model are correct");
let viewdoc = view.document; let doc = boxmodel.document;
for (let i = 0; i < res1.length; i++) { for (let i = 0; i < res1.length; i++) {
let elt = viewdoc.querySelector(res1[i].selector); let elt = doc.querySelector(res1[i].selector);
is(elt.textContent, res1[i].value, is(elt.textContent, res1[i].value,
res1[i].selector + " has the right value."); res1[i].selector + " has the right value.");
} }

Просмотреть файл

@ -99,21 +99,21 @@ const res1 = [
add_task(function* () { add_task(function* () {
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
let {inspector, view} = yield openBoxModelView(); let {inspector, boxmodel} = yield openLayoutView();
let node = yield getNodeFront("div", inspector); let node = yield getNodeFront("div", inspector);
let children = yield inspector.markup.walker.children(node); let children = yield inspector.markup.walker.children(node);
let beforeElement = children.nodes[0]; let beforeElement = children.nodes[0];
yield selectNode(beforeElement, inspector); yield selectNode(beforeElement, inspector);
yield testInitialValues(inspector, view); yield testInitialValues(inspector, boxmodel);
}); });
function* testInitialValues(inspector, view) { function* testInitialValues(inspector, boxmodel) {
info("Test that the initial values of the box model are correct"); info("Test that the initial values of the box model are correct");
let viewdoc = view.document; let doc = boxmodel.document;
for (let i = 0; i < res1.length; i++) { for (let i = 0; i < res1.length; i++) {
let elt = viewdoc.querySelector(res1[i].selector); let elt = doc.querySelector(res1[i].selector);
is(elt.textContent, res1[i].value, is(elt.textContent, res1[i].value,
res1[i].selector + " has the right value."); res1[i].selector + " has the right value.");
} }

Просмотреть файл

@ -32,11 +32,11 @@ const LONG_TEXT_ROTATE_LIMIT = 3;
add_task(function* () { add_task(function* () {
yield addTab("data:text/html," + TEST_URI); yield addTab("data:text/html," + TEST_URI);
let {inspector, view} = yield openBoxModelView(); let {inspector, boxmodel} = yield openLayoutView();
yield selectNode("div", inspector); yield selectNode("div", inspector);
for (let i = 0; i < res1.length; i++) { for (let i = 0; i < res1.length; i++) {
let elt = view.document.querySelector(res1[i].selector); let elt = boxmodel.document.querySelector(res1[i].selector);
let isLong = elt.textContent.length > LONG_TEXT_ROTATE_LIMIT; let isLong = elt.textContent.length > LONG_TEXT_ROTATE_LIMIT;
let classList = elt.parentNode.classList; let classList = elt.parentNode.classList;
let canBeRotated = classList.contains("boxmodel-left") || let canBeRotated = classList.contains("boxmodel-left") ||

Просмотреть файл

@ -10,21 +10,21 @@ const TEST_URI = "<p>hello</p>";
add_task(function* () { add_task(function* () {
yield addTab("data:text/html," + encodeURIComponent(TEST_URI)); yield addTab("data:text/html," + encodeURIComponent(TEST_URI));
let {inspector, view} = yield openBoxModelView(); let {inspector, boxmodel} = yield openLayoutView();
info("When a property is edited, it should sync in the rule view"); info("When a property is edited, it should sync in the rule view");
yield selectNode("p", inspector); yield selectNode("p", inspector);
info("Modify padding-bottom in box model view"); info("Modify padding-bottom in box model view");
let span = view.document.querySelector(".boxmodel-padding.boxmodel-bottom > span"); let span = boxmodel.document.querySelector(".boxmodel-padding.boxmodel-bottom > span");
EventUtils.synthesizeMouseAtCenter(span, {}, view.document.defaultView); EventUtils.synthesizeMouseAtCenter(span, {}, boxmodel.document.defaultView);
let editor = view.document.querySelector(".styleinspector-propertyeditor"); let editor = boxmodel.document.querySelector(".styleinspector-propertyeditor");
EventUtils.synthesizeKey("7", {}, view.document.defaultView); EventUtils.synthesizeKey("7", {}, boxmodel.document.defaultView);
yield waitForUpdate(inspector); yield waitForUpdate(inspector);
is(editor.value, "7", "Should have the right value in the editor."); is(editor.value, "7", "Should have the right value in the editor.");
EventUtils.synthesizeKey("VK_RETURN", {}, view.document.defaultView); EventUtils.synthesizeKey("VK_RETURN", {}, boxmodel.document.defaultView);
let onRuleViewRefreshed = once(inspector, "rule-view-refreshed"); let onRuleViewRefreshed = once(inspector, "rule-view-refreshed");
let onRuleViewSelected = once(inspector.sidebar, "ruleview-selected"); let onRuleViewSelected = once(inspector.sidebar, "ruleview-selected");

Просмотреть файл

@ -72,43 +72,43 @@ const VALUES_TEST_DATA = [{
add_task(function* () { add_task(function* () {
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
let {inspector, view} = yield openBoxModelView(); let {inspector, boxmodel} = yield openLayoutView();
info("Checking the regions tooltips"); info("Checking the regions tooltips");
ok(view.document.querySelector(".boxmodel-margins").hasAttribute("title"), ok(boxmodel.document.querySelector(".boxmodel-margins").hasAttribute("title"),
"The margin region has a tooltip"); "The margin region has a tooltip");
is(view.document.querySelector(".boxmodel-margins").getAttribute("title"), "margin", is(boxmodel.document.querySelector(".boxmodel-margins").getAttribute("title"), "margin",
"The margin region has the correct tooltip content"); "The margin region has the correct tooltip content");
ok(view.document.querySelector(".boxmodel-borders").hasAttribute("title"), ok(boxmodel.document.querySelector(".boxmodel-borders").hasAttribute("title"),
"The border region has a tooltip"); "The border region has a tooltip");
is(view.document.querySelector(".boxmodel-borders").getAttribute("title"), "border", is(boxmodel.document.querySelector(".boxmodel-borders").getAttribute("title"), "border",
"The border region has the correct tooltip content"); "The border region has the correct tooltip content");
ok(view.document.querySelector(".boxmodel-paddings").hasAttribute("title"), ok(boxmodel.document.querySelector(".boxmodel-paddings").hasAttribute("title"),
"The padding region has a tooltip"); "The padding region has a tooltip");
is(view.document.querySelector(".boxmodel-paddings").getAttribute("title"), "padding", is(boxmodel.document.querySelector(".boxmodel-paddings").getAttribute("title"),
"The padding region has the correct tooltip content"); "padding", "The padding region has the correct tooltip content");
ok(view.document.querySelector(".boxmodel-content").hasAttribute("title"), ok(boxmodel.document.querySelector(".boxmodel-content").hasAttribute("title"),
"The content region has a tooltip"); "The content region has a tooltip");
is(view.document.querySelector(".boxmodel-content").getAttribute("title"), "content", is(boxmodel.document.querySelector(".boxmodel-content").getAttribute("title"),
"The content region has the correct tooltip content"); "content", "The content region has the correct tooltip content");
for (let {selector, values} of VALUES_TEST_DATA) { for (let {selector, values} of VALUES_TEST_DATA) {
info("Selecting " + selector + " and checking the values tooltips"); info("Selecting " + selector + " and checking the values tooltips");
yield selectNode(selector, inspector); yield selectNode(selector, inspector);
info("Iterate over all values"); info("Iterate over all values");
for (let key in view.map) { for (let key in boxmodel.map) {
if (key === "position") { if (key === "position") {
continue; continue;
} }
let name = view.map[key].property; let name = boxmodel.map[key].property;
let expectedTooltipData = values.find(o => o.name === name); let expectedTooltipData = values.find(o => o.name === name);
let el = view.document.querySelector(view.map[key].selector); let el = boxmodel.document.querySelector(boxmodel.map[key].selector);
ok(el.hasAttribute("title"), "The " + name + " value has a tooltip"); ok(el.hasAttribute("title"), "The " + name + " value has a tooltip");

Просмотреть файл

@ -12,32 +12,32 @@ const IFRAME2 = URL_ROOT + "doc_boxmodel_iframe2.html";
add_task(function* () { add_task(function* () {
yield addTab(IFRAME1); yield addTab(IFRAME1);
let {inspector, view, testActor} = yield openBoxModelView(); let {inspector, boxmodel, testActor} = yield openLayoutView();
yield testFirstPage(inspector, view, testActor); yield testFirstPage(inspector, boxmodel, testActor);
info("Navigate to the second page"); info("Navigate to the second page");
let onMarkupLoaded = waitForMarkupLoaded(inspector); let onMarkupLoaded = waitForMarkupLoaded(inspector);
yield testActor.eval(`location.href="${IFRAME2}"`); yield testActor.eval(`location.href="${IFRAME2}"`);
yield onMarkupLoaded; yield onMarkupLoaded;
yield testSecondPage(inspector, view, testActor); yield testSecondPage(inspector, boxmodel, testActor);
info("Go back to the first page"); info("Go back to the first page");
onMarkupLoaded = waitForMarkupLoaded(inspector); onMarkupLoaded = waitForMarkupLoaded(inspector);
yield testActor.eval("history.back();"); yield testActor.eval("history.back();");
yield onMarkupLoaded; yield onMarkupLoaded;
yield testBackToFirstPage(inspector, view, testActor); yield testBackToFirstPage(inspector, boxmodel, testActor);
}); });
function* testFirstPage(inspector, view, testActor) { function* testFirstPage(inspector, boxmodel, testActor) {
info("Test that the box model view works on the first page"); info("Test that the box model view works on the first page");
yield selectNode("p", inspector); yield selectNode("p", inspector);
info("Checking that the box model view shows the right value"); info("Checking that the box model view shows the right value");
let paddingElt = view.document.querySelector( let paddingElt = boxmodel.document.querySelector(
".boxmodel-padding.boxmodel-top > span"); ".boxmodel-padding.boxmodel-top > span");
is(paddingElt.textContent, "50"); is(paddingElt.textContent, "50");
@ -51,13 +51,13 @@ function* testFirstPage(inspector, view, testActor) {
is(paddingElt.textContent, "20"); is(paddingElt.textContent, "20");
} }
function* testSecondPage(inspector, view, testActor) { function* testSecondPage(inspector, boxmodel, testActor) {
info("Test that the box model view works on the second page"); info("Test that the box model view works on the second page");
yield selectNode("p", inspector); yield selectNode("p", inspector);
info("Checking that the box model view shows the right value"); info("Checking that the box model view shows the right value");
let sizeElt = view.document.querySelector(".boxmodel-size > span"); let sizeElt = boxmodel.document.querySelector(".boxmodel-size > span");
is(sizeElt.textContent, "100" + "\u00D7" + "100"); is(sizeElt.textContent, "100" + "\u00D7" + "100");
info("Listening for box model view changes and modifying the size"); info("Listening for box model view changes and modifying the size");
@ -70,14 +70,14 @@ function* testSecondPage(inspector, view, testActor) {
is(sizeElt.textContent, "200" + "\u00D7" + "100"); is(sizeElt.textContent, "200" + "\u00D7" + "100");
} }
function* testBackToFirstPage(inspector, view, testActor) { function* testBackToFirstPage(inspector, boxmodel, testActor) {
info("Test that the box model view works on the first page after going back"); info("Test that the box model view works on the first page after going back");
yield selectNode("p", inspector); yield selectNode("p", inspector);
info("Checking that the box model view shows the right value, which is the" + info("Checking that the box model view shows the right value, which is the" +
"modified value from step one because of the bfcache"); "modified value from step one because of the bfcache");
let paddingElt = view.document.querySelector( let paddingElt = boxmodel.document.querySelector(
".boxmodel-padding.boxmodel-top > span"); ".boxmodel-padding.boxmodel-top > span");
is(paddingElt.textContent, "20"); is(paddingElt.textContent, "20");

Просмотреть файл

@ -8,10 +8,10 @@
add_task(function* () { add_task(function* () {
yield addTab(URL_ROOT + "doc_boxmodel_iframe1.html"); yield addTab(URL_ROOT + "doc_boxmodel_iframe1.html");
let {inspector, view, testActor} = yield openBoxModelView(); let {inspector, boxmodel, testActor} = yield openLayoutView();
info("Test that the box model view works on the first page"); info("Test that the box model view works on the first page");
yield assertBoxModelView(inspector, view, testActor); yield assertBoxModelView(inspector, boxmodel, testActor);
info("Reload the page"); info("Reload the page");
let onMarkupLoaded = waitForMarkupLoaded(inspector); let onMarkupLoaded = waitForMarkupLoaded(inspector);
@ -19,14 +19,14 @@ add_task(function* () {
yield onMarkupLoaded; yield onMarkupLoaded;
info("Test that the box model view works on the reloaded page"); info("Test that the box model view works on the reloaded page");
yield assertBoxModelView(inspector, view, testActor); yield assertBoxModelView(inspector, boxmodel, testActor);
}); });
function* assertBoxModelView(inspector, view, testActor) { function* assertBoxModelView(inspector, boxmodel, testActor) {
yield selectNode("p", inspector); yield selectNode("p", inspector);
info("Checking that the box model view shows the right value"); info("Checking that the box model view shows the right value");
let paddingElt = view.document.querySelector( let paddingElt = boxmodel.document.querySelector(
".boxmodel-padding.boxmodel-top > span"); ".boxmodel-padding.boxmodel-top > span");
is(paddingElt.textContent, "50"); is(paddingElt.textContent, "50");

Просмотреть файл

@ -9,20 +9,20 @@
add_task(function* () { add_task(function* () {
yield addTab(URL_ROOT + "doc_boxmodel_iframe1.html"); yield addTab(URL_ROOT + "doc_boxmodel_iframe1.html");
let {inspector, view, testActor} = yield openBoxModelView(); let {inspector, boxmodel, testActor} = yield openLayoutView();
yield testResizingInIframe(inspector, view, testActor); yield testResizingInIframe(inspector, boxmodel, testActor);
yield testReflowsAfterIframeDeletion(inspector, view, testActor); yield testReflowsAfterIframeDeletion(inspector, boxmodel, testActor);
}); });
function* testResizingInIframe(inspector, view, testActor) { function* testResizingInIframe(inspector, boxmodel, testActor) {
info("Test that resizing an element in an iframe updates its box model"); info("Test that resizing an element in an iframe updates its box model");
info("Selecting the nested test node"); info("Selecting the nested test node");
yield selectNodeInIframe2("div", inspector); yield selectNodeInIframe2("div", inspector);
info("Checking that the box model view shows the right value"); info("Checking that the box model view shows the right value");
let sizeElt = view.document.querySelector(".boxmodel-size > span"); let sizeElt = boxmodel.document.querySelector(".boxmodel-size > span");
is(sizeElt.textContent, "400\u00D7200"); is(sizeElt.textContent, "400\u00D7200");
info("Listening for box model view changes and modifying its size"); info("Listening for box model view changes and modifying its size");
@ -35,7 +35,7 @@ function* testResizingInIframe(inspector, view, testActor) {
is(sizeElt.textContent, "200\u00D7200"); is(sizeElt.textContent, "200\u00D7200");
} }
function* testReflowsAfterIframeDeletion(inspector, view, testActor) { function* testReflowsAfterIframeDeletion(inspector, boxmodel, testActor) {
info("Test reflows are still sent to the box model view after deleting an " + info("Test reflows are still sent to the box model view after deleting an " +
"iframe"); "iframe");
@ -48,7 +48,7 @@ function* testReflowsAfterIframeDeletion(inspector, view, testActor) {
yield selectNodeInIframe1("p", inspector); yield selectNodeInIframe1("p", inspector);
info("Checking that the box model view shows the right value"); info("Checking that the box model view shows the right value");
let sizeElt = view.document.querySelector(".boxmodel-size > span"); let sizeElt = boxmodel.document.querySelector(".boxmodel-size > span");
is(sizeElt.textContent, "100\u00D7100"); is(sizeElt.textContent, "100\u00D7100");
info("Listening for box model view changes and modifying its size"); info("Listening for box model view changes and modifying its size");

Просмотреть файл

@ -45,36 +45,6 @@ function isNodeVisible(node) {
return !!node.getClientRects().length; return !!node.getClientRects().length;
} }
/**
* Open the toolbox, with the inspector tool visible, and the computed view
* sidebar tab selected to display the box model view.
*
* @return {Promise} a promise that resolves when the inspector is ready and the box model
* view is visible and ready.
*/
function openBoxModelView() {
return openInspectorSidebarTab("computedview").then(data => {
// The actual highligher show/hide methods are mocked in box model tests.
// The highlighter is tested in devtools/inspector/test.
function mockHighlighter({highlighter}) {
highlighter.showBoxModel = function() {
return promise.resolve();
};
highlighter.hideBoxModel = function() {
return promise.resolve();
};
}
mockHighlighter(data.toolbox);
return {
toolbox: data.toolbox,
inspector: data.inspector,
view: data.inspector.getPanel("computedview"),
testActor: data.testActor
};
});
}
/** /**
* Wait for the boxmodel-view-updated event. * Wait for the boxmodel-view-updated event.
* *

Просмотреть файл

@ -27,12 +27,6 @@ const TooltipsOverlay = require("devtools/client/inspector/shared/tooltips-overl
const KeyShortcuts = require("devtools/client/shared/key-shortcuts"); const KeyShortcuts = require("devtools/client/shared/key-shortcuts");
const clipboardHelper = require("devtools/shared/platform/clipboard"); const clipboardHelper = require("devtools/shared/platform/clipboard");
const { createElement, createFactory } = require("devtools/client/shared/vendor/react");
const ReactDOM = require("devtools/client/shared/vendor/react-dom");
const { Provider } = require("devtools/client/shared/vendor/react-redux");
const BoxModelApp = createFactory(require("devtools/client/inspector/boxmodel/components/BoxModelApp"));
const STYLE_INSPECTOR_PROPERTIES = "devtools/shared/locales/styleinspector.properties"; const STYLE_INSPECTOR_PROPERTIES = "devtools/shared/locales/styleinspector.properties";
const {LocalizationHelper} = require("devtools/shared/l10n"); const {LocalizationHelper} = require("devtools/shared/l10n");
const STYLE_INSPECTOR_L10N = new LocalizationHelper(STYLE_INSPECTOR_PROPERTIES); const STYLE_INSPECTOR_L10N = new LocalizationHelper(STYLE_INSPECTOR_PROPERTIES);
@ -156,7 +150,6 @@ UpdateProcess.prototype = {
function CssComputedView(inspector, document, pageStyle) { function CssComputedView(inspector, document, pageStyle) {
this.inspector = inspector; this.inspector = inspector;
this.highlighters = inspector.highlighters; this.highlighters = inspector.highlighters;
this.store = inspector.store;
this.styleDocument = document; this.styleDocument = document;
this.styleWindow = this.styleDocument.defaultView; this.styleWindow = this.styleDocument.defaultView;
this.pageStyle = pageStyle; this.pageStyle = pageStyle;
@ -177,7 +170,6 @@ function CssComputedView(inspector, document, pageStyle) {
let doc = this.styleDocument; let doc = this.styleDocument;
this.element = doc.getElementById("computed-property-container"); this.element = doc.getElementById("computed-property-container");
this.boxModelWrapper = doc.getElementById("boxmodel-wrapper");
this.searchField = doc.getElementById("computed-searchbox"); this.searchField = doc.getElementById("computed-searchbox");
this.searchClearButton = doc.getElementById("computed-searchinput-clear"); this.searchClearButton = doc.getElementById("computed-searchinput-clear");
this.includeBrowserStylesCheckbox = doc.getElementById("browser-style-checkbox"); this.includeBrowserStylesCheckbox = doc.getElementById("browser-style-checkbox");
@ -209,7 +201,6 @@ function CssComputedView(inspector, document, pageStyle) {
// The element that we're inspecting, and the document that it comes from. // The element that we're inspecting, and the document that it comes from.
this._viewedElement = null; this._viewedElement = null;
this.createBoxModelView();
this.createStyleViews(); this.createStyleViews();
this._contextmenu = new StyleInspectorMenu(this, { isRuleView: false }); this._contextmenu = new StyleInspectorMenu(this, { isRuleView: false });
@ -577,10 +568,8 @@ CssComputedView.prototype = {
this._filterChangedTimeout = setTimeout(() => { this._filterChangedTimeout = setTimeout(() => {
if (this.searchField.value.length > 0) { if (this.searchField.value.length > 0) {
this.searchField.setAttribute("filled", true); this.searchField.setAttribute("filled", true);
this.boxModelWrapper.hidden = true;
} else { } else {
this.searchField.removeAttribute("filled"); this.searchField.removeAttribute("filled");
this.boxModelWrapper.hidden = false;
} }
this.refreshPanel(); this.refreshPanel();
@ -622,38 +611,6 @@ CssComputedView.prototype = {
CssLogic.FILTER.USER; CssLogic.FILTER.USER;
}, },
/**
* Render the box model view.
*/
createBoxModelView: function() {
let {
setSelectedNode,
onShowBoxModelHighlighterForNode,
} = this.inspector.getCommonComponentProps();
let {
onHideBoxModelHighlighter,
onShowBoxModelEditor,
onShowBoxModelHighlighter,
onToggleGeometryEditor,
} = this.inspector.getPanel("boxmodel").getComponentProps();
let provider = createElement(
Provider,
{ store: this.store },
BoxModelApp({
setSelectedNode,
showBoxModelProperties: false,
onHideBoxModelHighlighter,
onShowBoxModelEditor,
onShowBoxModelHighlighter,
onShowBoxModelHighlighterForNode,
onToggleGeometryEditor,
})
);
ReactDOM.render(provider, this.boxModelWrapper);
},
/** /**
* The CSS as displayed by the UI. * The CSS as displayed by the UI.
*/ */
@ -797,7 +754,6 @@ CssComputedView.prototype = {
// Nodes used in templating // Nodes used in templating
this.element = null; this.element = null;
this.boxModelWrapper = null;
this.searchField = null; this.searchField = null;
this.searchClearButton = null; this.searchClearButton = null;
this.includeBrowserStylesCheckbox = null; this.includeBrowserStylesCheckbox = null;
@ -810,7 +766,6 @@ CssComputedView.prototype = {
this.inspector = null; this.inspector = null;
this.highlighters = null; this.highlighters = null;
this.store = null;
this.styleDocument = null; this.styleDocument = null;
this.styleWindow = null; this.styleWindow = null;

Просмотреть файл

@ -33,8 +33,6 @@ function* testToggleDefaultStyles(inspector, computedView) {
function* testAddTextInFilter(inspector, computedView) { function* testAddTextInFilter(inspector, computedView) {
info("setting filter text to \"color\""); info("setting filter text to \"color\"");
let doc = computedView.styleDocument;
let boxModelWrapper = doc.getElementById("boxmodel-wrapper");
let searchField = computedView.searchField; let searchField = computedView.searchField;
let onRefreshed = inspector.once("computed-view-refreshed"); let onRefreshed = inspector.once("computed-view-refreshed");
let win = computedView.styleWindow; let win = computedView.styleWindow;
@ -53,8 +51,6 @@ function* testAddTextInFilter(inspector, computedView) {
synthesizeKeys("color", win); synthesizeKeys("color", win);
yield onRefreshed; yield onRefreshed;
ok(boxModelWrapper.hidden, "Box model is hidden");
info("check that the correct properties are visible"); info("check that the correct properties are visible");
let propertyViews = computedView.propertyViews; let propertyViews = computedView.propertyViews;

Просмотреть файл

@ -49,8 +49,6 @@ function* testClearSearchFilter(inspector, computedView) {
info("Clearing the search filter"); info("Clearing the search filter");
let win = computedView.styleWindow; let win = computedView.styleWindow;
let doc = computedView.styleDocument;
let boxModelWrapper = doc.getElementById("boxmodel-wrapper");
let propertyViews = computedView.propertyViews; let propertyViews = computedView.propertyViews;
let searchField = computedView.searchField; let searchField = computedView.searchField;
let searchClearButton = computedView.searchClearButton; let searchClearButton = computedView.searchClearButton;
@ -59,8 +57,6 @@ function* testClearSearchFilter(inspector, computedView) {
EventUtils.synthesizeMouseAtCenter(searchClearButton, {}, win); EventUtils.synthesizeMouseAtCenter(searchClearButton, {}, win);
yield onRefreshed; yield onRefreshed;
ok(!boxModelWrapper.hidden, "Box model is displayed");
info("Check that the correct properties are visible"); info("Check that the correct properties are visible");
ok(!searchField.value, "Search filter is cleared"); ok(!searchField.value, "Search filter is cleared");

Просмотреть файл

@ -133,7 +133,6 @@
<div id="computed-container"> <div id="computed-container">
<div id="computed-container-focusable" tabindex="-1"> <div id="computed-container-focusable" tabindex="-1">
<div id="boxmodel-wrapper"></div>
<div id="computed-property-container" class="devtools-monospace" tabindex="0" dir="ltr"></div> <div id="computed-property-container" class="devtools-monospace" tabindex="0" dir="ltr"></div>
<div id="computed-no-results" class="devtools-sidepanel-no-result" hidden="" data-localization="content=inspector.noProperties"></div> <div id="computed-no-results" class="devtools-sidepanel-no-result" hidden="" data-localization="content=inspector.noProperties"></div>
</div> </div>

Просмотреть файл

@ -64,10 +64,10 @@ add_task(function* () {
yield onRuleViewChanged; yield onRuleViewChanged;
yield checkTextBox(inspector.panelDoc.activeElement, toolbox); yield checkTextBox(inspector.panelDoc.activeElement, toolbox);
info("Switching to the computed-view"); info("Switching to the layout-view");
let onComputedViewReady = inspector.once("boxmodel-view-updated"); let onBoxModelUpdated = inspector.once("boxmodel-view-updated");
selectComputedView(inspector); selectLayoutView(inspector);
yield onComputedViewReady; yield onBoxModelUpdated;
info("Testing the box-model region"); info("Testing the box-model region");
let margin = inspector.panelDoc.querySelector( let margin = inspector.panelDoc.querySelector(

Просмотреть файл

@ -53,7 +53,7 @@ var openInspectorSidebarTab = Task.async(function* (id) {
info("Selecting the " + id + " sidebar"); info("Selecting the " + id + " sidebar");
let onSidebarSelect = inspector.sidebar.once("select"); let onSidebarSelect = inspector.sidebar.once("select");
if (id === "computedview" || id === "layoutview") { if (id === "layoutview") {
// The layout and computed views should wait until the box-model widget is ready. // The layout and computed views should wait until the box-model widget is ready.
let onBoxModelViewReady = inspector.once("boxmodel-view-updated"); let onBoxModelViewReady = inspector.once("boxmodel-view-updated");
// The layout view also needs to wait for the grid panel to be fully updated. // The layout view also needs to wait for the grid panel to be fully updated.
@ -169,6 +169,17 @@ function selectComputedView(inspector) {
return inspector.getPanel("computedview").computedView; return inspector.getPanel("computedview").computedView;
} }
/**
* Select the layout view sidebar tab on an already opened inspector panel.
*
* @param {InspectorPanel} inspector
* @return {BoxModel} the box model
*/
function selectLayoutView(inspector) {
inspector.sidebar.select("layoutview");
return inspector.getPanel("boxmodel");
}
/** /**
* Get the NodeFront for a node that matches a given css selector, via the * Get the NodeFront for a node that matches a given css selector, via the
* protocol. * protocol.

Просмотреть файл

@ -556,6 +556,9 @@ outline.header=Outline
# LOCALIZATION NOTE (outline.noFunctions): Outline text when there are no functions to display # LOCALIZATION NOTE (outline.noFunctions): Outline text when there are no functions to display
outline.noFunctions=No functions outline.noFunctions=No functions
# LOCALIZATION NOTE (outline.noFileSelected): Outline text when there are no files selected
outline.noFileSelected=No file selected
# LOCALIZATION NOTE (sources.search): Sources left sidebar prompt # LOCALIZATION NOTE (sources.search): Sources left sidebar prompt
# e.g. Cmd+P to search. On a mac, we use the command unicode character. # e.g. Cmd+P to search. On a mac, we use the command unicode character.
# On windows, it's ctrl. # On windows, it's ctrl.

Просмотреть файл

@ -82,8 +82,6 @@ pref("devtools.gridinspector.showGridAreas", false);
pref("devtools.gridinspector.showGridLineNumbers", false); pref("devtools.gridinspector.showGridLineNumbers", false);
pref("devtools.gridinspector.showInfiniteLines", false); pref("devtools.gridinspector.showInfiniteLines", false);
// Whether or not the box model panel is opened in the computed view
pref("devtools.computed.boxmodel.opened", true);
// Whether or not the box model panel is opened in the layout view // Whether or not the box model panel is opened in the layout view
pref("devtools.layout.boxmodel.opened", true); pref("devtools.layout.boxmodel.opened", true);
// Whether or not the flexbox panel is opened in the layout view // Whether or not the flexbox panel is opened in the layout view

Просмотреть файл

@ -168,7 +168,7 @@ var FunctionCallActor = protocol.ActorClassWithSpec(functionCallSpec, {
if (knownMethod) { if (knownMethod) {
let isOverloaded = typeof knownMethod.enums === "function"; let isOverloaded = typeof knownMethod.enums === "function";
if (isOverloaded) { if (isOverloaded) {
methodSignatureEnums = methodSignatureEnums(args); methodSignatureEnums = knownMethod.enums(args);
} else { } else {
methodSignatureEnums = knownMethod.enums; methodSignatureEnums = knownMethod.enums;
} }

Просмотреть файл

@ -16,14 +16,13 @@ Bug 1067491 - Test recording allocations.
"use strict"; "use strict";
window.onload = function() { window.onload = function() {
let { Task } = require("devtools/shared/task");
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
Task.spawn(function* () { (async function() {
let { memory, client } = yield startServerAndGetSelectedTabMemory(); let { memory, client } = await startServerAndGetSelectedTabMemory();
yield memory.attach(); await memory.attach();
yield memory.startRecordingAllocations(); await memory.startRecordingAllocations();
ok(true, "Can start recording allocations"); ok(true, "Can start recording allocations");
// Allocate some objects. // Allocate some objects.
@ -43,9 +42,9 @@ window.onload = function() {
}()); }());
/* eslint-enable max-nested-callbacks */ /* eslint-enable max-nested-callbacks */
let response = yield memory.getAllocations(); let response = await memory.getAllocations();
yield memory.stopRecordingAllocations(); await memory.stopRecordingAllocations();
ok(true, "Can stop recording allocations"); ok(true, "Can stop recording allocations");
// Filter out allocations by library and test code, and get only the // Filter out allocations by library and test code, and get only the
@ -95,9 +94,9 @@ window.onload = function() {
is(expectedLines.size, 0, is(expectedLines.size, 0,
"Should have found all the expected lines"); "Should have found all the expected lines");
yield memory.detach(); await memory.detach();
destroyServerAndFinish(client); destroyServerAndFinish(client);
}); })();
}; };
</script> </script>
</pre> </pre>

Просмотреть файл

@ -12,7 +12,7 @@
#include "nsContentUtils.h" #include "nsContentUtils.h"
#include "nsDOMClassInfoID.h" #include "nsDOMClassInfoID.h"
#include "nsIDOMDocument.h" #include "nsIDOMDocument.h"
#include "DocumentType.h" #include "mozilla/dom/DocumentType.h"
#include "nsTextNode.h" #include "nsTextNode.h"
namespace mozilla { namespace mozilla {
@ -60,14 +60,14 @@ DOMImplementation::CreateDocumentType(const nsAString& aQualifiedName,
// Indicate that there is no internal subset (not just an empty one) // Indicate that there is no internal subset (not just an empty one)
RefPtr<DocumentType> docType = RefPtr<DocumentType> docType =
NS_NewDOMDocumentType(mOwner->NodeInfoManager(), name, aPublicId, NS_NewDOMDocumentType(mOwner->NodeInfoManager(), name, aPublicId,
aSystemId, VoidString(), aRv); aSystemId, VoidString());
return docType.forget(); return docType.forget();
} }
nsresult nsresult
DOMImplementation::CreateDocument(const nsAString& aNamespaceURI, DOMImplementation::CreateDocument(const nsAString& aNamespaceURI,
const nsAString& aQualifiedName, const nsAString& aQualifiedName,
nsIDOMDocumentType* aDoctype, DocumentType* aDoctype,
nsIDocument** aDocument) nsIDocument** aDocument)
{ {
*aDocument = nullptr; *aDocument = nullptr;
@ -124,7 +124,7 @@ DOMImplementation::CreateDocument(const nsAString& aNamespaceURI,
already_AddRefed<nsIDocument> already_AddRefed<nsIDocument>
DOMImplementation::CreateDocument(const nsAString& aNamespaceURI, DOMImplementation::CreateDocument(const nsAString& aNamespaceURI,
const nsAString& aQualifiedName, const nsAString& aQualifiedName,
nsIDOMDocumentType* aDoctype, DocumentType* aDoctype,
ErrorResult& aRv) ErrorResult& aRv)
{ {
nsCOMPtr<nsIDocument> document; nsCOMPtr<nsIDocument> document;
@ -141,16 +141,13 @@ DOMImplementation::CreateHTMLDocument(const nsAString& aTitle,
NS_ENSURE_STATE(mOwner); NS_ENSURE_STATE(mOwner);
nsCOMPtr<nsIDOMDocumentType> doctype;
// Indicate that there is no internal subset (not just an empty one) // Indicate that there is no internal subset (not just an empty one)
nsresult rv = NS_NewDOMDocumentType(getter_AddRefs(doctype), RefPtr<DocumentType> doctype =
mOwner->NodeInfoManager(), NS_NewDOMDocumentType(mOwner->NodeInfoManager(),
nsGkAtoms::html, // aName nsGkAtoms::html, // aName
EmptyString(), // aPublicId EmptyString(), // aPublicId
EmptyString(), // aSystemId EmptyString(), // aSystemId
VoidString()); // aInternalSubset VoidString()); // aInternalSubset
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIGlobalObject> scriptHandlingObject = nsCOMPtr<nsIGlobalObject> scriptHandlingObject =
do_QueryReferent(mScriptObject); do_QueryReferent(mScriptObject);
@ -158,12 +155,12 @@ DOMImplementation::CreateHTMLDocument(const nsAString& aTitle,
NS_ENSURE_STATE(!mScriptObject || scriptHandlingObject); NS_ENSURE_STATE(!mScriptObject || scriptHandlingObject);
nsCOMPtr<nsIDOMDocument> document; nsCOMPtr<nsIDOMDocument> document;
rv = NS_NewDOMDocument(getter_AddRefs(document), nsresult rv = NS_NewDOMDocument(getter_AddRefs(document),
EmptyString(), EmptyString(), EmptyString(), EmptyString(),
doctype, mDocumentURI, mBaseURI, doctype, mDocumentURI, mBaseURI,
mOwner->NodePrincipal(), mOwner->NodePrincipal(),
true, scriptHandlingObject, true, scriptHandlingObject,
DocumentFlavorLegacyGuess); DocumentFlavorLegacyGuess);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocument> doc = do_QueryInterface(document); nsCOMPtr<nsIDocument> doc = do_QueryInterface(document);

Просмотреть файл

@ -67,7 +67,7 @@ public:
already_AddRefed<nsIDocument> already_AddRefed<nsIDocument>
CreateDocument(const nsAString& aNamespaceURI, CreateDocument(const nsAString& aNamespaceURI,
const nsAString& aQualifiedName, const nsAString& aQualifiedName,
nsIDOMDocumentType* aDoctype, DocumentType* aDoctype,
ErrorResult& aRv); ErrorResult& aRv);
already_AddRefed<nsIDocument> already_AddRefed<nsIDocument>
@ -76,7 +76,7 @@ public:
private: private:
nsresult CreateDocument(const nsAString& aNamespaceURI, nsresult CreateDocument(const nsAString& aNamespaceURI,
const nsAString& aQualifiedName, const nsAString& aQualifiedName,
nsIDOMDocumentType* aDoctype, DocumentType* aDoctype,
nsIDocument** aDocument); nsIDocument** aDocument);
nsresult CreateHTMLDocument(const nsAString& aTitle, nsresult CreateHTMLDocument(const nsAString& aTitle,
nsIDocument** aDocument); nsIDocument** aDocument);

Просмотреть файл

@ -5,7 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* /*
* Implementation of DOM Core's nsIDOMDocumentType node. * Implementation of DOM Core's DocumentType node.
*/ */
#include "mozilla/dom/DocumentType.h" #include "mozilla/dom/DocumentType.h"
@ -18,33 +18,14 @@
#include "nsWrapperCacheInlines.h" #include "nsWrapperCacheInlines.h"
#include "mozilla/dom/DocumentTypeBinding.h" #include "mozilla/dom/DocumentTypeBinding.h"
nsresult
NS_NewDOMDocumentType(nsIDOMDocumentType** aDocType,
nsNodeInfoManager *aNodeInfoManager,
nsAtom *aName,
const nsAString& aPublicId,
const nsAString& aSystemId,
const nsAString& aInternalSubset)
{
NS_ENSURE_ARG_POINTER(aDocType);
mozilla::ErrorResult rv;
*aDocType = NS_NewDOMDocumentType(aNodeInfoManager, aName, aPublicId,
aSystemId, aInternalSubset, rv).take();
return rv.StealNSResult();
}
already_AddRefed<mozilla::dom::DocumentType> already_AddRefed<mozilla::dom::DocumentType>
NS_NewDOMDocumentType(nsNodeInfoManager* aNodeInfoManager, NS_NewDOMDocumentType(nsNodeInfoManager* aNodeInfoManager,
nsAtom *aName, nsAtom *aName,
const nsAString& aPublicId, const nsAString& aPublicId,
const nsAString& aSystemId, const nsAString& aSystemId,
const nsAString& aInternalSubset, const nsAString& aInternalSubset)
mozilla::ErrorResult& rv)
{ {
if (!aName) { MOZ_ASSERT(aName, "Must have a name");
rv.Throw(NS_ERROR_INVALID_POINTER);
return nullptr;
}
already_AddRefed<mozilla::dom::NodeInfo> ni = already_AddRefed<mozilla::dom::NodeInfo> ni =
aNodeInfoManager->GetNodeInfo(nsGkAtoms::documentTypeNodeName, nullptr, aNodeInfoManager->GetNodeInfo(nsGkAtoms::documentTypeNodeName, nullptr,
@ -69,7 +50,7 @@ DocumentType::DocumentType(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
const nsAString& aPublicId, const nsAString& aPublicId,
const nsAString& aSystemId, const nsAString& aSystemId,
const nsAString& aInternalSubset) : const nsAString& aInternalSubset) :
DocumentTypeForward(aNodeInfo), nsGenericDOMDataNode(aNodeInfo),
mPublicId(aPublicId), mPublicId(aPublicId),
mSystemId(aSystemId), mSystemId(aSystemId),
mInternalSubset(aInternalSubset) mInternalSubset(aInternalSubset)
@ -82,8 +63,7 @@ DocumentType::~DocumentType()
{ {
} }
NS_IMPL_ISUPPORTS_INHERITED(DocumentType, nsGenericDOMDataNode, nsIDOMNode, NS_IMPL_ISUPPORTS_INHERITED(DocumentType, nsGenericDOMDataNode, nsIDOMNode)
nsIDOMDocumentType)
bool bool
DocumentType::IsNodeOfType(uint32_t aFlags) const DocumentType::IsNodeOfType(uint32_t aFlags) const
@ -101,34 +81,28 @@ DocumentType::GetText()
return nullptr; return nullptr;
} }
NS_IMETHODIMP void
DocumentType::GetName(nsAString& aName) DocumentType::GetName(nsAString& aName) const
{ {
aName = NodeName(); aName = NodeName();
return NS_OK;
} }
NS_IMETHODIMP void
DocumentType::GetPublicId(nsAString& aPublicId) DocumentType::GetPublicId(nsAString& aPublicId) const
{ {
aPublicId = mPublicId; aPublicId = mPublicId;
return NS_OK;
} }
NS_IMETHODIMP void
DocumentType::GetSystemId(nsAString& aSystemId) DocumentType::GetSystemId(nsAString& aSystemId) const
{ {
aSystemId = mSystemId; aSystemId = mSystemId;
return NS_OK;
} }
NS_IMETHODIMP void
DocumentType::GetInternalSubset(nsAString& aInternalSubset) DocumentType::GetInternalSubset(nsAString& aInternalSubset) const
{ {
aInternalSubset = mInternalSubset; aInternalSubset = mInternalSubset;
return NS_OK;
} }
nsGenericDOMDataNode* nsGenericDOMDataNode*

Просмотреть файл

@ -5,7 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* /*
* Implementation of DOM Core's nsIDOMDocumentType node. * Implementation of DOM Core's DocumentType node.
*/ */
#ifndef DocumentType_h #ifndef DocumentType_h
@ -13,7 +13,7 @@
#include "mozilla/Attributes.h" #include "mozilla/Attributes.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsIDOMDocumentType.h" #include "nsIDOMNode.h"
#include "nsIContent.h" #include "nsIContent.h"
#include "nsGenericDOMDataNode.h" #include "nsGenericDOMDataNode.h"
#include "nsString.h" #include "nsString.h"
@ -26,17 +26,8 @@ namespace dom {
// data. This is done simply for convenience and should be changed if // data. This is done simply for convenience and should be changed if
// this restricts what should be done for character data. // this restricts what should be done for character data.
class DocumentTypeForward : public nsGenericDOMDataNode, class DocumentType final : public nsGenericDOMDataNode,
public nsIDOMDocumentType public nsIDOMNode
{
public:
explicit DocumentTypeForward(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
: nsGenericDOMDataNode(aNodeInfo)
{
}
};
class DocumentType final : public DocumentTypeForward
{ {
public: public:
DocumentType(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo, DocumentType(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
@ -50,9 +41,6 @@ public:
// nsIDOMNode // nsIDOMNode
// Forwarded by base class // Forwarded by base class
// nsIDOMDocumentType
NS_DECL_NSIDOMDOCUMENTTYPE
// nsINode // nsINode
virtual bool IsNodeOfType(uint32_t aFlags) const override; virtual bool IsNodeOfType(uint32_t aFlags) const override;
virtual void GetNodeValueInternal(nsAString& aNodeValue) override virtual void GetNodeValueInternal(nsAString& aNodeValue) override
@ -72,6 +60,12 @@ public:
virtual nsIDOMNode* AsDOMNode() override { return this; } virtual nsIDOMNode* AsDOMNode() override { return this; }
// WebIDL API
void GetName(nsAString& aName) const;
void GetPublicId(nsAString& aPublicId) const;
void GetSystemId(nsAString& aSystemId) const;
void GetInternalSubset(nsAString& aInternalSubset) const;
protected: protected:
virtual ~DocumentType(); virtual ~DocumentType();
@ -87,15 +81,6 @@ protected:
already_AddRefed<mozilla::dom::DocumentType> already_AddRefed<mozilla::dom::DocumentType>
NS_NewDOMDocumentType(nsNodeInfoManager* aNodeInfoManager, NS_NewDOMDocumentType(nsNodeInfoManager* aNodeInfoManager,
nsAtom *aName,
const nsAString& aPublicId,
const nsAString& aSystemId,
const nsAString& aInternalSubset,
mozilla::ErrorResult& rv);
nsresult
NS_NewDOMDocumentType(nsIDOMDocumentType** aDocType,
nsNodeInfoManager* aNodeInfoManager,
nsAtom *aName, nsAtom *aName,
const nsAString& aPublicId, const nsAString& aPublicId,
const nsAString& aSystemId, const nsAString& aSystemId,

Просмотреть файл

@ -106,7 +106,6 @@
#include "nsNodeInfoManager.h" #include "nsNodeInfoManager.h"
#include "nsICategoryManager.h" #include "nsICategoryManager.h"
#include "nsIDOMDocumentType.h"
#include "nsGenericHTMLElement.h" #include "nsGenericHTMLElement.h"
#include "nsContentCreatorFunctions.h" #include "nsContentCreatorFunctions.h"
#include "nsIControllers.h" #include "nsIControllers.h"

Просмотреть файл

@ -132,7 +132,6 @@
#include "nsIDocumentEncoder.h" #include "nsIDocumentEncoder.h"
#include "nsIDOMChromeWindow.h" #include "nsIDOMChromeWindow.h"
#include "nsIDOMDocument.h" #include "nsIDOMDocument.h"
#include "nsIDOMDocumentType.h"
#include "nsIDOMElement.h" #include "nsIDOMElement.h"
#include "nsIDOMNode.h" #include "nsIDOMNode.h"
#include "nsIDOMNodeList.h" #include "nsIDOMNodeList.h"
@ -6034,15 +6033,9 @@ nsContentUtils::SetDataTransferInEvent(WidgetDragEvent* aDragEvent)
nsCOMPtr<nsIDragSession> dragSession = GetDragSession(); nsCOMPtr<nsIDragSession> dragSession = GetDragSession();
NS_ENSURE_TRUE(dragSession, NS_OK); // no drag in progress NS_ENSURE_TRUE(dragSession, NS_OK); // no drag in progress
nsCOMPtr<nsIDOMDataTransfer> dataTransfer; RefPtr<DataTransfer> initialDataTransfer =
nsCOMPtr<DataTransfer> initialDataTransfer; dragSession->GetDataTransfer();
dragSession->GetDataTransfer(getter_AddRefs(dataTransfer)); if (!initialDataTransfer) {
if (dataTransfer) {
initialDataTransfer = do_QueryInterface(dataTransfer);
if (!initialDataTransfer) {
return NS_ERROR_FAILURE;
}
} else {
// A dataTransfer won't exist when a drag was started by some other // A dataTransfer won't exist when a drag was started by some other
// means, for instance calling the drag service directly, or a drag // means, for instance calling the drag service directly, or a drag
// from another application. In either case, a new dataTransfer should // from another application. In either case, a new dataTransfer should
@ -6072,9 +6065,9 @@ nsContentUtils::SetDataTransferInEvent(WidgetDragEvent* aDragEvent)
// from the drop action, which platform specific widget code sets before // from the drop action, which platform specific widget code sets before
// the event is fired based on the keyboard state. // the event is fired based on the keyboard state.
if (aDragEvent->mMessage == eDragEnter || aDragEvent->mMessage == eDragOver) { if (aDragEvent->mMessage == eDragEnter || aDragEvent->mMessage == eDragOver) {
uint32_t action, effectAllowed; uint32_t action;
dragSession->GetDragAction(&action); dragSession->GetDragAction(&action);
aDragEvent->mDataTransfer->GetEffectAllowedInt(&effectAllowed); uint32_t effectAllowed = aDragEvent->mDataTransfer->EffectAllowedInt();
aDragEvent->mDataTransfer->SetDropEffectInt( aDragEvent->mDataTransfer->SetDropEffectInt(
FilterDropEffect(action, effectAllowed)); FilterDropEffect(action, effectAllowed));
} }
@ -6084,9 +6077,8 @@ nsContentUtils::SetDataTransferInEvent(WidgetDragEvent* aDragEvent)
// last value that the dropEffect had. This will have been set in // last value that the dropEffect had. This will have been set in
// EventStateManager::PostHandleEvent for the last dragenter or // EventStateManager::PostHandleEvent for the last dragenter or
// dragover event. // dragover event.
uint32_t dropEffect; aDragEvent->mDataTransfer->SetDropEffectInt(
initialDataTransfer->GetDropEffectInt(&dropEffect); initialDataTransfer->DropEffectInt());
aDragEvent->mDataTransfer->SetDropEffectInt(dropEffect);
} }
return NS_OK; return NS_OK;

Просмотреть файл

@ -919,7 +919,7 @@ nsCopySupport::FireClipboardEvent(EventMessage aEventMessage,
} }
} else if (clipboardData) { } else if (clipboardData) {
// check to see if any data was put on the data transfer. // check to see if any data was put on the data transfer.
clipboardData->GetMozItemCount(&count); count = clipboardData->MozItemCount();
if (count) { if (count) {
nsCOMPtr<nsIClipboard> clipboard(do_GetService("@mozilla.org/widget/clipboard;1")); nsCOMPtr<nsIClipboard> clipboard(do_GetService("@mozilla.org/widget/clipboard;1"));
NS_ENSURE_TRUE(clipboard, false); NS_ENSURE_TRUE(clipboard, false);

Просмотреть файл

@ -7389,18 +7389,16 @@ nsDocument::GetViewportInfo(const ScreenIntSize& aDisplaySize)
RefPtr<DocumentType> docType = GetDoctype(); RefPtr<DocumentType> docType = GetDoctype();
if (docType) { if (docType) {
nsAutoString docId; nsAutoString docId;
nsresult rv = docType->GetPublicId(docId); docType->GetPublicId(docId);
if (NS_SUCCEEDED(rv)) { if ((docId.Find("WAP") != -1) ||
if ((docId.Find("WAP") != -1) || (docId.Find("Mobile") != -1) ||
(docId.Find("Mobile") != -1) || (docId.Find("WML") != -1))
(docId.Find("WML") != -1)) {
{ // We're making an assumption that the docType can't change here
// We're making an assumption that the docType can't change here mViewportType = DisplayWidthHeight;
mViewportType = DisplayWidthHeight; return nsViewportInfo(aDisplaySize,
return nsViewportInfo(aDisplaySize, defaultScale,
defaultScale, /*allowZoom*/true);
/*allowZoom*/true);
}
} }
} }

Просмотреть файл

@ -24,7 +24,6 @@
#include "nsIDOMText.h" #include "nsIDOMText.h"
#include "nsIDOMComment.h" #include "nsIDOMComment.h"
#include "nsIDOMProcessingInstruction.h" #include "nsIDOMProcessingInstruction.h"
#include "nsIDOMDocumentType.h"
#include "nsIDOMNodeList.h" #include "nsIDOMNodeList.h"
#include "nsRange.h" #include "nsRange.h"
#include "nsIDOMRange.h" #include "nsIDOMRange.h"
@ -45,6 +44,7 @@
#include "nsTArray.h" #include "nsTArray.h"
#include "nsIFrame.h" #include "nsIFrame.h"
#include "nsStringBuffer.h" #include "nsStringBuffer.h"
#include "mozilla/dom/DocumentType.h"
#include "mozilla/dom/Element.h" #include "mozilla/dom/Element.h"
#include "mozilla/dom/ShadowRoot.h" #include "mozilla/dom/ShadowRoot.h"
#include "nsLayoutUtils.h" #include "nsLayoutUtils.h"
@ -430,7 +430,7 @@ nsDocumentEncoder::SerializeNodeStart(nsINode* aNode,
} }
case nsINode::DOCUMENT_TYPE_NODE: case nsINode::DOCUMENT_TYPE_NODE:
{ {
mSerializer->AppendDoctype(static_cast<nsIContent*>(node), aStr); mSerializer->AppendDoctype(static_cast<DocumentType*>(node), aStr);
break; break;
} }
} }

Просмотреть файл

@ -2033,7 +2033,7 @@ nsFrameLoader::ShouldUseRemoteProcess()
// If we're an <iframe mozbrowser> and we don't have a "remote" attribute, // If we're an <iframe mozbrowser> and we don't have a "remote" attribute,
// fall back to the default. // fall back to the default.
if (OwnerIsMozBrowserFrame() && if (OwnerIsMozBrowserFrame() &&
!mOwnerContent->HasAttr(kNameSpaceID_None, nsGkAtoms::Remote)) { !mOwnerContent->HasAttr(kNameSpaceID_None, nsGkAtoms::remote)) {
return Preferences::GetBool("dom.ipc.browser_frames.oop_by_default", false); return Preferences::GetBool("dom.ipc.browser_frames.oop_by_default", false);
} }
@ -2043,7 +2043,7 @@ nsFrameLoader::ShouldUseRemoteProcess()
return (OwnerIsMozBrowserFrame() || return (OwnerIsMozBrowserFrame() ||
mOwnerContent->GetNameSpaceID() == kNameSpaceID_XUL) && mOwnerContent->GetNameSpaceID() == kNameSpaceID_XUL) &&
mOwnerContent->AttrValueIs(kNameSpaceID_None, mOwnerContent->AttrValueIs(kNameSpaceID_None,
nsGkAtoms::Remote, nsGkAtoms::remote,
nsGkAtoms::_true, nsGkAtoms::_true,
eCaseMatters); eCaseMatters);
} }

Просмотреть файл

@ -5,7 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* /*
* Base class for DOM Core's nsIDOMComment, nsIDOMDocumentType, nsIDOMText, * Base class for DOM Core's nsIDOMComment, DocumentType, nsIDOMText,
* CDATASection and nsIDOMProcessingInstruction nodes. * CDATASection and nsIDOMProcessingInstruction nodes.
*/ */

Просмотреть файл

@ -5,7 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* /*
* Base class for DOM Core's nsIDOMComment, nsIDOMDocumentType, nsIDOMText, * Base class for DOM Core's nsIDOMComment, DocumentType, nsIDOMText,
* CDATASection, and nsIDOMProcessingInstruction nodes. * CDATASection, and nsIDOMProcessingInstruction nodes.
*/ */

Просмотреть файл

@ -640,7 +640,7 @@ GK_ATOM(level, "level")
GK_ATOM(li, "li") GK_ATOM(li, "li")
GK_ATOM(line, "line") GK_ATOM(line, "line")
GK_ATOM(link, "link") GK_ATOM(link, "link")
GK_ATOM(list, "list") //GK_ATOM(list, "list") # "list" is present below
GK_ATOM(listbox, "listbox") GK_ATOM(listbox, "listbox")
GK_ATOM(listboxbody, "listboxbody") GK_ATOM(listboxbody, "listboxbody")
GK_ATOM(listcell, "listcell") GK_ATOM(listcell, "listcell")
@ -714,7 +714,7 @@ GK_ATOM(minlength, "minlength")
GK_ATOM(minpos, "minpos") GK_ATOM(minpos, "minpos")
GK_ATOM(minusSign, "minus-sign") GK_ATOM(minusSign, "minus-sign")
GK_ATOM(minwidth, "minwidth") GK_ATOM(minwidth, "minwidth")
GK_ATOM(_mixed, "mixed") GK_ATOM(mixed, "mixed")
GK_ATOM(messagemanagergroup, "messagemanagergroup") GK_ATOM(messagemanagergroup, "messagemanagergroup")
GK_ATOM(mod, "mod") GK_ATOM(mod, "mod")
GK_ATOM(mode, "mode") GK_ATOM(mode, "mode")
@ -1319,7 +1319,7 @@ GK_ATOM(sub, "sub")
GK_ATOM(sum, "sum") GK_ATOM(sum, "sum")
GK_ATOM(sup, "sup") GK_ATOM(sup, "sup")
GK_ATOM(summary, "summary") GK_ATOM(summary, "summary")
GK_ATOM(_switch, "switch") //GK_ATOM(_switch, "switch") # "switch" is present below
GK_ATOM(systemProperty, "system-property") GK_ATOM(systemProperty, "system-property")
GK_ATOM(tab, "tab") GK_ATOM(tab, "tab")
GK_ATOM(tabbox, "tabbox") GK_ATOM(tabbox, "tabbox")
@ -1669,7 +1669,7 @@ GK_ATOM(rx, "rx")
GK_ATOM(ry, "ry") GK_ATOM(ry, "ry")
GK_ATOM(saturate, "saturate") GK_ATOM(saturate, "saturate")
GK_ATOM(saturation, "saturation") GK_ATOM(saturation, "saturation")
GK_ATOM(set, "set") //GK_ATOM(set, "set") # "set" is present below
GK_ATOM(seed, "seed") GK_ATOM(seed, "seed")
GK_ATOM(shape_rendering, "shape-rendering") GK_ATOM(shape_rendering, "shape-rendering")
GK_ATOM(skewX, "skewX") GK_ATOM(skewX, "skewX")
@ -1837,7 +1837,7 @@ GK_ATOM(divide_, "divide")
GK_ATOM(domain_, "domain") GK_ATOM(domain_, "domain")
GK_ATOM(domainofapplication_, "domainofapplication") GK_ATOM(domainofapplication_, "domainofapplication")
GK_ATOM(edge_, "edge") GK_ATOM(edge_, "edge")
GK_ATOM(el_, "el") GK_ATOM(el, "el")
GK_ATOM(emptyset_, "emptyset") GK_ATOM(emptyset_, "emptyset")
GK_ATOM(eq_, "eq") GK_ATOM(eq_, "eq")
GK_ATOM(equalcolumns_, "equalcolumns") GK_ATOM(equalcolumns_, "equalcolumns")
@ -1958,7 +1958,7 @@ GK_ATOM(notin_, "notin")
GK_ATOM(notprsubset_, "notprsubset") GK_ATOM(notprsubset_, "notprsubset")
GK_ATOM(notsubset_, "notsubset") GK_ATOM(notsubset_, "notsubset")
GK_ATOM(numalign_, "numalign") GK_ATOM(numalign_, "numalign")
GK_ATOM(other_, "other") GK_ATOM(other, "other")
GK_ATOM(outerproduct_, "outerproduct") GK_ATOM(outerproduct_, "outerproduct")
GK_ATOM(partialdiff_, "partialdiff") GK_ATOM(partialdiff_, "partialdiff")
GK_ATOM(piece_, "piece") GK_ATOM(piece_, "piece")
@ -2232,7 +2232,7 @@ GK_ATOM(x_tibt, "x-tibt")
GK_ATOM(az, "az") GK_ATOM(az, "az")
GK_ATOM(ba, "ba") GK_ATOM(ba, "ba")
GK_ATOM(crh, "crh") GK_ATOM(crh, "crh")
GK_ATOM(el, "el") //GK_ATOM(el, "el") # "el" is present above
GK_ATOM(ga, "ga") GK_ATOM(ga, "ga")
GK_ATOM(nl, "nl") GK_ATOM(nl, "nl")
@ -2253,7 +2253,7 @@ GK_ATOM(monospace, "monospace")
GK_ATOM(mozfixed, "-moz-fixed") GK_ATOM(mozfixed, "-moz-fixed")
// IPC stuff // IPC stuff
GK_ATOM(Remote, "remote") //GK_ATOM(Remote, "remote") # "remote" is present above
GK_ATOM(RemoteId, "_remote_id") GK_ATOM(RemoteId, "_remote_id")
GK_ATOM(RemoteType, "remoteType") GK_ATOM(RemoteType, "remoteType")
GK_ATOM(DisplayPort, "_displayport") GK_ATOM(DisplayPort, "_displayport")
@ -2371,7 +2371,7 @@ GK_ATOM(pixels, "pixels")
GK_ATOM(lines, "lines") GK_ATOM(lines, "lines")
GK_ATOM(pages, "pages") GK_ATOM(pages, "pages")
GK_ATOM(scrollbars, "scrollbars") GK_ATOM(scrollbars, "scrollbars")
GK_ATOM(other, "other") //GK_ATOM(other, "other") # "other" is present above
// Scroll origins without smooth-scrolling prefs // Scroll origins without smooth-scrolling prefs
GK_ATOM(apz, "apz") GK_ATOM(apz, "apz")
GK_ATOM(restore, "restore") GK_ATOM(restore, "restore")
@ -2420,7 +2420,7 @@ GK_ATOM(linkedPanel, "linkedpanel")
GK_ATOM(live, "live") GK_ATOM(live, "live")
GK_ATOM(menuitemcheckbox, "menuitemcheckbox") GK_ATOM(menuitemcheckbox, "menuitemcheckbox")
GK_ATOM(menuitemradio, "menuitemradio") GK_ATOM(menuitemradio, "menuitemradio")
GK_ATOM(mixed, "mixed") //GK_ATOM(mixed, "mixed") # "mixed" is present above
GK_ATOM(multiline, "multiline") GK_ATOM(multiline, "multiline")
GK_ATOM(navigation, "navigation") GK_ATOM(navigation, "navigation")
GK_ATOM(polite, "polite") GK_ATOM(polite, "polite")
@ -2508,6 +2508,21 @@ GK_ATOM(onupdateend, "onupdateend")
GK_ATOM(onaddsourcebuffer, "onaddsourcebuffer") GK_ATOM(onaddsourcebuffer, "onaddsourcebuffer")
GK_ATOM(onremovesourcebuffer, "onremovesourcebuffer") GK_ATOM(onremovesourcebuffer, "onremovesourcebuffer")
// RDF
GK_ATOM(about, "about")
GK_ATOM(ID, "ID")
GK_ATOM(nodeID, "nodeID")
GK_ATOM(aboutEach, "aboutEach")
GK_ATOM(resource, "resource")
GK_ATOM(RDF, "RDF")
GK_ATOM(Description, "Description")
GK_ATOM(Bag, "Bag")
GK_ATOM(Seq, "Seq")
GK_ATOM(Alt, "Alt")
//GK_ATOM(kLiAtom, "li") # "li" is present above
//GK_ATOM(kXMLNSAtom, "xmlns") # "xmlns" is present above
GK_ATOM(parseType, "parseType")
// THE REST OF THE FILE IS GENERATED BY THE HTML PARSER TRANSLATOR AND // THE REST OF THE FILE IS GENERATED BY THE HTML PARSER TRANSLATOR AND
// WILL BE OVERWRITTEN! // WILL BE OVERWRITTEN!
// Please put manually-added atoms above this section and please avoid #ifdefing // Please put manually-added atoms above this section and please avoid #ifdefing

Просмотреть файл

@ -16,6 +16,7 @@ class nsIDocument;
namespace mozilla { namespace mozilla {
class Encoding; class Encoding;
namespace dom { namespace dom {
class DocumentType;
class Element; class Element;
} // namespace dom } // namespace dom
} // namespace mozilla } // namespace mozilla
@ -51,7 +52,7 @@ class nsIContentSerializer : public nsISupports {
NS_IMETHOD AppendComment(nsIContent* aComment, int32_t aStartOffset, NS_IMETHOD AppendComment(nsIContent* aComment, int32_t aStartOffset,
int32_t aEndOffset, nsAString& aStr) = 0; int32_t aEndOffset, nsAString& aStr) = 0;
NS_IMETHOD AppendDoctype(nsIContent *aDoctype, NS_IMETHOD AppendDoctype(mozilla::dom::DocumentType* aDoctype,
nsAString& aStr) = 0; nsAString& aStr) = 0;
NS_IMETHOD AppendElementStart(mozilla::dom::Element* aElement, NS_IMETHOD AppendElementStart(mozilla::dom::Element* aElement,

Просмотреть файл

@ -95,7 +95,6 @@ class nsIDocShellTreeItem;
class nsIDocumentEncoder; class nsIDocumentEncoder;
class nsIDocumentObserver; class nsIDocumentObserver;
class nsIDOMDocument; class nsIDOMDocument;
class nsIDOMDocumentType;
class nsIDOMElement; class nsIDOMElement;
class nsIDOMNodeList; class nsIDOMNodeList;
class nsIHTMLCollection; class nsIHTMLCollection;
@ -4587,7 +4586,7 @@ nsresult
NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult, NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult,
const nsAString& aNamespaceURI, const nsAString& aNamespaceURI,
const nsAString& aQualifiedName, const nsAString& aQualifiedName,
nsIDOMDocumentType* aDoctype, mozilla::dom::DocumentType* aDoctype,
nsIURI* aDocumentURI, nsIURI* aDocumentURI,
nsIURI* aBaseURI, nsIURI* aBaseURI,
nsIPrincipal* aPrincipal, nsIPrincipal* aPrincipal,

Просмотреть файл

@ -5,7 +5,6 @@
#include "nsISupports.idl" #include "nsISupports.idl"
#include "nsIPrincipal.idl" #include "nsIPrincipal.idl"
interface nsIDOMDataTransfer;
interface nsIDOMDragEvent; interface nsIDOMDragEvent;
[scriptable, uuid(69E14F91-2E09-4CA6-A511-A715C99A2804)] [scriptable, uuid(69E14F91-2E09-4CA6-A511-A715C99A2804)]
@ -95,8 +94,10 @@ interface nsIDroppedLinkHandler : nsISupports
* dragged. Since drag/drop performs a roundtrip of parent, child, parent, * dragged. Since drag/drop performs a roundtrip of parent, child, parent,
* it allows the parent to verify that the child did not modify links * it allows the parent to verify that the child did not modify links
* being dropped. * being dropped.
*
* @param dataTransfer is a DataTransfer. See bug 1444991.
*/ */
void queryLinks(in nsIDOMDataTransfer aDataTransfer, void queryLinks(in nsISupports aDataTransfer,
[optional] out unsigned long aCount, [optional] out unsigned long aCount,
[retval, array, size_is(aCount)] out nsIDroppedLinkItem aLinks); [retval, array, size_is(aCount)] out nsIDroppedLinkItem aLinks);

Просмотреть файл

@ -28,6 +28,7 @@
#ifdef MOZ_OLD_STYLE #ifdef MOZ_OLD_STYLE
#include "mozilla/css/StyleRule.h" #include "mozilla/css/StyleRule.h"
#endif #endif
#include "mozilla/dom/DocumentType.h"
#include "mozilla/dom/Element.h" #include "mozilla/dom/Element.h"
#include "mozilla/dom/Event.h" #include "mozilla/dom/Event.h"
#include "mozilla/dom/L10nUtilsBinding.h" #include "mozilla/dom/L10nUtilsBinding.h"
@ -62,7 +63,6 @@
#include "nsIControllers.h" #include "nsIControllers.h"
#include "nsIDocument.h" #include "nsIDocument.h"
#include "nsIDOMDocument.h" #include "nsIDOMDocument.h"
#include "nsIDOMDocumentType.h"
#include "nsIDOMEvent.h" #include "nsIDOMEvent.h"
#include "nsIDOMEventListener.h" #include "nsIDOMEventListener.h"
#include "nsIDOMNodeList.h" #include "nsIDOMNodeList.h"
@ -106,7 +106,6 @@
#include "HTMLLegendElement.h" #include "HTMLLegendElement.h"
#include "nsWrapperCacheInlines.h" #include "nsWrapperCacheInlines.h"
#include "WrapperFactory.h" #include "WrapperFactory.h"
#include "DocumentType.h"
#include <algorithm> #include <algorithm>
#include "nsGlobalWindow.h" #include "nsGlobalWindow.h"
#include "nsDOMMutationObserver.h" #include "nsDOMMutationObserver.h"
@ -1048,10 +1047,8 @@ nsINode::IsEqualNode(nsINode* aOther)
} }
case DOCUMENT_TYPE_NODE: case DOCUMENT_TYPE_NODE:
{ {
nsCOMPtr<nsIDOMDocumentType> docType1 = do_QueryInterface(node1); DocumentType* docType1 = static_cast<DocumentType*>(node1);
nsCOMPtr<nsIDOMDocumentType> docType2 = do_QueryInterface(node2); DocumentType* docType2 = static_cast<DocumentType*>(node2);
NS_ASSERTION(docType1 && docType2, "Why don't we have a document type node?");
// Public ID // Public ID
docType1->GetPublicId(string1); docType1->GetPublicId(string1);

Просмотреть файл

@ -418,7 +418,9 @@ public:
/** animation elements */ /** animation elements */
eANIMATION = 1 << 10, eANIMATION = 1 << 10,
/** filter elements that implement SVGFilterPrimitiveStandardAttributes */ /** filter elements that implement SVGFilterPrimitiveStandardAttributes */
eFILTER = 1 << 11 eFILTER = 1 << 11,
/** SVGGeometryElement */
eSHAPE = 1 << 12
}; };
/** /**

Просмотреть файл

@ -21,7 +21,6 @@
class nsBindingManager; class nsBindingManager;
class nsAtom; class nsAtom;
class nsIDocument; class nsIDocument;
class nsIDOMDocumentType;
class nsIPrincipal; class nsIPrincipal;
class nsWindowSizes; class nsWindowSizes;
struct PLHashEntry; struct PLHashEntry;
@ -137,12 +136,6 @@ public:
protected: protected:
friend class nsIDocument; friend class nsIDocument;
friend class nsXULPrototypeDocument; friend class nsXULPrototypeDocument;
friend nsresult NS_NewDOMDocumentType(nsIDOMDocumentType** ,
nsNodeInfoManager *,
nsAtom *,
const nsAString& ,
const nsAString& ,
const nsAString& );
/** /**
* Sets the principal of the document this nodeinfo manager belongs to. * Sets the principal of the document this nodeinfo manager belongs to.

Просмотреть файл

@ -29,6 +29,7 @@ class nsIContent;
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
class DocumentType;
class Element; class Element;
} // namespace dom } // namespace dom
} // namespace mozilla } // namespace mozilla
@ -60,7 +61,7 @@ public:
nsAString& aStr) override { return NS_OK; } nsAString& aStr) override { return NS_OK; }
NS_IMETHOD AppendComment(nsIContent* aComment, int32_t aStartOffset, NS_IMETHOD AppendComment(nsIContent* aComment, int32_t aStartOffset,
int32_t aEndOffset, nsAString& aStr) override { return NS_OK; } int32_t aEndOffset, nsAString& aStr) override { return NS_OK; }
NS_IMETHOD AppendDoctype(nsIContent *aDoctype, NS_IMETHOD AppendDoctype(mozilla::dom::DocumentType* aDoctype,
nsAString& aStr) override { return NS_OK; } nsAString& aStr) override { return NS_OK; }
NS_IMETHOD AppendElementStart(mozilla::dom::Element* aElement, NS_IMETHOD AppendElementStart(mozilla::dom::Element* aElement,
mozilla::dom::Element* aOriginalElement, mozilla::dom::Element* aOriginalElement,

Просмотреть файл

@ -205,7 +205,7 @@ nsStaticAtom** const kAttributesHTML[] = {
&nsGkAtoms::kind, &nsGkAtoms::kind,
&nsGkAtoms::label, &nsGkAtoms::label,
&nsGkAtoms::lang, &nsGkAtoms::lang,
&nsGkAtoms::list, &nsGkAtoms::list_,
&nsGkAtoms::longdesc, &nsGkAtoms::longdesc,
&nsGkAtoms::loop, &nsGkAtoms::loop,
&nsGkAtoms::low, &nsGkAtoms::low,
@ -659,7 +659,7 @@ nsStaticAtom** const kElementsMathML[] = {
&nsGkAtoms::divide_, // divide &nsGkAtoms::divide_, // divide
&nsGkAtoms::domain_, // domain &nsGkAtoms::domain_, // domain
&nsGkAtoms::domainofapplication_, // domainofapplication &nsGkAtoms::domainofapplication_, // domainofapplication
&nsGkAtoms::el_, // el &nsGkAtoms::el, // el
&nsGkAtoms::emptyset_, // emptyset &nsGkAtoms::emptyset_, // emptyset
&nsGkAtoms::eq_, // eq &nsGkAtoms::eq_, // eq
&nsGkAtoms::equivalent_, // equivalent &nsGkAtoms::equivalent_, // equivalent
@ -892,7 +892,7 @@ nsStaticAtom** const kAttributesMathML[] = {
&nsGkAtoms::number, // number &nsGkAtoms::number, // number
&nsGkAtoms::open, // open &nsGkAtoms::open, // open
&nsGkAtoms::order, // order &nsGkAtoms::order, // order
&nsGkAtoms::other_, // other &nsGkAtoms::other, // other
&nsGkAtoms::overflow, // overflow &nsGkAtoms::overflow, // overflow
&nsGkAtoms::position, // position &nsGkAtoms::position, // position
&nsGkAtoms::role, // role &nsGkAtoms::role, // role

Просмотреть файл

@ -15,7 +15,6 @@
#include "nsGkAtoms.h" #include "nsGkAtoms.h"
#include "nsIDOMProcessingInstruction.h" #include "nsIDOMProcessingInstruction.h"
#include "nsIDOMComment.h" #include "nsIDOMComment.h"
#include "nsIDOMDocumentType.h"
#include "nsIContent.h" #include "nsIContent.h"
#include "nsIContentInlines.h" #include "nsIContentInlines.h"
#include "nsIDocument.h" #include "nsIDocument.h"
@ -29,6 +28,7 @@
#include "nsCRT.h" #include "nsCRT.h"
#include "nsContentUtils.h" #include "nsContentUtils.h"
#include "nsAttrName.h" #include "nsAttrName.h"
#include "mozilla/dom/DocumentType.h"
#include "mozilla/dom/Element.h" #include "mozilla/dom/Element.h"
#include "mozilla/intl/LineBreaker.h" #include "mozilla/intl/LineBreaker.h"
#include "nsParserConstants.h" #include "nsParserConstants.h"
@ -360,20 +360,13 @@ nsXMLContentSerializer::AppendComment(nsIContent* aComment,
} }
NS_IMETHODIMP NS_IMETHODIMP
nsXMLContentSerializer::AppendDoctype(nsIContent* aDocType, nsXMLContentSerializer::AppendDoctype(DocumentType* aDocType,
nsAString& aStr) nsAString& aStr)
{ {
nsCOMPtr<nsIDOMDocumentType> docType = do_QueryInterface(aDocType);
NS_ENSURE_ARG(docType);
nsresult rv;
nsAutoString name, publicId, systemId; nsAutoString name, publicId, systemId;
aDocType->GetName(name);
rv = docType->GetName(name); aDocType->GetPublicId(publicId);
if (NS_FAILED(rv)) return NS_ERROR_FAILURE; aDocType->GetSystemId(systemId);
rv = docType->GetPublicId(publicId);
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
rv = docType->GetSystemId(systemId);
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
NS_ENSURE_TRUE(MaybeAddNewlineForRootNode(aStr), NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(MaybeAddNewlineForRootNode(aStr), NS_ERROR_OUT_OF_MEMORY);

Просмотреть файл

@ -58,7 +58,7 @@ class nsXMLContentSerializer : public nsIContentSerializer {
NS_IMETHOD AppendComment(nsIContent* aComment, int32_t aStartOffset, NS_IMETHOD AppendComment(nsIContent* aComment, int32_t aStartOffset,
int32_t aEndOffset, nsAString& aStr) override; int32_t aEndOffset, nsAString& aStr) override;
NS_IMETHOD AppendDoctype(nsIContent *aDoctype, NS_IMETHOD AppendDoctype(mozilla::dom::DocumentType* aDoctype,
nsAString& aStr) override; nsAString& aStr) override;
NS_IMETHOD AppendElementStart(mozilla::dom::Element* aElement, NS_IMETHOD AppendElementStart(mozilla::dom::Element* aElement,

Просмотреть файл

@ -12,6 +12,7 @@
#include "mozilla/dom/StructuredCloneHolder.h" #include "mozilla/dom/StructuredCloneHolder.h"
#include "mozilla/dom/ipc/StructuredCloneData.h" #include "mozilla/dom/ipc/StructuredCloneData.h"
#include "mozilla/dom/WorkerPrivate.h" #include "mozilla/dom/WorkerPrivate.h"
#include "mozilla/dom/WorkerRef.h"
#include "mozilla/dom/WorkerRunnable.h" #include "mozilla/dom/WorkerRunnable.h"
#include "mozilla/ipc/BackgroundChild.h" #include "mozilla/ipc/BackgroundChild.h"
#include "mozilla/ipc/BackgroundUtils.h" #include "mozilla/ipc/BackgroundUtils.h"
@ -51,15 +52,15 @@ private:
namespace { namespace {
nsIPrincipal* nsIPrincipal*
GetPrincipalFromWorkerPrivate(WorkerPrivate* aWorkerPrivate) GetPrincipalFromThreadSafeWorkerRef(ThreadSafeWorkerRef* aWorkerRef)
{ {
nsIPrincipal* principal = aWorkerPrivate->GetPrincipal(); nsIPrincipal* principal = aWorkerRef->Private()->GetPrincipal();
if (principal) { if (principal) {
return principal; return principal;
} }
// Walk up to our containing page // Walk up to our containing page
WorkerPrivate* wp = aWorkerPrivate; WorkerPrivate* wp = aWorkerRef->Private();
while (wp->GetParent()) { while (wp->GetParent()) {
wp = wp->GetParent(); wp = wp->GetParent();
} }
@ -70,23 +71,23 @@ GetPrincipalFromWorkerPrivate(WorkerPrivate* aWorkerPrivate)
class InitializeRunnable final : public WorkerMainThreadRunnable class InitializeRunnable final : public WorkerMainThreadRunnable
{ {
public: public:
InitializeRunnable(WorkerPrivate* aWorkerPrivate, nsACString& aOrigin, InitializeRunnable(ThreadSafeWorkerRef* aWorkerRef, nsACString& aOrigin,
PrincipalInfo& aPrincipalInfo, ErrorResult& aRv) PrincipalInfo& aPrincipalInfo, ErrorResult& aRv)
: WorkerMainThreadRunnable(aWorkerPrivate, : WorkerMainThreadRunnable(aWorkerRef->Private(),
NS_LITERAL_CSTRING("BroadcastChannel :: Initialize")) NS_LITERAL_CSTRING("BroadcastChannel :: Initialize"))
, mWorkerPrivate(GetCurrentThreadWorkerPrivate()) , mWorkerRef(aWorkerRef)
, mOrigin(aOrigin) , mOrigin(aOrigin)
, mPrincipalInfo(aPrincipalInfo) , mPrincipalInfo(aPrincipalInfo)
, mRv(aRv) , mRv(aRv)
{ {
MOZ_ASSERT(mWorkerPrivate); MOZ_ASSERT(mWorkerRef);
} }
bool MainThreadRun() override bool MainThreadRun() override
{ {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
nsIPrincipal* principal = GetPrincipalFromWorkerPrivate(mWorkerPrivate); nsIPrincipal* principal = GetPrincipalFromThreadSafeWorkerRef(mWorkerRef);
if (!principal) { if (!principal) {
mRv.Throw(NS_ERROR_FAILURE); mRv.Throw(NS_ERROR_FAILURE);
return true; return true;
@ -103,7 +104,7 @@ public:
} }
// Walk up to our containing page // Walk up to our containing page
WorkerPrivate* wp = mWorkerPrivate; WorkerPrivate* wp = mWorkerRef->Private();
while (wp->GetParent()) { while (wp->GetParent()) {
wp = wp->GetParent(); wp = wp->GetParent();
} }
@ -118,7 +119,7 @@ public:
} }
private: private:
WorkerPrivate* mWorkerPrivate; RefPtr<ThreadSafeWorkerRef> mWorkerRef;
nsACString& mOrigin; nsACString& mOrigin;
PrincipalInfo& mPrincipalInfo; PrincipalInfo& mPrincipalInfo;
ErrorResult& mRv; ErrorResult& mRv;
@ -277,42 +278,12 @@ public:
{} {}
}; };
class BroadcastChannelWorkerHolder final : public WorkerHolder
{
BroadcastChannel* mChannel;
public:
explicit BroadcastChannelWorkerHolder(BroadcastChannel* aChannel)
: WorkerHolder("BroadcastChannelWorkerHolder")
, mChannel(aChannel)
{
MOZ_COUNT_CTOR(BroadcastChannelWorkerHolder);
}
virtual bool Notify(WorkerStatus aStatus) override
{
if (aStatus >= Closing) {
mChannel->Shutdown();
}
return true;
}
private:
~BroadcastChannelWorkerHolder()
{
MOZ_COUNT_DTOR(BroadcastChannelWorkerHolder);
}
};
} // namespace } // namespace
BroadcastChannel::BroadcastChannel(nsPIDOMWindowInner* aWindow, BroadcastChannel::BroadcastChannel(nsPIDOMWindowInner* aWindow,
const PrincipalInfo& aPrincipalInfo,
const nsACString& aOrigin,
const nsAString& aChannel) const nsAString& aChannel)
: DOMEventTargetHelper(aWindow) : DOMEventTargetHelper(aWindow)
, mWorkerHolder(nullptr)
, mChannel(aChannel) , mChannel(aChannel)
, mInnerID(0) , mInnerID(0)
, mState(StateActive) , mState(StateActive)
@ -325,7 +296,7 @@ BroadcastChannel::BroadcastChannel(nsPIDOMWindowInner* aWindow,
BroadcastChannel::~BroadcastChannel() BroadcastChannel::~BroadcastChannel()
{ {
Shutdown(); Shutdown();
MOZ_ASSERT(!mWorkerHolder); MOZ_ASSERT(!mWorkerRef);
} }
JSObject* JSObject*
@ -343,9 +314,10 @@ BroadcastChannel::Constructor(const GlobalObject& aGlobal,
do_QueryInterface(aGlobal.GetAsSupports()); do_QueryInterface(aGlobal.GetAsSupports());
// Window is null in workers. // Window is null in workers.
RefPtr<BroadcastChannel> bc = new BroadcastChannel(window, aChannel);
nsAutoCString origin; nsAutoCString origin;
PrincipalInfo principalInfo; PrincipalInfo principalInfo;
WorkerPrivate* workerPrivate = nullptr;
if (NS_IsMainThread()) { if (NS_IsMainThread()) {
nsCOMPtr<nsIGlobalObject> incumbent = mozilla::dom::GetIncumbentGlobal(); nsCOMPtr<nsIGlobalObject> incumbent = mozilla::dom::GetIncumbentGlobal();
@ -372,21 +344,32 @@ BroadcastChannel::Constructor(const GlobalObject& aGlobal,
} }
} else { } else {
JSContext* cx = aGlobal.Context(); JSContext* cx = aGlobal.Context();
workerPrivate = GetWorkerPrivateFromContext(cx);
WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(cx);
MOZ_ASSERT(workerPrivate); MOZ_ASSERT(workerPrivate);
RefPtr<StrongWorkerRef> workerRef =
StrongWorkerRef::Create(workerPrivate, "BroadcastChannel",
[bc] () { bc->Shutdown(); });
// We are already shutting down the worker. Let's return a non-active
// object.
if (NS_WARN_IF(!workerRef)) {
bc->mState = StateClosed;
return bc.forget();
}
RefPtr<ThreadSafeWorkerRef> tsr = new ThreadSafeWorkerRef(workerRef);
RefPtr<InitializeRunnable> runnable = RefPtr<InitializeRunnable> runnable =
new InitializeRunnable(workerPrivate, origin, principalInfo, aRv); new InitializeRunnable(tsr, origin, principalInfo, aRv);
runnable->Dispatch(Closing, aRv); runnable->Dispatch(Closing, aRv);
} if (aRv.Failed()) {
return nullptr;
}
if (aRv.Failed()) { bc->mWorkerRef = Move(workerRef);
return nullptr;
} }
RefPtr<BroadcastChannel> bc =
new BroadcastChannel(window, principalInfo, origin, aChannel);
// Register this component to PBackground. // Register this component to PBackground.
PBackgroundChild* actorChild = BackgroundChild::GetOrCreateForCurrentThread(); PBackgroundChild* actorChild = BackgroundChild::GetOrCreateForCurrentThread();
if (NS_WARN_IF(!actorChild)) { if (NS_WARN_IF(!actorChild)) {
@ -404,7 +387,7 @@ BroadcastChannel::Constructor(const GlobalObject& aGlobal,
bc->mActor->SetParent(bc); bc->mActor->SetParent(bc);
if (!workerPrivate) { if (!bc->mWorkerRef) {
MOZ_ASSERT(window); MOZ_ASSERT(window);
bc->mInnerID = window->WindowID(); bc->mInnerID = window->WindowID();
@ -413,13 +396,6 @@ BroadcastChannel::Constructor(const GlobalObject& aGlobal,
if (obs) { if (obs) {
obs->AddObserver(bc, "inner-window-destroyed", false); obs->AddObserver(bc, "inner-window-destroyed", false);
} }
} else {
bc->mWorkerHolder = new BroadcastChannelWorkerHolder(bc);
if (NS_WARN_IF(!bc->mWorkerHolder->HoldWorker(workerPrivate, Closing))) {
bc->mWorkerHolder = nullptr;
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
} }
return bc.forget(); return bc.forget();
@ -489,8 +465,8 @@ BroadcastChannel::Shutdown()
{ {
mState = StateClosed; mState = StateClosed;
// The DTOR of this WorkerHolder will release the worker for us. // The DTOR of this WorkerRef will release the worker for us.
mWorkerHolder = nullptr; mWorkerRef = nullptr;
if (mActor) { if (mActor) {
mActor->SetParent(nullptr); mActor->SetParent(nullptr);

Просмотреть файл

@ -26,7 +26,7 @@ namespace dom {
class BroadcastChannelChild; class BroadcastChannelChild;
class BroadcastChannelMessage; class BroadcastChannelMessage;
class WorkerHolder; class WorkerRef;
class BroadcastChannel final class BroadcastChannel final
: public DOMEventTargetHelper : public DOMEventTargetHelper
@ -68,8 +68,6 @@ public:
private: private:
BroadcastChannel(nsPIDOMWindowInner* aWindow, BroadcastChannel(nsPIDOMWindowInner* aWindow,
const PrincipalInfo& aPrincipalInfo,
const nsACString& aOrigin,
const nsAString& aChannel); const nsAString& aChannel);
~BroadcastChannel(); ~BroadcastChannel();
@ -83,7 +81,7 @@ private:
RefPtr<BroadcastChannelChild> mActor; RefPtr<BroadcastChannelChild> mActor;
nsAutoPtr<WorkerHolder> mWorkerHolder; RefPtr<WorkerRef> mWorkerRef;
nsString mChannel; nsString mChannel;

Просмотреть файл

@ -15,7 +15,6 @@
#include "mozilla/dom/ScriptSettings.h" #include "mozilla/dom/ScriptSettings.h"
#include "mozilla/ipc/PBackgroundChild.h" #include "mozilla/ipc/PBackgroundChild.h"
#include "mozilla/dom/ipc/StructuredCloneData.h" #include "mozilla/dom/ipc/StructuredCloneData.h"
#include "mozilla/dom/WorkerPrivate.h"
namespace mozilla { namespace mozilla {

Просмотреть файл

@ -59,7 +59,7 @@ CreateIframe(Element* aOpenerFrameElement, const nsAString& aName, bool aRemote)
aName, /* aNotify = */ false); aName, /* aNotify = */ false);
// Indicate whether the iframe is should be remote. // Indicate whether the iframe is should be remote.
popupFrameElement->SetAttr(kNameSpaceID_None, nsGkAtoms::Remote, popupFrameElement->SetAttr(kNameSpaceID_None, nsGkAtoms::remote,
aRemote ? NS_LITERAL_STRING("true") : aRemote ? NS_LITERAL_STRING("true") :
NS_LITERAL_STRING("false"), NS_LITERAL_STRING("false"),
/* aNotify = */ false); /* aNotify = */ false);

Просмотреть файл

@ -66,8 +66,7 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(DataTransfer)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DataTransfer) NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DataTransfer)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(mozilla::dom::DataTransfer) NS_INTERFACE_MAP_ENTRY(mozilla::dom::DataTransfer)
NS_INTERFACE_MAP_ENTRY(nsIDOMDataTransfer) NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMDataTransfer)
NS_INTERFACE_MAP_END NS_INTERFACE_MAP_END
// the size of the array // the size of the array
@ -223,16 +222,7 @@ DataTransfer::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
return DataTransferBinding::Wrap(aCx, this, aGivenProto); return DataTransferBinding::Wrap(aCx, this, aGivenProto);
} }
NS_IMETHODIMP void
DataTransfer::GetDropEffect(nsAString& aDropEffect)
{
nsString dropEffect;
GetDropEffect(dropEffect);
aDropEffect = dropEffect;
return NS_OK;
}
NS_IMETHODIMP
DataTransfer::SetDropEffect(const nsAString& aDropEffect) DataTransfer::SetDropEffect(const nsAString& aDropEffect)
{ {
// the drop effect can only be 'none', 'copy', 'move' or 'link'. // the drop effect can only be 'none', 'copy', 'move' or 'link'.
@ -246,25 +236,14 @@ DataTransfer::SetDropEffect(const nsAString& aDropEffect)
break; break;
} }
} }
return NS_OK;
} }
NS_IMETHODIMP void
DataTransfer::GetEffectAllowed(nsAString& aEffectAllowed)
{
nsString effectAllowed;
GetEffectAllowed(effectAllowed);
aEffectAllowed = effectAllowed;
return NS_OK;
}
NS_IMETHODIMP
DataTransfer::SetEffectAllowed(const nsAString& aEffectAllowed) DataTransfer::SetEffectAllowed(const nsAString& aEffectAllowed)
{ {
if (aEffectAllowed.EqualsLiteral("uninitialized")) { if (aEffectAllowed.EqualsLiteral("uninitialized")) {
mEffectAllowed = nsIDragService::DRAGDROP_ACTION_UNINITIALIZED; mEffectAllowed = nsIDragService::DRAGDROP_ACTION_UNINITIALIZED;
return NS_OK; return;
} }
static_assert(nsIDragService::DRAGDROP_ACTION_NONE == 0, static_assert(nsIDragService::DRAGDROP_ACTION_NONE == 0,
@ -282,29 +261,6 @@ DataTransfer::SetEffectAllowed(const nsAString& aEffectAllowed)
break; break;
} }
} }
return NS_OK;
}
NS_IMETHODIMP
DataTransfer::GetDropEffectInt(uint32_t* aDropEffect)
{
*aDropEffect = mDropEffect;
return NS_OK;
}
NS_IMETHODIMP
DataTransfer::SetDropEffectInt(uint32_t aDropEffect)
{
mDropEffect = aDropEffect;
return NS_OK;
}
NS_IMETHODIMP
DataTransfer::GetEffectAllowedInt(uint32_t* aEffectAllowed)
{
*aEffectAllowed = mEffectAllowed;
return NS_OK;
} }
void void
@ -321,46 +277,12 @@ DataTransfer::GetMozTriggeringPrincipalURISpec(nsAString& aPrincipalURISpec)
CopyUTF8toUTF16(principalURISpec, aPrincipalURISpec); CopyUTF8toUTF16(principalURISpec, aPrincipalURISpec);
} }
NS_IMETHODIMP
DataTransfer::SetEffectAllowedInt(uint32_t aEffectAllowed)
{
mEffectAllowed = aEffectAllowed;
return NS_OK;
}
NS_IMETHODIMP
DataTransfer::GetMozUserCancelled(bool* aUserCancelled)
{
*aUserCancelled = MozUserCancelled();
return NS_OK;
}
already_AddRefed<FileList> already_AddRefed<FileList>
DataTransfer::GetFiles(nsIPrincipal& aSubjectPrincipal, DataTransfer::GetFiles(nsIPrincipal& aSubjectPrincipal)
ErrorResult& aRv)
{ {
return mItems->Files(&aSubjectPrincipal); return mItems->Files(&aSubjectPrincipal);
} }
NS_IMETHODIMP
DataTransfer::GetFiles(nsIDOMFileList** aFileList)
{
if (!aFileList) {
return NS_ERROR_FAILURE;
}
// The XPCOM interface is only avaliable to system code, and thus we can
// assume the system principal. This is consistent with the previous behavour
// of this function, which also assumed the system principal.
//
// This code is also called from C++ code, which expects it to have a System
// Principal, and thus the SubjectPrincipal cannot be used.
RefPtr<FileList> files = mItems->Files(nsContentUtils::GetSystemPrincipal());
files.forget(aFileList);
return NS_OK;
}
void void
DataTransfer::GetTypes(nsTArray<nsString>& aTypes, CallerType aCallerType) const DataTransfer::GetTypes(nsTArray<nsString>& aTypes, CallerType aCallerType) const
{ {
@ -494,29 +416,11 @@ DataTransfer::ClearData(const Optional<nsAString>& aFormat,
} }
} }
NS_IMETHODIMP void
DataTransfer::GetMozItemCount(uint32_t* aCount)
{
*aCount = MozItemCount();
return NS_OK;
}
NS_IMETHODIMP
DataTransfer::GetMozCursor(nsAString& aCursorState)
{
nsString cursor;
GetMozCursor(cursor);
aCursorState = cursor;
return NS_OK;
}
NS_IMETHODIMP
DataTransfer::SetMozCursor(const nsAString& aCursorState) DataTransfer::SetMozCursor(const nsAString& aCursorState)
{ {
// Lock the cursor to an arrow during the drag. // Lock the cursor to an arrow during the drag.
mCursorState = aCursorState.EqualsLiteral("default"); mCursorState = aCursorState.EqualsLiteral("default");
return NS_OK;
} }
already_AddRefed<nsINode> already_AddRefed<nsINode>
@ -538,18 +442,6 @@ DataTransfer::GetMozSourceNode()
return node.forget(); return node.forget();
} }
NS_IMETHODIMP
DataTransfer::GetMozSourceNode(nsIDOMNode** aSourceNode)
{
nsCOMPtr<nsINode> sourceNode = GetMozSourceNode();
if (!sourceNode) {
*aSourceNode = nullptr;
return NS_OK;
}
return CallQueryInterface(sourceNode, aSourceNode);
}
already_AddRefed<DOMStringList> already_AddRefed<DOMStringList>
DataTransfer::MozTypesAt(uint32_t aIndex, CallerType aCallerType, DataTransfer::MozTypesAt(uint32_t aIndex, CallerType aCallerType,
ErrorResult& aRv) const ErrorResult& aRv) const
@ -843,16 +735,6 @@ DataTransfer::SetDragImage(Element& aImage, int32_t aX, int32_t aY)
} }
} }
NS_IMETHODIMP
DataTransfer::SetDragImage(nsIDOMElement* aImage, int32_t aX, int32_t aY)
{
nsCOMPtr<Element> image = do_QueryInterface(aImage);
if (image) {
SetDragImage(*image, aX, aY);
}
return NS_OK;
}
void void
DataTransfer::UpdateDragImage(Element& aImage, int32_t aX, int32_t aY) DataTransfer::UpdateDragImage(Element& aImage, int32_t aX, int32_t aY)
{ {
@ -924,19 +806,6 @@ DataTransfer::AddElement(Element& aElement, ErrorResult& aRv)
mDragTarget = &aElement; mDragTarget = &aElement;
} }
NS_IMETHODIMP
DataTransfer::AddElement(nsIDOMElement* aElement)
{
NS_ENSURE_TRUE(aElement, NS_ERROR_NULL_POINTER);
nsCOMPtr<Element> element = do_QueryInterface(aElement);
NS_ENSURE_TRUE(element, NS_ERROR_INVALID_ARG);
ErrorResult rv;
AddElement(*element, rv);
return rv.StealNSResult();
}
nsresult nsresult
DataTransfer::Clone(nsISupports* aParent, EventMessage aEventMessage, DataTransfer::Clone(nsISupports* aParent, EventMessage aEventMessage,
bool aUserCancelled, bool aIsCrossDomainSubFrameDrop, bool aUserCancelled, bool aIsCrossDomainSubFrameDrop,

Просмотреть файл

@ -11,11 +11,12 @@
#include "nsTArray.h" #include "nsTArray.h"
#include "nsIVariant.h" #include "nsIVariant.h"
#include "nsIPrincipal.h" #include "nsIPrincipal.h"
#include "nsIDOMDataTransfer.h"
#include "nsIDOMElement.h" #include "nsIDOMElement.h"
#include "nsIDragService.h" #include "nsIDragService.h"
#include "nsCycleCollectionParticipant.h" #include "nsCycleCollectionParticipant.h"
#include "mozilla/ArrayUtils.h"
#include "mozilla/Assertions.h"
#include "mozilla/Attributes.h" #include "mozilla/Attributes.h"
#include "mozilla/EventForwards.h" #include "mozilla/EventForwards.h"
#include "mozilla/dom/BindingDeclarations.h" #include "mozilla/dom/BindingDeclarations.h"
@ -43,24 +44,18 @@ template<typename T> class Optional;
{ 0x6c5f90d1, 0xa886, 0x42c8, \ { 0x6c5f90d1, 0xa886, 0x42c8, \
{ 0x85, 0x06, 0x10, 0xbe, 0x5c, 0x0d, 0xc6, 0x77 } } { 0x85, 0x06, 0x10, 0xbe, 0x5c, 0x0d, 0xc6, 0x77 } }
class DataTransfer final : public nsIDOMDataTransfer, class DataTransfer final : public nsISupports,
public nsWrapperCache public nsWrapperCache
{ {
public: public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_DATATRANSFER_IID) NS_DECLARE_STATIC_IID_ACCESSOR(NS_DATATRANSFER_IID)
NS_DECL_CYCLE_COLLECTING_ISUPPORTS NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_NSIDOMDATATRANSFER
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DataTransfer) NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DataTransfer)
friend class mozilla::EventStateManager; friend class mozilla::EventStateManager;
static DataTransfer* Cast(nsIDOMDataTransfer* aArg)
{
return static_cast<DataTransfer*>(aArg);
}
/// An enum which represents which "Drag Data Store Mode" the DataTransfer is /// An enum which represents which "Drag Data Store Mode" the DataTransfer is
/// in according to the spec. /// in according to the spec.
enum class Mode : uint8_t { enum class Mode : uint8_t {
@ -128,12 +123,57 @@ public:
Constructor(const GlobalObject& aGlobal, const nsAString& aEventType, Constructor(const GlobalObject& aGlobal, const nsAString& aEventType,
bool aIsExternal, ErrorResult& aRv); bool aIsExternal, ErrorResult& aRv);
void GetDropEffect(nsString& aDropEffect) /**
* The actual effect that will be used, and should always be one of the
* possible values of effectAllowed.
*
* For dragstart, drag and dragleave events, the dropEffect is initialized
* to none. Any value assigned to the dropEffect will be set, but the value
* isn't used for anything.
*
* For the dragenter and dragover events, the dropEffect will be initialized
* based on what action the user is requesting. How this is determined is
* platform specific, but typically the user can press modifier keys to
* adjust which action is desired. Within an event handler for the dragenter
* and dragover events, the dropEffect should be modified if the action the
* user is requesting is not the one that is desired.
*
* For the drop and dragend events, the dropEffect will be initialized to
* the action that was desired, which will be the value that the dropEffect
* had after the last dragenter or dragover event.
*
* Possible values:
* copy - a copy of the source item is made at the new location
* move - an item is moved to a new location
* link - a link is established to the source at the new location
* none - the item may not be dropped
*
* Assigning any other value has no effect and retains the old value.
*/
void GetDropEffect(nsAString& aDropEffect)
{ {
aDropEffect.AssignASCII(sEffects[mDropEffect]); aDropEffect.AssignASCII(sEffects[mDropEffect]);
} }
void SetDropEffect(const nsAString& aDropEffect);
void GetEffectAllowed(nsString& aEffectAllowed) /*
* Specifies the effects that are allowed for this drag. You may set this in
* the dragstart event to set the desired effects for the source, and within
* the dragenter and dragover events to set the desired effects for the
* target. The value is not used for other events.
*
* Possible values:
* copy - a copy of the source item is made at the new location
* move - an item is moved to a new location
* link - a link is established to the source at the new location
* copyLink, copyMove, linkMove, all - combinations of the above
* none - the item may not be dropped
* uninitialized - the default value when the effect has not been set,
* equivalent to all.
*
* Assigning any other value has no effect and retains the old value.
*/
void GetEffectAllowed(nsAString& aEffectAllowed)
{ {
if (mEffectAllowed == nsIDragService::DRAGDROP_ACTION_UNINITIALIZED) { if (mEffectAllowed == nsIDragService::DRAGDROP_ACTION_UNINITIALIZED) {
aEffectAllowed.AssignLiteral("uninitialized"); aEffectAllowed.AssignLiteral("uninitialized");
@ -141,7 +181,26 @@ public:
aEffectAllowed.AssignASCII(sEffects[mEffectAllowed]); aEffectAllowed.AssignASCII(sEffects[mEffectAllowed]);
} }
} }
void SetEffectAllowed(const nsAString& aEffectAllowed);
/**
* Set the image to be used for dragging if a custom one is desired. Most of
* the time, this would not be set, as a default image is created from the
* node that was dragged.
*
* If the node is an HTML img element, an HTML canvas element or a XUL image
* element, the image data is used. Otherwise, image should be a visible
* node and the drag image will be created from this. If image is null, any
* custom drag image is cleared and the default is used instead.
*
* The coordinates specify the offset into the image where the mouse cursor
* should be. To center the image for instance, use values that are half the
* width and height.
*
* @param image a node to use
* @param x the horizontal offset
* @param y the vertical offset
*/
void SetDragImage(Element& aElement, int32_t aX, int32_t aY); void SetDragImage(Element& aElement, int32_t aX, int32_t aY);
void UpdateDragImage(Element& aElement, int32_t aX, int32_t aY); void UpdateDragImage(Element& aElement, int32_t aX, int32_t aY);
@ -159,9 +218,13 @@ public:
nsIPrincipal& aSubjectPrincipal, nsIPrincipal& aSubjectPrincipal,
mozilla::ErrorResult& aRv); mozilla::ErrorResult& aRv);
/**
* Holds a list of all the local files available on this data transfer.
* A dataTransfer containing no files will return an empty list, and an
* invalid index access on the resulting file list will return null.
*/
already_AddRefed<FileList> already_AddRefed<FileList>
GetFiles(nsIPrincipal& aSubjectPrincipal, GetFiles(nsIPrincipal& aSubjectPrincipal);
mozilla::ErrorResult& aRv);
already_AddRefed<Promise> already_AddRefed<Promise>
GetFilesAndDirectories(nsIPrincipal& aSubjectPrincipal, GetFilesAndDirectories(nsIPrincipal& aSubjectPrincipal,
@ -177,7 +240,7 @@ public:
uint32_t MozItemCount() const; uint32_t MozItemCount() const;
void GetMozCursor(nsString& aCursor) void GetMozCursor(nsAString& aCursor)
{ {
if (mCursorState) { if (mCursorState) {
aCursor.AssignLiteral("default"); aCursor.AssignLiteral("default");
@ -185,6 +248,7 @@ public:
aCursor.AssignLiteral("auto"); aCursor.AssignLiteral("auto");
} }
} }
void SetMozCursor(const nsAString& aCursor);
already_AddRefed<DOMStringList> MozTypesAt(uint32_t aIndex, already_AddRefed<DOMStringList> MozTypesAt(uint32_t aIndex,
CallerType aCallerType, CallerType aCallerType,
@ -211,6 +275,29 @@ public:
already_AddRefed<nsINode> GetMozSourceNode(); already_AddRefed<nsINode> GetMozSourceNode();
/*
* Integer version of dropEffect, set to one of the constants in nsIDragService.
*/
uint32_t DropEffectInt() const
{
return mDropEffect;
}
void SetDropEffectInt(uint32_t aDropEffectInt)
{
MOZ_RELEASE_ASSERT(aDropEffectInt < ArrayLength(sEffects),
"Bogus drop effect value");
mDropEffect = aDropEffectInt;
}
/*
* Integer version of effectAllowed, set to one or a combination of the
* constants in nsIDragService.
*/
uint32_t EffectAllowedInt() const
{
return mEffectAllowed;
}
void GetMozTriggeringPrincipalURISpec(nsAString& aPrincipalURISpec); void GetMozTriggeringPrincipalURISpec(nsAString& aPrincipalURISpec);
mozilla::dom::Element* GetDragTarget() const mozilla::dom::Element* GetDragTarget() const

Просмотреть файл

@ -239,13 +239,13 @@ DataTransferItemList::Files(nsIPrincipal* aPrincipal)
// advanced caching mechanism for the FileList objects will be required. // advanced caching mechanism for the FileList objects will be required.
RefPtr<FileList> files; RefPtr<FileList> files;
if (nsContentUtils::IsSystemPrincipal(aPrincipal)) { if (nsContentUtils::IsSystemPrincipal(aPrincipal)) {
files = new FileList(static_cast<nsIDOMDataTransfer*>(mDataTransfer)); files = new FileList(mDataTransfer);
GenerateFiles(files, aPrincipal); GenerateFiles(files, aPrincipal);
return files.forget(); return files.forget();
} }
if (!mFiles) { if (!mFiles) {
mFiles = new FileList(static_cast<nsIDOMDataTransfer*>(mDataTransfer)); mFiles = new FileList(mDataTransfer);
mFilesPrincipal = aPrincipal; mFilesPrincipal = aPrincipal;
RegenerateFiles(); RegenerateFiles();
} }

Просмотреть файл

@ -66,13 +66,6 @@ DragEvent::InitDragEvent(const nsAString& aType,
} }
} }
NS_IMETHODIMP
DragEvent::GetDataTransfer(nsIDOMDataTransfer** aDataTransfer)
{
NS_IF_ADDREF(*aDataTransfer = GetDataTransfer());
return NS_OK;
}
DataTransfer* DataTransfer*
DragEvent::GetDataTransfer() DragEvent::GetDataTransfer()
{ {

Просмотреть файл

@ -30,12 +30,20 @@ public:
NS_DECL_NSIDOMDRAGEVENT NS_DECL_NSIDOMDRAGEVENT
NS_FORWARD_TO_MOUSEEVENT NS_FORWARD_TO_MOUSEEVENT
// And now pull in some things we just shadowed.
using UIEvent::GetRangeParent;
using UIEvent::RangeOffset;
virtual JSObject* WrapObjectInternal(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override virtual JSObject* WrapObjectInternal(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override
{ {
return DragEventBinding::Wrap(aCx, this, aGivenProto); return DragEventBinding::Wrap(aCx, this, aGivenProto);
} }
DragEvent* AsDragEvent() override
{
return this;
}
DataTransfer* GetDataTransfer(); DataTransfer* GetDataTransfer();
void InitDragEvent(const nsAString& aType, void InitDragEvent(const nsAString& aType,

Просмотреть файл

@ -30,6 +30,7 @@ namespace mozilla {
namespace dom { namespace dom {
class BeforeUnloadEvent; class BeforeUnloadEvent;
class DragEvent;
class EventTarget; class EventTarget;
class EventMessageAutoOverride; class EventMessageAutoOverride;
// ExtendableEvent is a ServiceWorker event that is not // ExtendableEvent is a ServiceWorker event that is not
@ -126,6 +127,12 @@ public:
return nullptr; return nullptr;
} }
// DragEvent has a non-autogeneratable initDragEvent.
virtual DragEvent* AsDragEvent()
{
return nullptr;
}
// nsIDOMEvent Interface // nsIDOMEvent Interface
NS_DECL_NSIDOMEVENT NS_DECL_NSIDOMEVENT

Просмотреть файл

@ -1337,10 +1337,9 @@ EventStateManager::DispatchCrossProcessEvent(WidgetEvent* aEvent,
dragSession->DragEventDispatchedToChildProcess(); dragSession->DragEventDispatchedToChildProcess();
dragSession->GetDragAction(&action); dragSession->GetDragAction(&action);
dragSession->GetTriggeringPrincipalURISpec(principalURISpec); dragSession->GetTriggeringPrincipalURISpec(principalURISpec);
nsCOMPtr<nsIDOMDataTransfer> initialDataTransfer; RefPtr<DataTransfer> initialDataTransfer = dragSession->GetDataTransfer();
dragSession->GetDataTransfer(getter_AddRefs(initialDataTransfer));
if (initialDataTransfer) { if (initialDataTransfer) {
initialDataTransfer->GetDropEffectInt(&dropEffect); dropEffect = initialDataTransfer->DropEffectInt();
} }
} }
@ -2059,10 +2058,12 @@ EventStateManager::DoDefaultDragStart(nsPresContext* aPresContext,
// No drag session is currently active, so check if a handler added // No drag session is currently active, so check if a handler added
// any items to be dragged. If not, there isn't anything to drag. // any items to be dragged. If not, there isn't anything to drag.
uint32_t count = 0; uint32_t count = 0;
if (aDataTransfer) if (aDataTransfer) {
aDataTransfer->GetMozItemCount(&count); count = aDataTransfer->MozItemCount();
if (!count) }
if (!count) {
return false; return false;
}
// Get the target being dragged, which may not be the same as the // Get the target being dragged, which may not be the same as the
// target of the mouse event. If one wasn't set in the // target of the mouse event. If one wasn't set in the
@ -2077,8 +2078,7 @@ EventStateManager::DoDefaultDragStart(nsPresContext* aPresContext,
// check which drag effect should initially be used. If the effect was not // check which drag effect should initially be used. If the effect was not
// set, just use all actions, otherwise Windows won't allow a drop. // set, just use all actions, otherwise Windows won't allow a drop.
uint32_t action; uint32_t action = aDataTransfer->EffectAllowedInt();
aDataTransfer->GetEffectAllowedInt(&action);
if (action == nsIDragService::DRAGDROP_ACTION_UNINITIALIZED) if (action == nsIDragService::DRAGDROP_ACTION_UNINITIALIZED)
action = nsIDragService::DRAGDROP_ACTION_COPY | action = nsIDragService::DRAGDROP_ACTION_COPY |
nsIDragService::DRAGDROP_ACTION_MOVE | nsIDragService::DRAGDROP_ACTION_MOVE |
@ -2101,9 +2101,7 @@ EventStateManager::DoDefaultDragStart(nsPresContext* aPresContext,
false, getter_AddRefs(dataTransfer)); false, getter_AddRefs(dataTransfer));
// Copy over the drop effect, as Clone doesn't copy it for us. // Copy over the drop effect, as Clone doesn't copy it for us.
uint32_t dropEffect; dataTransfer->SetDropEffectInt(aDataTransfer->DropEffectInt());
aDataTransfer->GetDropEffectInt(&dropEffect);
dataTransfer->SetDropEffectInt(dropEffect);
// XXXndeakin don't really want to create a new drag DOM event // XXXndeakin don't really want to create a new drag DOM event
// here, but we need something to pass to the InvokeDragSession // here, but we need something to pass to the InvokeDragSession
@ -3531,9 +3529,8 @@ EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
// the initial dataTransfer is the one from the dragstart event that // the initial dataTransfer is the one from the dragstart event that
// was set on the dragSession when the drag began. // was set on the dragSession when the drag began.
nsCOMPtr<nsIDOMDataTransfer> dataTransfer; RefPtr<DataTransfer> dataTransfer;
nsCOMPtr<nsIDOMDataTransfer> initialDataTransfer; RefPtr<DataTransfer> initialDataTransfer = dragSession->GetDataTransfer();
dragSession->GetDataTransfer(getter_AddRefs(initialDataTransfer));
WidgetDragEvent *dragEvent = aEvent->AsDragEvent(); WidgetDragEvent *dragEvent = aEvent->AsDragEvent();
@ -3556,8 +3553,8 @@ EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
// if the event has a dataTransfer set, use it. // if the event has a dataTransfer set, use it.
if (dragEvent->mDataTransfer) { if (dragEvent->mDataTransfer) {
// get the dataTransfer and the dropEffect that was set on it // get the dataTransfer and the dropEffect that was set on it
dataTransfer = do_QueryInterface(dragEvent->mDataTransfer); dataTransfer = dragEvent->mDataTransfer;
dataTransfer->GetDropEffectInt(&dropEffect); dropEffect = dataTransfer->DropEffectInt();
} }
else { else {
// if dragEvent->mDataTransfer is null, it means that no attempt was // if dragEvent->mDataTransfer is null, it means that no attempt was
@ -3581,8 +3578,9 @@ EventStateManager::PostHandleEvent(nsPresContext* aPresContext,
// drag was originally started by directly calling the drag service. // drag was originally started by directly calling the drag service.
// Just assume that all effects are allowed. // Just assume that all effects are allowed.
uint32_t effectAllowed = nsIDragService::DRAGDROP_ACTION_UNINITIALIZED; uint32_t effectAllowed = nsIDragService::DRAGDROP_ACTION_UNINITIALIZED;
if (dataTransfer) if (dataTransfer) {
dataTransfer->GetEffectAllowedInt(&effectAllowed); effectAllowed = dataTransfer->EffectAllowedInt();
}
// set the drag action based on the drop effect and effect allowed. // set the drag action based on the drop effect and effect allowed.
// The drop effect field on the drag transfer object specifies the // The drop effect field on the drag transfer object specifies the
@ -4779,8 +4777,7 @@ EventStateManager::UpdateDragDataTransfer(WidgetDragEvent* dragEvent)
if (dragSession) { if (dragSession) {
// the initial dataTransfer is the one from the dragstart event that // the initial dataTransfer is the one from the dragstart event that
// was set on the dragSession when the drag began. // was set on the dragSession when the drag began.
nsCOMPtr<nsIDOMDataTransfer> initialDataTransfer; RefPtr<DataTransfer> initialDataTransfer = dragSession->GetDataTransfer();
dragSession->GetDataTransfer(getter_AddRefs(initialDataTransfer));
if (initialDataTransfer) { if (initialDataTransfer) {
// retrieve the current moz cursor setting and save it. // retrieve the current moz cursor setting and save it.
nsAutoString mozCursor; nsAutoString mozCursor;

Просмотреть файл

@ -16,7 +16,8 @@
#include "mozilla/dom/File.h" #include "mozilla/dom/File.h"
#include "mozilla/dom/FileReaderBinding.h" #include "mozilla/dom/FileReaderBinding.h"
#include "mozilla/dom/ProgressEvent.h" #include "mozilla/dom/ProgressEvent.h"
#include "mozilla/dom/WorkerPrivate.h" #include "mozilla/dom/WorkerCommon.h"
#include "mozilla/dom/WorkerRef.h"
#include "mozilla/dom/WorkerScope.h" #include "mozilla/dom/WorkerScope.h"
#include "mozilla/Encoding.h" #include "mozilla/Encoding.h"
#include "nsAlgorithm.h" #include "nsAlgorithm.h"
@ -93,9 +94,8 @@ FileReader::RootResultArrayBuffer()
//FileReader constructors/initializers //FileReader constructors/initializers
FileReader::FileReader(nsIGlobalObject* aGlobal, FileReader::FileReader(nsIGlobalObject* aGlobal,
WorkerPrivate* aWorkerPrivate) WeakWorkerRef* aWorkerRef)
: DOMEventTargetHelper(aGlobal) : DOMEventTargetHelper(aGlobal)
, WorkerHolder("FileReader")
, mFileData(nullptr) , mFileData(nullptr)
, mDataLen(0) , mDataLen(0)
, mDataFormat(FILE_AS_BINARY) , mDataFormat(FILE_AS_BINARY)
@ -106,10 +106,10 @@ FileReader::FileReader(nsIGlobalObject* aGlobal,
, mTotal(0) , mTotal(0)
, mTransferred(0) , mTransferred(0)
, mBusyCount(0) , mBusyCount(0)
, mWorkerPrivate(aWorkerPrivate) , mWeakWorkerRef(aWorkerRef)
{ {
MOZ_ASSERT(aGlobal); MOZ_ASSERT(aGlobal);
MOZ_ASSERT(NS_IsMainThread() == !mWorkerPrivate); MOZ_ASSERT_IF(NS_IsMainThread(), !mWeakWorkerRef);
if (NS_IsMainThread()) { if (NS_IsMainThread()) {
mTarget = aGlobal->EventTargetFor(TaskCategory::Other); mTarget = aGlobal->EventTargetFor(TaskCategory::Other);
@ -130,15 +130,16 @@ FileReader::~FileReader()
FileReader::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv) FileReader::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv)
{ {
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aGlobal.GetAsSupports()); nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aGlobal.GetAsSupports());
WorkerPrivate* workerPrivate = nullptr; RefPtr<WeakWorkerRef> workerRef;
if (!NS_IsMainThread()) { if (!NS_IsMainThread()) {
JSContext* cx = aGlobal.Context(); JSContext* cx = aGlobal.Context();
workerPrivate = GetWorkerPrivateFromContext(cx); WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(cx);
MOZ_ASSERT(workerPrivate);
workerRef = WeakWorkerRef::Create(workerPrivate);
} }
RefPtr<FileReader> fileReader = new FileReader(global, workerPrivate); RefPtr<FileReader> fileReader = new FileReader(global, workerRef);
return fileReader.forget(); return fileReader.forget();
} }
@ -384,6 +385,11 @@ FileReader::ReadFileContent(Blob& aBlob,
eDataFormat aDataFormat, eDataFormat aDataFormat,
ErrorResult& aRv) ErrorResult& aRv)
{ {
if (IsCurrentThreadRunningWorker() && !mWeakWorkerRef) {
// The worker is already shutting down.
return;
}
if (mReadyState == LOADING) { if (mReadyState == LOADING) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return; return;
@ -647,7 +653,7 @@ FileReader::OnInputStreamReady(nsIAsyncInputStream* aStream)
// We use this class to decrease the busy counter at the end of this method. // We use this class to decrease the busy counter at the end of this method.
// In theory we can do it immediatelly but, for debugging reasons, we want to // In theory we can do it immediatelly but, for debugging reasons, we want to
// be 100% sure we have a workerHolder when OnLoadEnd() is called. // be 100% sure we have a workerRef when OnLoadEnd() is called.
FileReaderDecreaseBusyCounter RAII(this); FileReaderDecreaseBusyCounter RAII(this);
uint64_t count; uint64_t count;
@ -778,9 +784,21 @@ FileReader::Abort()
nsresult nsresult
FileReader::IncreaseBusyCounter() FileReader::IncreaseBusyCounter()
{ {
if (mWorkerPrivate && mBusyCount++ == 0 && if (mWeakWorkerRef && mBusyCount++ == 0) {
!HoldWorker(mWorkerPrivate, Closing)) { if (NS_WARN_IF(!mWeakWorkerRef->GetPrivate())) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
}
RefPtr<FileReader> self = this;
RefPtr<StrongWorkerRef> ref =
StrongWorkerRef::Create(mWeakWorkerRef->GetPrivate(), "FileReader",
[self]() { self->Shutdown(); });
if (NS_WARN_IF(!ref)) {
return NS_ERROR_FAILURE;
}
mStrongWorkerRef = ref;
} }
return NS_OK; return NS_OK;
@ -789,25 +807,12 @@ FileReader::IncreaseBusyCounter()
void void
FileReader::DecreaseBusyCounter() FileReader::DecreaseBusyCounter()
{ {
MOZ_ASSERT_IF(mWorkerPrivate, mBusyCount); MOZ_ASSERT_IF(mStrongWorkerRef, mBusyCount);
if (mWorkerPrivate && --mBusyCount == 0) { if (mStrongWorkerRef && --mBusyCount == 0) {
ReleaseWorker(); mStrongWorkerRef = nullptr;
} }
} }
bool
FileReader::Notify(WorkerStatus aStatus)
{
MOZ_ASSERT(mWorkerPrivate);
mWorkerPrivate->AssertIsOnWorkerThread();
if (aStatus > Running) {
Shutdown();
}
return true;
}
void void
FileReader::Shutdown() FileReader::Shutdown()
{ {
@ -821,9 +826,9 @@ FileReader::Shutdown()
FreeFileData(); FreeFileData();
mResultArrayBuffer = nullptr; mResultArrayBuffer = nullptr;
if (mWorkerPrivate && mBusyCount != 0) { if (mWeakWorkerRef && mBusyCount != 0) {
ReleaseWorker(); mStrongWorkerRef = nullptr;
mWorkerPrivate = nullptr; mWeakWorkerRef = nullptr;
mBusyCount = 0; mBusyCount = 0;
} }
} }

Просмотреть файл

@ -9,7 +9,6 @@
#include "mozilla/Attributes.h" #include "mozilla/Attributes.h"
#include "mozilla/DOMEventTargetHelper.h" #include "mozilla/DOMEventTargetHelper.h"
#include "mozilla/dom/WorkerHolder.h"
#include "nsIAsyncInputStream.h" #include "nsIAsyncInputStream.h"
#include "nsIInterfaceRequestor.h" #include "nsIInterfaceRequestor.h"
@ -28,7 +27,8 @@ namespace dom {
class Blob; class Blob;
class DOMException; class DOMException;
class WorkerPrivate; class StrongWorkerRef;
class WeakWorkerRef;
extern const uint64_t kUnknownSize; extern const uint64_t kUnknownSize;
@ -39,14 +39,13 @@ class FileReader final : public DOMEventTargetHelper,
public nsSupportsWeakReference, public nsSupportsWeakReference,
public nsIInputStreamCallback, public nsIInputStreamCallback,
public nsITimerCallback, public nsITimerCallback,
public nsINamed, public nsINamed
public WorkerHolder
{ {
friend class FileReaderDecreaseBusyCounter; friend class FileReaderDecreaseBusyCounter;
public: public:
FileReader(nsIGlobalObject* aGlobal, FileReader(nsIGlobalObject* aGlobal,
WorkerPrivate* aWorkerPrivate); WeakWorkerRef* aWorkerRef);
NS_DECL_ISUPPORTS_INHERITED NS_DECL_ISUPPORTS_INHERITED
@ -111,9 +110,6 @@ public:
ReadFileContent(aBlob, EmptyString(), FILE_AS_BINARY, aRv); ReadFileContent(aBlob, EmptyString(), FILE_AS_BINARY, aRv);
} }
// WorkerHolder
bool Notify(WorkerStatus) override;
private: private:
virtual ~FileReader(); virtual ~FileReader();
@ -197,8 +193,14 @@ private:
uint64_t mBusyCount; uint64_t mBusyCount;
// Kept alive with a WorkerHolder. // This is set if FileReader is created on workers, but it is null if the
WorkerPrivate* mWorkerPrivate; // worker is shutting down. The null value is checked in ReadFileContent()
// before starting any reading.
RefPtr<WeakWorkerRef> mWeakWorkerRef;
// This value is set when the reading starts in order to keep the worker alive
// during the process.
RefPtr<StrongWorkerRef> mStrongWorkerRef;
}; };
} // dom namespace } // dom namespace

Просмотреть файл

@ -1843,7 +1843,7 @@ nsGenericHTMLElement*
HTMLInputElement::GetList() const HTMLInputElement::GetList() const
{ {
nsAutoString dataListId; nsAutoString dataListId;
GetAttr(kNameSpaceID_None, nsGkAtoms::list, dataListId); GetAttr(kNameSpaceID_None, nsGkAtoms::list_, dataListId);
if (dataListId.IsEmpty()) { if (dataListId.IsEmpty()) {
return nullptr; return nullptr;
} }

Просмотреть файл

@ -35,24 +35,21 @@ HTMLMetaElement::~HTMLMetaElement()
NS_IMPL_ELEMENT_CLONE(HTMLMetaElement) NS_IMPL_ELEMENT_CLONE(HTMLMetaElement)
nsresult void
HTMLMetaElement::SetMetaReferrer(nsIDocument* aDocument) HTMLMetaElement::SetMetaReferrer(nsIDocument* aDocument)
{ {
if (!aDocument || if (!aDocument ||
!AttrValueIs(kNameSpaceID_None, nsGkAtoms::name, nsGkAtoms::referrer, eIgnoreCase)) { !AttrValueIs(kNameSpaceID_None, nsGkAtoms::name, nsGkAtoms::referrer, eIgnoreCase)) {
return NS_OK; return;
} }
nsAutoString content; nsAutoString content;
nsresult rv = GetContent(content); GetContent(content);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
Element* headElt = aDocument->GetHeadElement(); Element* headElt = aDocument->GetHeadElement();
if (headElt && nsContentUtils::ContentIsDescendantOf(this, headElt)) { if (headElt && nsContentUtils::ContentIsDescendantOf(this, headElt)) {
content = nsContentUtils::TrimWhitespace<nsContentUtils::IsHTMLWhitespace>(content); content = nsContentUtils::TrimWhitespace<nsContentUtils::IsHTMLWhitespace>(content);
aDocument->SetHeaderData(nsGkAtoms::referrer, content); aDocument->SetHeaderData(nsGkAtoms::referrer, content);
} }
return NS_OK;
} }
nsresult nsresult
@ -68,17 +65,13 @@ HTMLMetaElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
if (document && AttrValueIs(kNameSpaceID_None, nsGkAtoms::name, if (document && AttrValueIs(kNameSpaceID_None, nsGkAtoms::name,
nsGkAtoms::viewport, eIgnoreCase)) { nsGkAtoms::viewport, eIgnoreCase)) {
nsAutoString content; nsAutoString content;
nsresult rv = GetContent(content); GetContent(content);
NS_ENSURE_SUCCESS(rv, rv);
nsContentUtils::ProcessViewportInfo(document, content); nsContentUtils::ProcessViewportInfo(document, content);
} }
CreateAndDispatchEvent(document, NS_LITERAL_STRING("DOMMetaChanged")); CreateAndDispatchEvent(document, NS_LITERAL_STRING("DOMMetaChanged"));
} }
// Update referrer policy when it got changed from JS // Update referrer policy when it got changed from JS
nsresult rv = SetMetaReferrer(document); SetMetaReferrer(document);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
} }
return nsGenericHTMLElement::AfterSetAttr(aNameSpaceID, aName, aValue, return nsGenericHTMLElement::AfterSetAttr(aNameSpaceID, aName, aValue,
@ -97,8 +90,7 @@ HTMLMetaElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
if (aDocument && if (aDocument &&
AttrValueIs(kNameSpaceID_None, nsGkAtoms::name, nsGkAtoms::viewport, eIgnoreCase)) { AttrValueIs(kNameSpaceID_None, nsGkAtoms::name, nsGkAtoms::viewport, eIgnoreCase)) {
nsAutoString content; nsAutoString content;
rv = GetContent(content); GetContent(content);
NS_ENSURE_SUCCESS(rv, rv);
nsContentUtils::ProcessViewportInfo(aDocument, content); nsContentUtils::ProcessViewportInfo(aDocument, content);
} }
@ -111,8 +103,7 @@ HTMLMetaElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
if (headElt && nsContentUtils::ContentIsDescendantOf(this, headElt)) { if (headElt && nsContentUtils::ContentIsDescendantOf(this, headElt)) {
nsAutoString content; nsAutoString content;
rv = GetContent(content); GetContent(content);
NS_ENSURE_SUCCESS(rv, rv);
content = nsContentUtils::TrimWhitespace<nsContentUtils::IsHTMLWhitespace>(content); content = nsContentUtils::TrimWhitespace<nsContentUtils::IsHTMLWhitespace>(content);
nsIPrincipal* principal = aDocument->NodePrincipal(); nsIPrincipal* principal = aDocument->NodePrincipal();
@ -145,10 +136,7 @@ HTMLMetaElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
// Referrer Policy spec requires a <meta name="referrer" tag to be in the // Referrer Policy spec requires a <meta name="referrer" tag to be in the
// <head> element. // <head> element.
rv = SetMetaReferrer(aDocument); SetMetaReferrer(aDocument);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
CreateAndDispatchEvent(aDocument, NS_LITERAL_STRING("DOMMetaAdded")); CreateAndDispatchEvent(aDocument, NS_LITERAL_STRING("DOMMetaAdded"));
return rv; return rv;
} }

Просмотреть файл

@ -54,10 +54,9 @@ public:
{ {
SetHTMLAttr(nsGkAtoms::httpEquiv, aHttpEquiv, aRv); SetHTMLAttr(nsGkAtoms::httpEquiv, aHttpEquiv, aRv);
} }
nsresult GetContent(nsAString& aValue) void GetContent(nsAString& aValue)
{ {
GetHTMLAttr(nsGkAtoms::content, aValue); GetHTMLAttr(nsGkAtoms::content, aValue);
return NS_OK;
} }
void SetContent(const nsAString& aContent, ErrorResult& aRv) void SetContent(const nsAString& aContent, ErrorResult& aRv)
{ {
@ -78,7 +77,7 @@ protected:
virtual ~HTMLMetaElement(); virtual ~HTMLMetaElement();
private: private:
nsresult SetMetaReferrer(nsIDocument* aDocument); void SetMetaReferrer(nsIDocument* aDocument);
}; };
} // namespace dom } // namespace dom

Просмотреть файл

@ -37,7 +37,6 @@
#include "nsGenericHTMLElement.h" #include "nsGenericHTMLElement.h"
#include "nsIDOMDocument.h" #include "nsIDOMDocument.h"
#include "nsIDOMDocumentType.h"
#include "nsIScriptElement.h" #include "nsIScriptElement.h"
#include "nsIComponentManager.h" #include "nsIComponentManager.h"

Просмотреть файл

@ -20,7 +20,6 @@ interface nsIDOMCharacterData;
interface nsIDOMComment; interface nsIDOMComment;
interface nsIDOMDocument; interface nsIDOMDocument;
interface nsIDOMDocumentFragment; interface nsIDOMDocumentFragment;
interface nsIDOMDocumentType;
interface nsIDOMElement; interface nsIDOMElement;
interface nsIDOMNode; interface nsIDOMNode;
interface nsIDOMNodeList; interface nsIDOMNodeList;

Просмотреть файл

@ -12,7 +12,6 @@ XPIDL_SOURCES += [
'nsIDOMComment.idl', 'nsIDOMComment.idl',
'nsIDOMDocument.idl', 'nsIDOMDocument.idl',
'nsIDOMDocumentFragment.idl', 'nsIDOMDocumentFragment.idl',
'nsIDOMDocumentType.idl',
'nsIDOMDOMException.idl', 'nsIDOMDOMException.idl',
'nsIDOMElement.idl', 'nsIDOMElement.idl',
'nsIDOMNode.idl', 'nsIDOMNode.idl',

Просмотреть файл

@ -1,25 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsIDOMNode.idl"
/**
* Each Document has a doctype attribute whose value is either null
* or a DocumentType object.
* The nsIDOMDocumentType interface in the DOM Core provides an
* interface to the list of entities that are defined for the document.
*
* For more information on this interface please see
* http://www.w3.org/TR/DOM-Level-2-Core/
*/
[uuid(cd7467b9-0f26-4787-a359-66e80ba8db92)]
interface nsIDOMDocumentType : nsIDOMNode
{
readonly attribute DOMString name;
readonly attribute DOMString publicId;
readonly attribute DOMString systemId;
readonly attribute DOMString internalSubset;
};

Просмотреть файл

@ -9,7 +9,6 @@ with Files("**"):
XPIDL_SOURCES += [ XPIDL_SOURCES += [
'nsIDOMCustomEvent.idl', 'nsIDOMCustomEvent.idl',
'nsIDOMDataTransfer.idl',
'nsIDOMDragEvent.idl', 'nsIDOMDragEvent.idl',
'nsIDOMEvent.idl', 'nsIDOMEvent.idl',
'nsIDOMEventListener.idl', 'nsIDOMEventListener.idl',

Просмотреть файл

@ -1,143 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "domstubs.idl"
interface nsIVariant;
interface nsIDOMFileList;
[builtinclass, uuid(655078bf-1675-4aa0-a48d-a133e864ce57)]
interface nsIDOMDataTransfer : nsISupports
{
/**
* The actual effect that will be used, and should always be one of the
* possible values of effectAllowed.
*
* For dragstart, drag and dragleave events, the dropEffect is initialized
* to none. Any value assigned to the dropEffect will be set, but the value
* isn't used for anything.
*
* For the dragenter and dragover events, the dropEffect will be initialized
* based on what action the user is requesting. How this is determined is
* platform specific, but typically the user can press modifier keys to
* adjust which action is desired. Within an event handler for the dragenter
* and dragover events, the dropEffect should be modified if the action the
* user is requesting is not the one that is desired.
*
* For the drop and dragend events, the dropEffect will be initialized to
* the action that was desired, which will be the value that the dropEffect
* had after the last dragenter or dragover event.
*
* Possible values:
* copy - a copy of the source item is made at the new location
* move - an item is moved to a new location
* link - a link is established to the source at the new location
* none - the item may not be dropped
*
* Assigning any other value has no effect and retains the old value.
*/
attribute DOMString dropEffect;
/*
* Specifies the effects that are allowed for this drag. You may set this in
* the dragstart event to set the desired effects for the source, and within
* the dragenter and dragover events to set the desired effects for the
* target. The value is not used for other events.
*
* Possible values:
* copy - a copy of the source item is made at the new location
* move - an item is moved to a new location
* link - a link is established to the source at the new location
* copyLink, copyMove, linkMove, all - combinations of the above
* none - the item may not be dropped
* uninitialized - the default value when the effect has not been set,
* equivalent to all.
*
* Assigning any other value has no effect and retains the old value.
*/
attribute DOMString effectAllowed;
/**
* Holds a list of all the local files available on this data transfer.
* A dataTransfer containing no files will return an empty list, and an
* invalid index access on the resulting file list will return null.
*/
readonly attribute nsIDOMFileList files;
/**
* Set the image to be used for dragging if a custom one is desired. Most of
* the time, this would not be set, as a default image is created from the
* node that was dragged.
*
* If the node is an HTML img element, an HTML canvas element or a XUL image
* element, the image data is used. Otherwise, image should be a visible
* node and the drag image will be created from this. If image is null, any
* custom drag image is cleared and the default is used instead.
*
* The coordinates specify the offset into the image where the mouse cursor
* should be. To center the image for instance, use values that are half the
* width and height.
*
* @param image a node to use
* @param x the horizontal offset
* @param y the vertical offset
* @throws NO_MODIFICATION_ALLOWED_ERR if the item cannot be modified
*/
void setDragImage(in nsIDOMElement image, in long x, in long y);
/*
* Set the drag source. Usually you would not change this, but it will
* affect which node the drag and dragend events are fired at. The
* default target is the node that was dragged.
*
* @param element drag source to use
* @throws NO_MODIFICATION_ALLOWED_ERR if the item cannot be modified
*/
void addElement(in nsIDOMElement element);
/**
* The number of items being dragged.
*/
readonly attribute unsigned long mozItemCount;
/**
* Sets the drag cursor state. Primarily used to control the cursor during
* tab drags, but could be expanded to other uses. XXX Currently implemented
* on Win32 only.
*
* Possible values:
* auto - use default system behavior.
* default - set the cursor to an arrow during the drag operation.
*
* Values other than 'default' are indentical to setting mozCursor to
* 'auto'.
*/
attribute DOMString mozCursor;
/**
* Will be true when the user has cancelled the drag (typically by pressing
* Escape) and when the drag has been cancelled unexpectedly. This will be
* false otherwise, including when the drop has been rejected by its target.
* This property is only relevant for the dragend event.
*/
readonly attribute boolean mozUserCancelled;
/**
* The node that the mouse was pressed over to begin the drag. For external
* drags, or if the caller cannot access this node, this will be null.
*/
readonly attribute nsIDOMNode mozSourceNode;
/*
* Integer version of dropEffect, set to one of the constants in nsIDragService.
*/
[noscript] attribute unsigned long dropEffectInt;
/*
* Integer version of effectAllowed, set to one or a combination of the
* constants in nsIDragService.
*/
[noscript] attribute unsigned long effectAllowedInt;
};

Просмотреть файл

@ -6,10 +6,8 @@
#include "domstubs.idl" #include "domstubs.idl"
#include "nsIDOMMouseEvent.idl" #include "nsIDOMMouseEvent.idl"
interface nsIDOMDataTransfer; // FIXME: Bug 1445417, we should really remove this interface.
[builtinclass, uuid(d5c0d4c2-c646-4b4b-836e-48408b9c7b80)] [builtinclass, uuid(d5c0d4c2-c646-4b4b-836e-48408b9c7b80)]
interface nsIDOMDragEvent : nsIDOMMouseEvent interface nsIDOMDragEvent : nsIDOMMouseEvent
{ {
readonly attribute nsIDOMDataTransfer dataTransfer;
}; };

Просмотреть файл

@ -4512,9 +4512,7 @@ ContentParent::MaybeInvokeDragSession(TabParent* aParent)
dragService->GetCurrentSession(getter_AddRefs(session)); dragService->GetCurrentSession(getter_AddRefs(session));
if (session) { if (session) {
nsTArray<IPCDataTransfer> dataTransfers; nsTArray<IPCDataTransfer> dataTransfers;
nsCOMPtr<nsIDOMDataTransfer> domTransfer; RefPtr<DataTransfer> transfer = session->GetDataTransfer();
session->GetDataTransfer(getter_AddRefs(domTransfer));
nsCOMPtr<DataTransfer> transfer = do_QueryInterface(domTransfer);
if (!transfer) { if (!transfer) {
// Pass eDrop to get DataTransfer with external // Pass eDrop to get DataTransfer with external
// drag formats cached. // drag formats cached.
@ -4548,8 +4546,7 @@ ContentParent::RecvUpdateDropEffect(const uint32_t& aDragAction,
nsCOMPtr<nsIDragSession> dragSession = nsContentUtils::GetDragSession(); nsCOMPtr<nsIDragSession> dragSession = nsContentUtils::GetDragSession();
if (dragSession) { if (dragSession) {
dragSession->SetDragAction(aDragAction); dragSession->SetDragAction(aDragAction);
nsCOMPtr<nsIDOMDataTransfer> dt; RefPtr<DataTransfer> dt = dragSession->GetDataTransfer();
dragSession->GetDataTransfer(getter_AddRefs(dt));
if (dt) { if (dt) {
dt->SetDropEffectInt(aDropEffect); dt->SetDropEffectInt(aDropEffect);
} }

Просмотреть файл

@ -19,6 +19,7 @@
#include "mozilla/BrowserElementParent.h" #include "mozilla/BrowserElementParent.h"
#include "mozilla/ClearOnShutdown.h" #include "mozilla/ClearOnShutdown.h"
#include "mozilla/EventListenerManager.h" #include "mozilla/EventListenerManager.h"
#include "mozilla/dom/DataTransfer.h"
#include "mozilla/dom/indexedDB/PIndexedDBPermissionRequestChild.h" #include "mozilla/dom/indexedDB/PIndexedDBPermissionRequestChild.h"
#include "mozilla/dom/PaymentRequestChild.h" #include "mozilla/dom/PaymentRequestChild.h"
#include "mozilla/dom/TelemetryScrollProbe.h" #include "mozilla/dom/TelemetryScrollProbe.h"
@ -1955,8 +1956,7 @@ TabChild::RecvRealDragEvent(const WidgetDragEvent& aEvent,
if (dragSession) { if (dragSession) {
dragSession->SetDragAction(aDragAction); dragSession->SetDragAction(aDragAction);
dragSession->SetTriggeringPrincipalURISpec(aPrincipalURISpec); dragSession->SetTriggeringPrincipalURISpec(aPrincipalURISpec);
nsCOMPtr<nsIDOMDataTransfer> initialDataTransfer; RefPtr<DataTransfer> initialDataTransfer = dragSession->GetDataTransfer();
dragSession->GetDataTransfer(getter_AddRefs(initialDataTransfer));
if (initialDataTransfer) { if (initialDataTransfer) {
initialDataTransfer->SetDropEffectInt(aDropEffect); initialDataTransfer->SetDropEffectInt(aDropEffect);
} }

Просмотреть файл

@ -1179,8 +1179,7 @@ TabParent::QueryDropLinksForVerification()
return false; return false;
} }
nsCOMPtr<nsIDOMDataTransfer> initialDataTransfer; RefPtr<DataTransfer> initialDataTransfer = dragSession->GetDataTransfer();
dragSession->GetDataTransfer(getter_AddRefs(initialDataTransfer));
if (!initialDataTransfer) { if (!initialDataTransfer) {
NS_WARNING("No initialDataTransfer to query links for verification"); NS_WARNING("No initialDataTransfer to query links for verification");
return false; return false;

Просмотреть файл

@ -9,7 +9,6 @@
#include "mozilla/dom/MessageChannelBinding.h" #include "mozilla/dom/MessageChannelBinding.h"
#include "mozilla/dom/MessagePort.h" #include "mozilla/dom/MessagePort.h"
#include "mozilla/dom/Navigator.h" #include "mozilla/dom/Navigator.h"
#include "mozilla/dom/WorkerPrivate.h"
#include "mozilla/dom/WorkerRunnable.h" #include "mozilla/dom/WorkerRunnable.h"
#include "nsContentUtils.h" #include "nsContentUtils.h"
#include "nsIDocument.h" #include "nsIDocument.h"

Просмотреть файл

@ -18,7 +18,7 @@
#include "mozilla/dom/PMessagePort.h" #include "mozilla/dom/PMessagePort.h"
#include "mozilla/dom/ScriptSettings.h" #include "mozilla/dom/ScriptSettings.h"
#include "mozilla/dom/StructuredCloneTags.h" #include "mozilla/dom/StructuredCloneTags.h"
#include "mozilla/dom/WorkerPrivate.h" #include "mozilla/dom/WorkerRef.h"
#include "mozilla/dom/WorkerScope.h" #include "mozilla/dom/WorkerScope.h"
#include "mozilla/ipc/BackgroundChild.h" #include "mozilla/ipc/BackgroundChild.h"
#include "mozilla/ipc/PBackgroundChild.h" #include "mozilla/ipc/PBackgroundChild.h"
@ -200,41 +200,6 @@ NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
NS_IMPL_ADDREF_INHERITED(MessagePort, DOMEventTargetHelper) NS_IMPL_ADDREF_INHERITED(MessagePort, DOMEventTargetHelper)
NS_IMPL_RELEASE_INHERITED(MessagePort, DOMEventTargetHelper) NS_IMPL_RELEASE_INHERITED(MessagePort, DOMEventTargetHelper)
namespace {
class MessagePortWorkerHolder final : public WorkerHolder
{
MessagePort* mPort;
public:
explicit MessagePortWorkerHolder(MessagePort* aPort)
: WorkerHolder("MessagePortWorkerHolder")
, mPort(aPort)
{
MOZ_ASSERT(aPort);
MOZ_COUNT_CTOR(MessagePortWorkerHolder);
}
virtual bool Notify(WorkerStatus aStatus) override
{
if (aStatus > Running) {
// We cannot process messages anymore because we cannot dispatch new
// runnables. Let's force a Close().
mPort->CloseForced();
}
return true;
}
private:
~MessagePortWorkerHolder()
{
MOZ_COUNT_DTOR(MessagePortWorkerHolder);
}
};
} // namespace
MessagePort::MessagePort(nsIGlobalObject* aGlobal) MessagePort::MessagePort(nsIGlobalObject* aGlobal)
: DOMEventTargetHelper(aGlobal) : DOMEventTargetHelper(aGlobal)
, mInnerID(0) , mInnerID(0)
@ -251,7 +216,7 @@ MessagePort::MessagePort(nsIGlobalObject* aGlobal)
MessagePort::~MessagePort() MessagePort::~MessagePort()
{ {
CloseForced(); CloseForced();
MOZ_ASSERT(!mWorkerHolder); MOZ_ASSERT(!mWorkerRef);
} }
/* static */ already_AddRefed<MessagePort> /* static */ already_AddRefed<MessagePort>
@ -304,7 +269,7 @@ MessagePort::Initialize(const nsID& aUUID,
if (mNeutered) { if (mNeutered) {
// If this port is neutered we don't want to keep it alive artificially nor // If this port is neutered we don't want to keep it alive artificially nor
// we want to add listeners or workerWorkerHolders. // we want to add listeners or WorkerRefs.
mState = eStateDisentangled; mState = eStateDisentangled;
return; return;
} }
@ -322,17 +287,24 @@ MessagePort::Initialize(const nsID& aUUID,
UpdateMustKeepAlive(); UpdateMustKeepAlive();
if (!NS_IsMainThread()) { if (!NS_IsMainThread()) {
RefPtr<MessagePort> self = this;
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate(); WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
MOZ_ASSERT(workerPrivate); MOZ_ASSERT(workerPrivate);
MOZ_ASSERT(!mWorkerHolder);
nsAutoPtr<WorkerHolder> workerHolder(new MessagePortWorkerHolder(this)); // When the callback is executed, we cannot process messages anymore because
if (NS_WARN_IF(!workerHolder->HoldWorker(workerPrivate, Closing))) { // we cannot dispatch new runnables. Let's force a Close().
aRv.Throw(NS_ERROR_FAILURE); RefPtr<StrongWorkerRef> strongWorkerRef =
StrongWorkerRef::Create(workerPrivate, "MessagePort",
[self]() { self->CloseForced(); });
if (NS_WARN_IF(!strongWorkerRef)) {
// The worker is shutting down. Let's return an already closed port.
mState = eStateDisentangledForClose;
return; return;
} }
mWorkerHolder = Move(workerHolder); MOZ_ASSERT(!mWorkerRef);
mWorkerRef = Move(strongWorkerRef);
} else if (GetOwner()) { } else if (GetOwner()) {
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
mInnerID = GetOwner()->WindowID(); mInnerID = GetOwner()->WindowID();
@ -869,8 +841,8 @@ MessagePort::UpdateMustKeepAlive()
mIsKeptAlive) { mIsKeptAlive) {
mIsKeptAlive = false; mIsKeptAlive = false;
// The DTOR of this WorkerHolder will release the worker for us. // The DTOR of this WorkerRef will release the worker for us.
mWorkerHolder = nullptr; mWorkerRef = nullptr;
if (NS_IsMainThread()) { if (NS_IsMainThread()) {
nsCOMPtr<nsIObserverService> obs = nsCOMPtr<nsIObserverService> obs =

Просмотреть файл

@ -26,7 +26,7 @@ class MessagePortChild;
class MessagePortIdentifier; class MessagePortIdentifier;
class PostMessageRunnable; class PostMessageRunnable;
class SharedMessagePortMessage; class SharedMessagePortMessage;
class WorkerHolder; class StrongWorkerRef;
class MessagePort final : public DOMEventTargetHelper class MessagePort final : public DOMEventTargetHelper
, public nsIObserver , public nsIObserver
@ -162,7 +162,7 @@ private:
return mIsKeptAlive; return mIsKeptAlive;
} }
nsAutoPtr<WorkerHolder> mWorkerHolder; RefPtr<StrongWorkerRef> mWorkerRef;
RefPtr<PostMessageRunnable> mPostMessageRunnable; RefPtr<PostMessageRunnable> mPostMessageRunnable;

Просмотреть файл

@ -7,6 +7,7 @@
#include <limits> #include <limits>
#include "mozilla/Hal.h" #include "mozilla/Hal.h"
#include "ConnectionWorker.h" #include "ConnectionWorker.h"
#include "mozilla/dom/WorkerRef.h"
#include "mozilla/dom/WorkerRunnable.h" #include "mozilla/dom/WorkerRunnable.h"
namespace mozilla { namespace mozilla {
@ -14,7 +15,6 @@ namespace dom {
namespace network { namespace network {
class ConnectionProxy final : public NetworkObserver class ConnectionProxy final : public NetworkObserver
, public WorkerHolder
{ {
public: public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(ConnectionProxy) NS_INLINE_DECL_THREADSAFE_REFCOUNTING(ConnectionProxy)
@ -22,45 +22,37 @@ public:
static already_AddRefed<ConnectionProxy> static already_AddRefed<ConnectionProxy>
Create(WorkerPrivate* aWorkerPrivate, ConnectionWorker* aConnection) Create(WorkerPrivate* aWorkerPrivate, ConnectionWorker* aConnection)
{ {
RefPtr<ConnectionProxy> proxy = RefPtr<ConnectionProxy> proxy = new ConnectionProxy(aConnection);
new ConnectionProxy(aWorkerPrivate, aConnection);
if (!proxy->HoldWorker(aWorkerPrivate, Closing)) { RefPtr<StrongWorkerRef> workerRef =
proxy->mConnection = nullptr; StrongWorkerRef::Create(aWorkerPrivate, "ConnectionProxy",
[proxy]() { proxy->Shutdown(); });
if (NS_WARN_IF(!workerRef)) {
return nullptr; return nullptr;
} }
proxy->mWorkerRef = new ThreadSafeWorkerRef(workerRef);
return proxy.forget(); return proxy.forget();
} }
ThreadSafeWorkerRef* WorkerRef() const { return mWorkerRef; }
// For IObserver - main-thread only. // For IObserver - main-thread only.
void Notify(const hal::NetworkInformation& aNetworkInfo) override; void Notify(const hal::NetworkInformation& aNetworkInfo) override;
// Worker notification
virtual bool Notify(WorkerStatus aStatus) override
{
Shutdown();
return true;
}
void Shutdown(); void Shutdown();
void Update(ConnectionType aType, bool aIsWifi, uint32_t aDHCPGateway) void Update(ConnectionType aType, bool aIsWifi, uint32_t aDHCPGateway)
{ {
MOZ_ASSERT(mConnection); MOZ_ASSERT(mConnection);
mWorkerPrivate->AssertIsOnWorkerThread(); MOZ_ASSERT(IsCurrentThreadRunningWorker());
mConnection->Update(aType, aIsWifi, aDHCPGateway, true); mConnection->Update(aType, aIsWifi, aDHCPGateway, true);
} }
private: private:
ConnectionProxy(WorkerPrivate* aWorkerPrivate, ConnectionWorker* aConnection) explicit ConnectionProxy(ConnectionWorker* aConnection)
: WorkerHolder("ConnectionProxy") : mConnection(aConnection)
, mConnection(aConnection) {}
, mWorkerPrivate(aWorkerPrivate)
{
MOZ_ASSERT(mWorkerPrivate);
MOZ_ASSERT(mConnection);
mWorkerPrivate->AssertIsOnWorkerThread();
}
~ConnectionProxy() = default; ~ConnectionProxy() = default;
@ -69,7 +61,7 @@ private:
// shutdown procedure starts. // shutdown procedure starts.
ConnectionWorker* mConnection; ConnectionWorker* mConnection;
WorkerPrivate* mWorkerPrivate; RefPtr<ThreadSafeWorkerRef> mWorkerRef;
}; };
namespace { namespace {
@ -168,7 +160,7 @@ public:
/* static */ already_AddRefed<ConnectionWorker> /* static */ already_AddRefed<ConnectionWorker>
ConnectionWorker::Create(WorkerPrivate* aWorkerPrivate, ErrorResult& aRv) ConnectionWorker::Create(WorkerPrivate* aWorkerPrivate, ErrorResult& aRv)
{ {
RefPtr<ConnectionWorker> c = new ConnectionWorker(aWorkerPrivate); RefPtr<ConnectionWorker> c = new ConnectionWorker();
c->mProxy = ConnectionProxy::Create(aWorkerPrivate, c); c->mProxy = ConnectionProxy::Create(aWorkerPrivate, c);
if (!c->mProxy) { if (!c->mProxy) {
aRv.ThrowTypeError<MSG_WORKER_THREAD_SHUTTING_DOWN>(); aRv.ThrowTypeError<MSG_WORKER_THREAD_SHUTTING_DOWN>();
@ -189,12 +181,10 @@ ConnectionWorker::Create(WorkerPrivate* aWorkerPrivate, ErrorResult& aRv)
return c.forget(); return c.forget();
} }
ConnectionWorker::ConnectionWorker(WorkerPrivate* aWorkerPrivate) ConnectionWorker::ConnectionWorker()
: Connection(nullptr) : Connection(nullptr)
, mWorkerPrivate(aWorkerPrivate)
{ {
MOZ_ASSERT(aWorkerPrivate); MOZ_ASSERT(IsCurrentThreadRunningWorker());
aWorkerPrivate->AssertIsOnWorkerThread();
} }
ConnectionWorker::~ConnectionWorker() ConnectionWorker::~ConnectionWorker()
@ -205,7 +195,7 @@ ConnectionWorker::~ConnectionWorker()
void void
ConnectionWorker::ShutdownInternal() ConnectionWorker::ShutdownInternal()
{ {
mWorkerPrivate->AssertIsOnWorkerThread(); MOZ_ASSERT(IsCurrentThreadRunningWorker());
mProxy->Shutdown(); mProxy->Shutdown();
} }
@ -215,7 +205,7 @@ ConnectionProxy::Notify(const hal::NetworkInformation& aNetworkInfo)
MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(NS_IsMainThread());
RefPtr<NotifyRunnable> runnable = RefPtr<NotifyRunnable> runnable =
new NotifyRunnable(mWorkerPrivate, this, new NotifyRunnable(mWorkerRef->Private(), this,
static_cast<ConnectionType>(aNetworkInfo.type()), static_cast<ConnectionType>(aNetworkInfo.type()),
aNetworkInfo.isWifi(), aNetworkInfo.dhcpGateway()); aNetworkInfo.isWifi(), aNetworkInfo.dhcpGateway());
runnable->Dispatch(); runnable->Dispatch();
@ -224,7 +214,7 @@ ConnectionProxy::Notify(const hal::NetworkInformation& aNetworkInfo)
void void
ConnectionProxy::Shutdown() ConnectionProxy::Shutdown()
{ {
mWorkerPrivate->AssertIsOnWorkerThread(); MOZ_ASSERT(IsCurrentThreadRunningWorker());
// Already shut down. // Already shut down.
if (!mConnection) { if (!mConnection) {
@ -234,7 +224,7 @@ ConnectionProxy::Shutdown()
mConnection = nullptr; mConnection = nullptr;
RefPtr<ShutdownRunnable> runnable = RefPtr<ShutdownRunnable> runnable =
new ShutdownRunnable(mWorkerPrivate, this); new ShutdownRunnable(mWorkerRef->Private(), this);
ErrorResult rv; ErrorResult rv;
// This runnable _must_ be executed. // This runnable _must_ be executed.
@ -243,7 +233,7 @@ ConnectionProxy::Shutdown()
rv.SuppressException(); rv.SuppressException();
} }
ReleaseWorker(); mWorkerRef = nullptr;
} }
} // namespace network } // namespace network

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше