Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(283)

Side by Side Diff: Source/core/page/PageSerializer.cpp

Issue 299353004: Oilpan: move editing objects to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Make test wrapper class finalized Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/page/Page.cpp ('k') | Source/core/xml/XMLSerializer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 } 94 }
95 95
96 static const QualifiedName& frameOwnerURLAttributeName(const HTMLFrameOwnerEleme nt& frameOwner) 96 static const QualifiedName& frameOwnerURLAttributeName(const HTMLFrameOwnerEleme nt& frameOwner)
97 { 97 {
98 // FIXME: We should support all frame owners including applets. 98 // FIXME: We should support all frame owners including applets.
99 return isHTMLObjectElement(frameOwner) ? HTMLNames::dataAttr : HTMLNames::sr cAttr; 99 return isHTMLObjectElement(frameOwner) ? HTMLNames::dataAttr : HTMLNames::sr cAttr;
100 } 100 }
101 101
102 class SerializerMarkupAccumulator FINAL : public MarkupAccumulator { 102 class SerializerMarkupAccumulator FINAL : public MarkupAccumulator {
103 public: 103 public:
104 SerializerMarkupAccumulator(PageSerializer*, const Document&, Vector<Node*>* ); 104 SerializerMarkupAccumulator(PageSerializer*, const Document&, WillBeHeapVect or<RawPtrWillBeMember<Node> >*);
105 virtual ~SerializerMarkupAccumulator(); 105 virtual ~SerializerMarkupAccumulator();
106 106
107 protected: 107 protected:
108 virtual void appendText(StringBuilder& out, Text&) OVERRIDE; 108 virtual void appendText(StringBuilder& out, Text&) OVERRIDE;
109 virtual void appendElement(StringBuilder& out, Element&, Namespaces*) OVERRI DE; 109 virtual void appendElement(StringBuilder& out, Element&, Namespaces*) OVERRI DE;
110 virtual void appendCustomAttributes(StringBuilder& out, const Element&, Name spaces*) OVERRIDE; 110 virtual void appendCustomAttributes(StringBuilder& out, const Element&, Name spaces*) OVERRIDE;
111 virtual void appendEndTag(const Node&) OVERRIDE; 111 virtual void appendEndTag(const Node&) OVERRIDE;
112 112
113 private: 113 private:
114 PageSerializer* m_serializer; 114 PageSerializer* m_serializer;
115 const Document& m_document; 115 const Document& m_document;
116 }; 116 };
117 117
118 SerializerMarkupAccumulator::SerializerMarkupAccumulator(PageSerializer* seriali zer, const Document& document, Vector<Node*>* nodes) 118 SerializerMarkupAccumulator::SerializerMarkupAccumulator(PageSerializer* seriali zer, const Document& document, WillBeHeapVector<RawPtrWillBeMember<Node> >* node s)
119 : MarkupAccumulator(nodes, ResolveAllURLs) 119 : MarkupAccumulator(nodes, ResolveAllURLs, nullptr)
120 , m_serializer(serializer) 120 , m_serializer(serializer)
121 , m_document(document) 121 , m_document(document)
122 { 122 {
123 } 123 }
124 124
125 SerializerMarkupAccumulator::~SerializerMarkupAccumulator() 125 SerializerMarkupAccumulator::~SerializerMarkupAccumulator()
126 { 126 {
127 } 127 }
128 128
129 void SerializerMarkupAccumulator::appendText(StringBuilder& out, Text& text) 129 void SerializerMarkupAccumulator::appendText(StringBuilder& out, Text& text)
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 // frame. Arg! 201 // frame. Arg!
202 return; 202 return;
203 } 203 }
204 204
205 WTF::TextEncoding textEncoding(document.charset()); 205 WTF::TextEncoding textEncoding(document.charset());
206 if (!textEncoding.isValid()) { 206 if (!textEncoding.isValid()) {
207 // FIXME: iframes used as images trigger this. We should deal with them correctly. 207 // FIXME: iframes used as images trigger this. We should deal with them correctly.
208 return; 208 return;
209 } 209 }
210 210
211 Vector<Node*> serializedNodes; 211 WillBeHeapVector<RawPtrWillBeMember<Node> > serializedNodes;
212 SerializerMarkupAccumulator accumulator(this, document, &serializedNodes); 212 SerializerMarkupAccumulator accumulator(this, document, &serializedNodes);
213 String text = accumulator.serializeNodes(document, IncludeNode); 213 String text = accumulator.serializeNodes(document, IncludeNode);
214 CString frameHTML = textEncoding.normalizeAndEncode(text, WTF::EntitiesForUn encodables); 214 CString frameHTML = textEncoding.normalizeAndEncode(text, WTF::EntitiesForUn encodables);
215 m_resources->append(SerializedResource(url, document.suggestedMIMEType(), Sh aredBuffer::create(frameHTML.data(), frameHTML.length()))); 215 m_resources->append(SerializedResource(url, document.suggestedMIMEType(), Sh aredBuffer::create(frameHTML.data(), frameHTML.length())));
216 m_resourceURLs.add(url); 216 m_resourceURLs.add(url);
217 217
218 for (Vector<Node*>::iterator iter = serializedNodes.begin(); iter != seriali zedNodes.end(); ++iter) { 218 for (WillBeHeapVector<RawPtrWillBeMember<Node> >::iterator iter = serialized Nodes.begin(); iter != serializedNodes.end(); ++iter) {
219 ASSERT(*iter); 219 ASSERT(*iter);
220 Node& node = **iter; 220 Node& node = **iter;
221 if (!node.isElementNode()) 221 if (!node.isElementNode())
222 continue; 222 continue;
223 223
224 Element& element = toElement(node); 224 Element& element = toElement(node);
225 // We have to process in-line style as it might contain some resources ( typically background images). 225 // We have to process in-line style as it might contain some resources ( typically background images).
226 if (element.isStyledElement()) 226 if (element.isStyledElement())
227 retrieveResourcesForProperties(element.inlineStyle(), document); 227 retrieveResourcesForProperties(element.inlineStyle(), document);
228 228
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 if (iter != m_blankFrameURLs.end()) 381 if (iter != m_blankFrameURLs.end())
382 return iter->value; 382 return iter->value;
383 String url = "wyciwyg://frame/" + String::number(m_blankFrameCounter++); 383 String url = "wyciwyg://frame/" + String::number(m_blankFrameCounter++);
384 KURL fakeURL(ParsedURLString, url); 384 KURL fakeURL(ParsedURLString, url);
385 m_blankFrameURLs.add(frame, fakeURL); 385 m_blankFrameURLs.add(frame, fakeURL);
386 386
387 return fakeURL; 387 return fakeURL;
388 } 388 }
389 389
390 } 390 }
OLDNEW
« no previous file with comments | « Source/core/page/Page.cpp ('k') | Source/core/xml/XMLSerializer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698