diff --git a/accessible/src/base/nsAccUtils.h b/accessible/src/base/nsAccUtils.h index 2fb31dcc732..282b14a951c 100644 --- a/accessible/src/base/nsAccUtils.h +++ b/accessible/src/base/nsAccUtils.h @@ -279,6 +279,19 @@ public: return state; } + /** + * Return the extended state for the given accessible. + */ + static PRUint32 ExtendedState(nsIAccessible *aAcc) + { + PRUint32 state = 0; + PRUint32 extstate = 0; + if (aAcc) + aAcc->GetState(&state, &extstate); + + return extstate; + } + /** * Get the ARIA attribute characteristics for a given ARIA attribute. * diff --git a/accessible/src/base/nsRootAccessible.cpp b/accessible/src/base/nsRootAccessible.cpp index ac4fa1ce636..ff26cbeadd5 100644 --- a/accessible/src/base/nsRootAccessible.cpp +++ b/accessible/src/base/nsRootAccessible.cpp @@ -401,11 +401,12 @@ void nsRootAccessible::TryFireEarlyLoadEvent(nsIDOMNode *aDocNode) } } -PRBool nsRootAccessible::FireAccessibleFocusEvent(nsIAccessible *aAccessible, - nsIDOMNode *aNode, - nsIDOMEvent *aFocusEvent, - PRBool aForceEvent, - PRBool aIsAsynch) +PRBool +nsRootAccessible::FireAccessibleFocusEvent(nsIAccessible *aAccessible, + nsIDOMNode *aNode, + nsIDOMEvent *aFocusEvent, + PRBool aForceEvent, + PRBool aIsAsynch) { if (mCaretAccessible) { nsCOMPtr nsevent(do_QueryInterface(aFocusEvent)); @@ -531,10 +532,16 @@ PRBool nsRootAccessible::FireAccessibleFocusEvent(nsIAccessible *aAccessible, if (docAccessible) { // Doc is gaining focus, but actual focus may be on an element within document nsCOMPtr realFocusedNode = GetCurrentFocus(); - if (realFocusedNode != aNode || realFocusedNode == mDOMNode) { + if ((realFocusedNode != aNode || realFocusedNode == mDOMNode) && + !(nsAccUtils::ExtendedState(finalFocusAccessible) & + nsIAccessibleStates::EXT_STATE_EDITABLE)) { // Suppress document focus, because real DOM focus will be fired next, - // and that's what we care about + // except in the case of editable documents because we can't rely on a + // followup focus event for an element in an editable document. // Make sure we never fire focus for the nsRootAccessible (mDOMNode) + + // XXX todo dig deeper on editor focus inconsistency in bug 526313 + return PR_FALSE; } } diff --git a/accessible/tests/mochitest/Makefile.in b/accessible/tests/mochitest/Makefile.in index 5136b9b0ab5..8805989cf85 100644 --- a/accessible/tests/mochitest/Makefile.in +++ b/accessible/tests/mochitest/Makefile.in @@ -102,6 +102,7 @@ _TEST_FILES =\ test_events_flush.html \ test_events_focus.html \ test_events_focus.xul \ + test_events_focusdoc.html \ test_events_mutation.html \ test_events_scroll.xul \ test_events_tree.xul \ diff --git a/accessible/tests/mochitest/test_events_focusdoc.html b/accessible/tests/mochitest/test_events_focusdoc.html new file mode 100644 index 00000000000..3981d4922a7 --- /dev/null +++ b/accessible/tests/mochitest/test_events_focusdoc.html @@ -0,0 +1,102 @@ + + + + Accessible document focus event testing + + + + + + + + + + + + + + + + + Mozilla Bug 512058 + + + Mozilla Bug 512059 + + +

+ +
+  
+ +
+ +
+ + + +
+ +