| 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 result.append(WebPageSerializer::generateMarkOfTheWebDeclaration(par
am->url)); | 149 result.append(WebPageSerializer::generateMarkOfTheWebDeclaration(par
am->url)); |
| 150 } else if (isHTMLBaseElement(*element)) { | 150 } else if (isHTMLBaseElement(*element)) { |
| 151 // Comment the BASE tag when serializing dom. | 151 // Comment the BASE tag when serializing dom. |
| 152 result.appendLiteral("<!--"); | 152 result.appendLiteral("<!--"); |
| 153 } | 153 } |
| 154 } else { | 154 } else { |
| 155 // Write XML declaration. | 155 // Write XML declaration. |
| 156 if (!param->haveAddedXMLProcessingDirective) { | 156 if (!param->haveAddedXMLProcessingDirective) { |
| 157 param->haveAddedXMLProcessingDirective = true; | 157 param->haveAddedXMLProcessingDirective = true; |
| 158 // Get encoding info. | 158 // Get encoding info. |
| 159 String xmlEncoding = param->document->xmlEncoding(); | 159 String xmlEncoding = param->textEncoding.name(); |
| 160 if (xmlEncoding.isEmpty()) | |
| 161 xmlEncoding = param->document->encodingName(); | |
| 162 if (xmlEncoding.isEmpty()) | |
| 163 xmlEncoding = UTF8Encoding().name(); | |
| 164 result.appendLiteral("<?xml version=\""); | 160 result.appendLiteral("<?xml version=\""); |
| 165 result.append(param->document->xmlVersion()); | 161 result.append(param->document->xmlVersion()); |
| 166 result.appendLiteral("\" encoding=\""); | 162 result.appendLiteral("\" encoding=\""); |
| 167 result.append(xmlEncoding); | 163 result.append(xmlEncoding); |
| 168 if (param->document->xmlStandalone()) | 164 if (param->document->xmlStandalone()) |
| 169 result.appendLiteral("\" standalone=\"yes"); | 165 result.appendLiteral("\" standalone=\"yes"); |
| 170 result.appendLiteral("\"?>\n"); | 166 result.appendLiteral("\"?>\n"); |
| 171 } | 167 } |
| 172 // Add doc type declaration if original document has it. | 168 // Add doc type declaration if original document has it. |
| 173 if (!param->haveSeenDocType) { | 169 if (!param->haveSeenDocType) { |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 bool WebPageSerializerImpl::serialize() | 441 bool WebPageSerializerImpl::serialize() |
| 446 { | 442 { |
| 447 bool didSerialization = false; | 443 bool didSerialization = false; |
| 448 | 444 |
| 449 Document* document = m_specifiedWebLocalFrameImpl->frame()->document(); | 445 Document* document = m_specifiedWebLocalFrameImpl->frame()->document(); |
| 450 const KURL& url = document->url(); | 446 const KURL& url = document->url(); |
| 451 | 447 |
| 452 if (url.isValid()) { | 448 if (url.isValid()) { |
| 453 didSerialization = true; | 449 didSerialization = true; |
| 454 | 450 |
| 455 const WTF::TextEncoding& textEncoding = document->encoding().isValid() ?
document->encoding() : UTF8Encoding(); | 451 const WTF::TextEncoding& textEncoding = UTF8Encoding(); |
| 456 | 452 |
| 457 SerializeDomParam param(url, textEncoding, document, m_localDirectoryNam
e); | 453 SerializeDomParam param(url, textEncoding, document, m_localDirectoryNam
e); |
| 458 | 454 |
| 459 Element* documentElement = document->documentElement(); | 455 Element* documentElement = document->documentElement(); |
| 460 if (documentElement) | 456 if (documentElement) |
| 461 buildContentForNode(documentElement, ¶m); | 457 buildContentForNode(documentElement, ¶m); |
| 462 | 458 |
| 463 encodeAndFlushBuffer(WebPageSerializerClient::CurrentFrameIsFinished, &p
aram, ForceFlush); | 459 encodeAndFlushBuffer(WebPageSerializerClient::CurrentFrameIsFinished, &p
aram, ForceFlush); |
| 464 } else { | 460 } else { |
| 465 // Report empty contents for invalid URLs. | 461 // Report empty contents for invalid URLs. |
| 466 m_client->didSerializeDataForFrame( | 462 m_client->didSerializeDataForFrame( |
| 467 WebCString(), WebPageSerializerClient::CurrentFrameIsFinished); | 463 WebCString(), WebPageSerializerClient::CurrentFrameIsFinished); |
| 468 } | 464 } |
| 469 | 465 |
| 470 ASSERT(m_dataBuffer.isEmpty()); | 466 ASSERT(m_dataBuffer.isEmpty()); |
| 471 return didSerialization; | 467 return didSerialization; |
| 472 } | 468 } |
| 473 | 469 |
| 474 } // namespace blink | 470 } // namespace blink |
| OLD | NEW |