Bug 148902 Implemetation of nsIAccessibleEditableText

r=aaronl, sr=jst
This commit is contained in:
kyle.yuan%sun.com 2002-06-12 05:27:37 +00:00
Родитель 5edddda012
Коммит d5c0bf6b9b
5 изменённых файлов: 123 добавлений и 4 удалений

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

@ -34,8 +34,8 @@ interface nsIAccessibleEditableText : nsISupports
*/
void setAttributes (in long startPos, in long endPos,
in nsISupports attributes);
boolean setTextContents (in AString text);
void insertText (in AString text, in long length, inout long position);
void setTextContents (in AString text);
void insertText (in AString text, in long position);
void copyText (in long startPos, in long endPos);
void cutText (in long startPos, in long endPos);
void deleteText (in long startPos, in long endPos);

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

@ -31,6 +31,7 @@ LIBRARY_NAME = accessibility_html_s
REQUIRES = content \
docshell \
dom \
editor \
gfx \
gfx2 \
htmlparser \

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

@ -26,6 +26,7 @@ REQUIRES = \
content \
docshell \
dom \
editor \
gfx \
gfx2 \
htmlparser \

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

@ -42,6 +42,7 @@
#include "nsFormControlAccessible.h"
#include "nsHTMLAtoms.h"
#include "nsHTMLFormControlAccessible.h"
#include "nsIClipboard.h"
#include "nsIDOMHTMLButtonElement.h"
#include "nsIDOMHTMLFormElement.h"
#include "nsIDOMHTMLInputElement.h"
@ -52,8 +53,12 @@
#include "nsIDOMXULButtonElement.h"
#include "nsIDOMXULSelectCntrlItemEl.h"
#include "nsIDOMXULSelectCntrlEl.h"
#include "nsINameSpaceManager.h"
#include "nsIEditor.h"
#include "nsIEventStateManager.h"
#include "nsIFrame.h"
#include "nsIGfxTextControlFrame.h"
#include "nsINameSpaceManager.h"
#include "nsIPlaintextEditor.h"
#include "nsISelectionController.h"
#include "nsReadableUtils.h"
#include "nsWeakReference.h"
@ -310,6 +315,8 @@ nsFormControlAccessible(aNode, aShell)
{
}
NS_IMPL_ISUPPORTS_INHERITED1(nsHTMLTextFieldAccessible, nsFormControlAccessible, nsIAccessibleEditableText)
NS_IMETHODIMP nsHTMLTextFieldAccessible::GetAccRole(PRUint32 *_retval)
{
*_retval = ROLE_TEXT;
@ -400,6 +407,106 @@ NS_IMETHODIMP nsHTMLTextFieldAccessible::GetAccState(PRUint32 *_retval)
return NS_OK;
}
NS_IMETHODIMP nsHTMLTextFieldAccessible::SetAttributes(PRInt32 aStartPos, PRInt32 aEndPos, nsISupports *aAttributes)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsHTMLTextFieldAccessible::SetTextContents(const nsAString &aText)
{
nsCOMPtr<nsIDOMHTMLTextAreaElement> textArea(do_QueryInterface(mDOMNode));
if (textArea)
return textArea->SetValue(aText);
nsCOMPtr<nsIDOMHTMLInputElement> inputElement(do_QueryInterface(mDOMNode));
if (inputElement)
return inputElement->SetValue(aText);
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsHTMLTextFieldAccessible::MakeSelection(PRInt32 aStartPos, PRInt32 aEndPos, nsIEditor **aEditor)
{
nsCOMPtr<nsIPresShell> shell(do_QueryReferent(mPresShell));
if (!shell)
return NS_ERROR_FAILURE;
AccTakeFocus();
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
nsIFrame *frame = nsnull;
shell->GetPrimaryFrameFor(content, &frame);
nsCOMPtr<nsIGfxTextControlFrame2> tframe(do_QueryInterface(frame));
if (!tframe)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIEditor> editor;
tframe->SetSelectionRange(aStartPos, aEndPos);
tframe->GetEditor(getter_AddRefs(editor));
if (!editor)
return NS_ERROR_FAILURE;
*aEditor = editor;
NS_ADDREF(*aEditor);
return NS_OK;
}
NS_IMETHODIMP nsHTMLTextFieldAccessible::InsertText(const nsAString &aText, PRInt32 aPosition)
{
nsCOMPtr<nsIEditor> editor;
if (NS_SUCCEEDED(MakeSelection(aPosition, aPosition, getter_AddRefs(editor)))) {
nsCOMPtr<nsIPlaintextEditor> peditor(do_QueryInterface(editor));
peditor->InsertText(aText);
return NS_OK;
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsHTMLTextFieldAccessible::CopyText(PRInt32 aStartPos, PRInt32 aEndPos)
{
nsCOMPtr<nsIEditor> editor;
if (NS_SUCCEEDED(MakeSelection(aStartPos, aEndPos, getter_AddRefs(editor)))) {
editor->Copy();
return NS_OK;
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsHTMLTextFieldAccessible::CutText(PRInt32 aStartPos, PRInt32 aEndPos)
{
nsCOMPtr<nsIEditor> editor;
if (NS_SUCCEEDED(MakeSelection(aStartPos, aEndPos, getter_AddRefs(editor)))) {
editor->Cut();
return NS_OK;
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsHTMLTextFieldAccessible::DeleteText(PRInt32 aStartPos, PRInt32 aEndPos)
{
nsCOMPtr<nsIEditor> editor;
if (NS_SUCCEEDED(MakeSelection(aStartPos, aEndPos, getter_AddRefs(editor)))) {
editor->DeleteSelection(nsIEditor::eNone);
return NS_OK;
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsHTMLTextFieldAccessible::PasteText(PRInt32 aPosition)
{
nsCOMPtr<nsIEditor> editor;
if (NS_SUCCEEDED(MakeSelection(aPosition, aPosition, getter_AddRefs(editor)))) {
editor->Paste(nsIClipboard::kGlobalClipboard);
return NS_OK;
}
return NS_ERROR_FAILURE;
}
// --- groupbox -----

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

@ -42,6 +42,7 @@
#include "nsBaseWidgetAccessible.h"
#include "nsFormControlAccessible.h"
#include "nsIAccessibleEditableText.h"
class nsICheckboxControlFrame;
@ -92,13 +93,22 @@ public:
NS_IMETHOD AccDoAction(PRUint8 index);
};
class nsHTMLTextFieldAccessible : public nsFormControlAccessible
class nsIEditor;
class nsHTMLTextFieldAccessible : public nsFormControlAccessible,
public nsIAccessibleEditableText
{
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIACCESSIBLEEDITABLETEXT
nsHTMLTextFieldAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
NS_IMETHOD GetAccRole(PRUint32 *_retval);
NS_IMETHOD GetAccValue(nsAString& _retval);
NS_IMETHOD GetAccState(PRUint32 *_retval);
protected:
NS_IMETHOD MakeSelection(PRInt32 aStartPos, PRInt32 aEndPos, nsIEditor **aEditor);
};
class nsHTMLGroupboxAccessible : public nsAccessible