| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 private: | 108 private: |
| 109 PageSerializer* m_serializer; | 109 PageSerializer* m_serializer; |
| 110 Document* m_document; | 110 Document* m_document; |
| 111 }; | 111 }; |
| 112 | 112 |
| 113 SerializerMarkupAccumulator::SerializerMarkupAccumulator(PageSerializer* seriali
zer, Document* document, Vector<Node*>* nodes) | 113 SerializerMarkupAccumulator::SerializerMarkupAccumulator(PageSerializer* seriali
zer, Document* document, Vector<Node*>* nodes) |
| 114 : MarkupAccumulator(nodes, ResolveAllURLs) | 114 : MarkupAccumulator(nodes, ResolveAllURLs) |
| 115 , m_serializer(serializer) | 115 , m_serializer(serializer) |
| 116 , m_document(document) | 116 , m_document(document) |
| 117 { | 117 { |
| 118 // MarkupAccumulator does not serialize the <?xml ... line, so we add it exp
licitely to ensure the right encoding is specified. | |
| 119 if (m_document->isXHTMLDocument() || m_document->xmlStandalone() || m_docume
nt->isSVGDocument()) | |
| 120 appendString("<?xml version=\"" + m_document->xmlVersion() + "\" encodin
g=\"" + m_document->charset() + "\"?>"); | |
| 121 } | 118 } |
| 122 | 119 |
| 123 SerializerMarkupAccumulator::~SerializerMarkupAccumulator() | 120 SerializerMarkupAccumulator::~SerializerMarkupAccumulator() |
| 124 { | 121 { |
| 125 } | 122 } |
| 126 | 123 |
| 127 void SerializerMarkupAccumulator::appendText(StringBuilder& out, Text* text) | 124 void SerializerMarkupAccumulator::appendText(StringBuilder& out, Text* text) |
| 128 { | 125 { |
| 129 Element* parent = text->parentElement(); | 126 Element* parent = text->parentElement(); |
| 130 if (parent && !shouldIgnoreElement(parent)) | 127 if (parent && !shouldIgnoreElement(parent)) |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 } | 195 } |
| 199 | 196 |
| 200 Vector<Node*> nodes; | 197 Vector<Node*> nodes; |
| 201 SerializerMarkupAccumulator accumulator(this, document, &nodes); | 198 SerializerMarkupAccumulator accumulator(this, document, &nodes); |
| 202 WTF::TextEncoding textEncoding(document->charset()); | 199 WTF::TextEncoding textEncoding(document->charset()); |
| 203 CString data; | 200 CString data; |
| 204 if (!textEncoding.isValid()) { | 201 if (!textEncoding.isValid()) { |
| 205 // FIXME: iframes used as images trigger this. We should deal with them
correctly. | 202 // FIXME: iframes used as images trigger this. We should deal with them
correctly. |
| 206 return; | 203 return; |
| 207 } | 204 } |
| 208 String text = accumulator.serializeNodes(document->documentElement(), Includ
eNode); | 205 String text = accumulator.serializeNodes(document, IncludeNode); |
| 209 CString frameHTML = textEncoding.normalizeAndEncode(text, WTF::EntitiesForUn
encodables); | 206 CString frameHTML = textEncoding.normalizeAndEncode(text, WTF::EntitiesForUn
encodables); |
| 210 m_resources->append(SerializedResource(url, document->suggestedMIMEType(), S
haredBuffer::create(frameHTML.data(), frameHTML.length()))); | 207 m_resources->append(SerializedResource(url, document->suggestedMIMEType(), S
haredBuffer::create(frameHTML.data(), frameHTML.length()))); |
| 211 m_resourceURLs.add(url); | 208 m_resourceURLs.add(url); |
| 212 | 209 |
| 213 for (Vector<Node*>::iterator iter = nodes.begin(); iter != nodes.end(); ++it
er) { | 210 for (Vector<Node*>::iterator iter = nodes.begin(); iter != nodes.end(); ++it
er) { |
| 214 Node* node = *iter; | 211 Node* node = *iter; |
| 215 if (!node->isElementNode()) | 212 if (!node->isElementNode()) |
| 216 continue; | 213 continue; |
| 217 | 214 |
| 218 Element* element = toElement(node); | 215 Element* element = toElement(node); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 if (iter != m_blankFrameURLs.end()) | 343 if (iter != m_blankFrameURLs.end()) |
| 347 return iter->value; | 344 return iter->value; |
| 348 String url = "wyciwyg://frame/" + String::number(m_blankFrameCounter++); | 345 String url = "wyciwyg://frame/" + String::number(m_blankFrameCounter++); |
| 349 KURL fakeURL(ParsedURLString, url); | 346 KURL fakeURL(ParsedURLString, url); |
| 350 m_blankFrameURLs.add(frame, fakeURL); | 347 m_blankFrameURLs.add(frame, fakeURL); |
| 351 | 348 |
| 352 return fakeURL; | 349 return fakeURL; |
| 353 } | 350 } |
| 354 | 351 |
| 355 } | 352 } |
| OLD | NEW |