Bug 1507604 - Remove unused nsXMLNameSpaceMap. r=smaug
authorPeter Van der Beken <peterv@propagandism.org>
Fri, 23 Nov 2018 15:28:07 +0000
changeset 504294 48d962c4e1edf464d669e3637c0ddb3ae0a7c56f
parent 504293 93bf8d17f265bb2767114ac46975f2ff8f02b130
child 504295 e5445a98098fb3a78851243e9a53792f7d5518e7
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1507604
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1507604 - Remove unused nsXMLNameSpaceMap. r=smaug Differential Revision: https://phabricator.services.mozilla.com/D12138
dom/base/moz.build
dom/base/nsXMLNameSpaceMap.cpp
dom/base/nsXMLNameSpaceMap.h
--- a/dom/base/moz.build
+++ b/dom/base/moz.build
@@ -112,17 +112,16 @@ EXPORTS += [
     'nsTextFragment.h',
     'nsTraversal.h',
     'nsTreeSanitizer.h',
     'nsViewportInfo.h',
     'nsWindowMemoryReporter.h',
     'nsWindowSizes.h',
     'nsWrapperCache.h',
     'nsWrapperCacheInlines.h',
-    'nsXMLNameSpaceMap.h',
     'XPathGenerator.h',
 ]
 
 if CONFIG['MOZ_WEBRTC']:
     EXPORTS += [
         'nsDOMDataChannel.h',
         'nsDOMDataChannelDeclarations.h',
     ]
