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

--HG--
extra : rebase_source : 6ebc6996b129e70907f634e1876725c9e5da41ab
This commit is contained in:
Nicholas Nethercote 2018-03-14 10:27:34 +11:00
parent d41188c796
commit 5b4739162e
5 changed files with 34 additions and 68 deletions

View File

@ -2508,6 +2508,21 @@ 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

View File

@ -155,7 +155,6 @@ nsLayoutStatics::Initialize()
nsCSSProps::AddRefTable();
nsColorNames::AddRefTable();
nsGkAtoms::AddRefAtoms();
nsRDFAtoms::RegisterAtoms();
NS_SetStaticAtomsDone();

View File

@ -54,9 +54,4 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIRDFContentSink, NS_IRDFCONTENTSINK_IID)
nsresult
NS_NewRDFContentSink(nsIRDFContentSink** aResult);
class nsRDFAtoms {
public:
static void RegisterAtoms();
};
#endif // nsIRDFContentSink_h___

View File

@ -60,7 +60,7 @@
#include "nsIExpatSink.h"
#include "nsCRT.h"
#include "nsAtom.h"
#include "nsStaticAtom.h"
#include "nsGkAtoms.h"
#include "nsIScriptError.h"
#include "nsIDTD.h"
@ -126,10 +126,6 @@ public:
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;
@ -235,28 +231,6 @@ 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),
@ -799,7 +773,7 @@ RDFContentSinkImpl::GetIdAboutAttribute(const char16_t** aAttributes,
// 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;
@ -815,7 +789,7 @@ RDFContentSinkImpl::GetIdAboutAttribute(const char16_t** aAttributes,
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
@ -835,10 +809,10 @@ RDFContentSinkImpl::GetIdAboutAttribute(const char16_t** aAttributes,
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",
@ -890,7 +864,7 @@ RDFContentSinkImpl::GetResourceAttribute(const char16_t** aAttributes,
// 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...
@ -907,7 +881,7 @@ RDFContentSinkImpl::GetResourceAttribute(const char16_t** aAttributes,
return gRDFService->GetResource(NS_ConvertUTF16toUTF8(aAttributes[1]),
aResource);
}
else if (localName == kNodeIdAtom) {
else if (localName == nsGkAtoms::nodeID) {
nodeID.Assign(aAttributes[1]);
}
}
@ -952,8 +926,8 @@ RDFContentSinkImpl::AddProperties(const char16_t** aAttributes,
// 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;
@ -961,7 +935,7 @@ RDFContentSinkImpl::AddProperties(const char16_t** aAttributes,
// 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)) {
@ -993,7 +967,7 @@ RDFContentSinkImpl::SetParseMode(const char16_t **aAttributes)
const nsDependentSubstring& nameSpaceURI =
SplitExpatName(aAttributes[0], getter_AddRefs(localName));
if (localName == kParseTypeAtom) {
if (localName == nsGkAtoms::parseType) {
nsDependentString v(aAttributes[1]);
if (nameSpaceURI.IsEmpty() ||
@ -1028,7 +1002,8 @@ RDFContentSinkImpl::OpenRDF(const char16_t* aName)
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()));
@ -1071,21 +1046,21 @@ RDFContentSinkImpl::OpenObject(const char16_t* aName,
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;
@ -1202,7 +1177,7 @@ RDFContentSinkImpl::OpenMember(const char16_t* aName,
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
@ -1281,7 +1256,7 @@ RDFContentSinkImpl::RegisterNamespaces(const char16_t **aAttributes)
}
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]));

View File

@ -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")