rename from content/xul/document/src/nsXULDocument.cpp
rename to content/xul/document/src/XULDocument.cpp
--- a/content/xul/document/src/nsXULDocument.cpp
+++ b/content/xul/document/src/XULDocument.cpp
@@ -19,17 +19,17 @@
document observer methods will never be called because we'll be
adding the XUL nodes into the content model "quietly".
*/
#include "mozilla/Util.h"
// Note the ALPHABETICAL ORDERING
-#include "nsXULDocument.h"
+#include "XULDocument.h"
#include "nsError.h"
#include "nsIBoxObject.h"
#include "nsIChromeRegistry.h"
#include "nsView.h"
#include "nsViewManager.h"
#include "nsIContentViewer.h"
#include "nsGUIEvent.h"
@@ -96,17 +96,16 @@ using namespace mozilla::dom;
//
// CIDs
//
static NS_DEFINE_CID(kParserCID, NS_PARSER_CID);
static bool IsChromeURI(nsIURI* aURI)
{
- // why is this check a member function of nsXULDocument? -gagan
bool isChrome = false;
if (NS_SUCCEEDED(aURI->SchemeIs("chrome", &isChrome)) && isChrome)
return true;
return false;
}
static bool IsOverlayAllowed(nsIURI* aURI)
{
@@ -132,24 +131,24 @@ const nsForwardReference::Phase nsForwar
const uint32_t kMaxAttrNameLength = 512;
const uint32_t kMaxAttributeLength = 4096;
//----------------------------------------------------------------------
//
// Statics
//
-int32_t nsXULDocument::gRefCnt = 0;
-
-nsIRDFService* nsXULDocument::gRDFService;
-nsIRDFResource* nsXULDocument::kNC_persist;
-nsIRDFResource* nsXULDocument::kNC_attribute;
-nsIRDFResource* nsXULDocument::kNC_value;
-
-PRLogModuleInfo* nsXULDocument::gXULLog;
+int32_t XULDocument::gRefCnt = 0;
+
+nsIRDFService* XULDocument::gRDFService;
+nsIRDFResource* XULDocument::kNC_persist;
+nsIRDFResource* XULDocument::kNC_attribute;
+nsIRDFResource* XULDocument::kNC_value;
+
+PRLogModuleInfo* XULDocument::gXULLog;
//----------------------------------------------------------------------
struct BroadcasterMapEntry : public PLDHashEntryHdr {
nsIDOMElement* mBroadcaster; // [WEAK]
nsSmallVoidArray mListeners; // [OWNING] of BroadcastListener objects
};
@@ -187,20 +186,22 @@ nsRefMapEntry::RemoveElement(Element* aE
return mRefContentList.Count() == 0;
}
//----------------------------------------------------------------------
//
// ctors & dtors
//
- // NOTE! nsDocument::operator new() zeroes out all members, so
- // don't bother initializing members to 0.
-
-nsXULDocument::nsXULDocument(void)
+DOMCI_NODE_DATA(XULDocument, XULDocument)
+
+namespace mozilla {
+namespace dom {
+
+XULDocument::XULDocument(void)
: XMLDocument("application/vnd.mozilla.xul+xml"),
mDocLWTheme(Doc_Theme_Uninitialized),
mState(eState_Master),
mResolutionPhase(nsForwardReference::eStart)
{
// NOTE! nsDocument::operator new() zeroes out all members, so don't
// bother initializing members to 0.
@@ -211,17 +212,17 @@ nsXULDocument::nsXULDocument(void)
mDefaultElementType = kNameSpaceID_XUL;
mIsXUL = true;
mDelayFrameLoaderInitialization = true;
mAllowXULXBL = eTriTrue;
}
-nsXULDocument::~nsXULDocument()
+XULDocument::~XULDocument()
{
NS_ASSERTION(mNextSrcLoadWaiter == nullptr,
"unreferenced document still waiting for script source to load?");
// In case we failed somewhere early on and the forward observer
// decls never got resolved.
mForwardReferences.Clear();
@@ -234,52 +235,58 @@ nsXULDocument::~nsXULDocument()
nsCOMPtr<nsIRDFRemoteDataSource> remote =
do_QueryInterface(mLocalStore);
if (remote)
remote->Flush();
}
delete mTemplateBuilderTable;
- Preferences::UnregisterCallback(nsXULDocument::DirectionChanged,
+ Preferences::UnregisterCallback(XULDocument::DirectionChanged,
"intl.uidirection.", this);
if (--gRefCnt == 0) {
NS_IF_RELEASE(gRDFService);
NS_IF_RELEASE(kNC_persist);
NS_IF_RELEASE(kNC_attribute);
NS_IF_RELEASE(kNC_value);
}
}
+} // namespace dom
+} // namespace mozilla
+
nsresult
NS_NewXULDocument(nsIXULDocument** result)
{
NS_PRECONDITION(result != nullptr, "null ptr");
if (! result)
return NS_ERROR_NULL_POINTER;
- nsXULDocument* doc = new nsXULDocument();
+ XULDocument* doc = new XULDocument();
if (! doc)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(doc);
nsresult rv;
if (NS_FAILED(rv = doc->Init())) {
NS_RELEASE(doc);
return rv;
}
*result = doc;
return NS_OK;
}
+namespace mozilla {
+namespace dom {
+
//----------------------------------------------------------------------
//
// nsISupports interface
//
static PLDHashOperator
TraverseTemplateBuilders(nsISupports* aKey, nsIXULTemplateBuilder* aData,
void* aContext)
@@ -302,19 +309,19 @@ TraverseObservers(nsIURI* aKey, nsIObser
static_cast<nsCycleCollectionTraversalCallback*>(aContext);
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(*cb, "mOverlayLoadObservers/mPendingOverlayLoadNotifications value");
cb->NoteXPCOMChild(aData);
return PL_DHASH_NEXT;
}
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsXULDocument, XMLDocument)
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(XULDocument, XMLDocument)
NS_ASSERTION(!nsCCUncollectableMarker::InGeneration(cb, tmp->GetMarkedCCGeneration()),
- "Shouldn't traverse nsXULDocument!");
+ "Shouldn't traverse XULDocument!");
// XXX tmp->mForwardReferences?
// XXX tmp->mContextStack?
// An element will only have a template builder as long as it's in the
// document, so we'll traverse the table here instead of from the element.
if (tmp->mTemplateBuilderTable)
tmp->mTemplateBuilderTable->EnumerateRead(TraverseTemplateBuilders, &cb);
@@ -331,78 +338,76 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mLocalStore)
if (tmp->mOverlayLoadObservers.IsInitialized())
tmp->mOverlayLoadObservers.EnumerateRead(TraverseObservers, &cb);
if (tmp->mPendingOverlayLoadNotifications.IsInitialized())
tmp->mPendingOverlayLoadNotifications.EnumerateRead(TraverseObservers, &cb);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsXULDocument, XMLDocument)
+NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(XULDocument, XMLDocument)
delete tmp->mTemplateBuilderTable;
tmp->mTemplateBuilderTable = nullptr;
NS_IMPL_CYCLE_COLLECTION_UNLINK(mCommandDispatcher)
//XXX We should probably unlink all the objects we traverse.
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
-NS_IMPL_ADDREF_INHERITED(nsXULDocument, XMLDocument)
-NS_IMPL_RELEASE_INHERITED(nsXULDocument, XMLDocument)
-
-
-DOMCI_NODE_DATA(XULDocument, nsXULDocument)
-
-// QueryInterface implementation for nsXULDocument
-NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsXULDocument)
- NS_DOCUMENT_INTERFACE_TABLE_BEGIN(nsXULDocument)
- NS_INTERFACE_TABLE_ENTRY(nsXULDocument, nsIXULDocument)
- NS_INTERFACE_TABLE_ENTRY(nsXULDocument, nsIDOMXULDocument)
- NS_INTERFACE_TABLE_ENTRY(nsXULDocument, nsIStreamLoaderObserver)
- NS_INTERFACE_TABLE_ENTRY(nsXULDocument, nsICSSLoaderObserver)
+NS_IMPL_ADDREF_INHERITED(XULDocument, XMLDocument)
+NS_IMPL_RELEASE_INHERITED(XULDocument, XMLDocument)
+
+
+// QueryInterface implementation for XULDocument
+NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(XULDocument)
+ NS_DOCUMENT_INTERFACE_TABLE_BEGIN(XULDocument)
+ NS_INTERFACE_TABLE_ENTRY(XULDocument, nsIXULDocument)
+ NS_INTERFACE_TABLE_ENTRY(XULDocument, nsIDOMXULDocument)
+ NS_INTERFACE_TABLE_ENTRY(XULDocument, nsIStreamLoaderObserver)
+ NS_INTERFACE_TABLE_ENTRY(XULDocument, nsICSSLoaderObserver)
NS_OFFSET_AND_INTERFACE_TABLE_END
NS_OFFSET_AND_INTERFACE_TABLE_TO_MAP_SEGUE
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(XULDocument)
NS_INTERFACE_MAP_END_INHERITING(XMLDocument)
//----------------------------------------------------------------------
//
// nsIDocument interface
//
void
-nsXULDocument::Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup)
+XULDocument::Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup)
{
NS_NOTREACHED("Reset");
}
void
-nsXULDocument::ResetToURI(nsIURI* aURI, nsILoadGroup* aLoadGroup,
- nsIPrincipal* aPrincipal)
+XULDocument::ResetToURI(nsIURI* aURI, nsILoadGroup* aLoadGroup,
+ nsIPrincipal* aPrincipal)
{
NS_NOTREACHED("ResetToURI");
}
void
-nsXULDocument::SetContentType(const nsAString& aContentType)
+XULDocument::SetContentType(const nsAString& aContentType)
{
NS_ASSERTION(aContentType.EqualsLiteral("application/vnd.mozilla.xul+xml"),
"xul-documents always has content-type application/vnd.mozilla.xul+xml");
// Don't do anything, xul always has the mimetype
// application/vnd.mozilla.xul+xml
}
// This is called when the master document begins loading, whether it's
// being cached or not.
nsresult
-nsXULDocument::StartDocumentLoad(const char* aCommand, nsIChannel* aChannel,
- nsILoadGroup* aLoadGroup,
- nsISupports* aContainer,
- nsIStreamListener **aDocListener,
- bool aReset, nsIContentSink* aSink)
+XULDocument::StartDocumentLoad(const char* aCommand, nsIChannel* aChannel,
+ nsILoadGroup* aLoadGroup,
+ nsISupports* aContainer,
+ nsIStreamListener **aDocListener,
+ bool aReset, nsIContentSink* aSink)
{
#ifdef PR_LOGGING
if (PR_LOG_TEST(gXULLog, PR_LOG_WARNING)) {
nsCOMPtr<nsIURI> uri;
nsresult rv = aChannel->GetOriginalURI(getter_AddRefs(uri));
if (NS_SUCCEEDED(rv)) {
nsAutoCString urlspec;
@@ -436,17 +441,17 @@ nsXULDocument::StartDocumentLoad(const c
// Look in the chrome cache: we've got this puppy loaded
// already.
nsXULPrototypeDocument* proto = IsChromeURI(mDocumentURI) ?
nsXULPrototypeCache::GetInstance()->GetPrototype(mDocumentURI) :
nullptr;
// Same comment as nsChromeProtocolHandler::NewChannel and
- // nsXULDocument::ResumeWalk
+ // XULDocument::ResumeWalk
// - Ben Goodger
//
// We don't abort on failure here because there are too many valid
// cases that can return failure, and the null-ness of |proto| is enough
// to trigger the fail-safe parse-from-disk solution. Example failure cases
// (for reference) include:
//
// NS_ERROR_NOT_AVAILABLE: the URI cannot be found in the startup cache,
@@ -454,31 +459,31 @@ nsXULDocument::StartDocumentLoad(const c
// other: the startup cache file could not be found, probably
// due to being accessed before a profile has been selected (e.g.
// loading chrome for the profile manager itself). This must be
// parsed from disk.
if (proto) {
// If we're racing with another document to load proto, wait till the
// load has finished loading before trying to add cloned style sheets.
- // nsXULDocument::EndLoad will call proto->NotifyLoadDone, which will
+ // XULDocument::EndLoad will call proto->NotifyLoadDone, which will
// find all racing documents and notify them via OnPrototypeLoadDone,
// which will add style sheet clones to each document.
bool loaded;
rv = proto->AwaitLoadDone(this, &loaded);
if (NS_FAILED(rv)) return rv;
mMasterPrototype = mCurrentPrototype = proto;
// Set up the right principal on ourselves.
SetPrincipal(proto->DocumentPrincipal());
// We need a listener, even if proto is not yet loaded, in which
// event the listener's OnStopRequest method does nothing, and all
- // the interesting work happens below nsXULDocument::EndLoad, from
+ // the interesting work happens below XULDocument::EndLoad, from
// the call there to mCurrentPrototype->NotifyLoadDone().
*aDocListener = new CachedChromeStreamListener(this, loaded);
if (! *aDocListener)
return NS_ERROR_OUT_OF_MEMORY;
}
else {
bool useXULCache = nsXULPrototypeCache::GetInstance()->IsEnabled();
bool fillXULCache = (useXULCache && IsChromeURI(mDocumentURI));
@@ -516,17 +521,17 @@ nsXULDocument::StartDocumentLoad(const c
NS_IF_ADDREF(*aDocListener);
return NS_OK;
}
// This gets invoked after a prototype for this document or one of
// its overlays is fully built in the content sink.
void
-nsXULDocument::EndLoad()
+XULDocument::EndLoad()
{
// This can happen if an overlay fails to load
if (!mCurrentPrototype)
return;
nsresult rv;
// Whack the prototype document into the cache so that the next
@@ -536,17 +541,17 @@ nsXULDocument::EndLoad()
bool isChrome = IsChromeURI(uri);
// Remember if the XUL cache is on
bool useXULCache = nsXULPrototypeCache::GetInstance()->IsEnabled();
// If the current prototype is an overlay document (non-master prototype)
// and we're filling the FastLoad disk cache, tell the cache we're done
// loading it, and write the prototype. The master prototype is put into
- // the cache earlier in nsXULDocument::StartDocumentLoad.
+ // the cache earlier in XULDocument::StartDocumentLoad.
if (useXULCache && mIsWritingFastLoad && isChrome &&
mMasterPrototype != mCurrentPrototype) {
nsXULPrototypeCache::GetInstance()->WritePrototype(mCurrentPrototype);
}
if (IsOverlayAllowed(uri)) {
nsCOMPtr<nsIXULOverlayProvider> reg =
mozilla::services::GetXULOverlayProviderService();
@@ -594,17 +599,17 @@ nsXULDocument::EndLoad()
PR_LOG(gXULLog, PR_LOG_WARNING,
("xul: Finished loading document '%s'", urlspec.get()));
}
}
#endif
}
NS_IMETHODIMP
-nsXULDocument::OnPrototypeLoadDone(bool aResumeWalk)
+XULDocument::OnPrototypeLoadDone(bool aResumeWalk)
{
nsresult rv;
// Add the style overlays from chrome registry, if any.
rv = AddPrototypeSheets();
if (NS_FAILED(rv)) return rv;
rv = PrepareToWalk();
@@ -614,17 +619,17 @@ nsXULDocument::OnPrototypeLoadDone(bool
if (aResumeWalk) {
rv = ResumeWalk();
}
return rv;
}
// called when an error occurs parsing a document
bool
-nsXULDocument::OnDocumentParserError()
+XULDocument::OnDocumentParserError()
{
// don't report errors that are from overlays
if (mCurrentPrototype && mMasterPrototype != mCurrentPrototype) {
nsCOMPtr<nsIURI> uri = mCurrentPrototype->GetURI();
if (IsChromeURI(uri)) {
nsCOMPtr<nsIObserverService> os =
mozilla::services::GetObserverService();
if (os)
@@ -677,19 +682,19 @@ struct nsAttrNameInfo
mNamespaceID(aOther.mNamespaceID), mName(aOther.mName),
mPrefix(aOther.mPrefix) {}
int32_t mNamespaceID;
nsCOMPtr<nsIAtom> mName;
nsCOMPtr<nsIAtom> mPrefix;
};
void
-nsXULDocument::SynchronizeBroadcastListener(nsIDOMElement *aBroadcaster,
- nsIDOMElement *aListener,
- const nsAString &aAttr)
+XULDocument::SynchronizeBroadcastListener(nsIDOMElement *aBroadcaster,
+ nsIDOMElement *aListener,
+ const nsAString &aAttr)
{
if (!nsContentUtils::IsSafeToRunScript()) {
nsDelayedBroadcastUpdate delayedUpdate(aBroadcaster, aListener,
aAttr);
mDelayedBroadcasters.AppendElement(delayedUpdate);
MaybeBroadcast();
return;
}
@@ -750,19 +755,19 @@ nsXULDocument::SynchronizeBroadcastListe
// handler before the |onload| handler, which could define JS
// properties that mask XBL properties, etc.
ExecuteOnBroadcastHandlerFor(broadcaster, aListener, name);
#endif
}
}
NS_IMETHODIMP
-nsXULDocument::AddBroadcastListenerFor(nsIDOMElement* aBroadcaster,
- nsIDOMElement* aListener,
- const nsAString& aAttr)
+XULDocument::AddBroadcastListenerFor(nsIDOMElement* aBroadcaster,
+ nsIDOMElement* aListener,
+ const nsAString& aAttr)
{
NS_ENSURE_ARG(aBroadcaster && aListener);
nsresult rv =
nsContentUtils::CheckSameOrigin(this, aBroadcaster);
if (NS_FAILED(rv)) {
return rv;
@@ -837,19 +842,19 @@ nsXULDocument::AddBroadcastListenerFor(n
entry->mListeners.AppendElement(bl);
SynchronizeBroadcastListener(aBroadcaster, aListener, aAttr);
return NS_OK;
}
NS_IMETHODIMP
-nsXULDocument::RemoveBroadcastListenerFor(nsIDOMElement* aBroadcaster,
- nsIDOMElement* aListener,
- const nsAString& aAttr)
+XULDocument::RemoveBroadcastListenerFor(nsIDOMElement* aBroadcaster,
+ nsIDOMElement* aListener,
+ const nsAString& aAttr)
{
// If we haven't added any broadcast listeners, then there sure
// aren't any to remove.
if (! mBroadcasterMap)
return NS_OK;
BroadcasterMapEntry* entry =
static_cast<BroadcasterMapEntry*>
@@ -876,19 +881,19 @@ nsXULDocument::RemoveBroadcastListenerFo
}
}
}
return NS_OK;
}
nsresult
-nsXULDocument::ExecuteOnBroadcastHandlerFor(nsIContent* aBroadcaster,
- nsIDOMElement* aListener,
- nsIAtom* aAttr)
+XULDocument::ExecuteOnBroadcastHandlerFor(nsIContent* aBroadcaster,
+ nsIDOMElement* aListener,
+ nsIAtom* aAttr)
{
// Now we execute the onchange handler in the context of the
// observer. We need to find the observer in order to
// execute the handler.
nsCOMPtr<nsIContent> listener = do_QueryInterface(aListener);
for (nsIContent* child = listener->GetFirstChild();
child;
@@ -936,37 +941,37 @@ nsXULDocument::ExecuteOnBroadcastHandler
&status);
}
}
return NS_OK;
}
void
-nsXULDocument::AttributeWillChange(nsIDocument* aDocument,
- Element* aElement, int32_t aNameSpaceID,
- nsIAtom* aAttribute, int32_t aModType)
+XULDocument::AttributeWillChange(nsIDocument* aDocument,
+ Element* aElement, int32_t aNameSpaceID,
+ nsIAtom* aAttribute, int32_t aModType)
{
NS_ABORT_IF_FALSE(aElement, "Null content!");
NS_PRECONDITION(aAttribute, "Must have an attribute that's changing!");
// XXXbz check aNameSpaceID, dammit!
// See if we need to update our ref map.
if (aAttribute == nsGkAtoms::ref ||
(aAttribute == nsGkAtoms::id && !aElement->GetIDAttributeName())) {
// Might not need this, but be safe for now.
nsCOMPtr<nsIMutationObserver> kungFuDeathGrip(this);
RemoveElementFromRefMap(aElement);
}
}
void
-nsXULDocument::AttributeChanged(nsIDocument* aDocument,
- Element* aElement, int32_t aNameSpaceID,
- nsIAtom* aAttribute, int32_t aModType)
+XULDocument::AttributeChanged(nsIDocument* aDocument,
+ Element* aElement, int32_t aNameSpaceID,
+ nsIAtom* aAttribute, int32_t aModType)
{
NS_ASSERTION(aDocument == this, "unexpected doc");
// Might not need this, but be safe for now.
nsCOMPtr<nsIMutationObserver> kungFuDeathGrip(this);
// XXXbz check aNameSpaceID, dammit!
// See if we need to update our ref map.
@@ -1051,103 +1056,103 @@ nsXULDocument::AttributeChanged(nsIDocum
if (persist.Find(nsDependentAtomString(aAttribute)) >= 0) {
rv = Persist(aElement, kNameSpaceID_None, aAttribute);
if (NS_FAILED(rv)) return;
}
}
}
void
-nsXULDocument::ContentAppended(nsIDocument* aDocument,
- nsIContent* aContainer,
- nsIContent* aFirstNewContent,
- int32_t aNewIndexInContainer)
+XULDocument::ContentAppended(nsIDocument* aDocument,
+ nsIContent* aContainer,
+ nsIContent* aFirstNewContent,
+ int32_t aNewIndexInContainer)
{
NS_ASSERTION(aDocument == this, "unexpected doc");
// Might not need this, but be safe for now.
nsCOMPtr<nsIMutationObserver> kungFuDeathGrip(this);
// Update our element map
nsresult rv = NS_OK;
for (nsIContent* cur = aFirstNewContent; cur && NS_SUCCEEDED(rv);
cur = cur->GetNextSibling()) {
rv = AddSubtreeToDocument(cur);
}
}
void
-nsXULDocument::ContentInserted(nsIDocument* aDocument,
- nsIContent* aContainer,
- nsIContent* aChild,
- int32_t aIndexInContainer)
+XULDocument::ContentInserted(nsIDocument* aDocument,
+ nsIContent* aContainer,
+ nsIContent* aChild,
+ int32_t aIndexInContainer)
{
NS_ASSERTION(aDocument == this, "unexpected doc");
// Might not need this, but be safe for now.
nsCOMPtr<nsIMutationObserver> kungFuDeathGrip(this);
AddSubtreeToDocument(aChild);
}
void
-nsXULDocument::ContentRemoved(nsIDocument* aDocument,
- nsIContent* aContainer,
- nsIContent* aChild,
- int32_t aIndexInContainer,
- nsIContent* aPreviousSibling)
+XULDocument::ContentRemoved(nsIDocument* aDocument,
+ nsIContent* aContainer,
+ nsIContent* aChild,
+ int32_t aIndexInContainer,
+ nsIContent* aPreviousSibling)
{
NS_ASSERTION(aDocument == this, "unexpected doc");
// Might not need this, but be safe for now.
nsCOMPtr<nsIMutationObserver> kungFuDeathGrip(this);
RemoveSubtreeFromDocument(aChild);
}
//----------------------------------------------------------------------
//
// nsIXULDocument interface
//
void
-nsXULDocument::GetElementsForID(const nsAString& aID,
- nsCOMArray<nsIContent>& aElements)
+XULDocument::GetElementsForID(const nsAString& aID,
+ nsCOMArray<nsIContent>& aElements)
{
aElements.Clear();
nsIdentifierMapEntry *entry = mIdentifierMap.GetEntry(aID);
if (entry) {
entry->AppendAllIdContent(&aElements);
}
nsRefMapEntry *refEntry = mRefMap.GetEntry(aID);
if (refEntry) {
refEntry->AppendAll(&aElements);
}
}
nsresult
-nsXULDocument::AddForwardReference(nsForwardReference* aRef)
+XULDocument::AddForwardReference(nsForwardReference* aRef)
{
if (mResolutionPhase < aRef->GetPhase()) {
if (!mForwardReferences.AppendElement(aRef)) {
delete aRef;
return NS_ERROR_OUT_OF_MEMORY;
}
}
else {
NS_ERROR("forward references have already been resolved");
delete aRef;
}
return NS_OK;
}
nsresult
-nsXULDocument::ResolveForwardReferences()
+XULDocument::ResolveForwardReferences()
{
if (mResolutionPhase == nsForwardReference::eDone)
return NS_OK;
NS_ASSERTION(mResolutionPhase == nsForwardReference::eStart,
"nested ResolveForwardReferences()");
// Resolve each outstanding 'forward' reference. We iterate
@@ -1180,47 +1185,47 @@ nsXULDocument::ResolveForwardReferences(
case nsForwardReference::eResolve_Later:
// do nothing. we'll try again later
;
}
if (mResolutionPhase == nsForwardReference::eStart) {
// Resolve() loaded a dynamic overlay,
- // (see nsXULDocument::LoadOverlayInternal()).
+ // (see XULDocument::LoadOverlayInternal()).
// Return for now, we will be called again.
return NS_OK;
}
}
}
}
++pass;
}
mForwardReferences.Clear();
return NS_OK;
}
NS_IMETHODIMP
-nsXULDocument::GetScriptGlobalObjectOwner(nsIScriptGlobalObjectOwner** aGlobalOwner)
+XULDocument::GetScriptGlobalObjectOwner(nsIScriptGlobalObjectOwner** aGlobalOwner)
{
NS_IF_ADDREF(*aGlobalOwner = mMasterPrototype);
return NS_OK;
}
//----------------------------------------------------------------------
//
// nsIDOMDocument interface
//
NS_IMETHODIMP
-nsXULDocument::GetElementsByAttribute(const nsAString& aAttribute,
- const nsAString& aValue,
- nsIDOMNodeList** aReturn)
+XULDocument::GetElementsByAttribute(const nsAString& aAttribute,
+ const nsAString& aValue,
+ nsIDOMNodeList** aReturn)
{
nsCOMPtr<nsIAtom> attrAtom(do_GetAtom(aAttribute));
NS_ENSURE_TRUE(attrAtom, NS_ERROR_OUT_OF_MEMORY);
void* attrValue = new nsString(aValue);
NS_ENSURE_TRUE(attrValue, NS_ERROR_OUT_OF_MEMORY);
nsContentList *list = new nsContentList(this,
MatchAttribute,
nsContentUtils::DestroyMatchString,
@@ -1230,20 +1235,20 @@ nsXULDocument::GetElementsByAttribute(co
kNameSpaceID_Unknown);
NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY);
NS_ADDREF(*aReturn = list);
return NS_OK;
}
NS_IMETHODIMP
-nsXULDocument::GetElementsByAttributeNS(const nsAString& aNamespaceURI,
- const nsAString& aAttribute,
- const nsAString& aValue,
- nsIDOMNodeList** aReturn)
+XULDocument::GetElementsByAttributeNS(const nsAString& aNamespaceURI,
+ const nsAString& aAttribute,
+ const nsAString& aValue,
+ nsIDOMNodeList** aReturn)
{
nsCOMPtr<nsIAtom> attrAtom(do_GetAtom(aAttribute));
NS_ENSURE_TRUE(attrAtom, NS_ERROR_OUT_OF_MEMORY);
void* attrValue = new nsString(aValue);
NS_ENSURE_TRUE(attrValue, NS_ERROR_OUT_OF_MEMORY);
int32_t nameSpaceId = kNameSpaceID_Wildcard;
if (!aNamespaceURI.EqualsLiteral("*")) {
@@ -1262,18 +1267,18 @@ nsXULDocument::GetElementsByAttributeNS(
nameSpaceId);
NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY);
NS_ADDREF(*aReturn = list);
return NS_OK;
}
NS_IMETHODIMP
-nsXULDocument::Persist(const nsAString& aID,
- const nsAString& aAttr)
+XULDocument::Persist(const nsAString& aID,
+ const nsAString& aAttr)
{
// If we're currently reading persisted attributes out of the
// localstore, _don't_ re-enter and try to set them again!
if (mApplyingPersistedAttrs)
return NS_OK;
nsresult rv;
@@ -1312,18 +1317,18 @@ nsXULDocument::Persist(const nsAString&
rv = Persist(element, nameSpaceID, tag);
if (NS_FAILED(rv)) return rv;
return NS_OK;
}
nsresult
-nsXULDocument::Persist(nsIContent* aElement, int32_t aNameSpaceID,
- nsIAtom* aAttribute)
+XULDocument::Persist(nsIContent* aElement, int32_t aNameSpaceID,
+ nsIAtom* aAttribute)
{
// For non-chrome documents, persistance is simply broken
if (!nsContentUtils::IsSystemPrincipal(NodePrincipal()))
return NS_ERROR_NOT_AVAILABLE;
// First make sure we _have_ a local store to stuff the persisted
// information into. (We might not have one if profile information
// hasn't been loaded yet...)
@@ -1419,18 +1424,18 @@ nsXULDocument::Persist(nsIContent* aElem
}
}
return NS_OK;
}
nsresult
-nsXULDocument::GetViewportSize(int32_t* aWidth,
- int32_t* aHeight)
+XULDocument::GetViewportSize(int32_t* aWidth,
+ int32_t* aHeight)
{
*aWidth = *aHeight = 0;
FlushPendingNotifications(Flush_Layout);
nsIPresShell *shell = GetShell();
NS_ENSURE_TRUE(shell, NS_ERROR_FAILURE);
@@ -1441,40 +1446,40 @@ nsXULDocument::GetViewportSize(int32_t*
*aWidth = nsPresContext::AppUnitsToIntCSSPixels(size.width);
*aHeight = nsPresContext::AppUnitsToIntCSSPixels(size.height);
return NS_OK;
}
NS_IMETHODIMP
-nsXULDocument::GetWidth(int32_t* aWidth)
+XULDocument::GetWidth(int32_t* aWidth)
{
NS_ENSURE_ARG_POINTER(aWidth);
int32_t height;
return GetViewportSize(aWidth, &height);
}
NS_IMETHODIMP
-nsXULDocument::GetHeight(int32_t* aHeight)
+XULDocument::GetHeight(int32_t* aHeight)
{
NS_ENSURE_ARG_POINTER(aHeight);
int32_t width;
return GetViewportSize(&width, aHeight);
}
//----------------------------------------------------------------------
//
// nsIDOMXULDocument interface
//
NS_IMETHODIMP
-nsXULDocument::GetPopupNode(nsIDOMNode** aNode)
+XULDocument::GetPopupNode(nsIDOMNode** aNode)
{
*aNode = nullptr;
nsCOMPtr<nsIDOMNode> node;
nsCOMPtr<nsPIWindowRoot> rootWin = GetWindowRoot();
if (rootWin)
node = rootWin->GetPopupNode(); // addref happens here
@@ -1487,17 +1492,17 @@ nsXULDocument::GetPopupNode(nsIDOMNode**
if (node && nsContentUtils::CanCallerAccess(node))
node.swap(*aNode);
return NS_OK;
}
NS_IMETHODIMP
-nsXULDocument::SetPopupNode(nsIDOMNode* aNode)
+XULDocument::SetPopupNode(nsIDOMNode* aNode)
{
if (aNode) {
// only allow real node objects
nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
NS_ENSURE_ARG(node);
}
nsCOMPtr<nsPIWindowRoot> rootWin = GetWindowRoot();
@@ -1505,17 +1510,17 @@ nsXULDocument::SetPopupNode(nsIDOMNode*
rootWin->SetPopupNode(aNode); // addref happens here
return NS_OK;
}
// Returns the rangeOffset element from the XUL Popup Manager. This is for
// chrome callers only.
NS_IMETHODIMP
-nsXULDocument::GetPopupRangeParent(nsIDOMNode** aRangeParent)
+XULDocument::GetPopupRangeParent(nsIDOMNode** aRangeParent)
{
NS_ENSURE_ARG_POINTER(aRangeParent);
*aRangeParent = nullptr;
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
if (!pm)
return NS_ERROR_FAILURE;
@@ -1528,17 +1533,17 @@ nsXULDocument::GetPopupRangeParent(nsIDO
}
return NS_OK;
}
// Returns the rangeOffset element from the XUL Popup Manager. We check the
// rangeParent to determine if the caller has rights to access to the data.
NS_IMETHODIMP
-nsXULDocument::GetPopupRangeOffset(int32_t* aRangeOffset)
+XULDocument::GetPopupRangeOffset(int32_t* aRangeOffset)
{
NS_ENSURE_ARG_POINTER(aRangeOffset);
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
if (!pm)
return NS_ERROR_FAILURE;
int32_t offset;
@@ -1548,48 +1553,48 @@ nsXULDocument::GetPopupRangeOffset(int32
if (parent && !nsContentUtils::CanCallerAccess(parent))
return NS_ERROR_DOM_SECURITY_ERR;
*aRangeOffset = offset;
return NS_OK;
}
NS_IMETHODIMP
-nsXULDocument::GetTooltipNode(nsIDOMNode** aNode)
+XULDocument::GetTooltipNode(nsIDOMNode** aNode)
{
*aNode = nullptr;
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
if (pm) {
nsCOMPtr<nsIDOMNode> node = pm->GetLastTriggerTooltipNode(this);
if (node && nsContentUtils::CanCallerAccess(node))
node.swap(*aNode);
}
return NS_OK;
}
NS_IMETHODIMP
-nsXULDocument::SetTooltipNode(nsIDOMNode* aNode)
+XULDocument::SetTooltipNode(nsIDOMNode* aNode)
{
// do nothing
return NS_OK;
}
NS_IMETHODIMP
-nsXULDocument::GetCommandDispatcher(nsIDOMXULCommandDispatcher** aTracker)
+XULDocument::GetCommandDispatcher(nsIDOMXULCommandDispatcher** aTracker)
{
*aTracker = mCommandDispatcher;
NS_IF_ADDREF(*aTracker);
return NS_OK;
}
Element*
-nsXULDocument::GetElementById(const nsAString& aId)
+XULDocument::GetElementById(const nsAString& aId)
{
if (!CheckGetElementByIdArg(aId))
return nullptr;
nsIdentifierMapEntry *entry = mIdentifierMap.GetEntry(aId);
if (entry) {
Element* element = entry->GetIdElement();
if (element)
@@ -1601,17 +1606,17 @@ nsXULDocument::GetElementById(const nsAS
NS_ASSERTION(refEntry->GetFirstElement(),
"nsRefMapEntries should have nonempty content lists");
return refEntry->GetFirstElement();
}
return nullptr;
}
nsresult
-nsXULDocument::AddElementToDocumentPre(Element* aElement)
+XULDocument::AddElementToDocumentPre(Element* aElement)
{
// Do a bunch of work that's necessary when an element gets added
// to the XUL Document.
nsresult rv;
// 1. Add the element to the resource-to-element map. Also add it to
// the id map, since it seems this can be called when creating
// elements from prototypes.
@@ -1648,17 +1653,17 @@ nsXULDocument::AddElementToDocumentPre(E
rv = AddForwardReference(hookup);
if (NS_FAILED(rv)) return rv;
}
return NS_OK;
}
nsresult
-nsXULDocument::AddElementToDocumentPost(Element* aElement)
+XULDocument::AddElementToDocumentPost(Element* aElement)
{
// We need to pay special attention to the keyset tag to set up a listener
if (aElement->NodeInfo()->Equals(nsGkAtoms::keyset, kNameSpaceID_XUL)) {
// Create our XUL key listener and hook it up.
nsXBLService::AttachGlobalKeyHandler(aElement);
}
// See if we need to attach a XUL template to this node
@@ -1683,17 +1688,17 @@ nsXULDocument::AddElementToDocumentPost(
return rv;
}
}
return NS_OK;
}
NS_IMETHODIMP
-nsXULDocument::AddSubtreeToDocument(nsIContent* aContent)
+XULDocument::AddSubtreeToDocument(nsIContent* aContent)
{
NS_ASSERTION(aContent->GetCurrentDoc() == this, "Element not in doc!");
// From here on we only care about elements.
if (!aContent->IsElement()) {
return NS_OK;
}
Element* aElement = aContent->AsElement();
@@ -1712,17 +1717,17 @@ nsXULDocument::AddSubtreeToDocument(nsIC
return rv;
}
// Do post-order addition magic
return AddElementToDocumentPost(aElement);
}
NS_IMETHODIMP
-nsXULDocument::RemoveSubtreeFromDocument(nsIContent* aContent)
+XULDocument::RemoveSubtreeFromDocument(nsIContent* aContent)
{
// From here on we only care about elements.
if (!aContent->IsElement()) {
return NS_OK;
}
Element* aElement = aContent->AsElement();
@@ -1776,18 +1781,18 @@ nsXULDocument::RemoveSubtreeFromDocument
if (rv == NS_FINDBROADCASTER_FOUND) {
RemoveBroadcastListenerFor(broadcaster, listener, attribute);
}
return NS_OK;
}
NS_IMETHODIMP
-nsXULDocument::SetTemplateBuilderFor(nsIContent* aContent,
- nsIXULTemplateBuilder* aBuilder)
+XULDocument::SetTemplateBuilderFor(nsIContent* aContent,
+ nsIXULTemplateBuilder* aBuilder)
{
if (! mTemplateBuilderTable) {
if (!aBuilder) {
return NS_OK;
}
mTemplateBuilderTable = new BuilderTable;
mTemplateBuilderTable->Init();
}
@@ -1798,18 +1803,18 @@ nsXULDocument::SetTemplateBuilderFor(nsI
else {
mTemplateBuilderTable->Remove(aContent);
}
return NS_OK;
}
NS_IMETHODIMP
-nsXULDocument::GetTemplateBuilderFor(nsIContent* aContent,
- nsIXULTemplateBuilder** aResult)
+XULDocument::GetTemplateBuilderFor(nsIContent* aContent,
+ nsIXULTemplateBuilder** aResult)
{
if (mTemplateBuilderTable) {
mTemplateBuilderTable->Get(aContent, aResult);
}
else
*aResult = nullptr;
return NS_OK;
@@ -1820,17 +1825,17 @@ GetRefMapAttribute(Element* aElement, ns
{
aElement->GetAttr(kNameSpaceID_None, nsGkAtoms::ref, *aValue);
if (aValue->IsEmpty() && !aElement->GetIDAttributeName()) {
aElement->GetAttr(kNameSpaceID_None, nsGkAtoms::id, *aValue);
}
}
nsresult
-nsXULDocument::AddElementToRefMap(Element* aElement)
+XULDocument::AddElementToRefMap(Element* aElement)
{
// Look at the element's 'ref' attribute, and if set,
// add an entry in the resource-to-element map to the element.
nsAutoString value;
GetRefMapAttribute(aElement, &value);
if (!value.IsEmpty()) {
nsRefMapEntry *entry = mRefMap.PutEntry(value);
if (!entry)
@@ -1838,17 +1843,17 @@ nsXULDocument::AddElementToRefMap(Elemen
if (!entry->AddElement(aElement))
return NS_ERROR_OUT_OF_MEMORY;
}
return NS_OK;
}
void
-nsXULDocument::RemoveElementFromRefMap(Element* aElement)
+XULDocument::RemoveElementFromRefMap(Element* aElement)
{
// Remove the element from the resource-to-element map.
nsAutoString value;
GetRefMapAttribute(aElement, &value);
if (!value.IsEmpty()) {
nsRefMapEntry *entry = mRefMap.GetEntry(value);
if (!entry)
return;
@@ -1859,31 +1864,31 @@ nsXULDocument::RemoveElementFromRefMap(E
}
//----------------------------------------------------------------------
//
// nsIDOMNode interface
//
nsresult
-nsXULDocument::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const
+XULDocument::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const
{
// We don't allow cloning of a XUL document
*aResult = nullptr;
return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
}
//----------------------------------------------------------------------
//
// Implementation methods
//
nsresult
-nsXULDocument::Init()
+XULDocument::Init()
{
mRefMap.Init();
nsresult rv = XMLDocument::Init();
NS_ENSURE_SUCCESS(rv, rv);
// Create our command dispatcher and hook it up.
mCommandDispatcher = new nsXULCommandDispatcher(this);
@@ -1913,30 +1918,30 @@ nsXULDocument::Init()
// null-checks in the rest of the class.
nsXULPrototypeCache* cache = nsXULPrototypeCache::GetInstance();
if (!cache) {
NS_ERROR("Could not instantiate nsXULPrototypeCache");
return NS_ERROR_FAILURE;
}
}
- Preferences::RegisterCallback(nsXULDocument::DirectionChanged,
+ Preferences::RegisterCallback(XULDocument::DirectionChanged,
"intl.uidirection.", this);
#ifdef PR_LOGGING
if (! gXULLog)
- gXULLog = PR_NewLogModule("nsXULDocument");
+ gXULLog = PR_NewLogModule("XULDocument");
#endif
return NS_OK;
}
nsresult
-nsXULDocument::StartLayout(void)
+XULDocument::StartLayout(void)
{
mMayStartLayout = true;
nsCOMPtr<nsIPresShell> shell = GetShell();
if (shell) {
// Resize-reflow this time
nsPresContext *cx = shell->GetPresContext();
NS_ASSERTION(cx != nullptr, "no pres context");
if (! cx)
@@ -1958,20 +1963,20 @@ nsXULDocument::StartLayout(void)
NS_ENSURE_SUCCESS(rv, rv);
}
return NS_OK;
}
/* static */
bool
-nsXULDocument::MatchAttribute(nsIContent* aContent,
- int32_t aNamespaceID,
- nsIAtom* aAttrName,
- void* aData)
+XULDocument::MatchAttribute(nsIContent* aContent,
+ int32_t aNamespaceID,
+ nsIAtom* aAttrName,
+ void* aData)
{
NS_PRECONDITION(aContent, "Must have content node to work with!");
nsString* attrValue = static_cast<nsString*>(aData);
if (aNamespaceID != kNameSpaceID_Unknown &&
aNamespaceID != kNameSpaceID_Wildcard) {
return attrValue->EqualsLiteral("*") ?
aContent->HasAttr(aNamespaceID, aAttrName) :
aContent->AttrValueIs(aNamespaceID, aAttrName, *attrValue,
@@ -1998,34 +2003,34 @@ nsXULDocument::MatchAttribute(nsIContent
*attrValue, eCaseMatters);
}
}
return false;
}
nsresult
-nsXULDocument::PrepareToLoad(nsISupports* aContainer,
- const char* aCommand,
- nsIChannel* aChannel,
- nsILoadGroup* aLoadGroup,
- nsIParser** aResult)
+XULDocument::PrepareToLoad(nsISupports* aContainer,
+ const char* aCommand,
+ nsIChannel* aChannel,
+ nsILoadGroup* aLoadGroup,
+ nsIParser** aResult)
{
// Get the document's principal
nsCOMPtr<nsIPrincipal> principal;
nsContentUtils::GetSecurityManager()->
GetChannelPrincipal(aChannel, getter_AddRefs(principal));
return PrepareToLoadPrototype(mDocumentURI, aCommand, principal, aResult);
}
nsresult
-nsXULDocument::PrepareToLoadPrototype(nsIURI* aURI, const char* aCommand,
- nsIPrincipal* aDocumentPrincipal,
- nsIParser** aResult)
+XULDocument::PrepareToLoadPrototype(nsIURI* aURI, const char* aCommand,
+ nsIPrincipal* aDocumentPrincipal,
+ nsIParser** aResult)
{
nsresult rv;
// Create a new prototype document.
rv = NS_NewXULPrototypeDocument(getter_AddRefs(mCurrentPrototype));
if (NS_FAILED(rv)) return rv;
rv = mCurrentPrototype->InitPrincipal(aURI, aDocumentPrincipal);
@@ -2063,17 +2068,17 @@ nsXULDocument::PrepareToLoadPrototype(ns
*aResult = parser;
NS_ADDREF(*aResult);
return NS_OK;
}
nsresult
-nsXULDocument::ApplyPersistentAttributes()
+XULDocument::ApplyPersistentAttributes()
{
// For non-chrome documents, persistance is simply broken
if (!nsContentUtils::IsSystemPrincipal(NodePrincipal()))
return NS_ERROR_NOT_AVAILABLE;
// Add all of the 'persisted' attributes into the content
// model.
if (!mLocalStore)
@@ -2083,17 +2088,17 @@ nsXULDocument::ApplyPersistentAttributes
ApplyPersistentAttributesInternal();
mApplyingPersistedAttrs = false;
return NS_OK;
}
nsresult
-nsXULDocument::ApplyPersistentAttributesInternal()
+XULDocument::ApplyPersistentAttributesInternal()
{
nsCOMArray<nsIContent> elements;
nsAutoCString docurl;
mDocumentURI->GetSpec(docurl);
nsCOMPtr<nsIRDFResource> doc;
gRDFService->GetResource(docurl, getter_AddRefs(doc));
@@ -2136,18 +2141,18 @@ nsXULDocument::ApplyPersistentAttributes
ApplyPersistentAttributesToElements(resource, elements);
}
return NS_OK;
}
nsresult
-nsXULDocument::ApplyPersistentAttributesToElements(nsIRDFResource* aResource,
- nsCOMArray<nsIContent>& aElements)
+XULDocument::ApplyPersistentAttributesToElements(nsIRDFResource* aResource,
+ nsCOMArray<nsIContent>& aElements)
{
nsresult rv;
nsCOMPtr<nsISimpleEnumerator> attrs;
rv = mLocalStore->ArcLabelsOut(aResource, getter_AddRefs(attrs));
if (NS_FAILED(rv)) return rv;
while (1) {
@@ -2208,47 +2213,47 @@ nsXULDocument::ApplyPersistentAttributes
true);
}
}
return NS_OK;
}
void
-nsXULDocument::TraceProtos(JSTracer* aTrc, uint32_t aGCNumber)
+XULDocument::TraceProtos(JSTracer* aTrc, uint32_t aGCNumber)
{
uint32_t i, count = mPrototypes.Length();
for (i = 0; i < count; ++i) {
mPrototypes[i]->TraceProtos(aTrc, aGCNumber);
}
}
//----------------------------------------------------------------------
//
-// nsXULDocument::ContextStack
+// XULDocument::ContextStack
//
-nsXULDocument::ContextStack::ContextStack()
+XULDocument::ContextStack::ContextStack()
: mTop(nullptr), mDepth(0)
{
}
-nsXULDocument::ContextStack::~ContextStack()
+XULDocument::ContextStack::~ContextStack()
{
while (mTop) {
Entry* doomed = mTop;
mTop = mTop->mNext;
NS_IF_RELEASE(doomed->mElement);
delete doomed;
}
}
nsresult
-nsXULDocument::ContextStack::Push(nsXULPrototypeElement* aPrototype,
- nsIContent* aElement)
+XULDocument::ContextStack::Push(nsXULPrototypeElement* aPrototype,
+ nsIContent* aElement)
{
Entry* entry = new Entry;
if (! entry)
return NS_ERROR_OUT_OF_MEMORY;
entry->mPrototype = aPrototype;
entry->mElement = aElement;
NS_IF_ADDREF(entry->mElement);
@@ -2257,65 +2262,65 @@ nsXULDocument::ContextStack::Push(nsXULP
entry->mNext = mTop;
mTop = entry;
++mDepth;
return NS_OK;
}
nsresult
-nsXULDocument::ContextStack::Pop()
+XULDocument::ContextStack::Pop()
{
if (mDepth == 0)
return NS_ERROR_UNEXPECTED;
Entry* doomed = mTop;
mTop = mTop->mNext;
--mDepth;
NS_IF_RELEASE(doomed->mElement);
delete doomed;
return NS_OK;
}
nsresult
-nsXULDocument::ContextStack::Peek(nsXULPrototypeElement** aPrototype,
- nsIContent** aElement,
- int32_t* aIndex)
+XULDocument::ContextStack::Peek(nsXULPrototypeElement** aPrototype,
+ nsIContent** aElement,
+ int32_t* aIndex)
{
if (mDepth == 0)
return NS_ERROR_UNEXPECTED;
*aPrototype = mTop->mPrototype;
*aElement = mTop->mElement;
NS_IF_ADDREF(*aElement);
*aIndex = mTop->mIndex;
return NS_OK;
}
nsresult
-nsXULDocument::ContextStack::SetTopIndex(int32_t aIndex)
+XULDocument::ContextStack::SetTopIndex(int32_t aIndex)
{
if (mDepth == 0)
return NS_ERROR_UNEXPECTED;
mTop->mIndex = aIndex;
return NS_OK;
}
//----------------------------------------------------------------------
//
// Content model walking routines
//
nsresult
-nsXULDocument::PrepareToWalk()
+XULDocument::PrepareToWalk()
{
// Prepare to walk the mCurrentPrototype
nsresult rv;
// Keep an owning reference to the prototype document so that its
// elements aren't yanked from beneath us.
mPrototypes.AppendElement(mCurrentPrototype);
@@ -2395,18 +2400,18 @@ nsXULDocument::PrepareToWalk()
rv = mContextStack.Push(proto, root);
if (NS_FAILED(rv)) return rv;
return NS_OK;
}
nsresult
-nsXULDocument::CreateAndInsertPI(const nsXULPrototypePI* aProtoPI,
- nsINode* aParent, uint32_t aIndex)
+XULDocument::CreateAndInsertPI(const nsXULPrototypePI* aProtoPI,
+ nsINode* aParent, uint32_t aIndex)
{
NS_PRECONDITION(aProtoPI, "null ptr");
NS_PRECONDITION(aParent, "null ptr");
nsresult rv;
nsCOMPtr<nsIContent> node;
rv = NS_NewXMLProcessingInstruction(getter_AddRefs(node),
@@ -2423,20 +2428,20 @@ nsXULDocument::CreateAndInsertPI(const n
// No special processing, just add the PI to the document.
rv = aParent->InsertChildAt(node, aIndex, false);
}
return rv;
}
nsresult
-nsXULDocument::InsertXMLStylesheetPI(const nsXULPrototypePI* aProtoPI,
- nsINode* aParent,
- uint32_t aIndex,
- nsIContent* aPINode)
+XULDocument::InsertXMLStylesheetPI(const nsXULPrototypePI* aProtoPI,
+ nsINode* aParent,
+ uint32_t aIndex,
+ nsIContent* aPINode)
{
nsCOMPtr<nsIStyleSheetLinkingElement> ssle(do_QueryInterface(aPINode));
NS_ASSERTION(ssle, "passed XML Stylesheet node does not "
"implement nsIStyleSheetLinkingElement!");
nsresult rv;
ssle->InitStyleLinkElement(false);
@@ -2465,20 +2470,20 @@ nsXULDocument::InsertXMLStylesheetPI(con
if (rv == NS_ERROR_OUT_OF_MEMORY) {
return rv;
}
return NS_OK;
}
nsresult
-nsXULDocument::InsertXULOverlayPI(const nsXULPrototypePI* aProtoPI,
- nsINode* aParent,
- uint32_t aIndex,
- nsIContent* aPINode)
+XULDocument::InsertXULOverlayPI(const nsXULPrototypePI* aProtoPI,
+ nsINode* aParent,
+ uint32_t aIndex,
+ nsIContent* aPINode)
{
nsresult rv;
rv = aParent->InsertChildAt(aPINode, aIndex, false);
if (NS_FAILED(rv)) return rv;
// xul-overlay PI is special only in prolog
if (!nsContentUtils::InProlog(aPINode)) {
@@ -2514,17 +2519,17 @@ nsXULDocument::InsertXULOverlayPI(const
// XXX report this to the Error Console (bug 359846)
rv = NS_OK;
}
return rv;
}
nsresult
-nsXULDocument::AddChromeOverlays()
+XULDocument::AddChromeOverlays()
{
nsresult rv;
nsCOMPtr<nsIURI> docUri = mCurrentPrototype->GetURI();
/* overlays only apply to chrome or about URIs */
if (!IsOverlayAllowed(docUri)) return NS_OK;
@@ -2549,25 +2554,25 @@ nsXULDocument::AddChromeOverlays()
if (NS_FAILED(rv) || !next) break;
uri = do_QueryInterface(next);
if (!uri) {
NS_ERROR("Chrome registry handed me a non-nsIURI object!");
continue;
}
- // Same comment as in nsXULDocument::InsertXULOverlayPI
+ // Same comment as in XULDocument::InsertXULOverlayPI
mUnloadedOverlays.InsertElementAt(0, uri);
}
return rv;
}
NS_IMETHODIMP
-nsXULDocument::LoadOverlay(const nsAString& aURL, nsIObserver* aObserver)
+XULDocument::LoadOverlay(const nsAString& aURL, nsIObserver* aObserver)
{
nsresult rv;
nsCOMPtr<nsIURI> uri;
rv = NS_NewURI(getter_AddRefs(uri), aURL, nullptr);
if (NS_FAILED(rv)) return rv;
if (aObserver) {
@@ -2587,19 +2592,19 @@ nsXULDocument::LoadOverlay(const nsAStri
bool shouldReturn, failureFromContent;
rv = LoadOverlayInternal(uri, true, &shouldReturn, &failureFromContent);
if (NS_FAILED(rv) && mOverlayLoadObservers.IsInitialized())
mOverlayLoadObservers.Remove(uri); // remove the observer if LoadOverlayInternal generated an error
return rv;
}
nsresult
-nsXULDocument::LoadOverlayInternal(nsIURI* aURI, bool aIsDynamic,
- bool* aShouldReturn,
- bool* aFailureFromContent)
+XULDocument::LoadOverlayInternal(nsIURI* aURI, bool aIsDynamic,
+ bool* aShouldReturn,
+ bool* aFailureFromContent)
{
nsresult rv;
*aShouldReturn = false;
*aFailureFromContent = false;
#ifdef PR_LOGGING
if (PR_LOG_TEST(gXULLog, PR_LOG_DEBUG)) {
@@ -2639,17 +2644,17 @@ nsXULDocument::LoadOverlayInternal(nsIUR
// the specified overlay URI. Only use the cache if the containing
// document is chrome otherwise it may not have a system principal and
// the cached document will, see bug 565610.
bool overlayIsChrome = IsChromeURI(aURI);
mCurrentPrototype = overlayIsChrome && documentIsChrome ?
nsXULPrototypeCache::GetInstance()->GetPrototype(aURI) : nullptr;
// Same comment as nsChromeProtocolHandler::NewChannel and
- // nsXULDocument::StartDocumentLoad
+ // XULDocument::StartDocumentLoad
// - Ben Goodger
//
// We don't abort on failure here because there are too many valid
// cases that can return failure, and the null-ness of |proto| is
// enough to trigger the fail-safe parse-from-disk solution.
// Example failure cases (for reference) include:
//
// NS_ERROR_NOT_AVAILABLE: the URI was not found in the FastLoad file,
@@ -2779,17 +2784,17 @@ FirePendingMergeNotification(nsIURI* aKe
typedef nsInterfaceHashtable<nsURIHashKey,nsIObserver> table;
table* observers = static_cast<table*>(aClosure);
observers->Remove(aKey);
return PL_DHASH_REMOVE;
}
nsresult
-nsXULDocument::ResumeWalk()
+XULDocument::ResumeWalk()
{
// Walk the prototype and build the delegate content model. The
// walk is performed in a top-down, left-to-right fashion. That
// is, a parent is built before any of its children; a node is
// only built after all of its siblings to the left are fully
// constructed.
//
// It is interruptable so that transcluded documents (e.g.,
@@ -3053,17 +3058,17 @@ nsXULDocument::ResumeWalk()
mStillWalking = false;
if (mPendingSheets == 0) {
rv = DoneWalking();
}
return rv;
}
nsresult
-nsXULDocument::DoneWalking()
+XULDocument::DoneWalking()
{
NS_PRECONDITION(mPendingSheets == 0, "there are sheets to be loaded");
NS_PRECONDITION(!mStillWalking, "walk not done");
// XXXldb This is where we should really be setting the chromehidden
// attribute.
uint32_t count = mOverlaySheets.Length();
@@ -3172,19 +3177,19 @@ nsXULDocument::DoneWalking()
}
}
}
return NS_OK;
}
NS_IMETHODIMP
-nsXULDocument::StyleSheetLoaded(nsCSSStyleSheet* aSheet,
- bool aWasAlternate,
- nsresult aStatus)
+XULDocument::StyleSheetLoaded(nsCSSStyleSheet* aSheet,
+ bool aWasAlternate,
+ nsresult aStatus)
{
if (!aWasAlternate) {
// Don't care about when alternate sheets finish loading
NS_ASSERTION(mPendingSheets > 0,
"Unexpected StyleSheetLoaded notification");
--mPendingSheets;
@@ -3193,26 +3198,26 @@ nsXULDocument::StyleSheetLoaded(nsCSSSty
return DoneWalking();
}
}
return NS_OK;
}
void
-nsXULDocument::MaybeBroadcast()
+XULDocument::MaybeBroadcast()
{
// Only broadcast when not in an update and when safe to run scripts.
if (mUpdateNestLevel == 0 &&
(mDelayedAttrChangeBroadcasts.Length() ||
mDelayedBroadcasters.Length())) {
if (!nsContentUtils::IsSafeToRunScript()) {
if (!mInDestructor) {
nsContentUtils::AddScriptRunner(
- NS_NewRunnableMethod(this, &nsXULDocument::MaybeBroadcast));
+ NS_NewRunnableMethod(this, &XULDocument::MaybeBroadcast));
}
return;
}
if (!mHandlingDelayedAttrChange) {
mHandlingDelayedAttrChange = true;
for (uint32_t i = 0; i < mDelayedAttrChangeBroadcasts.Length(); ++i) {
nsIAtom* attrName = mDelayedAttrChangeBroadcasts[i].mAttrName;
if (mDelayedAttrChangeBroadcasts[i].mNeedsAttrChange) {
@@ -3249,42 +3254,42 @@ nsXULDocument::MaybeBroadcast()
delayedBroadcasters[i].mAttr);
}
mHandlingDelayedBroadcasters = oldValue;
}
}
}
void
-nsXULDocument::EndUpdate(nsUpdateType aUpdateType)
+XULDocument::EndUpdate(nsUpdateType aUpdateType)
{
XMLDocument::EndUpdate(aUpdateType);
MaybeBroadcast();
}
void
-nsXULDocument::ReportMissingOverlay(nsIURI* aURI)
+XULDocument::ReportMissingOverlay(nsIURI* aURI)
{
NS_PRECONDITION(aURI, "Must have a URI");
nsAutoCString spec;
aURI->GetSpec(spec);
NS_ConvertUTF8toUTF16 utfSpec(spec);
const PRUnichar* params[] = { utfSpec.get() };
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
"XUL Document", this,
nsContentUtils::eXUL_PROPERTIES,
"MissingOverlay",
params, ArrayLength(params));
}
nsresult
-nsXULDocument::LoadScript(nsXULPrototypeScript* aScriptProto, bool* aBlock)
+XULDocument::LoadScript(nsXULPrototypeScript* aScriptProto, bool* aBlock)
{
// Load a transcluded script
nsresult rv;
bool isChromeDoc = IsChromeURI(mDocumentURI);
if (isChromeDoc && aScriptProto->GetScriptObject()) {
rv = ExecuteScript(aScriptProto);
@@ -3363,21 +3368,21 @@ nsXULDocument::LoadScript(nsXULPrototype
// Block until OnStreamComplete resumes us.
*aBlock = true;
return NS_OK;
}
NS_IMETHODIMP
-nsXULDocument::OnStreamComplete(nsIStreamLoader* aLoader,
- nsISupports* context,
- nsresult aStatus,
- uint32_t stringLen,
- const uint8_t* string)
+XULDocument::OnStreamComplete(nsIStreamLoader* aLoader,
+ nsISupports* context,
+ nsresult aStatus,
+ uint32_t stringLen,
+ const uint8_t* string)
{
nsCOMPtr<nsIRequest> request;
aLoader->GetRequest(getter_AddRefs(request));
nsCOMPtr<nsIChannel> channel = do_QueryInterface(request);
#ifdef DEBUG
// print a load error on bad status
if (NS_FAILED(aStatus)) {
@@ -3453,17 +3458,17 @@ nsXULDocument::OnStreamComplete(nsIStrea
// the fillXULCache logic.
//
// A document such as about:config is free to load a script via
// a URL such as chrome://global/content/config.js, and we must
// not cache that script object without a prototype cache entry
// containing a companion nsXULPrototypeScript node that owns a
// GC root protecting the script object. Otherwise, the script
// cache entry will dangle once the uncached prototype document
- // is released when its owning nsXULDocument is unloaded.
+ // is released when its owning XULDocument is unloaded.
//
// (See http://bugzilla.mozilla.org/show_bug.cgi?id=98207 for
// the true crime story.)
bool useXULCache = nsXULPrototypeCache::GetInstance()->IsEnabled();
if (useXULCache && IsChromeURI(mDocumentURI)) {
nsXULPrototypeCache::GetInstance()->PutScript(
scriptProto->mSrcURI,
@@ -3496,23 +3501,23 @@ nsXULDocument::OnStreamComplete(nsIStrea
}
}
}
// ignore any evaluation errors
}
rv = ResumeWalk();
- // Load a pointer to the prototype-script's list of nsXULDocuments who
+ // Load a pointer to the prototype-script's list of XULDocuments who
// raced to load the same script
- nsXULDocument** docp = &scriptProto->mSrcLoadWaiters;
+ XULDocument** docp = &scriptProto->mSrcLoadWaiters;
// Resume walking other documents that waited for this one's load, first
// executing the script we just compiled, in each doc's script context
- nsXULDocument* doc;
+ XULDocument* doc;
while ((doc = *docp) != nullptr) {
NS_ASSERTION(doc->mCurrentScriptProto == scriptProto,
"waiting for wrong script to load?");
doc->mCurrentScriptProto = nullptr;
// Unlink doc from scriptProto's list before executing and resuming
*docp = doc->mNextSrcLoadWaiter;
doc->mNextSrcLoadWaiter = nullptr;
@@ -3525,31 +3530,31 @@ nsXULDocument::OnStreamComplete(nsIStrea
NS_RELEASE(doc);
}
return rv;
}
nsresult
-nsXULDocument::ExecuteScript(nsIScriptContext * aContext, JSScript* aScriptObject)
+XULDocument::ExecuteScript(nsIScriptContext * aContext, JSScript* aScriptObject)
{
NS_PRECONDITION(aScriptObject != nullptr && aContext != nullptr, "null ptr");
if (! aScriptObject || ! aContext)
return NS_ERROR_NULL_POINTER;
NS_ENSURE_TRUE(mScriptGlobalObject, NS_ERROR_NOT_INITIALIZED);
// Execute the precompiled script with the given version
JSObject* global = mScriptGlobalObject->GetGlobalJSObject();
return aContext->ExecuteScript(aScriptObject, global);
}
nsresult
-nsXULDocument::ExecuteScript(nsXULPrototypeScript *aScript)
+XULDocument::ExecuteScript(nsXULPrototypeScript *aScript)
{
NS_PRECONDITION(aScript != nullptr, "null ptr");
NS_ENSURE_TRUE(aScript, NS_ERROR_NULL_POINTER);
NS_ENSURE_TRUE(mScriptGlobalObject, NS_ERROR_NOT_INITIALIZED);
nsresult rv;
rv = mScriptGlobalObject->EnsureScriptEnvironment();
NS_ENSURE_SUCCESS(rv, rv);
@@ -3563,19 +3568,19 @@ nsXULDocument::ExecuteScript(nsXULProtot
rv = ExecuteScript(context, aScript->GetScriptObject());
else
rv = NS_ERROR_UNEXPECTED;
return rv;
}
nsresult
-nsXULDocument::CreateElementFromPrototype(nsXULPrototypeElement* aPrototype,
- Element** aResult,
- bool aIsRoot)
+XULDocument::CreateElementFromPrototype(nsXULPrototypeElement* aPrototype,
+ Element** aResult,
+ bool aIsRoot)
{
// Create a content model element from a prototype element.
NS_PRECONDITION(aPrototype != nullptr, "null ptr");
if (! aPrototype)
return NS_ERROR_NULL_POINTER;
*aResult = nullptr;
nsresult rv = NS_OK;
@@ -3621,18 +3626,18 @@ nsXULDocument::CreateElementFromPrototyp
}
result.swap(*aResult);
return NS_OK;
}
nsresult
-nsXULDocument::CreateOverlayElement(nsXULPrototypeElement* aPrototype,
- Element** aResult)
+XULDocument::CreateOverlayElement(nsXULPrototypeElement* aPrototype,
+ Element** aResult)
{
nsresult rv;
nsRefPtr<Element> element;
rv = CreateElementFromPrototype(aPrototype, getter_AddRefs(element), false);
if (NS_FAILED(rv)) return rv;
OverlayForwardReference* fwdref =
@@ -3644,18 +3649,18 @@ nsXULDocument::CreateOverlayElement(nsXU
rv = AddForwardReference(fwdref);
if (NS_FAILED(rv)) return rv;
NS_ADDREF(*aResult = element);
return NS_OK;
}
nsresult
-nsXULDocument::AddAttributes(nsXULPrototypeElement* aPrototype,
- nsIContent* aElement)
+XULDocument::AddAttributes(nsXULPrototypeElement* aPrototype,
+ nsIContent* aElement)
{
nsresult rv;
for (uint32_t i = 0; i < aPrototype->mNumAttributes; ++i) {
nsXULPrototypeAttribute* protoattr = &(aPrototype->mAttributes[i]);
nsAutoString valueStr;
protoattr->mValue.ToString(valueStr);
@@ -3667,18 +3672,18 @@ nsXULDocument::AddAttributes(nsXULProtot
if (NS_FAILED(rv)) return rv;
}
return NS_OK;
}
nsresult
-nsXULDocument::CheckTemplateBuilderHookup(nsIContent* aElement,
- bool* aNeedsHookup)
+XULDocument::CheckTemplateBuilderHookup(nsIContent* aElement,
+ bool* aNeedsHookup)
{
// See if the element already has a `database' attribute. If it
// does, then the template builder has already been created.
//
// XXX This approach will crash and burn (well, maybe not _that_
// bad) if aElement is not a XUL element.
//
// XXXvarga Do we still want to support non XUL content?
@@ -3695,17 +3700,17 @@ nsXULDocument::CheckTemplateBuilderHooku
// Check aElement for a 'datasources' attribute, if it has
// one a XUL template builder needs to be hooked up.
*aNeedsHookup = aElement->HasAttr(kNameSpaceID_None,
nsGkAtoms::datasources);
return NS_OK;
}
/* static */ nsresult
-nsXULDocument::CreateTemplateBuilder(nsIContent* aElement)
+XULDocument::CreateTemplateBuilder(nsIContent* aElement)
{
// Check if need to construct a tree builder or content builder.
bool isTreeBuilder = false;
// return successful if the element is not is a document, as an inline
// script could have removed it
nsIDocument *document = aElement->GetCurrentDoc();
NS_ENSURE_TRUE(document, NS_OK);
@@ -3766,17 +3771,17 @@ nsXULDocument::CreateTemplateBuilder(nsI
builder->CreateContents(aElement, false);
}
return NS_OK;
}
nsresult
-nsXULDocument::AddPrototypeSheets()
+XULDocument::AddPrototypeSheets()
{
nsresult rv;
const nsCOMArray<nsIURI>& sheets = mCurrentPrototype->GetStyleSheetReferences();
for (int32_t i = 0; i < sheets.Count(); i++) {
nsCOMPtr<nsIURI> uri = sheets[i];
@@ -3798,21 +3803,21 @@ nsXULDocument::AddPrototypeSheets()
}
return NS_OK;
}
//----------------------------------------------------------------------
//
-// nsXULDocument::OverlayForwardReference
+// XULDocument::OverlayForwardReference
//
nsForwardReference::Result
-nsXULDocument::OverlayForwardReference::Resolve()
+XULDocument::OverlayForwardReference::Resolve()
{
// Resolve a forward reference from an overlay element; attempt to
// hook it up into the main document.
nsresult rv;
nsCOMPtr<nsIContent> target;
nsIPresShell *shell = mDocument->GetShell();
bool notify = shell && shell->DidInitialize();
@@ -3867,19 +3872,19 @@ nsXULDocument::OverlayForwardReference::
mResolved = true;
return eResolve_Succeeded;
}
nsresult
-nsXULDocument::OverlayForwardReference::Merge(nsIContent* aTargetNode,
- nsIContent* aOverlayNode,
- bool aNotify)
+XULDocument::OverlayForwardReference::Merge(nsIContent* aTargetNode,
+ nsIContent* aOverlayNode,
+ bool aNotify)
{
// This function is given:
// aTargetNode: the node in the document whose 'id' attribute
// matches a toplevel node in our overlay.
// aOverlayNode: the node in the overlay document that matches
// a node in the actual document.
// aNotify: whether or not content manipulation methods should
// use the aNotify parameter. After the initial
@@ -4016,17 +4021,17 @@ nsXULDocument::OverlayForwardReference::
if (NS_FAILED(rv)) return rv;
}
return NS_OK;
}
-nsXULDocument::OverlayForwardReference::~OverlayForwardReference()
+XULDocument::OverlayForwardReference::~OverlayForwardReference()
{
#ifdef PR_LOGGING
if (PR_LOG_TEST(gXULLog, PR_LOG_WARNING) && !mResolved) {
nsAutoString id;
mOverlay->GetAttr(kNameSpaceID_None, nsGkAtoms::id, id);
nsAutoCString idC;
idC.AssignWithConversion(id);
@@ -4045,33 +4050,33 @@ nsXULDocument::OverlayForwardReference::
urlspec.get(), idC.get(), parentDoc.get()));
}
#endif
}
//----------------------------------------------------------------------
//
-// nsXULDocument::BroadcasterHookup
+// XULDocument::BroadcasterHookup
//
nsForwardReference::Result
-nsXULDocument::BroadcasterHookup::Resolve()
+XULDocument::BroadcasterHookup::Resolve()
{
nsresult rv;
bool listener;
rv = mDocument->CheckBroadcasterHookup(mObservesElement, &listener, &mResolved);
if (NS_FAILED(rv)) return eResolve_Error;
return mResolved ? eResolve_Succeeded : eResolve_Later;
}
-nsXULDocument::BroadcasterHookup::~BroadcasterHookup()
+XULDocument::BroadcasterHookup::~BroadcasterHookup()
{
#ifdef PR_LOGGING
if (PR_LOG_TEST(gXULLog, PR_LOG_WARNING) && !mResolved) {
// Tell the world we failed
nsIAtom *tag = mObservesElement->Tag();
nsAutoString broadcasterID;
nsAutoString attribute;
@@ -4095,21 +4100,21 @@ nsXULDocument::BroadcasterHookup::~Broad
broadcasteridC.get()));
}
#endif
}
//----------------------------------------------------------------------
//
-// nsXULDocument::TemplateBuilderHookup
+// XULDocument::TemplateBuilderHookup
//
nsForwardReference::Result
-nsXULDocument::TemplateBuilderHookup::Resolve()
+XULDocument::TemplateBuilderHookup::Resolve()
{
bool needsHookup;
nsresult rv = CheckTemplateBuilderHookup(mElement, &needsHookup);
if (NS_FAILED(rv))
return eResolve_Error;
if (needsHookup) {
rv = CreateTemplateBuilder(mElement);
@@ -4119,21 +4124,21 @@ nsXULDocument::TemplateBuilderHookup::Re
return eResolve_Succeeded;
}
//----------------------------------------------------------------------
nsresult
-nsXULDocument::BroadcastAttributeChangeFromOverlay(nsIContent* aNode,
- int32_t aNameSpaceID,
- nsIAtom* aAttribute,
- nsIAtom* aPrefix,
- const nsAString& aValue)
+XULDocument::BroadcastAttributeChangeFromOverlay(nsIContent* aNode,
+ int32_t aNameSpaceID,
+ nsIAtom* aAttribute,
+ nsIAtom* aPrefix,
+ const nsAString& aValue)
{
nsresult rv = NS_OK;
if (!mBroadcasterMap || !CanBroadcast(aNameSpaceID, aAttribute))
return rv;
nsCOMPtr<nsIDOMElement> domele = do_QueryInterface(aNode);
if (!domele)
@@ -4160,21 +4165,21 @@ nsXULDocument::BroadcastAttributeChangeF
aPrefix, aValue, false);
if (NS_FAILED(rv)) return rv;
}
}
return rv;
}
nsresult
-nsXULDocument::FindBroadcaster(Element* aElement,
- nsIDOMElement** aListener,
- nsString& aBroadcasterID,
- nsString& aAttribute,
- nsIDOMElement** aBroadcaster)
+XULDocument::FindBroadcaster(Element* aElement,
+ nsIDOMElement** aListener,
+ nsString& aBroadcasterID,
+ nsString& aAttribute,
+ nsIDOMElement** aBroadcaster)
{
nsresult rv;
nsINodeInfo *ni = aElement->NodeInfo();
*aListener = nullptr;
*aBroadcaster = nullptr;
if (ni->Equals(nsGkAtoms::observes, kNameSpaceID_XUL)) {
// It's an <observes> element, which means that the actual
@@ -4249,19 +4254,19 @@ nsXULDocument::FindBroadcaster(Element*
if (! *aBroadcaster) {
return NS_FINDBROADCASTER_AWAIT_OVERLAYS;
}
return NS_FINDBROADCASTER_FOUND;
}
nsresult
-nsXULDocument::CheckBroadcasterHookup(Element* aElement,
- bool* aNeedsHookup,
- bool* aDidResolve)
+XULDocument::CheckBroadcasterHookup(Element* aElement,
+ bool* aNeedsHookup,
+ bool* aDidResolve)
{
// Resolve a broadcaster hookup. Look at the element that we're
// trying to resolve: it could be an '<observes>' element, or just
// a vanilla element with an 'observes' attribute on it.
nsresult rv;
*aDidResolve = false;
@@ -4310,18 +4315,18 @@ nsXULDocument::CheckBroadcasterHookup(El
#endif
*aNeedsHookup = false;
*aDidResolve = true;
return NS_OK;
}
nsresult
-nsXULDocument::InsertElement(nsIContent* aParent, nsIContent* aChild,
- bool aNotify)
+XULDocument::InsertElement(nsIContent* aParent, nsIContent* aChild,
+ bool aNotify)
{
// Insert aChild appropriately into aParent, accounting for a
// 'pos' attribute set on aChild.
nsAutoString posStr;
bool wasInserted = false;
// insert after an element of a given id
@@ -4391,97 +4396,97 @@ nsXULDocument::InsertElement(nsIContent*
if (!wasInserted) {
return aParent->AppendChildTo(aChild, aNotify);
}
return NS_OK;
}
nsresult
-nsXULDocument::RemoveElement(nsIContent* aParent, nsIContent* aChild)
+XULDocument::RemoveElement(nsIContent* aParent, nsIContent* aChild)
{
int32_t nodeOffset = aParent->IndexOf(aChild);
aParent->RemoveChildAt(nodeOffset, true);
return NS_OK;
}
//----------------------------------------------------------------------
//
// CachedChromeStreamListener
//
-nsXULDocument::CachedChromeStreamListener::CachedChromeStreamListener(nsXULDocument* aDocument, bool aProtoLoaded)
+XULDocument::CachedChromeStreamListener::CachedChromeStreamListener(XULDocument* aDocument, bool aProtoLoaded)
: mDocument(aDocument),
mProtoLoaded(aProtoLoaded)
{
NS_ADDREF(mDocument);
}
-nsXULDocument::CachedChromeStreamListener::~CachedChromeStreamListener()
+XULDocument::CachedChromeStreamListener::~CachedChromeStreamListener()
{
NS_RELEASE(mDocument);
}
-NS_IMPL_ISUPPORTS2(nsXULDocument::CachedChromeStreamListener,
+NS_IMPL_ISUPPORTS2(XULDocument::CachedChromeStreamListener,
nsIRequestObserver, nsIStreamListener)
NS_IMETHODIMP
-nsXULDocument::CachedChromeStreamListener::OnStartRequest(nsIRequest *request,
- nsISupports* acontext)
+XULDocument::CachedChromeStreamListener::OnStartRequest(nsIRequest *request,
+ nsISupports* acontext)
{
return NS_ERROR_PARSED_DATA_CACHED;
}
NS_IMETHODIMP
-nsXULDocument::CachedChromeStreamListener::OnStopRequest(nsIRequest *request,
- nsISupports* aContext,
- nsresult aStatus)
+XULDocument::CachedChromeStreamListener::OnStopRequest(nsIRequest *request,
+ nsISupports* aContext,
+ nsresult aStatus)
{
if (! mProtoLoaded)
return NS_OK;
return mDocument->OnPrototypeLoadDone(true);
}
NS_IMETHODIMP
-nsXULDocument::CachedChromeStreamListener::OnDataAvailable(nsIRequest *request,
- nsISupports* aContext,
- nsIInputStream* aInStr,
- uint64_t aSourceOffset,
- uint32_t aCount)
+XULDocument::CachedChromeStreamListener::OnDataAvailable(nsIRequest *request,
+ nsISupports* aContext,
+ nsIInputStream* aInStr,
+ uint64_t aSourceOffset,
+ uint32_t aCount)
{
NS_NOTREACHED("CachedChromeStream doesn't receive data");
return NS_ERROR_UNEXPECTED;
}
//----------------------------------------------------------------------
//
// ParserObserver
//
-nsXULDocument::ParserObserver::ParserObserver(nsXULDocument* aDocument,
- nsXULPrototypeDocument* aPrototype)
+XULDocument::ParserObserver::ParserObserver(XULDocument* aDocument,
+ nsXULPrototypeDocument* aPrototype)
: mDocument(aDocument), mPrototype(aPrototype)
{
}
-nsXULDocument::ParserObserver::~ParserObserver()
+XULDocument::ParserObserver::~ParserObserver()
{
}
-NS_IMPL_ISUPPORTS1(nsXULDocument::ParserObserver, nsIRequestObserver)
+NS_IMPL_ISUPPORTS1(XULDocument::ParserObserver, nsIRequestObserver)
NS_IMETHODIMP
-nsXULDocument::ParserObserver::OnStartRequest(nsIRequest *request,
- nsISupports* aContext)
+XULDocument::ParserObserver::OnStartRequest(nsIRequest *request,
+ nsISupports* aContext)
{
// Guard against buggy channels calling OnStartRequest multiple times.
if (mPrototype) {
nsCOMPtr<nsIChannel> channel = do_QueryInterface(request);
nsIScriptSecurityManager* secMan = nsContentUtils::GetSecurityManager();
if (channel && secMan) {
nsCOMPtr<nsIPrincipal> principal;
secMan->GetChannelPrincipal(channel, getter_AddRefs(principal));
@@ -4493,19 +4498,19 @@ nsXULDocument::ParserObserver::OnStartRe
// Make sure to avoid cycles
mPrototype = nullptr;
}
return NS_OK;
}
NS_IMETHODIMP
-nsXULDocument::ParserObserver::OnStopRequest(nsIRequest *request,
- nsISupports* aContext,
- nsresult aStatus)
+XULDocument::ParserObserver::OnStopRequest(nsIRequest *request,
+ nsISupports* aContext,
+ nsresult aStatus)
{
nsresult rv = NS_OK;
if (NS_FAILED(aStatus)) {
// If an overlay load fails, we need to nudge the prototype
// walk along.
nsCOMPtr<nsIChannel> aChannel = do_QueryInterface(request);
if (aChannel) {
@@ -4523,26 +4528,26 @@ nsXULDocument::ParserObserver::OnStopReq
// document, the parser, the content sink, and the parser
// observer.
mDocument = nullptr;
return rv;
}
already_AddRefed<nsPIWindowRoot>
-nsXULDocument::GetWindowRoot()
+XULDocument::GetWindowRoot()
{
nsCOMPtr<nsIInterfaceRequestor> ir = do_QueryReferent(mDocumentContainer);
nsCOMPtr<nsIDOMWindow> window(do_GetInterface(ir));
nsCOMPtr<nsPIDOMWindow> piWin(do_QueryInterface(window));
return piWin ? piWin->GetTopWindowRoot() : nullptr;
}
bool
-nsXULDocument::IsDocumentRightToLeft()
+XULDocument::IsDocumentRightToLeft()
{
// setting the localedir attribute on the root element forces a
// specific direction for the document.
Element* element = GetRootElement();
if (element) {
static nsIContent::AttrValuesArray strings[] =
{&nsGkAtoms::ltr, &nsGkAtoms::rtl, nullptr};
switch (element->FindAttrValueIn(kNameSpaceID_None, nsGkAtoms::localedir,
@@ -4584,35 +4589,35 @@ nsXULDocument::IsDocumentRightToLeft()
}
bool isRTL = false;
reg->IsLocaleRTL(package, &isRTL);
return isRTL;
}
void
-nsXULDocument::ResetDocumentDirection()
+XULDocument::ResetDocumentDirection()
{
DocumentStatesChanged(NS_DOCUMENT_STATE_RTL_LOCALE);
}
int
-nsXULDocument::DirectionChanged(const char* aPrefName, void* aData)
+XULDocument::DirectionChanged(const char* aPrefName, void* aData)
{
// Reset the direction and restyle the document if necessary.
- nsXULDocument* doc = (nsXULDocument *)aData;
+ XULDocument* doc = (XULDocument *)aData;
if (doc) {
doc->ResetDocumentDirection();
}
return 0;
}
int
-nsXULDocument::GetDocumentLWTheme()
+XULDocument::GetDocumentLWTheme()
{
if (mDocLWTheme == Doc_Theme_Uninitialized) {
mDocLWTheme = Doc_Theme_None; // No lightweight theme by default
Element* element = GetRootElement();
nsAutoString hasLWTheme;
if (element &&
element->GetAttr(kNameSpaceID_None, nsGkAtoms::lwtheme, hasLWTheme) &&
@@ -4628,12 +4633,15 @@ nsXULDocument::GetDocumentLWTheme()
mDocLWTheme = Doc_Theme_Bright;
}
}
}
return mDocLWTheme;
}
NS_IMETHODIMP
-nsXULDocument::GetBoxObjectFor(nsIDOMElement* aElement, nsIBoxObject** aResult)
+XULDocument::GetBoxObjectFor(nsIDOMElement* aElement, nsIBoxObject** aResult)
{
return nsDocument::GetBoxObjectFor(aElement, aResult);
}
+
+} // namespace dom
+} // namespace mozilla