2001-09-25 04:48:50 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2001-03-04 05:31:28 +03:00
|
|
|
|
2012-05-04 10:09:22 +04:00
|
|
|
#include "RootAccessible.h"
|
|
|
|
|
2013-12-09 06:52:54 +04:00
|
|
|
#include "mozilla/ArrayUtils.h"
|
2011-10-11 09:50:08 +04:00
|
|
|
|
2011-05-23 20:46:36 +04:00
|
|
|
#define CreateEvent CreateEventA
|
|
|
|
#include "nsIDOMDocument.h"
|
|
|
|
|
2012-04-13 18:17:03 +04:00
|
|
|
#include "Accessible-inl.h"
|
2012-06-01 22:39:47 +04:00
|
|
|
#include "DocAccessible-inl.h"
|
2003-03-20 11:27:31 +03:00
|
|
|
#include "nsAccessibilityService.h"
|
2010-04-27 10:52:03 +04:00
|
|
|
#include "nsAccUtils.h"
|
|
|
|
#include "nsCoreUtils.h"
|
2012-07-28 08:21:40 +04:00
|
|
|
#include "nsEventShell.h"
|
2011-08-10 05:44:00 +04:00
|
|
|
#include "Relation.h"
|
2012-01-12 07:07:35 +04:00
|
|
|
#include "Role.h"
|
2011-08-10 05:44:00 +04:00
|
|
|
#include "States.h"
|
2012-06-11 03:44:50 +04:00
|
|
|
#ifdef MOZ_XUL
|
|
|
|
#include "XULTreeAccessible.h"
|
|
|
|
#endif
|
2009-08-21 16:33:31 +04:00
|
|
|
|
2010-06-11 12:23:18 +04:00
|
|
|
#include "mozilla/dom/Element.h"
|
2012-06-06 14:27:46 +04:00
|
|
|
|
2006-09-15 09:10:58 +04:00
|
|
|
#include "nsIDocShellTreeItem.h"
|
|
|
|
#include "nsIDocShellTreeOwner.h"
|
2014-03-05 04:37:43 +04:00
|
|
|
#include "mozilla/dom/Event.h"
|
2013-04-06 04:44:15 +04:00
|
|
|
#include "mozilla/dom/EventTarget.h"
|
2014-03-21 07:59:59 +04:00
|
|
|
#include "nsIDOMCustomEvent.h"
|
2004-06-08 17:59:11 +04:00
|
|
|
#include "nsIDOMXULMultSelectCntrlEl.h"
|
2003-03-20 11:27:31 +03:00
|
|
|
#include "nsIDocument.h"
|
2001-09-25 12:34:42 +04:00
|
|
|
#include "nsIInterfaceRequestorUtils.h"
|
2014-03-21 07:59:59 +04:00
|
|
|
#include "nsIPropertyBag2.h"
|
2003-03-20 11:27:31 +03:00
|
|
|
#include "nsIServiceManager.h"
|
2006-09-15 09:10:58 +04:00
|
|
|
#include "nsPIDOMWindow.h"
|
2007-01-28 06:58:18 +03:00
|
|
|
#include "nsIWebBrowserChrome.h"
|
2003-03-20 11:27:31 +03:00
|
|
|
#include "nsReadableUtils.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 22:00:39 +04:00
|
|
|
#include "nsFocusManager.h"
|
2015-09-26 00:03:51 +03:00
|
|
|
#include "nsGlobalWindow.h"
|
2005-02-01 11:50:50 +03:00
|
|
|
|
2003-04-11 04:56:27 +04:00
|
|
|
#ifdef MOZ_XUL
|
|
|
|
#include "nsIXULDocument.h"
|
2007-01-28 06:58:18 +03:00
|
|
|
#include "nsIXULWindow.h"
|
2003-04-11 04:56:27 +04:00
|
|
|
#endif
|
2001-04-18 03:06:38 +04:00
|
|
|
|
2011-10-11 09:50:08 +04:00
|
|
|
using namespace mozilla;
|
2011-07-27 16:43:01 +04:00
|
|
|
using namespace mozilla::a11y;
|
2013-04-06 04:44:15 +04:00
|
|
|
using namespace mozilla::dom;
|
2010-04-30 17:12:05 +04:00
|
|
|
|
2009-12-10 22:12:19 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsISupports
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED0(RootAccessible, DocAccessible)
|
Bug 109851, bug 108629, bug 109921, bug 109977, bug 109153, bug 109187, bug 109213, bug 109221. Check in latest XUL accessibility support - menus, <colorpicker>, <progressmeter>, <groupbox>, mixed states for checkboxes, buttons that can be 'checked' ie pressed down, fixes extra MSAA events being generated, couldn't see HTML content
2001-11-20 05:05:26 +03:00
|
|
|
|
2009-12-10 22:12:19 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-05-04 10:09:22 +04:00
|
|
|
// Constructor/destructor
|
2009-12-10 22:12:19 +03:00
|
|
|
|
2012-05-04 10:09:22 +04:00
|
|
|
RootAccessible::
|
|
|
|
RootAccessible(nsIDocument* aDocument, nsIContent* aRootContent,
|
|
|
|
nsIPresShell* aPresShell) :
|
2012-05-27 13:01:40 +04:00
|
|
|
DocAccessibleWrap(aDocument, aRootContent, aPresShell)
|
2001-03-04 05:31:28 +03:00
|
|
|
{
|
2012-12-18 09:22:26 +04:00
|
|
|
mType = eRootType;
|
2001-03-04 05:31:28 +03:00
|
|
|
}
|
|
|
|
|
2012-05-04 10:09:22 +04:00
|
|
|
RootAccessible::~RootAccessible()
|
2001-03-04 05:31:28 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-12-10 22:12:19 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-05-29 05:18:45 +04:00
|
|
|
// Accessible
|
2009-12-10 22:12:19 +03:00
|
|
|
|
2012-05-01 07:08:31 +04:00
|
|
|
ENameValueFlag
|
2012-05-04 10:09:22 +04:00
|
|
|
RootAccessible::Name(nsString& aName)
|
2005-02-01 11:50:50 +03:00
|
|
|
{
|
2008-08-24 20:45:56 +04:00
|
|
|
aName.Truncate();
|
|
|
|
|
2005-06-01 18:03:38 +04:00
|
|
|
if (mRoleMapEntry) {
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible::Name(aName);
|
2012-05-01 07:08:31 +04:00
|
|
|
if (!aName.IsEmpty())
|
|
|
|
return eNameOK;
|
2005-06-01 18:03:38 +04:00
|
|
|
}
|
|
|
|
|
2014-01-21 01:52:04 +04:00
|
|
|
mDocumentNode->GetTitle(aName);
|
2012-05-01 07:08:31 +04:00
|
|
|
return eNameOK;
|
2005-02-01 11:50:50 +03:00
|
|
|
}
|
|
|
|
|
2012-01-12 07:07:35 +04:00
|
|
|
role
|
2012-05-04 10:09:22 +04:00
|
|
|
RootAccessible::NativeRole()
|
2010-09-05 06:14:01 +04:00
|
|
|
{
|
2012-01-12 07:07:35 +04:00
|
|
|
// If it's a <dialog> or <wizard>, use roles::DIALOG instead
|
2012-11-23 02:15:25 +04:00
|
|
|
dom::Element* rootElm = mDocumentNode->GetRootElement();
|
2015-03-03 14:08:59 +03:00
|
|
|
if (rootElm && rootElm->IsAnyOfXULElements(nsGkAtoms::dialog,
|
|
|
|
nsGkAtoms::wizard))
|
2012-05-22 19:36:38 +04:00
|
|
|
return roles::DIALOG;
|
2002-03-10 08:12:39 +03:00
|
|
|
|
2012-05-27 13:01:40 +04:00
|
|
|
return DocAccessibleWrap::NativeRole();
|
2001-03-04 05:31:28 +03:00
|
|
|
}
|
2001-04-18 03:06:38 +04:00
|
|
|
|
2012-05-04 10:09:22 +04:00
|
|
|
// RootAccessible protected member
|
2007-01-28 06:58:18 +03:00
|
|
|
#ifdef MOZ_XUL
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t
|
2012-05-04 10:09:22 +04:00
|
|
|
RootAccessible::GetChromeFlags()
|
2007-01-28 06:58:18 +03:00
|
|
|
{
|
|
|
|
// 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
|
2013-02-13 02:02:51 +04:00
|
|
|
nsCOMPtr<nsIDocShell> docShell = nsCoreUtils::GetDocShellFor(mDocumentNode);
|
|
|
|
NS_ENSURE_TRUE(docShell, 0);
|
2007-01-28 06:58:18 +03:00
|
|
|
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
|
2013-02-13 02:02:51 +04:00
|
|
|
docShell->GetTreeOwner(getter_AddRefs(treeOwner));
|
2007-01-28 06:58:18 +03:00
|
|
|
NS_ENSURE_TRUE(treeOwner, 0);
|
|
|
|
nsCOMPtr<nsIXULWindow> xulWin(do_GetInterface(treeOwner));
|
|
|
|
if (!xulWin) {
|
|
|
|
return 0;
|
|
|
|
}
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t chromeFlags;
|
2007-01-28 06:58:18 +03:00
|
|
|
xulWin->GetChromeFlags(&chromeFlags);
|
|
|
|
return chromeFlags;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint64_t
|
2012-05-04 10:09:22 +04:00
|
|
|
RootAccessible::NativeState()
|
2004-06-15 06:31:20 +04:00
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
uint64_t state = DocAccessibleWrap::NativeState();
|
2012-05-23 03:48:35 +04:00
|
|
|
if (state & states::DEFUNCT)
|
|
|
|
return state;
|
2004-06-15 06:31:20 +04:00
|
|
|
|
2007-01-28 06:58:18 +03:00
|
|
|
#ifdef MOZ_XUL
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t chromeFlags = GetChromeFlags();
|
2011-04-27 17:42:03 +04:00
|
|
|
if (chromeFlags & nsIWebBrowserChrome::CHROME_WINDOW_RESIZE)
|
2012-05-23 03:48:35 +04:00
|
|
|
state |= states::SIZEABLE;
|
2007-01-28 06:58:18 +03: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 17:42:03 +04:00
|
|
|
if (chromeFlags & nsIWebBrowserChrome::CHROME_TITLEBAR)
|
2012-05-23 03:48:35 +04:00
|
|
|
state |= states::MOVEABLE;
|
2011-04-27 17:42:03 +04:00
|
|
|
if (chromeFlags & nsIWebBrowserChrome::CHROME_MODAL)
|
2012-05-23 03:48:35 +04:00
|
|
|
state |= states::MODAL;
|
2007-01-28 06:58:18 +03:00
|
|
|
#endif
|
|
|
|
|
2012-02-12 06:34:00 +04:00
|
|
|
nsFocusManager* fm = nsFocusManager::GetFocusManager();
|
2012-11-23 02:15:25 +04:00
|
|
|
if (fm && fm->GetActiveWindow() == mDocumentNode->GetWindow())
|
2012-05-23 03:48:35 +04:00
|
|
|
state |= states::ACTIVE;
|
2010-05-20 12:00:37 +04:00
|
|
|
|
2012-05-23 03:48:35 +04:00
|
|
|
return state;
|
2006-07-13 09:42:32 +04:00
|
|
|
}
|
|
|
|
|
2012-11-20 19:33:30 +04:00
|
|
|
const char* const kEventTypes[] = {
|
2012-11-20 07:54:41 +04:00
|
|
|
#ifdef DEBUG_DRAGDROPSTART
|
|
|
|
// Capture mouse over events and fire fake DRAGDROPSTART event to simplify
|
2012-11-20 19:33:30 +04:00
|
|
|
// debugging a11y objects with event viewers.
|
2012-11-20 07:54:41 +04:00
|
|
|
"mouseover",
|
|
|
|
#endif
|
2012-11-20 19:33:30 +04:00
|
|
|
// Fired when list or tree selection changes.
|
2012-11-20 07:54:41 +04:00
|
|
|
"select",
|
2012-11-20 19:33:30 +04:00
|
|
|
// Fired when value changes immediately, wether or not focused changed.
|
2012-11-20 07:54:41 +04:00
|
|
|
"ValueChange",
|
|
|
|
"AlertActive",
|
|
|
|
"TreeRowCountChanged",
|
|
|
|
"TreeInvalidated",
|
|
|
|
// add ourself as a OpenStateChange listener (custom event fired in tree.xml)
|
|
|
|
"OpenStateChange",
|
2013-03-28 23:41:32 +04:00
|
|
|
// add ourself as a CheckboxStateChange listener (custom event fired in HTMLInputElement.cpp)
|
2012-11-20 07:54:41 +04:00
|
|
|
"CheckboxStateChange",
|
2013-03-28 23:41:32 +04:00
|
|
|
// add ourself as a RadioStateChange Listener ( custom event fired in in HTMLInputElement.cpp & radio.xml)
|
2012-11-20 07:54:41 +04:00
|
|
|
"RadioStateChange",
|
|
|
|
"popupshown",
|
|
|
|
"popuphiding",
|
|
|
|
"DOMMenuInactive",
|
|
|
|
"DOMMenuItemActive",
|
|
|
|
"DOMMenuItemInactive",
|
|
|
|
"DOMMenuBarActive",
|
|
|
|
"DOMMenuBarInactive"
|
|
|
|
};
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
RootAccessible::AddEventListeners()
|
|
|
|
{
|
2013-04-06 04:44:15 +04:00
|
|
|
// EventTarget interface allows to register event listeners to
|
2012-11-20 07:54:41 +04: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.
|
2013-04-06 04:44:15 +04:00
|
|
|
nsCOMPtr<EventTarget> nstarget = mDocumentNode;
|
2012-11-20 07:54:41 +04:00
|
|
|
|
|
|
|
if (nstarget) {
|
2012-11-20 19:33:30 +04:00
|
|
|
for (const char* const* e = kEventTypes,
|
|
|
|
* const* e_end = ArrayEnd(kEventTypes);
|
2012-11-20 07:54:41 +04:00
|
|
|
e < e_end; ++e) {
|
|
|
|
nsresult rv = nstarget->AddEventListener(NS_ConvertASCIItoUTF16(*e),
|
|
|
|
this, true, true, 2);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return DocAccessible::AddEventListeners();
|
|
|
|
}
|
|
|
|
|
2012-05-04 10:09:22 +04:00
|
|
|
nsresult
|
|
|
|
RootAccessible::RemoveEventListeners()
|
2001-04-18 03:06:38 +04:00
|
|
|
{
|
2013-04-06 04:44:15 +04:00
|
|
|
nsCOMPtr<EventTarget> target = mDocumentNode;
|
2003-04-15 12:45:55 +04:00
|
|
|
if (target) {
|
2012-11-20 19:33:30 +04:00
|
|
|
for (const char* const* e = kEventTypes,
|
|
|
|
* const* e_end = ArrayEnd(kEventTypes);
|
2006-04-07 17:51:04 +04:00
|
|
|
e < e_end; ++e) {
|
2011-10-17 18:59:28 +04:00
|
|
|
nsresult rv = target->RemoveEventListener(NS_ConvertASCIItoUTF16(*e), this, true);
|
2006-04-07 17:51:04 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
2003-04-15 12:45:55 +04:00
|
|
|
}
|
2002-05-09 00:21:03 +04:00
|
|
|
|
2007-11-27 21:08:50 +03:00
|
|
|
// Do this before removing clearing caret accessible, so that it can use
|
|
|
|
// shutdown the caret accessible's selection listener
|
2012-05-27 13:01:40 +04:00
|
|
|
DocAccessible::RemoveEventListeners();
|
2007-11-27 21:08:50 +03:00
|
|
|
return NS_OK;
|
2002-06-26 02:54:23 +04:00
|
|
|
}
|
|
|
|
|
2011-03-02 17:41:42 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// public
|
|
|
|
|
|
|
|
void
|
2012-05-27 13:01:40 +04:00
|
|
|
RootAccessible::DocumentActivated(DocAccessible* aDocument)
|
2011-03-02 17:41:42 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-12-10 22:12:19 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsIDOMEventListener
|
2001-04-18 03:06:38 +04:00
|
|
|
|
2010-07-01 06:18:08 +04:00
|
|
|
NS_IMETHODIMP
|
2012-05-04 10:09:22 +04:00
|
|
|
RootAccessible::HandleEvent(nsIDOMEvent* aDOMEvent)
|
2001-04-18 03:06:38 +04:00
|
|
|
{
|
2012-08-04 11:44:00 +04:00
|
|
|
MOZ_ASSERT(aDOMEvent);
|
2014-03-05 04:37:43 +04:00
|
|
|
Event* event = aDOMEvent->InternalDOMEvent();
|
2013-04-06 04:44:15 +04:00
|
|
|
nsCOMPtr<nsINode> origTargetNode = do_QueryInterface(event->GetOriginalTarget());
|
2011-01-18 11:03:38 +03:00
|
|
|
if (!origTargetNode)
|
|
|
|
return NS_OK;
|
|
|
|
|
2012-10-05 17:00:28 +04:00
|
|
|
#ifdef A11Y_LOG
|
|
|
|
if (logging::IsEnabled(logging::eDOMEvents)) {
|
|
|
|
nsAutoString eventType;
|
|
|
|
aDOMEvent->GetType(eventType);
|
|
|
|
logging::DOMEvent("handled", origTargetNode, eventType);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-05-27 13:01:40 +04:00
|
|
|
DocAccessible* document =
|
2011-10-18 14:53:36 +04:00
|
|
|
GetAccService()->GetDocAccessible(origTargetNode->OwnerDoc());
|
2011-01-18 11:03:38 +03:00
|
|
|
|
|
|
|
if (document) {
|
|
|
|
// Root accessible exists longer than any of its descendant documents so
|
|
|
|
// that we are guaranteed notification is processed before root accessible
|
|
|
|
// is destroyed.
|
2012-05-04 10:09:22 +04:00
|
|
|
document->HandleNotification<RootAccessible, nsIDOMEvent>
|
|
|
|
(this, &RootAccessible::ProcessDOMEvent, aDOMEvent);
|
2011-01-18 11:03:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-05-04 10:09:22 +04:00
|
|
|
// RootAccessible protected
|
2011-01-18 11:03:38 +03:00
|
|
|
void
|
2012-05-04 10:09:22 +04:00
|
|
|
RootAccessible::ProcessDOMEvent(nsIDOMEvent* aDOMEvent)
|
2011-01-18 11:03:38 +03:00
|
|
|
{
|
2012-08-04 11:44:00 +04:00
|
|
|
MOZ_ASSERT(aDOMEvent);
|
2014-03-05 04:37:43 +04:00
|
|
|
Event* event = aDOMEvent->InternalDOMEvent();
|
2013-04-06 04:44:15 +04:00
|
|
|
nsCOMPtr<nsINode> origTargetNode = do_QueryInterface(event->GetOriginalTarget());
|
2009-12-10 22:12:19 +03:00
|
|
|
|
2004-06-02 08:06:28 +04:00
|
|
|
nsAutoString eventType;
|
2011-01-18 11:03:38 +03:00
|
|
|
aDOMEvent->GetType(eventType);
|
2007-01-10 09:34:39 +03:00
|
|
|
|
2012-10-05 17:00:28 +04:00
|
|
|
#ifdef A11Y_LOG
|
|
|
|
if (logging::IsEnabled(logging::eDOMEvents))
|
|
|
|
logging::DOMEvent("processed", origTargetNode, eventType);
|
|
|
|
#endif
|
|
|
|
|
2011-01-18 11:03:38 +03:00
|
|
|
if (eventType.EqualsLiteral("popuphiding")) {
|
2011-09-28 05:46:11 +04:00
|
|
|
HandlePopupHidingEvent(origTargetNode);
|
2011-01-18 11:03:38 +03:00
|
|
|
return;
|
|
|
|
}
|
2008-12-03 12:04:02 +03:00
|
|
|
|
2012-05-27 13:01:40 +04:00
|
|
|
DocAccessible* targetDocument = GetAccService()->
|
2012-02-08 02:38:54 +04:00
|
|
|
GetDocAccessible(origTargetNode->OwnerDoc());
|
|
|
|
NS_ASSERTION(targetDocument, "No document while accessible is in document?!");
|
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible* accessible =
|
2012-02-08 02:38:54 +04:00
|
|
|
targetDocument->GetAccessibleOrContainer(origTargetNode);
|
2010-05-12 10:47:35 +04:00
|
|
|
if (!accessible)
|
2011-01-18 11:03:38 +03:00
|
|
|
return;
|
2007-02-16 07:49:15 +03:00
|
|
|
|
2008-01-24 02:49:10 +03:00
|
|
|
#ifdef MOZ_XUL
|
2012-06-11 03:44:50 +04:00
|
|
|
XULTreeAccessible* treeAcc = accessible->AsXULTree();
|
2012-04-03 13:54:01 +04:00
|
|
|
if (treeAcc) {
|
|
|
|
if (eventType.EqualsLiteral("TreeRowCountChanged")) {
|
|
|
|
HandleTreeRowCountChangedEvent(aDOMEvent, treeAcc);
|
|
|
|
return;
|
|
|
|
}
|
2011-12-02 00:43:07 +04:00
|
|
|
|
2012-04-03 13:54:01 +04:00
|
|
|
if (eventType.EqualsLiteral("TreeInvalidated")) {
|
|
|
|
HandleTreeInvalidatedEvent(aDOMEvent, treeAcc);
|
|
|
|
return;
|
2008-06-16 10:16:18 +04:00
|
|
|
}
|
|
|
|
}
|
2008-01-24 02:49:10 +03:00
|
|
|
#endif
|
2007-12-11 11:18:04 +03:00
|
|
|
|
2007-04-17 16:39:10 +04:00
|
|
|
if (eventType.EqualsLiteral("RadioStateChange")) {
|
2012-08-22 19:56:38 +04:00
|
|
|
uint64_t state = accessible->State();
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isEnabled = (state & (states::CHECKED | states::SELECTED)) != 0;
|
2007-04-17 16:39:10 +04:00
|
|
|
|
2013-08-02 20:42:36 +04:00
|
|
|
if (accessible->NeedsDOMUIEvent()) {
|
|
|
|
nsRefPtr<AccEvent> accEvent =
|
|
|
|
new AccStateChangeEvent(accessible, states::CHECKED, isEnabled);
|
|
|
|
nsEventShell::FireEvent(accEvent);
|
|
|
|
}
|
2007-04-17 16:39:10 +04:00
|
|
|
|
2011-09-28 05:46:11 +04:00
|
|
|
if (isEnabled) {
|
|
|
|
FocusMgr()->ActiveItemChanged(accessible);
|
2012-10-04 13:57:09 +04:00
|
|
|
#ifdef A11Y_LOG
|
2012-09-27 03:53:23 +04:00
|
|
|
if (logging::IsEnabled(logging::eFocus))
|
|
|
|
logging::ActiveItemChangeCausedBy("RadioStateChange", accessible);
|
|
|
|
#endif
|
2011-09-28 05:46:11 +04:00
|
|
|
}
|
2007-04-17 16:39:10 +04:00
|
|
|
|
2011-01-18 11:03:38 +03:00
|
|
|
return;
|
2007-04-17 16:39:10 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (eventType.EqualsLiteral("CheckboxStateChange")) {
|
2013-08-02 20:42:36 +04:00
|
|
|
if (accessible->NeedsDOMUIEvent()) {
|
|
|
|
uint64_t state = accessible->State();
|
|
|
|
bool isEnabled = !!(state & states::CHECKED);
|
2007-04-17 16:39:10 +04:00
|
|
|
|
2013-08-02 20:42:36 +04:00
|
|
|
nsRefPtr<AccEvent> accEvent =
|
|
|
|
new AccStateChangeEvent(accessible, states::CHECKED, isEnabled);
|
|
|
|
nsEventShell::FireEvent(accEvent);
|
|
|
|
}
|
2011-01-18 11:03:38 +03:00
|
|
|
return;
|
2007-04-17 16:39:10 +04:00
|
|
|
}
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
Accessible* treeItemAcc = nullptr;
|
2003-04-11 04:56:27 +04:00
|
|
|
#ifdef MOZ_XUL
|
2011-11-25 08:32:49 +04:00
|
|
|
// If it's a tree element, need the currently selected item.
|
|
|
|
if (treeAcc) {
|
|
|
|
treeItemAcc = accessible->CurrentItem();
|
|
|
|
if (treeItemAcc)
|
|
|
|
accessible = treeItemAcc;
|
2003-04-15 12:45:55 +04:00
|
|
|
}
|
2002-05-13 11:19:43 +04:00
|
|
|
|
2011-11-25 08:32:49 +04:00
|
|
|
if (treeItemAcc && eventType.EqualsLiteral("OpenStateChange")) {
|
2012-08-22 19:56:38 +04:00
|
|
|
uint64_t state = accessible->State();
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isEnabled = (state & states::EXPANDED) != 0;
|
2007-04-17 16:39:10 +04:00
|
|
|
|
2010-08-25 06:08:28 +04:00
|
|
|
nsRefPtr<AccEvent> accEvent =
|
2011-04-10 03:38:06 +04:00
|
|
|
new AccStateChangeEvent(accessible, states::EXPANDED, isEnabled);
|
2010-01-18 19:17:01 +03:00
|
|
|
nsEventShell::FireEvent(accEvent);
|
2011-01-18 11:03:38 +03:00
|
|
|
return;
|
2007-04-10 08:37:52 +04:00
|
|
|
}
|
2007-04-17 16:39:10 +04:00
|
|
|
|
2012-11-20 08:53:38 +04:00
|
|
|
nsINode* targetNode = accessible->GetNode();
|
2011-11-25 08:32:49 +04:00
|
|
|
if (treeItemAcc && eventType.EqualsLiteral("select")) {
|
2011-11-01 04:52:27 +04: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-10 08:37:52 +04:00
|
|
|
// If multiselect tree, we should fire selectionadd or selection removed
|
2011-09-28 05:46:11 +04:00
|
|
|
if (FocusMgr()->HasDOMFocus(targetNode)) {
|
2007-04-10 08:37:52 +04:00
|
|
|
nsCOMPtr<nsIDOMXULMultiSelectControlElement> multiSel =
|
2010-07-01 06:18:08 +04:00
|
|
|
do_QueryInterface(targetNode);
|
2007-04-10 08:37:52 +04: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
|
2012-06-11 03:44:50 +04:00
|
|
|
// that state changes. XULTreeAccessible::UpdateTreeSelection();
|
2010-01-18 19:16:07 +03:00
|
|
|
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_SELECTION_WITHIN,
|
|
|
|
accessible);
|
2011-01-18 11:03:38 +03:00
|
|
|
return;
|
2005-07-28 21:18:28 +04:00
|
|
|
}
|
2007-04-10 08:37:52 +04:00
|
|
|
|
2011-11-25 08:32:49 +04:00
|
|
|
nsRefPtr<AccSelChangeEvent> selChangeEvent =
|
|
|
|
new AccSelChangeEvent(treeAcc, treeItemAcc,
|
|
|
|
AccSelChangeEvent::eSelectionAdd);
|
|
|
|
nsEventShell::FireEvent(selChangeEvent);
|
2011-01-18 11:03:38 +03:00
|
|
|
return;
|
2005-05-13 18:47:48 +04:00
|
|
|
}
|
2003-04-15 12:45:55 +04:00
|
|
|
}
|
2007-04-10 08:37:52 +04:00
|
|
|
else
|
2003-04-11 04:56:27 +04:00
|
|
|
#endif
|
2011-09-28 05:46:11 +04:00
|
|
|
if (eventType.EqualsLiteral("AlertActive")) {
|
2010-01-18 19:16:07 +03:00
|
|
|
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_ALERT, accessible);
|
2005-03-15 18:00:44 +03:00
|
|
|
}
|
2007-05-29 10:53:50 +04:00
|
|
|
else if (eventType.EqualsLiteral("popupshown")) {
|
2008-12-03 12:04:02 +03:00
|
|
|
HandlePopupShownEvent(accessible);
|
2007-05-21 17:53:57 +04:00
|
|
|
}
|
2005-09-30 23:23:42 +04:00
|
|
|
else if (eventType.EqualsLiteral("DOMMenuInactive")) {
|
2012-01-12 07:07:35 +04:00
|
|
|
if (accessible->Role() == roles::MENUPOPUP) {
|
2010-01-18 19:16:07 +03:00
|
|
|
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_MENUPOPUP_END,
|
|
|
|
accessible);
|
2002-10-25 06:50:24 +04:00
|
|
|
}
|
2003-04-15 12:45:55 +04:00
|
|
|
}
|
2007-04-10 08:37:52 +04:00
|
|
|
else if (eventType.EqualsLiteral("DOMMenuItemActive")) {
|
2011-09-28 05:46:11 +04:00
|
|
|
FocusMgr()->ActiveItemChanged(accessible);
|
2012-10-04 13:57:09 +04:00
|
|
|
#ifdef A11Y_LOG
|
2012-09-27 03:53:23 +04:00
|
|
|
if (logging::IsEnabled(logging::eFocus))
|
|
|
|
logging::ActiveItemChangeCausedBy("DOMMenuItemActive", accessible);
|
|
|
|
#endif
|
2011-09-28 05:46:11 +04:00
|
|
|
}
|
|
|
|
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.
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible* widget =
|
2011-09-28 05:46:11 +04:00
|
|
|
accessible->IsWidget() ? accessible : accessible->ContainerWidget();
|
|
|
|
if (widget && widget->IsAutoCompletePopup()) {
|
2012-07-30 18:20:58 +04:00
|
|
|
FocusMgr()->ActiveItemChanged(nullptr);
|
2012-10-04 13:57:09 +04:00
|
|
|
#ifdef A11Y_LOG
|
2012-09-27 03:53:23 +04:00
|
|
|
if (logging::IsEnabled(logging::eFocus))
|
|
|
|
logging::ActiveItemChangeCausedBy("DOMMenuItemInactive", accessible);
|
|
|
|
#endif
|
2008-03-06 06:43:50 +03:00
|
|
|
}
|
2006-08-08 18:01:19 +04:00
|
|
|
}
|
2010-10-21 08:16:10 +04:00
|
|
|
else if (eventType.EqualsLiteral("DOMMenuBarActive")) { // Always from user input
|
2010-01-18 19:16:07 +03:00
|
|
|
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_MENU_START,
|
2010-10-21 08:16:10 +04:00
|
|
|
accessible, eFromUserInput);
|
2011-09-28 05:46:11 +04: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.
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible* activeItem = accessible->CurrentItem();
|
2011-09-28 05:46:11 +04:00
|
|
|
if (activeItem) {
|
|
|
|
FocusMgr()->ActiveItemChanged(activeItem);
|
2012-10-04 13:57:09 +04:00
|
|
|
#ifdef A11Y_LOG
|
2012-09-27 03:53:23 +04:00
|
|
|
if (logging::IsEnabled(logging::eFocus))
|
|
|
|
logging::ActiveItemChangeCausedBy("DOMMenuBarActive", accessible);
|
|
|
|
#endif
|
2011-09-28 05:46:11 +04:00
|
|
|
}
|
2006-08-08 18:01:19 +04:00
|
|
|
}
|
2010-10-21 08:16:10 +04:00
|
|
|
else if (eventType.EqualsLiteral("DOMMenuBarInactive")) { // Always from user input
|
2010-01-18 19:16:07 +03:00
|
|
|
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_MENU_END,
|
2010-10-21 08:16:10 +04:00
|
|
|
accessible, eFromUserInput);
|
2011-09-28 05:46:11 +04:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
FocusMgr()->ActiveItemChanged(nullptr);
|
2012-10-04 13:57:09 +04:00
|
|
|
#ifdef A11Y_LOG
|
2012-09-27 03:53:23 +04:00
|
|
|
if (logging::IsEnabled(logging::eFocus))
|
|
|
|
logging::ActiveItemChangeCausedBy("DOMMenuBarInactive", accessible);
|
|
|
|
#endif
|
2006-08-08 18:01:19 +04:00
|
|
|
}
|
2013-08-02 20:42:36 +04:00
|
|
|
else if (accessible->NeedsDOMUIEvent() &&
|
|
|
|
eventType.EqualsLiteral("ValueChange")) {
|
|
|
|
targetDocument->FireDelayedEvent(nsIAccessibleEvent::EVENT_VALUE_CHANGE,
|
|
|
|
accessible);
|
2007-03-21 19:46:28 +03:00
|
|
|
}
|
2010-12-02 11:46:59 +03:00
|
|
|
#ifdef DEBUG_DRAGDROPSTART
|
2007-12-11 06:30:02 +03:00
|
|
|
else if (eventType.EqualsLiteral("mouseover")) {
|
2010-01-18 19:16:07 +03:00
|
|
|
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_DRAGDROP_START,
|
|
|
|
accessible);
|
2007-12-11 06:30:02 +03:00
|
|
|
}
|
|
|
|
#endif
|
2001-05-12 01:11:38 +04:00
|
|
|
}
|
2001-04-18 03:06:38 +04:00
|
|
|
|
2001-08-14 10:01:48 +04:00
|
|
|
|
2009-12-10 22:12:19 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2013-10-29 07:30:55 +04:00
|
|
|
// Accessible
|
2009-12-10 22:12:19 +03:00
|
|
|
|
2010-06-12 08:04:35 +04:00
|
|
|
void
|
2012-05-04 10:09:22 +04:00
|
|
|
RootAccessible::Shutdown()
|
2001-06-30 04:25:09 +04:00
|
|
|
{
|
2013-10-29 07:30:55 +04:00
|
|
|
// Called manually or by Accessible::LastRelease()
|
2012-02-08 02:38:54 +04:00
|
|
|
if (!PresShell())
|
2010-06-12 08:04:35 +04:00
|
|
|
return; // Already shutdown
|
2007-10-10 20:51:45 +04:00
|
|
|
|
2012-05-27 13:01:40 +04:00
|
|
|
DocAccessibleWrap::Shutdown();
|
2001-06-30 04:25:09 +04:00
|
|
|
}
|
|
|
|
|
2011-08-10 05:44:00 +04:00
|
|
|
Relation
|
2013-10-19 22:19:50 +04:00
|
|
|
RootAccessible::RelationByType(RelationType aType)
|
2006-07-17 18:10:24 +04:00
|
|
|
{
|
2013-10-19 22:19:50 +04:00
|
|
|
if (!mDocumentNode || aType != RelationType::EMBEDS)
|
2012-05-27 13:01:40 +04:00
|
|
|
return DocAccessibleWrap::RelationByType(aType);
|
2006-07-17 18:10:24 +04:00
|
|
|
|
2015-09-26 00:03:51 +03:00
|
|
|
nsPIDOMWindow* rootWindow = mDocumentNode->GetWindow();
|
2012-01-31 10:40:06 +04:00
|
|
|
if (rootWindow) {
|
2015-09-26 00:03:51 +03:00
|
|
|
nsCOMPtr<nsIDOMWindow> contentWindow = nsGlobalWindow::Cast(rootWindow)->GetContent();
|
2012-01-31 10:40:06 +04:00
|
|
|
if (contentWindow) {
|
|
|
|
nsCOMPtr<nsIDOMDocument> contentDOMDocument;
|
|
|
|
contentWindow->GetDocument(getter_AddRefs(contentDOMDocument));
|
|
|
|
nsCOMPtr<nsIDocument> contentDocumentNode =
|
|
|
|
do_QueryInterface(contentDOMDocument);
|
|
|
|
if (contentDocumentNode) {
|
2012-05-27 13:01:40 +04:00
|
|
|
DocAccessible* contentDocument =
|
2012-01-31 10:40:06 +04:00
|
|
|
GetAccService()->GetDocAccessible(contentDocumentNode);
|
|
|
|
if (contentDocument)
|
|
|
|
return Relation(contentDocument);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-02-10 13:03:30 +03:00
|
|
|
|
2012-01-31 10:40:06 +04:00
|
|
|
return Relation();
|
2006-07-17 18:10:24 +04:00
|
|
|
}
|
|
|
|
|
2009-12-10 22:12:19 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Protected members
|
|
|
|
|
2011-01-18 11:03:38 +03:00
|
|
|
void
|
2012-05-29 05:18:45 +04:00
|
|
|
RootAccessible::HandlePopupShownEvent(Accessible* aAccessible)
|
2008-12-03 12:04:02 +03:00
|
|
|
{
|
2012-01-12 07:07:35 +04:00
|
|
|
roles::Role role = aAccessible->Role();
|
2008-12-03 12:04:02 +03:00
|
|
|
|
2012-01-12 07:07:35 +04:00
|
|
|
if (role == roles::MENUPOPUP) {
|
2008-12-03 12:04:02 +03:00
|
|
|
// Don't fire menupopup events for combobox and autocomplete lists.
|
2010-01-18 19:16:07 +03:00
|
|
|
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_MENUPOPUP_START,
|
|
|
|
aAccessible);
|
2011-01-18 11:03:38 +03:00
|
|
|
return;
|
2008-12-03 12:04:02 +03:00
|
|
|
}
|
|
|
|
|
2012-01-12 07:07:35 +04:00
|
|
|
if (role == roles::TOOLTIP) {
|
2008-12-03 12:04:02 +03: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 19:16:07 +03:00
|
|
|
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_SHOW, aAccessible);
|
2011-01-18 11:03:38 +03:00
|
|
|
return;
|
2008-12-03 12:04:02 +03:00
|
|
|
}
|
|
|
|
|
2012-01-12 07:07:35 +04:00
|
|
|
if (role == roles::COMBOBOX_LIST) {
|
2008-12-03 12:04:02 +03:00
|
|
|
// Fire expanded state change event for comboboxes and autocompeletes.
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible* combobox = aAccessible->Parent();
|
2011-01-18 11:03:38 +03:00
|
|
|
if (!combobox)
|
|
|
|
return;
|
2010-09-07 06:41:53 +04:00
|
|
|
|
2012-01-12 07:07:35 +04:00
|
|
|
roles::Role comboboxRole = combobox->Role();
|
|
|
|
if (comboboxRole == roles::COMBOBOX ||
|
|
|
|
comboboxRole == roles::AUTOCOMPLETE) {
|
2010-08-25 06:08:28 +04:00
|
|
|
nsRefPtr<AccEvent> event =
|
2011-10-17 18:59:28 +04:00
|
|
|
new AccStateChangeEvent(combobox, states::EXPANDED, true);
|
2011-01-18 11:03:38 +03:00
|
|
|
if (event)
|
|
|
|
nsEventShell::FireEvent(event);
|
2008-12-03 12:04:02 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-18 11:03:38 +03:00
|
|
|
void
|
2012-05-04 10:09:22 +04:00
|
|
|
RootAccessible::HandlePopupHidingEvent(nsINode* aPopupNode)
|
2008-12-03 12:04:02 +03:00
|
|
|
{
|
2011-09-28 05:46:11 +04: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.
|
2012-05-27 13:01:40 +04:00
|
|
|
DocAccessible* document = nsAccUtils::GetDocAccessibleFor(aPopupNode);
|
2011-09-28 05:46:11 +04:00
|
|
|
if (!document)
|
|
|
|
return;
|
2010-01-27 14:43:25 +03:00
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible* popup = document->GetAccessible(aPopupNode);
|
2011-09-28 05:46:11 +04:00
|
|
|
if (!popup) {
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible* popupContainer = document->GetContainerAccessible(aPopupNode);
|
2011-09-28 05:46:11 +04:00
|
|
|
if (!popupContainer)
|
|
|
|
return;
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t childCount = popupContainer->ChildCount();
|
|
|
|
for (uint32_t idx = 0; idx < childCount; idx++) {
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible* child = popupContainer->GetChildAt(idx);
|
2011-09-28 05:46:11 +04:00
|
|
|
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 12:04:02 +03:00
|
|
|
}
|
|
|
|
|
2011-09-28 05:46:11 +04: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.
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
static const uint32_t kNotifyOfFocus = 1;
|
|
|
|
static const uint32_t kNotifyOfState = 2;
|
|
|
|
uint32_t notifyOf = 0;
|
2011-09-28 05:46:11 +04:00
|
|
|
|
|
|
|
// 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.
|
2012-07-30 18:20:58 +04:00
|
|
|
Accessible* widget = nullptr;
|
2011-09-28 05:46:11 +04:00
|
|
|
if (popup->IsCombobox()) {
|
|
|
|
widget = popup;
|
|
|
|
} else {
|
|
|
|
widget = popup->ContainerWidget();
|
|
|
|
if (!widget) {
|
|
|
|
if (!popup->IsMenuPopup())
|
|
|
|
return;
|
2008-12-03 12:04:02 +03:00
|
|
|
|
2011-09-28 05:46:11 +04: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.
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible* compositeWidget = widget->ContainerWidget();
|
2011-09-28 05:46:11 +04:00
|
|
|
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) {
|
2012-07-30 18:20:58 +04:00
|
|
|
FocusMgr()->ActiveItemChanged(nullptr);
|
2012-10-04 13:57:09 +04:00
|
|
|
#ifdef A11Y_LOG
|
2012-09-27 03:53:23 +04:00
|
|
|
if (logging::IsEnabled(logging::eFocus))
|
|
|
|
logging::ActiveItemChangeCausedBy("popuphiding", popup);
|
|
|
|
#endif
|
2011-09-28 05:46:11 +04:00
|
|
|
}
|
2010-09-07 06:41:53 +04:00
|
|
|
|
2011-09-28 05:46:11 +04:00
|
|
|
// Fire expanded state change event.
|
|
|
|
if (notifyOf & kNotifyOfState) {
|
2010-08-25 06:08:28 +04:00
|
|
|
nsRefPtr<AccEvent> event =
|
2011-10-17 18:59:28 +04:00
|
|
|
new AccStateChangeEvent(widget, states::EXPANDED, false);
|
2012-11-20 08:53:38 +04:00
|
|
|
document->FireDelayedEvent(event);
|
2008-12-03 12:04:02 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-05 15:30:19 +04:00
|
|
|
#ifdef MOZ_XUL
|
2011-01-18 11:03:38 +03:00
|
|
|
void
|
2012-05-04 10:09:22 +04:00
|
|
|
RootAccessible::HandleTreeRowCountChangedEvent(nsIDOMEvent* aEvent,
|
2012-06-11 03:44:50 +04:00
|
|
|
XULTreeAccessible* aAccessible)
|
2008-02-08 15:55:57 +03:00
|
|
|
{
|
2014-03-21 07:59:59 +04:00
|
|
|
nsCOMPtr<nsIDOMCustomEvent> customEvent(do_QueryInterface(aEvent));
|
|
|
|
if (!customEvent)
|
2011-01-18 11:03:38 +03:00
|
|
|
return;
|
2008-02-08 15:55:57 +03:00
|
|
|
|
2014-03-21 07:59:59 +04:00
|
|
|
nsCOMPtr<nsIVariant> detailVariant;
|
|
|
|
customEvent->GetDetail(getter_AddRefs(detailVariant));
|
|
|
|
if (!detailVariant)
|
2011-01-18 11:03:38 +03:00
|
|
|
return;
|
2008-02-08 15:55:57 +03:00
|
|
|
|
2014-03-21 07:59:59 +04:00
|
|
|
nsCOMPtr<nsISupports> supports;
|
|
|
|
detailVariant->GetAsISupports(getter_AddRefs(supports));
|
|
|
|
nsCOMPtr<nsIPropertyBag2> propBag(do_QueryInterface(supports));
|
|
|
|
if (!propBag)
|
2011-01-18 11:03:38 +03:00
|
|
|
return;
|
2008-02-08 15:55:57 +03:00
|
|
|
|
2014-03-21 07:59:59 +04:00
|
|
|
nsresult rv;
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t index, count;
|
2014-03-21 07:59:59 +04:00
|
|
|
rv = propBag->GetPropertyAsInt32(NS_LITERAL_STRING("index"), &index);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return;
|
|
|
|
|
|
|
|
rv = propBag->GetPropertyAsInt32(NS_LITERAL_STRING("count"), &count);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return;
|
2008-02-08 15:55:57 +03:00
|
|
|
|
2009-06-29 19:38:17 +04:00
|
|
|
aAccessible->InvalidateCache(index, count);
|
2008-02-08 15:55:57 +03:00
|
|
|
}
|
|
|
|
|
2011-01-18 11:03:38 +03:00
|
|
|
void
|
2012-05-04 10:09:22 +04:00
|
|
|
RootAccessible::HandleTreeInvalidatedEvent(nsIDOMEvent* aEvent,
|
2012-06-11 03:44:50 +04:00
|
|
|
XULTreeAccessible* aAccessible)
|
2008-02-08 15:55:57 +03:00
|
|
|
{
|
2014-03-21 07:59:59 +04:00
|
|
|
nsCOMPtr<nsIDOMCustomEvent> customEvent(do_QueryInterface(aEvent));
|
|
|
|
if (!customEvent)
|
2011-01-18 11:03:38 +03:00
|
|
|
return;
|
2008-02-08 15:55:57 +03:00
|
|
|
|
2014-03-21 07:59:59 +04:00
|
|
|
nsCOMPtr<nsIVariant> detailVariant;
|
|
|
|
customEvent->GetDetail(getter_AddRefs(detailVariant));
|
|
|
|
if (!detailVariant)
|
|
|
|
return;
|
|
|
|
|
|
|
|
nsCOMPtr<nsISupports> supports;
|
|
|
|
detailVariant->GetAsISupports(getter_AddRefs(supports));
|
|
|
|
nsCOMPtr<nsIPropertyBag2> propBag(do_QueryInterface(supports));
|
|
|
|
if (!propBag)
|
|
|
|
return;
|
2008-02-08 15:55:57 +03:00
|
|
|
|
2014-03-21 07:59:59 +04:00
|
|
|
int32_t startRow = 0, endRow = -1, startCol = 0, endCol = -1;
|
|
|
|
propBag->GetPropertyAsInt32(NS_LITERAL_STRING("startrow"),
|
|
|
|
&startRow);
|
|
|
|
propBag->GetPropertyAsInt32(NS_LITERAL_STRING("endrow"),
|
|
|
|
&endRow);
|
|
|
|
propBag->GetPropertyAsInt32(NS_LITERAL_STRING("startcolumn"),
|
|
|
|
&startCol);
|
|
|
|
propBag->GetPropertyAsInt32(NS_LITERAL_STRING("endcolumn"),
|
|
|
|
&endCol);
|
2008-02-08 15:55:57 +03:00
|
|
|
|
2009-06-29 19:38:17 +04:00
|
|
|
aAccessible->TreeViewInvalidated(startRow, endRow, startCol, endCol);
|
2008-02-08 15:55:57 +03:00
|
|
|
}
|
2008-09-05 15:30:19 +04:00
|
|
|
#endif
|
2015-10-06 21:00:20 +03:00
|
|
|
|
|
|
|
ProxyAccessible*
|
|
|
|
RootAccessible::GetPrimaryRemoteTopLevelContentDoc() const
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDocShellTreeOwner> owner;
|
|
|
|
mDocumentNode->GetDocShell()->GetTreeOwner(getter_AddRefs(owner));
|
|
|
|
NS_ENSURE_TRUE(owner, nullptr);
|
|
|
|
|
|
|
|
nsCOMPtr<nsITabParent> tabParent;
|
|
|
|
owner->GetPrimaryTabParent(getter_AddRefs(tabParent));
|
|
|
|
if (!tabParent) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto tab = static_cast<dom::TabParent*>(tabParent.get());
|
|
|
|
return tab->GetTopLevelDocAccessible();
|
|
|
|
}
|