Reverting bug 340825 for aaronlev due to a busted checkin

This commit is contained in:
benjamin%smedbergs.us 2006-06-15 15:22:23 +00:00
Родитель 5ba747768c
Коммит c4c823f375
23 изменённых файлов: 2416 добавлений и 207 удалений

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

@ -100,7 +100,7 @@ interface nsIAccessible : nsISupports
* Accessible value -- a number or a secondary text equivalent for this node
* Widgets that use xhtml2:role can force a value using the valuenow attribute
*/
readonly attribute AString value;
readonly attribute AString finalValue;
/**
* Accessible description -- long text associated with this node

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

@ -44,8 +44,14 @@ interface nsIAccessibleValue : nsISupports
{
readonly attribute double maximumValue;
readonly attribute double minimumValue;
attribute double currentValue;
readonly attribute double minimumIncrement;
readonly attribute double currentValue;
/**
* We want to be able to return a success condition of the value
* getting set. ie if the value is not within the interval of
* minimumValue-maximumValue
*/
boolean setCurrentValue (in double value);
};
/*

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

@ -0,0 +1,538 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** 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
* Sun Microsystems, Inc.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Kyle Yuan (kyle.yuan@sun.com)
* Ginn Chen (ginn.chen@sun.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either 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 ***** */
#include "nsAccessibilityAtoms.h"
#include "nsAccessibilityService.h"
#include "nsAccessibleHyperText.h"
#include "nsHTMLLinkAccessibleWrap.h"
#include "nsHTMLTextAccessible.h"
#include "nsPIAccessNode.h"
#include "nsIFrame.h"
#include "nsILink.h"
#include "nsIServiceManager.h"
#include "nsArrayUtils.h"
/*
* nsAccessibleHyperText supports both nsIAccessibleHyperText and nsIAccessibleText.
* It's mainly aimed at the compound content that consists of many text nodes and links.
* Typically, it's a paragraph of text, a cell of table, etc.
*/
NS_IMPL_ISUPPORTS2(nsAccessibleHyperText, nsIAccessibleHyperText, nsIAccessibleText)
nsAccessibleHyperText::nsAccessibleHyperText(nsIDOMNode* aDomNode, nsIWeakReference* aShell)
{
mIndex = -1;
nsCOMPtr<nsIContent> content(do_QueryInterface(aDomNode));
if (content) {
nsCOMPtr<nsIContent> parentContent = content->GetParent();
if (parentContent)
mIndex = parentContent->IndexOf(content);
}
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(aShell));
if (shell) {
mTextChildren = do_CreateInstance(NS_ARRAY_CONTRACTID);
if (mTextChildren) {
nsCOMPtr<nsIContent> content(do_QueryInterface(aDomNode));
nsIFrame *frame = shell->GetPrimaryFrameFor(content);
nsIFrame *parentFrame = nsAccessible::GetParentBlockFrame(frame);
NS_ASSERTION(parentFrame, "Error: HyperText can't get parent block frame");
if (parentFrame) {
nsIFrame* childFrame = parentFrame->GetFirstChild(nsnull);
PRBool bSave = PR_FALSE;
GetAllTextChildren(shell->GetPresContext(), childFrame,
aDomNode, bSave);
}
}
}
}
void nsAccessibleHyperText::Shutdown()
{
mTextChildren = nsnull;
}
PRBool nsAccessibleHyperText::GetAllTextChildren(nsPresContext *aPresContext, nsIFrame *aCurFrame, nsIDOMNode* aNode, PRBool &bSave)
{
while (aCurFrame) {
nsIAtom* frameType = aCurFrame->GetType();
if (frameType == nsAccessibilityAtoms::blockFrame) {
if (bSave)
return PR_TRUE;
}
else {
if (frameType == nsAccessibilityAtoms::textFrame) {
// Skip the empty text frames that usually only consist of "\n"
if (! aCurFrame->GetRect().IsEmpty()) {
nsCOMPtr<nsIDOMNode> node(do_QueryInterface(aCurFrame->GetContent()));
if (bSave || node == aNode) {
// some long text node may be divided into several frames,
// so we must check whether this node is already in the array
PRUint32 index;
nsresult rv = mTextChildren->IndexOf(0, node, &index);
if (NS_FAILED(rv)) {
mTextChildren->AppendElement(node, PR_FALSE);
}
bSave = PR_TRUE;
}
}
}
nsIFrame* childFrame = aCurFrame->GetFirstChild(nsnull);
if (GetAllTextChildren(aPresContext, childFrame, aNode, bSave))
return PR_TRUE;
}
nsIFrame* siblingFrame = aCurFrame->GetNextSibling();
aCurFrame = siblingFrame;
}
return PR_FALSE;
}
PRInt32 nsAccessibleHyperText::GetIndex()
// XXX, this index is used for giving a hypertext a meaningful name, such as "Paragraph n",
// but by now, we haven't found a better way to do that, just use the index of our parent's
// children list as the number.
{
return mIndex;
}
nsIDOMNode* nsAccessibleHyperText::FindTextNodeByOffset(PRInt32 aOffset, PRInt32& aBeforeLength)
{
aBeforeLength = 0;
PRUint32 index, count;
mTextChildren->GetLength(&count);
for (index = 0; index < count; index++) {
nsCOMPtr<nsIDOMNode> domNode(do_QueryElementAt(mTextChildren, index));
nsAccessibleText accText(domNode);
PRInt32 charCount;
if (NS_SUCCEEDED(accText.GetCharacterCount(&charCount))) {
if (aOffset >= 0 && aOffset <= charCount) {
return domNode;
}
aOffset -= charCount;
aBeforeLength += charCount;
}
}
return nsnull;
}
nsresult nsAccessibleHyperText::GetTextHelper(EGetTextType aType, nsAccessibleTextBoundary aBoundaryType,
PRInt32 aOffset, PRInt32 *aStartOffset, PRInt32 *aEndOffset, nsAString & aText)
{
PRInt32 beforeLength;
nsIDOMNode* domNode = FindTextNodeByOffset(aOffset, beforeLength);
if (domNode) {
nsAccessibleText accText(domNode);
// call nsAccessibleText::GetTextHelper directly so that it can adjust the aStartOffset/aEndOffset
// according to the mTextChildren
nsresult rv = accText.GetTextHelper(aType, aBoundaryType, aOffset - beforeLength, aStartOffset, aEndOffset, mTextChildren, aText);
return rv;
}
return NS_ERROR_INVALID_ARG;
}
// ------- nsIAccessibleText ---------------
/* attribute long caretOffset; */
NS_IMETHODIMP nsAccessibleHyperText::GetCaretOffset(PRInt32 *aCaretOffset)
{
*aCaretOffset = 0;
PRInt32 charCount, caretOffset;
PRUint32 index, count;
mTextChildren->GetLength(&count);
for (index = 0; index < count; index++) {
nsCOMPtr<nsIDOMNode> domNode(do_QueryElementAt(mTextChildren, index));
nsAccessibleText accText(domNode);
if (NS_SUCCEEDED(accText.GetCaretOffset(&caretOffset))) {
*aCaretOffset += caretOffset;
return NS_OK;
} else if (GetLinkNode(domNode) == nsAccessNode::gLastFocusedNode) {
//Focus is here
return NS_OK;
}
if (NS_SUCCEEDED(accText.GetCharacterCount(&charCount))) {
*aCaretOffset += charCount;
}
}
// The current focus node is not inside us
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsAccessibleHyperText::SetCaretOffset(PRInt32 aCaretOffset)
{
PRInt32 beforeLength;
nsIDOMNode* domNode = FindTextNodeByOffset(aCaretOffset, beforeLength);
if (domNode) {
nsAccessibleText accText(domNode);
return accText.SetCaretOffset(aCaretOffset - beforeLength);
}
return NS_ERROR_INVALID_ARG;
}
/* readonly attribute long characterCount; */
NS_IMETHODIMP nsAccessibleHyperText::GetCharacterCount(PRInt32 *aCharacterCount)
{
*aCharacterCount = 0;
PRInt32 charCount;
PRUint32 index, count;
mTextChildren->GetLength(&count);
for (index = 0; index < count; index++) {
nsCOMPtr<nsIDOMNode> domNode(do_QueryElementAt(mTextChildren, index));
nsAccessibleText accText(domNode);
if (NS_SUCCEEDED(accText.GetCharacterCount(&charCount)))
*aCharacterCount += charCount;
}
return NS_OK;
}
/* readonly attribute long selectionCount; */
NS_IMETHODIMP nsAccessibleHyperText::GetSelectionCount(PRInt32 *aSelectionCount)
{
*aSelectionCount = 0;
PRInt32 selCount;
PRUint32 index, count;
mTextChildren->GetLength(&count);
for (index = 0; index < count; index++) {
nsCOMPtr<nsIDOMNode> domNode(do_QueryElementAt(mTextChildren, index));
nsAccessibleText accText(domNode);
if (NS_SUCCEEDED(accText.GetSelectionCount(&selCount)))
*aSelectionCount += selCount;
}
return NS_OK;
}
/* AString getText (in long startOffset, in long endOffset); */
NS_IMETHODIMP nsAccessibleHyperText::GetText(PRInt32 aStartOffset, PRInt32 aEndOffset, nsAString & aText)
{
if (aEndOffset == -1)
GetCharacterCount(&aEndOffset);
PRInt32 charCount, totalCount = 0, currentStart, currentEnd;
PRUint32 index, count;
nsAutoString text, nodeText;
mTextChildren->GetLength(&count);
for (index = 0; index < count; index++) {
nsCOMPtr<nsIDOMNode> domNode(do_QueryElementAt(mTextChildren, index));
nsAccessibleText accText(domNode);
if (NS_SUCCEEDED(accText.GetCharacterCount(&charCount))) {
currentStart = aStartOffset - totalCount;
currentEnd = aEndOffset - totalCount;
if (currentStart >= 0 && currentStart < charCount) {
accText.GetText(currentStart, NS_MIN(charCount, currentEnd), nodeText);
text += nodeText;
aStartOffset += charCount - currentStart;
if (aStartOffset >= aEndOffset)
break;
}
totalCount += charCount;
}
}
// Eliminate the new line character
PRInt32 start = 0, length = text.Length();
PRInt32 offset = text.FindCharInSet("\n\r");
while (offset != kNotFound) {
if (offset > start)
aText += Substring(text, start, offset - start);
start = offset + 1;
offset = text.FindCharInSet("\n\r", start);
}
// Consume the last bit of the string if there's any left
if (start < length) {
if (start)
aText += Substring(text, start, length - start);
else
aText = text;
}
return NS_OK;
}
/* AString getTextBeforeOffset (in long offset, in nsAccessibleTextBoundary boundaryType, out long startOffset, out long endOffset); */
NS_IMETHODIMP nsAccessibleHyperText::GetTextBeforeOffset(PRInt32 aOffset, nsAccessibleTextBoundary aBoundaryType,
PRInt32 *aStartOffset, PRInt32 *aEndOffset, nsAString & aText)
{
return GetTextHelper(eGetBefore, aBoundaryType, aOffset, aStartOffset, aEndOffset, aText);
}
/* AString getTextAfterOffset (in long offset, in nsAccessibleTextBoundary boundaryType, out long startOffset, out long endOffset); */
NS_IMETHODIMP nsAccessibleHyperText::GetTextAfterOffset(PRInt32 aOffset, nsAccessibleTextBoundary aBoundaryType,
PRInt32 *aStartOffset, PRInt32 *aEndOffset, nsAString & aText)
{
return GetTextHelper(eGetAfter, aBoundaryType, aOffset, aStartOffset, aEndOffset, aText);
}
/* AString getTextAtOffset (in long offset, in nsAccessibleTextBoundary boundaryType, out long startOffset, out long endOffset); */
NS_IMETHODIMP nsAccessibleHyperText::GetTextAtOffset(PRInt32 aOffset, nsAccessibleTextBoundary aBoundaryType,
PRInt32 *aStartOffset, PRInt32 *aEndOffset, nsAString & aText)
{
return GetTextHelper(eGetAt, aBoundaryType, aOffset, aStartOffset, aEndOffset, aText);
}
/* wchar getCharacterAtOffset (in long offset); */
NS_IMETHODIMP nsAccessibleHyperText::GetCharacterAtOffset(PRInt32 aOffset, PRUnichar *aCharacter)
{
PRInt32 beforeLength;
nsIDOMNode* domNode = FindTextNodeByOffset(aOffset, beforeLength);
if (domNode) {
nsAccessibleText accText(domNode);
return accText.GetCharacterAtOffset(aOffset - beforeLength, aCharacter);
}
return NS_ERROR_INVALID_ARG;
}
/* nsISupports getAttributeRange (in long offset, out long rangeStartOffset, out long rangeEndOffset); */
NS_IMETHODIMP nsAccessibleHyperText::GetAttributeRange(PRInt32 aOffset, PRInt32 *aRangeStartOffset, PRInt32 *aRangeEndOffset, nsISupports **aAttributes)
{
*aRangeStartOffset = aOffset;
GetCharacterCount(aRangeEndOffset);
*aAttributes = 0;
return NS_OK;
}
/* void getCharacterExtents (in long offset, out long x, out long y, out long width, out long height, in nsAccessibleCoordType coordType); */
NS_IMETHODIMP nsAccessibleHyperText::GetCharacterExtents(PRInt32 aOffset, PRInt32 *aX, PRInt32 *aY, PRInt32 *aWidth, PRInt32 *aHeight, nsAccessibleCoordType aCoordType)
{
PRInt32 beforeLength;
nsIDOMNode* domNode = FindTextNodeByOffset(aOffset, beforeLength);
if (domNode) {
nsAccessibleText accText(domNode);
return accText.GetCharacterExtents(aOffset - beforeLength, aX, aY, aWidth, aHeight, aCoordType);
}
return NS_ERROR_INVALID_ARG;
}
/* long getOffsetAtPoint (in long x, in long y, in nsAccessibleCoordType coordType); */
NS_IMETHODIMP nsAccessibleHyperText::GetOffsetAtPoint(PRInt32 aX, PRInt32 aY, nsAccessibleCoordType aCoordType, PRInt32 *aOffset)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void getSelectionBounds (in long selectionNum, out long startOffset, out long endOffset); */
NS_IMETHODIMP nsAccessibleHyperText::GetSelectionBounds(PRInt32 aSelectionNum, PRInt32 *aStartOffset, PRInt32 *aEndOffset)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void setSelectionBounds (in long selectionNum, in long startOffset, in long endOffset); */
NS_IMETHODIMP nsAccessibleHyperText::SetSelectionBounds(PRInt32 aSelectionNum, PRInt32 aStartOffset, PRInt32 aEndOffset)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void addSelection (in long startOffset, in long endOffset); */
NS_IMETHODIMP nsAccessibleHyperText::AddSelection(PRInt32 aStartOffset, PRInt32 aEndOffset)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void removeSelection (in long selectionNum); */
NS_IMETHODIMP nsAccessibleHyperText::RemoveSelection(PRInt32 aSelectionNum)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
// ------- nsIAccessibleHyperText ---------------
/* readonly attribute long links; */NS_IMETHODIMP nsAccessibleHyperText::GetLinks(PRInt32 *aLinks)
{
*aLinks = 0;
PRUint32 index, count;
mTextChildren->GetLength(&count);
for (index = 0; index < count; index++) {
nsCOMPtr<nsIDOMNode> domNode(do_QueryElementAt(mTextChildren, index));
if (GetLinkNode(domNode)) {
(*aLinks)++;
}
}
return NS_OK;
}
/* nsIAccessibleHyperLink getLink (in long index); */
NS_IMETHODIMP nsAccessibleHyperText::GetLink(PRInt32 aIndex, nsIAccessibleHyperLink **aLink)
{
PRUint32 index, count, linkCount = 0;
mTextChildren->GetLength(&count);
for (index = 0; index < count; index++) {
nsCOMPtr<nsIDOMNode> domNode(do_QueryElementAt(mTextChildren, index));
nsIDOMNode* parentNode = GetLinkNode(domNode);
if (parentNode) {
if (linkCount++ == NS_STATIC_CAST(PRUint32, aIndex)) {
nsCOMPtr<nsIWeakReference> weakShell;
nsAccessibilityService::GetShellFromNode(parentNode, getter_AddRefs(weakShell));
NS_ENSURE_TRUE(weakShell, NS_ERROR_FAILURE);
// Check to see if we already have it in the cache.
nsCOMPtr<nsIAccessibilityService>
accService(do_GetService("@mozilla.org/accessibilityService;1"));
NS_ENSURE_TRUE(accService, NS_ERROR_FAILURE);
nsCOMPtr<nsIAccessible> cachedAcc;
nsresult rv = accService->GetCachedAccessible(parentNode, weakShell,
getter_AddRefs(cachedAcc));
NS_ENSURE_SUCCESS(rv, rv);
*aLink = nsnull;
if (cachedAcc) {
// Retrieved from cache
nsCOMPtr<nsIAccessibleHyperLink> cachedLink(do_QueryInterface(cachedAcc));
if (cachedLink) {
*aLink = cachedLink;
NS_IF_ADDREF(*aLink);
}
}
if (!(*aLink)) {
*aLink = new nsHTMLLinkAccessibleWrap(parentNode, mTextChildren, weakShell, nsnull);
NS_ENSURE_TRUE(*aLink, NS_ERROR_OUT_OF_MEMORY);
NS_ADDREF(*aLink);
nsCOMPtr<nsPIAccessNode> accessNode(do_QueryInterface(*aLink));
accessNode->Init();
}
break;
}
}
}
return NS_OK;
}
/* long getLinkIndex (in long charIndex); */
NS_IMETHODIMP nsAccessibleHyperText::GetLinkIndex(PRInt32 aCharIndex, PRInt32 *aLinkIndex)
{
*aLinkIndex = -1;
PRInt32 beforeLength_unused;
PRUint32 nodeIndex;
nsIDOMNode* domNode = FindTextNodeByOffset(aCharIndex, beforeLength_unused);
if (GetLinkNode(domNode)
&& NS_SUCCEEDED(mTextChildren->IndexOf(0, domNode, &nodeIndex))) {
(*aLinkIndex)++;
for (PRUint32 index = 0; index < nodeIndex; index++) {
nsCOMPtr<nsIDOMNode> childNode(do_QueryElementAt(mTextChildren, index));
if (GetLinkNode(childNode)) {
(*aLinkIndex)++;
}
}
}
return NS_OK;
}
/* long getSelectedLinkIndex (); */
NS_IMETHODIMP nsAccessibleHyperText::GetSelectedLinkIndex(PRInt32 *aSelectedLinkIndex)
{
*aSelectedLinkIndex = -1;
PRUint32 count;
mTextChildren->GetLength(&count);
if (count <= 0)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMNode> curNode(do_QueryElementAt(mTextChildren, 0));
PRUint32 index, linkCount = 0;
for (index = 0; index < count; index++) {
nsCOMPtr<nsIDOMNode> domNode(do_QueryElementAt(mTextChildren, index));
nsIDOMNode* linkNode = GetLinkNode(domNode);
if (linkNode) {
if (linkNode == nsAccessNode::gLastFocusedNode) {
*aSelectedLinkIndex = linkCount;
return NS_OK;
}
linkCount++;
}
}
return NS_ERROR_FAILURE;
}
nsresult nsAccessibleHyperText::GetBounds(nsIWeakReference *aWeakShell, PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height)
{
*x = *y = *width = *height = 0;
nsRect unionRectTwips;
PRUint32 index, count;
mTextChildren->GetLength(&count);
for (index = 0; index < count; index++) {
nsCOMPtr<nsIDOMNode> domNode(do_QueryElementAt(mTextChildren, index));
nsHTMLTextAccessible *accText = new nsHTMLTextAccessible(domNode, aWeakShell, nsnull);
if (!accText)
return NS_ERROR_OUT_OF_MEMORY;
nsRect frameRect;
accText->GetBounds(&frameRect.x, &frameRect.y, &frameRect.width, &frameRect.height);
unionRectTwips.UnionRect(unionRectTwips, frameRect);
delete accText;
}
*x = unionRectTwips.x;
*y = unionRectTwips.y;
*width = unionRectTwips.width;
*height = unionRectTwips.height;
return NS_OK;
}
nsIDOMNode* nsAccessibleHyperText::GetLinkNode(nsIDOMNode* aNode)
{
nsCOMPtr<nsIDOMNode> parentNode;
nsCOMPtr<nsILink> link;
while (aNode && link == nsnull) {
// text node maybe a child (or grandchild, ...) of a link node
aNode->GetParentNode(getter_AddRefs(parentNode));
aNode = parentNode;
link = do_QueryInterface(parentNode);
}
return parentNode;
}

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

@ -0,0 +1,76 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** 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
* Sun Microsystems, Inc.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Kyle Yuan (kyle.yuan@sun.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either 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 ***** */
#ifndef _nsAccessibleHyperText_H_
#define _nsAccessibleHyperText_H_
#include "nsAccessibleText.h"
#include "nsIAccessibleHyperText.h"
#include "nsIAccessibleText.h"
#include "nsIMutableArray.h"
#include "nsTextAccessible.h"
class nsAccessibleHyperText : public nsIAccessibleHyperText,
public nsIAccessibleText
{
NS_DECL_ISUPPORTS
NS_DECL_NSIACCESSIBLEHYPERTEXT
NS_DECL_NSIACCESSIBLETEXT
public:
nsAccessibleHyperText(nsIDOMNode* aDomNode, nsIWeakReference* aShell);
virtual ~nsAccessibleHyperText() {};
nsresult GetBounds(nsIWeakReference *aShell, PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height);
void Shutdown();
PRInt32 GetIndex();
protected:
nsCOMPtr<nsIMutableArray> mTextChildren;
PRInt32 mIndex;
PRBool GetAllTextChildren(nsPresContext *aPresContext, nsIFrame *aCurFrame, nsIDOMNode* aNode, PRBool &bSave);
nsIDOMNode* FindTextNodeByOffset(PRInt32 aOffset, PRInt32& aBeforeLength);
nsresult GetTextHelper(EGetTextType aType,
nsAccessibleTextBoundary aBoundaryType,
PRInt32 aOffset, PRInt32 *aStartOffset,
PRInt32 *aEndOffset, nsAString & aText);
nsIDOMNode* GetLinkNode(nsIDOMNode* aNode);
};
#endif

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -0,0 +1,136 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** 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
* Sun Microsystems, Inc.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Kyle Yuan (kyle.yuan@sun.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either 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 ***** */
#ifndef _nsAccessibleText_H_
#define _nsAccessibleText_H_
#include "nsAccessibleEventData.h"
#include "nsBaseWidgetAccessible.h"
#include "nsIAccessibleEditableText.h"
#include "nsIAccessibleText.h"
#include "nsIEditActionListener.h"
#include "nsIEditor.h"
#include "nsISelectionController.h"
#include "nsITextControlFrame.h"
#include "nsTextAccessibleWrap.h"
#include "nsTextAccessible.h"
enum EGetTextType { eGetBefore=-1, eGetAt=0, eGetAfter=1 };
class nsAccessibleText : public nsIAccessibleText
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIACCESSIBLETEXT
nsAccessibleText(nsIDOMNode *aNode);
virtual ~nsAccessibleText() {};
static PRBool gSuppressedNotifySelectionChanged;
protected:
nsCOMPtr<nsIDOMNode> mTextNode;
virtual nsresult GetSelections(nsISelectionController **aSelCon, nsISelection **aDomSel);
nsresult GetTextHelperCore(EGetTextType aType, nsAccessibleTextBoundary aBoundaryType,
PRInt32 aOffset, PRInt32 *aStartOffset, PRInt32 *aEndOffset,
nsISelectionController *aSelCon, nsISelection *aDomSel,
nsISupports *aClosure, nsAString & aText);
nsresult GetTextHelper(EGetTextType aType, nsAccessibleTextBoundary aBoundaryType,
PRInt32 aOffset, PRInt32 *aStartOffset, PRInt32 *aEndOffset,
nsISupports *aClosure, nsAString & aText);
static nsresult DOMPointToOffset(nsISupports *aClosure, nsIDOMNode* aNode, PRInt32 aNodeOffset, PRInt32 *aResult);
static nsresult OffsetToDOMPoint(nsISupports *aClosure, PRInt32 aOffset, nsIDOMNode** aResult, PRInt32* aPosition);
static nsresult GetCurrentOffset(nsISupports *aClosure, nsISelection *aDomSel, PRInt32 *aOffset);
friend class nsAccessibleHyperText;
};
class nsAccessibleEditableText : public nsAccessibleText,
public nsIAccessibleEditableText,
public nsIEditActionListener
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIACCESSIBLEEDITABLETEXT
NS_DECL_NSIEDITACTIONLISTENER
nsAccessibleEditableText(nsIDOMNode *aNode);
virtual ~nsAccessibleEditableText() {};
NS_IMETHOD GetCaretOffset(PRInt32 *aCaretOffset);
NS_IMETHOD SetCaretOffset(PRInt32 aCaretOffset);
NS_IMETHOD GetCharacterCount(PRInt32 *aCharacterCount);
NS_IMETHOD GetText(PRInt32 startOffset, PRInt32 endOffset, nsAString & aText);
NS_IMETHOD GetTextBeforeOffset(PRInt32 aOffset, nsAccessibleTextBoundary aBoundaryType,
PRInt32 *aStartOffset, PRInt32 *aEndOffset, nsAString & aText);
NS_IMETHOD GetTextAtOffset(PRInt32 aOffset, nsAccessibleTextBoundary aBoundaryType,
PRInt32 *aStartOffset, PRInt32 *aEndOffset, nsAString & aText);
NS_IMETHOD GetTextAfterOffset(PRInt32 aOffset, nsAccessibleTextBoundary aBoundaryType,
PRInt32 *aStartOffset, PRInt32 *aEndOffset, nsAString & aText);
void ShutdownEditor();
static PRBool IsSingleLineTextControl(nsIDOMNode *aDomNode);
protected:
virtual nsresult GetSelections(nsISelectionController **aSelCon, nsISelection **aDomSel);
void SetEditor(nsIEditor *aEditor);
nsITextControlFrame* GetTextFrame();
nsresult GetSelectionRange(PRInt32 *aStartPos, PRInt32 *aEndPos);
nsresult SetSelectionRange(PRInt32 aStartPos, PRInt32 aEndPos);
nsresult FireTextChangeEvent(AtkTextChange *aTextData);
// To solve the naming conflict with nsDocAccessible::mEditor, we have to name it
// "mPlainEditor", though it's not necessary to be a "plaintext" editor.
nsCOMPtr<nsIEditor> mPlainEditor;
};
class nsTextAccessibleWrap : public nsTextAccessible,
public nsAccessibleText
{
public:
NS_DECL_ISUPPORTS_INHERITED
nsTextAccessibleWrap(nsIDOMNode* aDomNode, nsIWeakReference* aShell);
};
#endif

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

@ -0,0 +1,76 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** 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
* Sun Microsystems, Inc.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Kyle Yuan (kyle.yuan@sun.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either 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 ***** */
#include "nsHTMLBlockAccessible.h"
NS_IMPL_ISUPPORTS_INHERITED2(nsHTMLBlockAccessible, nsBlockAccessible, nsIAccessibleText, nsIAccessibleHyperText)
nsHTMLBlockAccessible::nsHTMLBlockAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell):
nsBlockAccessible(aDomNode, aShell), nsAccessibleHyperText(aDomNode, aShell)
{
}
NS_IMETHODIMP nsHTMLBlockAccessible::GetName(nsAString& aName)
{
return nsBlockAccessible::GetName(aName);
}
NS_IMETHODIMP nsHTMLBlockAccessible::GetRole(PRUint32 *aRole)
{
*aRole = ROLE_TEXT;
return NS_OK;
}
NS_IMETHODIMP nsHTMLBlockAccessible::GetState(PRUint32 *aState)
{
nsAccessible::GetState(aState);
*aState &= ~STATE_FOCUSABLE;
*aState |= STATE_UNAVAILABLE;
return NS_OK;
}
NS_IMETHODIMP nsHTMLBlockAccessible::GetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height)
{
return nsAccessibleHyperText::GetBounds(mWeakShell, x, y, width, height);
}
NS_IMETHODIMP nsHTMLBlockAccessible::Shutdown()
{
nsAccessibleHyperText::Shutdown();
return nsBlockAccessible::Shutdown();
}

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

