Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
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)
27 {
28 }
30 ////////////////////////////////////////////////////////////////////////////////
31 // XULColorPickerTileAccessible: nsIAccessible
33 void
34 XULColorPickerTileAccessible::Value(nsString& aValue)
35 {
36 aValue.Truncate();
38 mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::color, aValue);
39 }
41 ////////////////////////////////////////////////////////////////////////////////
42 // XULColorPickerTileAccessible: Accessible
44 role
45 XULColorPickerTileAccessible::NativeRole()
46 {
47 return roles::PUSHBUTTON;
48 }
50 uint64_t
51 XULColorPickerTileAccessible::NativeState()
52 {
53 uint64_t state = AccessibleWrap::NativeState();
54 if (mContent->HasAttr(kNameSpaceID_None, nsGkAtoms::selected))
55 state |= states::SELECTED;
57 return state;
58 }
60 uint64_t
61 XULColorPickerTileAccessible::NativeInteractiveState() const
62 {
63 return NativelyUnavailable() ?
64 states::UNAVAILABLE : states::FOCUSABLE | states::SELECTABLE;
65 }
67 ////////////////////////////////////////////////////////////////////////////////
68 // XULColorPickerTileAccessible: Widgets
70 Accessible*
71 XULColorPickerTileAccessible::ContainerWidget() const
72 {
73 Accessible* parent = Parent();
74 if (parent) {
75 Accessible* grandParent = parent->Parent();
76 if (grandParent && grandParent->IsMenuButton())
77 return grandParent;
78 }
79 return nullptr;
80 }
82 ////////////////////////////////////////////////////////////////////////////////
83 // XULColorPickerAccessible
84 ////////////////////////////////////////////////////////////////////////////////
86 XULColorPickerAccessible::
87 XULColorPickerAccessible(nsIContent* aContent, DocAccessible* aDoc) :
88 XULColorPickerTileAccessible(aContent, aDoc)
89 {
90 mGenericTypes |= eMenuButton;
91 }
93 ////////////////////////////////////////////////////////////////////////////////
94 // XULColorPickerAccessible: Accessible
96 uint64_t
97 XULColorPickerAccessible::NativeState()
98 {
99 uint64_t state = AccessibleWrap::NativeState();
100 return state | states::HASPOPUP;
101 }
103 role
104 XULColorPickerAccessible::NativeRole()
105 {
106 return roles::BUTTONDROPDOWNGRID;
107 }
109 ////////////////////////////////////////////////////////////////////////////////
110 // XULColorPickerAccessible: Widgets
112 bool
113 XULColorPickerAccessible::IsWidget() const
114 {
115 return true;
116 }
118 bool
119 XULColorPickerAccessible::IsActiveWidget() const
120 {
121 return FocusMgr()->HasDOMFocus(mContent);
122 }
124 bool
125 XULColorPickerAccessible::AreItemsOperable() const
126 {
127 Accessible* menuPopup = mChildren.SafeElementAt(0, nullptr);
128 if (menuPopup) {
129 nsMenuPopupFrame* menuPopupFrame = do_QueryFrame(menuPopup->GetFrame());
130 return menuPopupFrame && menuPopupFrame->IsOpen();
131 }
132 return false;
133 }
135 ////////////////////////////////////////////////////////////////////////////////
136 // XULColorPickerAccessible: protected Accessible
138 bool
139 XULColorPickerAccessible::IsAcceptableChild(Accessible* aPossibleChild) const
140 {
141 return roles::ALERT == aPossibleChild->Role();
142 }