Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #include "XULColorPickerAccessible.h" |
michael@0 | 7 | |
michael@0 | 8 | #include "Accessible-inl.h" |
michael@0 | 9 | #include "nsAccUtils.h" |
michael@0 | 10 | #include "nsCoreUtils.h" |
michael@0 | 11 | #include "DocAccessible.h" |
michael@0 | 12 | #include "Role.h" |
michael@0 | 13 | #include "States.h" |
michael@0 | 14 | |
michael@0 | 15 | #include "nsIDOMElement.h" |
michael@0 | 16 | #include "nsMenuPopupFrame.h" |
michael@0 | 17 | |
michael@0 | 18 | using namespace mozilla::a11y; |
michael@0 | 19 | |
michael@0 | 20 | //////////////////////////////////////////////////////////////////////////////// |
michael@0 | 21 | // XULColorPickerTileAccessible |
michael@0 | 22 | //////////////////////////////////////////////////////////////////////////////// |
michael@0 | 23 | |
michael@0 | 24 | XULColorPickerTileAccessible:: |
michael@0 | 25 | XULColorPickerTileAccessible(nsIContent* aContent, DocAccessible* aDoc) : |
michael@0 | 26 | AccessibleWrap(aContent, aDoc) |
michael@0 | 27 | { |
michael@0 | 28 | } |
michael@0 | 29 | |
michael@0 | 30 | //////////////////////////////////////////////////////////////////////////////// |
michael@0 | 31 | // XULColorPickerTileAccessible: nsIAccessible |
michael@0 | 32 | |
michael@0 | 33 | void |
michael@0 | 34 | XULColorPickerTileAccessible::Value(nsString& aValue) |
michael@0 | 35 | { |
michael@0 | 36 | aValue.Truncate(); |
michael@0 | 37 | |
michael@0 | 38 | mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::color, aValue); |
michael@0 | 39 | } |
michael@0 | 40 | |
michael@0 | 41 | //////////////////////////////////////////////////////////////////////////////// |
michael@0 | 42 | // XULColorPickerTileAccessible: Accessible |
michael@0 | 43 | |
michael@0 | 44 | role |
michael@0 | 45 | XULColorPickerTileAccessible::NativeRole() |
michael@0 | 46 | { |
michael@0 | 47 | return roles::PUSHBUTTON; |
michael@0 | 48 | } |
michael@0 | 49 | |
michael@0 | 50 | uint64_t |
michael@0 | 51 | XULColorPickerTileAccessible::NativeState() |
michael@0 | 52 | { |
michael@0 | 53 | uint64_t state = AccessibleWrap::NativeState(); |
michael@0 | 54 | if (mContent->HasAttr(kNameSpaceID_None, nsGkAtoms::selected)) |
michael@0 | 55 | state |= states::SELECTED; |
michael@0 | 56 | |
michael@0 | 57 | return state; |
michael@0 | 58 | } |
michael@0 | 59 | |
michael@0 | 60 | uint64_t |
michael@0 | 61 | XULColorPickerTileAccessible::NativeInteractiveState() const |
michael@0 | 62 | { |
michael@0 | 63 | return NativelyUnavailable() ? |
michael@0 | 64 | states::UNAVAILABLE : states::FOCUSABLE | states::SELECTABLE; |
michael@0 | 65 | } |
michael@0 | 66 | |
michael@0 | 67 | //////////////////////////////////////////////////////////////////////////////// |
michael@0 | 68 | // XULColorPickerTileAccessible: Widgets |
michael@0 | 69 | |
michael@0 | 70 | Accessible* |
michael@0 | 71 | XULColorPickerTileAccessible::ContainerWidget() const |
michael@0 | 72 | { |
michael@0 | 73 | Accessible* parent = Parent(); |
michael@0 | 74 | if (parent) { |
michael@0 | 75 | Accessible* grandParent = parent->Parent(); |
michael@0 | 76 | if (grandParent && grandParent->IsMenuButton()) |
michael@0 | 77 | return grandParent; |
michael@0 | 78 | } |
michael@0 | 79 | return nullptr; |
michael@0 | 80 | } |
michael@0 | 81 | |
michael@0 | 82 | //////////////////////////////////////////////////////////////////////////////// |
michael@0 | 83 | // XULColorPickerAccessible |
michael@0 | 84 | //////////////////////////////////////////////////////////////////////////////// |
michael@0 | 85 | |
michael@0 | 86 | XULColorPickerAccessible:: |
michael@0 | 87 | XULColorPickerAccessible(nsIContent* aContent, DocAccessible* aDoc) : |
michael@0 | 88 | XULColorPickerTileAccessible(aContent, aDoc) |
michael@0 | 89 | { |
michael@0 | 90 | mGenericTypes |= eMenuButton; |
michael@0 | 91 | } |
michael@0 | 92 | |
michael@0 | 93 | //////////////////////////////////////////////////////////////////////////////// |
michael@0 | 94 | // XULColorPickerAccessible: Accessible |
michael@0 | 95 | |
michael@0 | 96 | uint64_t |
michael@0 | 97 | XULColorPickerAccessible::NativeState() |
michael@0 | 98 | { |
michael@0 | 99 | uint64_t state = AccessibleWrap::NativeState(); |
michael@0 | 100 | return state | states::HASPOPUP; |
michael@0 | 101 | } |
michael@0 | 102 | |
michael@0 | 103 | role |
michael@0 | 104 | XULColorPickerAccessible::NativeRole() |
michael@0 | 105 | { |
michael@0 | 106 | return roles::BUTTONDROPDOWNGRID; |
michael@0 | 107 | } |
michael@0 | 108 | |
michael@0 | 109 | //////////////////////////////////////////////////////////////////////////////// |
michael@0 | 110 | // XULColorPickerAccessible: Widgets |
michael@0 | 111 | |
michael@0 | 112 | bool |
michael@0 | 113 | XULColorPickerAccessible::IsWidget() const |
michael@0 | 114 | { |
michael@0 | 115 | return true; |
michael@0 | 116 | } |
michael@0 | 117 | |
michael@0 | 118 | bool |
michael@0 | 119 | XULColorPickerAccessible::IsActiveWidget() const |
michael@0 | 120 | { |
michael@0 | 121 | return FocusMgr()->HasDOMFocus(mContent); |
michael@0 | 122 | } |
michael@0 | 123 | |
michael@0 | 124 | bool |
michael@0 | 125 | XULColorPickerAccessible::AreItemsOperable() const |
michael@0 | 126 | { |
michael@0 | 127 | Accessible* menuPopup = mChildren.SafeElementAt(0, nullptr); |
michael@0 | 128 | if (menuPopup) { |
michael@0 | 129 | nsMenuPopupFrame* menuPopupFrame = do_QueryFrame(menuPopup->GetFrame()); |
michael@0 | 130 | return menuPopupFrame && menuPopupFrame->IsOpen(); |
michael@0 | 131 | } |
michael@0 | 132 | return false; |
michael@0 | 133 | } |
michael@0 | 134 | |
michael@0 | 135 | //////////////////////////////////////////////////////////////////////////////// |
michael@0 | 136 | // XULColorPickerAccessible: protected Accessible |
michael@0 | 137 | |
michael@0 | 138 | bool |
michael@0 | 139 | XULColorPickerAccessible::IsAcceptableChild(Accessible* aPossibleChild) const |
michael@0 | 140 | { |
michael@0 | 141 | return roles::ALERT == aPossibleChild->Role(); |
michael@0 | 142 | } |