@@ -358,17 +357,16 @@ UNIFIED_SOURCES += [
     'nsTraversal.cpp',
     'nsTreeSanitizer.cpp',
     'nsViewportInfo.cpp',
     'nsWindowMemoryReporter.cpp',
     'nsWindowRoot.cpp',
     'nsWrapperCache.cpp',
     'nsXHTMLContentSerializer.cpp',
     'nsXMLContentSerializer.cpp',
-    'nsXMLNameSpaceMap.cpp',
     'ParentProcessMessageManager.cpp',
     'Pose.cpp',
     'PostMessageEvent.cpp',
     'ProcessMessageManager.cpp',
     'ResponsiveImageSelector.cpp',
     'SameProcessMessageQueue.cpp',
     'ScreenLuminance.cpp',
     'ScreenOrientation.cpp',
deleted file mode 100644
--- a/dom/base/nsXMLNameSpaceMap.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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/. */
-
-/*
- * A class for keeping track of prefix-to-namespace-id mappings
- */
-
-#include "nsXMLNameSpaceMap.h"
-#include "nsContentUtils.h"
-#include "nsGkAtoms.h"
-#include "nsNameSpaceManager.h"
-#include "mozilla/dom/NameSpaceConstants.h"
-
-template <>
-class nsDefaultComparator <nsNameSpaceEntry, nsAtom*> {
-  public:
-    bool Equals(const nsNameSpaceEntry& aEntry, nsAtom* const& aPrefix) const {
-      return aEntry.prefix == aPrefix;
-    }
-};
-
-template <>
-class nsDefaultComparator <nsNameSpaceEntry, int32_t> {
-  public:
-    bool Equals(const nsNameSpaceEntry& aEntry, const int32_t& aNameSpace) const {
-      return aEntry.nameSpaceID == aNameSpace;
-    }
-};
-
-
-/* static */ nsXMLNameSpaceMap*
-nsXMLNameSpaceMap::Create(bool aForXML)
-{
-  nsXMLNameSpaceMap *map = new nsXMLNameSpaceMap();
-  NS_ENSURE_TRUE(map, nullptr);
-
-  if (aForXML) {
-    nsresult rv1 = map->AddPrefix(nsGkAtoms::xmlns,
-                                  kNameSpaceID_XMLNS);
-    nsresult rv2 = map->AddPrefix(nsGkAtoms::xml, kNameSpaceID_XML);
-
-    if (NS_FAILED(rv1) || NS_FAILED(rv2)) {
-      delete map;
-      map = nullptr;
-    }
-  }
-
-  return map;
-}
-
-nsXMLNameSpaceMap::nsXMLNameSpaceMap()
-  : mNameSpaces(4)
-{
-}
-
-nsresult
-nsXMLNameSpaceMap::AddPrefix(nsAtom *aPrefix, int32_t aNameSpaceID)
-{
-  if (!mNameSpaces.Contains(aPrefix) && !mNameSpaces.AppendElement(aPrefix)) {
-    return NS_ERROR_OUT_OF_MEMORY;
-  }
-  mNameSpaces[mNameSpaces.IndexOf(aPrefix)].nameSpaceID = aNameSpaceID;
-  return NS_OK;
-}
-
-nsresult
-nsXMLNameSpaceMap::AddPrefix(nsAtom *aPrefix, nsString &aURI)
-{
-  int32_t id;
-  nsresult rv = nsContentUtils::NameSpaceManager()->RegisterNameSpace(aURI,
-                                                                      id);
-
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  return AddPrefix(aPrefix, id);
-}
-
-int32_t
-nsXMLNameSpaceMap::FindNameSpaceID(nsAtom *aPrefix) const
-{
-  size_t index = mNameSpaces.IndexOf(aPrefix);
-  if (index != mNameSpaces.NoIndex) {
-    return mNameSpaces[index].nameSpaceID;
-  }
-
-  // The default mapping for no prefix is no namespace.  If a non-null prefix
-  // was specified and we didn't find it, we return an error.
-
-  return aPrefix ? kNameSpaceID_Unknown : kNameSpaceID_None;
-}
-
-nsAtom*
-nsXMLNameSpaceMap::FindPrefix(int32_t aNameSpaceID) const
-{
-  size_t index = mNameSpaces.IndexOf(aNameSpaceID);
-  if (index != mNameSpaces.NoIndex) {
-    return mNameSpaces[index].prefix;
-  }
-
-  return nullptr;
-}
-
-void
-nsXMLNameSpaceMap::Clear()
-{
-  mNameSpaces.Clear();
-}
deleted file mode 100644
--- a/dom/base/nsXMLNameSpaceMap.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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/. */
-
-#ifndef nsXMLNameSpaceMap_h_
-#define nsXMLNameSpaceMap_h_
-
-#include "nsString.h"
-#include "nsTArray.h"
-#include "nsCOMPtr.h"
-#include "nsAtom.h"
-
-struct nsNameSpaceEntry
-{
-  explicit nsNameSpaceEntry(nsAtom* aPrefix)
-    : prefix(aPrefix) {}
-
-  RefPtr<nsAtom> prefix;
-  MOZ_INIT_OUTSIDE_CTOR int32_t nameSpaceID;
-};
-
-/**
- * nsXMLNameSpaceMap contains a set of prefixes which are mapped onto
- * namespaces.  It allows the set to be searched by prefix or by namespace ID.
- */
-class nsXMLNameSpaceMap
-{
-public:
-  /**
-   * Allocates a new nsXMLNameSpaceMap (with new()) and if aForXML is
-   * true initializes it with the xmlns and xml namespaces.
-   */
-  static nsXMLNameSpaceMap* Create(bool aForXML);
-
-  /**
-   * Add a prefix and its corresponding namespace ID to the map.
-   * Passing a null |aPrefix| corresponds to the default namespace, which may
-   * be set to something other than kNameSpaceID_None.
-   */
-  nsresult AddPrefix(nsAtom *aPrefix, int32_t aNameSpaceID);
-
-  /**
-   * Add a prefix and a namespace URI to the map.  The URI will be converted
-   * to its corresponding namespace ID.
-   */
-  nsresult AddPrefix(nsAtom *aPrefix, nsString &aURI);
-
-  /*
-   * Returns the namespace ID for the given prefix, if it is in the map.
-   * If |aPrefix| is null and is not in the map, then a null namespace
-   * (kNameSpaceID_None) is returned.  If |aPrefix| is non-null and is not in
-   * the map, then kNameSpaceID_Unknown is returned.
-   */
-  int32_t FindNameSpaceID(nsAtom *aPrefix) const;
-
-  /**
-   * If the given namespace ID is in the map, then the first prefix which
-   * maps to that namespace is returned.  Otherwise, null is returned.
-   */
-  nsAtom* FindPrefix(int32_t aNameSpaceID) const;
-
-  /* Removes all prefix mappings. */
-  void Clear();
-
-  ~nsXMLNameSpaceMap() { Clear(); }
-
-private:
-  nsXMLNameSpaceMap();  // use Create() to create new instances
-
-  nsTArray<nsNameSpaceEntry> mNameSpaces;
-};
-
-#endif