2007-03-22 10:30:00 -07:00
|
|
|
/* -*- 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
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* 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 ***** */
|
|
|
|
|
2011-10-10 22:50:08 -07:00
|
|
|
#include "mozilla/Util.h"
|
|
|
|
|
2011-05-23 09:46:36 -07:00
|
|
|
#define CreateEvent CreateEventA
|
|
|
|
#include "nsIDOMDocument.h"
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsAccessibilityService.h"
|
2009-08-21 05:33:31 -07:00
|
|
|
#include "nsApplicationAccessibleWrap.h"
|
2010-04-26 23:52:03 -07:00
|
|
|
#include "nsAccUtils.h"
|
|
|
|
#include "nsCoreUtils.h"
|
2011-08-09 18:44:00 -07:00
|
|
|
#include "Relation.h"
|
2012-01-11 19:07:35 -08:00
|
|
|
#include "Role.h"
|
2011-08-09 18:44:00 -07:00
|
|
|
#include "States.h"
|
2009-08-21 05:33:31 -07:00
|
|
|
|
2010-06-11 01:23:18 -07:00
|
|
|
#include "mozilla/dom/Element.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsHTMLSelectAccessible.h"
|
2011-08-09 18:44:00 -07:00
|
|
|
#include "nsIAccessibleRelation.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIDocShell.h"
|
|
|
|
#include "nsIDocShellTreeItem.h"
|
|
|
|
#include "nsIDocShellTreeNode.h"
|
|
|
|
#include "nsIDocShellTreeOwner.h"
|
|
|
|
#include "nsIDOMElement.h"
|
|
|
|
#include "nsIDOMEventListener.h"
|
|
|
|
#include "nsIDOMEventTarget.h"
|
|
|
|
#include "nsIDOMHTMLAnchorElement.h"
|
|
|
|
#include "nsIDOMHTMLImageElement.h"
|
|
|
|
#include "nsIDOMHTMLInputElement.h"
|
|
|
|
#include "nsIDOMHTMLSelectElement.h"
|
2007-12-11 00:18:04 -08:00
|
|
|
#include "nsIDOMDataContainerEvent.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIDOMNSEvent.h"
|
|
|
|
#include "nsIDOMXULMultSelectCntrlEl.h"
|
|
|
|
#include "nsIDOMXULPopupElement.h"
|
|
|
|
#include "nsIDocument.h"
|
2011-06-23 19:18:01 -07:00
|
|
|
#include "nsEventListenerManager.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIFrame.h"
|
2007-04-07 11:48:29 -07:00
|
|
|
#include "nsIHTMLDocument.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIInterfaceRequestorUtils.h"
|
|
|
|
#include "nsISelectionPrivate.h"
|
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsPIDOMWindow.h"
|
|
|
|
#include "nsIWebBrowserChrome.h"
|
|
|
|
#include "nsReadableUtils.h"
|
|
|
|
#include "nsRootAccessible.h"
|
2010-06-23 02:28:09 -07:00
|
|
|
#include "nsIPrivateDOMEvent.h"
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 11:00:39 -07:00
|
|
|
#include "nsFocusManager.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifdef MOZ_XUL
|
|
|
|
#include "nsXULTreeAccessible.h"
|
|
|
|
#include "nsIXULDocument.h"
|
|
|
|
#include "nsIXULWindow.h"
|
|
|
|
#endif
|
|
|
|
|
2011-10-10 22:50:08 -07:00
|
|
|
using namespace mozilla;
|
2011-07-27 05:43:01 -07:00
|
|
|
using namespace mozilla::a11y;
|
2010-04-30 06:12:05 -07:00
|
|
|
|
2009-12-10 11:12:19 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsISupports
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Expanded version of NS_IMPL_ISUPPORTS_INHERITED2
|
|
|
|
// so we can QI directly to concrete nsRootAccessible
|
|
|
|
NS_IMPL_QUERY_HEAD(nsRootAccessible)
|
|
|
|
NS_IMPL_QUERY_BODY(nsIDOMEventListener)
|
|
|
|
if (aIID.Equals(NS_GET_IID(nsRootAccessible)))
|
2007-07-08 00:08:04 -07:00
|
|
|
foundInterface = reinterpret_cast<nsISupports*>(this);
|
2007-03-22 10:30:00 -07:00
|
|
|
else
|
|
|
|
NS_IMPL_QUERY_TAIL_INHERITING(nsDocAccessible)
|
|
|
|
|
|
|
|
NS_IMPL_ADDREF_INHERITED(nsRootAccessible, nsDocAccessible)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(nsRootAccessible, nsDocAccessible)
|
|
|
|
|
2009-12-10 11:12:19 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Constructor/desctructor
|
|
|
|
|
2010-06-11 01:23:18 -07:00
|
|
|
nsRootAccessible::
|
2012-02-09 08:49:17 -08:00
|
|
|
nsRootAccessible(nsIDocument* aDocument, nsIContent* aRootContent,
|
|
|
|
nsIPresShell* aPresShell) :
|
|
|
|
nsDocAccessibleWrap(aDocument, aRootContent, aPresShell)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-03-01 21:16:28 -08:00
|
|
|
mFlags |= eRootAccessible;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsRootAccessible::~nsRootAccessible()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-12-10 11:12:19 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsIAccessible
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/* readonly attribute AString name; */
|
2008-08-24 09:45:56 -07:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsRootAccessible::GetName(nsAString& aName)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2008-08-24 09:45:56 -07:00
|
|
|
aName.Truncate();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!mDocument) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mRoleMapEntry) {
|
|
|
|
nsAccessible::GetName(aName);
|
|
|
|
if (!aName.IsEmpty()) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-28 00:43:53 -07:00
|
|
|
nsCOMPtr<nsIDOMDocument> document = do_QueryInterface(mDocument);
|
2009-08-21 06:20:18 -07:00
|
|
|
return document->GetTitle(aName);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-01-11 19:07:35 -08:00
|
|
|
role
|
2010-09-04 19:14:01 -07:00
|
|
|
nsRootAccessible::NativeRole()
|
|
|
|
{
|
2012-01-11 19:07:35 -08:00
|
|
|
// If it's a <dialog> or <wizard>, use roles::DIALOG instead
|
2010-05-05 11:18:05 -07:00
|
|
|
dom::Element *root = mDocument->GetRootElement();
|
2010-04-30 06:12:05 -07:00
|
|
|
if (root) {
|
|
|
|
nsCOMPtr<nsIDOMElement> rootElement(do_QueryInterface(root));
|
2007-03-22 10:30:00 -07:00
|
|
|
if (rootElement) {
|
|
|
|
nsAutoString name;
|
|
|
|
rootElement->GetLocalName(name);
|
|
|
|
if (name.EqualsLiteral("dialog") || name.EqualsLiteral("wizard")) {
|
2012-01-11 19:07:35 -08:00
|
|
|
return roles::DIALOG; // Always at the root
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-04 19:14:01 -07:00
|
|
|
return nsDocAccessibleWrap::NativeRole();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2009-12-10 11:12:19 -08:00
|
|
|
// nsRootAccessible protected member
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef MOZ_XUL
|
|
|
|
PRUint32 nsRootAccessible::GetChromeFlags()
|
|
|
|
{
|
|
|
|
// Return the flag set for the top level window as defined
|
|
|
|
// by nsIWebBrowserChrome::CHROME_WINDOW_[FLAGNAME]
|
|
|
|
// Not simple: nsIXULWindow is not just a QI from nsIDOMWindow
|
2007-09-05 00:39:09 -07:00
|
|
|
nsCOMPtr<nsIDocShellTreeItem> treeItem =
|
2010-06-11 01:23:18 -07:00
|
|
|
nsCoreUtils::GetDocShellTreeItemFor(mDocument);
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ENSURE_TRUE(treeItem, 0);
|
|
|
|
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
|
|
|
|
treeItem->GetTreeOwner(getter_AddRefs(treeOwner));
|
|
|
|
NS_ENSURE_TRUE(treeOwner, 0);
|
|
|
|
nsCOMPtr<nsIXULWindow> xulWin(do_GetInterface(treeOwner));
|
|
|
|
if (!xulWin) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
PRUint32 chromeFlags;
|
|
|
|
xulWin->GetChromeFlags(&chromeFlags);
|
|
|
|
return chromeFlags;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-04-09 16:38:06 -07:00
|
|
|
PRUint64
|
|
|
|
nsRootAccessible::NativeState()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-04-09 16:38:06 -07:00
|
|
|
PRUint64 states = nsDocAccessibleWrap::NativeState();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifdef MOZ_XUL
|
|
|
|
PRUint32 chromeFlags = GetChromeFlags();
|
2011-04-27 06:42:03 -07:00
|
|
|
if (chromeFlags & nsIWebBrowserChrome::CHROME_WINDOW_RESIZE)
|
2011-04-09 16:38:06 -07:00
|
|
|
states |= states::SIZEABLE;
|
2007-03-22 10:30:00 -07:00
|
|
|
// If it has a titlebar it's movable
|
|
|
|
// XXX unless it's minimized or maximized, but not sure
|
|
|
|
// how to detect that
|
2011-04-27 06:42:03 -07:00
|
|
|
if (chromeFlags & nsIWebBrowserChrome::CHROME_TITLEBAR)
|
2011-04-09 16:38:06 -07:00
|
|
|
states |= states::MOVEABLE;
|
2011-04-27 06:42:03 -07:00
|
|
|
if (chromeFlags & nsIWebBrowserChrome::CHROME_MODAL)
|
|
|
|
states |= states::MODAL;
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
|
2010-05-20 01:00:37 -07:00
|
|
|
nsCOMPtr<nsIFocusManager> fm = do_GetService(FOCUSMANAGER_CONTRACTID);
|
|
|
|
if (fm) {
|
|
|
|
nsCOMPtr<nsIDOMWindow> rootWindow;
|
|
|
|
GetWindow(getter_AddRefs(rootWindow));
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMWindow> activeWindow;
|
|
|
|
fm->GetActiveWindow(getter_AddRefs(activeWindow));
|
|
|
|
if (activeWindow == rootWindow)
|
2011-04-09 16:38:06 -07:00
|
|
|
states |= states::ACTIVE;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2010-05-20 01:00:37 -07:00
|
|
|
|
2011-04-09 16:38:06 -07:00
|
|
|
return states;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
const char* const docEvents[] = {
|
2010-12-02 00:46:59 -08:00
|
|
|
#ifdef DEBUG_DRAGDROPSTART
|
2007-12-10 19:30:02 -08:00
|
|
|
// Capture mouse over events and fire fake DRAGDROPSTART event to simplify
|
|
|
|
// debugging a11y objects with event viewers
|
|
|
|
"mouseover",
|
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
// capture Form change events
|
|
|
|
"select",
|
|
|
|
// capture ValueChange events (fired whenever value changes, immediately after, whether focus moves or not)
|
|
|
|
"ValueChange",
|
|
|
|
// capture AlertActive events (fired whenever alert pops up)
|
|
|
|
"AlertActive",
|
|
|
|
// add ourself as a TreeViewChanged listener (custom event fired in nsTreeBodyFrame.cpp)
|
|
|
|
"TreeViewChanged",
|
2007-12-11 00:18:04 -08:00
|
|
|
"TreeRowCountChanged",
|
2008-02-08 04:55:57 -08:00
|
|
|
"TreeInvalidated",
|
2007-03-22 10:30:00 -07:00
|
|
|
// add ourself as a OpenStateChange listener (custom event fired in tree.xml)
|
|
|
|
"OpenStateChange",
|
|
|
|
// add ourself as a CheckboxStateChange listener (custom event fired in nsHTMLInputElement.cpp)
|
|
|
|
"CheckboxStateChange",
|
|
|
|
// add ourself as a RadioStateChange Listener ( custom event fired in in nsHTMLInputElement.cpp & radio.xml)
|
|
|
|
"RadioStateChange",
|
|
|
|
"popupshown",
|
|
|
|
"popuphiding",
|
|
|
|
"DOMMenuInactive",
|
|
|
|
"DOMMenuItemActive",
|
2011-09-27 18:46:11 -07:00
|
|
|
"DOMMenuItemInactive",
|
2007-03-22 10:30:00 -07:00
|
|
|
"DOMMenuBarActive",
|
2010-06-08 09:39:58 -07:00
|
|
|
"DOMMenuBarInactive"
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
nsresult nsRootAccessible::AddEventListeners()
|
|
|
|
{
|
2011-06-23 19:17:59 -07:00
|
|
|
// nsIDOMEventTarget interface allows to register event listeners to
|
2007-03-22 10:30:00 -07:00
|
|
|
// receive untrusted events (synthetic events generated by untrusted code).
|
|
|
|
// For example, XBL bindings implementations for elements that are hosted in
|
|
|
|
// non chrome document fire untrusted events.
|
2011-06-23 19:17:59 -07:00
|
|
|
nsCOMPtr<nsIDOMEventTarget> nstarget(do_QueryInterface(mDocument));
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
if (nstarget) {
|
|
|
|
for (const char* const* e = docEvents,
|
2011-10-10 22:50:08 -07:00
|
|
|
* const* e_end = ArrayEnd(docEvents);
|
2007-03-22 10:30:00 -07:00
|
|
|
e < e_end; ++e) {
|
|
|
|
nsresult rv = nstarget->AddEventListener(NS_ConvertASCIItoUTF16(*e),
|
2011-10-17 07:59:28 -07:00
|
|
|
this, true, true, 2);
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mCaretAccessible) {
|
2007-06-14 10:12:50 -07:00
|
|
|
mCaretAccessible = new nsCaretAccessible(this);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return nsDocAccessible::AddEventListeners();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult nsRootAccessible::RemoveEventListeners()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDOMEventTarget> target(do_QueryInterface(mDocument));
|
|
|
|
if (target) {
|
|
|
|
for (const char* const* e = docEvents,
|
2011-10-10 22:50:08 -07:00
|
|
|
* const* e_end = ArrayEnd(docEvents);
|
2007-03-22 10:30:00 -07:00
|
|
|
e < e_end; ++e) {
|
2011-10-17 07:59:28 -07:00
|
|
|
nsresult rv = target->RemoveEventListener(NS_ConvertASCIItoUTF16(*e), this, true);
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-27 10:08:50 -08:00
|
|
|
// Do this before removing clearing caret accessible, so that it can use
|
|
|
|
// shutdown the caret accessible's selection listener
|
|
|
|
nsDocAccessible::RemoveEventListeners();
|
|
|
|
|
2007-06-14 10:12:50 -07:00
|
|
|
if (mCaretAccessible) {
|
|
|
|
mCaretAccessible->Shutdown();
|
2007-03-22 10:30:00 -07:00
|
|
|
mCaretAccessible = nsnull;
|
|
|
|
}
|
|
|
|
|
2007-11-27 10:08:50 -08:00
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-03-02 06:41:42 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// public
|
|
|
|
|
2007-06-14 12:19:19 -07:00
|
|
|
nsCaretAccessible*
|
2007-06-14 10:12:50 -07:00
|
|
|
nsRootAccessible::GetCaretAccessible()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2007-06-14 12:19:19 -07:00
|
|
|
return mCaretAccessible;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-03-02 06:41:42 -08:00
|
|
|
void
|
|
|
|
nsRootAccessible::DocumentActivated(nsDocAccessible* aDocument)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-12-10 11:12:19 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsIDOMEventListener
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-06-30 19:18:08 -07:00
|
|
|
NS_IMETHODIMP
|
2011-01-18 00:03:38 -08:00
|
|
|
nsRootAccessible::HandleEvent(nsIDOMEvent* aDOMEvent)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-01-18 00:03:38 -08:00
|
|
|
nsCOMPtr<nsIDOMNSEvent> DOMNSEvent(do_QueryInterface(aDOMEvent));
|
|
|
|
nsCOMPtr<nsIDOMEventTarget> DOMEventTarget;
|
|
|
|
DOMNSEvent->GetOriginalTarget(getter_AddRefs(DOMEventTarget));
|
|
|
|
nsCOMPtr<nsINode> origTargetNode(do_QueryInterface(DOMEventTarget));
|
|
|
|
if (!origTargetNode)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
nsDocAccessible* document =
|
2011-10-18 03:53:36 -07:00
|
|
|
GetAccService()->GetDocAccessible(origTargetNode->OwnerDoc());
|
2011-01-18 00:03:38 -08:00
|
|
|
|
|
|
|
if (document) {
|
|
|
|
#ifdef DEBUG_NOTIFICATIONS
|
|
|
|
if (origTargetNode->IsElement()) {
|
|
|
|
nsIContent* elm = origTargetNode->AsElement();
|
|
|
|
|
|
|
|
nsAutoString tag;
|
|
|
|
elm->Tag()->ToString(tag);
|
|
|
|
|
|
|
|
nsIAtom* atomid = elm->GetID();
|
|
|
|
nsCAutoString id;
|
|
|
|
if (atomid)
|
|
|
|
atomid->ToUTF8String(id);
|
|
|
|
|
|
|
|
nsAutoString eventType;
|
|
|
|
aDOMEvent->GetType(eventType);
|
|
|
|
|
|
|
|
printf("\nPend DOM event processing for %s@id='%s', type: %s\n\n",
|
|
|
|
NS_ConvertUTF16toUTF8(tag).get(), id.get(),
|
|
|
|
NS_ConvertUTF16toUTF8(eventType).get());
|
|
|
|
}
|
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-01-18 00:03:38 -08:00
|
|
|
// Root accessible exists longer than any of its descendant documents so
|
|
|
|
// that we are guaranteed notification is processed before root accessible
|
|
|
|
// is destroyed.
|
|
|
|
document->HandleNotification<nsRootAccessible, nsIDOMEvent>
|
|
|
|
(this, &nsRootAccessible::ProcessDOMEvent, aDOMEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// nsRootAccessible protected
|
|
|
|
void
|
|
|
|
nsRootAccessible::ProcessDOMEvent(nsIDOMEvent* aDOMEvent)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDOMNSEvent> DOMNSEvent(do_QueryInterface(aDOMEvent));
|
|
|
|
nsCOMPtr<nsIDOMEventTarget> DOMEventTarget;
|
|
|
|
DOMNSEvent->GetOriginalTarget(getter_AddRefs(DOMEventTarget));
|
|
|
|
nsCOMPtr<nsINode> origTargetNode(do_QueryInterface(DOMEventTarget));
|
2009-12-10 11:12:19 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsAutoString eventType;
|
2011-01-18 00:03:38 -08:00
|
|
|
aDOMEvent->GetType(eventType);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-01-18 00:03:38 -08:00
|
|
|
if (eventType.EqualsLiteral("popuphiding")) {
|
2011-09-27 18:46:11 -07:00
|
|
|
HandlePopupHidingEvent(origTargetNode);
|
2011-01-18 00:03:38 -08:00
|
|
|
return;
|
|
|
|
}
|
2008-12-03 01:04:02 -08:00
|
|
|
|
2012-02-07 14:38:54 -08:00
|
|
|
nsDocAccessible* targetDocument = GetAccService()->
|
|
|
|
GetDocAccessible(origTargetNode->OwnerDoc());
|
|
|
|
NS_ASSERTION(targetDocument, "No document while accessible is in document?!");
|
|
|
|
|
|
|
|
nsAccessible* accessible =
|
|
|
|
targetDocument->GetAccessibleOrContainer(origTargetNode);
|
2010-05-11 23:47:35 -07:00
|
|
|
if (!accessible)
|
2011-01-18 00:03:38 -08:00
|
|
|
return;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-06-30 19:18:08 -07:00
|
|
|
nsINode* targetNode = accessible->GetNode();
|
2011-02-15 08:33:54 -08:00
|
|
|
|
2008-01-23 15:49:10 -08:00
|
|
|
#ifdef MOZ_XUL
|
2011-11-24 20:32:49 -08:00
|
|
|
nsRefPtr<nsXULTreeAccessible> treeAcc;
|
|
|
|
if (targetNode->IsElement() &&
|
|
|
|
targetNode->AsElement()->NodeInfo()->Equals(nsGkAtoms::tree,
|
|
|
|
kNameSpaceID_XUL)) {
|
|
|
|
treeAcc = do_QueryObject(accessible);
|
2011-12-01 13:35:42 -08:00
|
|
|
if (treeAcc) {
|
|
|
|
if (eventType.EqualsLiteral("TreeViewChanged")) {
|
|
|
|
treeAcc->TreeViewChanged();
|
|
|
|
return;
|
|
|
|
}
|
2011-11-24 20:32:49 -08:00
|
|
|
|
2011-12-01 13:35:42 -08:00
|
|
|
if (eventType.EqualsLiteral("TreeRowCountChanged")) {
|
|
|
|
HandleTreeRowCountChangedEvent(aDOMEvent, treeAcc);
|
|
|
|
return;
|
|
|
|
}
|
2011-12-01 12:43:07 -08:00
|
|
|
|
2011-12-01 13:35:42 -08:00
|
|
|
if (eventType.EqualsLiteral("TreeInvalidated")) {
|
|
|
|
HandleTreeInvalidatedEvent(aDOMEvent, treeAcc);
|
|
|
|
return;
|
|
|
|
}
|
2008-06-15 23:16:18 -07:00
|
|
|
}
|
|
|
|
}
|
2008-01-23 15:49:10 -08:00
|
|
|
#endif
|
2007-12-11 00:18:04 -08:00
|
|
|
|
2007-04-17 05:39:10 -07:00
|
|
|
if (eventType.EqualsLiteral("RadioStateChange")) {
|
2011-04-09 16:38:06 -07:00
|
|
|
PRUint64 state = accessible->State();
|
2007-05-16 01:21:12 -07:00
|
|
|
|
|
|
|
// radiogroup in prefWindow is exposed as a list,
|
|
|
|
// and panebutton is exposed as XULListitem in A11y.
|
2008-11-03 19:37:46 -08:00
|
|
|
// nsXULListitemAccessible::GetStateInternal uses STATE_SELECTED in this case,
|
2011-04-09 16:38:06 -07:00
|
|
|
// so we need to check states::SELECTED also.
|
2011-09-28 23:19:26 -07:00
|
|
|
bool isEnabled = (state & (states::CHECKED | states::SELECTED)) != 0;
|
2007-04-17 05:39:10 -07:00
|
|
|
|
2010-08-24 19:08:28 -07:00
|
|
|
nsRefPtr<AccEvent> accEvent =
|
2011-04-09 16:38:06 -07:00
|
|
|
new AccStateChangeEvent(accessible, states::CHECKED, isEnabled);
|
2010-01-18 08:17:01 -08:00
|
|
|
nsEventShell::FireEvent(accEvent);
|
2007-04-17 05:39:10 -07:00
|
|
|
|
2011-09-27 18:46:11 -07:00
|
|
|
if (isEnabled) {
|
|
|
|
FocusMgr()->ActiveItemChanged(accessible);
|
|
|
|
A11YDEBUG_FOCUS_ACTIVEITEMCHANGE_CAUSE("RadioStateChange", accessible)
|
|
|
|
}
|
2007-04-17 05:39:10 -07:00
|
|
|
|
2011-01-18 00:03:38 -08:00
|
|
|
return;
|
2007-04-17 05:39:10 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (eventType.EqualsLiteral("CheckboxStateChange")) {
|
2011-04-09 16:38:06 -07:00
|
|
|
PRUint64 state = accessible->State();
|
2007-04-17 05:39:10 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool isEnabled = !!(state & states::CHECKED);
|
2007-04-17 05:39:10 -07:00
|
|
|
|
2010-08-24 19:08:28 -07:00
|
|
|
nsRefPtr<AccEvent> accEvent =
|
2011-04-09 16:38:06 -07:00
|
|
|
new AccStateChangeEvent(accessible, states::CHECKED, isEnabled);
|
2007-04-17 05:39:10 -07:00
|
|
|
|
2010-01-18 08:17:01 -08:00
|
|
|
nsEventShell::FireEvent(accEvent);
|
2011-01-18 00:03:38 -08:00
|
|
|
return;
|
2007-04-17 05:39:10 -07:00
|
|
|
}
|
|
|
|
|
2011-11-24 20:32:49 -08:00
|
|
|
nsAccessible* treeItemAcc = nsnull;
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef MOZ_XUL
|
2011-11-24 20:32:49 -08:00
|
|
|
// If it's a tree element, need the currently selected item.
|
|
|
|
if (treeAcc) {
|
|
|
|
treeItemAcc = accessible->CurrentItem();
|
|
|
|
if (treeItemAcc)
|
|
|
|
accessible = treeItemAcc;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-11-24 20:32:49 -08:00
|
|
|
if (treeItemAcc && eventType.EqualsLiteral("OpenStateChange")) {
|
2011-04-09 16:38:06 -07:00
|
|
|
PRUint64 state = accessible->State();
|
2011-09-28 23:19:26 -07:00
|
|
|
bool isEnabled = (state & states::EXPANDED) != 0;
|
2007-04-17 05:39:10 -07:00
|
|
|
|
2010-08-24 19:08:28 -07:00
|
|
|
nsRefPtr<AccEvent> accEvent =
|
2011-04-09 16:38:06 -07:00
|
|
|
new AccStateChangeEvent(accessible, states::EXPANDED, isEnabled);
|
2010-01-18 08:17:01 -08:00
|
|
|
nsEventShell::FireEvent(accEvent);
|
2011-01-18 00:03:38 -08:00
|
|
|
return;
|
2007-04-09 21:37:52 -07:00
|
|
|
}
|
2007-04-17 05:39:10 -07:00
|
|
|
|
2011-11-24 20:32:49 -08:00
|
|
|
if (treeItemAcc && eventType.EqualsLiteral("select")) {
|
2011-10-31 17:52:27 -07:00
|
|
|
// XXX: We shouldn't be based on DOM select event which doesn't provide us
|
|
|
|
// any context info. We should integrate into nsTreeSelection instead.
|
2007-04-09 21:37:52 -07:00
|
|
|
// If multiselect tree, we should fire selectionadd or selection removed
|
2011-09-27 18:46:11 -07:00
|
|
|
if (FocusMgr()->HasDOMFocus(targetNode)) {
|
2007-04-09 21:37:52 -07:00
|
|
|
nsCOMPtr<nsIDOMXULMultiSelectControlElement> multiSel =
|
2010-06-30 19:18:08 -07:00
|
|
|
do_QueryInterface(targetNode);
|
2007-04-09 21:37:52 -07:00
|
|
|
nsAutoString selType;
|
|
|
|
multiSel->GetSelType(selType);
|
|
|
|
if (selType.IsEmpty() || !selType.EqualsLiteral("single")) {
|
|
|
|
// XXX: We need to fire EVENT_SELECTION_ADD and EVENT_SELECTION_REMOVE
|
|
|
|
// 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();
|
2010-01-18 08:16:07 -08:00
|
|
|
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_SELECTION_WITHIN,
|
|
|
|
accessible);
|
2011-01-18 00:03:38 -08:00
|
|
|
return;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2007-04-09 21:37:52 -07:00
|
|
|
|
2011-11-24 20:32:49 -08:00
|
|
|
nsRefPtr<AccSelChangeEvent> selChangeEvent =
|
|
|
|
new AccSelChangeEvent(treeAcc, treeItemAcc,
|
|
|
|
AccSelChangeEvent::eSelectionAdd);
|
|
|
|
nsEventShell::FireEvent(selChangeEvent);
|
2011-01-18 00:03:38 -08:00
|
|
|
return;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
2007-04-09 21:37:52 -07:00
|
|
|
else
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
2011-09-27 18:46:11 -07:00
|
|
|
if (eventType.EqualsLiteral("AlertActive")) {
|
2010-01-18 08:16:07 -08:00
|
|
|
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_ALERT, accessible);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2007-05-28 23:53:50 -07:00
|
|
|
else if (eventType.EqualsLiteral("popupshown")) {
|
2008-12-03 01:04:02 -08:00
|
|
|
HandlePopupShownEvent(accessible);
|
2007-05-21 06:53:57 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
else if (eventType.EqualsLiteral("DOMMenuInactive")) {
|
2012-01-11 19:07:35 -08:00
|
|
|
if (accessible->Role() == roles::MENUPOPUP) {
|
2010-01-18 08:16:07 -08:00
|
|
|
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_MENUPOPUP_END,
|
|
|
|
accessible);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
2007-04-09 21:37:52 -07:00
|
|
|
else if (eventType.EqualsLiteral("DOMMenuItemActive")) {
|
2011-09-27 18:46:11 -07:00
|
|
|
FocusMgr()->ActiveItemChanged(accessible);
|
|
|
|
A11YDEBUG_FOCUS_ACTIVEITEMCHANGE_CAUSE("DOMMenuItemActive", accessible)
|
|
|
|
}
|
|
|
|
else if (eventType.EqualsLiteral("DOMMenuItemInactive")) {
|
|
|
|
// Process DOMMenuItemInactive event for autocomplete only because this is
|
|
|
|
// unique widget that may acquire focus from autocomplete popup while popup
|
|
|
|
// stays open and has no active item. In case of XUL tree autocomplete
|
|
|
|
// popup this event is fired for tree accessible.
|
|
|
|
nsAccessible* widget =
|
|
|
|
accessible->IsWidget() ? accessible : accessible->ContainerWidget();
|
|
|
|
if (widget && widget->IsAutoCompletePopup()) {
|
|
|
|
FocusMgr()->ActiveItemChanged(nsnull);
|
|
|
|
A11YDEBUG_FOCUS_ACTIVEITEMCHANGE_CAUSE("DOMMenuItemInactive", accessible)
|
2008-03-05 19:43:50 -08:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2010-10-20 21:16:10 -07:00
|
|
|
else if (eventType.EqualsLiteral("DOMMenuBarActive")) { // Always from user input
|
2010-01-18 08:16:07 -08:00
|
|
|
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_MENU_START,
|
2010-10-20 21:16:10 -07:00
|
|
|
accessible, eFromUserInput);
|
2011-09-27 18:46:11 -07:00
|
|
|
|
|
|
|
// Notify of active item change when menubar gets active and if it has
|
|
|
|
// current item. This is a case of mouseover (set current menuitem) and
|
|
|
|
// mouse click (activate the menubar). If menubar doesn't have current item
|
|
|
|
// (can be a case of menubar activation from keyboard) then ignore this
|
|
|
|
// notification because later we'll receive DOMMenuItemActive event after
|
|
|
|
// current menuitem is set.
|
|
|
|
nsAccessible* activeItem = accessible->CurrentItem();
|
|
|
|
if (activeItem) {
|
|
|
|
FocusMgr()->ActiveItemChanged(activeItem);
|
|
|
|
A11YDEBUG_FOCUS_ACTIVEITEMCHANGE_CAUSE("DOMMenuBarActive", accessible)
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2010-10-20 21:16:10 -07:00
|
|
|
else if (eventType.EqualsLiteral("DOMMenuBarInactive")) { // Always from user input
|
2010-01-18 08:16:07 -08:00
|
|
|
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_MENU_END,
|
2010-10-20 21:16:10 -07:00
|
|
|
accessible, eFromUserInput);
|
2011-09-27 18:46:11 -07:00
|
|
|
|
|
|
|
FocusMgr()->ActiveItemChanged(nsnull);
|
|
|
|
A11YDEBUG_FOCUS_ACTIVEITEMCHANGE_CAUSE("DOMMenuBarInactive", accessible)
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
else if (eventType.EqualsLiteral("ValueChange")) {
|
2010-12-13 14:06:34 -08:00
|
|
|
targetDocument->
|
|
|
|
FireDelayedAccessibleEvent(nsIAccessibleEvent::EVENT_VALUE_CHANGE,
|
|
|
|
targetNode, AccEvent::eRemoveDupes);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2010-12-02 00:46:59 -08:00
|
|
|
#ifdef DEBUG_DRAGDROPSTART
|
2007-12-10 19:30:02 -08:00
|
|
|
else if (eventType.EqualsLiteral("mouseover")) {
|
2010-01-18 08:16:07 -08:00
|
|
|
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_DRAGDROP_START,
|
|
|
|
accessible);
|
2007-12-10 19:30:02 -08:00
|
|
|
}
|
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-10 11:12:19 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsAccessNode
|
|
|
|
|
2010-06-11 21:04:35 -07:00
|
|
|
void
|
2008-10-31 20:58:07 -07:00
|
|
|
nsRootAccessible::Shutdown()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2007-10-10 09:51:45 -07:00
|
|
|
// Called manually or by nsAccessNode::LastRelease()
|
2012-02-07 14:38:54 -08:00
|
|
|
if (!PresShell())
|
2010-06-11 21:04:35 -07:00
|
|
|
return; // Already shutdown
|
2007-10-10 09:51:45 -07:00
|
|
|
|
2010-06-11 21:04:35 -07:00
|
|
|
nsDocAccessibleWrap::Shutdown();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2009-12-10 11:12:19 -08:00
|
|
|
// nsIAccessible method
|
2011-08-09 18:44:00 -07:00
|
|
|
Relation
|
|
|
|
nsRootAccessible::RelationByType(PRUint32 aType)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-08-09 18:44:00 -07:00
|
|
|
if (!mDocument || aType != nsIAccessibleRelation::RELATION_EMBEDS)
|
|
|
|
return nsDocAccessibleWrap::RelationByType(aType);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-01-30 22:40:06 -08:00
|
|
|
nsIDOMWindow* rootWindow = mDocument->GetWindow();
|
|
|
|
if (rootWindow) {
|
|
|
|
nsCOMPtr<nsIDOMWindow> contentWindow;
|
|
|
|
rootWindow->GetContent(getter_AddRefs(contentWindow));
|
|
|
|
if (contentWindow) {
|
|
|
|
nsCOMPtr<nsIDOMDocument> contentDOMDocument;
|
|
|
|
contentWindow->GetDocument(getter_AddRefs(contentDOMDocument));
|
|
|
|
nsCOMPtr<nsIDocument> contentDocumentNode =
|
|
|
|
do_QueryInterface(contentDOMDocument);
|
|
|
|
if (contentDocumentNode) {
|
|
|
|
nsDocAccessible* contentDocument =
|
|
|
|
GetAccService()->GetDocAccessible(contentDocumentNode);
|
|
|
|
if (contentDocument)
|
|
|
|
return Relation(contentDocument);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-02-10 02:03:30 -08:00
|
|
|
|
2012-01-30 22:40:06 -08:00
|
|
|
return Relation();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2009-12-10 11:12:19 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Protected members
|
|
|
|
|
2011-01-18 00:03:38 -08:00
|
|
|
void
|
|
|
|
nsRootAccessible::HandlePopupShownEvent(nsAccessible* aAccessible)
|
2008-12-03 01:04:02 -08:00
|
|
|
{
|
2012-01-11 19:07:35 -08:00
|
|
|
roles::Role role = aAccessible->Role();
|
2008-12-03 01:04:02 -08:00
|
|
|
|
2012-01-11 19:07:35 -08:00
|
|
|
if (role == roles::MENUPOPUP) {
|
2008-12-03 01:04:02 -08:00
|
|
|
// Don't fire menupopup events for combobox and autocomplete lists.
|
2010-01-18 08:16:07 -08:00
|
|
|
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_MENUPOPUP_START,
|
|
|
|
aAccessible);
|
2011-01-18 00:03:38 -08:00
|
|
|
return;
|
2008-12-03 01:04:02 -08:00
|
|
|
}
|
|
|
|
|
2012-01-11 19:07:35 -08:00
|
|
|
if (role == roles::TOOLTIP) {
|
2008-12-03 01:04:02 -08:00
|
|
|
// There is a single <xul:tooltip> node which Mozilla moves around.
|
|
|
|
// 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.
|
2010-01-18 08:16:07 -08:00
|
|
|
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_SHOW, aAccessible);
|
2011-01-18 00:03:38 -08:00
|
|
|
return;
|
2008-12-03 01:04:02 -08:00
|
|
|
}
|
|
|
|
|
2012-01-11 19:07:35 -08:00
|
|
|
if (role == roles::COMBOBOX_LIST) {
|
2008-12-03 01:04:02 -08:00
|
|
|
// Fire expanded state change event for comboboxes and autocompeletes.
|
2011-07-23 01:38:33 -07:00
|
|
|
nsAccessible* combobox = aAccessible->Parent();
|
2011-01-18 00:03:38 -08:00
|
|
|
if (!combobox)
|
|
|
|
return;
|
2010-09-06 19:41:53 -07:00
|
|
|
|
2012-01-11 19:07:35 -08:00
|
|
|
roles::Role comboboxRole = combobox->Role();
|
|
|
|
if (comboboxRole == roles::COMBOBOX ||
|
|
|
|
comboboxRole == roles::AUTOCOMPLETE) {
|
2010-08-24 19:08:28 -07:00
|
|
|
nsRefPtr<AccEvent> event =
|
2011-10-17 07:59:28 -07:00
|
|
|
new AccStateChangeEvent(combobox, states::EXPANDED, true);
|
2011-01-18 00:03:38 -08:00
|
|
|
if (event)
|
|
|
|
nsEventShell::FireEvent(event);
|
2008-12-03 01:04:02 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-18 00:03:38 -08:00
|
|
|
void
|
2011-09-27 18:46:11 -07:00
|
|
|
nsRootAccessible::HandlePopupHidingEvent(nsINode* aPopupNode)
|
2008-12-03 01:04:02 -08:00
|
|
|
{
|
2011-09-27 18:46:11 -07:00
|
|
|
// Get popup accessible. There are cases when popup element isn't accessible
|
|
|
|
// but an underlying widget is and behaves like popup, an example is
|
|
|
|
// autocomplete popups.
|
|
|
|
nsDocAccessible* document = nsAccUtils::GetDocAccessibleFor(aPopupNode);
|
|
|
|
if (!document)
|
|
|
|
return;
|
2010-01-27 03:43:25 -08:00
|
|
|
|
2011-09-27 18:46:11 -07:00
|
|
|
nsAccessible* popup = document->GetAccessible(aPopupNode);
|
|
|
|
if (!popup) {
|
|
|
|
nsAccessible* popupContainer = document->GetContainerAccessible(aPopupNode);
|
|
|
|
if (!popupContainer)
|
|
|
|
return;
|
|
|
|
|
|
|
|
PRInt32 childCount = popupContainer->GetChildCount();
|
|
|
|
for (PRInt32 idx = 0; idx < childCount; idx++) {
|
|
|
|
nsAccessible* child = popupContainer->GetChildAt(idx);
|
|
|
|
if (child->IsAutoCompletePopup()) {
|
|
|
|
popup = child;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// No popup no events. Focus is managed by DOM. This is a case for
|
|
|
|
// menupopups of menus on Linux since there are no accessible for popups.
|
|
|
|
if (!popup)
|
|
|
|
return;
|
2008-12-03 01:04:02 -08:00
|
|
|
}
|
|
|
|
|
2011-09-27 18:46:11 -07:00
|
|
|
// In case of autocompletes and comboboxes fire state change event for
|
|
|
|
// expanded state. Note, HTML form autocomplete isn't a subject of state
|
|
|
|
// change event because they aren't autocompletes strictly speaking.
|
|
|
|
// When popup closes (except nested popups and menus) then fire focus event to
|
|
|
|
// where it was. The focus event is expected even if popup didn't take a focus.
|
|
|
|
|
|
|
|
static const PRUint32 kNotifyOfFocus = 1;
|
|
|
|
static const PRUint32 kNotifyOfState = 2;
|
|
|
|
PRUint32 notifyOf = 0;
|
|
|
|
|
|
|
|
// HTML select is target of popuphidding event. Otherwise get container
|
|
|
|
// widget. No container widget means this is either tooltip or menupopup.
|
|
|
|
// No events in the former case.
|
|
|
|
nsAccessible* widget = nsnull;
|
|
|
|
if (popup->IsCombobox()) {
|
|
|
|
widget = popup;
|
|
|
|
} else {
|
|
|
|
widget = popup->ContainerWidget();
|
|
|
|
if (!widget) {
|
|
|
|
if (!popup->IsMenuPopup())
|
|
|
|
return;
|
2008-12-03 01:04:02 -08:00
|
|
|
|
2011-09-27 18:46:11 -07:00
|
|
|
widget = popup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (popup->IsAutoCompletePopup()) {
|
|
|
|
// No focus event for autocomplete because it's managed by
|
|
|
|
// DOMMenuItemInactive events.
|
|
|
|
if (widget->IsAutoComplete())
|
|
|
|
notifyOf = kNotifyOfState;
|
|
|
|
|
|
|
|
} else if (widget->IsCombobox()) {
|
|
|
|
// Fire focus for active combobox, otherwise the focus is managed by DOM
|
|
|
|
// focus notifications. Always fire state change event.
|
|
|
|
if (widget->IsActiveWidget())
|
|
|
|
notifyOf = kNotifyOfFocus;
|
|
|
|
notifyOf |= kNotifyOfState;
|
|
|
|
|
|
|
|
} else if (widget->IsMenuButton()) {
|
|
|
|
// Can be a part of autocomplete.
|
|
|
|
nsAccessible* compositeWidget = widget->ContainerWidget();
|
|
|
|
if (compositeWidget && compositeWidget->IsAutoComplete()) {
|
|
|
|
widget = compositeWidget;
|
|
|
|
notifyOf = kNotifyOfState;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Autocomplete (like searchbar) can be inactive when popup hiddens
|
|
|
|
notifyOf |= kNotifyOfFocus;
|
|
|
|
|
|
|
|
} else if (widget == popup) {
|
|
|
|
// Top level context menus and alerts.
|
|
|
|
// Ignore submenus and menubar. When submenu is closed then sumbenu
|
|
|
|
// container menuitem takes a focus via DOMMenuItemActive notification.
|
|
|
|
// For menubars processing we listen DOMMenubarActive/Inactive
|
|
|
|
// notifications.
|
|
|
|
notifyOf = kNotifyOfFocus;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Restore focus to where it was.
|
|
|
|
if (notifyOf & kNotifyOfFocus) {
|
|
|
|
FocusMgr()->ActiveItemChanged(nsnull);
|
|
|
|
A11YDEBUG_FOCUS_ACTIVEITEMCHANGE_CAUSE("popuphiding", popup)
|
|
|
|
}
|
2010-09-06 19:41:53 -07:00
|
|
|
|
2011-09-27 18:46:11 -07:00
|
|
|
// Fire expanded state change event.
|
|
|
|
if (notifyOf & kNotifyOfState) {
|
2010-08-24 19:08:28 -07:00
|
|
|
nsRefPtr<AccEvent> event =
|
2011-10-17 07:59:28 -07:00
|
|
|
new AccStateChangeEvent(widget, states::EXPANDED, false);
|
2011-09-27 18:46:11 -07:00
|
|
|
document->FireDelayedAccessibleEvent(event);
|
2008-12-03 01:04:02 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-05 04:30:19 -07:00
|
|
|
#ifdef MOZ_XUL
|
2011-01-18 00:03:38 -08:00
|
|
|
void
|
|
|
|
nsRootAccessible::HandleTreeRowCountChangedEvent(nsIDOMEvent* aEvent,
|
|
|
|
nsXULTreeAccessible* aAccessible)
|
2008-02-08 04:55:57 -08:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDOMDataContainerEvent> dataEvent(do_QueryInterface(aEvent));
|
|
|
|
if (!dataEvent)
|
2011-01-18 00:03:38 -08:00
|
|
|
return;
|
2008-02-08 04:55:57 -08:00
|
|
|
|
|
|
|
nsCOMPtr<nsIVariant> indexVariant;
|
|
|
|
dataEvent->GetData(NS_LITERAL_STRING("index"),
|
|
|
|
getter_AddRefs(indexVariant));
|
|
|
|
if (!indexVariant)
|
2011-01-18 00:03:38 -08:00
|
|
|
return;
|
2008-02-08 04:55:57 -08:00
|
|
|
|
|
|
|
nsCOMPtr<nsIVariant> countVariant;
|
|
|
|
dataEvent->GetData(NS_LITERAL_STRING("count"),
|
|
|
|
getter_AddRefs(countVariant));
|
|
|
|
if (!countVariant)
|
2011-01-18 00:03:38 -08:00
|
|
|
return;
|
2008-02-08 04:55:57 -08:00
|
|
|
|
|
|
|
PRInt32 index, count;
|
|
|
|
indexVariant->GetAsInt32(&index);
|
|
|
|
countVariant->GetAsInt32(&count);
|
|
|
|
|
2009-06-29 08:38:17 -07:00
|
|
|
aAccessible->InvalidateCache(index, count);
|
2008-02-08 04:55:57 -08:00
|
|
|
}
|
|
|
|
|
2011-01-18 00:03:38 -08:00
|
|
|
void
|
|
|
|
nsRootAccessible::HandleTreeInvalidatedEvent(nsIDOMEvent* aEvent,
|
|
|
|
nsXULTreeAccessible* aAccessible)
|
2008-02-08 04:55:57 -08:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDOMDataContainerEvent> dataEvent(do_QueryInterface(aEvent));
|
|
|
|
if (!dataEvent)
|
2011-01-18 00:03:38 -08:00
|
|
|
return;
|
2008-02-08 04:55:57 -08:00
|
|
|
|
|
|
|
PRInt32 startRow = 0, endRow = -1, startCol = 0, endCol = -1;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIVariant> startRowVariant;
|
|
|
|
dataEvent->GetData(NS_LITERAL_STRING("startrow"),
|
|
|
|
getter_AddRefs(startRowVariant));
|
|
|
|
if (startRowVariant)
|
|
|
|
startRowVariant->GetAsInt32(&startRow);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIVariant> endRowVariant;
|
|
|
|
dataEvent->GetData(NS_LITERAL_STRING("endrow"),
|
|
|
|
getter_AddRefs(endRowVariant));
|
|
|
|
if (endRowVariant)
|
|
|
|
endRowVariant->GetAsInt32(&endRow);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIVariant> startColVariant;
|
|
|
|
dataEvent->GetData(NS_LITERAL_STRING("startcolumn"),
|
|
|
|
getter_AddRefs(startColVariant));
|
|
|
|
if (startColVariant)
|
|
|
|
startColVariant->GetAsInt32(&startCol);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIVariant> endColVariant;
|
|
|
|
dataEvent->GetData(NS_LITERAL_STRING("endcolumn"),
|
|
|
|
getter_AddRefs(endColVariant));
|
|
|
|
if (endColVariant)
|
|
|
|
endColVariant->GetAsInt32(&endCol);
|
|
|
|
|
2009-06-29 08:38:17 -07:00
|
|
|
aAccessible->TreeViewInvalidated(startRow, endRow, startCol, endCol);
|
2008-02-08 04:55:57 -08:00
|
|
|
}
|
2008-09-05 04:30:19 -07:00
|
|
|
#endif
|