Bug 1449791 - Remove platform support of overlays. r=bz

The following was removed:
- the main meat of the overlays and interface in XULDocument
- all overlay observers and forward references
- the notion of a master document
- XUL overlay provider
- manifest parsing of overlay attribute
- references to "overlay" atom
- restrictions on persistence (only need because of overlays)
- unused code that the above referenced

I also attempted to update comments that referenced overlays, but there is still
some work to be done here.


MozReview-Commit-ID: 8lrirzcgSuJ

--HG--
extra : rebase_source : 25b4e1d3fb2af6f02d894887271fd345c9c2083b
This commit is contained in:
Brendan Dahl 2018-03-28 18:20:04 -07:00
parent 9d30878aa5
commit 133e16ecf4
17 changed files with 62 additions and 1471 deletions

View File

@ -108,9 +108,6 @@ NS_INTERFACE_MAP_BEGIN(nsChromeRegistry)
NS_INTERFACE_MAP_ENTRY(nsIChromeRegistry)
NS_INTERFACE_MAP_ENTRY(nsIXULChromeRegistry)
NS_INTERFACE_MAP_ENTRY(nsIToolkitChromeRegistry)
#ifdef MOZ_XUL
NS_INTERFACE_MAP_ENTRY(nsIXULOverlayProvider)
#endif
NS_INTERFACE_MAP_ENTRY(nsIObserver)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIChromeRegistry)

View File

