| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
| 6 * Copyright (C) 2006 Samuel Weinig (sam@webkit.org) | 6 * Copyright (C) 2006 Samuel Weinig (sam@webkit.org) |
| 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 | 56 |
| 57 namespace WebCore { | 57 namespace WebCore { |
| 58 | 58 |
| 59 typedef HashSet<String, CaseFoldingHash> FeatureSet; | 59 typedef HashSet<String, CaseFoldingHash> FeatureSet; |
| 60 | 60 |
| 61 static void addString(FeatureSet& set, const char* string) | 61 static void addString(FeatureSet& set, const char* string) |
| 62 { | 62 { |
| 63 set.add(string); | 63 set.add(string); |
| 64 } | 64 } |
| 65 | 65 |
| 66 static bool isSVG10Feature(const String &feature, const String &version) | 66 static bool isSupportedSVG10Feature(const String& feature, const String& version
) |
| 67 { | 67 { |
| 68 if (!version.isEmpty() && version != "1.0") | 68 if (!version.isEmpty() && version != "1.0") |
| 69 return false; | 69 return false; |
| 70 | 70 |
| 71 static bool initialized = false; | 71 static bool initialized = false; |
| 72 DEFINE_STATIC_LOCAL(FeatureSet, svgFeatures, ()); | 72 DEFINE_STATIC_LOCAL(FeatureSet, svgFeatures, ()); |
| 73 if (!initialized) { | 73 if (!initialized) { |
| 74 #if ENABLE(SVG_FONTS) | 74 #if ENABLE(SVG_FONTS) |
| 75 addString(svgFeatures, "svg"); | 75 addString(svgFeatures, "svg"); |
| 76 addString(svgFeatures, "svg.static"); | 76 addString(svgFeatures, "svg.static"); |
| 77 #endif | 77 #endif |
| 78 // addString(svgFeatures, "svg.animation"); | 78 // addString(svgFeatures, "svg.animation"); |
| 79 // addString(svgFeatures, "svg.dynamic"); | 79 // addString(svgFeatures, "svg.dynamic"); |
| 80 // addString(svgFeatures, "svg.dom.animation"); | 80 // addString(svgFeatures, "svg.dom.animation"); |
| 81 // addString(svgFeatures, "svg.dom.dynamic"); | 81 // addString(svgFeatures, "svg.dom.dynamic"); |
| 82 #if ENABLE(SVG_FONTS) | 82 #if ENABLE(SVG_FONTS) |
| 83 addString(svgFeatures, "dom"); | 83 addString(svgFeatures, "dom"); |
| 84 addString(svgFeatures, "dom.svg"); | 84 addString(svgFeatures, "dom.svg"); |
| 85 addString(svgFeatures, "dom.svg.static"); | 85 addString(svgFeatures, "dom.svg.static"); |
| 86 #endif | 86 #endif |
| 87 // addString(svgFeatures, "svg.all"); | 87 // addString(svgFeatures, "svg.all"); |
| 88 // addString(svgFeatures, "dom.svg.all"); | 88 // addString(svgFeatures, "dom.svg.all"); |
| 89 initialized = true; | 89 initialized = true; |
| 90 } | 90 } |
| 91 return feature.startsWith("org.w3c.", false) | 91 return feature.startsWith("org.w3c.", false) |
| 92 && svgFeatures.contains(feature.right(feature.length() - 8)); | 92 && svgFeatures.contains(feature.right(feature.length() - 8)); |
| 93 } | 93 } |
| 94 | 94 |
| 95 static bool isSVG11Feature(const String &feature, const String &version) | 95 static bool isSupportedSVG11Feature(const String& feature, const String& version
) |
| 96 { | 96 { |
| 97 if (!version.isEmpty() && version != "1.1") | 97 if (!version.isEmpty() && version != "1.1") |
| 98 return false; | 98 return false; |
| 99 | 99 |
| 100 static bool initialized = false; | 100 static bool initialized = false; |
| 101 DEFINE_STATIC_LOCAL(FeatureSet, svgFeatures, ()); | 101 DEFINE_STATIC_LOCAL(FeatureSet, svgFeatures, ()); |
| 102 if (!initialized) { | 102 if (!initialized) { |
| 103 // Sadly, we cannot claim to implement any of the SVG 1.1 generic featur
e sets | 103 // Sadly, we cannot claim to implement any of the SVG 1.1 generic featur
e sets |
| 104 // lack of Font and Filter support. | 104 // lack of Font and Filter support. |
| 105 // http://bugs.webkit.org/show_bug.cgi?id=15480 | 105 // http://bugs.webkit.org/show_bug.cgi?id=15480 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 addString(svgFeatures, "Font"); | 152 addString(svgFeatures, "Font"); |
| 153 addString(svgFeatures, "BasicFont"); | 153 addString(svgFeatures, "BasicFont"); |
| 154 #endif | 154 #endif |
| 155 addString(svgFeatures, "Extensibility"); | 155 addString(svgFeatures, "Extensibility"); |
| 156 initialized = true; | 156 initialized = true; |
| 157 } | 157 } |
| 158 return feature.startsWith("http://www.w3.org/tr/svg11/feature#", false) | 158 return feature.startsWith("http://www.w3.org/tr/svg11/feature#", false) |
| 159 && svgFeatures.contains(feature.right(feature.length() - 35)); | 159 && svgFeatures.contains(feature.right(feature.length() - 35)); |
| 160 } | 160 } |
| 161 | 161 |
| 162 static bool isEvents2Feature(const String &feature, const String &version) | |
| 163 { | |
| 164 if (!version.isEmpty() && version != "2.0") | |
| 165 return false; | |
| 166 | |
| 167 static bool initialized = false; | |
| 168 DEFINE_STATIC_LOCAL(FeatureSet, events2Features, ()); | |
| 169 if (!initialized) { | |
| 170 addString(events2Features, "Events"); | |
| 171 addString(events2Features, "HTMLEvents"); | |
| 172 addString(events2Features, "MouseEvents"); | |
| 173 addString(events2Features, "MutationEvents"); | |
| 174 addString(events2Features, "UIEvents"); | |
| 175 initialized = true; | |
| 176 } | |
| 177 return events2Features.contains(feature); | |
| 178 } | |
| 179 | |
| 180 static bool isEvents3Feature(const String &feature, const String &version) | |
| 181 { | |
| 182 if (!version.isEmpty() && version != "3.0") | |
| 183 return false; | |
| 184 | |
| 185 static bool initialized = false; | |
| 186 DEFINE_STATIC_LOCAL(FeatureSet, events3Features, ()); | |
| 187 if (!initialized) { | |
| 188 // FIXME: We probably support many of these features. | |
| 189 // addString(events3Features, "CompositionEvents"); | |
| 190 // addString(events3Features, "Events"); | |
| 191 // addString(events3Features, "FocusEvents"); | |
| 192 // addString(events3Features, "HTMLEvents"); | |
| 193 // addString(events3Features, "KeyboardEvents"); | |
| 194 // addString(events3Features, "MouseEvents"); | |
| 195 // addString(events3Features, "MutationEvents"); | |
| 196 // addString(events3Features, "MutationNameEvents"); | |
| 197 addString(events3Features, "TextEvents"); | |
| 198 // addString(events3Features, "UIEvents"); | |
| 199 // addString(events3Features, "WheelEvents"); | |
| 200 initialized = true; | |
| 201 } | |
| 202 // FIXME: We do not yet support Events 3 "extended feature strings". | |
| 203 return events3Features.contains(feature); | |
| 204 } | |
| 205 | |
| 206 DOMImplementation::DOMImplementation(Document* document) | 162 DOMImplementation::DOMImplementation(Document* document) |
| 207 : m_document(document) | 163 : m_document(document) |
| 208 { | 164 { |
| 209 ScriptWrappable::init(this); | 165 ScriptWrappable::init(this); |
| 210 } | 166 } |
| 211 | 167 |
| 212 bool DOMImplementation::hasFeature(const String& feature, const String& version) | 168 bool DOMImplementation::hasFeature(const String& feature, const String& version) |
| 213 { | 169 { |
| 214 String lower = feature.lower(); | 170 if (feature.startsWith("http://www.w3.org/TR/SVG", false) |
| 215 if (lower == "core" || lower == "html" || lower == "xml" || lower == "xhtml"
) | 171 || feature.startsWith("org.w3c.dom.svg", false) |
| 216 return version.isEmpty() || version == "1.0" || version == "2.0"; | 172 || feature.startsWith("org.w3c.svg", false)) { |
| 217 if (lower == "css" | 173 // FIXME: SVG 2.0 support? |
| 218 || lower == "css2" | 174 return isSupportedSVG10Feature(feature, version) || isSupportedSVG11Feat
ure(feature, version); |
| 219 || lower == "range" | 175 } |
| 220 || lower == "stylesheets" | 176 return true; |
| 221 || lower == "traversal" | |
| 222 || lower == "views") | |
| 223 return version.isEmpty() || version == "2.0"; | |
| 224 if (isEvents2Feature(feature, version)) | |
| 225 return true; | |
| 226 if (lower == "xpath") | |
| 227 return version.isEmpty() || version == "3.0"; | |
| 228 if (isEvents3Feature(feature, version)) | |
| 229 return true; | |
| 230 | |
| 231 if (isSVG11Feature(feature, version)) | |
| 232 return true; | |
| 233 if (isSVG10Feature(feature, version)) | |
| 234 return true; | |
| 235 | |
| 236 return false; | |
| 237 } | 177 } |
| 238 | 178 |
| 239 PassRefPtr<DocumentType> DOMImplementation::createDocumentType(const String& qua
lifiedName, | 179 PassRefPtr<DocumentType> DOMImplementation::createDocumentType(const String& qua
lifiedName, |
| 240 const String& publicId, const String& systemId, ExceptionCode& ec) | 180 const String& publicId, const String& systemId, ExceptionCode& ec) |
| 241 { | 181 { |
| 242 String prefix, localName; | 182 String prefix, localName; |
| 243 if (!Document::parseQualifiedName(qualifiedName, prefix, localName, ec)) | 183 if (!Document::parseQualifiedName(qualifiedName, prefix, localName, ec)) |
| 244 return 0; | 184 return 0; |
| 245 | 185 |
| 246 return DocumentType::create(0, qualifiedName, publicId, systemId); | 186 return DocumentType::create(0, qualifiedName, publicId, systemId); |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 return TextDocument::create(DocumentInit(url, frame)); | 358 return TextDocument::create(DocumentInit(url, frame)); |
| 419 if (type == "image/svg+xml") | 359 if (type == "image/svg+xml") |
| 420 return SVGDocument::create(DocumentInit(url, frame)); | 360 return SVGDocument::create(DocumentInit(url, frame)); |
| 421 if (isXMLMIMEType(type)) | 361 if (isXMLMIMEType(type)) |
| 422 return Document::create(DocumentInit(url, frame)); | 362 return Document::create(DocumentInit(url, frame)); |
| 423 | 363 |
| 424 return HTMLDocument::create(DocumentInit(url, frame)); | 364 return HTMLDocument::create(DocumentInit(url, frame)); |
| 425 } | 365 } |
| 426 | 366 |
| 427 } | 367 } |
| OLD | NEW |