Bug 1276669 - Part 4: Initialize RDF atoms in nsLayoutStatics. r=Pike, a=ritu
authorNathan Froyd <froydnj@mozilla.com>
Thu, 26 Jan 2017 15:43:39 -0500
changeset 375821 a5abb9c78e53ff6083c4e81cad93416b2492c8e9
parent 375820 c922a29ad1460b52ee197a8a285006aba1076996
child 375822 c1b5e94191ec94a36a2c01a161933ce7ee43d7e8
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersPike, ritu
bugs1276669
milestone53.0a2
Bug 1276669 - Part 4: Initialize RDF atoms in nsLayoutStatics. r=Pike, a=ritu This is not the cleanest code ever, but we need to move all static atom initialization prior to NS_SealStaticAtomTable to avoid the possibility of dynamic atoms being transmuted into static atoms. We therefore need to open up an avenue for somebody else to initialize the atoms that RDF needs.
layout/build/nsLayoutStatics.cpp
rdf/base/nsIRDFContentSink.h
rdf/base/nsRDFContentSink.cpp
--- a/layout/build/nsLayoutStatics.cpp
+++ b/layout/build/nsLayoutStatics.cpp
@@ -48,16 +48,17 @@
 #include "nsCCUncollectableMarker.h"
 #include "nsTextFragment.h"
 #include "nsCSSRuleProcessor.h"
 #include "nsCORSListenerProxy.h"
 #include "nsHTMLDNSPrefetch.h"
 #include "nsHtml5Atoms.h"
 #include "nsHtml5Module.h"
 #include "nsHTMLTags.h"
+#include "nsIRDFContentSink.h"	// for RDF atom initialization
 #include "mozilla/dom/FallbackEncoding.h"
 #include "nsFocusManager.h"
 #include "nsListControlFrame.h"
 #include "mozilla/dom/HTMLInputElement.h"
 #include "SVGElementFactory.h"
 #include "nsSVGUtils.h"
 #include "nsMathMLAtoms.h"
 #include "nsMathMLOperators.h"
@@ -159,16 +160,17 @@ nsLayoutStatics::Initialize()
   nsCSSPseudoElements::AddRefAtoms();
   nsCSSKeywords::AddRefTable();
   nsCSSProps::AddRefTable();
   nsColorNames::AddRefTable();
   nsGkAtoms::AddRefAtoms();
   nsHtml5Atoms::AddRefAtoms();
   nsTextServicesDocument::RegisterAtoms();
   nsHTMLTags::RegisterAtoms();
+  nsRDFAtoms::RegisterAtoms();
 
   StartupJSEnvironment();
   rv = nsRegion::InitStatic();
   if (NS_FAILED(rv)) {
     NS_ERROR("Could not initialize nsRegion");
     return rv;
   }
 
--- a/rdf/base/nsIRDFContentSink.h
+++ b/rdf/base/nsIRDFContentSink.h
@@ -49,9 +49,14 @@ 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
@@ -252,16 +252,23 @@ mozilla::LazyLogModule RDFContentSinkImp
 #undef RDF_ATOM
 
 static const nsStaticAtom rdf_atoms[] = {
 #define RDF_ATOM(name_, value_) NS_STATIC_ATOM(name_##_buffer, &RDFContentSinkImpl::name_),
 #include "nsRDFContentSinkAtomList.h"
 #undef RDF_ATOM
 };
 
+// static
+void
+nsRDFAtoms::RegisterAtoms()
+{
+    NS_RegisterStaticAtoms(rdf_atoms);
+}
+
 RDFContentSinkImpl::RDFContentSinkImpl()
     : mText(nullptr),
       mTextLength(0),
       mTextSize(0),
       mState(eRDFContentSinkState_InProlog),
       mParseMode(eRDFContentSinkParseMode_Literal),
       mContextStack(nullptr)
 {
@@ -282,18 +289,16 @@ RDFContentSinkImpl::RDFContentSinkImpl()
             rv = gRDFService->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "Seq"),
                                           &kRDF_Seq);
             rv = gRDFService->GetResource(NS_LITERAL_CSTRING(RDF_NAMESPACE_URI "nextVal"),
                                           &kRDF_nextVal);
         }
 
         NS_DEFINE_CID(kRDFContainerUtilsCID, NS_RDFCONTAINERUTILS_CID);
         rv = CallGetService(kRDFContainerUtilsCID, &gRDFContainerUtils);
-
-        NS_RegisterStaticAtoms(rdf_atoms);
     }
 }
 
 
 RDFContentSinkImpl::~RDFContentSinkImpl()
 {
 #ifdef DEBUG_REFS
     --gInstanceCount;