Bug 630001, part2 - fix nsAccUtils::TextLength to not use nsIFrame::GetRenderedText, r=davidb, a=betaN
authorAlexander Surkov <surkov.alexander@gmail.com>
Tue, 01 Feb 2011 11:00:45 +0800
changeset 61683 ba5140cd34c868e285886214bf4110b44eafd6b4
parent 61682 0a5bf58306bce274399c7583620b3f1db1a0ae1d
child 61684 6fbc3c08894e5988b230aebb4ef25a3e0a3c1ff5
child 61714 dd753ec085e2a9090abae279eac9f3d1b0aa85af
push id18448
push usersurkov.alexander@gmail.com
push dateTue, 01 Feb 2011 03:01:39 +0000
treeherdermozilla-central@ba5140cd34c8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdavidb, betaN
bugs630001
milestone2.0b11pre
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 630001, part2 - fix nsAccUtils::TextLength to not use nsIFrame::GetRenderedText, r=davidb, a=betaN
accessible/src/base/nsAccUtils.cpp
--- a/accessible/src/base/nsAccUtils.cpp
+++ b/accessible/src/base/nsAccUtils.cpp
@@ -39,22 +39,22 @@
 #include "nsCoreUtils.h"
 #include "nsAccUtils.h"
 
 #include "nsIAccessibleStates.h"
 #include "nsIAccessibleTypes.h"
 
 #include "nsAccessibilityService.h"
 #include "nsAccessibilityAtoms.h"
-#include "nsAccessible.h"
 #include "nsAccTreeWalker.h"
 #include "nsARIAMap.h"
 #include "nsDocAccessible.h"
 #include "nsHyperTextAccessible.h"
 #include "nsHTMLTableAccessible.h"
+#include "nsTextAccessible.h"
 #include "nsXULTreeGridAccessible.h"
 
 #include "nsIDOMXULContainerElement.h"
 #include "nsIDOMXULSelectCntrlEl.h"
 #include "nsIDOMXULSelectCntrlItemEl.h"
 #include "nsWhitespaceTokenizer.h"
 #include "nsComponentManagerUtils.h"
 
@@ -633,33 +633,19 @@ nsAccUtils::IsTextInterfaceSupportCorrec
 #endif
 
 PRUint32
 nsAccUtils::TextLength(nsAccessible *aAccessible)
 {
   if (!IsText(aAccessible))
     return 1;
 
-  nsIFrame *frame = aAccessible->GetFrame();
-  if (frame && frame->GetType() == nsAccessibilityAtoms::textFrame) {
-    // Ensure that correct text length is calculated (with non-rendered
-    // whitespace chars not counted).
-    nsIContent *content = frame->GetContent();
-    if (content) {
-      PRUint32 length;
-      nsresult rv = nsHyperTextAccessible::
-        ContentToRenderedOffset(frame, content->TextLength(), &length);
-      if (NS_FAILED(rv)) {
-        NS_NOTREACHED("Failed to get rendered offset!");
-        return 0;
-      }
-
-      return length;
-    }
-  }
+  nsTextAccessible* textLeaf = aAccessible->AsTextLeaf();
+  if (textLeaf)
+    return textLeaf->Text().Length();
 
   // For list bullets (or anything other accessible which would compute its own
   // text. They don't have their own frame.
   // XXX In the future, list bullets may have frame and anon content, so 
   // we should be able to remove this at that point
   nsAutoString text;
   aAccessible->AppendTextTo(text); // Get all the text
   return text.Length();