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

Side by Side Diff: third_party/WebKit/Source/core/frame/FrameSerializer.cpp

Issue 1541463002: Rename [Web]PageSerializer[Test|Client|Impl] to ...FrameSerializer... (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mhtml-deduplication-of-resources
Patch Set: Rebasing... Created 4 years, 11 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
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 10 matching lines...) Expand all
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "core/page/PageSerializer.h" 31 #include "core/frame/FrameSerializer.h"
32 32
33 #include "core/HTMLNames.h" 33 #include "core/HTMLNames.h"
34 #include "core/InputTypeNames.h" 34 #include "core/InputTypeNames.h"
35 #include "core/css/CSSFontFaceRule.h" 35 #include "core/css/CSSFontFaceRule.h"
36 #include "core/css/CSSFontFaceSrcValue.h" 36 #include "core/css/CSSFontFaceSrcValue.h"
37 #include "core/css/CSSImageValue.h" 37 #include "core/css/CSSImageValue.h"
38 #include "core/css/CSSImportRule.h" 38 #include "core/css/CSSImportRule.h"
39 #include "core/css/CSSRuleList.h" 39 #include "core/css/CSSRuleList.h"
40 #include "core/css/CSSStyleDeclaration.h" 40 #include "core/css/CSSStyleDeclaration.h"
41 #include "core/css/CSSStyleRule.h" 41 #include "core/css/CSSStyleRule.h"
42 #include "core/css/CSSValueList.h" 42 #include "core/css/CSSValueList.h"
43 #include "core/css/StylePropertySet.h" 43 #include "core/css/StylePropertySet.h"
44 #include "core/css/StyleRule.h" 44 #include "core/css/StyleRule.h"
45 #include "core/css/StyleSheetContents.h" 45 #include "core/css/StyleSheetContents.h"
46 #include "core/dom/Document.h" 46 #include "core/dom/Document.h"
47 #include "core/dom/Element.h" 47 #include "core/dom/Element.h"
48 #include "core/dom/Text.h" 48 #include "core/dom/Text.h"
49 #include "core/editing/serializers/MarkupAccumulator.h" 49 #include "core/editing/serializers/MarkupAccumulator.h"
50 #include "core/fetch/FontResource.h" 50 #include "core/fetch/FontResource.h"
51 #include "core/fetch/ImageResource.h" 51 #include "core/fetch/ImageResource.h"
52 #include "core/frame/LocalFrame.h" 52 #include "core/frame/LocalFrame.h"
53 #include "core/html/HTMLFrameElementBase.h" 53 #include "core/html/HTMLFrameElementBase.h"
54 #include "core/html/HTMLImageElement.h" 54 #include "core/html/HTMLImageElement.h"
55 #include "core/html/HTMLInputElement.h" 55 #include "core/html/HTMLInputElement.h"
56 #include "core/html/HTMLLinkElement.h" 56 #include "core/html/HTMLLinkElement.h"
57 #include "core/html/HTMLMetaElement.h" 57 #include "core/html/HTMLMetaElement.h"
58 #include "core/html/HTMLStyleElement.h" 58 #include "core/html/HTMLStyleElement.h"
59 #include "core/html/ImageDocument.h" 59 #include "core/html/ImageDocument.h"
60 #include "core/page/Page.h"
61 #include "core/style/StyleFetchedImage.h" 60 #include "core/style/StyleFetchedImage.h"
62 #include "core/style/StyleImage.h" 61 #include "core/style/StyleImage.h"
63 #include "platform/SerializedResource.h" 62 #include "platform/SerializedResource.h"
64 #include "platform/graphics/Image.h" 63 #include "platform/graphics/Image.h"
65 #include "platform/heap/Handle.h" 64 #include "platform/heap/Handle.h"
66 #include "wtf/HashSet.h" 65 #include "wtf/HashSet.h"
67 #include "wtf/OwnPtr.h" 66 #include "wtf/OwnPtr.h"
68 #include "wtf/text/CString.h" 67 #include "wtf/text/CString.h"
69 #include "wtf/text/StringBuilder.h" 68 #include "wtf/text/StringBuilder.h"
70 #include "wtf/text/TextEncoding.h" 69 #include "wtf/text/TextEncoding.h"
71 #include "wtf/text/WTFString.h" 70 #include "wtf/text/WTFString.h"
72 71
73 namespace blink { 72 namespace blink {
74 73
75 static bool shouldIgnoreElement(const Element& element) 74 static bool shouldIgnoreElement(const Element& element)
76 { 75 {
77 if (isHTMLScriptElement(element)) 76 if (isHTMLScriptElement(element))
78 return true; 77 return true;
79 if (isHTMLNoScriptElement(element)) 78 if (isHTMLNoScriptElement(element))
80 return true; 79 return true;
81 return isHTMLMetaElement(element) && toHTMLMetaElement(element).computeEncod ing().isValid(); 80 return isHTMLMetaElement(element) && toHTMLMetaElement(element).computeEncod ing().isValid();
82 } 81 }
83 82
84 class SerializerMarkupAccumulator : public MarkupAccumulator { 83 class SerializerMarkupAccumulator : public MarkupAccumulator {
85 STACK_ALLOCATED(); 84 STACK_ALLOCATED();
86 public: 85 public:
87 SerializerMarkupAccumulator(PageSerializer::Delegate&, const Document&, Will BeHeapVector<RawPtrWillBeMember<Node>>&); 86 SerializerMarkupAccumulator(FrameSerializer::Delegate&, const Document&, Wil lBeHeapVector<RawPtrWillBeMember<Node>>&);
88 ~SerializerMarkupAccumulator() override; 87 ~SerializerMarkupAccumulator() override;
89 88
90 protected: 89 protected:
91 void appendText(StringBuilder& out, Text&) override; 90 void appendText(StringBuilder& out, Text&) override;
92 bool shouldIgnoreAttribute(const Attribute&) override; 91 bool shouldIgnoreAttribute(const Attribute&) override;
93 void appendElement(StringBuilder& out, Element&, Namespaces*) override; 92 void appendElement(StringBuilder& out, Element&, Namespaces*) override;
94 void appendAttribute(StringBuilder& out, const Element&, const Attribute&, N amespaces*) override; 93 void appendAttribute(StringBuilder& out, const Element&, const Attribute&, N amespaces*) override;
95 void appendStartTag(Node&, Namespaces* = nullptr) override; 94 void appendStartTag(Node&, Namespaces* = nullptr) override;
96 void appendEndTag(const Element&) override; 95 void appendEndTag(const Element&) override;
97 96
98 private: 97 private:
99 void appendAttributeValue(StringBuilder& out, const String& attributeValue); 98 void appendAttributeValue(StringBuilder& out, const String& attributeValue);
100 void appendRewrittenAttribute( 99 void appendRewrittenAttribute(
101 StringBuilder& out, 100 StringBuilder& out,
102 const Element&, 101 const Element&,
103 const String& attributeName, 102 const String& attributeName,
104 const String& attributeValue); 103 const String& attributeValue);
105 104
106 PageSerializer::Delegate& m_delegate; 105 FrameSerializer::Delegate& m_delegate;
107 RawPtrWillBeMember<const Document> m_document; 106 RawPtrWillBeMember<const Document> m_document;
108 107
109 // FIXME: |PageSerializer| uses |m_nodes| for collecting nodes in document 108 // FIXME: |FrameSerializer| uses |m_nodes| for collecting nodes in document
110 // included into serialized text then extracts image, object, etc. The size 109 // included into serialized text then extracts image, object, etc. The size
111 // of this vector isn't small for large document. It is better to use 110 // of this vector isn't small for large document. It is better to use
112 // callback like functionality. 111 // callback like functionality.
113 WillBeHeapVector<RawPtrWillBeMember<Node>>& m_nodes; 112 WillBeHeapVector<RawPtrWillBeMember<Node>>& m_nodes;
114 113
115 // Elements with links rewritten via appendAttribute method. 114 // Elements with links rewritten via appendAttribute method.
116 WillBeHeapHashSet<RawPtrWillBeMember<const Element>> m_elementsWithRewritten Links; 115 WillBeHeapHashSet<RawPtrWillBeMember<const Element>> m_elementsWithRewritten Links;
117 }; 116 };
118 117
119 SerializerMarkupAccumulator::SerializerMarkupAccumulator(PageSerializer::Delegat e& delegate, const Document& document, WillBeHeapVector<RawPtrWillBeMember<Node> >& nodes) 118 SerializerMarkupAccumulator::SerializerMarkupAccumulator(FrameSerializer::Delega te& delegate, const Document& document, WillBeHeapVector<RawPtrWillBeMember<Node >>& nodes)
120 : MarkupAccumulator(ResolveAllURLs) 119 : MarkupAccumulator(ResolveAllURLs)
121 , m_delegate(delegate) 120 , m_delegate(delegate)
122 , m_document(&document) 121 , m_document(&document)
123 , m_nodes(nodes) 122 , m_nodes(nodes)
124 { 123 {
125 } 124 }
126 125
127 SerializerMarkupAccumulator::~SerializerMarkupAccumulator() 126 SerializerMarkupAccumulator::~SerializerMarkupAccumulator()
128 { 127 {
129 } 128 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 out.appendLiteral("\""); 232 out.appendLiteral("\"");
234 } 233 }
235 234
236 // TODO(tiger): Right now there is no support for rewriting URLs inside CSS 235 // TODO(tiger): Right now there is no support for rewriting URLs inside CSS
237 // documents which leads to bugs like <https://crbug.com/251898>. Not being 236 // documents which leads to bugs like <https://crbug.com/251898>. Not being
238 // able to rewrite URLs inside CSS documents means that resources imported from 237 // able to rewrite URLs inside CSS documents means that resources imported from
239 // url(...) statements in CSS might not work when rewriting links for the 238 // url(...) statements in CSS might not work when rewriting links for the
240 // "Webpage, Complete" method of saving a page. It will take some work but it 239 // "Webpage, Complete" method of saving a page. It will take some work but it
241 // needs to be done if we want to continue to support non-MHTML saved pages. 240 // needs to be done if we want to continue to support non-MHTML saved pages.
242 241
243 PageSerializer::PageSerializer( 242 FrameSerializer::FrameSerializer(
244 Vector<SerializedResource>& resources, 243 Vector<SerializedResource>& resources,
245 Delegate& delegate) 244 Delegate& delegate)
246 : m_resources(&resources) 245 : m_resources(&resources)
247 , m_delegate(delegate) 246 , m_delegate(delegate)
248 { 247 {
249 } 248 }
250 249
251 void PageSerializer::serializeFrame(const LocalFrame& frame) 250 void FrameSerializer::serializeFrame(const LocalFrame& frame)
252 { 251 {
253 ASSERT(frame.document()); 252 ASSERT(frame.document());
254 Document& document = *frame.document(); 253 Document& document = *frame.document();
255 KURL url = document.url(); 254 KURL url = document.url();
256 255
257 // If frame is an image document, add the image and don't continue 256 // If frame is an image document, add the image and don't continue
258 if (document.isImageDocument()) { 257 if (document.isImageDocument()) {
259 ImageDocument& imageDocument = toImageDocument(document); 258 ImageDocument& imageDocument = toImageDocument(document);
260 addImageToResources(imageDocument.cachedImage(), url); 259 addImageToResources(imageDocument.cachedImage(), url);
261 return; 260 return;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 serializeCSSStyleSheet(*sheet, url); 298 serializeCSSStyleSheet(*sheet, url);
300 } 299 }
301 } else if (isHTMLStyleElement(element)) { 300 } else if (isHTMLStyleElement(element)) {
302 HTMLStyleElement& styleElement = toHTMLStyleElement(element); 301 HTMLStyleElement& styleElement = toHTMLStyleElement(element);
303 if (CSSStyleSheet* sheet = styleElement.sheet()) 302 if (CSSStyleSheet* sheet = styleElement.sheet())
304 serializeCSSStyleSheet(*sheet, KURL()); 303 serializeCSSStyleSheet(*sheet, KURL());
305 } 304 }
306 } 305 }
307 } 306 }
308 307
309 void PageSerializer::serializeCSSStyleSheet(CSSStyleSheet& styleSheet, const KUR L& url) 308 void FrameSerializer::serializeCSSStyleSheet(CSSStyleSheet& styleSheet, const KU RL& url)
310 { 309 {
311 StringBuilder cssText; 310 StringBuilder cssText;
312 cssText.appendLiteral("@charset \""); 311 cssText.appendLiteral("@charset \"");
313 cssText.append(styleSheet.contents()->charset().lower()); 312 cssText.append(styleSheet.contents()->charset().lower());
314 cssText.appendLiteral("\";\n\n"); 313 cssText.appendLiteral("\";\n\n");
315 314
316 for (unsigned i = 0; i < styleSheet.length(); ++i) { 315 for (unsigned i = 0; i < styleSheet.length(); ++i) {
317 CSSRule* rule = styleSheet.item(i); 316 CSSRule* rule = styleSheet.item(i);
318 String itemText = rule->cssText(); 317 String itemText = rule->cssText();
319 if (!itemText.isEmpty()) { 318 if (!itemText.isEmpty()) {
320 cssText.append(itemText); 319 cssText.append(itemText);
321 if (i < styleSheet.length() - 1) 320 if (i < styleSheet.length() - 1)
322 cssText.appendLiteral("\n\n"); 321 cssText.appendLiteral("\n\n");
323 } 322 }
324 323
325 // Some rules have resources associated with them that we need to retrie ve. 324 // Some rules have resources associated with them that we need to retrie ve.
326 serializeCSSRule(rule); 325 serializeCSSRule(rule);
327 } 326 }
328 327
329 if (shouldAddURL(url)) { 328 if (shouldAddURL(url)) {
330 WTF::TextEncoding textEncoding(styleSheet.contents()->charset()); 329 WTF::TextEncoding textEncoding(styleSheet.contents()->charset());
331 ASSERT(textEncoding.isValid()); 330 ASSERT(textEncoding.isValid());
332 String textString = cssText.toString(); 331 String textString = cssText.toString();
333 CString text = textEncoding.encode(textString, WTF::EntitiesForUnencodab les); 332 CString text = textEncoding.encode(textString, WTF::EntitiesForUnencodab les);
334 m_resources->append(SerializedResource(url, String("text/css"), SharedBu ffer::create(text.data(), text.length()))); 333 m_resources->append(SerializedResource(url, String("text/css"), SharedBu ffer::create(text.data(), text.length())));
335 m_resourceURLs.add(url); 334 m_resourceURLs.add(url);
336 } 335 }
337 } 336 }
338 337
339 void PageSerializer::serializeCSSRule(CSSRule* rule) 338 void FrameSerializer::serializeCSSRule(CSSRule* rule)
340 { 339 {
341 ASSERT(rule->parentStyleSheet()->ownerDocument()); 340 ASSERT(rule->parentStyleSheet()->ownerDocument());
342 Document& document = *rule->parentStyleSheet()->ownerDocument(); 341 Document& document = *rule->parentStyleSheet()->ownerDocument();
343 342
344 switch (rule->type()) { 343 switch (rule->type()) {
345 case CSSRule::STYLE_RULE: 344 case CSSRule::STYLE_RULE:
346 retrieveResourcesForProperties(&toCSSStyleRule(rule)->styleRule()->prope rties(), document); 345 retrieveResourcesForProperties(&toCSSStyleRule(rule)->styleRule()->prope rties(), document);
347 break; 346 break;
348 347
349 case CSSRule::IMPORT_RULE: { 348 case CSSRule::IMPORT_RULE: {
(...skipping 27 matching lines...) Expand all
377 case CSSRule::KEYFRAMES_RULE: 376 case CSSRule::KEYFRAMES_RULE:
378 case CSSRule::KEYFRAME_RULE: 377 case CSSRule::KEYFRAME_RULE:
379 case CSSRule::VIEWPORT_RULE: 378 case CSSRule::VIEWPORT_RULE:
380 break; 379 break;
381 380
382 default: 381 default:
383 ASSERT_NOT_REACHED(); 382 ASSERT_NOT_REACHED();
384 } 383 }
385 } 384 }
386 385
387 bool PageSerializer::shouldAddURL(const KURL& url) 386 bool FrameSerializer::shouldAddURL(const KURL& url)
388 { 387 {
389 return url.isValid() && !m_resourceURLs.contains(url) && !url.protocolIsData () 388 return url.isValid() && !m_resourceURLs.contains(url) && !url.protocolIsData ()
390 && !m_delegate.shouldSkipResource(url); 389 && !m_delegate.shouldSkipResource(url);
391 } 390 }
392 391
393 void PageSerializer::addToResources(Resource* resource, PassRefPtr<SharedBuffer> data, const KURL& url) 392 void FrameSerializer::addToResources(Resource* resource, PassRefPtr<SharedBuffer > data, const KURL& url)
394 { 393 {
395 if (!data) { 394 if (!data) {
396 WTF_LOG_ERROR("No data for resource %s", url.string().utf8().data()); 395 WTF_LOG_ERROR("No data for resource %s", url.string().utf8().data());
397 return; 396 return;
398 } 397 }
399 398
400 String mimeType = resource->response().mimeType(); 399 String mimeType = resource->response().mimeType();
401 m_resources->append(SerializedResource(url, mimeType, data)); 400 m_resources->append(SerializedResource(url, mimeType, data));
402 m_resourceURLs.add(url); 401 m_resourceURLs.add(url);
403 } 402 }
404 403
405 void PageSerializer::addImageToResources(ImageResource* image, const KURL& url) 404 void FrameSerializer::addImageToResources(ImageResource* image, const KURL& url)
406 { 405 {
407 if (!shouldAddURL(url)) 406 if (!shouldAddURL(url))
408 return; 407 return;
409 408
410 if (!image || !image->hasImage() || image->errorOccurred()) 409 if (!image || !image->hasImage() || image->errorOccurred())
411 return; 410 return;
412 411
413 RefPtr<SharedBuffer> data = image->image()->data(); 412 RefPtr<SharedBuffer> data = image->image()->data();
414 addToResources(image, data, url); 413 addToResources(image, data, url);
415 } 414 }
416 415
417 void PageSerializer::addFontToResources(FontResource* font) 416 void FrameSerializer::addFontToResources(FontResource* font)
418 { 417 {
419 if (!font || !shouldAddURL(font->url()) || !font->isLoaded() || !font->resou rceBuffer()) 418 if (!font || !shouldAddURL(font->url()) || !font->isLoaded() || !font->resou rceBuffer())
420 return; 419 return;
421 420
422 RefPtr<SharedBuffer> data(font->resourceBuffer()); 421 RefPtr<SharedBuffer> data(font->resourceBuffer());
423 422
424 addToResources(font, data, font->url()); 423 addToResources(font, data, font->url());
425 } 424 }
426 425
427 void PageSerializer::retrieveResourcesForProperties(const StylePropertySet* styl eDeclaration, Document& document) 426 void FrameSerializer::retrieveResourcesForProperties(const StylePropertySet* sty leDeclaration, Document& document)
428 { 427 {
429 if (!styleDeclaration) 428 if (!styleDeclaration)
430 return; 429 return;
431 430
432 // The background-image and list-style-image (for ul or ol) are the CSS prop erties 431 // The background-image and list-style-image (for ul or ol) are the CSS prop erties
433 // that make use of images. We iterate to make sure we include any other 432 // that make use of images. We iterate to make sure we include any other
434 // image properties there might be. 433 // image properties there might be.
435 unsigned propertyCount = styleDeclaration->propertyCount(); 434 unsigned propertyCount = styleDeclaration->propertyCount();
436 for (unsigned i = 0; i < propertyCount; ++i) { 435 for (unsigned i = 0; i < propertyCount; ++i) {
437 RefPtrWillBeRawPtr<CSSValue> cssValue = styleDeclaration->propertyAt(i). value(); 436 RefPtrWillBeRawPtr<CSSValue> cssValue = styleDeclaration->propertyAt(i). value();
438 retrieveResourcesForCSSValue(cssValue.get(), document); 437 retrieveResourcesForCSSValue(cssValue.get(), document);
439 } 438 }
440 } 439 }
441 440
442 void PageSerializer::retrieveResourcesForCSSValue(CSSValue* cssValue, Document& document) 441 void FrameSerializer::retrieveResourcesForCSSValue(CSSValue* cssValue, Document& document)
443 { 442 {
444 if (cssValue->isImageValue()) { 443 if (cssValue->isImageValue()) {
445 CSSImageValue* imageValue = toCSSImageValue(cssValue); 444 CSSImageValue* imageValue = toCSSImageValue(cssValue);
446 if (imageValue->isCachePending()) 445 if (imageValue->isCachePending())
447 return; 446 return;
448 StyleImage* styleImage = imageValue->cachedImage(); 447 StyleImage* styleImage = imageValue->cachedImage();
449 if (!styleImage || !styleImage->isImageResource()) 448 if (!styleImage || !styleImage->isImageResource())
450 return; 449 return;
451 450
452 addImageToResources(styleImage->cachedImage(), styleImage->cachedImage() ->url()); 451 addImageToResources(styleImage->cachedImage(), styleImage->cachedImage() ->url());
453 } else if (cssValue->isFontFaceSrcValue()) { 452 } else if (cssValue->isFontFaceSrcValue()) {
454 CSSFontFaceSrcValue* fontFaceSrcValue = toCSSFontFaceSrcValue(cssValue); 453 CSSFontFaceSrcValue* fontFaceSrcValue = toCSSFontFaceSrcValue(cssValue);
455 if (fontFaceSrcValue->isLocal()) { 454 if (fontFaceSrcValue->isLocal()) {
456 return; 455 return;
457 } 456 }
458 457
459 addFontToResources(fontFaceSrcValue->fetch(&document)); 458 addFontToResources(fontFaceSrcValue->fetch(&document));
460 } else if (cssValue->isValueList()) { 459 } else if (cssValue->isValueList()) {
461 CSSValueList* cssValueList = toCSSValueList(cssValue); 460 CSSValueList* cssValueList = toCSSValueList(cssValue);
462 for (unsigned i = 0; i < cssValueList->length(); i++) 461 for (unsigned i = 0; i < cssValueList->length(); i++)
463 retrieveResourcesForCSSValue(cssValueList->item(i), document); 462 retrieveResourcesForCSSValue(cssValueList->item(i), document);
464 } 463 }
465 } 464 }
466 465
467 // Returns MOTW (Mark of the Web) declaration before html tag which is in 466 // Returns MOTW (Mark of the Web) declaration before html tag which is in
468 // HTML comment, e.g. "<!-- saved from url=(%04d)%s -->" 467 // HTML comment, e.g. "<!-- saved from url=(%04d)%s -->"
469 // See http://msdn2.microsoft.com/en-us/library/ms537628(VS.85).aspx. 468 // See http://msdn2.microsoft.com/en-us/library/ms537628(VS.85).aspx.
470 String PageSerializer::markOfTheWebDeclaration(const KURL& url) 469 String FrameSerializer::markOfTheWebDeclaration(const KURL& url)
471 { 470 {
472 StringBuilder builder; 471 StringBuilder builder;
473 bool emitsMinus = false; 472 bool emitsMinus = false;
474 CString orignalUrl = url.string().ascii(); 473 CString orignalUrl = url.string().ascii();
475 for (const char* string = orignalUrl.data(); *string; ++string) { 474 for (const char* string = orignalUrl.data(); *string; ++string) {
476 const char ch = *string; 475 const char ch = *string;
477 if (ch == '-' && emitsMinus) { 476 if (ch == '-' && emitsMinus) {
478 builder.append("%2D"); 477 builder.append("%2D");
479 emitsMinus = false; 478 emitsMinus = false;
480 continue; 479 continue;
481 } 480 }
482 emitsMinus = ch == '-'; 481 emitsMinus = ch == '-';
483 builder.append(ch); 482 builder.append(ch);
484 } 483 }
485 CString escapedUrl = builder.toString().ascii(); 484 CString escapedUrl = builder.toString().ascii();
486 return String::format("saved from url=(%04d)%s", static_cast<int>(escapedUrl .length()), escapedUrl.data()); 485 return String::format("saved from url=(%04d)%s", static_cast<int>(escapedUrl .length()), escapedUrl.data());
487 } 486 }
488 487
489 } // namespace blink 488 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/FrameSerializer.h ('k') | third_party/WebKit/Source/core/page/PageSerializer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698