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

Unified Diff: content/shell/renderer/test_runner/web_test_proxy.cc

Issue 396953002: Add testRunner.copyAtAndCapturePixelsAsyncThen() method (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
Index: content/shell/renderer/test_runner/web_test_proxy.cc
diff --git a/content/shell/renderer/test_runner/web_test_proxy.cc b/content/shell/renderer/test_runner/web_test_proxy.cc
index e3838f6481af96bc6dddcad9c6b5b929aafc52a9..6ae6f98e06cbced83c27c988b37ab84d87ef1b3b 100644
--- a/content/shell/renderer/test_runner/web_test_proxy.cc
+++ b/content/shell/renderer/test_runner/web_test_proxy.cc
@@ -26,7 +26,9 @@
#include "content/shell/renderer/test_runner/web_test_runner.h"
// FIXME: Including platform_canvas.h here is a layering violation.
#include "skia/ext/platform_canvas.h"
+#include "third_party/WebKit/public/platform/Platform.h"
#include "third_party/WebKit/public/platform/WebCString.h"
+#include "third_party/WebKit/public/platform/WebClipboard.h"
#include "third_party/WebKit/public/platform/WebURLError.h"
#include "third_party/WebKit/public/platform/WebURLRequest.h"
#include "third_party/WebKit/public/platform/WebURLResponse.h"
@@ -468,6 +470,20 @@ void WebTestProxyBase::SetAcceptLanguages(const std::string& accept_languages) {
GetWebView()->acceptLanguagesChanged();
}
+void WebTestProxyBase::CopyAtAndCapturePixels(
+ const int x, const int y, const base::Callback<void(const SkBitmap&)>& callback) {
+ DCHECK(web_widget_->isAcceleratedCompositingActive());
+ DCHECK(!callback.is_null());
+
+ GetWebView()->copyImageAt(blink::WebPoint(x, y));
+ blink::WebData data = blink::Platform::current()->clipboard()->readImage(blink::WebClipboard::Buffer());
Ken Russell (switch to Gerrit) 2014/07/16 20:40:50 You'll need to handle the case where WebView::copy
hj.r.chung 2014/07/17 05:33:40 I added a test in the Blink patch. Thanks!
+ blink::WebImage image = blink::WebImage::fromData(data, blink::WebSize());
+ const SkBitmap& bitmap = image.getSkBitmap();
+ SkAutoLockPixels autoLock(bitmap);
+ callback.Run(bitmap);
+}
+
+
void WebTestProxyBase::CapturePixelsForPrinting(
const base::Callback<void(const SkBitmap&)>& callback) {
web_widget_->layout();

Powered by Google App Engine
This is Rietveld 408576698