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

Unified Diff: content/renderer/pepper/pepper_plugin_instance_impl.cc

Issue 1609193002: [UseZoomForDSF] Alwatys use DIP coordinates in pepper plugin (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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/pepper/pepper_plugin_instance_impl.cc
diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.cc b/content/renderer/pepper/pepper_plugin_instance_impl.cc
index ade82c2000fbff03f841994c081a4aadc32b7ba8..1155aad8e0d7fe22ba054cee1193d58b3c77294a 100644
--- a/content/renderer/pepper/pepper_plugin_instance_impl.cc
+++ b/content/renderer/pepper/pepper_plugin_instance_impl.cc
@@ -120,6 +120,7 @@
#include "third_party/WebKit/public/web/WebUserGestureIndicator.h"
#include "third_party/WebKit/public/web/WebView.h"
#include "third_party/khronos/GLES2/gl2.h"
+#include "ui/events/blink/blink_event_util.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/image/image_skia_rep.h"
#include "ui/gfx/range/range.h"
@@ -494,6 +495,7 @@ PepperPluginInstanceImpl::PepperPluginInstanceImpl(
has_been_clicked_(false),
javascript_used_(false),
full_frame_(false),
+ viewport_to_dip_scale_(1.0f),
sent_initial_did_change_view_(false),
bound_graphics_2d_platform_(NULL),
bound_compositor_(NULL),
@@ -1079,19 +1081,22 @@ bool PepperPluginInstanceImpl::IsPluginAcceptingCompositionEvents() const {
gfx::Rect PepperPluginInstanceImpl::GetCaretBounds() const {
if (!text_input_caret_set_) {
// If it is never set by the plugin, use the bottom left corner.
- return gfx::Rect(view_data_.rect.point.x,
- view_data_.rect.point.y + view_data_.rect.size.height,
- 0,
- 0);
- }
-
- // TODO(kinaba) Take CSS transformation into accont.
- // TODO(kinaba) Take bounding_box into account. On some platforms, an
- // "exclude rectangle" where candidate window must avoid the region can be
- // passed to IME. Currently, we pass only the caret rectangle because
- // it is the only information supported uniformly in Chromium.
+ gfx::Rect rect(view_data_.rect.point.x,
+ view_data_.rect.point.y + view_data_.rect.size.height,
+ 0, 0);
+ ConvertDIPToViewport(&rect);
+ return rect;
+ }
+
+ // TODO(kinaba) Take CSS transformation into account.
+ // TODO(kinaba) Take |text_input_caret_bounds_| into account. On
+ // some platforms, an "exclude rectangle" where candidate window
+ // must avoid the region can be passed to IME. Currently, we pass
+ // only the caret rectangle because it is the only information
+ // supported uniformly in Chromium.
gfx::Rect caret(text_input_caret_);
caret.Offset(view_data_.rect.point.x, view_data_.rect.point.y);
+ ConvertDIPToViewport(&caret);
return caret;
}
@@ -1105,6 +1110,7 @@ bool PepperPluginInstanceImpl::HandleInputEvent(
(event.modifiers & blink::WebInputEvent::LeftButtonDown)) {
has_been_clicked_ = true;
blink::WebRect bounds = container()->element().boundsInViewport();
+ render_frame()->GetRenderWidget()->convertViewportToWindow(&bounds);
RecordFlashClickSizeMetric(bounds.width, bounds.height);
}
@@ -1138,7 +1144,12 @@ bool PepperPluginInstanceImpl::HandleInputEvent(
(input_event_mask_ & event_class)) {
// Actually send the event.
std::vector<ppapi::InputEventData> events;
- CreateInputEventData(event, &events);
+ scoped_ptr<const WebInputEvent> event_in_dip(
+ ui::ScaleWebInputEvent(event, viewport_to_dip_scale_));
tdresser 2016/01/21 21:14:51 Do we need a scoped_ptr here? const WebInputEvent
oshima 2016/01/22 01:22:23 yes because it needs to be deleted if the event wa
+ if (event_in_dip)
+ CreateInputEventData(*event_in_dip.get(), &events);
+ else
+ CreateInputEventData(event, &events);
// Allow the user gesture to be pending after the plugin handles the
// event. This allows out-of-process plugins to respond to the user
@@ -1256,6 +1267,14 @@ void PepperPluginInstanceImpl::ViewChanged(
view_data_.css_scale =
container_->pageZoomFactor() * container_->pageScaleFactor();
+ float windowToViewportScale =
+ render_frame()->GetRenderWidget()->convertWindowToViewport(1.0f);
+ viewport_to_dip_scale_ = 1.0f / windowToViewportScale;
+ ConvertRectToDIP(&view_data_.rect);
+ ConvertRectToDIP(&view_data_.clip_rect);
+ view_data_.css_scale *= viewport_to_dip_scale_;
+ view_data_.device_scale /= viewport_to_dip_scale_;
+
gfx::Size scroll_offset =
container_->element().document().frame()->scrollOffset();
view_data_.scroll_offset = PP_MakePoint(scroll_offset.width(),
@@ -3299,4 +3318,18 @@ void PepperPluginInstanceImpl::RecordFlashJavaScriptUse() {
}
}
+void PepperPluginInstanceImpl::ConvertRectToDIP(PP_Rect* rect) const {
+ rect->point.x *= viewport_to_dip_scale_;
+ rect->point.y *= viewport_to_dip_scale_;
+ rect->size.width *= viewport_to_dip_scale_;
+ rect->size.height *= viewport_to_dip_scale_;
+}
+
+void PepperPluginInstanceImpl::ConvertDIPToViewport(gfx::Rect* rect) const {
+ rect->set_x(rect->x() / viewport_to_dip_scale_);
+ rect->set_y(rect->y() / viewport_to_dip_scale_);
+ rect->set_width(rect->width() / viewport_to_dip_scale_);
+ rect->set_height(rect->height() / viewport_to_dip_scale_);
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698