Bug 1516947 - remove nsSVGFeatures by moving its code into SVGTests r=jwatt

This commit is contained in:
longsonr 2018-12-31 15:10:00 +00:00
parent e990c18296
commit ceed8b45c3
5 changed files with 13 additions and 67 deletions

View File

@ -8,7 +8,6 @@
#include "DOMSVGStringList.h"
#include "nsIContent.h"
#include "nsIContentInlines.h"
#include "nsSVGFeatures.h"
#include "mozilla/dom/SVGSwitchElement.h"
#include "nsCharSeparatedTokenizer.h"
#include "nsStyleUtil.h"
@ -42,9 +41,17 @@ already_AddRefed<DOMSVGStringList> SVGTests::SystemLanguage() {
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(
@ -109,8 +116,7 @@ bool SVGTests::PassesConditionalProcessingTests(
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;
}
}

View File

@ -96,7 +96,7 @@ class SVGTests : public nsISupports {
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;

View File

@ -11,7 +11,6 @@ MOCHITEST_MANIFESTS += ['test/mochitest.ini']
EXPORTS += [
'nsSVGClass.h',
'nsSVGFeatures.h',
]
EXPORTS.mozilla += [
@ -131,7 +130,6 @@ UNIFIED_SOURCES += [
'nsSVGBoolean.cpp',
'nsSVGClass.cpp',
'nsSVGEnum.cpp',
'nsSVGFeatures.cpp',
'nsSVGInteger.cpp',
'nsSVGIntegerPair.cpp',
'nsSVGLength2.cpp',

View File

@ -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;
}

View File

@ -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__