Merge inbound to mozilla-central r=merge a=merge

This commit is contained in:
Tiberius Oros 2017-11-24 00:28:29 +02:00
Родитель 0e0cbd0bc9 af62b14db3
Коммит da0a72a9d7
329 изменённых файлов: 16502 добавлений и 10818 удалений

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

@ -98,6 +98,18 @@ jobs:
mozilla-central: [{hour: 10, minute: 0}]
# No default
- name: searchfox-index
job:
type: decision-task
treeherder-symbol: Searchfox
target-tasks-method: searchfox_index
run-on-projects:
- mozilla-central
when:
by-project:
mozilla-central: [{hour: 10, minute: 30}]
# No default
- name: periodic-update
job:
type: decision-task

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

@ -20,7 +20,7 @@ var BrowserPageActions = {
},
/**
* The photonmultiview node in the main page action panel (DOM node)
* The panelmultiview node in the main page action panel (DOM node)
*/
get multiViewNode() {
delete this.multiViewNode;
@ -234,7 +234,7 @@ var BrowserPageActions = {
let iframeNode = null;
if (action.subview) {
let multiViewNode = document.createElement("photonpanelmultiview");
let multiViewNode = document.createElement("panelmultiview");
panelViewNode = this._makePanelViewNodeForAction(action, true);
multiViewNode.appendChild(panelViewNode);
panelNode.appendChild(multiViewNode);

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

@ -71,32 +71,17 @@ panelmultiview {
-moz-binding: url("chrome://browser/content/customizableui/panelUI.xml#panelmultiview");
}
photonpanelmultiview {
-moz-binding: url("chrome://browser/content/customizableui/panelUI.xml#photonpanelmultiview");
}
panelview {
-moz-binding: url("chrome://browser/content/customizableui/panelUI.xml#panelview");
-moz-box-orient: vertical;
}
panel[hidden] panelmultiview,
panel[hidden] photonpanelmultiview,
panel[hidden] panelview {
-moz-binding: none;
}
.panel-mainview {
transition: transform var(--panelui-subview-transition-duration);
}
panelview:not([mainview]):not([current]):not([in-transition]) {
transition: visibility 0s linear var(--panelui-subview-transition-duration);
visibility: collapse;
}
photonpanelmultiview panelview:not([current]):not([in-transition]) {
transition: none;
panelview:not([current]):not([in-transition]) {
visibility: collapse;
}
@ -1070,12 +1055,6 @@ notification[value="translation"] {
-moz-binding: url("chrome://browser/content/translation-infobar.xml#translationbar");
}
/** See bug 872317 for why the following rule is necessary. */
#downloads-button {
-moz-binding: url("chrome://browser/content/downloads/download.xml#download-toolbarbutton");
}
/*** Visibility of downloads indicator controls ***/
/* Bug 924050: If we've loaded the indicator, for now we hide it in the menu panel,

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

@ -417,15 +417,15 @@
emailLink-title="&emailPageCmd.label;"
sendToDevice-title="&pageAction.sendTabToDevice.label;"
sendToDevice-notReadyTitle="&sendToDevice.syncNotReady.label;">
<photonpanelmultiview id="pageActionPanelMultiView"
mainViewId="pageActionPanelMainView"
viewCacheId="appMenu-viewCache">
<panelmultiview id="pageActionPanelMultiView"
mainViewId="pageActionPanelMainView"
viewCacheId="appMenu-viewCache">
<panelview id="pageActionPanelMainView"
context="pageActionContextMenu"
class="PanelUI-subView">
<vbox class="panel-subview-body"/>
</panelview>
</photonpanelmultiview>
</panelmultiview>
</panel>
<panel id="pageActionFeedback"
role="alert"

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

@ -16,8 +16,8 @@
<broadcaster id="identity-popup-insecure-login-forms-learn-more" class="text-link plain" value="&identity.learnMore;"/>
</broadcasterset>
<photonpanelmultiview id="identity-popup-multiView"
mainViewId="identity-popup-mainView">
<panelmultiview id="identity-popup-multiView"
mainViewId="identity-popup-mainView">
<panelview id="identity-popup-mainView"
descriptionheightworkaround="true">
<!-- Security Section -->
@ -184,5 +184,5 @@
</vbox>
</panelview>
</photonpanelmultiview>
</panelmultiview>
</panel>

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

@ -1620,7 +1620,7 @@ var CustomizableUIInternal = {
if (areaType != CustomizableUI.TYPE_MENU_PANEL) {
let wrapper = this.wrapWidget(aWidget.id).forWindow(ownerWindow);
let hasMultiView = !!aNode.closest("photonpanelmultiview,panelmultiview");
let hasMultiView = !!aNode.closest("panelmultiview");
if (wrapper && !hasMultiView && wrapper.anchor) {
this.hidePanelForNode(aNode);
anchor = wrapper.anchor;
@ -1804,13 +1804,9 @@ var CustomizableUIInternal = {
if (closemenu == "single") {
let panel = this._getPanelForNode(target);
let multiview = panel.querySelector("photonpanelmultiview,panelmultiview");
let multiview = panel.querySelector("panelmultiview");
if (multiview.showingSubView) {
if (multiview.instance.panelViews) {
multiview.goBack();
} else {
multiview.showMainView();
}
multiview.goBack();
return;
}
}
@ -4303,15 +4299,10 @@ OverflowableToolbar.prototype = {
return new Promise(resolve => {
let doc = this._panel.ownerDocument;
this._panel.hidden = false;
let photonView = this._panel.querySelector("photonpanelmultiview");
let contextMenu;
if (photonView) {
let mainViewId = photonView.getAttribute("mainViewId");
let mainView = doc.getElementById(mainViewId);
contextMenu = doc.getElementById(mainView.getAttribute("context"));
} else {
contextMenu = doc.getElementById(this._panel.getAttribute("context"));
}
let multiview = this._panel.querySelector("panelmultiview");
let mainViewId = multiview.getAttribute("mainViewId");
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");
// Ensure we update the gEditUIVisible flag when opening the popup, in

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

@ -166,7 +166,7 @@ this.PanelMultiView = class {
}
get showingSubView() {
return this.node.getAttribute("viewtype") == "subview";
return this._showingSubView;
}
get _mainViewId() {
return this.node.getAttribute("mainViewId");
@ -201,11 +201,6 @@ this.PanelMultiView = class {
}
get panelViews() {
// If there's a dedicated subViews container, we're not in the right binding
// to use SlidingPanelViews.
if (this._subViews)
return null;
if (this._panelViews)
return this._panelViews;
@ -234,14 +229,10 @@ this.PanelMultiView = class {
return this._viewShowing || this._currentSubView;
}
get _currentSubView() {
return this.panelViews ? this.panelViews.currentView : this.__currentSubView;
return this.panelViews.currentView;
}
set _currentSubView(panel) {
if (this.panelViews)
this.panelViews.currentView = panel;
else
this.__currentSubView = panel;
return panel;
this.panelViews.currentView = panel;
}
/**
* @return {Promise} showSubView() returns a promise, which is kept here for
@ -268,20 +259,14 @@ this.PanelMultiView = class {
if (testMode)
return;
this._currentSubView = this._anchorElement = this._subViewObserver = null;
this._currentSubView = this._subViewObserver = null;
this._mainViewHeight = 0;
this.__transitioning = this._ignoreMutations = false;
this.__transitioning = this._ignoreMutations = this._showingSubView = false;
const {document, window} = this;
this._clickCapturer =
document.getAnonymousElementByAttribute(this.node, "anonid", "clickCapturer");
this._viewContainer =
document.getAnonymousElementByAttribute(this.node, "anonid", "viewContainer");
this._mainViewContainer =
document.getAnonymousElementByAttribute(this.node, "anonid", "mainViewContainer");
this._subViews =
document.getAnonymousElementByAttribute(this.node, "anonid", "subViews");
this._viewStack =
document.getAnonymousElementByAttribute(this.node, "anonid", "viewStack");
this._offscreenViewStack =
@ -296,24 +281,14 @@ this.PanelMultiView = class {
this._panel.addEventListener("popuppositioned", this);
this._panel.addEventListener("popuphidden", this);
this._panel.addEventListener("popupshown", this);
if (this.panelViews) {
let cs = window.getComputedStyle(document.documentElement);
// Set CSS-determined attributes now to prevent a layout flush when we do
// it when transitioning between panels.
this._dir = cs.direction;
this.setMainView(this.panelViews.currentView);
this.showMainView();
} else {
this._clickCapturer.addEventListener("click", this);
let cs = window.getComputedStyle(document.documentElement);
// Set CSS-determined attributes now to prevent a layout flush when we do
// it when transitioning between panels.
this._dir = cs.direction;
this.setMainView(this.panelViews.currentView);
this.showMainView();
this._mainViewContainer.setAttribute("panelid", this._panel.id);
if (this._mainView) {
this.setMainView(this._mainView);
}
}
this.node.setAttribute("viewtype", "main");
this._showingSubView = false;
// Proxy these public properties and methods, as used elsewhere by various
// parts of the browser, to this instance.
@ -354,24 +329,17 @@ this.PanelMultiView = class {
this._panelViewCache.appendChild(mainView);
mainView.removeAttribute("mainview");
}
if (this._subViews)
this._moveOutKids(this._subViews);
if (this.panelViews) {
this._moveOutKids(this._viewStack);
this.panelViews.clear();
} else {
this._clickCapturer.removeEventListener("click", this);
}
this._moveOutKids(this._viewStack);
this.panelViews.clear();
this._panel.removeEventListener("mousemove", this);
this._panel.removeEventListener("popupshowing", this);
this._panel.removeEventListener("popuppositioned", this);
this._panel.removeEventListener("popupshown", this);
this._panel.removeEventListener("popuphidden", this);
this.window.removeEventListener("keydown", this);
this.node = this._clickCapturer = this._viewContainer = this._mainViewContainer =
this._subViews = this._viewStack = this.__dwu = this._panelViewCache =
this._transitionDetails = null;
this.node = this._viewContainer = this._viewStack = this.__dwu =
this._panelViewCache = this._transitionDetails = null;
}
/**
@ -395,13 +363,9 @@ this.PanelMultiView = class {
}
_placeSubView(viewNode) {
if (this.panelViews) {
this._viewStack.appendChild(viewNode);
if (!this.panelViews.includes(viewNode))
this.panelViews.push(viewNode);
} else {
this._subViews.appendChild(viewNode);
}
this._viewStack.appendChild(viewNode);
if (!this.panelViews.includes(viewNode))
this.panelViews.push(viewNode);
}
goBack(target) {
@ -425,20 +389,15 @@ this.PanelMultiView = class {
return;
if (this._mainView) {
if (!this.panelViews)
this._subViews.appendChild(this._mainView);
this._mainView.removeAttribute("mainview");
}
this._mainViewId = aNewMainView.id;
aNewMainView.setAttribute("mainview", "true");
if (this.panelViews) {
// If the new main view is not yet in the zeroth position, make sure it's
// inserted there.
if (aNewMainView.parentNode != this._viewStack && this._viewStack.firstChild != aNewMainView) {
this._viewStack.insertBefore(aNewMainView, this._viewStack.firstChild);
}
} else {
this._mainViewContainer.appendChild(aNewMainView);
// If the new main view is not yet in the zeroth position, make sure it's
// inserted there.
if (aNewMainView.parentNode != this._viewStack &&
this._viewStack.firstChild != aNewMainView) {
this._viewStack.insertBefore(aNewMainView, this._viewStack.firstChild);
}
}
@ -446,21 +405,7 @@ this.PanelMultiView = class {
if (!this._mainViewId)
return Promise.resolve();
if (this.panelViews)
return this.showSubView(this._mainView);
if (this.showingSubView) {
let viewNode = this._currentSubView;
this._dispatchViewEvent(viewNode, "ViewHiding");
this._transitionHeight(() => {
viewNode.removeAttribute("current");
this._currentSubView = null;
this.node.setAttribute("viewtype", "main");
});
}
this._shiftMainView();
return Promise.resolve();
return this.showSubView(this._mainView);
}
/**
@ -491,7 +436,7 @@ this.PanelMultiView = class {
this.descriptionHeightWorkaround(theOne);
this._dispatchViewEvent(theOne, "ViewShown");
}
this.node.setAttribute("viewtype", (theOne.id == this._mainViewId) ? "main" : "subview");
this._showingSubView = theOne.id != this._mainViewId;
}
showSubView(aViewId, aAnchor, aPreviousView) {
@ -517,26 +462,21 @@ this.PanelMultiView = class {
let playTransition = (!!previousViewNode && !showingSameView && this._panel.state == "open");
let isMainView = viewNode.id == this._mainViewId;
let dwu, previousRect;
if (playTransition || this.panelViews) {
dwu = this._dwu;
previousRect = previousViewNode.__lastKnownBoundingRect =
let dwu = this._dwu;
let previousRect = previousViewNode.__lastKnownBoundingRect =
dwu.getBoundsWithoutFlushing(previousViewNode);
if (this.panelViews) {
// Cache the measures that have the same caching lifetime as the width
// or height of the main view, i.e. whilst the panel is shown and/ or
// visible.
if (!this._mainViewWidth) {
this._mainViewWidth = previousRect.width;
let top = dwu.getBoundsWithoutFlushing(previousViewNode.firstChild || previousViewNode).top;
let bottom = dwu.getBoundsWithoutFlushing(previousViewNode.lastChild || previousViewNode).bottom;
this._viewVerticalPadding = previousRect.height - (bottom - top);
}
if (!this._mainViewHeight) {
this._mainViewHeight = previousRect.height;
this._viewContainer.style.minHeight = this._mainViewHeight + "px";
}
}
// Cache the measures that have the same caching lifetime as the width
// or height of the main view, i.e. whilst the panel is shown and/ or
// visible.
if (!this._mainViewWidth) {
this._mainViewWidth = previousRect.width;
let top = dwu.getBoundsWithoutFlushing(previousViewNode.firstChild || previousViewNode).top;
let bottom = dwu.getBoundsWithoutFlushing(previousViewNode.lastChild || previousViewNode).bottom;
this._viewVerticalPadding = previousRect.height - (bottom - top);
}
if (!this._mainViewHeight) {
this._mainViewHeight = previousRect.height;
this._viewContainer.style.minHeight = this._mainViewHeight + "px";
}
this._viewShowing = viewNode;
@ -549,12 +489,12 @@ this.PanelMultiView = class {
viewNode.removeAttribute("mainview");
// Make sure that new panels always have a title set.
if (this.panelViews && aAnchor) {
if (aAnchor) {
if (!viewNode.hasAttribute("title"))
viewNode.setAttribute("title", aAnchor.getAttribute("label"));
viewNode.classList.add("PanelUI-subView");
}
if (this.panelViews && !isMainView && this._mainViewWidth)
if (!isMainView && this._mainViewWidth)
viewNode.style.maxWidth = viewNode.style.minWidth = this._mainViewWidth + "px";
if (!showingSameView || !viewNode.hasAttribute("current")) {
@ -584,31 +524,14 @@ this.PanelMultiView = class {
}
}
// Now we have to transition the panel.
if (this.panelViews) {
// If we've got an older transition still running, make sure to clean it up.
await this._cleanupTransitionPhase();
if (playTransition) {
await this._transitionViews(previousViewNode, viewNode, reverse, previousRect, aAnchor);
this._updateKeyboardFocus(viewNode);
} else {
this.hideAllViewsExcept(viewNode);
}
// Now we have to transition the panel. If we've got an older transition
// still running, make sure to clean it up.
await this._cleanupTransitionPhase();
if (playTransition) {
await this._transitionViews(previousViewNode, viewNode, reverse, previousRect, aAnchor);
this._updateKeyboardFocus(viewNode);
} else {
this._currentSubView = viewNode;
this._transitionHeight(() => {
viewNode.setAttribute("current", true);
if (viewNode.id == this._mainViewId) {
this.node.setAttribute("viewtype", "main");
} else {
this.node.setAttribute("viewtype", "subview");
}
// Now that the subview is visible, we can check the height of the
// description elements it contains.
this.descriptionHeightWorkaround(viewNode);
this._dispatchViewEvent(viewNode, "ViewShown");
});
this._shiftMainView(aAnchor);
this.hideAllViewsExcept(viewNode);
}
})().catch(e => Cu.reportError(e));
return this._currentShowPromise;
@ -901,123 +824,12 @@ this.PanelMultiView = class {
return maxHeight;
}
/**
* Applies the height transition for which <panelmultiview> is designed.
*
* The height transition involves two elements, the viewContainer and its only
* immediate child the viewStack. In order for this to work correctly, the
* viewContainer must have "overflow: hidden;" and the two elements must have
* no margins or padding. This means that the height of the viewStack is never
* limited by the viewContainer, but when the height of the container is not
* constrained it matches the height of the viewStack.
*
* @param changeFn
* This synchronous function is called to make the DOM changes
* that will result in a new height of the viewStack.
*/
_transitionHeight(changeFn) {
if (this._panel.state != "open") {
changeFn();
return;
}
// Lock the dimensions of the window that hosts the popup panel. This
// in turn constrains the height of the viewContainer.
let rect = this._panel.popupBoxObject.getOuterScreenRect();
this._panel.setAttribute("width", rect.width);
this._panel.setAttribute("height", rect.height);
// Read the current height of the viewStack. If we are in the middle
// of a transition, this is the actual height of the element at this
// point in time.
let oldHeight = this._dwu.getBoundsWithoutFlushing(this._viewStack).height;
// Make the necessary DOM changes, and remove the "height" property of the
// viewStack to ensure that we read its final value even if we are in the
// middle of a transition. To avoid flickering, we have to prevent the panel
// from being painted in this temporary state, which requires a synchronous
// layout when reading the new height.
this._viewStack.style.removeProperty("height");
changeFn();
let newHeight = this._viewStack.getBoundingClientRect().height;
// Now we can allow the popup panel to resize again. This must occur
// in the same tick as the code below, but we can do this before
// setting the starting height in case the transition is not needed.
this._panel.removeAttribute("width");
this._panel.removeAttribute("height");
if (oldHeight != newHeight) {
// Height transitions can only occur between two numeric values, and
// cannot start if the height is not set. In case a transition is
// needed, we have to set the height to the old value, then force a
// synchronous layout so the panel won't resize unexpectedly.
this._viewStack.style.height = oldHeight + "px";
this._viewStack.getBoundingClientRect().height;
// We can now set the new height to start the transition, but
// before doing that we set up a listener to reset the height to
// "auto" at the end, so that DOM changes made after the
// transition ends are still reflected by the height of the panel.
let onTransitionEnd = event => {
if (event.target != this._viewStack) {
return;
}
this._viewStack.removeEventListener("transitionend", onTransitionEnd);
this._viewStack.style.removeProperty("height");
};
this._viewStack.addEventListener("transitionend", onTransitionEnd);
this._viewStack.style.height = newHeight + "px";
}
}
_shiftMainView(aAnchor) {
if (aAnchor) {
// We need to find the edge of the anchor, relative to the main panel.
// Then we need to add half the width of the anchor. This is the target
// that we need to transition to.
let anchorRect = aAnchor.getBoundingClientRect();
let mainViewRect = this._mainViewContainer.getBoundingClientRect();
let center = aAnchor.clientWidth / 2;
let direction = aAnchor.ownerGlobal.getComputedStyle(aAnchor).direction;
let edge;
if (direction == "ltr") {
edge = anchorRect.left - mainViewRect.left;
} else {
edge = mainViewRect.right - anchorRect.right;
}
// If the anchor is an element on the far end of the mainView we
// don't want to shift the mainView too far, we would reveal empty
// space otherwise.
let cstyle = this.window.getComputedStyle(this.document.documentElement);
let exitSubViewGutterWidth =
cstyle.getPropertyValue("--panel-ui-exit-subview-gutter-width");
let maxShift = mainViewRect.width - parseInt(exitSubViewGutterWidth);
let target = Math.min(maxShift, edge + center);
let neg = direction == "ltr" ? "-" : "";
this._mainViewContainer.style.transform = `translateX(${neg}${target}px)`;
aAnchor.setAttribute("panel-multiview-anchor", true);
} else {
this._mainViewContainer.style.transform = "";
if (this.anchorElement)
this.anchorElement.removeAttribute("panel-multiview-anchor");
}
this.anchorElement = aAnchor;
}
handleEvent(aEvent) {
if (aEvent.type.startsWith("popup") && aEvent.target != this._panel) {
// Shouldn't act on e.g. context menus being shown from within the panel.
return;
}
switch (aEvent.type) {
case "click":
if (aEvent.originalTarget == this._clickCapturer) {
this.showMainView();
}
break;
case "keydown":
this._keyNavigation(aEvent);
break;
@ -1060,27 +872,25 @@ this.PanelMultiView = class {
this._transitioning = false;
this.node.removeAttribute("panelopen");
this.showMainView();
if (this.panelViews) {
for (let panelView of this._viewStack.children) {
if (panelView.nodeName != "children") {
panelView.__lastKnownBoundingRect = null;
panelView.style.removeProperty("min-width");
panelView.style.removeProperty("max-width");
}
for (let panelView of this._viewStack.children) {
if (panelView.nodeName != "children") {
panelView.__lastKnownBoundingRect = null;
panelView.style.removeProperty("min-width");
panelView.style.removeProperty("max-width");
}
this.window.removeEventListener("keydown", this);
this._panel.removeEventListener("mousemove", this);
this._resetKeyNavigation();
// Clear the main view size caches. The dimensions could be different
// when the popup is opened again, e.g. through touch mode sizing.
this._mainViewHeight = 0;
this._mainViewWidth = 0;
this._viewContainer.style.removeProperty("min-height");
this._viewStack.style.removeProperty("max-height");
this._viewContainer.style.removeProperty("min-width");
this._viewContainer.style.removeProperty("max-width");
}
this.window.removeEventListener("keydown", this);
this._panel.removeEventListener("mousemove", this);
this._resetKeyNavigation();
// Clear the main view size caches. The dimensions could be different
// when the popup is opened again, e.g. through touch mode sizing.
this._mainViewHeight = 0;
this._mainViewWidth = 0;
this._viewContainer.style.removeProperty("min-height");
this._viewStack.style.removeProperty("max-height");
this._viewContainer.style.removeProperty("min-width");
this._viewContainer.style.removeProperty("max-width");
this._dispatchViewEvent(this.node, "PanelMultiViewHidden");
break;

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

@ -2,45 +2,23 @@
* 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/. */
.panel-viewstack[viewtype="main"] > .panel-clickcapturer {
pointer-events: none;
}
.panel-viewcontainer {
overflow: hidden;
}
.panel-viewstack {
overflow: visible;
transition: height var(--panelui-subview-transition-duration);
}
.panel-subviews {
-moz-stack-sizing: ignore-horizontal;
transform: translateX(0);
}
.panel-viewstack[viewtype="main"] > .panel-subviews {
-moz-stack-sizing: ignore;
}
.panel-subviews[panelopen] {
transition: transform var(--panelui-subview-transition-duration);
}
.panel-viewcontainer[panelopen]:-moz-any(:not([viewtype="main"]),[transitioning]) {
.panel-viewcontainer[panelopen] {
transition-property: height;
transition-timing-function: var(--animation-easing-function);
transition-duration: var(--panelui-subview-transition-duration);
will-change: height;
}
/* START photon adjustments */
photonpanelmultiview > .panel-viewcontainer > .panel-viewstack {
overflow: visible;
}
photonpanelmultiview[transitioning] {
panelmultiview[transitioning] {
pointer-events: none;
}
@ -55,5 +33,3 @@ photonpanelmultiview[transitioning] {
margin: 0;
padding: 0;
}
/* END photon adjustments */

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

@ -9,7 +9,7 @@
position="bottomcenter topright"
photon="true"
hidden="true">
<photonpanelmultiview mainViewId="widget-overflow-mainView" disablekeynav="true">
<panelmultiview mainViewId="widget-overflow-mainView" disablekeynav="true">
<panelview id="widget-overflow-mainView"
context="toolbar-context-menu">
<vbox class="panel-subview-body">
@ -24,7 +24,7 @@
accesskey="&overflowCustomizeToolbar.accesskey;"
label="&overflowCustomizeToolbar.label;"/>
</panelview>
</photonpanelmultiview>
</panelmultiview>
<!-- This menu is here because not having it in the menu in which it's used flickers
when hover styles overlap. See https://bugzilla.mozilla.org/show_bug.cgi?id=1378427 .
-->
@ -164,8 +164,8 @@
flip="slide"
position="bottomcenter topright"
noautofocus="true">
<photonpanelmultiview id="appMenu-multiView" mainViewId="appMenu-mainView"
viewCacheId="appMenu-viewCache">
<panelmultiview id="appMenu-multiView" mainViewId="appMenu-mainView"
viewCacheId="appMenu-viewCache">
<panelview id="appMenu-mainView" class="PanelUI-subView"
descriptionheightworkaround="true">
<vbox class="panel-subview-body">
@ -667,7 +667,7 @@
label-checked="&hideBookmarksToolbar.label;"/>
</vbox>
</panelview>
</photonpanelmultiview>
</panelmultiview>
</panel>
<panel id="downloads-button-autohide-panel"

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

@ -399,7 +399,7 @@ const PanelUI = {
this.ensureLibraryInitialized(viewNode);
let container = aAnchor.closest("panelmultiview,photonpanelmultiview");
let container = aAnchor.closest("panelmultiview");
if (container) {
container.showSubView(aViewId, aAnchor);
} else if (!aAnchor.open) {
@ -434,7 +434,7 @@ const PanelUI = {
let listener = () => viewShown = true;
viewNode.addEventListener("ViewShown", listener, {once: true});
let multiView = document.createElement("photonpanelmultiview");
let multiView = document.createElement("panelmultiview");
multiView.setAttribute("id", "customizationui-widget-multiview");
multiView.setAttribute("viewCacheId", "appMenu-viewCache");
multiView.setAttribute("mainViewId", viewNode.id);

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

@ -18,26 +18,14 @@
<stylesheet src="chrome://browser/content/customizableui/panelUI.css"/>
</resources>
<content>
<xul:vbox anonid="viewContainer" class="panel-viewcontainer" xbl:inherits="panelopen,viewtype,transitioning">
<xul:stack anonid="viewStack" xbl:inherits="viewtype,transitioning" class="panel-viewstack">
<xul:vbox anonid="mainViewContainer" class="panel-mainview" xbl:inherits="viewtype"/>
<!-- Used to capture click events over the PanelUI-mainView if we're in
subview mode. That way, any click on the PanelUI-mainView causes us
to revert to the mainView mode, whereupon PanelUI-click-capture then
allows click events to go through it. -->
<xul:vbox anonid="clickCapturer" class="panel-clickcapturer"/>
<!-- We manually set display: none (via a CSS attribute selector) on the
subviews that are not being displayed. We're using this over a deck
because a deck assumes the size of its largest child, regardless of
whether or not it is shown. That's not good for our case, since we
want to allow each subview to be uniquely sized. -->
<xul:vbox anonid="subViews" class="panel-subviews" xbl:inherits="panelopen">
<children includes="panelview"/>
</xul:vbox>
</xul:stack>
</xul:vbox>
<xul:box anonid="viewContainer" class="panel-viewcontainer" xbl:inherits="panelopen,transitioning">
<xul:box anonid="viewStack" xbl:inherits="transitioning" class="panel-viewstack">
<children includes="panelview"/>
</xul:box>
</xul:box>
<xul:box class="panel-viewcontainer offscreen">
<xul:box anonid="offscreenViewStack" class="panel-viewstack"/>
</xul:box>
</content>
<implementation>
<constructor><![CDATA[
@ -51,19 +39,6 @@
</implementation>
</binding>
<binding id="photonpanelmultiview" extends="chrome://browser/content/customizableui/panelUI.xml#panelmultiview">
<content>
<xul:box anonid="viewContainer" class="panel-viewcontainer" xbl:inherits="panelopen,transitioning">
<xul:box anonid="viewStack" xbl:inherits="transitioning" class="panel-viewstack">
<children includes="panelview"/>
</xul:box>
</xul:box>
<xul:box class="panel-viewcontainer offscreen">
<xul:box anonid="offscreenViewStack" class="panel-viewstack"/>
</xul:box>
</content>
</binding>
<binding id="panelview">
<content>
<xul:box class="panel-header" anonid="header">

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

@ -46,7 +46,7 @@ add_task(async function() {
let checkedButtons = characterEncodingView.querySelectorAll("toolbarbutton[checked='true']");
is(checkedButtons.length, 2, "There should be 2 checked items (1 charset, 1 detector).");
is(checkedButtons[0].getAttribute("label"), "Unicode", "The unicode encoding is correctly selected");
is(checkedButtons[0].getAttribute("label"), "Western", "The western encoding is correctly selected");
is(characterEncodingView.querySelectorAll("#PanelUI-characterEncodingView-autodetect toolbarbutton[checked='true']").length,
1,
"There should be 1 checked detector.");

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

@ -26,32 +26,34 @@ add_task(async function() {
let checkedButtons = characterEncodingView.querySelectorAll("toolbarbutton[checked='true']");
let initialEncoding = checkedButtons[0];
is(initialEncoding.getAttribute("label"), "Unicode", "The unicode encoding is initially selected");
is(initialEncoding.getAttribute("label"), "Western", "The western encoding is initially selected");
// change the encoding
let encodings = characterEncodingView.querySelectorAll("toolbarbutton");
let newEncoding = encodings[0].hasAttribute("checked") ? encodings[1] : encodings[0];
let tabLoadPromise = promiseTabLoadEvent(gBrowser.selectedTab, TEST_PAGE);
let browserStopPromise = BrowserTestUtils.browserStopped(gBrowser, TEST_PAGE);
newEncoding.click();
await tabLoadPromise;
await browserStopPromise;
is(gBrowser.selectedBrowser.characterSet, "UTF-8", "The encoding should be changed to UTF-8");
ok(!gBrowser.selectedBrowser.mayEnableCharacterEncodingMenu, "The encoding menu should be disabled");
// check that the new encodng is applied
await document.getElementById("nav-bar").overflowable.show();
charEncodingButton.click();
checkedButtons = characterEncodingView.querySelectorAll("toolbarbutton[checked='true']");
let selectedEncodingName = checkedButtons[0].getAttribute("label");
ok(selectedEncodingName != "Unicode", "The encoding was changed to " + selectedEncodingName);
ok(selectedEncodingName == "Unicode", "The encoding was changed to " + selectedEncodingName);
// reset the initial encoding
CustomizableUI.removeWidgetFromArea("characterencoding-button");
CustomizableUI.addWidgetToArea("characterencoding-button",
CustomizableUI.AREA_FIXED_OVERFLOW_PANEL);
await waitForOverflowButtonShown();
await document.getElementById("nav-bar").overflowable.show();
charEncodingButton.click();
tabLoadPromise = promiseTabLoadEvent(gBrowser.selectedTab, TEST_PAGE);
initialEncoding.click();
await tabLoadPromise;
await document.getElementById("nav-bar").overflowable.show();
charEncodingButton.click();
checkedButtons = characterEncodingView.querySelectorAll("toolbarbutton[checked='true']");
is(checkedButtons[0].getAttribute("label"), "Unicode", "The encoding was reset to Unicode");
charEncodingButton = document.getElementById("characterencoding-button");
// check the encoding menu again
is(charEncodingButton.getAttribute("disabled"), "true", "We should disable the encoding menu");
await BrowserTestUtils.removeTab(newTab);
});

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

@ -39,7 +39,7 @@ add_task(async function check_developer_subview_in_overflow() {
let subviewShownPromise = subviewShown(developerView);
button.click();
await subviewShownPromise;
let hasSubviews = !!kOverflowPanel.querySelector("photonpanelmultiview,panelmultiview");
let hasSubviews = !!kOverflowPanel.querySelector("panelmultiview");
let expectedPanel = hasSubviews ? kOverflowPanel : document.getElementById("customizationui-widget-panel");
is(developerView.closest("panel"), expectedPanel, "Should be inside the panel");
expectedPanel.hidePopup();

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

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta charset="iso-8859-1">
<title>Test page</title>
</head>

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

@ -110,21 +110,6 @@
</content>
</binding>
<binding id="download-toolbarbutton"
extends="chrome://global/content/bindings/toolbarbutton.xml#toolbarbutton-badged">
<content>
<xul:stack class="toolbarbutton-badge-stack">
<children />
<xul:image class="toolbarbutton-icon" xbl:inherits="validate,src=image,label,consumeanchor"/>
<xul:label class="toolbarbutton-badge" xbl:inherits="value=badge" top="0" end="0" crop="none"/>
</xul:stack>
<xul:label class="toolbarbutton-text" crop="right" flex="1"
xbl:inherits="value=label,accesskey,crop,wrap"/>
<xul:label class="toolbarbutton-multiline-text" flex="1"
xbl:inherits="xbl:text=label,accesskey,wrap"/>
</content>
</binding>
<binding id="download-subview-toolbarbutton"
extends="chrome://global/content/bindings/button.xml#menu-button-base">
<content>

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

@ -198,8 +198,7 @@ richlistitem.download button {
/* Make the panel wide enough to show the download list items without improperly
truncating them. */
#downloadsPanel-multiView > .panel-viewcontainer,
#downloadsPanel-multiView > .panel-viewcontainer > .panel-viewstack,
#downloadsPanel-multiView > .panel-viewcontainer > .panel-viewstack > .panel-mainview {
#downloadsPanel-multiView > .panel-viewcontainer > .panel-viewstack {
max-width: unset;
}

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

@ -109,8 +109,8 @@
label="&cmd.clearDownloads.label;"/>
</menupopup>
<photonpanelmultiview id="downloadsPanel-multiView"
mainViewId="downloadsPanel-mainView">
<panelmultiview id="downloadsPanel-multiView"
mainViewId="downloadsPanel-mainView">
<panelview id="downloadsPanel-mainView">
<vbox class="panel-view-body-unscrollable">
@ -207,7 +207,7 @@
oncommand="BrowserDownloadsUI(); CustomizableUI.hidePanelForNode(this);"/>
</panelview>
</photonpanelmultiview>
</panelmultiview>
</panel>
</popupset>

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

@ -2204,7 +2204,7 @@ BrowserGlue.prototype = {
let defaultEngine = Services.search.originalDefaultEngine;
defaultEngine.hidden = false;
Services.search.currentEngine = defaultEngine;
Services.prefs.setIntPref("browser.search.reset.status", "silent");
Services.prefs.setCharPref("browser.search.reset.status", "silent");
}
});
}

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

@ -41,7 +41,7 @@
<p>&searchreset.pageInfo1;</p>
<p>&searchreset.selector.label;<span id="defaultEngine"/></p>
<p>&searchreset.beforelink.pageInfo2;<a id="linkSettingsPage" href="about:preferences">&searchreset.link.pageInfo2;</a>&searchreset.afterlink.pageInfo2;</p>
<p>&searchreset.beforelink.pageInfo2;<a id="linkSettingsPage" href="about:preferences#search">&searchreset.link.pageInfo2;</a>&searchreset.afterlink.pageInfo2;</p>
</div>
<div class="button-container">

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

@ -115,7 +115,7 @@ var gTests = [
Services.prefs.setCharPref(kStatusPref, "pending");
let loadPromise = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser,
false,
"about:preferences");
"about:preferences#search");
// eslint-disable-next-line mozilla/no-cpows-in-tests
gBrowser.contentDocument.getElementById("linkSettingsPage").click();
await loadPromise;

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

@ -219,7 +219,7 @@ skip-if = true # Needs to be rewritten as Marionette test, bug 995916
[browser_739531.js]
[browser_739805.js]
[browser_819510_perwindowpb.js]
skip-if = (os == 'win' && bits == 64) || (os == "mac") # Win: Bug 1284312, Mac: Bug 1341980
skip-if = (os == 'win' && bits == 64) || (os == "mac") || (os == "linux") # Win: Bug 1284312, Mac: Bug 1341980, Linux: bug 1381451
[browser_not_collect_when_idle.js]
# Disabled for frequent intermittent failures

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

@ -0,0 +1,25 @@
MOZ_AUTOMATION_BUILD_SYMBOLS=0
MOZ_AUTOMATION_PACKAGE_TESTS=0
MOZ_AUTOMATION_L10N_CHECK=0
. "$topsrcdir/build/mozconfig.common"
ac_add_options --enable-debug
ac_add_options --enable-dmd
. $topsrcdir/build/mozconfig.stylo
# Use Clang as specified in manifest
export CC="$topsrcdir/clang/bin/clang"
export CXX="$topsrcdir/clang/bin/clang++"
# Add the static checker
ac_add_options --enable-clang-plugin
ac_add_options --enable-mozsearch-plugin
. "$topsrcdir/build/unix/mozconfig.stdcxx"
export PKG_CONFIG_LIBDIR=/usr/lib64/pkgconfig:/usr/share/pkgconfig
. $topsrcdir/build/unix/mozconfig.gtk
. "$topsrcdir/build/mozconfig.common.override"

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

@ -0,0 +1,13 @@
MOZ_AUTOMATION_BUILD_SYMBOLS=0
MOZ_AUTOMATION_PACKAGE_TESTS=0
MOZ_AUTOMATION_L10N_CHECK=0
. $topsrcdir/build/macosx/mozconfig.common
ac_add_options --enable-debug
ac_add_options --enable-dmd
ac_add_options --enable-clang-plugin
ac_add_options --enable-mozsearch-plugin
. "$topsrcdir/build/mozconfig.common.override"

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

@ -0,0 +1,17 @@
MOZ_AUTOMATION_BUILD_SYMBOLS=0
MOZ_AUTOMATION_PACKAGE_TESTS=0
MOZ_AUTOMATION_L10N_CHECK=0
. "$topsrcdir/build/mozconfig.win-common"
. "$topsrcdir/browser/config/mozconfigs/common"
ac_add_options --enable-optimize
ac_add_options --enable-debug
ac_add_options --enable-clang-plugin
ac_add_options --enable-mozsearch-plugin
. $topsrcdir/build/win32/mozconfig.vs-latest
. "$topsrcdir/build/mozconfig.common.override"
. "$topsrcdir/build/mozconfig.clang-cl"

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

@ -4,10 +4,6 @@
%include ../../shared/customizableui/panelUI.inc.css
.panel-subviews {
background-color: var(--arrowpanel-background);
}
#BMB_bookmarksPopup > menuitem[type="checkbox"] {
-moz-appearance: none !important; /* important, to override toolkit rule */
}

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

@ -10,15 +10,6 @@
box-shadow: var(--focus-ring-box-shadow);
}
#identity-popup-multiView > .panel-viewcontainer > .panel-viewstack > .panel-subviews {
border-bottom-right-radius: 3.5px;
}
#identity-popup-multiView > .panel-viewcontainer > .panel-viewstack > .panel-subviews:-moz-locale-dir(rtl) {
border-bottom-right-radius: 0;
border-bottom-left-radius: 3.5px;
}
#tracking-action-block,
#tracking-action-unblock,
#tracking-action-unblock-private,

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

@ -4,10 +4,6 @@
%include ../../shared/customizableui/panelUI.inc.css
.panel-subviews {
background-color: hsla(0,0%,100%,.97);
}
.restoreallitem > .toolbarbutton-icon {
display: none;
}
@ -20,7 +16,7 @@
padding-inline-start: 14px;
}
photonpanelmultiview .toolbaritem-combined-buttons > spacer {
panelmultiview .toolbaritem-combined-buttons > spacer {
width: 42px; /* 18px toolbarbutton padding + 16px icon + 8px label padding start */
}

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

@ -68,20 +68,6 @@
max-width: 30em;
}
#identity-popup-multiView > .panel-viewcontainer > .panel-viewstack[viewtype="main"] > .panel-subviews {
transform: translateX(100%);
box-shadow: none;
}
#identity-popup-multiView > .panel-viewcontainer > .panel-viewstack[viewtype="main"] > .panel-subviews:-moz-locale-dir(rtl) {
transform: translateX(-100%);
}
#identity-popup-multiView > .panel-viewcontainer > .panel-viewstack > .panel-subviews {
background: var(--arrowpanel-background);
padding: 0;
}
.identity-popup-section:not(:first-child) {
border-top: 1px solid var(--panel-separator-color);
}
@ -164,7 +150,7 @@
.identity-popup-host {
word-wrap: break-word;
/* 1em + 2em + 24px is .identity-popup-security-content padding
* 30em is .panel-mainview width */
* 30em is the panel width */
max-width: calc(30rem - 3rem - 24px - @identityPopupExpanderWidth@);
}

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

@ -22,7 +22,6 @@
%define panelPaletteIconSize 16px
:root {
--panel-ui-exit-subview-gutter-width: 38px;
--appmenu-yellow-warning-border-color: hsl(45, 100%, 77%);
--appmenu-yellow-warning-color: #FFEFBF;
--appmenu-yellow-warning-hover-color: #FFE8A2;
@ -114,26 +113,11 @@
background: #FFBF00 url(chrome://browser/skin/update-badge-failed.svg) no-repeat center;
}
.panel-subviews {
padding: 4px;
background-clip: padding-box;
border-left: 1px solid var(--arrowpanel-border-color);
box-shadow: 0 3px 5px hsla(210,4%,10%,.1),
0 0 7px hsla(210,4%,10%,.1);
margin-inline-start: var(--panel-ui-exit-subview-gutter-width);
}
.panel-viewstack[viewtype="main"] > .panel-subviews {
transform: translateX(@menuPanelWidth@);
}
.panel-viewstack[viewtype="main"] > .panel-subviews:-moz-locale-dir(rtl) {
transform: translateX(-@menuPanelWidth@);
}
panelview {
-moz-box-orient: vertical;
-moz-box-flex: 1;
background: var(--arrowpanel-background);
padding: 0;
}
/* This section is to anchor all the drop down panels at the same height, shift the
@ -200,6 +184,7 @@ panelview {
overflow-y: auto;
overflow-x: hidden;
-moz-box-flex: 1;
padding: 6px 0;
}
.panel-view-body-unscrollable {
@ -242,8 +227,7 @@ panel[photon] > .panel-arrowcontainer > .panel-arrowcontent {
margin-inline-start: 0;
}
#BMB_bookmarksPopup,
.panel-mainview {
#BMB_bookmarksPopup {
max-width: @standaloneSubviewWidth@;
}
@ -323,11 +307,6 @@ panel[photon] > .panel-arrowcontainer > .panel-arrowcontent {
opacity: 1;
}
/* Give WebExtension stand-alone panels extra width for Chrome compatibility */
.cui-widget-panel[viewId^=PanelUI-webext-] .panel-mainview {
max-width: 800px;
}
.cui-widget-panel[viewId^=PanelUI-webext-] > .panel-arrowcontainer > .panel-arrowcontent {
padding: 0;
}
@ -347,18 +326,11 @@ panelview:not([mainview]) .toolbarbutton-text,
padding: 4px 0;
}
/* START photonpanelview adjustments */
#appMenu-popup > .panel-arrowcontainer > .panel-arrowcontent,
panel[photon] > .panel-arrowcontainer > .panel-arrowcontent {
padding: 0;
}
photonpanelmultiview panelview {
background: var(--arrowpanel-background);
padding: 0;
}
#appMenu-popup panelview,
#customizationui-widget-multiview panelview:not([extension]) {
min-width: @menuPanelWidth@;
@ -377,12 +349,6 @@ photonpanelmultiview panelview {
min-width: calc(@menuPanelWidth@ + 32px);
}
photonpanelmultiview .panel-subview-body {
padding: 6px 0;
}
/* END photonpanelview adjustments */
.cui-widget-panel.cui-widget-panelWithFooter > .panel-arrowcontainer > .panel-arrowcontent {
padding-bottom: 0;
}
@ -461,7 +427,8 @@ toolbarbutton[constrain-size="true"][cui-areatype="menu-panel"] > .toolbarbutton
content: "";
width: 16px;
height: 16px;
margin-inline-end: 16.5px;
margin-inline-start: 10px;
margin-inline-end: 12px;
display: -moz-box;
}
@ -904,25 +871,9 @@ panelview .toolbarbutton-1,
color: inherit;
}
/* START photon adjustments */
.subviewbutton[checked="true"] {
background: url(chrome://browser/skin/check.svg) center left 7px / 11px 11px no-repeat transparent;
fill: currentColor;
}
.subviewbutton[checked="true"]:-moz-locale-dir(rtl) {
background-position: center right 7px;
}
photonpanelmultiview .subviewbutton[checked="true"] {
background: none;
list-style-image: url(chrome://browser/skin/check.svg);
}
photonpanelmultiview .subviewbutton > .menu-iconic-left {
-moz-appearance: none;
margin-inline-end: 0;
fill: currentColor;
}
#appMenu-popup .toolbaritem-combined-buttons {
@ -933,22 +884,22 @@ photonpanelmultiview .subviewbutton > .menu-iconic-left {
margin-inline-end: 8px;
}
photonpanelmultiview .toolbaritem-combined-buttons > label {
panelmultiview .toolbaritem-combined-buttons > label {
-moz-box-flex: 1;
font: menu;
margin: 0;
}
photonpanelmultiview .toolbaritem-combined-buttons > spacer.before-label {
panelmultiview .toolbaritem-combined-buttons > spacer.before-label {
width: 36px; /* 12px toolbarbutton padding + 16px icon + 8px label padding start */
}
photonpanelmultiview .toolbaritem-combined-buttons > spacer.after-label {
panelmultiview .toolbaritem-combined-buttons > spacer.after-label {
-moz-box-flex: 1;
width: 20px; /* a little bigger than the width of the scrollbar */
}
photonpanelmultiview .PanelUI-subView .toolbaritem-combined-buttons > .subviewbutton {
.PanelUI-subView .toolbaritem-combined-buttons > .subviewbutton {
-moz-box-flex: 0;
height: auto;
margin-inline-start: 18px;
@ -975,44 +926,33 @@ photonpanelmultiview .PanelUI-subView .toolbaritem-combined-buttons > .subviewbu
margin-inline-start: 0;
}
photonpanelmultiview .PanelUI-subView .toolbaritem-combined-buttons >
.subviewbutton-iconic > .toolbarbutton-text,
photonpanelmultiview .PanelUI-subView .toolbaritem-combined-buttons >
.subviewbutton:not(.subviewbutton-iconic) > .toolbarbutton-icon {
.PanelUI-subView .toolbaritem-combined-buttons > .subviewbutton-iconic > .toolbarbutton-text,
.PanelUI-subView .toolbaritem-combined-buttons > .subviewbutton:not(.subviewbutton-iconic) > .toolbarbutton-icon {
display: none;
}
/* Using this selector, because this way the hover and active selectors will apply properly. */
photonpanelmultiview .PanelUI-subView .toolbaritem-combined-buttons >
.subviewbutton:not(.subviewbutton-iconic) {
.PanelUI-subView .toolbaritem-combined-buttons > .subviewbutton:not(.subviewbutton-iconic) {
background-color: #f9f9f9;
border: 1px solid #e1e1e1;
border-radius: 10000px;
padding: 1px 8px;
}
photonpanelmultiview .toolbaritem-combined-buttons > .subviewbutton:not(.subviewbutton-iconic) > .toolbarbutton-text {
.toolbaritem-combined-buttons > .subviewbutton:not(.subviewbutton-iconic) > .toolbarbutton-text {
font-size: 1em;
padding-inline-start: 0;
}
photonpanelmultiview .addon-banner-item::after,
photonpanelmultiview .panel-banner-item::after {
margin-inline-end: 12px;
margin-inline-start: 10px;
}
photonpanelmultiview .subview-subheader {
.subview-subheader {
color: GrayText;
}
photonpanelmultiview .subview-subheader,
photonpanelmultiview .panel-subview-footer {
.subview-subheader,
.panel-subview-footer {
font: menu;
}
/* END photon adjustments */
panelview .toolbarbutton-1 {
margin-top: 6px;
}
@ -1108,12 +1048,16 @@ menuitem.panel-subview-footer@menuStateActive@,
padding: 0;
}
.PanelUI-subView menuseparator,
.PanelUI-subView toolbarseparator {
.PanelUI-subView menuseparator {
margin-inline-start: -5px;
margin-inline-end: -4px;
}
.PanelUI-subView toolbarseparator {
margin-inline-start: 0;
margin-inline-end: 0;
}
.PanelUI-subView menuseparator.small-separator,
.PanelUI-subView toolbarseparator.small-separator {
margin-left: 5px;
@ -1240,7 +1184,6 @@ toolbarpaletteitem[place=panel] > .toolbaritem-combined-buttons > toolbarbutton
padding: 0;
}
.cui-widget-panelview,
#widget-overflow-mainView .panel-subview-body {
overflow-y: auto;
overflow-x: hidden;
@ -1293,14 +1236,13 @@ toolbarpaletteitem[place=panel] > .subviewbutton-nav::after {
.subviewbutton > .menu-iconic-left {
-moz-appearance: none;
margin-inline-end: 3px;
margin-inline-end: 0;
}
menuitem[checked="true"].subviewbutton > .menu-iconic-left {
visibility: hidden;
}
.panel-mainview[panelid=customizationui-widget-panel],
#PanelUI-panicView > .panel-subview-body,
#PanelUI-panicView {
overflow: visible;
@ -1493,8 +1435,6 @@ menuitem[checked="true"].subviewbutton > .menu-iconic-left {
}
}
/* START photon adjustments */
.panel-header {
align-items: center;
border-bottom: 1px solid var(--panel-separator-color);
@ -1514,7 +1454,7 @@ menuitem[checked="true"].subviewbutton > .menu-iconic-left {
text-align: center;
}
photonpanelmultiview .PanelUI-subView .panel-header > .subviewbutton-back {
.PanelUI-subView .panel-header > .subviewbutton-back {
-moz-context-properties: fill;
fill: var(--arrowpanel-color);
list-style-image: url(chrome://browser/skin/arrow-left.svg);
@ -1531,18 +1471,7 @@ photonpanelmultiview .PanelUI-subView .panel-header > .subviewbutton-back {
display: none !important;
}
photonpanelmultiview .PanelUI-subView toolbarseparator {
margin-inline-start: 0;
margin-inline-end: 0;
}
/* This is explicitly overriding the overflow properties set above. */
photonpanelmultiview .cui-widget-panelview {
overflow-x: visible;
overflow-y: visible;
}
photonpanelmultiview #panelMenu_pocket {
#panelMenu_pocket {
display: none;
}
@ -1597,5 +1526,3 @@ photonpanelmultiview #panelMenu_pocket {
.subviewbutton.download:-moz-any([openLabel],[retryLabel]) > .action-button@buttonStateActive@ {
background-color: var(--arrowpanel-dimmed-even-further);
}
/* END photon adjustments */

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

@ -15,10 +15,6 @@
#downloadsPanel > .panel-arrowcontainer > .panel-arrowcontent {
overflow: hidden;
}
#downloadsPanel > .panel-arrowcontainer > .panel-arrowcontent,
#downloadsPanel-multiView > .panel-viewcontainer > .panel-viewstack > .panel-subviews {
padding: 0;
}

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

@ -4,10 +4,6 @@
%include ../../shared/customizableui/panelUI.inc.css
.panel-subviews {
background-color: var(--arrowpanel-background);
}
/* bookmark panel submenus */
#BMB_bookmarksPopup menupopup[placespopup=true] {

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

@ -3864,7 +3864,6 @@ ItemIsActive(nsIDocShellTreeItem* aItem)
{
if (nsCOMPtr<nsPIDOMWindowOuter> window = aItem->GetWindow()) {
auto* win = nsGlobalWindowOuter::Cast(window);
MOZ_ASSERT(win->IsOuterWindow());
if (!win->GetClosedOuter()) {
return true;
}

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

@ -1,5 +1,3 @@
/* -*- 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/. */
@ -77,8 +75,6 @@ AudioChannelAgent::InitWithWeakCallback(mozIDOMWindow* aWindow,
nsresult
AudioChannelAgent::FindCorrectWindow(nsPIDOMWindowInner* aWindow)
{
MOZ_ASSERT(aWindow->IsInnerWindow());
mWindow = aWindow->GetScriptableTop();
if (NS_WARN_IF(!mWindow)) {
return NS_OK;
@ -142,7 +138,6 @@ AudioChannelAgent::InitInternal(nsPIDOMWindowInner* aWindow,
return NS_ERROR_FAILURE;
}
MOZ_ASSERT(aWindow->IsInnerWindow());
mInnerWindowID = aWindow->WindowID();
nsresult rv = FindCorrectWindow(aWindow);

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

@ -345,12 +345,10 @@ AudioChannelService::UnregisterAudioChannelAgent(AudioChannelAgent* aAgent)
AudioPlaybackConfig
AudioChannelService::GetMediaConfig(nsPIDOMWindowOuter* aWindow) const
{
MOZ_ASSERT(!aWindow || aWindow->IsOuterWindow());
AudioPlaybackConfig config(1.0, false,
nsISuspendedTypes::NONE_SUSPENDED);
if (!aWindow || !aWindow->IsOuterWindow()) {
if (!aWindow) {
config.SetConfig(0.0, true,
nsISuspendedTypes::SUSPENDED_BLOCK);
return config;
@ -452,7 +450,6 @@ AudioChannelService::RefreshAgents(nsPIDOMWindowOuter* aWindow,
const std::function<void(AudioChannelAgent*)>& aFunc)
{
MOZ_ASSERT(aWindow);
MOZ_ASSERT(aWindow->IsOuterWindow());
nsCOMPtr<nsPIDOMWindowOuter> topWindow = aWindow->GetScriptableTop();
if (!topWindow) {
@ -495,7 +492,6 @@ AudioChannelService::SetWindowAudioCaptured(nsPIDOMWindowOuter* aWindow,
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aWindow);
MOZ_ASSERT(aWindow->IsOuterWindow());
MOZ_LOG(GetAudioChannelLog(), LogLevel::Debug,
("AudioChannelService, SetWindowAudioCaptured, window = %p, "
@ -532,7 +528,6 @@ AudioChannelService::GetOrCreateWindowData(nsPIDOMWindowOuter* aWindow)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aWindow);
MOZ_ASSERT(aWindow->IsOuterWindow());
AudioChannelWindow* winData = GetWindowData(aWindow->WindowID());
if (!winData) {
@ -595,7 +590,6 @@ void
AudioChannelService::NotifyMediaResumedFromBlock(nsPIDOMWindowOuter* aWindow)
{
MOZ_ASSERT(aWindow);
MOZ_ASSERT(aWindow->IsOuterWindow());
nsCOMPtr<nsPIDOMWindowOuter> topWindow = aWindow->GetScriptableTop();
if (!topWindow) {
@ -974,7 +968,6 @@ AudioChannelService::AudioChannelWindow::MaybeNotifyMediaBlockStart(AudioChannel
return;
}
MOZ_ASSERT(window->IsOuterWindow());
nsCOMPtr<nsPIDOMWindowInner> inner = window->GetCurrentInnerWindow();
if (!inner) {
return;

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

@ -21,7 +21,6 @@ namespace dom {
BarProp::BarProp(nsGlobalWindowInner* aWindow)
: mDOMWindow(aWindow)
{
MOZ_ASSERT(aWindow->IsInnerWindow());
}
BarProp::~BarProp()

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

@ -224,7 +224,6 @@ CustomElementRegistry::CustomElementRegistry(nsPIDOMWindowInner* aWindow)
, mIsCustomDefinitionRunning(false)
{
MOZ_ASSERT(aWindow);
MOZ_ASSERT(aWindow->IsInnerWindow());
MOZ_ALWAYS_TRUE(mConstructors.init());
mozilla::HoldJSObjects(this);

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

@ -1965,8 +1965,7 @@ EventSource::Constructor(const GlobalObject& aGlobal, const nsAString& aURL,
nsCOMPtr<nsPIDOMWindowInner> ownerWindow =
do_QueryInterface(aGlobal.GetAsSupports());
MOZ_ASSERT(!NS_IsMainThread() ||
(ownerWindow && ownerWindow->IsInnerWindow()));
MOZ_ASSERT(!NS_IsMainThread() || ownerWindow);
RefPtr<EventSource> eventSource =
new EventSource(ownerWindow, aEventSourceInitDict.mWithCredentials);

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

@ -42,8 +42,6 @@ namespace dom {
Location::Location(nsPIDOMWindowInner* aWindow, nsIDocShell *aDocShell)
: mInnerWindow(aWindow)
{
MOZ_ASSERT(mInnerWindow->IsInnerWindow());
// aDocShell can be null if it gets called after nsDocShell::Destory().
mDocShell = do_GetWeakReference(aDocShell);
}

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

@ -168,7 +168,6 @@ Navigator::Init()
Navigator::Navigator(nsPIDOMWindowInner* aWindow)
: mWindow(aWindow)
{
MOZ_ASSERT(aWindow->IsInnerWindow(), "Navigator must get an inner window!");
}
Navigator::~Navigator()
@ -1628,8 +1627,6 @@ Navigator::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
void
Navigator::SetWindow(nsPIDOMWindowInner *aInnerWindow)
{
NS_ASSERTION(aInnerWindow->IsInnerWindow(),
"Navigator must get an inner window!");
mWindow = aInnerWindow;
}
@ -1712,7 +1709,6 @@ Navigator::GetWindowFromGlobal(JSObject* aGlobal)
{
nsCOMPtr<nsPIDOMWindowInner> win =
do_QueryInterface(nsJSUtils::GetStaticScriptGlobal(aGlobal));
MOZ_ASSERT(!win || win->IsInnerWindow());
return win.forget();
}

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

@ -55,11 +55,6 @@ PostMessageEvent::~PostMessageEvent()
NS_IMETHODIMP
PostMessageEvent::Run()
{
MOZ_ASSERT(mTargetWindow->IsOuterWindow(),
"should have been passed an outer window!");
MOZ_ASSERT(!mSource || mSource->IsOuterWindow(),
"should have been passed an outer window!");
// Note: We don't init this AutoJSAPI with targetWindow, because we do not
// want exceptions during message deserialization to trigger error events on
// targetWindow.
@ -82,8 +77,6 @@ PostMessageEvent::Run()
targetWindow->IsClosedOrClosing())
return NS_OK;
MOZ_ASSERT(targetWindow->IsInnerWindow(),
"we ordered an inner window!");
JSAutoCompartment ac(cx, targetWindow->GetWrapper());
// Ensure that any origin which might have been provided is the origin of this

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

@ -410,8 +410,6 @@ TimeoutManager::TimeoutManager(nsGlobalWindowInner& aWindow)
mThrottleTrackingTimeouts(false),
mBudgetThrottleTimeouts(false)
{
MOZ_DIAGNOSTIC_ASSERT(aWindow.IsInnerWindow());
MOZ_LOG(gLog, LogLevel::Debug,
("TimeoutManager %p created, tracking bucketing %s\n",
this, gAnnotateTrackingChannels ? "enabled" : "disabled"));
@ -587,7 +585,7 @@ TimeoutManager::SetTimeout(nsITimeoutHandler* aHandler,
}
if (gRunningTimeoutDepth == 0 &&
mWindow.GetPopupControlState() < openBlocked) {
nsContentUtils::GetPopupControlState() < openBlocked) {
// This timeout is *not* set from another timeout and it's set
// while popups are enabled. Propagate the state to the timeout if
// its delay (interval) is equal to or less than what
@ -597,7 +595,7 @@ TimeoutManager::SetTimeout(nsITimeoutHandler* aHandler,
// because our lower bound for |realInterval| could be pretty high
// in some cases.
if (interval <= gDisableOpenClickDelay) {
timeout->mPopupState = mWindow.GetPopupControlState();
timeout->mPopupState = nsContentUtils::GetPopupControlState();
}
}
@ -1197,7 +1195,6 @@ public:
explicit ThrottleTimeoutsCallback(nsGlobalWindowInner* aWindow)
: mWindow(aWindow)
{
MOZ_DIAGNOSTIC_ASSERT(aWindow->IsInnerWindow());
}
NS_DECL_ISUPPORTS

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

@ -0,0 +1,138 @@
#include "WindowDestroyedEvent.h"
#include "nsJSUtils.h"
#include "jsapi.h" // for JSAutoRequest
#include "jswrapper.h"
#include "nsIPrincipal.h"
#include "nsISupportsPrimitives.h"
#include "nsIAppStartup.h"
#include "nsToolkitCompsCID.h"
#include "nsCOMPtr.h"
namespace mozilla {
// Try to match compartments that are not web content by matching compartments
// with principals that are either the system principal or an expanded principal.
// This may not return true for all non-web-content compartments.
struct BrowserCompartmentMatcher : public js::CompartmentFilter {
bool match(JSCompartment* aC) const override
{
nsCOMPtr<nsIPrincipal> pc = nsJSPrincipals::get(JS_GetCompartmentPrincipals(aC));
return nsContentUtils::IsSystemOrExpandedPrincipal(pc);
}
};
WindowDestroyedEvent::WindowDestroyedEvent(nsGlobalWindowInner* aWindow,
uint64_t aID, const char* aTopic)
: mozilla::Runnable("WindowDestroyedEvent")
, mID(aID)
, mPhase(Phase::Destroying)
, mTopic(aTopic)
, mIsInnerWindow(true)
{
mWindow = do_GetWeakReference(aWindow);
}
WindowDestroyedEvent::WindowDestroyedEvent(nsGlobalWindowOuter* aWindow,
uint64_t aID, const char* aTopic)
: mozilla::Runnable("WindowDestroyedEvent")
, mID(aID)
, mPhase(Phase::Destroying)
, mTopic(aTopic)
, mIsInnerWindow(false)
{
mWindow = do_GetWeakReference(aWindow);
}
NS_IMETHODIMP
WindowDestroyedEvent::Run()
{
AUTO_PROFILER_LABEL("WindowDestroyedEvent::Run", OTHER);
nsCOMPtr<nsIObserverService> observerService =
services::GetObserverService();
if (!observerService) {
return NS_OK;
}
nsCOMPtr<nsISupportsPRUint64> wrapper =
do_CreateInstance(NS_SUPPORTS_PRUINT64_CONTRACTID);
if (wrapper) {
wrapper->SetData(mID);
observerService->NotifyObservers(wrapper, mTopic.get(), nullptr);
}
switch (mPhase) {
case Phase::Destroying:
{
bool skipNukeCrossCompartment = false;
#ifndef DEBUG
nsCOMPtr<nsIAppStartup> appStartup =
do_GetService(NS_APPSTARTUP_CONTRACTID);
if (appStartup) {
appStartup->GetShuttingDown(&skipNukeCrossCompartment);
}
#endif
if (!skipNukeCrossCompartment) {
// The compartment nuking phase might be too expensive, so do that
// part off of idle dispatch.
// For the compartment nuking phase, we dispatch either an
// inner-window-nuked or an outer-window-nuked notification.
// This will allow tests to wait for compartment nuking to happen.
if (mTopic.EqualsLiteral("inner-window-destroyed")) {
mTopic.AssignLiteral("inner-window-nuked");
} else if (mTopic.EqualsLiteral("outer-window-destroyed")) {
mTopic.AssignLiteral("outer-window-nuked");
}
mPhase = Phase::Nuking;
nsCOMPtr<nsIRunnable> copy(this);
NS_IdleDispatchToCurrentThread(copy.forget(), 1000);
}
}
break;
case Phase::Nuking:
{
nsCOMPtr<nsISupports> window = do_QueryReferent(mWindow);
if (window) {
nsGlobalWindowInner* currentInner;
if (mIsInnerWindow) {
currentInner = nsGlobalWindowInner::FromSupports(window);
} else {
nsGlobalWindowOuter* outer = nsGlobalWindowOuter::FromSupports(window);
currentInner = outer->GetCurrentInnerWindowInternal();
}
NS_ENSURE_TRUE(currentInner, NS_OK);
AutoSafeJSContext cx;
JS::Rooted<JSObject*> obj(cx, currentInner->FastGetGlobalJSObject());
if (obj && !js::IsSystemCompartment(js::GetObjectCompartment(obj))) {
JSCompartment* cpt = js::GetObjectCompartment(obj);
nsCOMPtr<nsIPrincipal> pc = nsJSPrincipals::get(JS_GetCompartmentPrincipals(cpt));
if (BasePrincipal::Cast(pc)->AddonPolicy()) {
// We want to nuke all references to the add-on compartment.
xpc::NukeAllWrappersForCompartment(cx, cpt,
mIsInnerWindow ? js::DontNukeWindowReferences
: js::NukeWindowReferences);
} else {
// We only want to nuke wrappers for the chrome->content case
js::NukeCrossCompartmentWrappers(cx, BrowserCompartmentMatcher(), cpt,
mIsInnerWindow ? js::DontNukeWindowReferences
: js::NukeWindowReferences,
js::NukeIncomingReferences);
}
}
}
}
break;
}
return NS_OK;
}
} // namespace mozilla

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

@ -0,0 +1,43 @@
/* -*- 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/. */
#ifndef WindowDestroyedEvent_h
#define WindowDestroyedEvent_h
#include "nsGlobalWindow.h"
#include "nsThreadUtils.h"
#include "nsWeakPtr.h"
#include "nsString.h"
namespace mozilla {
class WindowDestroyedEvent final : public Runnable
{
public:
WindowDestroyedEvent(nsGlobalWindowInner* aWindow,
uint64_t aID, const char* aTopic);
WindowDestroyedEvent(nsGlobalWindowOuter* aWindow,
uint64_t aID, const char* aTopic);
enum class Phase
{
Destroying,
Nuking
};
NS_IMETHOD Run() override;
private:
uint64_t mID;
Phase mPhase;
nsCString mTopic;
nsWeakPtr mWindow;
bool mIsInnerWindow;
};
} // namespace mozilla
#endif // defined(WindowDestroyedEvent_h)

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

@ -21,7 +21,7 @@ WindowOrientationObserver::WindowOrientationObserver(
nsGlobalWindowInner* aGlobalWindow)
: mWindow(aGlobalWindow)
{
MOZ_ASSERT(aGlobalWindow && aGlobalWindow->IsInnerWindow());
MOZ_ASSERT(aGlobalWindow);
hal::RegisterScreenConfigurationObserver(this);
hal::ScreenConfiguration config;

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

@ -363,6 +363,7 @@ UNIFIED_SOURCES += [
'TimeoutManager.cpp',
'TreeWalker.cpp',
'WebKitCSSMatrix.cpp',
'WindowDestroyedEvent.cpp',
'WindowNamedPropertiesHandler.cpp',
'WindowOrientationObserver.cpp',
'XPathGenerator.cpp',
@ -388,11 +389,9 @@ SOURCES += [
'nsDOMWindowUtils.cpp',
# Conflicts with windows.h's definition of SendMessage.
'nsFrameMessageManager.cpp',
# This file has a #error "Never include windows.h in this file!"
'nsGlobalWindow.cpp',
# These files are included by nsGlobalWindow.cpp
# 'nsGlobalWindowInner.cpp',
# 'nsGlobalWindowOuter.cpp',
# These files have a #error "Never include windows.h in this file!"
'nsGlobalWindowInner.cpp',
'nsGlobalWindowOuter.cpp',
# Conflicts with windows.h's definition of LoadImage.
'nsImageLoadingContent.cpp',
# Because of OS X headers.

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

@ -364,7 +364,6 @@ nsContentPermissionUtils::CreateContentPermissionRequestParent(const nsTArray<Pe
nsContentPermissionUtils::AskPermission(nsIContentPermissionRequest* aRequest,
nsPIDOMWindowInner* aWindow)
{
MOZ_ASSERT(!aWindow || aWindow->IsInnerWindow());
NS_ENSURE_STATE(aWindow && aWindow->IsCurrentInnerWindow());
// for content process

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

@ -343,6 +343,11 @@ bool nsContentUtils::sDoNotTrackEnabled = false;
mozilla::LazyLogModule nsContentUtils::sDOMDumpLog("Dump");
PopupControlState nsContentUtils::sPopupControlState = openAbused;
int32_t nsContentUtils::sInnerOrOuterWindowCount = 0;
uint32_t nsContentUtils::sInnerOrOuterWindowSerialCounter = 0;
// Subset of http://www.whatwg.org/specs/web-apps/current-work/#autofill-field-name
enum AutocompleteUnsupportedFieldName : uint8_t
{
@ -9017,8 +9022,6 @@ nsContentUtils::IsNonSubresourceRequest(nsIChannel* aChannel)
nsContentUtils::StorageAccess
nsContentUtils::StorageAllowedForWindow(nsPIDOMWindowInner* aWindow)
{
MOZ_ASSERT(aWindow->IsInnerWindow());
if (nsIDocument* document = aWindow->GetExtantDoc()) {
nsCOMPtr<nsIPrincipal> principal = document->NodePrincipal();
return InternalStorageAllowedForPrincipal(principal, aWindow);
@ -9107,7 +9110,6 @@ nsContentUtils::InternalStorageAllowedForPrincipal(nsIPrincipal* aPrincipal,
nsPIDOMWindowInner* aWindow)
{
MOZ_ASSERT(aPrincipal);
MOZ_ASSERT(!aWindow || aWindow->IsInnerWindow());
StorageAccess access = StorageAccess::eAllow;
@ -10974,3 +10976,44 @@ nsContentUtils::DevToolsEnabled(JSContext* aCx)
return workerPrivate->DevToolsEnabled();
}
/* static */ bool
nsContentUtils::ContentIsLink(nsIContent* aContent)
{
return aContent && (aContent->IsHTMLElement(nsGkAtoms::a) ||
aContent->AttrValueIs(kNameSpaceID_XLink, nsGkAtoms::type,
nsGkAtoms::simple, eCaseMatters));
}
/* static */ already_AddRefed<EventTarget>
nsContentUtils::TryGetTabChildGlobalAsEventTarget(nsISupports* aFrom)
{
nsCOMPtr<nsIFrameLoaderOwner> frameLoaderOwner = do_QueryInterface(aFrom);
if (!frameLoaderOwner) {
return nullptr;
}
RefPtr<nsFrameLoader> frameLoader = frameLoaderOwner->GetFrameLoader();
if (!frameLoader) {
return nullptr;
}
nsCOMPtr<EventTarget> target = frameLoader->GetTabChildGlobalAsEventTarget();
return target.forget();
}
/* static */ uint32_t
nsContentUtils::InnerOrOuterWindowCreated()
{
MOZ_ASSERT(NS_IsMainThread());
++sInnerOrOuterWindowCount;
return ++sInnerOrOuterWindowSerialCounter;
}
/* static */ void
nsContentUtils::InnerOrOuterWindowDestroyed()
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(sInnerOrOuterWindowCount > 0);
--sInnerOrOuterWindowCount;
}

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

@ -3243,6 +3243,38 @@ public:
static void AsyncPrecreateStringBundles();
static bool ContentIsLink(nsIContent* aContent);
static already_AddRefed<mozilla::dom::EventTarget>
TryGetTabChildGlobalAsEventTarget(nsISupports* aFrom);
static PopupControlState
PushPopupControlState(PopupControlState aState, bool aForce)
{
MOZ_ASSERT(NS_IsMainThread());
PopupControlState old = sPopupControlState;
if (aState < old || aForce) {
sPopupControlState = aState;
}
return old;
}
static void
PopPopupControlState(PopupControlState aState)
{
MOZ_ASSERT(NS_IsMainThread());
sPopupControlState = aState;
}
static PopupControlState GetPopupControlState() { return sPopupControlState; }
// Get a serial number for a newly created inner or outer window.
static uint32_t InnerOrOuterWindowCreated();
// Record that an inner or outer window has been destroyed.
static void InnerOrOuterWindowDestroyed();
// Get the current number of inner or outer windows.
static int32_t GetCurrentInnerOrOuterWindowCount() { return sInnerOrOuterWindowCount; }
private:
static bool InitializeEventTable();
@ -3431,6 +3463,11 @@ private:
#endif
static bool sDoNotTrackEnabled;
static mozilla::LazyLogModule sDOMDumpLog;
static PopupControlState sPopupControlState;
static int32_t sInnerOrOuterWindowCount;
static uint32_t sInnerOrOuterWindowSerialCounter;
};
/* static */ inline

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

@ -229,7 +229,6 @@ static inline nsresult
SetParentToWindow(nsGlobalWindowInner *win, JSObject **parent)
{
MOZ_ASSERT(win);
MOZ_ASSERT(win->IsInnerWindow());
*parent = win->FastGetGlobalJSObject();
if (MOZ_UNLIKELY(!*parent)) {
@ -1029,12 +1028,13 @@ nsDOMConstructor::Create(const char16_t* aName,
nsPIDOMWindowOuter* outerWindow = aOwner->GetOuterWindow();
nsPIDOMWindowInner* currentInner =
outerWindow ? outerWindow->GetCurrentInnerWindow() : aOwner;
if (!currentInner ||
(aOwner != currentInner &&
!nsContentUtils::CanCallerAccess(currentInner) &&
!(currentInner = aOwner)->IsInnerWindow())) {
if (!currentInner) {
return NS_ERROR_DOM_SECURITY_ERR;
}
if (aOwner != currentInner &&
!nsContentUtils::CanCallerAccess(currentInner)) {
currentInner = aOwner;
}
bool constructable = aNameStruct && IsConstructable(aNameStruct);

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

@ -816,7 +816,6 @@ nsDOMMutationObserver::Constructor(const mozilla::dom::GlobalObject& aGlobal,
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
MOZ_ASSERT(window->IsInnerWindow());
bool isChrome = nsContentUtils::IsChromeDoc(window->GetExtantDoc());
RefPtr<nsDOMMutationObserver> observer =
new nsDOMMutationObserver(window.forget(), aCb, isChrome);

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

@ -212,7 +212,6 @@ nsDOMWindowUtils::nsDOMWindowUtils(nsGlobalWindowOuter *aWindow)
{
nsCOMPtr<nsISupports> supports = do_QueryObject(aWindow);
mWindow = do_GetWeakReference(supports);
NS_ASSERTION(aWindow->IsOuterWindow(), "How did that happen?");
}
nsDOMWindowUtils::~nsDOMWindowUtils()
@ -2390,7 +2389,6 @@ nsDOMWindowUtils::GetOuterWindowID(uint64_t *aWindowID)
nsCOMPtr<nsPIDOMWindowOuter> window = do_QueryReferent(mWindow);
NS_ENSURE_STATE(window);
NS_ASSERTION(window->IsOuterWindow(), "How did that happen?");
*aWindowID = window->WindowID();
return NS_OK;
}
@ -2401,7 +2399,6 @@ nsDOMWindowUtils::GetCurrentInnerWindowID(uint64_t *aWindowID)
nsCOMPtr<nsPIDOMWindowOuter> window = do_QueryReferent(mWindow);
NS_ENSURE_TRUE(window, NS_ERROR_NOT_AVAILABLE);
NS_ASSERTION(window->IsOuterWindow(), "How did that happen?");
nsGlobalWindowInner* inner =
nsGlobalWindowOuter::Cast(window)->GetCurrentInnerWindowInternal();
if (!inner) {

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

@ -1538,6 +1538,7 @@ nsIDocument::nsIDocument()
mDidCallBeginLoad(false),
mBufferingCSPViolations(false),
mAllowPaymentRequest(false),
mEncodingMenuDisabled(false),
mIsScopedStyleEnabled(eScopedStyle_Unknown),
mCompatMode(eCompatibility_FullStandards),
mReadyState(ReadyState::READYSTATE_UNINITIALIZED),
@ -5063,14 +5064,6 @@ nsIDocument::GetContainer() const
void
nsDocument::SetScriptGlobalObject(nsIScriptGlobalObject *aScriptGlobalObject)
{
#ifdef DEBUG
{
nsCOMPtr<nsPIDOMWindowInner> win(do_QueryInterface(aScriptGlobalObject));
NS_ASSERTION(!win || win->IsInnerWindow(),
"Script global object must be an inner window!");
}
#endif
MOZ_ASSERT(aScriptGlobalObject || !mAnimationController ||
mAnimationController->IsPausedByType(
nsSMILTimeContainer::PAUSE_PAGEHIDE |
@ -10889,7 +10882,6 @@ nsIDocument::CreateTouch(nsGlobalWindowInner* aView,
float aRotationAngle,
float aForce)
{
MOZ_ASSERT_IF(aView, aView->IsInnerWindow());
RefPtr<Touch> touch = new Touch(aTarget,
aIdentifier,
aPageX, aPageY,
@ -14380,7 +14372,6 @@ nsIDocument::GetSelection(ErrorResult& aRv)
return nullptr;
}
NS_ASSERTION(window->IsInnerWindow(), "Should have inner window here!");
if (!window->IsCurrentInnerWindow()) {
return nullptr;
}

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

@ -1038,7 +1038,6 @@ nsFocusManager::WindowHidden(mozIDOMWindowProxy* aWindow)
// not happen if nsIAppStartup::eForceQuit is used to quit, and can cause
// a leak. So if the active window is being destroyed, call WindowLowered
// directly.
NS_ASSERTION(mFocusedWindow->IsOuterWindow(), "outer window expected");
if (mActiveWindow == mFocusedWindow || mActiveWindow == window)
WindowLowered(mActiveWindow);
else

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

@ -1,832 +0,0 @@
/* -*- 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/. */
#include "nsGlobalWindow.h"
#include <algorithm>
#include "mozilla/MemoryReporting.h"
// Local Includes
#include "Navigator.h"
#include "nsContentSecurityManager.h"
#include "nsScreen.h"
#include "nsHistory.h"
#include "nsDOMNavigationTiming.h"
#include "nsIDOMStorageManager.h"
#include "mozilla/dom/LocalStorage.h"
#include "mozilla/dom/Storage.h"
#include "mozilla/dom/IdleRequest.h"
#include "mozilla/dom/Performance.h"
#include "mozilla/dom/StorageEvent.h"
#include "mozilla/dom/StorageEventBinding.h"
#include "mozilla/dom/StorageNotifierService.h"
#include "mozilla/dom/StorageUtils.h"
#include "mozilla/dom/Timeout.h"
#include "mozilla/dom/TimeoutHandler.h"
#include "mozilla/dom/TimeoutManager.h"
#include "mozilla/IntegerPrintfMacros.h"
#if defined(MOZ_WIDGET_ANDROID)
#include "mozilla/dom/WindowOrientationObserver.h"
#endif
#include "nsDOMOfflineResourceList.h"
#include "nsError.h"
#include "nsIIdleService.h"
#include "nsISizeOfEventTarget.h"
#include "nsDOMJSUtils.h"
#include "nsArrayUtils.h"
#include "nsIDOMWindowCollection.h"
#include "nsDOMWindowList.h"
#include "mozilla/dom/WakeLock.h"
#include "mozilla/dom/power/PowerManagerService.h"
#include "nsIDocShellTreeOwner.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIPermissionManager.h"
#include "nsIScriptContext.h"
#include "nsIScriptTimeoutHandler.h"
#include "nsITimeoutHandler.h"
#include "nsIController.h"
#include "nsScriptNameSpaceManager.h"
#include "nsISlowScriptDebug.h"
#include "nsWindowMemoryReporter.h"
#include "nsWindowSizes.h"
#include "WindowNamedPropertiesHandler.h"
#include "nsFrameSelection.h"
#include "nsNetUtil.h"
#include "nsVariant.h"
#include "nsPrintfCString.h"
#include "mozilla/intl/LocaleService.h"
// Helper Classes
#include "nsJSUtils.h"
#include "jsapi.h" // for JSAutoRequest
#include "jswrapper.h"
#include "nsCharSeparatedTokenizer.h"
#include "nsReadableUtils.h"
#include "nsDOMClassInfo.h"
#include "nsJSEnvironment.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/Preferences.h"
#include "mozilla/Likely.h"
#include "mozilla/Sprintf.h"
#include "mozilla/Unused.h"
// Other Classes
#include "mozilla/dom/BarProps.h"
#include "nsContentCID.h"
#include "nsLayoutStatics.h"
#include "nsCCUncollectableMarker.h"
#include "mozilla/dom/workers/Workers.h"
#include "mozilla/dom/ToJSValue.h"
#include "nsJSPrincipals.h"
#include "mozilla/Attributes.h"
#include "mozilla/Debug.h"
#include "mozilla/EventListenerManager.h"
#include "mozilla/EventStates.h"
#include "mozilla/MouseEvents.h"
#include "mozilla/ProcessHangMonitor.h"
#include "mozilla/ThrottledEventQueue.h"
#include "AudioChannelService.h"
#include "nsAboutProtocolUtils.h"
#include "nsCharTraits.h" // NS_IS_HIGH/LOW_SURROGATE
#include "PostMessageEvent.h"
#include "mozilla/dom/DocGroup.h"
#include "mozilla/dom/TabGroup.h"
// Interfaces Needed
#include "nsIFrame.h"
#include "nsCanvasFrame.h"
#include "nsIWidget.h"
#include "nsIWidgetListener.h"
#include "nsIBaseWindow.h"
#include "nsIDeviceSensors.h"
#include "nsIContent.h"
#include "nsIDocShell.h"
#include "nsIDocCharset.h"
#include "nsIDocument.h"
#include "Crypto.h"
#include "nsIDOMDocument.h"
#include "nsIDOMElement.h"
#include "nsIDOMEvent.h"
#include "nsIDOMOfflineResourceList.h"
#include "nsDOMString.h"
#include "nsIEmbeddingSiteWindow.h"
#include "nsThreadUtils.h"
#include "nsILoadContext.h"
#include "nsIPresShell.h"
#include "nsIScrollableFrame.h"
#include "nsView.h"
#include "nsViewManager.h"
#include "nsISelectionController.h"
#include "nsISelection.h"
#include "nsIPrompt.h"
#include "nsIPromptService.h"
#include "nsIPromptFactory.h"
#include "nsIAddonPolicyService.h"
#include "nsIWritablePropertyBag2.h"
#include "nsIWebNavigation.h"
#include "nsIWebBrowserChrome.h"
#include "nsIWebBrowserFind.h" // For window.find()
#include "nsIWindowMediator.h" // For window.find()
#include "nsComputedDOMStyle.h"
#include "nsDOMCID.h"
#include "nsDOMWindowUtils.h"
#include "nsIWindowWatcher.h"
#include "nsPIWindowWatcher.h"
#include "nsIContentViewer.h"
#include "nsIScriptError.h"
#include "nsIControllers.h"
#include "nsIControllerContext.h"
#include "nsGlobalWindowCommands.h"
#include "nsQueryObject.h"
#include "nsContentUtils.h"
#include "nsCSSProps.h"
#include "nsIDOMFileList.h"
#include "nsIURIFixup.h"
#ifndef DEBUG
#include "nsIAppStartup.h"
#include "nsToolkitCompsCID.h"
#endif
#include "nsCDefaultURIFixup.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/EventStateManager.h"
#include "nsIObserverService.h"
#include "nsFocusManager.h"
#include "nsIXULWindow.h"
#include "nsITimedChannel.h"
#include "nsServiceManagerUtils.h"
#ifdef MOZ_XUL
#include "nsIDOMXULControlElement.h"
#include "nsMenuPopupFrame.h"
#endif
#include "mozilla/dom/CustomEvent.h"
#include "nsIJARChannel.h"
#include "nsIScreenManager.h"
#include "nsIEffectiveTLDService.h"
#include "xpcprivate.h"
#ifdef NS_PRINTING
#include "nsIPrintSettings.h"
#include "nsIPrintSettingsService.h"
#include "nsIWebBrowserPrint.h"
#endif
#include "nsWindowRoot.h"
#include "nsNetCID.h"
#include "nsIArray.h"
// XXX An unfortunate dependency exists here (two XUL files).
#include "nsIDOMXULDocument.h"
#include "nsIDOMXULCommandDispatcher.h"
#include "nsBindingManager.h"
#include "nsXBLService.h"
// used for popup blocking, needs to be converted to something
// belonging to the back-end like nsIContentPolicy
#include "nsIPopupWindowManager.h"
#include "nsIDragService.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/Selection.h"
#include "nsFrameLoader.h"
#include "nsISupportsPrimitives.h"
#include "nsXPCOMCID.h"
#include "mozilla/Logging.h"
#include "prenv.h"
#include "mozilla/dom/IDBFactory.h"
#include "mozilla/dom/MessageChannel.h"
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/Gamepad.h"
#include "mozilla/dom/GamepadManager.h"
#include "gfxVR.h"
#include "mozilla/dom/VRDisplay.h"
#include "mozilla/dom/VRDisplayEvent.h"
#include "mozilla/dom/VRDisplayEventBinding.h"
#include "mozilla/dom/VREventObserver.h"
#include "nsRefreshDriver.h"
#include "Layers.h"
#include "mozilla/AddonPathService.h"
#include "mozilla/BasePrincipal.h"
#include "mozilla/Services.h"
#include "mozilla/Telemetry.h"
#include "mozilla/dom/Location.h"
#include "nsHTMLDocument.h"
#include "nsWrapperCacheInlines.h"
#include "mozilla/DOMEventTargetHelper.h"
#include "prrng.h"
#include "nsSandboxFlags.h"
#include "TimeChangeObserver.h"
#include "mozilla/dom/AudioContext.h"
#include "mozilla/dom/BrowserElementDictionariesBinding.h"
#include "mozilla/dom/cache/CacheStorage.h"
#include "mozilla/dom/Console.h"
#include "mozilla/dom/Fetch.h"
#include "mozilla/dom/FunctionBinding.h"
#include "mozilla/dom/HashChangeEvent.h"
#include "mozilla/dom/IntlUtils.h"
#include "mozilla/dom/MozSelfSupportBinding.h"
#include "mozilla/dom/PopStateEvent.h"
#include "mozilla/dom/PopupBlockedEvent.h"
#include "mozilla/dom/PrimitiveConversions.h"
#include "mozilla/dom/WindowBinding.h"
#include "nsITabChild.h"
#include "mozilla/dom/MediaQueryList.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/dom/NavigatorBinding.h"
#include "mozilla/dom/ImageBitmap.h"
#include "mozilla/dom/ImageBitmapBinding.h"
#include "mozilla/dom/ServiceWorkerRegistration.h"
#include "mozilla/dom/U2F.h"
#include "mozilla/dom/WebIDLGlobalNameHash.h"
#include "mozilla/dom/Worklet.h"
#ifdef HAVE_SIDEBAR
#include "mozilla/dom/ExternalBinding.h"
#endif
#ifdef MOZ_WEBSPEECH
#include "mozilla/dom/SpeechSynthesis.h"
#endif
// Apple system headers seem to have a check() macro. <sigh>
#ifdef check
class nsIScriptTimeoutHandler;
#undef check
#endif // check
#include "AccessCheck.h"
#ifdef ANDROID
#include <android/log.h>
#endif
#ifdef XP_WIN
#include <process.h>
#define getpid _getpid
#else
#include <unistd.h> // for getpid()
#endif
static const char kStorageEnabled[] = "dom.storage.enabled";
using namespace mozilla;
using namespace mozilla::dom;
using namespace mozilla::dom::ipc;
using mozilla::BasePrincipal;
using mozilla::OriginAttributes;
using mozilla::TimeStamp;
using mozilla::TimeDuration;
using mozilla::dom::cache::CacheStorage;
static LazyLogModule gDOMLeakPRLog("DOMLeak");
static int32_t gRefCnt = 0;
static int32_t gOpenPopupSpamCount = 0;
static PopupControlState gPopupControlState = openAbused;
static bool gMouseDown = false;
static bool gDragServiceDisabled = false;
static FILE *gDumpFile = nullptr;
static uint32_t gSerialCounter = 0;
static bool gIdleObserversAPIFuzzTimeDisabled = false;
#ifdef DEBUG_jst
int32_t gTimeoutCnt = 0;
#endif
#if defined(DEBUG_bryner) || defined(DEBUG_chb)
#define DEBUG_PAGE_CACHE
#endif
#define DOM_TOUCH_LISTENER_ADDED "dom-touch-listener-added"
#define MEMORY_PRESSURE_OBSERVER_TOPIC "memory-pressure"
// The interval at which we execute idle callbacks
static uint32_t gThrottledIdlePeriodLength;
#define DEFAULT_THROTTLED_IDLE_PERIOD_LENGTH 10000
// CIDs
static NS_DEFINE_CID(kXULControllersCID, NS_XULCONTROLLERS_CID);
#define NETWORK_UPLOAD_EVENT_NAME NS_LITERAL_STRING("moznetworkupload")
#define NETWORK_DOWNLOAD_EVENT_NAME NS_LITERAL_STRING("moznetworkdownload")
namespace mozilla {
namespace dom {
extern uint64_t
NextWindowID();
} // namespace dom
} // namespace mozilla
template<class T>
nsPIDOMWindow<T>::nsPIDOMWindow(nsPIDOMWindowOuter *aOuterWindow)
: mFrameElement(nullptr), mDocShell(nullptr), mModalStateDepth(0),
mMutationBits(0), mActivePeerConnections(0), mIsDocumentLoaded(false),
mIsHandlingResizeEvent(false), mIsInnerWindow(aOuterWindow != nullptr),
mMayHavePaintEventListener(false), mMayHaveTouchEventListener(false),
mMayHaveSelectionChangeEventListener(false),
mMayHaveMouseEnterLeaveEventListener(false),
mMayHavePointerEnterLeaveEventListener(false),
mInnerObjectsFreed(false),
mIsActive(false), mIsBackground(false),
mMediaSuspend(
Preferences::GetBool("media.block-autoplay-until-in-foreground", true) &&
Preferences::GetBool("media.autoplay.enabled", true) ?
nsISuspendedTypes::SUSPENDED_BLOCK : nsISuspendedTypes::NONE_SUSPENDED),
mAudioMuted(false), mAudioVolume(1.0), mAudioCaptured(false),
mDesktopModeViewport(false), mIsRootOuterWindow(false), mInnerWindow(nullptr),
mOuterWindow(aOuterWindow),
// Make sure no actual window ends up with mWindowID == 0
mWindowID(NextWindowID()), mHasNotifiedGlobalCreated(false),
mMarkedCCGeneration(0), mServiceWorkersTestingEnabled(false),
mLargeAllocStatus(LargeAllocStatus::NONE),
mHasTriedToCacheTopInnerWindow(false),
mNumOfIndexedDBDatabases(0),
mNumOfOpenWebSockets(0)
{
if (aOuterWindow) {
mTimeoutManager =
MakeUnique<mozilla::dom::TimeoutManager>(*nsGlobalWindowInner::Cast(AsInner()));
}
}
template<class T>
nsPIDOMWindow<T>::~nsPIDOMWindow() {}
PopupControlState
PushPopupControlState(PopupControlState aState, bool aForce)
{
MOZ_ASSERT(NS_IsMainThread());
PopupControlState oldState = gPopupControlState;
if (aState < gPopupControlState || aForce) {
gPopupControlState = aState;
}
return oldState;
}
void
PopPopupControlState(PopupControlState aState)
{
MOZ_ASSERT(NS_IsMainThread());
gPopupControlState = aState;
}
// We need certain special behavior for remote XUL whitelisted domains, but we
// don't want that behavior to take effect in automation, because we whitelist
// all the mochitest domains. So we need to check a pref here.
static bool
TreatAsRemoteXUL(nsIPrincipal* aPrincipal)
{
MOZ_ASSERT(!nsContentUtils::IsSystemPrincipal(aPrincipal));
return nsContentUtils::AllowXULXBLForPrincipal(aPrincipal) &&
!Preferences::GetBool("dom.use_xbl_scopes_for_remote_xul", false);
}
static bool
EnablePrivilege(JSContext* cx, unsigned argc, JS::Value* vp)
{
Telemetry::Accumulate(Telemetry::ENABLE_PRIVILEGE_EVER_CALLED, true);
return xpc::EnableUniversalXPConnect(cx);
}
static const JSFunctionSpec EnablePrivilegeSpec[] = {
JS_FN("enablePrivilege", EnablePrivilege, 1, 0),
JS_FS_END
};
static bool
InitializeLegacyNetscapeObject(JSContext* aCx, JS::Handle<JSObject*> aGlobal)
{
JSAutoCompartment ac(aCx, aGlobal);
// Note: MathJax depends on window.netscape being exposed. See bug 791526.
JS::Rooted<JSObject*> obj(aCx);
obj = JS_DefineObject(aCx, aGlobal, "netscape", nullptr);
NS_ENSURE_TRUE(obj, false);
obj = JS_DefineObject(aCx, obj, "security", nullptr);
NS_ENSURE_TRUE(obj, false);
// We hide enablePrivilege behind a pref because it has been altered in a
// way that makes it fundamentally insecure to use in production. Mozilla
// uses this pref during automated testing to support legacy test code that
// uses enablePrivilege. If you're not doing test automation, you _must_ not
// flip this pref, or you will be exposing all your users to security
// vulnerabilities.
if (!xpc::IsInAutomation()) {
return true;
}
/* Define PrivilegeManager object with the necessary "static" methods. */
obj = JS_DefineObject(aCx, obj, "PrivilegeManager", nullptr);
NS_ENSURE_TRUE(obj, false);
return JS_DefineFunctions(aCx, obj, EnablePrivilegeSpec);
}
static JS::CompartmentCreationOptions&
SelectZoneGroup(nsGlobalWindowInner* aNewInner,
JS::CompartmentCreationOptions& aOptions)
{
JS::CompartmentCreationOptions options;
if (aNewInner->GetOuterWindow()) {
nsGlobalWindowOuter *top = aNewInner->GetTopInternal();
// If we have a top-level window, use its zone (and zone group).
if (top && top->GetGlobalJSObject()) {
return aOptions.setExistingZone(top->GetGlobalJSObject());
}
}
// If we're in the parent process, don't bother with zone groups.
if (XRE_IsParentProcess()) {
return aOptions.setNewZoneInSystemZoneGroup();
}
// Otherwise, find a zone group from the TabGroup. Typically we only have to
// go through one iteration of this loop.
RefPtr<TabGroup> tabGroup = aNewInner->TabGroup();
for (nsPIDOMWindowOuter* outer : tabGroup->GetWindows()) {
nsGlobalWindowOuter* window = nsGlobalWindowOuter::Cast(outer);
if (JSObject* global = window->GetGlobalJSObject()) {
return aOptions.setNewZoneInExistingZoneGroup(global);
}
}
return aOptions.setNewZoneInNewZoneGroup();
}
/**
* Create a new global object that will be used for an inner window.
* Return the native global and an nsISupports 'holder' that can be used
* to manage the lifetime of it.
*/
static nsresult
CreateNativeGlobalForInner(JSContext* aCx,
nsGlobalWindowInner* aNewInner,
nsIURI* aURI,
nsIPrincipal* aPrincipal,
JS::MutableHandle<JSObject*> aGlobal,
bool aIsSecureContext)
{
MOZ_ASSERT(aCx);
MOZ_ASSERT(aNewInner);
MOZ_ASSERT(aNewInner->IsInnerWindow());
MOZ_ASSERT(aPrincipal);
// DOMWindow with nsEP is not supported, we have to make sure
// no one creates one accidentally.
nsCOMPtr<nsIExpandedPrincipal> nsEP = do_QueryInterface(aPrincipal);
MOZ_RELEASE_ASSERT(!nsEP, "DOMWindow with nsEP is not supported");
JS::CompartmentOptions options;
SelectZoneGroup(aNewInner, options.creationOptions());
// Sometimes add-ons load their own XUL windows, either as separate top-level
// windows or inside a browser element. In such cases we want to tag the
// window's compartment with the add-on ID. See bug 1092156.
if (nsContentUtils::IsSystemPrincipal(aPrincipal)) {
options.creationOptions().setAddonId(MapURIToAddonID(aURI));
}
options.creationOptions().setSecureContext(aIsSecureContext);
xpc::InitGlobalObjectOptions(options, aPrincipal);
// Determine if we need the Components object.
bool needComponents = nsContentUtils::IsSystemPrincipal(aPrincipal) ||
TreatAsRemoteXUL(aPrincipal);
uint32_t flags = needComponents ? 0 : xpc::OMIT_COMPONENTS_OBJECT;
flags |= xpc::DONT_FIRE_ONNEWGLOBALHOOK;
if (!WindowBinding::Wrap(aCx, aNewInner, aNewInner, options,
nsJSPrincipals::get(aPrincipal), false, aGlobal) ||
!xpc::InitGlobalObject(aCx, aGlobal, flags)) {
return NS_ERROR_FAILURE;
}
MOZ_ASSERT(aNewInner->GetWrapperPreserveColor() == aGlobal);
// Set the location information for the new global, so that tools like
// about:memory may use that information
xpc::SetLocationForGlobal(aGlobal, aURI);
if (!InitializeLegacyNetscapeObject(aCx, aGlobal)) {
return NS_ERROR_FAILURE;
}
return NS_OK;
}
static
already_AddRefed<EventTarget>
TryGetTabChildGlobalAsEventTarget(nsISupports *aFrom)
{
nsCOMPtr<nsIFrameLoaderOwner> frameLoaderOwner = do_QueryInterface(aFrom);
if (!frameLoaderOwner) {
return nullptr;
}
RefPtr<nsFrameLoader> frameLoader = frameLoaderOwner->GetFrameLoader();
if (!frameLoader) {
return nullptr;
}
nsCOMPtr<EventTarget> target = frameLoader->GetTabChildGlobalAsEventTarget();
return target.forget();
}
template <class T>
nsIURI*
nsPIDOMWindow<T>::GetDocumentURI() const
{
return mDoc ? mDoc->GetDocumentURI() : mDocumentURI.get();
}
template <class T>
nsIURI*
nsPIDOMWindow<T>::GetDocBaseURI() const
{
return mDoc ? mDoc->GetDocBaseURI() : mDocBaseURI.get();
}
template <class T>
void
nsPIDOMWindow<T>::MaybeCreateDoc()
{
MOZ_ASSERT(!mDoc);
if (nsIDocShell* docShell = GetDocShell()) {
// Note that |document| here is the same thing as our mDoc, but we
// don't have to explicitly set the member variable because the docshell
// has already called SetNewDocument().
nsCOMPtr<nsIDocument> document = docShell->GetDocument();
Unused << document;
}
}
// Try to match compartments that are not web content by matching compartments
// with principals that are either the system principal or an expanded principal.
// This may not return true for all non-web-content compartments.
struct BrowserCompartmentMatcher : public js::CompartmentFilter {
bool match(JSCompartment* aC) const override
{
nsCOMPtr<nsIPrincipal> pc = nsJSPrincipals::get(JS_GetCompartmentPrincipals(aC));
return nsContentUtils::IsSystemOrExpandedPrincipal(pc);
}
};
class WindowDestroyedEvent final : public Runnable
{
public:
WindowDestroyedEvent(nsGlobalWindowInner* aWindow, uint64_t aID, const char* aTopic)
: mozilla::Runnable("WindowDestroyedEvent")
, mID(aID)
, mPhase(Phase::Destroying)
, mTopic(aTopic)
, mIsInnerWindow(true)
{
mWindow = do_GetWeakReference(aWindow);
}
WindowDestroyedEvent(nsGlobalWindowOuter* aWindow, uint64_t aID, const char* aTopic)
: mozilla::Runnable("WindowDestroyedEvent")
, mID(aID)
, mPhase(Phase::Destroying)
, mTopic(aTopic)
, mIsInnerWindow(false)
{
mWindow = do_GetWeakReference(aWindow);
}
enum class Phase
{
Destroying,
Nuking
};
NS_IMETHOD Run() override
{
AUTO_PROFILER_LABEL("WindowDestroyedEvent::Run", OTHER);
nsCOMPtr<nsIObserverService> observerService =
services::GetObserverService();
if (!observerService) {
return NS_OK;
}
nsCOMPtr<nsISupportsPRUint64> wrapper =
do_CreateInstance(NS_SUPPORTS_PRUINT64_CONTRACTID);
if (wrapper) {
wrapper->SetData(mID);
observerService->NotifyObservers(wrapper, mTopic.get(), nullptr);
}
switch (mPhase) {
case Phase::Destroying:
{
bool skipNukeCrossCompartment = false;
#ifndef DEBUG
nsCOMPtr<nsIAppStartup> appStartup =
do_GetService(NS_APPSTARTUP_CONTRACTID);
if (appStartup) {
appStartup->GetShuttingDown(&skipNukeCrossCompartment);
}
#endif
if (!skipNukeCrossCompartment) {
// The compartment nuking phase might be too expensive, so do that
// part off of idle dispatch.
// For the compartment nuking phase, we dispatch either an
// inner-window-nuked or an outer-window-nuked notification.
// This will allow tests to wait for compartment nuking to happen.
if (mTopic.EqualsLiteral("inner-window-destroyed")) {
mTopic.AssignLiteral("inner-window-nuked");
} else if (mTopic.EqualsLiteral("outer-window-destroyed")) {
mTopic.AssignLiteral("outer-window-nuked");
}
mPhase = Phase::Nuking;
nsCOMPtr<nsIRunnable> copy(this);
NS_IdleDispatchToCurrentThread(copy.forget(), 1000);
}
}
break;
case Phase::Nuking:
{
nsCOMPtr<nsISupports> window = do_QueryReferent(mWindow);
if (window) {
nsGlobalWindowInner* currentInner;
if (mIsInnerWindow) {
currentInner = nsGlobalWindowInner::FromSupports(window);
} else {
nsGlobalWindowOuter* outer = nsGlobalWindowOuter::FromSupports(window);
currentInner = outer->GetCurrentInnerWindowInternal();
}
NS_ENSURE_TRUE(currentInner, NS_OK);
AutoSafeJSContext cx;
JS::Rooted<JSObject*> obj(cx, currentInner->FastGetGlobalJSObject());
if (obj && !js::IsSystemCompartment(js::GetObjectCompartment(obj))) {
JSCompartment* cpt = js::GetObjectCompartment(obj);
nsCOMPtr<nsIPrincipal> pc = nsJSPrincipals::get(JS_GetCompartmentPrincipals(cpt));
if (BasePrincipal::Cast(pc)->AddonPolicy()) {
// We want to nuke all references to the add-on compartment.
xpc::NukeAllWrappersForCompartment(cx, cpt,
mIsInnerWindow ? js::DontNukeWindowReferences
: js::NukeWindowReferences);
} else {
// We only want to nuke wrappers for the chrome->content case
js::NukeCrossCompartmentWrappers(cx, BrowserCompartmentMatcher(), cpt,
mIsInnerWindow ? js::DontNukeWindowReferences
: js::NukeWindowReferences,
js::NukeIncomingReferences);
}
}
}
}
break;
}
return NS_OK;
}
private:
uint64_t mID;
Phase mPhase;
nsCString mTopic;
nsWeakPtr mWindow;
bool mIsInnerWindow;
};
class ChildCommandDispatcher : public Runnable
{
public:
ChildCommandDispatcher(nsPIWindowRoot* aRoot,
nsITabChild* aTabChild,
const nsAString& aAction)
: mozilla::Runnable("ChildCommandDispatcher")
, mRoot(aRoot)
, mTabChild(aTabChild)
, mAction(aAction)
{
}
NS_IMETHOD Run() override
{
nsTArray<nsCString> enabledCommands, disabledCommands;
mRoot->GetEnabledDisabledCommands(enabledCommands, disabledCommands);
if (enabledCommands.Length() || disabledCommands.Length()) {
mTabChild->EnableDisableCommands(mAction, enabledCommands, disabledCommands);
}
return NS_OK;
}
private:
nsCOMPtr<nsPIWindowRoot> mRoot;
nsCOMPtr<nsITabChild> mTabChild;
nsString mAction;
};
class CommandDispatcher : public Runnable
{
public:
CommandDispatcher(nsIDOMXULCommandDispatcher* aDispatcher,
const nsAString& aAction)
: mozilla::Runnable("CommandDispatcher")
, mDispatcher(aDispatcher)
, mAction(aAction)
{
}
NS_IMETHOD Run() override
{
return mDispatcher->UpdateCommands(mAction);
}
nsCOMPtr<nsIDOMXULCommandDispatcher> mDispatcher;
nsString mAction;
};
static bool IsLink(nsIContent* aContent)
{
return aContent && (aContent->IsHTMLElement(nsGkAtoms::a) ||
aContent->AttrValueIs(kNameSpaceID_XLink, nsGkAtoms::type,
nsGkAtoms::simple, eCaseMatters));
}
static bool ShouldShowFocusRingIfFocusedByMouse(nsIContent* aNode)
{
if (!aNode) {
return true;
}
return !IsLink(aNode) &&
!aNode->IsAnyOfHTMLElements(nsGkAtoms::video, nsGkAtoms::audio);
}
static bool
IsInterval(const Optional<int32_t>& aTimeout, int32_t& aResultTimeout)
{
if (aTimeout.WasPassed()) {
aResultTimeout = aTimeout.Value();
return true;
}
// If no interval was specified, treat this like a timeout, to avoid setting
// an interval of 0 milliseconds.
aResultTimeout = 0;
return false;
}
template<typename T>
mozilla::dom::DocGroup*
nsPIDOMWindow<T>::GetDocGroup() const
{
nsIDocument* doc = GetExtantDoc();
if (doc) {
return doc->GetDocGroup();
}
return nullptr;
}
static void
EnsurePrefCaches()
{
static bool sFirstTime = true;
if (sFirstTime) {
TimeoutManager::Initialize();
Preferences::AddBoolVarCache(&gIdleObserversAPIFuzzTimeDisabled,
"dom.idle-observers-api.fuzz_time.disabled",
false);
Preferences::AddUintVarCache(&gThrottledIdlePeriodLength,
"dom.idle_period.throttled_length",
DEFAULT_THROTTLED_IDLE_PERIOD_LENGTH);
sFirstTime = false;
}
}
// Include the implementations for the inner and outer windows respectively.
#include "nsGlobalWindowOuter.cpp"
#include "nsGlobalWindowInner.cpp"
template class nsPIDOMWindow<mozIDOMWindowProxy>;
template class nsPIDOMWindow<mozIDOMWindow>;

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

@ -7,24 +7,6 @@
#ifndef nsGlobalWindow_h___
#define nsGlobalWindow_h___
// XXX(nika): Figure out where to put this?
#define DEFAULT_HOME_PAGE "www.mozilla.org"
#define PREF_BROWSER_STARTUP_HOMEPAGE "browser.startup.homepage"
// Amount of time allowed between alert/prompt/confirm before enabling
// the stop dialog checkbox.
#define DEFAULT_SUCCESSIVE_DIALOG_TIME_LIMIT 3 // 3 sec
// Maximum number of successive dialogs before we prompt users to disable
// dialogs for this window.
#define MAX_SUCCESSIVE_DIALOG_COUNT 5
// Idle fuzz time upper limit
#define MAX_IDLE_FUZZ_TIME_MS 90000
// Min idle notification time in seconds.
#define MIN_IDLE_NOTIFICATION_TIME_S 1
// NOTE: This is so that I can rewrite the includes in a separate patch.
// Specificially I don't think I want to change this until I've moved everything
// to mozilla/dom/Window.h and mozilla/dom/WindowProxy.h.

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

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

@ -192,27 +192,17 @@ ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
CycleCollectionNoteChild(aCallback, aField.mIdleObserver.get(), aName, aFlags);
}
// NOTE: Currently this file, despite being named mozilla/dom/Window.h, exports
// the class nsGlobalWindowInner. It will be renamed in the future to
// mozilla::dom::Window.
//*****************************************************************************
// nsGlobalWindow: Global Object for Scripting
// nsGlobalWindowInner: Global Object for Scripting
//*****************************************************************************
// Beware that all scriptable interfaces implemented by
// nsGlobalWindow will be reachable from JS, if you make this class
// implement new interfaces you better know what you're
// doing. Security wise this is very sensitive code. --
// jst@netscape.com
// nsGlobalWindow inherits PRCList for maintaining a list of all inner
// windows still in memory for any given outer window. This list is
// needed to ensure that mOuterWindow doesn't end up dangling. The
// nature of PRCList means that the window itself is always in the
// list, and an outer window's list will also contain all inner window
// objects that are still in memory (and in reality all inner window
// object's lists also contain its outer and all other inner windows
// belonging to the same outer window, but that's an unimportant
// nsGlobalWindowInner inherits PRCList for maintaining a list of all inner
// windows still in memory for any given outer window. This list is needed to
// ensure that mOuterWindow doesn't end up dangling. The nature of PRCList means
// that the window itself is always in the list, and an outer window's list will
// also contain all inner window objects that are still in memory (and in
// reality all inner window object's lists also contain its outer and all other
// inner windows belonging to the same outer window, but that's an unimportant
// side effect of inheriting PRCList).
class nsGlobalWindowInner : public mozilla::dom::EventTarget,
@ -262,8 +252,6 @@ public:
nsGlobalWindowInner* innerWindow =
sInnerWindowsById->Get(aInnerWindowID);
MOZ_ASSERT(!innerWindow || innerWindow->IsInnerWindow(),
"Outer window in sInnerWindowsById?");
return innerWindow;
}
@ -291,7 +279,7 @@ public:
// nsWrapperCache
virtual JSObject *WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override
{
return IsInnerWindow() || AsOuter()->EnsureInnerWindow() ? GetWrapper() : nullptr;
return GetWrapper();
}
// nsIGlobalJSObjectHolder
@ -348,22 +336,10 @@ public:
virtual nsPIDOMWindowOuter* GetPrivateRoot() override;
// Outer windows only.
virtual void ActivateOrDeactivate(bool aActivate) override;
virtual void SetActive(bool aActive) override;
virtual bool IsTopLevelWindowActive() override;
virtual void SetIsBackground(bool aIsBackground) override;
virtual void SetChromeEventHandler(mozilla::dom::EventTarget* aChromeEventHandler) override;
// Outer windows only.
virtual void SetInitialPrincipalToSubject() override;
virtual PopupControlState PushPopupControlState(PopupControlState state, bool aForce) const override;
virtual void PopPopupControlState(PopupControlState state) const override;
virtual PopupControlState GetPopupControlState() const override;
virtual already_AddRefed<nsISupports> SaveWindowState() override;
virtual nsresult RestoreWindowState(nsISupports *aState) override;
void Suspend();
void Resume();
virtual bool IsSuspended() const override;
@ -383,33 +359,14 @@ public:
virtual void SetOpenerWindow(nsPIDOMWindowOuter* aOpener,
bool aOriginalOpener) override;
// Outer windows only.
virtual void EnsureSizeAndPositionUpToDate() override;
virtual void EnterModalState() override;
virtual void LeaveModalState() override;
// Outer windows only.
virtual bool CanClose() override;
virtual void ForceClose() override;
virtual void MaybeUpdateTouchState() override;
// Outer windows only.
virtual bool DispatchCustomEvent(const nsAString& aEventName) override;
// Inner windows only.
void RefreshCompartmentPrincipal();
// For accessing protected field mFullScreen
friend class FullscreenTransitionTask;
// Outer windows only.
virtual nsresult SetFullscreenInternal(
FullscreenReason aReason, bool aIsFullscreen) override final;
virtual void FullscreenWillChange(bool aIsFullscreen) override final;
virtual void FinishFullscreenChange(bool aIsFullscreen) override final;
// Inner windows only.
virtual void SetHasGamepadEventListener(bool aHasGamepad = true) override;
void NotifyVREventListenerAdded();
@ -444,7 +401,6 @@ public:
void GetOwnPropertyNames(JSContext* aCx, JS::AutoIdVector& aNames,
bool aEnumerableOnly, mozilla::ErrorResult& aRv);
already_AddRefed<nsPIDOMWindowOuter> GetTop() override;
nsPIDOMWindowOuter* GetScriptableTop() override;
inline nsGlobalWindowOuter *GetTopInternal();
@ -475,11 +431,6 @@ public:
nsGlobalWindowOuter *GetOuterWindowInternal() const;
bool IsCreatingInnerWindow() const
{
return mCreatingInnerWindow;
}
bool IsChromeWindow() const
{
return mIsChrome;
@ -538,13 +489,8 @@ public:
virtual void EnableTimeChangeNotifications() override;
virtual void DisableTimeChangeNotifications() override;
virtual nsresult SetArguments(nsIArray* aArguments) override;
bool IsClosedOrClosing() {
return (mIsClosed ||
mInClose ||
mHavePendingClose ||
mCleanedUp);
return mCleanedUp;
}
bool
@ -553,12 +499,6 @@ public:
return mCleanedUp;
}
virtual void
FirePopupBlockedEvent(nsIDocument* aDoc,
nsIURI* aPopupURI,
const nsAString& aPopupWindowName,
const nsAString& aPopupWindowFeatures) override;
virtual uint32_t GetSerial() override {
return mSerial;
}
@ -575,11 +515,6 @@ public:
bool ContainsIdleObserver(nsIIdleObserver* aIdleObserver, uint32_t timeInS);
void HandleIdleObserverCallback();
void AllowScriptsToClose()
{
mAllowScriptsToClose = true;
}
enum SlowScriptResponse {
ContinueSlowScript = 0,
ContinueSlowScriptAndKeepNotifying,
@ -707,7 +642,6 @@ public:
void Close(mozilla::ErrorResult& aError);
nsresult Close() override;
bool GetClosed(mozilla::ErrorResult& aError);
bool Closed() override;
void Stop(mozilla::ErrorResult& aError);
void Focus(mozilla::ErrorResult& aError);
nsresult Focus() override;
@ -716,8 +650,6 @@ public:
already_AddRefed<nsPIDOMWindowOuter> GetFrames(mozilla::ErrorResult& aError);
uint32_t Length();
already_AddRefed<nsPIDOMWindowOuter> GetTop(mozilla::ErrorResult& aError);
nsresult GetPrompter(nsIPrompt** aPrompt) override;
protected:
explicit nsGlobalWindowInner(nsGlobalWindowOuter *aOuterWindow);
// Initializes the mWasOffline member variable
@ -726,11 +658,9 @@ public:
nsPIDOMWindowOuter* GetOpenerWindow(mozilla::ErrorResult& aError);
void GetOpener(JSContext* aCx, JS::MutableHandle<JS::Value> aRetval,
mozilla::ErrorResult& aError);
already_AddRefed<nsPIDOMWindowOuter> GetOpener() override;
void SetOpener(JSContext* aCx, JS::Handle<JS::Value> aOpener,
mozilla::ErrorResult& aError);
already_AddRefed<nsPIDOMWindowOuter> GetParent(mozilla::ErrorResult& aError);
already_AddRefed<nsPIDOMWindowOuter> GetParent() override;
nsPIDOMWindowOuter* GetScriptableParent() override;
nsPIDOMWindowOuter* GetScriptableParentOrNull() override;
mozilla::dom::Element*
@ -742,11 +672,6 @@ public:
const nsAString& aName,
const nsAString& aOptions,
mozilla::ErrorResult& aError);
nsresult Open(const nsAString& aUrl, const nsAString& aName,
const nsAString& aOptions,
nsIDocShellLoadInfo* aLoadInfo,
bool aForceNoOpener,
nsPIDOMWindowOuter **_retval) override;
mozilla::dom::Navigator* Navigator();
nsIDOMNavigator* GetNavigator() override;
nsIDOMOfflineResourceList* GetApplicationCache(mozilla::ErrorResult& aError);
@ -836,7 +761,6 @@ public:
mozilla::dom::Storage*
GetLocalStorage(mozilla::ErrorResult& aError);
mozilla::dom::Selection* GetSelection(mozilla::ErrorResult& aError);
already_AddRefed<nsISelection> GetSelection() override;
mozilla::dom::IDBFactory* GetIndexedDB(mozilla::ErrorResult& aError);
already_AddRefed<nsICSSDeclaration>
GetComputedStyle(mozilla::dom::Element& aElt, const nsAString& aPseudoElt,
@ -853,7 +777,6 @@ public:
void MoveBy(int32_t aXDif, int32_t aYDif,
mozilla::dom::CallerType aCallerType,
mozilla::ErrorResult& aError);
nsresult MoveBy(int32_t aXDif, int32_t aYDif) override;
void ResizeTo(int32_t aWidth, int32_t aHeight,
mozilla::dom::CallerType aCallerType,
mozilla::ErrorResult& aError);
@ -956,7 +879,6 @@ public:
bool GetFullScreen(mozilla::ErrorResult& aError);
bool GetFullScreen() override;
void SetFullScreen(bool aFullScreen, mozilla::ErrorResult& aError);
nsresult SetFullScreen(bool aFullScreen) override;
void Back(mozilla::ErrorResult& aError);
void Forward(mozilla::ErrorResult& aError);
void Home(nsIPrincipal& aSubjectPrincipal, mozilla::ErrorResult& aError);
@ -976,10 +898,6 @@ public:
const nsAString& aOptions,
const mozilla::dom::Sequence<JS::Value>& aExtraArgument,
mozilla::ErrorResult& aError);
nsresult OpenDialog(const nsAString& aUrl, const nsAString& aName,
const nsAString& aOptions,
nsISupports* aExtraArgument,
nsPIDOMWindowOuter** _retval) override;
nsresult UpdateCommands(const nsAString& anAction, nsISelection* aSel, int16_t aReason) override;
void GetContent(JSContext* aCx,
@ -1157,9 +1075,6 @@ protected:
// Object Management
virtual ~nsGlobalWindowInner();
void CleanUp();
void ClearControllers();
inline void MaybeClearInnerWindow(nsGlobalWindowInner* aExpectedInner);
void FreeInnerObjects();
nsGlobalWindowInner *CallerInnerWindow();
@ -1181,16 +1096,6 @@ public:
// popup tracking
bool IsPopupSpamWindow();
protected:
// Window Control Functions
// Outer windows only.
virtual nsresult
OpenNoNavigate(const nsAString& aUrl,
const nsAString& aName,
const nsAString& aOptions,
nsPIDOMWindowOuter** _retval) override;
private:
template<typename Method>
void CallOnChildren(Method aMethod);
@ -1256,9 +1161,6 @@ public:
virtual bool ShouldShowFocusRing() override;
virtual void SetKeyboardIndicators(UIStateChangeType aShowAccelerators,
UIStateChangeType aShowFocusRings) override;
// Inner windows only.
void UpdateCanvasFocus(bool aFocusChanged, nsIContent* aNewContent);
@ -1310,10 +1212,7 @@ private:
void DisconnectEventTargetObjects();
// nsPIDOMWindow<T> should be able to see these helper methods.
friend class nsPIDOMWindow<mozIDOMWindowProxy>;
friend class nsPIDOMWindow<mozIDOMWindow>;
friend class nsPIDOMWindow<nsISupports>;
// nsPIDOMWindow{Inner,Outer} should be able to see these helper methods.
friend class nsPIDOMWindowInner;
friend class nsPIDOMWindowOuter;
@ -1360,23 +1259,7 @@ public:
void RemoveIdleCallback(mozilla::dom::IdleRequest* aRequest);
protected:
// These members are only used on outer window objects. Make sure
// you never set any of these on an inner object!
bool mFullScreen : 1;
bool mFullscreenMode : 1;
bool mIsClosed : 1;
bool mInClose : 1;
// mHavePendingClose means we've got a termination function set to
// close us when the JS stops executing or that we have a close
// event posted. If this is set, just ignore window.close() calls.
bool mHavePendingClose : 1;
bool mHadOriginalOpener : 1;
bool mOriginalOpenerWasSecureContext : 1;
bool mIsSecureContextIfOpenerIgnored : 1;
bool mIsPopupSpam : 1;
// Indicates whether scripts are allowed to close this window.
bool mBlockScriptedClosingFlag : 1;
// Window offline status. Checked to see if we need to fire offline event
bool mWasOffline : 1;
@ -1390,10 +1273,6 @@ protected:
bool mNotifyIdleObserversIdleOnThaw : 1;
bool mNotifyIdleObserversActiveOnThaw : 1;
// Indicates whether we're in the middle of creating an initializing
// a new inner window object.
bool mCreatingInnerWindow : 1;
// Fast way to tell if this is a chrome window (without having to QI).
bool mIsChrome : 1;
@ -1415,53 +1294,29 @@ protected:
// should be displayed.
bool mFocusByKeyOccurred : 1;
// Inner windows only.
// Indicates whether this window wants gamepad input events
bool mHasGamepad : 1;
// Inner windows only.
// Indicates whether this window wants VR events
bool mHasVREvents : 1;
// Inner windows only.
// Indicates whether this window wants VRDisplayActivate events
bool mHasVRDisplayActivateEvents : 1;
nsCheapSet<nsUint32HashKey> mGamepadIndexSet;
nsRefPtrHashtable<nsUint32HashKey, mozilla::dom::Gamepad> mGamepads;
bool mHasSeenGamepadInput;
// whether we've sent the destroy notification for our window id
bool mNotifiedIDDestroyed : 1;
// whether scripts may close the window,
// even if "dom.allow_scripts_to_close_windows" is false.
bool mAllowScriptsToClose : 1;
bool mTopLevelOuterContentWindow : 1;
nsCOMPtr<nsIScriptContext> mContext;
nsWeakPtr mOpener;
nsCOMPtr<nsIControllers> mControllers;
// For |window.arguments|, via |openDialog|.
nsCOMPtr<nsIArray> mArguments;
// Only used in the outer.
RefPtr<DialogValueHolder> mReturnValue;
RefPtr<mozilla::dom::Navigator> mNavigator;
RefPtr<nsScreen> mScreen;
RefPtr<nsDOMWindowList> mFrames;
// All BarProps are inner window only.
RefPtr<mozilla::dom::BarProp> mMenubar;
RefPtr<mozilla::dom::BarProp> mToolbar;
RefPtr<mozilla::dom::BarProp> mLocationbar;
RefPtr<mozilla::dom::BarProp> mPersonalbar;
RefPtr<mozilla::dom::BarProp> mStatusbar;
RefPtr<mozilla::dom::BarProp> mScrollbars;
RefPtr<nsDOMWindowUtils> mWindowUtils;
nsString mStatus;
nsString mDefaultStatus;
RefPtr<nsGlobalWindowObserver> mObserver; // Inner windows only.
RefPtr<nsGlobalWindowObserver> mObserver;
RefPtr<mozilla::dom::Crypto> mCrypto;
RefPtr<mozilla::dom::U2F> mU2F;
RefPtr<mozilla::dom::cache::CacheStorage> mCacheStorage;
@ -1479,13 +1334,11 @@ protected:
RefPtr<mozilla::dom::Storage> mLocalStorage;
RefPtr<mozilla::dom::Storage> mSessionStorage;
// These member variable are used only on inner windows.
RefPtr<mozilla::EventListenerManager> mListenerManager;
RefPtr<mozilla::dom::Location> mLocation;
RefPtr<nsHistory> mHistory;
RefPtr<mozilla::dom::CustomElementRegistry> mCustomElements;
// These member variables are used on both inner and the outer windows.
nsCOMPtr<nsIPrincipal> mDocumentPrincipal;
// mTabChild is only ever populated in the content process.
nsCOMPtr<nsITabChild> mTabChild;
@ -1504,7 +1357,6 @@ protected:
RefPtr<IdleRequestExecutor> mIdleRequestExecutor;
#ifdef DEBUG
bool mSetOpenerWindowCalled;
nsCOMPtr<nsIURI> mLastOpenedURI;
#endif
@ -1515,14 +1367,6 @@ protected:
using XBLPrototypeHandlerTable = nsJSThingHashtable<nsPtrHashKey<nsXBLPrototypeHandler>, JSObject*>;
mozilla::UniquePtr<XBLPrototypeHandlerTable> mCachedXBLPrototypeHandlers;
// mSuspendedDoc is only set on outer windows. It's useful when we get matched
// EnterModalState/LeaveModalState calls, in which case the outer window is
// responsible for unsuspending events on the document. If we don't (for
// example, if the outer window is closed before the LeaveModalState call),
// then the inner window whose mDoc is our mSuspendedDoc is responsible for
// unsuspending it.
nsCOMPtr<nsIDocument> mSuspendedDoc;
RefPtr<mozilla::dom::IDBFactory> mIndexedDB;
// This counts the number of windows that have been opened in rapid succession
@ -1550,16 +1394,9 @@ protected:
#endif
#ifdef MOZ_WEBSPEECH
// mSpeechSynthesis is only used on inner windows.
RefPtr<mozilla::dom::SpeechSynthesis> mSpeechSynthesis;
#endif
#ifdef DEBUG
// This member is used in the debug only assertions in TabGroup()
// to catch cyclic parent/opener trees and not overflow the stack.
bool mIsValidatingTabGroup;
#endif
// This is the CC generation the last time we called CanSkip.
uint32_t mCanSkipCCGeneration;
@ -1568,11 +1405,7 @@ protected:
RefPtr<mozilla::dom::VREventObserver> mVREventObserver;
// When non-zero, the document should receive a vrdisplayactivate event
// after loading. The value is the ID of the VRDisplay that content should
// begin presentation on.
uint32_t mAutoActivateVRDisplayID; // Outer windows only
int64_t mBeforeUnloadListenerCount; // Inner windows only
int64_t mBeforeUnloadListenerCount;
RefPtr<mozilla::dom::IntlUtils> mIntlUtils;
@ -1587,16 +1420,15 @@ protected:
: mGroupMessageManagers(1)
{}
nsCOMPtr<nsIBrowserDOMWindow> mBrowserDOMWindow;
nsCOMPtr<nsIMessageBroadcaster> mMessageManager;
nsInterfaceHashtable<nsStringHashKey, nsIMessageBroadcaster> mGroupMessageManagers;
// A weak pointer to the nsPresShell that we are doing fullscreen for.
// The pointer being set indicates we've set the IsInFullscreenChange
// flag on this pres shell.
nsWeakPtr mFullscreenPresShell;
nsCOMPtr<mozIDOMWindowProxy> mOpenerForInitialContentBrowser;
} mChromeFields;
// These fields are used by the inner and outer windows to prevent
// programatically moving the window while the mouse is down.
static bool sMouseDown;
static bool sDragServiceDisabled;
friend class nsDOMScriptableHelper;
friend class nsDOMWindowUtils;
friend class mozilla::dom::PostMessageEvent;
@ -1652,7 +1484,7 @@ nsGlobalWindowInner::GetContextInternal()
return GetOuterWindowInternal()->mContext;
}
return mContext;
return nullptr;
}
inline nsGlobalWindowOuter*
@ -1664,7 +1496,7 @@ nsGlobalWindowInner::GetOuterWindowInternal() const
inline bool
nsGlobalWindowInner::IsPopupSpamWindow()
{
if (IsInnerWindow() && !mOuterWindow) {
if (!mOuterWindow) {
return false;
}
@ -1677,12 +1509,4 @@ nsGlobalWindowInner::IsFrame()
return GetParentInternal() != nullptr;
}
inline void
nsGlobalWindowInner::MaybeClearInnerWindow(nsGlobalWindowInner* aExpectedInner)
{
if(mInnerWindow == aExpectedInner->AsInner()) {
mInnerWindow = nullptr;
}
}
#endif /* nsGlobalWindowInner_h___ */

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

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

@ -46,7 +46,6 @@
#include "mozilla/Attributes.h"
#include "mozilla/GuardObjects.h"
#include "mozilla/LinkedList.h"
#include "mozilla/TimeStamp.h"
#include "nsWrapperCacheInlines.h"
#include "nsIIdleObserver.h"
#include "nsIDocument.h"
@ -151,59 +150,17 @@ NS_CreateJSTimeoutHandler(JSContext* aCx, nsGlobalWindowInner *aWindow,
extern const js::Class OuterWindowProxyClass;
// Helper class to manage modal dialog arguments and all their quirks.
//
// Given our clunky embedding APIs, modal dialog arguments need to be passed
// as an nsISupports parameter to WindowWatcher, get stuck inside an array of
// length 1, and then passed back to the newly-created dialog.
//
// However, we need to track both the caller-passed value as well as the
// caller's, so that we can do an origin check (even for primitives) when the
// value is accessed. This class encapsulates that magic.
//
// We also use the same machinery for |returnValue|, which needs similar origin
// checks.
class DialogValueHolder final : public nsISupports
{
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS(DialogValueHolder)
DialogValueHolder(nsIPrincipal* aSubject, nsIVariant* aValue)
: mOrigin(aSubject)
, mValue(aValue) {}
nsresult Get(nsIPrincipal* aSubject, nsIVariant** aResult);
void Get(JSContext* aCx, JS::Handle<JSObject*> aScope, nsIPrincipal* aSubject,
JS::MutableHandle<JS::Value> aResult, mozilla::ErrorResult& aError);
private:
virtual ~DialogValueHolder() {}
nsCOMPtr<nsIPrincipal> mOrigin;
nsCOMPtr<nsIVariant> mValue;
};
// NOTE: Currently this file, despite being named mozilla/dom/WindowProxy.h,
// exports the class nsGlobalWindowOuter. It will be renamed in the future to
// mozilla::dom::WindowProxy.
//*****************************************************************************
// nsGlobalWindow: Global Object for Scripting
// nsGlobalWindowOuter
//*****************************************************************************
// Beware that all scriptable interfaces implemented by
// nsGlobalWindow will be reachable from JS, if you make this class
// implement new interfaces you better know what you're
// doing. Security wise this is very sensitive code. --
// jst@netscape.com
// nsGlobalWindow inherits PRCList for maintaining a list of all inner
// windows still in memory for any given outer window. This list is
// needed to ensure that mOuterWindow doesn't end up dangling. The
// nature of PRCList means that the window itself is always in the
// list, and an outer window's list will also contain all inner window
// objects that are still in memory (and in reality all inner window
// object's lists also contain its outer and all other inner windows
// belonging to the same outer window, but that's an unimportant
// nsGlobalWindowOuter inherits PRCList for maintaining a list of all inner
// windows still in memory for any given outer window. This list is needed to
// ensure that mOuterWindow doesn't end up dangling. The nature of PRCList means
// that the window itself is always in the list, and an outer window's list will
// also contain all inner window objects that are still in memory (and in
// reality all inner window object's lists also contain its outer and all other
// inner windows belonging to the same outer window, but that's an unimportant
// side effect of inheriting PRCList).
class nsGlobalWindowOuter : public mozilla::dom::EventTarget,
@ -219,9 +176,6 @@ class nsGlobalWindowOuter : public mozilla::dom::EventTarget,
public PRCListStr
{
public:
typedef mozilla::TimeStamp TimeStamp;
typedef mozilla::TimeDuration TimeDuration;
typedef nsDataHashtable<nsUint64HashKey, nsGlobalWindowOuter*> OuterWindowByIdTable;
static void
@ -252,8 +206,6 @@ public:
}
nsGlobalWindowOuter* outerWindow = sOuterWindowsById->Get(aWindowID);
MOZ_ASSERT(!outerWindow || outerWindow->IsOuterWindow(),
"Inner window in sOuterWindowsById?");
return outerWindow;
}
@ -406,9 +358,6 @@ public:
nsIWidget* aWidget, nsIScreen* aScreen);
bool FullScreen() const;
// Inner windows only.
virtual void SetHasGamepadEventListener(bool aHasGamepad = true) override;
using EventTarget::EventListenerAdded;
virtual void EventListenerAdded(nsAtom* aType) override;
using EventTarget::EventListenerRemoved;
@ -498,43 +447,14 @@ public:
static void ShutDown();
static bool IsCallerChrome();
void CleanupCachedXBLHandlers();
friend class WindowStateHolder;
NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsGlobalWindowOuter,
nsIDOMEventTarget)
#ifdef DEBUG
// Call Unlink on this window. This may cause bad things to happen, so use
// with caution.
void RiskyUnlink();
#endif
virtual JSObject*
GetCachedXBLPrototypeHandler(nsXBLPrototypeHandler* aKey) override;
virtual void
CacheXBLPrototypeHandler(nsXBLPrototypeHandler* aKey,
JS::Handle<JSObject*> aHandler) override;
virtual bool TakeFocus(bool aFocus, uint32_t aFocusMethod) override;
virtual void SetReadyForFocus() override;
virtual void PageHidden() override;
virtual nsresult DispatchAsyncHashchange(nsIURI *aOldURI, nsIURI *aNewURI) override;
virtual nsresult DispatchSyncPopState() override;
// Inner windows only.
virtual void EnableDeviceSensor(uint32_t aType) override;
virtual void DisableDeviceSensor(uint32_t aType) override;
#if defined(MOZ_WIDGET_ANDROID)
virtual void EnableOrientationChangeListener() override;
virtual void DisableOrientationChangeListener() override;
#endif
virtual void EnableTimeChangeNotifications() override;
virtual void DisableTimeChangeNotifications() override;
virtual nsresult SetArguments(nsIArray* aArguments) override;
@ -555,7 +475,6 @@ public:
bool
HadOriginalOpener() const
{
MOZ_ASSERT(IsOuterWindow());
return mHadOriginalOpener;
}
@ -647,7 +566,6 @@ public:
void GetNameOuter(nsAString& aName);
void SetNameOuter(const nsAString& aName, mozilla::ErrorResult& aError);
mozilla::dom::Location* GetLocation() override;
mozilla::dom::CustomElementRegistry* CustomElements() override;
void GetStatusOuter(nsAString& aStatus);
void SetStatusOuter(const nsAString& aStatus);
void CloseOuter(bool aTrustedCaller);
@ -692,7 +610,6 @@ public:
bool aForceNoOpener,
nsPIDOMWindowOuter **_retval) override;
nsIDOMNavigator* GetNavigator() override;
already_AddRefed<nsIDOMOfflineResourceList> GetApplicationCache() override;
#if defined(MOZ_WIDGET_ANDROID)
int16_t Orientation(mozilla::dom::CallerType aCallerType) const;
@ -717,9 +634,6 @@ public:
void PrintOuter(mozilla::ErrorResult& aError);
mozilla::dom::Selection* GetSelectionOuter();
already_AddRefed<nsISelection> GetSelection() override;
already_AddRefed<nsICSSDeclaration>
GetComputedStyle(mozilla::dom::Element& aElt, const nsAString& aPseudoElt,
mozilla::ErrorResult& aError) override;
already_AddRefed<mozilla::dom::MediaQueryList> MatchMediaOuter(
const nsAString& aQuery,
mozilla::dom::CallerType aCallerType);
@ -784,7 +698,6 @@ public:
mozilla::ErrorResult& aError);
already_AddRefed<nsPIDOMWindowOuter> GetContent()
{
MOZ_ASSERT(IsOuterWindow());
mozilla::IgnoredErrorResult ignored;
nsCOMPtr<nsPIDOMWindowOuter> win =
GetContentInternal(ignored, mozilla::dom::CallerType::System);
@ -1002,9 +915,6 @@ private:
void ReportLargeAllocStatus();
public:
virtual nsresult RegisterIdleObserver(nsIIdleObserver* aIdleObserverPtr) override;
virtual nsresult UnregisterIdleObserver(nsIIdleObserver* aIdleObserverPtr) override;
void FlushPendingNotifications(mozilla::FlushType aType);
// Outer windows only.
@ -1132,32 +1042,14 @@ private:
SecureContextFlags aFlags =
SecureContextFlags::eDefault);
// nsPIDOMWindow<T> should be able to see these helper methods.
friend class nsPIDOMWindow<mozIDOMWindowProxy>;
friend class nsPIDOMWindow<mozIDOMWindow>;
friend class nsPIDOMWindow<nsISupports>;
// nsPIDOMWindow{Inner,Outer} should be able to see these helper methods.
friend class nsPIDOMWindowInner;
friend class nsPIDOMWindowOuter;
mozilla::dom::TabGroup* TabGroupOuter();
bool IsBackgroundInternal() const;
void SetIsBackgroundInternal(bool aIsBackground);
// NOTE: Chrome Only
void DisconnectAndClearGroupMessageManagers()
{
MOZ_RELEASE_ASSERT(IsChromeWindow());
for (auto iter = mChromeFields.mGroupMessageManagers.Iter(); !iter.Done(); iter.Next()) {
nsIMessageBroadcaster* mm = iter.UserData();
if (mm) {
static_cast<nsFrameMessageManager*>(mm)->Disconnect();
}
}
mChromeFields.mGroupMessageManagers.Clear();
}
nsresult GetInterfaceInternal(const nsIID& aIID, void** aSink);
public:
@ -1171,17 +1063,9 @@ public:
virtual mozilla::AbstractThread*
AbstractMainThreadFor(mozilla::TaskCategory aCategory) override;
uint32_t LastIdleRequestHandle() const { return mIdleRequestCallbackCounter - 1; }
nsresult RunIdleRequest(mozilla::dom::IdleRequest* aRequest,
DOMHighResTimeStamp aDeadline, bool aDidTimeout);
typedef mozilla::LinkedList<mozilla::dom::IdleRequest> IdleRequests;
void RemoveIdleCallback(mozilla::dom::IdleRequest* aRequest);
protected:
// These members are only used on outer window objects. Make sure
// you never set any of these on an inner object!
bool mFullScreen : 1;
bool mFullscreenMode : 1;
bool mIsClosed : 1;
@ -1192,7 +1076,6 @@ protected:
bool mHavePendingClose : 1;
bool mHadOriginalOpener : 1;
bool mOriginalOpenerWasSecureContext : 1;
bool mIsSecureContextIfOpenerIgnored : 1;
bool mIsPopupSpam : 1;
// Indicates whether scripts are allowed to close this window.
@ -1201,15 +1084,6 @@ protected:
// Window offline status. Checked to see if we need to fire offline event
bool mWasOffline : 1;
// Represents whether the inner window's page has had a slow script notice.
// Only used by inner windows; will always be false for outer windows.
// This is used to implement Telemetry measures such as SLOW_SCRIPT_PAGE_COUNT.
bool mHasHadSlowScript : 1;
// Track what sorts of events we need to fire when thawed
bool mNotifyIdleObserversIdleOnThaw : 1;
bool mNotifyIdleObserversActiveOnThaw : 1;
// Indicates whether we're in the middle of creating an initializing
// a new inner window object.
bool mCreatingInnerWindow : 1;
@ -1217,41 +1091,6 @@ protected:
// Fast way to tell if this is a chrome window (without having to QI).
bool mIsChrome : 1;
// Hack to indicate whether a chrome window needs its message manager
// to be disconnected, since clean up code is shared in the global
// window superclass.
bool mCleanMessageManager : 1;
// Indicates that the current document has never received a document focus
// event.
bool mNeedsFocus : 1;
bool mHasFocus : 1;
// when true, show focus rings for the current focused content only.
// This will be reset when another element is focused
bool mShowFocusRingForContent : 1;
// true if tab navigation has occurred for this window. Focus rings
// should be displayed.
bool mFocusByKeyOccurred : 1;
// Inner windows only.
// Indicates whether this window wants gamepad input events
bool mHasGamepad : 1;
// Inner windows only.
// Indicates whether this window wants VR events
bool mHasVREvents : 1;
// Inner windows only.
// Indicates whether this window wants VRDisplayActivate events
bool mHasVRDisplayActivateEvents : 1;
nsCheapSet<nsUint32HashKey> mGamepadIndexSet;
nsRefPtrHashtable<nsUint32HashKey, mozilla::dom::Gamepad> mGamepads;
bool mHasSeenGamepadInput;
// whether we've sent the destroy notification for our window id
bool mNotifiedIDDestroyed : 1;
// whether scripts may close the window,
// even if "dom.allow_scripts_to_close_windows" is false.
bool mAllowScriptsToClose : 1;
@ -1265,64 +1104,18 @@ protected:
// For |window.arguments|, via |openDialog|.
nsCOMPtr<nsIArray> mArguments;
// Only used in the outer.
RefPtr<DialogValueHolder> mReturnValue;
RefPtr<mozilla::dom::Navigator> mNavigator;
RefPtr<nsScreen> mScreen;
RefPtr<nsDOMWindowList> mFrames;
// All BarProps are inner window only.
RefPtr<mozilla::dom::BarProp> mMenubar;
RefPtr<mozilla::dom::BarProp> mToolbar;
RefPtr<mozilla::dom::BarProp> mLocationbar;
RefPtr<mozilla::dom::BarProp> mPersonalbar;
RefPtr<mozilla::dom::BarProp> mStatusbar;
RefPtr<mozilla::dom::BarProp> mScrollbars;
RefPtr<nsDOMWindowUtils> mWindowUtils;
nsString mStatus;
nsString mDefaultStatus;
RefPtr<nsGlobalWindowObserver> mObserver; // Inner windows only.
RefPtr<mozilla::dom::Crypto> mCrypto;
RefPtr<mozilla::dom::U2F> mU2F;
RefPtr<mozilla::dom::cache::CacheStorage> mCacheStorage;
RefPtr<mozilla::dom::Console> mConsole;
RefPtr<mozilla::dom::Worklet> mAudioWorklet;
RefPtr<mozilla::dom::Worklet> mPaintWorklet;
// We need to store an nsISupports pointer to this object because the
// mozilla::dom::External class doesn't exist on b2g and using the type
// forward declared here means that ~nsGlobalWindow wouldn't compile because
// it wouldn't see the ~External function's declaration.
nsCOMPtr<nsISupports> mExternal;
RefPtr<mozilla::dom::MozSelfSupport> mMozSelfSupport;
RefPtr<mozilla::dom::Storage> mLocalStorage;
RefPtr<mozilla::dom::Storage> mSessionStorage;
// These member variable are used only on inner windows.
RefPtr<mozilla::EventListenerManager> mListenerManager;
RefPtr<mozilla::dom::Location> mLocation;
RefPtr<nsHistory> mHistory;
RefPtr<mozilla::dom::CustomElementRegistry> mCustomElements;
// These member variables are used on both inner and the outer windows.
nsCOMPtr<nsIPrincipal> mDocumentPrincipal;
// mTabChild is only ever populated in the content process.
nsCOMPtr<nsITabChild> mTabChild;
uint32_t mSuspendDepth;
uint32_t mFreezeDepth;
// the method that was used to focus mFocusedNode
uint32_t mFocusMethod;
uint32_t mSerial;
// The current idle request callback handle
uint32_t mIdleRequestCallbackCounter;
IdleRequests mIdleRequestCallbacks;
RefPtr<IdleRequestExecutor> mIdleRequestExecutor;
#ifdef DEBUG
bool mSetOpenerWindowCalled;
nsCOMPtr<nsIURI> mLastOpenedURI;
@ -1330,50 +1123,13 @@ protected:
bool mCleanedUp;
nsCOMPtr<nsIDOMOfflineResourceList> mApplicationCache;
using XBLPrototypeHandlerTable = nsJSThingHashtable<nsPtrHashKey<nsXBLPrototypeHandler>, JSObject*>;
mozilla::UniquePtr<XBLPrototypeHandlerTable> mCachedXBLPrototypeHandlers;
// mSuspendedDoc is only set on outer windows. It's useful when we get matched
// EnterModalState/LeaveModalState calls, in which case the outer window is
// responsible for unsuspending events on the document. If we don't (for
// example, if the outer window is closed before the LeaveModalState call),
// then the inner window whose mDoc is our mSuspendedDoc is responsible for
// unsuspending it.
// It's useful when we get matched EnterModalState/LeaveModalState calls, in
// which case the outer window is responsible for unsuspending events on the
// document. If we don't (for example, if the outer window is closed before
// the LeaveModalState call), then the inner window whose mDoc is our
// mSuspendedDoc is responsible for unsuspending it.
nsCOMPtr<nsIDocument> mSuspendedDoc;
RefPtr<mozilla::dom::IDBFactory> mIndexedDB;
// This counts the number of windows that have been opened in rapid succession
// (i.e. within dom.successive_dialog_time_limit of each other). It is reset
// to 0 once a dialog is opened after dom.successive_dialog_time_limit seconds
// have elapsed without any other dialogs.
uint32_t mDialogAbuseCount;
// This holds the time when the last modal dialog was shown. If more than
// MAX_DIALOG_LIMIT dialogs are shown within the time span defined by
// dom.successive_dialog_time_limit, we show a checkbox or confirmation prompt
// to allow disabling of further dialogs from this window.
TimeStamp mLastDialogQuitTime;
// This flag keeps track of whether dialogs are
// currently enabled on this window.
bool mAreDialogsEnabled;
nsTHashtable<nsPtrHashKey<mozilla::DOMEventTargetHelper> > mEventTargetObjects;
nsTArray<uint32_t> mEnabledSensors;
#if defined(MOZ_WIDGET_ANDROID)
mozilla::UniquePtr<mozilla::dom::WindowOrientationObserver> mOrientationChangeObserver;
#endif
#ifdef MOZ_WEBSPEECH
// mSpeechSynthesis is only used on inner windows.
RefPtr<mozilla::dom::SpeechSynthesis> mSpeechSynthesis;
#endif
#ifdef DEBUG
// This member is used in the debug only assertions in TabGroup()
// to catch cyclic parent/opener trees and not overflow the stack.
@ -1383,36 +1139,21 @@ protected:
// This is the CC generation the last time we called CanSkip.
uint32_t mCanSkipCCGeneration;
// The VR Displays for this window
nsTArray<RefPtr<mozilla::dom::VRDisplay>> mVRDisplays;
RefPtr<mozilla::dom::VREventObserver> mVREventObserver;
// When non-zero, the document should receive a vrdisplayactivate event
// after loading. The value is the ID of the VRDisplay that content should
// begin presentation on.
uint32_t mAutoActivateVRDisplayID; // Outer windows only
int64_t mBeforeUnloadListenerCount; // Inner windows only
RefPtr<mozilla::dom::IntlUtils> mIntlUtils;
uint32_t mAutoActivateVRDisplayID;
static OuterWindowByIdTable* sOuterWindowsById;
// Members in the mChromeFields member should only be used in chrome windows.
// All accesses to this field should be guarded by a check of mIsChrome.
struct ChromeFields {
ChromeFields()
: mGroupMessageManagers(1)
{}
nsCOMPtr<nsIBrowserDOMWindow> mBrowserDOMWindow;
nsCOMPtr<nsIMessageBroadcaster> mMessageManager;
nsInterfaceHashtable<nsStringHashKey, nsIMessageBroadcaster> mGroupMessageManagers;
// A weak pointer to the nsPresShell that we are doing fullscreen for.
// The pointer being set indicates we've set the IsInFullscreenChange
// flag on this pres shell.
nsWeakPtr mFullscreenPresShell;
nsCOMPtr<mozIDOMWindowProxy> mOpenerForInitialContentBrowser;
} mChromeFields;
friend class nsDOMScriptableHelper;
@ -1465,10 +1206,6 @@ nsGlobalWindowOuter::GetScriptableTopInternal()
inline nsIScriptContext*
nsGlobalWindowOuter::GetContextInternal()
{
if (mOuterWindow) {
return GetOuterWindowInternal()->mContext;
}
return mContext;
}
@ -1481,7 +1218,6 @@ nsGlobalWindowOuter::GetOuterWindowInternal()
inline nsGlobalWindowInner*
nsGlobalWindowOuter::GetCurrentInnerWindowInternal() const
{
MOZ_ASSERT(IsOuterWindow());
return nsGlobalWindowInner::Cast(mInnerWindow);
}
@ -1494,7 +1230,6 @@ nsGlobalWindowOuter::EnsureInnerWindowInternal()
inline bool
nsGlobalWindowOuter::IsTopLevelWindow()
{
MOZ_ASSERT(IsOuterWindow());
nsPIDOMWindowOuter* parentWindow = GetScriptableTop();
return parentWindow == this->AsOuter();
}

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

@ -40,7 +40,6 @@ NS_INTERFACE_MAP_END
nsHistory::nsHistory(nsPIDOMWindowInner* aInnerWindow)
: mInnerWindow(do_GetWeakReference(aInnerWindow))
{
MOZ_ASSERT(aInnerWindow->IsInnerWindow());
}
nsHistory::~nsHistory()

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

@ -900,6 +900,15 @@ public:
mBufferedCSPViolations.AppendElement(aReportingRunnable, mozilla::fallible);
}
/**
* Called when the document was decoded as UTF-8 and decoder encountered no
* errors.
*/
void DisableEncodingMenu()
{
mEncodingMenuDisabled = true;
}
/**
* Access HTTP header data (this may also get set from other
* sources, like HTML META tags).
@ -3592,6 +3601,9 @@ protected:
// True if the document is allowed to use PaymentRequest.
bool mAllowPaymentRequest : 1;
// True if the encoding menu should be disabled.
bool mEncodingMenuDisabled : 1;
// Whether <style scoped> support is enabled in this document.
enum { eScopedStyle_Unknown, eScopedStyle_Disabled, eScopedStyle_Enabled };
unsigned int mIsScopedStyleEnabled : 2;

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

@ -230,7 +230,6 @@ nsInProcessTabChildGlobal::DisconnectEventListeners()
{
if (mDocShell) {
if (nsCOMPtr<nsPIDOMWindowOuter> win = mDocShell->GetWindow()) {
MOZ_ASSERT(win->IsOuterWindow());
win->SetChromeEventHandler(win->GetChromeEventHandler());
}
}

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

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

@ -4,54 +4,23 @@
* 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/. */
template<class T>
nsPIDOMWindowInner*
nsPIDOMWindow<T>::AsInner()
{
MOZ_ASSERT(IsInnerWindow());
return reinterpret_cast<nsPIDOMWindowInner*>(this);
}
template<class T>
const nsPIDOMWindowInner*
nsPIDOMWindow<T>::AsInner() const
{
MOZ_ASSERT(IsInnerWindow());
return reinterpret_cast<const nsPIDOMWindowInner*>(this);
}
template<class T>
nsPIDOMWindowOuter*
nsPIDOMWindow<T>::AsOuter()
{
MOZ_ASSERT(IsOuterWindow());
return reinterpret_cast<nsPIDOMWindowOuter*>(this);
}
template<class T>
const nsPIDOMWindowOuter*
nsPIDOMWindow<T>::AsOuter() const
{
MOZ_ASSERT(IsOuterWindow());
return reinterpret_cast<const nsPIDOMWindowOuter*>(this);
}
template <class T>
bool
nsPIDOMWindow<T>::IsLoading() const
nsPIDOMWindowOuter::IsLoading() const
{
if (IsOuterWindow()) {
auto* win = AsOuter()->GetCurrentInnerWindow();
auto* win = GetCurrentInnerWindow();
if (!win) {
NS_ERROR("No current inner window available!");
if (!win) {
NS_ERROR("No current inner window available!");
return false;
}
return win->IsLoading();
return false;
}
return win->IsLoading();
}
bool
nsPIDOMWindowInner::IsLoading() const
{
if (!mOuterWindow) {
NS_ERROR("IsLoading() called on orphan inner window!");
@ -61,22 +30,23 @@ nsPIDOMWindow<T>::IsLoading() const
return !mIsDocumentLoaded;
}
template <class T>
bool
nsPIDOMWindow<T>::IsHandlingResizeEvent() const
nsPIDOMWindowOuter::IsHandlingResizeEvent() const
{
if (IsOuterWindow()) {
auto* win = AsOuter()->GetCurrentInnerWindow();
auto* win = GetCurrentInnerWindow();
if (!win) {
NS_ERROR("No current inner window available!");
if (!win) {
NS_ERROR("No current inner window available!");
return false;
}
return win->IsHandlingResizeEvent();
return false;
}
return win->IsHandlingResizeEvent();
}
bool
nsPIDOMWindowInner::IsHandlingResizeEvent() const
{
if (!mOuterWindow) {
NS_ERROR("IsHandlingResizeEvent() called on orphan inner window!");
@ -107,24 +77,26 @@ nsPIDOMWindowInner::IsTopInnerWindow() const
return mTopInnerWindow == this;
}
template <class T>
nsIDocShell*
nsPIDOMWindow<T>::GetDocShell() const
nsPIDOMWindowOuter::GetDocShell() const
{
if (mOuterWindow) {
return mOuterWindow->GetDocShell();
}
return mDocShell;
}
template <class T>
nsIContent*
nsPIDOMWindow<T>::GetFocusedNode() const
nsIDocShell*
nsPIDOMWindowInner::GetDocShell() const
{
if (IsOuterWindow()) {
return mInnerWindow ? mInnerWindow->GetFocusedNode() : nullptr;
}
return mOuterWindow ? mOuterWindow->GetDocShell() : nullptr;
}
nsIContent*
nsPIDOMWindowOuter::GetFocusedNode() const
{
return mInnerWindow ? mInnerWindow->GetFocusedNode() : nullptr;
}
nsIContent*
nsPIDOMWindowInner::GetFocusedNode() const
{
return mFocusedNode;
}

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

@ -25,7 +25,6 @@ using namespace mozilla::dom;
nsScreen::Create(nsPIDOMWindowInner* aWindow)
{
MOZ_ASSERT(aWindow);
MOZ_ASSERT(aWindow->IsInnerWindow());
if (!aWindow->GetDocShell()) {
return nullptr;

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

@ -36,7 +36,6 @@ using namespace mozilla::dom;
nsWindowRoot::nsWindowRoot(nsPIDOMWindowOuter* aWindow)
{
mWindow = aWindow;
MOZ_ASSERT(mWindow->IsOuterWindow());
// Keyboard indicators are not shown on Mac by default.
#if defined(XP_MACOSX)

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

@ -186,7 +186,6 @@ CallbackObject::CallSetup::CallSetup(CallbackObject* aCallback,
? xpc::WindowGlobalOrNull(realCallback)
: nullptr;
if (win) {
MOZ_ASSERT(win->IsInnerWindow());
// We don't want to run script in windows that have been navigated away
// from.
if (!win->AsInner()->HasActiveDocument()) {

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

@ -363,7 +363,6 @@ BroadcastChannel::Constructor(const GlobalObject& aGlobal,
if (!workerPrivate) {
MOZ_ASSERT(window);
MOZ_ASSERT(window->IsInnerWindow());
bc->mInnerID = window->WindowID();
// Register as observer for inner-window-destroyed.

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

@ -5506,8 +5506,6 @@ CanvasRenderingContext2D::DrawWindow(nsGlobalWindowInner& aWindow, double aX,
const nsAString& aBgColor,
uint32_t aFlags, ErrorResult& aError)
{
MOZ_ASSERT(aWindow.IsInnerWindow());
if (int32_t(aW) == 0 || int32_t(aH) == 0) {
return;
}

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

@ -380,7 +380,6 @@ protected:
return;
}
MOZ_ASSERT(aWindow->IsInnerWindow());
nsPIDOMWindowOuter* outerWindow = aWindow->GetOuterWindow();
if (NS_WARN_IF(!outerWindow)) {
return;
@ -822,7 +821,6 @@ Console::Console(nsPIDOMWindowInner* aWindow)
MOZ_ASSERT_IF(NS_IsMainThread(), aWindow);
if (mWindow) {
MOZ_ASSERT(mWindow->IsInnerWindow());
mInnerID = mWindow->WindowID();
// Without outerwindow any console message coming from this object will not

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

@ -810,12 +810,6 @@ EventListenerManager::SetEventHandler(nsAtom* aName,
return NS_OK;
}
#ifdef DEBUG
if (nsCOMPtr<nsPIDOMWindowInner> win = do_QueryInterface(global)) {
MOZ_ASSERT(win->IsInnerWindow(), "We should not have an outer window here!");
}
#endif
nsresult rv = NS_OK;
// return early preventing the event listener from being added
// 'doc' is fetched above

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

@ -98,15 +98,6 @@ Blob::Blob(nsISupports* aParent, BlobImpl* aImpl)
, mParent(aParent)
{
MOZ_ASSERT(mImpl);
#ifdef DEBUG
{
nsCOMPtr<nsPIDOMWindowInner> win = do_QueryInterface(aParent);
if (win) {
MOZ_ASSERT(win->IsInnerWindow());
}
}
#endif
}
Blob::~Blob()

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

@ -135,7 +135,6 @@ void
GamepadManager::AddListener(nsGlobalWindowInner* aWindow)
{
MOZ_ASSERT(aWindow);
MOZ_ASSERT(aWindow->IsInnerWindow());
MOZ_ASSERT(NS_IsMainThread());
// IPDL child has not been created
@ -181,7 +180,6 @@ void
GamepadManager::RemoveListener(nsGlobalWindowInner* aWindow)
{
MOZ_ASSERT(aWindow);
MOZ_ASSERT(aWindow->IsInnerWindow());
if (mShuttingDown) {
// Doesn't matter at this point. It's possible we're being called
@ -353,9 +351,6 @@ GamepadManager::NewConnectionEvent(uint32_t aIndex, bool aConnected)
if (aConnected) {
for (uint32_t i = 0; i < listeners.Length(); i++) {
MOZ_ASSERT(listeners[i]->IsInnerWindow());
// Only send events to non-background windows
if (!listeners[i]->AsInner()->IsCurrentInnerWindow() ||
listeners[i]->GetOuterWindow()->IsBackground()) {
@ -492,7 +487,6 @@ GamepadManager::SetWindowHasSeenGamepad(nsGlobalWindowInner* aWindow,
bool aHasSeen)
{
MOZ_ASSERT(aWindow);
MOZ_ASSERT(aWindow->IsInnerWindow());
if (mListeners.IndexOf(aWindow) == NoIndex) {
// This window isn't even listening for gamepad events.
@ -549,8 +543,6 @@ GamepadManager::Update(const GamepadChangeEvent& aEvent)
nsTArray<RefPtr<nsGlobalWindowInner>> listeners(mListeners);
for (uint32_t i = 0; i < listeners.Length(); i++) {
MOZ_ASSERT(listeners[i]->IsInnerWindow());
// Only send events to non-background windows
if (!listeners[i]->AsInner()->IsCurrentInnerWindow() ||
listeners[i]->GetOuterWindow()->IsBackground()) {

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

@ -129,9 +129,6 @@ nsGenericHTMLFrameElement::GetContentWindow()
return nullptr;
}
NS_ASSERTION(win->IsOuterWindow(),
"Uh, this window should always be an outer window!");
return win.forget();
}

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

@ -3665,6 +3665,9 @@ nsHTMLDocument::DocAddSizeOfExcludingThis(nsWindowSizes& aWindowSizes) const
bool
nsHTMLDocument::WillIgnoreCharsetOverride()
{
if (mEncodingMenuDisabled) {
return true;
}
if (mType != eHTML) {
MOZ_ASSERT(mType == eXHTML);
return true;

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

@ -32,20 +32,4 @@ interface nsIDOMChromeWindow : nsISupports
*/
[noscript]
nsIMessageBroadcaster getGroupMessageManager(in AString group);
/**
* These methods provide a way to specify the opener value for the content in
* the window before the content itself is created. This is important in order
* to set the DocGroup of a document, as the opener must be set before the
* document is created.
*
* SetOpenerForInitialContentBrowser is used to set which opener will be used,
* and TakeOpenerForInitialContentBrowser is used by nsXULElement in order to
* take the value set earlier, and null out the value in the
* nsIDOMChromeWindow.
*/
[noscript]
void setOpenerForInitialContentBrowser(in mozIDOMWindowProxy aOpener);
[noscript]
mozIDOMWindowProxy takeOpenerForInitialContentBrowser();
};

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

@ -1248,7 +1248,6 @@ MediaRecorder::MediaRecorder(DOMMediaStream& aSourceMediaStream,
, mState(RecordingState::Inactive)
{
MOZ_ASSERT(aOwnerWindow);
MOZ_ASSERT(aOwnerWindow->IsInnerWindow());
mDOMStream = &aSourceMediaStream;
RegisterActivityObserver();
@ -1262,7 +1261,6 @@ MediaRecorder::MediaRecorder(AudioNode& aSrcAudioNode,
, mState(RecordingState::Inactive)
{
MOZ_ASSERT(aOwnerWindow);
MOZ_ASSERT(aOwnerWindow->IsInnerWindow());
mAudioNode = &aSrcAudioNode;

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

@ -195,7 +195,6 @@ SpeechRecognition::Constructor(const GlobalObject& aGlobal,
return nullptr;
}
MOZ_ASSERT(win->IsInnerWindow());
RefPtr<SpeechRecognition> object = new SpeechRecognition(win);
return object.forget();
}

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

@ -61,7 +61,6 @@ SpeechSynthesis::SpeechSynthesis(nsPIDOMWindowInner* aParent)
, mHoldQueue(false)
, mInnerID(aParent->WindowID())
{
MOZ_ASSERT(aParent->IsInnerWindow());
MOZ_ASSERT(NS_IsMainThread());
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();

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

@ -72,7 +72,6 @@ SpeechSynthesisUtterance::Constructor(GlobalObject& aGlobal,
return nullptr;
}
MOZ_ASSERT(win->IsInnerWindow());
RefPtr<SpeechSynthesisUtterance> object =
new SpeechSynthesisUtterance(win, aText);
return object.forget();

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

@ -337,7 +337,6 @@ MessagePort::Initialize(const nsID& aUUID,
mWorkerHolder = Move(workerHolder);
} else if (GetOwner()) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(GetOwner()->IsInnerWindow());
mInnerID = GetOwner()->WindowID();
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();

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

@ -123,7 +123,6 @@ UDPSocket::UDPSocket(nsPIDOMWindowInner* aOwner,
, mReadyState(SocketReadyState::Opening)
{
MOZ_ASSERT(aOwner);
MOZ_ASSERT(aOwner->IsInnerWindow());
nsIDocument* aDoc = aOwner->GetExtantDoc();
if (aDoc) {

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

@ -82,7 +82,6 @@ PerformanceObserver::Constructor(const GlobalObject& aGlobal,
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
MOZ_ASSERT(ownerWindow->IsInnerWindow());
RefPtr<PerformanceObserver> observer =
new PerformanceObserver(ownerWindow, aCb);

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

@ -38,11 +38,17 @@ Storage::Storage(nsPIDOMWindowInner* aWindow, nsIPrincipal* aPrincipal)
Storage::~Storage()
{}
/* static */ bool
Storage::StoragePrefIsEnabled()
{
return mozilla::Preferences::GetBool(kStorageEnabled);
}
bool
Storage::CanUseStorage(nsIPrincipal& aSubjectPrincipal)
{
// This method is responsible for correct setting of mIsSessionOnly.
if (!mozilla::Preferences::GetBool(kStorageEnabled)) {
if (!StoragePrefIsEnabled()) {
return false;
}

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

@ -32,6 +32,8 @@ public:
Storage(nsPIDOMWindowInner* aWindow, nsIPrincipal* aPrincipal);
static bool StoragePrefIsEnabled();
enum StorageType {
eSessionStorage,
eLocalStorage,

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

@ -27,7 +27,7 @@ VREventObserver::VREventObserver(nsGlobalWindowInner* aGlobalWindow)
, mIs2DView(true)
, mHasReset(false)
{
MOZ_ASSERT(aGlobalWindow && aGlobalWindow->IsInnerWindow());
MOZ_ASSERT(aGlobalWindow);
UpdateSpentTimeIn2DTelemetry(false);
VRManagerChild* vmc = VRManagerChild::Get();

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

@ -1278,8 +1278,6 @@ WebSocket::ConstructorCommon(const GlobalObject& aGlobal,
}
}
MOZ_ASSERT_IF(ownerWindow, ownerWindow->IsInnerWindow());
nsTArray<nsString> protocolArray;
for (uint32_t index = 0, len = aProtocols.Length(); index < len; ++index) {

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

@ -382,7 +382,6 @@ public:
MOZ_ASSERT(aPromiseProxy);
MOZ_ASSERT(aServiceWorkerPrivate);
MOZ_ASSERT(aWindow);
MOZ_ASSERT(aWindow->IsOuterWindow());
MOZ_ASSERT(aBaseURI);
AssertIsOnMainThread();

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

@ -220,7 +220,6 @@ ServiceWorkerRegistrationMainThread::ServiceWorkerRegistrationMainThread(nsPIDOM
{
AssertIsOnMainThread();
MOZ_ASSERT(aWindow);
MOZ_ASSERT(aWindow->IsInnerWindow());
StartListeningForEvents();
}

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

@ -216,7 +216,6 @@ public:
MOZ_ASSERT(aPromiseProxy);
MOZ_ASSERT(aServiceWorkerPrivate);
MOZ_ASSERT(aWindow);
MOZ_ASSERT(aWindow->IsOuterWindow());
MOZ_ASSERT(aBaseURI);
AssertIsOnMainThread();

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

@ -2848,8 +2848,6 @@ WorkerPrivateParent<Derived>::WorkerPrivateParent(
if (aLoadInfo.mWindow) {
AssertIsOnMainThread();
MOZ_ASSERT(aLoadInfo.mWindow->IsInnerWindow(),
"Should have inner window here!");
BindToOwner(aLoadInfo.mWindow);
}

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

@ -203,7 +203,6 @@ public:
MOZ_ASSERT(aPrincipal);
nsCOMPtr<nsPIDOMWindowInner> win = do_QueryInterface(aGlobalObject);
if (win) {
MOZ_ASSERT(win->IsInnerWindow());
if (win->GetExtantDoc()) {
mStyleBackend = win->GetExtantDoc()->GetStyleBackendType();
}

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

@ -1465,13 +1465,10 @@ nsXULElement::LoadSrc()
nsCOMPtr<nsPIDOMWindowOuter> opener = do_QueryInterface(slots->mFrameLoaderOrOpener);
if (!opener) {
// If we are a primary xul-browser, we want to take the opener property!
nsCOMPtr<nsIDOMChromeWindow> chromeWindow = do_QueryInterface(OwnerDoc()->GetWindow());
nsCOMPtr<nsPIDOMWindowOuter> window = OwnerDoc()->GetWindow();
if (AttrValueIs(kNameSpaceID_None, nsGkAtoms::primary,
nsGkAtoms::_true, eIgnoreCase) &&
chromeWindow) {
nsCOMPtr<mozIDOMWindowProxy> wp;
chromeWindow->TakeOpenerForInitialContentBrowser(getter_AddRefs(wp));
opener = nsPIDOMWindowOuter::From(wp);
nsGkAtoms::_true, eIgnoreCase) && window) {
opener = window->TakeOpenerForInitialContentBrowser();
}
}

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

@ -281,7 +281,7 @@ ScaledFontBase::GetGlyphDesignMetrics(const uint16_t* aGlyphs, uint32_t aNumGlyp
}
cairo_font_options_destroy(options);
}
return;
}
#endif

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

@ -196,7 +196,9 @@ ScaledFontDWrite::CopyGlyphsToBuilder(const GlyphBuffer &aBuffer, PathBuilder *a
}
void
ScaledFontDWrite::GetGlyphDesignMetrics(const uint16_t* aGlyphs, uint32_t aNumGlyphs, GlyphMetrics* aGlyphMetrics)
ScaledFontDWrite::GetGlyphDesignMetrics(const uint16_t* aGlyphs,
uint32_t aNumGlyphs,
GlyphMetrics* aGlyphMetrics)
{
DWRITE_FONT_METRICS fontMetrics;
mFontFace->GetMetrics(&fontMetrics);
@ -204,16 +206,20 @@ ScaledFontDWrite::GetGlyphDesignMetrics(const uint16_t* aGlyphs, uint32_t aNumGl
vector<DWRITE_GLYPH_METRICS> metrics(aNumGlyphs);
mFontFace->GetDesignGlyphMetrics(aGlyphs, aNumGlyphs, &metrics.front());
Float designUnitCorrection = 1.f / fontMetrics.designUnitsPerEm;
Float scaleFactor = mSize / fontMetrics.designUnitsPerEm;
for (uint32_t i = 0; i < aNumGlyphs; i++) {
aGlyphMetrics[i].mXBearing = metrics[i].leftSideBearing * designUnitCorrection * mSize;
aGlyphMetrics[i].mXAdvance = metrics[i].advanceWidth * designUnitCorrection * mSize;
aGlyphMetrics[i].mYBearing = metrics[i].topSideBearing * designUnitCorrection * mSize;
aGlyphMetrics[i].mYAdvance = metrics[i].advanceHeight * designUnitCorrection * mSize;
aGlyphMetrics[i].mWidth = (metrics[i].advanceHeight - metrics[i].topSideBearing - metrics[i].bottomSideBearing) *
designUnitCorrection * mSize;
aGlyphMetrics[i].mHeight = (metrics[i].topSideBearing - metrics[i].verticalOriginY) * designUnitCorrection * mSize;
aGlyphMetrics[i].mXBearing = metrics[i].leftSideBearing * scaleFactor;
aGlyphMetrics[i].mXAdvance = metrics[i].advanceWidth * scaleFactor;
aGlyphMetrics[i].mYBearing = (metrics[i].topSideBearing -
metrics[i].verticalOriginY) * scaleFactor;
aGlyphMetrics[i].mYAdvance = metrics[i].advanceHeight * scaleFactor;
aGlyphMetrics[i].mWidth = (metrics[i].advanceWidth -
metrics[i].leftSideBearing -
metrics[i].rightSideBearing) * scaleFactor;
aGlyphMetrics[i].mHeight = (metrics[i].advanceHeight -
metrics[i].topSideBearing -
metrics[i].bottomSideBearing) * scaleFactor;
}
}

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

@ -3481,7 +3481,8 @@ gfxFont::SetupGlyphExtents(DrawTarget* aDrawTarget, uint32_t aGlyphID,
{
gfxRect svgBounds;
if (mFontEntry->TryGetSVGData(this) && mFontEntry->HasSVGGlyph(aGlyphID) &&
mFontEntry->GetSVGGlyphExtents(aDrawTarget, aGlyphID, &svgBounds)) {
mFontEntry->GetSVGGlyphExtents(aDrawTarget, aGlyphID,
GetAdjustedSize(), &svgBounds)) {
gfxFloat d2a = aExtents->GetAppUnitsPerDevUnit();
aExtents->SetTightGlyphExtents(aGlyphID,
gfxRect(svgBounds.x * d2a,
@ -3491,20 +3492,22 @@ gfxFont::SetupGlyphExtents(DrawTarget* aDrawTarget, uint32_t aGlyphID,
return;
}
cairo_glyph_t glyph;
glyph.index = aGlyphID;
glyph.x = 0;
glyph.y = 0;
cairo_text_extents_t extents;
cairo_glyph_extents(gfxFont::RefCairo(aDrawTarget), &glyph, 1, &extents);
RefPtr<ScaledFont> sf = GetScaledFont(aDrawTarget);
uint16_t glyphIndex = aGlyphID;
GlyphMetrics metrics;
if (mAntialiasOption == kAntialiasNone) {
sf->GetGlyphDesignMetrics(&glyphIndex, 1, &metrics);
} else {
aDrawTarget->GetGlyphRasterizationMetrics(sf, &glyphIndex, 1, &metrics);
}
const Metrics& fontMetrics = GetMetrics(eHorizontal);
int32_t appUnitsPerDevUnit = aExtents->GetAppUnitsPerDevUnit();
if (!aNeedTight && extents.x_bearing >= 0 &&
extents.y_bearing >= -fontMetrics.maxAscent &&
extents.height + extents.y_bearing <= fontMetrics.maxDescent) {
if (!aNeedTight && metrics.mXBearing >= 0.0 &&
metrics.mYBearing >= -fontMetrics.maxAscent &&
metrics.mHeight + metrics.mYBearing <= fontMetrics.maxDescent) {
uint32_t appUnitsWidth =
uint32_t(ceil((extents.x_bearing + extents.width)*appUnitsPerDevUnit));
uint32_t(ceil((metrics.mXBearing + metrics.mWidth)*appUnitsPerDevUnit));
if (appUnitsWidth < gfxGlyphExtents::INVALID_WIDTH) {
aExtents->SetContainedGlyphWidthAppUnits(aGlyphID, uint16_t(appUnitsWidth));
return;
@ -3517,8 +3520,8 @@ gfxFont::SetupGlyphExtents(DrawTarget* aDrawTarget, uint32_t aGlyphID,
#endif
gfxFloat d2a = appUnitsPerDevUnit;
gfxRect bounds(extents.x_bearing*d2a, extents.y_bearing*d2a,
extents.width*d2a, extents.height*d2a);
gfxRect bounds(metrics.mXBearing * d2a, metrics.mYBearing * d2a,
metrics.mWidth * d2a, metrics.mHeight * d2a);
aExtents->SetTightGlyphExtents(aGlyphID, bounds);
}

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

@ -34,8 +34,6 @@
#include "gfxSVGGlyphs.h"
#include "gfx2DGlue.h"
#include "cairo.h"
#include "harfbuzz/hb.h"
#include "harfbuzz/hb-ot.h"
#include "graphite2/Font.h"
@ -319,22 +317,15 @@ gfxFontEntry::HasSVGGlyph(uint32_t aGlyphId)
bool
gfxFontEntry::GetSVGGlyphExtents(DrawTarget* aDrawTarget, uint32_t aGlyphId,
gfxRect *aResult)
gfxFloat aSize, gfxRect* aResult)
{
MOZ_ASSERT(mSVGInitialized,
"SVG data has not yet been loaded. TryGetSVGData() first.");
MOZ_ASSERT(mUnitsPerEm >= kMinUPEM && mUnitsPerEm <= kMaxUPEM,
"font has invalid unitsPerEm");
cairo_matrix_t fontMatrix;
cairo_get_font_matrix(gfxFont::RefCairo(aDrawTarget), &fontMatrix);
gfxMatrix svgToAppSpace(fontMatrix.xx, fontMatrix.yx,
fontMatrix.xy, fontMatrix.yy,
fontMatrix.x0, fontMatrix.y0);
svgToAppSpace.PreScale(1.0f / mUnitsPerEm, 1.0f / mUnitsPerEm);
return mSVGGlyphs->GetGlyphExtents(aGlyphId, svgToAppSpace, aResult);
gfxMatrix svgToApp(aSize / mUnitsPerEm, 0, 0, aSize / mUnitsPerEm, 0, 0);
return mSVGGlyphs->GetGlyphExtents(aGlyphId, svgToApp, aResult);
}
void

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

@ -205,7 +205,7 @@ public:
bool TryGetSVGData(gfxFont* aFont);
bool HasSVGGlyph(uint32_t aGlyphId);
bool GetSVGGlyphExtents(DrawTarget* aDrawTarget, uint32_t aGlyphId,
gfxRect *aResult);
gfxFloat aSize, gfxRect* aResult);
void RenderSVGGlyph(gfxContext *aContext, uint32_t aGlyphId,
mozilla::SVGContextPaint* aContextPaint);
// Call this when glyph geometry or rendering has changed

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

@ -191,28 +191,11 @@ gfxGDIFont::Initialize()
LOGFONTW logFont;
// Figure out if we want to do synthetic oblique styling.
GDIFontEntry* fe = static_cast<GDIFontEntry*>(GetFontEntry());
bool wantFakeItalic = mStyle.style != NS_FONT_STYLE_NORMAL &&
fe->IsUpright() && mStyle.allowSyntheticStyle;
// If the font's family has an actual italic face (but font matching
// didn't choose it), we have to use a cairo transform instead of asking
// GDI to italicize, because that would use a different face and result
// in a possible glyph ID mismatch between shaping and rendering.
//
// We use the mFamilyHasItalicFace flag in the entry in case of user fonts,
// where the *CSS* family may not know about italic faces that are present
// in the *GDI* family, and which GDI would use if we asked it to perform
// the "italicization".
bool useCairoFakeItalic = wantFakeItalic && fe->mFamilyHasItalicFace;
if (mAdjustedSize == 0.0) {
mAdjustedSize = mStyle.size;
if (mStyle.sizeAdjust > 0.0 && mAdjustedSize > 0.0) {
// to implement font-size-adjust, we first create the "unadjusted" font
FillLogFont(logFont, mAdjustedSize,
wantFakeItalic && !useCairoFakeItalic);
FillLogFont(logFont, mAdjustedSize);
mFont = ::CreateFontIndirectW(&logFont);
// initialize its metrics so we can calculate size adjustment
@ -245,7 +228,7 @@ gfxGDIFont::Initialize()
// this may end up being zero
mAdjustedSize = ROUND(mAdjustedSize);
FillLogFont(logFont, mAdjustedSize, wantFakeItalic && !useCairoFakeItalic);
FillLogFont(logFont, mAdjustedSize);
mFont = ::CreateFontIndirectW(&logFont);
mMetrics = new gfxFont::Metrics;
@ -458,8 +441,7 @@ gfxGDIFont::Initialize()
}
void
gfxGDIFont::FillLogFont(LOGFONTW& aLogFont, gfxFloat aSize,
bool aUseGDIFakeItalic)
gfxGDIFont::FillLogFont(LOGFONTW& aLogFont, gfxFloat aSize)
{
GDIFontEntry *fe = static_cast<GDIFontEntry*>(GetFontEntry());
@ -480,11 +462,6 @@ gfxGDIFont::FillLogFont(LOGFONTW& aLogFont, gfxFloat aSize,
}
fe->FillLogFont(&aLogFont, weight, aSize);
// If GDI synthetic italic is wanted, force the lfItalic field to true
if (aUseGDIFakeItalic) {
aLogFont.lfItalic = 1;
}
}
uint32_t

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