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

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

Issue 16520007: Serialize <input type="image"> images (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 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 | « no previous file | no next file » | 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 26 matching lines...) Expand all
37 #include "core/css/CSSStyleRule.h" 37 #include "core/css/CSSStyleRule.h"
38 #include "core/css/StylePropertySet.h" 38 #include "core/css/StylePropertySet.h"
39 #include "core/css/StyleRule.h" 39 #include "core/css/StyleRule.h"
40 #include "core/css/StyleSheetContents.h" 40 #include "core/css/StyleSheetContents.h"
41 #include "core/dom/Document.h" 41 #include "core/dom/Document.h"
42 #include "core/dom/Element.h" 42 #include "core/dom/Element.h"
43 #include "core/dom/Text.h" 43 #include "core/dom/Text.h"
44 #include "core/editing/MarkupAccumulator.h" 44 #include "core/editing/MarkupAccumulator.h"
45 #include "core/html/HTMLFrameOwnerElement.h" 45 #include "core/html/HTMLFrameOwnerElement.h"
46 #include "core/html/HTMLImageElement.h" 46 #include "core/html/HTMLImageElement.h"
47 #include "core/html/HTMLInputElement.h"
47 #include "core/html/HTMLLinkElement.h" 48 #include "core/html/HTMLLinkElement.h"
48 #include "core/html/HTMLStyleElement.h" 49 #include "core/html/HTMLStyleElement.h"
49 #include "core/html/parser/HTMLMetaCharsetParser.h" 50 #include "core/html/parser/HTMLMetaCharsetParser.h"
50 #include "core/loader/cache/CachedImage.h" 51 #include "core/loader/cache/CachedImage.h"
51 #include "core/page/Frame.h" 52 #include "core/page/Frame.h"
52 #include "core/page/Page.h" 53 #include "core/page/Page.h"
53 #include "core/platform/SerializedResource.h" 54 #include "core/platform/SerializedResource.h"
54 #include "core/platform/graphics/Image.h" 55 #include "core/platform/graphics/Image.h"
56 #include "core/rendering/RenderImage.h"
55 #include "core/rendering/style/StyleCachedImage.h" 57 #include "core/rendering/style/StyleCachedImage.h"
56 #include "core/rendering/style/StyleImage.h" 58 #include "core/rendering/style/StyleImage.h"
57 #include "wtf/text/CString.h" 59 #include "wtf/text/CString.h"
58 #include "wtf/text/StringBuilder.h" 60 #include "wtf/text/StringBuilder.h"
59 #include "wtf/text/TextEncoding.h" 61 #include "wtf/text/TextEncoding.h"
60 #include "wtf/text/WTFString.h" 62 #include "wtf/text/WTFString.h"
61 63
62 namespace WebCore { 64 namespace WebCore {
63 65
64 static bool isCharsetSpecifyingNode(Node* node) 66 static bool isCharsetSpecifyingNode(Node* node)
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 Element* element = toElement(node); 218 Element* element = toElement(node);
217 // We have to process in-line style as it might contain some resources ( typically background images). 219 // We have to process in-line style as it might contain some resources ( typically background images).
218 if (element->isStyledElement()) 220 if (element->isStyledElement())
219 retrieveResourcesForProperties(static_cast<StyledElement*>(element)- >inlineStyle(), document); 221 retrieveResourcesForProperties(static_cast<StyledElement*>(element)- >inlineStyle(), document);
220 222
221 if (element->hasTagName(HTMLNames::imgTag)) { 223 if (element->hasTagName(HTMLNames::imgTag)) {
222 HTMLImageElement* imageElement = toHTMLImageElement(element); 224 HTMLImageElement* imageElement = toHTMLImageElement(element);
223 KURL url = document->completeURL(imageElement->getAttribute(HTMLName s::srcAttr)); 225 KURL url = document->completeURL(imageElement->getAttribute(HTMLName s::srcAttr));
224 CachedImage* cachedImage = imageElement->cachedImage(); 226 CachedImage* cachedImage = imageElement->cachedImage();
225 addImageToResources(cachedImage, imageElement->renderer(), url); 227 addImageToResources(cachedImage, imageElement->renderer(), url);
228 } else if (element->hasTagName(HTMLNames::inputTag)) {
229 HTMLInputElement* inputElement = static_cast<HTMLInputElement*>(elem ent);
abarth-chromium 2013/06/12 18:41:11 static_cast<HTMLInputElement*> -> toHTMLInputE
230 if (inputElement->isImageButton()) {
231 KURL url = inputElement->src();
232 CachedImage* cachedImage = static_cast<RenderImage*>(inputElemen t->renderer())->cachedImage();
abarth-chromium 2013/06/12 18:41:11 Is this static_cast always safe?
233 addImageToResources(cachedImage, inputElement->renderer(), url);
234 }
226 } else if (element->hasTagName(HTMLNames::linkTag)) { 235 } else if (element->hasTagName(HTMLNames::linkTag)) {
227 HTMLLinkElement* linkElement = static_cast<HTMLLinkElement*>(element ); 236 HTMLLinkElement* linkElement = static_cast<HTMLLinkElement*>(element );
228 if (CSSStyleSheet* sheet = linkElement->sheet()) { 237 if (CSSStyleSheet* sheet = linkElement->sheet()) {
229 KURL url = document->completeURL(linkElement->getAttribute(HTMLN ames::hrefAttr)); 238 KURL url = document->completeURL(linkElement->getAttribute(HTMLN ames::hrefAttr));
230 serializeCSSStyleSheet(sheet, url); 239 serializeCSSStyleSheet(sheet, url);
231 ASSERT(m_resourceURLs.contains(url)); 240 ASSERT(m_resourceURLs.contains(url));
232 } 241 }
233 } else if (element->hasTagName(HTMLNames::styleTag)) { 242 } else if (element->hasTagName(HTMLNames::styleTag)) {
234 HTMLStyleElement* styleElement = static_cast<HTMLStyleElement*>(elem ent); 243 HTMLStyleElement* styleElement = static_cast<HTMLStyleElement*>(elem ent);
235 if (CSSStyleSheet* sheet = styleElement->sheet()) 244 if (CSSStyleSheet* sheet = styleElement->sheet())
(...skipping 20 matching lines...) Expand all
256 // Some rules have resources associated with them that we need to retrie ve. 265 // Some rules have resources associated with them that we need to retrie ve.
257 if (rule->type() == CSSRule::IMPORT_RULE) { 266 if (rule->type() == CSSRule::IMPORT_RULE) {
258 CSSImportRule* importRule = static_cast<CSSImportRule*>(rule); 267 CSSImportRule* importRule = static_cast<CSSImportRule*>(rule);
259 KURL importURL = document->completeURL(importRule->href()); 268 KURL importURL = document->completeURL(importRule->href());
260 if (m_resourceURLs.contains(importURL)) 269 if (m_resourceURLs.contains(importURL))
261 continue; 270 continue;
262 serializeCSSStyleSheet(importRule->styleSheet(), importURL); 271 serializeCSSStyleSheet(importRule->styleSheet(), importURL);
263 } else if (rule->type() == CSSRule::FONT_FACE_RULE) { 272 } else if (rule->type() == CSSRule::FONT_FACE_RULE) {
264 // FIXME: Add support for font face rule. It is not clear to me at t his point if the actual otf/eot file can 273 // FIXME: Add support for font face rule. It is not clear to me at t his point if the actual otf/eot file can
265 // be retrieved from the CSSFontFaceRule object. 274 // be retrieved from the CSSFontFaceRule object.
266 } else if (rule->type() == CSSRule::STYLE_RULE) 275 } else if (rule->type() == CSSRule::STYLE_RULE) {
267 retrieveResourcesForRule(static_cast<CSSStyleRule*>(rule)->styleRule (), document); 276 retrieveResourcesForRule(static_cast<CSSStyleRule*>(rule)->styleRule (), document);
277 }
268 } 278 }
269 279
270 if (url.isValid() && !m_resourceURLs.contains(url)) { 280 if (url.isValid() && !m_resourceURLs.contains(url)) {
271 // FIXME: We should check whether a charset has been specified and if no ne was found add one. 281 // FIXME: We should check whether a charset has been specified and if no ne was found add one.
272 WTF::TextEncoding textEncoding(styleSheet->contents()->charset()); 282 WTF::TextEncoding textEncoding(styleSheet->contents()->charset());
273 ASSERT(textEncoding.isValid()); 283 ASSERT(textEncoding.isValid());
274 String textString = cssText.toString(); 284 String textString = cssText.toString();
275 CString text = textEncoding.encode(textString.characters(), textString.l ength(), WTF::EntitiesForUnencodables); 285 CString text = textEncoding.encode(textString.characters(), textString.l ength(), WTF::EntitiesForUnencodables);
276 m_resources->append(SerializedResource(url, String("text/css"), SharedBu ffer::create(text.data(), text.length()))); 286 m_resources->append(SerializedResource(url, String("text/css"), SharedBu ffer::create(text.data(), text.length())));
277 m_resourceURLs.add(url); 287 m_resourceURLs.add(url);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 if (iter != m_blankFrameURLs.end()) 346 if (iter != m_blankFrameURLs.end())
337 return iter->value; 347 return iter->value;
338 String url = "wyciwyg://frame/" + String::number(m_blankFrameCounter++); 348 String url = "wyciwyg://frame/" + String::number(m_blankFrameCounter++);
339 KURL fakeURL(ParsedURLString, url); 349 KURL fakeURL(ParsedURLString, url);
340 m_blankFrameURLs.add(frame, fakeURL); 350 m_blankFrameURLs.add(frame, fakeURL);
341 351
342 return fakeURL; 352 return fakeURL;
343 } 353 }
344 354
345 } 355 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698