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. |
11 | 11 |
12 This library is distributed in the hope that it will be useful, | 12 This library is distributed in the hope that it will be useful, |
13 but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 Library General Public License for more details. | 15 Library General Public License for more details. |
16 | 16 |
17 You should have received a copy of the GNU Library General Public License | 17 You should have received a copy of the GNU Library General Public License |
18 along with this library; see the file COPYING.LIB. If not, write to | 18 along with this library; see the file COPYING.LIB. If not, write to |
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 Boston, MA 02110-1301, USA. | 20 Boston, MA 02110-1301, USA. |
21 */ | 21 */ |
22 | 22 |
23 #ifndef DocumentResource_h | 23 #ifndef DocumentResource_h |
24 #define DocumentResource_h | 24 #define DocumentResource_h |
25 | 25 |
26 #include "core/fetch/Resource.h" | 26 #include "core/fetch/Resource.h" |
27 #include "core/fetch/ResourceClient.h" | 27 #include "core/fetch/ResourceClient.h" |
| 28 #include "core/fetch/TextResource.h" |
28 #include "core/html/parser/TextResourceDecoder.h" | 29 #include "core/html/parser/TextResourceDecoder.h" |
29 #include "platform/heap/Handle.h" | 30 #include "platform/heap/Handle.h" |
30 #include <memory> | 31 #include <memory> |
31 | 32 |
32 namespace blink { | 33 namespace blink { |
33 | 34 |
34 class Document; | 35 class Document; |
35 class FetchRequest; | 36 class FetchRequest; |
36 class ResourceFetcher; | 37 class ResourceFetcher; |
37 | 38 |
38 class CORE_EXPORT DocumentResource final : public Resource { | 39 class CORE_EXPORT DocumentResource final : public TextResource { |
39 public: | 40 public: |
40 using ClientType = ResourceClient; | 41 using ClientType = ResourceClient; |
41 | 42 |
42 static DocumentResource* fetchSVGDocument(FetchRequest&, ResourceFetcher*); | 43 static DocumentResource* fetchSVGDocument(FetchRequest&, ResourceFetcher*); |
43 ~DocumentResource() override; | 44 ~DocumentResource() override; |
44 DECLARE_VIRTUAL_TRACE(); | 45 DECLARE_VIRTUAL_TRACE(); |
45 | 46 |
46 Document* document() const { return m_document.get(); } | 47 Document* document() const { return m_document.get(); } |
47 | 48 |
48 void setEncoding(const String&) override; | |
49 String encoding() const override; | |
50 void checkNotify() override; | 49 void checkNotify() override; |
51 | 50 |
52 private: | 51 private: |
53 class SVGDocumentResourceFactory : public ResourceFactory { | 52 class SVGDocumentResourceFactory : public ResourceFactory { |
54 public: | 53 public: |
55 SVGDocumentResourceFactory() | 54 SVGDocumentResourceFactory() |
56 : ResourceFactory(Resource::SVGDocument) { } | 55 : ResourceFactory(Resource::SVGDocument) { } |
57 | 56 |
58 Resource* create(const ResourceRequest& request, const ResourceLoaderOpt
ions& options, const String& charset) const override | 57 Resource* create(const ResourceRequest& request, const ResourceLoaderOpt
ions& options, const String& charset) const override |
59 { | 58 { |
60 return new DocumentResource(request, Resource::SVGDocument, options)
; | 59 return new DocumentResource(request, Resource::SVGDocument, options)
; |
61 } | 60 } |
62 }; | 61 }; |
63 DocumentResource(const ResourceRequest&, Type, const ResourceLoaderOptions&)
; | 62 DocumentResource(const ResourceRequest&, Type, const ResourceLoaderOptions&)
; |
64 | 63 |
65 bool mimeTypeAllowed() const; | 64 bool mimeTypeAllowed() const; |
66 Document* createDocument(const KURL&); | 65 Document* createDocument(const KURL&); |
67 | 66 |
68 Member<Document> m_document; | 67 Member<Document> m_document; |
69 std::unique_ptr<TextResourceDecoder> m_decoder; | |
70 }; | 68 }; |
71 | 69 |
72 DEFINE_TYPE_CASTS(DocumentResource, Resource, resource, resource->getType() == R
esource::SVGDocument, resource.getType() == Resource::SVGDocument); | 70 DEFINE_TYPE_CASTS(DocumentResource, Resource, resource, resource->getType() == R
esource::SVGDocument, resource.getType() == Resource::SVGDocument); |
73 | 71 |
74 class CORE_EXPORT DocumentResourceClient : public GarbageCollectedMixin, public
ResourceClient { | 72 class CORE_EXPORT DocumentResourceClient : public GarbageCollectedMixin, public
ResourceClient { |
75 public: | 73 public: |
76 ~DocumentResourceClient() override {} | 74 ~DocumentResourceClient() override {} |
77 static bool isExpectedType(ResourceClient* client) { return client->getResou
rceClientType() == DocumentType; } | 75 static bool isExpectedType(ResourceClient* client) { return client->getResou
rceClientType() == DocumentType; } |
78 ResourceClientType getResourceClientType() const final { return DocumentType
; } | 76 ResourceClientType getResourceClientType() const final { return DocumentType
; } |
79 DEFINE_INLINE_VIRTUAL_TRACE() {} | 77 DEFINE_INLINE_VIRTUAL_TRACE() {} |
80 }; | 78 }; |
81 | 79 |
82 } // namespace blink | 80 } // namespace blink |
83 | 81 |
84 #endif // DocumentResource_h | 82 #endif // DocumentResource_h |
OLD | NEW |