Reversing backout of fix for bug 372367 as it is not the cause of startup crashes when a screen reader is running. Original patch by surkov, r=ginn.chen
authoraaronleventhal@moonset.net
Thu, 05 Apr 2007 15:14:08 -0700
changeset 374 3d777c35b040ed3ac703a8b87c697fcf4166efe9
parent 373 c3cc17feaff58ec4bd8f03e63ddc060bd40dce03
child 375 841d8d842583afdad584e06f80e31361867bda7b
push idunknown
push userunknown
push dateunknown
reviewersginn.chen
bugs372367
milestone1.9a4pre
Reversing backout of fix for bug 372367 as it is not the cause of startup crashes when a screen reader is running. Original patch by surkov, r=ginn.chen
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(3494b81a-1d90-491a-be34-7893f8e27117)]
+[scriptable, uuid(b3674866-49a9-4cf2-bfea-c00be2d4a695)]
 interface nsIAccessible : nsISupports
 {
   /**
    * Parent node in accessible tree.
    */
   readonly attribute nsIAccessible parent;
 
   /**
@@ -161,22 +161,16 @@ 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,16 +140,17 @@ 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,22 +2715,16 @@ 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,31 +144,32 @@ 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) {
-    PRBool isEditable;
-    docAccessible->GetIsEditable(&isEditable);
-    if (isEditable) {
+    PRUint32 docState = 0, docExtraState = 0;
+    rv = docAccessible->GetFinalState(&docState, &docExtraState);
+    if (NS_SUCCEEDED(rv) &&
+        (docExtraState & nsIAccessibleStates::EXT_STATE_EDITABLE)) {
       // 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,17 +353,18 @@ nsHTML4ButtonAccessible::GetState(PRUint
 
 // --- textfield -----
 
 nsHTMLTextFieldAccessible::nsHTMLTextFieldAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
 nsHyperTextAccessible(aNode, aShell)
 {
 }
 
-NS_IMPL_ISUPPORTS_INHERITED2(nsHTMLTextFieldAccessible, nsAccessible, nsIAccessibleText, nsIAccessibleEditableText)
+NS_IMPL_ISUPPORTS_INHERITED1(nsHTMLTextFieldAccessible, nsHyperTextAccessible,
+                             nsIAccessibleText)
 
 NS_IMETHODIMP nsHTMLTextFieldAccessible::Init()
 {
   CheckForEditor();
   return nsHyperTextAccessible::Init();
 }
 
 NS_IMETHODIMP nsHTMLTextFieldAccessible::Shutdown()
@@ -428,54 +429,56 @@ nsHTMLTextFieldAccessible::GetState(PRUi
       *aState |= nsIAccessibleStates::STATE_HASPOPUP;
     }
   }
 
   if (content->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::readonly)) {
     *aState |= nsIAccessibleStates::STATE_READONLY;
   }
 
-  if (!aExtraState)
+  if (!aExtraState || !(*aExtraState & nsIAccessibleStates::EXT_STATE_EDITABLE))
     return NS_OK;
 
-  nsCOMPtr<nsIDOMHTMLInputElement> htmlInput(do_QueryInterface(mDOMNode, &rv));
+  nsCOMPtr<nsIDOMHTMLInputElement> htmlInput(do_QueryInterface(mDOMNode));
   // Is it an <input> or a <textarea> ?
   *aExtraState |= htmlInput ? nsIAccessibleStates::EXT_STATE_SINGLE_LINE :
                               nsIAccessibleStates::EXT_STATE_MULTI_LINE;
 
-  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;
+  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);
       }
-    } 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;
-        }
-      }
+
+      if (!formContent || !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,17 +670,18 @@ nsXULToolbarSeparatorAccessible::GetStat
   * XUL Textfield
   */
 
 nsXULTextFieldAccessible::nsXULTextFieldAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell) :
  nsHyperTextAccessible(aNode, aShell)
 {
 }
 
-NS_IMPL_ISUPPORTS_INHERITED2(nsXULTextFieldAccessible, nsAccessible, nsIAccessibleText, nsIAccessibleEditableText)
+NS_IMPL_ISUPPORTS_INHERITED1(nsXULTextFieldAccessible, nsHyperTextAccessible,
+                             nsIAccessibleText)
 
 NS_IMETHODIMP nsXULTextFieldAccessible::Init()
 {
   CheckForEditor();
   return nsHyperTextAccessible::Init();
 }
 
 NS_IMETHODIMP nsXULTextFieldAccessible::Shutdown()
@@ -775,21 +776,16 @@ 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 &&