2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2004-08-24 03:29:08 +04:00
|
|
|
|
2008-07-13 15:30:48 +04:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2009-05-07 23:37:33 +04:00
|
|
|
#include "nsSVGFeatures.h"
|
2008-07-13 15:30:48 +04:00
|
|
|
#include "nsIContent.h"
|
2013-10-02 15:40:07 +04:00
|
|
|
#include "nsIDocument.h"
|
2016-06-28 17:24:48 +03:00
|
|
|
#include "nsNameSpaceManager.h"
|
2011-05-27 08:53:03 +04:00
|
|
|
#include "mozilla/Preferences.h"
|
|
|
|
|
|
|
|
using namespace mozilla;
|
2008-07-13 15:30:48 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
/*static*/ bool
|
2011-12-31 13:44:03 +04:00
|
|
|
nsSVGFeatures::HasFeature(nsISupports* aObject, const nsAString& aFeature)
|
2008-07-13 15:30:48 +04:00
|
|
|
{
|
2011-04-29 15:28:10 +04:00
|
|
|
if (aFeature.EqualsLiteral("http://www.w3.org/TR/SVG11/feature#Script")) {
|
|
|
|
nsCOMPtr<nsIContent> content(do_QueryInterface(aObject));
|
|
|
|
if (content) {
|
2014-10-03 16:32:26 +04:00
|
|
|
nsIDocument* doc = content->GetUncomposedDoc();
|
2011-04-29 15:28:10 +04:00
|
|
|
if (doc && doc->IsResourceDoc()) {
|
|
|
|
// no scripting in SVG images or external resource documents
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2011-04-29 15:28:10 +04:00
|
|
|
}
|
|
|
|
}
|
2011-09-29 10:19:26 +04:00
|
|
|
return Preferences::GetBool("javascript.enabled", false);
|
2011-04-29 15:28:10 +04:00
|
|
|
}
|
2011-10-17 18:59:28 +04:00
|
|
|
#define SVG_SUPPORTED_FEATURE(str) if (aFeature.EqualsLiteral(str)) return true;
|
2004-08-24 03:29:08 +04:00
|
|
|
#define SVG_UNSUPPORTED_FEATURE(str)
|
|
|
|
#include "nsSVGFeaturesList.h"
|
|
|
|
#undef SVG_SUPPORTED_FEATURE
|
|
|
|
#undef SVG_UNSUPPORTED_FEATURE
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2004-08-24 03:29:08 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
/*static*/ bool
|
2016-06-28 17:24:48 +03:00
|
|
|
nsSVGFeatures::HasExtension(const nsAString& aExtension, const bool aIsInChrome)
|
2008-10-29 07:21:06 +03:00
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
#define SVG_SUPPORTED_EXTENSION(str) if (aExtension.EqualsLiteral(str)) return true;
|
2008-10-29 07:21:06 +03:00
|
|
|
SVG_SUPPORTED_EXTENSION("http://www.w3.org/1999/xhtml")
|
2016-06-28 17:24:48 +03:00
|
|
|
nsNameSpaceManager* nameSpaceManager = nsNameSpaceManager::GetInstance();
|
|
|
|
if (aIsInChrome || !nameSpaceManager->mMathMLDisabled) {
|
|
|
|
SVG_SUPPORTED_EXTENSION("http://www.w3.org/1998/Math/MathML")
|
|
|
|
}
|
2008-10-29 07:21:06 +03:00
|
|
|
#undef SVG_SUPPORTED_EXTENSION
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2008-10-29 07:21:06 +03:00
|
|
|
}
|