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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | public/web/WebNode.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/WebNode.cpp
diff --git a/Source/web/WebNode.cpp b/Source/web/WebNode.cpp
index 9ce1b976448e9ec9b492f5999dc3ff9971ee2c65..416910254ab9c676ced6965faf987fd99f00664d 100644
--- a/Source/web/WebNode.cpp
+++ b/Source/web/WebNode.cpp
@@ -49,6 +49,7 @@
#include "core/editing/markup.h"
#include "core/page/Frame.h"
#include "core/platform/Widget.h"
+#include "core/rendering/RenderImage.h"
#include "core/rendering/RenderObject.h"
#include "core/rendering/RenderWidget.h"
#include "public/platform/WebString.h"
@@ -251,6 +252,30 @@ WebElement WebNode::shadowHost() const
return WebElement(coreNode->shadowHost());
}
+WebImage WebNode::imageContents()
+{
+ if (isNull())
+ return WebImage();
+
+ RefPtr<Node> node = unwrap<Node>();
+
+ if (!(node->renderer() && node->renderer()->isImage()))
+ return WebImage();
+
+ WebCore::RenderImage* renderer = toRenderImage(node->renderer());
+ WebCore::CachedImage* cachedImage = renderer->cachedImage();
+ if (!cachedImage || cachedImage->errorOccurred())
+ return WebImage();
+ 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
+ ASSERT(image);
+
+ RefPtr<NativeImageSkia> bitmap = image->nativeImageForCurrentFrame();
+ if (!bitmap)
+ return WebImage();
+
+ return bitmap->bitmap();
+}
+
WebNode::WebNode(const PassRefPtr<Node>& node)
: m_private(node)
{
« 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