Commit 8c5d7e5e authored by Andrew McCreight's avatar Andrew McCreight
Browse files

Bug 1736707, part 1 - Get rid of nsContentUtils::NameSpaceManager(). r=peterv

Call nsNameSpaceManager::GetInstance() instead.

Differential Revision: https://phabricator.services.mozilla.com/D129033
parent 1ee43111
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@
#include "js/PropertyAndElement.h"  // JS_GetProperty, JS_GetUCProperty
#include "xpcprivate.h"
#include "nsGlobalWindow.h"
#include "nsNameSpaceManager.h"

namespace mozilla::dom {

@@ -1219,7 +1220,7 @@ void CustomElementRegistry::Upgrade(Element* aElement,
        int32_t namespaceID = name->NamespaceID();
        nsAutoString attrValue, namespaceURI;
        info.mValue->ToString(attrValue);
        nsContentUtils::NameSpaceManager()->GetNameSpaceURI(namespaceID,
        nsNameSpaceManager::GetInstance()->GetNameSpaceURI(namespaceID,
                                                           namespaceURI);

        LifecycleCallbackArgs args = {
+3 −1
Original line number Diff line number Diff line
@@ -17,10 +17,12 @@
#include "mozilla/dom/ShadowRoot.h"
#include "mozilla/dom/StyleSheetList.h"
#include "nsTHashtable.h"
#include "nsContentUtils.h"
#include "nsFocusManager.h"
#include "nsIRadioVisitor.h"
#include "nsIFormControl.h"
#include "nsLayoutUtils.h"
#include "nsNameSpaceManager.h"
#include "nsWindowSizes.h"

namespace mozilla::dom {
@@ -264,7 +266,7 @@ already_AddRefed<nsContentList> DocumentOrShadowRoot::GetElementsByTagNameNS(
  int32_t nameSpaceId = kNameSpaceID_Wildcard;

  if (!aNamespaceURI.EqualsLiteral("*")) {
    aResult = nsContentUtils::NameSpaceManager()->RegisterNameSpace(
    aResult = nsNameSpaceManager::GetInstance()->RegisterNameSpace(
        aNamespaceURI, nameSpaceId);
    if (aResult.Failed()) {
      return nullptr;
+10 −10
Original line number Diff line number Diff line
@@ -1481,7 +1481,7 @@ already_AddRefed<Attr> Element::RemoveAttributeNode(Attr& aAttribute,

void Element::GetAttributeNS(const nsAString& aNamespaceURI,
                             const nsAString& aLocalName, nsAString& aReturn) {
  int32_t nsid = nsContentUtils::NameSpaceManager()->GetNameSpaceID(
  int32_t nsid = nsNameSpaceManager::GetInstance()->GetNameSpaceID(
      aNamespaceURI, nsContentUtils::IsChromeDoc(OwnerDoc()));

  if (nsid == kNameSpaceID_Unknown) {
@@ -1554,7 +1554,7 @@ void Element::RemoveAttributeNS(const nsAString& aNamespaceURI,
                                const nsAString& aLocalName,
                                ErrorResult& aError) {
  RefPtr<nsAtom> name = NS_AtomizeMainThread(aLocalName);
  int32_t nsid = nsContentUtils::NameSpaceManager()->GetNameSpaceID(
  int32_t nsid = nsNameSpaceManager::GetInstance()->GetNameSpaceID(
      aNamespaceURI, nsContentUtils::IsChromeDoc(OwnerDoc()));

  if (nsid == kNameSpaceID_Unknown) {
@@ -1588,8 +1588,8 @@ already_AddRefed<nsIHTMLCollection> Element::GetElementsByTagNameNS(
  int32_t nameSpaceId = kNameSpaceID_Wildcard;

  if (!aNamespaceURI.EqualsLiteral("*")) {
    aError = nsContentUtils::NameSpaceManager()->RegisterNameSpace(
        aNamespaceURI, nameSpaceId);
    aError = nsNameSpaceManager::GetInstance()->RegisterNameSpace(aNamespaceURI,
                                                                  nameSpaceId);
    if (aError.Failed()) {
      return nullptr;
    }
@@ -1602,7 +1602,7 @@ already_AddRefed<nsIHTMLCollection> Element::GetElementsByTagNameNS(

bool Element::HasAttributeNS(const nsAString& aNamespaceURI,
                             const nsAString& aLocalName) const {
  int32_t nsid = nsContentUtils::NameSpaceManager()->GetNameSpaceID(
  int32_t nsid = nsNameSpaceManager::GetInstance()->GetNameSpaceID(
      aNamespaceURI, nsContentUtils::IsChromeDoc(OwnerDoc()));

  if (nsid == kNameSpaceID_Unknown) {
@@ -2504,7 +2504,7 @@ nsresult Element::SetAttrAndNotify(
      }
      RefPtr<nsAtom> newValueAtom = valueForAfterSetAttr.GetAsAtom();
      nsAutoString ns;
      nsContentUtils::NameSpaceManager()->GetNameSpaceURI(aNamespaceID, ns);
      nsNameSpaceManager::GetInstance()->GetNameSpaceURI(aNamespaceID, ns);

      LifecycleCallbackArgs args = {nsDependentAtomString(aName),
                                    aModType == MutationEvent_Binding::ADDITION
@@ -2545,7 +2545,7 @@ nsresult Element::SetAttrAndNotify(
    InternalMutationEvent mutation(true, eLegacyAttrModified);

    nsAutoString ns;
    nsContentUtils::NameSpaceManager()->GetNameSpaceURI(aNamespaceID, ns);
    nsNameSpaceManager::GetInstance()->GetNameSpaceURI(aNamespaceID, ns);
    Attr* attrNode =
        GetAttributeNodeNSInternal(ns, nsDependentAtomString(aName));
    mutation.mRelatedNode = attrNode;
@@ -2690,7 +2690,7 @@ nsresult Element::OnAttrSetButNotChanged(int32_t aNamespaceID, nsAtom* aName,

    if (definition->IsInObservedAttributeList(aName)) {
      nsAutoString ns;
      nsContentUtils::NameSpaceManager()->GetNameSpaceURI(aNamespaceID, ns);
      nsNameSpaceManager::GetInstance()->GetNameSpaceURI(aNamespaceID, ns);

      nsAutoString value(aValue.String());
      LifecycleCallbackArgs args = {nsDependentAtomString(aName), value, value,
@@ -2767,7 +2767,7 @@ nsresult Element::UnsetAttr(int32_t aNameSpaceID, nsAtom* aName, bool aNotify) {
  RefPtr<Attr> attrNode;
  if (hasMutationListeners) {
    nsAutoString ns;
    nsContentUtils::NameSpaceManager()->GetNameSpaceURI(aNameSpaceID, ns);
    nsNameSpaceManager::GetInstance()->GetNameSpaceURI(aNameSpaceID, ns);
    attrNode = GetAttributeNodeNSInternal(ns, nsDependentAtomString(aName));
  }

@@ -2802,7 +2802,7 @@ nsresult Element::UnsetAttr(int32_t aNameSpaceID, nsAtom* aName, bool aNotify) {

    if (definition->IsInObservedAttributeList(aName)) {
      nsAutoString ns;
      nsContentUtils::NameSpaceManager()->GetNameSpaceURI(aNameSpaceID, ns);
      nsNameSpaceManager::GetInstance()->GetNameSpaceURI(aNameSpaceID, ns);

      RefPtr<nsAtom> oldValueAtom = oldValue.GetAsAtom();
      LifecycleCallbackArgs args = {
+2 −2
Original line number Diff line number Diff line
@@ -155,7 +155,7 @@ void NodeInfo::GetPrefix(nsAString& aPrefix) const {

void NodeInfo::GetNamespaceURI(nsAString& aNameSpaceURI) const {
  if (mInner.mNamespaceID > 0) {
    nsresult rv = nsContentUtils::NameSpaceManager()->GetNameSpaceURI(
    nsresult rv = nsNameSpaceManager::GetInstance()->GetNameSpaceURI(
        mInner.mNamespaceID, aNameSpaceURI);
    // How can we possibly end up with a bogus namespace ID here?
    if (NS_FAILED(rv)) {
@@ -167,7 +167,7 @@ void NodeInfo::GetNamespaceURI(nsAString& aNameSpaceURI) const {
}

bool NodeInfo::NamespaceEquals(const nsAString& aNamespaceURI) const {
  int32_t nsid = nsContentUtils::NameSpaceManager()->GetNameSpaceID(
  int32_t nsid = nsNameSpaceManager::GetInstance()->GetNameSpaceID(
      aNamespaceURI, nsContentUtils::IsChromeDoc(mOwnerManager->GetDocument()));

  return mozilla::dom::NodeInfo::NamespaceEquals(nsid);
+1 −1
Original line number Diff line number Diff line
@@ -3347,7 +3347,7 @@ nsresult nsContentUtils::SplitQName(const nsIContent* aNamespaceResolver,
        Substring(aQName.get(), colon), nameSpace);
    NS_ENSURE_SUCCESS(rv, rv);

    *aNamespace = NameSpaceManager()->GetNameSpaceID(
    *aNamespace = nsNameSpaceManager::GetInstance()->GetNameSpaceID(
        nameSpace, nsContentUtils::IsChromeDoc(aNamespaceResolver->OwnerDoc()));
    if (*aNamespace == kNameSpaceID_Unknown) return NS_ERROR_FAILURE;

Loading