2015-05-03 19:32:37 +00: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 11:12:37 +00: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-23 23:29:08 +00:00
|
|
|
|
2008-07-13 11:30:48 +00: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 19:37:33 +00:00
|
|
|
#include "nsSVGFeatures.h"
|
2008-07-13 11:30:48 +00:00
|
|
|
#include "nsIContent.h"
|
2013-10-02 11:40:07 +00:00
|
|
|
#include "nsIDocument.h"
|
2011-05-27 04:53:03 +00:00
|
|
|
#include "mozilla/Preferences.h"
|
|
|
|
|
|
|
|
using namespace mozilla;
|
2008-07-13 11:30:48 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
/*static*/ bool
|
2011-12-31 09:44:03 +00:00
|
|
|
nsSVGFeatures::HasFeature(nsISupports* aObject, const nsAString& aFeature)
|
2008-07-13 11:30:48 +00:00
|
|
|
{
|
2011-04-29 11:28:10 +00:00
|
|
|
if (aFeature.EqualsLiteral("http://www.w3.org/TR/SVG11/feature#Script")) {
|
|
|
|
nsCOMPtr<nsIContent> content(do_QueryInterface(aObject));
|
|
|
|
if (content) {
|
2014-10-03 12:32:26 +00:00
|
|
|
nsIDocument* doc = content->GetUncomposedDoc();
|
2011-04-29 11:28:10 +00:00
|
|
|
if (doc && doc->IsResourceDoc()) {
|
|
|
|
// no scripting in SVG images or external resource documents
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2011-04-29 11:28:10 +00:00
|
|
|
}
|
|
|
|
}
|
2011-09-29 06:19:26 +00:00
|
|
|
return Preferences::GetBool("javascript.enabled", false);
|
2011-04-29 11:28:10 +00:00
|
|
|
}
|
2011-10-17 14:59:28 +00:00
|
|
|
#define SVG_SUPPORTED_FEATURE(str) if (aFeature.EqualsLiteral(str)) return true;
|
2004-08-23 23:29:08 +00:00
|
|
|
#define SVG_UNSUPPORTED_FEATURE(str)
|
|
|
|
#include "nsSVGFeaturesList.h"
|
|
|
|
#undef SVG_SUPPORTED_FEATURE
|
|
|
|
#undef SVG_UNSUPPORTED_FEATURE
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2004-08-23 23:29:08 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
/*static*/ bool
|
2011-12-31 09:44:03 +00:00
|
|
|
nsSVGFeatures::HasExtension(const nsAString& aExtension)
|
2008-10-29 04:21:06 +00:00
|
|
|
{
|
2011-10-17 14:59:28 +00:00
|
|
|
#define SVG_SUPPORTED_EXTENSION(str) if (aExtension.EqualsLiteral(str)) return true;
|
2008-10-29 04:21:06 +00:00
|
|
|
SVG_SUPPORTED_EXTENSION("http://www.w3.org/1999/xhtml")
|
|
|
|
SVG_SUPPORTED_EXTENSION("http://www.w3.org/1998/Math/MathML")
|
|
|
|
#undef SVG_SUPPORTED_EXTENSION
|
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2008-10-29 04:21:06 +00:00
|
|
|
}
|