@ -0,0 +1,59 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** 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
* Sun Microsystems, Inc.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Kyle Yuan (kyle.yuan@sun.com)
*
* Alternatively, the contents of this file may be used under the terms of
* either 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 ***** */
#ifndef _nsHTMLBlockAccessible_H_
#define _nsHTMLBlockAccessible_H_
#include "nsAccessibleHyperText.h"
class nsHTMLBlockAccessible : public nsBlockAccessible,
public nsAccessibleHyperText
{
NS_DECL_ISUPPORTS_INHERITED
public:
nsHTMLBlockAccessible(nsIDOMNode* aDomNode, nsIWeakReference* aShell);
NS_IMETHOD GetName(nsAString& aName);
NS_IMETHOD GetRole(PRUint32 *aRole);
NS_IMETHOD GetState(PRUint32 *aState);
NS_IMETHOD GetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height);
NS_IMETHOD Shutdown();
};
#endif

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

@ -50,9 +50,6 @@ valueInterfaceInitCB(AtkValueIface *aIface)
aIface->get_current_value = getCurrentValueCB;
aIface->get_maximum_value = getMaximumValueCB;
aIface->get_minimum_value = getMinimumValueCB;
#ifdef USE_ATK_VALUE_MINIMUMINCREMENT
aIface->get_minimum_increment = getMinimumIncrementCB;
#endif
aIface->set_current_value = setCurrentValueCB;
}
@ -119,29 +116,6 @@ getMinimumValueCB(AtkValue *obj, GValue *value)
g_value_set_double (value, accDouble);
}
#ifdef USE_ATK_VALUE_MINIMUMINCREMENT
void
getMinimumIncrementCB(AtkValue *obj, GValue *minimumIncrement)
{
nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
if (!accWrap)
return;
nsCOMPtr<nsIAccessibleValue> accValue;
accWrap->QueryInterface(NS_GET_IID(nsIAccessibleValue),
getter_AddRefs(accValue));
if (!accValue)
return;
memset (value, 0, sizeof (GValue));
double accDouble;
if (NS_FAILED(accValue->GetMinimumIncrement(&accDouble)))
return;
g_value_init (minimumIncrement, G_TYPE_DOUBLE);
g_value_set_double (minimumIncrement, accDouble);
}
#endif
gboolean
setCurrentValueCB(AtkValue *obj, const GValue *value)
{
@ -153,6 +127,9 @@ setCurrentValueCB(AtkValue *obj, const GValue *value)
getter_AddRefs(accValue));
NS_ENSURE_TRUE(accValue, FALSE);
double accDouble =g_value_get_double (value);
return !NS_FAILED(accValue->SetCurrentValue(accDouble));
PRBool aBool;
double accDouble;
accDouble = g_value_get_double (value);
accValue->SetCurrentValue(accDouble, &aBool);
return aBool;
}

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

