Index: content/browser/renderer_host/render_widget_host_view_aura.cc |
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc |
index a54d860bc9e646cb9c5d0c9b52559e8042e2f17f..cd97c39fe691fc1b5398abd4db5cff1c1468558d 100644 |
--- a/content/browser/renderer_host/render_widget_host_view_aura.cc |
+++ b/content/browser/renderer_host/render_widget_host_view_aura.cc |
@@ -29,6 +29,7 @@ |
#include "content/browser/renderer_host/input/synthetic_gesture_target_aura.h" |
#include "content/browser/renderer_host/overscroll_controller.h" |
#include "content/browser/renderer_host/render_view_host_delegate.h" |
+#include "content/browser/renderer_host/render_view_host_delegate_view.h" |
#include "content/browser/renderer_host/render_view_host_impl.h" |
#include "content/browser/renderer_host/render_widget_host_impl.h" |
#include "content/browser/renderer_host/ui_events_helper.h" |
@@ -1230,6 +1231,58 @@ gfx::GLSurfaceHandle RenderWidgetHostViewAura::GetCompositingSurface() { |
return ImageTransportFactory::GetInstance()->GetSharedSurfaceHandle(); |
} |
+void RenderWidgetHostViewAura::ShowDisambiguationPopup( |
+ const gfx::Rect& target_rect, |
+ const SkBitmap& zoomed_bitmap) { |
+ // |target_rect| is provided in pixels, not DIPs. So we convert it to DIPs |
+ // by scaling it by the inverse of the device scale factor. |
+ gfx::RectF screen_target_rect_f(target_rect); |
+ screen_target_rect_f.Scale(1.0f / current_device_scale_factor_); |
+ disambiguation_target_rect_ = gfx::ToEnclosingRect(screen_target_rect_f); |
sky
2014/09/11 14:53:43
Won't this conversion be losing? Will it matter?
luken
2014/09/17 00:00:48
Yes, it loses accuracy. No, it doesn't seem to mat
|
+ |
+ float scale = static_cast<float>(zoomed_bitmap.width()) / |
+ static_cast<float>(target_rect.width()); |
+ gfx::Size zoomed_size(gfx::ToCeiledSize( |
+ gfx::ScaleSize(disambiguation_target_rect_.size(), scale))); |
+ |
+ CopyFromCompositingSurface( |
+ disambiguation_target_rect_, |
+ zoomed_size, |
+ base::Bind(&RenderWidgetHostViewAura::DisambiguationPopupRendered, |
sky
2014/09/11 14:53:43
How do you know by the time this is returned that
luken
2014/09/17 00:00:48
I've added code to save the last_scroll_offset_ fo
sky
2014/09/19 15:19:23
Is that really enough? Might the dom or other rand
luken
2014/09/19 19:27:41
AFAICT we are already doing more than what this fe
sky
2014/09/22 15:01:30
Have you talked with any of the guys on the Androi
|
+ base::internal::SupportsWeakPtrBase::StaticAsWeakPtr |
+ <RenderWidgetHostViewAura>(this)), |
+ kN32_SkColorType); |
+} |
+ |
+void RenderWidgetHostViewAura::DisambiguationPopupRendered( |
+ bool success, |
+ const SkBitmap& result) { |
+ if (!success) |
+ return; |
+ |
+ // Use RenderViewHostDelegate to get to the WebContentsViewAura, which will |
+ // actually show the delegate. |
+ RenderViewHostDelegate* delegate = NULL; |
+ if (host_->IsRenderView()) |
+ delegate = RenderViewHost::From(host_)->GetDelegate(); |
+ RenderViewHostDelegateView* delegate_view = NULL; |
+ if (delegate) |
+ delegate_view = delegate->GetDelegateView(); |
+ if (delegate_view) |
+ delegate_view->ShowDisambiguationPopup(disambiguation_target_rect_, result); |
+} |
+ |
+void RenderWidgetHostViewAura::HideDisambiguationPopup() { |
+ RenderViewHostDelegate* delegate = NULL; |
+ if (host_->IsRenderView()) |
+ delegate = RenderViewHost::From(host_)->GetDelegate(); |
+ RenderViewHostDelegateView* delegate_view = NULL; |
+ if (delegate) |
+ delegate_view = delegate->GetDelegateView(); |
+ if (delegate_view) |
+ delegate_view->HideDisambiguationPopup(); |
+} |
+ |
bool RenderWidgetHostViewAura::LockMouse() { |
aura::Window* root_window = window_->GetRootWindow(); |
if (!root_window) |
@@ -1845,6 +1898,9 @@ void RenderWidgetHostViewAura::OnMouseEvent(ui::MouseEvent* event) { |
DismissOwnedPopups, |
reinterpret_cast<LPARAM>(toplevel_hwnd)); |
} |
+ // The Disambiguation popup does not parent itself from this window, so we |
+ // manually dismiss it. |
+ HideDisambiguationPopup(); |
sky
2014/09/11 14:53:43
Why is this in the ifdef? Also, it seems like the
luken
2014/09/17 00:00:48
I moved it outside of the ifdef. I wasn't able to
|
#endif |
blink::WebMouseWheelEvent mouse_wheel_event = |
MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent*>(event)); |