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

Side by Side Diff: Source/core/page/PageSerializer.cpp

Issue 1174923003: Merge page serializers [10/12] (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 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
« no previous file with comments | « no previous file | no next file » | 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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 , m_serializer(serializer) 128 , m_serializer(serializer)
129 , m_document(&document) 129 , m_document(&document)
130 , m_nodes(nodes) 130 , m_nodes(nodes)
131 { 131 {
132 } 132 }
133 133
134 SerializerMarkupAccumulator::~SerializerMarkupAccumulator() 134 SerializerMarkupAccumulator::~SerializerMarkupAccumulator()
135 { 135 {
136 } 136 }
137 137
138 void SerializerMarkupAccumulator::appendText(StringBuilder& out, Text& text) 138 void SerializerMarkupAccumulator::appendText(StringBuilder& result, Text& text)
139 { 139 {
140 Element* parent = text.parentElement(); 140 Element* parent = text.parentElement();
141 if (parent && !shouldIgnoreElement(*parent)) 141 if (parent && !shouldIgnoreElement(*parent))
142 MarkupAccumulator::appendText(out, text); 142 MarkupAccumulator::appendText(result, text);
143 } 143 }
144 144
145 bool SerializerMarkupAccumulator::shouldIgnoreAttribute(const Attribute& attribu te) 145 bool SerializerMarkupAccumulator::shouldIgnoreAttribute(const Attribute& attribu te)
146 { 146 {
147 PageSerializer::Delegate* delegate = m_serializer->delegate(); 147 PageSerializer::Delegate* delegate = m_serializer->delegate();
148 if (delegate) 148 if (delegate)
149 return delegate->shouldIgnoreAttribute(attribute); 149 return delegate->shouldIgnoreAttribute(attribute);
150 150
151 return MarkupAccumulator::shouldIgnoreAttribute(attribute); 151 return MarkupAccumulator::shouldIgnoreAttribute(attribute);
152 } 152 }
153 153
154 void SerializerMarkupAccumulator::appendElement(StringBuilder& out, Element& ele ment, Namespaces* namespaces) 154 void SerializerMarkupAccumulator::appendElement(StringBuilder& result, Element& element, Namespaces* namespaces)
155 { 155 {
156 if (!shouldIgnoreElement(element)) 156 if (!shouldIgnoreElement(element))
157 MarkupAccumulator::appendElement(out, element, namespaces); 157 MarkupAccumulator::appendElement(result, element, namespaces);
158 158
159 // FIXME: Refactor MarkupAccumulator so it is easier to append an element li ke this, without special cases for XHTML
hajimehoshi 2015/06/11 01:40:32 nit: Use TODO(yourname) instead.
hajimehoshi 2015/06/11 02:30:16 Now MarkupFormatter has two modes represented by e
Tiger (Sony Mobile) 2015/06/11 08:15:16 Done.
Tiger (Sony Mobile) 2015/06/11 08:15:16 It would be nice to have that delegated yes. Is an
hajimehoshi 2015/06/11 08:37:12 Yes, XHTML is slightly different from XML in that
Tiger (Sony Mobile) 2015/06/11 10:22:10 This is only recommended for compatibility but not
yosin_UTC9 2015/06/12 07:07:31 How about using |Document* document = element->do
philipj_slow 2015/06/12 07:58:49 Actually XHTML does not need a space before the sl
159 if (isHTMLHeadElement(element)) { 160 if (isHTMLHeadElement(element)) {
160 out.appendLiteral("<meta charset=\""); 161 result.appendLiteral("<meta http-equiv=\"Content-Type\" content=\"");
161 out.append(m_document->charset()); 162 result.append(m_document->suggestedMIMEType());
hajimehoshi 2015/06/11 01:40:32 Use MarkupFormatter::appendAttributeValue for esca
Tiger (Sony Mobile) 2015/06/11 08:15:16 Done.
162 out.appendLiteral("\">"); 163 result.appendLiteral("; charset=");
hajimehoshi 2015/06/11 01:41:40 last '"' is missing?
Tiger (Sony Mobile) 2015/06/11 08:15:16 The last " is on line 166/168. The complete tag wi
164 result.append(m_document->charset());
hajimehoshi 2015/06/11 01:41:41 MarkupFormatter::appendAttributeValue
Tiger (Sony Mobile) 2015/06/11 08:15:17 Done.
165 if (m_document->isXHTMLDocument())
166 result.appendLiteral("\" />");
167 else
168 result.appendLiteral("\">");
163 } 169 }
164 170
165 // FIXME: For object (plugins) tags and video tag we could replace them by a n image of their current contents. 171 // FIXME: For object (plugins) tags and video tag we could replace them by a n image of their current contents.
166 } 172 }
167 173
168 void SerializerMarkupAccumulator::appendCustomAttributes(StringBuilder& out, con st Element& element, Namespaces* namespaces) 174 void SerializerMarkupAccumulator::appendCustomAttributes(StringBuilder& result, const Element& element, Namespaces* namespaces)
169 { 175 {
170 if (!element.isFrameOwnerElement()) 176 if (!element.isFrameOwnerElement())
171 return; 177 return;
172 178
173 const HTMLFrameOwnerElement& frameOwner = toHTMLFrameOwnerElement(element); 179 const HTMLFrameOwnerElement& frameOwner = toHTMLFrameOwnerElement(element);
174 Frame* frame = frameOwner.contentFrame(); 180 Frame* frame = frameOwner.contentFrame();
175 // FIXME: RemoteFrames not currently supported here. 181 // FIXME: RemoteFrames not currently supported here.
176 if (!frame || !frame->isLocalFrame()) 182 if (!frame || !frame->isLocalFrame())
177 return; 183 return;
178 184
179 KURL url = toLocalFrame(frame)->document()->url(); 185 KURL url = toLocalFrame(frame)->document()->url();
180 if (url.isValid() && !url.protocolIsAbout()) 186 if (url.isValid() && !url.protocolIsAbout())
181 return; 187 return;
182 188
183 // We need to give a fake location to blank frames so they can be referenced by the serialized frame. 189 // We need to give a fake location to blank frames so they can be referenced by the serialized frame.
184 url = m_serializer->urlForBlankFrame(toLocalFrame(frame)); 190 url = m_serializer->urlForBlankFrame(toLocalFrame(frame));
185 appendAttribute(out, element, Attribute(frameOwnerURLAttributeName(frameOwne r), AtomicString(url.string())), namespaces); 191 appendAttribute(result, element, Attribute(frameOwnerURLAttributeName(frameO wner), AtomicString(url.string())), namespaces);
186 } 192 }
187 193
188 void SerializerMarkupAccumulator::appendStartTag(Node& node, Namespaces* namespa ces) 194 void SerializerMarkupAccumulator::appendStartTag(Node& node, Namespaces* namespa ces)
189 { 195 {
190 MarkupAccumulator::appendStartTag(node, namespaces); 196 MarkupAccumulator::appendStartTag(node, namespaces);
191 m_nodes.append(&node); 197 m_nodes.append(&node);
192 } 198 }
193 199
194 void SerializerMarkupAccumulator::appendEndTag(const Element& element) 200 void SerializerMarkupAccumulator::appendEndTag(const Element& element)
195 { 201 {
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 424
419 return fakeURL; 425 return fakeURL;
420 } 426 }
421 427
422 PageSerializer::Delegate* PageSerializer::delegate() 428 PageSerializer::Delegate* PageSerializer::delegate()
423 { 429 {
424 return m_delegate.get(); 430 return m_delegate.get();
425 } 431 }
426 432
427 } // namespace blink 433 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698