| Index: content/browser/renderer_host/render_widget_host_view_android.cc
|
| diff --git a/content/browser/renderer_host/render_widget_host_view_android.cc b/content/browser/renderer_host/render_widget_host_view_android.cc
|
| index 53c758f11f2760db6d1ec2218b6fdc475ba4ecbb..65bae5d74795ca70755ce4a3c840e95727c15290 100644
|
| --- a/content/browser/renderer_host/render_widget_host_view_android.cc
|
| +++ b/content/browser/renderer_host/render_widget_host_view_android.cc
|
| @@ -80,14 +80,12 @@
|
| #include "ui/android/window_android.h"
|
| #include "ui/android/window_android_compositor.h"
|
| #include "ui/base/layout.h"
|
| -#include "ui/display/display.h"
|
| -#include "ui/display/screen.h"
|
| +#include "ui/events/android/motion_event_android.h"
|
| #include "ui/events/base_event_utils.h"
|
| #include "ui/events/blink/blink_event_util.h"
|
| #include "ui/events/blink/did_overscroll_params.h"
|
| #include "ui/events/blink/web_input_event_traits.h"
|
| #include "ui/events/gesture_detection/gesture_provider_config_helper.h"
|
| -#include "ui/events/gesture_detection/motion_event.h"
|
| #include "ui/gfx/android/java_bitmap.h"
|
| #include "ui/gfx/android/view_configuration.h"
|
| #include "ui/gfx/geometry/dip_util.h"
|
| @@ -399,6 +397,17 @@ void PrepareTextureCopyOutputResult(
|
| display_compositor::GLHelper::SCALER_QUALITY_GOOD);
|
| }
|
|
|
| +void RecordToolTypeForActionDown(const ui::MotionEventAndroid& event) {
|
| + ui::MotionEventAndroid::Action action = event.GetAction();
|
| + if (action == ui::MotionEventAndroid::ACTION_DOWN ||
|
| + action == ui::MotionEventAndroid::ACTION_POINTER_DOWN ||
|
| + action == ui::MotionEventAndroid::ACTION_BUTTON_PRESS) {
|
| + UMA_HISTOGRAM_ENUMERATION("Event.AndroidActionDown.ToolType",
|
| + event.GetToolType(0),
|
| + ui::MotionEventAndroid::TOOL_TYPE_LAST + 1);
|
| + }
|
| +}
|
| +
|
| bool FloatEquals(float a, float b) {
|
| return std::abs(a - b) < FLT_EPSILON;
|
| }
|
| @@ -429,6 +438,7 @@ RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid(
|
| content_view_core_(nullptr),
|
| ime_adapter_android_(this),
|
| cached_background_color_(SK_ColorWHITE),
|
| + view_(this),
|
| last_compositor_frame_sink_id_(kUndefinedCompositorFrameSinkId),
|
| gesture_provider_(ui::GetGestureProviderConfig(
|
| ui::GestureProviderConfigType::CURRENT_PLATFORM),
|
| @@ -444,6 +454,8 @@ RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid(
|
| // Set the layer which will hold the content layer for this view. The content
|
| // layer is managed by the DelegatedFrameHost.
|
| view_.SetLayer(cc::Layer::Create());
|
| + view_.SetLayout(ui::ViewAndroid::LayoutParams::MatchParent());
|
| +
|
| if (using_browser_compositor_) {
|
| cc::FrameSinkId frame_sink_id =
|
| host_->AllocateFrameSinkId(false /* is_guest_view_hack */);
|
| @@ -542,9 +554,7 @@ void RenderWidgetHostViewAndroid::GetScaledContentBitmap(
|
| src_subrect = gfx::Rect(bounds);
|
| DCHECK_LE(src_subrect.width() + src_subrect.x(), bounds.width());
|
| DCHECK_LE(src_subrect.height() + src_subrect.y(), bounds.height());
|
| - const display::Display& display =
|
| - display::Screen::GetScreen()->GetDisplayNearestWindow(GetNativeView());
|
| - float device_scale_factor = display.device_scale_factor();
|
| + float device_scale_factor = view_.GetDipScale();
|
| DCHECK_GT(device_scale_factor, 0);
|
| gfx::Size dst_size(
|
| gfx::ScaleToCeiledSize(src_subrect.size(), scale / device_scale_factor));
|
| @@ -935,9 +945,7 @@ void RenderWidgetHostViewAndroid::CopyFromCompositingSurface(
|
| }
|
|
|
| base::TimeTicks start_time = base::TimeTicks::Now();
|
| - const display::Display& display =
|
| - display::Screen::GetScreen()->GetDisplayNearestWindow(GetNativeView());
|
| - float device_scale_factor = display.device_scale_factor();
|
| + float device_scale_factor = view_.GetDipScale();
|
| gfx::Size dst_size_in_pixel =
|
| gfx::ConvertRectToPixel(device_scale_factor, gfx::Rect(dst_size)).size();
|
| gfx::Rect src_subrect_in_pixel =
|
| @@ -1770,6 +1778,22 @@ void RenderWidgetHostViewAndroid::RunAckCallbacks() {
|
| }
|
| }
|
|
|
| +bool RenderWidgetHostViewAndroid::OnTouchEvent(
|
| + const ui::MotionEventAndroid& event,
|
| + bool for_touch_handle) {
|
| + RecordToolTypeForActionDown(event);
|
| +
|
| + // TODO(jinsukkim): Remove this distinction.
|
| + return for_touch_handle ? OnTouchHandleEvent(event) : OnTouchEvent(event);
|
| +}
|
| +
|
| +bool RenderWidgetHostViewAndroid::OnMouseEvent(
|
| + const ui::MotionEventAndroid& event) {
|
| + RecordToolTypeForActionDown(event);
|
| + SendMouseEvent(event, event.GetActionButton());
|
| + return true;
|
| +}
|
| +
|
| void RenderWidgetHostViewAndroid::OnGestureEvent(
|
| const ui::GestureEventData& gesture) {
|
| blink::WebGestureEvent web_gesture =
|
|
|