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

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

Issue 10382051: Add initial GTK web accessibility framework (third attempt). (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 7 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 | Annotate | Revision Log
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 "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 return E_INVALIDARG; 128 return E_INVALIDARG;
129 } 129 }
130 130
131 BrowserAccessibilityManager* manager = owner_->manager(); 131 BrowserAccessibilityManager* manager = owner_->manager();
132 BrowserAccessibility* result = 132 BrowserAccessibility* result =
133 manager->GetFromRendererID(target_ids_[target_index]); 133 manager->GetFromRendererID(target_ids_[target_index]);
134 if (!result || !result->instance_active()) 134 if (!result || !result->instance_active())
135 return E_FAIL; 135 return E_FAIL;
136 136
137 *target = static_cast<IAccessible*>( 137 *target = static_cast<IAccessible*>(
138 result->toBrowserAccessibilityWin()->NewReference()); 138 result->ToBrowserAccessibilityWin()->NewReference());
139 return S_OK; 139 return S_OK;
140 } 140 }
141 141
142 STDMETHODIMP BrowserAccessibilityRelation::get_targets( 142 STDMETHODIMP BrowserAccessibilityRelation::get_targets(
143 long max_targets, IUnknown** targets, long* n_targets) { 143 long max_targets, IUnknown** targets, long* n_targets) {
144 if (!targets || !n_targets) 144 if (!targets || !n_targets)
145 return E_INVALIDARG; 145 return E_INVALIDARG;
146 146
147 if (!owner_->instance_active()) 147 if (!owner_->instance_active())
148 return E_FAIL; 148 return E_FAIL;
(...skipping 20 matching lines...) Expand all
169 // 169 //
170 170
171 // static 171 // static
172 BrowserAccessibility* BrowserAccessibility::Create() { 172 BrowserAccessibility* BrowserAccessibility::Create() {
173 CComObject<BrowserAccessibilityWin>* instance; 173 CComObject<BrowserAccessibilityWin>* instance;
174 HRESULT hr = CComObject<BrowserAccessibilityWin>::CreateInstance(&instance); 174 HRESULT hr = CComObject<BrowserAccessibilityWin>::CreateInstance(&instance);
175 DCHECK(SUCCEEDED(hr)); 175 DCHECK(SUCCEEDED(hr));
176 return instance->NewReference(); 176 return instance->NewReference();
177 } 177 }
178 178
179 BrowserAccessibilityWin* BrowserAccessibility::toBrowserAccessibilityWin() { 179 BrowserAccessibilityWin* BrowserAccessibility::ToBrowserAccessibilityWin() {
180 return static_cast<BrowserAccessibilityWin*>(this); 180 return static_cast<BrowserAccessibilityWin*>(this);
181 } 181 }
182 182
183 BrowserAccessibilityWin::BrowserAccessibilityWin() 183 BrowserAccessibilityWin::BrowserAccessibilityWin()
184 : ia_role_(0), 184 : ia_role_(0),
185 ia_state_(0), 185 ia_state_(0),
186 ia2_role_(0), 186 ia2_role_(0),
187 ia2_state_(0), 187 ia2_state_(0),
188 first_time_(true), 188 first_time_(true),
189 old_ia_state_(0) { 189 old_ia_state_(0) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 return S_FALSE; 231 return S_FALSE;
232 } 232 }
233 233
234 BrowserAccessibility* result = BrowserAccessibilityForPoint(point); 234 BrowserAccessibility* result = BrowserAccessibilityForPoint(point);
235 if (result == this) { 235 if (result == this) {
236 // Point is within this object. 236 // Point is within this object.
237 child->vt = VT_I4; 237 child->vt = VT_I4;
238 child->lVal = CHILDID_SELF; 238 child->lVal = CHILDID_SELF;
239 } else { 239 } else {
240 child->vt = VT_DISPATCH; 240 child->vt = VT_DISPATCH;
241 child->pdispVal = result->toBrowserAccessibilityWin()->NewReference(); 241 child->pdispVal = result->ToBrowserAccessibilityWin()->NewReference();
242 } 242 }
243 return S_OK; 243 return S_OK;
244 } 244 }
245 245
246 STDMETHODIMP BrowserAccessibilityWin::accLocation(LONG* x_left, LONG* y_top, 246 STDMETHODIMP BrowserAccessibilityWin::accLocation(LONG* x_left, LONG* y_top,
247 LONG* width, LONG* height, 247 LONG* width, LONG* height,
248 VARIANT var_id) { 248 VARIANT var_id) {
249 if (!instance_active_) 249 if (!instance_active_)
250 return E_FAIL; 250 return E_FAIL;
251 251
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 result = target->GetPreviousSibling(); 300 result = target->GetPreviousSibling();
301 break; 301 break;
302 } 302 }
303 303
304 if (!result) { 304 if (!result) {
305 end->vt = VT_EMPTY; 305 end->vt = VT_EMPTY;
306 return S_FALSE; 306 return S_FALSE;
307 } 307 }
308 308
309 end->vt = VT_DISPATCH; 309 end->vt = VT_DISPATCH;
310 end->pdispVal = result->toBrowserAccessibilityWin()->NewReference(); 310 end->pdispVal = result->ToBrowserAccessibilityWin()->NewReference();
311 return S_OK; 311 return S_OK;
312 } 312 }
313 313
314 STDMETHODIMP BrowserAccessibilityWin::get_accChild(VARIANT var_child, 314 STDMETHODIMP BrowserAccessibilityWin::get_accChild(VARIANT var_child,
315 IDispatch** disp_child) { 315 IDispatch** disp_child) {
316 if (!instance_active_) 316 if (!instance_active_)
317 return E_FAIL; 317 return E_FAIL;
318 318
319 if (!disp_child) 319 if (!disp_child)
320 return E_INVALIDARG; 320 return E_INVALIDARG;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 return S_OK; 458 return S_OK;
459 } 459 }
460 460
461 STDMETHODIMP BrowserAccessibilityWin::get_accParent(IDispatch** disp_parent) { 461 STDMETHODIMP BrowserAccessibilityWin::get_accParent(IDispatch** disp_parent) {
462 if (!instance_active_) 462 if (!instance_active_)
463 return E_FAIL; 463 return E_FAIL;
464 464
465 if (!disp_parent) 465 if (!disp_parent)
466 return E_INVALIDARG; 466 return E_INVALIDARG;
467 467
468 IAccessible* parent = parent_->toBrowserAccessibilityWin(); 468 IAccessible* parent = parent_->ToBrowserAccessibilityWin();
469 if (parent == NULL) { 469 if (parent == NULL) {
470 // This happens if we're the root of the tree; 470 // This happens if we're the root of the tree;
471 // return the IAccessible for the window. 471 // return the IAccessible for the window.
472 parent = manager_->toBrowserAccessibilityManagerWin()-> 472 parent = manager_->ToBrowserAccessibilityManagerWin()->
473 GetParentWindowIAccessible(); 473 GetParentWindowIAccessible();
474 } 474 }
475 475
476 parent->AddRef(); 476 parent->AddRef();
477 *disp_parent = parent; 477 *disp_parent = parent;
478 return S_OK; 478 return S_OK;
479 } 479 }
480 480
481 STDMETHODIMP BrowserAccessibilityWin::get_accRole( 481 STDMETHODIMP BrowserAccessibilityWin::get_accRole(
482 VARIANT var_id, VARIANT* role) { 482 VARIANT var_id, VARIANT* role) {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 if (selected_count == 0) { 559 if (selected_count == 0) {
560 selected->vt = VT_EMPTY; 560 selected->vt = VT_EMPTY;
561 return S_OK; 561 return S_OK;
562 } 562 }
563 563
564 if (selected_count == 1) { 564 if (selected_count == 1) {
565 for (size_t i = 0; i < children_.size(); ++i) { 565 for (size_t i = 0; i < children_.size(); ++i) {
566 if (children_[i]->HasState(WebAccessibility::STATE_SELECTED)) { 566 if (children_[i]->HasState(WebAccessibility::STATE_SELECTED)) {
567 selected->vt = VT_DISPATCH; 567 selected->vt = VT_DISPATCH;
568 selected->pdispVal = 568 selected->pdispVal =
569 children_[i]->toBrowserAccessibilityWin()->NewReference(); 569 children_[i]->ToBrowserAccessibilityWin()->NewReference();
570 return S_OK; 570 return S_OK;
571 } 571 }
572 } 572 }
573 } 573 }
574 574
575 // Multiple items are selected. 575 // Multiple items are selected.
576 base::win::EnumVariant* enum_variant = 576 base::win::EnumVariant* enum_variant =
577 new base::win::EnumVariant(selected_count); 577 new base::win::EnumVariant(selected_count);
578 enum_variant->AddRef(); 578 enum_variant->AddRef();
579 unsigned long index = 0; 579 unsigned long index = 0;
580 for (size_t i = 0; i < children_.size(); ++i) { 580 for (size_t i = 0; i < children_.size(); ++i) {
581 if (children_[i]->HasState(WebAccessibility::STATE_SELECTED)) { 581 if (children_[i]->HasState(WebAccessibility::STATE_SELECTED)) {
582 enum_variant->ItemAt(index)->vt = VT_DISPATCH; 582 enum_variant->ItemAt(index)->vt = VT_DISPATCH;
583 enum_variant->ItemAt(index)->pdispVal = 583 enum_variant->ItemAt(index)->pdispVal =
584 children_[i]->toBrowserAccessibilityWin()->NewReference(); 584 children_[i]->ToBrowserAccessibilityWin()->NewReference();
585 ++index; 585 ++index;
586 } 586 }
587 } 587 }
588 selected->vt = VT_UNKNOWN; 588 selected->vt = VT_UNKNOWN;
589 selected->punkVal = static_cast<IUnknown*>( 589 selected->punkVal = static_cast<IUnknown*>(
590 static_cast<base::win::IUnknownImpl*>(enum_variant)); 590 static_cast<base::win::IUnknownImpl*>(enum_variant));
591 return S_OK; 591 return S_OK;
592 } 592 }
593 593
594 STDMETHODIMP BrowserAccessibilityWin::accSelect( 594 STDMETHODIMP BrowserAccessibilityWin::accSelect(
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
1066 return E_INVALIDARG; 1066 return E_INVALIDARG;
1067 1067
1068 int cell_id_count = static_cast<int>(unique_cell_ids_.size()); 1068 int cell_id_count = static_cast<int>(unique_cell_ids_.size());
1069 if (cell_index < 0) 1069 if (cell_index < 0)
1070 return E_INVALIDARG; 1070 return E_INVALIDARG;
1071 if (cell_index >= cell_id_count) 1071 if (cell_index >= cell_id_count)
1072 return S_FALSE; 1072 return S_FALSE;
1073 1073
1074 int cell_id = unique_cell_ids_[cell_index]; 1074 int cell_id = unique_cell_ids_[cell_index];
1075 BrowserAccessibilityWin* cell = 1075 BrowserAccessibilityWin* cell =
1076 manager_->GetFromRendererID(cell_id)->toBrowserAccessibilityWin(); 1076 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin();
1077 int col_index; 1077 int col_index;
1078 if (cell && 1078 if (cell &&
1079 cell->GetIntAttribute( 1079 cell->GetIntAttribute(
1080 WebAccessibility::ATTR_TABLE_CELL_COLUMN_INDEX, &col_index)) { 1080 WebAccessibility::ATTR_TABLE_CELL_COLUMN_INDEX, &col_index)) {
1081 *column_index = col_index; 1081 *column_index = col_index;
1082 return S_OK; 1082 return S_OK;
1083 } 1083 }
1084 1084
1085 return S_FALSE; 1085 return S_FALSE;
1086 } 1086 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 rows <= 0) { 1173 rows <= 0) {
1174 return S_FALSE; 1174 return S_FALSE;
1175 } 1175 }
1176 1176
1177 if (row < 0 || row >= rows) 1177 if (row < 0 || row >= rows)
1178 return E_INVALIDARG; 1178 return E_INVALIDARG;
1179 1179
1180 for (int i = 0; i < columns; ++i) { 1180 for (int i = 0; i < columns; ++i) {
1181 int cell_id = cell_ids_[row * columns + i]; 1181 int cell_id = cell_ids_[row * columns + i];
1182 BrowserAccessibilityWin* cell = 1182 BrowserAccessibilityWin* cell =
1183 manager_->GetFromRendererID(cell_id)->toBrowserAccessibilityWin(); 1183 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin();
1184 if (cell && cell->role_ == WebAccessibility::ROLE_ROW_HEADER) { 1184 if (cell && cell->role_ == WebAccessibility::ROLE_ROW_HEADER) {
1185 if (cell->name_.size() > 0) { 1185 if (cell->name_.size() > 0) {
1186 *description = SysAllocString(cell->name_.c_str()); 1186 *description = SysAllocString(cell->name_.c_str());
1187 return S_OK; 1187 return S_OK;
1188 } 1188 }
1189 1189
1190 return cell->GetStringAttributeAsBstr( 1190 return cell->GetStringAttributeAsBstr(
1191 WebAccessibility::ATTR_DESCRIPTION, description); 1191 WebAccessibility::ATTR_DESCRIPTION, description);
1192 } 1192 }
1193 } 1193 }
(...skipping 18 matching lines...) Expand all
1212 columns <= 0 || 1212 columns <= 0 ||
1213 rows <= 0) { 1213 rows <= 0) {
1214 return S_FALSE; 1214 return S_FALSE;
1215 } 1215 }
1216 1216
1217 if (row < 0 || row >= rows || column < 0 || column >= columns) 1217 if (row < 0 || row >= rows || column < 0 || column >= columns)
1218 return E_INVALIDARG; 1218 return E_INVALIDARG;
1219 1219
1220 int cell_id = cell_ids_[row * columns + column]; 1220 int cell_id = cell_ids_[row * columns + column];
1221 BrowserAccessibilityWin* cell = 1221 BrowserAccessibilityWin* cell =
1222 manager_->GetFromRendererID(cell_id)->toBrowserAccessibilityWin(); 1222 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin();
1223 int rowspan; 1223 int rowspan;
1224 if (cell && 1224 if (cell &&
1225 cell->GetIntAttribute( 1225 cell->GetIntAttribute(
1226 WebAccessibility::ATTR_TABLE_CELL_ROW_SPAN, &rowspan) && 1226 WebAccessibility::ATTR_TABLE_CELL_ROW_SPAN, &rowspan) &&
1227 rowspan >= 1) { 1227 rowspan >= 1) {
1228 *n_rows_spanned = rowspan; 1228 *n_rows_spanned = rowspan;
1229 return S_OK; 1229 return S_OK;
1230 } 1230 }
1231 1231
1232 return S_FALSE; 1232 return S_FALSE;
(...skipping 16 matching lines...) Expand all
1249 return E_INVALIDARG; 1249 return E_INVALIDARG;
1250 1250
1251 int cell_id_count = static_cast<int>(unique_cell_ids_.size()); 1251 int cell_id_count = static_cast<int>(unique_cell_ids_.size());
1252 if (cell_index < 0) 1252 if (cell_index < 0)
1253 return E_INVALIDARG; 1253 return E_INVALIDARG;
1254 if (cell_index >= cell_id_count) 1254 if (cell_index >= cell_id_count)
1255 return S_FALSE; 1255 return S_FALSE;
1256 1256
1257 int cell_id = unique_cell_ids_[cell_index]; 1257 int cell_id = unique_cell_ids_[cell_index];
1258 BrowserAccessibilityWin* cell = 1258 BrowserAccessibilityWin* cell =
1259 manager_->GetFromRendererID(cell_id)->toBrowserAccessibilityWin(); 1259 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin();
1260 int cell_row_index; 1260 int cell_row_index;
1261 if (cell && 1261 if (cell &&
1262 cell->GetIntAttribute( 1262 cell->GetIntAttribute(
1263 WebAccessibility::ATTR_TABLE_CELL_ROW_INDEX, &cell_row_index)) { 1263 WebAccessibility::ATTR_TABLE_CELL_ROW_INDEX, &cell_row_index)) {
1264 *row_index = cell_row_index; 1264 *row_index = cell_row_index;
1265 return S_OK; 1265 return S_OK;
1266 } 1266 }
1267 1267
1268 return S_FALSE; 1268 return S_FALSE;
1269 } 1269 }
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1382 return E_INVALIDARG; 1382 return E_INVALIDARG;
1383 1383
1384 int cell_id_count = static_cast<int>(unique_cell_ids_.size()); 1384 int cell_id_count = static_cast<int>(unique_cell_ids_.size());
1385 if (index < 0) 1385 if (index < 0)
1386 return E_INVALIDARG; 1386 return E_INVALIDARG;
1387 if (index >= cell_id_count) 1387 if (index >= cell_id_count)
1388 return S_FALSE; 1388 return S_FALSE;
1389 1389
1390 int cell_id = unique_cell_ids_[index]; 1390 int cell_id = unique_cell_ids_[index];
1391 BrowserAccessibilityWin* cell = 1391 BrowserAccessibilityWin* cell =
1392 manager_->GetFromRendererID(cell_id)->toBrowserAccessibilityWin(); 1392 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin();
1393 int rowspan; 1393 int rowspan;
1394 int colspan; 1394 int colspan;
1395 if (cell && 1395 if (cell &&
1396 cell->GetIntAttribute( 1396 cell->GetIntAttribute(
1397 WebAccessibility::ATTR_TABLE_CELL_ROW_SPAN, &rowspan) && 1397 WebAccessibility::ATTR_TABLE_CELL_ROW_SPAN, &rowspan) &&
1398 cell->GetIntAttribute( 1398 cell->GetIntAttribute(
1399 WebAccessibility::ATTR_TABLE_CELL_COLUMN_SPAN, &colspan) && 1399 WebAccessibility::ATTR_TABLE_CELL_COLUMN_SPAN, &colspan) &&
1400 rowspan >= 1 && 1400 rowspan >= 1 &&
1401 colspan >= 1) { 1401 colspan >= 1) {
1402 *row_extents = rowspan; 1402 *row_extents = rowspan;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1520 !table->GetIntAttribute( 1520 !table->GetIntAttribute(
1521 WebAccessibility::ATTR_TABLE_ROW_COUNT, &rows)) { 1521 WebAccessibility::ATTR_TABLE_ROW_COUNT, &rows)) {
1522 return S_FALSE; 1522 return S_FALSE;
1523 } 1523 }
1524 if (columns <= 0 || rows <= 0 || column < 0 || column >= columns) 1524 if (columns <= 0 || rows <= 0 || column < 0 || column >= columns)
1525 return S_FALSE; 1525 return S_FALSE;
1526 1526
1527 for (int i = 0; i < rows; ++i) { 1527 for (int i = 0; i < rows; ++i) {
1528 int cell_id = table->cell_ids()[i * columns + column]; 1528 int cell_id = table->cell_ids()[i * columns + column];
1529 BrowserAccessibilityWin* cell = 1529 BrowserAccessibilityWin* cell =
1530 manager_->GetFromRendererID(cell_id)->toBrowserAccessibilityWin(); 1530 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin();
1531 if (cell && cell->role_ == WebAccessibility::ROLE_COLUMN_HEADER) 1531 if (cell && cell->role_ == WebAccessibility::ROLE_COLUMN_HEADER)
1532 (*n_column_header_cells)++; 1532 (*n_column_header_cells)++;
1533 } 1533 }
1534 1534
1535 *cell_accessibles = static_cast<IUnknown**>(CoTaskMemAlloc( 1535 *cell_accessibles = static_cast<IUnknown**>(CoTaskMemAlloc(
1536 (*n_column_header_cells) * sizeof(cell_accessibles[0]))); 1536 (*n_column_header_cells) * sizeof(cell_accessibles[0])));
1537 int index = 0; 1537 int index = 0;
1538 for (int i = 0; i < rows; ++i) { 1538 for (int i = 0; i < rows; ++i) {
1539 int cell_id = table->cell_ids()[i * columns + column]; 1539 int cell_id = table->cell_ids()[i * columns + column];
1540 BrowserAccessibilityWin* cell = 1540 BrowserAccessibilityWin* cell =
1541 manager_->GetFromRendererID(cell_id)->toBrowserAccessibilityWin(); 1541 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin();
1542 if (cell && cell->role_ == WebAccessibility::ROLE_COLUMN_HEADER) { 1542 if (cell && cell->role_ == WebAccessibility::ROLE_COLUMN_HEADER) {
1543 (*cell_accessibles)[index] = 1543 (*cell_accessibles)[index] =
1544 static_cast<IAccessible*>(cell->NewReference()); 1544 static_cast<IAccessible*>(cell->NewReference());
1545 ++index; 1545 ++index;
1546 } 1546 }
1547 } 1547 }
1548 1548
1549 return S_OK; 1549 return S_OK;
1550 } 1550 }
1551 1551
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1618 !table->GetIntAttribute( 1618 !table->GetIntAttribute(
1619 WebAccessibility::ATTR_TABLE_ROW_COUNT, &rows)) { 1619 WebAccessibility::ATTR_TABLE_ROW_COUNT, &rows)) {
1620 return S_FALSE; 1620 return S_FALSE;
1621 } 1621 }
1622 if (columns <= 0 || rows <= 0 || row < 0 || row >= rows) 1622 if (columns <= 0 || rows <= 0 || row < 0 || row >= rows)
1623 return S_FALSE; 1623 return S_FALSE;
1624 1624
1625 for (int i = 0; i < columns; ++i) { 1625 for (int i = 0; i < columns; ++i) {
1626 int cell_id = table->cell_ids()[row * columns + i]; 1626 int cell_id = table->cell_ids()[row * columns + i];
1627 BrowserAccessibilityWin* cell = 1627 BrowserAccessibilityWin* cell =
1628 manager_->GetFromRendererID(cell_id)->toBrowserAccessibilityWin(); 1628 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin();
1629 if (cell && cell->role_ == WebAccessibility::ROLE_ROW_HEADER) 1629 if (cell && cell->role_ == WebAccessibility::ROLE_ROW_HEADER)
1630 (*n_row_header_cells)++; 1630 (*n_row_header_cells)++;
1631 } 1631 }
1632 1632
1633 *cell_accessibles = static_cast<IUnknown**>(CoTaskMemAlloc( 1633 *cell_accessibles = static_cast<IUnknown**>(CoTaskMemAlloc(
1634 (*n_row_header_cells) * sizeof(cell_accessibles[0]))); 1634 (*n_row_header_cells) * sizeof(cell_accessibles[0])));
1635 int index = 0; 1635 int index = 0;
1636 for (int i = 0; i < columns; ++i) { 1636 for (int i = 0; i < columns; ++i) {
1637 int cell_id = table->cell_ids()[row * columns + i]; 1637 int cell_id = table->cell_ids()[row * columns + i];
1638 BrowserAccessibilityWin* cell = 1638 BrowserAccessibilityWin* cell =
1639 manager_->GetFromRendererID(cell_id)->toBrowserAccessibilityWin(); 1639 manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin();
1640 if (cell && cell->role_ == WebAccessibility::ROLE_ROW_HEADER) { 1640 if (cell && cell->role_ == WebAccessibility::ROLE_ROW_HEADER) {
1641 (*cell_accessibles)[index] = 1641 (*cell_accessibles)[index] =
1642 static_cast<IAccessible*>(cell->NewReference()); 1642 static_cast<IAccessible*>(cell->NewReference());
1643 ++index; 1643 ++index;
1644 } 1644 }
1645 } 1645 }
1646 1646
1647 return S_OK; 1647 return S_OK;
1648 } 1648 }
1649 1649
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1730 1730
1731 BrowserAccessibility* find_table = parent(); 1731 BrowserAccessibility* find_table = parent();
1732 while (find_table && find_table->role() != WebAccessibility::ROLE_TABLE) 1732 while (find_table && find_table->role() != WebAccessibility::ROLE_TABLE)
1733 find_table = find_table->parent(); 1733 find_table = find_table->parent();
1734 if (!find_table) { 1734 if (!find_table) {
1735 NOTREACHED(); 1735 NOTREACHED();
1736 return S_FALSE; 1736 return S_FALSE;
1737 } 1737 }
1738 1738
1739 *table = static_cast<IAccessibleTable*>( 1739 *table = static_cast<IAccessibleTable*>(
1740 find_table->toBrowserAccessibilityWin()->NewReference()); 1740 find_table->ToBrowserAccessibilityWin()->NewReference());
1741 1741
1742 return S_OK; 1742 return S_OK;
1743 } 1743 }
1744 1744
1745 // 1745 //
1746 // IAccessibleText methods. 1746 // IAccessibleText methods.
1747 // 1747 //
1748 1748
1749 STDMETHODIMP BrowserAccessibilityWin::get_nCharacters(LONG* n_characters) { 1749 STDMETHODIMP BrowserAccessibilityWin::get_nCharacters(LONG* n_characters) {
1750 if (!instance_active_) 1750 if (!instance_active_)
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
2088 if (!instance_active_) 2088 if (!instance_active_)
2089 return E_FAIL; 2089 return E_FAIL;
2090 2090
2091 if (!hyperlink || 2091 if (!hyperlink ||
2092 index < 0 || 2092 index < 0 ||
2093 index >= static_cast<long>(hyperlinks_.size())) { 2093 index >= static_cast<long>(hyperlinks_.size())) {
2094 return E_INVALIDARG; 2094 return E_INVALIDARG;
2095 } 2095 }
2096 2096
2097 BrowserAccessibilityWin* child = 2097 BrowserAccessibilityWin* child =
2098 children_[hyperlinks_[index]]->toBrowserAccessibilityWin(); 2098 children_[hyperlinks_[index]]->ToBrowserAccessibilityWin();
2099 *hyperlink = static_cast<IAccessibleHyperlink*>(child->NewReference()); 2099 *hyperlink = static_cast<IAccessibleHyperlink*>(child->NewReference());
2100 return S_OK; 2100 return S_OK;
2101 } 2101 }
2102 2102
2103 STDMETHODIMP BrowserAccessibilityWin::get_hyperlinkIndex( 2103 STDMETHODIMP BrowserAccessibilityWin::get_hyperlinkIndex(
2104 long char_index, 2104 long char_index,
2105 long* hyperlink_index) { 2105 long* hyperlink_index) {
2106 if (!instance_active_) 2106 if (!instance_active_)
2107 return E_FAIL; 2107 return E_FAIL;
2108 2108
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
2390 IA2_SCROLL_TYPE_ANYWHERE); 2390 IA2_SCROLL_TYPE_ANYWHERE);
2391 } 2391 }
2392 2392
2393 STDMETHODIMP BrowserAccessibilityWin::get_parentNode(ISimpleDOMNode** node) { 2393 STDMETHODIMP BrowserAccessibilityWin::get_parentNode(ISimpleDOMNode** node) {
2394 if (!instance_active_) 2394 if (!instance_active_)
2395 return E_FAIL; 2395 return E_FAIL;
2396 2396
2397 if (!node) 2397 if (!node)
2398 return E_INVALIDARG; 2398 return E_INVALIDARG;
2399 2399
2400 *node = parent_->toBrowserAccessibilityWin()->NewReference(); 2400 *node = parent_->ToBrowserAccessibilityWin()->NewReference();
2401 return S_OK; 2401 return S_OK;
2402 } 2402 }
2403 2403
2404 STDMETHODIMP BrowserAccessibilityWin::get_firstChild(ISimpleDOMNode** node) { 2404 STDMETHODIMP BrowserAccessibilityWin::get_firstChild(ISimpleDOMNode** node) {
2405 if (!instance_active_) 2405 if (!instance_active_)
2406 return E_FAIL; 2406 return E_FAIL;
2407 2407
2408 if (!node) 2408 if (!node)
2409 return E_INVALIDARG; 2409 return E_INVALIDARG;
2410 2410
2411 if (children_.size()) { 2411 if (children_.size()) {
2412 *node = children_[0]->toBrowserAccessibilityWin()->NewReference(); 2412 *node = children_[0]->ToBrowserAccessibilityWin()->NewReference();
2413 return S_OK; 2413 return S_OK;
2414 } else { 2414 } else {
2415 *node = NULL; 2415 *node = NULL;
2416 return S_FALSE; 2416 return S_FALSE;
2417 } 2417 }
2418 } 2418 }
2419 2419
2420 STDMETHODIMP BrowserAccessibilityWin::get_lastChild(ISimpleDOMNode** node) { 2420 STDMETHODIMP BrowserAccessibilityWin::get_lastChild(ISimpleDOMNode** node) {
2421 if (!instance_active_) 2421 if (!instance_active_)
2422 return E_FAIL; 2422 return E_FAIL;
2423 2423
2424 if (!node) 2424 if (!node)
2425 return E_INVALIDARG; 2425 return E_INVALIDARG;
2426 2426
2427 if (children_.size()) { 2427 if (children_.size()) {
2428 *node = children_[children_.size() - 1]->toBrowserAccessibilityWin()-> 2428 *node = children_[children_.size() - 1]->ToBrowserAccessibilityWin()->
2429 NewReference(); 2429 NewReference();
2430 return S_OK; 2430 return S_OK;
2431 } else { 2431 } else {
2432 *node = NULL; 2432 *node = NULL;
2433 return S_FALSE; 2433 return S_FALSE;
2434 } 2434 }
2435 } 2435 }
2436 2436
2437 STDMETHODIMP BrowserAccessibilityWin::get_previousSibling( 2437 STDMETHODIMP BrowserAccessibilityWin::get_previousSibling(
2438 ISimpleDOMNode** node) { 2438 ISimpleDOMNode** node) {
2439 if (!instance_active_) 2439 if (!instance_active_)
2440 return E_FAIL; 2440 return E_FAIL;
2441 2441
2442 if (!node) 2442 if (!node)
2443 return E_INVALIDARG; 2443 return E_INVALIDARG;
2444 2444
2445 if (parent_ && index_in_parent_ > 0) { 2445 if (parent_ && index_in_parent_ > 0) {
2446 *node = parent_->children()[index_in_parent_ - 1]-> 2446 *node = parent_->children()[index_in_parent_ - 1]->
2447 toBrowserAccessibilityWin()->NewReference(); 2447 ToBrowserAccessibilityWin()->NewReference();
2448 return S_OK; 2448 return S_OK;
2449 } else { 2449 } else {
2450 *node = NULL; 2450 *node = NULL;
2451 return S_FALSE; 2451 return S_FALSE;
2452 } 2452 }
2453 } 2453 }
2454 2454
2455 STDMETHODIMP BrowserAccessibilityWin::get_nextSibling(ISimpleDOMNode** node) { 2455 STDMETHODIMP BrowserAccessibilityWin::get_nextSibling(ISimpleDOMNode** node) {
2456 if (!instance_active_) 2456 if (!instance_active_)
2457 return E_FAIL; 2457 return E_FAIL;
2458 2458
2459 if (!node) 2459 if (!node)
2460 return E_INVALIDARG; 2460 return E_INVALIDARG;
2461 2461
2462 if (parent_ && 2462 if (parent_ &&
2463 index_in_parent_ >= 0 && 2463 index_in_parent_ >= 0 &&
2464 index_in_parent_ < static_cast<int>(parent_->children().size()) - 1) { 2464 index_in_parent_ < static_cast<int>(parent_->children().size()) - 1) {
2465 *node = parent_->children()[index_in_parent_ + 1]-> 2465 *node = parent_->children()[index_in_parent_ + 1]->
2466 toBrowserAccessibilityWin()->NewReference(); 2466 ToBrowserAccessibilityWin()->NewReference();
2467 return S_OK; 2467 return S_OK;
2468 } else { 2468 } else {
2469 *node = NULL; 2469 *node = NULL;
2470 return S_FALSE; 2470 return S_FALSE;
2471 } 2471 }
2472 } 2472 }
2473 2473
2474 STDMETHODIMP BrowserAccessibilityWin::get_childAt( 2474 STDMETHODIMP BrowserAccessibilityWin::get_childAt(
2475 unsigned int child_index, 2475 unsigned int child_index,
2476 ISimpleDOMNode** node) { 2476 ISimpleDOMNode** node) {
2477 if (!instance_active_) 2477 if (!instance_active_)
2478 return E_FAIL; 2478 return E_FAIL;
2479 2479
2480 if (!node) 2480 if (!node)
2481 return E_INVALIDARG; 2481 return E_INVALIDARG;
2482 2482
2483 if (child_index < children_.size()) { 2483 if (child_index < children_.size()) {
2484 *node = children_[child_index]->toBrowserAccessibilityWin()->NewReference(); 2484 *node = children_[child_index]->ToBrowserAccessibilityWin()->NewReference();
2485 return S_OK; 2485 return S_OK;
2486 } else { 2486 } else {
2487 *node = NULL; 2487 *node = NULL;
2488 return S_FALSE; 2488 return S_FALSE;
2489 } 2489 }
2490 } 2490 }
2491 2491
2492 // 2492 //
2493 // ISimpleDOMText methods. 2493 // ISimpleDOMText methods.
2494 // 2494 //
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
2826 } 2826 }
2827 2827
2828 void BrowserAccessibilityWin::NativeAddReference() { 2828 void BrowserAccessibilityWin::NativeAddReference() {
2829 AddRef(); 2829 AddRef();
2830 } 2830 }
2831 2831
2832 void BrowserAccessibilityWin::NativeReleaseReference() { 2832 void BrowserAccessibilityWin::NativeReleaseReference() {
2833 Release(); 2833 Release();
2834 } 2834 }
2835 2835
2836 bool BrowserAccessibilityWin::IsNative() const {
2837 return true;
2838 }
2839
2836 BrowserAccessibilityWin* BrowserAccessibilityWin::NewReference() { 2840 BrowserAccessibilityWin* BrowserAccessibilityWin::NewReference() {
2837 AddRef(); 2841 AddRef();
2838 return this; 2842 return this;
2839 } 2843 }
2840 2844
2841 BrowserAccessibilityWin* BrowserAccessibilityWin::GetTargetFromChildID( 2845 BrowserAccessibilityWin* BrowserAccessibilityWin::GetTargetFromChildID(
2842 const VARIANT& var_id) { 2846 const VARIANT& var_id) {
2843 if (var_id.vt != VT_I4) 2847 if (var_id.vt != VT_I4)
2844 return NULL; 2848 return NULL;
2845 2849
2846 LONG child_id = var_id.lVal; 2850 LONG child_id = var_id.lVal;
2847 if (child_id == CHILDID_SELF) 2851 if (child_id == CHILDID_SELF)
2848 return this; 2852 return this;
2849 2853
2850 if (child_id >= 1 && child_id <= static_cast<LONG>(children_.size())) 2854 if (child_id >= 1 && child_id <= static_cast<LONG>(children_.size()))
2851 return children_[child_id - 1]->toBrowserAccessibilityWin(); 2855 return children_[child_id - 1]->ToBrowserAccessibilityWin();
2852 2856
2853 return manager_->GetFromChildID(child_id)->toBrowserAccessibilityWin(); 2857 return manager_->GetFromChildID(child_id)->ToBrowserAccessibilityWin();
2854 } 2858 }
2855 2859
2856 HRESULT BrowserAccessibilityWin::GetStringAttributeAsBstr( 2860 HRESULT BrowserAccessibilityWin::GetStringAttributeAsBstr(
2857 WebAccessibility::StringAttribute attribute, BSTR* value_bstr) { 2861 WebAccessibility::StringAttribute attribute, BSTR* value_bstr) {
2858 string16 str; 2862 string16 str;
2859 2863
2860 if (!GetStringAttribute(attribute, &str)) 2864 if (!GetStringAttribute(attribute, &str))
2861 return S_FALSE; 2865 return S_FALSE;
2862 2866
2863 if (str.empty()) 2867 if (str.empty())
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
2937 LONG start_offset, 2941 LONG start_offset,
2938 ui::TextBoundaryDirection direction) { 2942 ui::TextBoundaryDirection direction) {
2939 HandleSpecialTextOffset(text, &start_offset); 2943 HandleSpecialTextOffset(text, &start_offset);
2940 ui::TextBoundaryType boundary = IA2TextBoundaryToTextBoundary(ia2_boundary); 2944 ui::TextBoundaryType boundary = IA2TextBoundaryToTextBoundary(ia2_boundary);
2941 return ui::FindAccessibleTextBoundary( 2945 return ui::FindAccessibleTextBoundary(
2942 text, line_breaks_, boundary, start_offset, direction); 2946 text, line_breaks_, boundary, start_offset, direction);
2943 } 2947 }
2944 2948
2945 BrowserAccessibilityWin* BrowserAccessibilityWin::GetFromRendererID( 2949 BrowserAccessibilityWin* BrowserAccessibilityWin::GetFromRendererID(
2946 int32 renderer_id) { 2950 int32 renderer_id) {
2947 return manager_->GetFromRendererID(renderer_id)->toBrowserAccessibilityWin(); 2951 return manager_->GetFromRendererID(renderer_id)->ToBrowserAccessibilityWin();
2948 } 2952 }
2949 2953
2950 void BrowserAccessibilityWin::InitRoleAndState() { 2954 void BrowserAccessibilityWin::InitRoleAndState() {
2951 ia_state_ = 0; 2955 ia_state_ = 0;
2952 ia2_state_ = IA2_STATE_OPAQUE; 2956 ia2_state_ = IA2_STATE_OPAQUE;
2953 ia2_attributes_.clear(); 2957 ia2_attributes_.clear();
2954 2958
2955 if (HasState(WebAccessibility::STATE_BUSY)) 2959 if (HasState(WebAccessibility::STATE_BUSY))
2956 ia_state_|= STATE_SYSTEM_BUSY; 2960 ia_state_|= STATE_SYSTEM_BUSY;
2957 if (HasState(WebAccessibility::STATE_CHECKED)) 2961 if (HasState(WebAccessibility::STATE_CHECKED))
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
3383 } 3387 }
3384 3388
3385 // The role should always be set. 3389 // The role should always be set.
3386 DCHECK(!role_name_.empty() || ia_role_); 3390 DCHECK(!role_name_.empty() || ia_role_);
3387 3391
3388 // If we didn't explicitly set the IAccessible2 role, make it the same 3392 // If we didn't explicitly set the IAccessible2 role, make it the same
3389 // as the MSAA role. 3393 // as the MSAA role.
3390 if (!ia2_role_) 3394 if (!ia2_role_)
3391 ia2_role_ = ia_role_; 3395 ia2_role_ = ia_role_;
3392 } 3396 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698