Merge mozilla-central to mozilla-inbound

This commit is contained in:
Daniel Varga 2019-06-01 12:45:58 +03:00
commit f35d98dcc4
245 changed files with 2600 additions and 1347 deletions

View File

@ -4790,9 +4790,11 @@ window._gBrowser = {
el.setAttribute("data-l10n-id", el.getAttribute("data-lazy-l10n-id"));
el.removeAttribute("data-lazy-l10n-id");
});
this.tabContainer.removeEventListener("contextmenu", tabContextFTLInserter, true);
this.tabContainer.removeEventListener("mouseover", tabContextFTLInserter);
this.tabContainer.removeEventListener("focus", tabContextFTLInserter, true);
};
this.tabContainer.addEventListener("contextmenu", tabContextFTLInserter, true);
this.tabContainer.addEventListener("mouseover", tabContextFTLInserter);
this.tabContainer.addEventListener("focus", tabContextFTLInserter, true);
},

View File

@ -34,9 +34,13 @@ function sleep(ms) {
async function blockedIconShown() {
await TestUtils.waitForCondition(() => {
return BrowserTestUtils.is_visible(autoplayBlockedIcon());
});
}, "Blocked icon is shown");
}
ok(BrowserTestUtils.is_visible(autoplayBlockedIcon()), "Blocked icon is shown");
async function blockedIconHidden() {
await TestUtils.waitForCondition(() => {
return BrowserTestUtils.is_hidden(autoplayBlockedIcon());
}, "Blocked icon is hidden");
}
add_task(async function setup() {
@ -133,9 +137,7 @@ add_task(async function testBFCache() {
await blockedIconShown();
gBrowser.goBack();
await TestUtils.waitForCondition(() => {
return BrowserTestUtils.is_hidden(autoplayBlockedIcon());
});
await blockedIconHidden();
// Not sure why using `gBrowser.goForward()` doesn't trigger document's
// visibility changes in some debug build on try server, which makes us not
@ -158,9 +160,7 @@ add_task(async function testChangingBlockingSettingDuringNavigation() {
Services.prefs.setIntPref(AUTOPLAY_PREF, Ci.nsIAutoplay.ALLOWED);
gBrowser.goBack();
await TestUtils.waitForCondition(() => {
return BrowserTestUtils.is_hidden(autoplayBlockedIcon());
});
await blockedIconHidden();
gBrowser.goForward();
@ -184,9 +184,7 @@ add_task(async function testSlowLoadingPage() {
await BrowserTestUtils.switchTab(gBrowser, tab1);
// Wait until the blocked icon is hidden by switching tabs
await TestUtils.waitForCondition(() => {
return BrowserTestUtils.is_hidden(autoplayBlockedIcon());
});
await blockedIconHidden();
await BrowserTestUtils.switchTab(gBrowser, tab2);
await blockedIconShown();

View File

@ -1,7 +1,7 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
const DELAY_MS = "1000";
const DELAY_MS = 200;
const AUTOPLAY_HTML = `<!DOCTYPE HTML>
<html dir="ltr" xml:lang="en-US" lang="en-US">
@ -12,7 +12,9 @@ const AUTOPLAY_HTML = `<!DOCTYPE HTML>
<audio autoplay="autoplay" >
<source src="audio.ogg" />
</audio>
<script>setTimeout(() => { document.location.href = '#foo'; }, 500);</script>
<script>
document.location.href = '#foo';
</script>
</body>
</html>`;
@ -27,4 +29,4 @@ function handleRequest(req, resp) {
resp.write("");
resp.finish();
}, DELAY_MS, Ci.nsITimer.TYPE_ONE_SHOT);
}
}

View File

@ -219,6 +219,7 @@ class LoginItem extends ReflectedFluentElement {
return;
}
this.toggleEditing(false);
this._login = login;
this.render();
}
@ -227,6 +228,8 @@ class LoginItem extends ReflectedFluentElement {
if (login.guid != this._login.guid) {
return;
}
this.toggleEditing(false);
this._login = {};
this.render();
}

View File

@ -12,6 +12,8 @@
padding: 10px;
border-bottom: 1px solid var(--in-content-box-border-color);
background-color: var(--in-content-box-info-background);
position: sticky;
top: 0;
}
.count {

View File

@ -127,6 +127,8 @@ class ModalInput extends ReflectedFluentElement {
} else {
lockedValue.textContent = val;
}
let revealCheckbox = this.shadowRoot.querySelector(".reveal-checkbox");
revealCheckbox.checked = false;
}
checkValidity() {

View File

@ -66,6 +66,8 @@ add_task(async function test_login_item() {
usernameInput.value += "-saveme";
passwordInput.value += "-saveme";
ok(loginItem.hasAttribute("editing"), "LoginItem should be in 'edit' mode");
let saveChangesButton = loginItem.shadowRoot.querySelector(".save-changes-button");
saveChangesButton.click();
@ -74,5 +76,21 @@ add_task(async function test_login_item() {
return loginListItem._login.username == usernameInput.value &&
loginListItem._login.password == passwordInput.value;
}, "Waiting for corresponding login in login list to update");
ok(!loginItem.hasAttribute("editing"), "LoginItem should not be in 'edit' mode after saving");
editButton.click();
await Promise.resolve();
ok(loginItem.hasAttribute("editing"), "LoginItem should be in 'edit' mode");
let deleteButton = loginItem.shadowRoot.querySelector(".delete-button");
deleteButton.click();
await ContentTaskUtils.waitForCondition(() => {
loginListItem = Cu.waiveXrays(loginList.shadowRoot.querySelector("login-list-item"));
return !loginListItem;
}, "Waiting for login to be removed from list");
ok(!loginItem.hasAttribute("editing"), "LoginItem should not be in 'edit' mode after deleting");
});
});

View File

@ -37,6 +37,16 @@ const TEST_LOGIN_1 = {
timeLastUsed: "4000",
};
const TEST_LOGIN_2 = {
guid: "987654321",
hostname: "https://example.com",
username: "user2",
password: "pass2",
timeCreated: "2000",
timePasswordChanged: "4000",
timeLastUsed: "8000",
};
add_task(async function setup() {
stubFluentL10n({
"time-created": "timeCreated",
@ -130,6 +140,19 @@ add_task(async function test_edit_login_cancel() {
}
});
add_task(async function test_reveal_password_change_selected_login() {
gLoginItem.setLogin(TEST_LOGIN_1);
let passwordInput = gLoginItem.shadowRoot.querySelector('modal-input[name="password"]');
let revealCheckbox = passwordInput.shadowRoot.querySelector(".reveal-checkbox");
ok(!revealCheckbox.checked, "reveal-checkbox should not be checked by default");
revealCheckbox.click();
ok(revealCheckbox.checked, "reveal-checkbox should be checked after clicking");
gLoginItem.setLogin(TEST_LOGIN_2);
ok(!revealCheckbox.checked, "reveal-checkbox should be unchecked when changing logins");
});
add_task(async function test_set_login_empty() {
gLoginItem.setLogin({});
await asyncElementRendered();

View File

@ -656,7 +656,7 @@ class TabTracker extends TabTrackerBase {
let {gBrowser} = browser.ownerGlobal;
// Some non-browser windows have gBrowser but not getTabForBrowser!
if (!gBrowser || !gBrowser.getTabForBrowser) {
if (browser.ownerDocument.documentURI === "about:addons") {
if (browser.ownerGlobal.top.document.documentURI === "about:addons") {
// When we're loaded into a <browser> inside about:addons, we need to go up
// one more level.
browser = browser.ownerGlobal.docShell.chromeEventHandler;

View File

@ -59,9 +59,7 @@ async function loadExtension(options) {
return extension;
}
add_task(async function test_inline_options() {
info(`Test options opened inline`);
async function run_test_inline_options() {
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "http://example.com/");
let extension = await loadExtension({
@ -200,6 +198,17 @@ add_task(async function test_inline_options() {
await extension.unload();
BrowserTestUtils.removeTab(tab);
}
add_task(async function test_inline_options() {
for (let htmlEnabled of [false, true]) {
info(`Test options opened inline ${htmlEnabled ? "HTML" : "XUL"} about:addons`);
await SpecialPowers.pushPrefEnv({
set: [["extensions.htmlaboutaddons.enabled", htmlEnabled]],
});
await run_test_inline_options();
await SpecialPowers.popPrefEnv();
}
});
add_task(async function test_tab_options() {

View File

@ -1,6 +0,0 @@
. $topsrcdir/browser/config/mozconfigs/linux64/nightly
export MOZ_LTO=1
ac_add_options --enable-profile-use
ac_add_options --with-pgo-jarlog=/builds/worker/fetches/en-US.log
ac_add_options --with-pgo-profile-path=/builds/worker/fetches

View File

@ -185,7 +185,7 @@ const GloballyBlockedPermissions = {
browser.removeProgressListener(this);
}
},
});
}, Ci.nsIWebProgress.NOTIFY_LOCATION);
},
// Removes a permission with the specified id for the specified browser.

View File

@ -25,7 +25,12 @@ else
if [ -n "$MOZ_PGO" ]; then
if [ -z "$USE_ARTIFACT" ]; then
ac_add_options --enable-lto
export MOZ_LTO=1
if [ -n "$MOZ_PGO_PROFILE_USE" ]; then
ac_add_options --enable-profile-use
ac_add_options --with-pgo-jarlog=/builds/worker/fetches/en-US.log
ac_add_options --with-pgo-profile-path=/builds/worker/fetches
fi
fi
export LLVM_PROFDATA="$TOOLTOOL_DIR/clang/bin/llvm-profdata"
export AR="$topsrcdir/clang/bin/llvm-ar"

View File

@ -95,7 +95,7 @@ class Preview extends PureComponent<Props, State> {
onTokenEnter = ({ target, tokenPos }) => {
const { cx, editor, updatePreview, preview } = this.props;
if (cx.isPaused || (!preview || target !== preview.target)) {
if (cx.isPaused && (!preview || target !== preview.target)) {
updatePreview(cx, target, tokenPos, editor.codeMirror);
}
};

View File

@ -1,5 +1,35 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`visible column breakpoints doesnt show breakpoints to the right 1`] = `
Array [
Object {
"breakpoint": Object {
"astLocation": null,
"disabled": false,
"generatedLocation": Object {
"column": 1,
"line": 1,
"sourceId": "foo",
},
"id": "breakpoint",
"location": Object {
"column": 1,
"line": 1,
"sourceId": "foo",
},
"options": Object {},
"originalText": "text",
"text": "text",
},
"location": Object {
"column": 1,
"line": 1,
"sourceId": "foo",
},
},
]
`;
exports[`visible column breakpoints ignores single breakpoints 1`] = `
Array [
Object {

View File

@ -14,7 +14,11 @@ import {
getColumnBreakpoints,
getFirstBreakpointPosition,
} from "../visibleColumnBreakpoints";
import { makeMockSource, makeMockBreakpoint } from "../../utils/test-mockup";
import {
makeMockSource,
makeMockSourceWithContent,
makeMockBreakpoint,
} from "../../utils/test-mockup";
function pp(line, column) {
return {
@ -31,6 +35,17 @@ function bp(line, column) {
return makeMockBreakpoint(defaultSource(), line, column);
}
const source = makeMockSourceWithContent(
undefined,
"foo.js",
undefined,
`function foo() {
console.log("hello");
}
console.log('bye');
`
);
describe("visible column breakpoints", () => {
it("simple", () => {
const viewport = {
@ -40,7 +55,12 @@ describe("visible column breakpoints", () => {
const pausePoints = { [1]: [pp(1, 1), pp(1, 5)], [3]: [pp(3, 1)] };
const breakpoints = [bp(1, 1), bp(4, 0), bp(4, 3)];
const columnBps = getColumnBreakpoints(pausePoints, breakpoints, viewport);
const columnBps = getColumnBreakpoints(
pausePoints,
breakpoints,
viewport,
source
);
expect(columnBps).toMatchSnapshot();
});
@ -51,7 +71,12 @@ describe("visible column breakpoints", () => {
};
const pausePoints = { [1]: [pp(1, 1), pp(1, 3)], [2]: [pp(2, 1)] };
const breakpoints = [bp(1, 1)];
const columnBps = getColumnBreakpoints(pausePoints, breakpoints, viewport);
const columnBps = getColumnBreakpoints(
pausePoints,
breakpoints,
viewport,
source
);
expect(columnBps).toMatchSnapshot();
});
@ -63,7 +88,29 @@ describe("visible column breakpoints", () => {
const pausePoints = { [1]: [pp(1, 1), pp(1, 3)], [20]: [pp(20, 1)] };
const breakpoints = [bp(1, 1)];
const columnBps = getColumnBreakpoints(pausePoints, breakpoints, viewport);
const columnBps = getColumnBreakpoints(
pausePoints,
breakpoints,
viewport,
source
);
expect(columnBps).toMatchSnapshot();
});
it("doesnt show breakpoints to the right", () => {
const viewport = {
start: { line: 1, column: 0 },
end: { line: 10, column: 10 },
};
const pausePoints = { [1]: [pp(1, 1), pp(1, 15)], [20]: [pp(20, 1)] };
const breakpoints = [bp(1, 1), bp(1, 15)];
const columnBps = getColumnBreakpoints(
pausePoints,
breakpoints,
viewport,
source
);
expect(columnBps).toMatchSnapshot();
});
});
@ -75,16 +122,16 @@ describe("getFirstBreakpointPosition", () => {
await dispatch(actions.newGeneratedSource(makeSource("foo1")));
const source = selectors.getSourceFromId(getState(), "foo1");
const fooSource = selectors.getSourceFromId(getState(), "foo1");
dispatch({
type: "ADD_BREAKPOINT_POSITIONS",
positions: [pp(1, 5), pp(1, 3)],
source,
source: fooSource,
});
const position = getFirstBreakpointPosition(getState(), {
line: 1,
sourceId: source.id,
sourceId: fooSource.id,
});
if (!position) {

View File

@ -10,12 +10,14 @@ import {
getViewport,
getSource,
getSelectedSource,
getSelectedSourceWithContent,
getBreakpointPositions,
getBreakpointPositionsForSource,
} from "../selectors";
import { getVisibleBreakpoints } from "./visibleBreakpoints";
import { getSelectedLocation } from "../utils/selected-location";
import { sortSelectedLocations } from "../utils/location";
import { getLineText } from "../utils/source";
import type { Selector, State } from "../reducers/types";
@ -26,7 +28,7 @@ import type {
Range,
BreakpointPositions,
BreakpointPosition,
Source,
SourceWithContent,
} from "../types";
export type ColumnBreakpoint = {|
@ -96,6 +98,7 @@ function filterByLineCount(positions, selectedSource) {
function filterVisible(positions, selectedSource, viewport) {
return positions.filter(columnBreakpoint => {
const location = getSelectedLocation(columnBreakpoint, selectedSource);
return viewport && contains(location, viewport);
});
}
@ -107,6 +110,20 @@ function filterByBreakpoints(positions, selectedSource, breakpointMap) {
});
}
// Filters out breakpoints to the right of the line. (bug 1552039)
function filterInLine(positions, selectedSource, selectedContent) {
return positions.filter(position => {
const location = getSelectedLocation(position, selectedSource);
const lineText = getLineText(
selectedSource.id,
selectedContent,
location.line
);
return lineText.length >= (location.column || 0);
});
}
function formatPositions(
positions: BreakpointPosition[],
selectedSource,
@ -131,12 +148,17 @@ export function getColumnBreakpoints(
positions: ?BreakpointPositions,
breakpoints: ?(Breakpoint[]),
viewport: Range,
selectedSource: ?Source
selectedSourceWithContent: ?SourceWithContent
) {
if (!positions) {
if (!positions || !selectedSourceWithContent) {
return [];
}
const {
source: selectedSource,
content: selectedContent,
} = selectedSourceWithContent;
// We only want to show a column breakpoint if several conditions are matched
// - it is the first breakpoint to appear at an the original location
// - the position is in the current viewport
@ -146,6 +168,7 @@ export function getColumnBreakpoints(
let newPositions = convertToList(positions);
newPositions = filterByLineCount(newPositions, selectedSource);
newPositions = filterVisible(newPositions, selectedSource, viewport);
newPositions = filterInLine(newPositions, selectedSource, selectedContent);
newPositions = filterByBreakpoints(
newPositions,
selectedSource,
@ -165,7 +188,7 @@ export const visibleColumnBreakpoints: Selector<ColumnBreakpoints> = createSelec
getVisibleBreakpointPositions,
getVisibleBreakpoints,
getViewport,
getSelectedSource,
getSelectedSourceWithContent,
getColumnBreakpoints
);

View File

@ -16,7 +16,7 @@ import { endTruncateStr } from "./utils";
import { truncateMiddleText } from "../utils/text";
import { parse as parseURL } from "../utils/url";
import { renderWasmText } from "./wasm";
import { toEditorPosition } from "./editor";
import { toEditorLine } from "./editor";
export { isMinified } from "./isMinified";
import { getURL, getFileExtension } from "./sources-tree";
import { prefs, features } from "./prefs";
@ -407,30 +407,36 @@ export function isInlineScript(source: SourceActor): boolean {
return source.introductionType === "scriptElement";
}
export function getTextAtPosition(
export function getLineText(
sourceId: SourceId,
asyncContent: AsyncValue<SourceContent> | null,
location: SourceLocation
) {
line: number
): string {
if (!asyncContent || !isFulfilled(asyncContent)) {
return "";
}
const content = asyncContent.value;
const line = location.line;
const column = location.column || 0;
if (content.type === "wasm") {
const { line: editorLine } = toEditorPosition(location);
const editorLine = toEditorLine(sourceId, line);
const lines = renderWasmText(sourceId, content);
return lines[editorLine];
return lines[editorLine] || "";
}
const lineText = content.value.split("\n")[line - 1];
if (!lineText) {
return "";
}
return lineText || "";
}
export function getTextAtPosition(
sourceId: SourceId,
asyncContent: AsyncValue<SourceContent> | null,
location: SourceLocation
) {
const column = location.column || 0;
const line = location.line;
const lineText = getLineText(sourceId, asyncContent, line);
return lineText.slice(column, column + 100).trim();
}

View File

@ -16,7 +16,6 @@ import type { Source } from "../../types";
* Gets domain from url (without www prefix)
*/
export function getDomain(url?: string): ?string {
// TODO: define how files should be ordered on the browser debugger
if (!url) {
return null;
}
@ -36,6 +35,13 @@ function isExactDomainMatch(part: string, debuggeeHost: string): boolean {
: part === debuggeeHost;
}
/*
* Checks if node name matches IndexName
*/
function isIndexName(part: string, ...rest): boolean {
return part === IndexName;
}
/*
* Function to assist with node search for a defined sorted order, see e.g.
* `createTreeNodeMatcher`. Returns negative number if the node
@ -78,48 +84,12 @@ export function findNodeInContents(
const IndexName = "(index)";
function createTreeNodeMatcherWithIndex(): FindNodeInContentsMatcher {
return (node: TreeNode) => (node.name === IndexName ? 0 : 1);
}
function createTreeNodeMatcherWithDebuggeeHost(
debuggeeHost: string
): FindNodeInContentsMatcher {
return (node: TreeNode) => {
if (node.name === IndexName) {
return -1;
}
return isExactDomainMatch(node.name, debuggeeHost) ? 0 : 1;
};
}
function createTreeNodeMatcherWithNameAndOther(
part: string,
isDir: boolean,
debuggeeHost: ?string,
source?: Source,
sortByUrl?: boolean
): FindNodeInContentsMatcher {
return (node: TreeNode) => {
if (node.name === IndexName) {
return -1;
}
if (debuggeeHost && isExactDomainMatch(node.name, debuggeeHost)) {
return -1;
}
const nodeIsDir = nodeHasChildren(node);
if (nodeIsDir && !isDir) {
return -1;
} else if (!nodeIsDir && isDir) {
return 1;
}
if (sortByUrl && node.type === "source" && source) {
return node.contents.url.localeCompare(source.url);
}
return node.name.localeCompare(part);
};
}
/*
* An array of functions to identify exceptions when sorting sourcesTree.
* Each function must return a boolean. Keep functions in array in the
* order exceptions should be sorted in.
*/
const matcherFunctions = [isIndexName, isExactDomainMatch];
/*
* Creates a matcher for findNodeInContents.
@ -136,22 +106,43 @@ export function createTreeNodeMatcher(
source?: Source,
sortByUrl?: boolean
): FindNodeInContentsMatcher {
if (part === IndexName) {
// Specialied matcher, when we are looking for "(index)" position.
return createTreeNodeMatcherWithIndex();
}
return (node: TreeNode) => {
for (let i = 0; i < matcherFunctions.length; i++) {
// Check part against exceptions
if (matcherFunctions[i](part, debuggeeHost)) {
for (let j = 0; j < i; j++) {
// Check node.name against exceptions
if (matcherFunctions[j](node.name, debuggeeHost)) {
return -1;
}
}
// If part and node.name share the same exception, return 0
if (matcherFunctions[i](node.name, debuggeeHost)) {
return 0;
}
return 1;
}
// Check node.name against exceptions if part is not exception
if (matcherFunctions[i](node.name, debuggeeHost)) {
return -1;
}
}
// Sort directories before files
const nodeIsDir = nodeHasChildren(node);
if (nodeIsDir && !isDir) {
return -1;
} else if (!nodeIsDir && isDir) {
return 1;
}
if (debuggeeHost && isExactDomainMatch(part, debuggeeHost)) {
// Specialied matcher, when we are looking for domain position.
return createTreeNodeMatcherWithDebuggeeHost(debuggeeHost);
}
if (sortByUrl && node.type === "source" && source) {
return node.contents.url.localeCompare(source.url);
}
// Rest of the cases, without mentioned above.
return createTreeNodeMatcherWithNameAndOther(
part,
isDir,
debuggeeHost,
source,
sortByUrl
);
if (isExactDomainMatch(part, node.name)) {
return 0;
}
return node.name.localeCompare(part);
};
}

View File

@ -38,10 +38,11 @@ class SummaryGraph extends PureComponent {
this.props.selectAnimation(this.props.animation);
}
/* eslint-disable complexity */
getTitleText(state) {
const getTime =
time => getFormatStr("player.timeLabel", numberWithDecimals(time / 1000, 2));
const getTimeOrInfinity =
time => time === Infinity ? getStr("player.infiniteDurationText") : getTime(time);
let text = "";
@ -58,9 +59,7 @@ class SummaryGraph extends PureComponent {
// Adding the duration.
text += getStr("player.animationDurationLabel") + " ";
text += state.duration === Infinity
? getStr("player.infiniteDurationText")
: getTime(state.duration);
text += getTimeOrInfinity(state.duration);
text += "\n";
// Adding the endDelay.
@ -81,9 +80,7 @@ class SummaryGraph extends PureComponent {
if (state.iterationStart !== 0) {
text += getFormatStr("player.animationIterationStartLabel2",
state.iterationStart,
state.duration === Infinity
? getStr("player.infiniteDurationText")
: getTime(state.iterationStart * state.duration));
getTimeOrInfinity(state.iterationStart * state.duration));
text += "\n";
}
@ -137,7 +134,6 @@ class SummaryGraph extends PureComponent {
return text;
}
/* eslint-enable complexity */
render() {
const {

View File

@ -50,6 +50,7 @@ tags = devtools webextensions
skip-if = true # Bug 1413765
[browser_network_throttling.js]
[browser_orientationchange_event.js]
[browser_outer_size.js]
[browser_page_state.js]
[browser_page_style.js]
[browser_permission_doorhanger.js]

View File

@ -0,0 +1,42 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test the window's outerWidth and outerHeight values are not affected by page zoom.
const TEST_URL = "data:text/html;charset=utf-8,";
const OUTER_WIDTH = 375;
const OUTER_HEIGHT = 450;
const ZOOM_LEVELS = [0.3, 0.5, 0.9, 1, 1.5, 2, 2.4];
add_task(async function() {
const tab = await addTab(TEST_URL);
const browser = tab.linkedBrowser;
const { ui, manager } = await openRDM(tab);
await setViewportSize(ui, manager, OUTER_WIDTH, OUTER_HEIGHT);
info("Ensure outer size values are unchanged at different zoom levels.");
for (let i = 0; i < ZOOM_LEVELS.length; i++) {
await checkWindowOuterSize(ui, browser, ZOOM_LEVELS[i]);
}
});
async function checkWindowOuterSize(ui, browser, zoom) {
info(`Setting zoom level to ${zoom}`);
ZoomManager.setZoomForBrowser(browser, zoom);
return ContentTask.spawn(ui.getViewportBrowser(),
{ width: OUTER_WIDTH, height: OUTER_HEIGHT },
async function({ width, height }) {
// Approximate the outer size value returned on the window content with the expected
// value. We should expect, at the very most, a 1px difference between the two due
// to floating point rounding errors that occur when scaling from inner size CSS
// integer values to outer size CSS integer values. See Part 1 of Bug 1107456.
ok(Math.abs(content.outerWidth - width) <= 1,
`window.outerWidth should be ${width} and we got ${content.outerWidth}.`);
ok(Math.abs(content.outerHeight - height) <= 1,
`window.outerHeight should be ${height} and we got ${content.outerHeight}.`);
});
}

View File

@ -64,6 +64,7 @@ function test_pause_frame() {
var a = 1;
var b = true;
var c = { a: "a" };
eval("");
debugger;
}
stopMe(42, true, "nasu", null, undefined, { foo: "bar" });

View File

@ -56,6 +56,7 @@ function test_banana_environment() {
gDebuggee.eval("function banana(x) {\n" +
" return function banana2(y) {\n" +
" return function banana3(z) {\n" +
" eval(\"\");\n" +
" debugger;\n" +
" };\n" +
" };\n" +

View File

@ -62,6 +62,7 @@ function test_banana_environment() {
gDebuggee.eval("function banana(x) {\n" +
" return function banana2(y) {\n" +
" return function banana3(z) {\n" +
" eval(\"\");\n" +
" debugger;\n" +
" };\n" +
" };\n" +

80
dom/base/BindContext.h Normal file
View File

@ -0,0 +1,80 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
/* State that is passed down to BindToTree. */
#ifndef mozilla_dom_BindContext_h__
#define mozilla_dom_BindContext_h__
#include "mozilla/Attributes.h"
#include "nsXBLBinding.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/ShadowRoot.h"
namespace mozilla {
namespace dom {
struct MOZ_STACK_CLASS BindContext final {
// The document that owns the tree we're getting bound to.
//
// This is mostly an optimization to avoid silly pointer-chases to get the
// OwnerDoc().
Document& OwnerDoc() const { return mDoc; }
// Whether our subtree root is changing as a result of this operation.
bool SubtreeRootChanges() const { return mSubtreeRootChanges; }
// Returns the binding parent of the subtree to be inserted.
//
// This can be null.
Element* GetBindingParent() const { return mBindingParent; }
// This constructor should be used for regular appends to content.
explicit BindContext(nsINode& aParentNode)
: mDoc(*aParentNode.OwnerDoc()),
mSubtreeRootChanges(true),
mBindingParent(aParentNode.IsContent()
? aParentNode.AsContent()->GetBindingParent()
: nullptr) {}
// When re-binding a shadow host into a tree, we re-bind all the shadow tree
// from the root. In that case, the shadow tree contents remain within the
// same subtree root. So children should avoid doing silly things like adding
// themselves to the ShadowRoot's id table twice or what not.
//
// This constructor is only meant to be used in that situation.
explicit BindContext(ShadowRoot& aShadowRoot)
: mDoc(*aShadowRoot.OwnerDoc()),
mSubtreeRootChanges(false),
mBindingParent(aShadowRoot.Host()) {}
// This constructor is meant to be used when inserting native-anonymous
// children into a subtree.
enum ForNativeAnonymous { ForNativeAnonymous };
BindContext(Element& aParentElement, enum ForNativeAnonymous)
: mDoc(*aParentElement.OwnerDoc()),
mSubtreeRootChanges(true),
mBindingParent(&aParentElement) {}
// This is meant to be used to bind XBL anonymous content.
BindContext(nsXBLBinding& aBinding, Element& aParentElement)
: mDoc(*aParentElement.OwnerDoc()),
mSubtreeRootChanges(true),
mBindingParent(aBinding.GetBoundElement()) {}
private:
Document& mDoc;
// Whether the bind operation will change the subtree root of the content
// we're binding.
const bool mSubtreeRootChanges;
Element* const mBindingParent;
};
} // namespace dom
} // namespace mozilla
#endif

View File

@ -15,6 +15,7 @@
#include "mozilla/AsyncEventDispatcher.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/dom/BindContext.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/HTMLSlotElement.h"
#include "mozilla/dom/ShadowRoot.h"
@ -386,95 +387,90 @@ void CharacterData::ToCString(nsAString& aBuf, int32_t aOffset,
}
#endif
nsresult CharacterData::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
MOZ_ASSERT(aParent || aDocument, "Must have document if no parent!");
MOZ_ASSERT(NODE_FROM(aParent, aDocument)->OwnerDoc() == OwnerDoc(),
nsresult CharacterData::BindToTree(BindContext& aContext, nsINode& aParent) {
MOZ_ASSERT(aParent.IsContent() || aParent.IsDocument(),
"Must have content or document parent!");
MOZ_ASSERT(aParent.OwnerDoc() == OwnerDoc(),
"Must have the same owner document");
MOZ_ASSERT(!aParent || aDocument == aParent->GetUncomposedDoc(),
"aDocument must be current doc of aParent");
MOZ_ASSERT(!GetUncomposedDoc() && !IsInUncomposedDoc(),
"Already have a document. Unbind first!");
MOZ_ASSERT(OwnerDoc() == &aContext.OwnerDoc(), "These should match too");
MOZ_ASSERT(!IsInUncomposedDoc(), "Already have a document. Unbind first!");
MOZ_ASSERT(!IsInComposedDoc(), "Already have a document. Unbind first!");
// Note that as we recurse into the kids, they'll have a non-null parent. So
// only assert if our parent is _changing_ while we have a parent.
MOZ_ASSERT(!GetParent() || aParent == GetParent(),
MOZ_ASSERT(!GetParentNode() || &aParent == GetParentNode(),
"Already have a parent. Unbind first!");
MOZ_ASSERT(!GetBindingParent() || aBindingParent == GetBindingParent() ||
(!aBindingParent && aParent &&
aParent->GetBindingParent() == GetBindingParent()),
"Already have a binding parent. Unbind first!");
MOZ_ASSERT(aBindingParent != this,
"Content must not be its own binding parent");
MOZ_ASSERT(!IsRootOfNativeAnonymousSubtree() || aBindingParent == aParent,
MOZ_ASSERT(
!GetBindingParent() ||
aContext.GetBindingParent() == GetBindingParent() ||
(!aContext.GetBindingParent() && aParent.IsContent() &&
aParent.AsContent()->GetBindingParent() == GetBindingParent()),
"Already have a binding parent. Unbind first!");
MOZ_ASSERT(!IsRootOfNativeAnonymousSubtree() ||
aContext.GetBindingParent() == &aParent,
"Native anonymous content must have its parent as its "
"own binding parent");
if (!aBindingParent && aParent) {
aBindingParent = aParent->GetBindingParent();
}
MOZ_ASSERT(aContext.GetBindingParent() || !aParent.IsContent() ||
aContext.GetBindingParent() ==
aParent.AsContent()->GetBindingParent(),
"We should be passed the right binding parent");
// First set the binding parent
if (aBindingParent) {
NS_ASSERTION(IsRootOfNativeAnonymousSubtree() ||
!HasFlag(NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE) ||
(aParent && aParent->IsInNativeAnonymousSubtree()),
"Trying to re-bind content from native anonymous subtree to "
"non-native anonymous parent!");
ExtendedContentSlots()->mBindingParent =
aBindingParent; // Weak, so no addref happens.
if (aParent->IsInNativeAnonymousSubtree()) {
SetFlags(NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE);
}
if (aParent->HasFlag(NODE_HAS_BEEN_IN_UA_WIDGET)) {
SetFlags(NODE_HAS_BEEN_IN_UA_WIDGET);
}
if (HasFlag(NODE_IS_ANONYMOUS_ROOT)) {
aParent->SetMayHaveAnonymousChildren();
}
if (Element* bindingParent = aContext.GetBindingParent()) {
ExtendedContentSlots()->mBindingParent = bindingParent;
}
if (aParent && aParent->IsInShadowTree()) {
ClearSubtreeRootPointer();
SetFlags(NODE_IS_IN_SHADOW_TREE);
SetIsConnected(aParent->IsInComposedDoc());
MOZ_ASSERT(aParent->GetContainingShadow());
ExtendedContentSlots()->mContainingShadow = aParent->GetContainingShadow();
}
const bool hadParent = !!GetParentNode();
bool hadParent = !!GetParentNode();
NS_ASSERTION(!aContext.GetBindingParent() ||
IsRootOfNativeAnonymousSubtree() ||
!HasFlag(NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE) ||
aParent.IsInNativeAnonymousSubtree(),
"Trying to re-bind content from native anonymous subtree to "
"non-native anonymous parent!");
if (aParent.IsInNativeAnonymousSubtree()) {
SetFlags(NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE);
}
if (aParent.HasFlag(NODE_HAS_BEEN_IN_UA_WIDGET)) {
SetFlags(NODE_HAS_BEEN_IN_UA_WIDGET);
}
if (HasFlag(NODE_IS_ANONYMOUS_ROOT)) {
aParent.SetMayHaveAnonymousChildren();
}
// Set parent
if (aParent) {
if (!GetParent()) {
NS_ADDREF(aParent);
}
mParent = aParent;
} else {
mParent = aDocument;
mParent = &aParent;
if (!hadParent && aParent.IsContent()) {
SetParentIsContent(true);
NS_ADDREF(mParent);
}
SetParentIsContent(aParent);
MOZ_ASSERT(!!GetParent() == aParent.IsContent());
// XXXbz sXBL/XBL2 issue!
// Set document
if (aDocument) {
if (aParent.IsInUncomposedDoc() || aParent.IsInShadowTree()) {
// We no longer need to track the subtree pointer (and in fact we'll assert
// if we do this any later).
ClearSubtreeRootPointer();
SetIsConnected(aParent.IsInComposedDoc());
// XXX See the comment in Element::BindToTree
SetIsInDocument();
SetIsConnected(true);
if (mText.IsBidi()) {
aDocument->SetBidiEnabled();
if (aParent.IsInUncomposedDoc()) {
SetIsInDocument();
// FIXME(emilio): This should probably be dependent on composed doc, not
// uncomposed.
if (mText.IsBidi()) {
aContext.OwnerDoc().SetBidiEnabled();
}
} else {
SetFlags(NODE_IS_IN_SHADOW_TREE);
MOZ_ASSERT(aParent.IsContent() &&
aParent.AsContent()->GetContainingShadow());
ExtendedContentSlots()->mContainingShadow =
aParent.AsContent()->GetContainingShadow();
}
// Clear the lazy frame construction bits.
UnsetFlags(NODE_NEEDS_FRAME | NODE_DESCENDANTS_NEED_FRAMES);
} else if (!IsInShadowTree()) {
} else {
// If we're not in the doc and not in a shadow tree,
// update our subtree pointer.
SetSubtreeRootPointer(aParent->SubtreeRoot());
SetSubtreeRootPointer(aParent.SubtreeRoot());
}
nsNodeUtils::ParentChainChanged(this);
@ -484,11 +480,14 @@ nsresult CharacterData::BindToTree(Document* aDocument, nsIContent* aParent,
UpdateEditableState(false);
MOZ_ASSERT(aDocument == GetUncomposedDoc(), "Bound to wrong document");
MOZ_ASSERT(aParent == GetParent(), "Bound to wrong parent");
MOZ_ASSERT(aBindingParent == GetBindingParent(),
MOZ_ASSERT(OwnerDoc() == aParent.OwnerDoc(), "Bound to wrong document");
MOZ_ASSERT(&aParent == GetParentNode(), "Bound to wrong parent node");
MOZ_ASSERT(aContext.GetBindingParent() == GetBindingParent(),
"Bound to wrong binding parent");
MOZ_ASSERT(aParent.IsInUncomposedDoc() == IsInUncomposedDoc());
MOZ_ASSERT(aParent.IsInComposedDoc() == IsInComposedDoc());
MOZ_ASSERT(aParent.IsInShadowTree() == IsInShadowTree());
MOZ_ASSERT(aParent.SubtreeRoot() == SubtreeRoot());
return NS_OK;
}

View File

@ -107,8 +107,7 @@ class CharacterData : public nsIContent {
}
// Implementation for nsIContent
nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
nsresult BindToTree(BindContext&, nsINode& aParent) override;
void UnbindFromTree(bool aNullParent = true) override;

View File

@ -59,8 +59,7 @@ class DocumentFragment : public FragmentOrElement {
virtual bool IsNodeOfType(uint32_t aFlags) const override;
nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override {
nsresult BindToTree(BindContext&, nsINode& aParent) override {
NS_ASSERTION(false, "Trying to bind a fragment to a tree");
return NS_ERROR_NOT_IMPLEMENTED;
}

View File

@ -17,6 +17,7 @@
#include "mozilla/StaticPrefs.h"
#include "mozilla/dom/Animation.h"
#include "mozilla/dom/Attr.h"
#include "mozilla/dom/BindContext.h"
#include "mozilla/dom/Flex.h"
#include "mozilla/dom/Grid.h"
#include "mozilla/dom/ScriptLoader.h"
@ -1575,126 +1576,97 @@ void Element::GetElementsWithGrid(nsTArray<RefPtr<Element>>& aElements) {
}
}
nsresult Element::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
MOZ_ASSERT(aParent || aDocument, "Must have document if no parent!");
MOZ_ASSERT((NODE_FROM(aParent, aDocument)->OwnerDoc() == OwnerDoc()),
nsresult Element::BindToTree(BindContext& aContext, nsINode& aParent) {
MOZ_ASSERT(aParent.IsContent() || aParent.IsDocument(),
"Must have content or document parent!");
MOZ_ASSERT(aParent.OwnerDoc() == OwnerDoc(),
"Must have the same owner document");
MOZ_ASSERT(!aParent || aDocument == aParent->GetUncomposedDoc(),
"aDocument must be current doc of aParent");
MOZ_ASSERT(!IsInComposedDoc(), "Already have a document. Unbind first!");
MOZ_ASSERT(OwnerDoc() == &aContext.OwnerDoc(), "These should match too");
MOZ_ASSERT(!IsInUncomposedDoc(), "Already have a document. Unbind first!");
MOZ_ASSERT(!IsInComposedDoc(), "Already have a document. Unbind first!");
// Note that as we recurse into the kids, they'll have a non-null parent. So
// only assert if our parent is _changing_ while we have a parent.
MOZ_ASSERT(!GetParent() || aParent == GetParent(),
MOZ_ASSERT(!GetParentNode() || &aParent == GetParentNode(),
"Already have a parent. Unbind first!");
MOZ_ASSERT(!GetBindingParent() || aBindingParent == GetBindingParent() ||
(!aBindingParent && aParent &&
aParent->GetBindingParent() == GetBindingParent()),
"Already have a binding parent. Unbind first!");
MOZ_ASSERT(aBindingParent != this,
MOZ_ASSERT(
!GetBindingParent() ||
aContext.GetBindingParent() == GetBindingParent() ||
(!aContext.GetBindingParent() && aParent.IsContent() &&
aParent.AsContent()->GetBindingParent() == GetBindingParent()),
"Already have a binding parent. Unbind first!");
MOZ_ASSERT(aContext.GetBindingParent() != this,
"Content must not be its own binding parent");
MOZ_ASSERT(!IsRootOfNativeAnonymousSubtree() || aBindingParent == aParent,
MOZ_ASSERT(!IsRootOfNativeAnonymousSubtree() ||
aContext.GetBindingParent() == &aParent,
"Native anonymous content must have its parent as its "
"own binding parent");
MOZ_ASSERT(aBindingParent || !aParent ||
aBindingParent == aParent->GetBindingParent(),
MOZ_ASSERT(aContext.GetBindingParent() || !aParent.IsContent() ||
aContext.GetBindingParent() ==
aParent.AsContent()->GetBindingParent(),
"We should be passed the right binding parent");
#ifdef MOZ_XUL
// First set the binding parent
nsXULElement* xulElem = nsXULElement::FromNode(this);
if (xulElem) {
xulElem->SetXULBindingParent(aBindingParent);
if (nsXULElement* xulElem = nsXULElement::FromNode(this)) {
xulElem->SetXULBindingParent(aContext.GetBindingParent());
} else
#endif
{
if (aBindingParent) {
nsExtendedDOMSlots* slots = ExtendedDOMSlots();
slots->mBindingParent = aBindingParent; // Weak, so no addref happens.
if (Element* bindingParent = aContext.GetBindingParent()) {
ExtendedDOMSlots()->mBindingParent = bindingParent;
}
}
const bool hadParent = !!GetParentNode();
const bool wasInShadowTree = IsInShadowTree();
NS_ASSERTION(!aBindingParent || IsRootOfNativeAnonymousSubtree() ||
NS_ASSERTION(!aContext.GetBindingParent() ||
IsRootOfNativeAnonymousSubtree() ||
!HasFlag(NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE) ||
(aParent && aParent->IsInNativeAnonymousSubtree()),
aParent.IsInNativeAnonymousSubtree(),
"Trying to re-bind content from native anonymous subtree to "
"non-native anonymous parent!");
if (aParent) {
if (aParent->IsInNativeAnonymousSubtree()) {
SetFlags(NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE);
}
if (aParent->HasFlag(NODE_HAS_BEEN_IN_UA_WIDGET)) {
SetFlags(NODE_HAS_BEEN_IN_UA_WIDGET);
}
if (HasFlag(NODE_IS_ANONYMOUS_ROOT)) {
aParent->SetMayHaveAnonymousChildren();
}
if (aParent->IsInShadowTree()) {
ClearSubtreeRootPointer();
SetFlags(NODE_IS_IN_SHADOW_TREE);
MOZ_ASSERT(aParent->GetContainingShadow());
ExtendedDOMSlots()->mContainingShadow = aParent->GetContainingShadow();
}
if (aParent.IsInNativeAnonymousSubtree()) {
SetFlags(NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE);
}
if (aParent.HasFlag(NODE_HAS_BEEN_IN_UA_WIDGET)) {
SetFlags(NODE_HAS_BEEN_IN_UA_WIDGET);
}
if (HasFlag(NODE_IS_ANONYMOUS_ROOT)) {
aParent.SetMayHaveAnonymousChildren();
}
MOZ_ASSERT_IF(wasInShadowTree, IsInShadowTree());
// Now set the parent.
if (aParent) {
if (!GetParent()) {
NS_ADDREF(aParent);
}
mParent = aParent;
} else {
mParent = aDocument;
mParent = &aParent;
if (!hadParent && aParent.IsContent()) {
SetParentIsContent(true);
NS_ADDREF(mParent);
}
SetParentIsContent(aParent);
// XXXbz sXBL/XBL2 issue!
MOZ_ASSERT(!!GetParent() == aParent.IsContent());
MOZ_ASSERT(!HasAnyOfFlags(Element::kAllServoDescendantBits));
// Finally, set the document
if (aDocument) {
// Notify XBL- & nsIAnonymousContentCreator-generated
// anonymous content that the document is changing.
// XXXbz ordering issues here? Probably not, since ChangeDocumentFor is
// just pretty broken anyway.... Need to get it working.
// XXXbz XBL doesn't handle this (asserts), and we don't really want
// to be doing this during parsing anyway... sort this out.
// aDocument->BindingManager()->ChangeDocumentFor(this, nullptr,
// aDocument);
if (aParent.IsInUncomposedDoc() || aParent.IsInShadowTree()) {
// We no longer need to track the subtree pointer (and in fact we'll assert
// if we do this any later).
ClearSubtreeRootPointer();
SetIsConnected(aParent.IsInComposedDoc());
// Being added to a document.
SetIsInDocument();
SetIsConnected(true);
if (aParent.IsInUncomposedDoc()) {
SetIsInDocument();
} else {
SetFlags(NODE_IS_IN_SHADOW_TREE);
MOZ_ASSERT(aParent.IsContent() &&
aParent.AsContent()->GetContainingShadow());
ExtendedDOMSlots()->mContainingShadow =
aParent.AsContent()->GetContainingShadow();
}
// Clear the lazy frame construction bits.
UnsetFlags(NODE_NEEDS_FRAME | NODE_DESCENDANTS_NEED_FRAMES);
} else if (IsInShadowTree()) {
SetIsConnected(aParent->IsInComposedDoc());
// We're not in a document, but we did get inserted into a shadow tree.
// Since we won't have any restyle data in the document's restyle trackers,
// don't let us get inserted with restyle bits set incorrectly.
//
// Also clear all the other flags that are cleared above when we do get
// inserted into a document.
//
// See the comment about the restyle bits above, it also applies.
UnsetFlags(NODE_NEEDS_FRAME | NODE_DESCENDANTS_NEED_FRAMES);
} else {
// If we're not in the doc and not in a shadow tree,
// update our subtree pointer.
SetSubtreeRootPointer(aParent->SubtreeRoot());
SetSubtreeRootPointer(aParent.SubtreeRoot());
}
if (IsInComposedDoc()) {
@ -1714,7 +1686,7 @@ nsresult Element::BindToTree(Document* aDocument, nsIContent* aParent,
// because it has to happen after updating the parent pointer, but before
// recursively binding the kids.
if (IsHTMLElement()) {
SetDirOnBind(this, aParent);
SetDirOnBind(this, nsIContent::FromNode(aParent));
}
UpdateEditableState(false);
@ -1723,7 +1695,7 @@ nsresult Element::BindToTree(Document* aDocument, nsIContent* aParent,
// also need to be told that they are moving.
if (HasFlag(NODE_MAY_BE_IN_BINDING_MNGR)) {
nsXBLBinding* binding =
OwnerDoc()->BindingManager()->GetBindingWithContent(this);
aContext.OwnerDoc().BindingManager()->GetBindingWithContent(this);
if (binding) {
binding->BindAnonymousContent(binding->GetAnonymousContent(), this);
@ -1734,7 +1706,7 @@ nsresult Element::BindToTree(Document* aDocument, nsIContent* aParent,
nsresult rv;
for (nsIContent* child = GetFirstChild(); child;
child = child->GetNextSibling()) {
rv = child->BindToTree(aDocument, this, aBindingParent);
rv = child->BindToTree(aContext, *this);
NS_ENSURE_SUCCESS(rv, rv);
}
@ -1745,7 +1717,7 @@ nsresult Element::BindToTree(Document* aDocument, nsIContent* aParent,
// Ensure we only add to the table once, in the case we move the ShadowRoot
// around.
if (HasID() && !wasInShadowTree) {
if (HasID() && aContext.SubtreeRootChanges()) {
AddToIdTable(DoGetID());
}
@ -1767,14 +1739,14 @@ nsresult Element::BindToTree(Document* aDocument, nsIContent* aParent,
//
// Also, if this _is_ needed, then it's wrong and should use GetComposedDoc()
// to account for Shadow DOM.
if (aDocument && MayHaveAnimations()) {
if (aParent.IsInUncomposedDoc() && MayHaveAnimations()) {
PseudoStyleType pseudoType = GetPseudoElementType();
if ((pseudoType == PseudoStyleType::NotPseudo ||
pseudoType == PseudoStyleType::before ||
pseudoType == PseudoStyleType::after ||
pseudoType == PseudoStyleType::marker) &&
EffectSet::GetEffectSet(this, pseudoType)) {
if (nsPresContext* presContext = aDocument->GetPresContext()) {
if (nsPresContext* presContext = aContext.OwnerDoc().GetPresContext()) {
presContext->EffectCompositor()->RequestRestyle(
this, pseudoType, EffectCompositor::RestyleType::Standard,
EffectCompositor::CascadeLevel::Animations);
@ -1785,11 +1757,14 @@ nsresult Element::BindToTree(Document* aDocument, nsIContent* aParent,
// XXXbz script execution during binding can trigger some of these
// postcondition asserts.... But we do want that, since things will
// generally be quite broken when that happens.
MOZ_ASSERT(aDocument == GetUncomposedDoc(), "Bound to wrong document");
MOZ_ASSERT(aParent == GetParent(), "Bound to wrong parent");
MOZ_ASSERT(aBindingParent == GetBindingParent(),
MOZ_ASSERT(OwnerDoc() == aParent.OwnerDoc(), "Bound to wrong document");
MOZ_ASSERT(&aParent == GetParentNode(), "Bound to wrong parent node");
MOZ_ASSERT(aContext.GetBindingParent() == GetBindingParent(),
"Bound to wrong binding parent");
MOZ_ASSERT(aParent.IsInUncomposedDoc() == IsInUncomposedDoc());
MOZ_ASSERT(aParent.IsInComposedDoc() == IsInComposedDoc());
MOZ_ASSERT(aParent.IsInShadowTree() == IsInShadowTree());
MOZ_ASSERT(aParent.SubtreeRoot() == SubtreeRoot());
return NS_OK;
}

View File

@ -653,8 +653,7 @@ class Element : public FragmentOrElement {
void UpdateEditableState(bool aNotify) override;
nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
nsresult BindToTree(BindContext&, nsINode& aParent) override;
void UnbindFromTree(bool aNullParent = true) override;

View File

@ -1123,6 +1123,28 @@ void nsIContent::SetXBLInsertionPoint(nsIContent* aContent) {
}
}
#ifdef DEBUG
void nsIContent::AssertAnonymousSubtreeRelatedInvariants() const {
NS_ASSERTION(!IsRootOfNativeAnonymousSubtree() ||
(GetParent() && GetBindingParent() == GetParent()),
"root of native anonymous subtree must have parent equal "
"to binding parent");
NS_ASSERTION(!GetParent() ||
((GetBindingParent() == GetParent()) ==
HasFlag(NODE_IS_ANONYMOUS_ROOT)) ||
// Unfortunately default content for XBL insertion points
// is anonymous content that is bound with the parent of
// the insertion point as the parent but the bound element
// for the binding as the binding parent. So we have to
// complicate the assert a bit here.
(GetBindingParent() &&
(GetBindingParent() == GetParent()->GetBindingParent()) ==
HasFlag(NODE_IS_ANONYMOUS_ROOT)),
"For nodes with parent, flag and GetBindingParent() check "
"should match");
}
#endif
void FragmentOrElement::GetTextContentInternal(nsAString& aTextContent,
OOMReporter& aError) {
if (!nsContentUtils::GetNodeTextContent(this, true, aTextContent, fallible)) {

View File

@ -5,6 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/Preferences.h"
#include "mozilla/dom/BindContext.h"
#include "mozilla/dom/ShadowRoot.h"
#include "mozilla/dom/DocumentFragment.h"
#include "ChildIterator.h"
@ -131,9 +132,10 @@ nsresult ShadowRoot::Bind() {
OwnerDoc()->AddComposedDocShadowRoot(*this);
}
BindContext context(*this);
for (nsIContent* child = GetFirstChild(); child;
child = child->GetNextSibling()) {
nsresult rv = child->BindToTree(nullptr, this, Host());
nsresult rv = child->BindToTree(context, *this);
NS_ENSURE_SUCCESS(rv, rv);
}

View File

@ -141,6 +141,7 @@ EXPORTS.mozilla.dom += [
'AnonymousContent.h',
'Attr.h',
'BarProps.h',
'BindContext.h',
'BodyUtil.h',
'BorrowedAttrInfo.h',
'CharacterData.h',

View File

@ -1093,7 +1093,7 @@ void nsFocusManager::EnsureCurrentWidgetFocused() {
if (!widget) {
return;
}
widget->SetFocus(false);
widget->SetFocus(nsIWidget::Raise::No);
}
bool ActivateOrDeactivateChild(BrowserParent* aParent, void* aArg) {
@ -1629,13 +1629,12 @@ bool nsFocusManager::Blur(nsPIDOMWindowOuter* aWindowToClear,
} else {
// note that the presshell's widget is being retrieved here, not the
// one for the object frame.
nsViewManager* vm = presShell->GetViewManager();
if (vm) {
if (nsViewManager* vm = presShell->GetViewManager()) {
nsCOMPtr<nsIWidget> widget;
vm->GetRootWidget(getter_AddRefs(widget));
if (widget) {
// set focus to the top level window but don't raise it.
widget->SetFocus(false);
widget->SetFocus(nsIWidget::Raise::No);
}
}
}
@ -1821,11 +1820,10 @@ void nsFocusManager::Focus(nsPIDOMWindowOuter* aWindow, Element* aElement,
if (objectFrame) objectFrameWidget = objectFrame->GetWidget();
}
if (aAdjustWidgets && !objectFrameWidget && !sTestMode) {
nsViewManager* vm = presShell->GetViewManager();
if (vm) {
if (nsViewManager* vm = presShell->GetViewManager()) {
nsCOMPtr<nsIWidget> widget;
vm->GetRootWidget(getter_AddRefs(widget));
if (widget) widget->SetFocus(false);
if (widget) widget->SetFocus(nsIWidget::Raise::No);
}
}
@ -1878,8 +1876,9 @@ void nsFocusManager::Focus(nsPIDOMWindowOuter* aWindow, Element* aElement,
// that we might no longer be in the same document, due to the events we
// fired above when aIsNewDocument.
if (presShell->GetDocument() == aElement->GetComposedDoc()) {
if (aAdjustWidgets && objectFrameWidget && !sTestMode)
objectFrameWidget->SetFocus(false);
if (aAdjustWidgets && objectFrameWidget && !sTestMode) {
objectFrameWidget->SetFocus(nsIWidget::Raise::No);
}
// if the object being focused is a remote browser, activate remote
// content
@ -1911,11 +1910,12 @@ void nsFocusManager::Focus(nsPIDOMWindowOuter* aWindow, Element* aElement,
// the root widget.
if (aAdjustWidgets && objectFrameWidget && mFocusedWindow == aWindow &&
mFocusedElement == nullptr && !sTestMode) {
nsViewManager* vm = presShell->GetViewManager();
if (vm) {
if (nsViewManager* vm = presShell->GetViewManager()) {
nsCOMPtr<nsIWidget> widget;
vm->GetRootWidget(getter_AddRefs(widget));
if (widget) widget->SetFocus(false);
if (widget) {
widget->SetFocus(nsIWidget::Raise::No);
}
}
}
@ -2189,11 +2189,10 @@ void nsFocusManager::RaiseWindow(nsPIDOMWindowOuter* aWindow) {
return;
}
nsViewManager* vm = presShell->GetViewManager();
if (vm) {
if (nsViewManager* vm = presShell->GetViewManager()) {
nsCOMPtr<nsIWidget> widget;
vm->GetRootWidget(getter_AddRefs(widget));
if (widget) widget->SetFocus(true);
if (widget) widget->SetFocus(nsIWidget::Raise::Yes);
}
#else
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin =
@ -2201,7 +2200,7 @@ void nsFocusManager::RaiseWindow(nsPIDOMWindowOuter* aWindow) {
if (treeOwnerAsWin) {
nsCOMPtr<nsIWidget> widget;
treeOwnerAsWin->GetMainWidget(getter_AddRefs(widget));
if (widget) widget->SetFocus(true);
if (widget) widget->SetFocus(nsIWidget::Raise::Yes);
}
#endif
}

View File

@ -2627,12 +2627,17 @@ bool nsFrameLoader::TryRemoteBrowserInternal() {
nsCOMPtr<nsIURI> parentURI;
bool equals;
if (!((parentWebNav = do_GetInterface(parentDocShell)) &&
NS_SUCCEEDED(
NS_NewURI(getter_AddRefs(aboutAddons), "about:addons")) &&
NS_SUCCEEDED(
parentWebNav->GetCurrentURI(getter_AddRefs(parentURI))) &&
NS_SUCCEEDED(parentURI->EqualsExceptRef(aboutAddons, &equals)) &&
equals)) {
((NS_SUCCEEDED(
NS_NewURI(getter_AddRefs(aboutAddons), "about:addons")) &&
NS_SUCCEEDED(parentURI->EqualsExceptRef(aboutAddons, &equals)) &&
equals) ||
(NS_SUCCEEDED(NS_NewURI(
getter_AddRefs(aboutAddons),
"chrome://mozapps/content/extensions/aboutaddons.html")) &&
NS_SUCCEEDED(parentURI->EqualsExceptRef(aboutAddons, &equals)) &&
equals)))) {
return false;
}
}

View File

@ -2240,6 +2240,8 @@ nsresult nsGlobalWindowOuter::SetNewDocument(Document* aDocument,
// Tell the WindowGlobalParent that it should become the current window global
// for our BrowsingContext if it isn't already.
mInnerWindow->GetWindowGlobalChild()->SendUpdateDocumentURI(
aDocument->GetDocumentURI());
mInnerWindow->GetWindowGlobalChild()->SendBecomeCurrentWindowGlobal();
// We no longer need the old inner window. Start its destruction if
@ -3523,13 +3525,32 @@ void nsGlobalWindowOuter::SetInnerHeightOuter(int32_t aInnerHeight,
nsIntSize nsGlobalWindowOuter::GetOuterSize(CallerType aCallerType,
ErrorResult& aError) {
if (nsContentUtils::ResistFingerprinting(aCallerType) ||
(mDoc && mDoc->InRDMPane())) {
if (nsContentUtils::ResistFingerprinting(aCallerType)) {
CSSIntSize size;
aError = GetInnerSize(size);
return nsIntSize(size.width, size.height);
}
if (mDoc && mDoc->InRDMPane()) {
CSSIntSize size;
aError = GetInnerSize(size);
// Obtain the current zoom of the presentation shell. The zoom value will
// be used to scale the size of the visual viewport to the device browser's
// outer size values. Once RDM no longer relies on the having the page
// content being embedded in a <iframe mozbrowser>, we can do away with
// this approach and retrieve the size of the frame containing the browser
// content.
RefPtr<nsPresContext> presContext = mDocShell->GetPresContext();
if (presContext) {
float zoom = presContext->GetDeviceFullZoom();
int32_t width = std::round(size.width * zoom);
int32_t height = std::round(size.height * zoom);
return nsIntSize(width, height);
}
}
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = GetTreeOwnerWindow();
if (!treeOwnerAsWin) {
aError.Throw(NS_ERROR_FAILURE);

View File

@ -28,6 +28,7 @@ namespace mozilla {
class EventChainPreVisitor;
struct URLExtraData;
namespace dom {
struct BindContext;
class ShadowRoot;
class HTMLSlotElement;
} // namespace dom
@ -57,7 +58,9 @@ enum nsLinkState {
*/
class nsIContent : public nsINode {
public:
typedef mozilla::widget::IMEState IMEState;
using IMEState = mozilla::widget::IMEState;
using BindContext = mozilla::dom::BindContext;
void ConstructUbiNode(void* storage) override;
@ -85,19 +88,9 @@ class nsIContent : public nsINode {
* appended to a parent, this will be called after the node has been added to
* the parent's child list and before nsIDocumentObserver notifications for
* the addition are dispatched.
* @param aDocument The new document for the content node. May not be null
* if aParent is null. Must match the current document of
* aParent, if aParent is not null (note that
* aParent->GetUncomposedDoc() can be null, in which case
* this must also be null).
* @param aParent The new parent for the content node. May be null if the
* node is being bound as a direct child of the document.
* @param aBindingParent The new binding parent for the content node.
* This is must either be non-null if a particular
* binding parent is desired or match aParent's binding
* parent.
* @note either aDocument or aParent must be non-null. If both are null,
* this method _will_ crash.
* BindContext propagates various information down the subtree; see its
* documentation to know how to set it up.
* @param aParent The new parent node for the content node. May be a document.
* @note This method must not be called by consumers of nsIContent on a node
* that is already bound to a tree. Call UnbindFromTree first.
* @note This method will handle rebinding descendants appropriately (eg
@ -108,8 +101,7 @@ class nsIContent : public nsINode {
* TODO(emilio): Should we move to nsIContent::BindToTree most of the
* FragmentOrElement / CharacterData duplicated code?
*/
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) = 0;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) = 0;
/**
* Unbind this content node from a tree. This will set its current document
@ -194,28 +186,18 @@ class nsIContent : public nsINode {
*/
nsIContent* FindFirstNonChromeOnlyAccessContent() const;
#ifdef DEBUG
void AssertAnonymousSubtreeRelatedInvariants() const;
#endif
/**
* Returns true if and only if this node has a parent, but is not in
* its parent's child list.
*/
bool IsRootOfAnonymousSubtree() const {
NS_ASSERTION(!IsRootOfNativeAnonymousSubtree() ||
(GetParent() && GetBindingParent() == GetParent()),
"root of native anonymous subtree must have parent equal "
"to binding parent");
NS_ASSERTION(!GetParent() ||
((GetBindingParent() == GetParent()) ==
HasFlag(NODE_IS_ANONYMOUS_ROOT)) ||
// Unfortunately default content for XBL insertion points
// is anonymous content that is bound with the parent of
// the insertion point as the parent but the bound element
// for the binding as the binding parent. So we have to
// complicate the assert a bit here.
(GetBindingParent() &&
(GetBindingParent() == GetParent()->GetBindingParent()) ==
HasFlag(NODE_IS_ANONYMOUS_ROOT)),
"For nodes with parent, flag and GetBindingParent() check "
"should match");
#ifdef DEBUG
AssertAnonymousSubtreeRelatedInvariants();
#endif
return HasFlag(NODE_IS_ANONYMOUS_ROOT);
}
@ -409,7 +391,7 @@ class nsIContent : public nsINode {
*
* @return the binding parent
*/
virtual nsIContent* GetBindingParent() const {
virtual mozilla::dom::Element* GetBindingParent() const {
const nsExtendedContentSlots* slots = GetExistingExtendedContentSlots();
return slots ? slots->mBindingParent.get() : nullptr;
}
@ -743,11 +725,10 @@ class nsIContent : public nsINode {
/**
* The nearest enclosing content node with a binding that created us.
* TODO(emilio): This should be an Element*.
*
* @see nsIContent::GetBindingParent
*/
nsCOMPtr<nsIContent> mBindingParent;
RefPtr<mozilla::dom::Element> mBindingParent;
/**
* @see nsIContent::GetXBLInsertionPoint

View File

@ -28,6 +28,7 @@
#include "mozilla/Telemetry.h"
#include "mozilla/TextEditor.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/dom/BindContext.h"
#include "mozilla/dom/CharacterData.h"
#include "mozilla/dom/DocumentType.h"
#include "mozilla/dom/Element.h"
@ -1223,7 +1224,6 @@ nsresult nsINode::InsertChildBefore(nsIContent* aKid,
nsMutationGuard::DidMutate();
// Do this before checking the child-count since this could cause mutations
Document* doc = GetUncomposedDoc();
mozAutoDocUpdate updateBatch(GetComposedDoc(), aNotify);
if (OwnerDoc() != aKid->OwnerDoc()) {
@ -1249,8 +1249,8 @@ nsresult nsINode::InsertChildBefore(nsIContent* aKid,
// XXXbz Do we even need this code anymore?
bool wasInNACScope = ShouldUseNACScope(aKid);
nsresult rv = aKid->BindToTree(doc, parent,
parent ? parent->GetBindingParent() : nullptr);
BindContext context(*this);
nsresult rv = aKid->BindToTree(context, *this);
if (NS_SUCCEEDED(rv) && !wasInNACScope && ShouldUseNACScope(aKid)) {
MOZ_ASSERT(ShouldUseNACScope(this),
"Why does the kid need to use an the anonymous content scope?");

View File

@ -1610,10 +1610,11 @@ void nsImageLoadingContent::NotifyOwnerDocumentActivityChanged() {
}
}
void nsImageLoadingContent::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
void nsImageLoadingContent::BindToTree(BindContext& aContext,
nsINode& aParent) {
// We may be getting connected, if so our image should be tracked,
if (GetOurCurrentDoc()) {
// NOTE(emilio): Using aParent to avoid silly virtual call.
if (aParent.IsInComposedDoc()) {
TrackImage(mCurrentRequest);
TrackImage(mPendingRequest);
}

View File

@ -35,6 +35,7 @@ class imgRequestProxy;
namespace mozilla {
class AsyncEventDispatcher;
namespace dom {
struct BindContext;
class Document;
class Element;
} // namespace dom
@ -216,8 +217,7 @@ class nsImageLoadingContent : public nsIImageLoadingContent {
virtual mozilla::net::ReferrerPolicy GetImageReferrerPolicy();
// Subclasses are *required* to call BindToTree/UnbindFromTree.
void BindToTree(mozilla::dom::Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent);
void BindToTree(mozilla::dom::BindContext&, nsINode& aParent);
void UnbindFromTree(bool aNullParent);
nsresult OnLoadComplete(imgIRequest* aRequest, nsresult aStatus);

View File

@ -16,6 +16,7 @@
#include "nsIContent.h"
#include "nsIContentInlines.h"
#include "nsIDocShell.h"
#include "mozilla/dom/BindContext.h"
#include "mozilla/dom/Document.h"
#include "nsIExternalProtocolHandler.h"
#include "nsIInterfaceRequestorUtils.h"
@ -563,15 +564,14 @@ already_AddRefed<nsIDocShell> nsObjectLoadingContent::SetupDocShell(
return docShell.forget();
}
nsresult nsObjectLoadingContent::BindToTree(Document* aDocument,
nsIContent* aParent,
nsIContent* aBindingParent) {
nsImageLoadingContent::BindToTree(aDocument, aParent, aBindingParent);
if (aDocument) {
aDocument->AddPlugin(this);
nsresult nsObjectLoadingContent::BindToTree(BindContext& aContext,
nsINode& aParent) {
nsImageLoadingContent::BindToTree(aContext, aParent);
// NOTE(emilio): Using aParent to avoid silly QI.
// FIXME(emilio): Should probably use composed doc?
if (aParent.IsInUncomposedDoc()) {
aContext.OwnerDoc().AddPlugin(this);
}
return NS_OK;
}

View File

@ -35,6 +35,7 @@ class nsPluginInstanceOwner;
namespace mozilla {
namespace dom {
struct BindContext;
template <typename T>
class Sequence;
struct MozPluginParameter;
@ -316,8 +317,7 @@ class nsObjectLoadingContent : public nsImageLoadingContent,
void DoStopPlugin(nsPluginInstanceOwner* aInstanceOwner);
nsresult BindToTree(mozilla::dom::Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent);
nsresult BindToTree(mozilla::dom::BindContext&, nsINode& aParent);
void UnbindFromTree(bool aNullParent = true);
/**

View File

@ -42,8 +42,7 @@ class nsAttributeTextNode final : public nsTextNode,
NS_ASSERTION(mAttrName, "Must have attr name");
}
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;
NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
@ -113,9 +112,8 @@ nsresult nsTextNode::AppendTextForNormalize(const char16_t* aBuffer,
&details);
}
nsresult nsTextNode::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv = CharacterData::BindToTree(aDocument, aParent, aBindingParent);
nsresult nsTextNode::BindToTree(BindContext& aContext, nsINode& aParent) {
nsresult rv = CharacterData::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
SetDirectionFromNewTextNode(this);
@ -194,18 +192,17 @@ nsresult NS_NewAttributeContent(nsNodeInfoManager* aNodeInfoManager,
NS_IMPL_ISUPPORTS_INHERITED(nsAttributeTextNode, nsTextNode,
nsIMutationObserver)
nsresult nsAttributeTextNode::BindToTree(Document* aDocument,
nsIContent* aParent,
nsIContent* aBindingParent) {
MOZ_ASSERT(
aParent && aParent->GetParent(),
"This node can't be a child of the document or of the document root");
nsresult nsAttributeTextNode::BindToTree(BindContext& aContext,
nsINode& aParent) {
MOZ_ASSERT(aParent.IsContent() && aParent.GetParent(),
"This node can't be a child of the document or of "
"the document root");
nsresult rv = nsTextNode::BindToTree(aDocument, aParent, aBindingParent);
nsresult rv = nsTextNode::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
NS_ASSERTION(!mGrandparent, "We were already bound!");
mGrandparent = aParent->GetParent()->AsElement();
mGrandparent = aParent.GetParent()->AsElement();
mGrandparent->AddMutationObserver(this);
// Note that there is no need to notify here, since we have no

View File

@ -46,8 +46,7 @@ class nsTextNode : public mozilla::dom::Text {
virtual already_AddRefed<CharacterData> CloneDataNode(
mozilla::dom::NodeInfo* aNodeInfo, bool aCloneText) const override;
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;
nsresult AppendTextForNormalize(const char16_t* aBuffer, uint32_t aLength,

View File

@ -6,6 +6,7 @@
#include "mozilla/dom/HTMLAnchorElement.h"
#include "mozilla/dom/BindContext.h"
#include "mozilla/dom/HTMLAnchorElementBinding.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/EventStates.h"
@ -93,18 +94,16 @@ bool HTMLAnchorElement::HasDeferredDNSPrefetchRequest() {
return HasFlag(HTML_ANCHOR_DNS_PREFETCH_DEFERRED);
}
nsresult HTMLAnchorElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult HTMLAnchorElement::BindToTree(BindContext& aContext,
nsINode& aParent) {
Link::ResetLinkState(false, Link::ElementHasHref());
nsresult rv =
nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
// Prefetch links
Document* doc = GetComposedDoc();
if (doc) {
doc->RegisterPendingLinkUpdate(this);
if (IsInComposedDoc()) {
aContext.OwnerDoc().RegisterPendingLinkUpdate(this);
TryDNSPrefetch();
}

View File

@ -43,8 +43,7 @@ class HTMLAnchorElement final : public nsGenericHTMLElement, public Link {
// DOM memory reporter participant
NS_DECL_ADDSIZEOFEXCLUDINGTHIS
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;
virtual bool IsHTMLFocusable(bool aWithMouse, bool* aIsFocusable,
int32_t* aTabIndex) override;

View File

@ -7,6 +7,7 @@
#include "mozilla/dom/HTMLAreaElement.h"
#include "mozilla/Attributes.h"
#include "mozilla/dom/BindContext.h"
#include "mozilla/dom/HTMLAnchorElement.h"
#include "mozilla/dom/HTMLAreaElementBinding.h"
#include "mozilla/EventDispatcher.h"
@ -66,16 +67,13 @@ nsDOMTokenList* HTMLAreaElement::RelList() {
return mRelList;
}
nsresult HTMLAreaElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult HTMLAreaElement::BindToTree(BindContext& aContext, nsINode& aParent) {
Link::ResetLinkState(false, Link::ElementHasHref());
nsresult rv =
nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
Document* doc = GetComposedDoc();
if (doc) {
doc->RegisterPendingLinkUpdate(this);
if (IsInComposedDoc()) {
aContext.OwnerDoc().RegisterPendingLinkUpdate(this);
}
return rv;
}

View File

@ -43,8 +43,7 @@ class HTMLAreaElement final : public nsGenericHTMLElement, public Link {
virtual void GetLinkTarget(nsAString& aTarget) override;
virtual already_AddRefed<nsIURI> GetHrefURI() const override;
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;
virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;

View File

@ -5,6 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "HTMLBodyElement.h"
#include "mozilla/dom/BindContext.h"
#include "mozilla/dom/HTMLBodyElementBinding.h"
#include "mozilla/MappedDeclarations.h"
#include "mozilla/HTMLEditor.h"
@ -283,12 +284,10 @@ bool HTMLBodyElement::IsEventAttributeNameInternal(nsAtom* aName) {
aName, EventNameType_HTML | EventNameType_HTMLBodyOrFramesetOnly);
}
nsresult HTMLBodyElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv =
nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult HTMLBodyElement::BindToTree(BindContext& aContext, nsINode& aParent) {
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
return mAttrs.ForceMapped(this, OwnerDoc());
return mAttrs.ForceMapped(this, &aContext.OwnerDoc());
}
nsresult HTMLBodyElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,

View File

@ -100,8 +100,7 @@ class HTMLBodyElement final : public nsGenericHTMLElement {
virtual bool IsEventAttributeNameInternal(nsAtom* aName) override;
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
/**
* Called when an attribute has just been changed
*/

View File

@ -287,10 +287,10 @@ nsresult HTMLButtonElement::PostHandleEvent(EventChainPostVisitor& aVisitor) {
return rv;
}
nsresult HTMLButtonElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv = nsGenericHTMLFormElementWithState::BindToTree(
aDocument, aParent, aBindingParent);
nsresult HTMLButtonElement::BindToTree(BindContext& aContext,
nsINode& aParent) {
nsresult rv =
nsGenericHTMLFormElementWithState::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
// Update our state; we may now be the default submit element

View File

@ -60,8 +60,7 @@ class HTMLButtonElement final : public nsGenericHTMLFormElementWithState,
JS::Handle<JSObject*> aGivenProto) override;
// nsIContent
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;
virtual void DoneCreatingElement() override;

View File

@ -5,6 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/EventStates.h"
#include "mozilla/dom/BindContext.h"
#include "mozilla/dom/HTMLEmbedElement.h"
#include "mozilla/dom/HTMLEmbedElementBinding.h"
#include "mozilla/dom/ElementInlines.h"
@ -73,24 +74,24 @@ void HTMLEmbedElement::AsyncEventRunning(AsyncEventDispatcher* aEvent) {
nsImageLoadingContent::AsyncEventRunning(aEvent);
}
nsresult HTMLEmbedElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv =
nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult HTMLEmbedElement::BindToTree(BindContext& aContext, nsINode& aParent) {
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
rv = nsObjectLoadingContent::BindToTree(aDocument, aParent, aBindingParent);
rv = nsObjectLoadingContent::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
// Don't kick off load from being bound to a plugin document - the plugin
// document will call nsObjectLoadingContent::InitializeFromChannel() for the
// initial load.
nsCOMPtr<nsIPluginDocument> pluginDoc = do_QueryInterface(aDocument);
if (!pluginDoc) {
void (HTMLEmbedElement::*start)() = &HTMLEmbedElement::StartObjectLoad;
nsContentUtils::AddScriptRunner(
NewRunnableMethod("dom::HTMLEmbedElement::BindToTree", this, start));
if (IsInComposedDoc()) {
// Don't kick off load from being bound to a plugin document - the plugin
// document will call nsObjectLoadingContent::InitializeFromChannel() for the
// initial load.
nsCOMPtr<nsIPluginDocument> pluginDoc =
do_QueryInterface(&aContext.OwnerDoc());
if (!pluginDoc) {
void (HTMLEmbedElement::*start)() = &HTMLEmbedElement::StartObjectLoad;
nsContentUtils::AddScriptRunner(
NewRunnableMethod("dom::HTMLEmbedElement::BindToTree", this, start));
}
}
return NS_OK;

View File

@ -36,8 +36,7 @@ class HTMLEmbedElement final : public nsGenericHTMLElement,
// EventTarget
virtual void AsyncEventRunning(AsyncEventDispatcher* aEvent) override;
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;
virtual bool IsHTMLFocusable(bool aWithMouse, bool* aIsFocusable,

View File

@ -10,6 +10,7 @@
#include "mozilla/ContentEvents.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/EventStates.h"
#include "mozilla/dom/BindContext.h"
#include "mozilla/dom/nsCSPUtils.h"
#include "mozilla/dom/nsCSPContext.h"
#include "mozilla/dom/nsMixedContentBlocker.h"
@ -25,6 +26,7 @@
#include "nsIFormControlFrame.h"
#include "nsError.h"
#include "nsContentUtils.h"
#include "nsHTMLDocument.h"
#include "nsInterfaceHashtable.h"
#include "nsContentList.h"
#include "nsCOMArray.h"
@ -251,15 +253,12 @@ bool HTMLFormElement::ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
aMaybeScriptedPrincipal, aResult);
}
nsresult HTMLFormElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv =
nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult HTMLFormElement::BindToTree(BindContext& aContext, nsINode& aParent) {
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIHTMLDocument> htmlDoc(do_QueryInterface(aDocument));
if (htmlDoc) {
htmlDoc->AddedForm();
if (IsInUncomposedDoc() && aContext.OwnerDoc().IsHTMLOrXHTML()) {
aContext.OwnerDoc().AsHTMLDocument()->AddedForm();
}
return rv;

View File

@ -94,8 +94,7 @@ class HTMLFormElement final : public nsGenericHTMLElement,
void WillHandleEvent(EventChainPostVisitor& aVisitor) override;
virtual nsresult PostHandleEvent(EventChainPostVisitor& aVisitor) override;
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;
virtual nsresult BeforeSetAttr(int32_t aNamespaceID, nsAtom* aName,
const nsAttrValueOrString* aValue,

View File

@ -65,10 +65,9 @@ HTMLIFrameElement::~HTMLIFrameElement() {}
NS_IMPL_ELEMENT_CLONE(HTMLIFrameElement)
nsresult HTMLIFrameElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv =
nsGenericHTMLFrameElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult HTMLIFrameElement::BindToTree(BindContext& aContext,
nsINode& aParent) {
nsresult rv = nsGenericHTMLFrameElement::BindToTree(aContext, aParent);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}

View File

@ -34,8 +34,7 @@ class HTMLIFrameElement final : public nsGenericHTMLFrameElement {
}
// nsIContent
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
const nsAString& aValue,
nsIPrincipal* aMaybeScriptedPrincipal,

View File

@ -6,6 +6,7 @@
#include "mozilla/dom/HTMLImageElement.h"
#include "mozilla/dom/HTMLImageElementBinding.h"
#include "mozilla/dom/BindContext.h"
#include "nsGkAtoms.h"
#include "nsStyleConsts.h"
#include "nsPresContext.h"
@ -491,22 +492,17 @@ bool HTMLImageElement::IsHTMLFocusable(bool aWithMouse, bool* aIsFocusable,
return false;
}
nsresult HTMLImageElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv =
nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult HTMLImageElement::BindToTree(BindContext& aContext, nsINode& aParent) {
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
nsImageLoadingContent::BindToTree(aDocument, aParent, aBindingParent);
nsImageLoadingContent::BindToTree(aContext, aParent);
if (aParent) {
UpdateFormOwner();
}
UpdateFormOwner();
if (HaveSrcsetOrInPicture()) {
Document* doc = GetComposedDoc();
if (doc && !mInDocResponsiveContent) {
doc->AddResponsiveContent(this);
if (IsInComposedDoc() && !mInDocResponsiveContent) {
aContext.OwnerDoc().AddResponsiveContent(this);
mInDocResponsiveContent = true;
}
@ -537,7 +533,7 @@ nsresult HTMLImageElement::BindToTree(Document* aDocument, nsIContent* aParent,
// If loading is temporarily disabled, don't even launch MaybeLoadImage.
// Otherwise MaybeLoadImage may run later when someone has reenabled
// loading.
if (LoadingEnabled() && OwnerDoc()->ShouldLoadImages()) {
if (LoadingEnabled() && aContext.OwnerDoc().ShouldLoadImages()) {
nsContentUtils::AddScriptRunner(
NewRunnableMethod<bool>("dom::HTMLImageElement::MaybeLoadImage", this,
&HTMLImageElement::MaybeLoadImage, false));

View File

@ -73,8 +73,7 @@ class HTMLImageElement final : public nsGenericHTMLElement,
bool IsHTMLFocusable(bool aWithMouse, bool* aIsFocusable,
int32_t* aTabIndex) override;
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent) override;
virtual EventStates IntrinsicState() const override;

View File

@ -4265,13 +4265,12 @@ void HTMLInputElement::MaybeLoadImage() {
}
}
nsresult HTMLInputElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv = nsGenericHTMLFormElementWithState::BindToTree(
aDocument, aParent, aBindingParent);
nsresult HTMLInputElement::BindToTree(BindContext& aContext, nsINode& aParent) {
nsresult rv =
nsGenericHTMLFormElementWithState::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
nsImageLoadingContent::BindToTree(aDocument, aParent, aBindingParent);
nsImageLoadingContent::BindToTree(aContext, aParent);
if (mType == NS_FORM_INPUT_IMAGE) {
// Our base URI may have changed; claim that our URI changed, and the

View File

@ -200,8 +200,7 @@ class HTMLInputElement final : public nsGenericHTMLFormElementWithState,
MOZ_CAN_RUN_SCRIPT
void SetValueOfRangeForUserEvent(Decimal aValue);
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;
MOZ_CAN_RUN_SCRIPT_BOUNDARY

View File

@ -57,9 +57,9 @@ nsChangeHint HTMLLegendElement::GetAttributeChangeHint(const nsAtom* aAttribute,
return retval;
}
nsresult HTMLLegendElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
return nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult HTMLLegendElement::BindToTree(BindContext& aContext,
nsINode& aParent) {
return nsGenericHTMLElement::BindToTree(aContext, aParent);
}
void HTMLLegendElement::UnbindFromTree(bool aNullParent) {

View File

@ -30,8 +30,7 @@ class HTMLLegendElement final : public nsGenericHTMLElement {
bool aIsTrustedEvent) override;
// nsIContent
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;
virtual bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
const nsAString& aValue,

View File

@ -12,6 +12,7 @@
#include "mozilla/EventStates.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/Preferences.h"
#include "mozilla/dom/BindContext.h"
#include "mozilla/dom/DocumentInlines.h"
#include "mozilla/dom/HTMLLinkElementBinding.h"
#include "nsContentUtils.h"
@ -116,17 +117,15 @@ bool HTMLLinkElement::HasDeferredDNSPrefetchRequest() {
return HasFlag(HTML_LINK_DNS_PREFETCH_DEFERRED);
}
nsresult HTMLLinkElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult HTMLLinkElement::BindToTree(BindContext& aContext, nsINode& aParent) {
Link::ResetLinkState(false, Link::ElementHasHref());
nsresult rv =
nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
if (Document* doc = GetComposedDoc()) {
if (!doc->NodePrincipal()->IsSystemPrincipal()) {
doc->RegisterPendingLinkUpdate(this);
if (IsInComposedDoc()) {
if (!aContext.OwnerDoc().NodePrincipal()->IsSystemPrincipal()) {
aContext.OwnerDoc().RegisterPendingLinkUpdate(this);
}
TryDNSPrefetchOrPreconnectOrPrefetchOrPreloadOrPrerender();
}
@ -136,12 +135,15 @@ nsresult HTMLLinkElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsContentUtils::AddScriptRunner(
NewRunnableMethod("dom::HTMLLinkElement::BindToTree", this, update));
if (aDocument && AttrValueIs(kNameSpaceID_None, nsGkAtoms::rel,
nsGkAtoms::localization, eIgnoreCase)) {
aDocument->LocalizationLinkAdded(this);
// FIXME(emilio, bug 1555947): Why does this use the uncomposed doc but the
// attribute change code the composed doc?
if (IsInUncomposedDoc() &&
AttrValueIs(kNameSpaceID_None, nsGkAtoms::rel, nsGkAtoms::localization,
eIgnoreCase)) {
aContext.OwnerDoc().LocalizationLinkAdded(this);
}
CreateAndDispatchEvent(aDocument, NS_LITERAL_STRING("DOMLinkAdded"));
LinkAdded();
return rv;
}

View File

@ -48,8 +48,7 @@ class HTMLLinkElement final : public nsGenericHTMLElement,
JS::Handle<JSObject*> aGivenProto) override;
// nsIContent
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;
virtual nsresult BeforeSetAttr(int32_t aNameSpaceID, nsAtom* aName,
const nsAttrValueOrString* aValue,

View File

@ -46,11 +46,9 @@ JSObject* HTMLMarqueeElement::WrapNode(JSContext* aCx,
return dom::HTMLMarqueeElement_Binding::Wrap(aCx, this, aGivenProto);
}
nsresult HTMLMarqueeElement::BindToTree(Document* aDocument,
nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv =
nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult HTMLMarqueeElement::BindToTree(BindContext& aContext,
nsINode& aParent) {
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
if (IsInComposedDoc()) {

View File

@ -17,8 +17,7 @@ class HTMLMarqueeElement final : public nsGenericHTMLElement {
explicit HTMLMarqueeElement(already_AddRefed<dom::NodeInfo>&& aNodeInfo)
: nsGenericHTMLElement(std::move(aNodeInfo)) {}
nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
nsresult BindToTree(BindContext&, nsINode& aParent) override;
void UnbindFromTree(bool aNullParent = true) override;
static const int kDefaultLoop = -1;

View File

@ -4066,10 +4066,8 @@ void HTMLMediaElement::AfterMaybeChangeAttr(int32_t aNamespaceID, nsAtom* aName,
}
}
nsresult HTMLMediaElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv =
nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult HTMLMediaElement::BindToTree(BindContext& aContext, nsINode& aParent) {
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
if (IsInComposedDoc()) {
// Construct Shadow Root so web content can be hidden in the DOM.
@ -4077,9 +4075,11 @@ nsresult HTMLMediaElement::BindToTree(Document* aDocument, nsIContent* aParent,
NotifyUAWidgetSetupOrChange();
}
// FIXME(emilio, bug 1555946): mUnboundFromTree doesn't make any sense, should
// just use IsInComposedDoc() in the relevant places or something.
mUnboundFromTree = false;
if (aDocument) {
if (IsInUncomposedDoc()) {
// The preload action depends on the value of the autoplay attribute.
// It's value may have changed, so update it.
UpdatePreloadAction();
@ -5679,8 +5679,7 @@ bool HTMLMediaElement::IsActive() const {
}
bool HTMLMediaElement::IsHidden() const {
Document* ownerDoc;
return mUnboundFromTree || !(ownerDoc = OwnerDoc()) || ownerDoc->Hidden();
return mUnboundFromTree || OwnerDoc()->Hidden();
}
VideoFrameContainer* HTMLMediaElement::GetVideoFrameContainer() {

View File

@ -34,7 +34,6 @@
# undef CurrentTime
#endif
// Define to output information on decoding and painting framerate
/* #define DEBUG_FRAME_RATE 1 */
@ -148,8 +147,7 @@ class HTMLMediaElement : public nsGenericHTMLElement,
nsIPrincipal* aMaybeScriptedPrincipal,
nsAttrValue& aResult) override;
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;
virtual void DoneCreatingElement() override;

View File

@ -269,13 +269,12 @@ nsresult HTMLMenuItemElement::PostHandleEvent(EventChainPostVisitor& aVisitor) {
return NS_OK;
}
nsresult HTMLMenuItemElement::BindToTree(Document* aDocument,
nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv =
nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult HTMLMenuItemElement::BindToTree(BindContext& aContext,
nsINode& aParent) {
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
if (NS_SUCCEEDED(rv) && aDocument && mType == CMD_TYPE_RADIO) {
if (IsInUncomposedDoc() && mType == CMD_TYPE_RADIO) {
AddedToRadioGroup();
}

View File

@ -34,8 +34,7 @@ class HTMLMenuItemElement final : public nsGenericHTMLElement {
void GetEventTargetParent(EventChainPreVisitor& aVisitor) override;
virtual nsresult PostHandleEvent(EventChainPostVisitor& aVisitor) override;
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
const nsAString& aValue,

View File

@ -5,6 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/AsyncEventDispatcher.h"
#include "mozilla/dom/BindContext.h"
#include "mozilla/dom/HTMLMetaElement.h"
#include "mozilla/dom/HTMLMetaElementBinding.h"
#include "mozilla/dom/nsCSPService.h"
@ -70,25 +71,26 @@ nsresult HTMLMetaElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
aNameSpaceID, aName, aValue, aOldValue, aSubjectPrincipal, aNotify);
}
nsresult HTMLMetaElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv =
nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult HTMLMetaElement::BindToTree(BindContext& aContext, nsINode& aParent) {
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
if (aDocument && AttrValueIs(kNameSpaceID_None, nsGkAtoms::name,
nsGkAtoms::viewport, eIgnoreCase)) {
if (!IsInUncomposedDoc()) {
return rv;
}
Document& doc = aContext.OwnerDoc();
if (AttrValueIs(kNameSpaceID_None, nsGkAtoms::name, nsGkAtoms::viewport,
eIgnoreCase)) {
nsAutoString content;
GetContent(content);
nsContentUtils::ProcessViewportInfo(aDocument, content);
nsContentUtils::ProcessViewportInfo(&doc, content);
}
if (StaticPrefs::security_csp_enable() && aDocument &&
!aDocument->IsLoadedAsData() &&
if (StaticPrefs::security_csp_enable() && !doc.IsLoadedAsData() &&
AttrValueIs(kNameSpaceID_None, nsGkAtoms::httpEquiv, nsGkAtoms::headerCSP,
eIgnoreCase)) {
// only accept <meta http-equiv="Content-Security-Policy" content=""> if it
// appears in the <head> element.
Element* headElt = aDocument->GetHeadElement();
Element* headElt = doc.GetHeadElement();
if (headElt && nsContentUtils::ContentIsDescendantOf(this, headElt)) {
nsAutoString content;
GetContent(content);
@ -96,19 +98,17 @@ nsresult HTMLMetaElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsContentUtils::TrimWhitespace<nsContentUtils::IsHTMLWhitespace>(
content);
nsCOMPtr<nsIContentSecurityPolicy> csp = aDocument->GetCsp();
if (csp) {
if (nsCOMPtr<nsIContentSecurityPolicy> csp = doc.GetCsp()) {
if (LOG_ENABLED()) {
nsAutoCString documentURIspec;
nsIURI* documentURI = aDocument->GetDocumentURI();
if (documentURI) {
if (nsIURI* documentURI = doc.GetDocumentURI()) {
documentURI->GetAsciiSpec(documentURIspec);
}
LOG(
("HTMLMetaElement %p sets CSP '%s' on document=%p, "
"document-uri=%s",
this, NS_ConvertUTF16toUTF8(content).get(), aDocument,
this, NS_ConvertUTF16toUTF8(content).get(), &doc,
documentURIspec.get()));
}
@ -120,19 +120,18 @@ nsresult HTMLMetaElement::BindToTree(Document* aDocument, nsIContent* aParent,
false, // csp via meta tag can not be report only
true); // delivered through the meta tag
NS_ENSURE_SUCCESS(rv, rv);
nsPIDOMWindowInner* inner = aDocument->GetInnerWindow();
if (inner) {
if (nsPIDOMWindowInner* inner = doc.GetInnerWindow()) {
inner->SetCsp(csp);
}
aDocument->ApplySettingsFromCSP(false);
doc.ApplySettingsFromCSP(false);
}
}
}
// Referrer Policy spec requires a <meta name="referrer" tag to be in the
// <head> element.
SetMetaReferrer(aDocument);
CreateAndDispatchEvent(aDocument, NS_LITERAL_STRING("DOMMetaAdded"));
SetMetaReferrer(&doc);
CreateAndDispatchEvent(&doc, NS_LITERAL_STRING("DOMMetaAdded"));
return rv;
}

View File

@ -21,8 +21,7 @@ class HTMLMetaElement final : public nsGenericHTMLElement {
// nsISupports
NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLMetaElement, nsGenericHTMLElement)
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;
virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,

View File

@ -5,6 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/EventStates.h"
#include "mozilla/dom/BindContext.h"
#include "mozilla/dom/HTMLFormSubmission.h"
#include "mozilla/dom/HTMLObjectElement.h"
#include "mozilla/dom/HTMLObjectElementBinding.h"
@ -196,25 +197,26 @@ HTMLObjectElement::PostHandleEvent(EventChainPostVisitor& aVisitor) {
#endif // #ifdef XP_MACOSX
nsresult HTMLObjectElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv =
nsGenericHTMLFormElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult HTMLObjectElement::BindToTree(BindContext& aContext,
nsINode& aParent) {
nsresult rv = nsGenericHTMLFormElement::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
rv = nsObjectLoadingContent::BindToTree(aDocument, aParent, aBindingParent);
rv = nsObjectLoadingContent::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
// Don't kick off load from being bound to a plugin document - the plugin
// document will call nsObjectLoadingContent::InitializeFromChannel() for the
// initial load.
nsCOMPtr<nsIPluginDocument> pluginDoc = do_QueryInterface(aDocument);
// If we already have all the children, start the load.
if (mIsDoneAddingChildren && !pluginDoc) {
void (HTMLObjectElement::*start)() = &HTMLObjectElement::StartObjectLoad;
nsContentUtils::AddScriptRunner(
NewRunnableMethod("dom::HTMLObjectElement::BindToTree", this, start));
if (IsInComposedDoc()) {
nsCOMPtr<nsIPluginDocument> pluginDoc =
do_QueryInterface(&aContext.OwnerDoc());
// If we already have all the children, start the load.
if (mIsDoneAddingChildren && !pluginDoc) {
void (HTMLObjectElement::*start)() = &HTMLObjectElement::StartObjectLoad;
nsContentUtils::AddScriptRunner(
NewRunnableMethod("dom::HTMLObjectElement::BindToTree", this, start));
}
}
return NS_OK;

View File

@ -52,8 +52,7 @@ class HTMLObjectElement final : public nsGenericHTMLFormElement,
// EventTarget
virtual void AsyncEventRunning(AsyncEventDispatcher* aEvent) override;
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;
virtual bool IsHTMLFocusable(bool aWithMouse, bool* aIsFocusable,

View File

@ -243,10 +243,9 @@ void HTMLOptionElement::SetText(const nsAString& aText, ErrorResult& aRv) {
aRv = nsContentUtils::SetNodeTextContent(this, aText, true);
}
nsresult HTMLOptionElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv =
nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult HTMLOptionElement::BindToTree(BindContext& aContext,
nsINode& aParent) {
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
// Our new parent might change :disabled/:enabled state.

View File

@ -65,8 +65,7 @@ class HTMLOptionElement final : public nsGenericHTMLElement {
*/
void UpdateDisabledState(bool aNotify);
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;
// nsIContent

View File

@ -100,10 +100,9 @@ EventStates HTMLOutputElement::IntrinsicState() const {
return states;
}
nsresult HTMLOutputElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv =
nsGenericHTMLFormElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult HTMLOutputElement::BindToTree(BindContext& aContext,
nsINode& aParent) {
nsresult rv = nsGenericHTMLFormElement::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
// Unfortunately, we can actually end up having to change our state

View File

@ -45,8 +45,7 @@ class HTMLOutputElement final : public nsGenericHTMLFormElement,
EventStates IntrinsicState() const override;
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
// This function is called when a callback function from nsIMutationObserver
// has to be used to update the defaultValue attribute.

View File

@ -47,13 +47,12 @@ NS_IMPL_ISUPPORTS_INHERITED(HTMLScriptElement, nsGenericHTMLElement,
nsIScriptLoaderObserver, nsIScriptElement,
nsIMutationObserver)
nsresult HTMLScriptElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv =
nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult HTMLScriptElement::BindToTree(BindContext& aContext,
nsINode& aParent) {
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
if (GetComposedDoc()) {
if (IsInComposedDoc()) {
MaybeProcessScript();
}

View File

@ -39,8 +39,7 @@ class HTMLScriptElement final : public nsGenericHTMLElement,
virtual mozilla::net::ReferrerPolicy GetReferrerPolicy() override;
// nsIContent
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
const nsAString& aValue,
nsIPrincipal* aMaybeScriptedPrincipal,

View File

@ -1003,10 +1003,10 @@ bool HTMLSelectElement::SelectSomething(bool aNotify) {
return false;
}
nsresult HTMLSelectElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv = nsGenericHTMLFormElementWithState::BindToTree(
aDocument, aParent, aBindingParent);
nsresult HTMLSelectElement::BindToTree(BindContext& aContext,
nsINode& aParent) {
nsresult rv =
nsGenericHTMLFormElementWithState::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
// If there is a disabled fieldset in the parent chain, the element is now

View File

@ -268,8 +268,7 @@ class HTMLSelectElement final : public nsGenericHTMLFormElementWithState,
/**
* Called when an attribute is about to be changed
*/
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent) override;
virtual nsresult BeforeSetAttr(int32_t aNameSpaceID, nsAtom* aName,
const nsAttrValueOrString* aValue,

View File

@ -5,6 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/HTMLSharedElement.h"
#include "mozilla/dom/BindContext.h"
#include "mozilla/dom/HTMLBaseElementBinding.h"
#include "mozilla/dom/HTMLDirectoryElementBinding.h"
#include "mozilla/dom/HTMLHeadElementBinding.h"
@ -224,20 +225,19 @@ nsresult HTMLSharedElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName,
aNamespaceID, aName, aValue, aOldValue, aSubjectPrincipal, aNotify);
}
nsresult HTMLSharedElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv =
nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult HTMLSharedElement::BindToTree(BindContext& aContext,
nsINode& aParent) {
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
// The document stores a pointer to its base URI and base target, which we may
// need to update here.
if (mNodeInfo->Equals(nsGkAtoms::base) && aDocument) {
if (mNodeInfo->Equals(nsGkAtoms::base) && IsInUncomposedDoc()) {
if (HasAttr(kNameSpaceID_None, nsGkAtoms::href)) {
SetBaseURIUsingFirstBaseWithHref(aDocument, this);
SetBaseURIUsingFirstBaseWithHref(&aContext.OwnerDoc(), this);
}
if (HasAttr(kNameSpaceID_None, nsGkAtoms::target)) {
SetBaseTargetUsingFirstBaseWithTarget(aDocument, this);
SetBaseTargetUsingFirstBaseWithTarget(&aContext.OwnerDoc(), this);
}
}

View File

@ -36,8 +36,7 @@ class HTMLSharedElement final : public nsGenericHTMLElement {
nsIPrincipal* aMaybeScriptedPrincipal,
nsAttrValue& aResult) override;
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;

View File

@ -39,12 +39,10 @@ NS_INTERFACE_MAP_END_INHERITING(nsGenericHTMLElement)
NS_IMPL_ELEMENT_CLONE(HTMLSlotElement)
nsresult HTMLSlotElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult HTMLSlotElement::BindToTree(BindContext& aContext, nsINode& aParent) {
RefPtr<ShadowRoot> oldContainingShadow = GetContainingShadow();
nsresult rv =
nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
ShadowRoot* containingShadow = GetContainingShadow();

View File

@ -27,8 +27,7 @@ class HTMLSlotElement final : public nsGenericHTMLElement {
virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
// nsIContent
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent) override;
virtual nsresult BeforeSetAttr(int32_t aNameSpaceID, nsAtom* aName,

View File

@ -124,13 +124,12 @@ nsresult HTMLSourceElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
aNameSpaceID, aName, aValue, aOldValue, aMaybeScriptedPrincipal, aNotify);
}
nsresult HTMLSourceElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv =
nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult HTMLSourceElement::BindToTree(BindContext& aContext,
nsINode& aParent) {
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
if (auto* media = HTMLMediaElement::FromNodeOrNull(aParent)) {
if (auto* media = HTMLMediaElement::FromNode(aParent)) {
media->NotifyAddedSource();
}

View File

@ -34,8 +34,7 @@ class HTMLSourceElement final : public nsGenericHTMLElement {
// Override BindToTree() so that we can trigger a load when we add a
// child source element.
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
// If this element's media attr matches for its owner document. Returns true
// if no media attr was set.

View File

@ -81,10 +81,8 @@ void HTMLStyleElement::ContentChanged(nsIContent* aContent) {
}
}
nsresult HTMLStyleElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv =
nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult HTMLStyleElement::BindToTree(BindContext& aContext, nsINode& aParent) {
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
void (HTMLStyleElement::*update)() =

View File

@ -38,8 +38,7 @@ class HTMLStyleElement final : public nsGenericHTMLElement,
nsIPrincipal* aSubjectPrincipal,
mozilla::ErrorResult& aError) override;
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;
virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
const nsAttrValue* aValue,

View File

@ -1023,11 +1023,9 @@ void HTMLTableElement::ReleaseInheritedAttributes() {
NS_IF_RELEASE(mTableInheritedAttributes);
}
nsresult HTMLTableElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult HTMLTableElement::BindToTree(BindContext& aContext, nsINode& aParent) {
ReleaseInheritedAttributes();
nsresult rv =
nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
BuildInheritedAttributes();
return NS_OK;

View File

@ -157,8 +157,7 @@ class HTMLTableElement final : public nsGenericHTMLElement {
virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;
/**
* Called when an attribute is about to be changed

View File

@ -781,11 +781,10 @@ EventStates HTMLTextAreaElement::IntrinsicState() const {
return state;
}
nsresult HTMLTextAreaElement::BindToTree(Document* aDocument,
nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv = nsGenericHTMLFormElementWithState::BindToTree(
aDocument, aParent, aBindingParent);
nsresult HTMLTextAreaElement::BindToTree(BindContext& aContext,
nsINode& aParent) {
nsresult rv =
nsGenericHTMLFormElementWithState::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
// If there is a disabled fieldset in the parent chain, the element is now

View File

@ -106,8 +106,7 @@ class HTMLTextAreaElement final : public nsGenericHTMLFormElementWithState,
NS_IMETHOD_(bool) HasCachedSelection() override;
// nsIContent
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;
virtual bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
const nsAString& aValue,

View File

@ -63,11 +63,9 @@ void HTMLTitleElement::ContentRemoved(nsIContent* aChild,
SendTitleChangeEvent(false);
}
nsresult HTMLTitleElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult HTMLTitleElement::BindToTree(BindContext& aContext, nsINode& aParent) {
// Let this fall through.
nsresult rv =
nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
SendTitleChangeEvent(true);

View File

@ -39,8 +39,7 @@ class HTMLTitleElement final : public nsGenericHTMLElement,
virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
virtual nsresult BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) override;
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
virtual void UnbindFromTree(bool aNullParent = true) override;

View File

@ -378,14 +378,12 @@ void HTMLTrackElement::LoadResource(RefPtr<WebVTTListener>&& aWebVTTListener) {
doc->Dispatch(TaskCategory::Other, runnable.forget());
}
nsresult HTMLTrackElement::BindToTree(Document* aDocument, nsIContent* aParent,
nsIContent* aBindingParent) {
nsresult rv =
nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
nsresult HTMLTrackElement::BindToTree(BindContext& aContext, nsINode& aParent) {
nsresult rv = nsGenericHTMLElement::BindToTree(aContext, aParent);
NS_ENSURE_SUCCESS(rv, rv);
LOG("Track Element bound to tree.");
auto* parent = HTMLMediaElement::FromNodeOrNull(aParent);
auto* parent = HTMLMediaElement::FromNode(aParent);
if (!parent) {
return NS_OK;
}

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