Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 // TODO(tiger): Refactor MarkupAccumulator so it is easier to append an elem ent like this, without special cases for XHTML | |
| 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 MarkupFormatter::appendAttributeValue(result, m_document->suggestedMIMET ype(), m_document->isHTMLDocument()); |
| 162 out.appendLiteral("\">"); | 163 result.appendLiteral("; charset="); |
| 164 MarkupFormatter::appendAttributeValue(result, m_document->charset(), m_d ocument->isHTMLDocument()); | |
| 165 if (m_document->isXHTMLDocument()) | |
|
hajimehoshi
2015/06/12 09:57:02
Please remove fixing XHTML compatibility in this C
Tiger (Sony Mobile)
2015/06/12 11:31:55
This is not only for XHTML compatibility but XML c
| |
| 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 Loading... | |
| 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 |
| OLD | NEW |