diff --git a/accessible/generic/RootAccessible.cpp b/accessible/generic/RootAccessible.cpp index 821f83ec68a2..488f440e9f42 100644 --- a/accessible/generic/RootAccessible.cpp +++ b/accessible/generic/RootAccessible.cpp @@ -27,6 +27,7 @@ #include "mozilla/dom/CustomEvent.h" #include "mozilla/dom/Element.h" #include "mozilla/dom/ScriptSettings.h" +#include "mozilla/dom/BrowserHost.h" #include "nsIDocShellTreeItem.h" #include "nsIDocShellTreeOwner.h" @@ -669,12 +670,12 @@ ProxyAccessible* RootAccessible::GetPrimaryRemoteTopLevelContentDoc() const { mDocumentNode->GetDocShell()->GetTreeOwner(getter_AddRefs(owner)); NS_ENSURE_TRUE(owner, nullptr); - nsCOMPtr browserParent; - owner->GetPrimaryRemoteTab(getter_AddRefs(browserParent)); - if (!browserParent) { + nsCOMPtr remoteTab; + owner->GetPrimaryRemoteTab(getter_AddRefs(remoteTab)); + if (!remoteTab) { return nullptr; } - auto tab = static_cast(browserParent.get()); + auto tab = static_cast(remoteTab.get()); return tab->GetTopLevelDocAccessible(); } diff --git a/accessible/ipc/DocAccessibleParent.cpp b/accessible/ipc/DocAccessibleParent.cpp index bb7ea5df66c5..adb9175449a9 100644 --- a/accessible/ipc/DocAccessibleParent.cpp +++ b/accessible/ipc/DocAccessibleParent.cpp @@ -672,8 +672,8 @@ void DocAccessibleParent::MaybeInitWindowEmulation() { rect.MoveToX(rootRect.X() - rect.X()); rect.MoveToY(rect.Y() - rootRect.Y()); - auto tab = static_cast(Manager()); - tab->GetDocShellIsActive(&isActive); + auto browserParent = static_cast(Manager()); + isActive = browserParent->GetDocShellIsActive(); } nsWinUtils::NativeWindowCreateProc onCreate([this](HWND aHwnd) -> void { diff --git a/browser/base/content/browser-pageActions.js b/browser/base/content/browser-pageActions.js index aecec62e6297..b3c0161ea535 100644 --- a/browser/base/content/browser-pageActions.js +++ b/browser/base/content/browser-pageActions.js @@ -239,6 +239,9 @@ var BrowserPageActions = { "subviewbutton-iconic", "pageAction-panel-button" ); + if (action.isBadged) { + buttonNode.setAttribute("badged", "true"); + } buttonNode.setAttribute("actionid", action.id); buttonNode.addEventListener("command", event => { this.doCommandForAction(action, event, buttonNode); @@ -1126,7 +1129,6 @@ BrowserPageActions.addSearchEngine = { this._updateTitleAndIcon(); this.action.setWantsSubview(this.engines.length > 1, window); let button = BrowserPageActions.panelButtonNodeForActionID(this.action.id); - button.classList.add("badged-button"); button.setAttribute("image", this.engines[0].icon); button.setAttribute("uri", this.engines[0].uri); button.setAttribute("crop", "center"); @@ -1139,7 +1141,7 @@ BrowserPageActions.addSearchEngine = { } for (let engine of this.engines) { let button = document.createXULElement("toolbarbutton"); - button.classList.add("subviewbutton", "subviewbutton-iconic"); + button.classList.add("subviewbutton", "subviewbutton-iconic", "badged-button"); button.setAttribute("label", engine.title); button.setAttribute("image", engine.icon); button.setAttribute("uri", engine.uri); diff --git a/browser/base/content/browser-places.js b/browser/base/content/browser-places.js index 09933721d910..93c16a5174f1 100755 --- a/browser/base/content/browser-places.js +++ b/browser/base/content/browser-places.js @@ -1136,8 +1136,7 @@ var LibraryUI = { let animatableBox = document.getElementById("library-animatable-box"); let navBar = document.getElementById("nav-bar"); - let libraryIcon = document.getAnonymousElementByAttribute(libraryButton, "class", "toolbarbutton-icon"); - let iconBounds = window.windowUtils.getBoundsWithoutFlushing(libraryIcon); + let iconBounds = window.windowUtils.getBoundsWithoutFlushing(libraryButton.icon); let libraryBounds = window.windowUtils.getBoundsWithoutFlushing(libraryButton); animatableBox.style.setProperty("--library-button-height", libraryBounds.height + "px"); @@ -1197,8 +1196,7 @@ var LibraryUI = { } let animatableBox = document.getElementById("library-animatable-box"); - let libraryIcon = document.getAnonymousElementByAttribute(libraryButton, "class", "toolbarbutton-icon"); - let iconBounds = window.windowUtils.getBoundsWithoutFlushing(libraryIcon); + let iconBounds = window.windowUtils.getBoundsWithoutFlushing(libraryButton.icon); // Resizing the window will only have the ability to change the X offset of the // library button. diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index ab255978c00b..212f85b33c90 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -568,7 +568,7 @@ function UpdateBackForwardCommands(aWebNavigation) { /** * Click-and-Hold implementation for the Back and Forward buttons - * XXXmano: should this live in toolbarbutton.xml? + * XXXmano: should this live in toolbarbutton.js? */ function SetClickAndHoldHandlers() { // Bug 414797: Clone the back/forward buttons' context menu into both buttons. @@ -579,13 +579,13 @@ function SetClickAndHoldHandlers() { let backButton = document.getElementById("back-button"); backButton.setAttribute("type", "menu"); - backButton.appendChild(popup); + backButton.prepend(popup); gClickAndHoldListenersOnElement.add(backButton); let forwardButton = document.getElementById("forward-button"); popup = popup.cloneNode(true); forwardButton.setAttribute("type", "menu"); - forwardButton.appendChild(popup); + forwardButton.prepend(popup); gClickAndHoldListenersOnElement.add(forwardButton); } @@ -600,7 +600,7 @@ const gClickAndHoldListenersOnElement = { return; // Prevent the menupopup from opening immediately - aEvent.currentTarget.firstElementChild.hidden = true; + aEvent.currentTarget.menupopup.hidden = true; aEvent.currentTarget.addEventListener("mouseout", this); aEvent.currentTarget.addEventListener("mouseup", this); @@ -8391,8 +8391,7 @@ var PanicButtonNotifier = { popup.addEventListener("popuphidden", removeListeners); let widget = CustomizableUI.getWidget("panic-button").forWindow(window); - let anchor = widget.anchor; - anchor = document.getAnonymousElementByAttribute(anchor, "class", "toolbarbutton-icon"); + let anchor = widget.anchor.icon; popup.openPopup(anchor, popup.getAttribute("position")); } catch (ex) { Cu.reportError(ex); diff --git a/browser/base/content/browser.xul b/browser/base/content/browser.xul index f5f671444b26..54bb31b69582 100644 --- a/browser/base/content/browser.xul +++ b/browser/base/content/browser.xul @@ -745,7 +745,8 @@ removable="true"/> - @@ -1203,7 +1207,6 @@ type="menu" label="&bookmarksMenuButton2.label;" tooltip="dynamic-shortcut-tooltip" - anchor="dropmarker" ondragenter="PlacesMenuDNDHandler.onDragEnter(event);" ondragover="PlacesMenuDNDHandler.onDragOver(event);" ondragleave="PlacesMenuDNDHandler.onDragLeave(event);" diff --git a/browser/base/content/tabbrowser.xml b/browser/base/content/tabbrowser.xml index c228b16e4cf3..0ee33ad8d3a5 100644 --- a/browser/base/content/tabbrowser.xml +++ b/browser/base/content/tabbrowser.xml @@ -210,6 +210,9 @@ containersEnabled = false; } + // There are separate "new tab" buttons for when the tab strip + // is overflowed and when it is not. Attach the long click + // popup to both of them. const newTab = document.getElementById("new-tab-button"); const newTab2 = document.getAnonymousElementByAttribute(this, "anonid", "tabs-newtab-button"); @@ -219,8 +222,8 @@ gClickAndHoldListenersOnElement.remove(parent); parent.removeAttribute("type"); - if (parent.firstElementChild) { - parent.firstElementChild.remove(); + if (parent.menupopup) { + parent.menupopup.remove(); } if (containersEnabled) { @@ -240,7 +243,7 @@ showDefaultTab: Services.prefs.getIntPref("privacy.userContext.longPressBehavior") == 1, }); }); - parent.appendChild(popup); + parent.prepend(popup); // longPressBehavior == 2 means that the menu is shown after X // millisecs. Otherwise, with 1, the menu is open immediatelly. diff --git a/browser/base/content/test/tabs/browser_audioTabIcon.js b/browser/base/content/test/tabs/browser_audioTabIcon.js index fe3fbb4664f8..592dd9e05619 100644 --- a/browser/base/content/test/tabs/browser_audioTabIcon.js +++ b/browser/base/content/test/tabs/browser_audioTabIcon.js @@ -167,8 +167,7 @@ async function test_playing_icon_on_hidden_tab(tab) { ]; let tabContainer = tab.parentNode; let alltabsButton = document.getElementById("alltabs-button"); - let alltabsBadge = document.getAnonymousElementByAttribute( - alltabsButton, "class", "toolbarbutton-badge"); + let alltabsBadge = alltabsButton.badgeLabel; function assertIconShowing() { is(getComputedStyle(alltabsBadge).backgroundImage, diff --git a/browser/components/customizableui/CustomizableUI.jsm b/browser/components/customizableui/CustomizableUI.jsm index 0641ebbdc7ac..0b715aee0f74 100644 --- a/browser/components/customizableui/CustomizableUI.jsm +++ b/browser/components/customizableui/CustomizableUI.jsm @@ -4438,7 +4438,7 @@ OverflowableToolbar.prototype = { let mainView = doc.getElementById(mainViewId); let contextMenu = doc.getElementById(mainView.getAttribute("context")); gELS.addSystemEventListener(contextMenu, "command", this, true); - let anchor = doc.getAnonymousElementByAttribute(this._chevron, "class", "toolbarbutton-icon"); + let anchor = this._chevron.icon; // Ensure we update the gEditUIVisible flag when opening the popup, in // case the edit controls are in it. this._panel.addEventListener("popupshowing", () => doc.defaultView.updateEditUIVisibility(), {once: true}); diff --git a/browser/components/customizableui/PanelMultiView.jsm b/browser/components/customizableui/PanelMultiView.jsm index 04076b36dacf..dc3e155ef25e 100644 --- a/browser/components/customizableui/PanelMultiView.jsm +++ b/browser/components/customizableui/PanelMultiView.jsm @@ -1348,6 +1348,11 @@ var PanelView = class extends AssociatedToNode { continue; } + // Ignore content inside a + if (element.tagName != "toolbarbutton" && element.closest("toolbarbutton")) { + continue; + } + // Take the label for toolbarbuttons; it only exists on those elements. element = element.multilineLabel || element; diff --git a/browser/components/customizableui/content/panelUI.js b/browser/components/customizableui/content/panelUI.js index fb5653f8194a..920cd29466db 100644 --- a/browser/components/customizableui/content/panelUI.js +++ b/browser/components/customizableui/content/panelUI.js @@ -866,11 +866,7 @@ const PanelUI = { _getBadgeStatus(notification) { return notification.id; }, _getPanelAnchor(candidate) { - let iconAnchor = - document.getAnonymousElementByAttribute(candidate, "class", - "toolbarbutton-badge-stack") || - document.getAnonymousElementByAttribute(candidate, "class", - "toolbarbutton-icon"); + let iconAnchor = candidate.badgeStack || candidate.icon; return iconAnchor || candidate; }, diff --git a/browser/components/customizableui/test/head.js b/browser/components/customizableui/test/head.js index e286c7bbbf3f..95f4b7355630 100644 --- a/browser/components/customizableui/test/head.js +++ b/browser/components/customizableui/test/head.js @@ -30,7 +30,7 @@ const kNSXUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; const kForceOverflowWidthPx = 300; function createDummyXULButton(id, label, win = window) { - let btn = document.createElementNS(kNSXUL, "toolbarbutton"); + let btn = win.document.createElementNS(kNSXUL, "toolbarbutton"); btn.id = id; btn.setAttribute("label", label || id); btn.className = "toolbarbutton-1 chromeclass-toolbar-additional"; @@ -445,8 +445,7 @@ function checkContextMenu(aContextMenu, aExpectedEntries, aWindow = window) { function waitForOverflowButtonShown(win = window) { let ov = win.document.getElementById("nav-bar-overflow-button"); - let icon = win.document.getAnonymousElementByAttribute(ov, "class", "toolbarbutton-icon"); - return waitForElementShown(icon); + return waitForElementShown(ov.icon); } function waitForElementShown(element) { let win = element.ownerGlobal; diff --git a/browser/components/downloads/content/indicator.js b/browser/components/downloads/content/indicator.js index 507a5fd4ffe3..44d681ecfdb8 100644 --- a/browser/components/downloads/content/indicator.js +++ b/browser/components/downloads/content/indicator.js @@ -613,11 +613,10 @@ const DownloadsIndicatorView = { let widgetGroup = CustomizableUI.getWidget("downloads-button"); if (widgetGroup.areaType == CustomizableUI.TYPE_MENU_PANEL) { let overflowIcon = widgetGroup.forWindow(window).anchor; - return document.getAnonymousElementByAttribute(overflowIcon, "class", "toolbarbutton-icon"); + return overflowIcon.icon; } - return document.getAnonymousElementByAttribute(this.indicator, "class", - "toolbarbutton-badge-stack"); + return this.indicator.badgeStack; }, get _progressIcon() { diff --git a/browser/components/downloads/test/browser/browser_overflow_anchor.js b/browser/components/downloads/test/browser/browser_overflow_anchor.js index b6545aa72778..6905debb2ca8 100644 --- a/browser/components/downloads/test/browser/browser_overflow_anchor.js +++ b/browser/components/downloads/test/browser/browser_overflow_anchor.js @@ -34,9 +34,8 @@ add_task(async function test_overflow_anchor() { let panel = DownloadsPanel.panel; let chevron = document.getElementById("nav-bar-overflow-button"); - let chevronIcon = document.getAnonymousElementByAttribute(chevron, - "class", "toolbarbutton-icon"); - is(panel.anchorNode, chevronIcon, "Panel should be anchored to the chevron`s icon."); + + is(panel.anchorNode, chevron.icon, "Panel should be anchored to the chevron`s icon."); DownloadsPanel.hidePanel(); @@ -47,8 +46,7 @@ add_task(async function test_overflow_anchor() { EventUtils.sendMouseEvent({ type: "mousedown", button: 0 }, button.node); await promise; - let downloadsAnchor = document.getAnonymousElementByAttribute(button.node, "class", - "toolbarbutton-badge-stack"); + let downloadsAnchor = button.node.badgeStack; is(panel.anchorNode, downloadsAnchor); DownloadsPanel.hidePanel(); diff --git a/browser/components/extensions/ExtensionControlledPopup.jsm b/browser/components/extensions/ExtensionControlledPopup.jsm index a6a0333636d2..56317af5f3be 100644 --- a/browser/components/extensions/ExtensionControlledPopup.jsm +++ b/browser/components/extensions/ExtensionControlledPopup.jsm @@ -275,8 +275,7 @@ class ExtensionControlledPopup { // Anchor to a toolbar browserAction if found, otherwise use the menu button. anchorButton = action || doc.getElementById("PanelUI-menu-button"); } - let anchor = doc.getAnonymousElementByAttribute( - anchorButton, "class", "toolbarbutton-icon"); + let anchor = anchorButton.icon; panel.hidden = false; popupnotification.show(); panel.openPopup(anchor); diff --git a/browser/components/extensions/parent/ext-browserAction.js b/browser/components/extensions/parent/ext-browserAction.js index 65ae4d0f1fa3..1db40400099f 100644 --- a/browser/components/extensions/parent/ext-browserAction.js +++ b/browser/components/extensions/parent/ext-browserAction.js @@ -165,8 +165,8 @@ this.browserAction = class extends ExtensionAPI { }, onCreated: node => { - node.classList.add("badged-button"); node.classList.add("webextension-browser-action"); + node.setAttribute("badged", "true"); node.setAttribute("constrain-size", "true"); node.setAttribute("data-extensionid", this.extension.id); diff --git a/browser/components/extensions/test/browser/browser_ext_browserAction_context.js b/browser/components/extensions/test/browser/browser_ext_browserAction_context.js index 265d445d479c..d10d1958219b 100644 --- a/browser/components/extensions/test/browser/browser_ext_browserAction_context.js +++ b/browser/components/extensions/test/browser/browser_ext_browserAction_context.js @@ -129,8 +129,7 @@ async function runTests(options) { is(button.getAttribute("disabled") == "true", !details.enabled, "disabled state is correct"); if (details.badge) { - let badge = button.ownerDocument.getAnonymousElementByAttribute( - button, "class", "toolbarbutton-badge"); + let badge = button.badgeLabel; let style = window.getComputedStyle(badge); let expected = { backgroundColor: serializeColor(details.badgeBackgroundColor), @@ -426,7 +425,7 @@ add_task(async function testBadgeColorPersistence() { function getBadgeForWindow(win) { const widget = getBrowserActionWidget(extension).forWindow(win).node; - return document.getAnonymousElementByAttribute(widget, "class", "toolbarbutton-badge"); + return widget.badgeLabel; } let badge = getBadgeForWindow(window); diff --git a/browser/components/extensions/test/browser/browser_ext_browserAction_contextMenu.js b/browser/components/extensions/test/browser/browser_ext_browserAction_contextMenu.js index c8d1138c49ee..0b199ce58fc3 100644 --- a/browser/components/extensions/test/browser/browser_ext_browserAction_contextMenu.js +++ b/browser/components/extensions/test/browser/browser_ext_browserAction_contextMenu.js @@ -247,7 +247,7 @@ add_task(async function browseraction_contextmenu_manage_extension() { info("Wait until the overflow menu is ready"); let overflowButton = win.document.getElementById("nav-bar-overflow-button"); - let icon = win.document.getAnonymousElementByAttribute(overflowButton, "class", "toolbarbutton-icon"); + let icon = overflowButton.icon; await waitForElementShown(icon); if (!customizing) { @@ -326,7 +326,7 @@ async function runTestContextMenu({ info("Wait until the overflow menu is ready"); let overflowButton = win.document.getElementById("nav-bar-overflow-button"); - let icon = win.document.getAnonymousElementByAttribute(overflowButton, "class", "toolbarbutton-icon"); + let icon = overflowButton.icon; await waitForElementShown(icon); if (!customizing) { diff --git a/browser/components/places/content/browserPlacesViews.js b/browser/components/places/content/browserPlacesViews.js index 9f3c81c89924..2a1304fc242a 100644 --- a/browser/components/places/content/browserPlacesViews.js +++ b/browser/components/places/content/browserPlacesViews.js @@ -1519,7 +1519,7 @@ PlacesToolbar.prototype = { // If the menu is open, close it. if (draggedElt.open) { - draggedElt.lastElementChild.hidePopup(); + draggedElt.menupopup.hidePopup(); draggedElt.open = false; } } diff --git a/browser/components/places/tests/browser/browser_views_liveupdate.js b/browser/components/places/tests/browser/browser_views_liveupdate.js index 9ef1b1fbd185..45f2d7c07aca 100644 --- a/browser/components/places/tests/browser/browser_views_liveupdate.js +++ b/browser/components/places/tests/browser/browser_views_liveupdate.js @@ -289,7 +289,7 @@ function getNodeForToolbarItem(itemGuid, validator) { // Don't search in queries, they could contain our item in a // different position. Search only folders if (PlacesUtils.nodeIsFolder(child._placesNode)) { - var popup = child.lastElementChild; + var popup = child.menupopup; popup.openPopup(); var foundNode = findNode(popup); popup.hidePopup(); diff --git a/browser/components/search/test/browser/browser_tooManyEnginesOffered.js b/browser/components/search/test/browser/browser_tooManyEnginesOffered.js index 5553de1c6656..6fe00f3e95f2 100644 --- a/browser/components/search/test/browser/browser_tooManyEnginesOffered.js +++ b/browser/components/search/test/browser/browser_tooManyEnginesOffered.js @@ -37,7 +37,7 @@ add_task(async function test() { Assert.equal(menuButton.type, "menu", "A menu button"); // Mouse over the menu button to open it. - let buttonPopup = menuButton.firstElementChild; + let buttonPopup = menuButton.menupopup; promise = promiseEvent(buttonPopup, "popupshown"); EventUtils.synthesizeMouse(menuButton, 5, 5, { type: "mousemove" }); await promise; diff --git a/browser/components/sessionstore/SessionStore.jsm b/browser/components/sessionstore/SessionStore.jsm index 6a10e519644d..2bfbcbbb0e9f 100644 --- a/browser/components/sessionstore/SessionStore.jsm +++ b/browser/components/sessionstore/SessionStore.jsm @@ -2331,7 +2331,7 @@ var SessionStoreInternal = { // Tell our caller to redirect the load into this newly created process. let remoteTab = aBrowser.frameLoader.remoteTab; debug(`[process-switch]: new tabID: ${remoteTab.tabId}`); - return remoteTab; + return remoteTab.contentProcessId; }, /** diff --git a/browser/components/uitour/UITour.jsm b/browser/components/uitour/UITour.jsm index b0027a422f84..b23d07115408 100644 --- a/browser/components/uitour/UITour.jsm +++ b/browser/components/uitour/UITour.jsm @@ -87,9 +87,7 @@ var UITour = { // Otherwise use the sync setup icon. let statusButton = aDocument.getElementById("appMenu-fxa-label"); - return aDocument.getAnonymousElementByAttribute(statusButton, - "class", - "toolbarbutton-icon"); + return statusButton.icon; }, // This is a fake widgetName starting with the "appMenu-" prefix so we know // to automatically open the appMenu when annotating this target. diff --git a/browser/modules/PageActions.jsm b/browser/modules/PageActions.jsm index 5566e0737eb7..c9a7346fbf8d 100644 --- a/browser/modules/PageActions.jsm +++ b/browser/modules/PageActions.jsm @@ -455,6 +455,9 @@ var PageActions = { * some reason. You can also pass an object that maps pixel sizes to * URLs, like { 16: url16, 32: url32 }. The best size for the user's * screen will be used. + * @param isBadged (bool, optional) + * If true, the toolbarbutton for this action will get the + * "badged-button" class. * @param onBeforePlacedInWindow (function, optional) * Called before the action is placed in the window: * onBeforePlacedInWindow(window) @@ -537,6 +540,7 @@ function Action(options) { disabled: false, extensionID: false, iconURL: false, + isBadged: false, labelForHistogram: false, onBeforePlacedInWindow: false, onCommand: false, @@ -816,6 +820,10 @@ Action.prototype = { return this._wantsIframe || false; }, + get isBadged() { + return this._isBadged || false; + }, + get labelForHistogram() { // The histogram label value has a length limit of 20 and restricted to a // pattern. See MAX_LABEL_LENGTH and CPP_IDENTIFIER_PATTERN in @@ -1184,6 +1192,7 @@ var gBuiltInActions = [ id: "addSearchEngine", // The title is set in browser-pageActions.js. title: "", + isBadged: true, _transient: true, onShowingInPanel(buttonNode) { browserPageActions(buttonNode).addSearchEngine.onShowingInPanel(); diff --git a/devtools/client/inspector/markup/test/browser_markup_anonymous_02.js b/devtools/client/inspector/markup/test/browser_markup_anonymous_02.js index 4920557dfbe6..3259b8db8834 100644 --- a/devtools/client/inspector/markup/test/browser_markup_anonymous_02.js +++ b/devtools/client/inspector/markup/test/browser_markup_anonymous_02.js @@ -12,14 +12,14 @@ const TEST_URL = URL_ROOT + "doc_markup_anonymous_xul.xul"; add_task(async function() { const {inspector} = await openInspectorForURL(TEST_URL); - const toolbarbutton = await getNodeFront("toolbarbutton", inspector); - const children = await inspector.walker.children(toolbarbutton); + const boundNode = await getNodeFront("#xbl-host", inspector); + const children = await inspector.walker.children(boundNode); - is(toolbarbutton.numChildren, 4, "Correct number of children"); - is(children.nodes.length, 4, "Children returned from walker"); + is(boundNode.numChildren, 2, "Correct number of children"); + is(children.nodes.length, 2, "Children returned from walker"); - is(toolbarbutton.isAnonymous, false, "Toolbarbutton is not anonymous"); - await isEditingMenuEnabled(toolbarbutton, inspector); + is(boundNode.isAnonymous, false, "Node with XBL binding is not anonymous"); + await isEditingMenuEnabled(boundNode, inspector); for (const node of children.nodes) { ok(node.isAnonymous, "Child is anonymous"); diff --git a/devtools/client/inspector/markup/test/doc_markup_anonymous_xul.xul b/devtools/client/inspector/markup/test/doc_markup_anonymous_xul.xul index 09cc26101f57..dfd5602e93b7 100644 --- a/devtools/client/inspector/markup/test/doc_markup_anonymous_xul.xul +++ b/devtools/client/inspector/markup/test/doc_markup_anonymous_xul.xul @@ -3,6 +3,15 @@ - + + + + Anonymous + Anonymous + + + + diff --git a/docshell/shistory/ParentSHistory.cpp b/docshell/shistory/ParentSHistory.cpp index 7b0c21fc2956..4f152a5d00db 100644 --- a/docshell/shistory/ParentSHistory.cpp +++ b/docshell/shistory/ParentSHistory.cpp @@ -26,7 +26,7 @@ nsDocShell* ParentSHistory::GetDocShell() { } BrowserParent* ParentSHistory::GetBrowserParent() { - return static_cast(mFrameLoader->GetRemoteBrowser()); + return mFrameLoader->GetBrowserParent(); } already_AddRefed ParentSHistory::GetChildIfSameProcess() { diff --git a/dom/base/nsContentAreaDragDrop.cpp b/dom/base/nsContentAreaDragDrop.cpp index aa34e5f6666f..9deb07736d36 100644 --- a/dom/base/nsContentAreaDragDrop.cpp +++ b/dom/base/nsContentAreaDragDrop.cpp @@ -552,11 +552,11 @@ nsresult DragDataProducer::Produce(DataTransfer* aDataTransfer, bool* aCanDrag, if (flo) { RefPtr fl = flo->GetFrameLoader(); if (fl) { - BrowserParent* tp = static_cast(fl->GetRemoteBrowser()); - if (tp) { + BrowserParent* bp = fl->GetBrowserParent(); + if (bp) { // We have a BrowserParent, so it may have data for dnd in case the // child process started a dnd session. - tp->AddInitialDnDDataTo(aDataTransfer, aPrincipal); + bp->AddInitialDnDDataTo(aDataTransfer, aPrincipal); } } } diff --git a/dom/base/nsDOMAttributeMap.h b/dom/base/nsDOMAttributeMap.h index 5584bb822df2..8cb73617d12b 100644 --- a/dom/base/nsDOMAttributeMap.h +++ b/dom/base/nsDOMAttributeMap.h @@ -60,7 +60,8 @@ class nsAttrHashKey : public PLDHashEntryHdr { typedef const nsAttrKey* KeyTypePointer; explicit nsAttrHashKey(KeyTypePointer aKey) : mKey(*aKey) {} - nsAttrHashKey(const nsAttrHashKey& aCopy) : mKey(aCopy.mKey) {} + nsAttrHashKey(const nsAttrHashKey& aCopy) + : PLDHashEntryHdr{}, mKey(aCopy.mKey) {} ~nsAttrHashKey() {} KeyType GetKey() const { return mKey; } diff --git a/dom/base/nsFrameLoader.cpp b/dom/base/nsFrameLoader.cpp index db8654bcca69..62c143b3c6ee 100644 --- a/dom/base/nsFrameLoader.cpp +++ b/dom/base/nsFrameLoader.cpp @@ -109,6 +109,8 @@ #include "mozilla/dom/CanonicalBrowsingContext.h" #include "mozilla/dom/ContentChild.h" #include "mozilla/dom/BrowserBridgeChild.h" +#include "mozilla/dom/BrowserHost.h" +#include "mozilla/dom/BrowserBridgeHost.h" #include "mozilla/dom/HTMLBodyElement.h" @@ -155,7 +157,7 @@ typedef ScrollableLayerGuid::ViewID ViewID; NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(nsFrameLoader, mBrowsingContext, mMessageManager, mChildMessageManager, - mParentSHistory, mBrowserParent) + mParentSHistory, mRemoteBrowser) NS_IMPL_CYCLE_COLLECTING_ADDREF(nsFrameLoader) NS_IMPL_CYCLE_COLLECTING_RELEASE(nsFrameLoader) @@ -172,7 +174,6 @@ nsFrameLoader::nsFrameLoader(Element* aOwner, BrowsingContext* aBrowsingContext, mOwnerContent(aOwner), mDetachedSubdocFrame(nullptr), mPendingSwitchID(0), - mBrowserParent(nullptr), mChildID(0), mDepthTooGreat(false), mIsTopLevelContent(false), @@ -197,7 +198,6 @@ nsFrameLoader::nsFrameLoader(Element* aOwner, BrowsingContext* aBrowsingContext, mOwnerContent(aOwner), mDetachedSubdocFrame(nullptr), mPendingSwitchID(0), - mBrowserParent(nullptr), mChildID(0), mDepthTooGreat(false), mIsTopLevelContent(false), @@ -543,28 +543,16 @@ nsresult nsFrameLoader::ReallyStartLoadingInternal() { AUTO_PROFILER_LABEL("nsFrameLoader::ReallyStartLoadingInternal", OTHER); if (IsRemoteFrame()) { - if (!mBrowserParent && !mBrowserBridgeChild && !TryRemoteBrowser()) { + if (!EnsureRemoteBrowser()) { NS_WARNING("Couldn't create child process for iframe."); return NS_ERROR_FAILURE; } if (mPendingSwitchID) { - if (mBrowserBridgeChild) { - Unused << mBrowserBridgeChild->SendResumeLoad(mPendingSwitchID); - } else { - mBrowserParent->ResumeLoad(mPendingSwitchID); - } - + mRemoteBrowser->ResumeLoad(mPendingSwitchID); mPendingSwitchID = 0; } else { - if (mBrowserBridgeChild) { - nsAutoCString spec; - mURIToLoad->GetSpec(spec); - Unused << mBrowserBridgeChild->SendLoadURL(spec); - } else { - // FIXME get error codes from child - mBrowserParent->LoadURL(mURIToLoad); - } + mRemoteBrowser->LoadURL(mURIToLoad); } if (!mRemoteBrowserShown) { @@ -1029,7 +1017,7 @@ bool nsFrameLoader::ShowRemoteFrame(const ScreenIntSize& size, NS_ASSERTION(IsRemoteFrame(), "ShowRemote only makes sense on remote frames."); - if (!mBrowserParent && !mBrowserBridgeChild && !TryRemoteBrowser()) { + if (!EnsureRemoteBrowser()) { NS_ERROR("Couldn't create child process."); return false; } @@ -1048,7 +1036,8 @@ bool nsFrameLoader::ShowRemoteFrame(const ScreenIntSize& size, return false; } - if (mBrowserBridgeChild) { + if (RefPtr browserBridgeChild = + GetBrowserBridgeChild()) { nsCOMPtr container = mOwnerContent->OwnerDoc()->GetContainer(); nsCOMPtr baseWindow = do_QueryInterface(container); @@ -1057,21 +1046,16 @@ bool nsFrameLoader::ShowRemoteFrame(const ScreenIntSize& size, nsSizeMode sizeMode = mainWidget ? mainWidget->SizeMode() : nsSizeMode_Normal; - Unused << mBrowserBridgeChild->SendShow( + Unused << browserBridgeChild->SendShow( size, ParentWindowIsActive(mOwnerContent->OwnerDoc()), sizeMode); mRemoteBrowserShown = true; return true; } - RenderFrame* rf = - mBrowserParent ? mBrowserParent->GetRenderFrame() : nullptr; - - if (!rf || !rf->AttachLayerManager()) { - // This is just not going to work. + if (!mRemoteBrowser->Show( + size, ParentWindowIsActive(mOwnerContent->OwnerDoc()))) { return false; } - - mBrowserParent->Show(size, ParentWindowIsActive(mOwnerContent->OwnerDoc())); mRemoteBrowserShown = true; nsCOMPtr os = services::GetObserverService(); @@ -1084,11 +1068,7 @@ bool nsFrameLoader::ShowRemoteFrame(const ScreenIntSize& size, // Don't show remote iframe if we are waiting for the completion of reflow. if (!aFrame || !(aFrame->GetStateBits() & NS_FRAME_FIRST_REFLOW)) { - if (mBrowserParent) { - mBrowserParent->UpdateDimensions(dimensions, size); - } else if (mBrowserBridgeChild) { - mBrowserBridgeChild->UpdateDimensions(dimensions, size); - } + mRemoteBrowser->UpdateDimensions(dimensions, size); } } @@ -1181,17 +1161,15 @@ nsresult nsFrameLoader::SwapWithOtherRemoteLoader( return NS_ERROR_NOT_IMPLEMENTED; } - // FIXME: Consider supporting FrameLoader swapping for remote sub frames. - if (mBrowserBridgeChild) { + auto* browserParent = GetBrowserParent(); + auto* otherBrowserParent = aOther->GetBrowserParent(); + + if (!browserParent || !otherBrowserParent) { return NS_ERROR_NOT_IMPLEMENTED; } - if (!mBrowserParent || !aOther->mBrowserParent) { - return NS_ERROR_NOT_IMPLEMENTED; - } - - if (mBrowserParent->IsIsolatedMozBrowserElement() != - aOther->mBrowserParent->IsIsolatedMozBrowserElement()) { + if (browserParent->IsIsolatedMozBrowserElement() != + otherBrowserParent->IsIsolatedMozBrowserElement()) { return NS_ERROR_NOT_IMPLEMENTED; } @@ -1203,12 +1181,12 @@ nsresult nsFrameLoader::SwapWithOtherRemoteLoader( // This is the reason why now we must retrieve the correct value from the // usercontextid attribute before comparing our originAttributes with the // other one. - OriginAttributes ourOriginAttributes = mBrowserParent->OriginAttributesRef(); + OriginAttributes ourOriginAttributes = browserParent->OriginAttributesRef(); rv = PopulateUserContextIdFromAttribute(ourOriginAttributes); NS_ENSURE_SUCCESS(rv, rv); OriginAttributes otherOriginAttributes = - aOther->mBrowserParent->OriginAttributesRef(); + otherBrowserParent->OriginAttributesRef(); rv = aOther->PopulateUserContextIdFromAttribute(otherOriginAttributes); NS_ENSURE_SUCCESS(rv, rv); @@ -1252,9 +1230,9 @@ nsresult nsFrameLoader::SwapWithOtherRemoteLoader( } nsCOMPtr otherBrowserDOMWindow = - aOther->mBrowserParent->GetBrowserDOMWindow(); + otherBrowserParent->GetBrowserDOMWindow(); nsCOMPtr browserDOMWindow = - mBrowserParent->GetBrowserDOMWindow(); + browserParent->GetBrowserDOMWindow(); if (!!otherBrowserDOMWindow != !!browserDOMWindow) { return NS_ERROR_NOT_IMPLEMENTED; @@ -1268,8 +1246,8 @@ nsresult nsFrameLoader::SwapWithOtherRemoteLoader( aOther->DestroyBrowserFrameScripts(); } - aOther->mBrowserParent->SetBrowserDOMWindow(browserDOMWindow); - mBrowserParent->SetBrowserDOMWindow(otherBrowserDOMWindow); + otherBrowserParent->SetBrowserDOMWindow(browserDOMWindow); + browserParent->SetBrowserDOMWindow(otherBrowserDOMWindow); #ifdef XP_WIN // Native plugin windows used by this remote content need to be reparented. @@ -1277,7 +1255,7 @@ nsresult nsFrameLoader::SwapWithOtherRemoteLoader( RefPtr newParent = nsGlobalWindowOuter::Cast(newWin)->GetMainWidget(); const ManagedContainer& plugins = - aOther->mBrowserParent->ManagedPPluginWidgetParent(); + otherBrowserParent->ManagedPPluginWidgetParent(); for (auto iter = plugins.ConstIter(); !iter.Done(); iter.Next()) { static_cast(iter.Get()->GetKey()) ->SetParent(newParent); @@ -1291,13 +1269,13 @@ nsresult nsFrameLoader::SwapWithOtherRemoteLoader( SetOwnerContent(otherContent); aOther->SetOwnerContent(ourContent); - mBrowserParent->SetOwnerElement(otherContent); - aOther->mBrowserParent->SetOwnerElement(ourContent); + browserParent->SetOwnerElement(otherContent); + otherBrowserParent->SetOwnerElement(ourContent); // Update window activation state for the swapped owner content. - Unused << mBrowserParent->SendParentActivated( + Unused << browserParent->SendParentActivated( ParentWindowIsActive(otherContent->OwnerDoc())); - Unused << aOther->mBrowserParent->SendParentActivated( + Unused << otherBrowserParent->SendParentActivated( ParentWindowIsActive(ourContent->OwnerDoc())); MaybeUpdatePrimaryBrowserParent(eBrowserParentChanged); @@ -1344,9 +1322,9 @@ nsresult nsFrameLoader::SwapWithOtherRemoteLoader( return rv; } - Unused << mBrowserParent->SendSwappedWithOtherRemoteLoader( + Unused << browserParent->SendSwappedWithOtherRemoteLoader( ourContext.AsIPCTabContext()); - Unused << aOther->mBrowserParent->SendSwappedWithOtherRemoteLoader( + Unused << otherBrowserParent->SendSwappedWithOtherRemoteLoader( otherContext.AsIPCTabContext()); return NS_OK; } @@ -1800,10 +1778,10 @@ void nsFrameLoader::StartDestroy() { // Retain references to the element and the frameloader in case we // receive any messages from the message manager on the frame. These // references are dropped in DestroyComplete. - if (mChildMessageManager || mBrowserParent) { + if (mChildMessageManager || mRemoteBrowser) { mOwnerContentStrong = mOwnerContent; - if (mBrowserParent) { - mBrowserParent->CacheFrameLoader(this); + if (auto* browserParent = GetBrowserParent()) { + browserParent->CacheFrameLoader(this); } if (mChildMessageManager) { mChildMessageManager->CacheFrameLoader(this); @@ -1812,8 +1790,8 @@ void nsFrameLoader::StartDestroy() { // If the BrowserParent has installed any event listeners on the window, this // is its last chance to remove them while we're still in the document. - if (mBrowserParent) { - mBrowserParent->RemoveWindowListeners(); + if (auto* browserParent = GetBrowserParent()) { + browserParent->RemoveWindowListeners(); } nsCOMPtr doc; @@ -1912,13 +1890,8 @@ void nsFrameLoader::DestroyDocShell() { // Ask the BrowserChild to fire the frame script "unload" event, destroy its // docshell, and finally destroy the PBrowser actor. This eventually leads to // nsFrameLoader::DestroyComplete being called. - if (mBrowserParent) { - mBrowserParent->Destroy(); - } - - if (mBrowserBridgeChild) { - Unused << mBrowserBridgeChild->Send__delete__(mBrowserBridgeChild); - mBrowserBridgeChild = nullptr; + if (mRemoteBrowser) { + mRemoteBrowser->DestroyStart(); } // Fire the "unload" event if we're in-process. @@ -1951,10 +1924,10 @@ void nsFrameLoader::DestroyComplete() { // case, StartDestroy might not have been called. // Drop the strong references created in StartDestroy. - if (mChildMessageManager || mBrowserParent) { + if (mChildMessageManager || mRemoteBrowser) { mOwnerContentStrong = nullptr; - if (mBrowserParent) { - mBrowserParent->CacheFrameLoader(nullptr); + if (auto* browserParent = GetBrowserParent()) { + browserParent->CacheFrameLoader(nullptr); } if (mChildMessageManager) { mChildMessageManager->CacheFrameLoader(nullptr); @@ -1962,15 +1935,9 @@ void nsFrameLoader::DestroyComplete() { } // Call BrowserParent::Destroy if we haven't already (in case of a crash). - if (mBrowserParent) { - mBrowserParent->SetOwnerElement(nullptr); - mBrowserParent->Destroy(); - mBrowserParent = nullptr; - } - - if (mBrowserBridgeChild) { - Unused << mBrowserBridgeChild->Send__delete__(mBrowserBridgeChild); - mBrowserBridgeChild = nullptr; + if (mRemoteBrowser) { + mRemoteBrowser->DestroyComplete(); + mRemoteBrowser = nullptr; } if (mMessageManager) { @@ -2494,7 +2461,7 @@ nsresult nsFrameLoader::GetWindowDimensions(nsIntRect& aRect) { nsresult nsFrameLoader::UpdatePositionAndSize(nsSubDocumentFrame* aIFrame) { if (IsRemoteFrame()) { - if (mBrowserParent || mBrowserBridgeChild) { + if (mRemoteBrowser) { ScreenIntSize size = aIFrame->GetSubdocumentSize(); // If we were not able to show remote frame before, we should probably // retry now to send correct showInfo. @@ -2504,11 +2471,7 @@ nsresult nsFrameLoader::UpdatePositionAndSize(nsSubDocumentFrame* aIFrame) { nsIntRect dimensions; NS_ENSURE_SUCCESS(GetWindowDimensions(dimensions), NS_ERROR_FAILURE); mLazySize = size; - if (mBrowserParent) { - mBrowserParent->UpdateDimensions(dimensions, size); - } else if (mBrowserBridgeChild) { - mBrowserBridgeChild->UpdateDimensions(dimensions, size); - } + mRemoteBrowser->UpdateDimensions(dimensions, size); } return NS_OK; } @@ -2520,8 +2483,8 @@ void nsFrameLoader::SendIsUnderHiddenEmbedderElement( bool aIsUnderHiddenEmbedderElement) { MOZ_ASSERT(IsRemoteFrame()); - if (mBrowserBridgeChild) { - mBrowserBridgeChild->SetIsUnderHiddenEmbedderElement( + if (auto* browserBridgeChild = GetBrowserBridgeChild()) { + browserBridgeChild->SetIsUnderHiddenEmbedderElement( aIsUnderHiddenEmbedderElement); } } @@ -2597,8 +2560,13 @@ static Tuple GetContentParent( return ReturnTuple(nullptr, nullptr); } +bool nsFrameLoader::EnsureRemoteBrowser() { + MOZ_ASSERT(IsRemoteFrame()); + return mRemoteBrowser || TryRemoteBrowser(); +} + bool nsFrameLoader::TryRemoteBrowser() { - NS_ASSERTION(!mBrowserParent && !mBrowserBridgeChild, + NS_ASSERTION(!mRemoteBrowser, "TryRemoteBrowser called with a remote browser already?"); if (!mOwnerContent) { @@ -2631,13 +2599,10 @@ bool nsFrameLoader::TryRemoteBrowser() { return false; } - BrowserParent* openingTab = - BrowserParent::GetFrom(parentDocShell->GetOpener()); RefPtr openerContentParent; RefPtr sameTabGroupAs; - - if (openingTab && openingTab->Manager()) { - openerContentParent = openingTab->Manager(); + if (auto* host = BrowserHost::GetFrom(parentDocShell->GetOpener())) { + openerContentParent = host->GetActor()->Manager(); } //