author | Alexander Surkov <surkov.alexander@gmail.com> |
Thu, 14 Oct 2010 18:05:22 +0900 | |
changeset 55763 | 9b24526d81320daf1e1b04336aeced052d08c267 |
parent 55762 | 047cb442023aa2a5074e9c8e6cb1188ee2b1b1f2 |
child 55764 | 17c52dc86a74ee25c5597fd9fe4e0d5e0245286a |
push id | 1 |
push user | root |
push date | Tue, 26 Apr 2011 22:38:44 +0000 |
treeherder | mozilla-beta@bfdb6e623a36 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | davidb, roc, blocking |
bugs | 557795 |
milestone | 2.0b8pre |
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
|
--- a/accessible/public/nsIAccessibilityService.h +++ b/accessible/public/nsIAccessibilityService.h @@ -104,18 +104,17 @@ public: CreateHTMLGroupboxAccessible(nsIContent* aContent, nsIPresShell* aPresShell) = 0; virtual already_AddRefed<nsAccessible> CreateHTMLHRAccessible(nsIContent* aContent, nsIPresShell* aPresShell) = 0; virtual already_AddRefed<nsAccessible> CreateHTMLImageAccessible(nsIContent* aContent, nsIPresShell* aPresShell) = 0; 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> CreateHTMLMediaAccessible(nsIContent* aContent, nsIPresShell* aPresShell) = 0; virtual already_AddRefed<nsAccessible> CreateHTMLObjectFrameAccessible(nsObjectFrame* aFrame, nsIContent* aContent, nsIPresShell* aPresShell) = 0; virtual already_AddRefed<nsAccessible>
--- a/accessible/src/base/nsAccessibilityService.cpp +++ b/accessible/src/base/nsAccessibilityService.cpp @@ -227,22 +227,20 @@ nsAccessibilityService::CreateHTMLButton nsCOMPtr<nsIWeakReference> weakShell(do_GetWeakReference(aPresShell)); nsAccessible* accessible = new nsHTMLButtonAccessible(aContent, weakShell); NS_IF_ADDREF(accessible); return accessible; } 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; } already_AddRefed<nsAccessible> nsAccessibilityService::CreateHyperTextAccessible(nsIContent* aContent, nsIPresShell* aPresShell) { @@ -1629,18 +1627,17 @@ nsAccessibilityService::CreateHTMLAccess } if (tag == nsAccessibilityAtoms::dt || (tag == nsAccessibilityAtoms::li && aFrame->GetType() != nsAccessibilityAtoms::blockFrame)) { // 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; } if (tag == nsAccessibilityAtoms::abbr || tag == nsAccessibilityAtoms::acronym || tag == nsAccessibilityAtoms::blockquote || tag == nsAccessibilityAtoms::dd ||
--- a/accessible/src/base/nsAccessibilityService.h +++ b/accessible/src/base/nsAccessibilityService.h @@ -79,18 +79,17 @@ public: CreateHTMLGroupboxAccessible(nsIContent* aContent, nsIPresShell* aPresShell); virtual already_AddRefed<nsAccessible> CreateHTMLHRAccessible(nsIContent* aContent, nsIPresShell* aPresShell); virtual already_AddRefed<nsAccessible> CreateHTMLImageAccessible(nsIContent* aContent, nsIPresShell* aPresShell); 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> CreateHTMLMediaAccessible(nsIContent* aContent, nsIPresShell* aPresShell); virtual already_AddRefed<nsAccessible> CreateHTMLObjectFrameAccessible(nsObjectFrame* aFrame, nsIContent* aContent, nsIPresShell* aPresShell); virtual already_AddRefed<nsAccessible>
--- a/accessible/src/html/nsHTMLTextAccessible.cpp +++ b/accessible/src/html/nsHTMLTextAccessible.cpp @@ -41,16 +41,17 @@ #include "nsDocAccessible.h" #include "nsAccUtils.h" #include "nsRelUtils.h" #include "nsTextEquivUtils.h" #include "nsIFrame.h" #include "nsPresContext.h" +#include "nsBlockFrame.h" #include "nsISelection.h" #include "nsISelectionController.h" #include "nsComponentManagerUtils.h" //////////////////////////////////////////////////////////////////////////////// // nsHTMLTextAccessible //////////////////////////////////////////////////////////////////////////////// @@ -247,23 +248,22 @@ nsHTMLOutputAccessible::GetAttributesInt } //////////////////////////////////////////////////////////////////////////////// // nsHTMLLIAccessible //////////////////////////////////////////////////////////////////////////////// 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(); } } NS_IMPL_ISUPPORTS_INHERITED0(nsHTMLLIAccessible, nsHyperTextAccessible) void @@ -324,19 +324,18 @@ nsHTMLLIAccessible::CacheChildren() nsAccessibleWrap::CacheChildren(); } //////////////////////////////////////////////////////////////////////////////// // nsHTMLListBulletAccessible //////////////////////////////////////////////////////////////////////////////// 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 } NS_IMETHODIMP nsHTMLListBulletAccessible::GetUniqueID(void **aUniqueID) { // Since mContent is same as for list item, use |this| pointer as the unique @@ -350,18 +349,30 @@ nsHTMLListBulletAccessible::Shutdown() { mBulletText.Truncate(); nsLeafAccessible::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; } PRUint32 nsHTMLListBulletAccessible::NativeRole() { return nsIAccessibleRole::ROLE_STATICTEXT; } @@ -376,21 +387,27 @@ nsHTMLListBulletAccessible::GetStateInte *aState |= nsIAccessibleStates::STATE_READONLY; return NS_OK; } 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; } //////////////////////////////////////////////////////////////////////////////// // nsHTMLListAccessible //////////////////////////////////////////////////////////////////////////////// nsHTMLListAccessible::
--- a/accessible/src/html/nsHTMLTextAccessible.h +++ b/accessible/src/html/nsHTMLTextAccessible.h @@ -125,18 +125,17 @@ public: }; /** * Used for bullet of HTML list item element (for example, HTML li). */ class nsHTMLListBulletAccessible : public nsLeafAccessible { public: - nsHTMLListBulletAccessible(nsIContent *aContent, nsIWeakReference *aShell, - const nsAString& aBulletText); + nsHTMLListBulletAccessible(nsIContent* aContent, nsIWeakReference* aShell); // nsIAccessNode NS_IMETHOD GetUniqueID(void **aUniqueID); // nsIAccessible NS_IMETHOD GetName(nsAString& aName); // nsAccessNode @@ -175,18 +174,17 @@ public: }; /** * Used for HTML list item (e.g. HTML li). */ class nsHTMLLIAccessible : public nsHyperTextAccessibleWrap { public: - nsHTMLLIAccessible(nsIContent *aContent, nsIWeakReference *aShell, - const nsAString& aBulletText); + nsHTMLLIAccessible(nsIContent* aContent, nsIWeakReference* aShell); // nsISupports NS_DECL_ISUPPORTS_INHERITED // nsIAccessible NS_IMETHOD GetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height); // nsAccessNode
--- a/accessible/tests/mochitest/Makefile.in +++ b/accessible/tests/mochitest/Makefile.in @@ -47,16 +47,17 @@ DIRS = \ attributes \ events \ hyperlink \ relations \ selectable \ states \ table \ tree \ + treeupdate \ $(null) include $(DEPTH)/config/autoconf.mk include $(topsrcdir)/config/rules.mk _TEST_FILES =\ formimage.png \ letters.gif \
--- a/accessible/tests/mochitest/tree/Makefile.in +++ b/accessible/tests/mochitest/tree/Makefile.in @@ -57,17 +57,16 @@ include $(topsrcdir)/config/rules.mk test_filectrl.html \ test_formctrl.html \ test_formctrl.xul \ test_gencontent.html \ test_groupbox.xul \ test_iframe.html \ test_img.html \ test_list.html \ - test_list_invalidate.html \ test_media.html \ test_menu.xul \ test_select.html \ test_tabbox.xul \ test_tabbrowser.xul \ test_table.html \ test_tree.xul \ test_txtcntr.html \
new file mode 100644 --- /dev/null +++ b/accessible/tests/mochitest/treeupdate/Makefile.in @@ -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)
rename from accessible/tests/mochitest/tree/test_list_invalidate.html rename to accessible/tests/mochitest/treeupdate/test_list.html
new file mode 100644 --- /dev/null +++ b/accessible/tests/mochitest/treeupdate/test_list_editabledoc.html @@ -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>
--- a/layout/generic/nsBlockFrame.cpp +++ b/layout/generic/nsBlockFrame.cpp @@ -6272,30 +6272,17 @@ nsBlockFrame::CreateAccessible() } // Not a bullet, treat as normal HTML container return accService->CreateHyperTextAccessible(mContent, presContext->PresShell()); } // 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 void nsBlockFrame::ClearLineCursor() { if (!(GetStateBits() & NS_BLOCK_HAS_LINE_CURSOR)) { return; } @@ -6530,16 +6517,35 @@ nsBlockFrame::BulletIsEmpty() const NS_STYLE_DISPLAY_LIST_ITEM && HaveOutsideBullet(), "should only care when we have an outside bullet"); const nsStyleList* list = GetStyleList(); return list->mListStyleType == NS_STYLE_LIST_STYLE_NONE && !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) { nsIContent* content = aFrame->GetContent(); if (!content || !content->IsHTML()) return PR_FALSE;
--- a/layout/generic/nsBlockFrame.h +++ b/layout/generic/nsBlockFrame.h @@ -244,16 +244,17 @@ public: virtual PRBool IsEmpty(); virtual PRBool CachedIsEmpty(); virtual PRBool IsSelfEmpty(); // Given that we have a bullet, does it actually draw something, i.e., // 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); virtual nscoord GetPrefWidth(nsIRenderingContext *aRenderingContext); virtual nsRect ComputeTightBounds(gfxContext* aContext) const; NS_IMETHOD Reflow(nsPresContext* aPresContext, @@ -334,24 +335,26 @@ protected: { #ifdef DEBUG InitDebugFlags(); #endif } virtual ~nsBlockFrame(); #ifdef DEBUG +#ifdef _IMPL_NS_LAYOUT already_AddRefed<nsStyleContext> GetFirstLetterStyle(nsPresContext* aPresContext) { return aPresContext->StyleSet()-> ProbePseudoElementStyle(mContent->AsElement(), nsCSSPseudoElements::ePseudo_firstLetter, mStyleContext); } #endif +#endif /* * Overides member function of nsHTMLContainerFrame. Needed to handle the * lines in a nsBlockFrame properly. */ virtual void PaintTextDecorationLine(gfxContext* aCtx, const nsPoint& aPt, nsLineBox* aLine,