Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(615)

Side by Side Diff: content/browser/accessibility/browser_accessibility_win.cc

Issue 2054393002: Implemented IAccessible2 reverse relations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/browser_accessibility_win.h" 5 #include "content/browser/accessibility/browser_accessibility_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>
(...skipping 3508 matching lines...) Expand 10 before | Expand all | Expand 10 after
3519 // attribute. This allows screen readers to read an empty link's destination. 3519 // attribute. This allows screen readers to read an empty link's destination.
3520 if (value.empty() && (ia_state() & STATE_SYSTEM_LINKED)) 3520 if (value.empty() && (ia_state() & STATE_SYSTEM_LINKED))
3521 value = GetString16Attribute(ui::AX_ATTR_URL); 3521 value = GetString16Attribute(ui::AX_ATTR_URL);
3522 win_attributes_->value = value; 3522 win_attributes_->value = value;
3523 3523
3524 // Clear any old relationships between this node and other nodes. 3524 // Clear any old relationships between this node and other nodes.
3525 for (size_t i = 0; i < relations_.size(); ++i) 3525 for (size_t i = 0; i < relations_.size(); ++i)
3526 relations_[i]->Release(); 3526 relations_[i]->Release();
3527 relations_.clear(); 3527 relations_.clear();
3528 3528
3529 // Handle title UI element. 3529 AddBidirectionalRelations(IA2_RELATION_CONTROLLER_FOR,
3530 AddRelations(ui::AX_ATTR_CONTROLS_IDS, IA2_RELATION_CONTROLLER_FOR); 3530 IA2_RELATION_CONTROLLED_BY,
3531 AddRelations(ui::AX_ATTR_DESCRIBEDBY_IDS, IA2_RELATION_DESCRIBED_BY); 3531 ui::AX_ATTR_CONTROLS_IDS);
3532 AddRelations(ui::AX_ATTR_FLOWTO_IDS, IA2_RELATION_FLOWS_TO); 3532 AddBidirectionalRelations(IA2_RELATION_DESCRIBED_BY,
3533 AddRelations(ui::AX_ATTR_LABELLEDBY_IDS, IA2_RELATION_LABELLED_BY); 3533 IA2_RELATION_DESCRIPTION_FOR,
3534 ui::AX_ATTR_DESCRIBEDBY_IDS);
3535 AddBidirectionalRelations(IA2_RELATION_FLOWS_TO, IA2_RELATION_FLOWS_FROM,
3536 ui::AX_ATTR_FLOWTO_IDS);
3537 AddBidirectionalRelations(IA2_RELATION_LABELLED_BY, IA2_RELATION_LABEL_FOR,
3538 ui::AX_ATTR_LABELLEDBY_IDS);
3539
3540 int member_of_id;
3541 if (GetIntAttribute(ui::AX_ATTR_MEMBER_OF_ID, &member_of_id))
3542 AddRelation(IA2_RELATION_MEMBER_OF, member_of_id);
3534 3543
3535 UpdateRequiredAttributes(); 3544 UpdateRequiredAttributes();
3536 // If this is a web area for a presentational iframe, give it a role of 3545 // If this is a web area for a presentational iframe, give it a role of
3537 // something other than DOCUMENT so that the fact that it's a separate doc 3546 // something other than DOCUMENT so that the fact that it's a separate doc
3538 // is not exposed to AT. 3547 // is not exposed to AT.
3539 if (IsWebAreaForPresentationalIframe()) { 3548 if (IsWebAreaForPresentationalIframe()) {
3540 win_attributes_->ia_role = ROLE_SYSTEM_GROUPING; 3549 win_attributes_->ia_role = ROLE_SYSTEM_GROUPING;
3541 win_attributes_->ia2_role = ROLE_SYSTEM_GROUPING; 3550 win_attributes_->ia2_role = ROLE_SYSTEM_GROUPING;
3542 } 3551 }
3543 } 3552 }
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after
4429 } 4438 }
4430 4439
4431 if (role == ui::AX_ROLE_MENU_LIST_OPTION && 4440 if (role == ui::AX_ROLE_MENU_LIST_OPTION &&
4432 parent_role == ui::AX_ROLE_MENU_LIST_POPUP) { 4441 parent_role == ui::AX_ROLE_MENU_LIST_POPUP) {
4433 return true; 4442 return true;
4434 } 4443 }
4435 4444
4436 return false; 4445 return false;
4437 } 4446 }
4438 4447
4439 void BrowserAccessibilityWin::AddRelations( 4448 void BrowserAccessibilityWin::AddRelation(const base::string16& relation_type,
4440 ui::AXIntListAttribute src_attr, 4449 int target_id) {
4441 const base::string16& iaccessiblerelation_type) { 4450 CComObject<BrowserAccessibilityRelation>* relation;
4442 if (!HasIntListAttribute(src_attr)) 4451 HRESULT hr =
4452 CComObject<BrowserAccessibilityRelation>::CreateInstance(&relation);
4453 DCHECK(SUCCEEDED(hr));
4454 relation->AddRef();
4455 relation->Initialize(this, relation_type);
4456 relation->AddTarget(target_id);
4457 relations_.push_back(relation);
4458 }
4459
4460 void BrowserAccessibilityWin::AddBidirectionalRelations(
4461 const base::string16& relation_type,
4462 const base::string16& reverse_relation_type,
4463 ui::AXIntListAttribute attribute) {
4464 if (!HasIntListAttribute(attribute))
4443 return; 4465 return;
4444 4466
4445 const std::vector<int32_t>& ids = GetIntListAttribute(src_attr); 4467 for (int target_id : GetIntListAttribute(attribute)) {
4446 for (size_t i = 0; i < ids.size(); ++i) { 4468 BrowserAccessibilityWin* target =
4469 GetFromID(static_cast<int32_t>(target_id));
4470 if (!target || !target->instance_active())
4471 continue;
4447 CComObject<BrowserAccessibilityRelation>* relation; 4472 CComObject<BrowserAccessibilityRelation>* relation;
4448 HRESULT hr = 4473 HRESULT hr =
4449 CComObject<BrowserAccessibilityRelation>::CreateInstance(&relation); 4474 CComObject<BrowserAccessibilityRelation>::CreateInstance(&relation);
4450 DCHECK(SUCCEEDED(hr)); 4475 DCHECK(SUCCEEDED(hr));
4451 relation->AddRef(); 4476 relation->AddRef();
4452 relation->Initialize(this, iaccessiblerelation_type); 4477 relation->Initialize(this, relation_type);
4453 relation->AddTarget(ids[i]); 4478 relation->AddTarget(target_id);
4454 relations_.push_back(relation); 4479 relations_.push_back(relation);
4480 target->AddRelation(reverse_relation_type, target_id);
dmazzoni 2016/06/13 05:41:18 I think this is going to keep adding this reverse
4455 } 4481 }
4456 } 4482 }
4457 4483
4458 void BrowserAccessibilityWin::UpdateRequiredAttributes() { 4484 void BrowserAccessibilityWin::UpdateRequiredAttributes() {
4459 // Expose slider value. 4485 // Expose slider value.
4460 if (ia_role() == ROLE_SYSTEM_PROGRESSBAR || 4486 if (ia_role() == ROLE_SYSTEM_PROGRESSBAR ||
4461 ia_role() == ROLE_SYSTEM_SCROLLBAR || 4487 ia_role() == ROLE_SYSTEM_SCROLLBAR ||
4462 ia_role() == ROLE_SYSTEM_SLIDER) { 4488 ia_role() == ROLE_SYSTEM_SLIDER) {
4463 base::string16 value_text = GetValueText(); 4489 base::string16 value_text = GetValueText();
4464 SanitizeStringAttributeForIA2(value_text, &value_text); 4490 SanitizeStringAttributeForIA2(value_text, &value_text);
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after
5088 return static_cast<BrowserAccessibilityWin*>(obj); 5114 return static_cast<BrowserAccessibilityWin*>(obj);
5089 } 5115 }
5090 5116
5091 const BrowserAccessibilityWin* 5117 const BrowserAccessibilityWin*
5092 ToBrowserAccessibilityWin(const BrowserAccessibility* obj) { 5118 ToBrowserAccessibilityWin(const BrowserAccessibility* obj) {
5093 DCHECK(!obj || obj->IsNative()); 5119 DCHECK(!obj || obj->IsNative());
5094 return static_cast<const BrowserAccessibilityWin*>(obj); 5120 return static_cast<const BrowserAccessibilityWin*>(obj);
5095 } 5121 }
5096 5122
5097 } // namespace content 5123 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698