Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: Source/core/loader/DocumentWriter.cpp

Issue 314953002: Oilpan: Replace RefPtrs to Node and its subclasses in core/loader with Oilpan transition types. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/loader/DocumentWriter.h ('k') | Source/core/loader/NavigationScheduler.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010. Adam Barth. All rights reserved. 2 * Copyright (C) 2010. Adam Barth. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 26 matching lines...) Expand all
37 #include "core/frame/DOMWindow.h" 37 #include "core/frame/DOMWindow.h"
38 #include "core/frame/FrameView.h" 38 #include "core/frame/FrameView.h"
39 #include "core/frame/LocalFrame.h" 39 #include "core/frame/LocalFrame.h"
40 #include "core/frame/Settings.h" 40 #include "core/frame/Settings.h"
41 #include "platform/weborigin/KURL.h" 41 #include "platform/weborigin/KURL.h"
42 #include "platform/weborigin/SecurityOrigin.h" 42 #include "platform/weborigin/SecurityOrigin.h"
43 #include "wtf/PassOwnPtr.h" 43 #include "wtf/PassOwnPtr.h"
44 44
45 namespace WebCore { 45 namespace WebCore {
46 46
47 PassRefPtr<DocumentWriter> DocumentWriter::create(Document* document, const Atom icString& mimeType, const AtomicString& encoding, bool encodingUserChoosen) 47 PassRefPtrWillBeRawPtr<DocumentWriter> DocumentWriter::create(Document* document , const AtomicString& mimeType, const AtomicString& encoding, bool encodingUserC hoosen)
48 { 48 {
49 return adoptRef(new DocumentWriter(document, mimeType, encoding, encodingUse rChoosen)); 49 return adoptRefWillBeNoop(new DocumentWriter(document, mimeType, encoding, e ncodingUserChoosen));
50 } 50 }
51 51
52 DocumentWriter::DocumentWriter(Document* document, const AtomicString& mimeType, const AtomicString& encoding, bool encodingUserChoosen) 52 DocumentWriter::DocumentWriter(Document* document, const AtomicString& mimeType, const AtomicString& encoding, bool encodingUserChoosen)
53 : m_document(document) 53 : m_document(document)
54 , m_decoderBuilder(mimeType, encoding, encodingUserChoosen) 54 , m_decoderBuilder(mimeType, encoding, encodingUserChoosen)
55 // We grab a reference to the parser so that we'll always send data to the 55 // We grab a reference to the parser so that we'll always send data to the
56 // original parser, even if the document acquires a new parser (e.g., via 56 // original parser, even if the document acquires a new parser (e.g., via
57 // document.open). 57 // document.open).
58 , m_parser(m_document->implicitOpen()) 58 , m_parser(m_document->implicitOpen())
59 { 59 {
60 if (m_document->frame()) { 60 if (m_document->frame()) {
61 if (FrameView* view = m_document->frame()->view()) 61 if (FrameView* view = m_document->frame()->view())
62 view->setContentsSize(IntSize()); 62 view->setContentsSize(IntSize());
63 } 63 }
64 } 64 }
65 65
66 DocumentWriter::~DocumentWriter() 66 DocumentWriter::~DocumentWriter()
67 { 67 {
68 } 68 }
69 69
70 void DocumentWriter::trace(Visitor* visitor)
71 {
72 visitor->trace(m_document);
73 visitor->trace(m_parser);
74 }
75
70 void DocumentWriter::appendReplacingData(const String& source) 76 void DocumentWriter::appendReplacingData(const String& source)
71 { 77 {
72 m_document->setCompatibilityMode(Document::NoQuirksMode); 78 m_document->setCompatibilityMode(Document::NoQuirksMode);
73 79
74 // FIXME: This should call DocumentParser::appendBytes instead of append 80 // FIXME: This should call DocumentParser::appendBytes instead of append
75 // to support RawDataDocumentParsers. 81 // to support RawDataDocumentParsers.
76 if (DocumentParser* parser = m_document->parser()) { 82 if (DocumentParser* parser = m_document->parser()) {
77 parser->pinToMainThread(); 83 parser->pinToMainThread();
78 // Because we're pinned to the main thread we don't need to worry about 84 // Because we're pinned to the main thread we don't need to worry about
79 // passing ownership of the source string. 85 // passing ownership of the source string.
80 parser->append(source.impl()); 86 parser->append(source.impl());
81 } 87 }
82 } 88 }
83 89
84 void DocumentWriter::addData(const char* bytes, size_t length) 90 void DocumentWriter::addData(const char* bytes, size_t length)
85 { 91 {
86 ASSERT(m_parser); 92 ASSERT(m_parser);
87 if (m_parser->needsDecoder() && 0 < length) { 93 if (m_parser->needsDecoder() && 0 < length) {
88 OwnPtr<TextResourceDecoder> decoder = m_decoderBuilder.buildFor(m_docume nt); 94 OwnPtr<TextResourceDecoder> decoder = m_decoderBuilder.buildFor(m_docume nt);
89 m_parser->setDecoder(decoder.release()); 95 m_parser->setDecoder(decoder.release());
90 } 96 }
91 // appendBytes() can result replacing DocumentLoader::m_writer. 97 // appendBytes() can result replacing DocumentLoader::m_writer.
92 RefPtr<DocumentWriter> protectingThis(this); 98 RefPtrWillBeRawPtr<DocumentWriter> protectingThis(this);
93 m_parser->appendBytes(bytes, length); 99 m_parser->appendBytes(bytes, length);
94 } 100 }
95 101
96 void DocumentWriter::end() 102 void DocumentWriter::end()
97 { 103 {
98 ASSERT(m_document); 104 ASSERT(m_document);
99 105
100 // http://bugs.webkit.org/show_bug.cgi?id=10854 106 // http://bugs.webkit.org/show_bug.cgi?id=10854
101 // The frame's last ref may be removed and it can be deleted by checkComplet ed(), 107 // The frame's last ref may be removed and it can be deleted by checkComplet ed(),
102 // so we'll add a protective refcount 108 // so we'll add a protective refcount
103 RefPtr<LocalFrame> protector(m_document->frame()); 109 RefPtr<LocalFrame> protector(m_document->frame());
104 110
105 if (!m_parser) 111 if (!m_parser)
106 return; 112 return;
107 113
108 if (m_parser->needsDecoder()) { 114 if (m_parser->needsDecoder()) {
109 OwnPtr<TextResourceDecoder> decoder = m_decoderBuilder.buildFor(m_docume nt); 115 OwnPtr<TextResourceDecoder> decoder = m_decoderBuilder.buildFor(m_docume nt);
110 m_parser->setDecoder(decoder.release()); 116 m_parser->setDecoder(decoder.release());
111 } 117 }
112 // flush() can result replacing DocumentLoader::m_writer. 118 // flush() can result replacing DocumentLoader::m_writer.
113 RefPtr<DocumentWriter> protectingThis(this); 119 RefPtrWillBeRawPtr<DocumentWriter> protectingThis(this);
114 m_parser->flush(); 120 m_parser->flush();
115 121
116 if (!m_parser) 122 if (!m_parser)
117 return; 123 return;
118 124
119 m_parser->finish(); 125 m_parser->finish();
120 m_parser = nullptr; 126 m_parser = nullptr;
121 m_document = 0; 127 m_document = nullptr;
122 } 128 }
123 129
124 void DocumentWriter::setUserChosenEncoding(const String& charset) 130 void DocumentWriter::setUserChosenEncoding(const String& charset)
125 { 131 {
126 TextResourceDecoder* decoder = m_parser->decoder(); 132 TextResourceDecoder* decoder = m_parser->decoder();
127 if (decoder) 133 if (decoder)
128 decoder->setEncoding(charset, TextResourceDecoder::UserChosenEncoding); 134 decoder->setEncoding(charset, TextResourceDecoder::UserChosenEncoding);
129 } 135 }
130 136
131 void DocumentWriter::setDocumentWasLoadedAsPartOfNavigation() 137 void DocumentWriter::setDocumentWasLoadedAsPartOfNavigation()
132 { 138 {
133 ASSERT(m_parser && !m_parser->isStopped()); 139 ASSERT(m_parser && !m_parser->isStopped());
134 m_parser->setDocumentWasLoadedAsPartOfNavigation(); 140 m_parser->setDocumentWasLoadedAsPartOfNavigation();
135 } 141 }
136 142
137 } // namespace WebCore 143 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/loader/DocumentWriter.h ('k') | Source/core/loader/NavigationScheduler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698