Bug 1394649 - Use nsGkAtoms on nsTextServiceDocument. r?masayuki draft
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Mon, 23 Oct 2017 13:09:49 +0900
changeset 684571 8ad70ff1adfa145bc0e8da3c6f43f3dba9b558f1
parent 684570 d10766b6ea6040f33c774a8087f36de0cc9d6074
child 736890 1c7a02fb55fb51510e65755ecd0a83bb33be7ece
push id85645
push userbmo:m_kato@ga2.so-net.ne.jp
push dateMon, 23 Oct 2017 04:11:31 +0000
reviewersmasayuki
bugs1394649
milestone58.0a1
Bug 1394649 - Use nsGkAtoms on nsTextServiceDocument. r?masayuki It is no reason to use custom atom instead of nsGkAtoms now, so we should use nsGkAtoms instead. MozReview-Commit-ID: 9slsZtLDNKH
editor/txtsvc/nsTSAtomList.h
editor/txtsvc/nsTextServicesDocument.cpp
editor/txtsvc/nsTextServicesDocument.h
layout/build/nsLayoutStatics.cpp
deleted file mode 100644
--- a/editor/txtsvc/nsTSAtomList.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/* 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/. */
-
-/******
-
-  This file contains the list of all text services nsAtoms and their values
-
-  It is designed to be used as inline input to nsTextServicesDocument.cpp *only*
-  through the magic of C preprocessing.
-
-  All entries must be enclosed in the macro TS_ATOM which will have cruel
-  and unusual things done to it
-
-  It is recommended (but not strictly necessary) to keep all entries
-  in alphabetical order
-
-  The first argument to TS_ATOM is the C++ identifier of the atom
-  The second argument is the string value of the atom
-
- ******/
-
-// OUTPUT_CLASS=nsTextServicesDocument
-// MACRO_NAME=TS_ATOM
-
-TS_ATOM(sAAtom, "a")
-TS_ATOM(sAddressAtom, "address")
-TS_ATOM(sBigAtom, "big")
-TS_ATOM(sBAtom, "b")
-TS_ATOM(sCiteAtom, "cite")
-TS_ATOM(sCodeAtom, "code")
-TS_ATOM(sDfnAtom, "dfn")
-TS_ATOM(sEmAtom, "em")
-TS_ATOM(sFontAtom, "font")
-TS_ATOM(sIAtom, "i")
-TS_ATOM(sKbdAtom, "kbd")
-TS_ATOM(sKeygenAtom, "keygen")
-TS_ATOM(sNobrAtom, "nobr")
-TS_ATOM(sSAtom, "s")
-TS_ATOM(sSampAtom, "samp")
-TS_ATOM(sSmallAtom, "small")
-TS_ATOM(sSpacerAtom, "spacer")
-TS_ATOM(sSpanAtom, "span")
-TS_ATOM(sStrikeAtom, "strike")
-TS_ATOM(sStrongAtom, "strong")
-TS_ATOM(sSubAtom, "sub")
-TS_ATOM(sSupAtom, "sup")
-TS_ATOM(sTtAtom, "tt")
-TS_ATOM(sUAtom, "u")
-TS_ATOM(sVarAtom, "var")
-TS_ATOM(sWbrAtom, "wbr")
--- a/editor/txtsvc/nsTextServicesDocument.cpp
+++ b/editor/txtsvc/nsTextServicesDocument.cpp
@@ -86,44 +86,16 @@ nsTextServicesDocument::nsTextServicesDo
   mIteratorStatus = eIsDone;
 }
 
 nsTextServicesDocument::~nsTextServicesDocument()
 {
   ClearOffsetTable(&mOffsetTable);
 }
 
-class TSAtoms
-{
-public:
-  #define TS_ATOM(name_, value_) NS_STATIC_ATOM_DECL(name_)
-  #include "nsTSAtomList.h" // IWYU pragma: keep
-  #undef TS_ATOM
-};
-
-#define TS_ATOM(name_, value_) NS_STATIC_ATOM_DEFN(TSAtoms, name_)
-#include "nsTSAtomList.h" // IWYU pragma: keep
-#undef TS_ATOM
-
-#define TS_ATOM(name_, value_) NS_STATIC_ATOM_BUFFER(name_, value_)
-#include "nsTSAtomList.h" // IWYU pragma: keep
-#undef TS_ATOM
-
-static const nsStaticAtomSetup sTSAtomSetup[] = {
-  #define TS_ATOM(name_, value_) NS_STATIC_ATOM_SETUP(TSAtoms, name_)
-  #include "nsTSAtomList.h" // IWYU pragma: keep
-  #undef TS_ATOM
-};
-
-/* static */ void
-nsTextServicesDocument::RegisterAtoms()
-{
-  NS_RegisterStaticAtoms(sTSAtomSetup);
-}
-
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsTextServicesDocument)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(nsTextServicesDocument)
 
 NS_INTERFACE_MAP_BEGIN(nsTextServicesDocument)
   NS_INTERFACE_MAP_ENTRY(nsITextServicesDocument)
   NS_INTERFACE_MAP_ENTRY(nsIEditActionListener)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsITextServicesDocument)
   NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(nsTextServicesDocument)
@@ -2042,42 +2014,42 @@ nsTextServicesDocument::IsBlockNode(nsIC
 {
   if (!aContent) {
     NS_ERROR("How did a null pointer get passed to IsBlockNode?");
     return false;
   }
 
   nsAtom *atom = aContent->NodeInfo()->NameAtom();
 
-  return (TSAtoms::sAAtom       != atom &&
-          TSAtoms::sAddressAtom != atom &&
-          TSAtoms::sBigAtom     != atom &&
-          TSAtoms::sBAtom       != atom &&
-          TSAtoms::sCiteAtom    != atom &&
-          TSAtoms::sCodeAtom    != atom &&
-          TSAtoms::sDfnAtom     != atom &&
-          TSAtoms::sEmAtom      != atom &&
-          TSAtoms::sFontAtom    != atom &&
-          TSAtoms::sIAtom       != atom &&
-          TSAtoms::sKbdAtom     != atom &&
-          TSAtoms::sKeygenAtom  != atom &&
-          TSAtoms::sNobrAtom    != atom &&
-          TSAtoms::sSAtom       != atom &&
-          TSAtoms::sSampAtom    != atom &&
-          TSAtoms::sSmallAtom   != atom &&
-          TSAtoms::sSpacerAtom  != atom &&
-          TSAtoms::sSpanAtom    != atom &&
-          TSAtoms::sStrikeAtom  != atom &&
-          TSAtoms::sStrongAtom  != atom &&
-          TSAtoms::sSubAtom     != atom &&
-          TSAtoms::sSupAtom     != atom &&
-          TSAtoms::sTtAtom      != atom &&
-          TSAtoms::sUAtom       != atom &&
-          TSAtoms::sVarAtom     != atom &&
-          TSAtoms::sWbrAtom     != atom);
+  return (nsGkAtoms::a       != atom &&
+          nsGkAtoms::address != atom &&
+          nsGkAtoms::big     != atom &&
+          nsGkAtoms::b       != atom &&
+          nsGkAtoms::cite    != atom &&
+          nsGkAtoms::code    != atom &&
+          nsGkAtoms::dfn     != atom &&
+          nsGkAtoms::em      != atom &&
+          nsGkAtoms::font    != atom &&
+          nsGkAtoms::i       != atom &&
+          nsGkAtoms::kbd     != atom &&
+          nsGkAtoms::keygen  != atom &&
+          nsGkAtoms::nobr    != atom &&
+          nsGkAtoms::s       != atom &&
+          nsGkAtoms::samp    != atom &&
+          nsGkAtoms::small   != atom &&
+          nsGkAtoms::spacer  != atom &&
+          nsGkAtoms::span    != atom &&
+          nsGkAtoms::strike  != atom &&
+          nsGkAtoms::strong  != atom &&
+          nsGkAtoms::sub     != atom &&
+          nsGkAtoms::sup     != atom &&
+          nsGkAtoms::tt      != atom &&
+          nsGkAtoms::u       != atom &&
+          nsGkAtoms::var     != atom &&
+          nsGkAtoms::wbr     != atom);
 }
 
 bool
 nsTextServicesDocument::HasSameBlockNodeParent(nsIContent *aContent1, nsIContent *aContent2)
 {
   nsIContent* p1 = aContent1->GetParent();
   nsIContent* p2 = aContent2->GetParent();
 
--- a/editor/txtsvc/nsTextServicesDocument.h
+++ b/editor/txtsvc/nsTextServicesDocument.h
@@ -12,17 +12,16 @@
 #include "nsISupportsImpl.h"
 #include "nsITextServicesDocument.h"
 #include "nsIWeakReferenceUtils.h"
 #include "nsStringFwd.h"
 #include "nsTArray.h"
 #include "nscore.h"
 
 class OffsetEntry;
-class nsAtom;
 class nsIContent;
 class nsIContentIterator;
 class nsIDOMCharacterData;
 class nsIDOMDocument;
 class nsIDOMNode;
 class nsIDOMRange;
 class nsIEditor;
 class nsISelection;
@@ -66,20 +65,16 @@ protected:
   virtual ~nsTextServicesDocument();
 
 public:
 
   /** The default constructor.
    */
   nsTextServicesDocument();
 
-  /** To be called at module init
-   */
-  static void RegisterAtoms();
-
   /* Macro for AddRef(), Release(), and QueryInterface() */
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsTextServicesDocument, nsITextServicesDocument)
 
   /* nsITextServicesDocument method implementations. */
   NS_IMETHOD InitWithEditor(nsIEditor *aEditor) override;
   NS_IMETHOD GetDocument(nsIDOMDocument **aDoc) override;
   NS_IMETHOD SetExtent(nsIDOMRange* aDOMRange) override;
--- a/layout/build/nsLayoutStatics.cpp
+++ b/layout/build/nsLayoutStatics.cpp
@@ -81,18 +81,16 @@
 #include "nsXULPrototypeCache.h"
 #include "nsXULTooltipListener.h"
 
 #include "inDOMView.h"
 
 #include "nsMenuBarListener.h"
 #endif
 
-#include "nsTextServicesDocument.h"
-
 #ifdef MOZ_WEBSPEECH
 #include "nsSynthVoiceRegistry.h"
 #endif
 
 #include "CubebUtils.h"
 #include "Latency.h"
 #include "WebAudioUtils.h"
 
@@ -149,17 +147,16 @@ nsLayoutStatics::Initialize()
   // Register all of our atoms once
   nsCSSAnonBoxes::AddRefAtoms();
   nsCSSPseudoClasses::AddRefAtoms();
   nsCSSPseudoElements::AddRefAtoms();
   nsCSSKeywords::AddRefTable();
   nsCSSProps::AddRefTable();
   nsColorNames::AddRefTable();
   nsGkAtoms::AddRefAtoms();
-  nsTextServicesDocument::RegisterAtoms();
   nsHTMLTags::RegisterAtoms();
   nsRDFAtoms::RegisterAtoms();
 
   NS_SealStaticAtomTable();
 
   StartupJSEnvironment();
   rv = nsRegion::InitStatic();
   if (NS_FAILED(rv)) {