Commit acf809ec authored by jdduke's avatar jdduke Committed by Commit bot

[Android] Enable composited selection updates

Now that selection bounds are routed through the compositor, enable the feature
in Blink and hook the CompositorFrameMetadata-carried bounds into the existing
selection handle pipeline.  Also suppress the sending of
ViewHostMsg_SelectionBoundsChanged messages when the feature is enabled.

This patch depends directly on
https://codereview.chromium.org/454643002/.

BUG=135959

Review URL: https://codereview.chromium.org/359033002

Cr-Commit-Position: refs/heads/master@{#296218}
parent 3a955110
...@@ -278,8 +278,6 @@ RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid( ...@@ -278,8 +278,6 @@ RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid(
switches::kDisableOverscrollEdgeEffect)), switches::kDisableOverscrollEdgeEffect)),
gesture_provider_(CreateGestureProviderConfig(), this), gesture_provider_(CreateGestureProviderConfig(), this),
gesture_text_selector_(this), gesture_text_selector_(this),
touch_scrolling_(false),
potentially_active_fling_count_(0),
accelerated_surface_route_id_(0), accelerated_surface_route_id_(0),
using_synchronous_compositor_(SynchronousCompositorImpl::FromID( using_synchronous_compositor_(SynchronousCompositorImpl::FromID(
widget_host->GetProcess()->GetID(), widget_host->GetProcess()->GetID(),
...@@ -477,6 +475,8 @@ void RenderWidgetHostViewAndroid::Focus() { ...@@ -477,6 +475,8 @@ void RenderWidgetHostViewAndroid::Focus() {
host_->SetInputMethodActive(true); host_->SetInputMethodActive(true);
if (overscroll_effect_) if (overscroll_effect_)
overscroll_effect_->Enable(); overscroll_effect_->Enable();
if (selection_controller_)
selection_controller_->SetTemporarilyHidden(false);
} }
void RenderWidgetHostViewAndroid::Blur() { void RenderWidgetHostViewAndroid::Blur() {
...@@ -484,6 +484,8 @@ void RenderWidgetHostViewAndroid::Blur() { ...@@ -484,6 +484,8 @@ void RenderWidgetHostViewAndroid::Blur() {
host_->Blur(); host_->Blur();
if (overscroll_effect_) if (overscroll_effect_)
overscroll_effect_->Disable(); overscroll_effect_->Disable();
if (selection_controller_)
selection_controller_->SetTemporarilyHidden(true);
} }
bool RenderWidgetHostViewAndroid::HasFocus() const { bool RenderWidgetHostViewAndroid::HasFocus() const {
...@@ -735,10 +737,6 @@ void RenderWidgetHostViewAndroid::ResetGestureDetection() { ...@@ -735,10 +737,6 @@ void RenderWidgetHostViewAndroid::ResetGestureDetection() {
scoped_ptr<ui::MotionEvent> cancel_event = current_down_event->Cancel(); scoped_ptr<ui::MotionEvent> cancel_event = current_down_event->Cancel();
DCHECK(cancel_event); DCHECK(cancel_event);
OnTouchEvent(*cancel_event); OnTouchEvent(*cancel_event);
touch_scrolling_ = false;
potentially_active_fling_count_ = 0;
OnContentScrollingChange();
} }
void RenderWidgetHostViewAndroid::SetDoubleTapSupportEnabled(bool enabled) { void RenderWidgetHostViewAndroid::SetDoubleTapSupportEnabled(bool enabled) {
...@@ -812,35 +810,7 @@ void RenderWidgetHostViewAndroid::SelectionChanged(const base::string16& text, ...@@ -812,35 +810,7 @@ void RenderWidgetHostViewAndroid::SelectionChanged(const base::string16& text,
void RenderWidgetHostViewAndroid::SelectionBoundsChanged( void RenderWidgetHostViewAndroid::SelectionBoundsChanged(
const ViewHostMsg_SelectionBounds_Params& params) { const ViewHostMsg_SelectionBounds_Params& params) {
if (!selection_controller_) NOTREACHED() << "Selection bounds should be routed through the compositor.";
return;
gfx::RectF start_rect(params.anchor_rect);
gfx::RectF end_rect(params.focus_rect);
if (params.is_anchor_first)
std::swap(start_rect, end_rect);
cc::ViewportSelectionBound start_bound, end_bound;
start_bound.visible = true;
end_bound.visible = true;
start_bound.edge_top = start_rect.origin();
start_bound.edge_bottom = start_rect.bottom_left();
end_bound.edge_top = end_rect.origin();
end_bound.edge_bottom = end_rect.bottom_left();
if (params.anchor_rect == params.focus_rect) {
if (params.anchor_rect.x() || params.anchor_rect.y())
start_bound.type = end_bound.type = cc::SELECTION_BOUND_CENTER;
} else {
start_bound.type = params.anchor_dir == blink::WebTextDirectionRightToLeft
? cc::SELECTION_BOUND_LEFT
: cc::SELECTION_BOUND_RIGHT;
end_bound.type = params.focus_dir == blink::WebTextDirectionRightToLeft
? cc::SELECTION_BOUND_RIGHT
: cc::SELECTION_BOUND_LEFT;
}
selection_controller_->OnSelectionBoundsChanged(start_bound, end_bound);
} }
void RenderWidgetHostViewAndroid::SetBackgroundOpaque(bool opaque) { void RenderWidgetHostViewAndroid::SetBackgroundOpaque(bool opaque) {
...@@ -1238,6 +1208,10 @@ void RenderWidgetHostViewAndroid::OnFrameMetadataUpdated( ...@@ -1238,6 +1208,10 @@ void RenderWidgetHostViewAndroid::OnFrameMetadataUpdated(
if (!content_view_core_) if (!content_view_core_)
return; return;
DCHECK(selection_controller_);
selection_controller_->OnSelectionBoundsChanged(
frame_metadata.selection_start, frame_metadata.selection_end);
// All offsets and sizes are in CSS pixels. // All offsets and sizes are in CSS pixels.
content_view_core_->UpdateFrameInfo( content_view_core_->UpdateFrameInfo(
frame_metadata.root_scroll_offset, frame_metadata.root_scroll_offset,
...@@ -1359,15 +1333,6 @@ bool RenderWidgetHostViewAndroid::Animate(base::TimeTicks frame_time) { ...@@ -1359,15 +1333,6 @@ bool RenderWidgetHostViewAndroid::Animate(base::TimeTicks frame_time) {
return needs_animate; return needs_animate;
} }
void RenderWidgetHostViewAndroid::OnContentScrollingChange() {
if (selection_controller_)
selection_controller_->SetTemporarilyHidden(IsContentScrolling());
}
bool RenderWidgetHostViewAndroid::IsContentScrolling() const {
return touch_scrolling_ || potentially_active_fling_count_ > 0;
}
void RenderWidgetHostViewAndroid::AcceleratedSurfacePostSubBuffer( void RenderWidgetHostViewAndroid::AcceleratedSurfacePostSubBuffer(
const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params,
int gpu_host_id) { int gpu_host_id) {
...@@ -1434,26 +1399,6 @@ void RenderWidgetHostViewAndroid::GestureEventAck( ...@@ -1434,26 +1399,6 @@ void RenderWidgetHostViewAndroid::GestureEventAck(
DidOverscroll(DidOverscrollParams()); DidOverscroll(DidOverscrollParams());
} }
switch (event.type) {
case blink::WebInputEvent::GestureScrollBegin:
touch_scrolling_ = true;
potentially_active_fling_count_ = 0;
OnContentScrollingChange();
break;
case blink::WebInputEvent::GestureScrollEnd:
touch_scrolling_ = false;
OnContentScrollingChange();
break;
case blink::WebInputEvent::GestureFlingStart:
touch_scrolling_ = false;
if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED)
++potentially_active_fling_count_;
OnContentScrollingChange();
break;
default:
break;
}
if (content_view_core_) if (content_view_core_)
content_view_core_->OnGestureEventAck(event, ack_result); content_view_core_->OnGestureEventAck(event, ack_result);
} }
...@@ -1615,11 +1560,6 @@ void RenderWidgetHostViewAndroid::DidOverscroll( ...@@ -1615,11 +1560,6 @@ void RenderWidgetHostViewAndroid::DidOverscroll(
} }
void RenderWidgetHostViewAndroid::DidStopFlinging() { void RenderWidgetHostViewAndroid::DidStopFlinging() {
if (potentially_active_fling_count_) {
--potentially_active_fling_count_;
OnContentScrollingChange();
}
if (content_view_core_) if (content_view_core_)
content_view_core_->DidStopFlinging(); content_view_core_->DidStopFlinging();
} }
......
...@@ -346,11 +346,6 @@ class CONTENT_EXPORT RenderWidgetHostViewAndroid ...@@ -346,11 +346,6 @@ class CONTENT_EXPORT RenderWidgetHostViewAndroid
void SendBeginFrame(base::TimeTicks frame_time, base::TimeDelta vsync_period); void SendBeginFrame(base::TimeTicks frame_time, base::TimeDelta vsync_period);
bool Animate(base::TimeTicks frame_time); bool Animate(base::TimeTicks frame_time);
void OnContentScrollingChange();
bool IsContentScrolling() const;
float GetDpiScale() const;
// Handles all unprocessed and pending readback requests. // Handles all unprocessed and pending readback requests.
void AbortPendingReadbackRequests(); void AbortPendingReadbackRequests();
...@@ -400,8 +395,6 @@ class CONTENT_EXPORT RenderWidgetHostViewAndroid ...@@ -400,8 +395,6 @@ class CONTENT_EXPORT RenderWidgetHostViewAndroid
// Manages selection handle rendering and manipulation. // Manages selection handle rendering and manipulation.
// This will always be NULL if |content_view_core_| is NULL. // This will always be NULL if |content_view_core_| is NULL.
scoped_ptr<TouchSelectionController> selection_controller_; scoped_ptr<TouchSelectionController> selection_controller_;
bool touch_scrolling_;
size_t potentially_active_fling_count_;
int accelerated_surface_route_id_; int accelerated_surface_route_id_;
......
...@@ -57,6 +57,7 @@ static void SetRuntimeFeatureDefaultsForPlatform() { ...@@ -57,6 +57,7 @@ static void SetRuntimeFeatureDefaultsForPlatform() {
WebRuntimeFeatures::enableOrientationEvent(true); WebRuntimeFeatures::enableOrientationEvent(true);
WebRuntimeFeatures::enableFastMobileScrolling(true); WebRuntimeFeatures::enableFastMobileScrolling(true);
WebRuntimeFeatures::enableMediaCapture(true); WebRuntimeFeatures::enableMediaCapture(true);
WebRuntimeFeatures::enableCompositedSelectionUpdate(true);
// If navigation transitions gets activated via field trial, enable it in // If navigation transitions gets activated via field trial, enable it in
// blink. We don't set this to false in case the user has manually enabled // blink. We don't set this to false in case the user has manually enabled
// the feature via experimental web platform features. // the feature via experimental web platform features.
......
...@@ -64,6 +64,7 @@ ...@@ -64,6 +64,7 @@
#include "third_party/WebKit/public/web/WebPopupMenu.h" #include "third_party/WebKit/public/web/WebPopupMenu.h"
#include "third_party/WebKit/public/web/WebPopupMenuInfo.h" #include "third_party/WebKit/public/web/WebPopupMenuInfo.h"
#include "third_party/WebKit/public/web/WebRange.h" #include "third_party/WebKit/public/web/WebRange.h"
#include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
#include "third_party/skia/include/core/SkShader.h" #include "third_party/skia/include/core/SkShader.h"
#include "ui/base/ui_base_switches.h" #include "ui/base/ui_base_switches.h"
#include "ui/gfx/frame_time.h" #include "ui/gfx/frame_time.h"
...@@ -1818,16 +1819,22 @@ void RenderWidget::UpdateSelectionBounds() { ...@@ -1818,16 +1819,22 @@ void RenderWidget::UpdateSelectionBounds() {
if (handling_ime_event_) if (handling_ime_event_)
return; return;
ViewHostMsg_SelectionBounds_Params params; // With composited selection updates, the selection bounds will be reported
GetSelectionBounds(&params.anchor_rect, &params.focus_rect); // directly by the compositor, in which case explicit IPC selection
if (selection_anchor_rect_ != params.anchor_rect || // notifications should be suppressed.
selection_focus_rect_ != params.focus_rect) { if (!blink::WebRuntimeFeatures::isCompositedSelectionUpdateEnabled()) {
selection_anchor_rect_ = params.anchor_rect; ViewHostMsg_SelectionBounds_Params params;
selection_focus_rect_ = params.focus_rect; GetSelectionBounds(&params.anchor_rect, &params.focus_rect);
webwidget_->selectionTextDirection(params.focus_dir, params.anchor_dir); if (selection_anchor_rect_ != params.anchor_rect ||
params.is_anchor_first = webwidget_->isSelectionAnchorFirst(); selection_focus_rect_ != params.focus_rect) {
Send(new ViewHostMsg_SelectionBoundsChanged(routing_id_, params)); selection_anchor_rect_ = params.anchor_rect;
selection_focus_rect_ = params.focus_rect;
webwidget_->selectionTextDirection(params.focus_dir, params.anchor_dir);
params.is_anchor_first = webwidget_->isSelectionAnchorFirst();
Send(new ViewHostMsg_SelectionBoundsChanged(routing_id_, params));
}
} }
#if defined(OS_MACOSX) || defined(USE_AURA) #if defined(OS_MACOSX) || defined(USE_AURA)
UpdateCompositionInfo(false); UpdateCompositionInfo(false);
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment