Bug 1516947 - remove nsSVGFeatures by moving its code into SVGTests r=jwatt
authorlongsonr <longsonr@gmail.com>
Mon, 31 Dec 2018 15:10:00 +0000
changeset 509305 13c1ffa4ed2b21db98e2064d16c71ea5d6c874e9
parent 509285 275c43b8572c70306e56d30e1f4e3df2f1c7090f
child 509306 cfc78c02568f395b46976fb724e40eef9299e628
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwatt
bugs1516947
milestone66.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 1516947 - remove nsSVGFeatures by moving its code into SVGTests r=jwatt
dom/svg/SVGTests.cpp
dom/svg/SVGTests.h
dom/svg/moz.build
dom/svg/nsSVGFeatures.cpp
dom/svg/nsSVGFeatures.h
--- a/dom/svg/SVGTests.cpp
+++ b/dom/svg/SVGTests.cpp
@@ -3,17 +3,16 @@
 /* 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/. */
 
 #include "mozilla/dom/SVGTests.h"
 #include "DOMSVGStringList.h"
 #include "nsIContent.h"
 #include "nsIContentInlines.h"
-#include "nsSVGFeatures.h"
 #include "mozilla/dom/SVGSwitchElement.h"
 #include "nsCharSeparatedTokenizer.h"
 #include "nsStyleUtil.h"
 #include "mozilla/Preferences.h"
 
 namespace mozilla {
 namespace dom {
 
@@ -37,19 +36,27 @@ already_AddRefed<DOMSVGStringList> SVGTe
                                          AsSVGElement(), true, EXTENSIONS);
 }
 
 already_AddRefed<DOMSVGStringList> SVGTests::SystemLanguage() {
   return DOMSVGStringList::GetDOMWrapper(&mStringListAttributes[LANGUAGE],
                                          AsSVGElement(), true, LANGUAGE);
 }
 
