OLD | NEW |
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 | 50 |
51 // FIXME: append() should be private, but DocumentWriter::replaceDocument | 51 // FIXME: append() should be private, but DocumentWriter::replaceDocument |
52 // uses it for now. | 52 // uses it for now. |
53 virtual void append(const SegmentedString&) = 0; | 53 virtual void append(const SegmentedString&) = 0; |
54 | 54 |
55 virtual void finish() = 0; | 55 virtual void finish() = 0; |
56 virtual bool finishWasCalled() = 0; | 56 virtual bool finishWasCalled() = 0; |
57 | 57 |
58 // FIXME: processingData() is only used by DocumentLoader::isLoadingInAPISen
se | 58 // FIXME: processingData() is only used by DocumentLoader::isLoadingInAPISen
se |
59 // and is very unclear as to what it actually means. The LegacyHTMLDocument
Parser | 59 // and is very unclear as to what it actually means. The LegacyHTMLDocument
Parser |
60 // used to implement it. | 60 // used to implements it. |
61 virtual bool processingData() const { return false; } | 61 virtual bool processingData() const { return false; } |
62 | 62 |
63 // document() will return 0 after detach() is called. | 63 // document() will return 0 after detach() is called. |
64 Document* document() const { ASSERT(m_document); return m_document; } | 64 Document* document() const { ASSERT(m_document); return m_document; } |
65 | 65 bool isDetached() const { return !m_document; } |
66 bool isParsing() const { return m_state == ParsingState; } | |
67 bool isStopping() const { return m_state == StoppingState; } | |
68 bool isStopped() const { return m_state >= StoppedState; } | |
69 bool isDetached() const { return m_state == DetachedState; } | |
70 | |
71 // FIXME: Is this necessary? Does XMLDocumentParserLibxml2 really need to se
t this? | |
72 virtual void startParsing(); | |
73 | |
74 // prepareToStop() is used when the EOF token is encountered and parsing is
to be | |
75 // stopped normally. | |
76 virtual void prepareToStopParsing(); | |
77 | |
78 // stopParsing() is used when a load is canceled/stopped. | |
79 // stopParsing() is currently different from detach(), but shouldn't be. | |
80 // It should NOT be ok to call any methods on DocumentParser after either | |
81 // detach() or stopParsing() but right now only detach() will ASSERT. | |
82 virtual void stopParsing(); | |
83 | 66 |
84 // Document is expected to detach the parser before releasing its ref. | 67 // Document is expected to detach the parser before releasing its ref. |
85 // After detach, m_document is cleared. The parser will unwind its | 68 // After detach, m_document is cleared. The parser will unwind its |
86 // callstacks, but not produce any more nodes. | 69 // callstacks, but not produce any more nodes. |
87 // 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 |
88 // detach is called. | 71 // detach is called. |
89 virtual void detach(); | 72 virtual void detach(); |
90 | 73 |
| 74 // stopParsing() is used when a load is canceled/stopped. |
| 75 // stopParsing() is currently different from detach(), but shouldn't be. |
| 76 // It should NOT be ok to call any methods on DocumentParser after either |
| 77 // detach() or stopParsing() but right now only detach() will ASSERT. |
| 78 virtual void stopParsing() { m_parserStopped = true; } |
| 79 |
91 protected: | 80 protected: |
92 DocumentParser(Document*); | 81 DocumentParser(Document*); |
93 | 82 |
| 83 // The parser has buffers, so parsing may continue even after |
| 84 // it stops receiving data. We use m_parserStopped to stop the parser |
| 85 // even when it has buffered data. |
| 86 // FIXME: m_document = 0 could be changed to mean "parser stopped". |
| 87 bool m_parserStopped; |
| 88 |
94 private: | 89 private: |
95 enum ParserState { | |
96 ParsingState, | |
97 StoppingState, | |
98 StoppedState, | |
99 DetachedState | |
100 }; | |
101 ParserState m_state; | |
102 | |
103 // Every DocumentParser needs a pointer back to the document. | 90 // Every DocumentParser needs a pointer back to the document. |
104 // m_document will be 0 after the parser is stopped. | 91 // m_document will be 0 after the parser is stopped. |
105 Document* m_document; | 92 Document* m_document; |
106 }; | 93 }; |
107 | 94 |
108 } // namespace WebCore | 95 } // namespace WebCore |
109 | 96 |
110 #endif // DocumentParser_h | 97 #endif // DocumentParser_h |
OLD | NEW |