2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07: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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-06-10 16:44:50 -07:00
|
|
|
#include "XULColorPickerAccessible.h"
|
2009-11-09 21:58:52 -08:00
|
|
|
|
2012-04-13 07:17:03 -07:00
|
|
|
#include "Accessible-inl.h"
|
2010-04-26 23:52:03 -07:00
|
|
|
#include "nsAccUtils.h"
|
|
|
|
#include "nsCoreUtils.h"
|
2012-05-27 02:01:40 -07:00
|
|
|
#include "DocAccessible.h"
|
2012-01-11 19:07:35 -08:00
|
|
|
#include "Role.h"
|
|
|
|
#include "States.h"
|
2009-11-09 21:58:52 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIDOMElement.h"
|
2011-09-27 18:46:11 -07:00
|
|
|
#include "nsMenuPopupFrame.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-07-27 05:43:01 -07:00
|
|
|
using namespace mozilla::a11y;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-11-09 21:58:52 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-10 16:44:50 -07:00
|
|
|
// XULColorPickerTileAccessible
|
2009-11-09 21:58:52 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-06-10 16:44:50 -07:00
|
|
|
XULColorPickerTileAccessible::
|
|
|
|
XULColorPickerTileAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
2012-05-28 18:18:45 -07:00
|
|
|
AccessibleWrap(aContent, aDoc)
|
2009-11-09 21:58:52 -08:00
|
|
|
{
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2009-11-09 21:58:52 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2014-10-21 17:49:28 -07:00
|
|
|
// XULColorPickerTileAccessible: Accessible
|
2009-11-09 21:58:52 -08:00
|
|
|
|
2012-04-09 02:48:41 -07:00
|
|
|
void
|
2012-06-10 16:44:50 -07:00
|
|
|
XULColorPickerTileAccessible::Value(nsString& aValue)
|
2009-11-09 21:58:52 -08:00
|
|
|
{
|
|
|
|
aValue.Truncate();
|
|
|
|
|
2011-06-03 14:35:17 -07:00
|
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::color, aValue);
|
2009-11-09 21:58:52 -08:00
|
|
|
}
|
|
|
|
|
2012-01-11 19:07:35 -08:00
|
|
|
role
|
2012-06-10 16:44:50 -07:00
|
|
|
XULColorPickerTileAccessible::NativeRole()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-01-11 19:07:35 -08:00
|
|
|
return roles::PUSHBUTTON;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint64_t
|
2012-06-10 16:44:50 -07:00
|
|
|
XULColorPickerTileAccessible::NativeState()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
uint64_t state = AccessibleWrap::NativeState();
|
2011-09-27 18:46:11 -07:00
|
|
|
if (mContent->HasAttr(kNameSpaceID_None, nsGkAtoms::selected))
|
|
|
|
state |= states::SELECTED;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-27 18:46:11 -07:00
|
|
|
return state;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint64_t
|
2012-06-10 16:44:50 -07:00
|
|
|
XULColorPickerTileAccessible::NativeInteractiveState() const
|
2012-06-03 22:41:06 -07:00
|
|
|
{
|
|
|
|
return NativelyUnavailable() ?
|
|
|
|
states::UNAVAILABLE : states::FOCUSABLE | states::SELECTABLE;
|
|
|
|
}
|
|
|
|
|
2011-09-27 18:46:11 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-10 16:44:50 -07:00
|
|
|
// XULColorPickerTileAccessible: Widgets
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible*
|
2012-06-10 16:44:50 -07:00
|
|
|
XULColorPickerTileAccessible::ContainerWidget() const
|
2011-09-27 18:46:11 -07:00
|
|
|
{
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* parent = Parent();
|
2011-09-27 18:46:11 -07:00
|
|
|
if (parent) {
|
2012-05-28 18:18:45 -07:00
|
|
|
Accessible* grandParent = parent->Parent();
|
2011-09-27 18:46:11 -07:00
|
|
|
if (grandParent && grandParent->IsMenuButton())
|
|
|
|
return grandParent;
|
|
|
|
}
|
2012-07-30 07:20:58 -07:00
|
|
|
return nullptr;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2009-11-09 21:58:52 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-10 16:44:50 -07:00
|
|
|
// XULColorPickerAccessible
|
2009-11-09 21:58:52 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-06-10 16:44:50 -07:00
|
|
|
XULColorPickerAccessible::
|
|
|
|
XULColorPickerAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
|
|
|
XULColorPickerTileAccessible(aContent, aDoc)
|
2010-06-11 01:23:18 -07:00
|
|
|
{
|
2012-12-17 21:22:26 -08:00
|
|
|
mGenericTypes |= eMenuButton;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2009-11-09 21:58:52 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-10 16:44:50 -07:00
|
|
|
// XULColorPickerAccessible: Accessible
|
2009-11-09 21:58:52 -08:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint64_t
|
2012-06-10 16:44:50 -07:00
|
|
|
XULColorPickerAccessible::NativeState()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
uint64_t state = AccessibleWrap::NativeState();
|
2012-06-03 22:41:06 -07:00
|
|
|
return state | states::HASPOPUP;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-01-11 19:07:35 -08:00
|
|
|
role
|
2012-06-10 16:44:50 -07:00
|
|
|
XULColorPickerAccessible::NativeRole()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-01-11 19:07:35 -08:00
|
|
|
return roles::BUTTONDROPDOWNGRID;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-09-27 18:46:11 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-10 16:44:50 -07:00
|
|
|
// XULColorPickerAccessible: Widgets
|
2011-09-27 18:46:11 -07:00
|
|
|
|
|
|
|
bool
|
2012-06-10 16:44:50 -07:00
|
|
|
XULColorPickerAccessible::IsWidget() const
|
2011-09-27 18:46:11 -07:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2012-06-10 16:44:50 -07:00
|
|
|
XULColorPickerAccessible::IsActiveWidget() const
|
2011-09-27 18:46:11 -07:00
|
|
|
{
|
|
|
|
return FocusMgr()->HasDOMFocus(mContent);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2012-06-10 16:44:50 -07:00
|
|
|
XULColorPickerAccessible::AreItemsOperable() const
|
2011-09-27 18:46:11 -07:00
|
|
|
{
|
2012-07-30 07:20:58 -07:00
|
|
|
Accessible* menuPopup = mChildren.SafeElementAt(0, nullptr);
|
2011-09-27 18:46:11 -07:00
|
|
|
if (menuPopup) {
|
|
|
|
nsMenuPopupFrame* menuPopupFrame = do_QueryFrame(menuPopup->GetFrame());
|
|
|
|
return menuPopupFrame && menuPopupFrame->IsOpen();
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-11-09 21:58:52 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-10 16:44:50 -07:00
|
|
|
// XULColorPickerAccessible: protected Accessible
|
2009-11-09 21:58:52 -08:00
|
|
|
|
2013-09-06 12:27:07 -07:00
|
|
|
bool
|
|
|
|
XULColorPickerAccessible::IsAcceptableChild(Accessible* aPossibleChild) const
|
2009-11-09 21:58:52 -08:00
|
|
|
{
|
2013-09-06 12:27:07 -07:00
|
|
|
return roles::ALERT == aPossibleChild->Role();
|
2009-11-09 21:58:52 -08:00
|
|
|
}
|