Merge inbound to mozilla-central. a=merge

This commit is contained in:
Ciure Andrei 2018-09-18 10:42:35 +03:00
Родитель e7e6a10f94 5d9d4af0cd
Коммит a0333927de
44 изменённых файлов: 336 добавлений и 192 удалений

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

@ -65,6 +65,7 @@
#include "nsIServiceManager.h"
#include "nsWhitespaceTokenizer.h"
#include "nsAttrName.h"
#include "nsPersistentProperties.h"
#include "mozilla/Assertions.h"
#include "mozilla/BasicEvents.h"
@ -1019,8 +1020,7 @@ Accessible::Attributes()
already_AddRefed<nsIPersistentProperties>
Accessible::NativeAttributes()
{
nsCOMPtr<nsIPersistentProperties> attributes =
do_CreateInstance(NS_PERSISTENTPROPERTIES_CONTRACTID);
RefPtr<nsPersistentProperties> attributes = new nsPersistentProperties();
nsAutoString unused;

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

@ -25,7 +25,7 @@
#include "nsFrameSelection.h"
#include "nsILineIterator.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIPersistentProperties2.h"
#include "nsPersistentProperties.h"
#include "nsIScrollableFrame.h"
#include "nsIServiceManager.h"
#include "nsITextControlElement.h"
@ -880,8 +880,7 @@ HyperTextAccessible::TextAttributes(bool aIncludeDefAttrs, int32_t aOffset,
return nullptr;
}
nsCOMPtr<nsIPersistentProperties> attributes =
do_CreateInstance(NS_PERSISTENTPROPERTIES_CONTRACTID);
RefPtr<nsPersistentProperties> attributes = new nsPersistentProperties();
Accessible* accAtOffset = GetChildAtOffset(offset);
if (!accAtOffset) {
@ -925,8 +924,7 @@ HyperTextAccessible::TextAttributes(bool aIncludeDefAttrs, int32_t aOffset,
already_AddRefed<nsIPersistentProperties>
HyperTextAccessible::DefaultTextAttributes()
{
nsCOMPtr<nsIPersistentProperties> attributes =
do_CreateInstance(NS_PERSISTENTPROPERTIES_CONTRACTID);
RefPtr<nsPersistentProperties> attributes = new nsPersistentProperties();
TextAttrsMgr textAttrsMgr(this);
textAttrsMgr.GetAttributes(attributes);

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

@ -11,7 +11,7 @@
#include "IUnknownImpl.h"
#include "nsIGfxInfo.h"
#include "nsIPersistentProperties2.h"
#include "nsPersistentProperties.h"
#include "nsServiceManagerUtils.h"
#include "mozilla/Services.h"
@ -26,8 +26,7 @@ NS_IMPL_ISUPPORTS_INHERITED0(ApplicationAccessibleWrap,
already_AddRefed<nsIPersistentProperties>
ApplicationAccessibleWrap::NativeAttributes()
{
nsCOMPtr<nsIPersistentProperties> attributes =
do_CreateInstance(NS_PERSISTENTPROPERTIES_CONTRACTID);
RefPtr<nsPersistentProperties> attributes = new nsPersistentProperties();
nsCOMPtr<nsIGfxInfo> gfxInfo = services::GetGfxInfo();
if (gfxInfo) {

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

@ -16,7 +16,7 @@
#include "xpcAccessibleDocument.h"
#include "nsIMutableArray.h"
#include "nsIPersistentProperties2.h"
#include "nsPersistentProperties.h"
using namespace mozilla::a11y;
@ -416,8 +416,7 @@ xpcAccessible::GetAttributes(nsIPersistentProperties** aAttributes)
AutoTArray<Attribute, 10> attrs;
proxy->Attributes(&attrs);
nsCOMPtr<nsIPersistentProperties> props =
do_CreateInstance(NS_PERSISTENTPROPERTIES_CONTRACTID);
RefPtr<nsPersistentProperties> props = new nsPersistentProperties();
uint32_t attrCount = attrs.Length();
nsAutoString unused;
for (uint32_t i = 0; i < attrCount; i++) {

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

@ -18,7 +18,7 @@
#include "nsIBoxObject.h"
#include "nsIMutableArray.h"
#include "nsIPersistentProperties2.h"
#include "nsPersistentProperties.h"
#include "nsITreeSelection.h"
#include "nsComponentManagerUtils.h"
#include "mozilla/dom/Element.h"
@ -646,8 +646,7 @@ XULTreeGridCellAccessible::Selected()
already_AddRefed<nsIPersistentProperties>
XULTreeGridCellAccessible::NativeAttributes()
{
nsCOMPtr<nsIPersistentProperties> attributes =
do_CreateInstance(NS_PERSISTENTPROPERTIES_CONTRACTID);
RefPtr<nsPersistentProperties> attributes = new nsPersistentProperties();
// "table-cell-index" attribute
TableAccessible* table = Table();

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

@ -201,34 +201,27 @@ LoadContext::GetInterface(const nsIID& aIID, void** aResult)
return NS_NOINTERFACE;
}
static nsresult
CreateTestInstance(bool aPrivate, nsISupports *aOuter, REFNSIID aIID, void **aResult)
static already_AddRefed<nsILoadContext>
CreateInstance(bool aPrivate)
{
// Shamelessly modified from NS_GENERIC_FACTORY_CONSTRUCTOR
*aResult = nullptr;
if (aOuter) {
return NS_ERROR_NO_AGGREGATION;
}
OriginAttributes oa;
oa.mPrivateBrowsingId = aPrivate ? 1 : 0;
RefPtr<LoadContext> lc = new LoadContext(oa);
nsCOMPtr<nsILoadContext> lc = new LoadContext(oa);
return lc->QueryInterface(aIID, aResult);
return lc.forget();
}
nsresult
CreateTestLoadContext(nsISupports *aOuter, REFNSIID aIID, void **aResult)
already_AddRefed<nsILoadContext>
CreateLoadContext()
{
return CreateTestInstance(false, aOuter, aIID, aResult);
return CreateInstance(false);
}
nsresult
CreatePrivateTestLoadContext(nsISupports *aOuter, REFNSIID aIID, void **aResult)
already_AddRefed<nsILoadContext>
CreatePrivateLoadContext()
{
return CreateTestInstance(true, aOuter, aIID, aResult);
return CreateInstance(true);
}
} // namespace mozilla

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

@ -122,8 +122,8 @@ private:
#endif
};
nsresult CreateTestLoadContext(nsISupports *aOuter, REFNSIID aIID, void **aResult);
nsresult CreatePrivateTestLoadContext(nsISupports *aOuter, REFNSIID aIID, void **aResult);
already_AddRefed<nsILoadContext> CreateLoadContext();
already_AddRefed<nsILoadContext> CreatePrivateLoadContext();
} // namespace mozilla

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

@ -76,16 +76,4 @@
*/
#define NS_CHROME_WEBNAVIGATION_DESTROY "chrome-webnavigation-destroy"
/**
* A way to create nsILoadContexts from script
*/
#define NS_LOADCONTEXT_CONTRACTID "@mozilla.org/loadcontext;1"
#define NS_LOADCONTEXT_CID \
{ 0xd0181d36, 0x19a2, 0x4347, \
{ 0x8f, 0x00, 0x04, 0x13, 0xa0, 0x70, 0xaa, 0xdc } }
#define NS_PRIVATELOADCONTEXT_CONTRACTID "@mozilla.org/privateloadcontext;1"
#define NS_PRIVATELOADCONTEXT_CID \
{ 0x01629810, 0xd8ae, 0x4455, \
{ 0x86, 0xe8, 0x69, 0x68, 0x87, 0xd1, 0xf7, 0x8d } }
#endif // nsDocShellCID_h__

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

@ -37,9 +37,6 @@
#include "nsSHEntryShared.h"
#include "nsSHistory.h"
// LoadContexts (used for testing)
#include "LoadContext.h"
using mozilla::dom::ContentHandlerService;
static bool gInitialized = false;
@ -117,8 +114,6 @@ NS_DEFINE_NAMED_CID(NS_EXTERNALURLHANDLERSERVICE_CID);
#endif
NS_DEFINE_NAMED_CID(NS_SHENTRY_CID);
NS_DEFINE_NAMED_CID(NS_CONTENTHANDLERSERVICE_CID);
NS_DEFINE_NAMED_CID(NS_LOADCONTEXT_CID);
NS_DEFINE_NAMED_CID(NS_PRIVATELOADCONTEXT_CID);
const mozilla::Module::CIDEntry kDocShellCIDs[] = {
{ &kNS_DOCSHELL_CID, false, nullptr, nsDocShellConstructor },
@ -142,8 +137,6 @@ const mozilla::Module::CIDEntry kDocShellCIDs[] = {
{ &kNS_EXTERNALURLHANDLERSERVICE_CID, false, nullptr, nsExternalURLHandlerServiceConstructor },
#endif
{ &kNS_SHENTRY_CID, false, nullptr, nsSHEntryConstructor },
{ &kNS_LOADCONTEXT_CID, false, nullptr, mozilla::CreateTestLoadContext },
{ &kNS_PRIVATELOADCONTEXT_CID, false, nullptr, mozilla::CreatePrivateTestLoadContext },
{ nullptr }
};
@ -197,8 +190,6 @@ const mozilla::Module::ContractIDEntry kDocShellContracts[] = {
{ NS_EXTERNALURLHANDLERSERVICE_CONTRACTID, &kNS_EXTERNALURLHANDLERSERVICE_CID },
#endif
{ NS_SHENTRY_CONTRACTID, &kNS_SHENTRY_CID },
{ NS_LOADCONTEXT_CONTRACTID, &kNS_LOADCONTEXT_CID },
{ NS_PRIVATELOADCONTEXT_CONTRACTID, &kNS_PRIVATELOADCONTEXT_CID },
{ NS_OSPERMISSIONREQUEST_CONTRACTID, &kNS_OSPERMISSIONREQUEST_CID, mozilla::Module::MAIN_PROCESS_ONLY },
{ nullptr }
};

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

@ -0,0 +1,237 @@
Off Main Thread Painting
========================
OMTP, or off main thread painting, is the component of Gecko that
allows us to perform painting of web content off of the main thread.
This gives us more time on the main thread for javascript, layout,
display list building, and other tasks which allows us to increase our
responsiveness.
Take a look at this `blog
post <https://mozillagfx.wordpress.com/2017/12/05/off-main-thread-painting/>`__
for an introduction.
Background
----------
Painting (or rasterization) is the last operation that happens in a
layer transaction before we forward it to the compositor. At this point,
all display items have been assigned to a layer and invalid regions have
been calculated and assigned to each layer.
The painted layer uses a content client to acquire a buffer for
painting. The main purpose of the content client is to allow us to
retain already painted content when we are scrolling a layer. We have
two main strategies for this, rotated buffer and tiling.
This is implemented with two class hierarchies. ``ContentClient`` for
rotated buffer and ``TiledContentClient`` for tiling. Additionally we
have two different painted layer implementations, ``ClientPaintedLayer``
and ``ClientTiledPaintedLayer``.
The main distinction between rotated buffer and tiling is the amount of
graphics surfaces required. Rotated buffer utilizes just a single buffer
for a frame but potentially requires painting into it multiple times.
Tiling uses multiple buffers but doesnt require painting into the
buffers multiple times.
Once the painted layer has a surface (or surfaces with tiling) to paint
into, they are wrapped in a ``DrawTarget`` of some form and a callback
to ``FrameLayerBuilder`` is called. This callback uses the assigned
display items and invalid regions to trigger rasterization. Each
``nsDisplayItem`` has their ``Paint`` method called with the provided
``DrawTarget`` that represents the surface, and they paint into it.
High level
----------
The key abstraction that allows us to paint off of the main thread is
``DrawTargetCapture`` [1]_. ``DrawTargetCapture`` is a special
``DrawTarget`` which records all draw commands for replaying to another
draw target in the local process. This is similar to
``DrawTargetRecording``, but only holds a reference to resources instead
of copying them into the command stream. This allows the command stream
to be much more lightweight than ``DrawTargetRecording``.
OMTP works by instrumenting the content clients to use a capture target
for all painting [2]_ [3]_ [4]_ [5]_. This capture draw target records all
the operations that would normally be performed directly on the
surfaces draw target. Once we have all of the commands, we send the
capture and surface draw target to the ``PaintThread`` [6]_ where the
commands are replayed onto the surface. Once the rasterization is done,
we forward the layer transaction to the compositor.
Tiling and parallel painting
----------------------------
We can make one additional improvement if we are using tiling as our
content client backend.
When we are tiling, the screen is subdivided into a grid of equally
sized surfaces and draw commands are performed on the tiles they affect.
Each tile is independent of the others, so were able to parallelize
painting by using a worker thread pool and dispatching a task for each
tile individually.
This is commonly referred to as P-OMTP or parallel painting.
Main thread rasterization
-------------------------
Even with OMTP its still possible for the main thread to perform
rasterization. A common pattern for painting code is to create a
temporary draw target, perform drawing with it, take a snapshot, and
then draw the snapshot onto the main draw target. This is done for
blurs, box shadows, text shadows, and with the basic layer manager
fallback.
If the temporary draw target is not a draw target capture, then this
will perform rasterization on the main thread. This can be bad as it
lowers our parallelism and can cause contention with content backends,
like Direct2D, that use locking around shared resources.
To work around this, we changed the main thread painting code to use a
draw target capture for these operations and added a source surface
capture [7]_ which only resolves the painting of the draw commands when
needed on the paint thread.
There are still possible cases we can perform main thread rasterization,
but we try and address them when they come up.
Out of memory issues
--------------------
The web is very complex, and so we can sometimes have a large amount of
draw commands for a content paint. Weve observed OOM errors for capture
command lists that have grown to be 200MiB large.
We initially tried to mitigate this by lowering the overhead of capture
command lists. We do this by filtering commands that dont actually
change the draw target state and folding consecutive transform changes,
but that was not always enough. So we added the ability for our draw
target captures to flush their command lists to the surface draw target
while we are capturing on the main thread [8]_.
This is triggered by a configurable memory limit. Because this
introduces a new source of main thread rasterization we try to balance
setting this too low and suffering poor performance, or setting this too
high and suffering crashes.
Synchronization
---------------
OMTP is conceptually simple, but in practice it relies on subtle code to
ensure thread safety. This was the most arguably the most difficult part
of the project.
There are roughly four areas that are critical.
1. Compositor message ordering
Immediately after we queue the async paints to be asynchronously
completed, we have a problem. We need to forward the layer
transaction at some point, but the compositor cannot process the
transaction until all async paints have finished. If it did, it could
access unfinished painted content.
We obviously cant block on the async paints completing as that would
beat the whole point of OMTP. We also cant hold off on sending the
layer transaction to ``IPDL``, as wed trigger race conditions for
messages sent after the layer transaction is built but before it is
forwarded. Reftest and other code assumes that messages sent after a
layer transaction to the compositor are processed after that layer
transaction is processed.
The solution is to forward the layer transaction to the compositor
over ``IPDL``, but flag the message channel to start postponing
messages [9]_. Then once all async paints have completed, we unflag
the message channel and all postponed messages are sent [10]_. This
allows us to keep our message ordering guarantees and not have to
worry about scheduling a runnable in the future.
2. Texture clients
The backing store for content surfaces is managed by texture client.
While async paints are executing, its possible for shutdown or any
number of things to happen that could cause layer manager, all
layers, all content clients, and therefore all texture clients to be
destroyed. Therefore its important that we keep these texture
clients alive throughout async painting. Texture clients also manage
IPC resources and must be destroyed on the main thread, so we are
careful to do that [11]_.
3. Double buffering
We currently double buffer our content painting - our content clients
only ever have zero or one texture that is available to be painted
into at any moment.
This implies that we cannot start async painting a layer tree while
previous async paints are still active as this would lead to awful
races. We also dont support multiple nested sets of postponed IPC
messages to allow sending the first layer transaction to the
compositor, but not the second.
To prevent issues with this, we flush all active async paints before
we begin to paint a new layer transaction [12]_.
There was some initial debate about implementing triple buffering for
content painting, but we have not seen evidence it would help us
significantly.
4. Moz2D thread safety
Finally, most Moz2D objects were not thread safe. We had to insert
special locking into draw target and source surface as they have a
special copy on write relationship that must be consistent even if
they are on different threads.
Some platform specific resources like fonts needed locking added in
order to be thread safe. We also did some work to make filter nodes
work with multiple threads executing them at the same time.
Browser process
---------------
Currently only content processes are able to use OMTP.
This restriction was added because of concern about message ordering
between ``APZ`` and OMTP. It might be able to lifted in the future.
Important bugs
--------------
1. `OMTP Meta <https://bugzilla.mozilla.org/show_bug.cgi?id=omtp>`__
2. `Enable on
Windows <https://bugzilla.mozilla.org/show_bug.cgi?id=1403935>`__
3. `Enable on
OSX <https://bugzilla.mozilla.org/show_bug.cgi?id=1422392>`__
4. `Enable on
Linux <https://bugzilla.mozilla.org/show_bug.cgi?id=1432531>`__
5. `Parallel
painting <https://bugzilla.mozilla.org/show_bug.cgi?id=1425056>`__
Code links
----------
.. [1] `DrawTargetCapture <https://searchfox.org/mozilla-central/rev/dd965445ec47fbf3cee566eff93b301666bda0e1/gfx/2d/DrawTargetCapture.h#22>`__
.. [2] `Creating DrawTargetCapture for rotated
buffer <https://searchfox.org/mozilla-central/rev/dd965445ec47fbf3cee566eff93b301666bda0e1/gfx/layers/client/ContentClient.cpp#185>`__
.. [3] `Dispatch DrawTargetCapture for rotated
buffer <https://searchfox.org/mozilla-central/rev/dd965445ec47fbf3cee566eff93b301666bda0e1/gfx/layers/client/ClientPaintedLayer.cpp#99>`__
.. [4] `Creating DrawTargetCapture for
tiling <https://searchfox.org/mozilla-central/rev/dd965445ec47fbf3cee566eff93b301666bda0e1/gfx/layers/client/TiledContentClient.cpp#714>`__
.. [5] `Dispatch DrawTargetCapture for
tiling <https://searchfox.org/mozilla-central/rev/dd965445ec47fbf3cee566eff93b301666bda0e1/gfx/layers/client/MultiTiledContentClient.cpp#288>`__
.. [6] `PaintThread <https://searchfox.org/mozilla-central/rev/dd965445ec47fbf3cee566eff93b301666bda0e1/gfx/layers/PaintThread.h#53>`__
.. [7] `SourceSurfaceCapture <https://searchfox.org/mozilla-central/rev/dd965445ec47fbf3cee566eff93b301666bda0e1/gfx/2d/SourceSurfaceCapture.h#19>`__
.. [8] `Sync flushing draw
commands <https://searchfox.org/mozilla-central/rev/dd965445ec47fbf3cee566eff93b301666bda0e1/gfx/2d/DrawTargetCapture.h#165>`__
.. [9] `Postponing messages for
PCompositorBridge <https://searchfox.org/mozilla-central/rev/dd965445ec47fbf3cee566eff93b301666bda0e1/gfx/layers/ipc/CompositorBridgeChild.cpp#1319>`__
.. [10] `Releasing messages for
PCompositorBridge <https://searchfox.org/mozilla-central/rev/dd965445ec47fbf3cee566eff93b301666bda0e1/gfx/layers/ipc/CompositorBridgeChild.cpp#1303>`__
.. [11] `Releasing texture clients on main
thread <https://searchfox.org/mozilla-central/rev/dd965445ec47fbf3cee566eff93b301666bda0e1/gfx/layers/ipc/CompositorBridgeChild.cpp#1170>`__
.. [12] `Flushing async
paints <https://searchfox.org/mozilla-central/rev/dd965445ec47fbf3cee566eff93b301666bda0e1/gfx/layers/client/ClientLayerManager.cpp#289>`__

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

@ -12,6 +12,7 @@ information about graphics and the graphics team at Mozilla.
GraphicsOverview
LayersHistory
OffMainThreadPainting
AsyncPanZoom
AdvancedLayers
Silk

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

@ -50,6 +50,7 @@
#include "GeckoProfiler.h"
#include "gfx2DGlue.h"
#include "gfxPrefs.h"
#include "nsProperties.h"
#include <algorithm>
namespace mozilla {
@ -1056,10 +1057,7 @@ NS_IMETHODIMP
RasterImage::Set(const char* prop, nsISupports* value)
{
if (!mProperties) {
mProperties = do_CreateInstance("@mozilla.org/properties;1");
}
if (!mProperties) {
return NS_ERROR_OUT_OF_MEMORY;
mProperties = new nsProperties();
}
return mProperties->Set(prop, value);
}

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

@ -37,6 +37,7 @@
#include "nsNetUtil.h"
#include "nsIProtocolHandler.h"
#include "imgIRequest.h"
#include "nsProperties.h"
#include "mozilla/IntegerPrintfMacros.h"
#include "mozilla/Telemetry.h"
@ -108,7 +109,7 @@ imgRequest::Init(nsIURI *aURI,
MOZ_ASSERT(aRequest, "No request");
MOZ_ASSERT(aChannel, "No channel");
mProperties = do_CreateInstance("@mozilla.org/properties;1");
mProperties = new nsProperties();
mURI = aURI;
mFinalURI = aFinalURI;
mRequest = aRequest;

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

@ -15,8 +15,8 @@ var gPublicLoader = Cc["@mozilla.org/image/loader;1"].createInstance(Ci.imgILoad
var gPrivateLoader = Cc["@mozilla.org/image/loader;1"].createInstance(Ci.imgILoader);
gPrivateLoader.QueryInterface(Ci.imgICache).respectPrivacyNotifications();
var nonPrivateLoadContext = Cc["@mozilla.org/loadcontext;1"].createInstance(Ci.nsILoadContext);
var privateLoadContext = Cc["@mozilla.org/privateloadcontext;1"].createInstance(Ci.nsILoadContext);
var nonPrivateLoadContext = Cu.createLoadContext();
var privateLoadContext = Cu.createPrivateLoadContext();
function imageHandler(metadata, response) {
gHits++;

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

@ -16,6 +16,8 @@ interface nsIComponentManager;
interface nsICycleCollectorListener;
interface nsIEditorSpellCheck;
interface nsIFile;
interface nsILoadContext;
interface nsIPersistentProperties;
interface nsIURI;
interface nsIJSCID;
interface nsIJSIID;
@ -725,8 +727,14 @@ interface nsIXPCComponents_Utils : nsISupports
/* Create a commandline object. */
nsISupports createCommandLine();
/* Create a command params object. */
nsICommandParams createCommandParams();
/* Create a loadcontext object. */
nsILoadContext createLoadContext();
/* Create a private loadcontext object. */
nsILoadContext createPrivateLoadContext();
/* Create a persistent property object. */
nsIPersistentProperties createPersistentProperties();
};
/**

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

@ -20,6 +20,7 @@
#include "js/StructuredClone.h"
#include "mozilla/Attributes.h"
#include "mozilla/jsipc/CrossProcessObjectWrappers.h"
#include "mozilla/LoadContext.h"
#include "mozilla/Preferences.h"
#include "nsJSEnvironment.h"
#include "mozilla/TimeStamp.h"
@ -43,7 +44,7 @@
#include "GeckoProfiler.h"
#include "mozilla/EditorSpellCheck.h"
#include "nsCommandLine.h"
#include "nsCommandParams.h"
#include "nsPersistentProperties.h"
using namespace mozilla;
using namespace JS;
@ -3233,11 +3234,29 @@ nsXPCComponents_Utils::CreateCommandLine(nsISupports** aCommandLine)
}
NS_IMETHODIMP
nsXPCComponents_Utils::CreateCommandParams(nsICommandParams** aCommandParams)
nsXPCComponents_Utils::CreateLoadContext(nsILoadContext** aLoadContext)
{
NS_ENSURE_ARG_POINTER(aCommandParams);
nsCOMPtr<nsICommandParams> commandParams = new nsCommandParams();
commandParams.forget(aCommandParams);
NS_ENSURE_ARG_POINTER(aLoadContext);
nsCOMPtr<nsILoadContext> loadContext = ::CreateLoadContext();
loadContext.forget(aLoadContext);
return NS_OK;
}
NS_IMETHODIMP
nsXPCComponents_Utils::CreatePrivateLoadContext(nsILoadContext** aLoadContext)
{
NS_ENSURE_ARG_POINTER(aLoadContext);
nsCOMPtr<nsILoadContext> loadContext = ::CreatePrivateLoadContext();
loadContext.forget(aLoadContext);
return NS_OK;
}
NS_IMETHODIMP
nsXPCComponents_Utils::CreatePersistentProperties(nsIPersistentProperties** aPersistentProperties)
{
NS_ENSURE_ARG_POINTER(aPersistentProperties);
nsCOMPtr<nsIPersistentProperties> props = new nsPersistentProperties();
props.forget(aPersistentProperties);
return NS_OK;
}

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

@ -44,7 +44,7 @@
#include "nsINode.h"
#include "nsIObjectLoadingContent.h"
#include "nsIOfflineCacheUpdate.h"
#include "nsIPersistentProperties2.h"
#include "nsPersistentProperties.h"
#include "nsIPrivateBrowsingChannel.h"
#include "nsIPropertyBag2.h"
#include "nsIProtocolProxyService.h"
@ -2029,9 +2029,7 @@ NS_LoadPersistentPropertiesFromURISpec(nsIPersistentProperties **outResult,
rv = channel->Open2(getter_AddRefs(in));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIPersistentProperties> properties =
do_CreateInstance(NS_PERSISTENTPROPERTIES_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIPersistentProperties> properties = new nsPersistentProperties();
rv = properties->Load(in);
NS_ENSURE_SUCCESS(rv, rv);

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

@ -16,9 +16,6 @@ var URIs = [
"ftp://example.org"
];
let LoadContext = Components.Constructor("@mozilla.org/loadcontext;1");
let PrivateLoadContext = Components.Constructor("@mozilla.org/privateloadcontext;1");
function* getChannels() {
for (let u of URIs) {
yield NetUtil.newChannel({
@ -70,7 +67,7 @@ add_test(function test_setPrivate_regular() {
* Load context mandates private mode
*/
add_test(function test_LoadContextPrivate() {
let ctx = new PrivateLoadContext();
let ctx = Cu.createPrivateLoadContext();
for (let c of getChannels()) {
c.notificationCallbacks = ctx;
checkPrivate(c, true);
@ -82,7 +79,7 @@ add_test(function test_LoadContextPrivate() {
* Load context mandates regular mode
*/
add_test(function test_LoadContextRegular() {
let ctx = new LoadContext();
let ctx = Cu.createLoadContext();
for (let c of getChannels()) {
c.notificationCallbacks = ctx;
checkPrivate(c, false);

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

@ -17,7 +17,7 @@ var nostorePath = "/nostore" + suffix;
var test410Path = "/test410" + suffix;
var test404Path = "/test404" + suffix;
var PrivateBrowsingLoadContext = Cc["@mozilla.org/privateloadcontext;1"].createInstance(Ci.nsILoadContext);
var PrivateBrowsingLoadContext = Cu.createPrivateLoadContext();
function make_channel(url, flags, usePrivateBrowsing) {
var securityFlags = Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL;

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

@ -6,6 +6,7 @@ add_task(async function() {
await SpecialPowers.flushPrefEnv();
await SpecialPowers.pushPrefEnv({"set": [
["browser.contentblocking.enabled", true],
["browser.fastblock.enabled", false],
["network.cookie.cookieBehavior", Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER],
["privacy.trackingprotection.enabled", false],
["privacy.trackingprotection.pbmode.enabled", false],

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

@ -5,6 +5,7 @@ add_task(async function() {
await SpecialPowers.flushPrefEnv();
await SpecialPowers.pushPrefEnv({"set": [
["browser.fastblock.enabled", false],
["privacy.trackingprotection.enabled", false],
["privacy.trackingprotection.pbmode.enabled", false],
["privacy.trackingprotection.annotate_channels", true],

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

@ -53,6 +53,7 @@ add_task(async function() {
await SpecialPowers.flushPrefEnv();
await SpecialPowers.pushPrefEnv({"set": [
["browser.contentblocking.enabled", true],
["browser.fastblock.enabled", false],
["privacy.trackingprotection.enabled", true],
// the test doesn't open a private window, so we don't care about this pref's value
["privacy.trackingprotection.pbmode.enabled", false],

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

@ -48,6 +48,7 @@ add_task(async function() {
await SpecialPowers.flushPrefEnv();
await SpecialPowers.pushPrefEnv({"set": [
["browser.contentblocking.enabled", true],
["browser.fastblock.enabled", false],
["privacy.trackingprotection.enabled", true],
// the test doesn't open a private window, so we don't care about this pref's value
["privacy.trackingprotection.pbmode.enabled", false],

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

@ -6,6 +6,7 @@ add_task(async function() {
await SpecialPowers.flushPrefEnv();
await SpecialPowers.pushPrefEnv({"set": [
["browser.contentblocking.enabled", true],
["browser.fastblock.enabled", false],
["network.cookie.cookieBehavior", Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER],
["privacy.trackingprotection.enabled", false],
["privacy.trackingprotection.pbmode.enabled", false],

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

@ -9,6 +9,7 @@ add_task(async function() {
["browser.contentblocking.enabled", true],
["browser.contentblocking.ui.enabled", true],
["browser.contentblocking.rejecttrackers.ui.enabled", true],
["browser.fastblock.enabled", false],
["network.cookie.cookieBehavior", Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER],
["privacy.trackingprotection.enabled", false],
["privacy.trackingprotection.pbmode.enabled", false],

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

@ -6,6 +6,7 @@ add_task(async function() {
await SpecialPowers.flushPrefEnv();
await SpecialPowers.pushPrefEnv({"set": [
["browser.contentblocking.enabled", true],
["browser.fastblock.enabled", false],
["network.cookie.cookieBehavior", Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER],
["privacy.trackingprotection.enabled", false],
["privacy.trackingprotection.pbmode.enabled", false],

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

@ -12,10 +12,8 @@ ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
ChromeUtils.defineModuleGetter(this, "_methodsCallableFromChild",
"resource://gre/modules/ContentPrefUtils.jsm");
let loadContext = Cc["@mozilla.org/loadcontext;1"].
createInstance(Ci.nsILoadContext);
let privateLoadContext = Cc["@mozilla.org/privateloadcontext;1"].
createInstance(Ci.nsILoadContext);
let loadContext = Cu.createLoadContext();
let privateLoadContext = Cu.createPrivateLoadContext();
function contextArg(context) {
return (context && context.usePrivateBrowsing) ?

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

@ -13,10 +13,9 @@
<script type="application/javascript">
"use strict";
let loadContext = SpecialPowers.Cc["@mozilla.org/loadcontext;1"].
createInstance(SpecialPowers.Ci.nsILoadContext);
let privateLoadContext = SpecialPowers.Cc["@mozilla.org/privateloadcontext;1"].
createInstance(SpecialPowers.Ci.nsILoadContext);
let Cu = SpecialPowers.Cu;
let loadContext = Cu.createLoadContext();
let privateLoadContext = Cu.createPrivateLoadContext();
SimpleTest.waitForExplicitFinish();
@ -191,8 +190,7 @@
cps.addObserverForName("test", prefObserver);
let privateLoadContext = Cc["@mozilla.org/privateloadcontext;1"].
createInstance(Ci.nsILoadContext);
let privateLoadContext = Cu.createPrivateLoadContext();
cps.set("http://mochi.test", "test", 42, privateLoadContext);
let event = await observed.promise;
tester.is(event.name, "test", "got the right event");

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

@ -4,10 +4,8 @@
ChromeUtils.import("resource://gre/modules/Services.jsm");
let loadContext = Cc["@mozilla.org/loadcontext;1"].
createInstance(Ci.nsILoadContext);
let privateLoadContext = Cc["@mozilla.org/privateloadcontext;1"].
createInstance(Ci.nsILoadContext);
let loadContext = Cu.createLoadContext();
let privateLoadContext = Cu.createPrivateLoadContext();
// There has to be a profile directory before the CPS service is gotten.
do_get_profile();

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

@ -32,10 +32,8 @@ var EXPORTED_SYMBOLS = [ "DownloadLastDir" ];
ChromeUtils.import("resource://gre/modules/Services.jsm");
let nonPrivateLoadContext = Cc["@mozilla.org/loadcontext;1"].
createInstance(Ci.nsILoadContext);
let privateLoadContext = Cc["@mozilla.org/privateloadcontext;1"].
createInstance(Ci.nsILoadContext);
let nonPrivateLoadContext = Cu.createLoadContext();
let privateLoadContext = Cu.createPrivateLoadContext();
var observer = {
QueryInterface: ChromeUtils.generateQI(["nsIObserver",

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

@ -55,7 +55,7 @@
#include "nsIAppShellService.h"
#include "nsIAppStartup.h"
#include "nsIAppStartupNotifier.h"
#include "nsAppStartupNotifier.h"
#include "nsIMutableArray.h"
#include "nsICategoryManager.h"
#include "nsIChromeRegistry.h"
@ -4628,13 +4628,7 @@ XREMain::XRE_mainRun()
// ready in time for early consumers, such as the component loader.
mDirProvider.InitializeUserPrefs();
{
nsCOMPtr<nsIObserver> startupNotifier
(do_CreateInstance(NS_APPSTARTUPNOTIFIER_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
startupNotifier->Observe(nullptr, APPSTARTUP_TOPIC, nullptr);
}
nsAppStartupNotifier::NotifyObservers(APPSTARTUP_TOPIC);
nsCOMPtr<nsIAppStartup> appStartup
(do_GetService(NS_APPSTARTUP_CONTRACTID));

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

@ -12,15 +12,8 @@
#include "nsAppStartupNotifier.h"
#include "nsISimpleEnumerator.h"
NS_IMPL_ISUPPORTS(nsAppStartupNotifier, nsIObserver)
nsAppStartupNotifier::nsAppStartupNotifier()
{
}
nsAppStartupNotifier::~nsAppStartupNotifier() = default;
NS_IMETHODIMP nsAppStartupNotifier::Observe(nsISupports *aSubject, const char *aTopic, const char16_t *someData)
/* static */ nsresult
nsAppStartupNotifier::NotifyObservers(const char* aTopic)
{
NS_ENSURE_ARG(aTopic);
nsresult rv;

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

@ -8,22 +8,10 @@
#include "nsIAppStartupNotifier.h"
// {1F59B001-02C9-11d5-AE76-CC92F7DB9E03}
#define NS_APPSTARTUPNOTIFIER_CID \
{ 0x1f59b001, 0x2c9, 0x11d5, { 0xae, 0x76, 0xcc, 0x92, 0xf7, 0xdb, 0x9e, 0x3 } }
class nsAppStartupNotifier : public nsIObserver
class nsAppStartupNotifier final
{
public:
NS_DEFINE_STATIC_CID_ACCESSOR( NS_APPSTARTUPNOTIFIER_CID )
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
nsAppStartupNotifier();
protected:
virtual ~nsAppStartupNotifier();
static nsresult NotifyObservers(const char* aTopic);
};
#endif /* nsAppStartupNotifier_h___ */

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

@ -16,7 +16,7 @@
#include "prenv.h"
#include "nsIAppShell.h"
#include "nsIAppStartupNotifier.h"
#include "nsAppStartupNotifier.h"
#include "nsIDirectoryService.h"
#include "nsIFile.h"
#include "nsIToolkitChromeRegistry.h"
@ -202,12 +202,7 @@ XRE_InitEmbedding2(nsIFile *aLibXULDirectory,
// If the app wants to autoregister every time (for instance, if it's debug),
// it can do so after we return from this function.
nsCOMPtr<nsIObserver> startupNotifier
(do_CreateInstance(NS_APPSTARTUPNOTIFIER_CONTRACTID));
if (!startupNotifier)
return NS_ERROR_FAILURE;
startupNotifier->Observe(nullptr, APPSTARTUP_TOPIC, nullptr);
nsAppStartupNotifier::NotifyObservers(APPSTARTUP_TOPIC);
return NS_OK;
}

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

@ -6,7 +6,6 @@
#include "mozilla/ModuleUtils.h"
#include "nsDialogParamBlock.h"
#include "nsWindowWatcher.h"
#include "nsAppStartupNotifier.h"
#include "nsFind.h"
#include "nsWebBrowserPersist.h"
#include "nsNetCID.h"
@ -19,7 +18,6 @@
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsWindowWatcher, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAppStartupNotifier)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFind)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsWebBrowserPersist)
@ -43,7 +41,6 @@ NS_DEFINE_NAMED_CID(NS_PRINTINGPROMPTSERVICE_CID);
#endif
NS_DEFINE_NAMED_CID(NS_WINDOWWATCHER_CID);
NS_DEFINE_NAMED_CID(NS_FIND_CID);
NS_DEFINE_NAMED_CID(NS_APPSTARTUPNOTIFIER_CID);
NS_DEFINE_NAMED_CID(NS_WEBBROWSERPERSIST_CID);
static const mozilla::Module::CIDEntry kEmbeddingCIDs[] = {
@ -63,7 +60,6 @@ static const mozilla::Module::CIDEntry kEmbeddingCIDs[] = {
#endif
{ &kNS_WINDOWWATCHER_CID, false, nullptr, nsWindowWatcherConstructor },
{ &kNS_FIND_CID, false, nullptr, nsFindConstructor },
{ &kNS_APPSTARTUPNOTIFIER_CID, false, nullptr, nsAppStartupNotifierConstructor },
{ &kNS_WEBBROWSERPERSIST_CID, false, nullptr, nsWebBrowserPersistConstructor },
{ nullptr }
};
@ -77,7 +73,6 @@ static const mozilla::Module::ContractIDEntry kEmbeddingContracts[] = {
#endif
{ NS_WINDOWWATCHER_CONTRACTID, &kNS_WINDOWWATCHER_CID },
{ NS_FIND_CONTRACTID, &kNS_FIND_CID },
{ NS_APPSTARTUPNOTIFIER_CONTRACTID, &kNS_APPSTARTUPNOTIFIER_CID },
{ NS_WEBBROWSERPERSIST_CONTRACTID, &kNS_WEBBROWSERPERSIST_CID },
{ nullptr }
};

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

@ -6,8 +6,6 @@
#ifndef nsIAppStartupNotifier_h___
#define nsIAppStartupNotifier_h___
#include "nsIObserver.h"
/*
Some components need to be run at the startup of mozilla or embedding - to
start new services etc.
@ -42,8 +40,6 @@
and release them.
*/
#define NS_APPSTARTUPNOTIFIER_CONTRACTID "@mozilla.org/embedcomp/appstartup-notifier;1"
#define APPSTARTUP_CATEGORY "app-startup"
#define APPSTARTUP_TOPIC "app-startup"

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

@ -28,8 +28,6 @@
#include "nsCycleCollector.h"
#include "nsObserverList.h"
#include "nsObserverService.h"
#include "nsProperties.h"
#include "nsPersistentProperties.h"
#include "nsScriptableInputStream.h"
#include "nsBinaryStream.h"
#include "nsStorageStream.h"
@ -211,8 +209,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsVariantCC)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsHashPropertyBagCC)
NS_GENERIC_AGGREGATED_CONSTRUCTOR(nsProperties)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsUUIDGenerator, Init)
#ifdef MOZ_WIDGET_COCOA
@ -259,8 +255,6 @@ NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsChromeRegistry,
nsChromeRegistry::GetSingleton)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsChromeProtocolHandler)
#define NS_PERSISTENTPROPERTIES_CID NS_IPERSISTENTPROPERTIES_CID /* sigh */
static already_AddRefed<nsIFactory>
CreateINIParserFactory(const mozilla::Module& aModule,
const mozilla::Module::CIDEntry& aEntry)

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

@ -12,10 +12,6 @@
COMPONENT(SCRIPTABLEBASE64ENCODER, nsScriptableBase64EncoderConstructor)
COMPONENT(PIPE, nsPipeConstructor)
COMPONENT(PROPERTIES, nsPropertiesConstructor)
COMPONENT(PERSISTENTPROPERTIES, nsPersistentProperties::Create)
COMPONENT(ARRAY, nsArrayBase::XPCOMConstructor)
COMPONENT(CONSOLESERVICE, nsConsoleServiceConstructor)
COMPONENT_M(OBSERVERSERVICE, nsObserverService::Create, Module::ALLOW_IN_GPU_PROCESS)

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

@ -61,7 +61,9 @@ EXPORTS += [
'nsInterfaceHashtable.h',
'nsJSThingHashtable.h',
'nsMathUtils.h',
'nsPersistentProperties.h',
'nsPointerHashKeys.h',
'nsProperties.h',
'nsQuickSort.h',
'nsRefPtrHashtable.h',
'nsSimpleEnumerator.h',

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

@ -58,13 +58,3 @@ interface nsIPersistentProperties : nsIProperties
%}
};
%{C++
#define NS_IPERSISTENTPROPERTIES_CID \
{ 0x2245e573, 0x9464, 0x11d2, \
{ 0x9b, 0x8b, 0x0, 0x80, 0x5f, 0x8a, 0x16, 0xd9 } }
#define NS_PERSISTENTPROPERTIES_CONTRACTID "@mozilla.org/persistent-properties;1"
%}

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

@ -459,17 +459,6 @@ nsPersistentProperties::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf)
return aMallocSizeOf(this) + n;
}
nsresult
nsPersistentProperties::Create(nsISupports* aOuter, REFNSIID aIID,
void** aResult)
{
if (aOuter) {
return NS_ERROR_NO_AGGREGATION;
}
RefPtr<nsPersistentProperties> props = new nsPersistentProperties();
return props->QueryInterface(aIID, aResult);
}
NS_IMPL_ISUPPORTS(nsPersistentProperties, nsIPersistentProperties, nsIProperties)
NS_IMETHODIMP

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

@ -25,9 +25,6 @@ public:
NS_DECL_NSIPROPERTIES
NS_DECL_NSIPERSISTENTPROPERTIES
static MOZ_MUST_USE nsresult
Create(nsISupports* aOuter, REFNSIID aIID, void** aResult);
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const override;
private:

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

@ -13,14 +13,6 @@
#include "nsAgg.h"
#include "mozilla/Attributes.h"
#define NS_PROPERTIES_CID \
{ /* 4de2bc90-b1bf-11d3-93b6-00104ba0fd40 */ \
0x4de2bc90, \
0xb1bf, \
0x11d3, \
{0x93, 0xb6, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40} \
}
typedef nsInterfaceHashtable<nsCharPtrHashKey,
nsISupports> nsProperties_HashBase;
@ -32,7 +24,7 @@ public:
NS_DECL_AGGREGATED
NS_DECL_NSIPROPERTIES
explicit nsProperties(nsISupports *aOuter) { NS_INIT_AGGREGATED(aOuter); }
nsProperties() { NS_INIT_AGGREGATED(nullptr); }
~nsProperties() {}
};

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

@ -9,8 +9,7 @@ function run_test() {
});
var inp = channel.open2();
var properties = Cc["@mozilla.org/persistent-properties;1"].
createInstance(Ci.nsIPersistentProperties);
var properties = Cu.createPersistentProperties();
properties.load(inp);
var value;
@ -56,8 +55,7 @@ function run_test() {
});
inp = channel2.open2();
var properties2 = Cc["@mozilla.org/persistent-properties;1"].
createInstance(Ci.nsIPersistentProperties);
var properties2 = Cu.createPersistentProperties();
try {
properties2.load(inp);
do_throw("load() didn't fail");