| 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 if (!param->haveSeenDocType) { | 149 if (!param->haveSeenDocType) { |
| 150 param->haveSeenDocType = true; | 150 param->haveSeenDocType = true; |
| 151 result.append(createMarkup(param->document->doctype())); | 151 result.append(createMarkup(param->document->doctype())); |
| 152 } | 152 } |
| 153 | 153 |
| 154 // Add MOTW declaration before html tag. | 154 // Add MOTW declaration before html tag. |
| 155 // See http://msdn2.microsoft.com/en-us/library/ms537628(VS.85).aspx
. | 155 // See http://msdn2.microsoft.com/en-us/library/ms537628(VS.85).aspx
. |
| 156 result.append(WebPageSerializer::generateMarkOfTheWebDeclaration(par
am->url)); | 156 result.append(WebPageSerializer::generateMarkOfTheWebDeclaration(par
am->url)); |
| 157 } else if (isHTMLBaseElement(*element)) { | 157 } else if (isHTMLBaseElement(*element)) { |
| 158 // Comment the BASE tag when serializing dom. | 158 // Comment the BASE tag when serializing dom. |
| 159 result.append("<!--"); | 159 result.appendLiteral("<!--"); |
| 160 } | 160 } |
| 161 } else { | 161 } else { |
| 162 // Write XML declaration. | 162 // Write XML declaration. |
| 163 if (!param->haveAddedXMLProcessingDirective) { | 163 if (!param->haveAddedXMLProcessingDirective) { |
| 164 param->haveAddedXMLProcessingDirective = true; | 164 param->haveAddedXMLProcessingDirective = true; |
| 165 // Get encoding info. | 165 // Get encoding info. |
| 166 String xmlEncoding = param->document->xmlEncoding(); | 166 String xmlEncoding = param->document->xmlEncoding(); |
| 167 if (xmlEncoding.isEmpty()) | 167 if (xmlEncoding.isEmpty()) |
| 168 xmlEncoding = param->document->encodingName(); | 168 xmlEncoding = param->document->encodingName(); |
| 169 if (xmlEncoding.isEmpty()) | 169 if (xmlEncoding.isEmpty()) |
| 170 xmlEncoding = UTF8Encoding().name(); | 170 xmlEncoding = UTF8Encoding().name(); |
| 171 result.append("<?xml version=\""); | 171 result.appendLiteral("<?xml version=\""); |
| 172 result.append(param->document->xmlVersion()); | 172 result.append(param->document->xmlVersion()); |
| 173 result.append("\" encoding=\""); | 173 result.appendLiteral("\" encoding=\""); |
| 174 result.append(xmlEncoding); | 174 result.append(xmlEncoding); |
| 175 if (param->document->xmlStandalone()) | 175 if (param->document->xmlStandalone()) |
| 176 result.append("\" standalone=\"yes"); | 176 result.appendLiteral("\" standalone=\"yes"); |
| 177 result.append("\"?>\n"); | 177 result.appendLiteral("\"?>\n"); |
| 178 } | 178 } |
| 179 // Add doc type declaration if original document has it. | 179 // Add doc type declaration if original document has it. |
| 180 if (!param->haveSeenDocType) { | 180 if (!param->haveSeenDocType) { |
| 181 param->haveSeenDocType = true; | 181 param->haveSeenDocType = true; |
| 182 result.append(createMarkup(param->document->doctype())); | 182 result.append(createMarkup(param->document->doctype())); |
| 183 } | 183 } |
| 184 } | 184 } |
| 185 return result.toString(); | 185 return result.toString(); |
| 186 } | 186 } |
| 187 | 187 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 // element a chance to do some post work to add some additional data. | 242 // element a chance to do some post work to add some additional data. |
| 243 String WebPageSerializerImpl::postActionAfterSerializeEndTag( | 243 String WebPageSerializerImpl::postActionAfterSerializeEndTag( |
| 244 const Element* element, SerializeDomParam* param) | 244 const Element* element, SerializeDomParam* param) |
| 245 { | 245 { |
| 246 StringBuilder result; | 246 StringBuilder result; |
| 247 | 247 |
| 248 if (!param->isHTMLDocument) | 248 if (!param->isHTMLDocument) |
| 249 return result.toString(); | 249 return result.toString(); |
| 250 // Comment the BASE tag when serializing DOM. | 250 // Comment the BASE tag when serializing DOM. |
| 251 if (isHTMLBaseElement(*element)) { | 251 if (isHTMLBaseElement(*element)) { |
| 252 result.append("-->"); | 252 result.appendLiteral("-->"); |
| 253 // Append a new base tag declaration. | 253 // Append a new base tag declaration. |
| 254 result.append(WebPageSerializer::generateBaseTagDeclaration( | 254 result.append(WebPageSerializer::generateBaseTagDeclaration( |
| 255 param->document->baseTarget())); | 255 param->document->baseTarget())); |
| 256 } | 256 } |
| 257 | 257 |
| 258 return result.toString(); | 258 return result.toString(); |
| 259 } | 259 } |
| 260 | 260 |
| 261 void WebPageSerializerImpl::saveHTMLContentToBuffer( | 261 void WebPageSerializerImpl::saveHTMLContentToBuffer( |
| 262 const String& result, SerializeDomParam* param) | 262 const String& result, SerializeDomParam* param) |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 | 512 |
| 513 encodeAndFlushBuffer(WebPageSerializerClient::CurrentFrameIsFinished, &p
aram, ForceFlush); | 513 encodeAndFlushBuffer(WebPageSerializerClient::CurrentFrameIsFinished, &p
aram, ForceFlush); |
| 514 } | 514 } |
| 515 | 515 |
| 516 ASSERT(m_dataBuffer.isEmpty()); | 516 ASSERT(m_dataBuffer.isEmpty()); |
| 517 m_client->didSerializeDataForFrame(KURL(), WebCString("", 0), WebPageSeriali
zerClient::AllFramesAreFinished); | 517 m_client->didSerializeDataForFrame(KURL(), WebCString("", 0), WebPageSeriali
zerClient::AllFramesAreFinished); |
| 518 return didSerialization; | 518 return didSerialization; |
| 519 } | 519 } |
| 520 | 520 |
| 521 } // namespace blink | 521 } // namespace blink |
| OLD | NEW |