Bug 918535 - Update focus state in UIABridge when focus moves to non-editable content. Addresses double-tap required to dismiss soft keyboard on start tab. f=rsilveira r=bbondy
authorJim Mathies <jmathies@mozilla.com>
Mon, 30 Sep 2013 14:20:38 -0500
changeset 149344 533241317d0f430971f66f11aa8dd688c0da0408
parent 149343 3fb7c71990d06392ec23a41a089ce6bff37afe15
child 149345 2fa72efe5bd3579e65bd452c6bee8aa41c47743a
push id25385
push useremorley@mozilla.com
push dateTue, 01 Oct 2013 09:25:32 +0000
treeherdermozilla-central@a55240c523be [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbondy
bugs918535
milestone27.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 918535 - Update focus state in UIABridge when focus moves to non-editable content. Addresses double-tap required to dismiss soft keyboard on start tab. f=rsilveira r=bbondy
widget/windows/winrt/UIABridge.cpp
--- a/widget/windows/winrt/UIABridge.cpp
+++ b/widget/windows/winrt/UIABridge.cpp
@@ -164,16 +164,36 @@ ChildHasFocus(nsCOMPtr<nsIAccessible>& a
   return (((access->NativeState() & mozilla::a11y::states::EDITABLE) > 0) &&
            ((access->NativeState() & mozilla::a11y::states::READONLY) == 0));
 }
 
 HRESULT
 UIABridge::FocusChangeEvent()
 {
   LogFunction();
+  if (!Connected()) {
+    return UIA_E_ELEMENTNOTAVAILABLE;
+  }
+
+  nsCOMPtr<nsIAccessible> child;
+  mAccessible->GetFocusedChild(getter_AddRefs(child));
+  if (!child) {
+    return S_OK;
+  }
+
+  if (!ChildHasFocus(child)) {
+    ComPtr<IUIAElement> element;
+    gElement.As(&element);
+    if (!element) {
+      return S_OK;
+    }
+    element->ClearFocus();
+    UiaRaiseAutomationEvent(this, UIA_AutomationFocusChangedEventId);
+  }
+
   return S_OK;
 }
 
 // IRawElementProviderFragmentRoot
 
 HRESULT
 UIABridge::ElementProviderFromPoint(double x, double y, IRawElementProviderFragment ** retVal)
 {