| OLD | NEW | 
|     1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. |     1 // Copyright (c) 2017 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/browser_accessibility_com_win.h" |     5 #include "content/browser/accessibility/browser_accessibility_com_win.h" | 
|     6  |     6  | 
|     7 #include <UIAutomationClient.h> |     7 #include <UIAutomationClient.h> | 
|     8 #include <UIAutomationCoreApi.h> |     8 #include <UIAutomationCoreApi.h> | 
|     9  |     9  | 
|    10 #include <algorithm> |    10 #include <algorithm> | 
|    11 #include <iterator> |    11 #include <iterator> | 
|    12 #include <utility> |    12 #include <utility> | 
|    13  |    13  | 
|    14 #include "base/metrics/histogram_macros.h" |    14 #include "base/metrics/histogram_macros.h" | 
|    15 #include "base/strings/string_number_conversions.h" |    15 #include "base/strings/string_number_conversions.h" | 
|    16 #include "base/strings/string_split.h" |    16 #include "base/strings/string_split.h" | 
|    17 #include "base/strings/string_util.h" |    17 #include "base/strings/string_util.h" | 
|    18 #include "base/strings/utf_string_conversions.h" |    18 #include "base/strings/utf_string_conversions.h" | 
|    19 #include "base/win/enum_variant.h" |    19 #include "base/win/enum_variant.h" | 
|    20 #include "base/win/scoped_comptr.h" |    20 #include "base/win/scoped_comptr.h" | 
|    21 #include "base/win/windows_version.h" |    21 #include "base/win/windows_version.h" | 
|    22 #include "content/browser/accessibility/browser_accessibility_event_win.h" |    22 #include "content/browser/accessibility/browser_accessibility_event_win.h" | 
|    23 #include "content/browser/accessibility/browser_accessibility_manager_win.h" |    23 #include "content/browser/accessibility/browser_accessibility_manager_win.h" | 
|    24 #include "content/browser/accessibility/browser_accessibility_state_impl.h" |    24 #include "content/browser/accessibility/browser_accessibility_state_impl.h" | 
|    25 #include "content/browser/accessibility/browser_accessibility_win.h" |    25 #include "content/browser/accessibility/browser_accessibility_win.h" | 
|    26 #include "content/common/accessibility_messages.h" |    26 #include "content/common/accessibility_messages.h" | 
|    27 #include "content/common/accessibility_mode.h" |    27 #include "content/common/accessibility_mode.h" | 
|    28 #include "content/public/common/content_client.h" |    28 #include "content/public/common/content_client.h" | 
|    29 #include "third_party/skia/include/core/SkColor.h" |    29 #include "third_party/skia/include/core/SkColor.h" | 
 |    30 #include "ui/accessibility/ax_role_properties.h" | 
