OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 30 matching lines...) Expand all Loading... |
41 #include "public/platform/WebString.h" | 41 #include "public/platform/WebString.h" |
42 #include "public/platform/WebURL.h" | 42 #include "public/platform/WebURL.h" |
43 #include "public/web/WebPageSerializer.h" | 43 #include "public/web/WebPageSerializer.h" |
44 #include "public/web/WebPageSerializerClient.h" | 44 #include "public/web/WebPageSerializerClient.h" |
45 #include "web/WebEntities.h" | 45 #include "web/WebEntities.h" |
46 | 46 |
47 namespace WTF{ | 47 namespace WTF{ |
48 class TextEncoding; | 48 class TextEncoding; |
49 } | 49 } |
50 | 50 |
51 namespace WebCore { | 51 namespace blink { |
52 class Document; | 52 class Document; |
53 class Element; | 53 class Element; |
54 class Node; | 54 class Node; |
55 } | 55 } |
56 | 56 |
57 namespace blink { | 57 namespace blink { |
58 class WebLocalFrameImpl; | 58 class WebLocalFrameImpl; |
59 | 59 |
60 // Get html data by serializing all frames of current page with lists | 60 // Get html data by serializing all frames of current page with lists |
61 // which contain all resource links that have local copy. | 61 // which contain all resource links that have local copy. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 // Local directory name of all local resource files. | 112 // Local directory name of all local resource files. |
113 WTF::String m_localDirectoryName; | 113 WTF::String m_localDirectoryName; |
114 // Vector for saving all frames which need to be serialized. | 114 // Vector for saving all frames which need to be serialized. |
115 Vector<WebLocalFrameImpl*> m_frames; | 115 Vector<WebLocalFrameImpl*> m_frames; |
116 | 116 |
117 // Web entities conversion maps. | 117 // Web entities conversion maps. |
118 WebEntities m_htmlEntities; | 118 WebEntities m_htmlEntities; |
119 WebEntities m_xmlEntities; | 119 WebEntities m_xmlEntities; |
120 | 120 |
121 struct SerializeDomParam { | 121 struct SerializeDomParam { |
122 const WebCore::KURL& url; | 122 const blink::KURL& url; |
123 const WTF::TextEncoding& textEncoding; | 123 const WTF::TextEncoding& textEncoding; |
124 WebCore::Document* document; | 124 blink::Document* document; |
125 const WTF::String& directoryName; | 125 const WTF::String& directoryName; |
126 bool isHTMLDocument; // document.isHTMLDocument() | 126 bool isHTMLDocument; // document.isHTMLDocument() |
127 bool haveSeenDocType; | 127 bool haveSeenDocType; |
128 bool haveAddedCharsetDeclaration; | 128 bool haveAddedCharsetDeclaration; |
129 // This meta element need to be skipped when serializing DOM. | 129 // This meta element need to be skipped when serializing DOM. |
130 const WebCore::Element* skipMetaElement; | 130 const blink::Element* skipMetaElement; |
131 // Flag indicates we are in script or style tag. | 131 // Flag indicates we are in script or style tag. |
132 bool isInScriptOrStyleTag; | 132 bool isInScriptOrStyleTag; |
133 bool haveAddedXMLProcessingDirective; | 133 bool haveAddedXMLProcessingDirective; |
134 // Flag indicates whether we have added additional contents before end t
ag. | 134 // Flag indicates whether we have added additional contents before end t
ag. |
135 // This flag will be re-assigned in each call of function | 135 // This flag will be re-assigned in each call of function |
136 // PostActionAfterSerializeOpenTag and it could be changed in function | 136 // PostActionAfterSerializeOpenTag and it could be changed in function |
137 // PreActionBeforeSerializeEndTag if the function adds new contents into | 137 // PreActionBeforeSerializeEndTag if the function adds new contents into |
138 // serialization stream. | 138 // serialization stream. |
139 bool haveAddedContentsBeforeEnd; | 139 bool haveAddedContentsBeforeEnd; |
140 | 140 |
141 SerializeDomParam(const WebCore::KURL&, const WTF::TextEncoding&, WebCor
e::Document*, const WTF::String& directoryName); | 141 SerializeDomParam(const blink::KURL&, const WTF::TextEncoding&, blink::D
ocument*, const WTF::String& directoryName); |
142 }; | 142 }; |
143 | 143 |
144 // Collect all target frames which need to be serialized. | 144 // Collect all target frames which need to be serialized. |
145 void collectTargetFrames(); | 145 void collectTargetFrames(); |
146 // Before we begin serializing open tag of a element, we give the target | 146 // Before we begin serializing open tag of a element, we give the target |
147 // element a chance to do some work prior to add some additional data. | 147 // element a chance to do some work prior to add some additional data. |
148 WTF::String preActionBeforeSerializeOpenTag(const WebCore::Element* element, | 148 WTF::String preActionBeforeSerializeOpenTag(const blink::Element* element, |
149 SerializeDomParam* param, | 149 SerializeDomParam* param, |
150 bool* needSkip); | 150 bool* needSkip); |
151 // After we finish serializing open tag of a element, we give the target | 151 // After we finish serializing open tag of a element, we give the target |
152 // element a chance to do some post work to add some additional data. | 152 // element a chance to do some post work to add some additional data. |
153 WTF::String postActionAfterSerializeOpenTag(const WebCore::Element* element, | 153 WTF::String postActionAfterSerializeOpenTag(const blink::Element* element, |
154 SerializeDomParam* param); | 154 SerializeDomParam* param); |
155 // Before we begin serializing end tag of a element, we give the target | 155 // Before we begin serializing end tag of a element, we give the target |
156 // element a chance to do some work prior to add some additional data. | 156 // element a chance to do some work prior to add some additional data. |
157 WTF::String preActionBeforeSerializeEndTag(const WebCore::Element* element, | 157 WTF::String preActionBeforeSerializeEndTag(const blink::Element* element, |
158 SerializeDomParam* param, | 158 SerializeDomParam* param, |
159 bool* needSkip); | 159 bool* needSkip); |
160 // After we finish serializing end tag of a element, we give the target | 160 // After we finish serializing end tag of a element, we give the target |
161 // element a chance to do some post work to add some additional data. | 161 // element a chance to do some post work to add some additional data. |
162 WTF::String postActionAfterSerializeEndTag(const WebCore::Element* element, | 162 WTF::String postActionAfterSerializeEndTag(const blink::Element* element, |
163 SerializeDomParam* param); | 163 SerializeDomParam* param); |
164 // Save generated html content to data buffer. | 164 // Save generated html content to data buffer. |
165 void saveHTMLContentToBuffer(const WTF::String& content, | 165 void saveHTMLContentToBuffer(const WTF::String& content, |
166 SerializeDomParam* param); | 166 SerializeDomParam* param); |
167 | 167 |
168 enum FlushOption { | 168 enum FlushOption { |
169 ForceFlush, | 169 ForceFlush, |
170 DoNotForceFlush, | 170 DoNotForceFlush, |
171 }; | 171 }; |
172 | 172 |
173 // Flushes the content buffer by encoding and sending the content to the | 173 // Flushes the content buffer by encoding and sending the content to the |
174 // WebPageSerializerClient. Content is not flushed if the buffer is not full | 174 // WebPageSerializerClient. Content is not flushed if the buffer is not full |
175 // unless force is 1. | 175 // unless force is 1. |
176 void encodeAndFlushBuffer(WebPageSerializerClient::PageSerializationStatus s
tatus, | 176 void encodeAndFlushBuffer(WebPageSerializerClient::PageSerializationStatus s
tatus, |
177 SerializeDomParam* param, | 177 SerializeDomParam* param, |
178 FlushOption); | 178 FlushOption); |
179 // Serialize open tag of an specified element. | 179 // Serialize open tag of an specified element. |
180 void openTagToString(WebCore::Element*, | 180 void openTagToString(blink::Element*, |
181 SerializeDomParam* param); | 181 SerializeDomParam* param); |
182 // Serialize end tag of an specified element. | 182 // Serialize end tag of an specified element. |
183 void endTagToString(WebCore::Element*, | 183 void endTagToString(blink::Element*, |
184 SerializeDomParam* param); | 184 SerializeDomParam* param); |
185 // Build content for a specified node | 185 // Build content for a specified node |
186 void buildContentForNode(WebCore::Node*, | 186 void buildContentForNode(blink::Node*, |
187 SerializeDomParam* param); | 187 SerializeDomParam* param); |
188 }; | 188 }; |
189 | 189 |
190 } // namespace blink | 190 } // namespace blink |
191 | 191 |
192 #endif | 192 #endif |
OLD | NEW |