Bug 386978 - get rid FireToolkitEvent, r=aaronlev

This commit is contained in:
surkov.alexander@gmail.com 2007-07-05 09:02:55 -07:00
Родитель 444759d663
Коммит 74093dafaa
13 изменённых файлов: 106 добавлений и 108 удалений

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

@ -41,7 +41,7 @@
interface nsIAccessible;
interface nsIAccessibleEvent;
[uuid(e4865da3-f292-4f1a-9c56-dd307f1bdc17)]
[uuid(96518e2e-b142-4b5d-9324-0fa5ba4f8bab)]
interface nsPIAccessible : nsISupports
{
/**
@ -69,18 +69,6 @@ interface nsPIAccessible : nsISupports
*/
void invalidateChildren();
/**
* Fire accessible event.
*
* @param aEvent - DOM event
* @param aTarget - target of DOM event
* @param aData - additional information for accessible event.
*
* XXX: eventually this method will be removed (see bug 377022)
*/
void fireToolkitEvent(in unsigned long aEvent, in nsIAccessible aTarget,
in voidPtr aData);
/**
* Fire accessible event.
*/

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

@ -37,6 +37,10 @@
* ***** END LICENSE BLOCK ***** */
#include "nsAccessibilityUtils.h"
#include "nsPIAccessible.h"
#include "nsAccessibleEventData.h"
#include "nsIDOMXULSelectCntrlEl.h"
#include "nsIDOMXULSelectCntrlItemEl.h"
#include "nsIEventListenerManager.h"
@ -163,3 +167,18 @@ nsAccUtils::HasListener(nsIContent *aContent, const nsAString& aEventType)
return listenerManager && listenerManager->HasListenersFor(aEventType);
}
nsresult
nsAccUtils::FireAccEvent(PRUint32 aEventType, nsIAccessible *aAccessible)
{
NS_ENSURE_ARG(aAccessible);
nsCOMPtr<nsPIAccessible> pAccessible(do_QueryInterface(aAccessible));
NS_ASSERTION(pAccessible, "Accessible doesn't implement nsPIAccessible");
nsCOMPtr<nsIAccessibleEvent> event =
new nsAccEvent(aEventType, aAccessible, nsnull);
NS_ENSURE_TRUE(event, NS_ERROR_OUT_OF_MEMORY);
return pAccessible->FireAccessibleEvent(event);
}

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

@ -40,6 +40,7 @@
#define nsAccessibilityUtils_h_
#include "nsAccessibilityAtoms.h"
#include "nsIAccessible.h"
#include "nsIDOMNode.h"
#include "nsIPersistentProperties2.h"
@ -101,7 +102,16 @@ public:
static void SetAccAttrsForXULSelectControlItem(nsIDOMNode *aNode,
nsIPersistentProperties *aAttributes);
/**
* Return true if the given node has registered event listener of the given
* type.
*/
static PRBool HasListener(nsIContent *aContent, const nsAString& aEventType);
/**
* Fire accessible event of the given type for the given accessible.
*/
static nsresult FireAccEvent(PRUint32 aEventType, nsIAccessible *aAccessible);
};
#endif

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

