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 30 matching lines...) Expand all Loading... |
41 #include "MediaDocument.h" | 41 #include "MediaDocument.h" |
42 #include "MediaList.h" | 42 #include "MediaList.h" |
43 #include "MediaPlayer.h" | 43 #include "MediaPlayer.h" |
44 #include "MIMETypeRegistry.h" | 44 #include "MIMETypeRegistry.h" |
45 #include "Page.h" | 45 #include "Page.h" |
46 #include "PluginData.h" | 46 #include "PluginData.h" |
47 #include "PluginDocument.h" | 47 #include "PluginDocument.h" |
48 #include "RegularExpression.h" | 48 #include "RegularExpression.h" |
49 #include "Settings.h" | 49 #include "Settings.h" |
50 #include "TextDocument.h" | 50 #include "TextDocument.h" |
| 51 #include "ThreadGlobalData.h" |
51 #include "XMLNames.h" | 52 #include "XMLNames.h" |
52 #include <wtf/StdLibExtras.h> | 53 #include <wtf/StdLibExtras.h> |
53 | 54 |
54 #if ENABLE(SVG) | 55 #if ENABLE(SVG) |
55 #include "SVGNames.h" | 56 #include "SVGNames.h" |
56 #include "SVGDocument.h" | 57 #include "SVGDocument.h" |
57 #endif | 58 #endif |
58 | 59 |
59 namespace WebCore { | 60 namespace WebCore { |
60 | 61 |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 | 266 |
266 PassRefPtr<CSSStyleSheet> DOMImplementation::createCSSStyleSheet(const String&,
const String& media, ExceptionCode&) | 267 PassRefPtr<CSSStyleSheet> DOMImplementation::createCSSStyleSheet(const String&,
const String& media, ExceptionCode&) |
267 { | 268 { |
268 // FIXME: Title should be set. | 269 // FIXME: Title should be set. |
269 // FIXME: Media could have wrong syntax, in which case we should generate an
exception. | 270 // FIXME: Media could have wrong syntax, in which case we should generate an
exception. |
270 RefPtr<CSSStyleSheet> sheet = CSSStyleSheet::create(); | 271 RefPtr<CSSStyleSheet> sheet = CSSStyleSheet::create(); |
271 sheet->setMedia(MediaList::createAllowingDescriptionSyntax(sheet.get(), medi
a)); | 272 sheet->setMedia(MediaList::createAllowingDescriptionSyntax(sheet.get(), medi
a)); |
272 return sheet.release(); | 273 return sheet.release(); |
273 } | 274 } |
274 | 275 |
| 276 static const char* const validXMLMIMETypeChars = "[0-9a-zA-Z_\\-+~!$\\^{}|.%'`#&
*]"; // per RFCs: 3023, 2045 |
| 277 |
| 278 XMLMIMETypeRegExp::XMLMIMETypeRegExp() : |
| 279 m_regex(adoptPtr(new RegularExpression(WTF::makeString("^", validXMLMIMEType
Chars, "+/", validXMLMIMETypeChars, "+\\+xml$"), TextCaseSensitive))) |
| 280 { |
| 281 } |
| 282 |
| 283 XMLMIMETypeRegExp::~XMLMIMETypeRegExp() |
| 284 { |
| 285 } |
| 286 |
| 287 bool XMLMIMETypeRegExp::isXMLMIMEType(const String& mimeType) |
| 288 { |
| 289 return m_regex->match(mimeType) > -1; |
| 290 } |
| 291 |
275 bool DOMImplementation::isXMLMIMEType(const String& mimeType) | 292 bool DOMImplementation::isXMLMIMEType(const String& mimeType) |
276 { | 293 { |
277 if (mimeType == "text/xml" || mimeType == "application/xml" || mimeType == "
text/xsl") | 294 if (mimeType == "text/xml" || mimeType == "application/xml" || mimeType == "
text/xsl") |
278 return true; | 295 return true; |
279 static const char* const validChars = "[0-9a-zA-Z_\\-+~!$\\^{}|.%'`#&*]"; //
per RFCs: 3023, 2045 | 296 return threadGlobalData().xmlTypeRegExp().isXMLMIMEType(mimeType); |
280 DEFINE_STATIC_LOCAL(RegularExpression, xmlTypeRegExp, (String("^") + validCh
ars + "+/" + validChars + "+\\+xml$", TextCaseSensitive)); | |
281 return xmlTypeRegExp.match(mimeType) > -1; | |
282 } | 297 } |
283 | 298 |
284 bool DOMImplementation::isTextMIMEType(const String& mimeType) | 299 bool DOMImplementation::isTextMIMEType(const String& mimeType) |
285 { | 300 { |
286 if (MIMETypeRegistry::isSupportedJavaScriptMIMEType(mimeType) | 301 if (MIMETypeRegistry::isSupportedJavaScriptMIMEType(mimeType) |
287 || mimeType == "application/json" // Render JSON as text/plain. | 302 || mimeType == "application/json" // Render JSON as text/plain. |
288 || (mimeType.startsWith("text/") && mimeType != "text/html" | 303 || (mimeType.startsWith("text/") && mimeType != "text/html" |
289 && mimeType != "text/xml" && mimeType != "text/xsl")) | 304 && mimeType != "text/xml" && mimeType != "text/xsl")) |
290 return true; | 305 return true; |
291 | 306 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 return SVGDocument::create(frame, url); | 372 return SVGDocument::create(frame, url); |
358 } | 373 } |
359 #endif | 374 #endif |
360 if (isXMLMIMEType(type)) | 375 if (isXMLMIMEType(type)) |
361 return Document::create(frame, url); | 376 return Document::create(frame, url); |
362 | 377 |
363 return HTMLDocument::create(frame, url); | 378 return HTMLDocument::create(frame, url); |
364 } | 379 } |
365 | 380 |
366 } | 381 } |
OLD | NEW |