Commit 57c99066 authored by Alexander Surkov's avatar Alexander Surkov
Browse files

Bug 557795 - wrong list bullet text of accessible for the first numbered...

Bug 557795 - wrong list bullet text of accessible for the first numbered HTML:li in CKEditor, r=davidb, sr=roc, a=blocking

--HG--
rename : accessible/tests/mochitest/tree/test_list_invalidate.html => accessible/tests/mochitest/treeupdate/test_list.html
parent 92826389
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -109,8 +109,7 @@ public:
  virtual already_AddRefed<nsAccessible>
    CreateHTMLLabelAccessible(nsIContent* aContent, nsIPresShell* aPresShell) = 0;
  virtual already_AddRefed<nsAccessible>
    CreateHTMLLIAccessible(nsIContent* aContent, nsIPresShell* aPresShell,
                           const nsAString& aBulletText) = 0;
    CreateHTMLLIAccessible(nsIContent* aContent, nsIPresShell* aPresShell) = 0;
  virtual already_AddRefed<nsAccessible>
    CreateHTMLListboxAccessible(nsIContent* aContent, nsIPresShell* aPresShell) = 0;
  virtual already_AddRefed<nsAccessible>
+3 −6
Original line number Diff line number Diff line
@@ -232,12 +232,10 @@ nsAccessibilityService::CreateHTMLButtonAccessible(nsIContent* aContent,

already_AddRefed<nsAccessible>
nsAccessibilityService::CreateHTMLLIAccessible(nsIContent* aContent,
                                               nsIPresShell* aPresShell,
                                               const nsAString& aBulletText)
                                               nsIPresShell* aPresShell)
{
  nsCOMPtr<nsIWeakReference> weakShell(do_GetWeakReference(aPresShell));
  nsAccessible* accessible = new nsHTMLLIAccessible(aContent, weakShell,
                                                    aBulletText);
  nsAccessible* accessible = new nsHTMLLIAccessible(aContent, weakShell);
  NS_IF_ADDREF(accessible);
  return accessible;
}
@@ -1634,8 +1632,7 @@ nsAccessibilityService::CreateHTMLAccessibleByMarkup(nsIFrame* aFrame,
    // Normally for li, it is created by the list item frame (in nsBlockFrame)
    // which knows about the bullet frame; however, in this case the list item
    // must have been styled using display: foo
    nsAccessible* accessible = new nsHTMLLIAccessible(aContent, aWeakShell,
                                                      EmptyString());
    nsAccessible* accessible = new nsHTMLLIAccessible(aContent, aWeakShell);
    NS_IF_ADDREF(accessible);
    return accessible;
  }
+1 −2
Original line number Diff line number Diff line
@@ -84,8 +84,7 @@ public:
  virtual already_AddRefed<nsAccessible>
    CreateHTMLLabelAccessible(nsIContent* aContent, nsIPresShell* aPresShell);
  virtual already_AddRefed<nsAccessible>
    CreateHTMLLIAccessible(nsIContent* aContent, nsIPresShell* aPresShell,
                           const nsAString& aBulletText);
    CreateHTMLLIAccessible(nsIContent* aContent, nsIPresShell* aPresShell);
  virtual already_AddRefed<nsAccessible>
    CreateHTMLListboxAccessible(nsIContent* aContent, nsIPresShell* aPresShell);
  virtual already_AddRefed<nsAccessible>
+31 −14
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@

