diff --git a/browser/actors/RFPHelperChild.jsm b/browser/actors/RFPHelperChild.jsm new file mode 100644 index 0000000000000..fa54afbcd03ff --- /dev/null +++ b/browser/actors/RFPHelperChild.jsm @@ -0,0 +1,22 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +var EXPORTED_SYMBOLS = ["RFPHelperChild"]; + +const {ActorChild} = ChromeUtils.import("resource://gre/modules/ActorChild.jsm"); +const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); + +const kPrefLetterboxing = "privacy.resistFingerprinting.letterboxing"; + +XPCOMUtils.defineLazyPreferenceGetter(this, "isLetterboxingEnabled", + kPrefLetterboxing, false); + +class RFPHelperChild extends ActorChild { + handleEvent() { + if (isLetterboxingEnabled) { + this.mm.sendAsyncMessage("Letterboxing:ContentSizeUpdated"); + } + } +} diff --git a/browser/actors/moz.build b/browser/actors/moz.build index e84a2a8e7af10..00d1d87867a08 100644 --- a/browser/actors/moz.build +++ b/browser/actors/moz.build @@ -42,6 +42,7 @@ FINAL_TARGET_FILES.actors += [ 'PageInfoChild.jsm', 'PageStyleChild.jsm', 'PluginChild.jsm', + 'RFPHelperChild.jsm', 'SearchTelemetryChild.jsm', 'URIFixupChild.jsm', 'WebRTCChild.jsm', diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 84074bf49cdd4..108a8ee961b42 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -28,7 +28,6 @@ XPCOMUtils.defineLazyModuleGetters(this, { E10SUtils: "resource://gre/modules/E10SUtils.jsm", ExtensionsUI: "resource:///modules/ExtensionsUI.jsm", FormValidationHandler: "resource:///modules/FormValidationHandler.jsm", - LanguagePrompt: "resource://gre/modules/LanguagePrompt.jsm", HomePage: "resource:///modules/HomePage.jsm", LightweightThemeConsumer: "resource://gre/modules/LightweightThemeConsumer.jsm", LightweightThemeManager: "resource://gre/modules/LightweightThemeManager.jsm", @@ -50,6 +49,7 @@ XPCOMUtils.defineLazyModuleGetters(this, { ProcessHangMonitor: "resource:///modules/ProcessHangMonitor.jsm", PromiseUtils: "resource://gre/modules/PromiseUtils.jsm", ReaderParent: "resource:///modules/ReaderParent.jsm", + RFPHelper: "resource://gre/modules/RFPHelper.jsm", SafeBrowsing: "resource://gre/modules/SafeBrowsing.jsm", Sanitizer: "resource:///modules/Sanitizer.jsm", SessionStartup: "resource:///modules/sessionstore/SessionStartup.jsm", @@ -1948,8 +1948,6 @@ var gBrowserInit = { ToolbarKeyboardNavigator.uninit(); } - LanguagePrompt.uninit(); - BrowserSearch.uninit(); // Now either cancel delayedStartup, or clean up the services initialized from diff --git a/browser/components/BrowserGlue.jsm b/browser/components/BrowserGlue.jsm index 00426c5862baf..040be5b7132aa 100644 --- a/browser/components/BrowserGlue.jsm +++ b/browser/components/BrowserGlue.jsm @@ -244,6 +244,16 @@ let ACTORS = { }, }, + RFPHelper: { + child: { + module: "resource:///actors/RFPHelperChild.jsm", + group: "browsers", + events: { + "resize": {}, + }, + }, + }, + SearchTelemetry: { child: { module: "resource:///actors/SearchTelemetryChild.jsm", @@ -397,7 +407,6 @@ XPCOMUtils.defineLazyModuleGetters(this, { HybridContentTelemetry: "resource://gre/modules/HybridContentTelemetry.jsm", Integration: "resource://gre/modules/Integration.jsm", L10nRegistry: "resource://gre/modules/L10nRegistry.jsm", - LanguagePrompt: "resource://gre/modules/LanguagePrompt.jsm", LightweightThemeManager: "resource://gre/modules/LightweightThemeManager.jsm", LiveBookmarkMigrator: "resource:///modules/LiveBookmarkMigrator.jsm", NewTabUtils: "resource://gre/modules/NewTabUtils.jsm", @@ -415,6 +424,7 @@ XPCOMUtils.defineLazyModuleGetters(this, { PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.jsm", ProcessHangMonitor: "resource:///modules/ProcessHangMonitor.jsm", RemoteSettings: "resource://services-settings/remote-settings.js", + RFPHelper: "resource://gre/modules/RFPHelper.jsm", SafeBrowsing: "resource://gre/modules/SafeBrowsing.jsm", Sanitizer: "resource:///modules/Sanitizer.jsm", SaveToPocket: "chrome://pocket/content/SaveToPocket.jsm", @@ -1461,6 +1471,7 @@ BrowserGlue.prototype = { DateTimePickerParent.uninit(); Normandy.uninit(); + RFPHelper.uninit(); }, // Set up a listener to enable/disable the screenshots extension @@ -1674,7 +1685,7 @@ BrowserGlue.prototype = { } Services.tm.idleDispatchToMainThread(() => { - LanguagePrompt.init(); + RFPHelper.init(); }); Services.tm.idleDispatchToMainThread(() => { diff --git a/browser/components/resistfingerprinting/test/browser/browser.ini b/browser/components/resistfingerprinting/test/browser/browser.ini index 024ee29907b4b..1aa918b4574bc 100644 --- a/browser/components/resistfingerprinting/test/browser/browser.ini +++ b/browser/components/resistfingerprinting/test/browser/browser.ini @@ -11,6 +11,7 @@ support-files = head.js [browser_block_mozAddonManager.js] +[browser_dynamical_window_rounding.js] [browser_navigator.js] [browser_netInfo.js] [browser_performanceAPI.js] diff --git a/browser/components/resistfingerprinting/test/browser/browser_bug1369357_site_specific_zoom_level.js b/browser/components/resistfingerprinting/test/browser/browser_bug1369357_site_specific_zoom_level.js index b11ea22631b72..ee77494e18166 100644 --- a/browser/components/resistfingerprinting/test/browser/browser_bug1369357_site_specific_zoom_level.js +++ b/browser/components/resistfingerprinting/test/browser/browser_bug1369357_site_specific_zoom_level.js @@ -25,6 +25,8 @@ add_task(async function() { isnot(tab3Zoom, tab1Zoom, "privacy.resistFingerprinting is true, site-specific zoom level should be disabled"); + await FullZoom.reset(); + BrowserTestUtils.removeTab(tab1); BrowserTestUtils.removeTab(tab2); BrowserTestUtils.removeTab(tab3); diff --git a/browser/components/resistfingerprinting/test/browser/browser_dynamical_window_rounding.js b/browser/components/resistfingerprinting/test/browser/browser_dynamical_window_rounding.js new file mode 100644 index 0000000000000..ae8055a49ce51 --- /dev/null +++ b/browser/components/resistfingerprinting/test/browser/browser_dynamical_window_rounding.js @@ -0,0 +1,281 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. + * + * Bug 1407366 - A test case for reassuring the size of the content viewport is + * rounded if the window is resized when letterboxing is enabled. + * + * A helpful note: if this test starts randomly failing; it may be because the + * zoom level was not reset by an earlier-run test. See Bug 1407366 for an + * example. + */ + +const TEST_PATH = "http://example.net/browser/browser/components/resistfingerprinting/test/browser/"; + +const DEFAULT_ROUNDED_WIDTH_STEP = 200; +const DEFAULT_ROUNDED_HEIGHT_STEP = 100; + +// A set of test cases which defines the width and the height of the outer window. +const TEST_CASES = [ + {width: 1250, height: 1000}, + {width: 1500, height: 1050}, + {width: 1120, height: 760}, + {width: 800, height: 600}, + {width: 640, height: 400}, + {width: 500, height: 350}, + {width: 300, height: 170}, +]; + +function getPlatform() { + const {OS} = Services.appinfo; + if (OS == "WINNT") { + return "win"; + } else if (OS == "Darwin") { + return "mac"; + } + return "linux"; +} + +function handleOSFuzziness(aContent, aTarget) { + /* + * On Windows, we observed off-by-one pixel differences that + * couldn't be expained. When manually setting the window size + * to try to reproduce it; it did not occur. + */ + if (getPlatform() == "win") { + return Math.abs(aContent - aTarget) <= 1; + } + return aContent == aTarget; +} + +function checkForDefaultSetting( + aContentWidth, aContentHeight, aRealWidth, aRealHeight) { + // The default behavior for rounding is to round window with 200x100 stepping. + // So, we can get the rounded size by subtracting the remainder. + let targetWidth = aRealWidth - (aRealWidth % DEFAULT_ROUNDED_WIDTH_STEP); + let targetHeight = aRealHeight - (aRealHeight % DEFAULT_ROUNDED_HEIGHT_STEP); + + // This platform-specific code is explained in the large comment below. + if (getPlatform() != "linux") { + ok(handleOSFuzziness(aContentWidth, targetWidth), + `Default Dimensions: The content window width is correctly rounded into. ${aRealWidth}px -> ${aContentWidth}px should equal ${targetWidth}px`); + + ok(handleOSFuzziness(aContentHeight, targetHeight), + `Default Dimensions: The content window height is correctly rounded into. ${aRealHeight}px -> ${aContentHeight}px should equal ${targetHeight}px`); + + // Using ok() above will cause Win/Mac to fail on even the first test, we don't need to repeat it, return true so waitForCondition ends + return true; + } + // Returning true or false depending on if the test succeeded will cause Linux to repeat until it succeeds. + return handleOSFuzziness(aContentWidth, targetWidth) && handleOSFuzziness(aContentHeight, targetHeight); +} + +async function test_dynamical_window_rounding(aWindow, aCheckFunc) { + // We need to wait for the updating the margins for the newly opened tab, or + // it will affect the following tests. + let promiseForTheFirstRounding = + TestUtils.topicObserved("test:letterboxing:update-margin-finish"); + + info("Open a content tab for testing."); + let tab = await BrowserTestUtils.openNewForegroundTab( + aWindow.gBrowser, TEST_PATH + "file_dummy.html"); + + info("Wait until the margins are applied for the opened tab."); + await promiseForTheFirstRounding; + + let getContainerSize = (aTab) => { + let browserContainer = aWindow.gBrowser + .getBrowserContainer(aTab.linkedBrowser); + return { + containerWidth: browserContainer.clientWidth, + containerHeight: browserContainer.clientHeight, + }; + }; + + for (let {width, height} of TEST_CASES) { + let caseString = "Case " + width + "x" + height + ": "; + // Create a promise for waiting for the margin update. + let promiseRounding = + TestUtils.topicObserved("test:letterboxing:update-margin-finish"); + + let {containerWidth, containerHeight} = getContainerSize(tab); + + info(caseString + "Resize the window and wait until resize event happened (currently " + + containerWidth + "x" + containerHeight + ")"); + await new Promise(resolve => { + ({containerWidth, containerHeight} = getContainerSize(tab)); + info(caseString + "Resizing (currently " + containerWidth + "x" + containerHeight + ")"); + + aWindow.onresize = () => { + ({containerWidth, containerHeight} = getContainerSize(tab)); + info(caseString + "Resized (currently " + containerWidth + "x" + containerHeight + ")"); + if (getPlatform() == "linux" && containerWidth != width) { + /* + * We observed frequent test failures that resulted from receiving an onresize + * event where the browser was resized to an earlier requested dimension. This + * resize event happens on Linux only, and is an artifact of the asynchronous + * resizing. (See more discussion on 1407366#53) + * + * We cope with this problem in two ways. + * + * 1: If we detect that the browser was resized to the wrong value; we + * redo the resize. (This is the lines of code immediately following this + * comment) + * 2: We repeat the test until it works using waitForCondition(). But we still + * test Win/Mac more thoroughly: they do not loop in waitForCondition more + * than once, and can fail the test on the first attempt (because their + * check() functions use ok() while on Linux, we do not all ok() and instead + * rely on waitForCondition to fail). + * + * The logging statements in this test, and RFPHelper.jsm, help narrow down and + * illustrate the issue. + */ + info(caseString + "We hit the weird resize bug. Resize it again."); + aWindow.resizeTo(width, height); + } else { + resolve(); + } + }; + aWindow.resizeTo(width, height); + }); + + ({containerWidth, containerHeight} = getContainerSize(tab)); + info(caseString + "Waiting until margin has been updated on browser element. (currently " + + containerWidth + "x" + containerHeight + ")"); + await promiseRounding; + + info(caseString + "Get innerWidth/Height from the content."); + await BrowserTestUtils.waitForCondition(async () => { + let {contentWidth, contentHeight} = await ContentTask.spawn( + tab.linkedBrowser, null, () => { + return { + contentWidth: content.innerWidth, + contentHeight: content.innerHeight, + }; + }); + + info(caseString + "Check the result."); + return aCheckFunc(contentWidth, contentHeight, containerWidth, containerHeight); + }, "Default Dimensions: The content window width is correctly rounded into."); + } + + BrowserTestUtils.removeTab(tab); +} + +async function test_customize_width_and_height(aWindow) { + const test_dimensions = `120x80, 200x143, 335x255, 600x312, 742x447, 813x558, + 990x672, 1200x733, 1470x858`; + + await SpecialPowers.pushPrefEnv({"set": + [ + ["privacy.resistFingerprinting.letterboxing.dimensions", test_dimensions], + ], + }); + + let dimensions_set = test_dimensions.split(",").map(item => { + let sizes = item.split("x").map(size => parseInt(size, 10)); + + return { + width: sizes[0], + height: sizes[1], + }; + }); + + let checkDimension = + (aContentWidth, aContentHeight, aRealWidth, aRealHeight) => { + let matchingArea = aRealWidth * aRealHeight; + let minWaste = Number.MAX_SAFE_INTEGER; + let targetDimensions = undefined; + + // Find the dimensions which waste the least content area. + for (let dim of dimensions_set) { + if (dim.width > aRealWidth || dim.height > aRealHeight) { + continue; + } + + let waste = matchingArea - dim.width * dim.height; + + if (waste >= 0 && waste < minWaste) { + targetDimensions = dim; + minWaste = waste; + } + } + + // This platform-specific code is explained in the large comment above. + if (getPlatform() != "linux") { + ok(handleOSFuzziness(aContentWidth, targetDimensions.width), + `Custom Dimension: The content window width is correctly rounded into. ${aRealWidth}px -> ${aContentWidth}px should equal ${targetDimensions.width}`); + + ok(handleOSFuzziness(aContentHeight, targetDimensions.height), + `Custom Dimension: The content window height is correctly rounded into. ${aRealHeight}px -> ${aContentHeight}px should equal ${targetDimensions.height}`); + + // Using ok() above will cause Win/Mac to fail on even the first test, we don't need to repeat it, return true so waitForCondition ends + return true; + } + // Returning true or false depending on if the test succeeded will cause Linux to repeat until it succeeds. + return handleOSFuzziness(aContentWidth, targetDimensions.width) && handleOSFuzziness(aContentHeight, targetDimensions.height); + }; + + await test_dynamical_window_rounding(aWindow, checkDimension); + + await SpecialPowers.popPrefEnv(); +} + +async function test_no_rounding_for_chrome(aWindow) { + // First, resize the window to a size with is not rounded. + await new Promise(resolve => { + aWindow.onresize = () => resolve(); + aWindow.resizeTo(700, 450); + }); + + // open a chrome privilege tab, like about:config. + let tab = await BrowserTestUtils.openNewForegroundTab( + aWindow.gBrowser, "about:config"); + + // Check that the browser element should not have a margin. + is(tab.linkedBrowser.style.margin, "", "There is no margin around chrome tab."); + + BrowserTestUtils.removeTab(tab); +} + +add_task(async function setup() { + await SpecialPowers.pushPrefEnv({"set": + [ + ["privacy.resistFingerprinting.letterboxing", true], + ["privacy.resistFingerprinting.letterboxing.testing", true], + ], + }); +}); + +add_task(async function do_tests() { + // Store the original window size before testing. + let originalOuterWidth = window.outerWidth; + let originalOuterHeight = window.outerHeight; + + info("Run test for the default window rounding."); + await test_dynamical_window_rounding(window, checkForDefaultSetting); + + info("Run test for the window rounding with customized dimensions."); + await test_customize_width_and_height(window); + + info("Run test for no margin around tab with the chrome privilege."); + await test_no_rounding_for_chrome(window); + + // Restore the original window size. + window.outerWidth = originalOuterWidth; + window.outerHeight = originalOuterHeight; + + // Testing that whether the dynamical rounding works for new windows. + let win = await BrowserTestUtils.openNewBrowserWindow(); + + info("Run test for the default window rounding in new window."); + await test_dynamical_window_rounding(win, checkForDefaultSetting); + + info("Run test for the window rounding with customized dimensions in new window."); + await test_customize_width_and_height(win); + + info("Run test for no margin around tab with the chrome privilege in new window."); + await test_no_rounding_for_chrome(win); + + await BrowserTestUtils.closeWindow(win); +}); diff --git a/devtools/platform/components.conf b/devtools/platform/components.conf new file mode 100644 index 0000000000000..7e7d451b832c8 --- /dev/null +++ b/devtools/platform/components.conf @@ -0,0 +1,14 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +Classes = [ + { + 'cid': '{ec5aa99c-7abb-4142-ac5f-aab2419e38e2}', + 'contract_ids': ['@mozilla.org/jsinspector;1'], + 'type': 'mozilla::jsinspector::nsJSInspector', + 'headers': ['/devtools/platform/nsJSInspector.h'], + }, +] diff --git a/devtools/platform/moz.build b/devtools/platform/moz.build index 5aad20065ea7b..349f5554029c3 100644 --- a/devtools/platform/moz.build +++ b/devtools/platform/moz.build @@ -16,4 +16,8 @@ SOURCES += [ 'nsJSInspector.cpp', ] +XPCOM_MANIFESTS += [ + 'components.conf', +] + FINAL_LIBRARY = 'xul' diff --git a/devtools/platform/nsJSInspector.cpp b/devtools/platform/nsJSInspector.cpp index 298f61121e46b..e4a1e92130f3e 100644 --- a/devtools/platform/nsJSInspector.cpp +++ b/devtools/platform/nsJSInspector.cpp @@ -8,7 +8,6 @@ #include "nsThreadUtils.h" #include "jsfriendapi.h" #include "mozilla/HoldDropJSObjects.h" -#include "mozilla/ModuleUtils.h" #include "mozilla/dom/ScriptSettings.h" #include "nsServiceManagerUtils.h" #include "nsMemory.h" @@ -27,8 +26,6 @@ namespace mozilla { namespace jsinspector { -NS_GENERIC_FACTORY_CONSTRUCTOR(nsJSInspector) - NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsJSInspector) NS_INTERFACE_MAP_ENTRY(nsISupports) NS_INTERFACE_MAP_ENTRY(nsIJSInspector) @@ -121,18 +118,3 @@ nsJSInspector::GetLastNestRequestor(JS::MutableHandle out) { } // namespace jsinspector } // namespace mozilla - -NS_DEFINE_NAMED_CID(JSINSPECTOR_CID); - -static const mozilla::Module::CIDEntry kJSInspectorCIDs[] = { - {&kJSINSPECTOR_CID, false, nullptr, - mozilla::jsinspector::nsJSInspectorConstructor}, - {nullptr}}; - -static const mozilla::Module::ContractIDEntry kJSInspectorContracts[] = { - {JSINSPECTOR_CONTRACTID, &kJSINSPECTOR_CID}, {nullptr}}; - -static const mozilla::Module kJSInspectorModule = { - mozilla::Module::kVersion, kJSInspectorCIDs, kJSInspectorContracts}; - -NSMODULE_DEFN(jsinspector) = &kJSInspectorModule; diff --git a/dom/base/Timeout.h b/dom/base/Timeout.h index 55a75544b8c51..0bfc704057d26 100644 --- a/dom/base/Timeout.h +++ b/dom/base/Timeout.h @@ -89,7 +89,7 @@ class Timeout final : public LinkedListElement> { // when sync loops trigger nested firing. uint32_t mFiringId; -#ifdef DEBUG +#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED int64_t mFiringIndex; #endif diff --git a/dom/base/TimeoutManager.cpp b/dom/base/TimeoutManager.cpp index 5e02d4c07aebb..5acf5385cbb5a 100644 --- a/dom/base/TimeoutManager.cpp +++ b/dom/base/TimeoutManager.cpp @@ -454,7 +454,7 @@ TimeoutManager::TimeoutManager(nsGlobalWindowInner& aWindow, mTimeouts(*this), mTimeoutIdCounter(1), mNextFiringId(InvalidFiringId + 1), -#ifdef DEBUG +#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED mFiringIndex(0), mLastFiringIndex(-1), #endif @@ -563,7 +563,7 @@ nsresult TimeoutManager::SetTimeout(nsITimeoutHandler* aHandler, } RefPtr timeout = new Timeout(); -#ifdef DEBUG +#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED timeout->mFiringIndex = -1; #endif timeout->mWindow = &mWindow; @@ -860,14 +860,30 @@ void TimeoutManager::RunTimeout(const TimeStamp& aNow, // objects we computed above. if (timeout->mFiringId != firingId) { // If the FiringId does not match, but is still valid, then this is - // a Timeout for another RunTimeout() on the call stack. Just - // skip it. + // a Timeout for another RunTimeout() on the call stack (such as in + // the case of nested event loops, for alert() or more likely XHR). + // Just skip it. if (IsValidFiringId(timeout->mFiringId)) { MOZ_LOG(gTimeoutLog, LogLevel::Debug, ("Skipping Run%s(TimeoutManager=%p, timeout=%p) since " - "firingId %d is valid (processing firingId %d)", + "firingId %d is valid (processing firingId %d) - " + "FiringIndex %" PRId64 " (mLastFiringIndex %" PRId64 ")", timeout->mIsInterval ? "Interval" : "Timeout", this, - timeout.get(), timeout->mFiringId, firingId)); + timeout.get(), timeout->mFiringId, firingId, + timeout->mFiringIndex, mFiringIndex)); +#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED + // The old FiringIndex assumed no recursion; recursion can cause + // other timers to get fired "in the middle" of a sequence we've + // already assigned firingindexes to. Since we're not going to + // run this timeout now, remove any FiringIndex that was already + // set. + + // Since all timers that have FiringIndexes set *must* be ready + // to run and have valid FiringIds, all of them will be 'skipped' + // and reset if we recurse - we don't have to look through the + // list past where we'll stop on the first InvalidFiringId. + timeout->mFiringIndex = -1; +#endif continue; } @@ -899,7 +915,7 @@ void TimeoutManager::RunTimeout(const TimeStamp& aNow, // ("Wait until any invocations of this algorithm that had the same // method context, that started before this one, and whose timeout is // equal to or less than this one's, have completed."). -#ifdef DEBUG +#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED if (timeout->mFiringIndex == -1) { timeout->mFiringIndex = mFiringIndex++; } @@ -939,8 +955,18 @@ void TimeoutManager::RunTimeout(const TimeStamp& aNow, continue; } -#ifdef DEBUG - MOZ_ASSERT(timeout->mFiringIndex > mLastFiringIndex); +#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED + if (timeout->mFiringIndex <= mLastFiringIndex) { + MOZ_LOG(gTimeoutLog, LogLevel::Debug, + ("Incorrect firing index for Run%s(TimeoutManager=%p, " + "timeout=%p) with " + "firingId %d - FiringIndex %" PRId64 + " (mLastFiringIndex %" PRId64 ")", + timeout->mIsInterval ? "Interval" : "Timeout", this, + timeout.get(), timeout->mFiringId, timeout->mFiringIndex, + mFiringIndex)); + } + MOZ_DIAGNOSTIC_ASSERT(timeout->mFiringIndex > mLastFiringIndex); mLastFiringIndex = timeout->mFiringIndex; #endif // This timeout is good to run @@ -1068,7 +1094,7 @@ bool TimeoutManager::RescheduleTimeout(Timeout* aTimeout, TimeStamp firingTime = aLastCallbackTime + nextInterval; TimeDuration delay = firingTime - aCurrentNow; -#ifdef DEBUG +#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED aTimeout->mFiringIndex = -1; #endif // And make sure delay is nonnegative; that might happen if the timer diff --git a/dom/base/TimeoutManager.h b/dom/base/TimeoutManager.h index cd03a7ecb1e2c..338360b78047f 100644 --- a/dom/base/TimeoutManager.h +++ b/dom/base/TimeoutManager.h @@ -203,7 +203,7 @@ class TimeoutManager final { Timeouts mTimeouts; uint32_t mTimeoutIdCounter; uint32_t mNextFiringId; -#ifdef DEBUG +#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED int64_t mFiringIndex; int64_t mLastFiringIndex; #endif diff --git a/dom/file/uri/BlobURLProtocolHandler.cpp b/dom/file/uri/BlobURLProtocolHandler.cpp index 1e64fcfb64414..e915224891a38 100644 --- a/dom/file/uri/BlobURLProtocolHandler.cpp +++ b/dom/file/uri/BlobURLProtocolHandler.cpp @@ -17,7 +17,6 @@ #include "mozilla/dom/MediaSource.h" #include "mozilla/ipc/IPCStreamUtils.h" #include "mozilla/LoadInfo.h" -#include "mozilla/ModuleUtils.h" #include "mozilla/NullPrincipal.h" #include "mozilla/Preferences.h" #include "mozilla/SystemGroup.h" @@ -903,33 +902,6 @@ nsresult NS_GetSourceForMediaSourceURI(nsIURI* aURI, MediaSource** aSource) { namespace mozilla { namespace dom { -#define NS_BLOBPROTOCOLHANDLER_CID \ - { \ - 0xb43964aa, 0xa078, 0x44b2, { \ - 0xb0, 0x6b, 0xfd, 0x4d, 0x1b, 0x17, 0x2e, 0x66 \ - } \ - } - -NS_GENERIC_FACTORY_CONSTRUCTOR(BlobURLProtocolHandler) - -NS_DEFINE_NAMED_CID(NS_BLOBPROTOCOLHANDLER_CID); - -static const Module::CIDEntry kBlobURLProtocolHandlerCIDs[] = { - {&kNS_BLOBPROTOCOLHANDLER_CID, false, nullptr, - BlobURLProtocolHandlerConstructor}, - {nullptr}}; - -static const Module::ContractIDEntry kBlobURLProtocolHandlerContracts[] = { - {NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX BLOBURI_SCHEME, - &kNS_BLOBPROTOCOLHANDLER_CID}, - {nullptr}}; - -static const Module kBlobURLProtocolHandlerModule = { - Module::kVersion, kBlobURLProtocolHandlerCIDs, - kBlobURLProtocolHandlerContracts}; - -NSMODULE_DEFN(BlobURLProtocolHandler) = &kBlobURLProtocolHandlerModule; - bool IsType(nsIURI* aUri, DataInfo::ObjectType aType) { DataInfo* info = GetDataInfoFromURI(aUri); if (!info) { diff --git a/dom/file/uri/FontTableURIProtocolHandler.cpp b/dom/file/uri/FontTableURIProtocolHandler.cpp index b401fceb8a0e2..2e2fde110193e 100644 --- a/dom/file/uri/FontTableURIProtocolHandler.cpp +++ b/dom/file/uri/FontTableURIProtocolHandler.cpp @@ -5,8 +5,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "FontTableURIProtocolHandler.h" -#include "mozilla/ModuleUtils.h" +#include "nsIURIMutator.h" +#include "nsIUUIDGenerator.h" #include "nsNetUtil.h" +#include "nsSimpleURI.h" using namespace mozilla; using namespace mozilla::dom; @@ -107,31 +109,3 @@ FontTableURIProtocolHandler::NewURI(const nsACString &aSpec, uri.forget(aResult); return NS_OK; } - -#define NS_FONTTABLEPROTOCOLHANDLER_CID \ - { \ - 0x3fc8f04e, 0xd719, 0x43ca, { \ - 0x9a, 0xd0, 0x18, 0xee, 0x32, 0x02, 0x11, 0xf2 \ - } \ - } - -NS_GENERIC_FACTORY_CONSTRUCTOR(FontTableURIProtocolHandler) - -NS_DEFINE_NAMED_CID(NS_FONTTABLEPROTOCOLHANDLER_CID); - -static const mozilla::Module::CIDEntry FontTableURIProtocolHandlerCIDs[] = { - {&kNS_FONTTABLEPROTOCOLHANDLER_CID, false, nullptr, - FontTableURIProtocolHandlerConstructor}, - {nullptr}}; - -static const mozilla::Module::ContractIDEntry - FontTableURIProtocolHandlerContracts[] = { - {NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX FONTTABLEURI_SCHEME, - &kNS_FONTTABLEPROTOCOLHANDLER_CID}, - {nullptr}}; - -static const mozilla::Module FontTableURIProtocolHandlerModule = { - mozilla::Module::kVersion, FontTableURIProtocolHandlerCIDs, - FontTableURIProtocolHandlerContracts}; - -NSMODULE_DEFN(FontTableURIProtocolHandler) = &FontTableURIProtocolHandlerModule; diff --git a/dom/file/uri/components.conf b/dom/file/uri/components.conf new file mode 100644 index 0000000000000..67b7f799bb666 --- /dev/null +++ b/dom/file/uri/components.conf @@ -0,0 +1,20 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +Classes = [ + { + 'cid': '{3fc8f04e-d719-43ca-9ad0-18ee320211f2}', + 'contract_ids': ['@mozilla.org/network/protocol;1?name=moz-fonttable'], + 'type': 'mozilla::dom::FontTableURIProtocolHandler', + 'headers': ['mozilla/dom/FontTableURIProtocolHandler.h'], + }, + { + 'cid': '{b43964aa-a078-44b2-b06b-fd4d1b172e66}', + 'contract_ids': ['@mozilla.org/network/protocol;1?name=blob'], + 'type': 'mozilla::dom::BlobURLProtocolHandler', + 'headers': ['mozilla/dom/BlobURLProtocolHandler.h'], + }, +] diff --git a/dom/file/uri/moz.build b/dom/file/uri/moz.build index 1bf3b9ccc6739..bfd9c4e6024ce 100644 --- a/dom/file/uri/moz.build +++ b/dom/file/uri/moz.build @@ -20,6 +20,10 @@ UNIFIED_SOURCES += [ 'FontTableURIProtocolHandler.cpp', ] +XPCOM_MANIFESTS += [ + 'components.conf', +] + LOCAL_INCLUDES += [ '/dom/file', '/netwerk/base', diff --git a/dom/media/webspeech/synth/moz.build b/dom/media/webspeech/synth/moz.build index 696881c83822a..ab1136dbec29a 100644 --- a/dom/media/webspeech/synth/moz.build +++ b/dom/media/webspeech/synth/moz.build @@ -38,10 +38,13 @@ if CONFIG['MOZ_WEBSPEECH']: if CONFIG['MOZ_WEBSPEECH_TEST_BACKEND']: UNIFIED_SOURCES += [ - 'test/FakeSynthModule.cpp', 'test/nsFakeSynthServices.cpp' ] + XPCOM_MANIFESTS += [ + 'test/components.conf', + ] + if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': DIRS += ['windows'] diff --git a/dom/media/webspeech/synth/speechd/SpeechDispatcherModule.cpp b/dom/media/webspeech/synth/speechd/SpeechDispatcherModule.cpp deleted file mode 100644 index 4bf356bc846d1..0000000000000 --- a/dom/media/webspeech/synth/speechd/SpeechDispatcherModule.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "mozilla/ModuleUtils.h" -#include "nsIClassInfoImpl.h" -#include "SpeechDispatcherService.h" - -using namespace mozilla::dom; - -#define SPEECHDISPATCHERSERVICE_CID \ - { \ - 0x8817b1cf, 0x5ada, 0x43bf, { \ - 0xbd, 0x73, 0x60, 0x76, 0x57, 0x70, 0x3d, 0x0d \ - } \ - } - -#define SPEECHDISPATCHERSERVICE_CONTRACTID \ - "@mozilla.org/synthspeechdispatcher;1" - -// Defines SpeechDispatcherServiceConstructor -NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR( - SpeechDispatcherService, SpeechDispatcherService::GetInstanceForService) - -// Defines kSPEECHDISPATCHERSERVICE_CID -NS_DEFINE_NAMED_CID(SPEECHDISPATCHERSERVICE_CID); - -static const mozilla::Module::CIDEntry kCIDs[] = { - {&kSPEECHDISPATCHERSERVICE_CID, true, nullptr, - SpeechDispatcherServiceConstructor}, - {nullptr}}; - -static const mozilla::Module::ContractIDEntry kContracts[] = { - {SPEECHDISPATCHERSERVICE_CONTRACTID, &kSPEECHDISPATCHERSERVICE_CID}, - {nullptr}}; - -static const mozilla::Module::CategoryEntry kCategories[] = { - {"speech-synth-started", "SpeechDispatcher Speech Synth", - SPEECHDISPATCHERSERVICE_CONTRACTID}, - {nullptr}}; - -static const mozilla::Module kModule = { - mozilla::Module::kVersion, - kCIDs, - kContracts, - kCategories, - nullptr, - nullptr, - nullptr, -}; - -NSMODULE_DEFN(synthspeechdispatcher) = &kModule; diff --git a/dom/media/webspeech/synth/speechd/components.conf b/dom/media/webspeech/synth/speechd/components.conf new file mode 100644 index 0000000000000..56b01ba5cbc52 --- /dev/null +++ b/dom/media/webspeech/synth/speechd/components.conf @@ -0,0 +1,17 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +Classes = [ + { + 'cid': '{8817b1cf-5ada-43bf-bd73-607657703d0d}', + 'contract_ids': ['@mozilla.org/synthspeechdispatcher;1'], + 'singleton': True, + 'type': 'mozilla::dom::SpeechDispatcherService', + 'headers': ['/dom/media/webspeech/synth/speechd/SpeechDispatcherService.h'], + 'constructor': 'mozilla::dom::SpeechDispatcherService::GetInstanceForService', + 'categories': {"speech-synth-started": 'SpeechDispatcher Speech Synth'}, + }, +] diff --git a/dom/media/webspeech/synth/speechd/moz.build b/dom/media/webspeech/synth/speechd/moz.build index 51d675c10a485..5dc831883d6cb 100644 --- a/dom/media/webspeech/synth/speechd/moz.build +++ b/dom/media/webspeech/synth/speechd/moz.build @@ -5,9 +5,13 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. UNIFIED_SOURCES += [ - 'SpeechDispatcherModule.cpp', 'SpeechDispatcherService.cpp' ] + +XPCOM_MANIFESTS += [ + 'components.conf', +] + include('/ipc/chromium/chromium-config.mozbuild') FINAL_LIBRARY = 'xul' diff --git a/dom/media/webspeech/synth/test/FakeSynthModule.cpp b/dom/media/webspeech/synth/test/FakeSynthModule.cpp deleted file mode 100644 index c195748f3922e..0000000000000 --- a/dom/media/webspeech/synth/test/FakeSynthModule.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "mozilla/ModuleUtils.h" -#include "nsIClassInfoImpl.h" - -#include "nsFakeSynthServices.h" - -using namespace mozilla::dom; - -#define FAKESYNTHSERVICE_CID \ - { \ - 0xe7d52d9e, 0xc148, 0x47d8, { \ - 0xab, 0x2a, 0x95, 0xd7, 0xf4, 0x0e, 0xa5, 0x3d \ - } \ - } - -#define FAKESYNTHSERVICE_CONTRACTID "@mozilla.org/fakesynth;1" - -// Defines nsFakeSynthServicesConstructor -NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR( - nsFakeSynthServices, nsFakeSynthServices::GetInstanceForService) - -// Defines kFAKESYNTHSERVICE_CID -NS_DEFINE_NAMED_CID(FAKESYNTHSERVICE_CID); - -static const mozilla::Module::CIDEntry kCIDs[] = { - {&kFAKESYNTHSERVICE_CID, true, nullptr, nsFakeSynthServicesConstructor}, - {nullptr}}; - -static const mozilla::Module::ContractIDEntry kContracts[] = { - {FAKESYNTHSERVICE_CONTRACTID, &kFAKESYNTHSERVICE_CID}, {nullptr}}; - -static const mozilla::Module::CategoryEntry kCategories[] = { - {"speech-synth-started", "Fake Speech Synth", FAKESYNTHSERVICE_CONTRACTID}, - {nullptr}}; - -static void UnloadFakeSynthmodule() { nsFakeSynthServices::Shutdown(); } - -static const mozilla::Module kModule = { - mozilla::Module::kVersion, kCIDs, kContracts, kCategories, nullptr, nullptr, - UnloadFakeSynthmodule}; - -NSMODULE_DEFN(fakesynth) = &kModule; diff --git a/dom/media/webspeech/synth/test/components.conf b/dom/media/webspeech/synth/test/components.conf new file mode 100644 index 0000000000000..f37e4eafae77d --- /dev/null +++ b/dom/media/webspeech/synth/test/components.conf @@ -0,0 +1,17 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +Classes = [ + { + 'cid': '{e7d52d9e-c148-47d8-ab2a-95d7f40ea53d}', + 'contract_ids': ['@mozilla.org/fakesynth;1'], + 'singleton': True, + 'type': 'mozilla::dom::nsFakeSynthServices', + 'headers': ['/dom/media/webspeech/synth/test/nsFakeSynthServices.h'], + 'constructor': 'mozilla::dom::nsFakeSynthServices::GetInstanceForService', + 'categories': {'speech-synth-started': 'Fake Speech Synth'}, + }, +] diff --git a/dom/media/webspeech/synth/test/nsFakeSynthServices.cpp b/dom/media/webspeech/synth/test/nsFakeSynthServices.cpp index 2c7db5ec4ee0f..e1d6a2bb4028b 100644 --- a/dom/media/webspeech/synth/test/nsFakeSynthServices.cpp +++ b/dom/media/webspeech/synth/test/nsFakeSynthServices.cpp @@ -10,6 +10,7 @@ #include "SharedBuffer.h" #include "nsISimpleEnumerator.h" +#include "mozilla/ClearOnShutdown.h" #include "mozilla/dom/nsSynthVoiceRegistry.h" #include "mozilla/dom/nsSpeechTask.h" @@ -273,6 +274,7 @@ nsFakeSynthServices* nsFakeSynthServices::GetInstance() { if (!sSingleton) { sSingleton = new nsFakeSynthServices(); + ClearOnShutdown(&sSingleton); } return sSingleton; @@ -284,13 +286,5 @@ nsFakeSynthServices::GetInstanceForService() { return picoService.forget(); } -void nsFakeSynthServices::Shutdown() { - if (!sSingleton) { - return; - } - - sSingleton = nullptr; -} - } // namespace dom } // namespace mozilla diff --git a/dom/media/webspeech/synth/test/nsFakeSynthServices.h b/dom/media/webspeech/synth/test/nsFakeSynthServices.h index 9d059bc899f7e..872ad0bb9fdbf 100644 --- a/dom/media/webspeech/synth/test/nsFakeSynthServices.h +++ b/dom/media/webspeech/synth/test/nsFakeSynthServices.h @@ -29,8 +29,6 @@ class nsFakeSynthServices : public nsIObserver { static already_AddRefed GetInstanceForService(); - static void Shutdown(); - private: virtual ~nsFakeSynthServices() = default; diff --git a/dom/plugins/base/components.conf b/dom/plugins/base/components.conf new file mode 100644 index 0000000000000..4b90c78f44169 --- /dev/null +++ b/dom/plugins/base/components.conf @@ -0,0 +1,16 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +Classes = [ + { + 'cid': '{23e8fd98-a625-4b08-be1a-f7cc18a5b106}', + 'contract_ids': ['@mozilla.org/plugin/host;1'], + 'singleton': True, + 'type': 'nsPluginHost', + 'headers': ['nsPluginHost.h'], + 'constructor': 'nsPluginHost::GetInst', + }, +] diff --git a/dom/plugins/base/moz.build b/dom/plugins/base/moz.build index 7f6161d80a510..ea67636794f7d 100644 --- a/dom/plugins/base/moz.build +++ b/dom/plugins/base/moz.build @@ -38,7 +38,6 @@ UNIFIED_SOURCES += [ 'nsNPAPIPluginInstance.cpp', 'nsNPAPIPluginStreamListener.cpp', 'nsPluginInstanceOwner.cpp', - 'nsPluginModule.cpp', 'nsPluginStreamListenerPeer.cpp', 'nsPluginTags.cpp', ] @@ -67,6 +66,10 @@ else: 'nsPluginsDirUnix.cpp', ] +XPCOM_MANIFESTS += [ + 'components.conf', +] + LOCAL_INCLUDES += [ '/dom/base', '/dom/plugins/ipc', diff --git a/dom/plugins/base/nsPluginModule.cpp b/dom/plugins/base/nsPluginModule.cpp deleted file mode 100644 index 4648a7567aaeb..0000000000000 --- a/dom/plugins/base/nsPluginModule.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "mozilla/ModuleUtils.h" -#include "nsPluginHost.h" -#include "nsPluginsCID.h" - -NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsPluginHost, nsPluginHost::GetInst) -NS_DEFINE_NAMED_CID(NS_PLUGIN_HOST_CID); - -static const mozilla::Module::CIDEntry kPluginCIDs[] = { - {&kNS_PLUGIN_HOST_CID, false, nullptr, nsPluginHostConstructor}, {nullptr}}; - -static const mozilla::Module::ContractIDEntry kPluginContracts[] = { - {MOZ_PLUGIN_HOST_CONTRACTID, &kNS_PLUGIN_HOST_CID}, {nullptr}}; - -static const mozilla::Module kPluginModule = {mozilla::Module::kVersion, - kPluginCIDs, kPluginContracts}; - -NSMODULE_DEFN(nsPluginModule) = &kPluginModule; diff --git a/dom/presentation/provider/PresentationDeviceProviderModule.cpp b/dom/presentation/provider/PresentationDeviceProviderModule.cpp deleted file mode 100644 index 4afa3c08d3ecc..0000000000000 --- a/dom/presentation/provider/PresentationDeviceProviderModule.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "MulticastDNSDeviceProvider.h" -#include "mozilla/ModuleUtils.h" - -#define MULTICAST_DNS_PROVIDER_CID \ - { \ - 0x814f947a, 0x52f7, 0x41c9, { \ - 0x94, 0xa1, 0x36, 0x84, 0x79, 0x72, 0x84, 0xac \ - } \ - } - -#define MULTICAST_DNS_PROVIDER_CONTRACT_ID \ - "@mozilla.org/presentation-device/multicastdns-provider;1" - -using mozilla::dom::presentation::MulticastDNSDeviceProvider; - -NS_GENERIC_FACTORY_CONSTRUCTOR(MulticastDNSDeviceProvider) -NS_DEFINE_NAMED_CID(MULTICAST_DNS_PROVIDER_CID); - -static const mozilla::Module::CIDEntry kPresentationDeviceProviderCIDs[] = { - {&kMULTICAST_DNS_PROVIDER_CID, false, nullptr, - MulticastDNSDeviceProviderConstructor}, - {nullptr}}; - -static const mozilla::Module::ContractIDEntry - kPresentationDeviceProviderContracts[] = { - {MULTICAST_DNS_PROVIDER_CONTRACT_ID, &kMULTICAST_DNS_PROVIDER_CID}, - {nullptr}}; - -static const mozilla::Module::CategoryEntry - kPresentationDeviceProviderCategories[] = { -#if defined(MOZ_WIDGET_COCOA) || defined(MOZ_WIDGET_ANDROID) - {PRESENTATION_DEVICE_PROVIDER_CATEGORY, "MulticastDNSDeviceProvider", - MULTICAST_DNS_PROVIDER_CONTRACT_ID}, -#endif - {nullptr}}; - -static const mozilla::Module kPresentationDeviceProviderModule = { - mozilla::Module::kVersion, kPresentationDeviceProviderCIDs, - kPresentationDeviceProviderContracts, - kPresentationDeviceProviderCategories}; - -NSMODULE_DEFN(PresentationDeviceProviderModule) = - &kPresentationDeviceProviderModule; diff --git a/dom/presentation/provider/components.conf b/dom/presentation/provider/components.conf index 5faef5f26dda8..70e86eb6b84f6 100644 --- a/dom/presentation/provider/components.conf +++ b/dom/presentation/provider/components.conf @@ -4,6 +4,11 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. +categories = {} + +if buildconfig.substs['MOZ_WIDGET_TOOLKIT'] in ('cocoa', 'android'): + categories["presentation-device-provider"] = "MulticastDNSDeviceProvider" + Classes = [ { 'cid': '{f4079b8b-ede5-4b90-a112-5b415a931deb}', @@ -11,6 +16,13 @@ Classes = [ 'jsm': 'resource://gre/modules/PresentationControlService.jsm', 'constructor': 'PresentationControlService', }, + { + 'cid': '{814f947a-52f7-41c9-94a1-3684797284ac}', + 'contract_ids': ['@mozilla.org/presentation-device/multicastdns-provider;1'], + 'type': 'mozilla::dom::presentation::MulticastDNSDeviceProvider', + 'headers': ['/dom/presentation/provider/MulticastDNSDeviceProvider.h'], + 'categories': categories, + }, ] if buildconfig.substs['MOZ_WIDGET_TOOLKIT'] == 'android': diff --git a/dom/presentation/provider/moz.build b/dom/presentation/provider/moz.build index cc4427dd6d038..139f305893302 100644 --- a/dom/presentation/provider/moz.build +++ b/dom/presentation/provider/moz.build @@ -11,7 +11,10 @@ EXTRA_JS_MODULES += [ UNIFIED_SOURCES += [ 'DeviceProviderHelpers.cpp', 'MulticastDNSDeviceProvider.cpp', - 'PresentationDeviceProviderModule.cpp', +] + +XPCOM_MANIFESTS += [ + 'components.conf', ] XPCOM_MANIFESTS += [ diff --git a/extensions/cookie/components.conf b/extensions/cookie/components.conf new file mode 100644 index 0000000000000..1e0075b1e52ec --- /dev/null +++ b/extensions/cookie/components.conf @@ -0,0 +1,22 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +Headers = [ + '/extensions/cookie/nsCookieModule.h', +] + +UnloadFunc = 'mozilla::CookieModuleDtor' + +Classes = [ + { + 'cid': '{4f6b5e00-0c36-11d5-a535-0010a401eb10}', + 'contract_ids': ['@mozilla.org/permissionmanager;1'], + 'singleton': True, + 'type': 'nsIPermissionManager', + 'constructor': 'nsPermissionManager::GetXPCOMSingleton', + 'headers': ['/extensions/cookie/nsPermissionManager.h'], + }, +] diff --git a/extensions/cookie/moz.build b/extensions/cookie/moz.build index 51f906e007772..079150c156fd3 100644 --- a/extensions/cookie/moz.build +++ b/extensions/cookie/moz.build @@ -17,6 +17,10 @@ UNIFIED_SOURCES += [ 'nsPermissionManager.cpp', ] +XPCOM_MANIFESTS += [ + 'components.conf', +] + LOCAL_INCLUDES += [ '/caps', ] diff --git a/extensions/cookie/nsCookieModule.cpp b/extensions/cookie/nsCookieModule.cpp index 310b2e5b8eff7..63c2db62bdeb2 100644 --- a/extensions/cookie/nsCookieModule.cpp +++ b/extensions/cookie/nsCookieModule.cpp @@ -3,35 +3,10 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "mozilla/ModuleUtils.h" -#include "nsIServiceManager.h" -#include "nsPermissionManager.h" -#include "nsICategoryManager.h" #include "nsCookiePermission.h" -#include "nsString.h" -// Define the constructor function for the objects -NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIPermissionManager, - nsPermissionManager::GetXPCOMSingleton) +namespace mozilla { -NS_DEFINE_NAMED_CID(NS_PERMISSIONMANAGER_CID); +void CookieModuleDtor() { nsCookiePermission::Shutdown(); } -static const mozilla::Module::CIDEntry kCookieCIDs[] = { - {&kNS_PERMISSIONMANAGER_CID, false, nullptr, - nsIPermissionManagerConstructor}, - {nullptr}}; - -static const mozilla::Module::ContractIDEntry kCookieContracts[] = { - {NS_PERMISSIONMANAGER_CONTRACTID, &kNS_PERMISSIONMANAGER_CID}, {nullptr}}; - -static void CookieModuleDtor() { nsCookiePermission::Shutdown(); } - -static const mozilla::Module kCookieModule = {mozilla::Module::kVersion, - kCookieCIDs, - kCookieContracts, - nullptr, - nullptr, - nullptr, - CookieModuleDtor}; - -NSMODULE_DEFN(nsCookieModule) = &kCookieModule; +} // namespace mozilla diff --git a/extensions/cookie/nsCookieModule.h b/extensions/cookie/nsCookieModule.h new file mode 100644 index 0000000000000..a654a1c857076 --- /dev/null +++ b/extensions/cookie/nsCookieModule.h @@ -0,0 +1,19 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef nsCookieModule_h +#define nsCookieModule_h + +#include "nscore.h" + +namespace mozilla { + +void CookieModuleDtor(); + +} // namespace mozilla + +#endif + diff --git a/extensions/permissions/components.conf b/extensions/permissions/components.conf new file mode 100644 index 0000000000000..ed04a893b32bf --- /dev/null +++ b/extensions/permissions/components.conf @@ -0,0 +1,16 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +Classes = [ + { + 'cid': '{4ca6b67b-5cc7-4e71-a98a-97af1c134862}', + 'contract_ids': ['@mozilla.org/permissions/contentblocker;1'], + 'type': 'nsContentBlocker', + 'headers': ['/extensions/permissions/nsContentBlocker.h'], + 'init_method': 'Init', + 'categories': {'content-policy': '@mozilla.org/permissions/contentblocker;1'}, + }, +] diff --git a/extensions/permissions/moz.build b/extensions/permissions/moz.build index 14bc17b5c748b..6860583da840f 100644 --- a/extensions/permissions/moz.build +++ b/extensions/permissions/moz.build @@ -6,7 +6,10 @@ UNIFIED_SOURCES += [ 'nsContentBlocker.cpp', - 'nsModuleFactory.cpp', +] + +XPCOM_MANIFESTS += [ + 'components.conf', ] FINAL_LIBRARY = 'xul' diff --git a/extensions/permissions/nsModuleFactory.cpp b/extensions/permissions/nsModuleFactory.cpp deleted file mode 100644 index 3ed08e918a4df..0000000000000 --- a/extensions/permissions/nsModuleFactory.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "mozilla/ModuleUtils.h" -#include "nsIServiceManager.h" -#include "nsContentBlocker.h" -#include "nsString.h" - -// Define the constructor function for the objects -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsContentBlocker, Init) - -NS_DEFINE_NAMED_CID(NS_CONTENTBLOCKER_CID); - -static const mozilla::Module::CIDEntry kPermissionsCIDs[] = { - {&kNS_CONTENTBLOCKER_CID, false, nullptr, nsContentBlockerConstructor}, - {nullptr}}; - -static const mozilla::Module::ContractIDEntry kPermissionsContracts[] = { - {NS_CONTENTBLOCKER_CONTRACTID, &kNS_CONTENTBLOCKER_CID}, {nullptr}}; - -static const mozilla::Module::CategoryEntry kPermissionsCategories[] = { - {"content-policy", NS_CONTENTBLOCKER_CONTRACTID, - NS_CONTENTBLOCKER_CONTRACTID}, - {nullptr}}; - -static const mozilla::Module kPermissionsModule = { - mozilla::Module::kVersion, kPermissionsCIDs, kPermissionsContracts, - kPermissionsCategories}; - -NSMODULE_DEFN(nsPermissionsModule) = &kPermissionsModule; diff --git a/extensions/pref/autoconfig/src/components.conf b/extensions/pref/autoconfig/src/components.conf new file mode 100644 index 0000000000000..789a44b2e39bf --- /dev/null +++ b/extensions/pref/autoconfig/src/components.conf @@ -0,0 +1,16 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +Classes = [ + { + 'cid': '{ba5bc4c6-1dd1-11b2-bb89-b844c6ec0339}', + 'contract_ids': ['@mozilla.org/readconfig;1'], + 'type': 'nsReadConfig', + 'headers': ['/extensions/pref/autoconfig/src/nsReadConfig.h'], + 'init_method': 'Init', + 'categories': {'pref-config-startup': 'ReadConfig Module'}, + }, +] diff --git a/extensions/pref/autoconfig/src/moz.build b/extensions/pref/autoconfig/src/moz.build index 3417269f07934..cb697f0c6615e 100644 --- a/extensions/pref/autoconfig/src/moz.build +++ b/extensions/pref/autoconfig/src/moz.build @@ -6,11 +6,14 @@ UNIFIED_SOURCES += [ 'nsAutoConfig.cpp', - 'nsConfigFactory.cpp', 'nsJSConfigTriggers.cpp', 'nsReadConfig.cpp', ] +XPCOM_MANIFESTS += [ + 'components.conf', +] + FINAL_LIBRARY = 'xul' FINAL_TARGET_FILES.defaults.autoconfig += [ diff --git a/extensions/pref/autoconfig/src/nsConfigFactory.cpp b/extensions/pref/autoconfig/src/nsConfigFactory.cpp deleted file mode 100644 index 3ad82ecbc7ac1..0000000000000 --- a/extensions/pref/autoconfig/src/nsConfigFactory.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "mozilla/ModuleUtils.h" -#include "nsReadConfig.h" -#include "nsIAppStartupNotifier.h" - -#define NS_READCONFIG_CID \ - { \ - 0xba5bc4c6, 0x1dd1, 0x11b2, { \ - 0xbb, 0x89, 0xb8, 0x44, 0xc6, 0xec, 0x03, 0x39 \ - } \ - } - -#define NS_READCONFIG_CONTRACTID "@mozilla.org/readconfig;1" - -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsReadConfig, Init) - -NS_DEFINE_NAMED_CID(NS_READCONFIG_CID); - -static const mozilla::Module::CIDEntry kAutoConfigCIDs[] = { - {&kNS_READCONFIG_CID, false, nullptr, nsReadConfigConstructor}, {nullptr}}; - -static const mozilla::Module::ContractIDEntry kAutoConfigContracts[] = { - {NS_READCONFIG_CONTRACTID, &kNS_READCONFIG_CID}, {nullptr}}; - -static const mozilla::Module::CategoryEntry kAutoConfigCategories[] = { - {"pref-config-startup", "ReadConfig Module", NS_READCONFIG_CONTRACTID}, - {nullptr}}; - -static const mozilla::Module kAutoConfigModule = { - mozilla::Module::kVersion, kAutoConfigCIDs, kAutoConfigContracts, - kAutoConfigCategories}; - -NSMODULE_DEFN(nsAutoConfigModule) = &kAutoConfigModule; diff --git a/extensions/spellcheck/hunspell/glue/mozHunspell.cpp b/extensions/spellcheck/hunspell/glue/mozHunspell.cpp index e2d985c247ab1..9f60f2269d78d 100644 --- a/extensions/spellcheck/hunspell/glue/mozHunspell.cpp +++ b/extensions/spellcheck/hunspell/glue/mozHunspell.cpp @@ -72,6 +72,7 @@ #include "nsIPrefBranch.h" #include "nsNetUtil.h" #include "mozilla/dom/ContentParent.h" +#include "mozilla/Components.h" using mozilla::dom::ContentParent; using namespace mozilla; @@ -90,6 +91,14 @@ NS_INTERFACE_MAP_END NS_IMPL_CYCLE_COLLECTION(mozHunspell, mPersonalDictionary) +NS_IMPL_COMPONENT_FACTORY(mozHunspell) { + auto hunspell = MakeRefPtr(); + if (NS_SUCCEEDED(hunspell->Init())) { + return hunspell.forget().downcast(); + } + return nullptr; +} + template <> mozilla::CountingAllocatorBase::AmountType mozilla::CountingAllocatorBase::sAmount(0); diff --git a/extensions/spellcheck/src/components.conf b/extensions/spellcheck/src/components.conf new file mode 100644 index 0000000000000..7fc73c1a1714d --- /dev/null +++ b/extensions/spellcheck/src/components.conf @@ -0,0 +1,20 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +Classes = [ + { + 'cid': '{56c778e4-1bee-45f3-a689-886692a97fe7}', + 'contract_ids': ['@mozilla.org/spellchecker/engine;1'], + 'type': 'mozHunspell', + }, + { + 'cid': '{7ef52eaf-b7e1-462b-87e2-5d1dbaca9048}', + 'contract_ids': ['@mozilla.org/spellchecker/personaldictionary;1'], + 'type': 'mozPersonalDictionary', + 'headers': ['/extensions/spellcheck/src/mozPersonalDictionary.h'], + 'init_method': 'Init', + }, +] diff --git a/extensions/spellcheck/src/moz.build b/extensions/spellcheck/src/moz.build index 3eabf96c4a5f8..1fa03d1c566b6 100644 --- a/extensions/spellcheck/src/moz.build +++ b/extensions/spellcheck/src/moz.build @@ -11,7 +11,10 @@ UNIFIED_SOURCES += [ 'mozInlineSpellWordUtil.cpp', 'mozPersonalDictionary.cpp', 'mozSpellChecker.cpp', - 'mozSpellCheckerFactory.cpp', +] + +XPCOM_MANIFESTS += [ + 'components.conf', ] FINAL_LIBRARY = 'xul' diff --git a/extensions/spellcheck/src/mozSpellCheckerFactory.cpp b/extensions/spellcheck/src/mozSpellCheckerFactory.cpp deleted file mode 100644 index 4b7dff4266c6e..0000000000000 --- a/extensions/spellcheck/src/mozSpellCheckerFactory.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "mozilla/ModuleUtils.h" -#include "mozHunspell.h" -#include "mozPersonalDictionary.h" -#include "nsIFile.h" - -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(mozHunspell, Init) -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(mozPersonalDictionary, Init) - -NS_DEFINE_NAMED_CID(MOZ_HUNSPELL_CID); -NS_DEFINE_NAMED_CID(MOZ_PERSONALDICTIONARY_CID); - -static const mozilla::Module::CIDEntry kSpellcheckCIDs[] = { - {&kMOZ_HUNSPELL_CID, false, nullptr, mozHunspellConstructor}, - {&kMOZ_PERSONALDICTIONARY_CID, false, nullptr, - mozPersonalDictionaryConstructor}, - {nullptr}}; - -static const mozilla::Module::ContractIDEntry kSpellcheckContracts[] = { - {MOZ_HUNSPELL_CONTRACTID, &kMOZ_HUNSPELL_CID}, - {MOZ_PERSONALDICTIONARY_CONTRACTID, &kMOZ_PERSONALDICTIONARY_CID}, - {nullptr}}; - -const mozilla::Module kSpellcheckModule = { - mozilla::Module::kVersion, kSpellcheckCIDs, kSpellcheckContracts, nullptr}; - -NSMODULE_DEFN(mozSpellCheckerModule) = &kSpellcheckModule; diff --git a/gfx/2d/BufferUnrotate.cpp b/gfx/2d/BufferUnrotate.cpp index 4edf131b0c032..7b6768fdbde66 100644 --- a/gfx/2d/BufferUnrotate.cpp +++ b/gfx/2d/BufferUnrotate.cpp @@ -4,6 +4,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "BufferUnrotate.h" + #include // min & max #include #include diff --git a/gfx/2d/DrawTargetCairo.cpp b/gfx/2d/DrawTargetCairo.cpp index b5e5d0afb897b..e7a88a359ee3d 100644 --- a/gfx/2d/DrawTargetCairo.cpp +++ b/gfx/2d/DrawTargetCairo.cpp @@ -192,14 +192,16 @@ static bool PatternIsCompatible(const Pattern& aPattern) { static cairo_user_data_key_t surfaceDataKey; -void ReleaseData(void* aData) { +static void ReleaseData(void* aData) { DataSourceSurface* data = static_cast(aData); data->Unmap(); data->Release(); } -cairo_surface_t* CopyToImageSurface(unsigned char* aData, const IntRect& aRect, - int32_t aStride, SurfaceFormat aFormat) { +static cairo_surface_t* CopyToImageSurface(unsigned char* aData, + const IntRect& aRect, + int32_t aStride, + SurfaceFormat aFormat) { MOZ_ASSERT(aData); auto aRectWidth = aRect.Width(); @@ -236,7 +238,7 @@ cairo_surface_t* CopyToImageSurface(unsigned char* aData, const IntRect& aRect, * CAIRO_SURFACE_TYPE_IMAGE then returns that surface. Does * not add a reference. */ -cairo_surface_t* GetAsImageSurface(cairo_surface_t* aSurface) { +static cairo_surface_t* GetAsImageSurface(cairo_surface_t* aSurface) { if (cairo_surface_get_type(aSurface) == CAIRO_SURFACE_TYPE_IMAGE) { return aSurface; #ifdef CAIRO_HAS_WIN32_SURFACE @@ -248,9 +250,9 @@ cairo_surface_t* GetAsImageSurface(cairo_surface_t* aSurface) { return nullptr; } -cairo_surface_t* CreateSubImageForData(unsigned char* aData, - const IntRect& aRect, int aStride, - SurfaceFormat aFormat) { +static cairo_surface_t* CreateSubImageForData(unsigned char* aData, + const IntRect& aRect, int aStride, + SurfaceFormat aFormat) { if (!aData) { gfxWarning() << "DrawTargetCairo.CreateSubImageForData null aData"; return nullptr; @@ -269,9 +271,9 @@ cairo_surface_t* CreateSubImageForData(unsigned char* aData, * Returns a referenced cairo_surface_t representing the * sub-image specified by aSubImage. */ -cairo_surface_t* ExtractSubImage(cairo_surface_t* aSurface, - const IntRect& aSubImage, - SurfaceFormat aFormat) { +static cairo_surface_t* ExtractSubImage(cairo_surface_t* aSurface, + const IntRect& aSubImage, + SurfaceFormat aFormat) { // No need to worry about retaining a reference to the original // surface since the only caller of this function guarantees // that aSurface will stay alive as long as the result @@ -305,7 +307,7 @@ cairo_surface_t* ExtractSubImage(cairo_surface_t* aSurface, * In either case, the caller must call cairo_surface_destroy on the * result when it is done with it. */ -cairo_surface_t* GetCairoSurfaceForSourceSurface( +static cairo_surface_t* GetCairoSurfaceForSourceSurface( SourceSurface* aSurface, bool aExistingOnly = false, const IntRect& aSubImage = IntRect()) { if (!aSurface) { diff --git a/gfx/2d/DrawTargetRecording.cpp b/gfx/2d/DrawTargetRecording.cpp index f07df2a182ece..e33474ab523bf 100644 --- a/gfx/2d/DrawTargetRecording.cpp +++ b/gfx/2d/DrawTargetRecording.cpp @@ -23,7 +23,7 @@ struct RecordingSourceSurfaceUserData { RefPtr recorder; }; -void RecordingSourceSurfaceUserDataFunc(void *aUserData) { +static void RecordingSourceSurfaceUserDataFunc(void *aUserData) { RecordingSourceSurfaceUserData *userData = static_cast(aUserData); @@ -269,7 +269,7 @@ struct RecordingFontUserData { RefPtr recorder; }; -void RecordingFontUserDataDestroyFunc(void *aUserData) { +static void RecordingFontUserDataDestroyFunc(void *aUserData) { RecordingFontUserData *userData = static_cast(aUserData); diff --git a/gfx/2d/DrawTargetWrapAndRecord.cpp b/gfx/2d/DrawTargetWrapAndRecord.cpp index 6807b253d67e1..c44f566e683ed 100644 --- a/gfx/2d/DrawTargetWrapAndRecord.cpp +++ b/gfx/2d/DrawTargetWrapAndRecord.cpp @@ -23,7 +23,7 @@ struct WrapAndRecordSourceSurfaceUserData { RefPtr recorder; }; -void WrapAndRecordSourceSurfaceUserDataFunc(void *aUserData) { +static void WrapAndRecordSourceSurfaceUserDataFunc(void *aUserData) { WrapAndRecordSourceSurfaceUserData *userData = static_cast(aUserData); @@ -355,7 +355,7 @@ struct WrapAndRecordFontUserData { RefPtr recorder; }; -void WrapAndRecordFontUserDataDestroyFunc(void *aUserData) { +static void WrapAndRecordFontUserDataDestroyFunc(void *aUserData) { WrapAndRecordFontUserData *userData = static_cast(aUserData); diff --git a/gfx/2d/FilterNodeSoftware.cpp b/gfx/2d/FilterNodeSoftware.cpp index fc902523656e5..dd5e4a95325af 100644 --- a/gfx/2d/FilterNodeSoftware.cpp +++ b/gfx/2d/FilterNodeSoftware.cpp @@ -180,7 +180,8 @@ static int32_t NS_lround(double x) { return x >= 0.0 ? int32_t(x + 0.5) : int32_t(x - 0.5); } -already_AddRefed CloneAligned(DataSourceSurface *aSource) { +static already_AddRefed CloneAligned( + DataSourceSurface *aSource) { return CreateDataSourceSurfaceByCloning(aSource); } @@ -1813,7 +1814,7 @@ static void TransferComponents( } } -bool IsAllZero(uint8_t aLookupTable[256]) { +static bool IsAllZero(const uint8_t aLookupTable[256]) { for (int32_t i = 0; i < 256; i++) { if (aLookupTable[i] != 0) { return false; diff --git a/gfx/2d/MacIOSurface.cpp b/gfx/2d/MacIOSurface.cpp index 569be1d93ad2e..b9bd5dcc05d99 100644 --- a/gfx/2d/MacIOSurface.cpp +++ b/gfx/2d/MacIOSurface.cpp @@ -439,7 +439,7 @@ using mozilla::gfx::IntSize; using mozilla::gfx::SourceSurface; using mozilla::gfx::SurfaceFormat; -void MacIOSurfaceBufferDeallocator(void* aClosure) { +static void MacIOSurfaceBufferDeallocator(void* aClosure) { MOZ_ASSERT(aClosure); delete[] static_cast(aClosure); diff --git a/gfx/2d/QuartzSupport.mm b/gfx/2d/QuartzSupport.mm index 13323f04f214f..38a08278c523a 100644 --- a/gfx/2d/QuartzSupport.mm +++ b/gfx/2d/QuartzSupport.mm @@ -35,7 +35,7 @@ CGColorSpaceRef CreateSystemColorSpace() { nsCARenderer::~nsCARenderer() { Destroy(); } -void cgdata_release_callback(void* aCGData, const void* data, size_t size) { +static void cgdata_release_callback(void* aCGData, const void* data, size_t size) { if (aCGData) { free(aCGData); } diff --git a/gfx/2d/ScaledFontMac.cpp b/gfx/2d/ScaledFontMac.cpp index 3b584cd40ee48..47e58e6d9f6d2 100644 --- a/gfx/2d/ScaledFontMac.cpp +++ b/gfx/2d/ScaledFontMac.cpp @@ -188,8 +188,8 @@ already_AddRefed ScaledFontMac::GetPathForGlyphs( return ScaledFontBase::GetPathForGlyphs(aBuffer, aTarget); } -uint32_t CalcTableChecksum(const uint32_t* tableStart, uint32_t length, - bool skipChecksumAdjust = false) { +static uint32_t CalcTableChecksum(const uint32_t* tableStart, uint32_t length, + bool skipChecksumAdjust = false) { uint32_t sum = 0L; const uint32_t* table = tableStart; const uint32_t* end = table + length / sizeof(uint32_t); @@ -221,7 +221,7 @@ struct TableRecord { CFDataRef data; }; -int maxPow2LessThan(int a) { +static int maxPow2LessThan(int a) { int x = 1; int shift = 0; while ((x << (shift + 1)) < a) { diff --git a/gfx/2d/unittest/TestCairo.cpp b/gfx/2d/unittest/TestCairo.cpp index b1046f755191a..7cd5a384b9c25 100644 --- a/gfx/2d/unittest/TestCairo.cpp +++ b/gfx/2d/unittest/TestCairo.cpp @@ -9,7 +9,7 @@ namespace mozilla { namespace layers { -void TryCircle(double centerX, double centerY, double radius) { +static void TryCircle(double centerX, double centerY, double radius) { printf("TestCairo:TryArcs centerY %f, radius %f\n", centerY, radius); cairo_surface_t *surf = diff --git a/gfx/layers/Layers.cpp b/gfx/layers/Layers.cpp index bbed7ae771bad..6bcd51af0f6e0 100644 --- a/gfx/layers/Layers.cpp +++ b/gfx/layers/Layers.cpp @@ -55,8 +55,6 @@ uint8_t gLayerManagerLayerBuilder; namespace mozilla { namespace layers { -FILE* FILEOrDefault(FILE* aFile) { return aFile ? aFile : stderr; } - typedef ScrollableLayerGuid::ViewID ViewID; using namespace mozilla::gfx; diff --git a/gfx/layers/basic/BasicLayersImpl.cpp b/gfx/layers/basic/BasicLayersImpl.cpp index 85bdce22932db..b7cdd45482e45 100644 --- a/gfx/layers/basic/BasicLayersImpl.cpp +++ b/gfx/layers/basic/BasicLayersImpl.cpp @@ -214,18 +214,5 @@ gfx::CompositionOp GetEffectiveOperator(Layer* aLayer) { return ToData(aLayer)->GetOperator(); } -ShadowableLayer* ToShadowable(Layer* aLayer) { - return aLayer->AsShadowableLayer(); -} - -bool ShouldShadow(Layer* aLayer) { - if (!ToShadowable(aLayer)) { - MOZ_ASSERT(aLayer->GetType() == Layer::TYPE_READBACK, - "Only expect not to shadow ReadbackLayers"); - return false; - } - return true; -} - } // namespace layers } // namespace mozilla diff --git a/gfx/layers/client/ClientPaintedLayer.cpp b/gfx/layers/client/ClientPaintedLayer.cpp index 43bd43d6168ce..615f122daf8bb 100644 --- a/gfx/layers/client/ClientPaintedLayer.cpp +++ b/gfx/layers/client/ClientPaintedLayer.cpp @@ -147,10 +147,20 @@ void ClientPaintedLayer::RenderLayerWithReadback(ReadbackProcessor* aReadback) { MOZ_ASSERT(ctx); // already checked the target above if (!gfxEnv::SkipRasterization()) { - ClientManager()->GetPaintedLayerCallback()( - this, ctx, iter.mDrawRegion, iter.mDrawRegion, state.mClip, - state.mRegionToInvalidate, - ClientManager()->GetPaintedLayerCallbackData()); + if (!target->IsCaptureDT()) { + target->ClearRect(Rect()); + if (target->IsValid()) { + ClientManager()->GetPaintedLayerCallback()( + this, ctx, iter.mDrawRegion, iter.mDrawRegion, state.mClip, + state.mRegionToInvalidate, + ClientManager()->GetPaintedLayerCallbackData()); + } + } else { + ClientManager()->GetPaintedLayerCallback()( + this, ctx, iter.mDrawRegion, iter.mDrawRegion, state.mClip, + state.mRegionToInvalidate, + ClientManager()->GetPaintedLayerCallbackData()); + } } ctx = nullptr; diff --git a/gfx/layers/client/TiledContentClient.cpp b/gfx/layers/client/TiledContentClient.cpp index ad2f56125201c..cee2fc69e46e7 100644 --- a/gfx/layers/client/TiledContentClient.cpp +++ b/gfx/layers/client/TiledContentClient.cpp @@ -24,7 +24,6 @@ #include "mozilla/layers/ShadowLayers.h" // for ShadowLayerForwarder #include "mozilla/layers/PaintThread.h" // for PaintThread #include "TextureClientPool.h" -#include "nsDebug.h" // for NS_ASSERTION #include "nsISupportsImpl.h" // for gfxContext::AddRef, etc #include "nsExpirationTracker.h" // for nsExpirationTracker #include "nsMathUtils.h" // for NS_lroundf @@ -32,12 +31,6 @@ #include "UnitTransforms.h" // for TransformTo #include "mozilla/UniquePtr.h" -// This is the minimum area that we deem reasonable to copy from the front -// buffer to the back buffer on tile updates. If the valid region is smaller -// than this, we just redraw it and save on the copy (and requisite -// surface-locking involved). -#define MINIMUM_TILE_COPY_AREA (1.f / 16.f) - #ifdef GFX_TILEDLAYER_DEBUG_OVERLAY # include "cairo.h" # include diff --git a/gfx/layers/ipc/CompositorThread.cpp b/gfx/layers/ipc/CompositorThread.cpp index a76667553d0cb..9b276b74193c6 100644 --- a/gfx/layers/ipc/CompositorThread.cpp +++ b/gfx/layers/ipc/CompositorThread.cpp @@ -23,10 +23,6 @@ namespace layers { static StaticRefPtr sCompositorThreadHolder; static bool sFinishedCompositorShutDown = false; -CompositorThreadHolder* GetCompositorThreadHolder() { - return sCompositorThreadHolder; -} - base::Thread* CompositorThread() { return sCompositorThreadHolder ? sCompositorThreadHolder->GetCompositorThread() diff --git a/gfx/layers/ipc/ImageBridgeParent.cpp b/gfx/layers/ipc/ImageBridgeParent.cpp index 264ff38466a96..2c3515d20b294 100644 --- a/gfx/layers/ipc/ImageBridgeParent.cpp +++ b/gfx/layers/ipc/ImageBridgeParent.cpp @@ -48,9 +48,6 @@ StaticAutoPtr sImageBridgesLock; static StaticRefPtr sImageBridgeParentSingleton; -// defined in CompositorBridgeParent.cpp -CompositorThreadHolder* GetCompositorThreadHolder(); - /* static */ void ImageBridgeParent::Setup() { MOZ_ASSERT(NS_IsMainThread()); if (!sImageBridgesLock) { diff --git a/gfx/src/components.conf b/gfx/src/components.conf new file mode 100644 index 0000000000000..d1c5d69351b1c --- /dev/null +++ b/gfx/src/components.conf @@ -0,0 +1,14 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +Classes = [ + { + 'cid': '{a6cf9115-15b3-11d2-932e-00805f8add32}', + 'contract_ids': ['@mozilla.org/gfx/fontenumerator;1'], + 'type': 'nsThebesFontEnumerator', + 'headers': ['/gfx/src/nsThebesFontEnumerator.h'], + }, +] diff --git a/gfx/src/moz.build b/gfx/src/moz.build index 8c0e6b9a089af..75aea035e3c38 100644 --- a/gfx/src/moz.build +++ b/gfx/src/moz.build @@ -68,7 +68,6 @@ UNIFIED_SOURCES += [ 'nsRect.cpp', 'nsRegion.cpp', 'nsThebesFontEnumerator.cpp', - 'nsThebesGfxFactory.cpp', 'nsTransform2D.cpp', 'TiledRegion.cpp', ] @@ -78,6 +77,10 @@ SOURCES += [ 'nsDeviceContext.cpp', ] +XPCOM_MANIFESTS += [ + 'components.conf', +] + include('/ipc/chromium/chromium-config.mozbuild') LOCAL_INCLUDES += [ diff --git a/gfx/src/nsThebesGfxFactory.cpp b/gfx/src/nsThebesGfxFactory.cpp deleted file mode 100644 index 301876541d7df..0000000000000 --- a/gfx/src/nsThebesGfxFactory.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "gfxPlatform.h" // for gfxPlatform -#include "mozilla/Assertions.h" // for MOZ_ASSERT_HELPER2 -#include "mozilla/Attributes.h" // for final -#include "mozilla/Module.h" // for Module, Module::CIDEntry, etc -#include "mozilla/ModuleUtils.h" -#include "mozilla/mozalloc.h" // for operator new -#include "nsCOMPtr.h" // for nsCOMPtr -#include "nsError.h" // for NS_ERROR_NO_AGGREGATION, etc -#include "nsGfxCIID.h" // for NS_FONT_ENUMERATOR_CID, etc -#include "nsID.h" // for NS_DEFINE_NAMED_CID, etc -#include "nsISupports.h" // for NS_DECL_ISUPPORTS, etc -#include "nsThebesFontEnumerator.h" // for nsThebesFontEnumerator - -NS_GENERIC_FACTORY_CONSTRUCTOR(nsThebesFontEnumerator) - -NS_DEFINE_NAMED_CID(NS_FONT_ENUMERATOR_CID); - -static const mozilla::Module::CIDEntry kThebesCIDs[] = { - {&kNS_FONT_ENUMERATOR_CID, false, nullptr, - nsThebesFontEnumeratorConstructor}, - {nullptr}}; - -static const mozilla::Module::ContractIDEntry kThebesContracts[] = { - {"@mozilla.org/gfx/fontenumerator;1", &kNS_FONT_ENUMERATOR_CID}, {nullptr}}; - -static const mozilla::Module kThebesModule = {mozilla::Module::kVersion, - kThebesCIDs, - kThebesContracts, - nullptr, - nullptr, - nullptr, - nullptr}; - -NSMODULE_DEFN(nsGfxModule) = &kThebesModule; diff --git a/gfx/tests/gtest/TestTreeTraversal.cpp b/gfx/tests/gtest/TestTreeTraversal.cpp index defd9e999bab9..652e5494ca0d0 100644 --- a/gfx/tests/gtest/TestTreeTraversal.cpp +++ b/gfx/tests/gtest/TestTreeTraversal.cpp @@ -1196,10 +1196,6 @@ struct AssignSearchNodeTypesWithLastLeafAsNeedle { } }; -bool FindNeedle(SearchTestNode* aNode) { - return aNode->GetType() == SearchNodeType::Needle; -} - struct AssignSearchNodeTypesAllHay { void operator()(SearchTestNode* aNode) { aNode->SetType(SearchNodeType::Hay); @@ -1249,8 +1245,6 @@ struct AllocateUnitRegionsToLeavesOnly { } }; -void ForEachNodeDoNothing(ForEachTestNode* aNode) {} - template static RefPtr DepthFirstSearchForwardRecursive(RefPtr aNode) { if (aNode->GetType() == SearchNodeType::Needle) { diff --git a/ipc/mscom/InterceptorLog.cpp b/ipc/mscom/InterceptorLog.cpp index cc606a9965083..85814c6941877 100644 --- a/ipc/mscom/InterceptorLog.cpp +++ b/ipc/mscom/InterceptorLog.cpp @@ -435,7 +435,7 @@ void Logger::Flush() { uint32_t bytesWritten; nsCString& line = linesToWrite[i]; nsresult rv = mLogFile->Write(line.get(), line.Length(), &bytesWritten); - NS_WARN_IF(NS_FAILED(rv)); + Unused << NS_WARN_IF(NS_FAILED(rv)); } } diff --git a/ipc/mscom/Registration.cpp b/ipc/mscom/Registration.cpp index c480548183345..458d87db93073 100644 --- a/ipc/mscom/Registration.cpp +++ b/ipc/mscom/Registration.cpp @@ -415,7 +415,7 @@ static CRITICAL_SECTION* GetMutex() { #endif } - sRegistry->emplaceBack(aProxy); + MOZ_ALWAYS_TRUE(sRegistry->emplaceBack(aProxy)); } /* static */ void RegisteredProxy::DeleteFromRegistry(RegisteredProxy* aProxy) { @@ -449,7 +449,7 @@ void RegisterArrayData(const ArrayData* aArrayData, size_t aLength) { ClearOnShutdown(&sArrayData, ShutdownPhase::ShutdownThreads); } - sArrayData->emplaceBack(MakePair(aArrayData, aLength)); + MOZ_ALWAYS_TRUE(sArrayData->emplaceBack(MakePair(aArrayData, aLength))); } const ArrayData* FindArrayData(REFIID aIid, ULONG aMethodIndex) { diff --git a/ipc/mscom/SpinEvent.cpp b/ipc/mscom/SpinEvent.cpp index eb68087165db7..b742d7f74f014 100644 --- a/ipc/mscom/SpinEvent.cpp +++ b/ipc/mscom/SpinEvent.cpp @@ -28,7 +28,7 @@ bool SpinEvent::sIsMulticore = false; SpinEvent::SpinEvent() : mDone(false) { static const bool gotStatics = InitStatics(); - MOZ_ASSERT(gotStatics); + MOZ_ALWAYS_TRUE(gotStatics); mDoneEvent.own(::CreateEventW(nullptr, FALSE, FALSE, nullptr)); MOZ_ASSERT(mDoneEvent); diff --git a/ipc/mscom/moz.build b/ipc/mscom/moz.build index 71a3cb05f8d57..feba340514c97 100644 --- a/ipc/mscom/moz.build +++ b/ipc/mscom/moz.build @@ -88,6 +88,3 @@ FINAL_LIBRARY = 'xul' with Files("**"): BUG_COMPONENT = ("Core", "IPC: MSCOM") - -if CONFIG['CC_TYPE'] == 'clang-cl': - AllowCompilerWarnings() # workaround for bug 1090497 diff --git a/ipc/mscom/oop/moz.build b/ipc/mscom/oop/moz.build index b2968575e32f1..8be7842b6e076 100644 --- a/ipc/mscom/oop/moz.build +++ b/ipc/mscom/oop/moz.build @@ -37,6 +37,3 @@ FORCE_STATIC_LIB = True # This DLL may be loaded into other processes, so we need static libs for # Windows 7 and Windows 8. USE_STATIC_LIBS = True - -if CONFIG['CC_TYPE'] == 'clang-cl': - AllowCompilerWarnings() # workaround for bug 1090497 diff --git a/js/ductwork/debugger/JSDebugger.cpp b/js/ductwork/debugger/JSDebugger.cpp index 9e6af1b54af2c..4fcb1a6818978 100644 --- a/js/ductwork/debugger/JSDebugger.cpp +++ b/js/ductwork/debugger/JSDebugger.cpp @@ -10,7 +10,6 @@ #include "jsapi.h" #include "jsfriendapi.h" #include "js/Wrapper.h" -#include "mozilla/ModuleUtils.h" #include "nsServiceManagerUtils.h" #include "nsMemory.h" @@ -26,8 +25,6 @@ namespace mozilla { namespace jsdebugger { -NS_GENERIC_FACTORY_CONSTRUCTOR(JSDebugger) - NS_IMPL_ISUPPORTS(JSDebugger, IJSDebugger) JSDebugger::JSDebugger() {} @@ -75,18 +72,3 @@ JSDebugger::AddClass(JS::Handle global, JSContext* cx) { } // namespace jsdebugger } // namespace mozilla - -NS_DEFINE_NAMED_CID(JSDEBUGGER_CID); - -static const mozilla::Module::CIDEntry kJSDebuggerCIDs[] = { - {&kJSDEBUGGER_CID, false, nullptr, - mozilla::jsdebugger::JSDebuggerConstructor}, - {nullptr}}; - -static const mozilla::Module::ContractIDEntry kJSDebuggerContracts[] = { - {JSDEBUGGER_CONTRACTID, &kJSDEBUGGER_CID}, {nullptr}}; - -static const mozilla::Module kJSDebuggerModule = { - mozilla::Module::kVersion, kJSDebuggerCIDs, kJSDebuggerContracts}; - -NSMODULE_DEFN(jsdebugger) = &kJSDebuggerModule; diff --git a/js/ductwork/debugger/components.conf b/js/ductwork/debugger/components.conf new file mode 100644 index 0000000000000..16d3c450dc40a --- /dev/null +++ b/js/ductwork/debugger/components.conf @@ -0,0 +1,14 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +Classes = [ + { + 'cid': '{0365cbd5-d46e-4e94-a39f-83b63cd1a963}', + 'contract_ids': ['@mozilla.org/jsdebugger;1'], + 'type': 'mozilla::jsdebugger::JSDebugger', + 'headers': ['/js/ductwork/debugger/JSDebugger.h'], + }, +] diff --git a/js/ductwork/debugger/moz.build b/js/ductwork/debugger/moz.build index 0fb85f8b86efb..6309c202c2319 100644 --- a/js/ductwork/debugger/moz.build +++ b/js/ductwork/debugger/moz.build @@ -19,6 +19,10 @@ SOURCES += [ 'JSDebugger.cpp', ] +XPCOM_MANIFESTS += [ + 'components.conf', +] + EXTRA_JS_MODULES += [ 'jsdebugger.jsm', ] diff --git a/js/src/builtin/TypedObject.cpp b/js/src/builtin/TypedObject.cpp index 4a052e5b8aeea..2341c3efc302c 100644 --- a/js/src/builtin/TypedObject.cpp +++ b/js/src/builtin/TypedObject.cpp @@ -1490,23 +1490,6 @@ bool TypedObject::isAttached() const { return true; } -/* static */ bool TypedObject::GetBuffer(JSContext* cx, unsigned argc, - Value* vp) { - CallArgs args = CallArgsFromVp(argc, vp); - JSObject& obj = args[0].toObject(); - ArrayBufferObject* buffer; - if (obj.is()) { - buffer = obj.as().getOrCreateBuffer(cx); - } else { - buffer = obj.as().getOrCreateBuffer(cx); - } - if (!buffer) { - return false; - } - args.rval().setObject(*buffer); - return true; -} - /* static */ bool TypedObject::GetByteOffset(JSContext* cx, unsigned argc, Value* vp) { CallArgs args = CallArgsFromVp(argc, vp); @@ -1531,11 +1514,6 @@ bool TypedObject::isAttached() const { } void OutlineTypedObject::setOwnerAndData(JSObject* owner, uint8_t* data) { - // Make sure we don't associate with array buffers whose data is from an - // inline typed object, see obj_trace. - MOZ_ASSERT_IF(owner && owner->is(), - !owner->as().forInlineTypedObject()); - // Typed objects cannot move from one owner to another, so don't worry // about pre barriers during this initialization. owner_ = owner; @@ -1594,14 +1572,6 @@ void OutlineTypedObject::attach(JSContext* cx, ArrayBufferObject& buffer, MOZ_ASSERT(offset <= buffer.byteLength()); MOZ_ASSERT(size() <= buffer.byteLength() - offset); - // If the owner's data is from an inline typed object, associate this with - // the inline typed object instead, to simplify tracing. - if (buffer.forInlineTypedObject()) { - InlineTypedObject& realOwner = buffer.firstView()->as(); - attach(cx, realOwner, offset); - return; - } - buffer.setHasTypedObjectViews(); { @@ -1711,11 +1681,7 @@ void OutlineTypedObject::attach(JSContext* cx, TypedObject& typedObj, uint8_t* newData = oldData; // Update the data pointer if the owner moved and the owner's data is - // inline with it. Note that an array buffer pointing to data in an inline - // typed object will never be used as an owner for another outline typed - // object. In such cases, the owner will be the inline typed object itself. - MOZ_ASSERT_IF(owner->is(), - !owner->as().forInlineTypedObject()); + // inline with it. if (owner != oldOwner && (owner->is() || owner->as().hasInlineData())) { newData += reinterpret_cast(owner) - @@ -2226,70 +2192,6 @@ void OutlineTypedObject::notifyBufferDetached(void* newData) { return 0; } -ArrayBufferObject* InlineTransparentTypedObject::getOrCreateBuffer( - JSContext* cx) { - ObjectRealm& realm = ObjectRealm::get(this); - if (!realm.lazyArrayBuffers) { - auto table = cx->make_unique(cx); - if (!table) { - return nullptr; - } - - realm.lazyArrayBuffers = std::move(table); - } - - ObjectWeakMap* table = realm.lazyArrayBuffers.get(); - - JSObject* obj = table->lookup(this); - if (obj) { - return &obj->as(); - } - - ArrayBufferObject::BufferContents contents = - ArrayBufferObject::BufferContents::createPlain(inlineTypedMem()); - size_t nbytes = typeDescr().size(); - - // Prevent GC under ArrayBufferObject::create, which might move this object - // and its contents. - gc::AutoSuppressGC suppress(cx); - - ArrayBufferObject* buffer = ArrayBufferObject::create( - cx, nbytes, contents, ArrayBufferObject::DoesntOwnData); - if (!buffer) { - return nullptr; - } - - // The owning object must always be the array buffer's first view. This - // both prevents the memory from disappearing out from under the buffer - // (the first view is held strongly by the buffer) and is used by the - // buffer marking code to detect whether its data pointer needs to be - // relocated. - MOZ_ALWAYS_TRUE(buffer->addView(cx, this)); - - buffer->setForInlineTypedObject(); - buffer->setHasTypedObjectViews(); - - if (!table->add(cx, this, buffer)) { - return nullptr; - } - - if (IsInsideNursery(this)) { - // Make sure the buffer is traced by the next generational collection, - // so that its data pointer is updated after this typed object moves. - storeBuffer()->putWholeCell(buffer); - } - - return buffer; -} - -ArrayBufferObject* OutlineTransparentTypedObject::getOrCreateBuffer( - JSContext* cx) { - if (owner().is()) { - return &owner().as(); - } - return owner().as().getOrCreateBuffer(cx); -} - /****************************************************************************** * Typed object classes */ diff --git a/js/src/builtin/TypedObject.h b/js/src/builtin/TypedObject.h index 2d1b9952eb861..8a11c53045e65 100644 --- a/js/src/builtin/TypedObject.h +++ b/js/src/builtin/TypedObject.h @@ -619,7 +619,6 @@ class TypedObject : public ShapedObject { static MOZ_MUST_USE bool construct(JSContext* cx, unsigned argc, Value* vp); /* Accessors for self hosted code. */ - static MOZ_MUST_USE bool GetBuffer(JSContext* cx, unsigned argc, Value* vp); static MOZ_MUST_USE bool GetByteOffset(JSContext* cx, unsigned argc, Value* vp); @@ -701,8 +700,6 @@ class OutlineTypedObject : public TypedObject { class OutlineTransparentTypedObject : public OutlineTypedObject { public: static const Class class_; - - ArrayBufferObject* getOrCreateBuffer(JSContext* cx); }; // Class for an opaque typed object whose owner may be either an array buffer @@ -760,8 +757,6 @@ class InlineTransparentTypedObject : public InlineTypedObject { public: static const Class class_; - ArrayBufferObject* getOrCreateBuffer(JSContext* cx); - uint8_t* inlineTypedMem() const { return InlineTypedObject::inlineTypedMem(); } diff --git a/js/src/builtin/TypedObjectConstants.h b/js/src/builtin/TypedObjectConstants.h index 77fc508957f31..fa45d7b9ca1a5 100644 --- a/js/src/builtin/TypedObjectConstants.h +++ b/js/src/builtin/TypedObjectConstants.h @@ -28,7 +28,7 @@ #define JS_ARRAYBUFFER_FLAGS_SLOT 3 -#define JS_ARRAYBUFFER_DETACHED_FLAG 0x4 +#define JS_ARRAYBUFFER_DETACHED_FLAG 0x8 /////////////////////////////////////////////////////////////////////////// // Slots for typed prototypes diff --git a/js/src/gc/Memory.cpp b/js/src/gc/Memory.cpp index fa3dc90f76b4f..79fef8b3532cb 100644 --- a/js/src/gc/Memory.cpp +++ b/js/src/gc/Memory.cpp @@ -158,12 +158,11 @@ static void* MapAlignedPagesLastDitch(size_t length, size_t alignment); #ifdef JS_64BIT static void* MapAlignedPagesRandom(size_t length, size_t alignment); -void* TestMapAlignedPagesLastDitch(size_t, size_t) { return nullptr; } -#else +#endif + void* TestMapAlignedPagesLastDitch(size_t length, size_t alignment) { return MapAlignedPagesLastDitch(length, alignment); } -#endif /* * We can only decommit unused pages if the hardcoded Arena @@ -425,28 +424,45 @@ void* MapAlignedPages(size_t length, size_t alignment) { } #endif + // Try to allocate the region. If the returned address is aligned, + // either we OOMed (region is nullptr) or we're done. void* region = MapMemory(length); if (OffsetFromAligned(region, alignment) == 0) { return region; } + // Try to align the region. On success, TryToAlignChunk() returns + // true and we can return the aligned region immediately. void* retainedRegion; - TryToAlignChunk(®ion, &retainedRegion, length, alignment); + if (TryToAlignChunk(®ion, &retainedRegion, length, alignment)) { + MOZ_ASSERT(region && OffsetFromAligned(region, alignment) == 0); + MOZ_ASSERT(!retainedRegion); + return region; + } + + // On failure, the unaligned region is retained unless we OOMed. We don't + // use the retained region on this path (see the last ditch allocator). if (retainedRegion) { UnmapInternal(retainedRegion, length); } + + // If it fails to align the given region, TryToAlignChunk() returns the + // next valid region that we might be able to align (unless we OOMed). if (region) { - if (OffsetFromAligned(region, alignment) == 0) { - return region; - } + MOZ_ASSERT(OffsetFromAligned(region, alignment) != 0); UnmapInternal(region, length); } + // Since we couldn't align the first region, fall back to allocating a + // region large enough that we can definitely align it. region = MapAlignedPagesSlow(length, alignment); if (!region) { + // If there wasn't enough contiguous address space left for that, + // try to find an alignable region using the last ditch allocator. region = MapAlignedPagesLastDitch(length, alignment); } + // At this point we should either have an aligned region or nullptr. MOZ_ASSERT(OffsetFromAligned(region, alignment) == 0); return region; } @@ -510,6 +526,7 @@ static void* MapAlignedPagesRandom(size_t length, size_t alignment) { } void* retainedRegion = nullptr; if (TryToAlignChunk(®ion, &retainedRegion, length, alignment)) { + MOZ_ASSERT(region && OffsetFromAligned(region, alignment) == 0); MOZ_ASSERT(!retainedRegion); return region; } @@ -590,6 +607,7 @@ static void* MapAlignedPagesLastDitch(size_t length, size_t alignment) { } for (; attempt < MaxLastDitchAttempts; ++attempt) { if (TryToAlignChunk(®ion, tempMaps + attempt, length, alignment)) { + MOZ_ASSERT(region && OffsetFromAligned(region, alignment) == 0); MOZ_ASSERT(!tempMaps[attempt]); break; // Success! } @@ -705,6 +723,12 @@ static bool TryToAlignChunk(void** aRegion, void** aRetainedRegion, // If our current chunk cannot be aligned, just get a new one. retainedRegion = regionStart; regionStart = MapMemory(length); + // Our new region might happen to already be aligned. + result = OffsetFromAligned(regionStart, alignment) == 0; + if (result) { + UnmapInternal(retainedRegion, length); + retainedRegion = nullptr; + } } *aRegion = regionStart; diff --git a/js/src/gc/Nursery.cpp b/js/src/gc/Nursery.cpp index 3666102851944..d4bf20a286755 100644 --- a/js/src/gc/Nursery.cpp +++ b/js/src/gc/Nursery.cpp @@ -221,6 +221,7 @@ void js::Nursery::disable() { // nursery. JIT'd code uses this even if the nursery is disabled. currentEnd_ = 0; currentStringEnd_ = 0; + position_ = 0; runtime()->gc.storeBuffer().disable(); } diff --git a/js/src/gc/Nursery.h b/js/src/gc/Nursery.h index 1296b5eb1a237..d1868b855e44e 100644 --- a/js/src/gc/Nursery.h +++ b/js/src/gc/Nursery.h @@ -362,6 +362,7 @@ class Nursery { return capacity() - freeSpace(); } MOZ_ALWAYS_INLINE size_t freeSpace() const { + MOZ_ASSERT(isEnabled()); MOZ_ASSERT(currentEnd_ - position_ <= NurseryChunkUsableSize); MOZ_ASSERT(currentChunk_ < maxChunkCount()); return (currentEnd_ - position_) + diff --git a/js/src/jit/MacroAssembler.cpp b/js/src/jit/MacroAssembler.cpp index 172c09716500d..52802bb169c23 100644 --- a/js/src/jit/MacroAssembler.cpp +++ b/js/src/jit/MacroAssembler.cpp @@ -3429,10 +3429,6 @@ void MacroAssembler::wasmInterruptCheck(Register tls, void MacroAssembler::wasmReserveStackChecked(uint32_t amount, wasm::BytecodeOffset trapOffset) { - if (!amount) { - return; - } - // If the frame is large, don't bump sp until after the stack limit check so // that the trap handler isn't called with a wild sp. diff --git a/js/src/jsapi-tests/testGCAllocator.cpp b/js/src/jsapi-tests/testGCAllocator.cpp index 8cc43357176c1..4c28b94ba299b 100644 --- a/js/src/jsapi-tests/testGCAllocator.cpp +++ b/js/src/jsapi-tests/testGCAllocator.cpp @@ -135,6 +135,9 @@ bool testGCAllocatorUp(const size_t PageSize) { // Check that the last ditch allocator works as expected. CHECK(positionIsCorrect("x--xx--xx-oox---", stagingArea, chunkPool, tempChunks, UseLastDitchAllocator)); + // Check that the last ditch allocator can deal with naturally aligned chunks. + CHECK(positionIsCorrect("x--xx--xoo------", stagingArea, chunkPool, + tempChunks, UseLastDitchAllocator)); // Clean up. while (--tempChunks >= 0) { @@ -185,6 +188,9 @@ bool testGCAllocatorDown(const size_t PageSize) { // Check that the last ditch allocator works as expected. CHECK(positionIsCorrect("---xoo-xx--xx--x", stagingArea, chunkPool, tempChunks, UseLastDitchAllocator)); + // Check that the last ditch allocator can deal with naturally aligned chunks. + CHECK(positionIsCorrect("------oox--xx--x", stagingArea, chunkPool, + tempChunks, UseLastDitchAllocator)); // Clean up. while (--tempChunks >= 0) { diff --git a/js/src/jsapi.h b/js/src/jsapi.h index eea0d1e1e1a8b..3a8b7e168ad94 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -2022,7 +2022,7 @@ JS_PUBLIC_API void JS_SetAllNonReservedSlotsToUndefined(JSContext* cx, /** * Create a new array buffer with the given contents. It must be legal to pass - * these contents to free(). On success, the ownership is transferred to the + * these contents to JS_free(). On success, the ownership is transferred to the * new array buffer. */ extern JS_PUBLIC_API JSObject* JS_NewArrayBufferWithContents(JSContext* cx, @@ -2067,8 +2067,8 @@ extern JS_PUBLIC_API JSObject* JS_NewExternalArrayBuffer( /** * Create a new array buffer with the given contents. The array buffer does not - * take ownership of contents, and JS_DetachArrayBuffer must be called before - * the contents are disposed of. + * take ownership of contents. JS_DetachArrayBuffer must be called before + * the contents are disposed of by the user; this call will always succeed. */ extern JS_PUBLIC_API JSObject* JS_NewArrayBufferWithExternalContents( JSContext* cx, size_t nbytes, void* contents); diff --git a/js/src/jsfriendapi.h b/js/src/jsfriendapi.h index 9cebfdaf3fb15..e4e0e2fb48368 100644 --- a/js/src/jsfriendapi.h +++ b/js/src/jsfriendapi.h @@ -1943,7 +1943,9 @@ extern JS_FRIEND_API JSObject* JS_GetArrayBufferViewBuffer( * Detach an ArrayBuffer, causing all associated views to no longer refer to * the ArrayBuffer's original attached memory. * - * The |changeData| argument is obsolete and ignored. + * This function throws only if it is provided a non-ArrayBuffer object or if + * the provided ArrayBuffer is a WASM-backed ArrayBuffer or an ArrayBuffer used + * in asm.js code. */ extern JS_FRIEND_API bool JS_DetachArrayBuffer(JSContext* cx, JS::HandleObject obj); diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp index fe43db2005bfa..090b7ae76a7fd 100644 --- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -1916,9 +1916,9 @@ static bool CacheEntry_setBytecode(JSContext* cx, HandleObject cache, uint8_t* buffer, uint32_t length) { MOZ_ASSERT(CacheEntry_isCacheEntry(cache)); - ArrayBufferObject::BufferContents contents = - ArrayBufferObject::BufferContents::create( - buffer); + using BufferContents = ArrayBufferObject::BufferContents; + + BufferContents contents = BufferContents::createPlainData(buffer); Rooted arrayBuffer( cx, ArrayBufferObject::create(cx, length, contents)); if (!arrayBuffer) { diff --git a/js/src/vm/ArrayBufferObject.cpp b/js/src/vm/ArrayBufferObject.cpp index dbf6f360c5108..8624936835e31 100644 --- a/js/src/vm/ArrayBufferObject.cpp +++ b/js/src/vm/ArrayBufferObject.cpp @@ -293,7 +293,7 @@ static const ClassOps ArrayBufferObjectClassOps = { nullptr, /* call */ nullptr, /* hasInstance */ nullptr, /* construct */ - ArrayBufferObject::trace, + nullptr, /* trace */ }; static const JSFunctionSpec arraybuffer_functions[] = { @@ -445,7 +445,7 @@ static ArrayBufferObject::BufferContents AllocateArrayBufferContents( JSContext* cx, uint32_t nbytes) { uint8_t* p = cx->pod_callocCanGC(nbytes, js::ArrayBufferContentsArena); - return ArrayBufferObject::BufferContents::create(p); + return ArrayBufferObject::BufferContents::createPlainData(p); } static void NoteViewBufferWasDetached( @@ -468,8 +468,6 @@ static void NoteViewBufferWasDetached( // When detaching buffers where we don't know all views, the new data must // match the old data. All missing views are typed objects, which do not // expect their data to ever change. - MOZ_ASSERT_IF(buffer->forInlineTypedObject(), - newContents.data() == buffer->dataPointer()); // When detaching a buffer with typed object views, any jitcode accessing // such views must be deoptimized so that detachment checks are performed. @@ -503,8 +501,6 @@ static void NoteViewBufferWasDetached( innerViews.removeViews(buffer); } if (JSObject* view = buffer->firstView()) { - MOZ_ASSERT(!buffer->forInlineTypedObject(), - "Typed object buffers cannot be detached"); NoteViewBufferWasDetached(&view->as(), newContents, cx); buffer->setFirstView(nullptr); @@ -561,7 +557,6 @@ void ArrayBufferObject::changeContents(JSContext* cx, BufferContents newContents, OwnsState ownsState) { MOZ_RELEASE_ASSERT(!isWasm()); - MOZ_ASSERT(!forInlineTypedObject()); // Change buffer contents. uint8_t* oldDataPointer = dataPointer(); @@ -931,17 +926,29 @@ bool js::CreateWasmBuffer(JSContext* cx, const wasm::Limits& memory, // Don't assert cx->wasmHaveSignalHandlers because (1) they aren't needed // for asm.js, (2) they are only installed for WebAssembly, not asm.js. - if (buffer->forInlineTypedObject()) { + // wasm buffers can be detached at any time. + if (buffer->isWasm()) { + MOZ_ASSERT(!buffer->isPreparedForAsmJS()); return false; } - if (!buffer->isWasm() && buffer->isPreparedForAsmJS()) { - return true; + // asm.js code and associated buffers are potentially long-lived. Yet if + // |buffer->hasUserOwnedData()|, |buffer| *must* be detached by the user + // before the user-provided data is disposed. Eliminate the complexity of + // this edge case by not allowing buffers with user-provided content to be + // used with asm.js, as no callers exist that want to use such buffer with + // asm.js. + if (buffer->hasUserOwnedData()) { + MOZ_ASSERT(!buffer->isPreparedForAsmJS()); + return false; } - // Non-prepared-for-asm.js wasm buffers can be detached at any time. - if (buffer->isWasm()) { - return false; + MOZ_ASSERT(buffer->isPlainData() || buffer->isMapped() || + buffer->isExternal()); + + // Buffers already prepared for asm.js need no further work. + if (buffer->isPreparedForAsmJS()) { + return true; } if (!buffer->ownsData()) { @@ -986,9 +993,12 @@ void ArrayBufferObject::releaseData(FreeOp* fop) { MOZ_ASSERT(ownsData()); switch (bufferKind()) { - case PLAIN: + case PLAIN_DATA: fop->free_(dataPointer()); break; + case USER_OWNED: + MOZ_ASSERT_UNREACHABLE("user-owned data should never be owned by this"); + break; case MAPPED: gc::DeallocateMappedContent(dataPointer(), byteLength()); break; @@ -1005,6 +1015,11 @@ void ArrayBufferObject::releaseData(FreeOp* fop) { freeInfo()->freeFunc(dataPointer(), freeInfo()->freeUserData); } break; + case BAD1: + case BAD2: + case BAD3: + MOZ_CRASH("invalid BufferKind encountered"); + break; } } @@ -1123,7 +1138,8 @@ Maybe js::WasmArrayBufferMaxSize( newBuf->initialize(newSize, contents, OwnsData); memcpy(newBuf->dataPointer(), oldBuf->dataPointer(), oldBuf->byteLength()); - ArrayBufferObject::detach(cx, oldBuf, BufferContents::createPlain(nullptr)); + ArrayBufferObject::detach(cx, oldBuf, + BufferContents::createPlainData(nullptr)); return true; } @@ -1207,7 +1223,7 @@ ArrayBufferObject* ArrayBufferObject::create( int newSlots = JS_HOWMANY(nbytes, sizeof(Value)); MOZ_ASSERT(int(nbytes) <= newSlots * int(sizeof(Value))); nslots = reservedSlots + newSlots; - contents = BufferContents::createPlain(nullptr); + contents = BufferContents::createPlainData(nullptr); } else { contents = AllocateArrayBufferContents(cx, nbytes); if (!contents) { @@ -1237,7 +1253,8 @@ ArrayBufferObject* ArrayBufferObject::create( if (!contents) { void* data = obj->inlineDataPointer(); memset(data, 0, nbytes); - obj->initialize(nbytes, BufferContents::createPlain(data), DoesntOwnData); + obj->initialize(nbytes, BufferContents::createPlainData(data), + DoesntOwnData); } else { obj->initialize(nbytes, contents, ownsState); } @@ -1247,7 +1264,7 @@ ArrayBufferObject* ArrayBufferObject::create( ArrayBufferObject* ArrayBufferObject::create( JSContext* cx, uint32_t nbytes, HandleObject proto /* = nullptr */) { - return create(cx, nbytes, BufferContents::createPlain(nullptr), + return create(cx, nbytes, BufferContents::createPlainData(nullptr), OwnsState::OwnsData, proto); } @@ -1261,7 +1278,7 @@ ArrayBufferObject* ArrayBufferObject::createEmpty(JSContext* cx) { obj->setByteLength(0); obj->setFlags(0); obj->setFirstView(nullptr); - obj->setDataPointer(BufferContents::createPlain(nullptr), DoesntOwnData); + obj->setDataPointer(BufferContents::createPlainData(nullptr), DoesntOwnData); return obj; } @@ -1291,7 +1308,8 @@ ArrayBufferObject* ArrayBufferObject::createFromNewRawBuffer( ArrayBufferObject::externalizeContents(JSContext* cx, Handle buffer, bool hasStealableContents) { - MOZ_ASSERT(buffer->isPlain(), "Only support doing this on plain ABOs"); + MOZ_ASSERT(buffer->isPlainData(), + "only support doing this on ABOs containing plain data"); MOZ_ASSERT(!buffer->isDetached(), "must have contents to externalize"); MOZ_ASSERT_IF(hasStealableContents, buffer->hasStealableContents()); @@ -1307,7 +1325,7 @@ ArrayBufferObject::externalizeContents(JSContext* cx, BufferContents newContents = AllocateArrayBufferContents(cx, buffer->byteLength()); if (!newContents) { - return BufferContents::createPlain(nullptr); + return BufferContents::createFailed(); } memcpy(newContents.data(), contents.data(), buffer->byteLength()); buffer->changeContents(cx, newContents, DoesntOwnData); @@ -1330,7 +1348,7 @@ ArrayBufferObject::externalizeContents(JSContext* cx, if (hasStealableContents) { // Return the old contents and reset the detached buffer's data // pointer. This pointer should never be accessed. - auto newContents = BufferContents::createPlain(nullptr); + auto newContents = BufferContents::createPlainData(nullptr); buffer->setOwnsData(DoesntOwnData); // Do not free the stolen data. ArrayBufferObject::detach(cx, buffer, newContents); buffer->setOwnsData(DoesntOwnData); // Do not free the nullptr. @@ -1342,7 +1360,7 @@ ArrayBufferObject::externalizeContents(JSContext* cx, BufferContents contentsCopy = AllocateArrayBufferContents(cx, buffer->byteLength()); if (!contentsCopy) { - return BufferContents::createPlain(nullptr); + return BufferContents::createFailed(); } if (buffer->byteLength() > 0) { @@ -1361,7 +1379,7 @@ ArrayBufferObject::externalizeContents(JSContext* cx, } switch (buffer.bufferKind()) { - case PLAIN: + case PLAIN_DATA: if (buffer.isPreparedForAsmJS()) { info->objectsMallocHeapElementsAsmJS += mallocSizeOf(buffer.dataPointer()); @@ -1370,6 +1388,11 @@ ArrayBufferObject::externalizeContents(JSContext* cx, mallocSizeOf(buffer.dataPointer()); } break; + case USER_OWNED: + MOZ_ASSERT_UNREACHABLE( + "user-owned data should never be owned by this, and such memory " + "should be accounted for by the code that provided it"); + break; case MAPPED: info->objectsNonHeapElementsNormal += buffer.byteLength(); break; @@ -1378,7 +1401,12 @@ ArrayBufferObject::externalizeContents(JSContext* cx, MOZ_ASSERT(buffer.wasmMappedSize() >= buffer.byteLength()); info->wasmGuardPages += buffer.wasmMappedSize() - buffer.byteLength(); break; - case KIND_MASK: + case EXTERNAL: + MOZ_CRASH("external buffers not currently supported"); + break; + case BAD1: + case BAD2: + case BAD3: MOZ_CRASH("bad bufferKind()"); } } @@ -1403,25 +1431,6 @@ ArrayBufferObject::externalizeContents(JSContext* cx, fromBuffer->dataPointer() + fromIndex, count); } -/* static */ void ArrayBufferObject::trace(JSTracer* trc, JSObject* obj) { - // If this buffer is associated with an inline typed object, - // fix up the data pointer if the typed object was moved. - ArrayBufferObject& buf = obj->as(); - - if (!buf.forInlineTypedObject()) { - return; - } - - JSObject* view = MaybeForwarded(buf.firstView()); - MOZ_ASSERT(view && view->is()); - - TraceManuallyBarrieredEdge(trc, &view, - "array buffer inline typed object owner"); - buf.setFixedSlot( - DATA_SLOT, - PrivateValue(view->as().inlineTypedMem())); -} - /* static */ size_t ArrayBufferObject::objectMoved(JSObject* obj, JSObject* old) { ArrayBufferObject& dst = obj->as(); @@ -1634,7 +1643,7 @@ JS_FRIEND_API bool JS_DetachArrayBuffer(JSContext* cx, HandleObject obj) { ArrayBufferObject::BufferContents newContents = buffer->hasStealableContents() - ? ArrayBufferObject::BufferContents::createPlain(nullptr) + ? ArrayBufferObject::BufferContents::createPlainData(nullptr) : buffer->contents(); ArrayBufferObject::detach(cx, buffer, newContents); @@ -1665,8 +1674,9 @@ JS_PUBLIC_API JSObject* JS_NewArrayBufferWithContents(JSContext* cx, CHECK_THREAD(cx); MOZ_ASSERT_IF(!data, nbytes == 0); - ArrayBufferObject::BufferContents contents = - ArrayBufferObject::BufferContents::create(data); + using BufferContents = ArrayBufferObject::BufferContents; + + BufferContents contents = BufferContents::createPlainData(data); return ArrayBufferObject::create(cx, nbytes, contents, ArrayBufferObject::OwnsData, /* proto = */ nullptr, TenuredObject); @@ -1695,8 +1705,10 @@ JS_PUBLIC_API JSObject* JS_NewArrayBufferWithExternalContents(JSContext* cx, AssertHeapIsIdle(); CHECK_THREAD(cx); MOZ_ASSERT_IF(!data, nbytes == 0); - ArrayBufferObject::BufferContents contents = - ArrayBufferObject::BufferContents::create(data); + + using BufferContents = ArrayBufferObject::BufferContents; + + BufferContents contents = BufferContents::createUserOwned(data); return ArrayBufferObject::create(cx, nbytes, contents, ArrayBufferObject::DoesntOwnData, /* proto = */ nullptr, TenuredObject); @@ -1731,8 +1743,9 @@ JS_PUBLIC_API void* JS_ExternalizeArrayBufferContents(JSContext* cx, } Handle buffer = obj.as(); - if (!buffer->isPlain()) { - // This operation isn't supported on mapped or wsm ArrayBufferObjects. + if (!buffer->isPlainData()) { + // This operation isn't supported on mapped or wasm ArrayBufferObjects, or + // on ArrayBufferObjects with user-provided data. JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_TYPED_ARRAY_BAD_ARGS); return nullptr; @@ -1785,12 +1798,16 @@ JS_PUBLIC_API void* JS_StealArrayBufferContents(JSContext* cx, return nullptr; } - // The caller assumes that a plain malloc'd buffer is returned. - // hasStealableContents is true for mapped buffers, so we must additionally - // require that the buffer is plain. In the future, we could consider - // returning something that handles releasing the memory. + // The caller assumes that a plain malloc'd buffer is returned. To steal + // actual contents, then, we must have |hasStealableContents()| *and* the + // contents must be |isPlainData()|. (Mapped data would not be malloc'd; + // user-provided data we flat-out know nothing about at all -- although it + // *should* have not passed the |hasStealableContents()| check anyway.) + // + // In the future, we could consider returning something that handles + // releasing the memory, in the mapped-data case. bool hasStealableContents = - buffer->hasStealableContents() && buffer->isPlain(); + buffer->hasStealableContents() && buffer->isPlainData(); AutoRealm ar(cx, buffer); return ArrayBufferObject::stealContents(cx, buffer, hasStealableContents) diff --git a/js/src/vm/ArrayBufferObject.h b/js/src/vm/ArrayBufferObject.h index 59190e9f6fdc6..20651c5b548bd 100644 --- a/js/src/vm/ArrayBufferObject.h +++ b/js/src/vm/ArrayBufferObject.h @@ -175,12 +175,27 @@ class ArrayBufferObject : public ArrayBufferObjectMaybeShared { }; enum BufferKind { - PLAIN = 0, // malloced or inline data - WASM = 1, - MAPPED = 2, - EXTERNAL = 3, - - KIND_MASK = 0x3 + /** Malloced or inline data. */ + PLAIN_DATA = 0b000, + + /** + * User-owned memory. The associated buffer must be manually detached + * before the user invalidates (deallocates, reuses the storage of, &c.) + * the user-owned memory. + */ + USER_OWNED = 0b001, + + WASM = 0b010, + MAPPED = 0b011, + EXTERNAL = 0b100, + + // These kind-values are currently invalid. We intend to expand valid + // BufferKinds in the future to either partly or fully use these values. + BAD1 = 0b101, + BAD2 = 0b110, + BAD3 = 0b111, + + KIND_MASK = 0b111 }; protected: @@ -188,7 +203,7 @@ class ArrayBufferObject : public ArrayBufferObjectMaybeShared { // The flags also store the BufferKind BUFFER_KIND_MASK = BufferKind::KIND_MASK, - DETACHED = 0x4, + DETACHED = 0b1000, // The dataPointer() is owned by this buffer and should be released // when no longer in use. Releasing the pointer may be done by freeing, @@ -199,20 +214,15 @@ class ArrayBufferObject : public ArrayBufferObjectMaybeShared { // allocate their data inline, and buffers that are created lazily for // typed objects with inline storage, in which case the buffer points // directly to the typed object's storage. - OWNS_DATA = 0x8, - - // This array buffer was created lazily for a typed object with inline - // data. This implies both that the typed object owns the buffer's data - // and that the list of views sharing this buffer's data might be - // incomplete. Any missing views will be typed objects. - FOR_INLINE_TYPED_OBJECT = 0x10, + OWNS_DATA = 0b1'0000, // Views of this buffer might include typed objects. - TYPED_OBJECT_VIEWS = 0x20, + TYPED_OBJECT_VIEWS = 0b10'0000, - // This PLAIN or WASM buffer has been prepared for asm.js and cannot - // henceforth be transferred/detached. - FOR_ASMJS = 0x40 + // This PLAIN_DATA, MAPPED, or EXTERNAL buffer (only WASM and USER_OWNED + // are excluded) has been prepared for asm.js and cannot henceforth be + // transferred/detached. + FOR_ASMJS = 0b100'0000, }; static_assert(JS_ARRAYBUFFER_DETACHED_FLAG == DETACHED, @@ -248,8 +258,12 @@ class ArrayBufferObject : public ArrayBufferObjectMaybeShared { return BufferContents(static_cast(data), Kind); } - static BufferContents createPlain(void* data) { - return BufferContents(static_cast(data), PLAIN); + static BufferContents createPlainData(void* data) { + return BufferContents(static_cast(data), PLAIN_DATA); + } + + static BufferContents createUserOwned(void* data) { + return BufferContents(static_cast(data), USER_OWNED); } static BufferContents createExternal(void* data, @@ -259,6 +273,10 @@ class ArrayBufferObject : public ArrayBufferObjectMaybeShared { freeUserData); } + static BufferContents createFailed() { + return BufferContents(nullptr, PLAIN_DATA); + } + uint8_t* data() const { return data_; } BufferKind kind() const { return kind_; } JS::BufferContentsFreeFunc freeFunc() const { return free_; } @@ -304,7 +322,6 @@ class ArrayBufferObject : public ArrayBufferObjectMaybeShared { Handle fromBuffer, uint32_t fromIndex, uint32_t count); - static void trace(JSTracer* trc, JSObject* obj); static size_t objectMoved(JSObject* obj, JSObject* old); static BufferContents externalizeContents(JSContext* cx, @@ -379,7 +396,10 @@ class ArrayBufferObject : public ArrayBufferObjectMaybeShared { BufferKind bufferKind() const { return BufferKind(flags() & BUFFER_KIND_MASK); } - bool isPlain() const { return bufferKind() == PLAIN; } + + bool isPlainData() const { return bufferKind() == PLAIN_DATA; } + bool hasUserOwnedData() const { return bufferKind() == USER_OWNED; } + bool isWasm() const { return bufferKind() == WASM; } bool isMapped() const { return bufferKind() == MAPPED; } bool isExternal() const { return bufferKind() == EXTERNAL; } @@ -409,15 +429,8 @@ class ArrayBufferObject : public ArrayBufferObjectMaybeShared { static size_t offsetOfFlagsSlot() { return getFixedSlotOffset(FLAGS_SLOT); } static size_t offsetOfDataSlot() { return getFixedSlotOffset(DATA_SLOT); } - void setForInlineTypedObject() { - setFlags(flags() | FOR_INLINE_TYPED_OBJECT); - } void setHasTypedObjectViews() { setFlags(flags() | TYPED_OBJECT_VIEWS); } - bool forInlineTypedObject() const { - return flags() & FOR_INLINE_TYPED_OBJECT; - } - protected: void setDataPointer(BufferContents contents, OwnsState ownsState); void setByteLength(uint32_t length); @@ -433,7 +446,12 @@ class ArrayBufferObject : public ArrayBufferObjectMaybeShared { bool hasTypedObjectViews() const { return flags() & TYPED_OBJECT_VIEWS; } void setIsDetached() { setFlags(flags() | DETACHED); } - void setIsPreparedForAsmJS() { setFlags(flags() | FOR_ASMJS); } + void setIsPreparedForAsmJS() { + MOZ_ASSERT(!isWasm()); + MOZ_ASSERT(!hasUserOwnedData()); + MOZ_ASSERT(isPlainData() || isMapped() || isExternal()); + setFlags(flags() | FOR_ASMJS); + } void initialize(size_t byteLength, BufferContents contents, OwnsState ownsState) { diff --git a/js/src/vm/ArrayBufferViewObject.cpp b/js/src/vm/ArrayBufferViewObject.cpp index 757b1adace949..c8e21e31bc927 100644 --- a/js/src/vm/ArrayBufferViewObject.cpp +++ b/js/src/vm/ArrayBufferViewObject.cpp @@ -36,12 +36,6 @@ using namespace js; uint32_t offset = uint32_t(obj->getFixedSlot(BYTEOFFSET_SLOT).toInt32()); MOZ_ASSERT(offset <= INT32_MAX); - // We don't expose the underlying ArrayBuffer for typed objects, - // and we don't allow constructing a TypedObject from an arbitrary - // ArrayBuffer, so we should never have a TypedArray/DataView with - // a buffer that has TypedObject views. - MOZ_RELEASE_ASSERT(!buf.forInlineTypedObject()); - MOZ_ASSERT_IF(buf.dataPointer() == nullptr, offset == 0); // The data may or may not be inline with the buffer. The buffer diff --git a/js/src/vm/SelfHosting.cpp b/js/src/vm/SelfHosting.cpp index 48c576a69d0f3..197859f50c563 100644 --- a/js/src/vm/SelfHosting.cpp +++ b/js/src/vm/SelfHosting.cpp @@ -2654,7 +2654,6 @@ static const JSFunctionSpec intrinsic_functions[] = { // See builtin/TypedObject.h for descriptors of the typedobj functions. JS_FN("NewOpaqueTypedObject", js::NewOpaqueTypedObject, 1, 0), JS_FN("NewDerivedTypedObject", js::NewDerivedTypedObject, 3, 0), - JS_FN("TypedObjectBuffer", TypedObject::GetBuffer, 1, 0), JS_FN("TypedObjectByteOffset", TypedObject::GetByteOffset, 1, 0), JS_FN("AttachTypedObject", js::AttachTypedObject, 3, 0), JS_FN("TypedObjectIsAttached", js::TypedObjectIsAttached, 1, 0), diff --git a/modules/libpref/Preferences.cpp b/modules/libpref/Preferences.cpp index 8b87f36dc519d..aad344bd31494 100644 --- a/modules/libpref/Preferences.cpp +++ b/modules/libpref/Preferences.cpp @@ -17,13 +17,13 @@ #include "mozilla/ArenaAllocator.h" #include "mozilla/ArrayUtils.h" #include "mozilla/Attributes.h" +#include "mozilla/Components.h" #include "mozilla/dom/PContent.h" #include "mozilla/HashFunctions.h" #include "mozilla/HashTable.h" #include "mozilla/Logging.h" #include "mozilla/Maybe.h" #include "mozilla/MemoryReporting.h" -#include "mozilla/ModuleUtils.h" #include "mozilla/Omnijar.h" #include "mozilla/Preferences.h" #include "mozilla/ResultExtensions.h" @@ -5409,35 +5409,16 @@ static void InitVarCachePref(const nsACString& aName, float* aCache, // Module and factory stuff //=========================================================================== -NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(Preferences, - Preferences::GetInstanceForService) -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrefLocalizedString, Init) - -static NS_DEFINE_CID(kPrefServiceCID, NS_PREFSERVICE_CID); -static NS_DEFINE_CID(kPrefLocalizedStringCID, NS_PREFLOCALIZEDSTRING_CID); - -static mozilla::Module::CIDEntry kPrefCIDs[] = { - {&kPrefServiceCID, true, nullptr, PreferencesConstructor, - Module::ALLOW_IN_SOCKET_PROCESS}, - {&kPrefLocalizedStringCID, false, nullptr, - nsPrefLocalizedStringConstructor}, - {nullptr}}; - -static mozilla::Module::ContractIDEntry kPrefContracts[] = { - {NS_PREFSERVICE_CONTRACTID, &kPrefServiceCID, - Module::ALLOW_IN_SOCKET_PROCESS}, - {NS_PREFLOCALIZEDSTRING_CONTRACTID, &kPrefLocalizedStringCID}, - {nullptr}}; - -static void UnloadPrefsModule() { Preferences::Shutdown(); } - -static const mozilla::Module kPrefModule = {mozilla::Module::kVersion, - kPrefCIDs, - kPrefContracts, - nullptr, - nullptr, - nullptr, - UnloadPrefsModule, - Module::ALLOW_IN_SOCKET_PROCESS}; - -NSMODULE_DEFN(nsPrefModule) = &kPrefModule; +NS_IMPL_COMPONENT_FACTORY(nsPrefLocalizedString) { + auto str = MakeRefPtr(); + if (NS_SUCCEEDED(str->Init())) { + return str.forget().downcast(); + } + return nullptr; +} + +namespace mozilla { + +void UnloadPrefsModule() { Preferences::Shutdown(); } + +} diff --git a/modules/libpref/Preferences.h b/modules/libpref/Preferences.h index 68a58022edb61..14e0b95b314d4 100644 --- a/modules/libpref/Preferences.h +++ b/modules/libpref/Preferences.h @@ -33,6 +33,8 @@ class nsPrefBranch; namespace mozilla { +void UnloadPrefsModule(); + // A typesafe version of PrefChangeFunc, with its data argument type deduced // from the type of the argument passed to RegisterCallback. // diff --git a/modules/libpref/components.conf b/modules/libpref/components.conf new file mode 100644 index 0000000000000..4b8dff423af00 --- /dev/null +++ b/modules/libpref/components.conf @@ -0,0 +1,27 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +Headers = [ + 'mozilla/Preferences.h', +] + +UnloadFunc = 'mozilla::UnloadPrefsModule' + +Classes = [ + { + 'cid': '{91ca2441-050f-4f7c-9df8-75b40ea40156}', + 'contract_ids': ['@mozilla.org/preferences-service;1'], + 'singleton': True, + 'type': 'mozilla::Preferences', + 'headers': ['mozilla/Preferences.h'], + 'constructor': 'mozilla::Preferences::GetInstanceForService', + }, + { + 'cid': '{064d9cee-1dd2-11b2-83e3-d25ab0193c26}', + 'contract_ids': ['@mozilla.org/pref-localizedstring;1'], + 'type': 'nsPrefLocalizedString', + }, +] diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index 471e844a1dbea..1ec585d0bd1cd 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -1442,6 +1442,9 @@ pref("privacy.firstparty.isolate.restrict_opener_access", true); // If you do set it, to work around some broken website, please file a bug with // information so we can understand why it is needed. pref("privacy.resistFingerprinting.autoDeclineNoUserInputCanvasPrompts", true); +// The log level for browser console messages logged in RFPHelper.jsm +// Change to 'All' and restart to see the messages +pref("privacy.resistFingerprinting.jsmloglevel", "Warn"); // A subset of Resist Fingerprinting protections focused specifically on timers for testing // This affects the Animation API, the performance APIs, Date.getTime, Event.timestamp, // File.lastModified, audioContext.currentTime, canvas.captureStream.currentTime diff --git a/modules/libpref/moz.build b/modules/libpref/moz.build index 655a6c1e4d1f8..24f98e1864155 100644 --- a/modules/libpref/moz.build +++ b/modules/libpref/moz.build @@ -36,6 +36,10 @@ UNIFIED_SOURCES += [ 'SharedPrefMap.cpp', ] +XPCOM_MANIFESTS += [ + 'components.conf', +] + include('/ipc/chromium/chromium-config.mozbuild') FINAL_LIBRARY = 'xul' diff --git a/netwerk/dns/mdns/libmdns/components.conf b/netwerk/dns/mdns/libmdns/components.conf index 00eb7e139600d..6e64140c820ed 100644 --- a/netwerk/dns/mdns/libmdns/components.conf +++ b/netwerk/dns/mdns/libmdns/components.conf @@ -4,7 +4,14 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -Classes = [] +Classes = [ + { + 'cid': '{14a50f2b-7ff6-48a5-88e3-615fd111f5d3}', + 'contract_ids': ['@mozilla.org/toolkit/components/mdnsresponder/dns-info;1'], + 'type': 'mozilla::net::nsDNSServiceInfo', + 'headers': ['/netwerk/dns/mdns/libmdns/nsDNSServiceInfo.h'], + }, +] if buildconfig.substs['MOZ_WIDGET_TOOLKIT'] != 'cocoa': Classes += [ diff --git a/netwerk/dns/mdns/libmdns/moz.build b/netwerk/dns/mdns/libmdns/moz.build index 6f8b179f5362c..05dc75eb9edad 100644 --- a/netwerk/dns/mdns/libmdns/moz.build +++ b/netwerk/dns/mdns/libmdns/moz.build @@ -34,7 +34,10 @@ else: UNIFIED_SOURCES += [ 'nsDNSServiceInfo.cpp', - 'nsMulticastDNSModule.cpp', +] + +XPCOM_MANIFESTS += [ + 'components.conf', ] XPCOM_MANIFESTS += [ diff --git a/netwerk/dns/mdns/libmdns/nsMulticastDNSModule.cpp b/netwerk/dns/mdns/libmdns/nsMulticastDNSModule.cpp deleted file mode 100644 index 3a108abcbc669..0000000000000 --- a/netwerk/dns/mdns/libmdns/nsMulticastDNSModule.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#if defined(MOZ_WIDGET_COCOA) -# define ENABLE_DNS_SERVICE_DISCOVERY -#endif - -#include "mozilla/ModuleUtils.h" - -#ifdef ENABLE_DNS_SERVICE_DISCOVERY -# include "nsDNSServiceDiscovery.h" -#endif - -#include "nsDNSServiceInfo.h" - -#ifdef ENABLE_DNS_SERVICE_DISCOVERY -using mozilla::net::nsDNSServiceDiscovery; -# define DNSSERVICEDISCOVERY_CID \ - { \ - 0x8df43d23, 0xd3f9, 0x4dd5, { \ - 0xb9, 0x65, 0xde, 0x2c, 0xa3, 0xf6, 0xa4, 0x2c \ - } \ - } -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsDNSServiceDiscovery, Init) -NS_DEFINE_NAMED_CID(DNSSERVICEDISCOVERY_CID); -#endif // ENABLE_DNS_SERVICE_DISCOVERY - -using mozilla::net::nsDNSServiceInfo; -#define DNSSERVICEINFO_CID \ - { \ - 0x14a50f2b, 0x7ff6, 0x48a5, { \ - 0x88, 0xe3, 0x61, 0x5f, 0xd1, 0x11, 0xf5, 0xd3 \ - } \ - } -NS_GENERIC_FACTORY_CONSTRUCTOR(nsDNSServiceInfo) -NS_DEFINE_NAMED_CID(DNSSERVICEINFO_CID); - -static const mozilla::Module::CIDEntry knsDNSServiceDiscoveryCIDs[] = { -#ifdef ENABLE_DNS_SERVICE_DISCOVERY - {&kDNSSERVICEDISCOVERY_CID, false, nullptr, - nsDNSServiceDiscoveryConstructor}, -#endif - {&kDNSSERVICEINFO_CID, false, nullptr, nsDNSServiceInfoConstructor}, - {nullptr}}; - -static const mozilla::Module::ContractIDEntry - knsDNSServiceDiscoveryContracts[] = { -#ifdef ENABLE_DNS_SERVICE_DISCOVERY - {DNSSERVICEDISCOVERY_CONTRACT_ID, &kDNSSERVICEDISCOVERY_CID}, -#endif - {DNSSERVICEINFO_CONTRACT_ID, &kDNSSERVICEINFO_CID}, - {nullptr}}; - -static const mozilla::Module::CategoryEntry knsDNSServiceDiscoveryCategories[] = - {{nullptr}}; - -static const mozilla::Module knsDNSServiceDiscoveryModule = { - mozilla::Module::kVersion, knsDNSServiceDiscoveryCIDs, - knsDNSServiceDiscoveryContracts, knsDNSServiceDiscoveryCategories}; - -NSMODULE_DEFN(nsDNSServiceDiscoveryModule) = &knsDNSServiceDiscoveryModule; diff --git a/netwerk/protocol/gio/components.conf b/netwerk/protocol/gio/components.conf new file mode 100644 index 0000000000000..a8b9a50fb17e0 --- /dev/null +++ b/netwerk/protocol/gio/components.conf @@ -0,0 +1,13 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +Classes = [ + { + 'cid': '{ee706783-3af8-4d19-9e84-e2ebfe213480}', + 'contract_ids': ['@mozilla.org/network/protocol;1?name=moz-gio'], + 'type': 'nsGIOProtocolHandler', + }, +] diff --git a/netwerk/protocol/gio/moz.build b/netwerk/protocol/gio/moz.build index 7a45898537caa..268d125dd3fcf 100644 --- a/netwerk/protocol/gio/moz.build +++ b/netwerk/protocol/gio/moz.build @@ -8,6 +8,10 @@ SOURCES += [ 'nsGIOProtocolHandler.cpp', ] +XPCOM_MANIFESTS += [ + 'components.conf', +] + FINAL_LIBRARY = 'xul' CXXFLAGS += CONFIG['TK_CFLAGS'] diff --git a/netwerk/protocol/gio/nsGIOProtocolHandler.cpp b/netwerk/protocol/gio/nsGIOProtocolHandler.cpp index 2640d644bfecc..a04387e64b95b 100644 --- a/netwerk/protocol/gio/nsGIOProtocolHandler.cpp +++ b/netwerk/protocol/gio/nsGIOProtocolHandler.cpp @@ -7,7 +7,7 @@ * This code is based on original Mozilla gnome-vfs extension. It implements * input stream provided by GVFS/GIO. */ -#include "mozilla/ModuleUtils.h" +#include "mozilla/Components.h" #include "mozilla/NullPrincipal.h" #include "nsIPrefService.h" #include "nsIPrefBranch.h" @@ -32,6 +32,8 @@ #include #include +using namespace mozilla; + #define MOZ_GIO_SCHEME "moz-gio" #define MOZ_GIO_SUPPORTED_PROTOCOLS "network.gio.supported-protocols" @@ -845,6 +847,14 @@ class nsGIOProtocolHandler final : public nsIProtocolHandler, NS_IMPL_ISUPPORTS(nsGIOProtocolHandler, nsIProtocolHandler, nsIObserver) +NS_IMPL_COMPONENT_FACTORY(nsGIOProtocolHandler) { + auto inst = MakeRefPtr(); + if (NS_SUCCEEDED(inst->Init())) { + return inst.forget().downcast(); + } + return nullptr; +} + nsresult nsGIOProtocolHandler::Init() { nsCOMPtr prefs = do_GetService(NS_PREFSERVICE_CONTRACTID); if (prefs) { @@ -1008,30 +1018,3 @@ nsGIOProtocolHandler::Observe(nsISupports *aSubject, const char *aTopic, } return NS_OK; } - -//----------------------------------------------------------------------------- - -#define NS_GIOPROTOCOLHANDLER_CID \ - { /* ee706783-3af8-4d19-9e84-e2ebfe213480 */ \ - 0xee706783, 0x3af8, 0x4d19, { \ - 0x9e, 0x84, 0xe2, 0xeb, 0xfe, 0x21, 0x34, 0x80 \ - } \ - } - -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsGIOProtocolHandler, Init) -NS_DEFINE_NAMED_CID(NS_GIOPROTOCOLHANDLER_CID); - -static const mozilla::Module::CIDEntry kVFSCIDs[] = { - {&kNS_GIOPROTOCOLHANDLER_CID, false, nullptr, - nsGIOProtocolHandlerConstructor}, - {nullptr}}; - -static const mozilla::Module::ContractIDEntry kVFSContracts[] = { - {NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX MOZ_GIO_SCHEME, - &kNS_GIOPROTOCOLHANDLER_CID}, - {nullptr}}; - -static const mozilla::Module kVFSModule = {mozilla::Module::kVersion, kVFSCIDs, - kVFSContracts}; - -NSMODULE_DEFN(nsGIOModule) = &kVFSModule; diff --git a/parser/htmlparser/components.conf b/parser/htmlparser/components.conf new file mode 100644 index 0000000000000..bf00428c40559 --- /dev/null +++ b/parser/htmlparser/components.conf @@ -0,0 +1,20 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +Headers = [ + 'nsHTMLTags.h', +] + +UnloadFunc = 'nsHTMLTags::ReleaseTable' + +Classes = [ + { + 'cid': '{2ce606b0-bee6-11d1-aad9-00805f8a3e14}', + 'contract_ids': [], + 'type': 'nsParser', + 'headers': ['/parser/htmlparser/nsParser.h'], + }, +] diff --git a/parser/htmlparser/moz.build b/parser/htmlparser/moz.build index 46d61831431de..a582f967de8f1 100644 --- a/parser/htmlparser/moz.build +++ b/parser/htmlparser/moz.build @@ -46,6 +46,10 @@ UNIFIED_SOURCES += [ 'nsScannerString.cpp', ] +XPCOM_MANIFESTS += [ + 'components.conf', +] + FINAL_LIBRARY = 'xul' if CONFIG['CC_TYPE'] in ('clang', 'gcc'): diff --git a/security/manager/pki/components.conf b/security/manager/pki/components.conf new file mode 100644 index 0000000000000..4850e1f17d8d4 --- /dev/null +++ b/security/manager/pki/components.conf @@ -0,0 +1,27 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +Classes = [ + { + 'cid': '{4bfaa9f0-1dd2-11b2-afae-a82cbaa0b606}', + 'contract_ids': ['@mozilla.org/security/nsASN1Tree;1'], + 'type': 'nsNSSASN1Tree', + 'headers': ['/security/manager/pki/nsASN1Tree.h'], + }, + { + 'cid': '{518e071f-1dd2-11b2-937e-c45f14def778}', + 'contract_ids': [ + '@mozilla.org/nsCertificateDialogs;1', + '@mozilla.org/nsClientAuthDialogs;1', + '@mozilla.org/nsGeneratingKeypairInfoDialogs;1', + '@mozilla.org/nsTokenDialogs;1', + '@mozilla.org/nsTokenPasswordDialogs;1', + ], + 'type': 'nsNSSDialogs', + 'headers': ['/security/manager/pki/nsNSSDialogs.h'], + 'init_method': 'Init', + }, +] diff --git a/security/manager/pki/moz.build b/security/manager/pki/moz.build index 7c3081d4ca613..93e5205f3a401 100644 --- a/security/manager/pki/moz.build +++ b/security/manager/pki/moz.build @@ -16,7 +16,10 @@ UNIFIED_SOURCES += [ 'nsASN1Tree.cpp', 'nsNSSDialogHelper.cpp', 'nsNSSDialogs.cpp', - 'nsPKIModule.cpp', +] + +XPCOM_MANIFESTS += [ + 'components.conf', ] LOCAL_INCLUDES += [ diff --git a/security/manager/pki/nsPKIModule.cpp b/security/manager/pki/nsPKIModule.cpp deleted file mode 100644 index ca081ad09dad9..0000000000000 --- a/security/manager/pki/nsPKIModule.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "mozilla/ModuleUtils.h" -#include "nsASN1Tree.h" -#include "nsNSSDialogs.h" - -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsNSSDialogs, Init) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsNSSASN1Tree) - -NS_DEFINE_NAMED_CID(NS_NSSDIALOGS_CID); -NS_DEFINE_NAMED_CID(NS_NSSASN1OUTINER_CID); - -static const mozilla::Module::CIDEntry kPKICIDs[] = { - {&kNS_NSSDIALOGS_CID, false, nullptr, nsNSSDialogsConstructor}, - {&kNS_NSSASN1OUTINER_CID, false, nullptr, nsNSSASN1TreeConstructor}, - {nullptr}}; - -static const mozilla::Module::ContractIDEntry kPKIContracts[] = { - {NS_TOKENPASSWORDSDIALOG_CONTRACTID, &kNS_NSSDIALOGS_CID}, - {NS_CERTIFICATEDIALOGS_CONTRACTID, &kNS_NSSDIALOGS_CID}, - {NS_CLIENTAUTHDIALOGS_CONTRACTID, &kNS_NSSDIALOGS_CID}, - {NS_TOKENDIALOGS_CONTRACTID, &kNS_NSSDIALOGS_CID}, - {NS_GENERATINGKEYPAIRINFODIALOGS_CONTRACTID, &kNS_NSSDIALOGS_CID}, - {NS_ASN1TREE_CONTRACTID, &kNS_NSSASN1OUTINER_CID}, - {nullptr}}; - -static const mozilla::Module kPKIModule = {mozilla::Module::kVersion, kPKICIDs, - kPKIContracts}; - -NSMODULE_DEFN(PKI) = &kPKIModule; diff --git a/security/sandbox/common/SandboxSettings.cpp b/security/sandbox/common/SandboxSettings.cpp index 11c55d3cdb20a..7e437953e2645 100644 --- a/security/sandbox/common/SandboxSettings.cpp +++ b/security/sandbox/common/SandboxSettings.cpp @@ -6,11 +6,13 @@ #include "mozISandboxSettings.h" -#include "mozilla/ModuleUtils.h" +#include "mozilla/Components.h" #include "mozilla/Preferences.h" #include "prenv.h" +using namespace mozilla; + namespace mozilla { int GetEffectiveContentSandboxLevel() { @@ -72,20 +74,9 @@ NS_IMETHODIMP SandboxSettings::GetEffectiveContentSandboxLevel( return NS_OK; } -NS_GENERIC_FACTORY_CONSTRUCTOR(SandboxSettings) - -NS_DEFINE_NAMED_CID(MOZ_SANDBOX_SETTINGS_CID); - -static const mozilla::Module::CIDEntry kSandboxSettingsCIDs[] = { - {&kMOZ_SANDBOX_SETTINGS_CID, false, nullptr, SandboxSettingsConstructor}, - {nullptr}}; - -static const mozilla::Module::ContractIDEntry kSandboxSettingsContracts[] = { - {MOZ_SANDBOX_SETTINGS_CONTRACTID, &kMOZ_SANDBOX_SETTINGS_CID}, {nullptr}}; - -static const mozilla::Module kSandboxSettingsModule = { - mozilla::Module::kVersion, kSandboxSettingsCIDs, kSandboxSettingsContracts}; +} // namespace mozilla -NSMODULE_DEFN(SandboxSettingsModule) = &kSandboxSettingsModule; -} // namespace mozilla +NS_IMPL_COMPONENT_FACTORY(mozISandboxSettings) { + return MakeAndAddRef().downcast(); +} diff --git a/security/sandbox/common/components.conf b/security/sandbox/common/components.conf new file mode 100644 index 0000000000000..fe8b07ca9699a --- /dev/null +++ b/security/sandbox/common/components.conf @@ -0,0 +1,13 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +Classes = [ + { + 'cid': '{5516303d-9007-45a0-94b9-940ef134a6e2}', + 'contract_ids': ['@mozilla.org/sandbox/sandbox-settings;1'], + 'type': 'mozISandboxSettings', + }, +] diff --git a/security/sandbox/common/moz.build b/security/sandbox/common/moz.build index a2fcba4cad22d..10c1cf63f8f7d 100644 --- a/security/sandbox/common/moz.build +++ b/security/sandbox/common/moz.build @@ -9,6 +9,10 @@ with Files('**'): UNIFIED_SOURCES += ['SandboxSettings.cpp'] +XPCOM_MANIFESTS += [ + 'components.conf', +] + XPIDL_SOURCES += [ 'mozISandboxSettings.idl', ] diff --git a/security/sandbox/linux/reporter/SandboxReporterWrappers.cpp b/security/sandbox/linux/reporter/SandboxReporterWrappers.cpp index 4db5b3a31915b..d2d64037f452e 100644 --- a/security/sandbox/linux/reporter/SandboxReporterWrappers.cpp +++ b/security/sandbox/linux/reporter/SandboxReporterWrappers.cpp @@ -10,12 +10,14 @@ #include #include "mozilla/Assertions.h" -#include "mozilla/ModuleUtils.h" +#include "mozilla/Components.h" #include "nsCOMPtr.h" #include "nsPrintfCString.h" #include "nsTArray.h" #include "nsXULAppAPI.h" +using namespace mozilla; + namespace mozilla { class SandboxReportWrapper final : public mozISandboxReport { @@ -181,21 +183,8 @@ NS_IMETHODIMP SandboxReporterWrapper::Snapshot( return NS_OK; } -NS_GENERIC_FACTORY_CONSTRUCTOR(SandboxReporterWrapper) - -NS_DEFINE_NAMED_CID(MOZ_SANDBOX_REPORTER_CID); - -static const mozilla::Module::CIDEntry kSandboxReporterCIDs[] = { - {&kMOZ_SANDBOX_REPORTER_CID, false, nullptr, - SandboxReporterWrapperConstructor}, - {nullptr}}; - -static const mozilla::Module::ContractIDEntry kSandboxReporterContracts[] = { - {MOZ_SANDBOX_REPORTER_CONTRACTID, &kMOZ_SANDBOX_REPORTER_CID}, {nullptr}}; - -static const mozilla::Module kSandboxReporterModule = { - mozilla::Module::kVersion, kSandboxReporterCIDs, kSandboxReporterContracts}; - -NSMODULE_DEFN(SandboxReporterModule) = &kSandboxReporterModule; - } // namespace mozilla + +NS_IMPL_COMPONENT_FACTORY(mozISandboxReporter) { + return MakeAndAddRef().downcast(); +} diff --git a/security/sandbox/linux/reporter/components.conf b/security/sandbox/linux/reporter/components.conf new file mode 100644 index 0000000000000..7bd278f3498e4 --- /dev/null +++ b/security/sandbox/linux/reporter/components.conf @@ -0,0 +1,13 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +Classes = [ + { + 'cid': '{5118a6f9-2493-4f97-9552-620663e03cb3}', + 'contract_ids': ['@mozilla.org/sandbox/syscall-reporter;1'], + 'type': 'mozISandboxReporter', + }, +] diff --git a/security/sandbox/linux/reporter/moz.build b/security/sandbox/linux/reporter/moz.build index 5244b494d8fc7..0a9c5cf3de500 100644 --- a/security/sandbox/linux/reporter/moz.build +++ b/security/sandbox/linux/reporter/moz.build @@ -14,6 +14,10 @@ SOURCES += [ 'SandboxReporterWrappers.cpp', ] +XPCOM_MANIFESTS += [ + 'components.conf', +] + LOCAL_INCLUDES += [ '/security/sandbox/linux', # SandboxLogging.h ] diff --git a/services/crypto/component/IdentityCryptoService.cpp b/services/crypto/component/IdentityCryptoService.cpp index 11668c579ec46..de1f7032753de 100644 --- a/services/crypto/component/IdentityCryptoService.cpp +++ b/services/crypto/component/IdentityCryptoService.cpp @@ -5,7 +5,6 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "nsIIdentityCryptoService.h" -#include "mozilla/ModuleUtils.h" #include "nsServiceManagerUtils.h" #include "nsIThread.h" #include "nsThreadUtils.h" @@ -14,6 +13,7 @@ #include "nsString.h" #include "mozilla/ArrayUtils.h" // ArrayLength #include "mozilla/Base64.h" +#include "mozilla/Components.h" #include "ScopedNSSTypes.h" #include "NSSErrorsService.h" @@ -449,31 +449,14 @@ SignRunnable::Run() { return NS_OK; } +} // unnamed namespace // XPCOM module registration -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(IdentityCryptoService, Init) - -#define NS_IDENTITYCRYPTOSERVICE_CID \ - { \ - 0xbea13a3a, 0x44e8, 0x4d7f, { \ - 0xa0, 0xa2, 0x2c, 0x67, 0xf8, 0x4e, 0x3a, 0x97 \ - } \ +NS_IMPL_COMPONENT_FACTORY(nsIIdentityCryptoService) { + auto inst = MakeRefPtr(); + if (NS_SUCCEEDED(inst->Init())) { + return inst.forget().downcast(); } - -NS_DEFINE_NAMED_CID(NS_IDENTITYCRYPTOSERVICE_CID); - -const mozilla::Module::CIDEntry kCIDs[] = { - {&kNS_IDENTITYCRYPTOSERVICE_CID, false, nullptr, - IdentityCryptoServiceConstructor}, - {nullptr}}; - -const mozilla::Module::ContractIDEntry kContracts[] = { - {"@mozilla.org/identity/crypto-service;1", &kNS_IDENTITYCRYPTOSERVICE_CID}, - {nullptr}}; - -const mozilla::Module kModule = {mozilla::Module::kVersion, kCIDs, kContracts}; - -} // unnamed namespace - -NSMODULE_DEFN(identity) = &kModule; + return nullptr; +} diff --git a/services/crypto/component/components.conf b/services/crypto/component/components.conf new file mode 100644 index 0000000000000..49a4b74d7a54c --- /dev/null +++ b/services/crypto/component/components.conf @@ -0,0 +1,13 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +Classes = [ + { + 'cid': '{bea13a3a-44e8-4d7f-a0a2-2c67f84e3a97}', + 'contract_ids': ['@mozilla.org/identity/crypto-service;1'], + 'type': 'nsIIdentityCryptoService', + }, +] diff --git a/services/crypto/component/moz.build b/services/crypto/component/moz.build index e91868118810a..b6db8c8fea8c7 100644 --- a/services/crypto/component/moz.build +++ b/services/crypto/component/moz.build @@ -14,4 +14,8 @@ SOURCES += [ 'IdentityCryptoService.cpp', ] +XPCOM_MANIFESTS += [ + 'components.conf', +] + FINAL_LIBRARY = 'xul' diff --git a/storage/build/components.conf b/storage/build/components.conf new file mode 100644 index 0000000000000..13eb8b4bd9def --- /dev/null +++ b/storage/build/components.conf @@ -0,0 +1,25 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +Classes = [ + { + 'cid': '{bbbb1d61-438f-4436-92ed-8308e5830fb0}', + 'contract_ids': ['@mozilla.org/storage/service;1'], + 'singleton': True, + 'type': 'mozilla::storage::Service', + 'headers': ['/storage/mozStorageService.h'], + 'constructor': 'mozilla::storage::Service::getSingleton', + }, + { + 'cid': '{3b667ee0-d2da-4ccc-9c3d-95f2ca6a8b4c}', + 'contract_ids': ['@mozilla.org/storage/vacuum;1'], + 'singleton': True, + 'type': 'mozilla::storage::VacuumManager', + 'headers': ['/storage/VacuumManager.h'], + 'constructor': 'mozilla::storage::VacuumManager::getSingleton', + 'categories': {'idle-daily': 'MozStorage Vacuum Manager'}, + }, +] diff --git a/storage/build/moz.build b/storage/build/moz.build index 284cd7e3f574b..27c61326d3d3b 100644 --- a/storage/build/moz.build +++ b/storage/build/moz.build @@ -8,14 +8,10 @@ EXPORTS += [ 'mozStorageCID.h', ] -SOURCES += [ - 'mozStorageModule.cpp', +XPCOM_MANIFESTS += [ + 'components.conf', ] FINAL_LIBRARY = 'xul' -LOCAL_INCLUDES += [ - '..', -] - CXXFLAGS += CONFIG['SQLITE_CFLAGS'] diff --git a/storage/build/mozStorageModule.cpp b/storage/build/mozStorageModule.cpp deleted file mode 100644 index e57c7e4a80a42..0000000000000 --- a/storage/build/mozStorageModule.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsCOMPtr.h" -#include "mozilla/ModuleUtils.h" - -#include "mozStorageService.h" -#include "mozStorageConnection.h" -#include "VacuumManager.h" - -#include "mozStorageCID.h" - -namespace mozilla { -namespace storage { - -NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(Service, Service::getSingleton) -NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(VacuumManager, - VacuumManager::getSingleton) - -} // namespace storage -} // namespace mozilla - -NS_DEFINE_NAMED_CID(MOZ_STORAGE_SERVICE_CID); -NS_DEFINE_NAMED_CID(VACUUMMANAGER_CID); - -static const mozilla::Module::CIDEntry kStorageCIDs[] = { - {&kMOZ_STORAGE_SERVICE_CID, false, nullptr, - mozilla::storage::ServiceConstructor}, - {&kVACUUMMANAGER_CID, false, nullptr, - mozilla::storage::VacuumManagerConstructor}, - {nullptr}}; - -static const mozilla::Module::ContractIDEntry kStorageContracts[] = { - {MOZ_STORAGE_SERVICE_CONTRACTID, &kMOZ_STORAGE_SERVICE_CID}, - {VACUUMMANAGER_CONTRACTID, &kVACUUMMANAGER_CID}, - {nullptr}}; - -static const mozilla::Module::CategoryEntry kStorageCategories[] = { - {"idle-daily", "MozStorage Vacuum Manager", VACUUMMANAGER_CONTRACTID}, - {nullptr}}; - -static const mozilla::Module kStorageModule = {mozilla::Module::kVersion, - kStorageCIDs, kStorageContracts, - kStorageCategories}; - -NSMODULE_DEFN(mozStorageModule) = &kStorageModule; diff --git a/testing/xpcshell/head.js b/testing/xpcshell/head.js index 0eeb0d289bed1..8a1fa04854940 100644 --- a/testing/xpcshell/head.js +++ b/testing/xpcshell/head.js @@ -231,6 +231,11 @@ function _do_quit() { _quit = true; } +// This is useless, except to the extent that it has the side-effect of +// initializing the widget module, which some tests unfortunately +// accidentally rely on. +void Cc["@mozilla.org/widget/transferable;1"].createInstance(); + /** * Overrides idleService with a mock. Idle is commonly used for maintenance * tasks, thus if a test uses a service that requires the idle service, it will @@ -252,12 +257,6 @@ var _fakeIdleService = { activate: function FIS_activate() { if (!this.originalCID) { - // This is useless, except to the extent that it has the - // side-effect of initializing the widget module, which some - // callers unfortunately accidentally rely on. - void Components.manager.getClassObject(Cc[this.contractID], - Ci.nsIFactory); - this.originalCID = this.registrar.contractIDToCID(this.contractID); // Replace with the mock. this.registrar.registerFactory(this.CID, "Fake Idle Service", diff --git a/toolkit/components/mozintl/components.conf b/toolkit/components/mozintl/components.conf index 7f9aebf54558e..521ff211b97a1 100644 --- a/toolkit/components/mozintl/components.conf +++ b/toolkit/components/mozintl/components.conf @@ -11,6 +11,7 @@ Classes = [ 'type': 'mozilla::MozIntlHelper', 'headers': ['/toolkit/components/mozintl/MozIntlHelper.h'], }, + { 'cid': '{35ec195a-e8d0-4300-83af-c8a2cc84b4a3}', 'contract_ids': ['@mozilla.org/mozintl;1'], diff --git a/toolkit/components/mozintl/moz.build b/toolkit/components/mozintl/moz.build index 92b1fc54b28fc..db6a1fd744efe 100644 --- a/toolkit/components/mozintl/moz.build +++ b/toolkit/components/mozintl/moz.build @@ -28,4 +28,8 @@ XPCOM_MANIFESTS += [ 'components.conf', ] +XPCOM_MANIFESTS += [ + 'components.conf', +] + FINAL_LIBRARY = 'xul' diff --git a/toolkit/components/places/moz.build b/toolkit/components/places/moz.build index 05db20f0f5644..6c45b5860523b 100644 --- a/toolkit/components/places/moz.build +++ b/toolkit/components/places/moz.build @@ -83,6 +83,10 @@ if CONFIG['MOZ_PLACES']: 'components.conf', ] + XPCOM_MANIFESTS += [ + 'components.conf', + ] + FINAL_LIBRARY = 'xul' include('/ipc/chromium/chromium-config.mozbuild') diff --git a/toolkit/components/resistfingerprinting/LanguagePrompt.jsm b/toolkit/components/resistfingerprinting/LanguagePrompt.jsm deleted file mode 100644 index 3f90244ccc4bf..0000000000000 --- a/toolkit/components/resistfingerprinting/LanguagePrompt.jsm +++ /dev/null @@ -1,201 +0,0 @@ -// -*- indent-tabs-mode: nil; js-indent-level: 2 -*- -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. */ -"use strict"; - -var EXPORTED_SYMBOLS = ["LanguagePrompt"]; - -const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm"); - -const kPrefResistFingerprinting = "privacy.resistFingerprinting"; -const kPrefSpoofEnglish = "privacy.spoof_english"; -const kTopicHttpOnModifyRequest = "http-on-modify-request"; - -class _LanguagePrompt { - constructor() { - this._initialized = false; - } - - init() { - if (this._initialized) { - return; - } - this._initialized = true; - - Services.prefs.addObserver(kPrefResistFingerprinting, this); - this._handleResistFingerprintingChanged(); - } - - uninit() { - if (!this._initialized) { - return; - } - this._initialized = false; - - Services.prefs.removeObserver(kPrefResistFingerprinting, this); - this._removeObservers(); - } - - observe(subject, topic, data) { - switch (topic) { - case "nsPref:changed": - this._handlePrefChanged(data); - break; - case kTopicHttpOnModifyRequest: - this._handleHttpOnModifyRequest(subject, data); - break; - default: - break; - } - } - - _removeObservers() { - try { - Services.pref.removeObserver(kPrefSpoofEnglish, this); - } catch (e) { - // do nothing - } - try { - Services.obs.removeObserver(this, kTopicHttpOnModifyRequest); - } catch (e) { - // do nothing - } - } - - _shouldPromptForLanguagePref() { - return (Services.locale.appLocaleAsLangTag.substr(0, 2) !== "en") - && (Services.prefs.getIntPref(kPrefSpoofEnglish) === 0); - } - - _handlePrefChanged(data) { - switch (data) { - case kPrefResistFingerprinting: - this._handleResistFingerprintingChanged(); - break; - case kPrefSpoofEnglish: - this._handleSpoofEnglishChanged(); - break; - default: - break; - } - } - - _handleResistFingerprintingChanged() { - if (Services.prefs.getBoolPref(kPrefResistFingerprinting)) { - Services.prefs.addObserver(kPrefSpoofEnglish, this); - if (this._shouldPromptForLanguagePref()) { - Services.obs.addObserver(this, kTopicHttpOnModifyRequest); - } - } else { - this._removeObservers(); - } - } - - _handleSpoofEnglishChanged() { - switch (Services.prefs.getIntPref(kPrefSpoofEnglish)) { - case 0: // will prompt - // This should only happen when turning privacy.resistFingerprinting off. - // Works like disabling accept-language spoofing. - case 1: // don't spoof - if (Services.prefs.prefHasUserValue("javascript.use_us_english_locale")) { - Services.prefs.clearUserPref("javascript.use_us_english_locale"); - } - // We don't reset intl.accept_languages. Instead, setting - // privacy.spoof_english to 1 allows user to change preferred language - // settings through Preferences UI. - break; - case 2: // spoof - Services.prefs.setCharPref("intl.accept_languages", "en-US, en"); - Services.prefs.setBoolPref("javascript.use_us_english_locale", true); - break; - default: - break; - } - } - - _handleHttpOnModifyRequest(subject, data) { - // If we are loading an HTTP page from content, show the - // "request English language web pages?" prompt. - let httpChannel; - try { - httpChannel = subject.QueryInterface(Ci.nsIHttpChannel); - } catch (e) { - return; - } - - if (!httpChannel) { - return; - } - - let notificationCallbacks = httpChannel.notificationCallbacks; - if (!notificationCallbacks) { - return; - } - - let loadContext = notificationCallbacks.getInterface(Ci.nsILoadContext); - if (!loadContext || !loadContext.isContent) { - return; - } - - if (!subject.URI.schemeIs("http") && !subject.URI.schemeIs("https")) { - return; - } - // The above QI did not throw, the scheme is http[s], and we know the - // load context is content, so we must have a true HTTP request from content. - // Stop the observer and display the prompt if another window has - // not already done so. - Services.obs.removeObserver(this, kTopicHttpOnModifyRequest); - - if (!this._shouldPromptForLanguagePref()) { - return; - } - - this._promptForLanguagePreference(); - - // The Accept-Language header for this request was set when the - // channel was created. Reset it to match the value that will be - // used for future requests. - let val = this._getCurrentAcceptLanguageValue(subject.URI); - if (val) { - httpChannel.setRequestHeader("Accept-Language", val, false); - } - } - - _promptForLanguagePreference() { - // Display two buttons, both with string titles. - let flags = Services.prompt.STD_YES_NO_BUTTONS; - let brandBundle = Services.strings.createBundle( - "chrome://branding/locale/brand.properties"); - let brandShortName = brandBundle.GetStringFromName("brandShortName"); - let navigatorBundle = Services.strings.createBundle( - "chrome://browser/locale/browser.properties"); - let message = navigatorBundle.formatStringFromName( - "privacy.spoof_english", [brandShortName], 1); - let response = Services.prompt.confirmEx( - null, "", message, flags, null, null, null, null, {value: false}); - - // Update preferences to reflect their response and to prevent the prompt - // from being displayed again. - Services.prefs.setIntPref(kPrefSpoofEnglish, (response == 0) ? 2 : 1); - } - - _getCurrentAcceptLanguageValue(uri) { - let channel = Services.io.newChannelFromURI2( - uri, - null, // aLoadingNode - Services.scriptSecurityManager.getSystemPrincipal(), - null, // aTriggeringPrincipal - Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL, - Ci.nsIContentPolicy.TYPE_OTHER); - let httpChannel; - try { - httpChannel = channel.QueryInterface(Ci.nsIHttpChannel); - } catch (e) { - return null; - } - return httpChannel.getRequestHeader("Accept-Language"); - } -} - -let LanguagePrompt = new _LanguagePrompt(); diff --git a/toolkit/components/resistfingerprinting/RFPHelper.jsm b/toolkit/components/resistfingerprinting/RFPHelper.jsm new file mode 100644 index 0000000000000..010443f6b33b6 --- /dev/null +++ b/toolkit/components/resistfingerprinting/RFPHelper.jsm @@ -0,0 +1,531 @@ +// -*- indent-tabs-mode: nil; js-indent-level: 2 -*- +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ +"use strict"; + +var EXPORTED_SYMBOLS = ["RFPHelper"]; + +const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm"); +const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); + +const kPrefResistFingerprinting = "privacy.resistFingerprinting"; +const kPrefSpoofEnglish = "privacy.spoof_english"; +const kTopicHttpOnModifyRequest = "http-on-modify-request"; + +const kPrefLetterboxing = "privacy.resistFingerprinting.letterboxing"; +const kPrefLetterboxingDimensions = + "privacy.resistFingerprinting.letterboxing.dimensions"; +const kPrefLetterboxingTesting = + "privacy.resistFingerprinting.letterboxing.testing"; +const kTopicDOMWindowOpened = "domwindowopened"; +const kEventLetterboxingSizeUpdate = "Letterboxing:ContentSizeUpdated"; + +const kDefaultWidthStepping = 200; +const kDefaultHeightStepping = 100; + +var logConsole; +function log(msg) { + if (!logConsole) { + logConsole = console.createInstance({ + prefix: "RFPHelper.jsm", + maxLogLevelPref: "privacy.resistFingerprinting.jsmloglevel", + }); + } + + logConsole.log(msg); +} + +class _RFPHelper { + // ============================================================================ + // Shared Setup + // ============================================================================ + constructor() { + this._initialized = false; + } + + init() { + if (this._initialized) { + return; + } + this._initialized = true; + + // Add unconditional observers + Services.prefs.addObserver(kPrefResistFingerprinting, this); + Services.prefs.addObserver(kPrefLetterboxing, this); + XPCOMUtils.defineLazyPreferenceGetter(this, "_letterboxingDimensions", + kPrefLetterboxingDimensions, "", null, this._parseLetterboxingDimensions); + XPCOMUtils.defineLazyPreferenceGetter(this, "_isLetterboxingTesting", + kPrefLetterboxingTesting, false); + + // Add RFP and Letterboxing observers if prefs are enabled + this._handleResistFingerprintingChanged(); + this._handleLetterboxingPrefChanged(); + } + + uninit() { + if (!this._initialized) { + return; + } + this._initialized = false; + + // Remove unconditional observers + Services.prefs.removeObserver(kPrefResistFingerprinting, this); + Services.prefs.removeObserver(kPrefLetterboxing, this); + // Remove the RFP observers, swallowing exceptions if they weren't present + this._removeRFPObservers(); + } + + observe(subject, topic, data) { + switch (topic) { + case "nsPref:changed": + this._handlePrefChanged(data); + break; + case kTopicHttpOnModifyRequest: + this._handleHttpOnModifyRequest(subject, data); + break; + case kTopicDOMWindowOpened: + // We attach to the newly created window by adding tabsProgressListener + // and event listener on it. We listen for new tabs being added or + // the change of the content principal and apply margins accordingly. + this._handleDOMWindowOpened(subject); + break; + default: + break; + } + } + + handleEvent(aMessage) { + switch (aMessage.type) { + case "TabOpen": + { + let tab = aMessage.target; + this._addOrClearContentMargin(tab.linkedBrowser); + break; + } + default: + break; + } + } + + receiveMessage(aMessage) { + switch (aMessage.name) { + case kEventLetterboxingSizeUpdate: + let win = aMessage.target.ownerGlobal; + this._updateMarginsForTabsInWindow(win); + break; + default: + break; + } + } + + _handlePrefChanged(data) { + switch (data) { + case kPrefResistFingerprinting: + this._handleResistFingerprintingChanged(); + break; + case kPrefSpoofEnglish: + this._handleSpoofEnglishChanged(); + break; + case kPrefLetterboxing: + this._handleLetterboxingPrefChanged(); + break; + default: + break; + } + } + + // ============================================================================ + // Language Prompt + // ============================================================================ + _addRFPObservers() { + Services.prefs.addObserver(kPrefSpoofEnglish, this); + if (this._shouldPromptForLanguagePref()) { + Services.obs.addObserver(this, kTopicHttpOnModifyRequest); + } + } + + _removeRFPObservers() { + try { + Services.pref.removeObserver(kPrefSpoofEnglish, this); + } catch (e) { + // do nothing + } + try { + Services.obs.removeObserver(this, kTopicHttpOnModifyRequest); + } catch (e) { + // do nothing + } + } + + _handleResistFingerprintingChanged() { + if (Services.prefs.getBoolPref(kPrefResistFingerprinting)) { + this._addRFPObservers(); + } else { + this._removeRFPObservers(); + } + } + + _handleSpoofEnglishChanged() { + switch (Services.prefs.getIntPref(kPrefSpoofEnglish)) { + case 0: // will prompt + // This should only happen when turning privacy.resistFingerprinting off. + // Works like disabling accept-language spoofing. + case 1: // don't spoof + if (Services.prefs.prefHasUserValue("javascript.use_us_english_locale")) { + Services.prefs.clearUserPref("javascript.use_us_english_locale"); + } + // We don't reset intl.accept_languages. Instead, setting + // privacy.spoof_english to 1 allows user to change preferred language + // settings through Preferences UI. + break; + case 2: // spoof + Services.prefs.setCharPref("intl.accept_languages", "en-US, en"); + Services.prefs.setBoolPref("javascript.use_us_english_locale", true); + break; + default: + break; + } + } + + _shouldPromptForLanguagePref() { + return (Services.locale.appLocaleAsLangTag.substr(0, 2) !== "en") + && (Services.prefs.getIntPref(kPrefSpoofEnglish) === 0); + } + + _handleHttpOnModifyRequest(subject, data) { + // If we are loading an HTTP page from content, show the + // "request English language web pages?" prompt. + let httpChannel; + try { + httpChannel = subject.QueryInterface(Ci.nsIHttpChannel); + } catch (e) { + return; + } + + if (!httpChannel) { + return; + } + + let notificationCallbacks = httpChannel.notificationCallbacks; + if (!notificationCallbacks) { + return; + } + + let loadContext = notificationCallbacks.getInterface(Ci.nsILoadContext); + if (!loadContext || !loadContext.isContent) { + return; + } + + if (!subject.URI.schemeIs("http") && !subject.URI.schemeIs("https")) { + return; + } + // The above QI did not throw, the scheme is http[s], and we know the + // load context is content, so we must have a true HTTP request from content. + // Stop the observer and display the prompt if another window has + // not already done so. + Services.obs.removeObserver(this, kTopicHttpOnModifyRequest); + + if (!this._shouldPromptForLanguagePref()) { + return; + } + + this._promptForLanguagePreference(); + + // The Accept-Language header for this request was set when the + // channel was created. Reset it to match the value that will be + // used for future requests. + let val = this._getCurrentAcceptLanguageValue(subject.URI); + if (val) { + httpChannel.setRequestHeader("Accept-Language", val, false); + } + } + + _promptForLanguagePreference() { + // Display two buttons, both with string titles. + let flags = Services.prompt.STD_YES_NO_BUTTONS; + let brandBundle = Services.strings.createBundle( + "chrome://branding/locale/brand.properties"); + let brandShortName = brandBundle.GetStringFromName("brandShortName"); + let navigatorBundle = Services.strings.createBundle( + "chrome://browser/locale/browser.properties"); + let message = navigatorBundle.formatStringFromName( + "privacy.spoof_english", [brandShortName], 1); + let response = Services.prompt.confirmEx( + null, "", message, flags, null, null, null, null, {value: false}); + + // Update preferences to reflect their response and to prevent the prompt + // from being displayed again. + Services.prefs.setIntPref(kPrefSpoofEnglish, (response == 0) ? 2 : 1); + } + + _getCurrentAcceptLanguageValue(uri) { + let channel = Services.io.newChannelFromURI2( + uri, + null, // aLoadingNode + Services.scriptSecurityManager.getSystemPrincipal(), + null, // aTriggeringPrincipal + Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL, + Ci.nsIContentPolicy.TYPE_OTHER); + let httpChannel; + try { + httpChannel = channel.QueryInterface(Ci.nsIHttpChannel); + } catch (e) { + return null; + } + return httpChannel.getRequestHeader("Accept-Language"); + } + + // ============================================================================== + // Letterboxing + // ============================================================================ + /** + * We use the TabsProgressListener to catch the change of the content + * principal. We would clear the margins around the content viewport if + * it is the system principal. + */ + onLocationChange(aBrowser) { + this._addOrClearContentMargin(aBrowser); + } + + _handleLetterboxingPrefChanged() { + if (Services.prefs.getBoolPref(kPrefLetterboxing, false)) { + Services.ww.registerNotification(this); + this._attachAllWindows(); + } else { + this._detachAllWindows(); + Services.ww.unregisterNotification(this); + } + } + + // The function to parse the dimension set from the pref value. The pref value + // should be formated as 'width1xheight1, width2xheight2, ...'. For + // example, '100x100, 200x200, 400x200 ...'. + _parseLetterboxingDimensions(aPrefValue) { + if (!aPrefValue || !aPrefValue.match(/^(?:\d+x\d+,\s*)*(?:\d+x\d+)$/)) { + if (aPrefValue) { + Cu.reportError(`Invalid pref value for ${kPrefLetterboxingDimensions}: ${aPrefValue}`); + } + return []; + } + + return aPrefValue.split(",").map(item => { + let sizes = item.split("x").map(size => parseInt(size, 10)); + + return { + width: sizes[0], + height: sizes[1], + }; + }); + } + + _addOrClearContentMargin(aBrowser) { + let tab = aBrowser.getTabBrowser() + .getTabForBrowser(aBrowser); + + // We won't do anything for lazy browsers. + if (!aBrowser.isConnected) { + return; + } + + // We should apply no margin around an empty tab or a tab with system + // principal. + if (tab.isEmpty || aBrowser.contentPrincipal.isSystemPrincipal) { + this._clearContentViewMargin(aBrowser); + } else { + this._roundContentView(aBrowser); + } + } + + /** + * The function will round the given browser by adding margins around the + * content viewport. + */ + async _roundContentView(aBrowser) { + let logId = Math.random(); + log("_roundContentView[" + logId + "]"); + let win = aBrowser.ownerGlobal; + let browserContainer = aBrowser.getTabBrowser() + .getBrowserContainer(aBrowser); + + let {contentWidth, contentHeight, containerWidth, containerHeight} = + await win.promiseDocumentFlushed(() => { + let contentWidth = aBrowser.clientWidth; + let contentHeight = aBrowser.clientHeight; + let containerWidth = browserContainer.clientWidth; + let containerHeight = browserContainer.clientHeight; + + return { + contentWidth, + contentHeight, + containerWidth, + containerHeight, + }; + }); + + log("_roundContentView[" + logId + "] contentWidth=" + contentWidth + " contentHeight=" + contentHeight + + " containerWidth=" + containerWidth + " containerHeight=" + containerHeight + " "); + + let calcMargins = (aWidth, aHeight) => { + let result; + log("_roundContentView[" + logId + "] calcMargins(" + aWidth + ", " + aHeight + ")"); + // If the set is empty, we will round the content with the default + // stepping size. + if (!this._letterboxingDimensions.length) { + result = { + width: (aWidth % kDefaultWidthStepping) / 2, + height: (aHeight % kDefaultHeightStepping) / 2, + }; + log("_roundContentView[" + logId + "] calcMargins(" + aWidth + ", " + aHeight + ") = " + result.width + " x " + result.height); + return result; + } + + let matchingArea = aWidth * aHeight; + let minWaste = Number.MAX_SAFE_INTEGER; + let targetDimensions = undefined; + + // Find the desired dimensions which waste the least content area. + for (let dim of this._letterboxingDimensions) { + // We don't need to consider the dimensions which cannot fit into the + // real content size. + if (dim.width > aWidth || dim.height > aHeight) { + continue; + } + + let waste = matchingArea - dim.width * dim.height; + + if (waste >= 0 && waste < minWaste) { + targetDimensions = dim; + minWaste = waste; + } + } + + // If we cannot find any dimensions match to the real content window, this + // means the content area is smaller the smallest size in the set. In this + // case, we won't apply any margins. + if (!targetDimensions) { + result = { + width: 0, + height: 0, + }; + } else { + result = { + width: (aWidth - targetDimensions.width) / 2, + height: (aHeight - targetDimensions.height) / 2, + }; + } + + log("_roundContentView[" + logId + "] calcMargins(" + aWidth + ", " + aHeight + ") = " + result.width + " x " + result.height); + return result; + }; + + // Calculating the margins around the browser element in order to round the + // content viewport. We will use a 200x100 stepping if the dimension set + // is not given. + let margins = calcMargins(containerWidth, containerHeight); + + // If the size of the content is already quantized, we do nothing. + if (aBrowser.style.margin == `${margins.height}px ${margins.width}px`) { + log("_roundContentView[" + logId + "] is_rounded == true"); + if (this._isLetterboxingTesting) { + log("_roundContentView[" + logId + "] is_rounded == true test:letterboxing:update-margin-finish"); + Services.obs.notifyObservers(null, "test:letterboxing:update-margin-finish"); + } + return; + } + + win.requestAnimationFrame(() => { + log("_roundContentView[" + logId + "] setting margins to " + margins.width + " x " + margins.height); + // One cannot (easily) control the color of a margin unfortunately. + // An initial attempt to use a border instead of a margin resulted + // in offset event dispatching; so for now we use a colorless margin. + aBrowser.style.margin = `${margins.height}px ${margins.width}px`; + }); + } + + _clearContentViewMargin(aBrowser) { + aBrowser.ownerGlobal.requestAnimationFrame(() => { + aBrowser.style.margin = ""; + }); + } + + _updateMarginsForTabsInWindow(aWindow) { + let tabBrowser = aWindow.gBrowser; + + for (let tab of tabBrowser.tabs) { + let browser = tab.linkedBrowser; + this._addOrClearContentMargin(browser); + } + } + + _attachWindow(aWindow) { + aWindow.gBrowser + .addTabsProgressListener(this); + aWindow.addEventListener("TabOpen", this); + aWindow.messageManager + .addMessageListener(kEventLetterboxingSizeUpdate, this); + + // Rounding the content viewport. + this._updateMarginsForTabsInWindow(aWindow); + } + + _attachAllWindows() { + let windowList = Services.wm.getEnumerator("navigator:browser"); + + while (windowList.hasMoreElements()) { + let win = windowList.getNext(); + + if (win.closed || !win.gBrowser) { + continue; + } + + this._attachWindow(win); + } + } + + _detachWindow(aWindow) { + let tabBrowser = aWindow.gBrowser; + tabBrowser.removeTabsProgressListener(this); + aWindow.removeEventListener("TabOpen", this); + aWindow.messageManager + .removeMessageListener(kEventLetterboxingSizeUpdate, this); + + // Clear all margins and tooltip for all browsers. + for (let tab of tabBrowser.tabs) { + let browser = tab.linkedBrowser; + this._clearContentViewMargin(browser); + } + } + + _detachAllWindows() { + let windowList = Services.wm.getEnumerator("navigator:browser"); + + while (windowList.hasMoreElements()) { + let win = windowList.getNext(); + + if (win.closed || !win.gBrowser) { + continue; + } + + this._detachWindow(win); + } + } + + _handleDOMWindowOpened(aSubject) { + let win = aSubject.QueryInterface(Ci.nsIDOMWindow); + let self = this; + + win.addEventListener("load", () => { + // We attach to the new window when it has been loaded if the new loaded + // window is a browsing window. + if (win.document + .documentElement + .getAttribute("windowtype") !== "navigator:browser") { + return; + } + self._attachWindow(win); + }, {once: true}); + } +} + +let RFPHelper = new _RFPHelper(); diff --git a/toolkit/components/resistfingerprinting/moz.build b/toolkit/components/resistfingerprinting/moz.build index 88525f6189eb5..021f2786f9661 100644 --- a/toolkit/components/resistfingerprinting/moz.build +++ b/toolkit/components/resistfingerprinting/moz.build @@ -21,5 +21,5 @@ EXPORTS.mozilla += [ ] EXTRA_JS_MODULES += [ - 'LanguagePrompt.jsm', + 'RFPHelper.jsm', ] diff --git a/toolkit/components/satchel/moz.build b/toolkit/components/satchel/moz.build index ecdf1be5922ab..25573c454fd76 100644 --- a/toolkit/components/satchel/moz.build +++ b/toolkit/components/satchel/moz.build @@ -40,6 +40,10 @@ XPCOM_MANIFESTS += [ 'components.conf', ] +XPCOM_MANIFESTS += [ + 'components.conf', +] + FINAL_LIBRARY = 'xul' JAR_MANIFESTS += ['jar.mn'] diff --git a/toolkit/recordreplay/ipc/ParentGraphics.cpp b/toolkit/recordreplay/ipc/ParentGraphics.cpp index d37ee62a82099..8dfe9f3172b13 100644 --- a/toolkit/recordreplay/ipc/ParentGraphics.cpp +++ b/toolkit/recordreplay/ipc/ParentGraphics.cpp @@ -10,6 +10,7 @@ #include "ParentInternal.h" #include "chrome/common/mach_ipc_mac.h" +#include "mozilla/Assertions.h" #include "mozilla/ClearOnShutdown.h" #include "mozilla/StaticPtr.h" #include "mozilla/dom/TabChild.h" @@ -163,7 +164,9 @@ void UpdateGraphicsInUIProcess(const PaintMessage* aMsg) { AutoSafeJSContext cx; JSAutoRealm ar(cx, xpc::PrivilegedJunkScope()); - JSObject* bufferObject = + // Create an ArrayBuffer whose contents are the externally-provided |memory|. + JS::RootedObject bufferObject(cx); + bufferObject = JS_NewArrayBufferWithExternalContents(cx, width * height * 4, memory); MOZ_RELEASE_ASSERT(bufferObject); @@ -173,6 +176,11 @@ void UpdateGraphicsInUIProcess(const PaintMessage* aMsg) { if (NS_FAILED(gGraphics->UpdateCanvas(buffer, width, height, hadFailure))) { MOZ_CRASH("UpdateGraphicsInUIProcess"); } + + // Manually detach this ArrayBuffer once this update completes, as the + // JS_NewArrayBufferWithExternalContents API mandates. (The API also + // guarantees that this call always succeeds.) + MOZ_ALWAYS_TRUE(JS_DetachArrayBuffer(cx, bufferObject)); } static void MaybeTriggerExplicitPaint() { diff --git a/tools/profiler/core/platform.h b/tools/profiler/core/platform.h index 98c87371e8328..f02faf2822364 100644 --- a/tools/profiler/core/platform.h +++ b/tools/profiler/core/platform.h @@ -33,6 +33,8 @@ #include "mozilla/Logging.h" #include "mozilla/UniquePtr.h" +#include "nsStringFwd.h" +#include "nsTArray.h" #include #include diff --git a/tools/profiler/gecko/components.conf b/tools/profiler/gecko/components.conf new file mode 100644 index 0000000000000..1584afc25465b --- /dev/null +++ b/tools/profiler/gecko/components.conf @@ -0,0 +1,15 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +Classes = [ + { + 'cid': '{25db9b8e-8123-4de1-b66d-8bbbedf2cdf4}', + 'contract_ids': ['@mozilla.org/tools/profiler;1'], + 'type': 'nsProfiler', + 'headers': ['/tools/profiler/gecko/nsProfiler.h'], + 'init_method': 'Init', + }, +] diff --git a/tools/profiler/gecko/nsProfilerFactory.cpp b/tools/profiler/gecko/nsProfilerFactory.cpp deleted file mode 100644 index 2835555490a46..0000000000000 --- a/tools/profiler/gecko/nsProfilerFactory.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsProfiler.h" -#include "nsProfilerCIID.h" - -#include "mozilla/ModuleUtils.h" -#include "nsCOMPtr.h" - -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsProfiler, Init) - -NS_DEFINE_NAMED_CID(NS_PROFILER_CID); - -static const mozilla::Module::CIDEntry kProfilerCIDs[] = { - {&kNS_PROFILER_CID, false, nullptr, nsProfilerConstructor}, {nullptr}}; - -static const mozilla::Module::ContractIDEntry kProfilerContracts[] = { - {"@mozilla.org/tools/profiler;1", &kNS_PROFILER_CID}, {nullptr}}; - -static const mozilla::Module kProfilerModule = { - mozilla::Module::kVersion, kProfilerCIDs, kProfilerContracts}; - -NSMODULE_DEFN(nsProfilerModule) = &kProfilerModule; diff --git a/tools/profiler/moz.build b/tools/profiler/moz.build index c12ad1211dc21..018bc2201b0a4 100644 --- a/tools/profiler/moz.build +++ b/tools/profiler/moz.build @@ -30,7 +30,6 @@ if CONFIG['MOZ_GECKO_PROFILER']: 'core/ProfilerMarkerPayload.cpp', 'core/RegisteredThread.cpp', 'gecko/ChildProfilerController.cpp', - 'gecko/nsProfilerFactory.cpp', 'gecko/nsProfilerStartParams.cpp', 'gecko/ProfilerChild.cpp', 'gecko/ProfilerIOInterposeObserver.cpp', @@ -42,6 +41,10 @@ if CONFIG['MOZ_GECKO_PROFILER']: 'core/memory_hooks.cpp', # conflicts with platform.h class Thread ] + XPCOM_MANIFESTS += [ + 'gecko/components.conf', + ] + if CONFIG['OS_TARGET'] == 'Darwin': # This file cannot be built in unified mode because it includes # "nsLocalFile.h", which pulls in a system header which uses a type diff --git a/widget/moz.build b/widget/moz.build index 544974e5ce927..f3cbc6c9f15b0 100644 --- a/widget/moz.build +++ b/widget/moz.build @@ -127,6 +127,7 @@ EXPORTS += [ 'GfxInfoBase.h', 'GfxInfoCollector.h', 'InputData.h', + 'nsBaseAppShell.h', 'nsBaseDragService.h', 'nsBaseFilePicker.h', 'nsBaseScreen.h', diff --git a/widget/windows/components.conf b/widget/windows/components.conf new file mode 100644 index 0000000000000..8db66ea3a64a4 --- /dev/null +++ b/widget/windows/components.conf @@ -0,0 +1,199 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +Headers = [ + '/widget/windows/nsWidgetFactory.h', +] + +InitFunc = 'nsWidgetWindowsModuleCtor' +UnloadFunc = 'nsWidgetWindowsModuleDtor' + +Classes = [ + { + 'cid': '{c401eb80-f9ea-11d3-bb6f-e732b73ebe7c}', + 'contract_ids': ['@mozilla.org/gfx/screenmanager;1'], + 'singleton': True, + 'type': 'mozilla::widget::ScreenManager', + 'constructor': 'mozilla::widget::ScreenManager::GetAddRefedSingleton', + 'headers': ['/widget/ScreenManager.h'], + 'processes': ProcessSelector.MAIN_PROCESS_ONLY, + }, + { + 'cid': '{2d96b3df-c051-11d1-a827-0040959a28c9}', + 'contract_ids': ['@mozilla.org/widget/appshell/win;1'], + 'headers': ['/widget/windows/nsWidgetFactory.h'], + 'legacy_constructor': 'nsAppShellConstructor', + 'processes': ProcessSelector.ALLOW_IN_GPU_VR_AND_SOCKET_PROCESS, + }, + { + 'cid': '{6987230e-0098-4e78-bc5f-1493ee7519fa}', + 'contract_ids': ['@mozilla.org/widget/idleservice;1'], + 'singleton': True, + 'type': 'nsIdleServiceWin', + 'constructor': 'nsIdleServiceWin::GetInstance', + 'headers': ['/widget/windows/nsIdleServiceWin.h', 'nsIdleService.h'], + }, + { + 'cid': '{b148eed2-236d-11d3-b35c-00a0cc3c1cde}', + 'contract_ids': ['@mozilla.org/sound;1'], + 'singleton': True, + 'type': 'nsISound', + 'constructor': 'nsSound::GetInstance', + 'headers': ['/widget/windows/nsSound.h'], + 'processes': ProcessSelector.MAIN_PROCESS_ONLY, + }, + { + 'cid': '{77221d5a-1dd2-11b2-8c69-c710f15d2ed5}', + 'contract_ids': ['@mozilla.org/widget/clipboardhelper;1'], + 'type': 'nsClipboardHelper', + 'headers': ['/widget/nsClipboardHelper.h'], + }, + { + 'cid': '{b8e5bc54-a22f-4eb2-b061-24cb6d19c15f}', + 'contract_ids': ['@mozilla.org/windows-taskbar;1'], + 'type': 'mozilla::widget::WinTaskbar', + 'headers': ['/widget/windows/WinTaskbar.h'], + }, + { + 'cid': '{73a5946f-608d-454f-9d33-0b8f8c7294b6}', + 'contract_ids': ['@mozilla.org/windows-jumplistbuilder;1'], + 'type': 'mozilla::widget::JumpListBuilder', + 'headers': ['/widget/windows/JumpListBuilder.h'], + }, + { + 'cid': '{2b9a1f2c-27ce-45b6-8d4e-755d0e34f8db}', + 'contract_ids': ['@mozilla.org/windows-jumplistitem;1'], + 'type': 'mozilla::widget::JumpListItem', + 'headers': ['/widget/windows/JumpListItem.h'], + }, + { + 'cid': '{21f1f13b-f75a-42ad-867a-d91ad694447e}', + 'contract_ids': ['@mozilla.org/windows-jumplistseparator;1'], + 'type': 'mozilla::widget::JumpListSeparator', + 'headers': ['/widget/windows/JumpListItem.h'], + }, + { + 'cid': '{f72c5dc4-5a12-47be-be28-ab105f33b08f}', + 'contract_ids': ['@mozilla.org/windows-jumplistlink;1'], + 'type': 'mozilla::widget::JumpListLink', + 'headers': ['/widget/windows/JumpListItem.h'], + }, + { + 'cid': '{b16656b2-5187-498f-abf4-56346126bfdb}', + 'contract_ids': ['@mozilla.org/windows-jumplistshortcut;1'], + 'type': 'mozilla::widget::JumpListShortcut', + 'headers': ['/widget/windows/JumpListItem.h'], + }, + { + 'cid': '{e04a55e8-fee3-4ea2-a98b-41d2621adc3c}', + 'contract_ids': ['@mozilla.org/windows-ui-utils;1'], + 'type': 'WindowsUIUtils', + 'headers': ['/widget/windows/WindowsUIUtils.h'], + }, + { + 'cid': '{8b5314bc-db01-11d2-96ce-0060b0fb9956}', + 'contract_ids': ['@mozilla.org/widget/transferable;1'], + 'type': 'nsTransferable', + 'headers': ['/widget/nsTransferable.h'], + }, + { + 'cid': '{948a0023-e3a7-11d2-96cf-0060b0fb9956}', + 'contract_ids': ['@mozilla.org/widget/htmlformatconverter;1'], + 'type': 'nsHTMLFormatConverter', + 'headers': ['/widget/nsHTMLFormatConverter.h'], + }, + { + 'cid': '{8b5314bb-db01-11d2-96ce-0060b0fb9956}', + 'contract_ids': ['@mozilla.org/widget/dragservice;1'], + 'type': 'nsDragService', + 'headers': ['/widget/windows/nsDragService.h'], + 'processes': ProcessSelector.MAIN_PROCESS_ONLY, + }, + { + 'cid': '{9a0cb62b-d638-4faf-9588-ae96f5e29093}', + 'contract_ids': ['@mozilla.org/widget/taskbar-preview-callback;1'], + 'type': 'mozilla::widget::TaskbarPreviewCallback', + 'headers': ['/widget/windows/TaskbarPreview.h'], + }, + { + 'cid': '{d755a760-9f27-11df-0800-200c9a664242}', + 'contract_ids': ['@mozilla.org/gfx/info;1'], + 'type': 'mozilla::widget::GfxInfo', + 'headers': ['/widget/windows/GfxInfo.h'], + 'init_method': 'Init', + 'processes': ProcessSelector.ALLOW_IN_GPU_AND_SOCKET_PROCESS, + }, + { + 'cid': '{bd57cee8-1dd1-11b2-9fe7-95cf4709aea3}', + 'contract_ids': ['@mozilla.org/filepicker;1'], + 'type': 'nsFilePicker', + 'headers': ['/widget/windows/nsFilePicker.h'], + 'processes': ProcessSelector.MAIN_PROCESS_ONLY, + }, + { + 'cid': '{0f872c8c-3ee6-46bd-92a2-69652c6b474e}', + 'contract_ids': ['@mozilla.org/colorpicker;1'], + 'type': 'nsColorPicker', + 'headers': ['/widget/windows/nsColorPicker.h'], + 'processes': ProcessSelector.MAIN_PROCESS_ONLY, + }, + { + 'cid': '{8b5314ba-db01-11d2-96ce-0060b0fb9956}', + 'contract_ids': ['@mozilla.org/widget/clipboard;1'], + 'type': 'nsIClipboard', + 'processes': ProcessSelector.MAIN_PROCESS_ONLY, + }, +] + +if buildconfig.substs['CC_TYPE'] in ('msvc', 'clang-cl'): + Classes += [ + { + 'cid': '{84e11f80-ca55-11dd-ad8b-0800200c9a66}', + 'contract_ids': ['@mozilla.org/system-alerts-service;1'], + 'type': 'mozilla::widget::ToastNotification', + 'headers': ['/widget/windows/ToastNotification.h'], + 'init_method': 'Init', + 'processes': ProcessSelector.MAIN_PROCESS_ONLY, + }, + ] + +if defined('NS_PRINTING'): + Classes += [ + { + 'cid': '{d3f69889-e13a-4321-980c-a39332e21f34}', + 'contract_ids': ['@mozilla.org/gfx/devicecontextspec;1'], + 'type': 'nsDeviceContextSpecWin', + 'headers': ['/widget/windows/nsDeviceContextSpecWin.h'], + }, + { + 'cid': '{06beec76-a183-4d9f-85dd-085f26da565a}', + 'contract_ids': ['@mozilla.org/widget/printdialog-service;1'], + 'type': 'nsPrintDialogServiceWin', + 'headers': ['/widget/windows/nsPrintDialogWin.h'], + 'init_method': 'Init', + 'processes': ProcessSelector.MAIN_PROCESS_ONLY, + }, + { + 'cid': '{841387c8-72e6-484b-9296-bf6eea80d58a}', + 'contract_ids': ['@mozilla.org/gfx/printsettings-service;1'], + 'type': 'nsPrintSettingsServiceWin', + 'headers': ['/widget/windows/nsPrintSettingsServiceWin.h'], + 'init_method': 'Init', + }, + { + 'cid': '{a6cf9129-15b3-11d2-932e-00805f8add32}', + 'contract_ids': ['@mozilla.org/gfx/printerenumerator;1'], + 'type': 'nsPrinterEnumeratorWin', + 'headers': ['/widget/windows/nsDeviceContextSpecWin.h'], + }, + { + 'cid': '{2f977d53-5485-11d4-87e2-0010a4e75ef2}', + 'contract_ids': ['@mozilla.org/gfx/printsession;1'], + 'type': 'nsPrintSession', + 'headers': ['/widget/nsPrintSession.h'], + 'init_method': 'Init', + }, + ] diff --git a/widget/windows/moz.build b/widget/windows/moz.build index fc592ce5974a8..420f2c714c4aa 100644 --- a/widget/windows/moz.build +++ b/widget/windows/moz.build @@ -116,6 +116,10 @@ if CONFIG['NS_ENABLE_TSF']: 'TSFTextStore.cpp', ] +XPCOM_MANIFESTS += [ + 'components.conf', +] + include('/ipc/chromium/chromium-config.mozbuild') FINAL_LIBRARY = 'xul' diff --git a/widget/windows/nsWidgetFactory.cpp b/widget/windows/nsWidgetFactory.cpp index db0f27675cc61..c89b4dca9aec6 100644 --- a/widget/windows/nsWidgetFactory.cpp +++ b/widget/windows/nsWidgetFactory.cpp @@ -3,22 +3,21 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "nsWidgetFactory.h" + +#include "mozilla/Components.h" #include "nsIFactory.h" #include "nsISupports.h" #include "nsdefs.h" #include "nsWidgetsCID.h" #include "nsAppShell.h" #include "nsAppShellSingleton.h" -#include "mozilla/ModuleUtils.h" #include "mozilla/WidgetUtils.h" #include "mozilla/widget/ScreenManager.h" #include "nsIServiceManager.h" -#include "nsIdleServiceWin.h" #include "nsLookAndFeel.h" -#include "nsSound.h" #include "WinMouseScrollHandler.h" #include "KeyboardLayout.h" -#include "GfxInfo.h" #include "nsToolkit.h" // Modules that switch out based on the environment @@ -29,231 +28,31 @@ // Content processes #include "nsFilePickerProxy.h" -// Drag & Drop, Clipboard +// Clipboard #include "nsClipboardHelper.h" #include "nsClipboard.h" #include "HeadlessClipboard.h" -#include "nsDragService.h" -#include "nsTransferable.h" -#include "nsHTMLFormatConverter.h" - -#include "WinTaskbar.h" -#include "JumpListBuilder.h" -#include "JumpListItem.h" -#include "TaskbarPreview.h" -// Toast notification support -#ifndef __MINGW32__ -# include "ToastNotification.h" -# include "nsToolkitCompsCID.h" -#endif #include "WindowsUIUtils.h" -#ifdef NS_PRINTING -# include "nsDeviceContextSpecWin.h" -# include "nsPrintDialogWin.h" -# include "nsPrintSettingsServiceWin.h" -# include "nsPrintSession.h" -#endif - using namespace mozilla; using namespace mozilla::widget; -static nsresult FilePickerConstructor(nsISupports *aOuter, REFNSIID aIID, - void **aResult) { - *aResult = nullptr; - if (aOuter != nullptr) { - return NS_ERROR_NO_AGGREGATION; - } - nsCOMPtr picker = new nsFilePicker; - return picker->QueryInterface(aIID, aResult); -} - -static nsresult ColorPickerConstructor(nsISupports *aOuter, REFNSIID aIID, - void **aResult) { - *aResult = nullptr; - if (aOuter != nullptr) { - return NS_ERROR_NO_AGGREGATION; - } - nsCOMPtr picker = new nsColorPicker; - return picker->QueryInterface(aIID, aResult); -} - -static nsresult nsClipboardConstructor(nsISupports *aOuter, REFNSIID aIID, - void **aResult) { - *aResult = nullptr; - if (aOuter != nullptr) { - return NS_ERROR_NO_AGGREGATION; - } +NS_IMPL_COMPONENT_FACTORY(nsIClipboard) { nsCOMPtr inst; if (gfxPlatform::IsHeadless()) { inst = new HeadlessClipboard(); } else { inst = new nsClipboard(); } - return inst->QueryInterface(aIID, aResult); + return inst.forget().downcast(); } -NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(ScreenManager, - ScreenManager::GetAddRefedSingleton) -NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIdleServiceWin, - nsIdleServiceWin::GetInstance) -NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsISound, nsSound::GetInstance) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardHelper) -NS_GENERIC_FACTORY_CONSTRUCTOR(WinTaskbar) -NS_GENERIC_FACTORY_CONSTRUCTOR(JumpListBuilder) -NS_GENERIC_FACTORY_CONSTRUCTOR(JumpListItem) -NS_GENERIC_FACTORY_CONSTRUCTOR(JumpListSeparator) -NS_GENERIC_FACTORY_CONSTRUCTOR(JumpListLink) -NS_GENERIC_FACTORY_CONSTRUCTOR(JumpListShortcut) -NS_GENERIC_FACTORY_CONSTRUCTOR(WindowsUIUtils) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService) -#ifndef __MINGW32__ -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(ToastNotification, Init) -#endif -NS_GENERIC_FACTORY_CONSTRUCTOR(TaskbarPreviewCallback) -#ifdef NS_PRINTING -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintDialogServiceWin, Init) -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSettingsServiceWin, Init) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrinterEnumeratorWin) -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSession, Init) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecWin) -#endif - -namespace mozilla { -namespace widget { -// This constructor should really be shared with all platforms. -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(GfxInfo, Init) -} // namespace widget -} // namespace mozilla - -NS_DEFINE_NAMED_CID(NS_FILEPICKER_CID); -NS_DEFINE_NAMED_CID(NS_COLORPICKER_CID); -NS_DEFINE_NAMED_CID(NS_APPSHELL_CID); -NS_DEFINE_NAMED_CID(NS_SCREENMANAGER_CID); -NS_DEFINE_NAMED_CID(NS_GFXINFO_CID); -NS_DEFINE_NAMED_CID(NS_IDLE_SERVICE_CID); -NS_DEFINE_NAMED_CID(NS_CLIPBOARD_CID); -NS_DEFINE_NAMED_CID(NS_CLIPBOARDHELPER_CID); -NS_DEFINE_NAMED_CID(NS_SOUND_CID); -NS_DEFINE_NAMED_CID(NS_TRANSFERABLE_CID); -NS_DEFINE_NAMED_CID(NS_HTMLFORMATCONVERTER_CID); -NS_DEFINE_NAMED_CID(NS_WIN_TASKBAR_CID); -NS_DEFINE_NAMED_CID(NS_WIN_JUMPLISTBUILDER_CID); -NS_DEFINE_NAMED_CID(NS_WIN_JUMPLISTITEM_CID); -NS_DEFINE_NAMED_CID(NS_WIN_JUMPLISTSEPARATOR_CID); -NS_DEFINE_NAMED_CID(NS_WIN_JUMPLISTLINK_CID); -NS_DEFINE_NAMED_CID(NS_WIN_JUMPLISTSHORTCUT_CID); -NS_DEFINE_NAMED_CID(NS_WINDOWS_UIUTILS_CID); -NS_DEFINE_NAMED_CID(NS_DRAGSERVICE_CID); -#ifndef __MINGW32__ -NS_DEFINE_NAMED_CID(NS_SYSTEMALERTSSERVICE_CID); -#endif -NS_DEFINE_NAMED_CID(NS_TASKBARPREVIEWCALLBACK_CID); -#ifdef NS_PRINTING -NS_DEFINE_NAMED_CID(NS_PRINTDIALOGSERVICE_CID); -NS_DEFINE_NAMED_CID(NS_PRINTSETTINGSSERVICE_CID); -NS_DEFINE_NAMED_CID(NS_PRINTER_ENUMERATOR_CID); -NS_DEFINE_NAMED_CID(NS_PRINTSESSION_CID); -NS_DEFINE_NAMED_CID(NS_DEVICE_CONTEXT_SPEC_CID); -#endif - -static const mozilla::Module::CIDEntry kWidgetCIDs[] = { - {&kNS_FILEPICKER_CID, false, nullptr, FilePickerConstructor, - Module::MAIN_PROCESS_ONLY}, - {&kNS_COLORPICKER_CID, false, nullptr, ColorPickerConstructor, - Module::MAIN_PROCESS_ONLY}, - {&kNS_APPSHELL_CID, false, nullptr, nsAppShellConstructor, - Module::ALLOW_IN_GPU_VR_AND_SOCKET_PROCESS}, - {&kNS_SCREENMANAGER_CID, false, nullptr, ScreenManagerConstructor, - Module::MAIN_PROCESS_ONLY}, - {&kNS_GFXINFO_CID, false, nullptr, GfxInfoConstructor, - Module::ALLOW_IN_GPU_AND_SOCKET_PROCESS}, - {&kNS_IDLE_SERVICE_CID, false, nullptr, nsIdleServiceWinConstructor}, - {&kNS_CLIPBOARD_CID, false, nullptr, nsClipboardConstructor, - Module::MAIN_PROCESS_ONLY}, - {&kNS_CLIPBOARDHELPER_CID, false, nullptr, nsClipboardHelperConstructor}, - {&kNS_SOUND_CID, false, nullptr, nsISoundConstructor, - Module::MAIN_PROCESS_ONLY}, - {&kNS_TRANSFERABLE_CID, false, nullptr, nsTransferableConstructor}, - {&kNS_HTMLFORMATCONVERTER_CID, false, nullptr, - nsHTMLFormatConverterConstructor}, - {&kNS_WIN_TASKBAR_CID, false, nullptr, WinTaskbarConstructor}, - {&kNS_WIN_JUMPLISTBUILDER_CID, false, nullptr, JumpListBuilderConstructor}, - {&kNS_WIN_JUMPLISTITEM_CID, false, nullptr, JumpListItemConstructor}, - {&kNS_WIN_JUMPLISTSEPARATOR_CID, false, nullptr, - JumpListSeparatorConstructor}, - {&kNS_WIN_JUMPLISTLINK_CID, false, nullptr, JumpListLinkConstructor}, - {&kNS_WIN_JUMPLISTSHORTCUT_CID, false, nullptr, - JumpListShortcutConstructor}, - {&kNS_WINDOWS_UIUTILS_CID, false, nullptr, WindowsUIUtilsConstructor}, - {&kNS_DRAGSERVICE_CID, false, nullptr, nsDragServiceConstructor, - Module::MAIN_PROCESS_ONLY}, -#ifndef __MINGW32__ - {&kNS_SYSTEMALERTSSERVICE_CID, false, nullptr, ToastNotificationConstructor, - Module::MAIN_PROCESS_ONLY}, -#endif - {&kNS_TASKBARPREVIEWCALLBACK_CID, false, nullptr, - TaskbarPreviewCallbackConstructor}, -#ifdef NS_PRINTING - {&kNS_PRINTDIALOGSERVICE_CID, false, nullptr, - nsPrintDialogServiceWinConstructor, Module::MAIN_PROCESS_ONLY}, - {&kNS_PRINTSETTINGSSERVICE_CID, false, nullptr, - nsPrintSettingsServiceWinConstructor}, - {&kNS_PRINTER_ENUMERATOR_CID, false, nullptr, - nsPrinterEnumeratorWinConstructor}, - {&kNS_PRINTSESSION_CID, false, nullptr, nsPrintSessionConstructor}, - {&kNS_DEVICE_CONTEXT_SPEC_CID, false, nullptr, - nsDeviceContextSpecWinConstructor}, -#endif - {nullptr}}; - -static const mozilla::Module::ContractIDEntry kWidgetContracts[] = { - {"@mozilla.org/filepicker;1", &kNS_FILEPICKER_CID, - Module::MAIN_PROCESS_ONLY}, - {"@mozilla.org/colorpicker;1", &kNS_COLORPICKER_CID, - Module::MAIN_PROCESS_ONLY}, - {"@mozilla.org/widget/appshell/win;1", &kNS_APPSHELL_CID, - Module::ALLOW_IN_GPU_VR_AND_SOCKET_PROCESS}, - {"@mozilla.org/gfx/screenmanager;1", &kNS_SCREENMANAGER_CID, - Module::MAIN_PROCESS_ONLY}, - {"@mozilla.org/gfx/info;1", &kNS_GFXINFO_CID, - Module::ALLOW_IN_GPU_AND_SOCKET_PROCESS}, - {"@mozilla.org/widget/idleservice;1", &kNS_IDLE_SERVICE_CID}, - {"@mozilla.org/widget/clipboard;1", &kNS_CLIPBOARD_CID, - Module::MAIN_PROCESS_ONLY}, - {"@mozilla.org/widget/clipboardhelper;1", &kNS_CLIPBOARDHELPER_CID}, - {"@mozilla.org/sound;1", &kNS_SOUND_CID, Module::MAIN_PROCESS_ONLY}, - {"@mozilla.org/widget/transferable;1", &kNS_TRANSFERABLE_CID}, - {"@mozilla.org/widget/htmlformatconverter;1", &kNS_HTMLFORMATCONVERTER_CID}, - {"@mozilla.org/windows-taskbar;1", &kNS_WIN_TASKBAR_CID}, - {"@mozilla.org/windows-jumplistbuilder;1", &kNS_WIN_JUMPLISTBUILDER_CID}, - {"@mozilla.org/windows-jumplistitem;1", &kNS_WIN_JUMPLISTITEM_CID}, - {"@mozilla.org/windows-jumplistseparator;1", - &kNS_WIN_JUMPLISTSEPARATOR_CID}, - {"@mozilla.org/windows-jumplistlink;1", &kNS_WIN_JUMPLISTLINK_CID}, - {"@mozilla.org/windows-jumplistshortcut;1", &kNS_WIN_JUMPLISTSHORTCUT_CID}, - {"@mozilla.org/windows-ui-utils;1", &kNS_WINDOWS_UIUTILS_CID}, - {"@mozilla.org/widget/dragservice;1", &kNS_DRAGSERVICE_CID, - Module::MAIN_PROCESS_ONLY}, -#ifndef __MINGW32__ - {NS_SYSTEMALERTSERVICE_CONTRACTID, &kNS_SYSTEMALERTSSERVICE_CID, - Module::MAIN_PROCESS_ONLY}, -#endif - {"@mozilla.org/widget/taskbar-preview-callback;1", - &kNS_TASKBARPREVIEWCALLBACK_CID}, -#ifdef NS_PRINTING - {NS_PRINTDIALOGSERVICE_CONTRACTID, &kNS_PRINTDIALOGSERVICE_CID}, - {"@mozilla.org/gfx/printsettings-service;1", &kNS_PRINTSETTINGSSERVICE_CID}, - {"@mozilla.org/gfx/printerenumerator;1", &kNS_PRINTER_ENUMERATOR_CID}, - {"@mozilla.org/gfx/printsession;1", &kNS_PRINTSESSION_CID}, - {"@mozilla.org/gfx/devicecontextspec;1", &kNS_DEVICE_CONTEXT_SPEC_CID}, -#endif - {nullptr}}; +nsresult nsWidgetWindowsModuleCtor() { + return nsAppShellInit(); +} -static void nsWidgetWindowsModuleDtor() { +void nsWidgetWindowsModuleDtor() { // Shutdown all XP level widget classes. WidgetUtils::Shutdown(); @@ -263,15 +62,3 @@ static void nsWidgetWindowsModuleDtor() { nsToolkit::Shutdown(); nsAppShellShutdown(); } - -static const mozilla::Module kWidgetModule = { - mozilla::Module::kVersion, - kWidgetCIDs, - kWidgetContracts, - nullptr, - nullptr, - nsAppShellInit, - nsWidgetWindowsModuleDtor, - Module::ALLOW_IN_GPU_VR_AND_SOCKET_PROCESS}; - -NSMODULE_DEFN(nsWidgetModule) = &kWidgetModule; diff --git a/widget/windows/nsWidgetFactory.h b/widget/windows/nsWidgetFactory.h new file mode 100644 index 0000000000000..cc9b30a776769 --- /dev/null +++ b/widget/windows/nsWidgetFactory.h @@ -0,0 +1,22 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim:expandtab:shiftwidth=4:tabstop=4: + */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef widget_windows_nsWidgetFactory_h +#define widget_windows_nsWidgetFactory_h + +#include "nscore.h" +#include "nsID.h" + +class nsISupports; + +nsresult nsAppShellConstructor(nsISupports *outer, const nsIID &iid, + void **result); + +nsresult nsWidgetWindowsModuleCtor(); +void nsWidgetWindowsModuleDtor(); + +#endif // defined widget_windows_nsWidgetFactory_h diff --git a/xpcom/build/XPCOMInit.cpp b/xpcom/build/XPCOMInit.cpp index 766cdb469ad82..d480898e714b2 100644 --- a/xpcom/build/XPCOMInit.cpp +++ b/xpcom/build/XPCOMInit.cpp @@ -175,6 +175,26 @@ const mozilla::Module kXPCOMModule = { nullptr, Module::ALLOW_IN_GPU_VR_AND_SOCKET_PROCESS}; +// FIXME: Dummy modules to avoid Windows PGO bustage when we have too few +// modules registered. +static const mozilla::Module kDummy1 = {mozilla::Module::kVersion}; +static const mozilla::Module kDummy2 = {mozilla::Module::kVersion}; +static const mozilla::Module kDummy3 = {mozilla::Module::kVersion}; +static const mozilla::Module kDummy4 = {mozilla::Module::kVersion}; +static const mozilla::Module kDummy5 = {mozilla::Module::kVersion}; +static const mozilla::Module kDummy6 = {mozilla::Module::kVersion}; +static const mozilla::Module kDummy7 = {mozilla::Module::kVersion}; +static const mozilla::Module kDummy8 = {mozilla::Module::kVersion}; + +NSMODULE_DEFN(Dummy1) = &kDummy1; +NSMODULE_DEFN(Dummy2) = &kDummy2; +NSMODULE_DEFN(Dummy3) = &kDummy3; +NSMODULE_DEFN(Dummy4) = &kDummy4; +NSMODULE_DEFN(Dummy5) = &kDummy5; +NSMODULE_DEFN(Dummy6) = &kDummy6; +NSMODULE_DEFN(Dummy7) = &kDummy7; +NSMODULE_DEFN(Dummy8) = &kDummy8; + // gDebug will be freed during shutdown. static nsIDebug2* gDebug = nullptr; diff --git a/xpfe/appshell/components.conf b/xpfe/appshell/components.conf new file mode 100644 index 0000000000000..547f5e502874a --- /dev/null +++ b/xpfe/appshell/components.conf @@ -0,0 +1,21 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +Classes = [ + { + 'cid': '{0099907d-123c-4853-a46a-43098b5fb68c}', + 'contract_ids': ['@mozilla.org/appshell/appShellService;1'], + 'type': 'nsAppShellService', + 'headers': ['/xpfe/appshell/nsAppShellService.h'], + }, + { + 'cid': '{79a2b7cc-f05b-4605-bfa0-fac54f27eec8}', + 'contract_ids': ['@mozilla.org/appshell/window-mediator;1'], + 'type': 'nsWindowMediator', + 'headers': ['/xpfe/appshell/nsWindowMediator.h'], + 'init_method': 'Init', + }, +] diff --git a/xpfe/appshell/moz.build b/xpfe/appshell/moz.build index a46feae971225..ca09649e4fd92 100644 --- a/xpfe/appshell/moz.build +++ b/xpfe/appshell/moz.build @@ -26,7 +26,6 @@ EXPORTS += [ ] UNIFIED_SOURCES += [ - 'nsAppShellFactory.cpp', 'nsAppShellService.cpp', 'nsAppShellWindowEnumerator.cpp', 'nsChromeTreeOwner.cpp', @@ -36,6 +35,10 @@ UNIFIED_SOURCES += [ 'nsXULWindow.cpp', ] +XPCOM_MANIFESTS += [ + 'components.conf', +] + LOCAL_INCLUDES += [ '/dom/base', '/dom/xul', diff --git a/xpfe/appshell/nsAppShellFactory.cpp b/xpfe/appshell/nsAppShellFactory.cpp deleted file mode 100644 index 0684a2c558d73..0000000000000 --- a/xpfe/appshell/nsAppShellFactory.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "mozilla/ModuleUtils.h" -#include "nscore.h" -#include "nsIWindowMediator.h" - -#include "nsIAppShellService.h" -#include "nsAppShellService.h" -#include "nsWindowMediator.h" -#include "nsChromeTreeOwner.h" -#include "nsAppShellCID.h" - -NS_GENERIC_FACTORY_CONSTRUCTOR(nsAppShellService) -NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsWindowMediator, Init) - -NS_DEFINE_NAMED_CID(NS_APPSHELLSERVICE_CID); -NS_DEFINE_NAMED_CID(NS_WINDOWMEDIATOR_CID); - -static const mozilla::Module::CIDEntry kAppShellCIDs[] = { - {&kNS_APPSHELLSERVICE_CID, false, nullptr, nsAppShellServiceConstructor}, - {&kNS_WINDOWMEDIATOR_CID, false, nullptr, nsWindowMediatorConstructor}, - {nullptr}}; - -static const mozilla::Module::ContractIDEntry kAppShellContracts[] = { - {NS_APPSHELLSERVICE_CONTRACTID, &kNS_APPSHELLSERVICE_CID}, - {NS_WINDOWMEDIATOR_CONTRACTID, &kNS_WINDOWMEDIATOR_CID}, - {nullptr}}; - -static const mozilla::Module kAppShellModule = { - mozilla::Module::kVersion, - kAppShellCIDs, - kAppShellContracts, -}; - -NSMODULE_DEFN(appshell) = &kAppShellModule;