1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "XULColorPickerAccessible.h"
8 #include "Accessible-inl.h"
9 #include "nsAccUtils.h"
10 #include "nsCoreUtils.h"
11 #include "DocAccessible.h"
15 #include "nsIDOMElement.h"
16 #include "nsMenuPopupFrame.h"
18 using namespace mozilla::a11y
;
20 ////////////////////////////////////////////////////////////////////////////////
21 // XULColorPickerTileAccessible
22 ////////////////////////////////////////////////////////////////////////////////
24 XULColorPickerTileAccessible::
25 XULColorPickerTileAccessible(nsIContent
* aContent
, DocAccessible
* aDoc
) :
26 AccessibleWrap(aContent
, aDoc
)
30 ////////////////////////////////////////////////////////////////////////////////
31 // XULColorPickerTileAccessible: Accessible
34 XULColorPickerTileAccessible::Value(nsString
& aValue
)
38 mContent
->GetAttr(kNameSpaceID_None
, nsGkAtoms::color
, aValue
);
42 XULColorPickerTileAccessible::NativeRole()
44 return roles::PUSHBUTTON
;
48 XULColorPickerTileAccessible::NativeState()
50 uint64_t state
= AccessibleWrap::NativeState();
51 if (mContent
->HasAttr(kNameSpaceID_None
, nsGkAtoms::selected
))
52 state
|= states::SELECTED
;
58 XULColorPickerTileAccessible::NativeInteractiveState() const
60 return NativelyUnavailable() ?
61 states::UNAVAILABLE
: states::FOCUSABLE
| states::SELECTABLE
;
64 ////////////////////////////////////////////////////////////////////////////////
65 // XULColorPickerTileAccessible: Widgets
68 XULColorPickerTileAccessible::ContainerWidget() const
70 Accessible
* parent
= Parent();
72 Accessible
* grandParent
= parent
->Parent();
73 if (grandParent
&& grandParent
->IsMenuButton())
79 ////////////////////////////////////////////////////////////////////////////////
80 // XULColorPickerAccessible
81 ////////////////////////////////////////////////////////////////////////////////
83 XULColorPickerAccessible::
84 XULColorPickerAccessible(nsIContent
* aContent
, DocAccessible
* aDoc
) :
85 XULColorPickerTileAccessible(aContent
, aDoc
)
87 mGenericTypes
|= eMenuButton
;
90 ////////////////////////////////////////////////////////////////////////////////
91 // XULColorPickerAccessible: Accessible
94 XULColorPickerAccessible::NativeState()
96 uint64_t state
= AccessibleWrap::NativeState();
97 return state
| states::HASPOPUP
;
101 XULColorPickerAccessible::NativeRole()
103 return roles::BUTTONDROPDOWNGRID
;
106 ////////////////////////////////////////////////////////////////////////////////
107 // XULColorPickerAccessible: Widgets
110 XULColorPickerAccessible::IsWidget() const
116 XULColorPickerAccessible::IsActiveWidget() const
118 return FocusMgr()->HasDOMFocus(mContent
);
122 XULColorPickerAccessible::AreItemsOperable() const
124 Accessible
* menuPopup
= mChildren
.SafeElementAt(0, nullptr);
126 nsMenuPopupFrame
* menuPopupFrame
= do_QueryFrame(menuPopup
->GetFrame());
127 return menuPopupFrame
&& menuPopupFrame
->IsOpen();
132 ////////////////////////////////////////////////////////////////////////////////
133 // XULColorPickerAccessible: protected Accessible
136 XULColorPickerAccessible::IsAcceptableChild(Accessible
* aPossibleChild
) const
138 return roles::ALERT
== aPossibleChild
->Role();