bug 886208 - don't force editor creation in HyperTextAccessible::NativeState() r=surkov
authorTrevor Saunders <trev.saunders@gmail.com>
Fri, 20 Dec 2013 11:53:58 -0500
changeset 162637 5ebb4c3f51e828f1692070e39fa2bf94556545f8
parent 162624 6996abc487ada8d2550d18f8d6ad6cd1f91d42bf
child 162638 9db7cf4cc385e37495c0f484ac607b8daf31a238
push id25965
push usercbook@mozilla.com
push dateThu, 09 Jan 2014 09:10:28 +0000
treeherdermozilla-central@99afe134bc7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssurkov
bugs886208
milestone29.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 886208 - don't force editor creation in HyperTextAccessible::NativeState() r=surkov
accessible/src/generic/HyperTextAccessible.cpp
accessible/tests/mochitest/elm/test_HTMLSpec.html
--- a/accessible/src/generic/HyperTextAccessible.cpp
+++ b/accessible/src/generic/HyperTextAccessible.cpp
@@ -22,16 +22,17 @@
 #include "nsIEditingSession.h"
 #include "nsIFrame.h"
 #include "nsFrameSelection.h"
 #include "nsILineIterator.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIPersistentProperties2.h"
 #include "nsIScrollableFrame.h"
 #include "nsIServiceManager.h"
+#include "nsITextControlElement.h"
 #include "nsTextFragment.h"
 #include "mozilla/Selection.h"
 #include "mozilla/MathAlgorithms.h"
 #include "gfxSkipChars.h"
 #include <algorithm>
 
 using namespace mozilla;
 using namespace mozilla::a11y;
@@ -97,18 +98,29 @@ HyperTextAccessible::NativeRole()
   return roles::TEXT_CONTAINER; // In ATK this works
 }
 
 uint64_t
 HyperTextAccessible::NativeState()
 {
   uint64_t states = AccessibleWrap::NativeState();
 
-  nsCOMPtr<nsIEditor> editor = GetEditor();
-  if (editor) {
+  nsCOMPtr<nsITextControlElement> textControl = do_QueryInterface(mContent);
+  bool editable = !!textControl;
+  Accessible* hyperText = this;
+  while (!editable && hyperText) {
+    if (hyperText->IsHyperText())
+      editable = hyperText->GetNode()->IsEditable();
+    if (hyperText->IsDoc())
+      break;
+
+    hyperText = hyperText->Parent();
+  }
+
+  if (editable) {
     states |= states::EDITABLE;
 
   } else if (mContent->Tag() == nsGkAtoms::article) {
     // We want <article> to behave like a document in terms of readonly state.
     states |= states::READONLY;
   }
 
   if (HasChildren())
--- a/accessible/tests/mochitest/elm/test_HTMLSpec.html
+++ b/accessible/tests/mochitest/elm/test_HTMLSpec.html
@@ -728,27 +728,39 @@
       //////////////////////////////////////////////////////////////////////////
       // HTML:input@type="password"
 
       obj = {
         role: ROLE_PASSWORD_TEXT,
         states: STATE_PROTECTED,
         extraStates: EXT_STATE_EDITABLE,
         actions: "activate",
-        children: [ ]
+        children: [
+        {
+            role: ROLE_TEXT_LEAF
+          }
+        ]
       };
       testElm("input_password", obj);
+      ok(getAccessible("input_password").firstChild.name != "44",
+         "text leaf for password shouldn't have its real value as its name!");
 
       obj = {
         role: ROLE_PASSWORD_TEXT,
         states: STATE_PROTECTED | STATE_READONLY,
         actions: "activate",
-        children: [ ]
+        children: [
+        {
+            role: ROLE_TEXT_LEAF
+          }
+        ]
       };
       testElm("input_password_readonly", obj);
+      ok(getAccessible("input_password_readonly").firstChild.name != "44",
+         "text leaf for password shouldn't have its real value as its name!");
 
       //////////////////////////////////////////////////////////////////////////
       // HTML:input@type="radio"
 
       obj = {
         role: ROLE_RADIOBUTTON,
         states: STATE_CHECKABLE,
         absentStates: STATE_CHECKED,