@ -51,9 +51,6 @@ void valueInterfaceInitCB(AtkValueIface *aIface);
void getCurrentValueCB(AtkValue *obj, GValue *value);
void getMaximumValueCB(AtkValue *obj, GValue *value);
void getMinimumValueCB(AtkValue *obj, GValue *value);
#ifdef USE_ATK_VALUE_MINIMUMINCREMENT
void getMinimumIncrementCB(AtkValue *obj, GValue *minIncrement);
#endif
gboolean setCurrentValueCB(AtkValue *obj, const GValue *value);
G_END_DECLS

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

@ -44,6 +44,62 @@
#include "nsIDOMHTMLInputElement.h"
#include "nsIDOMXULTextboxElement.h"
NS_IMPL_ISUPPORTS_INHERITED1(nsXULProgressMeterAccessibleWrap, nsXULProgressMeterAccessible, nsIAccessibleValue)
nsXULProgressMeterAccessibleWrap::nsXULProgressMeterAccessibleWrap(nsIDOMNode* aNode, nsIWeakReference* aShell):
nsXULProgressMeterAccessible(aNode, aShell)
{
}
/* readonly attribute double maximumValue; */
NS_IMETHODIMP nsXULProgressMeterAccessibleWrap::GetMaximumValue(double *aMaximumValue)
{
*aMaximumValue = 1; // 100% = 1;
return NS_OK;
}
/* readonly attribute double minimumValue; */
NS_IMETHODIMP nsXULProgressMeterAccessibleWrap::GetMinimumValue(double *aMinimumValue)
{
*aMinimumValue = 0;
return NS_OK;
}
/* readonly attribute double currentValue; */
NS_IMETHODIMP nsXULProgressMeterAccessibleWrap::GetCurrentValue(double *aCurrentValue)
{
nsAutoString currentValue;
GetValue(currentValue);
PRInt32 error;
*aCurrentValue = currentValue.ToFloat(&error) / 100;
return NS_OK;
}
/* boolean setCurrentValue (in double value); */
NS_IMETHODIMP nsXULProgressMeterAccessibleWrap::SetCurrentValue(double aValue, PRBool *_retval)
{
//Here I do not suppose the min/max are 0/1.00 because I want
// these part of code to be more extensible.
*_retval = PR_FALSE;
double min, max;
GetMinimumValue(&min);
GetMaximumValue(&max);
if (aValue > max || aValue < min)
return NS_ERROR_INVALID_ARG;
nsCOMPtr<nsIDOMElement> element(do_QueryInterface(mDOMNode));
NS_ASSERTION(element, "No element for DOM node!");
PRUint32 value = PRUint32(aValue * 100.0 + 0.5);
nsAutoString valueString;
valueString.AppendInt(value);
valueString.AppendLiteral("%");
if (NS_SUCCEEDED(element->SetAttribute(NS_LITERAL_STRING("value"), valueString))) {
*_retval = PR_TRUE;
return NS_OK;
}
return NS_ERROR_INVALID_ARG;
}
NS_IMPL_ISUPPORTS_INHERITED2(nsXULTextFieldAccessibleWrap, nsXULTextFieldAccessible, nsIAccessibleText, nsIAccessibleEditableText)
nsXULTextFieldAccessibleWrap::nsXULTextFieldAccessibleWrap(nsIDOMNode* aNode, nsIWeakReference* aShell):

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

