| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 #include "core/rendering/style/StyleImage.h" | 61 #include "core/rendering/style/StyleImage.h" |
| 62 #include "platform/SerializedResource.h" | 62 #include "platform/SerializedResource.h" |
| 63 #include "platform/graphics/Image.h" | 63 #include "platform/graphics/Image.h" |
| 64 #include "wtf/text/CString.h" | 64 #include "wtf/text/CString.h" |
| 65 #include "wtf/text/StringBuilder.h" | 65 #include "wtf/text/StringBuilder.h" |
| 66 #include "wtf/text/TextEncoding.h" | 66 #include "wtf/text/TextEncoding.h" |
| 67 #include "wtf/text/WTFString.h" | 67 #include "wtf/text/WTFString.h" |
| 68 | 68 |
| 69 namespace WebCore { | 69 namespace WebCore { |
| 70 | 70 |
| 71 static bool isCharsetSpecifyingNode(Node* node) | 71 static bool isCharsetSpecifyingNode(const Node& node) |
| 72 { | 72 { |
| 73 if (!node->isHTMLElement()) | 73 if (!node.isHTMLElement()) |
| 74 return false; | 74 return false; |
| 75 | 75 |
| 76 HTMLElement* element = toHTMLElement(node); | 76 const HTMLElement& element = toHTMLElement(node); |
| 77 if (!element->hasTagName(HTMLNames::metaTag)) | 77 if (!element.hasTagName(HTMLNames::metaTag)) |
| 78 return false; | 78 return false; |
| 79 HTMLAttributeList attributes; | 79 HTMLAttributeList attributes; |
| 80 if (element->hasAttributes()) { | 80 if (element.hasAttributes()) { |
| 81 for (unsigned i = 0; i < element->attributeCount(); ++i) { | 81 for (unsigned i = 0; i < element.attributeCount(); ++i) { |
| 82 const Attribute* attribute = element->attributeItem(i); | 82 const Attribute* attribute = element.attributeItem(i); |
| 83 // FIXME: We should deal appropriately with the attribute if they ha
ve a namespace. | 83 // FIXME: We should deal appropriately with the attribute if they ha
ve a namespace. |
| 84 attributes.append(std::make_pair(attribute->name().localName(), attr
ibute->value().string())); | 84 attributes.append(std::make_pair(attribute->name().localName(), attr
ibute->value().string())); |
| 85 } | 85 } |
| 86 } | 86 } |
| 87 WTF::TextEncoding textEncoding = encodingFromMetaAttributes(attributes); | 87 WTF::TextEncoding textEncoding = encodingFromMetaAttributes(attributes); |
| 88 return textEncoding.isValid(); | 88 return textEncoding.isValid(); |
| 89 } | 89 } |
| 90 | 90 |
| 91 static bool shouldIgnoreElement(Element* element) | 91 static bool shouldIgnoreElement(const Element& element) |
| 92 { | 92 { |
| 93 return element->hasTagName(HTMLNames::scriptTag) || element->hasTagName(HTML
Names::noscriptTag) || isCharsetSpecifyingNode(element); | 93 return element.hasTagName(HTMLNames::scriptTag) || element.hasTagName(HTMLNa
mes::noscriptTag) || isCharsetSpecifyingNode(element); |
| 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 frameOwner.hasTagName(HTMLNames::objectTag) ? HTMLNames::dataAttr : H
TMLNames::srcAttr; | 99 return frameOwner.hasTagName(HTMLNames::objectTag) ? HTMLNames::dataAttr : H
TMLNames::srcAttr; |
| 100 } | 100 } |
| 101 | 101 |
| 102 class SerializerMarkupAccumulator FINAL : public MarkupAccumulator { | 102 class SerializerMarkupAccumulator FINAL : public MarkupAccumulator { |
| 103 public: | 103 public: |
| 104 SerializerMarkupAccumulator(PageSerializer*, Document*, Vector<Node*>*); | 104 SerializerMarkupAccumulator(PageSerializer*, const Document&, Vector<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, Element*, Namespaces
*) OVERRIDE; | 110 virtual void appendCustomAttributes(StringBuilder& out, const Element&, Name
spaces*) OVERRIDE; |
| 111 virtual void appendEndTag(Node*) OVERRIDE; | 111 virtual void appendEndTag(const Node&) OVERRIDE; |
| 112 | 112 |
| 113 private: | 113 private: |
| 114 PageSerializer* m_serializer; | 114 PageSerializer* m_serializer; |
| 115 Document* m_document; | 115 const Document& m_document; |
| 116 }; | 116 }; |
| 117 | 117 |
| 118 SerializerMarkupAccumulator::SerializerMarkupAccumulator(PageSerializer* seriali
zer, Document* document, Vector<Node*>* nodes) | 118 SerializerMarkupAccumulator::SerializerMarkupAccumulator(PageSerializer* seriali
zer, const Document& document, Vector<Node*>* nodes) |
| 119 : MarkupAccumulator(nodes, ResolveAllURLs) | 119 : MarkupAccumulator(nodes, ResolveAllURLs) |
| 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) |
| 130 { | 130 { |
| 131 Element* parent = text->parentElement(); | 131 Element* parent = text.parentElement(); |
| 132 if (parent && !shouldIgnoreElement(parent)) | 132 if (parent && !shouldIgnoreElement(*parent)) |
| 133 MarkupAccumulator::appendText(out, text); | 133 MarkupAccumulator::appendText(out, text); |
| 134 } | 134 } |
| 135 | 135 |
| 136 void SerializerMarkupAccumulator::appendElement(StringBuilder& out, Element* ele
ment, Namespaces* namespaces) | 136 void SerializerMarkupAccumulator::appendElement(StringBuilder& out, Element& ele
ment, Namespaces* namespaces) |
| 137 { | 137 { |
| 138 if (!shouldIgnoreElement(element)) | 138 if (!shouldIgnoreElement(element)) |
| 139 MarkupAccumulator::appendElement(out, element, namespaces); | 139 MarkupAccumulator::appendElement(out, element, namespaces); |
| 140 | 140 |
| 141 if (element->hasTagName(HTMLNames::headTag)) { | 141 if (element.hasTagName(HTMLNames::headTag)) { |
| 142 out.append("<meta charset=\""); | 142 out.append("<meta charset=\""); |
| 143 out.append(m_document->charset()); | 143 out.append(m_document.charset()); |
| 144 out.append("\">"); | 144 out.append("\">"); |
| 145 } | 145 } |
| 146 | 146 |
| 147 // FIXME: For object (plugins) tags and video tag we could replace them by a
n image of their current contents. | 147 // FIXME: For object (plugins) tags and video tag we could replace them by a
n image of their current contents. |
| 148 } | 148 } |
| 149 | 149 |
| 150 void SerializerMarkupAccumulator::appendCustomAttributes(StringBuilder& out, Ele
ment* element, Namespaces* namespaces) | 150 void SerializerMarkupAccumulator::appendCustomAttributes(StringBuilder& out, con
st Element& element, Namespaces* namespaces) |
| 151 { | 151 { |
| 152 if (!element->isFrameOwnerElement()) | 152 if (!element.isFrameOwnerElement()) |
| 153 return; | 153 return; |
| 154 | 154 |
| 155 HTMLFrameOwnerElement* frameOwner = toHTMLFrameOwnerElement(element); | 155 const HTMLFrameOwnerElement& frameOwner = toHTMLFrameOwnerElement(element); |
| 156 Frame* frame = frameOwner->contentFrame(); | 156 Frame* frame = frameOwner.contentFrame(); |
| 157 if (!frame) | 157 if (!frame) |
| 158 return; | 158 return; |
| 159 | 159 |
| 160 KURL url = frame->document()->url(); | 160 KURL url = frame->document()->url(); |
| 161 if (url.isValid() && !url.isBlankURL()) | 161 if (url.isValid() && !url.isBlankURL()) |
| 162 return; | 162 return; |
| 163 | 163 |
| 164 // We need to give a fake location to blank frames so they can be referenced
by the serialized frame. | 164 // We need to give a fake location to blank frames so they can be referenced
by the serialized frame. |
| 165 url = m_serializer->urlForBlankFrame(frame); | 165 url = m_serializer->urlForBlankFrame(frame); |
| 166 appendAttribute(out, element, Attribute(frameOwnerURLAttributeName(*frameOwn
er), AtomicString(url.string())), namespaces); | 166 appendAttribute(out, element, Attribute(frameOwnerURLAttributeName(frameOwne
r), AtomicString(url.string())), namespaces); |
| 167 } | 167 } |
| 168 | 168 |
| 169 void SerializerMarkupAccumulator::appendEndTag(Node* node) | 169 void SerializerMarkupAccumulator::appendEndTag(const Node& node) |
| 170 { | 170 { |
| 171 if (node->isElementNode() && !shouldIgnoreElement(toElement(node))) | 171 if (node.isElementNode() && !shouldIgnoreElement(toElement(node))) |
| 172 MarkupAccumulator::appendEndTag(node); | 172 MarkupAccumulator::appendEndTag(node); |
| 173 } | 173 } |
| 174 | 174 |
| 175 PageSerializer::PageSerializer(Vector<SerializedResource>* resources) | 175 PageSerializer::PageSerializer(Vector<SerializedResource>* resources) |
| 176 : m_resources(resources) | 176 : m_resources(resources) |
| 177 , m_blankFrameCounter(0) | 177 , m_blankFrameCounter(0) |
| 178 { | 178 { |
| 179 } | 179 } |
| 180 | 180 |
| 181 void PageSerializer::serialize(Page* page) | 181 void PageSerializer::serialize(Page* page) |
| 182 { | 182 { |
| 183 serializeFrame(page->mainFrame()); | 183 serializeFrame(page->mainFrame()); |
| 184 } | 184 } |
| 185 | 185 |
| 186 void PageSerializer::serializeFrame(Frame* frame) | 186 void PageSerializer::serializeFrame(Frame* frame) |
| 187 { | 187 { |
| 188 Document* document = frame->document(); | 188 ASSERT(frame->document()); |
| 189 KURL url = document->url(); | 189 Document& document = *frame->document(); |
| 190 KURL url = document.url(); |
| 190 if (!url.isValid() || url.isBlankURL()) { | 191 if (!url.isValid() || url.isBlankURL()) { |
| 191 // For blank frames we generate a fake URL so they can be referenced by
their containing frame. | 192 // For blank frames we generate a fake URL so they can be referenced by
their containing frame. |
| 192 url = urlForBlankFrame(frame); | 193 url = urlForBlankFrame(frame); |
| 193 } | 194 } |
| 194 | 195 |
| 195 if (m_resourceURLs.contains(url)) { | 196 if (m_resourceURLs.contains(url)) { |
| 196 // FIXME: We could have 2 frame with the same URL but which were dynamic
ally changed and have now | 197 // FIXME: We could have 2 frame with the same URL but which were dynamic
ally changed and have now |
| 197 // different content. So we should serialize both and somehow rename the
frame src in the containing | 198 // different content. So we should serialize both and somehow rename the
frame src in the containing |
| 198 // frame. Arg! | 199 // frame. Arg! |
| 199 return; | 200 return; |
| 200 } | 201 } |
| 201 | 202 |
| 202 WTF::TextEncoding textEncoding(document->charset()); | 203 WTF::TextEncoding textEncoding(document.charset()); |
| 203 if (!textEncoding.isValid()) { | 204 if (!textEncoding.isValid()) { |
| 204 // FIXME: iframes used as images trigger this. We should deal with them
correctly. | 205 // FIXME: iframes used as images trigger this. We should deal with them
correctly. |
| 205 return; | 206 return; |
| 206 } | 207 } |
| 207 | 208 |
| 208 Vector<Node*> serializedNodes; | 209 Vector<Node*> serializedNodes; |
| 209 SerializerMarkupAccumulator accumulator(this, document, &serializedNodes); | 210 SerializerMarkupAccumulator accumulator(this, document, &serializedNodes); |
| 210 String text = accumulator.serializeNodes(document, IncludeNode); | 211 String text = accumulator.serializeNodes(document, IncludeNode); |
| 211 CString frameHTML = textEncoding.normalizeAndEncode(text, WTF::EntitiesForUn
encodables); | 212 CString frameHTML = textEncoding.normalizeAndEncode(text, WTF::EntitiesForUn
encodables); |
| 212 m_resources->append(SerializedResource(url, document->suggestedMIMEType(), S
haredBuffer::create(frameHTML.data(), frameHTML.length()))); | 213 m_resources->append(SerializedResource(url, document.suggestedMIMEType(), Sh
aredBuffer::create(frameHTML.data(), frameHTML.length()))); |
| 213 m_resourceURLs.add(url); | 214 m_resourceURLs.add(url); |
| 214 | 215 |
| 215 for (Vector<Node*>::iterator iter = serializedNodes.begin(); iter != seriali
zedNodes.end(); ++iter) { | 216 for (Vector<Node*>::iterator iter = serializedNodes.begin(); iter != seriali
zedNodes.end(); ++iter) { |
| 216 Node* node = *iter; | 217 ASSERT(*iter); |
| 217 if (!node->isElementNode()) | 218 Node& node = **iter; |
| 219 if (!node.isElementNode()) |
| 218 continue; | 220 continue; |
| 219 | 221 |
| 220 Element* element = toElement(node); | 222 Element& element = toElement(node); |
| 221 // We have to process in-line style as it might contain some resources (
typically background images). | 223 // We have to process in-line style as it might contain some resources (
typically background images). |
| 222 if (element->isStyledElement()) | 224 if (element.isStyledElement()) |
| 223 retrieveResourcesForProperties(element->inlineStyle(), document); | 225 retrieveResourcesForProperties(element.inlineStyle(), document); |
| 224 | 226 |
| 225 if (element->hasTagName(HTMLNames::imgTag)) { | 227 if (element.hasTagName(HTMLNames::imgTag)) { |
| 226 HTMLImageElement* imageElement = toHTMLImageElement(element); | 228 HTMLImageElement& imageElement = toHTMLImageElement(element); |
| 227 KURL url = document->completeURL(imageElement->getAttribute(HTMLName
s::srcAttr)); | 229 KURL url = document.completeURL(imageElement.getAttribute(HTMLNames:
:srcAttr)); |
| 228 ImageResource* cachedImage = imageElement->cachedImage(); | 230 ImageResource* cachedImage = imageElement.cachedImage(); |
| 229 addImageToResources(cachedImage, imageElement->renderer(), url); | 231 addImageToResources(cachedImage, imageElement.renderer(), url); |
| 230 } else if (element->hasTagName(HTMLNames::inputTag)) { | 232 } else if (element.hasTagName(HTMLNames::inputTag)) { |
| 231 HTMLInputElement* inputElement = toHTMLInputElement(element); | 233 HTMLInputElement& inputElement = toHTMLInputElement(element); |
| 232 if (inputElement->isImageButton() && inputElement->hasImageLoader())
{ | 234 if (inputElement.isImageButton() && inputElement.hasImageLoader()) { |
| 233 KURL url = inputElement->src(); | 235 KURL url = inputElement.src(); |
| 234 ImageResource* cachedImage = inputElement->imageLoader()->image(
); | 236 ImageResource* cachedImage = inputElement.imageLoader()->image()
; |
| 235 addImageToResources(cachedImage, inputElement->renderer(), url); | 237 addImageToResources(cachedImage, inputElement.renderer(), url); |
| 236 } | 238 } |
| 237 } else if (element->hasTagName(HTMLNames::linkTag)) { | 239 } else if (element.hasTagName(HTMLNames::linkTag)) { |
| 238 HTMLLinkElement* linkElement = toHTMLLinkElement(element); | 240 HTMLLinkElement& linkElement = toHTMLLinkElement(element); |
| 239 if (CSSStyleSheet* sheet = linkElement->sheet()) { | 241 if (CSSStyleSheet* sheet = linkElement.sheet()) { |
| 240 KURL url = document->completeURL(linkElement->getAttribute(HTMLN
ames::hrefAttr)); | 242 KURL url = document.completeURL(linkElement.getAttribute(HTMLNam
es::hrefAttr)); |
| 241 serializeCSSStyleSheet(sheet, url); | 243 serializeCSSStyleSheet(sheet, url); |
| 242 ASSERT(m_resourceURLs.contains(url)); | 244 ASSERT(m_resourceURLs.contains(url)); |
| 243 } | 245 } |
| 244 } else if (element->hasTagName(HTMLNames::styleTag)) { | 246 } else if (element.hasTagName(HTMLNames::styleTag)) { |
| 245 HTMLStyleElement* styleElement = toHTMLStyleElement(element); | 247 HTMLStyleElement& styleElement = toHTMLStyleElement(element); |
| 246 if (CSSStyleSheet* sheet = styleElement->sheet()) | 248 if (CSSStyleSheet* sheet = styleElement.sheet()) |
| 247 serializeCSSStyleSheet(sheet, KURL()); | 249 serializeCSSStyleSheet(sheet, KURL()); |
| 248 } | 250 } |
| 249 } | 251 } |
| 250 | 252 |
| 251 for (Frame* childFrame = frame->tree().firstChild(); childFrame; childFrame
= childFrame->tree().nextSibling()) | 253 for (Frame* childFrame = frame->tree().firstChild(); childFrame; childFrame
= childFrame->tree().nextSibling()) |
| 252 serializeFrame(childFrame); | 254 serializeFrame(childFrame); |
| 253 } | 255 } |
| 254 | 256 |
| 255 void PageSerializer::serializeCSSStyleSheet(CSSStyleSheet* styleSheet, const KUR
L& url) | 257 void PageSerializer::serializeCSSStyleSheet(CSSStyleSheet* styleSheet, const KUR
L& url) |
| 256 { | 258 { |
| 257 StringBuilder cssText; | 259 StringBuilder cssText; |
| 258 for (unsigned i = 0; i < styleSheet->length(); ++i) { | 260 for (unsigned i = 0; i < styleSheet->length(); ++i) { |
| 259 CSSRule* rule = styleSheet->item(i); | 261 CSSRule* rule = styleSheet->item(i); |
| 260 String itemText = rule->cssText(); | 262 String itemText = rule->cssText(); |
| 261 if (!itemText.isEmpty()) { | 263 if (!itemText.isEmpty()) { |
| 262 cssText.append(itemText); | 264 cssText.append(itemText); |
| 263 if (i < styleSheet->length() - 1) | 265 if (i < styleSheet->length() - 1) |
| 264 cssText.append("\n\n"); | 266 cssText.append("\n\n"); |
| 265 } | 267 } |
| 266 Document* document = styleSheet->ownerDocument(); | 268 ASSERT(styleSheet->ownerDocument()); |
| 269 Document& document = *styleSheet->ownerDocument(); |
| 267 // Some rules have resources associated with them that we need to retrie
ve. | 270 // Some rules have resources associated with them that we need to retrie
ve. |
| 268 if (rule->type() == CSSRule::IMPORT_RULE) { | 271 if (rule->type() == CSSRule::IMPORT_RULE) { |
| 269 CSSImportRule* importRule = toCSSImportRule(rule); | 272 CSSImportRule* importRule = toCSSImportRule(rule); |
| 270 KURL importURL = document->completeURL(importRule->href()); | 273 KURL importURL = document.completeURL(importRule->href()); |
| 271 if (m_resourceURLs.contains(importURL)) | 274 if (m_resourceURLs.contains(importURL)) |
| 272 continue; | 275 continue; |
| 273 serializeCSSStyleSheet(importRule->styleSheet(), importURL); | 276 serializeCSSStyleSheet(importRule->styleSheet(), importURL); |
| 274 } else if (rule->type() == CSSRule::FONT_FACE_RULE) { | 277 } else if (rule->type() == CSSRule::FONT_FACE_RULE) { |
| 275 retrieveResourcesForProperties(toCSSFontFaceRule(rule)->styleRule()-
>properties(), document); | 278 retrieveResourcesForProperties(toCSSFontFaceRule(rule)->styleRule()-
>properties(), document); |
| 276 } else if (rule->type() == CSSRule::STYLE_RULE) { | 279 } else if (rule->type() == CSSRule::STYLE_RULE) { |
| 277 retrieveResourcesForProperties(toCSSStyleRule(rule)->styleRule()->pr
operties(), document); | 280 retrieveResourcesForProperties(toCSSStyleRule(rule)->styleRule()->pr
operties(), document); |
| 278 } | 281 } |
| 279 } | 282 } |
| 280 | 283 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 void PageSerializer::addFontToResources(FontResource* font) | 327 void PageSerializer::addFontToResources(FontResource* font) |
| 325 { | 328 { |
| 326 if (!font || !shouldAddURL(font->url()) || !font->isLoaded() || !font->resou
rceBuffer()) { | 329 if (!font || !shouldAddURL(font->url()) || !font->isLoaded() || !font->resou
rceBuffer()) { |
| 327 return; | 330 return; |
| 328 } | 331 } |
| 329 RefPtr<SharedBuffer> data(font->resourceBuffer()); | 332 RefPtr<SharedBuffer> data(font->resourceBuffer()); |
| 330 | 333 |
| 331 addToResources(font, data, font->url()); | 334 addToResources(font, data, font->url()); |
| 332 } | 335 } |
| 333 | 336 |
| 334 void PageSerializer::retrieveResourcesForProperties(const StylePropertySet* styl
eDeclaration, Document* document) | 337 void PageSerializer::retrieveResourcesForProperties(const StylePropertySet* styl
eDeclaration, Document& document) |
| 335 { | 338 { |
| 336 if (!styleDeclaration) | 339 if (!styleDeclaration) |
| 337 return; | 340 return; |
| 338 | 341 |
| 339 // The background-image and list-style-image (for ul or ol) are the CSS prop
erties | 342 // The background-image and list-style-image (for ul or ol) are the CSS prop
erties |
| 340 // that make use of images. We iterate to make sure we include any other | 343 // that make use of images. We iterate to make sure we include any other |
| 341 // image properties there might be. | 344 // image properties there might be. |
| 342 unsigned propertyCount = styleDeclaration->propertyCount(); | 345 unsigned propertyCount = styleDeclaration->propertyCount(); |
| 343 for (unsigned i = 0; i < propertyCount; ++i) { | 346 for (unsigned i = 0; i < propertyCount; ++i) { |
| 344 RefPtr<CSSValue> cssValue = styleDeclaration->propertyAt(i).value(); | 347 RefPtr<CSSValue> cssValue = styleDeclaration->propertyAt(i).value(); |
| 345 retrieveResourcesForCSSValue(cssValue.get(), document); | 348 retrieveResourcesForCSSValue(cssValue.get(), document); |
| 346 } | 349 } |
| 347 } | 350 } |
| 348 | 351 |
| 349 void PageSerializer::retrieveResourcesForCSSValue(CSSValue* cssValue, Document*
document) | 352 void PageSerializer::retrieveResourcesForCSSValue(CSSValue* cssValue, Document&
document) |
| 350 { | 353 { |
| 351 if (cssValue->isImageValue()) { | 354 if (cssValue->isImageValue()) { |
| 352 CSSImageValue* imageValue = toCSSImageValue(cssValue); | 355 CSSImageValue* imageValue = toCSSImageValue(cssValue); |
| 353 StyleImage* styleImage = imageValue->cachedOrPendingImage(); | 356 StyleImage* styleImage = imageValue->cachedOrPendingImage(); |
| 354 // Non cached-images are just place-holders and do not contain data. | 357 // Non cached-images are just place-holders and do not contain data. |
| 355 if (!styleImage || !styleImage->isImageResource()) | 358 if (!styleImage || !styleImage->isImageResource()) |
| 356 return; | 359 return; |
| 357 | 360 |
| 358 addImageToResources(styleImage->cachedImage(), 0, styleImage->cachedImag
e()->url()); | 361 addImageToResources(styleImage->cachedImage(), 0, styleImage->cachedImag
e()->url()); |
| 359 } else if (cssValue->isFontFaceSrcValue()) { | 362 } else if (cssValue->isFontFaceSrcValue()) { |
| 360 CSSFontFaceSrcValue* fontFaceSrcValue = toCSSFontFaceSrcValue(cssValue); | 363 CSSFontFaceSrcValue* fontFaceSrcValue = toCSSFontFaceSrcValue(cssValue); |
| 361 if (fontFaceSrcValue->isLocal()) { | 364 if (fontFaceSrcValue->isLocal()) { |
| 362 return; | 365 return; |
| 363 } | 366 } |
| 364 | 367 |
| 365 addFontToResources(fontFaceSrcValue->fetch(document)); | 368 addFontToResources(fontFaceSrcValue->fetch(&document)); |
| 366 } else if (cssValue->isValueList()) { | 369 } else if (cssValue->isValueList()) { |
| 367 CSSValueList* cssValueList = toCSSValueList(cssValue); | 370 CSSValueList* cssValueList = toCSSValueList(cssValue); |
| 368 for (unsigned i = 0; i < cssValueList->length(); i++) | 371 for (unsigned i = 0; i < cssValueList->length(); i++) |
| 369 retrieveResourcesForCSSValue(cssValueList->item(i), document); | 372 retrieveResourcesForCSSValue(cssValueList->item(i), document); |
| 370 } | 373 } |
| 371 } | 374 } |
| 372 | 375 |
| 373 KURL PageSerializer::urlForBlankFrame(Frame* frame) | 376 KURL PageSerializer::urlForBlankFrame(Frame* frame) |
| 374 { | 377 { |
| 375 HashMap<Frame*, KURL>::iterator iter = m_blankFrameURLs.find(frame); | 378 HashMap<Frame*, KURL>::iterator iter = m_blankFrameURLs.find(frame); |
| 376 if (iter != m_blankFrameURLs.end()) | 379 if (iter != m_blankFrameURLs.end()) |
| 377 return iter->value; | 380 return iter->value; |
| 378 String url = "wyciwyg://frame/" + String::number(m_blankFrameCounter++); | 381 String url = "wyciwyg://frame/" + String::number(m_blankFrameCounter++); |
| 379 KURL fakeURL(ParsedURLString, url); | 382 KURL fakeURL(ParsedURLString, url); |
| 380 m_blankFrameURLs.add(frame, fakeURL); | 383 m_blankFrameURLs.add(frame, fakeURL); |
| 381 | 384 |
| 382 return fakeURL; | 385 return fakeURL; |
| 383 } | 386 } |
| 384 | 387 |
| 385 } | 388 } |
| OLD | NEW |