diff options
7 files changed, 33 insertions, 25 deletions
diff --git a/content/browser/accessibility/browser_accessibility_manager.cc b/content/browser/accessibility/browser_accessibility_manager.cc index fb4d8d4..c20474f 100644 --- a/content/browser/accessibility/browser_accessibility_manager.cc +++ b/content/browser/accessibility/browser_accessibility_manager.cc @@ -135,18 +135,12 @@ void BrowserAccessibilityManager::GotMouseDown() { NotifyAccessibilityEvent(AccessibilityNotificationFocusChanged, focus_); } -bool BrowserAccessibilityManager::IsOSKAllowed() { - return osk_state_ == OSK_ALLOWED_WITHIN_FOCUSED_OBJECT || - osk_state_ == OSK_ALLOWED; -} +bool BrowserAccessibilityManager::IsOSKAllowed(const gfx::Rect& bounds) { + if (!delegate_ || !delegate_->HasFocus()) + return false; -bool BrowserAccessibilityManager::ShouldRestrictOSKToControlBounds() { - AccessibilityMode mode = - BrowserAccessibilityStateImpl::GetInstance()->GetAccessibilityMode(); - if (mode == AccessibilityModeEditableTextOnly) - return osk_state_ == OSK_ALLOWED_WITHIN_FOCUSED_OBJECT; - else - return true; + gfx::Point touch_point = delegate_->GetLastTouchEventLocation(); + return bounds.Contains(touch_point); } void BrowserAccessibilityManager::Remove(int32 child_id, int32 renderer_id) { diff --git a/content/browser/accessibility/browser_accessibility_manager.h b/content/browser/accessibility/browser_accessibility_manager.h index b7d99f8..1694c7d 100644 --- a/content/browser/accessibility/browser_accessibility_manager.h +++ b/content/browser/accessibility/browser_accessibility_manager.h @@ -35,6 +35,7 @@ class CONTENT_EXPORT BrowserAccessibilityDelegate { int acc_obj_id, int start_offset, int end_offset) = 0; virtual bool HasFocus() const = 0; virtual gfx::Rect GetViewBounds() const = 0; + virtual gfx::Point GetLastTouchEventLocation() const = 0; }; class CONTENT_EXPORT BrowserAccessibilityFactory { @@ -150,12 +151,7 @@ class CONTENT_EXPORT BrowserAccessibilityManager { // Is the on-screen keyboard allowed to be shown, in response to a // focus event on a text box? - bool IsOSKAllowed(); - - // Should the on-screen keyboard be shown only when a touch is within the - // control bounds? If false, the OSK should be shown if any touch event leads - // to a control getting focus. - bool ShouldRestrictOSKToControlBounds(); + bool IsOSKAllowed(const gfx::Rect& bounds); protected: BrowserAccessibilityManager( diff --git a/content/browser/accessibility/browser_accessibility_win.cc b/content/browser/accessibility/browser_accessibility_win.cc index a9061ce..917e68c 100644 --- a/content/browser/accessibility/browser_accessibility_win.cc +++ b/content/browser/accessibility/browser_accessibility_win.cc @@ -255,11 +255,6 @@ STDMETHODIMP BrowserAccessibilityWin::accLocation(LONG* x_left, LONG* y_top, if (!target) return E_INVALIDARG; - // If we're not supposed to restrict the on-screen keyboard to the control - // bounds, get the bounds of this control from the root element's bounds. - while (target->parent() && !manager_->ShouldRestrictOSKToControlBounds()) - target = target->parent()->ToBrowserAccessibilityWin(); - gfx::Rect bounds = target->GetGlobalBoundsRect(); *x_left = bounds.x(); *y_top = bounds.y(); @@ -2578,7 +2573,7 @@ STDMETHODIMP BrowserAccessibilityWin::GetPatternProvider( if (IsEditableText()) { // The BrowserAccessibilityManager keeps track of instances when // we don't want to show the on-screen keyboard. - if (!manager_->IsOSKAllowed()) + if (!manager_->IsOSKAllowed(GetGlobalBoundsRect())) return E_NOTIMPL; DVLOG(1) << "Returning UIA text provider"; diff --git a/content/browser/renderer_host/render_widget_host_view_gtk.cc b/content/browser/renderer_host/render_widget_host_view_gtk.cc index b5dab88..80c011c 100644 --- a/content/browser/renderer_host/render_widget_host_view_gtk.cc +++ b/content/browser/renderer_host/render_widget_host_view_gtk.cc @@ -1523,6 +1523,11 @@ void RenderWidgetHostViewGtk::AccessibilitySetTextSelection( host_->AccessibilitySetTextSelection(acc_obj_id, start_offset, end_offset); } +gfx::Point RenderWidgetHostViewGtk::GetLastTouchEventLocation() const { + // Not needed on Linux. + return gfx::Point(); +} + void RenderWidgetHostViewGtk::OnAccessibilityNotifications( const std::vector<AccessibilityHostMsg_NotificationParams>& params) { if (!browser_accessibility_manager_.get()) { diff --git a/content/browser/renderer_host/render_widget_host_view_gtk.h b/content/browser/renderer_host/render_widget_host_view_gtk.h index 6e86079..a608a9a 100644 --- a/content/browser/renderer_host/render_widget_host_view_gtk.h +++ b/content/browser/renderer_host/render_widget_host_view_gtk.h @@ -166,6 +166,7 @@ class CONTENT_EXPORT RenderWidgetHostViewGtk int acc_obj_id, gfx::Point point) OVERRIDE; virtual void AccessibilitySetTextSelection( int acc_obj_id, int start_offset, int end_offset) OVERRIDE; + virtual gfx::Point GetLastTouchEventLocation() const OVERRIDE; // Get the root of the AtkObject* tree for accessibility. AtkObject* GetAccessible(); diff --git a/content/browser/renderer_host/render_widget_host_view_win.cc b/content/browser/renderer_host/render_widget_host_view_win.cc index b9e332a..e78a07e 100644 --- a/content/browser/renderer_host/render_widget_host_view_win.cc +++ b/content/browser/renderer_host/render_widget_host_view_win.cc @@ -490,6 +490,7 @@ RenderWidgetHostViewWin::RenderWidgetHostViewWin(RenderWidgetHost* widget) ALLOW_THIS_IN_INITIALIZER_LIST( touch_state_(new WebTouchState(this))), pointer_down_context_(false), + last_touch_location_(-1, -1), focus_on_editable_field_(false), received_focus_change_after_pointer_down_(false), touch_events_enabled_(false), @@ -1530,6 +1531,8 @@ void RenderWidgetHostViewWin::OnKillFocus(HWND window) { render_widget_host_->SetActive(false); render_widget_host_->Blur(); + last_touch_location_ = gfx::Point(-1, -1); + if (base::win::IsTsfAwareRequired()) ui::TsfBridge::GetInstance()->RemoveFocusedClient(this); } @@ -2244,8 +2247,12 @@ LRESULT RenderWidgetHostViewWin::OnTouchEvent(UINT message, WPARAM wparam, return 0; } - if (total == 1 && (points[0].dwFlags & TOUCHEVENTF_DOWN)) - pointer_down_context_ = true; + if (total == 1 && (points[0].dwFlags & TOUCHEVENTF_DOWN)) { + pointer_down_context_ = true; + last_touch_location_ = gfx::Point( + TOUCH_COORD_TO_PIXEL(points[0].x), + TOUCH_COORD_TO_PIXEL(points[0].y)); + } bool has_touch_handler = render_widget_host_->has_touch_handler() && touch_events_enabled_; @@ -2664,6 +2671,10 @@ void RenderWidgetHostViewWin::AccessibilitySetTextSelection( acc_obj_id, start_offset, end_offset); } +gfx::Point RenderWidgetHostViewWin::GetLastTouchEventLocation() const { + return last_touch_location_; +} + LRESULT RenderWidgetHostViewWin::OnGetObject(UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnGetObject"); diff --git a/content/browser/renderer_host/render_widget_host_view_win.h b/content/browser/renderer_host/render_widget_host_view_win.h index 8d388b0..034a9bb 100644 --- a/content/browser/renderer_host/render_widget_host_view_win.h +++ b/content/browser/renderer_host/render_widget_host_view_win.h @@ -237,6 +237,7 @@ class RenderWidgetHostViewWin int acc_obj_id, gfx::Point point) OVERRIDE; virtual void AccessibilitySetTextSelection( int acc_obj_id, int start_offset, int end_offset) OVERRIDE; + virtual gfx::Point GetLastTouchEventLocation() const OVERRIDE; // Overridden from ui::GestureEventHelper. virtual bool DispatchLongPressGestureEvent(ui::GestureEvent* event) OVERRIDE; @@ -559,6 +560,11 @@ class RenderWidgetHostViewWin // Set to true if we are in the context of a WM_POINTERDOWN message bool pointer_down_context_; + // The global x, y coordinates of the last point a touch event was + // received, used to determine if it's okay to open the on-screen + // keyboard. Reset when the window loses focus. + gfx::Point last_touch_location_; + // Set to true if the focus is currently on an editable field on the page. bool focus_on_editable_field_; |