зеркало из https://github.com/mozilla/gecko-dev.git
Bug 540265 - move nsAccUtils::FireEvent into special class, r=davidb
This commit is contained in:
Родитель
4e20e50999
Коммит
c08d0fac1c
|
@ -63,6 +63,7 @@ CPPSRCS = \
|
|||
nsAccessibleRelation.cpp \
|
||||
nsAccessibleTreeWalker.cpp \
|
||||
nsBaseWidgetAccessible.cpp \
|
||||
nsEventShell.cpp \
|
||||
nsFormControlAccessible.cpp \
|
||||
nsRootAccessible.cpp \
|
||||
nsApplicationAccessible.cpp \
|
||||
|
|
|
@ -348,21 +348,6 @@ nsAccUtils::HasDefinedARIAToken(nsIContent *aContent, nsIAtom *aAtom)
|
|||
return PR_TRUE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsAccUtils::FireAccEvent(PRUint32 aEventType, nsIAccessible *aAccessible,
|
||||
PRBool aIsAsynch)
|
||||
{
|
||||
NS_ENSURE_ARG(aAccessible);
|
||||
|
||||
nsRefPtr<nsAccessible> acc(nsAccUtils::QueryAccessible(aAccessible));
|
||||
|
||||
nsCOMPtr<nsIAccessibleEvent> event =
|
||||
new nsAccEvent(aEventType, aAccessible, aIsAsynch);
|
||||
NS_ENSURE_TRUE(event, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
return acc->FireAccessibleEvent(event);
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsAccUtils::HasAccessibleChildren(nsIDOMNode *aNode)
|
||||
{
|
||||
|
|
|
@ -144,12 +144,6 @@ public:
|
|||
*/
|
||||
static PRBool HasDefinedARIAToken(nsIContent *aContent, nsIAtom *aAtom);
|
||||
|
||||
/**
|
||||
* Fire accessible event of the given type for the given accessible.
|
||||
*/
|
||||
static nsresult FireAccEvent(PRUint32 aEventType, nsIAccessible *aAccessible,
|
||||
PRBool aIsAsynch = PR_FALSE);
|
||||
|
||||
/**
|
||||
* Return true if the given DOM node contains accessible children.
|
||||
*/
|
||||
|
|
|
@ -287,8 +287,8 @@ nsAccessibilityService::NotifyOfAnchorJumpTo(nsIContent *aTarget)
|
|||
}
|
||||
|
||||
if (targetAcc)
|
||||
return nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_SCROLLING_START,
|
||||
targetAcc);
|
||||
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_SCROLLING_START,
|
||||
targetAcc);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -297,7 +297,8 @@ NS_IMETHODIMP
|
|||
nsAccessibilityService::FireAccessibleEvent(PRUint32 aEvent,
|
||||
nsIAccessible *aTarget)
|
||||
{
|
||||
return nsAccUtils::FireAccEvent(aEvent, aTarget);
|
||||
nsEventShell::FireEvent(aEvent, aTarget);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsAccessibilityService::StartLoadCallback(nsITimer *aTimer, void *aClosure)
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include "nsAccessNodeWrap.h"
|
||||
|
||||
#include "nsARIAMap.h"
|
||||
#include "nsEventShell.h"
|
||||
#include "nsRelUtils.h"
|
||||
#include "nsTextEquivUtils.h"
|
||||
|
||||
|
|
|
@ -910,7 +910,7 @@ nsDocAccessible::FireDocLoadEvents(PRUint32 aEventType)
|
|||
FireAccessibleEvent(accEvent);
|
||||
}
|
||||
|
||||
nsAccUtils::FireAccEvent(aEventType, this);
|
||||
nsEventShell::FireEvent(aEventType, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -924,7 +924,7 @@ void nsDocAccessible::ScrollTimerCallback(nsITimer *aTimer, void *aClosure)
|
|||
// We only want to fire accessibilty scroll event when scrolling stops or pauses
|
||||
// Therefore, we wait for no scroll events to occur between 2 ticks of this timer
|
||||
// That indicates a pause in scrolling, so we fire the accessibilty scroll event
|
||||
nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_SCROLLING_END, docAcc);
|
||||
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_SCROLLING_END, docAcc);
|
||||
|
||||
docAcc->mScrollPositionChangedTicks = 0;
|
||||
if (docAcc->mScrollWatchTimer) {
|
||||
|
@ -1793,7 +1793,7 @@ nsDocAccessible::FlushPendingEvents()
|
|||
// line-number object attribute on it
|
||||
nsCOMPtr<nsIAccessible> accForFocus;
|
||||
GetAccService()->GetAccessibleFor(gLastFocusedNode, getter_AddRefs(accForFocus));
|
||||
nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_ALERT, accForFocus);
|
||||
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_ALERT, accForFocus);
|
||||
#endif
|
||||
nsCOMPtr<nsIAccessibleEvent> caretMoveEvent =
|
||||
new nsAccCaretMoveEvent(accessible, caretOffset);
|
||||
|
@ -1805,8 +1805,8 @@ nsDocAccessible::FlushPendingEvents()
|
|||
PRInt32 selectionCount;
|
||||
accessibleText->GetSelectionCount(&selectionCount);
|
||||
if (selectionCount) { // There's a selection so fire selection change as well
|
||||
nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_TEXT_SELECTION_CHANGED,
|
||||
accessible, PR_TRUE);
|
||||
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_TEXT_SELECTION_CHANGED,
|
||||
accessible, PR_TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1910,8 +1910,8 @@ void nsDocAccessible::RefreshNodes(nsIDOMNode *aStartNode)
|
|||
if (!popup) {
|
||||
// Popup elements already fire these via DOMMenuInactive
|
||||
// handling in nsRootAccessible::HandleEvent
|
||||
nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_MENUPOPUP_END,
|
||||
accessible);
|
||||
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_MENUPOPUP_END,
|
||||
accessible);
|
||||
}
|
||||
}
|
||||
nsRefPtr<nsAccessible> acc = nsAccUtils::QueryAccessible(accessible);
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
/* -*- 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
|
||||
* Mozilla Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alexander Surkov <surkov.alexander@gmail.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of 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 "nsEventShell.h"
|
||||
|
||||
#include "nsAccessible.h"
|
||||
#include "nsAccEvent.h"
|
||||
|
||||
void
|
||||
nsEventShell::FireEvent(PRUint32 aEventType, nsIAccessible *aAccessible,
|
||||
PRBool aIsAsynch)
|
||||
{
|
||||
NS_ENSURE_TRUE(aAccessible,);
|
||||
|
||||
nsRefPtr<nsAccessible> acc =
|
||||
nsAccUtils::QueryObject<nsAccessible>(aAccessible);
|
||||
|
||||
nsCOMPtr<nsIAccessibleEvent> event =
|
||||
new nsAccEvent(aEventType, aAccessible, aIsAsynch);
|
||||
|
||||
if (event)
|
||||
acc->FireAccessibleEvent(event);
|
||||
}
|
|
@ -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
|
||||
* Mozilla Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Alexander Surkov <surkov.alexander@gmail.com> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of 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 ***** */
|
||||
|
||||
#ifndef _nsEventShell_H_
|
||||
#define _nsEventShell_H_
|
||||
|
||||
#include "nsIAccessible.h"
|
||||
|
||||
class nsEventShell
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Fire accessible event of the given type for the given accessible.
|
||||
*
|
||||
* @param aEventType [in] the event type
|
||||
* @param aAccessible [in] the event target
|
||||
* @param aIsAsync [in, optional] specifies whether the origin change
|
||||
* this event is fired owing to is async.
|
||||
*/
|
||||
static void FireEvent(PRUint32 aEventType, nsIAccessible *aAccessible,
|
||||
PRBool aIsAsynch = PR_FALSE);
|
||||
};
|
||||
|
||||
#endif
|
|
@ -479,8 +479,8 @@ nsRootAccessible::FireAccessibleFocusEvent(nsIAccessible *aAccessible,
|
|||
if (menuBarAccessNode) {
|
||||
menuBarAccessNode->GetDOMNode(getter_AddRefs(mCurrentARIAMenubar));
|
||||
if (mCurrentARIAMenubar) {
|
||||
nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_MENU_START,
|
||||
menuBarAccessible);
|
||||
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_MENU_START,
|
||||
menuBarAccessible);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -751,12 +751,14 @@ nsresult nsRootAccessible::HandleEventWithTarget(nsIDOMEvent* aEvent,
|
|||
// for each tree item. Perhaps each tree item will need to cache its
|
||||
// selection state and fire an event after a DOM "select" event when
|
||||
// that state changes. nsXULTreeAccessible::UpdateTreeSelection();
|
||||
return nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_SELECTION_WITHIN,
|
||||
accessible);
|
||||
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_SELECTION_WITHIN,
|
||||
accessible);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_SELECTION,
|
||||
treeItemAccessible);
|
||||
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_SELECTION,
|
||||
treeItemAccessible);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -807,15 +809,15 @@ nsresult nsRootAccessible::HandleEventWithTarget(nsIDOMEvent* aEvent,
|
|||
FireAccessibleFocusEvent(accessible, focusedItem, aEvent);
|
||||
}
|
||||
else if (eventType.EqualsLiteral("AlertActive")) {
|
||||
nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_ALERT, accessible);
|
||||
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_ALERT, accessible);
|
||||
}
|
||||
else if (eventType.EqualsLiteral("popupshown")) {
|
||||
HandlePopupShownEvent(accessible);
|
||||
}
|
||||
else if (eventType.EqualsLiteral("DOMMenuInactive")) {
|
||||
if (nsAccUtils::Role(accessible) == nsIAccessibleRole::ROLE_MENUPOPUP) {
|
||||
nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_MENUPOPUP_END,
|
||||
accessible);
|
||||
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_MENUPOPUP_END,
|
||||
accessible);
|
||||
}
|
||||
}
|
||||
else if (eventType.EqualsLiteral("DOMMenuItemActive")) {
|
||||
|
@ -881,13 +883,13 @@ nsresult nsRootAccessible::HandleEventWithTarget(nsIDOMEvent* aEvent,
|
|||
}
|
||||
else if (eventType.EqualsLiteral("DOMMenuBarActive")) { // Always asynch, always from user input
|
||||
nsAccEvent::PrepareForEvent(aTargetNode, PR_TRUE);
|
||||
nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_MENU_START,
|
||||
accessible, PR_TRUE);
|
||||
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_MENU_START,
|
||||
accessible, PR_TRUE);
|
||||
}
|
||||
else if (eventType.EqualsLiteral("DOMMenuBarInactive")) { // Always asynch, always from user input
|
||||
nsAccEvent::PrepareForEvent(aTargetNode, PR_TRUE);
|
||||
nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_MENU_END,
|
||||
accessible, PR_TRUE);
|
||||
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_MENU_END,
|
||||
accessible, PR_TRUE);
|
||||
FireCurrentFocusEvent();
|
||||
}
|
||||
else if (eventType.EqualsLiteral("ValueChange")) {
|
||||
|
@ -896,8 +898,8 @@ nsresult nsRootAccessible::HandleEventWithTarget(nsIDOMEvent* aEvent,
|
|||
}
|
||||
#ifdef DEBUG
|
||||
else if (eventType.EqualsLiteral("mouseover")) {
|
||||
nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_DRAGDROP_START,
|
||||
accessible);
|
||||
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_DRAGDROP_START,
|
||||
accessible);
|
||||
}
|
||||
#endif
|
||||
return NS_OK;
|
||||
|
@ -1103,8 +1105,9 @@ nsRootAccessible::HandlePopupShownEvent(nsIAccessible *aAccessible)
|
|||
|
||||
if (role == nsIAccessibleRole::ROLE_MENUPOPUP) {
|
||||
// Don't fire menupopup events for combobox and autocomplete lists.
|
||||
return nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_MENUPOPUP_START,
|
||||
aAccessible);
|
||||
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_MENUPOPUP_START,
|
||||
aAccessible);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (role == nsIAccessibleRole::ROLE_TOOLTIP) {
|
||||
|
@ -1112,8 +1115,8 @@ nsRootAccessible::HandlePopupShownEvent(nsIAccessible *aAccessible)
|
|||
// The accessible for it stays the same no matter where it moves.
|
||||
// AT's expect to get an EVENT_SHOW for the tooltip.
|
||||
// In event callback the tooltip's accessible will be ready.
|
||||
return nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_SHOW,
|
||||
aAccessible);
|
||||
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_SHOW, aAccessible);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (role == nsIAccessibleRole::ROLE_COMBOBOX_LIST) {
|
||||
|
|
|
@ -811,8 +811,8 @@ void nsHTMLSelectOptionAccessible::SelectionChangedIfOption(nsIContent *aPossibl
|
|||
if (!optionAccessible)
|
||||
return;
|
||||
|
||||
nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_SELECTION_WITHIN,
|
||||
multiSelect);
|
||||
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_SELECTION_WITHIN,
|
||||
multiSelect);
|
||||
|
||||
PRUint32 state = nsAccUtils::State(optionAccessible);
|
||||
PRUint32 eventType;
|
||||
|
@ -823,7 +823,7 @@ void nsHTMLSelectOptionAccessible::SelectionChangedIfOption(nsIContent *aPossibl
|
|||
eventType = nsIAccessibleEvent::EVENT_SELECTION_REMOVE;
|
||||
}
|
||||
|
||||
nsAccUtils::FireAccEvent(eventType, optionAccessible);
|
||||
nsEventShell::FireEvent(eventType, optionAccessible);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -1274,7 +1274,7 @@ nsXULTreeItemAccessible::RowInvalidated(PRInt32 aStartColIdx,
|
|||
GetName(name);
|
||||
|
||||
if (name != mCachedName) {
|
||||
nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_NAME_CHANGE, this);
|
||||
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_NAME_CHANGE, this);
|
||||
mCachedName = name;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1266,7 +1266,7 @@ nsXULTreeGridCellAccessible::CellInvalidated()
|
|||
|
||||
mTreeView->GetCellText(mRow, mColumn, textEquiv);
|
||||
if (mCachedTextEquiv != textEquiv) {
|
||||
nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_NAME_CHANGE, this);
|
||||
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_NAME_CHANGE, this);
|
||||
mCachedTextEquiv = textEquiv;
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче