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

Unified Diff: components/test_runner/layout_and_paint_async_then.cc

Issue 1889673002: Move LayoutAndPaintAsyncThen to a separate compilation unit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing... Created 4 years, 8 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 | « components/test_runner/layout_and_paint_async_then.h ('k') | components/test_runner/test_interfaces.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/test_runner/layout_and_paint_async_then.cc
diff --git a/components/test_runner/layout_and_paint_async_then.cc b/components/test_runner/layout_and_paint_async_then.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b2834d249d771d07ecc62049b2b20b37db25f629
--- /dev/null
+++ b/components/test_runner/layout_and_paint_async_then.cc
@@ -0,0 +1,60 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/test_runner/layout_and_paint_async_then.h"
+
+#include "base/callback.h"
+#include "base/trace_event/trace_event.h"
+#include "third_party/WebKit/public/platform/WebLayoutAndPaintAsyncCallback.h"
+#include "third_party/WebKit/public/web/WebPagePopup.h"
+#include "third_party/WebKit/public/web/WebWidget.h"
+
+namespace test_runner {
+
+namespace {
+
+class LayoutAndPaintCallback : public blink::WebLayoutAndPaintAsyncCallback {
+ public:
+ LayoutAndPaintCallback(const base::Closure& callback)
+ : callback_(callback), wait_for_popup_(false) {}
+ virtual ~LayoutAndPaintCallback() {}
+
+ void set_wait_for_popup(bool wait) { wait_for_popup_ = wait; }
+
+ // WebLayoutAndPaintAsyncCallback implementation.
+ void didLayoutAndPaint() override;
+
+ private:
+ base::Closure callback_;
+ bool wait_for_popup_;
+};
+
+void LayoutAndPaintCallback::didLayoutAndPaint() {
+ TRACE_EVENT0("shell", "LayoutAndPaintCallback::didLayoutAndPaint");
+ if (wait_for_popup_) {
+ wait_for_popup_ = false;
+ return;
+ }
+
+ if (!callback_.is_null())
+ callback_.Run();
+ delete this;
+}
+
+} // namespace
+
+void LayoutAndPaintAsyncThen(blink::WebWidget* web_widget,
+ const base::Closure& callback) {
+ TRACE_EVENT0("shell", "LayoutAndPaintAsyncThen");
+
+ LayoutAndPaintCallback* layout_and_paint_callback =
+ new LayoutAndPaintCallback(callback);
+ web_widget->layoutAndPaintAsync(layout_and_paint_callback);
+ if (blink::WebPagePopup* popup = web_widget->pagePopup()) {
+ layout_and_paint_callback->set_wait_for_popup(true);
+ popup->layoutAndPaintAsync(layout_and_paint_callback);
+ }
+}
+
+} // namespace test_runner
« no previous file with comments | « components/test_runner/layout_and_paint_async_then.h ('k') | components/test_runner/test_interfaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698