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

Side by Side Diff: sky/engine/core/dom/DocumentParser.h

Issue 664573004: Live the dream (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: DEPS Created 6 years, 2 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
« no previous file with comments | « sky/engine/core/dom/Document.cpp ('k') | sky/engine/core/html/imports/HTMLImportLoader.h » ('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) 2000 Peter Kelly (pmk@post.com) 2 * Copyright (C) 2000 Peter Kelly (pmk@post.com)
3 * Copyright (C) 2005, 2006 Apple Computer, Inc. 3 * Copyright (C) 2005, 2006 Apple Computer, Inc.
4 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org) 4 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org)
5 * Copyright (C) 2010 Google, Inc. 5 * Copyright (C) 2010 Google, Inc.
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 23
24 #ifndef DocumentParser_h 24 #ifndef DocumentParser_h
25 #define DocumentParser_h 25 #define DocumentParser_h
26 26
27 #include "mojo/public/cpp/system/core.h"
27 #include "platform/heap/Handle.h" 28 #include "platform/heap/Handle.h"
28 #include "wtf/Forward.h" 29 #include "wtf/Forward.h"
29 #include "wtf/RefCounted.h" 30 #include "wtf/RefCounted.h"
30 31
31 namespace blink { 32 namespace blink {
32 33
33 class Document; 34 class Document;
34 class SegmentedString; 35 class SegmentedString;
35 class HTMLDocumentParser; 36 class HTMLDocumentParser;
36 class TextResourceDecoder; 37 class TextResourceDecoder;
37 38
38 class DocumentParser : public RefCountedWillBeGarbageCollectedFinalized<Document Parser> { 39 class DocumentParser : public RefCountedWillBeGarbageCollectedFinalized<Document Parser> {
39 public: 40 public:
40 virtual ~DocumentParser(); 41 virtual ~DocumentParser();
41 virtual void trace(Visitor*); 42 virtual void trace(Visitor*);
42 43
43 virtual HTMLDocumentParser* asHTMLDocumentParser() { return 0; } 44 virtual HTMLDocumentParser* asHTMLDocumentParser() { return 0; }
44 45
45 // http://www.whatwg.org/specs/web-apps/current-work/#insertion-point 46 virtual void parse(mojo::ScopedDataPipeConsumerHandle) = 0;
46 virtual bool hasInsertionPoint() { return true; }
47
48 // insert is used by document.write.
49 virtual void insert(const SegmentedString&) = 0;
50
51 // The below functions are used by DocumentWriter (the loader).
52 virtual void appendBytes(const char* bytes, size_t length) = 0;
53
54 // FIXME: append() should be private, but DocumentWriter::replaceDocumentWhi leExecutingJavaScriptURL uses it for now.
55 // FIXME: This really should take a PassOwnPtr to signify that it expects to take
56 // ownership of the buffer. The parser expects the PassRefPtr to hold the on ly ref of the StringImpl.
57 virtual void append(PassRefPtr<StringImpl>) = 0;
58
59 virtual void finish() = 0;
60
61 virtual bool processingData() const { return false; } 47 virtual bool processingData() const { return false; }
62 48
63 // document() will return 0 after detach() is called. 49 // document() will return 0 after detach() is called.
64 Document* document() const { ASSERT(m_document); return m_document; } 50 Document* document() const { ASSERT(m_document); return m_document; }
65 51
66 bool isParsing() const { return m_state == ParsingState; } 52 bool isParsing() const { return m_state == ParsingState; }
67 bool isStopping() const { return m_state == StoppingState; } 53 bool isStopping() const { return m_state == StoppingState; }
68 bool isStopped() const { return m_state >= StoppedState; } 54 bool isStopped() const { return m_state >= StoppedState; }
69 bool isDetached() const { return m_state == DetachedState; } 55 bool isDetached() const { return m_state == DetachedState; }
70 56
(...skipping 11 matching lines...) Expand all
82 // After detach, m_document is cleared. The parser will unwind its 68 // After detach, m_document is cleared. The parser will unwind its
83 // callstacks, but not produce any more nodes. 69 // callstacks, but not produce any more nodes.
84 // It is impossible for the parser to touch the rest of WebCore after 70 // It is impossible for the parser to touch the rest of WebCore after
85 // detach is called. 71 // detach is called.
86 // Oilpan: We don't need to call detach when a Document is destructed. 72 // Oilpan: We don't need to call detach when a Document is destructed.
87 virtual void detach(); 73 virtual void detach();
88 74
89 protected: 75 protected:
90 explicit DocumentParser(Document*); 76 explicit DocumentParser(Document*);
91 77
92 virtual void flush() = 0;
93
94 private: 78 private:
95 enum ParserState { 79 enum ParserState {
96 ParsingState, 80 ParsingState,
97 StoppingState, 81 StoppingState,
98 StoppedState, 82 StoppedState,
99 DetachedState 83 DetachedState
100 }; 84 };
101 ParserState m_state; 85 ParserState m_state;
102 86
103 // Every DocumentParser needs a pointer back to the document. 87 // Every DocumentParser needs a pointer back to the document.
104 // m_document will be 0 after the parser is stopped. 88 // m_document will be 0 after the parser is stopped.
105 RawPtrWillBeMember<Document> m_document; 89 RawPtrWillBeMember<Document> m_document;
106 }; 90 };
107 91
108 } // namespace blink 92 } // namespace blink
109 93
110 #endif // DocumentParser_h 94 #endif // DocumentParser_h
OLDNEW
« no previous file with comments | « sky/engine/core/dom/Document.cpp ('k') | sky/engine/core/html/imports/HTMLImportLoader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698