Bug 405248 - Space between embedded objects characters is missing r=aaronleventhal a=mtschrep
authorEvan.Yan@Sun.COM
Wed, 19 Dec 2007 04:57:08 -0800
changeset 9480 641da7bd6b958b82b6fc50ae4d727b0045910d88
parent 9479 2f519752b95aa39048aa53df479b94288c5f9ade
child 9481 25c911cb57fd41a21cfbb4bf4ea2a47c862fe347
push id1
push userbsmedberg@mozilla.com
push dateThu, 20 Mar 2008 16:49:24 +0000
treeherderautoland@61007906a1f8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaaronleventhal, mtschrep
bugs405248
milestone1.9b3pre
Bug 405248 - Space between embedded objects characters is missing r=aaronleventhal a=mtschrep
accessible/src/base/nsAccessibilityService.cpp
accessible/src/base/nsAccessible.cpp
layout/generic/nsTextFrameThebes.cpp
--- a/accessible/src/base/nsAccessibilityService.cpp
+++ b/accessible/src/base/nsAccessibilityService.cpp
@@ -1346,18 +1346,23 @@ NS_IMETHODIMP nsAccessibilityService::Ge
     return NS_OK;
 
   /**
    * Attempt to create an accessible based on what we know
    */
   if (content->IsNodeOfType(nsINode::eTEXT)) {
     // --- Create HTML for visible text frames ---
     if (frame->IsEmpty()) {
-      *aIsHidden = PR_TRUE;
-      return NS_OK;
+      nsAutoString renderedWhitespace;
+      frame->GetRenderedText(&renderedWhitespace, nsnull, nsnull, 0, 1);
+      if (renderedWhitespace.IsEmpty()) {
+        // Really empty -- nothing is rendered
+        *aIsHidden = PR_TRUE;
+        return NS_OK;
+      }
     }
     frame->GetAccessible(getter_AddRefs(newAcc));
     return InitAccessible(newAcc, aAccessible, nsnull);
   }
 
   nsRoleMapEntry *roleMapEntry = nsAccUtils::GetRoleMapEntry(aNode);
   if (roleMapEntry && !nsCRT::strcmp(roleMapEntry->roleString, "presentation") &&
       !content->IsFocusable()) { // For presentation only
--- a/accessible/src/base/nsAccessible.cpp
+++ b/accessible/src/base/nsAccessible.cpp
@@ -932,22 +932,27 @@ PRBool nsAccessible::IsVisible(PRBool *a
   }
 
   nsRectVisibility rectVisibility;
   viewManager->GetRectVisibility(containingView, relFrameRect,
                                  nsPresContext::CSSPixelsToAppUnits(kMinPixels),
                                  &rectVisibility);
 
   if (rectVisibility == nsRectVisibility_kZeroAreaRect) {
-    if (frame->GetNextContinuation()) {
+    nsIAtom *frameType = frame->GetType();
+    if (frameType == nsAccessibilityAtoms::textFrame) {
       // Zero area rects can occur in the first frame of a multi-frame text flow,
-      // in which case the next frame exists because the text flow is visible
-      rectVisibility = nsRectVisibility_kVisible;
+      // in which case the rendered text is not empty and the frame should not be marked invisible
+      nsAutoString renderedText;
+      frame->GetRenderedText (&renderedText, nsnull, nsnull, 0, 1);
+      if (!renderedText.IsEmpty()) {
+        rectVisibility = nsRectVisibility_kVisible;
+      }
     }
-    else if (IsCorrectFrameType(frame, nsAccessibilityAtoms::inlineFrame)) {
+    else if (frameType == nsAccessibilityAtoms::inlineFrame) {
       // Yuck. Unfortunately inline frames can contain larger frames inside of them,
       // so we can't really believe this is a zero area rect without checking more deeply.
       // GetBounds() will do that for us.
       PRInt32 x, y, width, height;
       GetBounds(&x, &y, &width, &height);
       if (width > 0 && height > 0) {
         rectVisibility = nsRectVisibility_kVisible;    
       }
--- a/layout/generic/nsTextFrameThebes.cpp
+++ b/layout/generic/nsTextFrameThebes.cpp
@@ -3047,24 +3047,29 @@ nsTextPaintStyle::GetResolvedForeColor(n
   return Get40PercentColor(aDefaultForeColor, actualBGColor);
 }
 
 //-----------------------------------------------------------------------------
 
 #ifdef ACCESSIBILITY
 NS_IMETHODIMP nsTextFrame::GetAccessible(nsIAccessible** aAccessible)
 {
-  if (!IsEmpty() || GetNextInFlow()) {
-
-    nsCOMPtr<nsIAccessibilityService> accService = do_GetService("@mozilla.org/accessibilityService;1");
-
-    if (accService) {
-      return accService->CreateHTMLTextAccessible(static_cast<nsIFrame*>(this), aAccessible);
+  if (IsEmpty()) {
+    nsAutoString renderedWhitespace;
+    GetRenderedText(&renderedWhitespace, nsnull, nsnull, 0, 1);
+    if (renderedWhitespace.IsEmpty()) {
+      return NS_ERROR_FAILURE;
     }
   }
+
+  nsCOMPtr<nsIAccessibilityService> accService = do_GetService("@mozilla.org/accessibilityService;1");
+
+  if (accService) {
+    return accService->CreateHTMLTextAccessible(static_cast<nsIFrame*>(this), aAccessible);
+  }
   return NS_ERROR_FAILURE;
 }
 #endif
 
 
 //-----------------------------------------------------------------------------
 NS_IMETHODIMP
 nsTextFrame::Init(nsIContent*      aContent,