| OLD | NEW |
| 1 /* | 1 /* |
| 2 Copyright (C) 2010 Rob Buis <rwlbuis@gmail.com> | 2 Copyright (C) 2010 Rob Buis <rwlbuis@gmail.com> |
| 3 Copyright (C) 2011 Cosmin Truta <ctruta@gmail.com> | 3 Copyright (C) 2011 Cosmin Truta <ctruta@gmail.com> |
| 4 Copyright (C) 2012 University of Szeged | 4 Copyright (C) 2012 University of Szeged |
| 5 Copyright (C) 2012 Renata Hodovan <reni@webkit.org> | 5 Copyright (C) 2012 Renata Hodovan <reni@webkit.org> |
| 6 | 6 |
| 7 This library is free software; you can redistribute it and/or | 7 This library is free software; you can redistribute it and/or |
| 8 modify it under the terms of the GNU Library General Public | 8 modify it under the terms of the GNU Library General Public |
| 9 License as published by the Free Software Foundation; either | 9 License as published by the Free Software Foundation; either |
| 10 version 2 of the License, or (at your option) any later version. | 10 version 2 of the License, or (at your option) any later version. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "core/dom/XMLDocument.h" | 25 #include "core/dom/XMLDocument.h" |
| 26 #include "core/fetch/FetchRequest.h" | 26 #include "core/fetch/FetchRequest.h" |
| 27 #include "core/fetch/ResourceFetcher.h" | 27 #include "core/fetch/ResourceFetcher.h" |
| 28 #include "platform/SharedBuffer.h" | 28 #include "platform/SharedBuffer.h" |
| 29 #include "wtf/text/StringBuilder.h" | 29 #include "wtf/text/StringBuilder.h" |
| 30 | 30 |
| 31 namespace blink { | 31 namespace blink { |
| 32 | 32 |
| 33 DocumentResource* DocumentResource::fetchSVGDocument(FetchRequest& request, Reso
urceFetcher* fetcher) | 33 DocumentResource* DocumentResource::fetchSVGDocument(FetchRequest& request, Reso
urceFetcher* fetcher) |
| 34 { | 34 { |
| 35 ASSERT(request.resourceRequest().frameType() == WebURLRequest::FrameTypeNone
); | 35 DCHECK_EQ(request.resourceRequest().frameType(), WebURLRequest::FrameTypeNon
e); |
| 36 request.mutableResourceRequest().setRequestContext(WebURLRequest::RequestCon
textImage); | 36 request.mutableResourceRequest().setRequestContext(WebURLRequest::RequestCon
textImage); |
| 37 return toDocumentResource(fetcher->requestResource(request, SVGDocumentResou
rceFactory())); | 37 return toDocumentResource(fetcher->requestResource(request, SVGDocumentResou
rceFactory())); |
| 38 } | 38 } |
| 39 | 39 |
| 40 DocumentResource::DocumentResource(const ResourceRequest& request, Type type, co
nst ResourceLoaderOptions& options) | 40 DocumentResource::DocumentResource(const ResourceRequest& request, Type type, co
nst ResourceLoaderOptions& options) |
| 41 : TextResource(request, type, options, "application/xml", String()) | 41 : TextResource(request, type, options, "application/xml", String()) |
| 42 { | 42 { |
| 43 // FIXME: We'll support more types to support HTMLImports. | 43 // FIXME: We'll support more types to support HTMLImports. |
| 44 ASSERT(type == SVGDocument); | 44 DCHECK_EQ(type, SVGDocument); |
| 45 } | 45 } |
| 46 | 46 |
| 47 DocumentResource::~DocumentResource() | 47 DocumentResource::~DocumentResource() |
| 48 { | 48 { |
| 49 } | 49 } |
| 50 | 50 |
| 51 DEFINE_TRACE(DocumentResource) | 51 DEFINE_TRACE(DocumentResource) |
| 52 { | 52 { |
| 53 visitor->trace(m_document); | 53 visitor->trace(m_document); |
| 54 Resource::trace(visitor); | 54 Resource::trace(visitor); |
| 55 } | 55 } |
| 56 | 56 |
| 57 void DocumentResource::checkNotify() | 57 void DocumentResource::checkNotify() |
| 58 { | 58 { |
| 59 if (data() && mimeTypeAllowed()) { | 59 if (data() && mimeTypeAllowed()) { |
| 60 // We don't need to create a new frame because the new document belongs
to the parent UseElement. | 60 // We don't need to create a new frame because the new document belongs
to the parent UseElement. |
| 61 m_document = createDocument(response().url()); | 61 m_document = createDocument(response().url()); |
| 62 m_document->setContent(decodedText()); | 62 m_document->setContent(decodedText()); |
| 63 } | 63 } |
| 64 Resource::checkNotify(); | 64 Resource::checkNotify(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 bool DocumentResource::mimeTypeAllowed() const | 67 bool DocumentResource::mimeTypeAllowed() const |
| 68 { | 68 { |
| 69 ASSERT(getType() == SVGDocument); | 69 DCHECK_EQ(getType(), SVGDocument); |
| 70 AtomicString mimeType = response().mimeType(); | 70 AtomicString mimeType = response().mimeType(); |
| 71 if (response().isHTTP()) | 71 if (response().isHTTP()) |
| 72 mimeType = httpContentType(); | 72 mimeType = httpContentType(); |
| 73 return mimeType == "image/svg+xml" | 73 return mimeType == "image/svg+xml" |
| 74 || mimeType == "text/xml" | 74 || mimeType == "text/xml" |
| 75 || mimeType == "application/xml" | 75 || mimeType == "application/xml" |
| 76 || mimeType == "application/xhtml+xml"; | 76 || mimeType == "application/xhtml+xml"; |
| 77 } | 77 } |
| 78 | 78 |
| 79 Document* DocumentResource::createDocument(const KURL& url) | 79 Document* DocumentResource::createDocument(const KURL& url) |
| 80 { | 80 { |
| 81 switch (getType()) { | 81 switch (getType()) { |
| 82 case SVGDocument: | 82 case SVGDocument: |
| 83 return XMLDocument::createSVG(DocumentInit(url)); | 83 return XMLDocument::createSVG(DocumentInit(url)); |
| 84 default: | 84 default: |
| 85 // FIXME: We'll add more types to support HTMLImports. | 85 // FIXME: We'll add more types to support HTMLImports. |
| 86 ASSERT_NOT_REACHED(); | 86 NOTREACHED(); |
| 87 return nullptr; | 87 return nullptr; |
| 88 } | 88 } |
| 89 } | 89 } |
| 90 | 90 |
| 91 } // namespace blink | 91 } // namespace blink |
| OLD | NEW |