#include "nsIFrame.h"
#include "nsPresContext.h"
#include "nsBlockFrame.h"
#include "nsISelection.h"
#include "nsISelectionController.h"
#include "nsComponentManagerUtils.h"
@@ -252,13 +253,12 @@ nsHTMLOutputAccessible::GetAttributesInternal(nsIPersistentProperties* aAttribut
////////////////////////////////////////////////////////////////////////////////

nsHTMLLIAccessible::
  nsHTMLLIAccessible(nsIContent *aContent, nsIWeakReference *aShell,
                     const nsAString& aBulletText) :
  nsHTMLLIAccessible(nsIContent* aContent, nsIWeakReference* aShell) :
  nsHyperTextAccessibleWrap(aContent, aShell)
{
  if (!aBulletText.IsEmpty()) {
    mBulletAccessible = new nsHTMLListBulletAccessible(mContent, mWeakShell, 
                                                       aBulletText);
  nsBlockFrame* blockFrame = do_QueryFrame(GetFrame());
  if (blockFrame && !blockFrame->BulletIsEmpty()) {
    mBulletAccessible = new nsHTMLListBulletAccessible(mContent, mWeakShell);
    if (mBulletAccessible)
      mBulletAccessible->Init();
  }
@@ -329,9 +329,8 @@ nsHTMLLIAccessible::CacheChildren()
////////////////////////////////////////////////////////////////////////////////

nsHTMLListBulletAccessible::
  nsHTMLListBulletAccessible(nsIContent *aContent, nsIWeakReference *aShell,
                             const nsAString& aBulletText) :
    nsLeafAccessible(aContent, aShell), mBulletText(aBulletText)
  nsHTMLListBulletAccessible(nsIContent* aContent, nsIWeakReference* aShell) :
    nsLeafAccessible(aContent, aShell)
{
  mBulletText += ' '; // Otherwise bullets are jammed up against list text
}
@@ -355,8 +354,20 @@ nsHTMLListBulletAccessible::Shutdown()
NS_IMETHODIMP
nsHTMLListBulletAccessible::GetName(nsAString &aName)
{
  // Native anonymous content, ARIA can't be used.
  aName = mBulletText;
  aName.Truncate();

  if (IsDefunct())
    return NS_ERROR_FAILURE;

  // Native anonymous content, ARIA can't be used. Get list bullet text.
  nsBlockFrame* blockFrame = do_QueryFrame(mContent->GetPrimaryFrame());
  if (blockFrame) {
    blockFrame->GetBulletText(aName);

    // Append space otherwise bullets are jammed up against list text.
    aName.Append(' ');
  }

  return NS_OK;
}

@@ -381,11 +392,17 @@ nsresult
nsHTMLListBulletAccessible::AppendTextTo(nsAString& aText, PRUint32 aStartOffset,
                                         PRUint32 aLength)
{
  PRUint32 maxLength = mBulletText.Length() - aStartOffset;
  if (aLength > maxLength) {
  nsBlockFrame* blockFrame = do_QueryFrame(mContent->GetPrimaryFrame());
  if (blockFrame) {
    nsAutoString bulletText;
    blockFrame->GetBulletText(bulletText);

    PRUint32 maxLength = bulletText.Length() - aStartOffset;
    if (aLength > maxLength)
      aLength = maxLength;

    aText += Substring(bulletText, aStartOffset, aLength);
  }
  aText += Substring(mBulletText, aStartOffset, aLength);
  return NS_OK;
}

+2 −4
Original line number Diff line number Diff line
@@ -130,8 +130,7 @@ public:
class nsHTMLListBulletAccessible : public nsLeafAccessible
{
public:
  nsHTMLListBulletAccessible(nsIContent *aContent, nsIWeakReference *aShell,
                             const nsAString& aBulletText);
  nsHTMLListBulletAccessible(nsIContent* aContent, nsIWeakReference* aShell);

  // nsIAccessNode
  NS_IMETHOD GetUniqueID(void **aUniqueID);
@@ -180,8 +179,7 @@ public:
class nsHTMLLIAccessible : public nsHyperTextAccessibleWrap
{
public:
  nsHTMLLIAccessible(nsIContent *aContent, nsIWeakReference *aShell,
                     const nsAString& aBulletText);
  nsHTMLLIAccessible(nsIContent* aContent, nsIWeakReference* aShell);

  // nsISupports
  NS_DECL_ISUPPORTS_INHERITED
Loading