merge mozilla-inbound to mozilla-central a=merge

This commit is contained in:
Carsten "Tomcat" Book 2017-07-27 10:57:25 +02:00
commit d360d49d2a
883 changed files with 8974 additions and 3437 deletions

View file

@ -24,7 +24,7 @@
^gfx/skia/.* ^gfx/skia/.*
^gfx/vr/openvr/.* ^gfx/vr/openvr/.*
^gfx/webrender.* ^gfx/webrender.*
^gfx/webrender_traits.* ^gfx/webrender_api.*
^gfx/ycbcr/.* ^gfx/ycbcr/.*
^intl/hyphenation/hyphen/.* ^intl/hyphenation/hyphen/.*
^intl/icu/.* ^intl/icu/.*

View file

@ -48,24 +48,21 @@ SelectionManager::SelectionManager() :
void void
SelectionManager::ClearControlSelectionListener() SelectionManager::ClearControlSelectionListener()
{ {
if (!mCurrCtrlFrame)
return;
const nsFrameSelection* frameSel = mCurrCtrlFrame->GetConstFrameSelection();
NS_ASSERTION(frameSel, "No frame selection for the element!");
mCurrCtrlFrame = nullptr;
if (!frameSel)
return;
// Remove 'this' registered as selection listener for the normal selection. // Remove 'this' registered as selection listener for the normal selection.
Selection* normalSel = frameSel->GetSelection(SelectionType::eNormal); nsCOMPtr<nsISelection> normalSel = do_QueryReferent(mCurrCtrlNormalSel);
normalSel->RemoveSelectionListener(this); if (normalSel) {
normalSel->AsSelection()->RemoveSelectionListener(this);
mCurrCtrlNormalSel = nullptr;
}
// Remove 'this' registered as selection listener for the spellcheck // Remove 'this' registered as selection listener for the spellcheck
// selection. // selection.
Selection* spellSel = frameSel->GetSelection(SelectionType::eSpellCheck); nsCOMPtr<nsISelection> spellSel = do_QueryReferent(mCurrCtrlSpellSel);
spellSel->RemoveSelectionListener(this); if (spellSel) {
spellSel->AsSelection()->RemoveSelectionListener(this);
mCurrCtrlSpellSel = nullptr;
}
} }
void void
@ -76,22 +73,24 @@ SelectionManager::SetControlSelectionListener(dom::Element* aFocusedElm)
// the current focus. // the current focus.
ClearControlSelectionListener(); ClearControlSelectionListener();
mCurrCtrlFrame = aFocusedElm->GetPrimaryFrame(); nsIFrame* controlFrame = aFocusedElm->GetPrimaryFrame();
if (!mCurrCtrlFrame) if (!controlFrame)
return; return;
const nsFrameSelection* frameSel = mCurrCtrlFrame->GetConstFrameSelection(); const nsFrameSelection* frameSel = controlFrame->GetConstFrameSelection();
NS_ASSERTION(frameSel, "No frame selection for focused element!"); NS_ASSERTION(frameSel, "No frame selection for focused element!");
if (!frameSel) if (!frameSel)
return; return;
// Register 'this' as selection listener for the normal selection. // Register 'this' as selection listener for the normal selection.
Selection* normalSel = frameSel->GetSelection(SelectionType::eNormal); nsCOMPtr<nsISelection> normalSel = frameSel->GetSelection(SelectionType::eNormal);
normalSel->AddSelectionListener(this); normalSel->AsSelection()->AddSelectionListener(this);
mCurrCtrlNormalSel = do_GetWeakReference(normalSel);
// Register 'this' as selection listener for the spell check selection. // Register 'this' as selection listener for the spell check selection.
Selection* spellSel = frameSel->GetSelection(SelectionType::eSpellCheck); nsCOMPtr<nsISelection> spellSel = frameSel->GetSelection(SelectionType::eSpellCheck);
spellSel->AddSelectionListener(this); spellSel->AsSelection()->AddSelectionListener(this);
mCurrCtrlSpellSel = do_GetWeakReference(spellSel);
} }
void void

View file

@ -121,9 +121,10 @@ protected:
private: private:
// Currently focused control. // Currently focused control.
WeakFrame mCurrCtrlFrame;
int32_t mCaretOffset; int32_t mCaretOffset;
HyperTextAccessible* mAccWithCaret; HyperTextAccessible* mAccWithCaret;
nsWeakPtr mCurrCtrlNormalSel;
nsWeakPtr mCurrCtrlSpellSel;
}; };
} // namespace a11y } // namespace a11y

View file

@ -58,6 +58,7 @@
#endif #endif
#include "nsImageFrame.h" #include "nsImageFrame.h"
#include "nsINamed.h"
#include "nsIObserverService.h" #include "nsIObserverService.h"
#include "nsLayoutUtils.h" #include "nsLayoutUtils.h"
#include "nsPluginFrame.h" #include "nsPluginFrame.h"
@ -412,6 +413,7 @@ static StaticAutoPtr<nsTArray<nsCOMPtr<nsIContent> > > sPendingPlugins;
static StaticAutoPtr<nsTArray<nsCOMPtr<nsITimer> > > sPluginTimers; static StaticAutoPtr<nsTArray<nsCOMPtr<nsITimer> > > sPluginTimers;
class PluginTimerCallBack final : public nsITimerCallback class PluginTimerCallBack final : public nsITimerCallback
, public nsINamed
{ {
~PluginTimerCallBack() {} ~PluginTimerCallBack() {}
@ -444,11 +446,17 @@ public:
return NS_OK; return NS_OK;
} }
NS_IMETHOD GetName(nsACString& aName) final
{
aName.AssignLiteral("PluginTimerCallBack");
return NS_OK;
}
private: private:
nsCOMPtr<nsIContent> mContent; nsCOMPtr<nsIContent> mContent;
}; };
NS_IMPL_ISUPPORTS(PluginTimerCallBack, nsITimerCallback) NS_IMPL_ISUPPORTS(PluginTimerCallBack, nsITimerCallback, nsINamed)
#endif #endif
already_AddRefed<Accessible> already_AddRefed<Accessible>

View file

@ -3,7 +3,7 @@ support-files =
!/accessible/tests/mochitest/*.js !/accessible/tests/mochitest/*.js
[test_focusedChild.html] [test_focusedChild.html]
skip-if = (os == 'win' && (os_version == '6.2' || os_version == '6.3')) # bug 845134 skip-if = (os == 'win' && (os_version == '6.2' || os_version == '6.3' || os_version == '10.0.15063')) # bug 845134
[test_takeFocus.html] [test_takeFocus.html]
skip-if = buildapp == 'mulet' skip-if = buildapp == 'mulet'
[test_takeFocus.xul] [test_takeFocus.xul]

View file

@ -1514,6 +1514,8 @@ pref("browser.translation.engine", "bing");
pref("toolkit.telemetry.archive.enabled", true); pref("toolkit.telemetry.archive.enabled", true);
// Enables sending the shutdown ping when Firefox shuts down. // Enables sending the shutdown ping when Firefox shuts down.
pref("toolkit.telemetry.shutdownPingSender.enabled", true); pref("toolkit.telemetry.shutdownPingSender.enabled", true);
// Enables sending the shutdown ping using the pingsender from the first session.
pref("toolkit.telemetry.shutdownPingSender.enabledFirstSession", false);
// Enables sending the 'new-profile' ping on new profiles. // Enables sending the 'new-profile' ping on new profiles.
pref("toolkit.telemetry.newProfilePing.enabled", true); pref("toolkit.telemetry.newProfilePing.enabled", true);

View file

@ -36,7 +36,7 @@ XPCOMUtils.defineLazyPreferenceGetter(this, "gPhotonStructure",
ReaderParent:false, RecentWindow:false, SafeBrowsing: false, ReaderParent:false, RecentWindow:false, SafeBrowsing: false,
SessionStore:false, SessionStore:false,
ShortcutUtils:false, SimpleServiceDiscovery:false, SitePermissions:false, ShortcutUtils:false, SimpleServiceDiscovery:false, SitePermissions:false,
Social:false, TabCrashHandler:false, Task:false, TelemetryStopwatch:false, Social:false, TabCrashHandler:false, TelemetryStopwatch:false,
Translation:false, UITour:false, Utils:false, UpdateUtils:false, Translation:false, UITour:false, Utils:false, UpdateUtils:false,
Weave:false, Weave:false,
WebNavigationFrames: false, fxAccounts:false, gDevTools:false, WebNavigationFrames: false, fxAccounts:false, gDevTools:false,
@ -85,7 +85,6 @@ XPCOMUtils.defineLazyPreferenceGetter(this, "gPhotonStructure",
["SitePermissions", "resource:///modules/SitePermissions.jsm"], ["SitePermissions", "resource:///modules/SitePermissions.jsm"],
["Social", "resource:///modules/Social.jsm"], ["Social", "resource:///modules/Social.jsm"],
["TabCrashHandler", "resource:///modules/ContentCrashHandlers.jsm"], ["TabCrashHandler", "resource:///modules/ContentCrashHandlers.jsm"],
["Task", "resource://gre/modules/Task.jsm"],
["TelemetryStopwatch", "resource://gre/modules/TelemetryStopwatch.jsm"], ["TelemetryStopwatch", "resource://gre/modules/TelemetryStopwatch.jsm"],
["Translation", "resource:///modules/translation/Translation.jsm"], ["Translation", "resource:///modules/translation/Translation.jsm"],
["UITour", "resource:///modules/UITour.jsm"], ["UITour", "resource:///modules/UITour.jsm"],

View file

@ -4,6 +4,9 @@ const PAGE = "data:text/html,<html><body>A%20regular,%20everyday,%20normal%20pag
const COMMENTS = "Here's my test comment!"; const COMMENTS = "Here's my test comment!";
const EMAIL = "foo@privacy.com"; const EMAIL = "foo@privacy.com";
// Avoid timeouts, as in bug 1325530
requestLongerTimeout(2);
add_task(async function setup() { add_task(async function setup() {
await setupLocalCrashReportServer(); await setupLocalCrashReportServer();
}); });

View file

@ -47,6 +47,8 @@ XPCOMUtils.defineLazyModuleGetter(this, "AppMenuNotifications",
"resource://gre/modules/AppMenuNotifications.jsm"); "resource://gre/modules/AppMenuNotifications.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "CustomizableUI", XPCOMUtils.defineLazyModuleGetter(this, "CustomizableUI",
"resource:///modules/CustomizableUI.jsm"); "resource:///modules/CustomizableUI.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "DownloadHistory",
"resource://gre/modules/DownloadHistory.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Downloads", XPCOMUtils.defineLazyModuleGetter(this, "Downloads",
"resource://gre/modules/Downloads.jsm"); "resource://gre/modules/Downloads.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "DownloadUIHelper", XPCOMUtils.defineLazyModuleGetter(this, "DownloadUIHelper",
@ -56,9 +58,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "DownloadUtils",
XPCOMUtils.defineLazyModuleGetter(this, "FileUtils", XPCOMUtils.defineLazyModuleGetter(this, "FileUtils",
"resource://gre/modules/FileUtils.jsm"); "resource://gre/modules/FileUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "OS", XPCOMUtils.defineLazyModuleGetter(this, "OS",
"resource://gre/modules/osfile.jsm") "resource://gre/modules/osfile.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
"resource://gre/modules/PlacesUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils", XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils",
"resource://gre/modules/PrivateBrowsingUtils.jsm"); "resource://gre/modules/PrivateBrowsingUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "RecentWindow", XPCOMUtils.defineLazyModuleGetter(this, "RecentWindow",
@ -742,32 +742,8 @@ DownloadsDataCtor.prototype = {
download.endTime = Date.now(); download.endTime = Date.now();
// This state transition code should actually be located in a Downloads // This state transition code should actually be located in a Downloads
// API module (bug 941009). Moreover, the fact that state is stored as // API module (bug 941009).
// annotations should be ideally hidden behind methods of DownloadHistory.updateMetaData(download);
// nsIDownloadHistory (bug 830415).
if (!this._isPrivate) {
try {
let downloadMetaData = {
state: DownloadsCommon.stateOfDownload(download),
endTime: download.endTime,
};
if (download.succeeded) {
downloadMetaData.fileSize = download.target.size;
}
if (download.error && download.error.reputationCheckVerdict) {
downloadMetaData.reputationCheckVerdict =
download.error.reputationCheckVerdict;
}
PlacesUtils.annotations.setPageAnnotation(
NetUtil.newURI(download.source.url),
"downloads/metaData",
JSON.stringify(downloadMetaData), 0,
PlacesUtils.annotations.EXPIRE_WITH_HISTORY);
} catch (ex) {
Cu.reportError(ex);
}
}
} }
if (download.succeeded || if (download.succeeded ||

View file

@ -39,7 +39,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "SafeBrowsing",
ProcessHangMonitor:false, ReaderParent:false, RecentWindow:false, ProcessHangMonitor:false, ReaderParent:false, RecentWindow:false,
RemotePrompt:false, SessionStore:false, RemotePrompt:false, SessionStore:false,
ShellService:false, SimpleServiceDiscovery:false, TabCrashHandler:false, ShellService:false, SimpleServiceDiscovery:false, TabCrashHandler:false,
Task:false, UITour:false, UIState:false, UpdateListener:false, WebChannel:false, UITour:false, UIState:false, UpdateListener:false, WebChannel:false,
WindowsRegistry:false, webrtcUI:false */ WindowsRegistry:false, webrtcUI:false */
@ -94,7 +94,6 @@ let initializedModules = {};
["ShellService", "resource:///modules/ShellService.jsm"], ["ShellService", "resource:///modules/ShellService.jsm"],
["SimpleServiceDiscovery", "resource://gre/modules/SimpleServiceDiscovery.jsm"], ["SimpleServiceDiscovery", "resource://gre/modules/SimpleServiceDiscovery.jsm"],
["TabCrashHandler", "resource:///modules/ContentCrashHandlers.jsm"], ["TabCrashHandler", "resource:///modules/ContentCrashHandlers.jsm"],
["Task", "resource://gre/modules/Task.jsm"],
["UIState", "resource://services-sync/UIState.jsm"], ["UIState", "resource://services-sync/UIState.jsm"],
["UITour", "resource:///modules/UITour.jsm"], ["UITour", "resource:///modules/UITour.jsm"],
["UpdateListener", "resource://gre/modules/UpdateListener.jsm", "init"], ["UpdateListener", "resource://gre/modules/UpdateListener.jsm", "init"],

View file

