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
This commit is contained in:
Alexander Surkov 2010-10-14 18:05:22 +09:00
Родитель 9282638967
Коммит 57c9906674
12 изменённых файлов: 228 добавлений и 43 удалений

Просмотреть файл

@ -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>

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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>

Просмотреть файл

@ -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) {
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;
}

Просмотреть файл

@ -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

Просмотреть файл

@ -52,6 +52,7 @@ DIRS = \
states \
table \
tree \
treeupdate \
$(null)
include $(DEPTH)/config/autoconf.mk

Просмотреть файл

@ -62,7 +62,6 @@ _TEST_FILES =\
test_iframe.html \
test_img.html \
test_list.html \
test_list_invalidate.html \
test_media.html \
test_menu.xul \
test_select.html \

Просмотреть файл

@ -0,0 +1,54 @@
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Mozilla Foundation.
# Portions created by the Initial Developer are Copyright (C) 2010
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Alexander Surkov <surkov.alexander@gmail.com> (original author)
#
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = accessible/treeupdate
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
_TEST_FILES =\
test_list_editabledoc.html \
test_list.html \
$(NULL)
libs:: $(_TEST_FILES)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/a11y/$(relativesrcdir)

Просмотреть файл

@ -0,0 +1,112 @@
<!DOCTYPE html>
<html>
<head>
<title>Test HTML li and listitem bullet accessible insertion into editable document</title>
<link rel="stylesheet" type="text/css"
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="../common.js"></script>
<script type="application/javascript"
src="../role.js"></script>
<script type="application/javascript"
src="../events.js"></script>
<script type="application/javascript">
////////////////////////////////////////////////////////////////////////////
// Invokers
function addLi(aID)
{
this.listNode = getNode(aID);
this.liNode = document.createElement("li");
this.liNode.textContent = "item";
this.eventSeq = [
new invokerChecker(EVENT_SHOW, getAccessible, this.liNode),
new invokerChecker(EVENT_REORDER, this.listNode)
];
this.invoke = function addLi_invoke()
{
this.listNode.appendChild(this.liNode);
}
this.finalCheck = function addLi_finalCheck()
{
var tree = {
role: ROLE_LIST,
children: [
{
role: ROLE_LISTITEM,
children: [
{
role: ROLE_STATICTEXT,
name: "1. ",
children: []
},
{
role: ROLE_TEXT_LEAF,
children: []
}
]
}
]
};
testAccessibleTree(aID, tree);
}
this.getID = function addLi_getID()
{
return "add li";
}
};
////////////////////////////////////////////////////////////////////////////
// Test
//gA11yEventDumpID = "eventdump"; // debug stuff
var gQueue = null;
function doTest()
{
todo(false, "Enable when bug 570275 is fixed");
SimpleTest.finish();
return;
gQueue = new eventQueue();
gQueue.push(new addLi("list"));
gQueue.invoke(); // SimpleTest.finish() will be called in the end
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTest);
</script>
</head>
<body contentEditable="true">
<a target="_blank"
title="Wrong list bullet text of accessible for the first numbered HTML:li in CKEditor"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=557795">Mozilla Bug 557795</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
<ol id="list">
</ol>
<div id="eventdump"></div>
</body>
</html>

Просмотреть файл

@ -6277,20 +6277,7 @@ nsBlockFrame::CreateAccessible()
}
// Create special list bullet accessible
const nsStyleList* myList = GetStyleList();
nsAutoString bulletText;
if (myList->GetListStyleImage() ||
myList->mListStyleType == NS_STYLE_LIST_STYLE_DISC ||
myList->mListStyleType == NS_STYLE_LIST_STYLE_CIRCLE ||
myList->mListStyleType == NS_STYLE_LIST_STYLE_SQUARE) {
bulletText.Assign(PRUnichar(0x2022));; // Unicode bullet character
}
else if (myList->mListStyleType != NS_STYLE_LIST_STYLE_NONE) {
mBullet->GetListItemText(*myList, bulletText);
}
return accService->CreateHTMLLIAccessible(mContent, presContext->PresShell(),
bulletText);
return accService->CreateHTMLLIAccessible(mContent, presContext->PresShell());
}
#endif
@ -6535,6 +6522,25 @@ nsBlockFrame::BulletIsEmpty() const
!list->GetListStyleImage();
}
void
nsBlockFrame::GetBulletText(nsAString& aText) const
{
aText.Truncate();
const nsStyleList* myList = GetStyleList();
if (myList->GetListStyleImage() ||
myList->mListStyleType == NS_STYLE_LIST_STYLE_DISC ||
myList->mListStyleType == NS_STYLE_LIST_STYLE_CIRCLE ||
myList->mListStyleType == NS_STYLE_LIST_STYLE_SQUARE) {
aText.Assign(PRUnichar(0x2022)); // Unicode bullet character
}
else if (myList->mListStyleType != NS_STYLE_LIST_STYLE_NONE) {
nsAutoString text;
mBullet->GetListItemText(*myList, text);
aText = text;
}
}
// static
PRBool
nsBlockFrame::FrameStartsCounterScope(nsIFrame* aFrame)

Просмотреть файл

@ -249,6 +249,7 @@ public:
// do we have either a 'list-style-type' or 'list-style-image' that is
// not 'none'?
PRBool BulletIsEmpty() const;
void GetBulletText(nsAString& aText) const;
virtual void MarkIntrinsicWidthsDirty();
virtual nscoord GetMinWidth(nsIRenderingContext *aRenderingContext);
@ -339,6 +340,7 @@ protected:
virtual ~nsBlockFrame();
#ifdef DEBUG
#ifdef _IMPL_NS_LAYOUT
already_AddRefed<nsStyleContext> GetFirstLetterStyle(nsPresContext* aPresContext)
{
return aPresContext->StyleSet()->
@ -346,6 +348,7 @@ protected:
nsCSSPseudoElements::ePseudo_firstLetter,
mStyleContext);
}
#endif
#endif
/*