@ -2007,22 +2007,6 @@ PRBool nsAccessible::IsNodeRelevant(nsIDOMNode *aNode)
return aNode == relevantNode;
}
NS_IMETHODIMP nsAccessible::FireToolkitEvent(PRUint32 aEvent, nsIAccessible *aTarget, void * aData)
{
// Don't fire event for accessible that has been shut down
if (!mWeakShell)
return NS_ERROR_FAILURE;
NS_ENSURE_TRUE(IsNodeRelevant(mDOMNode), NS_ERROR_FAILURE);
nsCOMPtr<nsIAccessibleDocument> docAccessible(GetDocAccessible());
nsCOMPtr<nsPIAccessible> eventHandlingAccessible(do_QueryInterface(docAccessible));
if (eventHandlingAccessible)
return eventHandlingAccessible->FireToolkitEvent(aEvent, aTarget, aData);
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsAccessible::FireAccessibleEvent(nsIAccessibleEvent *aEvent)
{

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

@ -757,8 +757,8 @@ NS_IMETHODIMP nsDocAccessible::FireAnchorJumpEvent()
}
if (mIsAnchorJumped) {
FireToolkitEvent(nsIAccessibleEvent::EVENT_DOCUMENT_ATTRIBUTES_CHANGED,
this, nsnull);
nsAccUtils::
FireAccEvent(nsIAccessibleEvent::EVENT_DOCUMENT_ATTRIBUTES_CHANGED, this);
}
return NS_OK;
@ -816,7 +816,7 @@ NS_IMETHODIMP nsDocAccessible::FireDocLoadEvents(PRUint32 aEventType)
FireAccessibleEvent(accEvent);
}
FireToolkitEvent(aEventType, this, nsnull);
nsAccUtils::FireAccEvent(aEventType, this);
return NS_OK;
}
@ -830,8 +830,8 @@ 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
docAcc->FireToolkitEvent(nsIAccessibleEvent::EVENT_SCROLLING_END, docAcc,
nsnull);
nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_SCROLLING_END, docAcc);
docAcc->mScrollPositionChangedTicks = 0;
if (docAcc->mScrollWatchTimer) {
docAcc->mScrollWatchTimer->Cancel();
@ -1278,8 +1278,8 @@ NS_IMETHODIMP nsDocAccessible::FlushPendingEvents()
PRInt32 selectionCount;
accessibleText->GetSelectionCount(&selectionCount);
if (selectionCount) { // There's a selection so fire selection change as well
FireToolkitEvent(nsIAccessibleEvent::EVENT_TEXT_SELECTION_CHANGED,
accessible, nsnull);
nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_TEXT_SELECTION_CHANGED,
accessible);
}
}
}
@ -1328,8 +1328,8 @@ void nsDocAccessible::RefreshNodes(nsIDOMNode *aStartNode, PRUint32 aChangeEvent
if (!popup) {
// Popup elements already fire these via DOMMenuInactive
// handling in nsRootAccessible::HandleEvent
FireToolkitEvent(nsIAccessibleEvent::EVENT_MENUPOPUP_END,
accessible, nsnull);
nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_MENUPOPUP_END,
accessible);
}
}
}
@ -1428,11 +1428,8 @@ NS_IMETHODIMP nsDocAccessible::InvalidateCacheSubtree(nsIContent *aChild,
aChangeEventType == nsIAccessibleEvent::EVENT_REORDER) {
// Fire EVENT_HIDE if previous accessible existed for node being hidden.
// Fire this before the accessible goes away.
nsCOMPtr<nsPIAccessible> privateChildAccessible =
do_QueryInterface(childAccessible);
if (privateChildAccessible)
privateChildAccessible->FireToolkitEvent(nsIAccessibleEvent::EVENT_HIDE,
childAccessible, nsnull);
if (childAccessible)
nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_HIDE, childAccessible);
}
// Shutdown nsIAccessNode's or nsIAccessibles for any DOM nodes in this subtree
@ -1539,21 +1536,6 @@ nsDocAccessible::GetAccessibleInParentChain(nsIDOMNode *aNode,
return NS_OK;
}
NS_IMETHODIMP
nsDocAccessible::FireToolkitEvent(PRUint32 aEvent, nsIAccessible *aTarget,
void * aData)
{
// Don't fire event for accessible that has been shut down.
if (!mWeakShell)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIAccessibleEvent> accEvent =
new nsAccEvent(aEvent, aTarget, aData);
NS_ENSURE_TRUE(accEvent, NS_ERROR_OUT_OF_MEMORY);
return FireAccessibleEvent(accEvent);
}
void nsDocAccessible::DocLoadCallback(nsITimer *aTimer, void *aClosure)
{
// Doc has finished loading, fire "load finished" event

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

@ -90,9 +90,6 @@ class nsDocAccessible : public nsHyperTextAccessibleWrap,
// nsIDocumentObserver
NS_DECL_NSIDOCUMENTOBSERVER
NS_IMETHOD FireToolkitEvent(PRUint32 aEvent, nsIAccessible* aAccessible,
void* aData);
static void FlushEventsCallback(nsITimer *aTimer, void *aClosure);
// nsIAccessNode

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

@ -483,13 +483,13 @@ PRBool nsRootAccessible::FireAccessibleFocusEvent(nsIAccessible *aAccessible,
PRUint32 naturalRole; // The natural role is the role that this type of element normally has
finalFocusAccessible->GetRole(&naturalRole);
if (role != naturalRole) { // Must be a DHTML menuitem
FireToolkitEvent(nsIAccessibleEvent::EVENT_MENU_START, this, nsnull);
nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_MENU_START, this);
mIsInDHTMLMenu = nsIAccessibleRole::ROLE_MENUITEM;
}
}
}
else if (mIsInDHTMLMenu) {
FireToolkitEvent(nsIAccessibleEvent::EVENT_MENU_END, this, nsnull);
nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_MENU_END, this);
mIsInDHTMLMenu = PR_FALSE;
}
@ -704,12 +704,12 @@ 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 privAcc->FireToolkitEvent(nsIAccessibleEvent::EVENT_SELECTION_WITHIN,
accessible, nsnull);
return nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_SELECTION_WITHIN,
accessible);
}
return privAcc->FireToolkitEvent(nsIAccessibleEvent::EVENT_SELECTION,
treeItemAccessible, nsnull);
return nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_SELECTION,
treeItemAccessible);
}
}
else
@ -747,12 +747,10 @@ nsresult nsRootAccessible::HandleEventWithTarget(nsIDOMEvent* aEvent,
FireAccessibleFocusEvent(accessible, focusedItem, aEvent);
}
else if (eventType.EqualsLiteral("NameChange")) {
privAcc->FireToolkitEvent(nsIAccessibleEvent::EVENT_NAME_CHANGE,
accessible, nsnull);
nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_NAME_CHANGE, accessible);
}
else if (eventType.EqualsLiteral("AlertActive")) {
privAcc->FireToolkitEvent(nsIAccessibleEvent::EVENT_ALERT,
accessible, nsnull);
nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_ALERT, accessible);
}
else if (eventType.EqualsLiteral("popupshown")) {
// Don't fire menupopup events for combobox and autocomplete lists
@ -769,7 +767,7 @@ nsresult nsRootAccessible::HandleEventWithTarget(nsIDOMEvent* aEvent,
event = nsIAccessibleEvent::EVENT_SHOW;
}
if (event) {
privAcc->FireToolkitEvent(event, accessible, nsnull);
nsAccUtils::FireAccEvent(event, accessible);
}
}
@ -796,8 +794,8 @@ nsresult nsRootAccessible::HandleEventWithTarget(nsIDOMEvent* aEvent,
}
else if (eventType.EqualsLiteral("DOMMenuInactive")) {
if (Role(accessible) == nsIAccessibleRole::ROLE_MENUPOPUP) {
privAcc->FireToolkitEvent(nsIAccessibleEvent::EVENT_MENUPOPUP_END,
accessible, nsnull);
nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_MENUPOPUP_END,
accessible);
}
}
else if (eventType.EqualsLiteral("DOMMenuItemActive")) {
@ -828,17 +826,14 @@ nsresult nsRootAccessible::HandleEventWithTarget(nsIDOMEvent* aEvent,
FireAccessibleFocusEvent(accessible, aTargetNode, aEvent, PR_TRUE);
}
else if (eventType.EqualsLiteral("DOMMenuBarActive")) {
privAcc->FireToolkitEvent(nsIAccessibleEvent::EVENT_MENU_START,
accessible, nsnull);
nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_MENU_START, accessible);
}
else if (eventType.EqualsLiteral("DOMMenuBarInactive")) {
privAcc->FireToolkitEvent(nsIAccessibleEvent::EVENT_MENU_END,
accessible, nsnull);
nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_MENU_END, accessible);
FireCurrentFocusEvent();
}
else if (eventType.EqualsLiteral("ValueChange")) {
privAcc->FireToolkitEvent(nsIAccessibleEvent::EVENT_VALUE_CHANGE,
accessible, nsnull);
nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_VALUE_CHANGE, accessible);
}
return NS_OK;
}

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

