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