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
|
|
|
|
|
|
|
#include "nsXULColorPickerAccessible.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"
|
2010-02-20 16:55:04 -08:00
|
|
|
#include "nsAccTreeWalker.h"
|
2010-04-26 23:52:03 -07:00
|
|
|
#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
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsXULColorPickerTileAccessible
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-11-09 21:58:52 -08:00
|
|
|
nsXULColorPickerTileAccessible::
|
2012-05-27 02:01:40 -07:00
|
|
|
nsXULColorPickerTileAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
2012-02-07 14:38:54 -08:00
|
|
|
nsAccessibleWrap(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
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsXULColorPickerTileAccessible: nsIAccessible
|
|
|
|
|
2012-04-09 02:48:41 -07:00
|
|
|
void
|
|
|
|
nsXULColorPickerTileAccessible::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
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsXULColorPickerTileAccessible: nsAccessible
|
|
|
|
|
2012-01-11 19:07:35 -08:00
|
|
|
role
|
2010-09-04 19:14:01 -07:00
|
|
|
nsXULColorPickerTileAccessible::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
|
|
|
}
|
|
|
|
|
2011-04-09 16:38:06 -07:00
|
|
|
PRUint64
|
|
|
|
nsXULColorPickerTileAccessible::NativeState()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-09-27 18:46:11 -07:00
|
|
|
PRUint64 state = nsAccessibleWrap::NativeState();
|
|
|
|
if (!(state & states::UNAVAILABLE))
|
|
|
|
state |= states::FOCUSABLE | states::SELECTABLE;
|
2009-11-09 21:58:52 -08:00
|
|
|
|
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
|
|
|
|
2011-09-27 18:46:11 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsXULColorPickerTileAccessible: Widgets
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-27 18:46:11 -07:00
|
|
|
nsAccessible*
|
|
|
|
nsXULColorPickerTileAccessible::ContainerWidget() const
|
|
|
|
{
|
|
|
|
nsAccessible* parent = Parent();
|
|
|
|
if (parent) {
|
|
|
|
nsAccessible* grandParent = parent->Parent();
|
|
|
|
if (grandParent && grandParent->IsMenuButton())
|
|
|
|
return grandParent;
|
|
|
|
}
|
|
|
|
return nsnull;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2009-11-09 21:58:52 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsXULColorPickerAccessible
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-06-11 01:23:18 -07:00
|
|
|
nsXULColorPickerAccessible::
|
2012-05-27 02:01:40 -07:00
|
|
|
nsXULColorPickerAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
2012-02-07 14:38:54 -08:00
|
|
|
nsXULColorPickerTileAccessible(aContent, aDoc)
|
2010-06-11 01:23:18 -07:00
|
|
|
{
|
2011-09-27 18:46:11 -07:00
|
|
|
mFlags |= eMenuButtonAccessible;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2009-11-09 21:58:52 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsXULColorPickerAccessible: nsAccessible
|
|
|
|
|
2011-04-09 16:38:06 -07:00
|
|
|
PRUint64
|
|
|
|
nsXULColorPickerAccessible::NativeState()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-11-09 21:58:52 -08:00
|
|
|
// Possible states: focused, focusable, unavailable(disabled).
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// get focus and disable status from base class
|
2011-04-09 16:38:06 -07:00
|
|
|
PRUint64 states = nsAccessibleWrap::NativeState();
|
2007-04-02 08:56:24 -07:00
|
|
|
|
2011-04-09 16:38:06 -07:00
|
|
|
states |= states::FOCUSABLE | states::HASPOPUP;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-04-09 16:38:06 -07:00
|
|
|
return states;
|
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
|
|
|
nsXULColorPickerAccessible::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
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsXULColorPickerAccessible: Widgets
|
|
|
|
|
|
|
|
bool
|
|
|
|
nsXULColorPickerAccessible::IsWidget() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
nsXULColorPickerAccessible::IsActiveWidget() const
|
|
|
|
{
|
|
|
|
return FocusMgr()->HasDOMFocus(mContent);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
nsXULColorPickerAccessible::AreItemsOperable() const
|
|
|
|
{
|
|
|
|
nsAccessible* menuPopup = mChildren.SafeElementAt(0, nsnull);
|
|
|
|
if (menuPopup) {
|
|
|
|
nsMenuPopupFrame* menuPopupFrame = do_QueryFrame(menuPopup->GetFrame());
|
|
|
|
return menuPopupFrame && menuPopupFrame->IsOpen();
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-11-09 21:58:52 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsXULColorPickerAccessible: protected nsAccessible
|
|
|
|
|
|
|
|
void
|
|
|
|
nsXULColorPickerAccessible::CacheChildren()
|
|
|
|
{
|
2012-02-07 14:38:54 -08:00
|
|
|
NS_ENSURE_TRUE(mDoc,);
|
|
|
|
|
2012-02-09 08:49:17 -08:00
|
|
|
nsAccTreeWalker walker(mDoc, mContent, true);
|
2009-11-09 21:58:52 -08:00
|
|
|
|
2011-03-31 02:30:58 -07:00
|
|
|
nsAccessible* child = nsnull;
|
|
|
|
while ((child = walker.NextChild())) {
|
2010-09-06 19:41:53 -07:00
|
|
|
PRUint32 role = child->Role();
|
2009-11-09 21:58:52 -08:00
|
|
|
|
2011-03-31 02:30:58 -07:00
|
|
|
// Get an accessible for menupopup or panel elements.
|
2012-01-11 19:07:35 -08:00
|
|
|
if (role == roles::ALERT) {
|
2010-07-01 18:22:41 -07:00
|
|
|
AppendChild(child);
|
2009-12-10 11:12:19 -08:00
|
|
|
return;
|
2009-11-09 21:58:52 -08:00
|
|
|
}
|
2010-11-12 11:00:55 -08:00
|
|
|
|
|
|
|
// Unbind rejected accessibles from the document.
|
2011-11-09 14:52:00 -08:00
|
|
|
Document()->UnbindFromDocument(child);
|
2009-11-09 21:58:52 -08:00
|
|
|
}
|
|
|
|
}
|