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

Unified Diff: content/renderer/gpu/render_widget_compositor.cc

Issue 300323005: Route selection bounds updates through the compositor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 6 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/renderer/gpu/render_widget_compositor.cc
diff --git a/content/renderer/gpu/render_widget_compositor.cc b/content/renderer/gpu/render_widget_compositor.cc
index 33612b0acb372936fd2e6a378a4caad2d6cae38b..3463e315842b7424a045a5cc44ac42d4679abeeb 100644
--- a/content/renderer/gpu/render_widget_compositor.cc
+++ b/content/renderer/gpu/render_widget_compositor.cc
@@ -19,6 +19,7 @@
#include "cc/base/switches.h"
#include "cc/debug/layer_tree_debug_state.h"
#include "cc/debug/micro_benchmark.h"
+#include "cc/input/layer_selection_bound.h"
#include "cc/layers/layer.h"
#include "cc/output/copy_output_request.h"
#include "cc/output/copy_output_result.h"
@@ -33,6 +34,7 @@
#include "content/renderer/render_thread_impl.h"
#include "gpu/command_buffer/client/gles2_interface.h"
#include "third_party/WebKit/public/platform/WebCompositeAndReadbackAsyncCallback.h"
+#include "third_party/WebKit/public/platform/WebSelectionBound.h"
#include "third_party/WebKit/public/platform/WebSize.h"
#include "third_party/WebKit/public/web/WebWidget.h"
#include "ui/gfx/frame_time.h"
@@ -48,6 +50,7 @@ class Layer;
}
using blink::WebFloatPoint;
+using blink::WebSelectionBound;
using blink::WebSize;
using blink::WebRect;
@@ -73,6 +76,29 @@ bool GetSwitchValueAsInt(
}
}
+bool ConvertWebSelectionBound(const WebSelectionBound& web_bound,
+ cc::LayerSelectionBound* cc_bound) {
+ DCHECK(cc_bound);
+ if (!web_bound.layerId)
+ return false;
aelias_OOO_until_Jul13 2014/06/28 00:02:17 Can we just DCHECK this instead? The Blink API is
jdduke (slow) 2014/06/28 00:29:10 Done, and I've already got ASSERT's in place on th
+
+ switch (web_bound.type) {
+ case blink::WebSelectionBound::Caret:
+ cc_bound->type = cc::SELECTION_BOUND_CENTER;
+ break;
+ case blink::WebSelectionBound::SelectionLeft:
+ cc_bound->type = cc::SELECTION_BOUND_LEFT;
+ break;
+ case blink::WebSelectionBound::SelectionRight:
+ cc_bound->type = cc::SELECTION_BOUND_RIGHT;
+ break;
+ }
+
+ cc_bound->layer_id = web_bound.layerId;
+ cc_bound->layer_rect = gfx::Rect(web_bound.edgeRectInLayer);
+ return true;
+}
+
} // namespace
// static
@@ -567,6 +593,25 @@ void RenderWidgetCompositor::clearViewportLayers() {
scoped_refptr<cc::Layer>());
}
+void RenderWidgetCompositor::registerSelection(
+ const blink::WebSelectionBound& anchor,
+ const blink::WebSelectionBound& focus) {
+ cc::LayerSelectionBound cc_anchor;
+ cc::LayerSelectionBound cc_focus;
+ if (!ConvertWebSelectionBound(anchor, &cc_anchor) ||
+ !ConvertWebSelectionBound(focus, &cc_focus)) {
+ clearSelection();
+ return;
+ }
+
+ layer_tree_host_->RegisterSelection(cc_anchor, cc_focus);
+}
+
+void RenderWidgetCompositor::clearSelection() {
+ cc::LayerSelectionBound empty_selection;
+ layer_tree_host_->RegisterSelection(empty_selection, empty_selection);
+}
+
void CompositeAndReadbackAsyncCallback(
blink::WebCompositeAndReadbackAsyncCallback* callback,
scoped_ptr<cc::CopyOutputResult> result) {

Powered by Google App Engine
This is Rietveld 408576698