|    30 #include "ui/accessibility/ax_text_utils.h" |    31 #include "ui/accessibility/ax_text_utils.h" | 
|    31 #include "ui/base/win/accessibility_ids_win.h" |    32 #include "ui/base/win/accessibility_ids_win.h" | 
|    32 #include "ui/base/win/accessibility_misc_utils.h" |    33 #include "ui/base/win/accessibility_misc_utils.h" | 
|    33 #include "ui/base/win/atl_module.h" |    34 #include "ui/base/win/atl_module.h" | 
|    34  |    35  | 
|    35 namespace { |    36 namespace { | 
|    36  |    37  | 
|    37 // IMPORTANT! |    38 // IMPORTANT! | 
|    38 // These values are written to logs.  Do not renumber or delete |    39 // These values are written to logs.  Do not renumber or delete | 
|    39 // existing items; add new entries to the end of the list. |    40 // existing items; add new entries to the end of the list. | 
| (...skipping 3448 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  3488     if (ia_role != ROLE_SYSTEM_GRAPHIC) { |  3489     if (ia_role != ROLE_SYSTEM_GRAPHIC) { | 
|  3489       *object = NULL; |  3490       *object = NULL; | 
|  3490       return E_NOINTERFACE; |  3491       return E_NOINTERFACE; | 
|  3491     } |  3492     } | 
|  3492   } else if (iid == IID_IAccessibleTable || iid == IID_IAccessibleTable2) { |  3493   } else if (iid == IID_IAccessibleTable || iid == IID_IAccessibleTable2) { | 
|  3493     if (ia_role != ROLE_SYSTEM_TABLE) { |  3494     if (ia_role != ROLE_SYSTEM_TABLE) { | 
|  3494       *object = NULL; |  3495       *object = NULL; | 
|  3495       return E_NOINTERFACE; |  3496       return E_NOINTERFACE; | 
|  3496     } |  3497     } | 
|  3497   } else if (iid == IID_IAccessibleTableCell) { |  3498   } else if (iid == IID_IAccessibleTableCell) { | 
|  3498     if (!accessibility->owner()->IsCellOrTableHeaderRole()) { |  3499     if (!ui::IsCellOrTableHeaderRole(accessibility->owner()->GetRole())) { | 
|  3499       *object = NULL; |  3500       *object = NULL; | 
|  3500       return E_NOINTERFACE; |  3501       return E_NOINTERFACE; | 
|  3501     } |  3502     } | 
|  3502   } else if (iid == IID_IAccessibleValue) { |  3503   } else if (iid == IID_IAccessibleValue) { | 
|  3503     if (!accessibility->IsRangeValueSupported()) { |  3504     if (!accessibility->IsRangeValueSupported()) { | 
|  3504       *object = NULL; |  3505       *object = NULL; | 
|  3505       return E_NOINTERFACE; |  3506       return E_NOINTERFACE; | 
|  3506     } |  3507     } | 
|  3507   } else if (iid == IID_ISimpleDOMDocument) { |  3508   } else if (iid == IID_ISimpleDOMDocument) { | 
|  3508     if (ia_role != ROLE_SYSTEM_DOCUMENT) { |  3509     if (ia_role != ROLE_SYSTEM_DOCUMENT) { | 
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  3703       case ui::AX_ARIA_CURRENT_STATE_DATE: |  3704       case ui::AX_ARIA_CURRENT_STATE_DATE: | 
|  3704         win_attributes_->ia2_attributes.push_back(L"current:date"); |  3705         win_attributes_->ia2_attributes.push_back(L"current:date"); | 
|  3705         break; |  3706         break; | 
|  3706       case ui::AX_ARIA_CURRENT_STATE_TIME: |  3707       case ui::AX_ARIA_CURRENT_STATE_TIME: | 
|  3707         win_attributes_->ia2_attributes.push_back(L"current:time"); |  3708         win_attributes_->ia2_attributes.push_back(L"current:time"); | 
|  3708         break; |  3709         break; | 
|  3709     } |  3710     } | 
|  3710   } |  3711   } | 
|  3711  |  3712  | 
|  3712   // Expose table cell index. |  3713   // Expose table cell index. | 
|  3713   if (owner()->IsCellOrTableHeaderRole()) { |  3714   if (ui::IsCellOrTableHeaderRole(owner()->GetRole())) { | 
|  3714     BrowserAccessibility* table = owner()->PlatformGetParent(); |  3715     BrowserAccessibility* table = owner()->PlatformGetParent(); | 
|  3715     while (table && !table->IsTableLikeRole()) |  3716     while (table && !ui::IsTableLikeRole(table->GetRole())) | 
|  3716       table = table->PlatformGetParent(); |  3717       table = table->PlatformGetParent(); | 
|  3717     if (table) { |  3718     if (table) { | 
|  3718       const std::vector<int32_t>& unique_cell_ids = |  3719       const std::vector<int32_t>& unique_cell_ids = | 
|  3719           table->GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS); |  3720           table->GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS); | 
|  3720       for (size_t i = 0; i < unique_cell_ids.size(); ++i) { |  3721       for (size_t i = 0; i < unique_cell_ids.size(); ++i) { | 
|  3721         if (unique_cell_ids[i] == owner()->GetId()) { |  3722         if (unique_cell_ids[i] == owner()->GetId()) { | 
|  3722           win_attributes_->ia2_attributes.push_back( |  3723           win_attributes_->ia2_attributes.push_back( | 
|  3723               base::string16(L"table-cell-index:") + base::IntToString16(i)); |  3724               base::string16(L"table-cell-index:") + base::IntToString16(i)); | 
|  3724         } |  3725         } | 
|  3725       } |  3726       } | 
|  3726     } |  3727     } | 
|  3727   } |  3728   } | 
|  3728  |  3729  | 
|  3729   // Expose aria-colcount and aria-rowcount in a table, grid or treegrid. |  3730   // Expose aria-colcount and aria-rowcount in a table, grid or treegrid. | 
|  3730   if (owner()->IsTableLikeRole()) { |  3731   if (ui::IsTableLikeRole(owner()->GetRole())) { | 
|  3731     IntAttributeToIA2(ui::AX_ATTR_ARIA_COLUMN_COUNT, "colcount"); |  3732     IntAttributeToIA2(ui::AX_ATTR_ARIA_COLUMN_COUNT, "colcount"); | 
|  3732     IntAttributeToIA2(ui::AX_ATTR_ARIA_ROW_COUNT, "rowcount"); |  3733     IntAttributeToIA2(ui::AX_ATTR_ARIA_ROW_COUNT, "rowcount"); | 
|  3733   } |  3734   } | 
|  3734  |  3735  | 
|  3735   // Expose aria-colindex and aria-rowindex in a cell or row. |  3736   // Expose aria-colindex and aria-rowindex in a cell or row. | 
|  3736   if (owner()->IsCellOrTableHeaderRole() || |  3737   if (ui::IsCellOrTableHeaderRole(owner()->GetRole()) || | 
|  3737       owner()->GetRole() == ui::AX_ROLE_ROW) { |  3738       owner()->GetRole() == ui::AX_ROLE_ROW) { | 
|  3738     if (owner()->GetRole() != ui::AX_ROLE_ROW) |  3739     if (owner()->GetRole() != ui::AX_ROLE_ROW) | 
|  3739       IntAttributeToIA2(ui::AX_ATTR_ARIA_CELL_COLUMN_INDEX, "colindex"); |  3740       IntAttributeToIA2(ui::AX_ATTR_ARIA_CELL_COLUMN_INDEX, "colindex"); | 
|  3740     IntAttributeToIA2(ui::AX_ATTR_ARIA_CELL_ROW_INDEX, "rowindex"); |  3741     IntAttributeToIA2(ui::AX_ATTR_ARIA_CELL_ROW_INDEX, "rowindex"); | 
|  3741   } |  3742   } | 
|  3742  |  3743  | 
|  3743   // Expose row or column header sort direction. |  3744   // Expose row or column header sort direction. | 
|  3744   int32_t sort_direction; |  3745   int32_t sort_direction; | 
|  3745   if ((ia_role() == ROLE_SYSTEM_COLUMNHEADER || |  3746   if ((ia_role() == ROLE_SYSTEM_COLUMNHEADER || | 
|  3746        ia_role() == ROLE_SYSTEM_ROWHEADER) && |  3747        ia_role() == ROLE_SYSTEM_ROWHEADER) && | 
| (...skipping 1169 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  4916     if (relation->get_target_ids().empty()) { |  4917     if (relation->get_target_ids().empty()) { | 
|  4917       iter = relations_.erase(iter); |  4918       iter = relations_.erase(iter); | 
|  4918       relation->Release(); |  4919       relation->Release(); | 
|  4919     } else { |  4920     } else { | 
|  4920       ++iter; |  4921       ++iter; | 
|  4921     } |  4922     } | 
|  4922   } |  4923   } | 
|  4923 } |  4924 } | 
|  4924  |  4925  | 
|  4925 void BrowserAccessibilityComWin::UpdateRequiredAttributes() { |  4926 void BrowserAccessibilityComWin::UpdateRequiredAttributes() { | 
|  4926   if (owner()->IsCellOrTableHeaderRole()) { |  4927   if (ui::IsCellOrTableHeaderRole(owner()->GetRole())) { | 
|  4927     // Expose colspan attribute. |  4928     // Expose colspan attribute. | 
|  4928     base::string16 colspan; |  4929     base::string16 colspan; | 
|  4929     if (owner()->GetHtmlAttribute("aria-colspan", &colspan)) { |  4930     if (owner()->GetHtmlAttribute("aria-colspan", &colspan)) { | 
|  4930       SanitizeStringAttributeForIA2(colspan, &colspan); |  4931       SanitizeStringAttributeForIA2(colspan, &colspan); | 
|  4931       win_attributes_->ia2_attributes.push_back(L"colspan:" + colspan); |  4932       win_attributes_->ia2_attributes.push_back(L"colspan:" + colspan); | 
|  4932     } |  4933     } | 
|  4933     // Expose rowspan attribute. |  4934     // Expose rowspan attribute. | 
|  4934     base::string16 rowspan; |  4935     base::string16 rowspan; | 
|  4935     if (owner()->GetHtmlAttribute("aria-rowspan", &rowspan)) { |  4936     if (owner()->GetHtmlAttribute("aria-rowspan", &rowspan)) { | 
|  4936       SanitizeStringAttributeForIA2(rowspan, &rowspan); |  4937       SanitizeStringAttributeForIA2(rowspan, &rowspan); | 
| (...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  5583  |  5584  | 
|  5584 BrowserAccessibilityComWin* ToBrowserAccessibilityComWin( |  5585 BrowserAccessibilityComWin* ToBrowserAccessibilityComWin( | 
|  5585     BrowserAccessibility* obj) { |  5586     BrowserAccessibility* obj) { | 
|  5586   if (!obj || !obj->IsNative()) |  5587   if (!obj || !obj->IsNative()) | 
|  5587     return nullptr; |  5588     return nullptr; | 
|  5588   auto* result = static_cast<BrowserAccessibilityWin*>(obj)->GetCOM(); |  5589   auto* result = static_cast<BrowserAccessibilityWin*>(obj)->GetCOM(); | 
|  5589   return result; |  5590   return result; | 
|  5590 } |  5591 } | 
|  5591  |  5592  | 
|  5592 }  // namespace content |  5593 }  // namespace content | 
| OLD | NEW |