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

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..e9ba90e67dbdba89ba8bb6e313a3ba83422ef02c 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"
@@ -532,6 +533,7 @@ PepperPluginInstanceImpl::PepperPluginInstanceImpl(
isolate_(v8::Isolate::GetCurrent()),
is_deleted_(false),
initialized_(false),
+ viewport_to_dip_scale_(1.f),
view_change_weak_ptr_factory_(this),
weak_factory_(this) {
pp_instance_ = HostGlobals::Get()->AddInstance(this);
@@ -1078,21 +1080,23 @@ bool PepperPluginInstanceImpl::IsPluginAcceptingCompositionEvents() const {
gfx::Rect PepperPluginInstanceImpl::GetCaretBounds() const {
if (!text_input_caret_set_) {
+ gfx::Rect rect(view_data_.rect.point.x,
+ view_data_.rect.point.y + view_data_.rect.size.height,
+ 0, 0);
// If it is never set by the plugin, use the bottom left corner.
bbudge 2016/01/21 00:34:51 Comment seems misplaced. Should it be before setti
oshima 2016/01/21 01:12:07 Done. I also removed else (I was going to fix it b
- return gfx::Rect(view_data_.rect.point.x,
- view_data_.rect.point.y + view_data_.rect.size.height,
- 0,
- 0);
+ ConvertDIPToViewport(&rect);
+ return rect;
+ } else {
+ // TODO(kinaba) Take CSS transformation into accont.
bbudge 2016/01/21 00:34:51 sp. account
oshima 2016/01/21 01:12:07 Done.
+ // TODO(kinaba) Take bounding_box into account. On some platforms, an
bbudge 2016/01/21 00:34:51 It's not clear to me what 'bounding_box' is referr
oshima 2016/01/21 01:12:07 I believe kinaba@ meant |text_input_caret_bounds_|
+ // "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;
}
-
- // 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 caret(text_input_caret_);
- caret.Offset(view_data_.rect.point.x, view_data_.rect.point.y);
- return caret;
}
bool PepperPluginInstanceImpl::HandleInputEvent(
@@ -1105,6 +1109,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 +1143,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_));
+ 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 +1266,14 @@ void PepperPluginInstanceImpl::ViewChanged(
view_data_.css_scale =
container_->pageZoomFactor() * container_->pageScaleFactor();
+ float windowToViewportScale =
+ render_frame()->GetRenderWidget()->convertWindowToViewport(1.0f);
bbudge 2016/01/21 00:34:51 nit: Mixing 1.0f and 1.f. 1.0f seems more consist
oshima 2016/01/21 01:12:07 Done
+ viewport_to_dip_scale_ = 1.f / 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 +3317,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