@ -11,6 +11,7 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
const TABLISTENER_JSM = "chrome://webcompat-reporter/content/TabListener.jsm"; const TABLISTENER_JSM = "chrome://webcompat-reporter/content/TabListener.jsm";
const WIDGET_ID = "webcompat-reporter-button"; const WIDGET_ID = "webcompat-reporter-button";
const PREF_STYLO_ENABLED = "layout.css.servo.enabled";
XPCOMUtils.defineLazyModuleGetter(this, "CustomizableUI", XPCOMUtils.defineLazyModuleGetter(this, "CustomizableUI",
"resource:///modules/CustomizableUI.jsm"); "resource:///modules/CustomizableUI.jsm");
@ -120,9 +121,18 @@ let WebCompatReporter = {
const FRAMESCRIPT = "chrome://webcompat-reporter/content/wc-frame.js"; const FRAMESCRIPT = "chrome://webcompat-reporter/content/wc-frame.js";
let win = Services.wm.getMostRecentWindow("navigator:browser"); let win = Services.wm.getMostRecentWindow("navigator:browser");
const WEBCOMPAT_ORIGIN = new win.URL(WebCompatReporter.endpoint).origin; const WEBCOMPAT_ORIGIN = new win.URL(WebCompatReporter.endpoint).origin;
let styloEnabled = Services.prefs.getBoolPref(PREF_STYLO_ENABLED, false);
let params = new URLSearchParams();
params.append("url", `${tabData.url}`);
params.append("src", "desktop-reporter");
if (styloEnabled) {
params.append("details", "layout.css.servo.enabled: true");
params.append("label", "type-stylo");
}
let tab = gBrowser.loadOneTab( let tab = gBrowser.loadOneTab(
`${WebCompatReporter.endpoint}?url=${encodeURIComponent(tabData.url)}&src=desktop-reporter`, `${WebCompatReporter.endpoint}?${params}`,
{inBackground: false, triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal()}); {inBackground: false, triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal()});
// If we successfully got a screenshot blob, add a listener to know when // If we successfully got a screenshot blob, add a listener to know when

View file

@ -250,7 +250,6 @@ def old_configure_options(*options):
'--with-app-name', '--with-app-name',
'--with-arch', '--with-arch',
'--with-branding', '--with-branding',
'--with-crashreporter-enable-percent',
'--with-cross-lib', '--with-cross-lib',
'--with-debug-label', '--with-debug-label',
'--with-default-mozilla-five-home', '--with-default-mozilla-five-home',

View file

@ -33,3 +33,4 @@ support-files =
[browser_grids_grid-outline-updates-on-grid-change.js] [browser_grids_grid-outline-updates-on-grid-change.js]
[browser_grids_highlighter-setting-rules-grid-toggle.js] [browser_grids_highlighter-setting-rules-grid-toggle.js]
[browser_grids_number-of-css-grids-telemetry.js] [browser_grids_number-of-css-grids-telemetry.js]
[browser_grids_restored-after-reload.js]

View file

@ -0,0 +1,87 @@
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Tests that the grid highlighter is re-displayed after reloading a page and the grid
// item is highlighted.
const TEST_URI = `
<style type='text/css'>
#grid {
display: grid;
}
</style>
<div id="grid">
<div id="cell1">cell1</div>
<div id="cell2">cell2</div>
</div>
`;
const OTHER_URI = `
<style type='text/css'>
#grid {
display: grid;
}
</style>
<div id="grid">
<div id="cell1">cell1</div>
<div id="cell2">cell2</div>
<div id="cell3">cell3</div>
</div>
`;
add_task(function* () {
yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
let { gridInspector, inspector } = yield openLayoutView();
let { document: doc } = gridInspector;
let { highlighters, store } = inspector;
yield selectNode("#grid", inspector);
let gridList = doc.getElementById("grid-list");
let checkbox = gridList.children[0].querySelector("input");
info("Toggling ON the CSS grid highlighter from the layout panel.");
let onHighlighterShown = highlighters.once("grid-highlighter-shown");
let onCheckboxChange = waitUntilState(store, state =>
state.grids.length == 1 &&
state.grids[0].highlighted);
checkbox.click();
yield onHighlighterShown;
yield onCheckboxChange;
info("Checking the CSS grid highlighter is created.");
ok(highlighters.highlighters[HIGHLIGHTER_TYPE],
"CSS grid highlighter is created in the highlighters overlay.");
ok(highlighters.gridHighlighterShown, "CSS grid highlighter is shown.");
info("Reload the page, expect the highlighter to be displayed once again and " +
"grid is checked");
let onStateRestored = highlighters.once("grid-state-restored");
let onGridListRestored = waitUntilState(store, state =>
state.grids.length == 1 &&
state.grids[0].highlighted);
yield refreshTab(gBrowser.selectedTab);
let { restored } = yield onStateRestored;
yield onGridListRestored;
info("Check that the grid highlighter can be displayed after reloading the page");
ok(restored, "The highlighter state was restored");
ok(highlighters.gridHighlighterShown, "CSS grid highlighter is shown.");
info("Navigate to another URL, and check that the highlighter is hidden and " +
"grid is unchecked");
let otherUri = "data:text/html;charset=utf-8," + encodeURIComponent(OTHER_URI);
onStateRestored = highlighters.once("grid-state-restored");
onGridListRestored = waitUntilState(store, state =>
state.grids.length == 1 &&
!state.grids[0].highlighted);
yield navigateTo(inspector, otherUri);
({ restored } = yield onStateRestored);
yield onGridListRestored;
info("Check that the grid highlighter is hidden after navigating to a different page");
ok(!restored, "The highlighter state was not restored");
ok(!highlighters.gridHighlighterShown, "CSS grid highlighter is hidden.");
});

View file

@ -108,21 +108,23 @@ function Inspector(toolbox) {
this.nodeMenuTriggerInfo = null; this.nodeMenuTriggerInfo = null;
this._handleRejectionIfNotDestroyed = this._handleRejectionIfNotDestroyed.bind(this); this._handleRejectionIfNotDestroyed = this._handleRejectionIfNotDestroyed.bind(this);
this._onBeforeNavigate = this._onBeforeNavigate.bind(this);
this.onNewRoot = this.onNewRoot.bind(this);
this._onContextMenu = this._onContextMenu.bind(this); this._onContextMenu = this._onContextMenu.bind(this);
this.onTextBoxContextMenu = this.onTextBoxContextMenu.bind(this); this._onBeforeNavigate = this._onBeforeNavigate.bind(this);
this._updateSearchResultsLabel = this._updateSearchResultsLabel.bind(this);
this.onNewSelection = this.onNewSelection.bind(this);
this.onDetached = this.onDetached.bind(this);
this.onPaneToggleButtonClicked = this.onPaneToggleButtonClicked.bind(this);
this._onMarkupFrameLoad = this._onMarkupFrameLoad.bind(this); this._onMarkupFrameLoad = this._onMarkupFrameLoad.bind(this);
this._updateSearchResultsLabel = this._updateSearchResultsLabel.bind(this);
this.onDetached = this.onDetached.bind(this);
this.onMarkupLoaded = this.onMarkupLoaded.bind(this);
this.onNewSelection = this.onNewSelection.bind(this);
this.onNewRoot = this.onNewRoot.bind(this);
this.onPaneToggleButtonClicked = this.onPaneToggleButtonClicked.bind(this);
this.onPanelWindowResize = this.onPanelWindowResize.bind(this); this.onPanelWindowResize = this.onPanelWindowResize.bind(this);
this.onSidebarShown = this.onSidebarShown.bind(this);
this.onSidebarHidden = this.onSidebarHidden.bind(this);
this.onSidebarSelect = this.onSidebarSelect.bind(this);
this.onShowBoxModelHighlighterForNode = this.onShowBoxModelHighlighterForNode =
this.onShowBoxModelHighlighterForNode.bind(this); this.onShowBoxModelHighlighterForNode.bind(this);
this.onSidebarHidden = this.onSidebarHidden.bind(this);
this.onSidebarSelect = this.onSidebarSelect.bind(this);
this.onSidebarShown = this.onSidebarShown.bind(this);
this.onTextBoxContextMenu = this.onTextBoxContextMenu.bind(this);
this._target.on("will-navigate", this._onBeforeNavigate); this._target.on("will-navigate", this._onBeforeNavigate);
this._detectingActorFeatures = this._detectActorFeatures(); this._detectingActorFeatures = this._detectActorFeatures();
@ -779,13 +781,7 @@ Inspector.prototype = {
this.selection.setNodeFront(defaultNode, "navigateaway"); this.selection.setNodeFront(defaultNode, "navigateaway");
this._initMarkup(); this._initMarkup();
this.once("markuploaded", () => { this.once("markuploaded", this.onMarkupLoaded);
if (!this.markup) {
return;
}
this.markup.expandNode(this.selection.nodeFront);
this.emit("new-root");
});
// Setup the toolbar again, since its content may depend on the current document. // Setup the toolbar again, since its content may depend on the current document.
this.setupToolbar(); this.setupToolbar();
@ -795,6 +791,27 @@ Inspector.prototype = {
.then(onNodeSelected, this._handleRejectionIfNotDestroyed); .then(onNodeSelected, this._handleRejectionIfNotDestroyed);
}, },
/**
* Handler for "markuploaded" event fired on a new root mutation and after the markup
* view is initialized. Expands the current selected node and restores the saved
* highlighter state.
*/
onMarkupLoaded: Task.async(function* () {
if (!this.markup) {
return;
}
this.markup.expandNode(this.selection.nodeFront);
// Restore the highlighter states prior to emitting "new-root".
yield Promise.all([
this.highlighters.restoreGridState(),
this.highlighters.restoreShapeState()
]);
this.emit("new-root");
}),
_selectionCssSelector: null, _selectionCssSelector: null,
/** /**

View file

@ -52,7 +52,6 @@ function HighlightersOverlay(inspector) {
this.onMouseMove = this.onMouseMove.bind(this); this.onMouseMove = this.onMouseMove.bind(this);
this.onMouseOut = this.onMouseOut.bind(this); this.onMouseOut = this.onMouseOut.bind(this);
this.onWillNavigate = this.onWillNavigate.bind(this); this.onWillNavigate = this.onWillNavigate.bind(this);
this.onNavigate = this.onNavigate.bind(this);
this.showGridHighlighter = this.showGridHighlighter.bind(this); this.showGridHighlighter = this.showGridHighlighter.bind(this);
this.showShapesHighlighter = this.showShapesHighlighter.bind(this); this.showShapesHighlighter = this.showShapesHighlighter.bind(this);
this._handleRejection = this._handleRejection.bind(this); this._handleRejection = this._handleRejection.bind(this);
@ -60,7 +59,6 @@ function HighlightersOverlay(inspector) {
// Add inspector events, not specific to a given view. // Add inspector events, not specific to a given view.
this.inspector.on("markupmutation", this.onMarkupMutation); this.inspector.on("markupmutation", this.onMarkupMutation);
this.inspector.target.on("navigate", this.onNavigate);
this.inspector.target.on("will-navigate", this.onWillNavigate); this.inspector.target.on("will-navigate", this.onWillNavigate);
EventEmitter.decorate(this); EventEmitter.decorate(this);
@ -387,7 +385,31 @@ HighlightersOverlay.prototype = {
}, },
/** /**
* Restore the saved highlighter states. * Restores the saved grid highlighter state.
*/
restoreGridState: Task.async(function* () {
try {
yield this.restoreState("grid", this.state.grid, this.showGridHighlighter);
} catch (e) {
this._handleRejection(e);
}
}),
/**
* Restores the saved shape highlighter state.
*/
restoreShapeState: Task.async(function* () {
try {
yield this.restoreState("shapes", this.state.shapes, this.showShapesHighlighter);
} catch (e) {
this._handleRejection(e);
}
}),
/**
* Helper function called by restoreGridState and restoreShapeState.
* Restores the saved highlighter state for the given highlighter and their state.
*
* @param {String} name * @param {String} name
* The name of the highlighter to be restored * The name of the highlighter to be restored
* @param {Object} state * @param {Object} state
@ -399,15 +421,13 @@ HighlightersOverlay.prototype = {
*/ */
restoreState: Task.async(function* (name, state, showFunction) { restoreState: Task.async(function* (name, state, showFunction) {
let { selector, options, url } = state; let { selector, options, url } = state;
if (!selector || url !== this.inspector.target.url) { if (!selector || url !== this.inspector.target.url) {
// Bail out if no selector was saved, or if we are on a different page. // Bail out if no selector was saved, or if we are on a different page.
this.emit(`${name}-state-restored`, { restored: false }); this.emit(`${name}-state-restored`, { restored: false });
return; return;
} }
// Wait for the new root to be ready in the inspector.
yield this.onInspectorNewRoot;
let walker = this.inspector.walker; let walker = this.inspector.walker;
let rootNode = yield walker.getRootNode(); let rootNode = yield walker.getRootNode();
let nodeFront = yield walker.querySelector(rootNode, selector); let nodeFront = yield walker.querySelector(rootNode, selector);
@ -713,18 +733,6 @@ HighlightersOverlay.prototype = {
} }
}), }),
/**
* Restore saved highlighter state after navigate.
*/
onNavigate: Task.async(function* () {
try {
yield this.restoreState("grid", this.state.grid, this.showGridHighlighter);
yield this.restoreState("shapes", this.state.shapes, this.showShapesHighlighter);
} catch (e) {
this._handleRejection(e);
}
}),
/** /**
* Clear saved highlighter shown properties on will-navigate. * Clear saved highlighter shown properties on will-navigate.
*/ */
@ -734,9 +742,6 @@ HighlightersOverlay.prototype = {
this.hoveredHighlighterShown = null; this.hoveredHighlighterShown = null;
this.selectorHighlighterShown = null; this.selectorHighlighterShown = null;
this.shapesHighlighterShown = null; this.shapesHighlighterShown = null;
// The inspector panel should emit the new-root event when it is ready after navigate.
this.onInspectorNewRoot = this.inspector.once("new-root");
}, },
/** /**
@ -756,7 +761,6 @@ HighlightersOverlay.prototype = {
// Remove inspector events. // Remove inspector events.
this.inspector.off("markupmutation", this.onMarkupMutation); this.inspector.off("markupmutation", this.onMarkupMutation);
this.inspector.target.off("navigate", this.onNavigate);
this.inspector.target.off("will-navigate", this.onWillNavigate); this.inspector.target.off("will-navigate", this.onWillNavigate);
this._lastHovered = null; this._lastHovered = null;

View file

@ -81,6 +81,7 @@ pref("devtools.gridinspector.gridOutlineMaxRows", 50);
pref("devtools.gridinspector.showGridAreas", false); pref("devtools.gridinspector.showGridAreas", false);
pref("devtools.gridinspector.showGridLineNumbers", false); pref("devtools.gridinspector.showGridLineNumbers", false);
pref("devtools.gridinspector.showInfiniteLines", false); pref("devtools.gridinspector.showInfiniteLines", false);
pref("devtools.gridinspector.showNegativeLineNumbers", false);
// Whether or not the box model panel is opened in the computed view // Whether or not the box model panel is opened in the computed view
pref("devtools.computed.boxmodel.opened", true); pref("devtools.computed.boxmodel.opened", true);

View file

@ -34,6 +34,7 @@ const LAYOUT_STRINGS_URI = "devtools/client/locales/layout.properties";
const LAYOUT_L10N = new LocalizationHelper(LAYOUT_STRINGS_URI); const LAYOUT_L10N = new LocalizationHelper(LAYOUT_STRINGS_URI);
const CSS_GRID_ENABLED_PREF = "layout.css.grid.enabled"; const CSS_GRID_ENABLED_PREF = "layout.css.grid.enabled";
const NEGATIVE_LINE_NUMBERS_PREF = "devtools.gridinspector.showNegativeLineNumbers";
const DEFAULT_GRID_COLOR = "#4B0082"; const DEFAULT_GRID_COLOR = "#4B0082";
@ -352,11 +353,9 @@ class CssGridHighlighter extends AutoRefreshHighlighter {
this.markup = new CanvasFrameAnonymousContentHelper(this.highlighterEnv, this.markup = new CanvasFrameAnonymousContentHelper(this.highlighterEnv,
this._buildMarkup.bind(this)); this._buildMarkup.bind(this));
this.onNavigate = this.onNavigate.bind(this);
this.onPageHide = this.onPageHide.bind(this); this.onPageHide = this.onPageHide.bind(this);
this.onWillNavigate = this.onWillNavigate.bind(this); this.onWillNavigate = this.onWillNavigate.bind(this);
this.highlighterEnv.on("navigate", this.onNavigate);
this.highlighterEnv.on("will-navigate", this.onWillNavigate); this.highlighterEnv.on("will-navigate", this.onWillNavigate);
let { pageListenerTarget } = highlighterEnv; let { pageListenerTarget } = highlighterEnv;
@ -590,7 +589,6 @@ class CssGridHighlighter extends AutoRefreshHighlighter {
destroy() { destroy() {
let { highlighterEnv } = this; let { highlighterEnv } = this;
highlighterEnv.off("navigate", this.onNavigate);
highlighterEnv.off("will-navigate", this.onWillNavigate); highlighterEnv.off("will-navigate", this.onWillNavigate);
let { pageListenerTarget } = highlighterEnv; let { pageListenerTarget } = highlighterEnv;
@ -677,14 +675,6 @@ class CssGridHighlighter extends AutoRefreshHighlighter {
return pattern; return pattern;
} }
/**
* Called when the page navigates. Used to clear the cached gap patterns and avoid
* using DeadWrapper objects as gap patterns the next time.
*/
onNavigate() {
this._clearCache();
}
onPageHide({ target }) { onPageHide({ target }) {
// If a page hide event is triggered for current window's highlighter, hide the // If a page hide event is triggered for current window's highlighter, hide the
// highlighter. // highlighter.
@ -693,7 +683,14 @@ class CssGridHighlighter extends AutoRefreshHighlighter {
} }
} }
/**
* Called when the page will-navigate. Used to hide the grid highlighter and clear
* the cached gap patterns and avoid using DeadWrapper obejcts as gap patterns the
* next time.
*/
onWillNavigate({ isTopLevel }) { onWillNavigate({ isTopLevel }) {
this._clearCache();
if (isTopLevel) { if (isTopLevel) {
this.hide(); this.hide();
} }
@ -1145,6 +1142,35 @@ class CssGridHighlighter extends AutoRefreshHighlighter {
this.getFirstRowLinePos(fragment)); this.getFirstRowLinePos(fragment));
this.renderLineNumbers(fragment.rows, ROWS, "top", "left", this.renderLineNumbers(fragment.rows, ROWS, "top", "left",
this.getFirstColLinePos(fragment)); this.getFirstColLinePos(fragment));
if (Services.prefs.getBoolPref(NEGATIVE_LINE_NUMBERS_PREF)) {
this.renderNegativeLineNumbers(fragment.cols, COLUMNS, "left", "top",
this.getLastRowLinePos(fragment));
this.renderNegativeLineNumbers(fragment.rows, ROWS, "top", "left",
this.getLastColLinePos(fragment));
}
}
}
/**
* Render the negative grid lines given the grid dimension information of the
* column or row lines.
*
* See @param for renderLines.
*/
renderNegativeLineNumbers(gridDimension, dimensionType, mainSide, crossSide,
startPos) {
let lineStartPos = startPos;
const { lines } = gridDimension;
for (let i = 0, line = lines[i]; i < lines.length; line = lines[++i]) {
let linePos = line.start;
const negativeLineNumber = i - lines.length;
this.renderGridLineNumber(negativeLineNumber, linePos, lineStartPos, line.breadth,
dimensionType);
} }
} }
@ -1331,6 +1357,9 @@ class CssGridHighlighter extends AutoRefreshHighlighter {
startPos) { startPos) {
let lineStartPos = startPos; let lineStartPos = startPos;
// Keep track of the number of collapsed lines per line position
let stackedLines = [];
for (let i = 0; i < gridDimension.lines.length; i++) { for (let i = 0; i < gridDimension.lines.length; i++) {
let line = gridDimension.lines[i]; let line = gridDimension.lines[i];
let linePos = line.start; let linePos = line.start;
@ -1347,6 +1376,21 @@ class CssGridHighlighter extends AutoRefreshHighlighter {
continue; continue;
} }
// Check for overlapping lines. We render a second box beneath the last overlapping
// line number to indicate there are lines beneath it.
const gridLine = gridDimension.tracks[line.number - 1];
if (gridLine) {
const { breadth } = gridLine;
if (breadth === 0) {
stackedLines.push(gridDimension.lines[i].number);
if (stackedLines.length > 0) {
this.renderGridLineNumber(line.number, linePos, lineStartPos, line.breadth,
dimensionType, 1);
}
continue;
}
}
this.renderGridLineNumber(line.number, linePos, lineStartPos, line.breadth, this.renderGridLineNumber(line.number, linePos, lineStartPos, line.breadth,
dimensionType); dimensionType);
} }
@ -1425,8 +1469,11 @@ class CssGridHighlighter extends AutoRefreshHighlighter {
* The grid line breadth value. * The grid line breadth value.
* @param {String} dimensionType * @param {String} dimensionType
* The grid dimension type which is either the constant COLUMNS or ROWS. * The grid dimension type which is either the constant COLUMNS or ROWS.
* @param {Number||undefined} stackedLineIndex
* The line index position of the stacked line.
*/ */
renderGridLineNumber(lineNumber, linePos, startPos, breadth, dimensionType) { renderGridLineNumber(lineNumber, linePos, startPos, breadth, dimensionType,
stackedLineIndex) {
let displayPixelRatio = getDisplayPixelRatio(this.win); let displayPixelRatio = getDisplayPixelRatio(this.win);
let { devicePixelRatio } = this.win; let { devicePixelRatio } = this.win;
let offset = (displayPixelRatio / 2) % 1; let offset = (displayPixelRatio / 2) % 1;
@ -1463,6 +1510,18 @@ class CssGridHighlighter extends AutoRefreshHighlighter {
// centered on the line, and in the middle of the gap if there is any. // centered on the line, and in the middle of the gap if there is any.
let x, y; let x, y;
let startOffset = (boxHeight + 2) / devicePixelRatio;
if (Services.prefs.getBoolPref(NEGATIVE_LINE_NUMBERS_PREF)) {
// If the line number is negative, offset it from the grid container edge,
// (downwards if its a column, rightwards if its a row).
if (lineNumber < 0) {
startPos += startOffset;
} else {
startPos -= startOffset;
}
}
if (dimensionType === COLUMNS) { if (dimensionType === COLUMNS) {
x = linePos + breadth / 2; x = linePos + breadth / 2;
y = startPos; y = startPos;
@ -1476,6 +1535,15 @@ class CssGridHighlighter extends AutoRefreshHighlighter {
x -= boxWidth / 2; x -= boxWidth / 2;
y -= boxHeight / 2; y -= boxHeight / 2;
if (stackedLineIndex) {
// Offset the stacked line number by half of the box's width/height
const xOffset = boxWidth / 4;
const yOffset = boxHeight / 4;
x += xOffset;
y += yOffset;
}
if (!this.hasNodeTransformations) { if (!this.hasNodeTransformations) {
x = Math.max(x, padding); x = Math.max(x, padding);
y = Math.max(y, padding); y = Math.max(y, padding);
@ -1491,7 +1559,8 @@ class CssGridHighlighter extends AutoRefreshHighlighter {
// Write the line number inside of the rectangle. // Write the line number inside of the rectangle.
this.ctx.fillStyle = "black"; this.ctx.fillStyle = "black";
this.ctx.fillText(lineNumber, x + padding, y + textHeight + padding); const numberText = stackedLineIndex ? "" : lineNumber;
this.ctx.fillText(numberText, x + padding, y + textHeight + padding);
this.ctx.restore(); this.ctx.restore();
} }

View file

@ -1771,8 +1771,7 @@ nsDocShell::FirePageHideNotificationInternal(bool aIsUnload,
} }
nsresult nsresult
nsDocShell::DispatchToTabGroup(const char* aName, nsDocShell::DispatchToTabGroup(TaskCategory aCategory,
TaskCategory aCategory,
already_AddRefed<nsIRunnable>&& aRunnable) already_AddRefed<nsIRunnable>&& aRunnable)
{ {
// Hold the ref so we won't forget to release it. // Hold the ref so we won't forget to release it.
@ -1785,14 +1784,13 @@ nsDocShell::DispatchToTabGroup(const char* aName,
} }
RefPtr<mozilla::dom::TabGroup> tabGroup = win->TabGroup(); RefPtr<mozilla::dom::TabGroup> tabGroup = win->TabGroup();
return tabGroup->Dispatch(aName, aCategory, runnable.forget()); return tabGroup->Dispatch(aCategory, runnable.forget());
} }
NS_IMETHODIMP NS_IMETHODIMP
nsDocShell::DispatchLocationChangeEvent() nsDocShell::DispatchLocationChangeEvent()
{ {
return DispatchToTabGroup( return DispatchToTabGroup(
"nsDocShell::FireDummyOnLocationChange",
TaskCategory::Other, TaskCategory::Other,
NewRunnableMethod("nsDocShell::FireDummyOnLocationChange", NewRunnableMethod("nsDocShell::FireDummyOnLocationChange",
this, this,
@ -6793,18 +6791,12 @@ nsDocShell::RefreshURI(nsIURI* aURI, int32_t aDelay, bool aRepeat,
return NS_OK; return NS_OK;
} }
nsRefreshTimer* refreshTimer = new nsRefreshTimer(); nsCOMPtr<nsITimerCallback> refreshTimer =
new nsRefreshTimer(this, aURI, aDelay, aRepeat, aMetaRefresh);
uint32_t busyFlags = 0; uint32_t busyFlags = 0;
GetBusyFlags(&busyFlags); GetBusyFlags(&busyFlags);
nsCOMPtr<nsISupports> dataRef = refreshTimer; // Get the ref count to 1
refreshTimer->mDocShell = this;
refreshTimer->mURI = aURI;
refreshTimer->mDelay = aDelay;
refreshTimer->mRepeat = aRepeat;
refreshTimer->mMetaRefresh = aMetaRefresh;
if (!mRefreshURIList) { if (!mRefreshURIList) {
mRefreshURIList = nsArray::Create(); mRefreshURIList = nsArray::Create();
} }
@ -8592,8 +8584,7 @@ nsDocShell::RestorePresentation(nsISHEntry* aSHEntry, bool* aRestoring)
mRestorePresentationEvent.Revoke(); mRestorePresentationEvent.Revoke();
RefPtr<RestorePresentationEvent> evt = new RestorePresentationEvent(this); RefPtr<RestorePresentationEvent> evt = new RestorePresentationEvent(this);
nsresult rv = DispatchToTabGroup("nsDocShell::RestorePresentationEvent", nsresult rv = DispatchToTabGroup(TaskCategory::Other,
TaskCategory::Other,
RefPtr<RestorePresentationEvent>(evt).forget()); RefPtr<RestorePresentationEvent>(evt).forget());
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
mRestorePresentationEvent = evt.get(); mRestorePresentationEvent = evt.get();
@ -10264,8 +10255,7 @@ nsDocShell::InternalLoad(nsIURI* aURI,
aFlags, aTypeHint, aPostData, aHeadersData, aFlags, aTypeHint, aPostData, aHeadersData,
aLoadType, aSHEntry, aFirstParty, aSrcdoc, aLoadType, aSHEntry, aFirstParty, aSrcdoc,
aSourceDocShell, aBaseURI, false); aSourceDocShell, aBaseURI, false);
return DispatchToTabGroup("nsDocShell::InternalLoadEvent", return DispatchToTabGroup(TaskCategory::Other, ev.forget());
TaskCategory::Other, ev.forget());
} }
// Just ignore this load attempt // Just ignore this load attempt
@ -13634,8 +13624,10 @@ nsDocShell::SetLayoutHistoryState(nsILayoutHistoryState* aLayoutHistoryState)
return NS_OK; return NS_OK;
} }
nsRefreshTimer::nsRefreshTimer() nsRefreshTimer::nsRefreshTimer(nsDocShell* aDocShell, nsIURI* aURI,
: mDelay(0), mRepeat(false), mMetaRefresh(false) int32_t aDelay, bool aRepeat, bool aMetaRefresh)
: mDocShell(aDocShell), mURI(aURI), mDelay(aDelay), mRepeat(aRepeat),
mMetaRefresh(aMetaRefresh)
{ {
} }
@ -13649,6 +13641,7 @@ NS_IMPL_RELEASE(nsRefreshTimer)
NS_INTERFACE_MAP_BEGIN(nsRefreshTimer) NS_INTERFACE_MAP_BEGIN(nsRefreshTimer)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsITimerCallback) NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsITimerCallback)
NS_INTERFACE_MAP_ENTRY(nsITimerCallback) NS_INTERFACE_MAP_ENTRY(nsITimerCallback)
NS_INTERFACE_MAP_ENTRY(nsINamed)
NS_INTERFACE_MAP_END_THREADSAFE NS_INTERFACE_MAP_END_THREADSAFE
NS_IMETHODIMP NS_IMETHODIMP
@ -13665,6 +13658,13 @@ nsRefreshTimer::Notify(nsITimer* aTimer)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
nsRefreshTimer::GetName(nsACString& aName)
{
aName.AssignLiteral("nsRefreshTimer");
return NS_OK;
}
nsDocShell::InterfaceRequestorProxy::InterfaceRequestorProxy( nsDocShell::InterfaceRequestorProxy::InterfaceRequestorProxy(
nsIInterfaceRequestor* aRequestor) nsIInterfaceRequestor* aRequestor)
{ {
@ -14166,8 +14166,7 @@ nsDocShell::OnLinkClick(nsIContent* aContent,
new OnLinkClickEvent(this, aContent, aURI, target.get(), aFileName, new OnLinkClickEvent(this, aContent, aURI, target.get(), aFileName,
aPostDataStream, aHeadersDataStream, noOpenerImplied, aPostDataStream, aHeadersDataStream, noOpenerImplied,
aIsTrusted, aTriggeringPrincipal); aIsTrusted, aTriggeringPrincipal);
return DispatchToTabGroup("nsDocShell::OnLinkClickEvent", return DispatchToTabGroup(TaskCategory::UI, ev.forget());
TaskCategory::UI, ev.forget());
} }
NS_IMETHODIMP NS_IMETHODIMP

View file

@ -44,6 +44,7 @@
// Interfaces Needed // Interfaces Needed
#include "nsIDocCharset.h" #include "nsIDocCharset.h"
#include "nsIInterfaceRequestor.h" #include "nsIInterfaceRequestor.h"
#include "nsINamed.h"
#include "nsIRefreshURI.h" #include "nsIRefreshURI.h"
#include "nsIWebNavigation.h" #include "nsIWebNavigation.h"
#include "nsIWebPageDescriptor.h" #include "nsIWebPageDescriptor.h"
@ -106,12 +107,15 @@ enum ViewMode
}; };
class nsRefreshTimer : public nsITimerCallback class nsRefreshTimer : public nsITimerCallback
, public nsINamed
{ {
public: public:
nsRefreshTimer(); nsRefreshTimer(nsDocShell* aDocShell, nsIURI* aURI, int32_t aDelay,
bool aRepeat, bool aMetaRefresh);
NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSITIMERCALLBACK NS_DECL_NSITIMERCALLBACK
NS_DECL_NSINAMED
int32_t GetDelay() { return mDelay ;} int32_t GetDelay() { return mDelay ;}
@ -1090,8 +1094,7 @@ private:
bool aSkipCheckingDynEntries); bool aSkipCheckingDynEntries);
// Dispatch a runnable to the TabGroup associated to this docshell. // Dispatch a runnable to the TabGroup associated to this docshell.
nsresult DispatchToTabGroup(const char* aName, nsresult DispatchToTabGroup(mozilla::TaskCategory aCategory,
mozilla::TaskCategory aCategory,
already_AddRefed<nsIRunnable>&& aRunnable); already_AddRefed<nsIRunnable>&& aRunnable);
#ifdef DEBUG #ifdef DEBUG

View file

@ -215,8 +215,7 @@ nsSHEntryShared::RemoveFromBFCacheAsync()
return NS_ERROR_UNEXPECTED; return NS_ERROR_UNEXPECTED;
} }
nsCOMPtr<nsIRunnable> evt = new DestroyViewerEvent(mContentViewer, mDocument); nsCOMPtr<nsIRunnable> evt = new DestroyViewerEvent(mContentViewer, mDocument);
nsresult rv = mDocument->Dispatch("nsSHEntryShared::DestroyViewerEvent", nsresult rv = mDocument->Dispatch(mozilla::TaskCategory::Other, evt.forget());
mozilla::TaskCategory::Other, evt.forget());
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
NS_WARNING("failed to dispatch DestroyViewerEvent"); NS_WARNING("failed to dispatch DestroyViewerEvent");
} else { } else {

View file

@ -433,15 +433,15 @@ DOMIntersectionObserver::Update(nsIDocument* aDocument, DOMHighResTimeStamp time
intersectionRatio = intersectionRect.isSome() ? 1.0 : 0.0; intersectionRatio = intersectionRect.isSome() ? 1.0 : 0.0;
} }
size_t threshold = -1; int32_t threshold = -1;
if (intersectionRatio > 0.0) { if (intersectionRatio > 0.0) {
if (intersectionRatio >= 1.0) { if (intersectionRatio >= 1.0) {
intersectionRatio = 1.0; intersectionRatio = 1.0;
threshold = mThresholds.Length(); threshold = (int32_t)mThresholds.Length();
} else { } else {
for (size_t k = 0; k < mThresholds.Length(); ++k) { for (size_t k = 0; k < mThresholds.Length(); ++k) {
if (mThresholds[k] <= intersectionRatio) { if (mThresholds[k] <= intersectionRatio) {
threshold = k + 1; threshold = (int32_t)k + 1;
} else { } else {
break; break;
} }

View file

@ -14,11 +14,10 @@ using namespace mozilla;
using namespace mozilla::dom; using namespace mozilla::dom;
nsresult nsresult
DispatcherTrait::Dispatch(const char* aName, DispatcherTrait::Dispatch(TaskCategory aCategory,
TaskCategory aCategory,
already_AddRefed<nsIRunnable>&& aRunnable) already_AddRefed<nsIRunnable>&& aRunnable)
{ {
return SchedulerGroup::UnlabeledDispatch(aName, aCategory, Move(aRunnable)); return SchedulerGroup::UnlabeledDispatch(aCategory, Move(aRunnable));
} }
nsISerialEventTarget* nsISerialEventTarget*

View file

@ -26,8 +26,7 @@ class DispatcherTrait {
public: public:
// This method may or may not be safe off of the main thread. For nsIDocument // This method may or may not be safe off of the main thread. For nsIDocument
// it is safe. For nsIGlobalWindow it is not safe. // it is safe. For nsIGlobalWindow it is not safe.
virtual nsresult Dispatch(const char* aName, virtual nsresult Dispatch(TaskCategory aCategory,
TaskCategory aCategory,
already_AddRefed<nsIRunnable>&& aRunnable); already_AddRefed<nsIRunnable>&& aRunnable);
// This method may or may not be safe off of the main thread. For nsIDocument // This method may or may not be safe off of the main thread. For nsIDocument

View file

@ -56,11 +56,10 @@ DocGroup::~DocGroup()
} }
nsresult nsresult
DocGroup::Dispatch(const char* aName, DocGroup::Dispatch(TaskCategory aCategory,
TaskCategory aCategory,
already_AddRefed<nsIRunnable>&& aRunnable) already_AddRefed<nsIRunnable>&& aRunnable)
{ {
return mTabGroup->Dispatch(aName, aCategory, Move(aRunnable)); return mTabGroup->Dispatch(aCategory, Move(aRunnable));
} }
nsISerialEventTarget* nsISerialEventTarget*

View file

@ -80,8 +80,7 @@ public:
return mDocuments.end(); return mDocuments.end();
} }
nsresult Dispatch(const char* aName, nsresult Dispatch(TaskCategory aCategory,
TaskCategory aCategory,
already_AddRefed<nsIRunnable>&& aRunnable); already_AddRefed<nsIRunnable>&& aRunnable);
nsISerialEventTarget* EventTargetFor(TaskCategory aCategory) const; nsISerialEventTarget* EventTargetFor(TaskCategory aCategory) const;

View file

@ -52,6 +52,7 @@
#include "nsITimer.h" #include "nsITimer.h"
#include "nsIDOMDocument.h" #include "nsIDOMDocument.h"
#include "nsIDocument.h" #include "nsIDocument.h"
#include "nsINamed.h"
#include "nsISelectionController.h"//for the enums #include "nsISelectionController.h"//for the enums
#include "nsAutoCopyListener.h" #include "nsAutoCopyListener.h"
@ -196,6 +197,7 @@ struct CachedOffsetForFrame {
}; };
class nsAutoScrollTimer final : public nsITimerCallback class nsAutoScrollTimer final : public nsITimerCallback
, public nsINamed
{ {
public: public:
@ -280,6 +282,12 @@ public:
return NS_OK; return NS_OK;
} }
NS_IMETHOD GetName(nsACString& aName) override
{
aName.AssignLiteral("nsAutoScrollTimer");
return NS_OK;
}
protected: protected:
virtual ~nsAutoScrollTimer() virtual ~nsAutoScrollTimer()
{ {
@ -299,7 +307,7 @@ private:
uint32_t mDelay; uint32_t mDelay;
}; };
NS_IMPL_ISUPPORTS(nsAutoScrollTimer, nsITimerCallback) NS_IMPL_ISUPPORTS(nsAutoScrollTimer, nsITimerCallback, nsINamed)
nsresult NS_NewDomSelection(nsISelection **aDomSelection) nsresult NS_NewDomSelection(nsISelection **aDomSelection)
{ {

View file

@ -244,11 +244,5 @@ TimeoutExecutor::GetName(nsACString& aNameOut)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
TimeoutExecutor::SetName(const char* aName)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
} // namespace dom } // namespace dom
} // namespace mozilla } // namespace mozilla

View file

@ -10,6 +10,8 @@
#include "mozilla/Telemetry.h" #include "mozilla/Telemetry.h"
#include "mozilla/ThrottledEventQueue.h" #include "mozilla/ThrottledEventQueue.h"
#include "mozilla/TimeStamp.h" #include "mozilla/TimeStamp.h"
#include "nsIDocShell.h"
#include "nsINamed.h"
#include "nsITimeoutHandler.h" #include "nsITimeoutHandler.h"
#include "mozilla/dom/TabGroup.h" #include "mozilla/dom/TabGroup.h"
#include "OrderedTimeoutIterator.h" #include "OrderedTimeoutIterator.h"
@ -107,10 +109,6 @@ TimeoutManager::IsActive() const
// A window is considered active if: // A window is considered active if:
// * It is a chrome window // * It is a chrome window
// * It is playing audio // * It is playing audio
// * If it is using user media
// * If it is using WebRTC
// * If it has open WebSockets
// * If it has active IndexedDB databases
// //
// Note that a window can be considered active if it is either in the // Note that a window can be considered active if it is either in the
// foreground or in the background. // foreground or in the background.
@ -124,45 +122,6 @@ TimeoutManager::IsActive() const
return true; return true;
} }
// Check if there are any active IndexedDB databases
if (mWindow.AsInner()->HasActiveIndexedDBDatabases()) {
return true;
}
// Check if we have active GetUserMedia
if (MediaManager::Exists() &&
MediaManager::Get()->IsWindowStillActive(mWindow.WindowID())) {
return true;
}
bool active = false;
#if 0
// Check if we have active PeerConnections This doesn't actually
// work, since we sometimes call IsActive from Resume, which in turn
// is sometimes called from nsGlobalWindow::LeaveModalState. The
// problem here is that LeaveModalState can be called with pending
// exeptions on the js context, and the following call to
// HasActivePeerConnection is a JS call, which will assert on that
// exception. Also, calling JS is expensive so we should try to fix
// this in some other way.
nsCOMPtr<IPeerConnectionManager> pcManager =
do_GetService(IPEERCONNECTION_MANAGER_CONTRACTID);
if (pcManager && NS_SUCCEEDED(pcManager->HasActivePeerConnection(
mWindow.WindowID(), &active)) &&
active) {
return true;
}
#endif // MOZ_WEBRTC
// Check if we have web sockets
RefPtr<WebSocketEventService> eventService = WebSocketEventService::Get();
if (eventService &&
NS_SUCCEEDED(eventService->HasListenerFor(mWindow.WindowID(), &active)) &&
active) {
return true;
}
return false; return false;
} }
@ -246,7 +205,7 @@ TimeoutManager::MinSchedulingDelay() const
TimeDuration unthrottled = TimeDuration unthrottled =
isBackground ? TimeDuration::FromMilliseconds(gMinBackgroundTimeoutValue) isBackground ? TimeDuration::FromMilliseconds(gMinBackgroundTimeoutValue)
: TimeDuration(); : TimeDuration();
if (mBudgetThrottleTimeouts && mExecutionBudget < TimeDuration()) { if (BudgetThrottlingEnabled() && mExecutionBudget < TimeDuration()) {
// Only throttle if execution budget is less than 0 // Only throttle if execution budget is less than 0
double factor = 1.0 / GetRegenerationFactor(mWindow.IsBackgroundInternal()); double factor = 1.0 / GetRegenerationFactor(mWindow.IsBackgroundInternal());
return TimeDuration::Min( return TimeDuration::Min(
@ -373,7 +332,7 @@ TimeoutManager::UpdateBudget(const TimeStamp& aNow, const TimeDuration& aDuratio
// window is active or not. If throttling is enabled and the window // window is active or not. If throttling is enabled and the window
// is active and then becomes inactive, an overdrawn budget will // is active and then becomes inactive, an overdrawn budget will
// still be counted against the minimum delay. // still be counted against the minimum delay.
if (mBudgetThrottleTimeouts) { if (BudgetThrottlingEnabled()) {
bool isBackground = mWindow.IsBackgroundInternal(); bool isBackground = mWindow.IsBackgroundInternal();
double factor = GetRegenerationFactor(isBackground); double factor = GetRegenerationFactor(isBackground);
TimeDuration regenerated = (aNow - mLastBudgetUpdate).MultDouble(factor); TimeDuration regenerated = (aNow - mLastBudgetUpdate).MultDouble(factor);
@ -1209,6 +1168,7 @@ TimeoutManager::IsTimeoutTracking(uint32_t aTimeoutId)
namespace { namespace {
class ThrottleTimeoutsCallback final : public nsITimerCallback class ThrottleTimeoutsCallback final : public nsITimerCallback
, public nsINamed
{ {
public: public:
explicit ThrottleTimeoutsCallback(nsGlobalWindow* aWindow) explicit ThrottleTimeoutsCallback(nsGlobalWindow* aWindow)
@ -1220,6 +1180,12 @@ public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_DECL_NSITIMERCALLBACK NS_DECL_NSITIMERCALLBACK
NS_IMETHOD GetName(nsACString& aName) override
{
aName.AssignLiteral("ThrottleTimeoutsCallback");
return NS_OK;
}
private: private:
~ThrottleTimeoutsCallback() {} ~ThrottleTimeoutsCallback() {}
@ -1229,7 +1195,7 @@ private:
RefPtr<nsGlobalWindow> mWindow; RefPtr<nsGlobalWindow> mWindow;
}; };
NS_IMPL_ISUPPORTS(ThrottleTimeoutsCallback, nsITimerCallback) NS_IMPL_ISUPPORTS(ThrottleTimeoutsCallback, nsITimerCallback, nsINamed)
NS_IMETHODIMP NS_IMETHODIMP
ThrottleTimeoutsCallback::Notify(nsITimer* aTimer) ThrottleTimeoutsCallback::Notify(nsITimer* aTimer)
@ -1241,6 +1207,66 @@ ThrottleTimeoutsCallback::Notify(nsITimer* aTimer)
} }
bool
TimeoutManager::BudgetThrottlingEnabled() const
{
// A window can be throttled using budget if
// * It isn't active
// * If it isn't using user media
// * If it isn't using WebRTC
// * If it hasn't got open WebSockets
// * If it hasn't got active IndexedDB databases
//
// Note that we allow both foreground and background to be
// considered for budget throttling. What determines if they are if
// budget throttling is enabled is the regeneration factor.
if (!mBudgetThrottleTimeouts || IsActive()) {
return false;
}
// Check if there are any active IndexedDB databases
if (mWindow.AsInner()->HasActiveIndexedDBDatabases()) {
return false;
}
// Check if we have active GetUserMedia
if (MediaManager::Exists() &&
MediaManager::Get()->IsWindowStillActive(mWindow.WindowID())) {
return false;
}
bool active = false;
#if 0
// Check if we have active PeerConnections This doesn't actually
// work, since we sometimes call IsActive from Resume, which in turn
// is sometimes called from nsGlobalWindow::LeaveModalState. The
// problem here is that LeaveModalState can be called with pending
// exeptions on the js context, and the following call to
// HasActivePeerConnection is a JS call, which will assert on that
// exception. Also, calling JS is expensive so we should try to fix
// this in some other way.
nsCOMPtr<IPeerConnectionManager> pcManager =
do_GetService(IPEERCONNECTION_MANAGER_CONTRACTID);
if (pcManager && NS_SUCCEEDED(pcManager->HasActivePeerConnection(
mWindow.WindowID(), &active)) &&
active) {
return false;
}
#endif // MOZ_WEBRTC
// Check if we have web sockets
RefPtr<WebSocketEventService> eventService = WebSocketEventService::Get();
if (eventService &&
NS_SUCCEEDED(eventService->HasListenerFor(mWindow.WindowID(), &active)) &&
active) {
return false;
}
return true;
}
void void
TimeoutManager::StartThrottlingTimeouts() TimeoutManager::StartThrottlingTimeouts()
{ {

View file

@ -148,6 +148,8 @@ private:
void UpdateBudget(const TimeStamp& aNow, void UpdateBudget(const TimeStamp& aNow,
const TimeDuration& aDuration = TimeDuration()); const TimeDuration& aDuration = TimeDuration());
bool BudgetThrottlingEnabled() const;
private: private:
struct Timeouts { struct Timeouts {
explicit Timeouts(const TimeoutManager& aManager) explicit Timeouts(const TimeoutManager& aManager)

View file

@ -249,7 +249,7 @@ NS_GetContentList(nsINode* aRootNode,
#ifdef DEBUG #ifdef DEBUG
const nsCacheableFuncStringContentList::ContentListType const nsCacheableFuncStringContentList::ContentListType
nsCacheableFuncStringNodeList::sType = nsCacheableFuncStringContentList::eNodeList; nsCachableElementsByNameNodeList::sType = nsCacheableFuncStringContentList::eNodeList;
const nsCacheableFuncStringContentList::ContentListType const nsCacheableFuncStringContentList::ContentListType
nsCacheableFuncStringHTMLCollection::sType = nsCacheableFuncStringContentList::eHTMLCollection; nsCacheableFuncStringHTMLCollection::sType = nsCacheableFuncStringContentList::eHTMLCollection;
#endif #endif
@ -338,33 +338,21 @@ GetFuncStringContentList(nsINode* aRootNode,
return list.forget(); return list.forget();
} }
// Explicit instantiations to avoid link errors
template
already_AddRefed<nsContentList> already_AddRefed<nsContentList>
NS_GetFuncStringNodeList(nsINode* aRootNode, GetFuncStringContentList<nsCachableElementsByNameNodeList>(nsINode* aRootNode,
nsContentListMatchFunc aFunc, nsContentListMatchFunc aFunc,
nsContentListDestroyFunc aDestroyFunc, nsContentListDestroyFunc aDestroyFunc,
nsFuncStringContentListDataAllocator aDataAllocator, nsFuncStringContentListDataAllocator aDataAllocator,
const nsAString& aString) const nsAString& aString);
{ template
return GetFuncStringContentList<nsCacheableFuncStringNodeList>(aRootNode,
aFunc,
aDestroyFunc,
aDataAllocator,
aString);
}
already_AddRefed<nsContentList> already_AddRefed<nsContentList>
NS_GetFuncStringHTMLCollection(nsINode* aRootNode, GetFuncStringContentList<nsCacheableFuncStringHTMLCollection>(nsINode* aRootNode,
nsContentListMatchFunc aFunc, nsContentListMatchFunc aFunc,
nsContentListDestroyFunc aDestroyFunc, nsContentListDestroyFunc aDestroyFunc,
nsFuncStringContentListDataAllocator aDataAllocator, nsFuncStringContentListDataAllocator aDataAllocator,
const nsAString& aString) const nsAString& aString);
{
return GetFuncStringContentList<nsCacheableFuncStringHTMLCollection>(aRootNode,
aFunc,
aDestroyFunc,
aDataAllocator,
aString);
}
//----------------------------------------------------- //-----------------------------------------------------
// nsContentList implementation // nsContentList implementation
@ -1076,14 +1064,33 @@ nsContentList::AssertInSync()
#endif #endif
//----------------------------------------------------- //-----------------------------------------------------
// nsCacheableFuncStringNodeList // nsCachableElementsByNameNodeList
JSObject* JSObject*
nsCacheableFuncStringNodeList::WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto) nsCachableElementsByNameNodeList::WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto)
{ {
return NodeListBinding::Wrap(cx, this, aGivenProto); return NodeListBinding::Wrap(cx, this, aGivenProto);
} }
void
nsCachableElementsByNameNodeList::AttributeChanged(nsIDocument* aDocument,
Element* aElement,
int32_t aNameSpaceID,
nsIAtom* aAttribute,
int32_t aModType,
const nsAttrValue* aOldValue)
{
// No need to rebuild the list if the changed attribute is not the name
// attribute.
if (aAttribute != nsGkAtoms::name) {
return;
}
nsCacheableFuncStringContentList::AttributeChanged(aDocument, aElement,
aNameSpaceID, aAttribute,
aModType, aOldValue);
}
//----------------------------------------------------- //-----------------------------------------------------
// nsCacheableFuncStringHTMLCollection // nsCacheableFuncStringHTMLCollection

View file

@ -546,15 +546,15 @@ protected:
nsString mString; nsString mString;
}; };
class nsCacheableFuncStringNodeList class nsCachableElementsByNameNodeList
: public nsCacheableFuncStringContentList : public nsCacheableFuncStringContentList
{ {
public: public:
nsCacheableFuncStringNodeList(nsINode* aRootNode, nsCachableElementsByNameNodeList(nsINode* aRootNode,
nsContentListMatchFunc aFunc, nsContentListMatchFunc aFunc,
nsContentListDestroyFunc aDestroyFunc, nsContentListDestroyFunc aDestroyFunc,
nsFuncStringContentListDataAllocator aDataAllocator, nsFuncStringContentListDataAllocator aDataAllocator,
const nsAString& aString) const nsAString& aString)
: nsCacheableFuncStringContentList(aRootNode, aFunc, aDestroyFunc, : nsCacheableFuncStringContentList(aRootNode, aFunc, aDestroyFunc,
aDataAllocator, aString) aDataAllocator, aString)
{ {
@ -563,6 +563,8 @@ public:
#endif #endif
} }
NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
virtual JSObject* WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override; virtual JSObject* WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
#ifdef DEBUG #ifdef DEBUG

View file

@ -57,17 +57,12 @@ NS_GetContentList(nsINode* aRootNode,
int32_t aMatchNameSpaceId, int32_t aMatchNameSpaceId,
const nsAString& aTagname); const nsAString& aTagname);
template<class ListType>
already_AddRefed<nsContentList> already_AddRefed<nsContentList>
NS_GetFuncStringNodeList(nsINode* aRootNode, GetFuncStringContentList(nsINode* aRootNode,
nsContentListMatchFunc aFunc, nsContentListMatchFunc aFunc,
nsContentListDestroyFunc aDestroyFunc, nsContentListDestroyFunc aDestroyFunc,
nsFuncStringContentListDataAllocator aDataAllocator, nsFuncStringContentListDataAllocator aDataAllocator,
const nsAString& aString); const nsAString& aString);
already_AddRefed<nsContentList>
NS_GetFuncStringHTMLCollection(nsINode* aRootNode,
nsContentListMatchFunc aFunc,
nsContentListDestroyFunc aDestroyFunc,
nsFuncStringContentListDataAllocator aDataAllocator,
const nsAString& aString);
#endif // nsContentListDeclarations_h #endif // nsContentListDeclarations_h

View file

@ -1659,9 +1659,3 @@ nsContentSink::GetName(nsACString& aName)
aName.AssignASCII("nsContentSink_timer"); aName.AssignASCII("nsContentSink_timer");
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
nsContentSink::SetName(const char* aName)
{
return NS_ERROR_NOT_IMPLEMENTED;
}

View file

@ -55,6 +55,7 @@ class imgIRequest;
class imgLoader; class imgLoader;
class imgRequestProxy; class imgRequestProxy;
class nsAutoScriptBlockerSuppressNodeRemoved; class nsAutoScriptBlockerSuppressNodeRemoved;
class nsCacheableFuncStringHTMLCollection;
class nsHtml5StringParser; class nsHtml5StringParser;
class nsIChannel; class nsIChannel;
class nsIConsoleService; class nsIConsoleService;
@ -2083,10 +2084,11 @@ public:
{ {
NS_PRECONDITION(aRootNode, "Must have root node"); NS_PRECONDITION(aRootNode, "Must have root node");
return NS_GetFuncStringHTMLCollection(aRootNode, MatchClassNames, return GetFuncStringContentList<nsCacheableFuncStringHTMLCollection>(aRootNode,
DestroyClassNameArray, MatchClassNames,
AllocClassMatchingInfo, DestroyClassNameArray,
aClasses); AllocClassMatchingInfo,
aClasses);
} }
/** /**

View file

@ -1582,7 +1582,7 @@ nsWindowSH::GlobalResolve(nsGlobalWindow *aWin, JSContext *cx,
!nsContentUtils::IsSystemPrincipal(nsContentUtils::ObjectPrincipal(obj))) !nsContentUtils::IsSystemPrincipal(nsContentUtils::ObjectPrincipal(obj)))
{ {
if (aWin->GetDoc()) { if (aWin->GetDoc()) {
aWin->GetDoc()->WarnOnceAbout(nsIDocument::eWindow_Controllers); aWin->GetDoc()->WarnOnceAbout(nsIDocument::eWindow_Cc_ontrollers);
} }
const JSClass* clazz; const JSClass* clazz;
if (id == XPCJSRuntime::Get()->GetStringID(XPCJSContext::IDX_CONTROLLERS)) { if (id == XPCJSRuntime::Get()->GetStringID(XPCJSContext::IDX_CONTROLLERS)) {

View file

@ -37,7 +37,7 @@ DEPRECATED_OPERATION(ChromeUseOfDOM3LoadMethod)
DEPRECATED_OPERATION(ShowModalDialog) DEPRECATED_OPERATION(ShowModalDialog)
DEPRECATED_OPERATION(Window_Content) DEPRECATED_OPERATION(Window_Content)
DEPRECATED_OPERATION(SyncXMLHttpRequest) DEPRECATED_OPERATION(SyncXMLHttpRequest)
DEPRECATED_OPERATION(Window_Controllers) DEPRECATED_OPERATION(Window_Cc_ontrollers)
DEPRECATED_OPERATION(ImportXULIntoContent) DEPRECATED_OPERATION(ImportXULIntoContent)
DEPRECATED_OPERATION(PannerNodeDoppler) DEPRECATED_OPERATION(PannerNodeDoppler)
DEPRECATED_OPERATION(NavigatorGetUserMedia) DEPRECATED_OPERATION(NavigatorGetUserMedia)

View file

@ -3050,15 +3050,14 @@ nsIDocument::GetDocGroup() const
} }
nsresult nsresult
nsIDocument::Dispatch(const char* aName, nsIDocument::Dispatch(TaskCategory aCategory,
TaskCategory aCategory,
already_AddRefed<nsIRunnable>&& aRunnable) already_AddRefed<nsIRunnable>&& aRunnable)
{ {
// Note that this method may be called off the main thread. // Note that this method may be called off the main thread.
if (mDocGroup) { if (mDocGroup) {
return mDocGroup->Dispatch(aName, aCategory, Move(aRunnable)); return mDocGroup->Dispatch(aCategory, Move(aRunnable));
} }
return DispatcherTrait::Dispatch(aName, aCategory, Move(aRunnable)); return DispatcherTrait::Dispatch(aCategory, Move(aRunnable));
} }
nsISerialEventTarget* nsISerialEventTarget*
@ -4459,8 +4458,7 @@ nsDocument::SetStyleSheetApplicableState(StyleSheet* aSheet,
&nsDocument::NotifyStyleSheetApplicableStateChanged); &nsDocument::NotifyStyleSheetApplicableStateChanged);
mSSApplicableStateNotificationPending = mSSApplicableStateNotificationPending =
NS_SUCCEEDED( NS_SUCCEEDED(
Dispatch("nsDocument::NotifyStyleSheetApplicableStateChanged", Dispatch(TaskCategory::Other, notification.forget()));
TaskCategory::Other, notification.forget()));
} }
} }
@ -5407,7 +5405,7 @@ nsDocument::UnblockDOMContentLoaded()
NewRunnableMethod("nsDocument::DispatchContentLoadedEvents", NewRunnableMethod("nsDocument::DispatchContentLoadedEvents",
this, this,
&nsDocument::DispatchContentLoadedEvents); &nsDocument::DispatchContentLoadedEvents);
Dispatch("nsDocument::DispatchContentLoadedEvents", TaskCategory::Other, ev.forget()); Dispatch(TaskCategory::Other, ev.forget());
} else { } else {
DispatchContentLoadedEvents(); DispatchContentLoadedEvents();
} }
@ -7047,8 +7045,7 @@ nsDocument::NotifyPossibleTitleChange(bool aBoundTitleElement)
NewNonOwningRunnableMethod("nsDocument::DoNotifyPossibleTitleChange", NewNonOwningRunnableMethod("nsDocument::DoNotifyPossibleTitleChange",
this, this,
&nsDocument::DoNotifyPossibleTitleChange); &nsDocument::DoNotifyPossibleTitleChange);
nsresult rv = Dispatch("nsDocument::DoNotifyPossibleTitleChange", nsresult rv = Dispatch(TaskCategory::Other, do_AddRef(event));
TaskCategory::Other, do_AddRef(event));
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
mPendingTitleChangeEvent = Move(event); mPendingTitleChangeEvent = Move(event);
} }
@ -8894,7 +8891,7 @@ nsDocument::PostUnblockOnloadEvent()
MOZ_RELEASE_ASSERT(NS_IsMainThread()); MOZ_RELEASE_ASSERT(NS_IsMainThread());
nsCOMPtr<nsIRunnable> evt = new nsUnblockOnloadEvent(this); nsCOMPtr<nsIRunnable> evt = new nsUnblockOnloadEvent(this);
nsresult rv = nsresult rv =
Dispatch("nsUnblockOnloadEvent", TaskCategory::Other, evt.forget()); Dispatch(TaskCategory::Other, evt.forget());
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
// Stabilize block count so we don't post more events while this one is up // Stabilize block count so we don't post more events while this one is up
++mOnloadBlockCount; ++mOnloadBlockCount;
@ -9805,7 +9802,7 @@ nsDocument::UnsuppressEventHandlingAndFireEvents(bool aFireEvents)
if (aFireEvents) { if (aFireEvents) {
MOZ_RELEASE_ASSERT(NS_IsMainThread()); MOZ_RELEASE_ASSERT(NS_IsMainThread());
nsCOMPtr<nsIRunnable> ded = new nsDelayedEventDispatcher(documents); nsCOMPtr<nsIRunnable> ded = new nsDelayedEventDispatcher(documents);
Dispatch("nsDelayedEventDispatcher", TaskCategory::Other, ded.forget()); Dispatch(TaskCategory::Other, ded.forget());
} else { } else {
FireOrClearDelayedEvents(documents, false); FireOrClearDelayedEvents(documents, false);
} }
@ -10958,7 +10955,7 @@ nsIDocument::AsyncExitFullscreen(nsIDocument* aDoc)
MOZ_RELEASE_ASSERT(NS_IsMainThread()); MOZ_RELEASE_ASSERT(NS_IsMainThread());
nsCOMPtr<nsIRunnable> exit = new nsCallExitFullscreen(aDoc); nsCOMPtr<nsIRunnable> exit = new nsCallExitFullscreen(aDoc);
if (aDoc) { if (aDoc) {
aDoc->Dispatch("nsCallExitFullscreen", TaskCategory::Other, exit.forget()); aDoc->Dispatch(TaskCategory::Other, exit.forget());
} else { } else {
NS_DispatchToCurrentThread(exit.forget()); NS_DispatchToCurrentThread(exit.forget());
} }
@ -11239,7 +11236,7 @@ nsDocument::AsyncRequestFullScreen(UniquePtr<FullscreenRequest>&& aRequest)
// Request full-screen asynchronously. // Request full-screen asynchronously.
MOZ_RELEASE_ASSERT(NS_IsMainThread()); MOZ_RELEASE_ASSERT(NS_IsMainThread());
nsCOMPtr<nsIRunnable> event = new nsCallRequestFullScreen(Move(aRequest)); nsCOMPtr<nsIRunnable> event = new nsCallRequestFullScreen(Move(aRequest));
Dispatch("nsCallRequestFullScreen", TaskCategory::Other, event.forget()); Dispatch(TaskCategory::Other, event.forget());
} }
void void
@ -12116,7 +12113,7 @@ nsDocument::RequestPointerLock(Element* aElement, CallerType aCallerType)
aCallerType == CallerType::System; aCallerType == CallerType::System;
nsCOMPtr<nsIRunnable> request = nsCOMPtr<nsIRunnable> request =
new PointerLockRequest(aElement, userInputOrSystemCaller); new PointerLockRequest(aElement, userInputOrSystemCaller);
Dispatch("PointerLockRequest", TaskCategory::Other, request.forget()); Dispatch(TaskCategory::Other, request.forget());
} }
bool bool
@ -12301,7 +12298,7 @@ nsDocument::PostVisibilityUpdateEvent()
NewRunnableMethod("nsDocument::UpdateVisibilityState", NewRunnableMethod("nsDocument::UpdateVisibilityState",
this, this,
&nsDocument::UpdateVisibilityState); &nsDocument::UpdateVisibilityState);
Dispatch("nsDocument::UpdateVisibilityState", TaskCategory::Other, event.forget()); Dispatch(TaskCategory::Other, event.forget());
} }
void void
@ -12848,8 +12845,7 @@ nsDocument::ScheduleIntersectionObserverNotification()
NewRunnableMethod("nsDocument::NotifyIntersectionObservers", NewRunnableMethod("nsDocument::NotifyIntersectionObservers",
this, this,
&nsDocument::NotifyIntersectionObservers); &nsDocument::NotifyIntersectionObservers);
Dispatch("nsDocument::IntersectionObserverNotification", TaskCategory::Other, Dispatch(TaskCategory::Other, notification.forget());
notification.forget());
} }
void void
@ -13140,8 +13136,7 @@ nsIDocument::RebuildUserFontSet()
NewRunnableMethod("nsIDocument::HandleRebuildUserFontSet", NewRunnableMethod("nsIDocument::HandleRebuildUserFontSet",
this, this,
&nsIDocument::HandleRebuildUserFontSet); &nsIDocument::HandleRebuildUserFontSet);
if (NS_SUCCEEDED(Dispatch("nsIDocument::HandleRebuildUserFontSet", if (NS_SUCCEEDED(Dispatch(TaskCategory::Other, ev.forget()))) {
TaskCategory::Other, ev.forget()))) {
mPostedFlushUserFontSet = true; mPostedFlushUserFontSet = true;
} }
} }

View file

@ -1034,6 +1034,7 @@ GK_ATOM(onupdateready, "onupdateready")
GK_ATOM(onupgradeneeded, "onupgradeneeded") GK_ATOM(onupgradeneeded, "onupgradeneeded")
GK_ATOM(onussdreceived, "onussdreceived") GK_ATOM(onussdreceived, "onussdreceived")
GK_ATOM(onversionchange, "onversionchange") GK_ATOM(onversionchange, "onversionchange")
GK_ATOM(onvisibilitychange, "onvisibilitychange")
GK_ATOM(onvoicechange, "onvoicechange") GK_ATOM(onvoicechange, "onvoicechange")
GK_ATOM(onvoiceschanged, "onvoiceschanged") GK_ATOM(onvoiceschanged, "onvoiceschanged")
GK_ATOM(onvrdisplayactivate, "onvrdisplayactivate") GK_ATOM(onvrdisplayactivate, "onvrdisplayactivate")

View file

@ -24,6 +24,7 @@
#include "mozilla/dom/StorageEvent.h" #include "mozilla/dom/StorageEvent.h"
#include "mozilla/dom/StorageEventBinding.h" #include "mozilla/dom/StorageEventBinding.h"
#include "mozilla/dom/StorageNotifierService.h" #include "mozilla/dom/StorageNotifierService.h"
#include "mozilla/dom/StorageUtils.h"
#include "mozilla/dom/Timeout.h" #include "mozilla/dom/Timeout.h"
#include "mozilla/dom/TimeoutHandler.h" #include "mozilla/dom/TimeoutHandler.h"
#include "mozilla/dom/TimeoutManager.h" #include "mozilla/dom/TimeoutManager.h"
@ -498,7 +499,19 @@ public:
} }
} }
virtual nsIEventTarget* nsIPrincipal*
GetPrincipal() const override
{
return mWindow ? mWindow->GetPrincipal() : nullptr;
}
bool
IsPrivateBrowsing() const override
{
return mWindow ? mWindow->IsPrivateBrowsing() : false;
}
nsIEventTarget*
GetEventTarget() const override GetEventTarget() const override
{ {
return mWindow ? mWindow->EventTargetFor(TaskCategory::Other) : nullptr; return mWindow ? mWindow->EventTargetFor(TaskCategory::Other) : nullptr;
@ -680,12 +693,6 @@ IdleRequestExecutor::GetName(nsACString& aName)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
IdleRequestExecutor::SetName(const char* aName)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP NS_IMETHODIMP
IdleRequestExecutor::Run() IdleRequestExecutor::Run()
{ {
@ -9242,7 +9249,7 @@ nsGlobalWindow::PostMessageMozOuter(JSContext* aCx, JS::Handle<JS::Value> aMessa
return; return;
} }
aError = Dispatch("PostMessageEvent", TaskCategory::Other, event.forget()); aError = Dispatch(TaskCategory::Other, event.forget());
} }
void void
@ -9294,7 +9301,7 @@ public:
PostCloseEvent(nsGlobalWindow* aWindow, bool aIndirect) { PostCloseEvent(nsGlobalWindow* aWindow, bool aIndirect) {
nsCOMPtr<nsIRunnable> ev = new nsCloseEvent(aWindow, aIndirect); nsCOMPtr<nsIRunnable> ev = new nsCloseEvent(aWindow, aIndirect);
nsresult rv = nsresult rv =
aWindow->Dispatch("nsCloseEvent", TaskCategory::Other, ev.forget()); aWindow->Dispatch(TaskCategory::Other, ev.forget());
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv))
aWindow->MaybeForgiveSpamCount(); aWindow->MaybeForgiveSpamCount();
return rv; return rv;
@ -9825,8 +9832,7 @@ void
nsGlobalWindow::NotifyWindowIDDestroyed(const char* aTopic) nsGlobalWindow::NotifyWindowIDDestroyed(const char* aTopic)
{ {
nsCOMPtr<nsIRunnable> runnable = new WindowDestroyedEvent(this, mWindowID, aTopic); nsCOMPtr<nsIRunnable> runnable = new WindowDestroyedEvent(this, mWindowID, aTopic);
nsresult rv = nsresult rv = Dispatch(TaskCategory::Other, runnable.forget());
Dispatch("WindowDestroyedEvent", TaskCategory::Other, runnable.forget());
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
mNotifiedIDDestroyed = true; mNotifiedIDDestroyed = true;
} }
@ -11094,7 +11100,7 @@ nsGlobalWindow::DispatchAsyncHashchange(nsIURI *aOldURI, nsIURI *aNewURI)
nsCOMPtr<nsIRunnable> callback = nsCOMPtr<nsIRunnable> callback =
new HashchangeCallback(oldWideSpec, newWideSpec, this); new HashchangeCallback(oldWideSpec, newWideSpec, this);
return Dispatch("HashchangeCallback", TaskCategory::Other, callback.forget()); return Dispatch(TaskCategory::Other, callback.forget());
} }
nsresult nsresult
@ -11694,8 +11700,7 @@ nsGlobalWindow::NotifyIdleObserver(IdleObserverHolder* aIdleObserverHolder,
new NotifyIdleObserverRunnable(aIdleObserverHolder->mIdleObserver, new NotifyIdleObserverRunnable(aIdleObserverHolder->mIdleObserver,
aIdleObserverHolder->mTimeInS, aIdleObserverHolder->mTimeInS,
aCallOnidle, this); aCallOnidle, this);
if (NS_FAILED(Dispatch("NotifyIdleObserverRunnable", TaskCategory::Other, if (NS_FAILED(Dispatch(TaskCategory::Other, caller.forget()))) {
caller.forget()))) {
NS_WARNING("Failed to dispatch thread for idle observer notification."); NS_WARNING("Failed to dispatch thread for idle observer notification.");
} }
} }
@ -12372,16 +12377,7 @@ nsGlobalWindow::ObserveStorageNotification(StorageEvent* aEvent,
{ {
MOZ_ASSERT(aEvent); MOZ_ASSERT(aEvent);
// Enforce that the source storage area's private browsing state matches MOZ_DIAGNOSTIC_ASSERT(IsPrivateBrowsing() == aPrivateBrowsing);
// this window's state. These flag checks and their maintenance independent
// from the principal's OriginAttributes matter because chrome docshells
// that are part of private browsing windows can be private browsing without
// having their OriginAttributes set (because they have the system
// principal).
bool isPrivateBrowsing = IsPrivateBrowsing();
if (isPrivateBrowsing != aPrivateBrowsing) {
return;
}
// LocalStorage can only exist on an inner window, and we don't want to // LocalStorage can only exist on an inner window, and we don't want to
// generate events on frozen or otherwise-navigated-away from windows. // generate events on frozen or otherwise-navigated-away from windows.
@ -12433,18 +12429,9 @@ nsGlobalWindow::ObserveStorageNotification(StorageEvent* aEvent,
else { else {
MOZ_ASSERT(!NS_strcmp(aStorageType, u"localStorage")); MOZ_ASSERT(!NS_strcmp(aStorageType, u"localStorage"));
nsIPrincipal* storagePrincipal = aEvent->GetPrincipal();
if (!storagePrincipal) {
return;
}
bool equals = false; MOZ_DIAGNOSTIC_ASSERT(StorageUtils::PrincipalsEqual(aEvent->GetPrincipal(),
nsresult rv = storagePrincipal->Equals(principal, &equals); principal));
NS_ENSURE_SUCCESS_VOID(rv);
if (!equals) {
return;
}
fireMozStorageChanged = mLocalStorage == aEvent->GetStorageArea(); fireMozStorageChanged = mLocalStorage == aEvent->GetStorageArea();
@ -12896,8 +12883,7 @@ public:
void (nsGlobalWindow::*run)() = &nsGlobalWindow::UnblockScriptedClosing; void (nsGlobalWindow::*run)() = &nsGlobalWindow::UnblockScriptedClosing;
nsCOMPtr<nsIRunnable> caller = NewRunnableMethod( nsCOMPtr<nsIRunnable> caller = NewRunnableMethod(
"AutoUnblockScriptClosing::~AutoUnblockScriptClosing", mWin, run); "AutoUnblockScriptClosing::~AutoUnblockScriptClosing", mWin, run);
mWin->Dispatch("nsGlobalWindow::UnblockScriptedClosing", mWin->Dispatch(TaskCategory::Other, caller.forget());
TaskCategory::Other, caller.forget());
} }
}; };
@ -15400,15 +15386,14 @@ nsPIDOMWindow<T>::GetDocGroup() const
} }
nsresult nsresult
nsGlobalWindow::Dispatch(const char* aName, nsGlobalWindow::Dispatch(TaskCategory aCategory,
TaskCategory aCategory,
already_AddRefed<nsIRunnable>&& aRunnable) already_AddRefed<nsIRunnable>&& aRunnable)
{ {
MOZ_RELEASE_ASSERT(NS_IsMainThread()); MOZ_RELEASE_ASSERT(NS_IsMainThread());
if (GetDocGroup()) { if (GetDocGroup()) {
return GetDocGroup()->Dispatch(aName, aCategory, Move(aRunnable)); return GetDocGroup()->Dispatch(aCategory, Move(aRunnable));
} }
return DispatcherTrait::Dispatch(aName, aCategory, Move(aRunnable)); return DispatcherTrait::Dispatch(aCategory, Move(aRunnable));
} }
nsISerialEventTarget* nsISerialEventTarget*

View file

@ -1829,8 +1829,7 @@ private:
public: public:
// Dispatch a runnable related to the global. // Dispatch a runnable related to the global.
virtual nsresult Dispatch(const char* aName, virtual nsresult Dispatch(mozilla::TaskCategory aCategory,
mozilla::TaskCategory aCategory,
already_AddRefed<nsIRunnable>&& aRunnable) override; already_AddRefed<nsIRunnable>&& aRunnable) override;
virtual nsISerialEventTarget* virtual nsISerialEventTarget*

View file

@ -2937,8 +2937,7 @@ public:
virtual void NotifyIntersectionObservers() = 0; virtual void NotifyIntersectionObservers() = 0;
// Dispatch a runnable related to the document. // Dispatch a runnable related to the document.
virtual nsresult Dispatch(const char* aName, virtual nsresult Dispatch(mozilla::TaskCategory aCategory,
mozilla::TaskCategory aCategory,
already_AddRefed<nsIRunnable>&& aRunnable) override; already_AddRefed<nsIRunnable>&& aRunnable) override;
virtual nsISerialEventTarget* virtual nsISerialEventTarget*

View file

@ -198,7 +198,7 @@ private:
template<typename T, template<typename T,
JSObject* UnwrapArray(JSObject*), JSObject* UnwrapArray(JSObject*),
T* GetData(JSObject*, bool* isShared, const JS::AutoCheckCannotGC&), T* GetData(JSObject*, bool* isShared, const JS::AutoRequireNoGC&),
void GetLengthAndDataAndSharedness(JSObject*, uint32_t*, bool*, T**), void GetLengthAndDataAndSharedness(JSObject*, uint32_t*, bool*, T**),
JSObject* CreateNew(JSContext*, uint32_t)> JSObject* CreateNew(JSContext*, uint32_t)>
struct TypedArray struct TypedArray

View file

@ -6,6 +6,7 @@
#include "WebGLContextLossHandler.h" #include "WebGLContextLossHandler.h"
#include "mozilla/DebugOnly.h" #include "mozilla/DebugOnly.h"
#include "nsINamed.h"
#include "nsISupportsImpl.h" #include "nsISupportsImpl.h"
#include "nsITimer.h" #include "nsITimer.h"
#include "nsThreadUtils.h" #include "nsThreadUtils.h"
@ -14,6 +15,7 @@
namespace mozilla { namespace mozilla {
class WatchdogTimerEvent final : public nsITimerCallback class WatchdogTimerEvent final : public nsITimerCallback
, public nsINamed
{ {
const WeakPtr<WebGLContextLossHandler> mHandler; const WeakPtr<WebGLContextLossHandler> mHandler;
@ -24,6 +26,12 @@ public:
: mHandler(handler) : mHandler(handler)
{ } { }
NS_IMETHOD GetName(nsACString& aName) override
{
aName.AssignLiteral("WatchdogTimerEvent");
return NS_OK;
}
private: private:
virtual ~WatchdogTimerEvent() { } virtual ~WatchdogTimerEvent() { }
@ -35,7 +43,7 @@ private:
} }
}; };
NS_IMPL_ISUPPORTS(WatchdogTimerEvent, nsITimerCallback, nsISupports) NS_IMPL_ISUPPORTS(WatchdogTimerEvent, nsITimerCallback, nsINamed)
//////////////////////////////////////// ////////////////////////////////////////

View file

@ -41,7 +41,6 @@ function prepareSources() {
// Prepare image. // Prepare image.
gImage = document.createElement("img"); gImage = document.createElement("img");
gImage.crossOrigin = "anonymous";
gImage.src = gCanvas.toDataURL(); gImage.src = gCanvas.toDataURL();
var resolverImage; var resolverImage;
var promiseImage = new Promise(function(resolve, reject) { var promiseImage = new Promise(function(resolve, reject) {
@ -92,4 +91,4 @@ function prepareSources() {
} }
return promise; return promise;
} }

View file

@ -40,7 +40,6 @@ var canvas = document.getElementById('c');
var ctx = canvas.getContext('2d'); var ctx = canvas.getContext('2d');
var img = document.getElementById("img"); var img = document.getElementById("img");
img.crossOrigin = "anonymous";
img.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="; img.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==";
img.onload = function () { img.onload = function () {

View file

@ -20887,7 +20887,6 @@ img.onload = wrapFunction(function ()
isPixel(ctx667, 62,40, 6,10,250,127, 4); isPixel(ctx667, 62,40, 6,10,250,127, 4);
isPixel(ctx667, 87,40, 12,16,244,63, 8); isPixel(ctx667, 87,40, 12,16,244,63, 8);
}); });
img.crossOrigin = "anonymous";
img.src = canvas667.toDataURL(); img.src = canvas667.toDataURL();
@ -21014,7 +21013,6 @@ img.onload = wrapFunction(function ()
isPixel(ctx672, 87,20, 0,0,255,255, 0); isPixel(ctx672, 87,20, 0,0,255,255, 0);
isPixel(ctx672, 50,45, 255,255,255,255, 0); isPixel(ctx672, 50,45, 255,255,255,255, 0);
}); });
img.crossOrigin = "anonymous";
img.src = data; img.src = data;

View file

@ -162,7 +162,6 @@ function prepareSources() {
// Prepare image. // Prepare image.
gImage = document.createElement("img"); gImage = document.createElement("img");
gImage.src = gCanvas.toDataURL(); gImage.src = gCanvas.toDataURL();
gImage.crossOrigin = "anonymous";
var resolverImage; var resolverImage;
var promiseImage = new Promise(function(resolve, reject) { var promiseImage = new Promise(function(resolve, reject) {
resolverImage = resolve; resolverImage = resolve;

View file

@ -170,7 +170,6 @@ function do_canvas(row, col, type, options)
isPixel(ctx, 50,25, r,g,b,255, 8); isPixel(ctx, 50,25, r,g,b,255, 8);
finishedTests[row + '_' + col] = true; finishedTests[row + '_' + col] = true;
}; };
img.crossOrigin = "anonymous";
img.src = data; img.src = data;
} }

View file

@ -84,14 +84,14 @@ AsyncEventDispatcher::PostDOMEvent()
RefPtr<AsyncEventDispatcher> ensureDeletionWhenFailing = this; RefPtr<AsyncEventDispatcher> ensureDeletionWhenFailing = this;
if (NS_IsMainThread()) { if (NS_IsMainThread()) {
if (nsCOMPtr<nsIGlobalObject> global = mTarget->GetOwnerGlobal()) { if (nsCOMPtr<nsIGlobalObject> global = mTarget->GetOwnerGlobal()) {
return global->Dispatch("AsyncEventDispatcher", TaskCategory::Other, ensureDeletionWhenFailing.forget()); return global->Dispatch(TaskCategory::Other, ensureDeletionWhenFailing.forget());
} }
// Sometimes GetOwnerGlobal returns null because it uses // Sometimes GetOwnerGlobal returns null because it uses
// GetScriptHandlingObject rather than GetScopeObject. // GetScriptHandlingObject rather than GetScopeObject.
if (nsCOMPtr<nsINode> node = do_QueryInterface(mTarget)) { if (nsCOMPtr<nsINode> node = do_QueryInterface(mTarget)) {
nsCOMPtr<nsIDocument> doc = node->OwnerDoc(); nsCOMPtr<nsIDocument> doc = node->OwnerDoc();
return doc->Dispatch("AsyncEventDispatcher", TaskCategory::Other, ensureDeletionWhenFailing.forget()); return doc->Dispatch(TaskCategory::Other, ensureDeletionWhenFailing.forget());
} }
} }
return NS_DispatchToCurrentThread(this); return NS_DispatchToCurrentThread(this);

View file

@ -478,7 +478,7 @@ DataTransferItem::GetAsString(FunctionStringCallback* aCallback,
} }
} }
if (global) { if (global) {
rv = global->Dispatch("GASRunnable", TaskCategory::Other, runnable.forget()); rv = global->Dispatch(TaskCategory::Other, runnable.forget());
} else { } else {
rv = NS_DispatchToMainThread(runnable); rv = NS_DispatchToMainThread(runnable);
} }

View file

@ -371,10 +371,9 @@ EventListenerService::NotifyAboutMainThreadListenerChangeInternal(dom::EventTarg
NewRunnableMethod("EventListenerService::NotifyPendingChanges", NewRunnableMethod("EventListenerService::NotifyPendingChanges",
this, &EventListenerService::NotifyPendingChanges); this, &EventListenerService::NotifyPendingChanges);
if (nsCOMPtr<nsIGlobalObject> global = aTarget->GetOwnerGlobal()) { if (nsCOMPtr<nsIGlobalObject> global = aTarget->GetOwnerGlobal()) {
global->Dispatch(nullptr, TaskCategory::Other, runnable.forget()); global->Dispatch(TaskCategory::Other, runnable.forget());
} else if (nsCOMPtr<nsINode> node = do_QueryInterface(aTarget)) { } else if (nsCOMPtr<nsINode> node = do_QueryInterface(aTarget)) {
node->OwnerDoc()->Dispatch(nullptr, TaskCategory::Other, node->OwnerDoc()->Dispatch(TaskCategory::Other, runnable.forget());
runnable.forget());
} else { } else {
NS_DispatchToCurrentThread(runnable); NS_DispatchToCurrentThread(runnable);
} }

View file

@ -682,6 +682,11 @@ DOCUMENT_ONLY_EVENT(selectionchange,
eSelectionChange, eSelectionChange,
EventNameType_HTMLXUL, EventNameType_HTMLXUL,
eBasicEventClass) eBasicEventClass)
DOCUMENT_ONLY_EVENT(visibilitychange,
eVisibilityChange,
EventNameType_HTMLXUL,
eBasicEventClass)
NON_IDL_EVENT(MozMouseHittest, NON_IDL_EVENT(MozMouseHittest,
eMouseHitTest, eMouseHitTest,

View file

@ -237,12 +237,6 @@ UITimerCallback::GetName(nsACString& aName)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
UITimerCallback::SetName(const char* aName)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/******************************************************************/ /******************************************************************/
/* mozilla::OverOutElementsWrapper */ /* mozilla::OverOutElementsWrapper */
/******************************************************************/ /******************************************************************/

View file

@ -1848,7 +1848,7 @@ IMEContentObserver::IMENotificationSender::Dispatch(nsIDocShell* aDocShell)
aDocShell ? aDocShell->GetScriptGlobalObject() : nullptr; aDocShell ? aDocShell->GetScriptGlobalObject() : nullptr;
if (globalObject) { if (globalObject) {
RefPtr<IMENotificationSender> queuedSender = this; RefPtr<IMENotificationSender> queuedSender = this;
globalObject->Dispatch(nullptr, TaskCategory::Other, globalObject->Dispatch(TaskCategory::Other,
queuedSender.forget()); queuedSender.forget());
} else { } else {
NS_DispatchToCurrentThread(this); NS_DispatchToCurrentThread(this);

View file

@ -71,6 +71,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(FileReader)
NS_INTERFACE_MAP_ENTRY(nsITimerCallback) NS_INTERFACE_MAP_ENTRY(nsITimerCallback)
NS_INTERFACE_MAP_ENTRY(nsIInputStreamCallback) NS_INTERFACE_MAP_ENTRY(nsIInputStreamCallback)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference) NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY(nsINamed)
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper) NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
NS_IMPL_ADDREF_INHERITED(FileReader, DOMEventTargetHelper) NS_IMPL_ADDREF_INHERITED(FileReader, DOMEventTargetHelper)
@ -684,6 +685,14 @@ FileReader::OnInputStreamReady(nsIAsyncInputStream* aStream)
return NS_OK; return NS_OK;
} }
// nsINamed
NS_IMETHODIMP
FileReader::GetName(nsACString& aName)
{
aName.AssignLiteral("FileReader");
return NS_OK;
}
nsresult nsresult
FileReader::OnLoadEnd(nsresult aStatus) FileReader::OnLoadEnd(nsresult aStatus)
{ {

View file

@ -12,6 +12,7 @@
#include "nsIAsyncInputStream.h" #include "nsIAsyncInputStream.h"
#include "nsIInterfaceRequestor.h" #include "nsIInterfaceRequestor.h"
#include "nsINamed.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsString.h" #include "nsString.h"
#include "nsWeakReference.h" #include "nsWeakReference.h"
@ -41,6 +42,7 @@ class FileReader final : public DOMEventTargetHelper,
public nsSupportsWeakReference, public nsSupportsWeakReference,
public nsIInputStreamCallback, public nsIInputStreamCallback,
public nsITimerCallback, public nsITimerCallback,
public nsINamed,
public workers::WorkerHolder public workers::WorkerHolder
{ {
friend class FileReaderDecreaseBusyCounter; friend class FileReaderDecreaseBusyCounter;
@ -54,6 +56,7 @@ public:
NS_DECL_NSITIMERCALLBACK NS_DECL_NSITIMERCALLBACK
NS_DECL_NSIINPUTSTREAMCALLBACK NS_DECL_NSIINPUTSTREAMCALLBACK
NS_DECL_NSIINTERFACEREQUESTOR NS_DECL_NSIINTERFACEREQUESTOR
NS_DECL_NSINAMED
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(FileReader, NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(FileReader,
DOMEventTargetHelper) DOMEventTargetHelper)

View file

@ -126,9 +126,7 @@ IPCBlobInputStreamThread::Initialize()
{ {
if (!NS_IsMainThread()) { if (!NS_IsMainThread()) {
RefPtr<Runnable> runnable = new ThreadInitializeRunnable(); RefPtr<Runnable> runnable = new ThreadInitializeRunnable();
SystemGroup::Dispatch("IPCBlobInputStreamThread::Initialize", SystemGroup::Dispatch(TaskCategory::Other, runnable.forget());
TaskCategory::Other,
runnable.forget());
return; return;
} }

View file

@ -469,13 +469,6 @@ public:
return NS_OK; return NS_OK;
} }
NS_IMETHOD
SetName(const char* aName) override
{
MOZ_CRASH("The name shall never be set!");
return NS_OK;
}
private: private:
explicit ReleasingTimerHolder(nsTArray<nsWeakPtr>&& aArray) explicit ReleasingTimerHolder(nsTArray<nsWeakPtr>&& aArray)
: mURIs(aArray) : mURIs(aArray)

View file

@ -25,6 +25,7 @@
#include "nsSocketTransport2.h" #include "nsSocketTransport2.h"
#include "nsHashPropertyBag.h" #include "nsHashPropertyBag.h"
#include "nsNetUtil.h" #include "nsNetUtil.h"
#include "nsINamed.h"
#include "nsISimpleEnumerator.h" #include "nsISimpleEnumerator.h"
#include "nsIProperty.h" #include "nsIProperty.h"
#include "nsICertOverrideService.h" #include "nsICertOverrideService.h"
@ -159,6 +160,7 @@ class FlyWebMDNSService final
, public nsIDNSServiceResolveListener , public nsIDNSServiceResolveListener
, public nsIDNSRegistrationListener , public nsIDNSRegistrationListener
, public nsITimerCallback , public nsITimerCallback
, public nsINamed
{ {
friend class FlyWebService; friend class FlyWebService;
@ -180,6 +182,12 @@ public:
explicit FlyWebMDNSService(FlyWebService* aService, explicit FlyWebMDNSService(FlyWebService* aService,
const nsACString& aServiceType); const nsACString& aServiceType);
NS_IMETHOD GetName(nsACString& aName) override
{
aName.AssignLiteral("FlyWebMDNSService");
return NS_OK;
}
private: private:
virtual ~FlyWebMDNSService() = default; virtual ~FlyWebMDNSService() = default;
@ -296,7 +304,8 @@ NS_IMPL_ISUPPORTS(FlyWebMDNSService,
nsIDNSServiceDiscoveryListener, nsIDNSServiceDiscoveryListener,
nsIDNSServiceResolveListener, nsIDNSServiceResolveListener,
nsIDNSRegistrationListener, nsIDNSRegistrationListener,
nsITimerCallback) nsITimerCallback,
nsINamed)
FlyWebMDNSService::FlyWebMDNSService( FlyWebMDNSService::FlyWebMDNSService(
FlyWebService* aService, FlyWebService* aService,

View file

@ -9,7 +9,7 @@
#include "nsIGeolocationProvider.h" #include "nsIGeolocationProvider.h"
#include "nsServiceManagerUtils.h" #include "nsServiceManagerUtils.h"
NS_IMPL_ISUPPORTS(MLSFallback, nsITimerCallback) NS_IMPL_ISUPPORTS(MLSFallback, nsITimerCallback, nsINamed)
MLSFallback::MLSFallback(uint32_t delay) MLSFallback::MLSFallback(uint32_t delay)
: mDelayMs(delay) : mDelayMs(delay)
@ -59,6 +59,13 @@ MLSFallback::Notify(nsITimer* aTimer)
return CreateMLSFallbackProvider(); return CreateMLSFallbackProvider();
} }
NS_IMETHODIMP
MLSFallback::GetName(nsACString& aName)
{
aName.AssignLiteral("MLSFallback");
return NS_OK;
}
nsresult nsresult
MLSFallback::CreateMLSFallbackProvider() MLSFallback::CreateMLSFallbackProvider()
{ {

View file

@ -6,6 +6,7 @@
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsITimer.h" #include "nsITimer.h"
#include "nsINamed.h"
class nsIGeolocationUpdate; class nsIGeolocationUpdate;
class nsIGeolocationProvider; class nsIGeolocationProvider;
@ -28,10 +29,12 @@ class nsIGeolocationProvider;
first when expected to do so. first when expected to do so.
*/ */
class MLSFallback : public nsITimerCallback class MLSFallback : public nsITimerCallback
, public nsINamed
{ {
public: public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_DECL_NSITIMERCALLBACK NS_DECL_NSITIMERCALLBACK
NS_DECL_NSINAMED
explicit MLSFallback(uint32_t delayMs = 2000); explicit MLSFallback(uint32_t delayMs = 2000);
nsresult Startup(nsIGeolocationUpdate* aWatcher); nsresult Startup(nsIGeolocationUpdate* aWatcher);

View file

@ -21,6 +21,7 @@
#include "nsDOMClassInfoID.h" #include "nsDOMClassInfoID.h"
#include "nsGlobalWindow.h" #include "nsGlobalWindow.h"
#include "nsIDocument.h" #include "nsIDocument.h"
#include "nsINamed.h"
#include "nsIObserverService.h" #include "nsIObserverService.h"
#include "nsIScriptError.h" #include "nsIScriptError.h"
#include "nsPIDOMWindow.h" #include "nsPIDOMWindow.h"
@ -96,6 +97,7 @@ class nsGeolocationRequest final
virtual ~nsGeolocationRequest(); virtual ~nsGeolocationRequest();
class TimerCallbackHolder final : public nsITimerCallback class TimerCallbackHolder final : public nsITimerCallback
, public nsINamed
{ {
public: public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
@ -105,6 +107,12 @@ class nsGeolocationRequest final
: mRequest(aRequest) : mRequest(aRequest)
{} {}
NS_IMETHOD GetName(nsACString& aName) override
{
aName.AssignLiteral("nsGeolocationRequest::TimerCallbackHolder");
return NS_OK;
}
private: private:
~TimerCallbackHolder() = default; ~TimerCallbackHolder() = default;
WeakPtr<nsGeolocationRequest> mRequest; WeakPtr<nsGeolocationRequest> mRequest;
@ -637,7 +645,9 @@ nsGeolocationRequest::Shutdown()
// nsGeolocationRequest::TimerCallbackHolder // nsGeolocationRequest::TimerCallbackHolder
//////////////////////////////////////////////////// ////////////////////////////////////////////////////
NS_IMPL_ISUPPORTS(nsGeolocationRequest::TimerCallbackHolder, nsISupports, nsITimerCallback) NS_IMPL_ISUPPORTS(nsGeolocationRequest::TimerCallbackHolder,
nsITimerCallback,
nsINamed)
NS_IMETHODIMP NS_IMETHODIMP
nsGeolocationRequest::TimerCallbackHolder::Notify(nsITimer*) nsGeolocationRequest::TimerCallbackHolder::Notify(nsITimer*)

View file

@ -530,9 +530,7 @@ HTMLCanvasElement::DispatchPrintCallback(nsITimerCallback* aCallback)
NewRunnableMethod("dom::HTMLCanvasElement::CallPrintCallback", NewRunnableMethod("dom::HTMLCanvasElement::CallPrintCallback",
this, this,
&HTMLCanvasElement::CallPrintCallback); &HTMLCanvasElement::CallPrintCallback);
return OwnerDoc()->Dispatch("HTMLCanvasElement::CallPrintCallback", return OwnerDoc()->Dispatch(TaskCategory::Other, renderEvent.forget());
TaskCategory::Other,
renderEvent.forget());
} }
void void
@ -852,7 +850,6 @@ HTMLCanvasElement::ToBlob(JSContext* aCx,
// dimension or its vertical dimension is zero. See link below. // dimension or its vertical dimension is zero. See link below.
// https://html.spec.whatwg.org/multipage/scripting.html#dom-canvas-toblob // https://html.spec.whatwg.org/multipage/scripting.html#dom-canvas-toblob
OwnerDoc()->Dispatch( OwnerDoc()->Dispatch(
"FireNullBlobEvent",
TaskCategory::Other, TaskCategory::Other,
NewRunnableMethod<Blob*, const char*>( NewRunnableMethod<Blob*, const char*>(
"dom::HTMLCanvasElement::ToBlob", "dom::HTMLCanvasElement::ToBlob",

View file

@ -445,8 +445,7 @@ HTMLTrackElement::DispatchTrackRunnable(const nsString& aEventName)
this, this,
&HTMLTrackElement::DispatchTrustedEvent, &HTMLTrackElement::DispatchTrustedEvent,
aEventName); aEventName);
doc->Dispatch("HTMLTrackElement::DispatchTrackRunnable", doc->Dispatch(TaskCategory::Other, runnable.forget());
TaskCategory::Other, runnable.forget());
} }
void void

View file

@ -630,7 +630,6 @@ TextTrackManager::DispatchUpdateCueDisplay()
nsPIDOMWindowInner* win = mMediaElement->OwnerDoc()->GetInnerWindow(); nsPIDOMWindowInner* win = mMediaElement->OwnerDoc()->GetInnerWindow();
if (win) { if (win) {
nsGlobalWindow::Cast(win)->Dispatch( nsGlobalWindow::Cast(win)->Dispatch(
"TextTrackManager::UpdateCueDisplay",
TaskCategory::Other, TaskCategory::Other,
NewRunnableMethod("dom::TextTrackManager::UpdateCueDisplay", NewRunnableMethod("dom::TextTrackManager::UpdateCueDisplay",
this, this,
@ -653,7 +652,6 @@ TextTrackManager::DispatchTimeMarchesOn()
nsPIDOMWindowInner* win = mMediaElement->OwnerDoc()->GetInnerWindow(); nsPIDOMWindowInner* win = mMediaElement->OwnerDoc()->GetInnerWindow();
if (win) { if (win) {
nsGlobalWindow::Cast(win)->Dispatch( nsGlobalWindow::Cast(win)->Dispatch(
"TextTrackManager::TimeMarchesOn",
TaskCategory::Other, TaskCategory::Other,
NewRunnableMethod("dom::TextTrackManager::TimeMarchesOn", NewRunnableMethod("dom::TextTrackManager::TimeMarchesOn",
this, this,

View file

@ -487,7 +487,7 @@ nsGenericHTMLElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
if (aDocument) { if (aDocument) {
RegAccessKey(); RegAccessKey();
if (HasName()) { if (CanHaveName(NodeInfo()->NameAtom()) && HasName()) {
aDocument-> aDocument->
AddToNameTable(this, GetParsedAttr(nsGkAtoms::name)->GetAtomValue()); AddToNameTable(this, GetParsedAttr(nsGkAtoms::name)->GetAtomValue());
} }
@ -776,15 +776,16 @@ nsGenericHTMLElement::AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName,
RegAccessKey(); RegAccessKey();
} }
} else if (aName == nsGkAtoms::name) { } else if (aName == nsGkAtoms::name) {
if (aValue && !aValue->Equals(EmptyString(), eIgnoreCase) && if (aValue && !aValue->Equals(EmptyString(), eIgnoreCase)) {
CanHaveName(NodeInfo()->NameAtom())) {
// This may not be quite right because we can have subclass code run // This may not be quite right because we can have subclass code run
// before here. But in practice subclasses don't care about this flag, // before here. But in practice subclasses don't care about this flag,
// and in particular selector matching does not care. Otherwise we'd // and in particular selector matching does not care. Otherwise we'd
// want to handle it like we handle id attributes (in PreIdMaybeChange // want to handle it like we handle id attributes (in PreIdMaybeChange
// and PostIdMaybeChange). // and PostIdMaybeChange).
SetHasName(); SetHasName();
AddToNameTable(aValue->GetAtomValue()); if (CanHaveName(NodeInfo()->NameAtom())) {
AddToNameTable(aValue->GetAtomValue());
}
} }
} }
} }

View file

@ -733,7 +733,7 @@ protected:
} }
} }
void RemoveFromNameTable() { void RemoveFromNameTable() {
if (HasName()) { if (CanHaveName(NodeInfo()->NameAtom()) && HasName()) {
nsIDocument* doc = GetUncomposedDoc(); nsIDocument* doc = GetUncomposedDoc();
if (doc) { if (doc) {
doc->RemoveFromNameTable(this, GetParsedAttr(nsGkAtoms::name)-> doc->RemoveFromNameTable(this, GetParsedAttr(nsGkAtoms::name)->

View file

@ -2038,6 +2038,11 @@ nsHTMLDocument::MatchNameAttribute(Element* aElement, int32_t aNamespaceID,
nsIAtom* aAtom, void* aData) nsIAtom* aAtom, void* aData)
{ {
NS_PRECONDITION(aElement, "Must have element to work with!"); NS_PRECONDITION(aElement, "Must have element to work with!");
if (!aElement->HasName()) {
return false;
}
nsString* elementName = static_cast<nsString*>(aData); nsString* elementName = static_cast<nsString*>(aData);
return return
aElement->GetNameSpaceID() == kNameSpaceID_XHTML && aElement->GetNameSpaceID() == kNameSpaceID_XHTML &&

View file

@ -193,8 +193,11 @@ public:
nsIHTMLCollection* Scripts(); nsIHTMLCollection* Scripts();
already_AddRefed<nsContentList> GetElementsByName(const nsAString & aName) already_AddRefed<nsContentList> GetElementsByName(const nsAString & aName)
{ {
return NS_GetFuncStringNodeList(this, MatchNameAttribute, nullptr, return GetFuncStringContentList<nsCachableElementsByNameNodeList>(this,
UseExistingNameString, aName); MatchNameAttribute,
nullptr,
UseExistingNameString,
aName);
} }
already_AddRefed<nsIDocument> Open(JSContext* cx, already_AddRefed<nsIDocument> Open(JSContext* cx,
const nsAString& aType, const nsAString& aType,

View file

@ -611,3 +611,4 @@ skip-if = os == "android" # up/down arrow keys not supported on android
support-files = support-files =
file_script_module.html file_script_module.html
file_script_nomodule.html file_script_nomodule.html
[test_getElementsByName_after_mutation.html]

View file

@ -0,0 +1,51 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1376695
-->
<head>
<title>Test for Bug 1376695</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1376695">Mozilla Bug 1376695</a>
<p id="display"></p>
<div id="originalFoo" name="foo">
<pre id="test">
<script type="application/javascript">
/** Test to ensure that the list returned by getElementsByName is updated after
* mutations.
**/
var fooList = document.getElementsByName("foo");
var originalDiv = document.getElementById("originalFoo");
is(fooList.length, 1, "Should find one element with name 'foo' initially");
is(fooList[0], originalDiv, "Element should be the original div");
var newTree = document.createElement("p");
var child1 = document.createElement("div");
var child2 = document.createElement("div");
child2.setAttribute("name", "foo");
newTree.appendChild(child1);
newTree.appendChild(child2);
document.body.appendChild(newTree);
is(fooList.length, 2,
"Should find two elements with name 'foo' after appending the new tree");
is(fooList[1], child2, "Element should be the new appended div with name 'foo'");
document.body.removeChild(newTree);
is(fooList.length, 1,
"Should find one element with name 'foo' after removing the new tree");
is(fooList[0], originalDiv,
"Element should be the original div after removing the new tree");
</script>
</pre>
</body>
</html>

View file

@ -9883,15 +9883,13 @@ CheckWasmModule(FileHelper* aFileHelper,
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
size_t compiledSize; size_t compiledSize = module->compiledSerializedSize();
module->serializedSize(nullptr, &compiledSize);
UniquePtr<uint8_t[]> compiled(new (fallible) uint8_t[compiledSize]); UniquePtr<uint8_t[]> compiled(new (fallible) uint8_t[compiledSize]);
if (NS_WARN_IF(!compiled)) { if (NS_WARN_IF(!compiled)) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
module->serialize(nullptr, 0, compiled.get(), compiledSize); module->compiledSerialize(compiled.get(), compiledSize);
nsCOMPtr<nsIInputStream> inputStream; nsCOMPtr<nsIInputStream> inputStream;
rv = NS_NewByteInputStream(getter_AddRefs(inputStream), rv = NS_NewByteInputStream(getter_AddRefs(inputStream),

View file

@ -349,25 +349,20 @@ StructuredCloneWriteCallback(JSContext* aCx,
RefPtr<JS::WasmModule> module = JS::GetWasmModule(aObj); RefPtr<JS::WasmModule> module = JS::GetWasmModule(aObj);
MOZ_ASSERT(module); MOZ_ASSERT(module);
size_t bytecodeSize; size_t bytecodeSize = module->bytecodeSerializedSize();
size_t compiledSize;
module->serializedSize(&bytecodeSize, &compiledSize);
UniquePtr<uint8_t[]> bytecode(new uint8_t[bytecodeSize]); UniquePtr<uint8_t[]> bytecode(new uint8_t[bytecodeSize]);
MOZ_ASSERT(bytecode); MOZ_ASSERT(bytecode);
module->bytecodeSerialize(bytecode.get(), bytecodeSize);
UniquePtr<uint8_t[]> compiled(new uint8_t[compiledSize]);
MOZ_ASSERT(compiled);
module->serialize(bytecode.get(),
bytecodeSize,
compiled.get(),
compiledSize);
RefPtr<BlobImpl> blobImpl = RefPtr<BlobImpl> blobImpl =
new MemoryBlobImpl(bytecode.release(), bytecodeSize, EmptyString()); new MemoryBlobImpl(bytecode.release(), bytecodeSize, EmptyString());
RefPtr<Blob> bytecodeBlob = Blob::Create(nullptr, blobImpl); RefPtr<Blob> bytecodeBlob = Blob::Create(nullptr, blobImpl);
size_t compiledSize = module->compiledSerializedSize();
UniquePtr<uint8_t[]> compiled(new uint8_t[compiledSize]);
MOZ_ASSERT(compiled);
module->compiledSerialize(compiled.get(), compiledSize);
blobImpl = blobImpl =
new MemoryBlobImpl(compiled.release(), compiledSize, EmptyString()); new MemoryBlobImpl(compiled.release(), compiledSize, EmptyString());
RefPtr<Blob> compiledBlob = Blob::Create(nullptr, blobImpl); RefPtr<Blob> compiledBlob = Blob::Create(nullptr, blobImpl);

View file

@ -1107,7 +1107,8 @@ IndexedDatabaseManager::GetLocale()
NS_IMPL_ADDREF(IndexedDatabaseManager) NS_IMPL_ADDREF(IndexedDatabaseManager)
NS_IMPL_RELEASE_WITH_DESTROY(IndexedDatabaseManager, Destroy()) NS_IMPL_RELEASE_WITH_DESTROY(IndexedDatabaseManager, Destroy())
NS_IMPL_QUERY_INTERFACE(IndexedDatabaseManager, nsIObserver, nsITimerCallback) NS_IMPL_QUERY_INTERFACE(IndexedDatabaseManager, nsIObserver, nsITimerCallback,
nsINamed)
NS_IMETHODIMP NS_IMETHODIMP
IndexedDatabaseManager::Observe(nsISupports* aSubject, const char* aTopic, IndexedDatabaseManager::Observe(nsISupports* aSubject, const char* aTopic,
@ -1163,6 +1164,13 @@ IndexedDatabaseManager::Notify(nsITimer* aTimer)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
IndexedDatabaseManager::GetName(nsACString& aName)
{
aName.AssignLiteral("IndexedDatabaseManager");
return NS_OK;
}
already_AddRefed<FileManager> already_AddRefed<FileManager>
FileManagerInfo::GetFileManager(PersistenceType aPersistenceType, FileManagerInfo::GetFileManager(PersistenceType aPersistenceType,
const nsAString& aName) const const nsAString& aName) const

View file

@ -16,6 +16,7 @@
#include "nsClassHashtable.h" #include "nsClassHashtable.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsHashKeys.h" #include "nsHashKeys.h"
#include "nsINamed.h"
#include "nsITimer.h" #include "nsITimer.h"
class nsIEventTarget; class nsIEventTarget;
@ -45,6 +46,7 @@ class FileManagerInfo;
class IndexedDatabaseManager final class IndexedDatabaseManager final
: public nsIObserver : public nsIObserver
, public nsITimerCallback , public nsITimerCallback
, public nsINamed
{ {
typedef mozilla::dom::quota::PersistenceType PersistenceType; typedef mozilla::dom::quota::PersistenceType PersistenceType;
typedef mozilla::dom::quota::QuotaManager QuotaManager; typedef mozilla::dom::quota::QuotaManager QuotaManager;
@ -64,6 +66,7 @@ public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER NS_DECL_NSIOBSERVER
NS_DECL_NSITIMERCALLBACK NS_DECL_NSITIMERCALLBACK
NS_DECL_NSINAMED
// Returns a non-owning reference. // Returns a non-owning reference.
static IndexedDatabaseManager* static IndexedDatabaseManager*

View file

@ -8,11 +8,13 @@
#include "Key.h" #include "Key.h"
#include <algorithm> #include <algorithm>
#include <stdint.h> // for UINT32_MAX, uintptr_t
#include "IndexedDatabaseManager.h" #include "IndexedDatabaseManager.h"
#include "js/Date.h" #include "js/Date.h"
#include "js/Value.h" #include "js/Value.h"
#include "jsfriendapi.h" #include "jsfriendapi.h"
#include "mozilla/Casting.h" #include "mozilla/Casting.h"
#include "mozilla/CheckedInt.h"
#include "mozilla/EndianUtils.h" #include "mozilla/EndianUtils.h"
#include "mozilla/FloatingPoint.h" #include "mozilla/FloatingPoint.h"
#include "mozIStorageStatement.h" #include "mozIStorageStatement.h"
@ -196,7 +198,10 @@ Key::ToLocaleBasedKey(Key& aTarget, const nsCString& aLocale) const
nsDependentString str; nsDependentString str;
DecodeString(it, end, str); DecodeString(it, end, str);
aTarget.EncodeLocaleString(str, typeOffset, aLocale); nsresult rv = aTarget.EncodeLocaleString(str, typeOffset, aLocale);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
} }
} }
aTarget.TrimBuffer(); aTarget.TrimBuffer();
@ -221,8 +226,7 @@ Key::EncodeJSValInternal(JSContext* aCx, JS::Handle<JS::Value> aVal,
IDB_REPORT_INTERNAL_ERR(); IDB_REPORT_INTERNAL_ERR();
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR; return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
} }
EncodeString(str, aTypeOffset); return EncodeString(str, aTypeOffset);
return NS_OK;
} }
if (aVal.isNumber()) { if (aVal.isNumber()) {
@ -299,13 +303,11 @@ Key::EncodeJSValInternal(JSContext* aCx, JS::Handle<JS::Value> aVal,
} }
if (JS_IsArrayBufferObject(obj)) { if (JS_IsArrayBufferObject(obj)) {
EncodeBinary(obj, /* aIsViewObject */ false, aTypeOffset); return EncodeBinary(obj, /* aIsViewObject */ false, aTypeOffset);
return NS_OK;
} }
if (JS_IsArrayBufferViewObject(obj)) { if (JS_IsArrayBufferViewObject(obj)) {
EncodeBinary(obj, /* aIsViewObject */ true, aTypeOffset); return EncodeBinary(obj, /* aIsViewObject */ true, aTypeOffset);
return NS_OK;
} }
} }
@ -415,44 +417,64 @@ Key::EncodeJSVal(JSContext* aCx,
return EncodeJSValInternal(aCx, aVal, aTypeOffset, 0); return EncodeJSValInternal(aCx, aVal, aTypeOffset, 0);
} }
void nsresult
Key::EncodeString(const nsAString& aString, uint8_t aTypeOffset) Key::EncodeString(const nsAString& aString, uint8_t aTypeOffset)
{ {
const char16_t* start = aString.BeginReading(); const char16_t* start = aString.BeginReading();
const char16_t* end = aString.EndReading(); const char16_t* end = aString.EndReading();
EncodeString(start, end, aTypeOffset); return EncodeString(start, end, aTypeOffset);
} }
template <typename T> template <typename T>
void nsresult
Key::EncodeString(const T* aStart, const T* aEnd, uint8_t aTypeOffset) Key::EncodeString(const T* aStart, const T* aEnd, uint8_t aTypeOffset)
{ {
EncodeAsString(aStart, aEnd, eString + aTypeOffset); return EncodeAsString(aStart, aEnd, eString + aTypeOffset);
} }
template <typename T> template <typename T>
void nsresult
Key::EncodeAsString(const T* aStart, const T* aEnd, uint8_t aType) Key::EncodeAsString(const T* aStart, const T* aEnd, uint8_t aType)
{ {
// First measure how long the encoded string will be. // First measure how long the encoded string will be.
if (NS_WARN_IF(aStart > aEnd || UINT32_MAX - 2 < uintptr_t(aEnd - aStart))) {
IDB_REPORT_INTERNAL_ERR();
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
// The +2 is for initial 3 and trailing 0. We'll compensate for multi-byte // The +2 is for initial 3 and trailing 0. We'll compensate for multi-byte
// chars below. // chars below.
uint32_t size = (aEnd - aStart) + 2; uint32_t checkedSize = aEnd - aStart;
CheckedUint32 size = checkedSize;
size += 2;
MOZ_ASSERT(size.isValid());
const T* start = aStart; const T* start = aStart;
const T* end = aEnd; const T* end = aEnd;
for (const T* iter = start; iter < end; ++iter) { for (const T* iter = start; iter < end; ++iter) {
if (*iter > ONE_BYTE_LIMIT) { if (*iter > ONE_BYTE_LIMIT) {
size += char16_t(*iter) > TWO_BYTE_LIMIT ? 2 : 1; size += char16_t(*iter) > TWO_BYTE_LIMIT ? 2 : 1;
if (!size.isValid()) {
IDB_REPORT_INTERNAL_ERR();
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
} }
} }
// Allocate memory for the new size // Allocate memory for the new size
uint32_t oldLen = mBuffer.Length(); uint32_t oldLen = mBuffer.Length();
size += oldLen;
if (!size.isValid()) {
IDB_REPORT_INTERNAL_ERR();
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
char* buffer; char* buffer;
if (!mBuffer.GetMutableData(&buffer, oldLen + size)) { if (!mBuffer.GetMutableData(&buffer, size.value())) {
return; IDB_REPORT_INTERNAL_ERR();
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
} }
buffer += oldLen; buffer += oldLen;
@ -481,6 +503,8 @@ Key::EncodeAsString(const T* aStart, const T* aEnd, uint8_t aType)
*(buffer++) = eTerminator; *(buffer++) = eTerminator;
NS_ASSERTION(buffer == mBuffer.EndReading(), "Wrote wrong number of bytes"); NS_ASSERTION(buffer == mBuffer.EndReading(), "Wrote wrong number of bytes");
return NS_OK;
} }
#ifdef ENABLE_INTL_API #ifdef ENABLE_INTL_API
@ -517,10 +541,9 @@ Key::EncodeLocaleString(const nsDependentString& aString, uint8_t aTypeOffset,
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
EncodeString(keyBuffer.Elements(), return EncodeString(keyBuffer.Elements(),
keyBuffer.Elements()+sortKeyLength, keyBuffer.Elements()+sortKeyLength,
aTypeOffset); aTypeOffset);
return NS_OK;
} }
#endif #endif
@ -640,7 +663,7 @@ Key::DecodeNumber(const unsigned char*& aPos, const unsigned char* aEnd)
return BitwiseCast<double>(bits); return BitwiseCast<double>(bits);
} }
void nsresult
Key::EncodeBinary(JSObject* aObject, bool aIsViewObject, uint8_t aTypeOffset) Key::EncodeBinary(JSObject* aObject, bool aIsViewObject, uint8_t aTypeOffset)
{ {
uint8_t* bufferData; uint8_t* bufferData;
@ -653,7 +676,7 @@ Key::EncodeBinary(JSObject* aObject, bool aIsViewObject, uint8_t aTypeOffset)
js::GetArrayBufferLengthAndData(aObject, &bufferLength, &unused, &bufferData); js::GetArrayBufferLengthAndData(aObject, &bufferLength, &unused, &bufferData);
} }
EncodeAsString(bufferData, bufferData + bufferLength, eBinary + aTypeOffset); return EncodeAsString(bufferData, bufferData + bufferLength, eBinary + aTypeOffset);
} }
// static // static

View file

@ -287,15 +287,15 @@ private:
nsresult nsresult
EncodeJSVal(JSContext* aCx, JS::Handle<JS::Value> aVal, uint8_t aTypeOffset); EncodeJSVal(JSContext* aCx, JS::Handle<JS::Value> aVal, uint8_t aTypeOffset);
void nsresult
EncodeString(const nsAString& aString, uint8_t aTypeOffset); EncodeString(const nsAString& aString, uint8_t aTypeOffset);
template <typename T> template <typename T>
void nsresult
EncodeString(const T* aStart, const T* aEnd, uint8_t aTypeOffset); EncodeString(const T* aStart, const T* aEnd, uint8_t aTypeOffset);
template <typename T> template <typename T>
void nsresult
EncodeAsString(const T* aStart, const T* aEnd, uint8_t aType); EncodeAsString(const T* aStart, const T* aEnd, uint8_t aType);
#ifdef ENABLE_INTL_API #ifdef ENABLE_INTL_API
@ -307,7 +307,7 @@ private:
void void
EncodeNumber(double aFloat, uint8_t aType); EncodeNumber(double aFloat, uint8_t aType);
void nsresult
EncodeBinary(JSObject* aObject, bool aIsViewObject, uint8_t aTypeOffset); EncodeBinary(JSObject* aObject, bool aIsViewObject, uint8_t aTypeOffset);
// Decoding functions. aPos points into mBuffer and is adjusted to point // Decoding functions. aPos points into mBuffer and is adjusted to point

View file

@ -214,9 +214,7 @@ ScriptErrorHelper::Dump(const nsAString& aMessage,
aIsChrome, aIsChrome,
aInnerWindowID); aInnerWindowID);
MOZ_ALWAYS_SUCCEEDS( MOZ_ALWAYS_SUCCEEDS(
SystemGroup::Dispatch("indexedDB::ScriptErrorHelper::Dump", SystemGroup::Dispatch(TaskCategory::Other, runnable.forget()));
TaskCategory::Other,
runnable.forget()));
} }
} }
@ -247,9 +245,7 @@ ScriptErrorHelper::DumpLocalizedMessage(const nsACString& aMessageName,
aIsChrome, aIsChrome,
aInnerWindowID); aInnerWindowID);
MOZ_ALWAYS_SUCCEEDS( MOZ_ALWAYS_SUCCEEDS(
SystemGroup::Dispatch("indexedDB::ScriptErrorHelper::DumpLocalizedMessage", SystemGroup::Dispatch(TaskCategory::Other, runnable.forget()));
TaskCategory::Other,
runnable.forget()));
} }
} }

View file

@ -5,6 +5,48 @@
#include "nsISupports.idl" #include "nsISupports.idl"
#include "nsIVariant.idl" #include "nsIVariant.idl"
#include "nsIPaymentAddress.idl"
[builtinclass, scriptable, uuid(2a338575-c688-40ee-a157-7488ab292ef2)]
interface nsIPaymentResponseData: nsISupports
{
const uint32_t GENERAL_RESPONSE = 0;
const uint32_t BASICCARD_RESPONSE = 1;
readonly attribute uint32_t type;
void init(in uint32_t aType);
};
[builtinclass, scriptable, uuid(b986773e-2b30-4ed2-b8fe-6a96631c8000)]
interface nsIGeneralResponseData : nsIPaymentResponseData
{
readonly attribute AString data;
[implicit_jscontext]
void initData(in jsval aData);
};
/*
Since PaymentAddress is an no constructor interface type, UI code can not
easy create PaymentAddress by calling new PaymentAddress().
Unfortunately, BasicCardResponse has a PaymentAddress attribute, billingAddress
, it means UI can not create BsaicCardResponse by calling the init() with a
given JSObject directly, because PaymentAddress creation in JS code is hard.
To let UI code can create BasicCardResponse easier, nsIBasicCardResponse is
provided for UI by passing the raw data of BasicCardResponse,
*/
[builtinclass, scriptable, uuid(0d55a5e6-d185-44f0-b992-a8e1321e4bce)]
interface nsIBasicCardResponseData : nsIPaymentResponseData
{
readonly attribute AString data;
void initData(in AString aCardholderName,
in AString aCardNumber,
in AString aExpiryMonth,
in AString aExpiryYear,
in AString aCardSecurityCode,
in nsIPaymentAddress billingAddress);
};
[builtinclass, scriptable, uuid(a607c095-ef60-4a9b-a3d0-0506c60728b3)] [builtinclass, scriptable, uuid(a607c095-ef60-4a9b-a3d0-0506c60728b3)]
interface nsIPaymentActionResponse : nsISupports interface nsIPaymentActionResponse : nsISupports
@ -94,7 +136,7 @@ interface nsIPaymentShowActionResponse : nsIPaymentActionResponse
void init(in AString aRequestId, void init(in AString aRequestId,
in uint32_t aAcceptStatus, in uint32_t aAcceptStatus,
in AString aMethodName, in AString aMethodName,
in AString aData, in nsIPaymentResponseData aData,
in AString aPayerName, in AString aPayerName,
in AString aPayerEmail, in AString aPayerEmail,
in AString aPayerPhone); in AString aPayerPhone);
@ -142,6 +184,16 @@ interface nsIPaymentCompleteActionResponse : nsIPaymentActionResponse
}; };
%{C++ %{C++
#define NS_GENERAL_RESPONSE_DATA_CID \
{ 0xb986773e, 0x2b30, 0x4ed2, { 0xb8, 0xfe, 0x6a, 0x96, 0x63, 0x1c, 0x80, 0x00 } }
#define NS_GENERAL_RESPONSE_DATA_CONTRACT_ID \
"@mozilla.org/dom/payments/general-response-data;1"
#define NS_BASICCARD_RESPONSE_DATA_CID \
{ 0x0d55a5e6, 0xd185, 0x44f0, { 0xb9, 0x92, 0xa8, 0xe1, 0x32, 0x1e, 0x4b, 0xce } }
#define NS_BASICCARD_RESPONSE_DATA_CONTRACT_ID \
"@mozilla.org/dom/payments/basiccard-response-data;1"
#define NS_PAYMENT_CANMAKE_ACTION_RESPONSE_CID \ #define NS_PAYMENT_CANMAKE_ACTION_RESPONSE_CID \
{ 0x52fc3f9f, 0xc0cb, 0x4874, { 0xb3, 0xd4, 0xee, 0x4b, 0x6e, 0x9c, 0xbe, 0x9c } } { 0x52fc3f9f, 0xc0cb, 0x4874, { 0xb3, 0xd4, 0xee, 0x4b, 0x6e, 0x9c, 0xbe, 0x9c } }
#define NS_PAYMENT_CANMAKE_ACTION_RESPONSE_CONTRACT_ID \ #define NS_PAYMENT_CANMAKE_ACTION_RESPONSE_CONTRACT_ID \

View file

@ -12,7 +12,8 @@ interface nsIArray;
interface nsIPaymentMethodData : nsISupports interface nsIPaymentMethodData : nsISupports
{ {
readonly attribute AString supportedMethods; readonly attribute AString supportedMethods;
readonly attribute AString data; [implicit_jscontext]
readonly attribute jsval data;
}; };
[scriptable, builtinclass, uuid(d22a6f5f-767b-4fea-bf92-68b0b8003eba)] [scriptable, builtinclass, uuid(d22a6f5f-767b-4fea-bf92-68b0b8003eba)]
@ -36,7 +37,8 @@ interface nsIPaymentDetailsModifier : nsISupports
readonly attribute AString supportedMethods; readonly attribute AString supportedMethods;
readonly attribute nsIPaymentItem total; readonly attribute nsIPaymentItem total;
readonly attribute nsIArray additionalDisplayItems; readonly attribute nsIArray additionalDisplayItems;
readonly attribute AString data; [implicit_jscontext]
readonly attribute jsval data;
}; };
[scriptable, builtinclass, uuid(68341551-3605-4381-b936-41e830aa88fb)] [scriptable, builtinclass, uuid(68341551-3605-4381-b936-41e830aa88fb)]

View file

@ -18,6 +18,7 @@
#include "nsPrintfCString.h" #include "nsPrintfCString.h"
#include "nsXULAppAPI.h" #include "nsXULAppAPI.h"
#include "nsIFrameLoader.h" #include "nsIFrameLoader.h"
#include "nsINamed.h"
#include "nsIObserverService.h" #include "nsIObserverService.h"
#include "StaticPtr.h" #include "StaticPtr.h"
#include "nsIMozBrowserFrame.h" #include "nsIMozBrowserFrame.h"
@ -226,6 +227,7 @@ class ParticularProcessPriorityManager final
: public WakeLockObserver : public WakeLockObserver
, public nsIObserver , public nsIObserver
, public nsITimerCallback , public nsITimerCallback
, public nsINamed
, public nsSupportsWeakReference , public nsSupportsWeakReference
{ {
~ParticularProcessPriorityManager(); ~ParticularProcessPriorityManager();
@ -274,6 +276,12 @@ public:
void ShutDown(); void ShutDown();
NS_IMETHOD GetName(nsACString& aName) override
{
aName.AssignLiteral("ParticularProcessPriorityManager");
return NS_OK;
}
private: private:
static uint32_t sBackgroundPerceivableGracePeriodMS; static uint32_t sBackgroundPerceivableGracePeriodMS;
static uint32_t sBackgroundGracePeriodMS; static uint32_t sBackgroundGracePeriodMS;
@ -561,7 +569,8 @@ ProcessPriorityManagerImpl::TabActivityChanged(TabParent* aTabParent,
NS_IMPL_ISUPPORTS(ParticularProcessPriorityManager, NS_IMPL_ISUPPORTS(ParticularProcessPriorityManager,
nsIObserver, nsIObserver,
nsITimerCallback, nsITimerCallback,
nsISupportsWeakReference); nsISupportsWeakReference,
nsINamed);
ParticularProcessPriorityManager::ParticularProcessPriorityManager( ParticularProcessPriorityManager::ParticularProcessPriorityManager(
ContentParent* aContentParent) ContentParent* aContentParent)

View file

@ -3544,14 +3544,13 @@ TabChildGlobal::GetGlobalJSObject()
} }
nsresult nsresult
TabChildGlobal::Dispatch(const char* aName, TabChildGlobal::Dispatch(TaskCategory aCategory,
TaskCategory aCategory,
already_AddRefed<nsIRunnable>&& aRunnable) already_AddRefed<nsIRunnable>&& aRunnable)
{ {
if (mTabChild && mTabChild->TabGroup()) { if (mTabChild && mTabChild->TabGroup()) {
return mTabChild->TabGroup()->Dispatch(aName, aCategory, Move(aRunnable)); return mTabChild->TabGroup()->Dispatch(aCategory, Move(aRunnable));
} }
return DispatcherTrait::Dispatch(aName, aCategory, Move(aRunnable)); return DispatcherTrait::Dispatch(aCategory, Move(aRunnable));
} }
nsISerialEventTarget* nsISerialEventTarget*

View file

@ -152,8 +152,7 @@ public:
} }
// Dispatch a runnable related to the global. // Dispatch a runnable related to the global.
virtual nsresult Dispatch(const char* aName, virtual nsresult Dispatch(mozilla::TaskCategory aCategory,
mozilla::TaskCategory aCategory,
already_AddRefed<nsIRunnable>&& aRunnable) override; already_AddRefed<nsIRunnable>&& aRunnable) override;
virtual nsISerialEventTarget* virtual nsISerialEventTarget*

View file

@ -173,6 +173,7 @@ TabParent::TabParent(nsIContentParent* aManager,
, mHasPresented(false) , mHasPresented(false)
, mHasBeforeUnload(false) , mHasBeforeUnload(false)
, mIsReadyToHandleInputEvents(false) , mIsReadyToHandleInputEvents(false)
, mIsMouseEnterIntoWidgetEventSuppressed(false)
{ {
MOZ_ASSERT(aManager); MOZ_ASSERT(aManager);
} }
@ -1092,7 +1093,7 @@ TabParent::SendKeyEvent(const nsAString& aType,
void void
TabParent::SendRealMouseEvent(WidgetMouseEvent& aEvent) TabParent::SendRealMouseEvent(WidgetMouseEvent& aEvent)
{ {
if (mIsDestroyed || !mIsReadyToHandleInputEvents) { if (mIsDestroyed) {
return; return;
} }
aEvent.mRefPoint += GetChildProcessOffset(); aEvent.mRefPoint += GetChildProcessOffset();
@ -1113,11 +1114,33 @@ TabParent::SendRealMouseEvent(WidgetMouseEvent& aEvent)
mTabSetsCursor = false; mTabSetsCursor = false;
} }
} }
if (!mIsReadyToHandleInputEvents) {
if (eMouseEnterIntoWidget == aEvent.mMessage) {
MOZ_ASSERT(!mIsMouseEnterIntoWidgetEventSuppressed);
mIsMouseEnterIntoWidgetEventSuppressed = true;
} else if (eMouseExitFromWidget == aEvent.mMessage) {
MOZ_ASSERT(mIsMouseEnterIntoWidgetEventSuppressed);
mIsMouseEnterIntoWidgetEventSuppressed = false;
}
return;
}
ScrollableLayerGuid guid; ScrollableLayerGuid guid;
uint64_t blockId; uint64_t blockId;
ApzAwareEventRoutingToChild(&guid, &blockId, nullptr); ApzAwareEventRoutingToChild(&guid, &blockId, nullptr);
if (mIsMouseEnterIntoWidgetEventSuppressed) {
// In the case that the TabParent suppressed the eMouseEnterWidget event due
// to its corresponding TabChild wasn't ready to handle it, we have to
// resend it when the TabChild is ready.
mIsMouseEnterIntoWidgetEventSuppressed = false;
WidgetMouseEvent localEvent(aEvent);
localEvent.mMessage = eMouseEnterIntoWidget;
DebugOnly<bool> ret = SendRealMouseButtonEvent(localEvent, guid, blockId);
NS_WARNING_ASSERTION(ret, "SendRealMouseButtonEvent(eMouseEnterIntoWidget) failed");
MOZ_ASSERT(!ret || localEvent.HasBeenPostedToRemoteProcess());
}
if (eMouseMove == aEvent.mMessage) { if (eMouseMove == aEvent.mMessage) {
if (aEvent.mReason == WidgetMouseEvent::eSynthesized) { if (aEvent.mReason == WidgetMouseEvent::eSynthesized) {
DebugOnly<bool> ret = SendSynthMouseMoveEvent(aEvent, guid, blockId); DebugOnly<bool> ret = SendSynthMouseMoveEvent(aEvent, guid, blockId);

View file

@ -786,6 +786,11 @@ private:
// True when the remote browser is created and ready to handle input events. // True when the remote browser is created and ready to handle input events.
bool mIsReadyToHandleInputEvents; bool mIsReadyToHandleInputEvents;
// True if we suppress the eMouseEnterIntoWidget event due to the TabChild was
// not ready to handle it. We will resend it when the next time we fire a
// mouse event and the TabChild is ready.
bool mIsMouseEnterIntoWidgetEventSuppressed;
public: public:
static TabParent* GetTabParentFromLayersId(uint64_t aLayersId); static TabParent* GetTabParentFromLayersId(uint64_t aLayersId);
}; };

View file

@ -187,7 +187,7 @@ Window_ContentWarning=window._content is deprecated. Please use window.content
SyncXMLHttpRequestWarning=Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end users experience. For more help http://xhr.spec.whatwg.org/ SyncXMLHttpRequestWarning=Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end users experience. For more help http://xhr.spec.whatwg.org/
ImplicitMetaViewportTagFallback=No meta-viewport tag found. Please explicitly specify one to prevent unexpected behavioural changes in future versions. For more help https://developer.mozilla.org/en/docs/Mozilla/Mobile/Viewport_meta_tag ImplicitMetaViewportTagFallback=No meta-viewport tag found. Please explicitly specify one to prevent unexpected behavioural changes in future versions. For more help https://developer.mozilla.org/en/docs/Mozilla/Mobile/Viewport_meta_tag
# LOCALIZATION NOTE: Do not translate "window.controllers/Controllers" # LOCALIZATION NOTE: Do not translate "window.controllers/Controllers"
Window_ControllersWarning=window.controllers/Controllers is deprecated. Do not use it for UA detection. Window_Cc_ontrollersWarning=window.controllers/Controllers is deprecated. Do not use it for UA detection.
ImportXULIntoContentWarning=Importing XUL nodes into a content document is deprecated. This functionality may be removed soon. ImportXULIntoContentWarning=Importing XUL nodes into a content document is deprecated. This functionality may be removed soon.
XMLDocumentLoadPrincipalMismatch=Use of document.load forbidden on Documents that come from other Windows. Only the Window in which a Document was created is allowed to call .load on that Document. Preferably, use XMLHttpRequest instead. XMLDocumentLoadPrincipalMismatch=Use of document.load forbidden on Documents that come from other Windows. Only the Window in which a Document was created is allowed to call .load on that Document. Preferably, use XMLHttpRequest instead.
# LOCALIZATION NOTE: Do not translate "IndexedDB". # LOCALIZATION NOTE: Do not translate "IndexedDB".

View file

@ -826,12 +826,6 @@ DecoderDoctorDocumentWatcher::GetName(nsACString& aName)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
DecoderDoctorDocumentWatcher::SetName(const char* aName)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
void void
DecoderDoctorDiagnostics::StoreFormatDiagnostics(nsIDocument* aDocument, DecoderDoctorDiagnostics::StoreFormatDiagnostics(nsIDocument* aDocument,
const nsAString& aFormat, const nsAString& aFormat,

View file

@ -206,8 +206,7 @@ FileBlockCache::Close()
// releasing memory etc! // releasing memory etc!
nsCOMPtr<nsIRunnable> event = nsCOMPtr<nsIRunnable> event =
new ShutdownThreadEvent(thread); new ShutdownThreadEvent(thread);
SystemGroup::Dispatch("ShutdownThreadEvent", SystemGroup::Dispatch(TaskCategory::Other,
TaskCategory::Other,
event.forget()); event.forget());
}), }),
NS_DISPATCH_NORMAL); NS_DISPATCH_NORMAL);

View file

@ -1509,9 +1509,7 @@ MediaCache::QueueUpdate()
// shutdown and get freed in the final cycle-collector cleanup. So // shutdown and get freed in the final cycle-collector cleanup. So
// don't leak a runnable in that case. // don't leak a runnable in that case.
nsCOMPtr<nsIRunnable> event = new UpdateEvent(this); nsCOMPtr<nsIRunnable> event = new UpdateEvent(this);
SystemGroup::Dispatch("MediaCache::UpdateEvent", SystemGroup::Dispatch(TaskCategory::Other, event.forget());
TaskCategory::Other,
event.forget());
} }
void void

View file

@ -10,6 +10,7 @@
#include "mozilla/MediaManager.h" #include "mozilla/MediaManager.h"
#include "MediaTrackConstraints.h" #include "MediaTrackConstraints.h"
#include "nsIEventTarget.h" #include "nsIEventTarget.h"
#include "nsINamed.h"
#include "nsIScriptGlobalObject.h" #include "nsIScriptGlobalObject.h"
#include "nsIPermissionManager.h" #include "nsIPermissionManager.h"
#include "nsPIDOMWindow.h" #include "nsPIDOMWindow.h"
@ -20,7 +21,7 @@
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
class FuzzTimerCallBack final : public nsITimerCallback class FuzzTimerCallBack final : public nsITimerCallback, public nsINamed
{ {
~FuzzTimerCallBack() {} ~FuzzTimerCallBack() {}
@ -35,11 +36,17 @@ public:
return NS_OK; return NS_OK;
} }
NS_IMETHOD GetName(nsACString& aName) override
{
aName.AssignLiteral("FuzzTimerCallBack");
return NS_OK;
}
private: private:
nsCOMPtr<MediaDevices> mMediaDevices; nsCOMPtr<MediaDevices> mMediaDevices;
}; };
NS_IMPL_ISUPPORTS(FuzzTimerCallBack, nsITimerCallback) NS_IMPL_ISUPPORTS(FuzzTimerCallBack, nsITimerCallback, nsINamed)
class MediaDevices::GumResolver : public nsIDOMGetUserMediaSuccessCallback class MediaDevices::GumResolver : public nsIDOMGetUserMediaSuccessCallback
{ {

View file

@ -117,7 +117,6 @@ GlobalAllocPolicy::GlobalAllocPolicy()
, mDecoderLimit(MediaPrefs::MediaDecoderLimit()) , mDecoderLimit(MediaPrefs::MediaDecoderLimit())
{ {
SystemGroup::Dispatch( SystemGroup::Dispatch(
"GlobalAllocPolicy::ClearOnShutdown",
TaskCategory::Other, TaskCategory::Other,
NS_NewRunnableFunction("GlobalAllocPolicy::GlobalAllocPolicy", [this]() { NS_NewRunnableFunction("GlobalAllocPolicy::GlobalAllocPolicy", [this]() {
ClearOnShutdown(this, ShutdownPhase::ShutdownThreads); ClearOnShutdown(this, ShutdownPhase::ShutdownThreads);

View file

@ -6,7 +6,7 @@
#if !defined(MediaQueue_h_) #if !defined(MediaQueue_h_)
#define MediaQueue_h_ #define MediaQueue_h_
#include "mozilla/ReentrantMonitor.h" #include "mozilla/RecursiveMutex.h"
#include "mozilla/TaskQueue.h" #include "mozilla/TaskQueue.h"
#include "nsDeque.h" #include "nsDeque.h"
@ -29,7 +29,7 @@ class MediaQueue : private nsDeque {
public: public:
MediaQueue() MediaQueue()
: nsDeque(new MediaQueueDeallocator<T>()), : nsDeque(new MediaQueueDeallocator<T>()),
mReentrantMonitor("mediaqueue"), mRecursiveMutex("mediaqueue"),
mEndOfStream(false) mEndOfStream(false)
{} {}
@ -38,12 +38,12 @@ public:
} }
inline size_t GetSize() const { inline size_t GetSize() const {
ReentrantMonitorAutoEnter mon(mReentrantMonitor); RecursiveMutexAutoLock lock(mRecursiveMutex);
return nsDeque::GetSize(); return nsDeque::GetSize();
} }
inline void Push(T* aItem) { inline void Push(T* aItem) {
ReentrantMonitorAutoEnter mon(mReentrantMonitor); RecursiveMutexAutoLock lock(mRecursiveMutex);
MOZ_ASSERT(!mEndOfStream); MOZ_ASSERT(!mEndOfStream);
MOZ_ASSERT(aItem); MOZ_ASSERT(aItem);
NS_ADDREF(aItem); NS_ADDREF(aItem);
@ -53,7 +53,7 @@ public:
} }
inline already_AddRefed<T> PopFront() { inline already_AddRefed<T> PopFront() {
ReentrantMonitorAutoEnter mon(mReentrantMonitor); RecursiveMutexAutoLock lock(mRecursiveMutex);
RefPtr<T> rv = dont_AddRef(static_cast<T*>(nsDeque::PopFront())); RefPtr<T> rv = dont_AddRef(static_cast<T*>(nsDeque::PopFront()));
if (rv) { if (rv) {
mPopEvent.Notify(rv); mPopEvent.Notify(rv);
@ -62,12 +62,12 @@ public:
} }
inline RefPtr<T> PeekFront() const { inline RefPtr<T> PeekFront() const {
ReentrantMonitorAutoEnter mon(mReentrantMonitor); RecursiveMutexAutoLock lock(mRecursiveMutex);
return static_cast<T*>(nsDeque::PeekFront()); return static_cast<T*>(nsDeque::PeekFront());
} }
void Reset() { void Reset() {
ReentrantMonitorAutoEnter mon(mReentrantMonitor); RecursiveMutexAutoLock lock(mRecursiveMutex);
while (GetSize() > 0) { while (GetSize() > 0) {
RefPtr<T> x = dont_AddRef(static_cast<T*>(nsDeque::PopFront())); RefPtr<T> x = dont_AddRef(static_cast<T*>(nsDeque::PopFront()));
} }
@ -75,7 +75,7 @@ public:
} }
bool AtEndOfStream() const { bool AtEndOfStream() const {
ReentrantMonitorAutoEnter mon(mReentrantMonitor); RecursiveMutexAutoLock lock(mRecursiveMutex);
return GetSize() == 0 && mEndOfStream; return GetSize() == 0 && mEndOfStream;
} }
@ -83,13 +83,13 @@ public:
// This happens when the media stream has been completely decoded. Note this // This happens when the media stream has been completely decoded. Note this
// does not mean that the corresponding stream has finished playback. // does not mean that the corresponding stream has finished playback.
bool IsFinished() const { bool IsFinished() const {
ReentrantMonitorAutoEnter mon(mReentrantMonitor); RecursiveMutexAutoLock lock(mRecursiveMutex);
return mEndOfStream; return mEndOfStream;
} }
// Informs the media queue that it won't be receiving any more items. // Informs the media queue that it won't be receiving any more items.
void Finish() { void Finish() {
ReentrantMonitorAutoEnter mon(mReentrantMonitor); RecursiveMutexAutoLock lock(mRecursiveMutex);
if (!mEndOfStream) { if (!mEndOfStream) {
mEndOfStream = true; mEndOfStream = true;
mFinishEvent.Notify(); mFinishEvent.Notify();
@ -98,7 +98,7 @@ public:
// Returns the approximate number of microseconds of items in the queue. // Returns the approximate number of microseconds of items in the queue.
int64_t Duration() { int64_t Duration() {
ReentrantMonitorAutoEnter mon(mReentrantMonitor); RecursiveMutexAutoLock lock(mRecursiveMutex);
if (GetSize() == 0) { if (GetSize() == 0) {
return 0; return 0;
} }
@ -108,14 +108,14 @@ public:
} }
void LockedForEach(nsDequeFunctor& aFunctor) const { void LockedForEach(nsDequeFunctor& aFunctor) const {
ReentrantMonitorAutoEnter mon(mReentrantMonitor); RecursiveMutexAutoLock lock(mRecursiveMutex);
ForEach(aFunctor); ForEach(aFunctor);
} }
// Extracts elements from the queue into aResult, in order. // Extracts elements from the queue into aResult, in order.
// Elements whose start time is before aTime are ignored. // Elements whose start time is before aTime are ignored.
void GetElementsAfter(int64_t aTime, nsTArray<RefPtr<T>>* aResult) { void GetElementsAfter(int64_t aTime, nsTArray<RefPtr<T>>* aResult) {
ReentrantMonitorAutoEnter mon(mReentrantMonitor); RecursiveMutexAutoLock lock(mRecursiveMutex);
if (GetSize() == 0) if (GetSize() == 0)
return; return;
size_t i; size_t i;
@ -138,14 +138,14 @@ public:
} }
void GetFirstElements(uint32_t aMaxElements, nsTArray<RefPtr<T>>* aResult) { void GetFirstElements(uint32_t aMaxElements, nsTArray<RefPtr<T>>* aResult) {
ReentrantMonitorAutoEnter mon(mReentrantMonitor); RecursiveMutexAutoLock lock(mRecursiveMutex);
for (size_t i = 0; i < aMaxElements && i < GetSize(); ++i) { for (size_t i = 0; i < aMaxElements && i < GetSize(); ++i) {
*aResult->AppendElement() = static_cast<T*>(ObjectAt(i)); *aResult->AppendElement() = static_cast<T*>(ObjectAt(i));
} }
} }
uint32_t FrameCount() { uint32_t FrameCount() {
ReentrantMonitorAutoEnter mon(mReentrantMonitor); RecursiveMutexAutoLock lock(mRecursiveMutex);
uint32_t frames = 0; uint32_t frames = 0;
for (size_t i = 0; i < GetSize(); ++i) { for (size_t i = 0; i < GetSize(); ++i) {
T* v = static_cast<T*>(ObjectAt(i)); T* v = static_cast<T*>(ObjectAt(i));
@ -167,7 +167,7 @@ public:
} }
private: private:
mutable ReentrantMonitor mReentrantMonitor; mutable RecursiveMutex mRecursiveMutex;
MediaEventProducer<RefPtr<T>> mPopEvent; MediaEventProducer<RefPtr<T>> mPopEvent;
MediaEventProducer<RefPtr<T>> mPushEvent; MediaEventProducer<RefPtr<T>> mPushEvent;
MediaEventProducer<void> mFinishEvent; MediaEventProducer<void> mFinishEvent;

View file

@ -64,7 +64,6 @@ MediaResource::Destroy()
return; return;
} }
nsresult rv = SystemGroup::Dispatch( nsresult rv = SystemGroup::Dispatch(
"MediaResource::Destroy",
TaskCategory::Other, TaskCategory::Other,
NewNonOwningRunnableMethod( NewNonOwningRunnableMethod(
"MediaResource::Destroy", this, &MediaResource::Destroy)); "MediaResource::Destroy", this, &MediaResource::Destroy));

View file

@ -1531,6 +1531,12 @@ MediaStreamGraphImpl::Notify(nsITimer* aTimer)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
MediaStreamGraphImpl::GetName(nsACString& aName)
{
aName.AssignLiteral("MediaStreamGraphImpl");
return NS_OK;
}
/* static */ StaticRefPtr<nsIAsyncShutdownBlocker> gMediaStreamGraphShutdownBlocker; /* static */ StaticRefPtr<nsIAsyncShutdownBlocker> gMediaStreamGraphShutdownBlocker;
@ -3623,7 +3629,8 @@ MediaStreamGraph::DestroyNonRealtimeInstance(MediaStreamGraph* aGraph)
graph->ForceShutDown(nullptr); graph->ForceShutDown(nullptr);
} }
NS_IMPL_ISUPPORTS(MediaStreamGraphImpl, nsIMemoryReporter, nsITimerCallback) NS_IMPL_ISUPPORTS(MediaStreamGraphImpl, nsIMemoryReporter, nsITimerCallback,
nsINamed)
NS_IMETHODIMP NS_IMETHODIMP
MediaStreamGraphImpl::CollectReports(nsIHandleReportCallback* aHandleReport, MediaStreamGraphImpl::CollectReports(nsIHandleReportCallback* aHandleReport,

View file

@ -14,6 +14,7 @@
#include "mozilla/Monitor.h" #include "mozilla/Monitor.h"
#include "mozilla/TimeStamp.h" #include "mozilla/TimeStamp.h"
#include "nsIMemoryReporter.h" #include "nsIMemoryReporter.h"
#include "nsINamed.h"
#include "nsIThread.h" #include "nsIThread.h"
#include "nsIRunnable.h" #include "nsIRunnable.h"
#include "nsIAsyncShutdown.h" #include "nsIAsyncShutdown.h"
@ -99,12 +100,14 @@ public:
*/ */
class MediaStreamGraphImpl : public MediaStreamGraph, class MediaStreamGraphImpl : public MediaStreamGraph,
public nsIMemoryReporter, public nsIMemoryReporter,
public nsITimerCallback public nsITimerCallback,
public nsINamed
{ {
public: public:
NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIMEMORYREPORTER NS_DECL_NSIMEMORYREPORTER
NS_DECL_NSITIMERCALLBACK NS_DECL_NSITIMERCALLBACK
NS_DECL_NSINAMED
/** /**
* Use aGraphDriverRequested with SYSTEM_THREAD_DRIVER or AUDIO_THREAD_DRIVER * Use aGraphDriverRequested with SYSTEM_THREAD_DRIVER or AUDIO_THREAD_DRIVER

View file

@ -337,7 +337,6 @@ TextTrack::DispatchAsyncTrustedEvent(const nsString& aEventName)
} }
RefPtr<TextTrack> self = this; RefPtr<TextTrack> self = this;
nsGlobalWindow::Cast(win)->Dispatch( nsGlobalWindow::Cast(win)->Dispatch(
"TextTrack::DispatchAsyncTrustedEvent",
TaskCategory::Other, TaskCategory::Other,
NS_NewRunnableFunction( NS_NewRunnableFunction(
"dom::TextTrack::DispatchAsyncTrustedEvent", "dom::TextTrack::DispatchAsyncTrustedEvent",

View file

@ -193,9 +193,7 @@ TextTrackList::CreateAndDispatchChangeEvent()
event->SetTrusted(true); event->SetTrusted(true);
nsCOMPtr<nsIRunnable> eventRunner = new ChangeEventRunner(this, event); nsCOMPtr<nsIRunnable> eventRunner = new ChangeEventRunner(this, event);
nsGlobalWindow::Cast(win)->Dispatch( nsGlobalWindow::Cast(win)->Dispatch(TaskCategory::Other, eventRunner.forget());
"TextTrackList::CreateAndDispatchChangeEvent", TaskCategory::Other,
eventRunner.forget());
} }
} }

View file

@ -341,6 +341,13 @@ SimpleTimer::Notify(nsITimer *timer) {
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
SimpleTimer::GetName(nsACString& aName)
{
aName.AssignLiteral("SimpleTimer");
return NS_OK;
}
nsresult nsresult
SimpleTimer::Init(nsIRunnable* aTask, uint32_t aTimeoutMs, nsIEventTarget* aTarget) SimpleTimer::Init(nsIRunnable* aTask, uint32_t aTimeoutMs, nsIEventTarget* aTarget)
{ {
@ -378,7 +385,7 @@ SimpleTimer::Init(nsIRunnable* aTask, uint32_t aTimeoutMs, nsIEventTarget* aTarg
return NS_OK; return NS_OK;
} }
NS_IMPL_ISUPPORTS(SimpleTimer, nsITimerCallback) NS_IMPL_ISUPPORTS(SimpleTimer, nsITimerCallback, nsINamed)
already_AddRefed<SimpleTimer> already_AddRefed<SimpleTimer>
SimpleTimer::Create(nsIRunnable* aTask, uint32_t aTimeoutMs, nsIEventTarget* aTarget) SimpleTimer::Create(nsIRunnable* aTask, uint32_t aTimeoutMs, nsIEventTarget* aTarget)
@ -397,7 +404,7 @@ LogToBrowserConsole(const nsAString& aMsg)
nsString msg(aMsg); nsString msg(aMsg);
nsCOMPtr<nsIRunnable> task = NS_NewRunnableFunction( nsCOMPtr<nsIRunnable> task = NS_NewRunnableFunction(
"LogToBrowserConsole", [msg]() { LogToBrowserConsole(msg); }); "LogToBrowserConsole", [msg]() { LogToBrowserConsole(msg); });
SystemGroup::Dispatch("LogToBrowserConsole", TaskCategory::Other, task.forget()); SystemGroup::Dispatch(TaskCategory::Other, task.forget());
return; return;
} }
nsCOMPtr<nsIConsoleService> console( nsCOMPtr<nsIConsoleService> console(

View file

@ -20,6 +20,7 @@
#include "mozilla/UniquePtr.h" #include "mozilla/UniquePtr.h"
#include "nsAutoPtr.h" #include "nsAutoPtr.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsINamed.h"
#include "nsIThread.h" #include "nsIThread.h"
#include "nsITimer.h" #include "nsITimer.h"
#include "nsRect.h" #include "nsRect.h"
@ -284,10 +285,11 @@ RefPtr<GenericPromise> InvokeUntil(Work aWork, Condition aCondition) {
} }
// Simple timer to run a runnable after a timeout. // Simple timer to run a runnable after a timeout.
class SimpleTimer : public nsITimerCallback class SimpleTimer : public nsITimerCallback, public nsINamed
{ {
public: public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_DECL_NSINAMED
// Create a new timer to run aTask after aTimeoutMs milliseconds // Create a new timer to run aTask after aTimeoutMs milliseconds
// on thread aTarget. If aTarget is null, task is run on the main thread. // on thread aTarget. If aTarget is null, task is run on the main thread.

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