| 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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.appendLiteral("<!--"); | 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->textEncoding.name(); |
| 167 if (xmlEncoding.isEmpty()) | |
| 168 xmlEncoding = param->document->encodingName(); | |
| 169 if (xmlEncoding.isEmpty()) | |
| 170 xmlEncoding = UTF8Encoding().name(); | |
| 171 result.appendLiteral("<?xml version=\""); | 167 result.appendLiteral("<?xml version=\""); |
| 172 result.append(param->document->xmlVersion()); | 168 result.append(param->document->xmlVersion()); |
| 173 result.appendLiteral("\" encoding=\""); | 169 result.appendLiteral("\" encoding=\""); |
| 174 result.append(xmlEncoding); | 170 result.append(xmlEncoding); |
| 175 if (param->document->xmlStandalone()) | 171 if (param->document->xmlStandalone()) |
| 176 result.appendLiteral("\" standalone=\"yes"); | 172 result.appendLiteral("\" standalone=\"yes"); |
| 177 result.appendLiteral("\"?>\n"); | 173 result.appendLiteral("\"?>\n"); |
| 178 } | 174 } |
| 179 // Add doc type declaration if original document has it. | 175 // Add doc type declaration if original document has it. |
| 180 if (!param->haveSeenDocType) { | 176 if (!param->haveSeenDocType) { |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 bool didSerialization = false; | 451 bool didSerialization = false; |
| 456 KURL mainURL = m_specifiedWebLocalFrameImpl->frame()->document()->url(); | 452 KURL mainURL = m_specifiedWebLocalFrameImpl->frame()->document()->url(); |
| 457 | 453 |
| 458 WebLocalFrameImpl* webFrame = m_specifiedWebLocalFrameImpl; | 454 WebLocalFrameImpl* webFrame = m_specifiedWebLocalFrameImpl; |
| 459 Document* document = webFrame->frame()->document(); | 455 Document* document = webFrame->frame()->document(); |
| 460 const KURL& url = document->url(); | 456 const KURL& url = document->url(); |
| 461 | 457 |
| 462 if (url.isValid() && m_localLinks.contains(url.string())) { | 458 if (url.isValid() && m_localLinks.contains(url.string())) { |
| 463 didSerialization = true; | 459 didSerialization = true; |
| 464 | 460 |
| 465 const WTF::TextEncoding& textEncoding = document->encoding().isValid() ?
document->encoding() : UTF8Encoding(); | 461 const WTF::TextEncoding& textEncoding = UTF8Encoding(); |
| 466 String directoryName = url == mainURL ? m_localDirectoryName : ""; | 462 String directoryName = url == mainURL ? m_localDirectoryName : ""; |
| 467 | 463 |
| 468 SerializeDomParam param(url, textEncoding, document, directoryName); | 464 SerializeDomParam param(url, textEncoding, document, directoryName); |
| 469 | 465 |
| 470 Element* documentElement = document->documentElement(); | 466 Element* documentElement = document->documentElement(); |
| 471 if (documentElement) | 467 if (documentElement) |
| 472 buildContentForNode(documentElement, ¶m); | 468 buildContentForNode(documentElement, ¶m); |
| 473 | 469 |
| 474 encodeAndFlushBuffer(WebPageSerializerClient::CurrentFrameIsFinished, &p
aram, ForceFlush); | 470 encodeAndFlushBuffer(WebPageSerializerClient::CurrentFrameIsFinished, &p
aram, ForceFlush); |
| 475 } | 471 } |
| 476 | 472 |
| 477 ASSERT(m_dataBuffer.isEmpty()); | 473 ASSERT(m_dataBuffer.isEmpty()); |
| 478 m_client->didSerializeDataForFrame(KURL(), WebCString("", 0), WebPageSeriali
zerClient::AllFramesAreFinished); | 474 m_client->didSerializeDataForFrame(KURL(), WebCString("", 0), WebPageSeriali
zerClient::AllFramesAreFinished); |
| 479 return didSerialization; | 475 return didSerialization; |
| 480 } | 476 } |
| 481 | 477 |
| 482 } // namespace blink | 478 } // namespace blink |
| OLD | NEW |