Backing out fix for bug 372367 as it causes startup crashes when a screen reader is running
authoraaronleventhal@moonset.net
Thu, 05 Apr 2007 14:52:03 -0700
changeset 372 fd8c349072a16a404b5f1c7d7011c41d2cee3bd7
parent 371 3a736a37c282cc0130b7e6cfee644dcaa67b67b0
child 373 c3cc17feaff58ec4bd8f03e63ddc060bd40dce03
push id1
push userbsmedberg@mozilla.com
push dateThu, 20 Mar 2008 16:49:24 +0000
treeherdermozilla-central@61007906a1f8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs372367
milestone1.9a4pre
Backing out fix for bug 372367 as it causes startup crashes when a screen reader is running
accessible/public/nsIAccessible.idl
accessible/src/base/nsAccessibilityAtomList.h
accessible/src/base/nsAccessible.cpp
accessible/src/base/nsBaseWidgetAccessible.cpp
accessible/src/html/nsHTMLFormControlAccessible.cpp
accessible/src/xul/nsXULFormControlAccessible.cpp
--- a/accessible/public/nsIAccessible.idl
+++ b/accessible/public/nsIAccessible.idl
@@ -52,17 +52,17 @@ interface nsIDOMDOMStringList;
  * Can also be used by in-process accessibility clients to get information
  * about objects in the accessible tree. The accessible tree is a subset of 
  * nodes in the DOM tree -- such as documents, focusable elements and text.
  * Mozilla creates the implementations of nsIAccessible on demand.
  * See http://www.mozilla.org/projects/ui/accessibility for more information.
  *
  * @status UNDER_REVIEW
  */
