From cf5d21b1f8a42e2d2ac2e7b9fc920b676f218ae6 Mon Sep 17 00:00:00 2001 From: Jonathan Kingston Date: Tue, 28 Jun 2016 15:24:48 +0100 Subject: [PATCH] Bug 1173199 - Create preference to disable MathML. r=huseby, r=smaug If the mathml.disabled preference is true, treat and other MathML elements as generic XML elements. This patch disables the rendering code of MathML however preserves the namespace so to reduce the breakage. Original patch by: Kathy Brade MozReview-Commit-ID: A2f2Q2b4eqR --HG-- extra : rebase_source : 63bf465fa6ff62610d7ed16002a7d479b87df393 --- dom/base/Element.cpp | 6 +- dom/base/NameSpaceConstants.h | 3 +- dom/base/NodeInfo.cpp | 3 +- dom/base/nsContentUtils.cpp | 3 +- dom/base/nsDOMAttributeMap.cpp | 3 +- dom/base/nsNameSpaceManager.cpp | 80 ++++++++++- dom/base/nsNameSpaceManager.h | 26 ++-- dom/svg/SVGAnimationElement.cpp | 9 ++ dom/svg/SVGAnimationElement.h | 4 + dom/svg/SVGGraphicsElement.cpp | 6 + dom/svg/SVGGraphicsElement.h | 2 + dom/svg/SVGSymbolElement.cpp | 10 ++ dom/svg/SVGSymbolElement.h | 3 + dom/svg/SVGTests.cpp | 4 +- dom/svg/SVGTests.h | 2 + dom/svg/nsSVGFeatures.cpp | 8 +- dom/svg/nsSVGFeatures.h | 2 +- dom/xbl/nsXBLPrototypeBinding.cpp | 2 +- dom/xml/nsXMLContentSink.cpp | 3 + layout/mathml/moz.build | 3 + layout/mathml/tests/chrome.ini | 6 + layout/mathml/tests/mathml_example_test.html | 28 ++++ layout/mathml/tests/mochitest.ini | 1 + layout/mathml/tests/test_disabled.html | 47 +++++++ layout/mathml/tests/test_disabled_chrome.html | 55 ++++++++ .../mathml/disabled-scriptlevel-1-ref.html | 129 +++++++++++++++++ .../mathml/disabled-scriptlevel-1-ref.xhtml | 133 ++++++++++++++++++ .../mathml/disabled-scriptlevel-1.html | 129 +++++++++++++++++ .../mathml/disabled-scriptlevel-1.xhtml | 133 ++++++++++++++++++ layout/reftests/mathml/reftest.list | 2 + layout/style/ServoBindings.cpp | 3 +- modules/libpref/init/all.js | 3 + .../web-platform/mozilla/meta/MANIFEST.json | 11 +- .../html/syntax/parsing/math-parse01.html.ini | 2 + .../html/syntax/parsing/math-parse01.html | 62 ++++++++ 35 files changed, 898 insertions(+), 28 deletions(-) create mode 100644 layout/mathml/tests/chrome.ini create mode 100644 layout/mathml/tests/mathml_example_test.html create mode 100644 layout/mathml/tests/test_disabled.html create mode 100644 layout/mathml/tests/test_disabled_chrome.html create mode 100644 layout/reftests/mathml/disabled-scriptlevel-1-ref.html create mode 100644 layout/reftests/mathml/disabled-scriptlevel-1-ref.xhtml create mode 100644 layout/reftests/mathml/disabled-scriptlevel-1.html create mode 100644 layout/reftests/mathml/disabled-scriptlevel-1.xhtml create mode 100644 testing/web-platform/mozilla/meta/html/syntax/parsing/math-parse01.html.ini create mode 100644 testing/web-platform/mozilla/tests/html/syntax/parsing/math-parse01.html diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp index e56b5db3ff22..ec6d430dc365 100644 --- a/dom/base/Element.cpp +++ b/dom/base/Element.cpp @@ -1258,7 +1258,7 @@ Element::GetAttributeNS(const nsAString& aNamespaceURI, nsAString& aReturn) { int32_t nsid = - nsContentUtils::NameSpaceManager()->GetNameSpaceID(aNamespaceURI); + nsContentUtils::NameSpaceManager()->GetNameSpaceID(aNamespaceURI, OwnerDoc()); if (nsid == kNameSpaceID_Unknown) { // Unknown namespace means no attribute. @@ -1300,7 +1300,7 @@ Element::RemoveAttributeNS(const nsAString& aNamespaceURI, { nsCOMPtr name = NS_Atomize(aLocalName); int32_t nsid = - nsContentUtils::NameSpaceManager()->GetNameSpaceID(aNamespaceURI); + nsContentUtils::NameSpaceManager()->GetNameSpaceID(aNamespaceURI, OwnerDoc()); if (nsid == kNameSpaceID_Unknown) { // If the namespace ID is unknown, it means there can't possibly be an @@ -1377,7 +1377,7 @@ Element::HasAttributeNS(const nsAString& aNamespaceURI, const nsAString& aLocalName) const { int32_t nsid = - nsContentUtils::NameSpaceManager()->GetNameSpaceID(aNamespaceURI); + nsContentUtils::NameSpaceManager()->GetNameSpaceID(aNamespaceURI, OwnerDoc()); if (nsid == kNameSpaceID_Unknown) { // Unknown namespace means no attr... diff --git a/dom/base/NameSpaceConstants.h b/dom/base/NameSpaceConstants.h index e4cad72a4e3c..d6c3f079fc47 100644 --- a/dom/base/NameSpaceConstants.h +++ b/dom/base/NameSpaceConstants.h @@ -23,6 +23,7 @@ static const int32_t kNameSpaceID_None = 0; #define kNameSpaceID_RDF 8 #define kNameSpaceID_XUL 9 #define kNameSpaceID_SVG 10 -#define kNameSpaceID_LastBuiltin 10 // last 'built-in' namespace +#define kNameSpaceID_disabled_MathML 11 +#define kNameSpaceID_LastBuiltin 11 // last 'built-in' namespace #endif // mozilla_dom_NameSpaceConstants_h__ diff --git a/dom/base/NodeInfo.cpp b/dom/base/NodeInfo.cpp index 791d4881ab2e..856d06c35aaf 100644 --- a/dom/base/NodeInfo.cpp +++ b/dom/base/NodeInfo.cpp @@ -197,7 +197,8 @@ bool NodeInfo::NamespaceEquals(const nsAString& aNamespaceURI) const { int32_t nsid = - nsContentUtils::NameSpaceManager()->GetNameSpaceID(aNamespaceURI); + nsContentUtils::NameSpaceManager()->GetNameSpaceID(aNamespaceURI, + mOwnerManager->GetDocument()); return mozilla::dom::NodeInfo::NamespaceEquals(nsid); } diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index e59869009e24..e0b68ebafd83 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -2892,7 +2892,8 @@ nsContentUtils::SplitQName(const nsIContent* aNamespaceResolver, nameSpace); NS_ENSURE_SUCCESS(rv, rv); - *aNamespace = NameSpaceManager()->GetNameSpaceID(nameSpace); + *aNamespace = NameSpaceManager()->GetNameSpaceID(nameSpace, + aNamespaceResolver->OwnerDoc()); if (*aNamespace == kNameSpaceID_Unknown) return NS_ERROR_FAILURE; diff --git a/dom/base/nsDOMAttributeMap.cpp b/dom/base/nsDOMAttributeMap.cpp index fe7de268ba98..ca9be88cc955 100644 --- a/dom/base/nsDOMAttributeMap.cpp +++ b/dom/base/nsDOMAttributeMap.cpp @@ -446,7 +446,8 @@ nsDOMAttributeMap::GetAttrNodeInfo(const nsAString& aNamespaceURI, if (!aNamespaceURI.IsEmpty()) { nameSpaceID = - nsContentUtils::NameSpaceManager()->GetNameSpaceID(aNamespaceURI); + nsContentUtils::NameSpaceManager()->GetNameSpaceID(aNamespaceURI, + mContent->OwnerDoc()); if (nameSpaceID == kNameSpaceID_Unknown) { return nullptr; diff --git a/dom/base/nsNameSpaceManager.cpp b/dom/base/nsNameSpaceManager.cpp index fb37832f6dcc..f82bf02be8c1 100644 --- a/dom/base/nsNameSpaceManager.cpp +++ b/dom/base/nsNameSpaceManager.cpp @@ -15,17 +15,25 @@ #include "mozilla/dom/NodeInfo.h" #include "nsCOMArray.h" #include "nsContentCreatorFunctions.h" +#include "nsContentUtils.h" #include "nsGkAtoms.h" +#include "nsIDocument.h" #include "nsString.h" #include "mozilla/dom/NodeInfo.h" #include "mozilla/ClearOnShutdown.h" #include "mozilla/dom/XBLChildrenElement.h" #include "mozilla/dom/Element.h" +#include "mozilla/Preferences.h" using namespace mozilla; using namespace mozilla::dom; -StaticAutoPtr nsNameSpaceManager::sInstance; +static const char* kPrefMathMLDisabled = "mathml.disabled"; +static const char* kObservedPrefs[] = { + kPrefMathMLDisabled, + nullptr +}; +StaticRefPtr nsNameSpaceManager::sInstance; /* static */ nsNameSpaceManager* nsNameSpaceManager::GetInstance() { @@ -49,6 +57,14 @@ bool nsNameSpaceManager::Init() rv = AddNameSpace(dont_AddRef(uri), id); \ NS_ENSURE_SUCCESS(rv, false) +#define REGISTER_DISABLED_NAMESPACE(uri, id) \ + rv = AddDisabledNameSpace(dont_AddRef(uri), id); \ + NS_ENSURE_SUCCESS(rv, false) + + mozilla::Preferences::AddStrongObservers(this, kObservedPrefs); + mMathMLDisabled = mozilla::Preferences::GetBool(kPrefMathMLDisabled); + + // Need to be ordered according to ID. REGISTER_NAMESPACE(nsGkAtoms::nsuri_xmlns, kNameSpaceID_XMLNS); REGISTER_NAMESPACE(nsGkAtoms::nsuri_xml, kNameSpaceID_XML); @@ -60,8 +76,10 @@ bool nsNameSpaceManager::Init() REGISTER_NAMESPACE(nsGkAtoms::nsuri_rdf, kNameSpaceID_RDF); REGISTER_NAMESPACE(nsGkAtoms::nsuri_xul, kNameSpaceID_XUL); REGISTER_NAMESPACE(nsGkAtoms::nsuri_svg, kNameSpaceID_SVG); + REGISTER_DISABLED_NAMESPACE(nsGkAtoms::nsuri_mathml, kNameSpaceID_disabled_MathML); #undef REGISTER_NAMESPACE +#undef REGISTER_DISABLED_NAMESPACE return true; } @@ -110,24 +128,32 @@ nsNameSpaceManager::GetNameSpaceURI(int32_t aNameSpaceID, nsAString& aURI) } int32_t -nsNameSpaceManager::GetNameSpaceID(const nsAString& aURI) +nsNameSpaceManager::GetNameSpaceID(const nsAString& aURI, + nsIDocument* aDocument) { if (aURI.IsEmpty()) { return kNameSpaceID_None; // xmlns="", see bug 75700 for details } nsCOMPtr atom = NS_Atomize(aURI); - return GetNameSpaceID(atom); + return GetNameSpaceID(atom, aDocument); } int32_t -nsNameSpaceManager::GetNameSpaceID(nsIAtom* aURI) +nsNameSpaceManager::GetNameSpaceID(nsIAtom* aURI, + nsIDocument* aDocument) { if (aURI == nsGkAtoms::_empty) { return kNameSpaceID_None; // xmlns="", see bug 75700 for details } int32_t nameSpaceID; + if (mMathMLDisabled && + mDisabledURIToIDTable.Get(aURI, &nameSpaceID) && + !nsContentUtils::IsChromeDoc(aDocument)) { + NS_POSTCONDITION(nameSpaceID >= 0, "Bogus namespace ID"); + return nameSpaceID; + } if (mURIToIDTable.Get(aURI, &nameSpaceID)) { NS_POSTCONDITION(nameSpaceID >= 0, "Bogus namespace ID"); return nameSpaceID; @@ -153,7 +179,19 @@ NS_NewElement(Element** aResult, } #endif if (ns == kNameSpaceID_MathML) { - return NS_NewMathMLElement(aResult, ni.forget()); + // If the mathml.disabled pref. is true, convert all MathML nodes into + // disabled MathML nodes by swapping the namespace. + nsNameSpaceManager* nsmgr = nsNameSpaceManager::GetInstance(); + if ((nsmgr && !nsmgr->mMathMLDisabled) || + nsContentUtils::IsChromeDoc(ni->GetDocument())) { + return NS_NewMathMLElement(aResult, ni.forget()); + } + + RefPtr genericXMLNI = + ni->NodeInfoManager()-> + GetNodeInfo(ni->NameAtom(), ni->GetPrefixAtom(), + kNameSpaceID_disabled_MathML, ni->NodeType(), ni->GetExtraName()); + return NS_NewXMLElement(aResult, genericXMLNI.forget()); } if (ns == kNameSpaceID_SVG) { return NS_NewSVGElement(aResult, ni.forget(), aFromParser); @@ -195,3 +233,35 @@ nsresult nsNameSpaceManager::AddNameSpace(already_AddRefed aURI, return NS_OK; } + +nsresult +nsNameSpaceManager::AddDisabledNameSpace(already_AddRefed aURI, + const int32_t aNameSpaceID) +{ + nsCOMPtr uri = aURI; + if (aNameSpaceID < 0) { + // We've wrapped... Can't do anything else here; just bail. + return NS_ERROR_OUT_OF_MEMORY; + } + + NS_ASSERTION(aNameSpaceID - 1 == (int32_t) mURIArray.Length(), + "BAD! AddDisabledNameSpace not called in right order!"); + + mURIArray.AppendElement(uri.forget()); + mDisabledURIToIDTable.Put(mURIArray.LastElement(), aNameSpaceID); + + return NS_OK; +} + +// nsISupports +NS_IMPL_ISUPPORTS(nsNameSpaceManager, + nsIObserver) + +// nsIObserver +NS_IMETHODIMP +nsNameSpaceManager::Observe(nsISupports* aObject, const char* aTopic, + const char16_t* aMessage) +{ + mMathMLDisabled = mozilla::Preferences::GetBool(kPrefMathMLDisabled); + return NS_OK; +} diff --git a/dom/base/nsNameSpaceManager.h b/dom/base/nsNameSpaceManager.h index 2d12391c9f31..9bbf4e6590b1 100644 --- a/dom/base/nsNameSpaceManager.h +++ b/dom/base/nsNameSpaceManager.h @@ -10,6 +10,8 @@ #include "nsDataHashtable.h" #include "nsHashKeys.h" #include "nsIAtom.h" +#include "nsIDocument.h" +#include "nsIObserver.h" #include "nsTArray.h" #include "mozilla/StaticPtr.h" @@ -30,34 +32,42 @@ class nsAString; * */ -class nsNameSpaceManager final +class nsNameSpaceManager final : public nsIObserver { public: - ~nsNameSpaceManager() {} + NS_DECL_ISUPPORTS + NS_DECL_NSIOBSERVER + virtual nsresult RegisterNameSpace(const nsAString& aURI, + int32_t& aNameSpaceID); - nsresult RegisterNameSpace(const nsAString& aURI, int32_t& aNameSpaceID); - - nsresult GetNameSpaceURI(int32_t aNameSpaceID, nsAString& aURI); + virtual nsresult GetNameSpaceURI(int32_t aNameSpaceID, nsAString& aURI); nsIAtom* NameSpaceURIAtom(int32_t aNameSpaceID) { MOZ_ASSERT(aNameSpaceID > 0 && (int64_t) aNameSpaceID <= (int64_t) mURIArray.Length()); return mURIArray.ElementAt(aNameSpaceID - 1); // id is index + 1 } - int32_t GetNameSpaceID(const nsAString& aURI); - int32_t GetNameSpaceID(nsIAtom* aURI); + int32_t GetNameSpaceID(const nsAString& aURI, + nsIDocument* aDocument); + int32_t GetNameSpaceID(nsIAtom* aURI, + nsIDocument* aDocument); bool HasElementCreator(int32_t aNameSpaceID); static nsNameSpaceManager* GetInstance(); + bool mMathMLDisabled; + private: bool Init(); nsresult AddNameSpace(already_AddRefed aURI, const int32_t aNameSpaceID); + nsresult AddDisabledNameSpace(already_AddRefed aURI, const int32_t aNameSpaceID); + ~nsNameSpaceManager() {}; nsDataHashtable mURIToIDTable; + nsDataHashtable mDisabledURIToIDTable; nsTArray> mURIArray; - static mozilla::StaticAutoPtr sInstance; + static mozilla::StaticRefPtr sInstance; }; #endif // nsNameSpaceManager_h___ diff --git a/dom/svg/SVGAnimationElement.cpp b/dom/svg/SVGAnimationElement.cpp index 9b8431c7e4fe..c9d1191daf4b 100644 --- a/dom/svg/SVGAnimationElement.cpp +++ b/dom/svg/SVGAnimationElement.cpp @@ -348,6 +348,15 @@ SVGAnimationElement::IsNodeOfType(uint32_t aFlags) const return !(aFlags & ~(eCONTENT | eANIMATION)); } +//---------------------------------------------------------------------- +// SVGTests methods + +bool +SVGAnimationElement::IsInChromeDoc() const +{ + return nsContentUtils::IsChromeDoc(OwnerDoc()); +} + //---------------------------------------------------------------------- // SVG utility methods diff --git a/dom/svg/SVGAnimationElement.h b/dom/svg/SVGAnimationElement.h index 8297a339fb97..9bcbdf0c2214 100644 --- a/dom/svg/SVGAnimationElement.h +++ b/dom/svg/SVGAnimationElement.h @@ -86,6 +86,10 @@ public: void EndElement(ErrorResult& rv) { EndElementAt(0.f, rv); } void EndElementAt(float offset, ErrorResult& rv); + // SVGTests + virtual bool IsInChromeDoc() const override; + + protected: // nsSVGElement overrides diff --git a/dom/svg/SVGGraphicsElement.cpp b/dom/svg/SVGGraphicsElement.cpp index d4e0fe50b37c..ba6306680317 100644 --- a/dom/svg/SVGGraphicsElement.cpp +++ b/dom/svg/SVGGraphicsElement.cpp @@ -31,5 +31,11 @@ SVGGraphicsElement::~SVGGraphicsElement() { } +bool +SVGGraphicsElement::IsInChromeDoc() const +{ + return nsContentUtils::IsChromeDoc(OwnerDoc()); +} + } // namespace dom } // namespace mozilla diff --git a/dom/svg/SVGGraphicsElement.h b/dom/svg/SVGGraphicsElement.h index 57a284fda1e8..a6437dba9ed6 100644 --- a/dom/svg/SVGGraphicsElement.h +++ b/dom/svg/SVGGraphicsElement.h @@ -25,6 +25,8 @@ protected: public: // interfaces: NS_DECL_ISUPPORTS_INHERITED + + bool IsInChromeDoc() const override; }; } // namespace dom diff --git a/dom/svg/SVGSymbolElement.cpp b/dom/svg/SVGSymbolElement.cpp index 7f77b464edb2..42de96efd182 100644 --- a/dom/svg/SVGSymbolElement.cpp +++ b/dom/svg/SVGSymbolElement.cpp @@ -80,6 +80,16 @@ SVGSymbolElement::IsAttributeMapped(const nsIAtom* name) const SVGSymbolElementBase::IsAttributeMapped(name); } +//---------------------------------------------------------------------- +// SVGTests methods + +bool +SVGSymbolElement::IsInChromeDoc() const +{ + return nsContentUtils::IsChromeDoc(OwnerDoc()); +} + + //---------------------------------------------------------------------- // nsSVGElement methods diff --git a/dom/svg/SVGSymbolElement.h b/dom/svg/SVGSymbolElement.h index dd28a2da717a..427840f3f2fe 100644 --- a/dom/svg/SVGSymbolElement.h +++ b/dom/svg/SVGSymbolElement.h @@ -44,6 +44,9 @@ public: already_AddRefed ViewBox(); already_AddRefed PreserveAspectRatio(); + // SVGTests + bool IsInChromeDoc() const override; + protected: virtual nsSVGViewBox *GetViewBox() override; virtual SVGAnimatedPreserveAspectRatio *GetPreserveAspectRatio() override; diff --git a/dom/svg/SVGTests.cpp b/dom/svg/SVGTests.cpp index ab8077dd5aef..0fa83ca9f7b0 100644 --- a/dom/svg/SVGTests.cpp +++ b/dom/svg/SVGTests.cpp @@ -57,7 +57,7 @@ SVGTests::SystemLanguage() bool SVGTests::HasExtension(const nsAString& aExtension) { - return nsSVGFeatures::HasExtension(aExtension); + return nsSVGFeatures::HasExtension(aExtension, IsInChromeDoc()); } bool @@ -139,7 +139,7 @@ SVGTests::PassesConditionalProcessingTests(const nsString *aAcceptLangs) const return false; } for (uint32_t i = 0; i < mStringListAttributes[EXTENSIONS].Length(); i++) { - if (!nsSVGFeatures::HasExtension(mStringListAttributes[EXTENSIONS][i])) { + if (!nsSVGFeatures::HasExtension(mStringListAttributes[EXTENSIONS][i], IsInChromeDoc())) { return false; } } diff --git a/dom/svg/SVGTests.h b/dom/svg/SVGTests.h index 4e65e5b9d13a..1e0de76e3f09 100644 --- a/dom/svg/SVGTests.h +++ b/dom/svg/SVGTests.h @@ -95,6 +95,8 @@ public: already_AddRefed SystemLanguage(); bool HasExtension(const nsAString& aExtension); + virtual bool IsInChromeDoc() const = 0; + protected: virtual ~SVGTests() {} diff --git a/dom/svg/nsSVGFeatures.cpp b/dom/svg/nsSVGFeatures.cpp index 3ce6d3697e31..1b028250b6d3 100644 --- a/dom/svg/nsSVGFeatures.cpp +++ b/dom/svg/nsSVGFeatures.cpp @@ -15,6 +15,7 @@ #include "nsSVGFeatures.h" #include "nsIContent.h" #include "nsIDocument.h" +#include "nsNameSpaceManager.h" #include "mozilla/Preferences.h" using namespace mozilla; @@ -42,11 +43,14 @@ nsSVGFeatures::HasFeature(nsISupports* aObject, const nsAString& aFeature) } /*static*/ bool -nsSVGFeatures::HasExtension(const nsAString& aExtension) +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") - SVG_SUPPORTED_EXTENSION("http://www.w3.org/1998/Math/MathML") + nsNameSpaceManager* nameSpaceManager = nsNameSpaceManager::GetInstance(); + if (aIsInChrome || !nameSpaceManager->mMathMLDisabled) { + SVG_SUPPORTED_EXTENSION("http://www.w3.org/1998/Math/MathML") + } #undef SVG_SUPPORTED_EXTENSION return false; diff --git a/dom/svg/nsSVGFeatures.h b/dom/svg/nsSVGFeatures.h index 248f36a99f10..0e8ad3eec1a6 100644 --- a/dom/svg/nsSVGFeatures.h +++ b/dom/svg/nsSVGFeatures.h @@ -30,7 +30,7 @@ public: * "http://www.w3.org/1999/xhtml" and "http://www.w3.org/1998/Math/MathML" */ static bool - HasExtension(const nsAString& aExtension); + HasExtension(const nsAString& aExtension, const bool aIsInChrome); }; #endif // __NS_SVGFEATURES_H__ diff --git a/dom/xbl/nsXBLPrototypeBinding.cpp b/dom/xbl/nsXBLPrototypeBinding.cpp index 5152360f82af..43ad448c405d 100644 --- a/dom/xbl/nsXBLPrototypeBinding.cpp +++ b/dom/xbl/nsXBLPrototypeBinding.cpp @@ -1599,7 +1599,7 @@ nsXBLPrototypeBinding::ResolveBaseBinding() mBinding->LookupNamespaceURI(prefix, nameSpace); if (!nameSpace.IsEmpty()) { int32_t nameSpaceID = - nsContentUtils::NameSpaceManager()->GetNameSpaceID(nameSpace); + nsContentUtils::NameSpaceManager()->GetNameSpaceID(nameSpace, doc); nsCOMPtr tagName = NS_Atomize(display); // Check the white list diff --git a/dom/xml/nsXMLContentSink.cpp b/dom/xml/nsXMLContentSink.cpp index d36c1fb1b4f2..aeaa302f466c 100644 --- a/dom/xml/nsXMLContentSink.cpp +++ b/dom/xml/nsXMLContentSink.cpp @@ -1049,6 +1049,9 @@ nsXMLContentSink::HandleEndElement(const char16_t *aName, bool isTemplateElement = debugTagAtom == nsGkAtoms::_template && debugNameSpaceID == kNameSpaceID_XHTML; NS_ASSERTION(content->NodeInfo()->Equals(debugTagAtom, debugNameSpaceID) || + (debugNameSpaceID == kNameSpaceID_MathML && + content->NodeInfo()->NamespaceID() == kNameSpaceID_disabled_MathML && + content->NodeInfo()->Equals(debugTagAtom)) || isTemplateElement, "Wrong element being closed"); #endif diff --git a/layout/mathml/moz.build b/layout/mathml/moz.build index c177c552b467..f40b2c2c6589 100644 --- a/layout/mathml/moz.build +++ b/layout/mathml/moz.build @@ -12,6 +12,9 @@ if CONFIG['ENABLE_TESTS']: 'imptests/mochitest.ini', 'tests/mochitest.ini', ] + MOCHITEST_CHROME_MANIFESTS += [ + 'tests/chrome.ini', +] UNIFIED_SOURCES += [ 'nsMathMLChar.cpp', diff --git a/layout/mathml/tests/chrome.ini b/layout/mathml/tests/chrome.ini new file mode 100644 index 000000000000..0885f4c6b378 --- /dev/null +++ b/layout/mathml/tests/chrome.ini @@ -0,0 +1,6 @@ +[DEFAULT] + +support-files = + mathml_example_test.html + +[test_disabled_chrome.html] diff --git a/layout/mathml/tests/mathml_example_test.html b/layout/mathml/tests/mathml_example_test.html new file mode 100644 index 000000000000..6eee75d01384 --- /dev/null +++ b/layout/mathml/tests/mathml_example_test.html @@ -0,0 +1,28 @@ + + + + O + O + + + O + O + + + O + O + O + + + O + O + O + + O + O + + + + + + diff --git a/layout/mathml/tests/mochitest.ini b/layout/mathml/tests/mochitest.ini index 3d7960c72c95..6a665150964b 100644 --- a/layout/mathml/tests/mochitest.ini +++ b/layout/mathml/tests/mochitest.ini @@ -6,6 +6,7 @@ [test_bug827713-2.html] [test_bug827713.html] [test_bug975681.html] +[test_disabled.html] [test_opentype-axis-height.html] [test_opentype-fraction.html] [test_opentype-limits.html] diff --git a/layout/mathml/tests/test_disabled.html b/layout/mathml/tests/test_disabled.html new file mode 100644 index 000000000000..9b649d0f9c45 --- /dev/null +++ b/layout/mathml/tests/test_disabled.html @@ -0,0 +1,47 @@ + + + + + + + + +Mozilla Bug 166235 +
hi there
+
+
+
+ + + diff --git a/layout/mathml/tests/test_disabled_chrome.html b/layout/mathml/tests/test_disabled_chrome.html new file mode 100644 index 000000000000..dff4011bb776 --- /dev/null +++ b/layout/mathml/tests/test_disabled_chrome.html @@ -0,0 +1,55 @@ + + + + + + + + + + +Mozilla Bug 166235 +
hi there
+
+
+
+ + + diff --git a/layout/reftests/mathml/disabled-scriptlevel-1-ref.html b/layout/reftests/mathml/disabled-scriptlevel-1-ref.html new file mode 100644 index 000000000000..76658a0b678d --- /dev/null +++ b/layout/reftests/mathml/disabled-scriptlevel-1-ref.html @@ -0,0 +1,129 @@ + + + + scriptlevel + + + + + + + + O + O + + + + + + + + + O + O + + + + + O + O + + + + + + + + + + O + O + + + O + + + + + + + + + O + O + + + O + O + + + O + O + O + + + O + O + O + + O + O + + + + + + + + + O + O + + + O + O + + + O + O + O + + + + + + diff --git a/layout/reftests/mathml/disabled-scriptlevel-1-ref.xhtml b/layout/reftests/mathml/disabled-scriptlevel-1-ref.xhtml new file mode 100644 index 000000000000..6b22791ab83f --- /dev/null +++ b/layout/reftests/mathml/disabled-scriptlevel-1-ref.xhtml @@ -0,0 +1,133 @@ + + + scriptlevel + + + + + + + + + O + O + + + + + + + + + O + O + + + + + O + O + + + + + + + + + + O + O + + + O + + + + + + + + + O + O + + + O + O + + + O + O + O + + + O + O + O + + O + O + + + + + + + + + O + O + + + O + O + + + O + O + O + + + + + + diff --git a/layout/reftests/mathml/disabled-scriptlevel-1.html b/layout/reftests/mathml/disabled-scriptlevel-1.html new file mode 100644 index 000000000000..9cd388f1c77c --- /dev/null +++ b/layout/reftests/mathml/disabled-scriptlevel-1.html @@ -0,0 +1,129 @@ + + + + scriptlevel + + + + + + + + O + O + + + + + + + + + O + O + + + + + O + O + + + + + + + + + + O + O + + + O + + + + + + + + + O + O + + + O + O + + + O + O + O + + + O + O + O + + O + O + + + + + + + + + O + O + + + O + O + + + O + O + O + + + + + + diff --git a/layout/reftests/mathml/disabled-scriptlevel-1.xhtml b/layout/reftests/mathml/disabled-scriptlevel-1.xhtml new file mode 100644 index 000000000000..5d710a787c2c --- /dev/null +++ b/layout/reftests/mathml/disabled-scriptlevel-1.xhtml @@ -0,0 +1,133 @@ + + + scriptlevel + + + + + + + + + O + O + + + + + + + + + O + O + + + + + O + O + + + + + + + + + + O + O + + + O + + + + + + + + + O + O + + + O + O + + + O + O + O + + + O + O + O + + O + O + + + + + + + + + O + O + + + O + O + + + O + O + O + + + + + + diff --git a/layout/reftests/mathml/reftest.list b/layout/reftests/mathml/reftest.list index cf0ddd9305cb..8afb1082bf89 100644 --- a/layout/reftests/mathml/reftest.list +++ b/layout/reftests/mathml/reftest.list @@ -11,6 +11,8 @@ fails == dir-9.html dir-9-ref.html # Bug 787215 == dir-10.html dir-10-ref.html random-if((B2G&&browserIsRemote)||Mulet) == dir-11.html dir-11-ref.html # Initial mulet triage: parity with B2G/B2G Desktop == css-spacing-1.html css-spacing-1-ref.html +pref(mathml.disabled,true) == disabled-scriptlevel-1.html disabled-scriptlevel-1-ref.html +pref(mathml.disabled,true) == disabled-scriptlevel-1.xhtml disabled-scriptlevel-1-ref.xhtml == displaystyle-1.html displaystyle-1-ref.html == displaystyle-2.html displaystyle-2-ref.html == displaystyle-3.html displaystyle-3-ref.html diff --git a/layout/style/ServoBindings.cpp b/layout/style/ServoBindings.cpp index 3442e28d4547..f8ce49d470b2 100644 --- a/layout/style/ServoBindings.cpp +++ b/layout/style/ServoBindings.cpp @@ -232,7 +232,8 @@ static bool DoMatch(Implementor* aElement, nsIAtom* aNS, nsIAtom* aName, MatchFn aMatch) { if (aNS) { - int32_t ns = nsContentUtils::NameSpaceManager()->GetNameSpaceID(aNS); + int32_t ns = nsContentUtils::NameSpaceManager()->GetNameSpaceID(aNS, + aElement->OwnerDoc()); NS_ENSURE_TRUE(ns != kNameSpaceID_Unknown, false); const nsAttrValue* value = aElement->GetParsedAttr(aName, ns); return value && aMatch(value); diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index dc761a4b8541..31351a4ee24a 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -280,6 +280,9 @@ pref("print.shrink-to-fit.scale-limit-percent", 20); // Whether we should display simplify page checkbox on print preview UI pref("print.use_simplify_page", false); +// Disable support for MathML +pref("mathml.disabled", false); + // Enable scale transform for stretchy MathML operators. See bug 414277. pref("mathml.scale_stretchy_operators.enabled", true); diff --git a/testing/web-platform/mozilla/meta/MANIFEST.json b/testing/web-platform/mozilla/meta/MANIFEST.json index 11cbfa0b451e..221d5356697c 100644 --- a/testing/web-platform/mozilla/meta/MANIFEST.json +++ b/testing/web-platform/mozilla/meta/MANIFEST.json @@ -9,7 +9,16 @@ "local_changes": { "deleted": [], "deleted_reftests": {}, - "items": {}, + "items": { + "testharness": { + "html/syntax/parsing/math-parse01.html": [ + { + "path": "html/syntax/parsing/math-parse01.html", + "url": "/html/syntax/parsing/math-parse01.html" + } + ] + } + }, "reftest_nodes": {} }, "reftest_nodes": {}, diff --git a/testing/web-platform/mozilla/meta/html/syntax/parsing/math-parse01.html.ini b/testing/web-platform/mozilla/meta/html/syntax/parsing/math-parse01.html.ini new file mode 100644 index 000000000000..73bc9da25c6d --- /dev/null +++ b/testing/web-platform/mozilla/meta/html/syntax/parsing/math-parse01.html.ini @@ -0,0 +1,2 @@ +[math-parse01.html] + prefs: ["mathml.disabled:true"] diff --git a/testing/web-platform/mozilla/tests/html/syntax/parsing/math-parse01.html b/testing/web-platform/mozilla/tests/html/syntax/parsing/math-parse01.html new file mode 100644 index 000000000000..3aff716d9f7c --- /dev/null +++ b/testing/web-platform/mozilla/tests/html/syntax/parsing/math-parse01.html @@ -0,0 +1,62 @@ + + + +math in html: parsing + + + + +

math in html: parsing

+ +
+ +
+
+
+
1a
+
⟨⟩
+
𝕂
+
a
+
a
+
+ + +