зеркало из https://github.com/mozilla/gecko-dev.git
Bug 390767. Support editable state and interface for contentEditable and designMode documents and their content. r=ginn.chen, a=dsicore
This commit is contained in:
Родитель
7db0ed8df7
Коммит
b08ef7a65d
|
@ -153,6 +153,7 @@ ACCESSIBILITY_ATOM(accesskey, "accesskey")
|
|||
ACCESSIBILITY_ATOM(alt, "alt")
|
||||
ACCESSIBILITY_ATOM(anonid, "anonid") // Used for ID's in XBL
|
||||
ACCESSIBILITY_ATOM(autocomplete, "autocomplete") // Used as attribute value too
|
||||
ACCESSIBILITY_ATOM(contenteditable, "contenteditable")
|
||||
ACCESSIBILITY_ATOM(control, "control")
|
||||
ACCESSIBILITY_ATOM(cycles, "cycles") // used for XUL cycler attribute
|
||||
ACCESSIBILITY_ATOM(curpos, "curpos") // XUL
|
||||
|
|
|
@ -243,7 +243,8 @@ nsDocAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState)
|
|||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIEditor> editor = GetEditor();
|
||||
nsCOMPtr<nsIEditor> editor;
|
||||
GetAssociatedEditor(getter_AddRefs(editor));
|
||||
if (!editor) {
|
||||
*aState |= nsIAccessibleStates::STATE_READONLY;
|
||||
}
|
||||
|
@ -397,37 +398,33 @@ NS_IMETHODIMP nsDocAccessible::GetDocument(nsIDOMDocument **aDOMDoc)
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
void nsDocAccessible::SetEditor(nsIEditor* aEditor)
|
||||
NS_IMETHODIMP nsDocAccessible::GetAssociatedEditor(nsIEditor **aEditor)
|
||||
{
|
||||
mEditor = aEditor;
|
||||
}
|
||||
NS_ENSURE_ARG_POINTER(aEditor);
|
||||
|
||||
void nsDocAccessible::CheckForEditor()
|
||||
{
|
||||
if (mEditor) {
|
||||
return; // Already have editor, don't need to check
|
||||
}
|
||||
if (!mDocument) {
|
||||
return; // No document -- we've been shut down
|
||||
*aEditor = nsnull;
|
||||
NS_ENSURE_TRUE(mDocument, NS_ERROR_FAILURE);
|
||||
|
||||
if (!mDocument->HasFlag(NODE_IS_EDITABLE)) {
|
||||
return NS_OK; // Document not editable
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISupports> container = mDocument->GetContainer();
|
||||
nsCOMPtr<nsIEditingSession> editingSession(do_GetInterface(container));
|
||||
if (!editingSession)
|
||||
return; // No editing session interface
|
||||
return NS_OK; // No editing session interface
|
||||
|
||||
nsCOMPtr<nsIEditor> editor;
|
||||
editingSession->GetEditorForWindow(mDocument->GetWindow(),
|
||||
getter_AddRefs(editor));
|
||||
SetEditor(editor);
|
||||
if (!editor)
|
||||
return;
|
||||
|
||||
// State editable is now set, readonly is now clear
|
||||
nsCOMPtr<nsIAccessibleStateChangeEvent> event =
|
||||
new nsAccStateChangeEvent(this, nsIAccessibleStates::EXT_STATE_EDITABLE,
|
||||
PR_TRUE, PR_TRUE);
|
||||
FireAccessibleEvent(event);
|
||||
editingSession->GetEditorForWindow(mDocument->GetWindow(), getter_AddRefs(editor));
|
||||
if (!editor) {
|
||||
return NS_OK;
|
||||
}
|
||||
PRBool isEditable;
|
||||
editor->GetIsDocumentEditable(&isEditable);
|
||||
if (isEditable) {
|
||||
NS_ADDREF(*aEditor = editor);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocAccessible::GetCachedAccessNode(void *aUniqueID, nsIAccessNode **aAccessNode)
|
||||
|
@ -531,8 +528,6 @@ NS_IMETHODIMP nsDocAccessible::Shutdown()
|
|||
nsCOMPtr<nsIDocShellTreeItem> treeItem = GetDocShellTreeItemFor(mDOMNode);
|
||||
ShutdownChildDocuments(treeItem);
|
||||
|
||||
mEditor = nsnull;
|
||||
|
||||
if (mDocLoadTimer) {
|
||||
mDocLoadTimer->Cancel();
|
||||
mDocLoadTimer = nsnull;
|
||||
|
@ -653,14 +648,10 @@ nsresult nsDocAccessible::AddEventListeners()
|
|||
PRBool isContent = (itemType == nsIDocShellTreeItem::typeContent);
|
||||
|
||||
if (isContent) {
|
||||
CheckForEditor();
|
||||
|
||||
if (!mEditor) {
|
||||
// We're not an editor yet, but we might become one
|
||||
nsCOMPtr<nsICommandManager> commandManager = do_GetInterface(docShellTreeItem);
|
||||
if (commandManager) {
|
||||
commandManager->AddCommandObserver(this, "obs_documentCreated");
|
||||
}
|
||||
// We're not an editor yet, but we might become one
|
||||
nsCOMPtr<nsICommandManager> commandManager = do_GetInterface(docShellTreeItem);
|
||||
if (commandManager) {
|
||||
commandManager->AddCommandObserver(this, "obs_documentCreated");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -898,9 +889,12 @@ NS_IMETHODIMP nsDocAccessible::ScrollPositionDidChange(nsIScrollableView *aScrol
|
|||
NS_IMETHODIMP nsDocAccessible::Observe(nsISupports *aSubject, const char *aTopic,
|
||||
const PRUnichar *aData)
|
||||
{
|
||||
if (!nsCRT::strcmp(aTopic,"obs_documentCreated")) {
|
||||
CheckForEditor();
|
||||
NS_ASSERTION(mEditor, "Should have editor if we see obs_documentCreated");
|
||||
if (!nsCRT::strcmp(aTopic,"obs_documentCreated")) {
|
||||
// State editable will now be set, readonly is now clear
|
||||
nsCOMPtr<nsIAccessibleStateChangeEvent> event =
|
||||
new nsAccStateChangeEvent(this, nsIAccessibleStates::EXT_STATE_EDITABLE,
|
||||
PR_TRUE, PR_TRUE);
|
||||
FireAccessibleEvent(event);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -1030,6 +1024,15 @@ nsDocAccessible::AttributeChanged(nsIDocument *aDocument, nsIContent* aContent,
|
|||
targetNode, nsnull);
|
||||
}
|
||||
}
|
||||
|
||||
if (aAttribute == nsAccessibilityAtoms::contenteditable) {
|
||||
nsCOMPtr<nsIAccessibleStateChangeEvent> editableChangeEvent =
|
||||
new nsAccStateChangeEvent(targetNode,
|
||||
nsIAccessibleStates::EXT_STATE_EDITABLE,
|
||||
PR_TRUE);
|
||||
FireDelayedAccessibleEvent(editableChangeEvent);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -99,6 +99,9 @@ class nsDocAccessible : public nsHyperTextAccessibleWrap,
|
|||
// nsPIAccessNode
|
||||
NS_IMETHOD_(nsIFrame *) GetFrame(void);
|
||||
|
||||
// nsIAccessibleText
|
||||
NS_IMETHOD GetAssociatedEditor(nsIEditor **aEditor);
|
||||
|
||||
/**
|
||||
* Non-virtual method to fire a delayed event after a 0 length timeout
|
||||
*
|
||||
|
@ -139,9 +142,6 @@ class nsDocAccessible : public nsHyperTextAccessibleWrap,
|
|||
void RemoveScrollListener();
|
||||
void RefreshNodes(nsIDOMNode *aStartNode);
|
||||
static void ScrollTimerCallback(nsITimer *aTimer, void *aClosure);
|
||||
void CheckForEditor();
|
||||
virtual void SetEditor(nsIEditor *aEditor);
|
||||
virtual already_AddRefed<nsIEditor> GetEditor() { nsIEditor *editor = mEditor; NS_IF_ADDREF(editor); return editor; }
|
||||
|
||||
/**
|
||||
* Fires accessible events when ARIA attribute is chaned.
|
||||
|
@ -180,7 +180,6 @@ class nsDocAccessible : public nsHyperTextAccessibleWrap,
|
|||
PRUint16 mScrollPositionChangedTicks; // Used for tracking scroll events
|
||||
PRPackedBool mIsContentLoaded;
|
||||
nsCOMArray<nsIAccessibleEvent> mEventsToFire;
|
||||
nsCOMPtr<nsIEditor> mEditor;
|
||||
|
||||
protected:
|
||||
PRBool mIsAnchor;
|
||||
|
|
|
@ -47,7 +47,8 @@ MODULE = accessibility
|
|||
LIBRARY_NAME = accessibility_html_s
|
||||
LIBXUL_LIBRARY = 1
|
||||
|
||||
REQUIRES = content \
|
||||
REQUIRES = composer \
|
||||
content \
|
||||
docshell \
|
||||
dom \
|
||||
editor \
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include "nsIDOMHTMLFormElement.h"
|
||||
#include "nsIDOMHTMLLegendElement.h"
|
||||
#include "nsIDOMHTMLTextAreaElement.h"
|
||||
#include "nsIEditor.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsISelectionController.h"
|
||||
|
@ -372,21 +373,6 @@ nsHyperTextAccessibleWrap(aNode, aShell)
|
|||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED1(nsHTMLTextFieldAccessible, nsHyperTextAccessibleWrap,
|
||||
nsIAccessibleText)
|
||||
|
||||
NS_IMETHODIMP nsHTMLTextFieldAccessible::Init()
|
||||
{
|
||||
CheckForEditor();
|
||||
return nsHyperTextAccessibleWrap::Init();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLTextFieldAccessible::Shutdown()
|
||||
{
|
||||
mEditor = nsnull;
|
||||
return nsHyperTextAccessibleWrap::Shutdown();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLTextFieldAccessible::GetRole(PRUint32 *aRole)
|
||||
{
|
||||
*aRole = nsIAccessibleRole::ROLE_ENTRY;
|
||||
|
@ -542,17 +528,11 @@ NS_IMETHODIMP nsHTMLTextFieldAccessible::DoAction(PRUint8 index)
|
|||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
void nsHTMLTextFieldAccessible::SetEditor(nsIEditor* aEditor)
|
||||
{
|
||||
mEditor = aEditor;
|
||||
}
|
||||
|
||||
void nsHTMLTextFieldAccessible::CheckForEditor()
|
||||
NS_IMETHODIMP nsHTMLTextFieldAccessible::GetAssociatedEditor(nsIEditor **aEditor)
|
||||
{
|
||||
*aEditor = nsnull;
|
||||
nsCOMPtr<nsIDOMNSEditableElement> editableElt(do_QueryInterface(mDOMNode));
|
||||
if (!editableElt) {
|
||||
return;
|
||||
}
|
||||
NS_ENSURE_TRUE(editableElt, NS_ERROR_FAILURE);
|
||||
|
||||
// nsGenericHTMLElement::GetEditor has a security check.
|
||||
// Make sure we're not restricted by the permissions of
|
||||
|
@ -562,16 +542,15 @@ void nsHTMLTextFieldAccessible::CheckForEditor()
|
|||
PRBool pushed = stack && NS_SUCCEEDED(stack->Push(nsnull));
|
||||
|
||||
nsCOMPtr<nsIEditor> editor;
|
||||
nsresult rv = editableElt->GetEditor(getter_AddRefs(editor));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
SetEditor(editor);
|
||||
}
|
||||
nsresult rv = editableElt->GetEditor(aEditor);
|
||||
|
||||
if (pushed) {
|
||||
JSContext* cx;
|
||||
stack->Pop(&cx);
|
||||
NS_ASSERTION(!cx, "context should be null");
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
// --- groupbox -----
|
||||
|
|
|
@ -102,12 +102,8 @@ class nsHTMLTextFieldAccessible : public nsHyperTextAccessibleWrap
|
|||
public:
|
||||
enum { eAction_Click = 0 };
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
nsHTMLTextFieldAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
|
||||
NS_IMETHOD Init();
|
||||
NS_IMETHOD Shutdown();
|
||||
NS_IMETHOD GetRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetName(nsAString& aName);
|
||||
NS_IMETHOD GetValue(nsAString& _retval);
|
||||
|
@ -116,12 +112,8 @@ public:
|
|||
NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName);
|
||||
NS_IMETHOD DoAction(PRUint8 index);
|
||||
|
||||
protected:
|
||||
// Editor helpers, subclasses of nsHyperTextAccessible may have editor
|
||||
virtual void SetEditor(nsIEditor *aEditor);
|
||||
virtual already_AddRefed<nsIEditor> GetEditor() { nsIEditor *editor = mEditor; NS_IF_ADDREF(editor); return editor; }
|
||||
void CheckForEditor();
|
||||
nsCOMPtr<nsIEditor> mEditor;
|
||||
// nsIAccessibleEditableText
|
||||
NS_IMETHOD GetAssociatedEditor(nsIEditor **aEditor);
|
||||
};
|
||||
|
||||
class nsHTMLGroupboxAccessible : public nsHyperTextAccessibleWrap
|
||||
|
|
|
@ -47,12 +47,16 @@
|
|||
#include "nsIDOMAbstractView.h"
|
||||
#include "nsIDOMCharacterData.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsIDOMDocumentView.h"
|
||||
#include "nsIDOMRange.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsIDOMXULDocument.h"
|
||||
#include "nsIEditingSession.h"
|
||||
#include "nsIEditor.h"
|
||||
#include "nsIFontMetrics.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsIPlaintextEditor.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsTextFragment.h"
|
||||
|
@ -64,8 +68,8 @@ static NS_DEFINE_IID(kRangeCID, NS_RANGE_CID);
|
|||
// nsHyperTextAccessible
|
||||
// ------------
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsHyperTextAccessible, nsAccessible)
|
||||
NS_IMPL_RELEASE_INHERITED(nsHyperTextAccessible, nsAccessible)
|
||||
NS_IMPL_ADDREF_INHERITED(nsHyperTextAccessible, nsAccessibleWrap)
|
||||
NS_IMPL_RELEASE_INHERITED(nsHyperTextAccessible, nsAccessibleWrap)
|
||||
|
||||
nsresult nsHyperTextAccessible::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
|
@ -169,7 +173,8 @@ nsHyperTextAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState)
|
|||
if (!aExtraState)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIEditor> editor = GetEditor();
|
||||
nsCOMPtr<nsIEditor> editor;
|
||||
GetAssociatedEditor(getter_AddRefs(editor));
|
||||
if (editor) {
|
||||
PRUint32 flags;
|
||||
editor->GetFlags(&flags);
|
||||
|
@ -195,8 +200,16 @@ void nsHyperTextAccessible::CacheChildren()
|
|||
return;
|
||||
}
|
||||
|
||||
// Special case for text entry fields, go directly to editor's root for children
|
||||
if (mAccChildCount == eChildCountUninitialized) {
|
||||
nsCOMPtr<nsIEditor> editor = GetEditor();
|
||||
PRUint32 role;
|
||||
GetRole(&role);
|
||||
if (role != nsIAccessibleRole::ROLE_ENTRY && role != nsIAccessibleRole::ROLE_PASSWORD_TEXT) {
|
||||
nsAccessible::CacheChildren();
|
||||
return;
|
||||
}
|
||||
nsCOMPtr<nsIEditor> editor;
|
||||
GetAssociatedEditor(getter_AddRefs(editor));
|
||||
if (!editor) {
|
||||
nsAccessible::CacheChildren();
|
||||
return;
|
||||
|
@ -1152,7 +1165,8 @@ NS_IMETHODIMP nsHyperTextAccessible::SetTextContents(const nsAString &aText)
|
|||
NS_IMETHODIMP nsHyperTextAccessible::InsertText(const nsAString &aText, PRInt32 aPosition)
|
||||
{
|
||||
if (NS_SUCCEEDED(SetCaretOffset(aPosition))) {
|
||||
nsCOMPtr<nsIEditor> editor = GetEditor();
|
||||
nsCOMPtr<nsIEditor> editor;
|
||||
GetAssociatedEditor(getter_AddRefs(editor));
|
||||
nsCOMPtr<nsIPlaintextEditor> peditor(do_QueryInterface(editor));
|
||||
return peditor ? peditor->InsertText(aText) : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -1162,7 +1176,8 @@ NS_IMETHODIMP nsHyperTextAccessible::InsertText(const nsAString &aText, PRInt32
|
|||
|
||||
NS_IMETHODIMP nsHyperTextAccessible::CopyText(PRInt32 aStartPos, PRInt32 aEndPos)
|
||||
{
|
||||
nsCOMPtr<nsIEditor> editor = GetEditor();
|
||||
nsCOMPtr<nsIEditor> editor;
|
||||
GetAssociatedEditor(getter_AddRefs(editor));
|
||||
if (editor && NS_SUCCEEDED(SetSelectionRange(aStartPos, aEndPos)))
|
||||
return editor->Copy();
|
||||
|
||||
|
@ -1171,7 +1186,8 @@ NS_IMETHODIMP nsHyperTextAccessible::CopyText(PRInt32 aStartPos, PRInt32 aEndPos
|
|||
|
||||
NS_IMETHODIMP nsHyperTextAccessible::CutText(PRInt32 aStartPos, PRInt32 aEndPos)
|
||||
{
|
||||
nsCOMPtr<nsIEditor> editor = GetEditor();
|
||||
nsCOMPtr<nsIEditor> editor;
|
||||
GetAssociatedEditor(getter_AddRefs(editor));
|
||||
if (editor && NS_SUCCEEDED(SetSelectionRange(aStartPos, aEndPos)))
|
||||
return editor->Cut();
|
||||
|
||||
|
@ -1180,7 +1196,8 @@ NS_IMETHODIMP nsHyperTextAccessible::CutText(PRInt32 aStartPos, PRInt32 aEndPos)
|
|||
|
||||
NS_IMETHODIMP nsHyperTextAccessible::DeleteText(PRInt32 aStartPos, PRInt32 aEndPos)
|
||||
{
|
||||
nsCOMPtr<nsIEditor> editor = GetEditor();
|
||||
nsCOMPtr<nsIEditor> editor;
|
||||
GetAssociatedEditor(getter_AddRefs(editor));
|
||||
if (editor && NS_SUCCEEDED(SetSelectionRange(aStartPos, aEndPos)))
|
||||
return editor->DeleteSelection(nsIEditor::eNone);
|
||||
|
||||
|
@ -1189,7 +1206,8 @@ NS_IMETHODIMP nsHyperTextAccessible::DeleteText(PRInt32 aStartPos, PRInt32 aEndP
|
|||
|
||||
NS_IMETHODIMP nsHyperTextAccessible::PasteText(PRInt32 aPosition)
|
||||
{
|
||||
nsCOMPtr<nsIEditor> editor = GetEditor();
|
||||
nsCOMPtr<nsIEditor> editor;
|
||||
GetAssociatedEditor(getter_AddRefs(editor));
|
||||
if (editor && NS_SUCCEEDED(SetCaretOffset(aPosition)))
|
||||
return editor->Paste(nsIClipboard::kGlobalClipboard);
|
||||
|
||||
|
@ -1201,10 +1219,27 @@ nsHyperTextAccessible::GetAssociatedEditor(nsIEditor **aEditor)
|
|||
{
|
||||
NS_ENSURE_ARG_POINTER(aEditor);
|
||||
|
||||
nsCOMPtr<nsIEditor> editor(GetEditor());
|
||||
NS_IF_ADDREF(*aEditor = editor);
|
||||
*aEditor = nsnull;
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(mDOMNode);
|
||||
NS_ENSURE_TRUE(content, NS_ERROR_FAILURE);
|
||||
|
||||
return NS_OK;
|
||||
if (!content->HasFlag(NODE_IS_EDITABLE)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeItem> docShellTreeItem = GetDocShellTreeItemFor(mDOMNode);
|
||||
nsCOMPtr<nsIEditingSession> editingSession(do_GetInterface(docShellTreeItem));
|
||||
if (!editingSession)
|
||||
return NS_OK; // No editing session interface
|
||||
|
||||
nsCOMPtr<nsIPresShell> shell = GetPresShell();
|
||||
NS_ENSURE_TRUE(shell, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIDocument> doc = shell->GetDocument();
|
||||
NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIEditor> editor;
|
||||
return editingSession->GetEditorForWindow(doc->GetWindow(), aEditor);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1276,7 +1311,8 @@ nsresult nsHyperTextAccessible::GetSelections(nsISelectionController **aSelCon,
|
|||
*aDomSel = nsnull;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIEditor> editor = GetEditor();
|
||||
nsCOMPtr<nsIEditor> editor;
|
||||
GetAssociatedEditor(getter_AddRefs(editor));
|
||||
if (editor) {
|
||||
if (aSelCon) {
|
||||
editor->GetSelectionController(aSelCon);
|
||||
|
|
|
@ -45,7 +45,6 @@
|
|||
#include "nsIAccessibleHyperText.h"
|
||||
#include "nsIAccessibleEditableText.h"
|
||||
#include "nsAccessibleEventData.h"
|
||||
#include "nsIEditor.h"
|
||||
#include "nsFrameSelection.h"
|
||||
#include "nsISelectionController.h"
|
||||
|
||||
|
@ -157,10 +156,6 @@ protected:
|
|||
|
||||
nsIntRect GetBoundsForString(nsIFrame *aFrame, PRUint32 aStartRenderedOffset, PRUint32 aEndRenderedOffset);
|
||||
|
||||
// Editor helpers, subclasses of nsHyperTextAccessible may have editor
|
||||
virtual void SetEditor(nsIEditor *aEditor) { return; }
|
||||
virtual already_AddRefed<nsIEditor> GetEditor() { return nsnull; }
|
||||
|
||||
// Selection helpers
|
||||
nsresult GetSelections(nsISelectionController **aSelCon, nsISelection **aDomSel);
|
||||
nsresult SetSelectionRange(PRInt32 aStartPos, PRInt32 aEndPos);
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIEditor.h"
|
||||
#include "nsIMutableArray.h"
|
||||
#include "nsIXFormsUtilityService.h"
|
||||
#include "nsIPlaintextEditor.h"
|
||||
|
@ -309,7 +310,7 @@ nsXFormsEditableAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState)
|
|||
nsresult rv = nsXFormsAccessible::GetState(aState, aExtraState);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!aExtraState || !mEditor)
|
||||
if (!aExtraState)
|
||||
return NS_OK;
|
||||
|
||||
PRBool isReadonly = PR_FALSE;
|
||||
|
@ -326,8 +327,11 @@ nsXFormsEditableAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState)
|
|||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIEditor> editor;
|
||||
GetAssociatedEditor(getter_AddRefs(editor));
|
||||
NS_ENSURE_TRUE(editor, NS_ERROR_FAILURE);
|
||||
PRUint32 flags;
|
||||
mEditor->GetFlags(&flags);
|
||||
editor->GetFlags(&flags);
|
||||
if (flags & nsIPlaintextEditor::eEditorSingleLineMask)
|
||||
*aExtraState |= nsIAccessibleStates::EXT_STATE_SINGLE_LINE;
|
||||
else
|
||||
|
@ -337,34 +341,9 @@ nsXFormsEditableAccessible::GetState(PRUint32 *aState, PRUint32 *aExtraState)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXFormsEditableAccessible::Init()
|
||||
nsXFormsEditableAccessible::GetAssociatedEditor(nsIEditor **aEditor)
|
||||
{
|
||||
nsCOMPtr<nsIEditor> editor;
|
||||
sXFormsService->GetEditor(mDOMNode, getter_AddRefs(editor));
|
||||
SetEditor(editor);
|
||||
|
||||
return nsXFormsAccessible::Init();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXFormsEditableAccessible::Shutdown()
|
||||
{
|
||||
SetEditor(nsnull);
|
||||
return nsXFormsAccessible::Shutdown();
|
||||
}
|
||||
|
||||
already_AddRefed<nsIEditor>
|
||||
nsXFormsEditableAccessible::GetEditor()
|
||||
{
|
||||
nsIEditor *editor = mEditor;
|
||||
NS_IF_ADDREF(editor);
|
||||
return editor;
|
||||
}
|
||||
|
||||
void
|
||||
nsXFormsEditableAccessible::SetEditor(nsIEditor *aEditor)
|
||||
{
|
||||
mEditor = aEditor;
|
||||
return sXFormsService->GetEditor(mDOMNode, aEditor);
|
||||
}
|
||||
|
||||
// nsXFormsSelectableAccessible
|
||||
|
|
|
@ -147,15 +147,8 @@ public:
|
|||
|
||||
NS_IMETHOD GetState(PRUint32 *aState, PRUint32 *aExtraState);
|
||||
|
||||
NS_IMETHOD Init();
|
||||
NS_IMETHOD Shutdown();
|
||||
|
||||
protected:
|
||||
virtual void SetEditor(nsIEditor *aEditor);
|
||||
virtual already_AddRefed<nsIEditor> GetEditor();
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIEditor> mEditor;
|
||||
// nsIAccessibleEditableText
|
||||
NS_IMETHOD GetAssociatedEditor(nsIEditor **aEditor);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
#include "nsIDOMXULMenuListElement.h"
|
||||
#include "nsIDOMXULSelectCntrlItemEl.h"
|
||||
#include "nsIDOMXULTextboxElement.h"
|
||||
#include "nsIEditor.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsITextControlFrame.h"
|
||||
|
@ -763,21 +764,6 @@ nsXULTextFieldAccessible::nsXULTextFieldAccessible(nsIDOMNode* aNode, nsIWeakRef
|
|||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED1(nsXULTextFieldAccessible, nsHyperTextAccessible,
|
||||
nsIAccessibleText)
|
||||
|
||||
NS_IMETHODIMP nsXULTextFieldAccessible::Init()
|
||||
{
|
||||
CheckForEditor();
|
||||
return nsHyperTextAccessibleWrap::Init();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULTextFieldAccessible::Shutdown()
|
||||
{
|
||||
mEditor = nsnull;
|
||||
return nsHyperTextAccessibleWrap::Shutdown();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULTextFieldAccessible::GetValue(nsAString& aValue)
|
||||
{
|
||||
PRUint32 state;
|
||||
|
@ -935,22 +921,11 @@ nsXULTextFieldAccessible::GetAllowsAnonChildAccessibles(PRBool *aAllowsAnonChild
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsXULTextFieldAccessible::SetEditor(nsIEditor* aEditor)
|
||||
{
|
||||
mEditor = aEditor;
|
||||
}
|
||||
|
||||
void nsXULTextFieldAccessible::CheckForEditor()
|
||||
NS_IMETHODIMP nsXULTextFieldAccessible::GetAssociatedEditor(nsIEditor **aEditor)
|
||||
{
|
||||
*aEditor = nsnull;
|
||||
nsCOMPtr<nsIDOMNode> inputField = GetInputField();
|
||||
nsCOMPtr<nsIDOMNSEditableElement> editableElt(do_QueryInterface(inputField));
|
||||
if (!editableElt) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIEditor> editor;
|
||||
nsresult rv = editableElt->GetEditor(getter_AddRefs(editor));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
SetEditor(editor);
|
||||
}
|
||||
NS_ENSURE_TRUE(editableElt, NS_ERROR_FAILURE);
|
||||
return editableElt->GetEditor(aEditor);
|
||||
}
|
||||
|
|
|
@ -161,12 +161,8 @@ class nsXULTextFieldAccessible : public nsHyperTextAccessibleWrap
|
|||
public:
|
||||
enum { eAction_Click = 0 };
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
nsXULTextFieldAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
|
||||
NS_IMETHOD Init();
|
||||
NS_IMETHOD Shutdown();
|
||||
NS_IMETHOD GetValue(nsAString& aValue);
|
||||
NS_IMETHOD GetState(PRUint32 *aState, PRUint32 *aExtraState);
|
||||
NS_IMETHOD GetRole(PRUint32 *aRole);
|
||||
|
@ -175,14 +171,11 @@ public:
|
|||
NS_IMETHOD DoAction(PRUint8 index);
|
||||
NS_IMETHOD GetAllowsAnonChildAccessibles(PRBool *aAllowsAnonChildren);
|
||||
|
||||
// nsIAccessibleEditableText
|
||||
NS_IMETHOD GetAssociatedEditor(nsIEditor **aEditor);
|
||||
|
||||
protected:
|
||||
already_AddRefed<nsIDOMNode> GetInputField();
|
||||
|
||||
// Editor helpers, subclasses of nsHyperTextAccessible may have editor
|
||||
virtual void SetEditor(nsIEditor *aEditor);
|
||||
virtual already_AddRefed<nsIEditor> GetEditor() { nsIEditor *editor = mEditor; NS_IF_ADDREF(editor); return editor; }
|
||||
void CheckForEditor();
|
||||
nsCOMPtr<nsIEditor> mEditor;
|
||||
};
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче