Commit d74b7d28 authored by hiroshige's avatar hiroshige Committed by Commit bot

Make DocumentResource to be a subclass of TextResource

BUG=None

Review-Url: https://codereview.chromium.org/2133153002
Cr-Commit-Position: refs/heads/master@{#404625}
parent 37f05c11
......@@ -38,8 +38,7 @@ DocumentResource* DocumentResource::fetchSVGDocument(FetchRequest& request, Reso
}
DocumentResource::DocumentResource(const ResourceRequest& request, Type type, const ResourceLoaderOptions& options)
: Resource(request, type, options)
, m_decoder(TextResourceDecoder::create("application/xml"))
: TextResource(request, type, options, "application/xml", String())
{
// FIXME: We'll support more types to support HTMLImports.
ASSERT(type == SVGDocument);
......@@ -55,25 +54,12 @@ DEFINE_TRACE(DocumentResource)
Resource::trace(visitor);
}
void DocumentResource::setEncoding(const String& chs)
{
m_decoder->setEncoding(chs, TextResourceDecoder::EncodingFromHTTPHeader);
}
String DocumentResource::encoding() const
{
return m_decoder->encoding().name();
}
void DocumentResource::checkNotify()
{
if (m_data && mimeTypeAllowed()) {
StringBuilder decodedText;
decodedText.append(m_decoder->decode(m_data->data(), m_data->size()));
decodedText.append(m_decoder->flush());
// We don't need to create a new frame because the new document belongs to the parent UseElement.
m_document = createDocument(response().url());
m_document->setContent(decodedText.toString());
m_document->setContent(decodedText());
}
Resource::checkNotify();
}
......
......@@ -25,6 +25,7 @@
#include "core/fetch/Resource.h"
#include "core/fetch/ResourceClient.h"
#include "core/fetch/TextResource.h"
#include "core/html/parser/TextResourceDecoder.h"
#include "platform/heap/Handle.h"
#include <memory>
......@@ -35,7 +36,7 @@ class Document;
class FetchRequest;
class ResourceFetcher;
class CORE_EXPORT DocumentResource final : public Resource {
class CORE_EXPORT DocumentResource final : public TextResource {
public:
using ClientType = ResourceClient;
......@@ -45,8 +46,6 @@ public:
Document* document() const { return m_document.get(); }
void setEncoding(const String&) override;
String encoding() const override;
void checkNotify() override;
private:
......@@ -66,7 +65,6 @@ private:
Document* createDocument(const KURL&);
Member<Document> m_document;
std::unique_ptr<TextResourceDecoder> m_decoder;
};
DEFINE_TYPE_CASTS(DocumentResource, Resource, resource, resource->getType() == Resource::SVGDocument, resource.getType() == Resource::SVGDocument);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment