| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/accessibility/accessibility_tree_formatter.h" | 5 #include "content/browser/accessibility/accessibility_tree_formatter.h" |
| 6 | 6 |
| 7 #include <oleacc.h> | 7 #include <oleacc.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "content/browser/accessibility/browser_accessibility_manager.h" | 22 #include "content/browser/accessibility/browser_accessibility_manager.h" |
| 23 #include "content/browser/accessibility/browser_accessibility_win.h" | 23 #include "content/browser/accessibility/browser_accessibility_win.h" |
| 24 #include "third_party/iaccessible2/ia2_api_all.h" | 24 #include "third_party/iaccessible2/ia2_api_all.h" |
| 25 #include "ui/base/win/atl_module.h" | 25 #include "ui/base/win/atl_module.h" |
| 26 | 26 |
| 27 | 27 |
| 28 namespace content { | 28 namespace content { |
| 29 | 29 |
| 30 class AccessibilityTreeFormatterWin : public AccessibilityTreeFormatter { | 30 class AccessibilityTreeFormatterWin : public AccessibilityTreeFormatter { |
| 31 public: | 31 public: |
| 32 explicit AccessibilityTreeFormatterWin(); | 32 AccessibilityTreeFormatterWin(); |
| 33 ~AccessibilityTreeFormatterWin() override; | 33 ~AccessibilityTreeFormatterWin() override; |
| 34 | 34 |
| 35 private: | 35 private: |
| 36 const base::FilePath::StringType GetExpectedFileSuffix() override; | 36 const base::FilePath::StringType GetExpectedFileSuffix() override; |
| 37 const std::string GetAllowEmptyString() override; | 37 const std::string GetAllowEmptyString() override; |
| 38 const std::string GetAllowString() override; | 38 const std::string GetAllowString() override; |
| 39 const std::string GetDenyString() override; | 39 const std::string GetDenyString() override; |
| 40 void AddProperties(const BrowserAccessibility& node, | 40 void AddProperties(const BrowserAccessibility& node, |
| 41 base::DictionaryValue* dict) override; | 41 base::DictionaryValue* dict) override; |
| 42 base::string16 ToString(const base::DictionaryValue& node) override; | 42 base::string16 ToString(const base::DictionaryValue& node) override; |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 // static | 45 // static |
| 46 AccessibilityTreeFormatter* AccessibilityTreeFormatter::Create() { | 46 AccessibilityTreeFormatter* AccessibilityTreeFormatter::Create() { |
| 47 return new AccessibilityTreeFormatterWin(); | 47 return new AccessibilityTreeFormatterWin(); |
| 48 } | 48 } |
| 49 | 49 |
| 50 AccessibilityTreeFormatterWin::AccessibilityTreeFormatterWin() { | 50 AccessibilityTreeFormatterWin::AccessibilityTreeFormatterWin() { |
| 51 ui::win::CreateATLModuleIfNeeded(); | 51 ui::win::CreateATLModuleIfNeeded(); |
| 52 } | 52 } |
| 53 | 53 |
| 54 AccessibilityTreeFormatterWin::~AccessibilityTreeFormatterWin() { | 54 AccessibilityTreeFormatterWin::~AccessibilityTreeFormatterWin() { |
| 55 } | 55 } |
| 56 | 56 |
| 57 const char* ALL_ATTRIBUTES[] = {"name", | 57 const char* const ALL_ATTRIBUTES[] = { |
| 58 "value", | 58 "name", |
| 59 "states", | 59 "value", |
| 60 "attributes", | 60 "states", |
| 61 "text_attributes", | 61 "attributes", |
| 62 "role_name", | 62 "text_attributes", |
| 63 "ia2_hypertext", | 63 "role_name", |
| 64 "currentValue", | 64 "ia2_hypertext", |
| 65 "minimumValue", | 65 "currentValue", |
| 66 "maximumValue", | 66 "minimumValue", |
| 67 "description", | 67 "maximumValue", |
| 68 "default_action", | 68 "description", |
| 69 "keyboard_shortcut", | 69 "default_action", |
| 70 "location", | 70 "keyboard_shortcut", |
| 71 "size", | 71 "location", |
| 72 "index_in_parent", | 72 "size", |
| 73 "n_relations", | 73 "index_in_parent", |
| 74 "group_level", | 74 "n_relations", |
| 75 "similar_items_in_group", | 75 "group_level", |
| 76 "position_in_group", | 76 "similar_items_in_group", |
| 77 "table_rows", | 77 "position_in_group", |
| 78 "table_columns", | 78 "table_rows", |
| 79 "row_index", | 79 "table_columns", |
| 80 "column_index", | 80 "row_index", |
| 81 "n_characters", | 81 "column_index", |
| 82 "caret_offset", | 82 "n_characters", |
| 83 "n_selections", | 83 "caret_offset", |
| 84 "selection_start", | 84 "n_selections", |
| 85 "selection_end"}; | 85 "selection_start", |
| 86 "selection_end" |
| 87 }; |
| 86 | 88 |
| 87 namespace { | 89 namespace { |
| 88 | 90 |
| 89 base::string16 GetIA2Hypertext(BrowserAccessibilityWin& ax_object) { | 91 base::string16 GetIA2Hypertext(BrowserAccessibilityWin& ax_object) { |
| 90 base::win::ScopedBstr text_bstr; | 92 base::win::ScopedBstr text_bstr; |
| 91 HRESULT hr; | 93 HRESULT hr; |
| 92 | 94 |
| 93 hr = ax_object.get_text(0, IA2_TEXT_OFFSET_LENGTH, text_bstr.Receive()); | 95 hr = ax_object.get_text(0, IA2_TEXT_OFFSET_LENGTH, text_bstr.Receive()); |
| 94 if (FAILED(hr)) | 96 if (FAILED(hr)) |
| 95 return base::string16(); | 97 return base::string16(); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 embedded_character, child_index_str); | 145 embedded_character, child_index_str); |
| 144 ++character_index; | 146 ++character_index; |
| 145 hypertext_index += child_index_str.length(); | 147 hypertext_index += child_index_str.length(); |
| 146 --number_of_embeds; | 148 --number_of_embeds; |
| 147 } | 149 } |
| 148 DCHECK_EQ(number_of_embeds, 0); | 150 DCHECK_EQ(number_of_embeds, 0); |
| 149 | 151 |
| 150 return ia2_hypertext; | 152 return ia2_hypertext; |
| 151 } | 153 } |
| 152 | 154 |
| 153 } // Namespace | 155 } // namespace |
| 154 | 156 |
| 155 void AccessibilityTreeFormatterWin::AddProperties( | 157 void AccessibilityTreeFormatterWin::AddProperties( |
| 156 const BrowserAccessibility& node, base::DictionaryValue* dict) { | 158 const BrowserAccessibility& node, base::DictionaryValue* dict) { |
| 157 dict->SetInteger("id", node.GetId()); | 159 dict->SetInteger("id", node.GetId()); |
| 158 BrowserAccessibilityWin* ax_object = | 160 BrowserAccessibilityWin* ax_object = |
| 159 ToBrowserAccessibilityWin(const_cast<BrowserAccessibility*>(&node)); | 161 ToBrowserAccessibilityWin(const_cast<BrowserAccessibility*>(&node)); |
| 160 DCHECK(ax_object); | 162 DCHECK(ax_object); |
| 161 | 163 |
| 162 VARIANT variant_self; | 164 VARIANT variant_self; |
| 163 variant_self.vt = VT_I4; | 165 variant_self.vt = VT_I4; |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 | 430 |
| 429 const std::string AccessibilityTreeFormatterWin::GetAllowString() { | 431 const std::string AccessibilityTreeFormatterWin::GetAllowString() { |
| 430 return "@WIN-ALLOW:"; | 432 return "@WIN-ALLOW:"; |
| 431 } | 433 } |
| 432 | 434 |
| 433 const std::string AccessibilityTreeFormatterWin::GetDenyString() { | 435 const std::string AccessibilityTreeFormatterWin::GetDenyString() { |
| 434 return "@WIN-DENY:"; | 436 return "@WIN-DENY:"; |
| 435 } | 437 } |
| 436 | 438 |
| 437 } // namespace content | 439 } // namespace content |
| OLD | NEW |