Chromium Code Reviews| 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 f1f6101c2d1422c07ff1b10c9d6f021ef7a8c7f0..f74e6adb3864c29e90f25103dd805d9c8ca9d45c 100644 |
| --- a/content/renderer/gpu/render_widget_compositor.cc |
| +++ b/content/renderer/gpu/render_widget_compositor.cc |
| @@ -22,6 +22,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" |
| @@ -36,6 +37,7 @@ |
| #include "gpu/command_buffer/client/gles2_interface.h" |
| #include "third_party/WebKit/public/platform/WebCompositeAndReadbackAsyncCallback.h" |
| #include "third_party/WebKit/public/platform/WebSize.h" |
| +#include "third_party/WebKit/public/web/WebSelection.h" |
| #include "third_party/WebKit/public/web/WebWidget.h" |
| #include "ui/gfx/frame_time.h" |
| #include "ui/gl/gl_switches.h" |
| @@ -51,6 +53,7 @@ class Layer; |
| } |
| using blink::WebFloatPoint; |
| +using blink::WebSelection; |
| using blink::WebSize; |
| using blink::WebRect; |
| @@ -76,6 +79,43 @@ bool GetSwitchValueAsInt( |
| } |
| } |
| +bool ConvertWebSelection(const WebSelection& selection, |
| + cc::LayerSelectionBound* anchor, |
| + cc::LayerSelectionBound* focus) { |
| + DCHECK(anchor); |
| + DCHECK(focus); |
| + if (selection.type == WebSelection::TypeNone) |
| + return false; |
| + |
| + if (!selection.anchorLayerId) |
| + return false; |
| + |
| + if (selection.type == WebSelection::TypeInsertion) { |
| + anchor->type = cc::SELECTION_BOUND_CENTER; |
| + anchor->layer_id = selection.anchorLayerId; |
| + anchor->layer_rect = gfx::Rect(selection.anchorRectInLayer); |
| + return true; |
| + } |
| + |
| + if (!selection.focusLayerId) |
| + return false; |
| + |
| + anchor->layer_id = selection.anchorLayerId; |
| + focus->layer_id = selection.focusLayerId; |
| + |
| + anchor->type = selection.anchorDirection == blink::WebTextDirectionRightToLeft |
| + ? cc::SELECTION_BOUND_RIGHT |
| + : cc::SELECTION_BOUND_LEFT; |
| + focus->type = selection.focusDirection == blink::WebTextDirectionRightToLeft |
| + ? cc::SELECTION_BOUND_LEFT |
| + : cc::SELECTION_BOUND_RIGHT; |
| + |
| + anchor->layer_rect = gfx::Rect(selection.anchorRectInLayer); |
| + focus->layer_rect = gfx::Rect(selection.focusRectInLayer); |
| + |
| + return true; |
| +} |
| + |
| } // namespace |
| // static |
| @@ -324,6 +364,7 @@ RenderWidgetCompositor::RenderWidgetCompositor(RenderWidget* widget, |
| bool threaded) |
| : threaded_(threaded), |
| suppress_schedule_composite_(false), |
| + suppress_selection_updates_(false), |
| widget_(widget) { |
| } |
| @@ -426,6 +467,19 @@ bool RenderWidgetCompositor::SendMessageToMicroBenchmark( |
| return layer_tree_host_->SendMessageToMicroBenchmark(id, value.Pass()); |
| } |
| +void RenderWidgetCompositor::SetIgnoreSelectionUpdates(bool ignore_selection) { |
|
aelias_OOO_until_Jul13
2014/06/12 06:22:42
This feels like the wrong way to solve this. Also
jdduke (slow)
2014/06/12 18:32:44
Sounds good to me. I'll update RenderWidget/Rende
|
| + if (suppress_selection_updates_ == ignore_selection) |
| + return; |
| + |
| + if (ignore_selection) { |
| + cc::LayerSelectionBound ignored_selection; |
| + ignored_selection.type = cc::SELECTION_BOUND_IGNORED; |
| + layer_tree_host_->RegisterSelection(ignored_selection, ignored_selection); |
| + } |
| + |
| + suppress_selection_updates_ = ignore_selection; |
| +} |
| + |
| void RenderWidgetCompositor::Initialize(cc::LayerTreeSettings settings) { |
| scoped_refptr<base::MessageLoopProxy> compositor_message_loop_proxy; |
| RenderThreadImpl* render_thread = RenderThreadImpl::current(); |
| @@ -571,6 +625,30 @@ void RenderWidgetCompositor::clearViewportLayers() { |
| scoped_refptr<cc::Layer>()); |
| } |
| +void RenderWidgetCompositor::registerSelection( |
| + const blink::WebSelection& selection) { |
| + if (suppress_selection_updates_) |
| + return; |
| + |
| + cc::LayerSelectionBound anchor; |
| + cc::LayerSelectionBound focus; |
| + if (!ConvertWebSelection(selection, &anchor, &focus)) { |
| + clearSelection(); |
| + return; |
| + } |
| + |
| + layer_tree_host_->RegisterSelection(anchor, focus); |
| +} |
| + |
| +void RenderWidgetCompositor::clearSelection() { |
| + if (suppress_selection_updates_) |
| + return; |
| + |
| + cc::LayerSelectionBound empty_selection; |
| + empty_selection.type = cc::SELECTION_BOUND_EMPTY; |
| + layer_tree_host_->RegisterSelection(empty_selection, empty_selection); |
| +} |
| + |
| void CompositeAndReadbackAsyncCallback( |
| blink::WebCompositeAndReadbackAsyncCallback* callback, |
| scoped_ptr<cc::CopyOutputResult> result) { |