@ -819,8 +819,9 @@ void nsHTMLSelectOptionAccessible::SelectionChangedIfOption(nsIContent *aPossibl
return;
}
privateMultiSelect->FireToolkitEvent(nsIAccessibleEvent::EVENT_SELECTION_WITHIN,
multiSelect, nsnull);
nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_SELECTION_WITHIN,
multiSelect);
PRUint32 state = State(optionAccessible);
PRUint32 eventType;
if (state & nsIAccessibleStates::STATE_SELECTED) {
@ -828,8 +829,9 @@ void nsHTMLSelectOptionAccessible::SelectionChangedIfOption(nsIContent *aPossibl
}
else {
eventType = nsIAccessibleEvent::EVENT_SELECTION_REMOVE;
}
privateMultiSelect->FireToolkitEvent(eventType, optionAccessible, nsnull);
}
nsAccUtils::FireAccEvent(eventType, optionAccessible);
}
nsIContent* nsHTMLSelectOptionAccessible::GetSelectState(PRUint32* aState,

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

@ -76,7 +76,9 @@ class nsAccessibleWrap : public nsAccessible
virtual nsresult Shutdown ();
virtual nsresult InvalidateChildren ();
NS_IMETHOD FireAccessibleEvent(nsIAccessibleEvent *aEvent);
// we'll flatten buttons and checkboxes. usually they have a text node
// child, that is their title. Works in conjunction with IsPruned() below.
PRBool IsFlat() {

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

@ -154,6 +154,43 @@ nsAccessibleWrap::Shutdown ()
return nsAccessible::Shutdown();
}
nsAccessibleWrap::FireAccessibleEvent(nsIAccessibleEvent *aEvent)
{
NS_ENSURE_ARG_POINTER(aEvent);
nsresult rv = nsAccessible::FireAccessibleEvent(aEvent);
NS_ENSURE_SUCCESS(rv, rv);
PRUint32 eventType;
rv = aEvent->GetEventType(&eventType);
NS_ENSURE_SUCCESS(rv, rv);
// ignore everything but focus-changed and value-changed events for now.
if (eventType != nsIAccessibleEvent::EVENT_FOCUS &&
eventType != nsIAccessibleEvent::EVENT_VALUE_CHANGE)
return NS_OK;
nsCOMPtr<nsIAccessible> accessible;
rv = aEvent->GetAccessible(getter_AddRefs(accessible));
NS_ENSURE_STATE(accessible);
mozAccessible *nativeAcc = nil;
accessible->GetNativeInterface((void**)&nativeAcc);
if (!nativeAcc)
return NS_ERROR_FAILURE;
switch (eventType) {
case nsIAccessibleEvent::EVENT_FOCUS:
[nativeAcc didReceiveFocus];
break;
case nsIAccessibleEvent::EVENT_VALUE_CHANGE:
[nativeAcc valueDidChange];
break;
}
return NS_OK;
}
nsresult
nsAccessibleWrap::InvalidateChildren ()
{

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

@ -41,17 +41,7 @@
#include "nsDocAccessible.h"
struct objc_class;
class nsDocAccessibleWrap: public nsDocAccessible
{
public:
nsDocAccessibleWrap(nsIDOMNode *aNode, nsIWeakReference *aShell);
virtual ~nsDocAccessibleWrap();
NS_IMETHOD FireToolkitEvent(PRUint32 aEvent, nsIAccessible* aAccessible,
void* aData);
};
typedef nsDocAccessible nsDocAccessibleWrap;
#endif

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

@ -194,11 +194,9 @@ NS_IMETHODIMP nsDocAccessibleWrap::FireAnchorJumpEvent()
}
nsCOMPtr<nsIAccessible> accessible = GetFirstAvailableAccessible(focusNode, PR_TRUE);
nsCOMPtr<nsPIAccessible> privateAccessible = do_QueryInterface(accessible);
if (privateAccessible) {
privateAccessible->FireToolkitEvent(nsIAccessibleEvent::EVENT_SCROLLING_START,
accessible, nsnull);
}
nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_SCROLLING_START,
accessible);
return NS_OK;
}

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

@ -45,12 +45,6 @@
#include "nsDocAccessible.h"
class nsDocAccessibleWrap: public nsDocAccessible
{
public:
nsDocAccessibleWrap(nsIDOMNode *aNode, nsIWeakReference *aShell);
virtual ~nsDocAccessibleWrap();
NS_IMETHOD FireToolkitEvent(PRUint32 aEvent, nsIAccessible* aAccessible, void* aData);
};
typedef nsDocAccessible nsDocAccessibleWrap;
#endif