зеркало из https://github.com/mozilla/pjs.git
Bug 148902 Implemetation of nsIAccessibleEditableText
r=aaronl, sr=jst
This commit is contained in:
Родитель
f3b55310fb
Коммит
e71e668ebf
|
@ -1,53 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* 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 the Mozilla browser.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Original Author: Marc Mulcahy (marc.mulcahy@sun.com)
|
||||
*
|
||||
* Contributor(s): Paul Sandoz (paul.sandoz@sun.com)
|
||||
* Bill Haneman (bill.haneman@sun.com)
|
||||
* John Gaunt (jgaunt@netscape.com)
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(91F0A56C-11BE-47C7-8D02-7C15E00C05F5)]
|
||||
interface nsIAccessibleEditableText : nsISupports
|
||||
{
|
||||
/**
|
||||
* Set font styles, such as italic, bold...
|
||||
*/
|
||||
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 copyText (in long startPos, in long endPos);
|
||||
void cutText (in long startPos, in long endPos);
|
||||
void deleteText (in long startPos, in long endPos);
|
||||
void pasteText (in long position);
|
||||
};
|
||||
|
||||
/*
|
||||
Assumptions:
|
||||
|
||||
selectAttributes method takes an nsISupports parameter.
|
||||
'set' methods throw exception on failure.
|
||||
'wstring' inputs are potentially multibyte (UTF-16 for
|
||||
instance); 'string' and UTF-8 may be a better choice.
|
||||
|
||||
*/
|
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче