Bug 207487. No accessible name using label for xul <textbox> element. r=kyle, sr=alecf

This commit is contained in:
aaronl%netscape.com 2003-06-04 20:57:39 +00:00
parent 39b6e7826f
commit 2a2c2b833e
6 changed files with 123 additions and 6 deletions

View File

@ -93,6 +93,7 @@ interface nsIAccessibilityService : nsISupports
nsIAccessible createXULTabPanelsAccessible(in nsIDOMNode aNode);
nsIAccessible createXULTabsAccessible(in nsIDOMNode aNode);
nsIAccessible createXULTextAccessible(in nsIDOMNode aNode);
nsIAccessible createXULTextBoxAccessible(in nsIDOMNode aNode);
nsIAccessible createXULTreeAccessible(in nsIDOMNode aNode);
nsIAccessible createXULTreeColumnsAccessible(in nsIDOMNode aNode);
nsIAccessible createXULTreeColumnitemAccessible(in nsIDOMNode aNode);

View File

@ -759,6 +759,25 @@ nsAccessibilityService::CreateHTMLTextFieldAccessible(nsISupports *aFrame, nsIAc
return NS_OK;
}
NS_IMETHODIMP
nsAccessibilityService::CreateXULTextBoxAccessible(nsIDOMNode *aNode, nsIAccessible **_retval)
{
#ifdef MOZ_XUL
nsCOMPtr<nsIWeakReference> weakShell;
GetShellFromNode(aNode, getter_AddRefs(weakShell));
// reusing the HTML accessible widget and enhancing for XUL
*_retval = new nsHTMLTextFieldAccessible(aNode, weakShell);
if (! *_retval)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*_retval);
#else
*_retval = nsnull;
#endif // MOZ_XUL
return NS_OK;
}
NS_IMETHODIMP
nsAccessibilityService::CreateHTMLLabelAccessible(nsISupports *aFrame, nsIAccessible **_retval)
{

View File

@ -44,6 +44,9 @@
#include "nsIDOMHTMLTextAreaElement.h"
#include "nsIFrame.h"
#include "nsISelectionController.h"
#ifdef MOZ_XUL
#include "nsIDOMXULTextboxElement.h"
#endif
// --- checkbox -----
@ -319,16 +322,21 @@ NS_IMETHODIMP nsHTMLTextFieldAccessible::GetAccValue(nsAString& _retval)
nsCOMPtr<nsIDOMHTMLTextAreaElement> textArea(do_QueryInterface(mDOMNode));
if (textArea) {
textArea->GetValue(_retval);
return NS_OK;
return textArea->GetValue(_retval);
}
nsCOMPtr<nsIDOMHTMLInputElement> inputElement(do_QueryInterface(mDOMNode));
if (inputElement) {
inputElement->GetValue(_retval);
return NS_OK;
return inputElement->GetValue(_retval);
}
#ifdef MOZ_XUL
nsCOMPtr<nsIDOMXULTextboxElement> textBox(do_QueryInterface(mDOMNode));
if (textBox) {
return textBox->GetValue(_retval);
}
#endif
return NS_ERROR_FAILURE;
}
@ -336,6 +344,25 @@ NS_IMETHODIMP nsHTMLTextFieldAccessible::GetAccState(PRUint32 *_retval)
{
// can be
// focusable, focused, protected. readonly, unavailable, selected
#ifdef MOZ_XUL
nsCOMPtr<nsIDOMXULTextboxElement> textBox(do_QueryInterface(mDOMNode));
if (textBox) {
nsCOMPtr<nsIDOMHTMLInputElement> inputField;
textBox->GetInputField(getter_AddRefs(inputField));
if (!inputField) {
return NS_ERROR_FAILURE;
}
// Create a temporary accessible from the HTML text field
// to get the accessible state from. Doesn't add to cache
// because Init() is not called.
nsHTMLTextFieldAccessible tempAccessible(inputField, mWeakShell);
return tempAccessible.GetAccState(_retval);
}
#endif
if (!mDOMNode) {
return NS_ERROR_FAILURE; // Node has been Shutdown()
}
nsAccessible::GetAccState(_retval);
*_retval |= STATE_FOCUSABLE;

View File

@ -46,6 +46,7 @@ XPIDLSRCS = \
nsIDOMXULSelectCntrlEl.idl \
nsIDOMXULSelectCntrlItemEl.idl \
nsIDOMXULMultSelectCntrlEl.idl \
nsIDOMXULTextboxElement.idl \
$(NULL)
include $(topsrcdir)/config/rules.mk

View File

@ -0,0 +1,60 @@
/* -*- 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
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2003
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Original Author: Aaron Leventhal (aaronl@netscape.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 "nsIDOMXULLabeledControlEl.idl"
interface nsIDOMHTMLInputElement;
[scriptable, uuid(71135B6C-294E-4634-A8E4-A72398F1E72A)]
interface nsIDOMXULTextboxElement : nsIDOMXULLabeledControlElement
{
readonly attribute nsIDOMHTMLInputElement inputField;
readonly attribute long textLength;
attribute long maxLength;
attribute long size;
attribute long selectionStart;
attribute long selectionEnd;
attribute DOMString value;
attribute DOMString type;
void select();
void setSelectionRange(in long selectionStart,
in long selectionEnd);
};

View File

@ -23,7 +23,16 @@
</xul:hbox>
</content>
<implementation>
<implementation implements="nsIAccessibleProvider, nsIDOMXULTextboxElement">
<property name="accessible">
<getter>
<![CDATA[
var accService = Components.classes["@mozilla.org/accessibilityService;1"].getService(Components.interfaces.nsIAccessibilityService);
return accService.createXULTextBoxAccessible(this);
]]>
</getter>
</property>
<field name="mInputField">null</field>
<property name="inputField" readonly="true">
@ -38,7 +47,7 @@
onget="return this.inputField.value;"/>
<property name="type" onset="this.inputField.type = val; return val;"
onget="return this.inputField.type;"/>
<property name="maxlength" onset="this.inputField.maxlength = val; return val;"
<property name="maxLength" onset="this.inputField.maxlength = val; return val;"
onget="return this.inputField.maxlength;"/>
<property name="disabled" onset="this.inputField.disabled = val;
if (val) this.setAttribute('disabled', 'true');