| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef UI_ACCESSIBILITY_AX_VIEW_STATE_H_ | |
| 6 #define UI_ACCESSIBILITY_AX_VIEW_STATE_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 | |
| 10 #include "base/callback.h" | |
| 11 #include "base/strings/string16.h" | |
| 12 #include "ui/accessibility/ax_enums.h" | |
| 13 #include "ui/accessibility/ax_export.h" | |
| 14 | |
| 15 namespace ui { | |
| 16 | |
| 17 //////////////////////////////////////////////////////////////////////////////// | |
| 18 // | |
| 19 // AXViewState | |
| 20 // | |
| 21 // A cross-platform struct for storing the core accessibility information | |
| 22 // that should be provided about any UI view to assistive technology (AT). | |
| 23 // | |
| 24 //////////////////////////////////////////////////////////////////////////////// | |
| 25 struct AX_EXPORT AXViewState { | |
| 26 public: | |
| 27 AXViewState(); | |
| 28 ~AXViewState(); | |
| 29 | |
| 30 // Helper to check whether |state_flag| is set in the given |state|. | |
| 31 static bool IsFlagSet(uint32_t state, ui::AXState state_flag); | |
| 32 | |
| 33 // Set or check bits in |state_|. | |
| 34 void AddStateFlag(ui::AXState state_flag); | |
| 35 bool HasStateFlag(ui::AXState state_flag) const; | |
| 36 | |
| 37 // The view's state, a bitmask containing fields such as checked | |
| 38 // (for a checkbox) and protected (for a password text box). This "state" | |
| 39 // should not be confused with the class's name. | |
| 40 uint32_t state() { return state_; } | |
| 41 | |
| 42 // The view's role, like button or list box. | |
| 43 AXRole role; | |
| 44 | |
| 45 // The view's name / label. | |
| 46 base::string16 name; | |
| 47 | |
| 48 // The view's value, for example the text content. | |
| 49 base::string16 value; | |
| 50 | |
| 51 // The name of the default action if the user clicks on this view. | |
| 52 base::string16 default_action; | |
| 53 | |
| 54 // The keyboard shortcut to activate this view, if any. | |
| 55 base::string16 keyboard_shortcut; | |
| 56 | |
| 57 // The view's placeholder value, used only for views with editable text. | |
| 58 base::string16 placeholder; | |
| 59 | |
| 60 // The view's help text/description, set to the view's tooltip text (if any). | |
| 61 base::string16 description; | |
| 62 | |
| 63 // The selection start and end. Only applies to views with text content, | |
| 64 // such as a text box or combo box; start and end should be -1 otherwise. | |
| 65 int selection_start; | |
| 66 int selection_end; | |
| 67 | |
| 68 // The selected item's index and the count of the number of items. | |
| 69 // Only applies to views with multiple choices like a listbox; both | |
| 70 // index and count should be -1 otherwise. | |
| 71 int index; | |
| 72 int count; | |
| 73 | |
| 74 // An optional callback that can be used by accessibility clients to | |
| 75 // set the string value of this view. This only applies to roles where | |
| 76 // setting the value makes sense, like a text box. Not often used by | |
| 77 // screen readers, but often used by automation software to script | |
| 78 // things like logging into portals or filling forms. If the second argument | |
| 79 // is true, this replaces all text with the string given. Otherwise this | |
| 80 // inserts at the cursor position, replacing any selected text. The cursor is | |
| 81 // placed at the end of the string given. | |
| 82 // | |
| 83 // This callback is only valid for the lifetime of the view, and should | |
| 84 // be a safe no-op if the view is deleted. Typically, accessible views | |
| 85 // should use a WeakPtr when binding the callback. | |
| 86 base::Callback<void(const base::string16&, bool)> set_value_callback; | |
| 87 | |
| 88 private: | |
| 89 uint32_t state_; | |
| 90 }; | |
| 91 | |
| 92 } // namespace ui | |
| 93 | |
| 94 #endif // UI_ACCESSIBILITY_AX_VIEW_STATE_H_ | |
| OLD | NEW |