@ -10,10 +10,6 @@
#include "nsIObserver.h"
#include "nsWeakReference.h"
#ifdef MOZ_XUL
#include "nsIXULOverlayProvider.h"
#endif
#include "nsString.h"
#include "nsURIHashKey.h"
#include "nsInterfaceHashtable.h"
@ -36,9 +32,6 @@ class nsIURL;
{ 0x47049e42, 0x1d87, 0x482a, { 0x98, 0x4d, 0x56, 0xae, 0x18, 0x5e, 0x36, 0x7a } }
class nsChromeRegistry : public nsIToolkitChromeRegistry,
#ifdef MOZ_XUL
public nsIXULOverlayProvider,
#endif
public nsIObserver,
public nsSupportsWeakReference
{
@ -128,8 +121,6 @@ public:
char *const * argv, int flags) = 0;
virtual void ManifestSkin(ManifestProcessingContext& cx, int lineno,
char *const * argv, int flags) = 0;
virtual void ManifestOverlay(ManifestProcessingContext& cx, int lineno,
char *const * argv, int flags) = 0;
virtual void ManifestOverride(ManifestProcessingContext& cx, int lineno,
char *const * argv, int flags) = 0;
virtual void ManifestResource(ManifestProcessingContext& cx, int lineno,

View File

@ -307,7 +307,6 @@ NS_IMETHODIMP
nsChromeRegistryChrome::CheckForNewChrome()
{
mPackagesHash.Clear();
mOverlayHash.Clear();
mOverrideTable.Clear();
mDynamicRegistration = false;
@ -543,54 +542,6 @@ nsChromeRegistryChrome::nsProviderArray::EnumerateToArray(nsTArray<nsCString> *a
}
}
void
nsChromeRegistryChrome::OverlayListEntry::AddURI(nsIURI* aURI)
{
int32_t i = mArray.Count();
while (i--) {
bool equals;
if (NS_SUCCEEDED(aURI->Equals(mArray[i], &equals)) && equals)
return;
}
mArray.AppendObject(aURI);
}
void
nsChromeRegistryChrome::OverlayListHash::Add(nsIURI* aBase, nsIURI* aOverlay)
{
OverlayListEntry* entry = mTable.PutEntry(aBase);
if (entry)
entry->AddURI(aOverlay);
}
const nsCOMArray<nsIURI>*
nsChromeRegistryChrome::OverlayListHash::GetArray(nsIURI* aBase)
{
OverlayListEntry* entry = mTable.GetEntry(aBase);
if (!entry)
return nullptr;
return &entry->mArray;
}
#ifdef MOZ_XUL
NS_IMETHODIMP
nsChromeRegistryChrome::GetXULOverlays(nsIURI *aChromeURL,
nsISimpleEnumerator **aResult)
{
nsCOMPtr<nsIURI> chromeURLWithoutHash;
if (aChromeURL) {
aChromeURL->CloneIgnoringRef(getter_AddRefs(chromeURLWithoutHash));
}
const nsCOMArray<nsIURI>* parray = mOverlayHash.GetArray(chromeURLWithoutHash);
if (!parray)
return NS_NewEmptyEnumerator(aResult);
return NS_NewArrayEnumerator(aResult, *parray);
}
#endif // MOZ_XUL
nsIURI*
nsChromeRegistry::ManifestProcessingContext::GetManifestURI()
{
@ -757,33 +708,6 @@ nsChromeRegistryChrome::ManifestSkin(ManifestProcessingContext& cx, int lineno,
}
}
void
nsChromeRegistryChrome::ManifestOverlay(ManifestProcessingContext& cx, int lineno,
char *const * argv, int flags)
{
char* base = argv[0];
char* overlay = argv[1];
nsCOMPtr<nsIURI> baseuri = cx.ResolveURI(base);
nsCOMPtr<nsIURI> overlayuri = cx.ResolveURI(overlay);
if (!baseuri || !overlayuri) {
LogMessageWithContext(cx.GetManifestURI(), lineno, nsIScriptError::warningFlag,
"During chrome registration, unable to create URI.");
return;
}
if (!CanLoadResource(overlayuri)) {
LogMessageWithContext(cx.GetManifestURI(), lineno, nsIScriptError::warningFlag,
"Cannot register non-local URI '%s' as an overlay.", overlay);
return;
}
nsCOMPtr<nsIURI> baseuriWithoutHash;
baseuri->CloneIgnoringRef(getter_AddRefs(baseuriWithoutHash));
mOverlayHash.Add(baseuriWithoutHash, overlayuri);
}
void
nsChromeRegistryChrome::ManifestOverride(ManifestProcessingContext& cx, int lineno,
char *const * argv, int flags)

View File

@ -41,11 +41,6 @@ class nsChromeRegistryChrome : public nsChromeRegistry
NS_IMETHOD Observe(nsISupports *aSubject, const char *aTopic,
const char16_t *someData) override;
#ifdef MOZ_XUL
NS_IMETHOD GetXULOverlays(nsIURI *aURI,
nsISimpleEnumerator **_retval) override;
#endif
// If aChild is non-null then it is a new child to notify. If aChild is
// null, then we have installed new chrome and we are resetting all of our
// children's registered chrome.
@ -114,40 +109,6 @@ class nsChromeRegistryChrome : public nsChromeRegistry
nsProviderArray skins;
};
class OverlayListEntry : public nsURIHashKey
{
public:
typedef nsURIHashKey::KeyType KeyType;
typedef nsURIHashKey::KeyTypePointer KeyTypePointer;
explicit OverlayListEntry(KeyTypePointer aKey) : nsURIHashKey(aKey) { }
OverlayListEntry(OverlayListEntry&& toMove) : nsURIHashKey(std::move(toMove)),
mArray(std::move(toMove.mArray)) { }
~OverlayListEntry() { }
void AddURI(nsIURI* aURI);
nsCOMArray<nsIURI> mArray;
};
class OverlayListHash
{
public:
OverlayListHash() { }
~OverlayListHash() { }
void Add(nsIURI* aBase, nsIURI* aOverlay);
void Clear() { mTable.Clear(); }
const nsCOMArray<nsIURI>* GetArray(nsIURI* aBase);
private:
nsTHashtable<OverlayListEntry> mTable;
};
// Hashes on the file to be overlaid (chrome://browser/content/browser.xul)
// to a list of overlays
OverlayListHash mOverlayHash;
bool mProfileLoaded;
bool mDynamicRegistration;
@ -162,8 +123,6 @@ class nsChromeRegistryChrome : public nsChromeRegistry
char *const * argv, int flags) override;
virtual void ManifestSkin(ManifestProcessingContext& cx, int lineno,
char *const * argv, int flags) override;
virtual void ManifestOverlay(ManifestProcessingContext& cx, int lineno,
char *const * argv, int flags) override;
virtual void ManifestOverride(ManifestProcessingContext& cx, int lineno,
char *const * argv, int flags) override;
virtual void ManifestResource(ManifestProcessingContext& cx, int lineno,

View File

@ -238,13 +238,6 @@ nsChromeRegistryContent::Observe(nsISupports* aSubject, const char* aTopic,
CONTENT_NOT_IMPLEMENTED();
}
NS_IMETHODIMP
nsChromeRegistryContent::GetXULOverlays(nsIURI *aChromeURL,
nsISimpleEnumerator **aResult)
{
CONTENT_NOT_IMPLEMENTED();
}
void
nsChromeRegistryContent::ManifestContent(ManifestProcessingContext& cx,
int lineno, char *const * argv,
@ -269,13 +262,6 @@ nsChromeRegistryContent::ManifestSkin(ManifestProcessingContext& cx,
CONTENT_NOTREACHED();
}
void
nsChromeRegistryContent::ManifestOverlay(ManifestProcessingContext& cx, int lineno,
char *const * argv, int flags)
{
CONTENT_NOTREACHED();
}
void
nsChromeRegistryContent::ManifestOverride(ManifestProcessingContext& cx,
int lineno,

View File

@ -35,8 +35,6 @@ class nsChromeRegistryContent : public nsChromeRegistry
NS_IMETHOD GetSelectedLocale(const nsACString& aPackage,
bool aAsBCP47,
nsACString& aLocale) override;
NS_IMETHOD GetXULOverlays(nsIURI *aChromeURL,
nsISimpleEnumerator **aResult) override;
void RegisterPackage(const ChromePackage& aPackage);
void RegisterOverride(const OverrideMapping& aOverride);
@ -68,8 +66,6 @@ class nsChromeRegistryContent : public nsChromeRegistry
char *const * argv, int flags) override;
virtual void ManifestSkin(ManifestProcessingContext& cx, int lineno,
char *const * argv, int flags) override;
virtual void ManifestOverlay(ManifestProcessingContext& cx, int lineno,
char *const * argv, int flags) override;
virtual void ManifestOverride(ManifestProcessingContext& cx, int lineno,
char *const * argv, int flags) override;
virtual void ManifestResource(ManifestProcessingContext& cx, int lineno,

View File

@ -507,7 +507,6 @@ Document.prototype.importNode = function(externalNode, deep) {};
/** @param {string} uri */
Document.prototype.load = function(uri) {};
Document.prototype.loadOverlay;
/**
* @see https://developer.mozilla.org/en/DOM/document.open

View File

@ -48,24 +48,4 @@ interface XULDocument : Document {
[Throws]
BoxObject? getBoxObjectFor(Element? element);
/**
* Loads a XUL overlay and merges it with the current document, notifying an
* observer when the merge is complete.
* @param url
* The URL of the overlay to load and merge
* @param observer
* An object implementing nsIObserver that will be notified with a
* message of topic "xul-overlay-merged" when the merge is complete.
* The subject parameter of |observe| will QI to a nsIURI - the URI
* of the merged overlay. This parameter is optional and may be null.
*
* NOTICE: In the 2.0 timeframe this API will change such that the
* implementation will fire a DOMXULOverlayMerged event upon merge
* completion rather than notifying an observer. Do not rely on this
* API's behavior _not_ to change because it will!
* - Ben Goodger (8/23/2005)
*/
[Throws]
void loadOverlay(DOMString url, MozObserver? observer);
};

File diff suppressed because it is too large Load Diff

View File

@ -106,10 +106,6 @@ public:
* Sometimes the caller of OnPrototypeLoadDone resumes the walk itself
*/
nsresult OnPrototypeLoadDone(bool aResumeWalk);
/**
* Callback notifying when a document could not be parsed properly.
*/
bool OnDocumentParserError();
// nsINode interface overrides
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
@ -174,8 +170,6 @@ public:
void Persist(const nsAString& aId, const nsAString& aAttr,
ErrorResult& aRv);
using nsDocument::GetBoxObjectFor;
void LoadOverlay(const nsAString& aURL, nsIObserver* aObserver,
ErrorResult& aRv);
protected:
virtual ~XULDocument();
@ -201,10 +195,6 @@ protected:
nsIPrincipal* aDocumentPrincipal,
nsIParser** aResult);
nsresult
LoadOverlayInternal(nsIURI* aURI, bool aIsDynamic, bool* aShouldReturn,
bool* aFailureFromContent);
nsresult ApplyPersistentAttributes();
nsresult ApplyPersistentAttributesInternal();
nsresult ApplyPersistentAttributesToElements(const nsAString &aID,
@ -221,13 +211,6 @@ protected:
Element* aListener,
nsAtom* aAttr);
nsresult
BroadcastAttributeChangeFromOverlay(nsIContent* aNode,
int32_t aNameSpaceID,
nsAtom* aAttribute,
nsAtom* aPrefix,
const nsAString& aValue);
already_AddRefed<nsPIWindowRoot> GetWindowRoot();
static void DirectionChanged(const char* aPrefName, void* aData);
@ -275,12 +258,6 @@ protected:
*/
bool mStillWalking;
/**
* These two values control where persistent attributes get applied.
*/
bool mRestrictPersistence;
nsTHashtable<nsStringHashKey> mPersistenceIds;
nsCOMPtr<nsIDOMXULCommandDispatcher> mCommandDispatcher; // [OWNER] of the focus tracker
uint32_t mPendingSheets;
@ -323,22 +300,6 @@ protected:
friend class ContextStack;
ContextStack mContextStack;
enum State { eState_Master, eState_Overlay };
State mState;
/**
* An array of overlay nsIURIs that have yet to be resolved. The
* order of the array is significant: overlays at the _end_ of the
* array are resolved before overlays earlier in the array (i.e.,
* it is a stack).
*
* In the current implementation the order the overlays are loaded
* in is as follows: first overlays from xul-overlay PIs, in the
* same order as in the document, then the overlays from the chrome
* registry.
*/
nsTArray<nsCOMPtr<nsIURI> > mUnloadedOverlays;
/**
* Load the transcluded script at the specified URI. If the
* prototype construction must 'block' until the load has
@ -360,13 +321,6 @@ protected:
Element** aResult,
bool aIsRoot);
/**
* Create a hook-up element to which content nodes can be attached for
* later resolution.
*/
nsresult CreateOverlayElement(nsXULPrototypeElement* aPrototype,
Element** aResult);
/**
* Add attributes from the prototype to the element.
*/
@ -450,30 +404,6 @@ protected:
friend class BroadcasterHookup;
/**
* Used to hook up overlays
*/
class OverlayForwardReference : public nsForwardReference
{
protected:
XULDocument* mDocument; // [WEAK]
nsCOMPtr<Element> mOverlay; // [OWNER]
bool mResolved;
nsresult Merge(Element* aTargetNode, Element* aOverlayNode, bool aNotify);
public:
OverlayForwardReference(XULDocument* aDocument, Element* aOverlay)
: mDocument(aDocument), mOverlay(aOverlay), mResolved(false) {}
virtual ~OverlayForwardReference();
virtual Phase GetPhase() override { return eConstruction; }
virtual Result Resolve() override;
};
friend class OverlayForwardReference;
// The out params of FindBroadcaster only have values that make sense when
// the method returns NS_FINDBROADCASTER_FOUND. In all other cases, the
// values of the out params should not be relied on (though *aListener and
@ -495,24 +425,12 @@ protected:
Element *aListener,
const nsAString &aAttr);
// FIXME: This should probably be renamed, there's nothing guaranteeing that
// aChild is an Element as far as I can tell!
static
nsresult
InsertElement(nsINode* aParent, nsIContent* aChild, bool aNotify);
/**
* The current prototype that we are walking to construct the
* content model.
*/
RefPtr<nsXULPrototypeDocument> mCurrentPrototype;
/**
* The master document (outermost, .xul) prototype, from which
* all subdocuments get their security principals.
*/
RefPtr<nsXULPrototypeDocument> mMasterPrototype;
/**
* Owning references to all of the prototype documents that were
* used to construct this document.
@ -547,22 +465,6 @@ protected:
nsINode* aBeforeThis,
nsIContent* aPINode);
/**
* Inserts the passed <?xul-overlay ?> PI at the specified index.
* Schedules the referenced overlay URI for further processing.
*/
nsresult
InsertXULOverlayPI(const nsXULPrototypePI* aProtoPI,
nsINode* aParent,
nsINode* aBeforeThis,
nsIContent* aPINode);
/**
* Add overlays from the chrome registry to the set of unprocessed
* overlays still to do.
*/
nsresult AddChromeOverlays();
/**
* Resume (or initiate) an interrupted (or newly prepared)
* prototype walk.
@ -576,12 +478,6 @@ protected:
*/
nsresult DoneWalking();
/**
* Report that an overlay failed to load
* @param aURI the URI of the overlay that failed to load
*/
void ReportMissingOverlay(nsIURI* aURI);
class CachedChromeStreamListener : public nsIStreamListener {
protected:
RefPtr<XULDocument> mDocument;
@ -600,31 +496,11 @@ protected:
friend class CachedChromeStreamListener;
class ParserObserver : public nsIRequestObserver {
protected:
RefPtr<XULDocument> mDocument;
RefPtr<nsXULPrototypeDocument> mPrototype;
virtual ~ParserObserver();
public:
ParserObserver(XULDocument* aDocument,
nsXULPrototypeDocument* aPrototype);
NS_DECL_ISUPPORTS
NS_DECL_NSIREQUESTOBSERVER
};
friend class ParserObserver;
/**
* A map from a broadcaster element to a list of listener elements.
*/
PLDHashTable* mBroadcasterMap;
nsAutoPtr<nsInterfaceHashtable<nsURIHashKey,nsIObserver> > mOverlayLoadObservers;
nsAutoPtr<nsInterfaceHashtable<nsURIHashKey,nsIObserver> > mPendingOverlayLoadNotifications;
bool mInitialLayoutComplete;
class nsDelayedBroadcastUpdate

View File

@ -79,9 +79,7 @@ void
XULFrameElement::LoadSrc()
{
if (!IsInUncomposedDoc() ||
!OwnerDoc()->GetRootElement() ||
OwnerDoc()->GetRootElement()->
NodeInfo()->Equals(nsGkAtoms::overlay, kNameSpaceID_XUL)) {
!OwnerDoc()->GetRootElement()) {
return;
}
RefPtr<nsFrameLoader> frameLoader = GetFrameLoader();

View File

@ -15,10 +15,6 @@ MOCHITEST_MANIFESTS += ['test/mochitest.ini']
MOCHITEST_CHROME_MANIFESTS += ['test/chrome.ini']
if CONFIG['MOZ_XUL']:
XPIDL_SOURCES += [
'nsIXULOverlayProvider.idl',
]
EXPORTS += [
'nsXULElement.h',
]

View File

@ -1,26 +0,0 @@
/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 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/. */
#include "nsISupports.idl"
interface nsISimpleEnumerator;
interface nsIURI;
/**
* The chrome registry implements this interface to give overlays
* to the gecko XUL engine.
*/
[scriptable, uuid(1d5b5b94-dc47-4050-93b7-ac092e383cad)]
interface nsIXULOverlayProvider : nsISupports
{
/**
* Get the XUL overlays for a particular chrome URI.
*
* @param aURI The URI being loaded
* @return An enumerator of nsIURI for the overlays of this URI
*/
nsISimpleEnumerator /*nsIURI*/ getXULOverlays(in nsIURI aURI);
};

View File

@ -651,13 +651,6 @@ XULContentSinkImpl::ReportError(const char16_t* aErrorText,
return NS_OK;
};
if (idoc &&
idoc->IsXULDocument() &&
!idoc->AsXULDocument()->OnDocumentParserError()) {
// The overlay was broken. Don't add a messy element to the master doc.
return NS_OK;
}
const char16_t* noAtts[] = { 0, 0 };
NS_NAMED_LITERAL_STRING(errorNs,

View File

@ -426,8 +426,7 @@ nsXULElement::GetEventListenerManagerForAttr(nsAtom* aAttrName, bool* aDefer)
nsPIDOMWindowInner *window;
Element *root = doc->GetRootElement();
if ((!root || root == this) && !mNodeInfo->Equals(nsGkAtoms::overlay) &&
(window = doc->GetInnerWindow())) {
if ((!root || root == this) && (window = doc->GetInnerWindow())) {
nsCOMPtr<EventTarget> piTarget = do_QueryInterface(window);

View File

@ -14,8 +14,6 @@ service('ToolkitChromeRegistryService', 'nsIToolkitChromeRegistry',
"@mozilla.org/chrome/chrome-registry;1")
service('XULChromeRegistryService', 'nsIXULChromeRegistry',
"@mozilla.org/chrome/chrome-registry;1")
service('XULOverlayProviderService', 'nsIXULOverlayProvider',
"@mozilla.org/chrome/chrome-registry;1")
service('IOService', 'nsIIOService',
"@mozilla.org/network/io-service;1")
service('ObserverService', 'nsIObserverService',
@ -66,7 +64,6 @@ CPP_INCLUDES = """
#include "nsIChromeRegistry.h"
#include "nsIStringBundle.h"
#include "nsIToolkitChromeRegistry.h"
#include "nsIXULOverlayProvider.h"
#include "IHistory.h"
#include "nsIXPConnect.h"
#include "nsIPermissionManager.h"

View File

@ -103,10 +103,6 @@ static const ManifestDirective kParsingTable[] = {
"skin", 3, false, false, true, true, false,
nullptr, &nsChromeRegistry::ManifestSkin,
},
{
"overlay", 2, false, true, true, false, false,
nullptr, &nsChromeRegistry::ManifestOverlay,
},
{
// NB: note that while skin manifests can use this, they are only allowed
// to use it for chrome://../skin/ URLs