-bool SVGTests::HasExtension(const nsAString& aExtension) {
-  return nsSVGFeatures::HasExtension(aExtension,
-                                     AsSVGElement()->IsInChromeDocument());
+bool SVGTests::HasExtension(const nsAString& aExtension) const {
+#define SVG_SUPPORTED_EXTENSION(str) \
+  if (aExtension.EqualsLiteral(str)) return true;
+  SVG_SUPPORTED_EXTENSION("http://www.w3.org/1999/xhtml")
+  nsNameSpaceManager* nameSpaceManager = nsNameSpaceManager::GetInstance();
+  if (AsSVGElement()->IsInChromeDocument() || !nameSpaceManager->mMathMLDisabled) {
+    SVG_SUPPORTED_EXTENSION("http://www.w3.org/1998/Math/MathML")
+  }
+#undef SVG_SUPPORTED_EXTENSION
+
+  return false;
 }
 
 bool SVGTests::IsConditionalProcessingAttribute(
     const nsAtom* aAttribute) const {
   for (uint32_t i = 0; i < ArrayLength(sStringListNames); i++) {
     if (aAttribute == sStringListNames[i]) {
       return true;
     }
@@ -104,18 +111,17 @@ bool SVGTests::PassesConditionalProcessi
   // go beyond the feature set defined in the SVG specification.
   // Each extension is identified by a URI reference.
   // For now, claim that mozilla's SVG implementation supports XHTML and MathML.
   if (mStringListAttributes[EXTENSIONS].IsExplicitlySet()) {
     if (mStringListAttributes[EXTENSIONS].IsEmpty()) {
       return false;
     }
     for (uint32_t i = 0; i < mStringListAttributes[EXTENSIONS].Length(); i++) {
-      if (!nsSVGFeatures::HasExtension(mStringListAttributes[EXTENSIONS][i],
-                                       AsSVGElement()->IsInChromeDocument())) {
+      if (!HasExtension(mStringListAttributes[EXTENSIONS][i])) {
         return false;
       }
     }
   }
 
   if (aAcceptLangs == kIgnoreSystemLanguage) {
     return true;
   }
--- a/dom/svg/SVGTests.h
+++ b/dom/svg/SVGTests.h
@@ -91,17 +91,17 @@ class SVGTests : public nsISupports {
   void GetAttrValue(uint8_t aAttrEnum, nsAttrValue& aValue) const;
 
   void MaybeInvalidate();
 
   // WebIDL
   already_AddRefed<DOMSVGStringList> RequiredFeatures();
   already_AddRefed<DOMSVGStringList> RequiredExtensions();
   already_AddRefed<DOMSVGStringList> SystemLanguage();
-  bool HasExtension(const nsAString& aExtension);
+  bool HasExtension(const nsAString& aExtension) const;
 
   virtual SVGElement* AsSVGElement() = 0;
 
   const SVGElement* AsSVGElement() const {
     return const_cast<SVGTests*>(this)->AsSVGElement();
   }
 
  protected:
--- a/dom/svg/moz.build
+++ b/dom/svg/moz.build
@@ -6,17 +6,16 @@
 
 with Files("**"):
     BUG_COMPONENT = ("Core", "SVG")
 
 MOCHITEST_MANIFESTS += ['test/mochitest.ini']
 
 EXPORTS += [
     'nsSVGClass.h',
-    'nsSVGFeatures.h',
 ]
 
 EXPORTS.mozilla += [
     'SVGAttrValueWrapper.h',
     'SVGContentUtils.h',
     'SVGPreserveAspectRatio.h',
     'SVGStringList.h',
     'SVGTagList.h',
@@ -126,17 +125,16 @@ UNIFIED_SOURCES += [
     'DOMSVGStringList.cpp',
     'DOMSVGTransform.cpp',
     'DOMSVGTransformList.cpp',
     'nsISVGPoint.cpp',
     'nsSVGAngle.cpp',
     'nsSVGBoolean.cpp',
     'nsSVGClass.cpp',
     'nsSVGEnum.cpp',
-    'nsSVGFeatures.cpp',
     'nsSVGInteger.cpp',
     'nsSVGIntegerPair.cpp',
     'nsSVGLength2.cpp',
     'nsSVGNumber2.cpp',
     'nsSVGNumberPair.cpp',
     'nsSVGString.cpp',
     'nsSVGViewBox.cpp',
     'SVGAElement.cpp',
deleted file mode 100644
--- a/dom/svg/nsSVGFeatures.cpp
+++ /dev/null
@@ -1,35 +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/. */
-
-/**
- * This file contains code to help implement the Conditional Processing
- * section of the SVG specification (i.e. the <switch> element and the
- * requiredFeatures, requiredExtensions and systemLanguage attributes).
- *
- *   http://www.w3.org/TR/SVG11/struct.html#ConditionalProcessing
- */
-
-#include "nsSVGFeatures.h"
-#include "nsIContent.h"
-#include "nsIDocument.h"
-#include "nsNameSpaceManager.h"
-#include "mozilla/Preferences.h"
-
-using namespace mozilla;
-
-/*static*/ bool nsSVGFeatures::HasExtension(const nsAString& aExtension,
-                                            const bool aIsInChrome) {
-#define SVG_SUPPORTED_EXTENSION(str) \
-  if (aExtension.EqualsLiteral(str)) return true;
-  SVG_SUPPORTED_EXTENSION("http://www.w3.org/1999/xhtml")
-  nsNameSpaceManager* nameSpaceManager = nsNameSpaceManager::GetInstance();
-  if (aIsInChrome || !nameSpaceManager->mMathMLDisabled) {
-    SVG_SUPPORTED_EXTENSION("http://www.w3.org/1998/Math/MathML")
-  }
-#undef SVG_SUPPORTED_EXTENSION
-
-  return false;
-}
deleted file mode 100644
--- a/dom/svg/nsSVGFeatures.h
+++ /dev/null
@@ -1,23 +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 __NS_SVGFEATURES_H__
-#define __NS_SVGFEATURES_H__
-
-#include "nsString.h"
-
-class nsSVGFeatures {
- public:
-  /**
-   * Check whether we support the given extension string.
-   *
-   * @param aExtension the URI of an extension. Known extensions are
-   *   "http://www.w3.org/1999/xhtml" and "http://www.w3.org/1998/Math/MathML"
-   */
-  static bool HasExtension(const nsAString& aExtension, const bool aIsInChrome);
-};
-
-#endif  // __NS_SVGFEATURES_H__