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

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

Issue 10379029: Revert 135593 - Add initial GTK web accessibility framework (new with valgrind fix). (Closed) Base URL: svn://svn.chromium.org/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* BrowserAccessibilityWin::ToBrowserAccessibilityWin() { 179 BrowserAccessibilityWin* BrowserAccessibility::toBrowserAccessibilityWin() {
180 return 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) {
190 } 190 }
(...skipping 40 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; 468 IAccessible* parent = parent_->toBrowserAccessibilityWin();
469 if (parent_) { 469 if (parent == NULL) {
470 parent = parent_->ToBrowserAccessibilityWin();
471 } else {
472 // This happens if we're the root of the tree; 470 // This happens if we're the root of the tree;
473 // return the IAccessible for the window. 471 // return the IAccessible for the window.
474 parent = manager_->ToBrowserAccessibilityManagerWin()-> 472 parent = manager_->toBrowserAccessibilityManagerWin()->
475 GetParentWindowIAccessible(); 473 GetParentWindowIAccessible();
476 } 474 }
477 475
478 parent->AddRef(); 476 parent->AddRef();
479 *disp_parent = parent; 477 *disp_parent = parent;
480 return S_OK; 478 return S_OK;
481 } 479 }
482 480
483 STDMETHODIMP BrowserAccessibilityWin::get_accRole( 481 STDMETHODIMP BrowserAccessibilityWin::get_accRole(
484 VARIANT var_id, VARIANT* role) { 482 VARIANT var_id, VARIANT* role) {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 if (selected_count == 0) { 559 if (selected_count == 0) {
562 selected->vt = VT_EMPTY; 560 selected->vt = VT_EMPTY;
563 return S_OK; 561 return S_OK;
564 } 562 }
565 563
566 if (selected_count == 1) { 564 if (selected_count == 1) {
567 for (size_t i = 0; i < children_.size(); ++i) { 565 for (size_t i = 0; i < children_.size(); ++i) {
568 if (children_[i]->HasState(WebAccessibility::STATE_SELECTED)) { 566 if (children_[i]->HasState(WebAccessibility::STATE_SELECTED)) {
569 selected->vt = VT_DISPATCH; 567 selected->vt = VT_DISPATCH;
570 selected->pdispVal = 568 selected->pdispVal =
571 children_[i]->ToBrowserAccessibilityWin()->NewReference(); 569 children_[i]->toBrowserAccessibilityWin()->NewReference();
572 return S_OK; 570 return S_OK;
573 } 571 }
574 } 572 }
575 } 573 }
576 574
577 // Multiple items are selected. 575 // Multiple items are selected.
578 base::win::EnumVariant* enum_variant = 576 base::win::EnumVariant* enum_variant =
579 new base::win::EnumVariant(selected_count); 577 new base::win::EnumVariant(selected_count);
580 enum_variant->AddRef(); 578 enum_variant->AddRef();
581 unsigned long index = 0; 579 unsigned long index = 0;
582 for (size_t i = 0; i < children_.size(); ++i) { 580 for (size_t i = 0; i < children_.size(); ++i) {
583 if (children_[i]->HasState(WebAccessibility::STATE_SELECTED)) { 581 if (children_[i]->HasState(WebAccessibility::STATE_SELECTED)) {
584 enum_variant->ItemAt(index)->vt = VT_DISPATCH; 582 enum_variant->ItemAt(index)->vt = VT_DISPATCH;
585 enum_variant->ItemAt(index)->pdispVal = 583 enum_variant->ItemAt(index)->pdispVal =
586 children_[i]->ToBrowserAccessibilityWin()->NewReference(); 584 children_[i]->toBrowserAccessibilityWin()->NewReference();
587 ++index; 585 ++index;
588 } 586 }
589 } 587 }
590 selected->vt = VT_UNKNOWN; 588 selected->vt = VT_UNKNOWN;
591 selected->punkVal = static_cast<IUnknown*>( 589 selected->punkVal = static_cast<IUnknown*>(
592 static_cast<base::win::IUnknownImpl*>(enum_variant)); 590 static_cast<base::win::IUnknownImpl*>(enum_variant));
593 return S_OK; 591 return S_OK;
594 } 592 }
595 593
596 STDMETHODIMP BrowserAccessibilityWin::accSelect( 594 STDMETHODIMP BrowserAccessibilityWin::accSelect(
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 if (!column_index) 1065 if (!column_index)
1068 return E_INVALIDARG; 1066 return E_INVALIDARG;
1069 1067
1070 int cell_id_count = static_cast<int>(unique_cell_ids_.size()); 1068 int cell_id_count = static_cast<int>(unique_cell_ids_.size());
1071 if (cell_index < 0) 1069 if (cell_index < 0)
1072 return E_INVALIDARG; 1070 return E_INVALIDARG;
1073 if (cell_index >= cell_id_count) 1071 if (cell_index >= cell_id_count)
1074 return S_FALSE; 1072 return S_FALSE;
1075 1073
1076 int cell_id = unique_cell_ids_[cell_index]; 1074 int cell_id = unique_cell_ids_[cell_index];
1077 BrowserAccessibility* cell = manager_->GetFromRendererID(cell_id); 1075 BrowserAccessibilityWin* cell =
1076 manager_->GetFromRendererID(cell_id)->toBrowserAccessibilityWin();
1078 int col_index; 1077 int col_index;
1079 if (cell && 1078 if (cell &&
1080 cell->GetIntAttribute( 1079 cell->GetIntAttribute(
1081 WebAccessibility::ATTR_TABLE_CELL_COLUMN_INDEX, &col_index)) { 1080 WebAccessibility::ATTR_TABLE_CELL_COLUMN_INDEX, &col_index)) {
1082 *column_index = col_index; 1081 *column_index = col_index;
1083 return S_OK; 1082 return S_OK;
1084 } 1083 }
1085 1084
1086 return S_FALSE; 1085 return S_FALSE;
1087 } 1086 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 columns <= 0 || 1172 columns <= 0 ||
1174 rows <= 0) { 1173 rows <= 0) {
1175 return S_FALSE; 1174 return S_FALSE;
1176 } 1175 }
1177 1176
1178 if (row < 0 || row >= rows) 1177 if (row < 0 || row >= rows)
1179 return E_INVALIDARG; 1178 return E_INVALIDARG;
1180 1179
1181 for (int i = 0; i < columns; ++i) { 1180 for (int i = 0; i < columns; ++i) {
1182 int cell_id = cell_ids_[row * columns + i]; 1181 int cell_id = cell_ids_[row * columns + i];
1183 BrowserAccessibility* cell = manager_->GetFromRendererID(cell_id); 1182 BrowserAccessibilityWin* cell =
1184 if (cell && cell->role() == WebAccessibility::ROLE_ROW_HEADER) { 1183 manager_->GetFromRendererID(cell_id)->toBrowserAccessibilityWin();
1185 if (cell->name().size() > 0) { 1184 if (cell && cell->role_ == WebAccessibility::ROLE_ROW_HEADER) {
1186 *description = SysAllocString(cell->name().c_str()); 1185 if (cell->name_.size() > 0) {
1186 *description = SysAllocString(cell->name_.c_str());
1187 return S_OK; 1187 return S_OK;
1188 } 1188 }
1189 1189
1190 return cell->ToBrowserAccessibilityWin()->GetStringAttributeAsBstr( 1190 return cell->GetStringAttributeAsBstr(
1191 WebAccessibility::ATTR_DESCRIPTION, description); 1191 WebAccessibility::ATTR_DESCRIPTION, description);
1192 } 1192 }
1193 } 1193 }
1194 1194
1195 return S_FALSE; 1195 return S_FALSE;
1196 } 1196 }
1197 1197
1198 STDMETHODIMP BrowserAccessibilityWin::get_rowExtentAt( 1198 STDMETHODIMP BrowserAccessibilityWin::get_rowExtentAt(
1199 long row, 1199 long row,
1200 long column, 1200 long column,
(...skipping 10 matching lines...) Expand all
1211 !GetIntAttribute(WebAccessibility::ATTR_TABLE_ROW_COUNT, &rows) || 1211 !GetIntAttribute(WebAccessibility::ATTR_TABLE_ROW_COUNT, &rows) ||
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 BrowserAccessibility* cell = manager_->GetFromRendererID(cell_id); 1221 BrowserAccessibilityWin* cell =
1222 manager_->GetFromRendererID(cell_id)->toBrowserAccessibilityWin();
1222 int rowspan; 1223 int rowspan;
1223 if (cell && 1224 if (cell &&
1224 cell->GetIntAttribute( 1225 cell->GetIntAttribute(
1225 WebAccessibility::ATTR_TABLE_CELL_ROW_SPAN, &rowspan) && 1226 WebAccessibility::ATTR_TABLE_CELL_ROW_SPAN, &rowspan) &&
1226 rowspan >= 1) { 1227 rowspan >= 1) {
1227 *n_rows_spanned = rowspan; 1228 *n_rows_spanned = rowspan;
1228 return S_OK; 1229 return S_OK;
1229 } 1230 }
1230 1231
1231 return S_FALSE; 1232 return S_FALSE;
(...skipping 15 matching lines...) Expand all
1247 if (!row_index) 1248 if (!row_index)
1248 return E_INVALIDARG; 1249 return E_INVALIDARG;
1249 1250
1250 int cell_id_count = static_cast<int>(unique_cell_ids_.size()); 1251 int cell_id_count = static_cast<int>(unique_cell_ids_.size());
1251 if (cell_index < 0) 1252 if (cell_index < 0)
1252 return E_INVALIDARG; 1253 return E_INVALIDARG;
1253 if (cell_index >= cell_id_count) 1254 if (cell_index >= cell_id_count)
1254 return S_FALSE; 1255 return S_FALSE;
1255 1256
1256 int cell_id = unique_cell_ids_[cell_index]; 1257 int cell_id = unique_cell_ids_[cell_index];
1257 BrowserAccessibility* cell = manager_->GetFromRendererID(cell_id); 1258 BrowserAccessibilityWin* cell =
1259 manager_->GetFromRendererID(cell_id)->toBrowserAccessibilityWin();
1258 int cell_row_index; 1260 int cell_row_index;
1259 if (cell && 1261 if (cell &&
1260 cell->GetIntAttribute( 1262 cell->GetIntAttribute(
1261 WebAccessibility::ATTR_TABLE_CELL_ROW_INDEX, &cell_row_index)) { 1263 WebAccessibility::ATTR_TABLE_CELL_ROW_INDEX, &cell_row_index)) {
1262 *row_index = cell_row_index; 1264 *row_index = cell_row_index;
1263 return S_OK; 1265 return S_OK;
1264 } 1266 }
1265 1267
1266 return S_FALSE; 1268 return S_FALSE;
1267 } 1269 }
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1379 if (!row || !column || !row_extents || !column_extents || !is_selected) 1381 if (!row || !column || !row_extents || !column_extents || !is_selected)
1380 return E_INVALIDARG; 1382 return E_INVALIDARG;
1381 1383
1382 int cell_id_count = static_cast<int>(unique_cell_ids_.size()); 1384 int cell_id_count = static_cast<int>(unique_cell_ids_.size());
1383 if (index < 0) 1385 if (index < 0)
1384 return E_INVALIDARG; 1386 return E_INVALIDARG;
1385 if (index >= cell_id_count) 1387 if (index >= cell_id_count)
1386 return S_FALSE; 1388 return S_FALSE;
1387 1389
1388 int cell_id = unique_cell_ids_[index]; 1390 int cell_id = unique_cell_ids_[index];
1389 BrowserAccessibility* cell = manager_->GetFromRendererID(cell_id); 1391 BrowserAccessibilityWin* cell =
1392 manager_->GetFromRendererID(cell_id)->toBrowserAccessibilityWin();
1390 int rowspan; 1393 int rowspan;
1391 int colspan; 1394 int colspan;
1392 if (cell && 1395 if (cell &&
1393 cell->GetIntAttribute( 1396 cell->GetIntAttribute(
1394 WebAccessibility::ATTR_TABLE_CELL_ROW_SPAN, &rowspan) && 1397 WebAccessibility::ATTR_TABLE_CELL_ROW_SPAN, &rowspan) &&
1395 cell->GetIntAttribute( 1398 cell->GetIntAttribute(
1396 WebAccessibility::ATTR_TABLE_CELL_COLUMN_SPAN, &colspan) && 1399 WebAccessibility::ATTR_TABLE_CELL_COLUMN_SPAN, &colspan) &&
1397 rowspan >= 1 && 1400 rowspan >= 1 &&
1398 colspan >= 1) { 1401 colspan >= 1) {
1399 *row_extents = rowspan; 1402 *row_extents = rowspan;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1516 WebAccessibility::ATTR_TABLE_COLUMN_COUNT, &columns) || 1519 WebAccessibility::ATTR_TABLE_COLUMN_COUNT, &columns) ||
1517 !table->GetIntAttribute( 1520 !table->GetIntAttribute(
1518 WebAccessibility::ATTR_TABLE_ROW_COUNT, &rows)) { 1521 WebAccessibility::ATTR_TABLE_ROW_COUNT, &rows)) {
1519 return S_FALSE; 1522 return S_FALSE;
1520 } 1523 }
1521 if (columns <= 0 || rows <= 0 || column < 0 || column >= columns) 1524 if (columns <= 0 || rows <= 0 || column < 0 || column >= columns)
1522 return S_FALSE; 1525 return S_FALSE;
1523 1526
1524 for (int i = 0; i < rows; ++i) { 1527 for (int i = 0; i < rows; ++i) {
1525 int cell_id = table->cell_ids()[i * columns + column]; 1528 int cell_id = table->cell_ids()[i * columns + column];
1526 BrowserAccessibility* cell = manager_->GetFromRendererID(cell_id); 1529 BrowserAccessibilityWin* cell =
1527 if (cell && cell->role() == WebAccessibility::ROLE_COLUMN_HEADER) 1530 manager_->GetFromRendererID(cell_id)->toBrowserAccessibilityWin();
1531 if (cell && cell->role_ == WebAccessibility::ROLE_COLUMN_HEADER)
1528 (*n_column_header_cells)++; 1532 (*n_column_header_cells)++;
1529 } 1533 }
1530 1534
1531 *cell_accessibles = static_cast<IUnknown**>(CoTaskMemAlloc( 1535 *cell_accessibles = static_cast<IUnknown**>(CoTaskMemAlloc(
1532 (*n_column_header_cells) * sizeof(cell_accessibles[0]))); 1536 (*n_column_header_cells) * sizeof(cell_accessibles[0])));
1533 int index = 0; 1537 int index = 0;
1534 for (int i = 0; i < rows; ++i) { 1538 for (int i = 0; i < rows; ++i) {
1535 int cell_id = table->cell_ids()[i * columns + column]; 1539 int cell_id = table->cell_ids()[i * columns + column];
1536 BrowserAccessibility* cell = manager_->GetFromRendererID(cell_id); 1540 BrowserAccessibilityWin* cell =
1537 if (cell && cell->role() == WebAccessibility::ROLE_COLUMN_HEADER) { 1541 manager_->GetFromRendererID(cell_id)->toBrowserAccessibilityWin();
1542 if (cell && cell->role_ == WebAccessibility::ROLE_COLUMN_HEADER) {
1538 (*cell_accessibles)[index] = 1543 (*cell_accessibles)[index] =
1539 static_cast<IAccessible*>( 1544 static_cast<IAccessible*>(cell->NewReference());
1540 cell->ToBrowserAccessibilityWin()->NewReference());
1541 ++index; 1545 ++index;
1542 } 1546 }
1543 } 1547 }
1544 1548
1545 return S_OK; 1549 return S_OK;
1546 } 1550 }
1547 1551
1548 STDMETHODIMP BrowserAccessibilityWin::get_columnIndex( 1552 STDMETHODIMP BrowserAccessibilityWin::get_columnIndex(
1549 long* column_index) { 1553 long* column_index) {
1550 if (!instance_active_) 1554 if (!instance_active_)
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1613 WebAccessibility::ATTR_TABLE_COLUMN_COUNT, &columns) || 1617 WebAccessibility::ATTR_TABLE_COLUMN_COUNT, &columns) ||
1614 !table->GetIntAttribute( 1618 !table->GetIntAttribute(
1615 WebAccessibility::ATTR_TABLE_ROW_COUNT, &rows)) { 1619 WebAccessibility::ATTR_TABLE_ROW_COUNT, &rows)) {
1616 return S_FALSE; 1620 return S_FALSE;
1617 } 1621 }
1618 if (columns <= 0 || rows <= 0 || row < 0 || row >= rows) 1622 if (columns <= 0 || rows <= 0 || row < 0 || row >= rows)
1619 return S_FALSE; 1623 return S_FALSE;
1620 1624
1621 for (int i = 0; i < columns; ++i) { 1625 for (int i = 0; i < columns; ++i) {
1622 int cell_id = table->cell_ids()[row * columns + i]; 1626 int cell_id = table->cell_ids()[row * columns + i];
1623 BrowserAccessibility* cell = manager_->GetFromRendererID(cell_id); 1627 BrowserAccessibilityWin* cell =
1624 if (cell && cell->role() == WebAccessibility::ROLE_ROW_HEADER) 1628 manager_->GetFromRendererID(cell_id)->toBrowserAccessibilityWin();
1629 if (cell && cell->role_ == WebAccessibility::ROLE_ROW_HEADER)
1625 (*n_row_header_cells)++; 1630 (*n_row_header_cells)++;
1626 } 1631 }
1627 1632
1628 *cell_accessibles = static_cast<IUnknown**>(CoTaskMemAlloc( 1633 *cell_accessibles = static_cast<IUnknown**>(CoTaskMemAlloc(
1629 (*n_row_header_cells) * sizeof(cell_accessibles[0]))); 1634 (*n_row_header_cells) * sizeof(cell_accessibles[0])));
1630 int index = 0; 1635 int index = 0;
1631 for (int i = 0; i < columns; ++i) { 1636 for (int i = 0; i < columns; ++i) {
1632 int cell_id = table->cell_ids()[row * columns + i]; 1637 int cell_id = table->cell_ids()[row * columns + i];
1633 BrowserAccessibility* cell = manager_->GetFromRendererID(cell_id); 1638 BrowserAccessibilityWin* cell =
1634 if (cell && cell->role() == WebAccessibility::ROLE_ROW_HEADER) { 1639 manager_->GetFromRendererID(cell_id)->toBrowserAccessibilityWin();
1640 if (cell && cell->role_ == WebAccessibility::ROLE_ROW_HEADER) {
1635 (*cell_accessibles)[index] = 1641 (*cell_accessibles)[index] =
1636 static_cast<IAccessible*>( 1642 static_cast<IAccessible*>(cell->NewReference());
1637 cell->ToBrowserAccessibilityWin()->NewReference());
1638 ++index; 1643 ++index;
1639 } 1644 }
1640 } 1645 }
1641 1646
1642 return S_OK; 1647 return S_OK;
1643 } 1648 }
1644 1649
1645 STDMETHODIMP BrowserAccessibilityWin::get_rowIndex( 1650 STDMETHODIMP BrowserAccessibilityWin::get_rowIndex(
1646 long* row_index) { 1651 long* row_index) {
1647 if (!instance_active_) 1652 if (!instance_active_)
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1725 1730
1726 BrowserAccessibility* find_table = parent(); 1731 BrowserAccessibility* find_table = parent();
1727 while (find_table && find_table->role() != WebAccessibility::ROLE_TABLE) 1732 while (find_table && find_table->role() != WebAccessibility::ROLE_TABLE)
1728 find_table = find_table->parent(); 1733 find_table = find_table->parent();
1729 if (!find_table) { 1734 if (!find_table) {
1730 NOTREACHED(); 1735 NOTREACHED();
1731 return S_FALSE; 1736 return S_FALSE;
1732 } 1737 }
1733 1738
1734 *table = static_cast<IAccessibleTable*>( 1739 *table = static_cast<IAccessibleTable*>(
1735 find_table->ToBrowserAccessibilityWin()->NewReference()); 1740 find_table->toBrowserAccessibilityWin()->NewReference());
1736 1741
1737 return S_OK; 1742 return S_OK;
1738 } 1743 }
1739 1744
1740 // 1745 //
1741 // IAccessibleText methods. 1746 // IAccessibleText methods.
1742 // 1747 //
1743 1748
1744 STDMETHODIMP BrowserAccessibilityWin::get_nCharacters(LONG* n_characters) { 1749 STDMETHODIMP BrowserAccessibilityWin::get_nCharacters(LONG* n_characters) {
1745 if (!instance_active_) 1750 if (!instance_active_)
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
2083 if (!instance_active_) 2088 if (!instance_active_)
2084 return E_FAIL; 2089 return E_FAIL;
2085 2090
2086 if (!hyperlink || 2091 if (!hyperlink ||
2087 index < 0 || 2092 index < 0 ||
2088 index >= static_cast<long>(hyperlinks_.size())) { 2093 index >= static_cast<long>(hyperlinks_.size())) {
2089 return E_INVALIDARG; 2094 return E_INVALIDARG;
2090 } 2095 }
2091 2096
2092 BrowserAccessibilityWin* child = 2097 BrowserAccessibilityWin* child =
2093 children_[hyperlinks_[index]]->ToBrowserAccessibilityWin(); 2098 children_[hyperlinks_[index]]->toBrowserAccessibilityWin();
2094 *hyperlink = static_cast<IAccessibleHyperlink*>(child->NewReference()); 2099 *hyperlink = static_cast<IAccessibleHyperlink*>(child->NewReference());
2095 return S_OK; 2100 return S_OK;
2096 } 2101 }
2097 2102
2098 STDMETHODIMP BrowserAccessibilityWin::get_hyperlinkIndex( 2103 STDMETHODIMP BrowserAccessibilityWin::get_hyperlinkIndex(
2099 long char_index, 2104 long char_index,
2100 long* hyperlink_index) { 2105 long* hyperlink_index) {
2101 if (!instance_active_) 2106 if (!instance_active_)
2102 return E_FAIL; 2107 return E_FAIL;
2103 2108
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
2385 IA2_SCROLL_TYPE_ANYWHERE); 2390 IA2_SCROLL_TYPE_ANYWHERE);
2386 } 2391 }
2387 2392
2388 STDMETHODIMP BrowserAccessibilityWin::get_parentNode(ISimpleDOMNode** node) { 2393 STDMETHODIMP BrowserAccessibilityWin::get_parentNode(ISimpleDOMNode** node) {
2389 if (!instance_active_) 2394 if (!instance_active_)
2390 return E_FAIL; 2395 return E_FAIL;
2391 2396
2392 if (!node) 2397 if (!node)
2393 return E_INVALIDARG; 2398 return E_INVALIDARG;
2394 2399
2395 if (!parent_) { 2400 *node = parent_->toBrowserAccessibilityWin()->NewReference();
2396 *node = NULL;
2397 return S_FALSE;
2398 }
2399
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 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
2841 BrowserAccessibilityWin* BrowserAccessibilityWin::GetTargetFromChildID( 2841 BrowserAccessibilityWin* BrowserAccessibilityWin::GetTargetFromChildID(
2842 const VARIANT& var_id) { 2842 const VARIANT& var_id) {
2843 if (var_id.vt != VT_I4) 2843 if (var_id.vt != VT_I4)
2844 return NULL; 2844 return NULL;
2845 2845
2846 LONG child_id = var_id.lVal; 2846 LONG child_id = var_id.lVal;
2847 if (child_id == CHILDID_SELF) 2847 if (child_id == CHILDID_SELF)
2848 return this; 2848 return this;
2849 2849
2850 if (child_id >= 1 && child_id <= static_cast<LONG>(children_.size())) 2850 if (child_id >= 1 && child_id <= static_cast<LONG>(children_.size()))
2851 return children_[child_id - 1]->ToBrowserAccessibilityWin(); 2851 return children_[child_id - 1]->toBrowserAccessibilityWin();
2852 2852
2853 return manager_->GetFromChildID(child_id)->ToBrowserAccessibilityWin(); 2853 return manager_->GetFromChildID(child_id)->toBrowserAccessibilityWin();
2854 } 2854 }
2855 2855
2856 HRESULT BrowserAccessibilityWin::GetStringAttributeAsBstr( 2856 HRESULT BrowserAccessibilityWin::GetStringAttributeAsBstr(
2857 WebAccessibility::StringAttribute attribute, BSTR* value_bstr) { 2857 WebAccessibility::StringAttribute attribute, BSTR* value_bstr) {
2858 string16 str; 2858 string16 str;
2859 2859
2860 if (!GetStringAttribute(attribute, &str)) 2860 if (!GetStringAttribute(attribute, &str))
2861 return S_FALSE; 2861 return S_FALSE;
2862 2862
2863 if (str.empty()) 2863 if (str.empty())
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
2937 LONG start_offset, 2937 LONG start_offset,
2938 ui::TextBoundaryDirection direction) { 2938 ui::TextBoundaryDirection direction) {
2939 HandleSpecialTextOffset(text, &start_offset); 2939 HandleSpecialTextOffset(text, &start_offset);
2940 ui::TextBoundaryType boundary = IA2TextBoundaryToTextBoundary(ia2_boundary); 2940 ui::TextBoundaryType boundary = IA2TextBoundaryToTextBoundary(ia2_boundary);
2941 return ui::FindAccessibleTextBoundary( 2941 return ui::FindAccessibleTextBoundary(
2942 text, line_breaks_, boundary, start_offset, direction); 2942 text, line_breaks_, boundary, start_offset, direction);
2943 } 2943 }
2944 2944
2945 BrowserAccessibilityWin* BrowserAccessibilityWin::GetFromRendererID( 2945 BrowserAccessibilityWin* BrowserAccessibilityWin::GetFromRendererID(
2946 int32 renderer_id) { 2946 int32 renderer_id) {
2947 BrowserAccessibility* result = manager_->GetFromRendererID(renderer_id); 2947 return manager_->GetFromRendererID(renderer_id)->toBrowserAccessibilityWin();
2948 return result ? result->ToBrowserAccessibilityWin() : NULL;
2949 } 2948 }
2950 2949
2951 void BrowserAccessibilityWin::InitRoleAndState() { 2950 void BrowserAccessibilityWin::InitRoleAndState() {
2952 ia_state_ = 0; 2951 ia_state_ = 0;
2953 ia2_state_ = IA2_STATE_OPAQUE; 2952 ia2_state_ = IA2_STATE_OPAQUE;
2954 ia2_attributes_.clear(); 2953 ia2_attributes_.clear();
2955 2954
2956 if (HasState(WebAccessibility::STATE_BUSY)) 2955 if (HasState(WebAccessibility::STATE_BUSY))
2957 ia_state_|= STATE_SYSTEM_BUSY; 2956 ia_state_|= STATE_SYSTEM_BUSY;
2958 if (HasState(WebAccessibility::STATE_CHECKED)) 2957 if (HasState(WebAccessibility::STATE_CHECKED))
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
3384 } 3383 }
3385 3384
3386 // The role should always be set. 3385 // The role should always be set.
3387 DCHECK(!role_name_.empty() || ia_role_); 3386 DCHECK(!role_name_.empty() || ia_role_);
3388 3387
3389 // If we didn't explicitly set the IAccessible2 role, make it the same 3388 // If we didn't explicitly set the IAccessible2 role, make it the same
3390 // as the MSAA role. 3389 // as the MSAA role.
3391 if (!ia2_role_) 3390 if (!ia2_role_)
3392 ia2_role_ = ia_role_; 3391 ia2_role_ = ia_role_;
3393 } 3392 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698