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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
287 hasSlash = true; | 287 hasSlash = true; |
288 continue; | 288 continue; |
289 default: | 289 default: |
290 return false; | 290 return false; |
291 } | 291 } |
292 } | 292 } |
293 | 293 |
294 return true; | 294 return true; |
295 } | 295 } |
296 | 296 |
297 bool DOMImplementation::isJSONMIMEType(const String& mimeType) | |
tyoshino (SeeGerritForStatus)
2013/12/05 18:57:42
doesn't this return true for "application/foo+json
sof
2013/12/05 19:34:55
True enough. Better handle it & now done. Thanks :
| |
298 { | |
299 if (mimeType.startsWith("application/json", false)) | |
300 return true; | |
301 if (mimeType.startsWith("application/", false)) { | |
302 size_t subtype = mimeType.find("+json", 12, false); | |
303 if (subtype != kNotFound) { | |
304 // Just check that a parameter wasn't matched. | |
305 size_t parameterMarker = mimeType.find(";"); | |
306 return (parameterMarker == kNotFound || parameterMarker > subtype); | |
pfeldman
2013/12/05 17:18:53
drop ()
sof
2013/12/05 19:32:44
Done.
| |
307 } | |
308 } | |
309 return false; | |
310 } | |
311 | |
312 static bool isTextPlainType(const String& mimeType) | |
313 { | |
314 return (mimeType.startsWith("text/", false) | |
pfeldman
2013/12/05 17:18:53
drop outmost ()
sof
2013/12/05 19:32:44
Done.
| |
315 && !(equalIgnoringCase(mimeType, "text/html") | |
316 || equalIgnoringCase(mimeType, "text/xml") | |
317 || equalIgnoringCase(mimeType, "text/xsl"))); | |
318 } | |
319 | |
297 bool DOMImplementation::isTextMIMEType(const String& mimeType) | 320 bool DOMImplementation::isTextMIMEType(const String& mimeType) |
298 { | 321 { |
299 if (MIMETypeRegistry::isSupportedJavaScriptMIMEType(mimeType) | 322 return MIMETypeRegistry::isSupportedJavaScriptMIMEType(mimeType) || isJSONMI METype(mimeType) || isTextPlainType(mimeType); |
300 || mimeType == "application/json" // Render JSON as text/plain. | |
301 || (mimeType.startsWith("text/") && mimeType != "text/html" | |
302 && mimeType != "text/xml" && mimeType != "text/xsl")) | |
303 return true; | |
304 | |
305 return false; | |
306 } | 323 } |
307 | 324 |
308 PassRefPtr<HTMLDocument> DOMImplementation::createHTMLDocument(const String& tit le) | 325 PassRefPtr<HTMLDocument> DOMImplementation::createHTMLDocument(const String& tit le) |
309 { | 326 { |
310 DocumentInit init = DocumentInit::fromContext(m_document.contextDocument()) | 327 DocumentInit init = DocumentInit::fromContext(m_document.contextDocument()) |
311 .withRegistrationContext(m_document.registrationContext()); | 328 .withRegistrationContext(m_document.registrationContext()); |
312 RefPtr<HTMLDocument> d = HTMLDocument::create(init); | 329 RefPtr<HTMLDocument> d = HTMLDocument::create(init); |
313 d->open(); | 330 d->open(); |
314 d->write("<!doctype html><html><body></body></html>"); | 331 d->write("<!doctype html><html><body></body></html>"); |
315 if (!title.isNull()) | 332 if (!title.isNull()) |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
359 return TextDocument::create(init); | 376 return TextDocument::create(init); |
360 if (type == "image/svg+xml") | 377 if (type == "image/svg+xml") |
361 return SVGDocument::create(init); | 378 return SVGDocument::create(init); |
362 if (isXMLMIMEType(type)) | 379 if (isXMLMIMEType(type)) |
363 return Document::create(init); | 380 return Document::create(init); |
364 | 381 |
365 return HTMLDocument::create(init); | 382 return HTMLDocument::create(init); |
366 } | 383 } |
367 | 384 |
368 } | 385 } |
OLD | NEW |