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

Side by Side Diff: Source/core/xml/parser/XMLDocumentParser.h

Issue 333143003: Fix style errors in core/xml/. (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/xml/XSLTUnicodeSort.cpp ('k') | Source/core/xml/parser/XMLDocumentParser.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) 2000 Peter Kelly (pmk@post.com) 2 * Copyright (C) 2000 Peter Kelly (pmk@post.com)
3 * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved. 3 * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved.
4 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org) 4 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org)
5 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 5 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
6 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 6 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 class ContainerNode; 43 class ContainerNode;
44 class ScriptResource; 44 class ScriptResource;
45 class ResourceFetcher; 45 class ResourceFetcher;
46 class DocumentFragment; 46 class DocumentFragment;
47 class Document; 47 class Document;
48 class Element; 48 class Element;
49 class FrameView; 49 class FrameView;
50 class Text; 50 class Text;
51 51
52 class XMLParserContext : public RefCounted<XMLParserContext> { 52 class XMLParserContext : public RefCounted<XMLParserContext> {
53 public:
54 static PassRefPtr<XMLParserContext> createMemoryParser(xmlSAXHandlerPtr, voi d* userData, const CString& chunk);
55 static PassRefPtr<XMLParserContext> createStringParser(xmlSAXHandlerPtr, voi d* userData);
56 ~XMLParserContext();
57 xmlParserCtxtPtr context() const { return m_context; }
58
59 private:
60 XMLParserContext(xmlParserCtxtPtr context)
61 : m_context(context)
62 {
63 }
64
65 xmlParserCtxtPtr m_context;
66 };
67
68 class XMLDocumentParser FINAL : public ScriptableDocumentParser, public Resource Client {
69 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
70 public:
71 static PassRefPtrWillBeRawPtr<XMLDocumentParser> create(Document& document, FrameView* view)
72 {
73 return adoptRefWillBeNoop(new XMLDocumentParser(document, view));
74 }
75 static PassRefPtrWillBeRawPtr<XMLDocumentParser> create(DocumentFragment* fr agment, Element* element, ParserContentPolicy parserContentPolicy)
76 {
77 return adoptRefWillBeNoop(new XMLDocumentParser(fragment, element, parse rContentPolicy));
78 }
79 virtual ~XMLDocumentParser();
80 virtual void trace(Visitor*) OVERRIDE;
81
82 // Exposed for callbacks:
83 void handleError(XMLErrors::ErrorType, const char* message, TextPosition);
84
85 void setIsXHTMLDocument(bool isXHTML) { m_isXHTMLDocument = isXHTML; }
86 bool isXHTMLDocument() const { return m_isXHTMLDocument; }
87
88 bool isCurrentlyParsing8BitChunk() { return m_isCurrentlyParsing8BitChunk; }
89
90 static bool parseDocumentFragment(const String&, DocumentFragment*, Element* parent = 0, ParserContentPolicy = AllowScriptingContent);
91
92 // Used by the XMLHttpRequest to check if the responseXML was well formed.
93 virtual bool wellFormed() const OVERRIDE { return !m_sawError; }
94
95 virtual TextPosition textPosition() const OVERRIDE;
96
97 static bool supportsXMLVersion(const String&);
98
99 class PendingCallback {
53 public: 100 public:
54 static PassRefPtr<XMLParserContext> createMemoryParser(xmlSAXHandlerPtr, void* userData, const CString& chunk); 101 virtual ~PendingCallback() { }
55 static PassRefPtr<XMLParserContext> createStringParser(xmlSAXHandlerPtr, void* userData); 102 virtual void call(XMLDocumentParser*) = 0;
56 ~XMLParserContext();
57 xmlParserCtxtPtr context() const { return m_context; }
58
59 private:
60 XMLParserContext(xmlParserCtxtPtr context)
61 : m_context(context)
62 {
63 }
64 xmlParserCtxtPtr m_context;
65 }; 103 };
66 104
67 class XMLDocumentParser FINAL : public ScriptableDocumentParser, public Reso urceClient { 105 private:
68 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; 106 explicit XMLDocumentParser(Document&, FrameView* = 0);
69 public: 107 XMLDocumentParser(DocumentFragment*, Element*, ParserContentPolicy);
70 static PassRefPtrWillBeRawPtr<XMLDocumentParser> create(Document& docume nt, FrameView* view)
71 {
72 return adoptRefWillBeNoop(new XMLDocumentParser(document, view));
73 }
74 static PassRefPtrWillBeRawPtr<XMLDocumentParser> create(DocumentFragment * fragment, Element* element, ParserContentPolicy parserContentPolicy)
75 {
76 return adoptRefWillBeNoop(new XMLDocumentParser(fragment, element, p arserContentPolicy));
77 }
78 108
79 virtual ~XMLDocumentParser(); 109 // From DocumentParser
80 virtual void trace(Visitor*) OVERRIDE; 110 virtual void insert(const SegmentedString&) OVERRIDE;
111 virtual void append(PassRefPtr<StringImpl>) OVERRIDE;
112 virtual void finish() OVERRIDE;
113 virtual bool isWaitingForScripts() const OVERRIDE;
114 virtual void stopParsing() OVERRIDE;
115 virtual void detach() OVERRIDE;
116 virtual OrdinalNumber lineNumber() const OVERRIDE;
117 OrdinalNumber columnNumber() const;
81 118
82 // Exposed for callbacks: 119 // from ResourceClient
83 void handleError(XMLErrors::ErrorType, const char* message, TextPosition ); 120 virtual void notifyFinished(Resource*) OVERRIDE;
84 121
85 void setIsXHTMLDocument(bool isXHTML) { m_isXHTMLDocument = isXHTML; } 122 void end();
86 bool isXHTMLDocument() const { return m_isXHTMLDocument; }
87 123
88 bool isCurrentlyParsing8BitChunk() { return m_isCurrentlyParsing8BitChun k; } 124 void pauseParsing();
125 void resumeParsing();
89 126
90 static bool parseDocumentFragment(const String&, DocumentFragment*, Elem ent* parent = 0, ParserContentPolicy = AllowScriptingContent); 127 bool appendFragmentSource(const String&);
91 128
92 // Used by the XMLHttpRequest to check if the responseXML was well forme d. 129 public:
93 virtual bool wellFormed() const OVERRIDE { return !m_sawError; } 130 // Callbacks from parser SAX
131 void error(XMLErrors::ErrorType, const char* message, va_list args) WTF_ATTR IBUTE_PRINTF(3, 0);
132 void startElementNs(const AtomicString& localName, const AtomicString& prefi x, const AtomicString& uri, int namespaceCount,
133 const xmlChar** namespaces, int attributeCount, int defaultedCount, cons t xmlChar** libxmlAttributes);
134 void endElementNs();
135 void characters(const xmlChar* chars, int length);
136 void processingInstruction(const String& target, const String& data);
137 void cdataBlock(const String&);
138 void comment(const String&);
139 void startDocument(const String& version, const String& encoding, int standa lone);
140 void internalSubset(const String& name, const String& externalID, const Stri ng& systemID);
141 void endDocument();
94 142
95 virtual TextPosition textPosition() const OVERRIDE; 143 private:
144 void initializeParserContext(const CString& chunk = CString());
96 145
97 static bool supportsXMLVersion(const String&); 146 void pushCurrentNode(ContainerNode*);
147 void popCurrentNode();
148 void clearCurrentNodeStack();
98 149
99 class PendingCallback { 150 void insertErrorMessageBlock();
100 public:
101 virtual ~PendingCallback() { }
102 virtual void call(XMLDocumentParser*) = 0;
103 };
104 151
105 private: 152 void enterText();
106 explicit XMLDocumentParser(Document&, FrameView* = 0); 153 void exitText();
107 XMLDocumentParser(DocumentFragment*, Element*, ParserContentPolicy);
108 154
109 // From DocumentParser 155 void doWrite(const String&);
110 virtual void insert(const SegmentedString&) OVERRIDE; 156 void doEnd();
111 virtual void append(PassRefPtr<StringImpl>) OVERRIDE;
112 virtual void finish() OVERRIDE;
113 virtual bool isWaitingForScripts() const OVERRIDE;
114 virtual void stopParsing() OVERRIDE;
115 virtual void detach() OVERRIDE;
116 virtual OrdinalNumber lineNumber() const OVERRIDE;
117 OrdinalNumber columnNumber() const;
118 157
119 // from ResourceClient 158 bool m_hasView;
120 virtual void notifyFinished(Resource*) OVERRIDE;
121 159
122 void end(); 160 SegmentedString m_originalSourceForTransform;
123 161
124 void pauseParsing(); 162 xmlParserCtxtPtr context() const { return m_context ? m_context->context() : 0; };
125 void resumeParsing(); 163 RefPtr<XMLParserContext> m_context;
164 Deque<OwnPtr<PendingCallback> > m_pendingCallbacks;
165 Vector<xmlChar> m_bufferedText;
126 166
127 bool appendFragmentSource(const String&); 167 RawPtrWillBeMember<ContainerNode> m_currentNode;
168 WillBeHeapVector<RawPtrWillBeMember<ContainerNode> > m_currentNodeStack;
128 169
129 public: 170 RefPtrWillBeMember<Text> m_leafTextNode;
130 // callbacks from parser SAX
131 void error(XMLErrors::ErrorType, const char* message, va_list args) WTF_ ATTRIBUTE_PRINTF(3, 0);
132 void startElementNs(const AtomicString& localName, const AtomicString& p refix, const AtomicString& uri, int nb_namespaces,
133 const xmlChar** namespaces, int nb_attributes, int n b_defaulted, const xmlChar** libxmlAttributes);
134 void endElementNs();
135 void characters(const xmlChar* chars, int length);
136 void processingInstruction(const String& target, const String& data);
137 void cdataBlock(const String&);
138 void comment(const String&);
139 void startDocument(const String& version, const String& encoding, int st andalone);
140 void internalSubset(const String& name, const String& externalID, const String& systemID);
141 void endDocument();
142 171
143 private: 172 bool m_isCurrentlyParsing8BitChunk;
144 void initializeParserContext(const CString& chunk = CString()); 173 bool m_sawError;
174 bool m_sawCSS;
175 bool m_sawXSLTransform;
176 bool m_sawFirstElement;
177 bool m_isXHTMLDocument;
178 bool m_parserPaused;
179 bool m_requestingScript;
180 bool m_finishCalled;
145 181
146 void pushCurrentNode(ContainerNode*); 182 XMLErrors m_xmlErrors;
147 void popCurrentNode();
148 void clearCurrentNodeStack();
149 183
150 void insertErrorMessageBlock(); 184 ResourcePtr<ScriptResource> m_pendingScript;
185 RefPtrWillBeMember<Element> m_scriptElement;
186 TextPosition m_scriptStartPosition;
151 187
152 void enterText(); 188 bool m_parsingFragment;
153 void exitText(); 189 AtomicString m_defaultNamespaceURI;
154 190
155 void doWrite(const String&); 191 typedef HashMap<AtomicString, AtomicString> PrefixForNamespaceMap;
156 void doEnd(); 192 PrefixForNamespaceMap m_prefixToNamespaceMap;
157 193 SegmentedString m_pendingSrc;
158 bool m_hasView; 194 };
159
160 SegmentedString m_originalSourceForTransform;
161
162 xmlParserCtxtPtr context() const { return m_context ? m_context->context () : 0; };
163 RefPtr<XMLParserContext> m_context;
164 Deque<OwnPtr<PendingCallback> > m_pendingCallbacks;
165 Vector<xmlChar> m_bufferedText;
166
167 RawPtrWillBeMember<ContainerNode> m_currentNode;
168 WillBeHeapVector<RawPtrWillBeMember<ContainerNode> > m_currentNodeStack;
169
170 RefPtrWillBeMember<Text> m_leafTextNode;
171
172 bool m_isCurrentlyParsing8BitChunk;
173 bool m_sawError;
174 bool m_sawCSS;
175 bool m_sawXSLTransform;
176 bool m_sawFirstElement;
177 bool m_isXHTMLDocument;
178 bool m_parserPaused;
179 bool m_requestingScript;
180 bool m_finishCalled;
181
182 XMLErrors m_xmlErrors;
183
184 ResourcePtr<ScriptResource> m_pendingScript;
185 RefPtrWillBeMember<Element> m_scriptElement;
186 TextPosition m_scriptStartPosition;
187
188 bool m_parsingFragment;
189 AtomicString m_defaultNamespaceURI;
190
191 typedef HashMap<AtomicString, AtomicString> PrefixForNamespaceMap;
192 PrefixForNamespaceMap m_prefixToNamespaceMap;
193 SegmentedString m_pendingSrc;
194 };
195 195
196 xmlDocPtr xmlDocPtrForString(ResourceFetcher*, const String& source, const Strin g& url); 196 xmlDocPtr xmlDocPtrForString(ResourceFetcher*, const String& source, const Strin g& url);
197
198 HashMap<String, String> parseAttributes(const String&, bool& attrsOK); 197 HashMap<String, String> parseAttributes(const String&, bool& attrsOK);
199 198
200 } // namespace WebCore 199 } // namespace WebCore
201 200
202 #endif // XMLDocumentParser_h 201 #endif // XMLDocumentParser_h
OLDNEW
« no previous file with comments | « Source/core/xml/XSLTUnicodeSort.cpp ('k') | Source/core/xml/parser/XMLDocumentParser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698