Bug 1445114 - Move RDF atoms into nsGkAtoms. r=froydnj
There are only a handful of them, and two of them are duplicates of atoms
within nsGkAtoms anyway.
MozReview-Commit-ID: Cb90STdeGdK
--- a/dom/base/nsGkAtomList.h
+++ b/dom/base/nsGkAtomList.h
@@ -2503,16 +2503,31 @@ GK_ATOM(onsourceopen, "onsourceopen")
GK_ATOM(onsourceended, "onsourceended")
GK_ATOM(onsourceclosed, "onsourceclosed")
GK_ATOM(onupdatestart, "onupdatestart")
GK_ATOM(onupdate, "onupdate")
GK_ATOM(onupdateend, "onupdateend")
GK_ATOM(onaddsourcebuffer, "onaddsourcebuffer")
GK_ATOM(onremovesourcebuffer, "onremovesourcebuffer")
+// RDF
+GK_ATOM(about, "about")
+GK_ATOM(ID, "ID")
+GK_ATOM(nodeID, "nodeID")
+GK_ATOM(aboutEach, "aboutEach")
+GK_ATOM(resource, "resource")
+GK_ATOM(RDF, "RDF")
+GK_ATOM(Description, "Description")
+GK_ATOM(Bag, "Bag")
+GK_ATOM(Seq, "Seq")
+GK_ATOM(Alt, "Alt")
+//GK_ATOM(kLiAtom, "li") # "li" is present above
+//GK_ATOM(kXMLNSAtom, "xmlns") # "xmlns" is present above
+GK_ATOM(parseType, "parseType")
+
// THE REST OF THE FILE IS GENERATED BY THE HTML PARSER TRANSLATOR AND
// WILL BE OVERWRITTEN!
// Please put manually-added atoms above this section and please avoid #ifdefing
// them so that the translator doesn't need to learn to deal with conditionally
// present manual atoms.
// BEGIN GENERATED
// ATOM GENERATED BY HTML PARSER TRANSLATOR (WILL BE AUTOMATICALLY OVERWRITTEN):
GK_ATOM(xlink, "xlink")
--- a/layout/build/nsLayoutStatics.cpp
+++ b/layout/build/nsLayoutStatics.cpp
@@ -150,17 +150,16 @@ nsLayoutStatics::Initialize()
// Register all of our atoms once
nsCSSAnonBoxes::AddRefAtoms();
nsCSSPseudoClasses::AddRefAtoms();
nsCSSPseudoElements::AddRefAtoms();
nsCSSKeywords::AddRefTable();
nsCSSProps::AddRefTable();
nsColorNames::AddRefTable();
nsGkAtoms::AddRefAtoms();
- nsRDFAtoms::RegisterAtoms();
NS_SetStaticAtomsDone();
StartupJSEnvironment();
nsGlobalWindowInner::Init();
nsGlobalWindowOuter::Init();
Navigator::Init();
--- a/rdf/base/nsIRDFContentSink.h
+++ b/rdf/base/nsIRDFContentSink.h
@@ -49,14 +49,9 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIRDFCont
/**
* This constructs a content sink that can be used without a
* document, say, to create a stand-alone in-memory graph.
*/
nsresult
NS_NewRDFContentSink(nsIRDFContentSink** aResult);
-class nsRDFAtoms {
-public:
- static void RegisterAtoms();
-};
-
#endif // nsIRDFContentSink_h___
--- a/rdf/base/nsRDFContentSink.cpp
+++ b/rdf/base/nsRDFContentSink.cpp
@@ -55,17 +55,17 @@
#include "nsString.h"
#include "mozilla/Logging.h"
#include "rdf.h"
#include "rdfutil.h"
#include "nsReadableUtils.h"
#include "nsIExpatSink.h"
#include "nsCRT.h"
#include "nsAtom.h"
-#include "nsStaticAtom.h"
+#include "nsGkAtoms.h"
#include "nsIScriptError.h"
#include "nsIDTD.h"
using namespace mozilla;
///////////////////////////////////////////////////////////////////////
enum RDFContentSinkState {
@@ -121,20 +121,16 @@ public:
static nsIRDFContainerUtils* gRDFContainerUtils;
static nsIRDFResource* kRDF_type;
static nsIRDFResource* kRDF_instanceOf; // XXX should be RDF:type
static nsIRDFResource* kRDF_Alt;
static nsIRDFResource* kRDF_Bag;
static nsIRDFResource* kRDF_Seq;
static nsIRDFResource* kRDF_nextVal;
- #define RDF_ATOM(name_, value_) NS_STATIC_ATOM_DECL(name_)
- #include "nsRDFContentSinkAtomList.h"
- #undef RDF_ATOM
-
typedef struct ContainerInfo {
nsIRDFResource** mType;
nsContainerTestFn mTestFn;
nsMakeContainerFn mMakeFn;
} ContainerInfo;
protected:
virtual ~RDFContentSinkImpl();
@@ -230,38 +226,16 @@ nsIRDFResource* RDFContentSinkImpl::kRDF
nsIRDFResource* RDFContentSinkImpl::kRDF_Bag;
nsIRDFResource* RDFContentSinkImpl::kRDF_Seq;
nsIRDFResource* RDFContentSinkImpl::kRDF_nextVal;
mozilla::LazyLogModule RDFContentSinkImpl::gLog("nsRDFContentSink");
////////////////////////////////////////////////////////////////////////
-#define RDF_ATOM(name_, value_) NS_STATIC_ATOM_DEFN(RDFContentSinkImpl, name_)
-#include "nsRDFContentSinkAtomList.h"
-#undef RDF_ATOM
-
-#define RDF_ATOM(name_, value_) NS_STATIC_ATOM_BUFFER(name_, value_)
-#include "nsRDFContentSinkAtomList.h"
-#undef RDF_ATOM
-
-static const nsStaticAtomSetup sRDFContentSinkAtomSetup[] = {
- #define RDF_ATOM(name_, value_) \
- NS_STATIC_ATOM_SETUP(RDFContentSinkImpl, name_)
- #include "nsRDFContentSinkAtomList.h"
- #undef RDF_ATOM
-};
-
-// static
-void
-nsRDFAtoms::RegisterAtoms()
-{
- NS_RegisterStaticAtoms(sRDFContentSinkAtomSetup);
-}
-
RDFContentSinkImpl::RDFContentSinkImpl()
: mText(nullptr),
mTextLength(0),
mTextSize(0),
mState(eRDFContentSinkState_InProlog),
mParseMode(eRDFContentSinkParseMode_Literal),
mContextStack(nullptr)
{
@@ -794,33 +768,33 @@ RDFContentSinkImpl::GetIdAboutAttribute(
if (!nameSpaceURI.IsEmpty() &&
!nameSpaceURI.EqualsLiteral(RDF_NAMESPACE_URI)) {
continue;
}
// XXX you can't specify both, but we'll just pick up the
// first thing that was specified and ignore the other.
- if (localName == kAboutAtom) {
+ if (localName == nsGkAtoms::about) {
if (aIsAnonymous)
*aIsAnonymous = false;
nsAutoString relURI(aAttributes[1]);
if (rdf_RequiresAbsoluteURI(relURI)) {
nsAutoCString uri;
rv = mDocumentURL->Resolve(NS_ConvertUTF16toUTF8(aAttributes[1]), uri);
if (NS_FAILED(rv)) return rv;
return gRDFService->GetResource(uri,
aResource);
}
return gRDFService->GetResource(NS_ConvertUTF16toUTF8(aAttributes[1]),
aResource);
}
- else if (localName == kIdAtom) {
+ else if (localName == nsGkAtoms::ID) {
if (aIsAnonymous)
*aIsAnonymous = false;
// In the spirit of leniency, we do not bother trying to
// enforce that this be a valid "XML Name" (see
// http://www.w3.org/TR/REC-xml#NT-Nmtoken), as per
// 6.21. If we wanted to, this would be where to do it.
// Construct an in-line resource whose URI is the
@@ -830,20 +804,20 @@ RDFContentSinkImpl::GetIdAboutAttribute(
nsAutoCString ref('#');
AppendUTF16toUTF8(aAttributes[1], ref);
rv = mDocumentURL->Resolve(ref, name);
if (NS_FAILED(rv)) return rv;
return gRDFService->GetResource(name, aResource);
}
- else if (localName == kNodeIdAtom) {
+ else if (localName == nsGkAtoms::nodeID) {
nodeID.Assign(aAttributes[1]);
}
- else if (localName == kAboutEachAtom) {
+ else if (localName == nsGkAtoms::about) {
// XXX we don't deal with aboutEach...
//MOZ_LOG(gLog, LogLevel::Warning,
// ("rdfxml: ignoring aboutEach at line %d",
// aNode.GetSourceLineNumber()));
}
}
// Otherwise, we couldn't find anything, so just gensym one...
@@ -885,34 +859,34 @@ RDFContentSinkImpl::GetResourceAttribute
if (!nameSpaceURI.IsEmpty() &&
!nameSpaceURI.EqualsLiteral(RDF_NAMESPACE_URI)) {
continue;
}
// XXX you can't specify both, but we'll just pick up the
// first thing that was specified and ignore the other.
- if (localName == kResourceAtom) {
+ if (localName == nsGkAtoms::resource) {
// XXX Take the URI and make it fully qualified by
// sticking it into the document's URL. This may not be
// appropriate...
nsAutoString relURI(aAttributes[1]);
if (rdf_RequiresAbsoluteURI(relURI)) {
nsresult rv;
nsAutoCString uri;
rv = mDocumentURL->Resolve(NS_ConvertUTF16toUTF8(aAttributes[1]), uri);
if (NS_FAILED(rv)) return rv;
return gRDFService->GetResource(uri, aResource);
}
return gRDFService->GetResource(NS_ConvertUTF16toUTF8(aAttributes[1]),
aResource);
}
- else if (localName == kNodeIdAtom) {
+ else if (localName == nsGkAtoms::nodeID) {
nodeID.Assign(aAttributes[1]);
}
}
// If nodeID is present, check if we already know about it. If we've seen
// the nodeID before, use the same resource, otherwise generate a new one.
if (!nodeID.IsEmpty()) {
mNodeIDMap.Get(nodeID,aResource);
@@ -947,26 +921,26 @@ RDFContentSinkImpl::AddProperties(const
// skip 'xmlns' directives, these are "meta" information
if (nameSpaceURI.EqualsLiteral("http://www.w3.org/2000/xmlns/")) {
continue;
}
// skip `about', `ID', `resource', and 'nodeID' attributes (either with or
// without the `rdf:' prefix); these are all "special" and
// should've been dealt with by the caller.
- if (localName == kAboutAtom || localName == kIdAtom ||
- localName == kResourceAtom || localName == kNodeIdAtom) {
+ if (localName == nsGkAtoms::about || localName == nsGkAtoms::ID ||
+ localName == nsGkAtoms::resource || localName == nsGkAtoms::nodeID) {
if (nameSpaceURI.IsEmpty() ||
nameSpaceURI.EqualsLiteral(RDF_NAMESPACE_URI))
continue;
}
// Skip `parseType', `RDF:parseType', and `NC:parseType'. This
// is meta-information that will be handled in SetParseMode.
- if (localName == kParseTypeAtom) {
+ if (localName == nsGkAtoms::parseType) {
if (nameSpaceURI.IsEmpty() ||
nameSpaceURI.EqualsLiteral(RDF_NAMESPACE_URI) ||
nameSpaceURI.EqualsLiteral(NC_NAMESPACE_URI)) {
continue;
}
}
NS_ConvertUTF16toUTF8 propertyStr(nameSpaceURI);
@@ -988,17 +962,17 @@ RDFContentSinkImpl::AddProperties(const
void
RDFContentSinkImpl::SetParseMode(const char16_t **aAttributes)
{
RefPtr<nsAtom> localName;
for (; *aAttributes; aAttributes += 2) {
const nsDependentSubstring& nameSpaceURI =
SplitExpatName(aAttributes[0], getter_AddRefs(localName));
- if (localName == kParseTypeAtom) {
+ if (localName == nsGkAtoms::parseType) {
nsDependentString v(aAttributes[1]);
if (nameSpaceURI.IsEmpty() ||
nameSpaceURI.EqualsLiteral(RDF_NAMESPACE_URI)) {
if (v.EqualsLiteral("Resource"))
mParseMode = eRDFContentSinkParseMode_Resource;
break;
@@ -1023,17 +997,18 @@ RDFContentSinkImpl::OpenRDF(const char16
{
// ensure that we're actually reading RDF by making sure that the
// opening tag is <rdf:RDF>, where "rdf:" corresponds to whatever
// they've declared the standard RDF namespace to be.
RefPtr<nsAtom> localName;
const nsDependentSubstring& nameSpaceURI =
SplitExpatName(aName, getter_AddRefs(localName));
- if (!nameSpaceURI.EqualsLiteral(RDF_NAMESPACE_URI) || localName != kRDFAtom) {
+ if (!nameSpaceURI.EqualsLiteral(RDF_NAMESPACE_URI) ||
+ localName != nsGkAtoms::RDF) {
// MOZ_LOG(gLog, LogLevel::Info,
// ("rdfxml: expected RDF:RDF at line %d",
// aNode.GetSourceLineNumber()));
return NS_ERROR_UNEXPECTED;
}
PushContext(nullptr, mState, mParseMode);
@@ -1066,31 +1041,31 @@ RDFContentSinkImpl::OpenObject(const cha
// Now figure out what kind of state transition we need to
// make. We'll either be going into a mode where we parse a
// description or a container.
bool isaTypedNode = true;
if (nameSpaceURI.EqualsLiteral(RDF_NAMESPACE_URI)) {
isaTypedNode = false;
- if (localName == kDescriptionAtom) {
+ if (localName == nsGkAtoms::Description) {
// it's a description
mState = eRDFContentSinkState_InDescriptionElement;
}
- else if (localName == kBagAtom) {
+ else if (localName == nsGkAtoms::Bag) {
// it's a bag container
InitContainer(kRDF_Bag, source);
mState = eRDFContentSinkState_InContainerElement;
}
- else if (localName == kSeqAtom) {
+ else if (localName == nsGkAtoms::Seq) {
// it's a seq container
InitContainer(kRDF_Seq, source);
mState = eRDFContentSinkState_InContainerElement;
}
- else if (localName == kAltAtom) {
+ else if (localName == nsGkAtoms::Alt) {
// it's an alt container
InitContainer(kRDF_Alt, source);
mState = eRDFContentSinkState_InContainerElement;
}
else {
// heh, that's not *in* the RDF namespace: just treat it
// like a typed node
isaTypedNode = true;
@@ -1197,17 +1172,17 @@ RDFContentSinkImpl::OpenMember(const cha
// to whatever they've declared the standard RDF namespace to be.
nsresult rv;
RefPtr<nsAtom> localName;
const nsDependentSubstring& nameSpaceURI =
SplitExpatName(aName, getter_AddRefs(localName));
if (!nameSpaceURI.EqualsLiteral(RDF_NAMESPACE_URI) ||
- localName != kLiAtom) {
+ localName != nsGkAtoms::li) {
MOZ_LOG(gLog, LogLevel::Error,
("rdfxml: expected RDF:li at line %d",
-1)); // XXX pass in line number
return NS_ERROR_UNEXPECTED;
}
// The parent element is the container.
@@ -1276,17 +1251,17 @@ RDFContentSinkImpl::RegisterNamespaces(c
}
// get the localname (or "xmlns" for the default namespace)
const char16_t* endLocal = ++attr;
while (*endLocal && *endLocal != 0xFFFF) {
++endLocal;
}
nsDependentSubstring lname(attr, endLocal);
RefPtr<nsAtom> preferred = NS_Atomize(lname);
- if (preferred == kXMLNSAtom) {
+ if (preferred == nsGkAtoms::xmlns) {
preferred = nullptr;
}
sink->AddNameSpace(preferred, nsDependentString(aAttributes[1]));
}
}
////////////////////////////////////////////////////////////////////////
// Qualified name resolution
deleted file mode 100644
--- a/rdf/base/nsRDFContentSinkAtomList.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; 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/. */
-
-RDF_ATOM(kAboutAtom, "about")
-RDF_ATOM(kIdAtom, "ID")
-RDF_ATOM(kNodeIdAtom, "nodeID")
-RDF_ATOM(kAboutEachAtom, "aboutEach")
-RDF_ATOM(kResourceAtom, "resource")
-RDF_ATOM(kRDFAtom, "RDF")
-RDF_ATOM(kDescriptionAtom, "Description")
-RDF_ATOM(kBagAtom, "Bag")
-RDF_ATOM(kSeqAtom, "Seq")
-RDF_ATOM(kAltAtom, "Alt")
-RDF_ATOM(kLiAtom, "li")
-RDF_ATOM(kXMLNSAtom, "xmlns")
-RDF_ATOM(kParseTypeAtom, "parseType")