зеркало из https://github.com/mozilla/pjs.git
Bug 153196. Active Accessibility: support MSAA caret object and events. r=kyle, sr=kin
This commit is contained in:
Родитель
6f99cd621e
Коммит
e634b069e0
|
@ -1154,6 +1154,13 @@
|
|||
<FILEKIND>Text</FILEKIND>
|
||||
<FILEFLAGS></FILEFLAGS>
|
||||
</FILE>
|
||||
<FILE>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsCaretAccessible.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
<FILEKIND>Text</FILEKIND>
|
||||
<FILEFLAGS></FILEFLAGS>
|
||||
</FILE>
|
||||
<FILE>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsSelectAccessible.cpp</PATH>
|
||||
|
@ -1301,6 +1308,11 @@
|
|||
<PATH>nsRootAccessible.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsCaretAccessible.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsSelectAccessible.cpp</PATH>
|
||||
|
@ -2429,6 +2441,13 @@
|
|||
<FILEKIND>Text</FILEKIND>
|
||||
<FILEFLAGS></FILEFLAGS>
|
||||
</FILE>
|
||||
<FILE>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsCaretAccessible.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
<FILEKIND>Text</FILEKIND>
|
||||
<FILEFLAGS></FILEFLAGS>
|
||||
</FILE>
|
||||
<FILE>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsSelectAccessible.cpp</PATH>
|
||||
|
@ -2576,6 +2595,11 @@
|
|||
<PATH>nsRootAccessible.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsCaretAccessible.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsSelectAccessible.cpp</PATH>
|
||||
|
@ -2701,6 +2725,12 @@
|
|||
<PATH>nsRootAccessible.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<TARGETNAME>accessible.shlb</TARGETNAME>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsCaretAccessible.cpp</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<TARGETNAME>accessible.shlb</TARGETNAME>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -33,6 +33,7 @@ XPIDLSRCS = \
|
|||
nsIAccessibilityService.idl \
|
||||
nsIAccessible.idl \
|
||||
nsIAccessibleAction.idl \
|
||||
nsIAccessibleCaret.idl \
|
||||
nsIAccessibleDocument.idl \
|
||||
nsIAccessibleEditableText.idl \
|
||||
nsIAccessibleEventReceiver.idl \
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape 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/NPL/
|
||||
#
|
||||
# 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 Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH=..\..
|
||||
MODULE=accessibility
|
||||
XPIDL_MODULE=accessibility
|
||||
|
||||
XPIDLSRCS = \
|
||||
.\nsIAccessibilityService.idl \
|
||||
.\nsIAccessible.idl \
|
||||
.\nsIAccessibleAction.idl \
|
||||
.\nsIAccessibleDocument.idl \
|
||||
.\nsIAccessibleEditableText.idl \
|
||||
.\nsIAccessibleEventReceiver.idl \
|
||||
.\nsIAccessibleEventListener.idl \
|
||||
.\nsIAccessibleHyperLink.idl \
|
||||
.\nsIAccessibleHyperText.idl \
|
||||
.\nsIAccessibleProvider.idl \
|
||||
.\nsIAccessibleSelectable.idl \
|
||||
.\nsIAccessibleTable.idl \
|
||||
.\nsIAccessibleText.idl \
|
||||
.\nsIAccessibleValue.idl \
|
||||
.\nsIAccessibleWin32Object.idl \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
|
@ -27,8 +27,10 @@
|
|||
#include "nsIAtom.idl"
|
||||
#include "domstubs.idl"
|
||||
#include "nsIAccessible.idl"
|
||||
#include "nsIAccessibleCaret.idl"
|
||||
|
||||
interface nsIWeakReference;
|
||||
interface nsIAccessibleEventListener;
|
||||
|
||||
[scriptable, uuid(68D9720A-0984-42b6-A3F5-8237ED925727)]
|
||||
interface nsIAccessibilityService : nsISupports
|
||||
|
@ -36,6 +38,7 @@ interface nsIAccessibilityService : nsISupports
|
|||
nsIAccessible createAccessible(in nsIDOMNode aNode, in nsISupports aDocument);
|
||||
nsIAccessible createIFrameAccessible(in nsIDOMNode aNode);
|
||||
nsIAccessible createRootAccessible(in nsISupports aPresContext, in nsISupports aFrame);
|
||||
nsIAccessibleCaret createCaretAccessible(in nsIDOMNode aNode, in nsIAccessibleEventListener aListener);
|
||||
|
||||
nsIAccessible createHTML4ButtonAccessible(in nsISupports aFrame);
|
||||
nsIAccessible createHTMLAreaAccessible(in nsIWeakReference aPresShell, in nsIDOMNode aDOMNode, in nsIAccessible aAccParent);
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
/* -*- 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: Aaron Leventhal (aaronl@netscape.com)
|
||||
*
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIAccessible.idl"
|
||||
|
||||
[scriptable, uuid(9124c666-6133-4be6-b3ed-dd0ec35f1e64)]
|
||||
interface nsIAccessibleCaret : nsISupports
|
||||
{
|
||||
void attachNewSelectionListener(in nsIDOMNode aFocusedNode);
|
||||
void removeSelectionListener();
|
||||
};
|
|
@ -26,6 +26,7 @@
|
|||
#include "nsISupports.idl"
|
||||
#include "nsIAccessible.idl"
|
||||
#include "domstubs.idl"
|
||||
#include "nsIAccessibleCaret.idl"
|
||||
interface nsIDocument;
|
||||
|
||||
[scriptable, uuid(8781FC88-355F-4439-881F-6504A0A1CEB6)]
|
||||
|
@ -37,5 +38,5 @@ interface nsIAccessibleDocument : nsISupports
|
|||
readonly attribute AString docType;
|
||||
AString getNameSpaceURIForID(in short nameSpaceID);
|
||||
[noscript] nsIDocument getDocument();
|
||||
|
||||
readonly attribute nsIAccessibleCaret caretAccessible;
|
||||
};
|
||||
|
|
|
@ -38,19 +38,45 @@ struct AccessibleEventData {
|
|||
interface nsIAccessibleEventListener : nsISupports
|
||||
{
|
||||
// these are set to the values given by MSAA
|
||||
const unsigned long EVENT_CREATE = 0x8000;
|
||||
const unsigned long EVENT_DESTROY = 0x8001;
|
||||
const unsigned long EVENT_SHOW = 0x8002;
|
||||
const unsigned long EVENT_HIDE = 0x8003;
|
||||
const unsigned long EVENT_REORDER = 0x8004;
|
||||
const unsigned long EVENT_FOCUS = 0x8005;
|
||||
const unsigned long EVENT_STATE_CHANGE = 0x800A;
|
||||
const unsigned long EVENT_LOCATION_CHANGE = 0x800B;
|
||||
const unsigned long EVENT_NAME_CHANGE = 0x800C;
|
||||
const unsigned long EVENT_DESCRIPTIONCHANGE = 0x800D;
|
||||
const unsigned long EVENT_VALUE_CHANGE = 0x800E;
|
||||
const unsigned long EVENT_PARENTCHANGE = 0x800F;
|
||||
const unsigned long EVENT_HELPCHANGE = 0x8010;
|
||||
const unsigned long EVENT_DEFACTIONCHANGE = 0x8011;
|
||||
const unsigned long EVENT_ACCELERATORCHANGE = 0x8012;
|
||||
const unsigned long EVENT_SELECTION = 0x8006;
|
||||
const unsigned long EVENT_SELECTION_ADD = 0x8007;
|
||||
const unsigned long EVENT_SELECTION_REMOVE = 0x8008;
|
||||
const unsigned long EVENT_SELECTION_WITHIN = 0x8009;
|
||||
const unsigned long EVENT_ALERT = 0x0002;
|
||||
const unsigned long EVENT_FOREGROUND = 0x0003;
|
||||
const unsigned long EVENT_MENUSTART = 0x0004;
|
||||
const unsigned long EVENT_MENUEND = 0x0005;
|
||||
const unsigned long EVENT_MENUPOPUPSTART = 0x0006;
|
||||
const unsigned long EVENT_MENUPOPUPEND = 0x0007;
|
||||
const unsigned long EVENT_CAPTURESTART = 0x0008;
|
||||
const unsigned long EVENT_CAPTUREEND = 0x0009;
|
||||
const unsigned long EVENT_MOVESIZESTART = 0x000A;
|
||||
const unsigned long EVENT_MOVESIZEEND = 0x000B;
|
||||
const unsigned long EVENT_CONTEXTHELPSTART = 0x000C;
|
||||
const unsigned long EVENT_CONTEXTHELPEND = 0x000D;
|
||||
const unsigned long EVENT_DRAGDROPSTART = 0x000E;
|
||||
const unsigned long EVENT_DRAGDROPEND = 0x000F;
|
||||
const unsigned long EVENT_DIALOGSTART = 0x0010;
|
||||
const unsigned long EVENT_DIALOGEND = 0x0011;
|
||||
const unsigned long EVENT_SCROLLINGSTART = 0x0012;
|
||||
const unsigned long EVENT_SCROLLINGEND = 0x0013;
|
||||
const unsigned long EVENT_MINIMIZESTART = 0x0016;
|
||||
const unsigned long EVENT_MINIMIZEEND = 0x0017;
|
||||
|
||||
// the additional events for ATK
|
||||
const unsigned long EVENT_ATK_PROPERTY_CHANGE = 0x0100;
|
||||
|
|
|
@ -55,6 +55,7 @@ CPPSRCS = \
|
|||
nsFormControlAccessible.cpp \
|
||||
nsGenericAccessible.cpp \
|
||||
nsRootAccessible.cpp \
|
||||
nsCaretAccessible.cpp \
|
||||
nsSelectAccessible.cpp \
|
||||
nsTextAccessible.cpp \
|
||||
$(NULL)
|
||||
|
|
|
@ -50,6 +50,7 @@ CPP_OBJS = \
|
|||
.\$(OBJDIR)\nsFormControlAccessible.obj \
|
||||
.\$(OBJDIR)\nsGenericAccessible.obj \
|
||||
.\$(OBJDIR)\nsRootAccessible.obj \
|
||||
.\$(OBJDIR)\nsCaretAccessible.obj \
|
||||
.\$(OBJDIR)\nsSelectAccessible.obj \
|
||||
.\$(OBJDIR)\nsTextAccessible.obj \
|
||||
$(NULL)
|
||||
|
|
|
@ -85,6 +85,8 @@
|
|||
#include "nsXULTextAccessible.h"
|
||||
#include "nsXULTreeAccessible.h"
|
||||
#include "nsIAccessible.h"
|
||||
#include "nsCaretAccessible.h"
|
||||
#include "nsIAccessibleCaret.h"
|
||||
|
||||
// For native window support for object/embed/applet tags
|
||||
#ifdef XP_WIN
|
||||
|
@ -370,6 +372,21 @@ nsAccessibilityService::CreateRootAccessible(nsISupports* aPresContext, nsISuppo
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAccessibilityService::CreateCaretAccessible(nsIDOMNode *aNode, nsIAccessibleEventListener *aListener,
|
||||
nsIAccessibleCaret **_retval)
|
||||
{
|
||||
nsCOMPtr<nsIWeakReference> weakShell;
|
||||
GetShellFromNode(aNode, getter_AddRefs(weakShell));
|
||||
|
||||
*_retval = new nsCaretAccessible(aNode, weakShell, aListener);
|
||||
if (! *_retval)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* HTML widget creation
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,217 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsCaretAccessible.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsICaret.h"
|
||||
#include "nsISelectionController.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsISelectionPrivate.h"
|
||||
#include "nsIAccessibleEventListener.h"
|
||||
#include "nsIViewManager.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsIPresShell.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED2(nsCaretAccessible, nsLeafAccessible, nsIAccessibleCaret, nsISelectionListener)
|
||||
|
||||
nsCaretAccessible::nsCaretAccessible(nsIDOMNode* aDocumentNode, nsIWeakReference* aShell, nsIAccessibleEventListener *aListener):
|
||||
nsLeafAccessible(aDocumentNode, aShell), mListener(aListener), mVisible(PR_TRUE)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsCaretAccessible::RemoveSelectionListener()
|
||||
{
|
||||
nsCOMPtr<nsISelection> prevDomSel(do_QueryReferent(mDomSelectionWeak));
|
||||
nsCOMPtr<nsISelectionPrivate> selPrivate(do_QueryInterface(prevDomSel));
|
||||
if (selPrivate) {
|
||||
mDomSelectionWeak = nsnull;
|
||||
return selPrivate->RemoveSelectionListener(this);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsCaretAccessible::AttachNewSelectionListener(nsIDOMNode *aCurrentNode)
|
||||
{
|
||||
// When focus moves such that the caret is part of a new frame selection
|
||||
// this removes the old selection listener and attaches a new one for the current focus
|
||||
nsCOMPtr<nsIDOMDocument> domDoc;
|
||||
aCurrentNode->GetOwnerDocument(getter_AddRefs(domDoc));
|
||||
nsCOMPtr<nsIDocument> doc(do_QueryInterface(domDoc));
|
||||
if (!doc) // we also should try to QI to document instead (necessary to do when node is a document)
|
||||
doc = do_QueryInterface(aCurrentNode);
|
||||
if (!doc)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
doc->GetShellAt(0, getter_AddRefs(presShell));
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(aCurrentNode));
|
||||
if (!content)
|
||||
doc->GetRootContent(getter_AddRefs(content)); // If node is not content, use root content
|
||||
if (!presShell || !content)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsIFrame *frame = nsnull;
|
||||
presShell->GetPrimaryFrameFor(content, &frame);
|
||||
nsCOMPtr<nsIPresContext> presContext;
|
||||
presShell->GetPresContext(getter_AddRefs(presContext));
|
||||
if (!frame || !presContext)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsISelectionController> selCon;
|
||||
frame->GetSelectionController(presContext, getter_AddRefs(selCon));
|
||||
if (!selCon)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsISelection> domSel, prevDomSel(do_QueryReferent(mDomSelectionWeak));
|
||||
selCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(domSel));
|
||||
if (domSel == prevDomSel)
|
||||
return NS_OK; // This is already the selection we're listening to
|
||||
RemoveSelectionListener();
|
||||
nsCOMPtr<nsISelectionPrivate> selPrivate(do_QueryInterface(domSel));
|
||||
|
||||
if (!selPrivate)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
mDomSelectionWeak = do_GetWeakReference(domSel);
|
||||
return selPrivate->AddSelectionListener(this);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsCaretAccessible::NotifySelectionChanged(nsIDOMDocument *aDoc, nsISelection *aSel, short aReason)
|
||||
{
|
||||
nsCOMPtr<nsIDocument> doc(do_QueryInterface(aDoc));
|
||||
if (!doc)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
doc->GetShellAt(0, getter_AddRefs(presShell));
|
||||
nsCOMPtr<nsISelection> domSel(do_QueryReferent(mDomSelectionWeak));
|
||||
if (!presShell || domSel != aSel)
|
||||
return NS_OK; // Only listening to selection changes in currently focused frame
|
||||
|
||||
nsCOMPtr<nsICaret> caret;
|
||||
presShell->GetCaret(getter_AddRefs(caret));
|
||||
if (!caret)
|
||||
return NS_OK;
|
||||
|
||||
nsRect caretRect;
|
||||
PRBool isCollapsed;
|
||||
caret->GetCaretCoordinates(nsICaret::eTopLevelWindowCoordinates, domSel, &caretRect, &isCollapsed);
|
||||
PRBool visible = (caretRect.x >= 0 && caretRect.y >= 0 && caretRect.width >= 0 && caretRect.height >= 0);
|
||||
if (visible) // Make sure it's visible both by looking at coordinates and visible flag
|
||||
caret->GetCaretVisible(&visible);
|
||||
if (visible != mVisible) {
|
||||
mVisible = visible;
|
||||
mListener->HandleEvent(mVisible? nsIAccessibleEventListener::EVENT_SHOW: nsIAccessibleEventListener::EVENT_HIDE, this, nsnull);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPresContext> presContext;
|
||||
presShell->GetPresContext(getter_AddRefs(presContext));
|
||||
nsCOMPtr<nsIViewManager> viewManager;
|
||||
presShell->GetViewManager(getter_AddRefs(viewManager));
|
||||
if (!presContext || !viewManager)
|
||||
return NS_OK;
|
||||
nsIView *view = nsnull;
|
||||
viewManager->GetRootView(view);
|
||||
if (!view)
|
||||
return NS_OK;
|
||||
nsCOMPtr<nsIWidget> widget;
|
||||
view->GetWidget(*getter_AddRefs(widget));
|
||||
if (!widget)
|
||||
return NS_OK;
|
||||
|
||||
float t2p;
|
||||
presContext->GetTwipsToPixels(&t2p);
|
||||
// Convert to pixels using that scale
|
||||
caretRect.x = NSTwipsToIntPixels(caretRect.x, t2p);
|
||||
caretRect.y = NSTwipsToIntPixels(caretRect.y, t2p);
|
||||
|
||||
caretRect.width = NSTwipsToIntPixels(caretRect.width, t2p);
|
||||
caretRect.height = NSTwipsToIntPixels(caretRect.height, t2p);
|
||||
|
||||
nsRect caretScreenRect;
|
||||
widget->WidgetToScreen(caretRect, mCaretRect);
|
||||
|
||||
if (visible)
|
||||
mListener->HandleEvent(nsIAccessibleEventListener::EVENT_LOCATION_CHANGE, this, nsnull);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/** Return the caret's bounds */
|
||||
NS_IMETHODIMP nsCaretAccessible::AccGetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height)
|
||||
{
|
||||
if (!mVisible)
|
||||
return NS_ERROR_FAILURE; // When root accessible hasn't yet called SetCaretBounds()
|
||||
*x = mCaretRect.x;
|
||||
*y = mCaretRect.y;
|
||||
*width = mCaretRect.width;
|
||||
*height = mCaretRect.height;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsCaretAccessible::GetAccRole(PRUint32 *_retval)
|
||||
{
|
||||
*_retval = ROLE_CARET;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsCaretAccessible::GetAccState(PRUint32 *_retval)
|
||||
{
|
||||
*_retval = mVisible? 0: STATE_INVISIBLE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsCaretAccessible::GetAccParent(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsCaretAccessible::GetAccPreviousSibling(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsCaretAccessible::GetAccNextSibling(nsIAccessible **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __nsCaretAccessible_h__
|
||||
#define __nsCaretAccessible_h__
|
||||
|
||||
#include "nsAccessible.h"
|
||||
#include "nsBaseWidgetAccessible.h"
|
||||
#include "nsIWeakReference.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIAccessibleCaret.h"
|
||||
#include "nsISelectionListener.h"
|
||||
/*
|
||||
* This special accessibility class is for the caret, which is really the currently focused selection.
|
||||
* There is only 1 visible caret per top level window (nsRootAccessible)
|
||||
* The caret accesible does not exist within the normal accessible tree; it lives in a different world.
|
||||
* In MSAA, it is retrieved with via the WM_GETOBJECT message with lParam = OBJID_CARET,
|
||||
* (as opposed to the root accessible tree for a window which is retrieved with OBJID_CLIENT)
|
||||
* The caret accessible is owned by the nsRootAccessible for the top level window that it's in.
|
||||
*/
|
||||
|
||||
class nsCaretAccessible : public nsLeafAccessible, public nsIAccessibleCaret, public nsISelectionListener
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
nsCaretAccessible(nsIDOMNode* aDocumentNode, nsIWeakReference* aShell, nsIAccessibleEventListener *aListener);
|
||||
|
||||
/* ----- nsIAccessible ----- */
|
||||
NS_IMETHOD GetAccParent(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccState(PRUint32 *_retval);
|
||||
NS_IMETHOD AccGetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height);
|
||||
NS_IMETHOD GetAccNextSibling(nsIAccessible **_retval);
|
||||
NS_IMETHOD GetAccPreviousSibling(nsIAccessible **_retval);
|
||||
|
||||
/* ----- nsIAccessibleCaret ------ */
|
||||
NS_IMETHOD AttachNewSelectionListener(nsIDOMNode *aFocusedNode);
|
||||
NS_IMETHOD RemoveSelectionListener();
|
||||
|
||||
/* ----- nsISelectionListener ---- */
|
||||
NS_IMETHOD NotifySelectionChanged(nsIDOMDocument *aDoc, nsISelection *aSel, short aReason);
|
||||
|
||||
private:
|
||||
nsRect mCaretRect;
|
||||
PRBool mVisible;
|
||||
// mListener is not a com pointer. It's a copy of the listener in the nsRootAccessible owner.
|
||||
//See nsRootAccessible.h for details of the lifetime if this listener
|
||||
nsIAccessibleEventListener *mListener;
|
||||
nsCOMPtr<nsIWeakReference> mDomSelectionWeak;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -63,7 +63,6 @@
|
|||
#include "nsIDOMDocumentType.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsIDOMNSHTMLSelectElement.h"
|
||||
#include "nsIAccessibleSelectable.h"
|
||||
#include "nsLayoutAtoms.h"
|
||||
#include "nsString.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
@ -76,12 +75,16 @@
|
|||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIViewManager.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsIScrollableView.h"
|
||||
#include "nsIDOMXULSelectCntrlEl.h"
|
||||
#include "nsIDOMXULSelectCntrlItemEl.h"
|
||||
#include "nsXULTreeAccessible.h"
|
||||
#include "nsITreeSelection.h"
|
||||
#include "nsAccessibilityService.h"
|
||||
#include "nsISelectionPrivate.h"
|
||||
#include "nsICaret.h"
|
||||
#include "nsIAccessibleCaret.h"
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsRootAccessible)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIAccessibleDocument)
|
||||
|
@ -464,6 +467,9 @@ NS_IMETHODIMP nsRootAccessible::AddAccessibleEventListener(nsIAccessibleEventLis
|
|||
NS_ASSERTION(mWebProgress, "Could not get nsIWebProgress for nsRootAccessible");
|
||||
}
|
||||
|
||||
if (!mCaretAccessible && mListener)
|
||||
mAccService->CreateCaretAccessible(mDOMNode, mListener, getter_AddRefs(mCaretAccessible));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -499,6 +505,17 @@ NS_IMETHODIMP nsRootAccessible::RemoveAccessibleEventListener()
|
|||
mListener = nsnull;
|
||||
}
|
||||
|
||||
if (mCaretAccessible) {
|
||||
mCaretAccessible->RemoveSelectionListener();
|
||||
mCaretAccessible = nsnull;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRootAccessible::GetCaretAccessible(nsIAccessibleCaret **aCaretAccessible)
|
||||
{
|
||||
*aCaretAccessible = mCaretAccessible;
|
||||
NS_IF_ADDREF(*aCaretAccessible);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -509,6 +526,8 @@ void nsRootAccessible::FireAccessibleFocusEvent(nsIAccessible *focusAccessible,
|
|||
NS_IF_RELEASE(gLastFocusedNode);
|
||||
gLastFocusedNode = focusNode;
|
||||
NS_ADDREF(gLastFocusedNode);
|
||||
if (mCaretAccessible)
|
||||
mCaretAccessible->AttachNewSelectionListener(focusNode);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -901,3 +920,10 @@ NS_IMETHODIMP nsDocAccessibleMixin::GetDocShellFromPS(nsIPresShell* aPresShell,
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocAccessibleMixin::GetCaretAccessible(nsIAccessibleCaret **aCaretAccessible)
|
||||
{
|
||||
// Caret only owned by top level window's document
|
||||
*aCaretAccessible = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -167,6 +167,7 @@ class nsRootAccessible : public nsAccessible,
|
|||
PRUint32 mScrollPositionChangedTicks;
|
||||
nsSupportsHashtable *mScrollablePresShells;
|
||||
nsCOMPtr<nsIWeakReference> mLastScrolledPresShell;
|
||||
nsCOMPtr<nsIAccessibleCaret> mCaretAccessible;
|
||||
};
|
||||
|
||||
#ifdef XP_UNIX
|
||||
|
|
|
@ -144,6 +144,13 @@ NS_IMETHODIMP nsHTMLIFrameAccessible::GetDocument(nsIDocument **doc)
|
|||
return nsDocAccessibleMixin::GetDocument(doc);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsHTMLIFrameAccessible::GetCaretAccessible(nsIAccessibleCaret **aCaretAccessible)
|
||||
{
|
||||
// Caret only owned by top level window's document
|
||||
*aCaretAccessible = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//=============================//
|
||||
// nsHTMLIFrameRootAccessible //
|
||||
//=============================//
|
||||
|
|
|
@ -128,3 +128,9 @@ NS_IMETHODIMP nsXULColorPickerAccessible::GetAccState(PRUint32 *_retval)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULColorPickerAccessible::GetAccRole(PRUint32 *_retval)
|
||||
{
|
||||
*_retval = ROLE_BUTTONDROPDOWNGRID;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,6 +58,7 @@ class nsXULColorPickerAccessible : public nsXULColorPickerTileAccessible
|
|||
public:
|
||||
nsXULColorPickerAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell);
|
||||
NS_IMETHOD GetAccState(PRUint32 *_retval);
|
||||
NS_IMETHOD GetAccRole(PRUint32 *_retval);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -372,7 +372,7 @@ NS_IMETHODIMP nsCaret::GetCaretCoordinates(EViewCoordinates aRelativeToType, nsI
|
|||
outCoordinates->x = viewOffset.x;
|
||||
outCoordinates->y = viewOffset.y;
|
||||
outCoordinates->height = frameRect.height;
|
||||
outCoordinates->width = frameRect.width;
|
||||
outCoordinates->width = mCaretTwipsWidth;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -372,7 +372,7 @@ NS_IMETHODIMP nsCaret::GetCaretCoordinates(EViewCoordinates aRelativeToType, nsI
|
|||
outCoordinates->x = viewOffset.x;
|
||||
outCoordinates->y = viewOffset.y;
|
||||
outCoordinates->height = frameRect.height;
|
||||
outCoordinates->width = frameRect.width;
|
||||
outCoordinates->width = mCaretTwipsWidth;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
#include "Accessible.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIAccessibilityService.h"
|
||||
#include "nsIAccessible.h"
|
||||
#include "nsIAccessibleDocument.h"
|
||||
#include "nsIAccessibleEventReceiver.h"
|
||||
|
@ -590,10 +589,6 @@ STDMETHODIMP Accessible::accLocation(
|
|||
PRInt32 x,y,w,h;
|
||||
a->AccGetBounds(&x,&y,&w,&h);
|
||||
|
||||
POINT cpos;
|
||||
cpos.x = x;
|
||||
cpos.y = y;
|
||||
|
||||
*pxLeft = x;
|
||||
*pyTop = y;
|
||||
*pcxWidth = w;
|
||||
|
@ -986,7 +981,16 @@ void RootAccessible::GetNSAccessibleFor(VARIANT varChild, nsCOMPtr<nsIAccessible
|
|||
// asked for corresponds to an event target. See RootAccessible::HandleEvent to see how we provide this unique ID.
|
||||
|
||||
aAcc = nsnull;
|
||||
if (varChild.lVal < 0) {
|
||||
if (varChild.lVal == UNIQUE_ID_CARET) {
|
||||
nsCOMPtr<nsIAccessibleDocument> accDoc(do_QueryInterface(mAccessible));
|
||||
if (accDoc) {
|
||||
nsCOMPtr<nsIAccessibleCaret> accessibleCaret;
|
||||
accDoc->GetCaretAccessible(getter_AddRefs(accessibleCaret));
|
||||
aAcc = do_QueryInterface(accessibleCaret);
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (varChild.lVal < 0) {
|
||||
for (int i=0; i < mListCount; i++) {
|
||||
if (varChild.lVal == mList[i].mId) {
|
||||
aAcc = mList[i].mAccessible;
|
||||
|
@ -1011,12 +1015,18 @@ NS_IMETHODIMP RootAccessible::HandleEvent(PRUint32 aEvent, nsIAccessible* aAcces
|
|||
if (accessibleDoc)
|
||||
return NS_OK;
|
||||
}
|
||||
PRInt32 childID, worldID = OBJID_CLIENT;
|
||||
PRUint32 role;
|
||||
|
||||
// get the id for the accessible
|
||||
PRInt32 id = GetIdFor(aAccessible);
|
||||
if (NS_SUCCEEDED(aAccessible->GetAccRole(&role)) && role == ROLE_SYSTEM_CARET) {
|
||||
childID = CHILDID_SELF;
|
||||
worldID = OBJID_CARET;
|
||||
}
|
||||
else
|
||||
childID = GetIdFor(aAccessible); // get the id for the accessible
|
||||
|
||||
// notify the window system
|
||||
NotifyWinEvent(aEvent, mWnd, OBJID_CLIENT, id);
|
||||
NotifyWinEvent(aEvent, mWnd, worldID, childID);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -241,6 +241,7 @@ public:
|
|||
|
||||
#define MAX_LIST_SIZE 100
|
||||
#define MAX_CHILD_ACCESSIBLES 1000000
|
||||
#define UNIQUE_ID_CARET -1
|
||||
|
||||
class RootAccessible: public DocAccessible, public nsIAccessibleEventListener
|
||||
{
|
||||
|
|
|
@ -4178,11 +4178,28 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
|
|||
LRESULT lAcc = 0;
|
||||
if (mIsTopWidgetWindow && !mRootAccessible)
|
||||
CreateRootAccessible();
|
||||
if (lParam == OBJID_CLIENT && mRootAccessible) // oleacc.dll will be loaded dynamically
|
||||
lAcc = Accessible::LresultFromObject(IID_IAccessible, wParam, mRootAccessible); // ref 1
|
||||
|
||||
if (mRootAccessible) {
|
||||
if (lParam == OBJID_CLIENT) // oleacc.dll will be loaded dynamically
|
||||
lAcc = Accessible::LresultFromObject(IID_IAccessible, wParam, mRootAccessible); // does an addref
|
||||
if (lParam == OBJID_CARET) { // each root accessible owns a caret accessible
|
||||
VARIANT variant;
|
||||
VariantInit(&variant);
|
||||
variant.vt = VT_I4;
|
||||
variant.lVal = UNIQUE_ID_CARET;
|
||||
IDispatch *dispatch = nsnull;
|
||||
mRootAccessible->get_accChild(variant, &dispatch); // does an addref
|
||||
if (dispatch) {
|
||||
IAccessible *accessible = nsnull;
|
||||
dispatch->QueryInterface(IID_IAccessible, (void**)&accessible); // does an addref
|
||||
dispatch->Release();
|
||||
if (accessible) {
|
||||
lAcc = Accessible::LresultFromObject(IID_IAccessible, wParam, accessible); // does an addref
|
||||
accessible->Release();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return (*aRetValue = lAcc) != 0;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче