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

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

Issue 722743002: Remove dynamic cast from DocumentPaser interface (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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/parser/HTMLDocumentParser.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.
(...skipping 10 matching lines...) Expand all
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 "mojo/public/cpp/system/core.h"
28 #include "platform/heap/Handle.h" 28 #include "platform/heap/Handle.h"
29 #include "wtf/Forward.h" 29 #include "wtf/Forward.h"
30 #include "wtf/RefCounted.h" 30 #include "wtf/RefCounted.h"
31 #include "wtf/text/TextPosition.h"
31 32
32 namespace blink { 33 namespace blink {
33 34
34 class Document; 35 class Document;
35 class SegmentedString; 36 class SegmentedString;
36 class HTMLDocumentParser; 37 class HTMLDocumentParser;
37 class TextResourceDecoder; 38 class TextResourceDecoder;
38 39
39 class DocumentParser : public RefCounted<DocumentParser> { 40 class DocumentParser : public RefCounted<DocumentParser> {
40 public: 41 public:
41 virtual ~DocumentParser(); 42 virtual ~DocumentParser();
42 43
43 virtual HTMLDocumentParser* asHTMLDocumentParser() { return 0; } 44 virtual void parse(mojo::ScopedDataPipeConsumerHandle) = 0;
44 45
45 virtual void parse(mojo::ScopedDataPipeConsumerHandle) = 0; 46 virtual TextPosition textPosition() const = 0;
46 virtual bool processingData() const { return false; } 47 virtual void executeScriptsWaitingForResources() = 0;
47 48 virtual bool isWaitingForScripts() const = 0;
48 // document() will return 0 after detach() is called. 49 virtual bool isExecutingScript() const = 0;
49 Document* document() const { ASSERT(m_document); return m_document; }
50 50
51 bool isParsing() const { return m_state == ParsingState; } 51 bool isParsing() const { return m_state == ParsingState; }
52 bool isStopping() const { return m_state == StoppingState; }
53 bool isStopped() const { return m_state >= StoppedState; }
54 bool isDetached() const { return m_state == DetachedState; }
55
56 // prepareToStop() is used when the EOF token is encountered and parsing is to be
57 // stopped normally.
58 virtual void prepareToStopParsing();
59 52
60 // stopParsing() is used when a load is canceled/stopped. 53 // stopParsing() is used when a load is canceled/stopped.
61 // stopParsing() is currently different from detach(), but shouldn't be. 54 // stopParsing() is currently different from detach(), but shouldn't be.
62 // It should NOT be ok to call any methods on DocumentParser after either 55 // It should NOT be ok to call any methods on DocumentParser after either
63 // detach() or stopParsing() but right now only detach() will ASSERT. 56 // detach() or stopParsing() but right now only detach() will ASSERT.
64 virtual void stopParsing(); 57 virtual void stopParsing();
65 58
66 // Document is expected to detach the parser before releasing its ref. 59 // Document is expected to detach the parser before releasing its ref.
67 // After detach, m_document is cleared. The parser will unwind its 60 // After detach, m_document is cleared. The parser will unwind its
68 // callstacks, but not produce any more nodes. 61 // callstacks, but not produce any more nodes.
69 // It is impossible for the parser to touch the rest of WebCore after 62 // It is impossible for the parser to touch the rest of WebCore after
70 // detach is called. 63 // detach is called.
71 // Oilpan: We don't need to call detach when a Document is destructed. 64 // Oilpan: We don't need to call detach when a Document is destructed.
72 virtual void detach(); 65 virtual void detach();
73 66
74 protected: 67 protected:
75 explicit DocumentParser(Document*); 68 explicit DocumentParser(Document*);
76 69
70 // document() will return 0 after detach() is called.
71 Document* document() const { ASSERT(m_document); return m_document; }
72
73 virtual void prepareToStopParsing();
74
75 bool isStopping() const { return m_state == StoppingState; }
76 bool isStopped() const { return m_state >= StoppedState; }
77 bool isDetached() const { return m_state == DetachedState; }
78
77 private: 79 private:
78 enum ParserState { 80 enum ParserState {
79 ParsingState, 81 ParsingState,
80 StoppingState, 82 StoppingState,
81 StoppedState, 83 StoppedState,
82 DetachedState 84 DetachedState
83 }; 85 };
84 ParserState m_state; 86 ParserState m_state;
85 87
86 // Every DocumentParser needs a pointer back to the document. 88 // Every DocumentParser needs a pointer back to the document.
87 // m_document will be 0 after the parser is stopped. 89 // m_document will be 0 after the parser is stopped.
88 Document* m_document; 90 Document* m_document;
89 }; 91 };
90 92
91 } // namespace blink 93 } // namespace blink
92 94
93 #endif // DocumentParser_h 95 #endif // DocumentParser_h
OLDNEW
« no previous file with comments | « sky/engine/core/dom/Document.cpp ('k') | sky/engine/core/html/parser/HTMLDocumentParser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698