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

Unified Diff: content/shell/renderer/test_runner/WebTestProxy.cpp

Issue 274253002: Make WebTestProxy handle printing + compositing mode (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 7 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 | « content/shell/renderer/test_runner/WebTestProxy.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/shell/renderer/test_runner/WebTestProxy.cpp
diff --git a/content/shell/renderer/test_runner/WebTestProxy.cpp b/content/shell/renderer/test_runner/WebTestProxy.cpp
index 1a85a23b2410dd473717fe5ffa159fb858939355..1cc010328583596ab4d09925fbefe3fc2312f8b1 100644
--- a/content/shell/renderer/test_runner/WebTestProxy.cpp
+++ b/content/shell/renderer/test_runner/WebTestProxy.cpp
@@ -66,20 +66,6 @@ private:
CallbackMethodType m_callback;
};
-class ClosureTask : public WebMethodTask<WebTestProxyBase> {
- public:
- ClosureTask(WebTestProxyBase* object, base::Closure callback)
- : WebMethodTask<WebTestProxyBase>(object), m_callback(callback) {}
-
- virtual void runIfValid() OVERRIDE {
- if (!m_callback.is_null())
- m_callback.Run();
- }
-
- private:
- base::Closure m_callback;
-};
-
void printFrameDescription(WebTestDelegate* delegate, WebFrame* frame)
{
string name8 = frame->uniqueName().utf8();
@@ -493,12 +479,33 @@ void WebTestProxyBase::didCompositeAndReadback(const SkBitmap& bitmap) {
m_compositeAndReadbackCallbacks.pop_front();
}
+void WebTestProxyBase::CapturePixelsForPrinting(
+ base::Callback<void(const SkBitmap&)> callback) {
+ // TODO(enne): get rid of stateful canvas().
+ webWidget()->layout();
+ paintPagesWithBoundaries();
+ DrawSelectionRect(canvas());
+ SkBaseDevice* device = skia::GetTopDevice(*canvas());
+ const SkBitmap& bitmap = device->accessBitmap(false);
+ callback.Run(bitmap);
+}
+
void WebTestProxyBase::CapturePixelsAsync(
base::Callback<void(const SkBitmap&)> callback) {
TRACE_EVENT0("shell", "WebTestProxyBase::CapturePixelsAsync");
DCHECK(webWidget()->isAcceleratedCompositingActive());
DCHECK(!callback.is_null());
+
+ if (m_testInterfaces->testRunner()->isPrinting()) {
+ base::MessageLoopProxy::current()->PostTask(
+ FROM_HERE,
+ base::Bind(&WebTestProxyBase::CapturePixelsForPrinting,
+ base::Unretained(this),
+ callback));
+ return;
+ }
+
m_compositeAndReadbackCallbacks.push_back(callback);
webWidget()->compositeAndReadbackAsync(this);
}
@@ -623,11 +630,11 @@ void WebTestProxyBase::displayAsyncThen(base::Closure callback) {
TRACE_EVENT0("shell",
"WebTestProxyBase::displayAsyncThen "
"isAcceleratedCompositingActive false");
- m_delegate->postTask(
- new ClosureTask(this,
- base::Bind(&WebTestProxyBase::DisplayForSoftwareMode,
- base::Unretained(this),
- callback)));
+ base::MessageLoopProxy::current()->PostTask(
+ FROM_HERE,
+ base::Bind(&WebTestProxyBase::DisplayForSoftwareMode,
+ base::Unretained(this),
+ callback));
return;
}
« no previous file with comments | « content/shell/renderer/test_runner/WebTestProxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698