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

Side by Side Diff: Source/web/WebNode.cpp

Issue 19856004: Adds WebElement::imageContents() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: put it on WebNode since we retain the context menu node Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | public/web/WebNode.h » ('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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "WebPluginContainer.h" 42 #include "WebPluginContainer.h"
43 #include "WebPluginContainerImpl.h" 43 #include "WebPluginContainerImpl.h"
44 #include "core/dom/Document.h" 44 #include "core/dom/Document.h"
45 #include "core/dom/Element.h" 45 #include "core/dom/Element.h"
46 #include "core/dom/Event.h" 46 #include "core/dom/Event.h"
47 #include "core/dom/Node.h" 47 #include "core/dom/Node.h"
48 #include "core/dom/NodeList.h" 48 #include "core/dom/NodeList.h"
49 #include "core/editing/markup.h" 49 #include "core/editing/markup.h"
50 #include "core/page/Frame.h" 50 #include "core/page/Frame.h"
51 #include "core/platform/Widget.h" 51 #include "core/platform/Widget.h"
52 #include "core/rendering/RenderImage.h"
52 #include "core/rendering/RenderObject.h" 53 #include "core/rendering/RenderObject.h"
53 #include "core/rendering/RenderWidget.h" 54 #include "core/rendering/RenderWidget.h"
54 #include "public/platform/WebString.h" 55 #include "public/platform/WebString.h"
55 #include "public/platform/WebVector.h" 56 #include "public/platform/WebVector.h"
56 57
57 using namespace WebCore; 58 using namespace WebCore;
58 59
59 namespace WebKit { 60 namespace WebKit {
60 61
61 void WebNode::reset() 62 void WebNode::reset()
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 } 245 }
245 246
246 WebElement WebNode::shadowHost() const 247 WebElement WebNode::shadowHost() const
247 { 248 {
248 if (isNull()) 249 if (isNull())
249 return WebElement(); 250 return WebElement();
250 const Node* coreNode = constUnwrap<Node>(); 251 const Node* coreNode = constUnwrap<Node>();
251 return WebElement(coreNode->shadowHost()); 252 return WebElement(coreNode->shadowHost());
252 } 253 }
253 254
255 WebImage WebNode::imageContents()
256 {
257 if (isNull())
258 return WebImage();
259
260 RefPtr<Node> node = unwrap<Node>();
261
262 if (!(node->renderer() && node->renderer()->isImage()))
263 return WebImage();
264
265 WebCore::RenderImage* renderer = toRenderImage(node->renderer());
266 WebCore::CachedImage* cachedImage = renderer->cachedImage();
267 if (!cachedImage || cachedImage->errorOccurred())
268 return WebImage();
269 WebCore::Image* image = cachedImage->imageForRenderer(renderer);
esprehn 2013/07/25 22:52:03 This should be a method on HTMLImageElement and th
jamesr 2013/07/26 17:54:33 I don't follow. This line isn't reaching into the
270 ASSERT(image);
271
272 RefPtr<NativeImageSkia> bitmap = image->nativeImageForCurrentFrame();
273 if (!bitmap)
274 return WebImage();
275
276 return bitmap->bitmap();
277 }
278
254 WebNode::WebNode(const PassRefPtr<Node>& node) 279 WebNode::WebNode(const PassRefPtr<Node>& node)
255 : m_private(node) 280 : m_private(node)
256 { 281 {
257 } 282 }
258 283
259 WebNode& WebNode::operator=(const PassRefPtr<Node>& node) 284 WebNode& WebNode::operator=(const PassRefPtr<Node>& node)
260 { 285 {
261 m_private = node; 286 m_private = node;
262 return *this; 287 return *this;
263 } 288 }
264 289
265 WebNode::operator PassRefPtr<Node>() const 290 WebNode::operator PassRefPtr<Node>() const
266 { 291 {
267 return m_private.get(); 292 return m_private.get();
268 } 293 }
269 294
270 } // namespace WebKit 295 } // namespace WebKit
OLDNEW
« no previous file with comments | « no previous file | public/web/WebNode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698