summaryrefslogtreecommitdiff
path: root/Source/WebCore/dom/DOMImplementation.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-02-03 09:55:33 +0100
committerSimon Hausmann <simon.hausmann@nokia.com>2012-02-03 09:55:33 +0100
commitcd44dc59cdfc39534aef4d417e9f3c412e3be139 (patch)
tree8d89889ba95ed6ec9322e733846cc9cce9d7dff1 /Source/WebCore/dom/DOMImplementation.cpp
parentd11f84f5b5cdc0d92a08af01b13472fdd5f9acb9 (diff)
downloadqtwebkit-cd44dc59cdfc39534aef4d417e9f3c412e3be139.tar.gz
Imported WebKit commit fce473cb4d55aa9fe9d0b0322a2fffecb731b961 (http://svn.webkit.org/repository/webkit/trunk@106560)
Diffstat (limited to 'Source/WebCore/dom/DOMImplementation.cpp')
-rw-r--r--Source/WebCore/dom/DOMImplementation.cpp129
1 files changed, 92 insertions, 37 deletions
diff --git a/Source/WebCore/dom/DOMImplementation.cpp b/Source/WebCore/dom/DOMImplementation.cpp
index bd41b30b6..33104097e 100644
--- a/Source/WebCore/dom/DOMImplementation.cpp
+++ b/Source/WebCore/dom/DOMImplementation.cpp
@@ -60,8 +60,6 @@
namespace WebCore {
-#if ENABLE(SVG)
-
typedef HashSet<String, CaseFoldingHash> FeatureSet;
static void addString(FeatureSet& set, const char* string)
@@ -69,8 +67,13 @@ static void addString(FeatureSet& set, const char* string)
set.add(string);
}
-static bool isSVG10Feature(const String &feature)
+#if ENABLE(SVG)
+
+static bool isSVG10Feature(const String &feature, const String &version)
{
+ if (!version.isEmpty() && version != "1.0")
+ return false;
+
static bool initialized = false;
DEFINE_STATIC_LOCAL(FeatureSet, svgFeatures, ());
if (!initialized) {
@@ -91,11 +94,15 @@ static bool isSVG10Feature(const String &feature)
// addString(svgFeatures, "dom.svg.all");
initialized = true;
}
- return svgFeatures.contains(feature);
+ return feature.startsWith("org.w3c.", false)
+ && svgFeatures.contains(feature.right(feature.length() - 8));
}
-static bool isSVG11Feature(const String &feature)
+static bool isSVG11Feature(const String &feature, const String &version)
{
+ if (!version.isEmpty() && version != "1.1")
+ return false;
+
static bool initialized = false;
DEFINE_STATIC_LOCAL(FeatureSet, svgFeatures, ());
if (!initialized) {
@@ -156,10 +163,55 @@ static bool isSVG11Feature(const String &feature)
addString(svgFeatures, "Extensibility");
initialized = true;
}
- return svgFeatures.contains(feature);
+ return feature.startsWith("http://www.w3.org/tr/svg11/feature#", false)
+ && svgFeatures.contains(feature.right(feature.length() - 35));
}
#endif
+static bool isEvents2Feature(const String &feature, const String &version)
+{
+ if (!version.isEmpty() && version != "2.0")
+ return false;
+
+ static bool initialized = false;
+ DEFINE_STATIC_LOCAL(FeatureSet, events2Features, ());
+ if (!initialized) {
+ addString(events2Features, "Events");
+ addString(events2Features, "HTMLEvents");
+ addString(events2Features, "MouseEvents");
+ addString(events2Features, "MutationEvents");
+ addString(events2Features, "UIEvents");
+ initialized = true;
+ }
+ return events2Features.contains(feature);
+}
+
+static bool isEvents3Feature(const String &feature, const String &version)
+{
+ if (!version.isEmpty() && version != "3.0")
+ return false;
+
+ static bool initialized = false;
+ DEFINE_STATIC_LOCAL(FeatureSet, events3Features, ());
+ if (!initialized) {
+ // FIXME: We probably support many of these features.
+// addString(events3Features, "CompositionEvents");
+// addString(events3Features, "Events");
+// addString(events3Features, "FocusEvents");
+// addString(events3Features, "HTMLEvents");
+// addString(events3Features, "KeyboardEvents");
+// addString(events3Features, "MouseEvents");
+// addString(events3Features, "MutationEvents");
+// addString(events3Features, "MutationNameEvents");
+ addString(events3Features, "TextEvents");
+// addString(events3Features, "UIEvents");
+// addString(events3Features, "WheelEvents");
+ initialized = true;
+ }
+ // FIXME: We do not yet support Events 3 "extended feature strings".
+ return events3Features.contains(feature);
+}
+
DOMImplementation::DOMImplementation(Document* document)
: m_document(document)
{
@@ -172,31 +224,25 @@ bool DOMImplementation::hasFeature(const String& feature, const String& version)
return version.isEmpty() || version == "1.0" || version == "2.0";
if (lower == "css"
|| lower == "css2"
- || lower == "events"
- || lower == "htmlevents"
- || lower == "mouseevents"
- || lower == "mutationevents"
|| lower == "range"
|| lower == "stylesheets"
|| lower == "traversal"
- || lower == "uievents"
|| lower == "views")
return version.isEmpty() || version == "2.0";
- if (lower == "xpath" || lower == "textevents")
+ if (isEvents2Feature(feature, version))
+ return true;
+ if (lower == "xpath")
return version.isEmpty() || version == "3.0";
+ if (isEvents3Feature(feature, version))
+ return true;
#if ENABLE(SVG)
- if ((version.isEmpty() || version == "1.1") && feature.startsWith("http://www.w3.org/tr/svg11/feature#", false)) {
- if (isSVG11Feature(feature.right(feature.length() - 35)))
- return true;
- }
-
- if ((version.isEmpty() || version == "1.0") && feature.startsWith("org.w3c.", false)) {
- if (isSVG10Feature(feature.right(feature.length() - 8)))
- return true;
- }
+ if (isSVG11Feature(feature, version))
+ return true;
+ if (isSVG10Feature(feature, version))
+ return true;
#endif
-
+
return false;
}
@@ -318,37 +364,46 @@ PassRefPtr<Document> DOMImplementation::createDocument(const String& type, Frame
// Plugins cannot take HTML and XHTML from us, and we don't even need to initialize the plugin database for those.
if (type == "text/html")
return HTMLDocument::create(frame, url);
+
+ // Plugins cannot take text/plain from us either.
+ if (type == "text/plain")
+ return TextDocument::create(frame, url);
+
if (type == "application/xhtml+xml")
return Document::createXHTML(frame, url);
#if ENABLE(FTPDIR)
- // Plugins cannot take FTP from us either
+ // Plugins cannot take FTP from us either.
if (type == "application/x-ftp-directory")
return FTPDirectoryDocument::create(frame, url);
#endif
- PluginData* pluginData = 0;
- if (frame && frame->page() && frame->loader()->subframeLoader()->allowPlugins(NotAboutToInstantiatePlugin))
- pluginData = frame->page()->pluginData();
-
- // PDF is one image type for which a plugin can override built-in support.
- // We do not want QuickTime to take over all image types, obviously.
- if ((type == "application/pdf" || type == "text/pdf") && pluginData && pluginData->supportsMimeType(type))
- return PluginDocument::create(frame, url);
- if (Image::supportsType(type))
+ // PDF is the only image type for which a plugin can override built-in support.
+ if (Image::supportsType(type) && type != "application/pdf" && type != "text/pdf")
return ImageDocument::create(frame, url);
#if ENABLE(VIDEO)
- // Check to see if the type can be played by our MediaPlayer, if so create a MediaDocument
+ // Check to see if the type can be played by our MediaPlayer, if so create a MediaDocument as
+ // this can not be taken by plugins either.
if (MediaPlayer::supportsType(ContentType(type)))
return MediaDocument::create(frame, url);
#endif
- // Everything else except text/plain can be overridden by plugins. In particular, Adobe SVG Viewer should be used for SVG, if installed.
- // Disallowing plug-ins to use text/plain prevents plug-ins from hijacking a fundamental type that the browser is expected to handle,
- // and also serves as an optimization to prevent loading the plug-in database in the common case.
- if (type != "text/plain" && pluginData && pluginData->supportsMimeType(type))
+ // The plugin database is initialized at this point if plugins are enabled
+ // which is non-zero overhead.
+ PluginData* pluginData = 0;
+ if (frame && frame->page() && frame->loader()->subframeLoader()->allowPlugins(NotAboutToInstantiatePlugin))
+ pluginData = frame->page()->pluginData();
+
+ // At this point anything that can be supported can be overridden by plugins.
+ if (pluginData && pluginData->supportsMimeType(type))
return PluginDocument::create(frame, url);
+
+ // Handle PDF for instance if it was not handled by a plugin.
+ if (Image::supportsType(type))
+ return ImageDocument::create(frame, url);
+
+ // Handle a text document was not handled by a plugin.
if (isTextMIMEType(type))
return TextDocument::create(frame, url);