Bumping manifests a=b2g-bump
[gecko.git] / accessible / xul / XULColorPickerAccessible.cpp
blob17cd81fee939d940866312a9ef24d51c8334fa73
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"
12 #include "Role.h"
13 #include "States.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
33 void
34 XULColorPickerTileAccessible::Value(nsString& aValue)
36 aValue.Truncate();
38 mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::color, aValue);
41 role
42 XULColorPickerTileAccessible::NativeRole()
44 return roles::PUSHBUTTON;
47 uint64_t
48 XULColorPickerTileAccessible::NativeState()
50 uint64_t state = AccessibleWrap::NativeState();
51 if (mContent->HasAttr(kNameSpaceID_None, nsGkAtoms::selected))
52 state |= states::SELECTED;
54 return state;
57 uint64_t
58 XULColorPickerTileAccessible::NativeInteractiveState() const
60 return NativelyUnavailable() ?
61 states::UNAVAILABLE : states::FOCUSABLE | states::SELECTABLE;
64 ////////////////////////////////////////////////////////////////////////////////
65 // XULColorPickerTileAccessible: Widgets
67 Accessible*
68 XULColorPickerTileAccessible::ContainerWidget() const
70 Accessible* parent = Parent();
71 if (parent) {
72 Accessible* grandParent = parent->Parent();
73 if (grandParent && grandParent->IsMenuButton())
74 return grandParent;
76 return nullptr;
79 ////////////////////////////////////////////////////////////////////////////////
80 // XULColorPickerAccessible
81 ////////////////////////////////////////////////////////////////////////////////
83 XULColorPickerAccessible::
84 XULColorPickerAccessible(nsIContent* aContent, DocAccessible* aDoc) :
85 XULColorPickerTileAccessible(aContent, aDoc)
87 mGenericTypes |= eMenuButton;
90 ////////////////////////////////////////////////////////////////////////////////
91 // XULColorPickerAccessible: Accessible
93 uint64_t
94 XULColorPickerAccessible::NativeState()
96 uint64_t state = AccessibleWrap::NativeState();
97 return state | states::HASPOPUP;
100 role
101 XULColorPickerAccessible::NativeRole()
103 return roles::BUTTONDROPDOWNGRID;
106 ////////////////////////////////////////////////////////////////////////////////
107 // XULColorPickerAccessible: Widgets
109 bool
110 XULColorPickerAccessible::IsWidget() const
112 return true;
115 bool
116 XULColorPickerAccessible::IsActiveWidget() const
118 return FocusMgr()->HasDOMFocus(mContent);
121 bool
122 XULColorPickerAccessible::AreItemsOperable() const
124 Accessible* menuPopup = mChildren.SafeElementAt(0, nullptr);
125 if (menuPopup) {
126 nsMenuPopupFrame* menuPopupFrame = do_QueryFrame(menuPopup->GetFrame());
127 return menuPopupFrame && menuPopupFrame->IsOpen();
129 return false;
132 ////////////////////////////////////////////////////////////////////////////////
133 // XULColorPickerAccessible: protected Accessible
135 bool
136 XULColorPickerAccessible::IsAcceptableChild(Accessible* aPossibleChild) const
138 return roles::ALERT == aPossibleChild->Role();