2007-06-02 07:01:38 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/* vim:expandtab:shiftwidth=4:tabstop=4:
|
|
|
|
*/
|
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/. */
|
2012-05-30 04:51:00 +04:00
|
|
|
|
2012-04-25 15:29:40 +04:00
|
|
|
#include "ApplicationAccessible.h"
|
2007-06-02 07:01:38 +04:00
|
|
|
|
2009-12-10 22:12:19 +03:00
|
|
|
#include "nsAccessibilityService.h"
|
2010-04-27 10:52:03 +04:00
|
|
|
#include "nsAccUtils.h"
|
2012-01-12 07:07:35 +04:00
|
|
|
#include "Relation.h"
|
|
|
|
#include "Role.h"
|
|
|
|
#include "States.h"
|
2009-12-10 22:12:19 +03:00
|
|
|
|
2007-06-02 07:01:38 +04:00
|
|
|
#include "nsIComponentManager.h"
|
2010-04-23 07:46:37 +04:00
|
|
|
#include "nsIDOMDocument.h"
|
|
|
|
#include "nsIDOMWindow.h"
|
|
|
|
#include "nsIWindowMediator.h"
|
2007-06-02 07:01:38 +04:00
|
|
|
#include "nsServiceManagerUtils.h"
|
2010-05-14 13:24:41 +04:00
|
|
|
#include "mozilla/Services.h"
|
2012-08-01 22:31:10 +04:00
|
|
|
#include "nsIStringBundle.h"
|
2007-06-02 07:01:38 +04:00
|
|
|
|
2011-07-27 16:43:01 +04:00
|
|
|
using namespace mozilla::a11y;
|
|
|
|
|
2012-04-25 15:29:40 +04:00
|
|
|
ApplicationAccessible::ApplicationAccessible() :
|
2012-07-30 18:20:58 +04:00
|
|
|
AccessibleWrap(nullptr, nullptr)
|
2007-06-02 07:01:38 +04:00
|
|
|
{
|
2012-12-18 09:22:26 +04:00
|
|
|
mType = eApplicationType;
|
2012-11-20 19:33:30 +04:00
|
|
|
mAppInfo = do_GetService("@mozilla.org/xre/app-info;1");
|
2007-06-02 07:01:38 +04:00
|
|
|
}
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED0(ApplicationAccessible, Accessible)
|
2008-08-06 16:19:56 +04:00
|
|
|
|
2010-04-23 07:45:16 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2010-06-11 12:23:18 +04:00
|
|
|
// nsIAccessible
|
2010-04-23 07:45:16 +04:00
|
|
|
|
2012-05-01 07:08:31 +04:00
|
|
|
ENameValueFlag
|
|
|
|
ApplicationAccessible::Name(nsString& aName)
|
2007-06-02 07:01:38 +04:00
|
|
|
{
|
2008-08-24 20:45:56 +04:00
|
|
|
aName.Truncate();
|
|
|
|
|
2007-06-02 07:01:38 +04:00
|
|
|
nsCOMPtr<nsIStringBundleService> bundleService =
|
2010-05-14 13:24:41 +04:00
|
|
|
mozilla::services::GetStringBundleService();
|
2007-06-02 07:01:38 +04:00
|
|
|
|
|
|
|
NS_ASSERTION(bundleService, "String bundle service must be present!");
|
2012-05-01 07:08:31 +04:00
|
|
|
if (!bundleService)
|
|
|
|
return eNameOK;
|
2007-06-02 07:01:38 +04:00
|
|
|
|
|
|
|
nsCOMPtr<nsIStringBundle> bundle;
|
2008-10-08 16:58:46 +04:00
|
|
|
nsresult rv = bundleService->CreateBundle("chrome://branding/locale/brand.properties",
|
|
|
|
getter_AddRefs(bundle));
|
2012-05-01 07:08:31 +04:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return eNameOK;
|
2007-06-02 07:01:38 +04:00
|
|
|
|
|
|
|
nsXPIDLString appName;
|
2013-12-13 05:50:01 +04:00
|
|
|
rv = bundle->GetStringFromName(MOZ_UTF16("brandShortName"),
|
2008-10-08 16:58:46 +04:00
|
|
|
getter_Copies(appName));
|
|
|
|
if (NS_FAILED(rv) || appName.IsEmpty()) {
|
|
|
|
NS_WARNING("brandShortName not found, using default app name");
|
|
|
|
appName.AssignLiteral("Gecko based application");
|
2007-06-02 07:01:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
aName.Assign(appName);
|
2012-05-01 07:08:31 +04:00
|
|
|
return eNameOK;
|
2007-06-02 07:01:38 +04:00
|
|
|
}
|
|
|
|
|
2012-04-09 13:48:41 +04:00
|
|
|
void
|
2012-04-25 15:29:40 +04:00
|
|
|
ApplicationAccessible::Description(nsString& aDescription)
|
2007-06-02 07:01:38 +04:00
|
|
|
{
|
2012-04-09 13:48:41 +04:00
|
|
|
aDescription.Truncate();
|
2007-06-02 07:01:38 +04:00
|
|
|
}
|
|
|
|
|
2011-04-23 17:14:05 +04:00
|
|
|
void
|
2012-04-25 15:29:40 +04:00
|
|
|
ApplicationAccessible::Value(nsString& aValue)
|
2010-06-11 12:23:18 +04:00
|
|
|
{
|
2012-04-09 13:48:41 +04:00
|
|
|
aValue.Truncate();
|
2010-06-11 12:23:18 +04:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint64_t
|
2012-04-25 15:29:40 +04:00
|
|
|
ApplicationAccessible::State()
|
2007-06-02 07:01:38 +04:00
|
|
|
{
|
2011-04-12 10:18:42 +04:00
|
|
|
return IsDefunct() ? states::DEFUNCT : 0;
|
2010-06-11 12:23:18 +04:00
|
|
|
}
|
2009-12-10 22:12:19 +03:00
|
|
|
|
2012-10-19 11:15:23 +04:00
|
|
|
already_AddRefed<nsIPersistentProperties>
|
|
|
|
ApplicationAccessible::NativeAttributes()
|
2010-06-11 12:23:18 +04:00
|
|
|
{
|
2012-10-19 11:15:23 +04:00
|
|
|
return nullptr;
|
2010-06-11 12:23:18 +04:00
|
|
|
}
|
2007-06-02 07:01:38 +04:00
|
|
|
|
2012-05-30 04:51:00 +04:00
|
|
|
GroupPos
|
|
|
|
ApplicationAccessible::GroupPosition()
|
2010-06-11 12:23:18 +04:00
|
|
|
{
|
2012-05-30 04:51:00 +04:00
|
|
|
return GroupPos();
|
2007-06-02 07:01:38 +04:00
|
|
|
}
|
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible*
|
2012-08-22 19:56:38 +04:00
|
|
|
ApplicationAccessible::ChildAtPoint(int32_t aX, int32_t aY,
|
2012-04-25 15:29:40 +04:00
|
|
|
EWhichChildAtPoint aWhichChild)
|
2010-06-11 12:23:18 +04:00
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2010-06-11 12:23:18 +04:00
|
|
|
}
|
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible*
|
2012-04-25 15:29:40 +04:00
|
|
|
ApplicationAccessible::FocusedChild()
|
2011-08-09 13:31:31 +04:00
|
|
|
{
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible* focus = FocusMgr()->FocusedAccessible();
|
2011-09-28 05:46:11 +04:00
|
|
|
if (focus && focus->Parent() == this)
|
|
|
|
return focus;
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2011-08-09 13:31:31 +04:00
|
|
|
}
|
|
|
|
|
2011-08-10 05:44:00 +04:00
|
|
|
Relation
|
2013-10-19 22:19:50 +04:00
|
|
|
ApplicationAccessible::RelationByType(RelationType aRelationType)
|
2010-06-11 12:23:18 +04:00
|
|
|
{
|
2011-08-10 05:44:00 +04:00
|
|
|
return Relation();
|
2010-06-11 12:23:18 +04:00
|
|
|
}
|
|
|
|
|
2014-09-16 21:30:23 +04:00
|
|
|
nsIntRect
|
|
|
|
ApplicationAccessible::Bounds() const
|
2010-06-11 12:23:18 +04:00
|
|
|
{
|
2014-09-16 21:30:23 +04:00
|
|
|
return nsIntRect();
|
2009-12-10 22:12:19 +03:00
|
|
|
}
|
2009-11-19 19:35:38 +03:00
|
|
|
|
2009-12-10 22:12:19 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2013-10-29 07:30:55 +04:00
|
|
|
// Accessible public methods
|
2009-11-19 19:35:38 +03:00
|
|
|
|
2010-06-12 08:04:35 +04:00
|
|
|
void
|
2012-04-25 15:29:40 +04:00
|
|
|
ApplicationAccessible::Shutdown()
|
2010-03-18 21:49:39 +03:00
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
mAppInfo = nullptr;
|
2007-06-02 07:01:38 +04:00
|
|
|
}
|
|
|
|
|
2011-04-10 03:38:06 +04:00
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
ApplicationAccessible::ApplyARIAState(uint64_t* aState) const
|
2010-06-11 12:23:18 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-01-12 07:07:35 +04:00
|
|
|
role
|
2012-04-25 15:29:40 +04:00
|
|
|
ApplicationAccessible::NativeRole()
|
2009-12-10 22:12:19 +03:00
|
|
|
{
|
2012-01-12 07:07:35 +04:00
|
|
|
return roles::APP_ROOT;
|
2007-06-02 07:01:38 +04:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint64_t
|
2012-04-25 15:29:40 +04:00
|
|
|
ApplicationAccessible::NativeState()
|
2008-03-30 07:24:02 +04:00
|
|
|
{
|
2011-04-12 10:18:42 +04:00
|
|
|
return 0;
|
2009-11-19 17:44:59 +03:00
|
|
|
}
|
2008-03-30 07:24:02 +04:00
|
|
|
|
2009-12-10 22:12:19 +03:00
|
|
|
void
|
2012-04-25 15:29:40 +04:00
|
|
|
ApplicationAccessible::InvalidateChildren()
|
2009-12-10 22:12:19 +03:00
|
|
|
{
|
2010-06-25 13:50:23 +04:00
|
|
|
// Do nothing because application children are kept updated by AppendChild()
|
|
|
|
// and RemoveChild() method calls.
|
2009-11-19 19:35:38 +03:00
|
|
|
}
|
2009-11-19 17:44:59 +03:00
|
|
|
|
2011-07-19 17:12:40 +04:00
|
|
|
KeyBinding
|
2012-04-25 15:29:40 +04:00
|
|
|
ApplicationAccessible::AccessKey() const
|
2011-07-19 17:12:40 +04:00
|
|
|
{
|
|
|
|
return KeyBinding();
|
|
|
|
}
|
|
|
|
|
2009-12-10 22:12:19 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-05-29 05:18:45 +04:00
|
|
|
// Accessible protected methods
|
2009-12-10 22:12:19 +03:00
|
|
|
|
2007-06-02 07:01:38 +04:00
|
|
|
void
|
2012-04-25 15:29:40 +04:00
|
|
|
ApplicationAccessible::CacheChildren()
|
2007-06-02 07:01:38 +04:00
|
|
|
{
|
2010-04-23 07:46:37 +04:00
|
|
|
// CacheChildren is called only once for application accessible when its
|
|
|
|
// children are requested because empty InvalidateChldren() prevents its
|
|
|
|
// repeated calls.
|
|
|
|
|
2010-06-25 13:50:23 +04:00
|
|
|
// Basically children are kept updated by Append/RemoveChild method calls.
|
|
|
|
// However if there are open windows before accessibility was started
|
2010-04-23 07:46:37 +04:00
|
|
|
// then we need to make sure root accessibles for open windows are created so
|
2010-04-24 05:51:10 +04:00
|
|
|
// that all root accessibles are stored in application accessible children
|
2010-04-23 07:46:37 +04:00
|
|
|
// array.
|
|
|
|
|
|
|
|
nsCOMPtr<nsIWindowMediator> windowMediator =
|
|
|
|
do_GetService(NS_WINDOWMEDIATOR_CONTRACTID);
|
|
|
|
|
|
|
|
nsCOMPtr<nsISimpleEnumerator> windowEnumerator;
|
2012-07-30 18:20:58 +04:00
|
|
|
nsresult rv = windowMediator->GetEnumerator(nullptr,
|
2010-04-23 07:46:37 +04:00
|
|
|
getter_AddRefs(windowEnumerator));
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return;
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool hasMore = false;
|
2010-04-23 07:46:37 +04:00
|
|
|
windowEnumerator->HasMoreElements(&hasMore);
|
|
|
|
while (hasMore) {
|
|
|
|
nsCOMPtr<nsISupports> window;
|
|
|
|
windowEnumerator->GetNext(getter_AddRefs(window));
|
|
|
|
nsCOMPtr<nsIDOMWindow> DOMWindow = do_QueryInterface(window);
|
|
|
|
if (DOMWindow) {
|
|
|
|
nsCOMPtr<nsIDOMDocument> DOMDocument;
|
|
|
|
DOMWindow->GetDocument(getter_AddRefs(DOMDocument));
|
|
|
|
if (DOMDocument) {
|
2010-06-28 17:22:49 +04:00
|
|
|
nsCOMPtr<nsIDocument> docNode(do_QueryInterface(DOMDocument));
|
|
|
|
GetAccService()->GetDocAccessible(docNode); // ensure creation
|
2010-04-23 07:46:37 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
windowEnumerator->HasMoreElements(&hasMore);
|
|
|
|
}
|
2009-12-10 22:12:19 +03:00
|
|
|
}
|
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible*
|
2012-08-22 19:56:38 +04:00
|
|
|
ApplicationAccessible::GetSiblingAtOffset(int32_t aOffset,
|
2012-04-25 15:29:40 +04:00
|
|
|
nsresult* aError) const
|
2009-12-10 22:12:19 +03:00
|
|
|
{
|
|
|
|
if (aError)
|
|
|
|
*aError = NS_OK; // fail peacefully
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2007-06-02 07:01:38 +04:00
|
|
|
}
|