-[scriptable, uuid(b3674866-49a9-4cf2-bfea-c00be2d4a695)]
+[scriptable, uuid(3494b81a-1d90-491a-be34-7893f8e27117)]
 interface nsIAccessible : nsISupports
 {
   /**
    * Parent node in accessible tree.
    */
   readonly attribute nsIAccessible parent;
 
   /**
@@ -161,16 +161,22 @@ interface nsIAccessible : nsISupports
    * @param aState - the first bit field (see nsIAccessibleStates::STATE_*
    *                 constants)
    * @param aExtraState - the second bit field
    *                      (see nsIAccessibleStates::EXT_STATE_* constants)
    */
   void getFinalState(out unsigned long aState, out unsigned long aExtraState);
 
   /**
+   * True if this element is live in an editor.
+   * False if the content is being displayed but not edited. 
+   */
+  readonly attribute boolean isEditable;
+
+  /**
    * Help text associated with node
    */
   readonly attribute AString help;
 
   /**
    * Focused accessible child of node
    */
   readonly attribute nsIAccessible focusedChild;
--- a/accessible/src/base/nsAccessibilityAtomList.h
+++ b/accessible/src/base/nsAccessibilityAtomList.h
@@ -140,17 +140,16 @@ ACCESSIBILITY_ATOM(flowto, "flowto")
 ACCESSIBILITY_ATOM(labelledby, "labelledby")
 ACCESSIBILITY_ATOM(owns, "owns")
 
   // Alphabetical list of attributes
 ACCESSIBILITY_ATOM(acceltext, "acceltext")
 ACCESSIBILITY_ATOM(accesskey, "accesskey")
 ACCESSIBILITY_ATOM(alt, "alt")
 ACCESSIBILITY_ATOM(anonid, "anonid") // Used for ID's in XBL
-ACCESSIBILITY_ATOM(autocomplete, "autocomplete") // Used as attribute value too
 ACCESSIBILITY_ATOM(control, "control")
 ACCESSIBILITY_ATOM(data, "data")
 ACCESSIBILITY_ATOM(disabled, "disabled")
 ACCESSIBILITY_ATOM(editable, "editable")
 ACCESSIBILITY_ATOM(_for, "for")
 ACCESSIBILITY_ATOM(href, "href")
 ACCESSIBILITY_ATOM(id, "id")
 ACCESSIBILITY_ATOM(lang, "lang")
--- a/accessible/src/base/nsAccessible.cpp
+++ b/accessible/src/base/nsAccessible.cpp
@@ -2715,16 +2715,22 @@ NS_IMETHODIMP nsAccessible::GetAccessibl
 
 /* void extendSelection (); */
 NS_IMETHODIMP nsAccessible::ExtendSelection()
 {
   // XXX Should be implemented, but not high priority
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
+NS_IMETHODIMP nsAccessible::GetIsEditable(PRBool *aIsEditable)
+{
+  *aIsEditable = PR_FALSE;
+  return NS_OK;
+}
+
 /* [noscript] void getNativeInterface(out voidPtr aOutAccessible); */
 NS_IMETHODIMP nsAccessible::GetNativeInterface(void **aOutAccessible)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 void nsAccessible::DoCommandCallback(nsITimer *aTimer, void *aClosure)
 {
--- a/accessible/src/base/nsBaseWidgetAccessible.cpp
+++ b/accessible/src/base/nsBaseWidgetAccessible.cpp
@@ -144,32 +144,31 @@ nsLinkableAccessible::GetState(PRUint32 
   }
   if (mActionContent && !mActionContent->IsFocusable()) {
     // Links must have href or tabindex
     *aState &= ~nsIAccessibleStates::STATE_FOCUSABLE;
   }
 
   // XXX What if we're in a contenteditable container?
   //     We may need to go up the parent chain unless a better API is found
-  nsCOMPtr<nsIAccessible> docAccessible =
+  nsCOMPtr<nsIAccessible> docAccessible = 
     do_QueryInterface(nsCOMPtr<nsIAccessibleDocument>(GetDocAccessible()));
   if (docAccessible) {
-    PRUint32 docState = 0, docExtraState = 0;
-    rv = docAccessible->GetFinalState(&docState, &docExtraState);
-    if (NS_SUCCEEDED(rv) &&
-        (docExtraState & nsIAccessibleStates::EXT_STATE_EDITABLE)) {
+    PRBool isEditable;
+    docAccessible->GetIsEditable(&isEditable);
+    if (isEditable) {
       // Links not focusable in editor
       *aState &= ~(nsIAccessibleStates::STATE_FOCUSED |
                    nsIAccessibleStates::STATE_FOCUSABLE);
     }
   }
-
   return NS_OK;
 }
 
+
 NS_IMETHODIMP nsLinkableAccessible::GetValue(nsAString& _retval)
 {
   if (mIsLink) {
     nsCOMPtr<nsIDOMNode> linkNode(do_QueryInterface(mActionContent));
     nsCOMPtr<nsIPresShell> presShell(do_QueryReferent(mWeakShell));
     if (linkNode && presShell)
       return presShell->GetLinkLocation(linkNode, _retval);
   }
--- a/accessible/src/html/nsHTMLFormControlAccessible.cpp
+++ b/accessible/src/html/nsHTMLFormControlAccessible.cpp
@@ -353,18 +353,17 @@ nsHTML4ButtonAccessible::GetState(PRUint
 
 // --- textfield -----
 
 nsHTMLTextFieldAccessible::nsHTMLTextFieldAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
 nsHyperTextAccessible(aNode, aShell)
 {
 }
 
-NS_IMPL_ISUPPORTS_INHERITED1(nsHTMLTextFieldAccessible, nsHyperTextAccessible,
-                             nsIAccessibleText)
+NS_IMPL_ISUPPORTS_INHERITED2(nsHTMLTextFieldAccessible, nsAccessible, nsIAccessibleText, nsIAccessibleEditableText)
 
 NS_IMETHODIMP nsHTMLTextFieldAccessible::Init()
 {
   CheckForEditor();
   return nsHyperTextAccessible::Init();
 }
 
 NS_IMETHODIMP nsHTMLTextFieldAccessible::Shutdown()
@@ -429,56 +428,54 @@ nsHTMLTextFieldAccessible::GetState(PRUi
       *aState |= nsIAccessibleStates::STATE_HASPOPUP;
     }
   }
 
   if (content->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::readonly)) {
     *aState |= nsIAccessibleStates::STATE_READONLY;
   }
 
-  if (!aExtraState || !(*aExtraState & nsIAccessibleStates::EXT_STATE_EDITABLE))
+  if (!aExtraState)
     return NS_OK;
 
-  nsCOMPtr<nsIDOMHTMLInputElement> htmlInput(do_QueryInterface(mDOMNode));
+  nsCOMPtr<nsIDOMHTMLInputElement> htmlInput(do_QueryInterface(mDOMNode, &rv));
   // Is it an <input> or a <textarea> ?
   *aExtraState |= htmlInput ? nsIAccessibleStates::EXT_STATE_SINGLE_LINE :
                               nsIAccessibleStates::EXT_STATE_MULTI_LINE;
 
-  nsCOMPtr<nsIContent> bindingContent = content->GetBindingParent();
-  if (bindingContent &&
-      bindingContent->NodeInfo()->Equals(nsAccessibilityAtoms::textbox,
-                                         kNameSpaceID_XUL) &&
-      bindingContent->AttrValueIs(kNameSpaceID_None, nsAccessibilityAtoms::type,
-                                  nsAccessibilityAtoms::autocomplete,
-                                  eIgnoreCase)) {
-    // If parent is XUL textbox and value of @type attribute is "autocomplete",
-    // then this accessible supports autocompletion.
-    *aExtraState |= nsIAccessibleStates::EXT_STATE_SUPPORTS_AUTOCOMPLETION;
-  } else if (gIsFormFillEnabled && htmlInput &&
-             !(*aState & nsIAccessibleStates::STATE_PROTECTED)) {
-    // Check to see if autocompletion is allowed on this input. We don't expose
-    // it for password fields even though the entire password can be remembered
-    // for a page if the user asks it to be. However, the kind of autocomplete
-    // we're talking here is based on what the user types, where a popup of
-    // possible choices comes up.
-    nsAutoString autocomplete;
-    content->GetAttr(kNameSpaceID_None, nsAccessibilityAtoms::autocomplete,
-                     autocomplete);
-
-    if (!autocomplete.LowerCaseEqualsLiteral("off")) {
-      nsCOMPtr<nsIDOMHTMLFormElement> form;
-      htmlInput->GetForm(getter_AddRefs(form));
-      nsCOMPtr<nsIContent> formContent(do_QueryInterface(form));
-      if (formContent) {
-        formContent->GetAttr(kNameSpaceID_None,
-                     nsAccessibilityAtoms::autocomplete, autocomplete);
+  const PRUint32 kNonEditableStates = nsIAccessibleStates::STATE_READONLY |
+                                      nsIAccessibleStates::STATE_UNAVAILABLE;
+  if (0 == (*aState & kNonEditableStates)) {
+    *aExtraState |= nsIAccessibleStates::EXT_STATE_EDITABLE;
+    nsCOMPtr<nsIContent> content = do_QueryInterface(mDOMNode);
+    if (content && (content = content->GetBindingParent()) != nsnull &&
+        content->NodeInfo()->Equals(nsAccessibilityAtoms::textbox, kNameSpaceID_XUL)) {
+      // If parent is XUL textbox, then it supports autocompletion if type="autocomplete"
+      if (content->AttrValueIs(kNameSpaceID_None, nsAccessibilityAtoms::type,
+                               NS_LITERAL_STRING("autocomplete"), eIgnoreCase)) {
+        *aExtraState |= nsIAccessibleStates::EXT_STATE_SUPPORTS_AUTOCOMPLETION;
       }
-
-      if (!formContent || !autocomplete.LowerCaseEqualsLiteral("off"))
-        *aExtraState |= nsIAccessibleStates::EXT_STATE_SUPPORTS_AUTOCOMPLETION;
+    } else if (gIsFormFillEnabled && htmlInput &&
+               !(*aState & nsIAccessibleStates::STATE_PROTECTED)) {
+      // Check to see if autocompletion is allowed on this input
+      // We don't expose it for password fields even though the entire password can
+      // be remembered for a page if the user asks it to be.
+      // However, the kind of autocomplete we're talking here is based on what
+      // the user types, where a popup of possible choices comes up.
+      nsAutoString autocomplete;
+      htmlInput->GetAttribute(NS_LITERAL_STRING("autocomplete"), autocomplete);
+      if (!autocomplete.LowerCaseEqualsLiteral("off")) {
+        nsCOMPtr<nsIDOMHTMLFormElement> form;
+        htmlInput->GetForm(getter_AddRefs(form));
+        if (form)
+          form->GetAttribute(NS_LITERAL_STRING("autocomplete"), autocomplete);
+        if (!form || !autocomplete.LowerCaseEqualsLiteral("off")) {
+          *aExtraState |= nsIAccessibleStates::EXT_STATE_SUPPORTS_AUTOCOMPLETION;
+        }
+      }
     }
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP nsHTMLTextFieldAccessible::GetNumActions(PRUint8 *_retval)
 {
--- a/accessible/src/xul/nsXULFormControlAccessible.cpp
+++ b/accessible/src/xul/nsXULFormControlAccessible.cpp
@@ -670,18 +670,17 @@ nsXULToolbarSeparatorAccessible::GetStat
   * XUL Textfield
   */
 
 nsXULTextFieldAccessible::nsXULTextFieldAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell) :
  nsHyperTextAccessible(aNode, aShell)
 {
 }
 
-NS_IMPL_ISUPPORTS_INHERITED1(nsXULTextFieldAccessible, nsHyperTextAccessible,
-                             nsIAccessibleText)
+NS_IMPL_ISUPPORTS_INHERITED2(nsXULTextFieldAccessible, nsAccessible, nsIAccessibleText, nsIAccessibleEditableText)
 
 NS_IMETHODIMP nsXULTextFieldAccessible::Init()
 {
   CheckForEditor();
   return nsHyperTextAccessible::Init();
 }
 
 NS_IMETHODIMP nsXULTextFieldAccessible::Shutdown()
@@ -776,16 +775,21 @@ nsXULTextFieldAccessible::GetState(PRUin
     return NS_OK;
 
   PRBool isMultiLine = content->HasAttr(kNameSpaceID_None,
                                         nsAccessibilityAtoms::multiline);
 
   *aExtraState |= (isMultiLine ? nsIAccessibleStates::EXT_STATE_MULTI_LINE :
                                  nsIAccessibleStates::EXT_STATE_SINGLE_LINE);
 
+  const PRUint32 kNonEditableStates = nsIAccessibleStates::STATE_READONLY |
+                                      nsIAccessibleStates::STATE_UNAVAILABLE;
+  if (0 == (*aState & kNonEditableStates))
+    *aExtraState |= nsIAccessibleStates::EXT_STATE_EDITABLE;
+
   return NS_OK;
 }
 
 NS_IMETHODIMP nsXULTextFieldAccessible::GetRole(PRUint32 *aRole)
 {
   *aRole = nsIAccessibleRole::ROLE_ENTRY;
   nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
   if (content &&