Fix OSR PDF mouse events after keyboard input (issue #2078)

This commit is contained in:
Marshall Greenblatt 2017-06-30 16:30:30 -04:00
parent 408afd16d4
commit f54b5cdf96
4 changed files with 37 additions and 13 deletions

View File

@ -951,6 +951,11 @@ void CefRenderWidgetHostViewOSR::SetNeedsBeginFrames(bool enabled) {
} }
} }
void CefRenderWidgetHostViewOSR::ProcessKeyboardEvent(
const content::NativeWebKeyboardEvent& event) {
render_widget_host_->ForwardKeyboardEvent(event);
}
void CefRenderWidgetHostViewOSR::ProcessMouseEvent( void CefRenderWidgetHostViewOSR::ProcessMouseEvent(
const blink::WebMouseEvent& event, const blink::WebMouseEvent& event,
const ui::LatencyInfo& latency) { const ui::LatencyInfo& latency) {
@ -1175,9 +1180,10 @@ void CefRenderWidgetHostViewOSR::Invalidate(
void CefRenderWidgetHostViewOSR::SendKeyEvent( void CefRenderWidgetHostViewOSR::SendKeyEvent(
const content::NativeWebKeyboardEvent& event) { const content::NativeWebKeyboardEvent& event) {
TRACE_EVENT0("libcef", "CefRenderWidgetHostViewOSR::SendKeyEvent"); TRACE_EVENT0("libcef", "CefRenderWidgetHostViewOSR::SendKeyEvent");
if (!render_widget_host_) if (render_widget_host_ && render_widget_host_->GetView()) {
return; // Direct routing requires that events go directly to the View.
render_widget_host_->ForwardKeyboardEvent(event); render_widget_host_->GetView()->ProcessKeyboardEvent(event);
}
} }
void CefRenderWidgetHostViewOSR::SendMouseEvent( void CefRenderWidgetHostViewOSR::SendMouseEvent(
@ -1438,12 +1444,13 @@ void CefRenderWidgetHostViewOSR::SetDeviceScaleFactor() {
// Notify the guest hosts if any. // Notify the guest hosts if any.
for (auto guest_host_view : guest_host_views_) { for (auto guest_host_view : guest_host_views_) {
if (guest_host_view->render_widget_host() && content::RenderWidgetHostImpl* rwhi = guest_host_view->render_widget_host();
guest_host_view->render_widget_host()->delegate()) { if (!rwhi)
guest_host_view->render_widget_host() continue;
->delegate() if (rwhi->delegate())
->UpdateDeviceScaleFactor(new_scale_factor); rwhi->delegate()->UpdateDeviceScaleFactor(new_scale_factor);
} if (rwhi->GetView())
rwhi->GetView()->set_current_device_scale_factor(new_scale_factor);
} }
} }
@ -1574,6 +1581,8 @@ void CefRenderWidgetHostViewOSR::RegisterGuestViewFrameSwappedCallback(
base::MakeUnique<base::Closure>(base::Bind( base::MakeUnique<base::Closure>(base::Bind(
&CefRenderWidgetHostViewOSR::OnGuestViewFrameSwapped, &CefRenderWidgetHostViewOSR::OnGuestViewFrameSwapped,
weak_ptr_factory_.GetWeakPtr(), base::Unretained(guest_host_view)))); weak_ptr_factory_.GetWeakPtr(), base::Unretained(guest_host_view))));
guest_host_view->set_current_device_scale_factor(
current_device_scale_factor_);
} }
void CefRenderWidgetHostViewOSR::OnGuestViewFrameSwapped( void CefRenderWidgetHostViewOSR::OnGuestViewFrameSwapped(

View File

@ -177,6 +177,8 @@ class CefRenderWidgetHostViewOSR : public content::RenderWidgetHostViewBase,
void SetNeedsBeginFrames(bool enabled) override; void SetNeedsBeginFrames(bool enabled) override;
void ProcessKeyboardEvent(const content::NativeWebKeyboardEvent& event)
override;
void ProcessMouseEvent(const blink::WebMouseEvent& event, void ProcessMouseEvent(const blink::WebMouseEvent& event,
const ui::LatencyInfo& latency) override; const ui::LatencyInfo& latency) override;
void ProcessMouseWheelEvent(const blink::WebMouseWheelEvent& event, void ProcessMouseWheelEvent(const blink::WebMouseWheelEvent& event,

View File

@ -72,6 +72,9 @@ patches = [
# #
# Support creation of captionless windows with resizable borders. # Support creation of captionless windows with resizable borders.
# https://bitbucket.org/chromiumembedded/cef/issues/1749 # https://bitbucket.org/chromiumembedded/cef/issues/1749
#
# Support configuration of RWHVGuest device scale factor.
# https://bitbucket.org/chromiumembedded/cef/issues/2078
'name': 'views_widget_180_1481_1565_1677_1749', 'name': 'views_widget_180_1481_1565_1677_1749',
}, },
{ {

View File

@ -26,7 +26,7 @@ index 8c862b6..d9394c7 100644
return renderer_frame_number_; return renderer_frame_number_;
} }
diff --git content/browser/renderer_host/render_widget_host_view_base.h content/browser/renderer_host/render_widget_host_view_base.h diff --git content/browser/renderer_host/render_widget_host_view_base.h content/browser/renderer_host/render_widget_host_view_base.h
index 3f0cdab..581b984 100644 index 3f0cdab..b0128a1 100644
--- content/browser/renderer_host/render_widget_host_view_base.h --- content/browser/renderer_host/render_widget_host_view_base.h
+++ content/browser/renderer_host/render_widget_host_view_base.h +++ content/browser/renderer_host/render_widget_host_view_base.h
@@ -73,6 +73,7 @@ class BrowserAccessibilityDelegate; @@ -73,6 +73,7 @@ class BrowserAccessibilityDelegate;
@ -37,7 +37,17 @@ index 3f0cdab..581b984 100644
class SyntheticGestureTarget; class SyntheticGestureTarget;
class TextInputManager; class TextInputManager;
class WebCursor; class WebCursor;
@@ -119,6 +120,8 @@ class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView, @@ -88,6 +89,9 @@ class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView,
float current_device_scale_factor() const {
return current_device_scale_factor_;
}
+ void set_current_device_scale_factor(float scale_factor) {
+ current_device_scale_factor_ = scale_factor;
+ }
// Returns the focused RenderWidgetHost inside this |view|'s RWH.
RenderWidgetHostImpl* GetFocusedWidget() const;
@@ -119,6 +123,8 @@ class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView,
void EndFrameSubscription() override; void EndFrameSubscription() override;
void FocusedNodeTouched(const gfx::Point& location_dips_screen, void FocusedNodeTouched(const gfx::Point& location_dips_screen,
bool editable) override; bool editable) override;
@ -46,7 +56,7 @@ index 3f0cdab..581b984 100644
// This only needs to be overridden by RenderWidgetHostViewBase subclasses // This only needs to be overridden by RenderWidgetHostViewBase subclasses
// that handle content embedded within other RenderWidgetHostViews. // that handle content embedded within other RenderWidgetHostViews.
@@ -353,6 +356,12 @@ class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView, @@ -353,6 +359,12 @@ class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView,
// helps to position the full screen widget on the correct monitor. // helps to position the full screen widget on the correct monitor.
virtual void InitAsFullscreen(RenderWidgetHostView* reference_host_view) = 0; virtual void InitAsFullscreen(RenderWidgetHostView* reference_host_view) = 0;
@ -59,7 +69,7 @@ index 3f0cdab..581b984 100644
// Sets the cursor to the one associated with the specified cursor_type // Sets the cursor to the one associated with the specified cursor_type
virtual void UpdateCursor(const WebCursor& cursor) = 0; virtual void UpdateCursor(const WebCursor& cursor) = 0;
@@ -454,6 +463,10 @@ class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView, @@ -454,6 +466,10 @@ class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView,
// destroyed before the RWHV is destroyed. // destroyed before the RWHV is destroyed.
TextInputManager* text_input_manager_; TextInputManager* text_input_manager_;