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 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 // 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 |
432 // 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 |
433 // image properties there might be. | 433 // image properties there might be. |
434 unsigned propertyCount = styleDeclaration->propertyCount(); | 434 unsigned propertyCount = styleDeclaration->propertyCount(); |
435 for (unsigned i = 0; i < propertyCount; ++i) { | 435 for (unsigned i = 0; i < propertyCount; ++i) { |
436 CSSValue* cssValue = styleDeclaration->propertyAt(i).value(); | 436 CSSValue* cssValue = styleDeclaration->propertyAt(i).value(); |
437 retrieveResourcesForCSSValue(cssValue, document); | 437 retrieveResourcesForCSSValue(cssValue, document); |
438 } | 438 } |
439 } | 439 } |
440 | 440 |
441 void FrameSerializer::retrieveResourcesForCSSValue(CSSValue* cssValue, Document&
document) | 441 void FrameSerializer::retrieveResourcesForCSSValue(const CSSValue* cssValue, Doc
ument& document) |
442 { | 442 { |
443 if (cssValue->isImageValue()) { | 443 if (cssValue->isImageValue()) { |
444 CSSImageValue* imageValue = toCSSImageValue(cssValue); | 444 const CSSImageValue* imageValue = toCSSImageValue(cssValue); |
445 if (imageValue->isCachePending()) | 445 if (imageValue->isCachePending()) |
446 return; | 446 return; |
447 StyleImage* styleImage = imageValue->cachedImage(); | 447 StyleImage* styleImage = imageValue->cachedImage(); |
448 if (!styleImage || !styleImage->isImageResource()) | 448 if (!styleImage || !styleImage->isImageResource()) |
449 return; | 449 return; |
450 | 450 |
451 addImageToResources(styleImage->cachedImage(), styleImage->cachedImage()
->url()); | 451 addImageToResources(styleImage->cachedImage(), styleImage->cachedImage()
->url()); |
452 } else if (cssValue->isFontFaceSrcValue()) { | 452 } else if (cssValue->isFontFaceSrcValue()) { |
453 CSSFontFaceSrcValue* fontFaceSrcValue = toCSSFontFaceSrcValue(cssValue); | 453 const CSSFontFaceSrcValue* fontFaceSrcValue = toCSSFontFaceSrcValue(cssV
alue); |
454 if (fontFaceSrcValue->isLocal()) { | 454 if (fontFaceSrcValue->isLocal()) { |
455 return; | 455 return; |
456 } | 456 } |
457 | 457 |
458 addFontToResources(fontFaceSrcValue->fetch(&document)); | 458 addFontToResources(fontFaceSrcValue->fetch(&document)); |
459 } else if (cssValue->isValueList()) { | 459 } else if (cssValue->isValueList()) { |
460 CSSValueList* cssValueList = toCSSValueList(cssValue); | 460 const CSSValueList* cssValueList = toCSSValueList(cssValue); |
461 for (unsigned i = 0; i < cssValueList->length(); i++) | 461 for (unsigned i = 0; i < cssValueList->length(); i++) |
462 retrieveResourcesForCSSValue(cssValueList->item(i), document); | 462 retrieveResourcesForCSSValue(cssValueList->item(i), document); |
463 } | 463 } |
464 } | 464 } |
465 | 465 |
466 // 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 |
467 // HTML comment, e.g. "<!-- saved from url=(%04d)%s -->" | 467 // HTML comment, e.g. "<!-- saved from url=(%04d)%s -->" |
468 // 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. |
469 String FrameSerializer::markOfTheWebDeclaration(const KURL& url) | 469 String FrameSerializer::markOfTheWebDeclaration(const KURL& url) |
470 { | 470 { |
471 StringBuilder builder; | 471 StringBuilder builder; |
472 bool emitsMinus = false; | 472 bool emitsMinus = false; |
473 CString orignalUrl = url.getString().ascii(); | 473 CString orignalUrl = url.getString().ascii(); |
474 for (const char* string = orignalUrl.data(); *string; ++string) { | 474 for (const char* string = orignalUrl.data(); *string; ++string) { |
475 const char ch = *string; | 475 const char ch = *string; |
476 if (ch == '-' && emitsMinus) { | 476 if (ch == '-' && emitsMinus) { |
477 builder.append("%2D"); | 477 builder.append("%2D"); |
478 emitsMinus = false; | 478 emitsMinus = false; |
479 continue; | 479 continue; |
480 } | 480 } |
481 emitsMinus = ch == '-'; | 481 emitsMinus = ch == '-'; |
482 builder.append(ch); | 482 builder.append(ch); |
483 } | 483 } |
484 CString escapedUrl = builder.toString().ascii(); | 484 CString escapedUrl = builder.toString().ascii(); |
485 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()); |
486 } | 486 } |
487 | 487 |
488 } // namespace blink | 488 } // namespace blink |
OLD | NEW |