@ -44,6 +44,17 @@
#include "nsXULFormControlAccessible.h"
#include "nsAccessibleText.h"
class nsXULProgressMeterAccessibleWrap : public nsXULProgressMeterAccessible,
public nsIAccessibleValue
{
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIACCESSIBLEVALUE
nsXULProgressMeterAccessibleWrap(nsIDOMNode* aNode, nsIWeakReference* aShell);
};
class nsXULTextFieldAccessibleWrap : public nsXULTextFieldAccessible,
public nsAccessibleEditableText
{

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

@ -153,5 +153,3 @@ ACCESSIBILITY_ATOM(required, "required")
ACCESSIBILITY_ATOM(role, "role")
ACCESSIBILITY_ATOM(selected, "selected")
ACCESSIBILITY_ATOM(valuenow, "valuenow") // For DHTML widget values
ACCESSIBILITY_ATOM(valuemin, "valuemin")
ACCESSIBILITY_ATOM(valuemax, "valuemax")

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

@ -1321,7 +1321,7 @@ nsAccessibilityService::CreateXULProgressMeterAccessible(nsIDOMNode *aNode, nsIA
nsCOMPtr<nsIWeakReference> weakShell;
GetShellFromNode(aNode, getter_AddRefs(weakShell));
*_retval = new nsXULProgressMeterAccessible(aNode, weakShell);
*_retval = new nsXULProgressMeterAccessibleWrap(aNode, weakShell);
if (! *_retval)
return NS_ERROR_OUT_OF_MEMORY;

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

@ -59,7 +59,7 @@
#include "nsISelectionController.h"
#include "nsIServiceManager.h"
#include "nsXPIDLString.h"
#include "prdtoa.h"
#include "nsIDOMComment.h"
#include "nsITextContent.h"
#include "nsIDOMHTMLImageElement.h"
@ -148,13 +148,6 @@ nsresult nsAccessible::QueryInterface(REFNSIID aIID, void** aInstancePtr)
}
}
if (aIID.Equals(NS_GET_IID(nsIAccessibleValue))) {
if (mRoleMapEntry && mRoleMapEntry->valueRule != eNoValue) {
*aInstancePtr = NS_STATIC_CAST(nsIAccessibleValue*, this);
NS_ADDREF_THIS();
}
}
return nsAccessNode::QueryInterface(aIID, aInstancePtr);
}
@ -1194,7 +1187,7 @@ nsresult nsAccessible::AppendNameFromAccessibleFor(nsIContent *aContent,
}
if (accessible) {
if (aFromValue) {
accessible->GetValue(textEquivalent);
accessible->GetFinalValue(textEquivalent);
}
else {
accessible->GetName(textEquivalent);
@ -1842,10 +1835,7 @@ NS_IMETHODIMP nsAccessible::GetFinalState(PRUint32 *aState)
return rv;
}
// Not implemented by this class
/* DOMString getValue (); */
NS_IMETHODIMP nsAccessible::GetValue(nsAString& aValue)
NS_IMETHODIMP nsAccessible::GetFinalValue(nsAString& aValue)
{
if (!mDOMNode) {
return NS_ERROR_FAILURE; // Node already shut down
@ -1860,112 +1850,15 @@ NS_IMETHODIMP nsAccessible::GetValue(nsAString& aValue)
return NS_OK;
}
}
return NS_OK;
return GetValue(aValue);
}
NS_IMETHODIMP nsAccessible::GetMaximumValue(double *aMaximumValue)
{
*aMaximumValue = 0;
if (!mDOMNode) {
return NS_ERROR_FAILURE; // Node already shut down
}
if (mRoleMapEntry) {
if (mRoleMapEntry->valueRule == eNoValue) {
return NS_OK;
}
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
nsAutoString valueMax;
if (content && content->GetAttr(kNameSpaceID_WAIProperties,
nsAccessibilityAtoms::valuemax, valueMax) &&
valueMax.IsEmpty() == PR_FALSE) {
*aMaximumValue = PR_strtod(NS_LossyConvertUTF16toASCII(valueMax).get(), nsnull);
return NS_OK;
}
}
return NS_ERROR_FAILURE; // No maximum
}
// Not implemented by this class
NS_IMETHODIMP nsAccessible::GetMinimumValue(double *aMinimumValue)
/* DOMString getValue (); */
NS_IMETHODIMP nsAccessible::GetValue(nsAString& _retval)
{
*aMinimumValue = 0;
if (!mDOMNode) {
return NS_ERROR_FAILURE; // Node already shut down
}
if (mRoleMapEntry) {
if (mRoleMapEntry->valueRule == eNoValue) {
return NS_OK;
}
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
nsAutoString valueMin;
if (content && content->GetAttr(kNameSpaceID_WAIProperties,
nsAccessibilityAtoms::valuemin, valueMin) &&
valueMin.IsEmpty() == PR_FALSE) {
*aMinimumValue = PR_strtod(NS_LossyConvertUTF16toASCII(valueMin).get(), nsnull);
return NS_OK;
}
}
return NS_ERROR_FAILURE; // No minimum
}
NS_IMETHODIMP nsAccessible::GetMinimumIncrement(double *aMinIncrement)
{
*aMinIncrement = 0;
return NS_ERROR_NOT_IMPLEMENTED; // No mimimum increment in dynamic content spec right now
}
NS_IMETHODIMP nsAccessible::GetCurrentValue(double *aValue)
{
*aValue = 0;
if (!mDOMNode) {
return NS_ERROR_FAILURE; // Node already shut down
}
if (mRoleMapEntry) {
if (mRoleMapEntry->valueRule == eNoValue) {
return NS_OK;
}
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
nsAutoString value;
if (content && content->GetAttr(kNameSpaceID_WAIProperties,
nsAccessibilityAtoms::valuenow, value) &&
value.IsEmpty() == PR_FALSE) {
*aValue = PR_strtod(NS_LossyConvertUTF16toASCII(value).get(), nsnull);
return NS_OK;
}
}
return NS_ERROR_FAILURE; // No value
}
NS_IMETHODIMP nsAccessible::SetCurrentValue(double aValue)
{
if (!mDOMNode) {
return NS_ERROR_FAILURE; // Node already shut down
}
if (mRoleMapEntry) {
if (mRoleMapEntry->valueRule == eNoValue) {
return NS_OK;
}
const PRUint32 kValueCannotChange = STATE_READONLY | STATE_UNAVAILABLE;
PRUint32 state;
if (NS_FAILED(GetFinalState(&state)) || (state & kValueCannotChange)) {
return NS_ERROR_FAILURE;
}
double minValue;
if (NS_SUCCEEDED(GetMinimumValue(&minValue)) && aValue < minValue) {
return NS_ERROR_INVALID_ARG;
}
double maxValue;
if (NS_SUCCEEDED(GetMaximumValue(&maxValue)) && aValue > maxValue) {
return NS_ERROR_INVALID_ARG;
}
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
if (content) {
nsAutoString newValue;
newValue.AppendFloat(aValue);
return content->SetAttr(kNameSpaceID_WAIProperties,
nsAccessibilityAtoms::valuenow, newValue, PR_TRUE);
}
}
return NS_ERROR_FAILURE; // Not in a role that can accept value
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void setName (in DOMString name); */

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

@ -44,7 +44,6 @@
#include "nsIAccessible.h"
#include "nsPIAccessible.h"
#include "nsIAccessibleSelectable.h"
#include "nsIAccessibleValue.h"
#include "nsIDOMNodeList.h"
#include "nsINameSpaceManager.h"
#include "nsWeakReference.h"
@ -115,8 +114,7 @@ struct nsRoleMapEntry
class nsAccessible : public nsAccessNodeWrap,
public nsIAccessible,
public nsPIAccessible,
public nsIAccessibleSelectable,
public nsIAccessibleValue
public nsIAccessibleSelectable
{
public:
// to eliminate the confusion of "magic numbers" -- if ( 0 ){ foo; }
@ -131,13 +129,14 @@ public:
NS_DECL_NSIACCESSIBLE
NS_DECL_NSPIACCESSIBLE
NS_DECL_NSIACCESSIBLESELECTABLE
NS_DECL_NSIACCESSIBLEVALUE
// nsIAccessNode
NS_IMETHOD Init();
NS_IMETHOD Shutdown();
NS_IMETHOD GetState(PRUint32 *aState); // Must support GetFinalState()
// Support GetFinalState(), GetFinalValue()
NS_IMETHOD GetState(PRUint32 *aState);
NS_IMETHOD GetValue(nsAString & aValue);
#ifdef MOZ_ACCESSIBILITY_ATK
static nsresult GetParentBlockNode(nsIPresShell *aPresShell, nsIDOMNode *aCurrentNode, nsIDOMNode **aBlockNode);

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

@ -734,7 +734,7 @@ NS_IMETHODIMP nsRootAccessible::HandleEvent(nsIDOMEvent* aEvent)
if (role == ROLE_PROGRESSBAR) {
// For progressmeter, fire EVENT_SHOW on 1st value change
nsAutoString value;
accessible->GetValue(value);
accessible->GetFinalValue(value);
if (value.EqualsLiteral("0%")) {
privAcc->FireToolkitEvent(nsIAccessibleEvent::EVENT_SHOW,
accessible, nsnull);

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

@ -58,6 +58,7 @@ typedef class nsHTMLTextFieldAccessible nsHTMLTextFieldAccessibleWrap;
typedef class nsHTMLLinkAccessible nsHTMLLinkAccessibleWrap;
typedef class nsHTMLTableCellAccessible nsHTMLTableCellAccessibleWrap;
typedef class nsHTMLTableAccessible nsHTMLTableAccessibleWrap;
typedef class nsXULProgressMeterAccessible nsXULProgressMeterAccessibleWrap;
typedef class nsXULTextFieldAccessible nsXULTextFieldAccessibleWrap;
#endif

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

@ -285,7 +285,7 @@ STDMETHODIMP nsAccessibleWrap::get_accValue(
GetXPAccessibleFor(varChild, getter_AddRefs(xpAccessible));
if (xpAccessible) {
nsAutoString value;
if (NS_FAILED(xpAccessible->GetValue(value)))
if (NS_FAILED(xpAccessible->GetFinalValue(value)))
return S_FALSE;
*pszValue = ::SysAllocString(value.get());

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

@ -200,6 +200,7 @@ typedef class nsHTMLTextFieldAccessible nsHTMLTextFieldAccessibleWrap;
typedef class nsHTMLLinkAccessible nsHTMLLinkAccessibleWrap;
typedef class nsHTMLTableCellAccessible nsHTMLTableCellAccessibleWrap;
typedef class nsHTMLTableAccessible nsHTMLTableAccessibleWrap;
typedef class nsXULProgressMeterAccessible nsXULProgressMeterAccessibleWrap;
typedef class nsXULTextFieldAccessible nsXULTextFieldAccessibleWrap;
#endif

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

@ -58,6 +58,7 @@ typedef class nsHTMLTextFieldAccessible nsHTMLTextFieldAccessibleWrap;
typedef class nsHTMLLinkAccessible nsHTMLLinkAccessibleWrap;
typedef class nsHTMLTableCellAccessible nsHTMLTableCellAccessibleWrap;
typedef class nsHTMLTableAccessible nsHTMLTableAccessibleWrap;
typedef class nsXULProgressMeterAccessible nsXULProgressMeterAccessibleWrap;
typedef class nsXULTextFieldAccessible nsXULTextFieldAccessibleWrap;
#endif

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

@ -425,7 +425,7 @@ NS_IMETHODIMP nsXULGroupboxAccessible::GetName(nsAString& aName)
/**
* progressmeter
*/
NS_IMPL_ISUPPORTS_INHERITED1(nsXULProgressMeterAccessible, nsFormControlAccessible, nsIAccessibleValue)
NS_IMPL_ISUPPORTS_INHERITED0(nsXULProgressMeterAccessible, nsFormControlAccessible)
nsXULProgressMeterAccessible::nsXULProgressMeterAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
nsFormControlAccessible(aNode, aShell)
@ -438,61 +438,26 @@ NS_IMETHODIMP nsXULProgressMeterAccessible::GetRole(PRUint32 *_retval)
return NS_OK;
}
/**
* No states supported for progressmeter
*/
NS_IMETHODIMP nsXULProgressMeterAccessible::GetState(PRUint32 *aState)
{
nsresult rv = nsAccessible::GetState(aState);
*aState &= ~STATE_FOCUSABLE; // Progress meters are not focusable
*aState &= ~STATE_FOCUSABLE;
return rv;
}
NS_IMETHODIMP nsXULProgressMeterAccessible::GetValue(nsAString& aValue)
NS_IMETHODIMP nsXULProgressMeterAccessible::GetValue(nsAString& _retval)
{
aValue.Truncate();
nsAccessible::GetValue(aValue);
if (!aValue.IsEmpty()) {
return NS_OK;
}
nsCOMPtr<nsIDOMElement> element(do_QueryInterface(mDOMNode));
NS_ASSERTION(element, "No element for DOM node!");
element->GetAttribute(NS_LITERAL_STRING("value"), aValue);
if (!aValue.IsEmpty() && aValue.Last() != '%')
aValue.AppendLiteral("%");
element->GetAttribute(NS_LITERAL_STRING("value"), _retval);
if (!_retval.IsEmpty() && _retval.Last() != '%')
_retval.AppendLiteral("%");
return NS_OK;
}
NS_IMETHODIMP nsXULProgressMeterAccessible::GetMaximumValue(double *aMaximumValue)
{
*aMaximumValue = 1; // 100% = 1;
return NS_OK;
}
NS_IMETHODIMP nsXULProgressMeterAccessible::GetMinimumValue(double *aMinimumValue)
{
*aMinimumValue = 0;
return NS_OK;
}
NS_IMETHODIMP nsXULProgressMeterAccessible::GetMinimumIncrement(double *aMinimumIncrement)
{
*aMinimumIncrement = 0;
return NS_OK;
}
NS_IMETHODIMP nsXULProgressMeterAccessible::GetCurrentValue(double *aCurrentValue)
{
nsAutoString currentValue;
GetValue(currentValue);
PRInt32 error;
*aCurrentValue = currentValue.ToFloat(&error) / 100;
return NS_OK;
}
NS_IMETHODIMP nsXULProgressMeterAccessible::SetCurrentValue(double aValue)
{
return NS_ERROR_FAILURE; // Progress meters are readonly!
}
/**
* XUL Radio Button
*/

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

@ -95,13 +95,12 @@ public:
class nsXULProgressMeterAccessible : public nsFormControlAccessible
{
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIACCESSIBLEVALUE
public:
nsXULProgressMeterAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
NS_IMETHOD GetRole(PRUint32 *aRole);
NS_IMETHOD GetState(PRUint32 *aState);
NS_IMETHOD GetValue(nsAString &aValue);
NS_IMETHOD GetRole(PRUint32 *_retval);
NS_IMETHOD GetState(PRUint32 *_retval);
NS_IMETHOD GetValue(nsAString &_retval);
};
class nsXULRadioButtonAccessible : public nsRadioButtonAccessible