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

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

Issue 1762143002: Use unique IDs for accessibility nodes on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix null obj deref in DCHECK Created 4 years, 9 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 24 matching lines...) Expand all
35 0x11cf, 35 0x11cf,
36 {0xb6, 0x61, 0x00, 0xaa, 0x00, 0x4c, 0xd6, 0xd8}}; 36 {0xb6, 0x61, 0x00, 0xaa, 0x00, 0x4c, 0xd6, 0xd8}};
37 const GUID GUID_IAccessibleContentDocument = { 37 const GUID GUID_IAccessibleContentDocument = {
38 0xa5d8e1f3, 38 0xa5d8e1f3,
39 0x3571, 39 0x3571,
40 0x4d8f, 40 0x4d8f,
41 {0x95, 0x21, 0x07, 0xed, 0x28, 0xfb, 0x07, 0x2e}}; 41 {0x95, 0x21, 0x07, 0xed, 0x28, 0xfb, 0x07, 0x2e}};
42 42
43 const base::char16 BrowserAccessibilityWin::kEmbeddedCharacter = L'\xfffc'; 43 const base::char16 BrowserAccessibilityWin::kEmbeddedCharacter = L'\xfffc';
44 44
45 // static
46 LONG BrowserAccessibilityWin::next_unique_id_win_ =
47 base::win::kFirstBrowserAccessibilityManagerAccessibilityId;
48
49 // 45 //
50 // BrowserAccessibilityRelation 46 // BrowserAccessibilityRelation
51 // 47 //
52 // A simple implementation of IAccessibleRelation, used to represent 48 // A simple implementation of IAccessibleRelation, used to represent
53 // a relationship between two accessible nodes in the tree. 49 // a relationship between two accessible nodes in the tree.
54 // 50 //
55 51
56 class BrowserAccessibilityRelation 52 class BrowserAccessibilityRelation
57 : public CComObjectRootEx<CComMultiThreadModel>, 53 : public CComObjectRootEx<CComMultiThreadModel>,
58 public IAccessibleRelation { 54 public IAccessibleRelation {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 return E_INVALIDARG; 139 return E_INVALIDARG;
144 } 140 }
145 141
146 BrowserAccessibilityManager* manager = owner_->manager(); 142 BrowserAccessibilityManager* manager = owner_->manager();
147 BrowserAccessibility* result = 143 BrowserAccessibility* result =
148 manager->GetFromID(target_ids_[target_index]); 144 manager->GetFromID(target_ids_[target_index]);
149 if (!result || !result->instance_active()) 145 if (!result || !result->instance_active())
150 return E_FAIL; 146 return E_FAIL;
151 147
152 *target = static_cast<IAccessible*>( 148 *target = static_cast<IAccessible*>(
153 result->ToBrowserAccessibilityWin()->NewReference()); 149 ToBrowserAccessibilityWin(result)->NewReference());
154 return S_OK; 150 return S_OK;
155 } 151 }
156 152
157 STDMETHODIMP BrowserAccessibilityRelation::get_targets(long max_targets, 153 STDMETHODIMP BrowserAccessibilityRelation::get_targets(long max_targets,
158 IUnknown** targets, 154 IUnknown** targets,
159 long* n_targets) { 155 long* n_targets) {
160 if (!targets || !n_targets) 156 if (!targets || !n_targets)
161 return E_INVALIDARG; 157 return E_INVALIDARG;
162 158
163 if (!owner_->instance_active()) 159 if (!owner_->instance_active())
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 196
201 // static 197 // static
202 BrowserAccessibility* BrowserAccessibility::Create() { 198 BrowserAccessibility* BrowserAccessibility::Create() {
203 ui::win::CreateATLModuleIfNeeded(); 199 ui::win::CreateATLModuleIfNeeded();
204 CComObject<BrowserAccessibilityWin>* instance; 200 CComObject<BrowserAccessibilityWin>* instance;
205 HRESULT hr = CComObject<BrowserAccessibilityWin>::CreateInstance(&instance); 201 HRESULT hr = CComObject<BrowserAccessibilityWin>::CreateInstance(&instance);
206 DCHECK(SUCCEEDED(hr)); 202 DCHECK(SUCCEEDED(hr));
207 return instance->NewReference(); 203 return instance->NewReference();
208 } 204 }
209 205
210 const BrowserAccessibilityWin* BrowserAccessibility::ToBrowserAccessibilityWin()
211 const {
212 return static_cast<const BrowserAccessibilityWin*>(this);
213 }
214
215 BrowserAccessibilityWin* BrowserAccessibility::ToBrowserAccessibilityWin() {
216 return static_cast<BrowserAccessibilityWin*>(this);
217 }
218
219 BrowserAccessibilityWin::BrowserAccessibilityWin() 206 BrowserAccessibilityWin::BrowserAccessibilityWin()
220 : win_attributes_(new WinAttributes()), 207 : win_attributes_(new WinAttributes()),
221 previous_scroll_x_(0), 208 previous_scroll_x_(0),
222 previous_scroll_y_(0) { 209 previous_scroll_y_(0) {
223 // Start unique IDs at -1 and decrement each time, because get_accChild
224 // uses positive IDs to enumerate children, so we use negative IDs to
225 // clearly distinguish between indices and unique IDs.
226 unique_id_win_ = next_unique_id_win_;
227 if (next_unique_id_win_ ==
228 base::win::kLastBrowserAccessibilityManagerAccessibilityId) {
229 next_unique_id_win_ =
230 base::win::kFirstBrowserAccessibilityManagerAccessibilityId;
231 }
232 next_unique_id_win_--;
233 } 210 }
234 211
235 BrowserAccessibilityWin::~BrowserAccessibilityWin() { 212 BrowserAccessibilityWin::~BrowserAccessibilityWin() {
236 for (size_t i = 0; i < relations_.size(); ++i) 213 for (size_t i = 0; i < relations_.size(); ++i)
237 relations_[i]->Release(); 214 relations_[i]->Release();
238 } 215 }
239 216
240 // 217 //
241 // IAccessible methods. 218 // IAccessible methods.
242 // 219 //
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 return S_FALSE; 251 return S_FALSE;
275 } 252 }
276 253
277 BrowserAccessibility* result = BrowserAccessibilityForPoint(point); 254 BrowserAccessibility* result = BrowserAccessibilityForPoint(point);
278 if (result == this) { 255 if (result == this) {
279 // Point is within this object. 256 // Point is within this object.
280 child->vt = VT_I4; 257 child->vt = VT_I4;
281 child->lVal = CHILDID_SELF; 258 child->lVal = CHILDID_SELF;
282 } else { 259 } else {
283 child->vt = VT_DISPATCH; 260 child->vt = VT_DISPATCH;
284 child->pdispVal = result->ToBrowserAccessibilityWin()->NewReference(); 261 child->pdispVal = ToBrowserAccessibilityWin(result)->NewReference();
285 } 262 }
286 return S_OK; 263 return S_OK;
287 } 264 }
288 265
289 STDMETHODIMP BrowserAccessibilityWin::accLocation(LONG* x_left, 266 STDMETHODIMP BrowserAccessibilityWin::accLocation(LONG* x_left,
290 LONG* y_top, 267 LONG* y_top,
291 LONG* width, 268 LONG* width,
292 LONG* height, 269 LONG* height,
293 VARIANT var_id) { 270 VARIANT var_id) {
294 if (!instance_active()) 271 if (!instance_active())
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 result = target->GetPreviousSibling(); 325 result = target->GetPreviousSibling();
349 break; 326 break;
350 } 327 }
351 328
352 if (!result) { 329 if (!result) {
353 end->vt = VT_EMPTY; 330 end->vt = VT_EMPTY;
354 return S_FALSE; 331 return S_FALSE;
355 } 332 }
356 333
357 end->vt = VT_DISPATCH; 334 end->vt = VT_DISPATCH;
358 end->pdispVal = result->ToBrowserAccessibilityWin()->NewReference(); 335 end->pdispVal = ToBrowserAccessibilityWin(result)->NewReference();
359 return S_OK; 336 return S_OK;
360 } 337 }
361 338
362 STDMETHODIMP BrowserAccessibilityWin::get_accChild(VARIANT var_child, 339 STDMETHODIMP BrowserAccessibilityWin::get_accChild(VARIANT var_child,
363 IDispatch** disp_child) { 340 IDispatch** disp_child) {
364 if (!instance_active()) 341 if (!instance_active())
365 return E_FAIL; 342 return E_FAIL;
366 343
367 if (!disp_child) 344 if (!disp_child)
368 return E_INVALIDARG; 345 return E_INVALIDARG;
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 return S_OK; 481 return S_OK;
505 } 482 }
506 483
507 STDMETHODIMP BrowserAccessibilityWin::get_accParent(IDispatch** disp_parent) { 484 STDMETHODIMP BrowserAccessibilityWin::get_accParent(IDispatch** disp_parent) {
508 if (!instance_active()) 485 if (!instance_active())
509 return E_FAIL; 486 return E_FAIL;
510 487
511 if (!disp_parent) 488 if (!disp_parent)
512 return E_INVALIDARG; 489 return E_INVALIDARG;
513 490
514 IAccessible* parent_obj = GetParent()->ToBrowserAccessibilityWin(); 491 IAccessible* parent_obj = ToBrowserAccessibilityWin(GetParent());
515 if (parent_obj == NULL) { 492 if (parent_obj == NULL) {
516 // This happens if we're the root of the tree; 493 // This happens if we're the root of the tree;
517 // return the IAccessible for the window. 494 // return the IAccessible for the window.
518 parent_obj = 495 parent_obj =
519 manager()->ToBrowserAccessibilityManagerWin()->GetParentIAccessible(); 496 manager()->ToBrowserAccessibilityManagerWin()->GetParentIAccessible();
520 // |parent| can only be NULL if the manager was created before the parent 497 // |parent| can only be NULL if the manager was created before the parent
521 // IAccessible was known and it wasn't subsequently set before a client 498 // IAccessible was known and it wasn't subsequently set before a client
522 // requested it. This has been fixed. |parent| may also be NULL during 499 // requested it. This has been fixed. |parent| may also be NULL during
523 // destruction. Possible cases where this could occur include tabs being 500 // destruction. Possible cases where this could occur include tabs being
524 // dragged to a new window, etc. 501 // dragged to a new window, etc.
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 if (selected_count == 0) { 616 if (selected_count == 0) {
640 selected->vt = VT_EMPTY; 617 selected->vt = VT_EMPTY;
641 return S_OK; 618 return S_OK;
642 } 619 }
643 620
644 if (selected_count == 1) { 621 if (selected_count == 1) {
645 for (size_t i = 0; i < InternalChildCount(); ++i) { 622 for (size_t i = 0; i < InternalChildCount(); ++i) {
646 if (InternalGetChild(i)->HasState(ui::AX_STATE_SELECTED)) { 623 if (InternalGetChild(i)->HasState(ui::AX_STATE_SELECTED)) {
647 selected->vt = VT_DISPATCH; 624 selected->vt = VT_DISPATCH;
648 selected->pdispVal = 625 selected->pdispVal =
649 InternalGetChild(i)->ToBrowserAccessibilityWin()->NewReference(); 626 ToBrowserAccessibilityWin(InternalGetChild(i))->NewReference();
650 return S_OK; 627 return S_OK;
651 } 628 }
652 } 629 }
653 } 630 }
654 631
655 // Multiple items are selected. 632 // Multiple items are selected.
656 base::win::EnumVariant* enum_variant = 633 base::win::EnumVariant* enum_variant =
657 new base::win::EnumVariant(selected_count); 634 new base::win::EnumVariant(selected_count);
658 enum_variant->AddRef(); 635 enum_variant->AddRef();
659 unsigned long index = 0; 636 unsigned long index = 0;
660 for (size_t i = 0; i < InternalChildCount(); ++i) { 637 for (size_t i = 0; i < InternalChildCount(); ++i) {
661 if (InternalGetChild(i)->HasState(ui::AX_STATE_SELECTED)) { 638 if (InternalGetChild(i)->HasState(ui::AX_STATE_SELECTED)) {
662 enum_variant->ItemAt(index)->vt = VT_DISPATCH; 639 enum_variant->ItemAt(index)->vt = VT_DISPATCH;
663 enum_variant->ItemAt(index)->pdispVal = 640 enum_variant->ItemAt(index)->pdispVal =
664 InternalGetChild(i)->ToBrowserAccessibilityWin()->NewReference(); 641 ToBrowserAccessibilityWin(InternalGetChild(i))->NewReference();
665 ++index; 642 ++index;
666 } 643 }
667 } 644 }
668 selected->vt = VT_UNKNOWN; 645 selected->vt = VT_UNKNOWN;
669 selected->punkVal = static_cast<IUnknown*>( 646 selected->punkVal = static_cast<IUnknown*>(
670 static_cast<base::win::IUnknownImpl*>(enum_variant)); 647 static_cast<base::win::IUnknownImpl*>(enum_variant));
671 return S_OK; 648 return S_OK;
672 } 649 }
673 650
674 STDMETHODIMP BrowserAccessibilityWin::accSelect( 651 STDMETHODIMP BrowserAccessibilityWin::accSelect(
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 return S_OK; 721 return S_OK;
745 } 722 }
746 723
747 STDMETHODIMP BrowserAccessibilityWin::get_uniqueID(LONG* unique_id) { 724 STDMETHODIMP BrowserAccessibilityWin::get_uniqueID(LONG* unique_id) {
748 if (!instance_active()) 725 if (!instance_active())
749 return E_FAIL; 726 return E_FAIL;
750 727
751 if (!unique_id) 728 if (!unique_id)
752 return E_INVALIDARG; 729 return E_INVALIDARG;
753 730
754 *unique_id = unique_id_win_; 731 *unique_id = -unique_id_;
755 return S_OK; 732 return S_OK;
756 } 733 }
757 734
758 STDMETHODIMP BrowserAccessibilityWin::get_windowHandle(HWND* window_handle) { 735 STDMETHODIMP BrowserAccessibilityWin::get_windowHandle(HWND* window_handle) {
759 if (!instance_active()) 736 if (!instance_active())
760 return E_FAIL; 737 return E_FAIL;
761 738
762 if (!window_handle) 739 if (!window_handle)
763 return E_INVALIDARG; 740 return E_INVALIDARG;
764 741
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
1282 const std::vector<int32_t>& unique_cell_ids = 1259 const std::vector<int32_t>& unique_cell_ids =
1283 GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS); 1260 GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS);
1284 int cell_id_count = static_cast<int>(unique_cell_ids.size()); 1261 int cell_id_count = static_cast<int>(unique_cell_ids.size());
1285 if (cell_index < 0) 1262 if (cell_index < 0)
1286 return E_INVALIDARG; 1263 return E_INVALIDARG;
1287 if (cell_index >= cell_id_count) 1264 if (cell_index >= cell_id_count)
1288 return S_FALSE; 1265 return S_FALSE;
1289 1266
1290 int cell_id = unique_cell_ids[cell_index]; 1267 int cell_id = unique_cell_ids[cell_index];
1291 BrowserAccessibilityWin* cell = 1268 BrowserAccessibilityWin* cell =
1292 manager()->GetFromID(cell_id)->ToBrowserAccessibilityWin(); 1269 ToBrowserAccessibilityWin(manager()->GetFromID(cell_id));
1293 int col_index; 1270 int col_index;
1294 if (cell && 1271 if (cell &&
1295 cell->GetIntAttribute( 1272 cell->GetIntAttribute(
1296 ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX, &col_index)) { 1273 ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX, &col_index)) {
1297 *column_index = col_index; 1274 *column_index = col_index;
1298 return S_OK; 1275 return S_OK;
1299 } 1276 }
1300 1277
1301 return S_FALSE; 1278 return S_FALSE;
1302 } 1279 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1387 } 1364 }
1388 1365
1389 if (row < 0 || row >= rows) 1366 if (row < 0 || row >= rows)
1390 return E_INVALIDARG; 1367 return E_INVALIDARG;
1391 1368
1392 const std::vector<int32_t>& cell_ids = 1369 const std::vector<int32_t>& cell_ids =
1393 GetIntListAttribute(ui::AX_ATTR_CELL_IDS); 1370 GetIntListAttribute(ui::AX_ATTR_CELL_IDS);
1394 for (int i = 0; i < columns; ++i) { 1371 for (int i = 0; i < columns; ++i) {
1395 int cell_id = cell_ids[row * columns + i]; 1372 int cell_id = cell_ids[row * columns + i];
1396 BrowserAccessibilityWin* cell = 1373 BrowserAccessibilityWin* cell =
1397 manager()->GetFromID(cell_id)->ToBrowserAccessibilityWin(); 1374 ToBrowserAccessibilityWin(manager()->GetFromID(cell_id));
1398 if (cell && cell->GetRole() == ui::AX_ROLE_ROW_HEADER) { 1375 if (cell && cell->GetRole() == ui::AX_ROLE_ROW_HEADER) {
1399 base::string16 cell_name = cell->GetString16Attribute( 1376 base::string16 cell_name = cell->GetString16Attribute(
1400 ui::AX_ATTR_NAME); 1377 ui::AX_ATTR_NAME);
1401 if (cell_name.size() > 0) { 1378 if (cell_name.size() > 0) {
1402 *description = SysAllocString(cell_name.c_str()); 1379 *description = SysAllocString(cell_name.c_str());
1403 return S_OK; 1380 return S_OK;
1404 } 1381 }
1405 1382
1406 if (cell->description().size() > 0) { 1383 if (cell->description().size() > 0) {
1407 *description = SysAllocString(cell->description().c_str()); 1384 *description = SysAllocString(cell->description().c_str());
(...skipping 24 matching lines...) Expand all
1432 return S_FALSE; 1409 return S_FALSE;
1433 } 1410 }
1434 1411
1435 if (row < 0 || row >= rows || column < 0 || column >= columns) 1412 if (row < 0 || row >= rows || column < 0 || column >= columns)
1436 return E_INVALIDARG; 1413 return E_INVALIDARG;
1437 1414
1438 const std::vector<int32_t>& cell_ids = 1415 const std::vector<int32_t>& cell_ids =
1439 GetIntListAttribute(ui::AX_ATTR_CELL_IDS); 1416 GetIntListAttribute(ui::AX_ATTR_CELL_IDS);
1440 int cell_id = cell_ids[row * columns + column]; 1417 int cell_id = cell_ids[row * columns + column];
1441 BrowserAccessibilityWin* cell = 1418 BrowserAccessibilityWin* cell =
1442 manager()->GetFromID(cell_id)->ToBrowserAccessibilityWin(); 1419 ToBrowserAccessibilityWin(manager()->GetFromID(cell_id));
1443 int rowspan; 1420 int rowspan;
1444 if (cell && 1421 if (cell &&
1445 cell->GetIntAttribute( 1422 cell->GetIntAttribute(
1446 ui::AX_ATTR_TABLE_CELL_ROW_SPAN, &rowspan) && 1423 ui::AX_ATTR_TABLE_CELL_ROW_SPAN, &rowspan) &&
1447 rowspan >= 1) { 1424 rowspan >= 1) {
1448 *n_rows_spanned = rowspan; 1425 *n_rows_spanned = rowspan;
1449 return S_OK; 1426 return S_OK;
1450 } 1427 }
1451 1428
1452 return S_FALSE; 1429 return S_FALSE;
(...skipping 17 matching lines...) Expand all
1470 const std::vector<int32_t>& unique_cell_ids = 1447 const std::vector<int32_t>& unique_cell_ids =
1471 GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS); 1448 GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS);
1472 int cell_id_count = static_cast<int>(unique_cell_ids.size()); 1449 int cell_id_count = static_cast<int>(unique_cell_ids.size());
1473 if (cell_index < 0) 1450 if (cell_index < 0)
1474 return E_INVALIDARG; 1451 return E_INVALIDARG;
1475 if (cell_index >= cell_id_count) 1452 if (cell_index >= cell_id_count)
1476 return S_FALSE; 1453 return S_FALSE;
1477 1454
1478 int cell_id = unique_cell_ids[cell_index]; 1455 int cell_id = unique_cell_ids[cell_index];
1479 BrowserAccessibilityWin* cell = 1456 BrowserAccessibilityWin* cell =
1480 manager()->GetFromID(cell_id)->ToBrowserAccessibilityWin(); 1457 ToBrowserAccessibilityWin(manager()->GetFromID(cell_id));
1481 int cell_row_index; 1458 int cell_row_index;
1482 if (cell && 1459 if (cell &&
1483 cell->GetIntAttribute( 1460 cell->GetIntAttribute(
1484 ui::AX_ATTR_TABLE_CELL_ROW_INDEX, &cell_row_index)) { 1461 ui::AX_ATTR_TABLE_CELL_ROW_INDEX, &cell_row_index)) {
1485 *row_index = cell_row_index; 1462 *row_index = cell_row_index;
1486 return S_OK; 1463 return S_OK;
1487 } 1464 }
1488 1465
1489 return S_FALSE; 1466 return S_FALSE;
1490 } 1467 }
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1599 const std::vector<int32_t>& unique_cell_ids = 1576 const std::vector<int32_t>& unique_cell_ids =
1600 GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS); 1577 GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS);
1601 int cell_id_count = static_cast<int>(unique_cell_ids.size()); 1578 int cell_id_count = static_cast<int>(unique_cell_ids.size());
1602 if (index < 0) 1579 if (index < 0)
1603 return E_INVALIDARG; 1580 return E_INVALIDARG;
1604 if (index >= cell_id_count) 1581 if (index >= cell_id_count)
1605 return S_FALSE; 1582 return S_FALSE;
1606 1583
1607 int cell_id = unique_cell_ids[index]; 1584 int cell_id = unique_cell_ids[index];
1608 BrowserAccessibilityWin* cell = 1585 BrowserAccessibilityWin* cell =
1609 manager()->GetFromID(cell_id)->ToBrowserAccessibilityWin(); 1586 ToBrowserAccessibilityWin(manager()->GetFromID(cell_id));
1610 int rowspan; 1587 int rowspan;
1611 int colspan; 1588 int colspan;
1612 if (cell && 1589 if (cell &&
1613 cell->GetIntAttribute( 1590 cell->GetIntAttribute(
1614 ui::AX_ATTR_TABLE_CELL_ROW_SPAN, &rowspan) && 1591 ui::AX_ATTR_TABLE_CELL_ROW_SPAN, &rowspan) &&
1615 cell->GetIntAttribute( 1592 cell->GetIntAttribute(
1616 ui::AX_ATTR_TABLE_CELL_COLUMN_SPAN, &colspan) && 1593 ui::AX_ATTR_TABLE_CELL_COLUMN_SPAN, &colspan) &&
1617 rowspan >= 1 && 1594 rowspan >= 1 &&
1618 colspan >= 1) { 1595 colspan >= 1) {
1619 *row_extents = rowspan; 1596 *row_extents = rowspan;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1758 } 1735 }
1759 if (columns <= 0 || rows <= 0 || column < 0 || column >= columns) 1736 if (columns <= 0 || rows <= 0 || column < 0 || column >= columns)
1760 return S_FALSE; 1737 return S_FALSE;
1761 1738
1762 const std::vector<int32_t>& cell_ids = 1739 const std::vector<int32_t>& cell_ids =
1763 table->GetIntListAttribute(ui::AX_ATTR_CELL_IDS); 1740 table->GetIntListAttribute(ui::AX_ATTR_CELL_IDS);
1764 1741
1765 for (int i = 0; i < rows; ++i) { 1742 for (int i = 0; i < rows; ++i) {
1766 int cell_id = cell_ids[i * columns + column]; 1743 int cell_id = cell_ids[i * columns + column];
1767 BrowserAccessibilityWin* cell = 1744 BrowserAccessibilityWin* cell =
1768 manager()->GetFromID(cell_id)->ToBrowserAccessibilityWin(); 1745 ToBrowserAccessibilityWin(manager()->GetFromID(cell_id));
1769 if (cell && cell->GetRole() == ui::AX_ROLE_COLUMN_HEADER) 1746 if (cell && cell->GetRole() == ui::AX_ROLE_COLUMN_HEADER)
1770 (*n_column_header_cells)++; 1747 (*n_column_header_cells)++;
1771 } 1748 }
1772 1749
1773 *cell_accessibles = static_cast<IUnknown**>(CoTaskMemAlloc( 1750 *cell_accessibles = static_cast<IUnknown**>(CoTaskMemAlloc(
1774 (*n_column_header_cells) * sizeof(cell_accessibles[0]))); 1751 (*n_column_header_cells) * sizeof(cell_accessibles[0])));
1775 int index = 0; 1752 int index = 0;
1776 for (int i = 0; i < rows; ++i) { 1753 for (int i = 0; i < rows; ++i) {
1777 int cell_id = cell_ids[i * columns + column]; 1754 int cell_id = cell_ids[i * columns + column];
1778 BrowserAccessibility* cell = manager()->GetFromID(cell_id); 1755 BrowserAccessibility* cell = manager()->GetFromID(cell_id);
1779 if (cell && cell->GetRole() == ui::AX_ROLE_COLUMN_HEADER) { 1756 if (cell && cell->GetRole() == ui::AX_ROLE_COLUMN_HEADER) {
1780 (*cell_accessibles)[index] = static_cast<IAccessible*>( 1757 (*cell_accessibles)[index] = static_cast<IAccessible*>(
1781 cell->ToBrowserAccessibilityWin()->NewReference()); 1758 ToBrowserAccessibilityWin(cell)->NewReference());
1782 ++index; 1759 ++index;
1783 } 1760 }
1784 } 1761 }
1785 1762
1786 return S_OK; 1763 return S_OK;
1787 } 1764 }
1788 1765
1789 STDMETHODIMP BrowserAccessibilityWin::get_columnIndex(long* column_index) { 1766 STDMETHODIMP BrowserAccessibilityWin::get_columnIndex(long* column_index) {
1790 if (!instance_active()) 1767 if (!instance_active())
1791 return E_FAIL; 1768 return E_FAIL;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1868 } 1845 }
1869 1846
1870 *cell_accessibles = static_cast<IUnknown**>(CoTaskMemAlloc( 1847 *cell_accessibles = static_cast<IUnknown**>(CoTaskMemAlloc(
1871 (*n_row_header_cells) * sizeof(cell_accessibles[0]))); 1848 (*n_row_header_cells) * sizeof(cell_accessibles[0])));
1872 int index = 0; 1849 int index = 0;
1873 for (int i = 0; i < columns; ++i) { 1850 for (int i = 0; i < columns; ++i) {
1874 int cell_id = cell_ids[row * columns + i]; 1851 int cell_id = cell_ids[row * columns + i];
1875 BrowserAccessibility* cell = manager()->GetFromID(cell_id); 1852 BrowserAccessibility* cell = manager()->GetFromID(cell_id);
1876 if (cell && cell->GetRole() == ui::AX_ROLE_ROW_HEADER) { 1853 if (cell && cell->GetRole() == ui::AX_ROLE_ROW_HEADER) {
1877 (*cell_accessibles)[index] = static_cast<IAccessible*>( 1854 (*cell_accessibles)[index] = static_cast<IAccessible*>(
1878 cell->ToBrowserAccessibilityWin()->NewReference()); 1855 ToBrowserAccessibilityWin(cell)->NewReference());
1879 ++index; 1856 ++index;
1880 } 1857 }
1881 } 1858 }
1882 1859
1883 return S_OK; 1860 return S_OK;
1884 } 1861 }
1885 1862
1886 STDMETHODIMP BrowserAccessibilityWin::get_rowIndex(long* row_index) { 1863 STDMETHODIMP BrowserAccessibilityWin::get_rowIndex(long* row_index) {
1887 if (!instance_active()) 1864 if (!instance_active())
1888 return E_FAIL; 1865 return E_FAIL;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1963 1940
1964 BrowserAccessibility* find_table = GetParent(); 1941 BrowserAccessibility* find_table = GetParent();
1965 while (find_table && find_table->GetRole() != ui::AX_ROLE_TABLE) 1942 while (find_table && find_table->GetRole() != ui::AX_ROLE_TABLE)
1966 find_table = find_table->GetParent(); 1943 find_table = find_table->GetParent();
1967 if (!find_table) { 1944 if (!find_table) {
1968 NOTREACHED(); 1945 NOTREACHED();
1969 return S_FALSE; 1946 return S_FALSE;
1970 } 1947 }
1971 1948
1972 *table = static_cast<IAccessibleTable*>( 1949 *table = static_cast<IAccessibleTable*>(
1973 find_table->ToBrowserAccessibilityWin()->NewReference()); 1950 ToBrowserAccessibilityWin(find_table)->NewReference());
1974 1951
1975 return S_OK; 1952 return S_OK;
1976 } 1953 }
1977 1954
1978 // 1955 //
1979 // IAccessibleText methods. 1956 // IAccessibleText methods.
1980 // 1957 //
1981 1958
1982 STDMETHODIMP BrowserAccessibilityWin::get_nCharacters(LONG* n_characters) { 1959 STDMETHODIMP BrowserAccessibilityWin::get_nCharacters(LONG* n_characters) {
1983 if (!instance_active()) 1960 if (!instance_active())
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
2405 return E_FAIL; 2382 return E_FAIL;
2406 2383
2407 if (!hyperlink || 2384 if (!hyperlink ||
2408 index < 0 || 2385 index < 0 ||
2409 index >= static_cast<long>(hyperlinks().size())) { 2386 index >= static_cast<long>(hyperlinks().size())) {
2410 return E_INVALIDARG; 2387 return E_INVALIDARG;
2411 } 2388 }
2412 2389
2413 int32_t id = hyperlinks()[index]; 2390 int32_t id = hyperlinks()[index];
2414 BrowserAccessibilityWin* child = 2391 BrowserAccessibilityWin* child =
2415 manager()->GetFromID(id)->ToBrowserAccessibilityWin(); 2392 ToBrowserAccessibilityWin(manager()->GetFromID(id));
2416 if (child) { 2393 if (child) {
2417 *hyperlink = static_cast<IAccessibleHyperlink*>(child->NewReference()); 2394 *hyperlink = static_cast<IAccessibleHyperlink*>(child->NewReference());
2418 return S_OK; 2395 return S_OK;
2419 } 2396 }
2420 2397
2421 return E_FAIL; 2398 return E_FAIL;
2422 } 2399 }
2423 2400
2424 STDMETHODIMP BrowserAccessibilityWin::get_hyperlinkIndex( 2401 STDMETHODIMP BrowserAccessibilityWin::get_hyperlinkIndex(
2425 long char_index, 2402 long char_index,
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
2503 if (!instance_active() || !IsHyperlink()) 2480 if (!instance_active() || !IsHyperlink())
2504 return E_FAIL; 2481 return E_FAIL;
2505 2482
2506 if (!index) 2483 if (!index)
2507 return E_INVALIDARG; 2484 return E_INVALIDARG;
2508 2485
2509 int32_t hypertext_offset = 0; 2486 int32_t hypertext_offset = 0;
2510 const auto parent = GetParent(); 2487 const auto parent = GetParent();
2511 if (parent) { 2488 if (parent) {
2512 hypertext_offset = 2489 hypertext_offset =
2513 parent->ToBrowserAccessibilityWin()->GetHypertextOffsetFromChild(*this); 2490 ToBrowserAccessibilityWin(parent)->GetHypertextOffsetFromChild(*this);
2514 } 2491 }
2515 *index = static_cast<LONG>(hypertext_offset); 2492 *index = static_cast<LONG>(hypertext_offset);
2516 return S_OK; 2493 return S_OK;
2517 } 2494 }
2518 2495
2519 STDMETHODIMP BrowserAccessibilityWin::get_endIndex(long* index) { 2496 STDMETHODIMP BrowserAccessibilityWin::get_endIndex(long* index) {
2520 LONG start_index; 2497 LONG start_index;
2521 HRESULT hr = get_startIndex(&start_index); 2498 HRESULT hr = get_startIndex(&start_index);
2522 if (hr == S_OK) 2499 if (hr == S_OK)
2523 *index = start_index + 1; 2500 *index = start_index + 1;
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
2744 2721
2745 base::string16 tag; 2722 base::string16 tag;
2746 if (GetString16Attribute(ui::AX_ATTR_HTML_TAG, &tag)) 2723 if (GetString16Attribute(ui::AX_ATTR_HTML_TAG, &tag))
2747 *node_name = SysAllocString(tag.c_str()); 2724 *node_name = SysAllocString(tag.c_str());
2748 else 2725 else
2749 *node_name = NULL; 2726 *node_name = NULL;
2750 2727
2751 *name_space_id = 0; 2728 *name_space_id = 0;
2752 *node_value = SysAllocString(value().c_str()); 2729 *node_value = SysAllocString(value().c_str());
2753 *num_children = PlatformChildCount(); 2730 *num_children = PlatformChildCount();
2754 *unique_id = unique_id_win_; 2731 *unique_id = -unique_id_;
2755 2732
2756 if (GetRole() == ui::AX_ROLE_ROOT_WEB_AREA || 2733 if (GetRole() == ui::AX_ROLE_ROOT_WEB_AREA ||
2757 GetRole() == ui::AX_ROLE_WEB_AREA) { 2734 GetRole() == ui::AX_ROLE_WEB_AREA) {
2758 *node_type = NODETYPE_DOCUMENT; 2735 *node_type = NODETYPE_DOCUMENT;
2759 } else if (IsTextOnlyObject()) { 2736 } else if (IsTextOnlyObject()) {
2760 *node_type = NODETYPE_TEXT; 2737 *node_type = NODETYPE_TEXT;
2761 } else { 2738 } else {
2762 *node_type = NODETYPE_ELEMENT; 2739 *node_type = NODETYPE_ELEMENT;
2763 } 2740 }
2764 2741
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
2882 IA2_SCROLL_TYPE_TOP_LEFT : IA2_SCROLL_TYPE_ANYWHERE); 2859 IA2_SCROLL_TYPE_TOP_LEFT : IA2_SCROLL_TYPE_ANYWHERE);
2883 } 2860 }
2884 2861
2885 STDMETHODIMP BrowserAccessibilityWin::get_parentNode(ISimpleDOMNode** node) { 2862 STDMETHODIMP BrowserAccessibilityWin::get_parentNode(ISimpleDOMNode** node) {
2886 if (!instance_active()) 2863 if (!instance_active())
2887 return E_FAIL; 2864 return E_FAIL;
2888 2865
2889 if (!node) 2866 if (!node)
2890 return E_INVALIDARG; 2867 return E_INVALIDARG;
2891 2868
2892 *node = GetParent()->ToBrowserAccessibilityWin()->NewReference(); 2869 *node = ToBrowserAccessibilityWin(GetParent())->NewReference();
2893 return S_OK; 2870 return S_OK;
2894 } 2871 }
2895 2872
2896 STDMETHODIMP BrowserAccessibilityWin::get_firstChild(ISimpleDOMNode** node) { 2873 STDMETHODIMP BrowserAccessibilityWin::get_firstChild(ISimpleDOMNode** node) {
2897 if (!instance_active()) 2874 if (!instance_active())
2898 return E_FAIL; 2875 return E_FAIL;
2899 2876
2900 if (!node) 2877 if (!node)
2901 return E_INVALIDARG; 2878 return E_INVALIDARG;
2902 2879
2903 if (PlatformChildCount() == 0) { 2880 if (PlatformChildCount() == 0) {
2904 *node = NULL; 2881 *node = NULL;
2905 return S_FALSE; 2882 return S_FALSE;
2906 } 2883 }
2907 2884
2908 *node = PlatformGetChild(0)->ToBrowserAccessibilityWin()->NewReference(); 2885 *node = ToBrowserAccessibilityWin(PlatformGetChild(0))->NewReference();
2909 return S_OK; 2886 return S_OK;
2910 } 2887 }
2911 2888
2912 STDMETHODIMP BrowserAccessibilityWin::get_lastChild(ISimpleDOMNode** node) { 2889 STDMETHODIMP BrowserAccessibilityWin::get_lastChild(ISimpleDOMNode** node) {
2913 if (!instance_active()) 2890 if (!instance_active())
2914 return E_FAIL; 2891 return E_FAIL;
2915 2892
2916 if (!node) 2893 if (!node)
2917 return E_INVALIDARG; 2894 return E_INVALIDARG;
2918 2895
2919 if (PlatformChildCount() == 0) { 2896 if (PlatformChildCount() == 0) {
2920 *node = NULL; 2897 *node = NULL;
2921 return S_FALSE; 2898 return S_FALSE;
2922 } 2899 }
2923 2900
2924 *node = PlatformGetChild(PlatformChildCount() - 1) 2901 *node = ToBrowserAccessibilityWin(
2925 ->ToBrowserAccessibilityWin()->NewReference(); 2902 PlatformGetChild(PlatformChildCount() - 1))->NewReference();
2926 return S_OK; 2903 return S_OK;
2927 } 2904 }
2928 2905
2929 STDMETHODIMP BrowserAccessibilityWin::get_previousSibling( 2906 STDMETHODIMP BrowserAccessibilityWin::get_previousSibling(
2930 ISimpleDOMNode** node) { 2907 ISimpleDOMNode** node) {
2931 if (!instance_active()) 2908 if (!instance_active())
2932 return E_FAIL; 2909 return E_FAIL;
2933 2910
2934 if (!node) 2911 if (!node)
2935 return E_INVALIDARG; 2912 return E_INVALIDARG;
2936 2913
2937 if (!GetParent() || GetIndexInParent() <= 0) { 2914 if (!GetParent() || GetIndexInParent() <= 0) {
2938 *node = NULL; 2915 *node = NULL;
2939 return S_FALSE; 2916 return S_FALSE;
2940 } 2917 }
2941 2918
2942 *node = GetParent()->InternalGetChild(GetIndexInParent() - 1)-> 2919 *node = ToBrowserAccessibilityWin(
2943 ToBrowserAccessibilityWin()->NewReference(); 2920 GetParent()->InternalGetChild(GetIndexInParent() - 1))->NewReference();
2944 return S_OK; 2921 return S_OK;
2945 } 2922 }
2946 2923
2947 STDMETHODIMP BrowserAccessibilityWin::get_nextSibling(ISimpleDOMNode** node) { 2924 STDMETHODIMP BrowserAccessibilityWin::get_nextSibling(ISimpleDOMNode** node) {
2948 if (!instance_active()) 2925 if (!instance_active())
2949 return E_FAIL; 2926 return E_FAIL;
2950 2927
2951 if (!node) 2928 if (!node)
2952 return E_INVALIDARG; 2929 return E_INVALIDARG;
2953 2930
2954 if (!GetParent() || 2931 if (!GetParent() ||
2955 GetIndexInParent() < 0 || 2932 GetIndexInParent() < 0 ||
2956 GetIndexInParent() >= static_cast<int>( 2933 GetIndexInParent() >= static_cast<int>(
2957 GetParent()->InternalChildCount()) - 1) { 2934 GetParent()->InternalChildCount()) - 1) {
2958 *node = NULL; 2935 *node = NULL;
2959 return S_FALSE; 2936 return S_FALSE;
2960 } 2937 }
2961 2938
2962 *node = GetParent()->InternalGetChild(GetIndexInParent() + 1)-> 2939 *node = ToBrowserAccessibilityWin(
2963 ToBrowserAccessibilityWin()->NewReference(); 2940 GetParent()->InternalGetChild(GetIndexInParent() + 1))->NewReference();
2964 return S_OK; 2941 return S_OK;
2965 } 2942 }
2966 2943
2967 STDMETHODIMP BrowserAccessibilityWin::get_childAt( 2944 STDMETHODIMP BrowserAccessibilityWin::get_childAt(
2968 unsigned int child_index, 2945 unsigned int child_index,
2969 ISimpleDOMNode** node) { 2946 ISimpleDOMNode** node) {
2970 if (!instance_active()) 2947 if (!instance_active())
2971 return E_FAIL; 2948 return E_FAIL;
2972 2949
2973 if (!node) 2950 if (!node)
2974 return E_INVALIDARG; 2951 return E_INVALIDARG;
2975 2952
2976 if (child_index >= PlatformChildCount()) 2953 if (child_index >= PlatformChildCount())
2977 return E_INVALIDARG; 2954 return E_INVALIDARG;
2978 2955
2979 BrowserAccessibility* child = PlatformGetChild(child_index); 2956 BrowserAccessibility* child = PlatformGetChild(child_index);
2980 if (!child) { 2957 if (!child) {
2981 *node = NULL; 2958 *node = NULL;
2982 return S_FALSE; 2959 return S_FALSE;
2983 } 2960 }
2984 2961
2985 *node = child->ToBrowserAccessibilityWin()->NewReference(); 2962 *node = ToBrowserAccessibilityWin(child)->NewReference();
2986 return S_OK; 2963 return S_OK;
2987 } 2964 }
2988 2965
2989 STDMETHODIMP BrowserAccessibilityWin::get_innerHTML(BSTR* innerHTML) { 2966 STDMETHODIMP BrowserAccessibilityWin::get_innerHTML(BSTR* innerHTML) {
2990 return E_NOTIMPL; 2967 return E_NOTIMPL;
2991 } 2968 }
2992 2969
2993 STDMETHODIMP 2970 STDMETHODIMP
2994 BrowserAccessibilityWin::get_localInterface(void** local_interface) { 2971 BrowserAccessibilityWin::get_localInterface(void** local_interface) {
2995 return E_NOTIMPL; 2972 return E_NOTIMPL;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
3094 if (riid == IID_IAccessible2) 3071 if (riid == IID_IAccessible2)
3095 BrowserAccessibilityStateImpl::GetInstance()->EnableAccessibility(); 3072 BrowserAccessibilityStateImpl::GetInstance()->EnableAccessibility();
3096 3073
3097 if (guid_service == GUID_IAccessibleContentDocument) { 3074 if (guid_service == GUID_IAccessibleContentDocument) {
3098 // Special Mozilla extension: return the accessible for the root document. 3075 // Special Mozilla extension: return the accessible for the root document.
3099 // Screen readers use this to distinguish between a document loaded event 3076 // Screen readers use this to distinguish between a document loaded event
3100 // on the root document vs on an iframe. 3077 // on the root document vs on an iframe.
3101 BrowserAccessibility* node = this; 3078 BrowserAccessibility* node = this;
3102 while (node->GetParent()) 3079 while (node->GetParent())
3103 node = node->GetParent()->manager()->GetRoot(); 3080 node = node->GetParent()->manager()->GetRoot();
3104 return node->ToBrowserAccessibilityWin()->QueryInterface( 3081 return ToBrowserAccessibilityWin(node)->QueryInterface(
3105 IID_IAccessible2, object); 3082 IID_IAccessible2, object);
3106 } 3083 }
3107 3084
3108 if (guid_service == IID_IAccessible || 3085 if (guid_service == IID_IAccessible ||
3109 guid_service == IID_IAccessible2 || 3086 guid_service == IID_IAccessible2 ||
3110 guid_service == IID_IAccessibleAction || 3087 guid_service == IID_IAccessibleAction ||
3111 guid_service == IID_IAccessibleApplication || 3088 guid_service == IID_IAccessibleApplication ||
3112 guid_service == IID_IAccessibleHyperlink || 3089 guid_service == IID_IAccessibleHyperlink ||
3113 guid_service == IID_IAccessibleHypertext || 3090 guid_service == IID_IAccessibleHypertext ||
3114 guid_service == IID_IAccessibleImage || 3091 guid_service == IID_IAccessibleImage ||
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
3451 return; 3428 return;
3452 } 3429 }
3453 3430
3454 // Construct the hypertext for this node, which contains the concatenation 3431 // Construct the hypertext for this node, which contains the concatenation
3455 // of all of the static text and widespace of this node's children and an 3432 // of all of the static text and widespace of this node's children and an
3456 // embedded object character for all the other children. Build up a map from 3433 // embedded object character for all the other children. Build up a map from
3457 // the character index of each embedded object character to the id of the 3434 // the character index of each embedded object character to the id of the
3458 // child object it points to. 3435 // child object it points to.
3459 for (unsigned int i = 0; i < PlatformChildCount(); ++i) { 3436 for (unsigned int i = 0; i < PlatformChildCount(); ++i) {
3460 BrowserAccessibilityWin* child = 3437 BrowserAccessibilityWin* child =
3461 PlatformGetChild(i)->ToBrowserAccessibilityWin(); 3438 ToBrowserAccessibilityWin(PlatformGetChild(i));
3462 DCHECK(child); 3439 DCHECK(child);
3463 // Similar to Firefox, we don't expose text-only objects in IA2 hypertext. 3440 // Similar to Firefox, we don't expose text-only objects in IA2 hypertext.
3464 if (child->IsTextOnlyObject()) { 3441 if (child->IsTextOnlyObject()) {
3465 win_attributes_->hypertext += child->name(); 3442 win_attributes_->hypertext += child->name();
3466 } else { 3443 } else {
3467 int32_t char_offset = static_cast<int32_t>(GetText().size()); 3444 int32_t char_offset = static_cast<int32_t>(GetText().size());
3468 int32_t child_id = child->GetId(); 3445 int32_t child_id = child->GetId();
3469 int32_t index = hyperlinks().size(); 3446 int32_t index = hyperlinks().size();
3470 win_attributes_->hyperlink_offset_to_index[char_offset] = index; 3447 win_attributes_->hyperlink_offset_to_index[char_offset] = index;
3471 win_attributes_->hyperlinks.push_back(child_id); 3448 win_attributes_->hyperlinks.push_back(child_id);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
3555 manager->MaybeCallNotifyWinEvent(IA2_EVENT_TEXT_REMOVED, this); 3532 manager->MaybeCallNotifyWinEvent(IA2_EVENT_TEXT_REMOVED, this);
3556 } 3533 }
3557 if (new_len > 0) { 3534 if (new_len > 0) {
3558 // In-process screen readers may call IAccessibleText::get_newText 3535 // In-process screen readers may call IAccessibleText::get_newText
3559 // in reaction to this event to retrieve the text that was inserted. 3536 // in reaction to this event to retrieve the text that was inserted.
3560 manager->MaybeCallNotifyWinEvent(IA2_EVENT_TEXT_INSERTED, this); 3537 manager->MaybeCallNotifyWinEvent(IA2_EVENT_TEXT_INSERTED, this);
3561 } 3538 }
3562 3539
3563 // Changing a static text node can affect the IAccessibleText hypertext 3540 // Changing a static text node can affect the IAccessibleText hypertext
3564 // of the parent node, so force an update on the parent. 3541 // of the parent node, so force an update on the parent.
3565 BrowserAccessibilityWin* parent = GetParent()->ToBrowserAccessibilityWin(); 3542 BrowserAccessibilityWin* parent = ToBrowserAccessibilityWin(GetParent());
3566 if (parent && IsTextOnlyObject() && 3543 if (parent && IsTextOnlyObject() &&
3567 name() != old_win_attributes_->name) { 3544 name() != old_win_attributes_->name) {
3568 parent->UpdateStep1ComputeWinAttributes(); 3545 parent->UpdateStep1ComputeWinAttributes();
3569 parent->UpdateStep2ComputeHypertext(); 3546 parent->UpdateStep2ComputeHypertext();
3570 parent->UpdateStep3FireEvents(false); 3547 parent->UpdateStep3FireEvents(false);
3571 } 3548 }
3572 } 3549 }
3573 3550
3574 old_win_attributes_.reset(nullptr); 3551 old_win_attributes_.reset(nullptr);
3575 } 3552 }
(...skipping 28 matching lines...) Expand all
3604 BrowserAccessibilityWin* BrowserAccessibilityWin::GetTargetFromChildID( 3581 BrowserAccessibilityWin* BrowserAccessibilityWin::GetTargetFromChildID(
3605 const VARIANT& var_id) { 3582 const VARIANT& var_id) {
3606 if (var_id.vt != VT_I4) 3583 if (var_id.vt != VT_I4)
3607 return NULL; 3584 return NULL;
3608 3585
3609 LONG child_id = var_id.lVal; 3586 LONG child_id = var_id.lVal;
3610 if (child_id == CHILDID_SELF) 3587 if (child_id == CHILDID_SELF)
3611 return this; 3588 return this;
3612 3589
3613 if (child_id >= 1 && child_id <= static_cast<LONG>(PlatformChildCount())) 3590 if (child_id >= 1 && child_id <= static_cast<LONG>(PlatformChildCount()))
3614 return PlatformGetChild(child_id - 1)->ToBrowserAccessibilityWin(); 3591 return ToBrowserAccessibilityWin(PlatformGetChild(child_id - 1));
3615 3592
3616 return manager()->ToBrowserAccessibilityManagerWin()-> 3593 return ToBrowserAccessibilityWin(
3617 GetFromUniqueIdWin(child_id); 3594 BrowserAccessibility::GetFromUniqueID(-child_id));
3618 } 3595 }
3619 3596
3620 HRESULT BrowserAccessibilityWin::GetStringAttributeAsBstr( 3597 HRESULT BrowserAccessibilityWin::GetStringAttributeAsBstr(
3621 ui::AXStringAttribute attribute, 3598 ui::AXStringAttribute attribute,
3622 BSTR* value_bstr) { 3599 BSTR* value_bstr) {
3623 base::string16 str; 3600 base::string16 str;
3624 3601
3625 if (!GetString16Attribute(attribute, &str)) 3602 if (!GetString16Attribute(attribute, &str))
3626 return S_FALSE; 3603 return S_FALSE;
3627 3604
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
3680 base::ASCIIToUTF16(ia2_attr) + L":" + 3657 base::ASCIIToUTF16(ia2_attr) + L":" +
3681 base::IntToString16(value)); 3658 base::IntToString16(value));
3682 } 3659 }
3683 } 3660 }
3684 3661
3685 bool BrowserAccessibilityWin::IsHyperlink() const { 3662 bool BrowserAccessibilityWin::IsHyperlink() const {
3686 int32_t hyperlink_index = -1; 3663 int32_t hyperlink_index = -1;
3687 const auto parent = GetParent(); 3664 const auto parent = GetParent();
3688 if (parent) { 3665 if (parent) {
3689 hyperlink_index = 3666 hyperlink_index =
3690 parent->ToBrowserAccessibilityWin()->GetHyperlinkIndexFromChild(*this); 3667 ToBrowserAccessibilityWin(parent)->GetHyperlinkIndexFromChild(*this);
3691 } 3668 }
3692 3669
3693 if (hyperlink_index >= 0) 3670 if (hyperlink_index >= 0)
3694 return true; 3671 return true;
3695 return false; 3672 return false;
3696 } 3673 }
3697 3674
3698 int32_t BrowserAccessibilityWin::GetHyperlinkIndexFromChild( 3675 int32_t BrowserAccessibilityWin::GetHyperlinkIndexFromChild(
3699 const BrowserAccessibilityWin& child) const { 3676 const BrowserAccessibilityWin& child) const {
3700 if (hyperlinks().empty()) 3677 if (hyperlinks().empty())
(...skipping 26 matching lines...) Expand all
3727 // and so |InternalChild...| functions need to be used. Also, direct text-only 3704 // and so |InternalChild...| functions need to be used. Also, direct text-only
3728 // children should not be present at tree roots and so no cross-tree traversal 3705 // children should not be present at tree roots and so no cross-tree traversal
3729 // is necessary.) 3706 // is necessary.)
3730 if (child.IsTextOnlyObject()) { 3707 if (child.IsTextOnlyObject()) {
3731 int32_t hypertextOffset = 0; 3708 int32_t hypertextOffset = 0;
3732 int32_t index_in_parent = child.GetIndexInParent(); 3709 int32_t index_in_parent = child.GetIndexInParent();
3733 DCHECK_GE(index_in_parent, 0); 3710 DCHECK_GE(index_in_parent, 0);
3734 DCHECK_LT(index_in_parent, static_cast<int32_t>(InternalChildCount())); 3711 DCHECK_LT(index_in_parent, static_cast<int32_t>(InternalChildCount()));
3735 for (uint32_t i = 0; i < static_cast<uint32_t>(index_in_parent); ++i) { 3712 for (uint32_t i = 0; i < static_cast<uint32_t>(index_in_parent); ++i) {
3736 const BrowserAccessibilityWin* sibling = 3713 const BrowserAccessibilityWin* sibling =
3737 InternalGetChild(i)->ToBrowserAccessibilityWin(); 3714 ToBrowserAccessibilityWin(InternalGetChild(i));
3738 DCHECK(sibling); 3715 DCHECK(sibling);
3739 if (sibling->IsTextOnlyObject()) 3716 if (sibling->IsTextOnlyObject())
3740 hypertextOffset += sibling->GetText().size(); 3717 hypertextOffset += sibling->GetText().size();
3741 else 3718 else
3742 ++hypertextOffset; 3719 ++hypertextOffset;
3743 } 3720 }
3744 return hypertextOffset; 3721 return hypertextOffset;
3745 } 3722 }
3746 3723
3747 int32_t hyperlink_index = GetHyperlinkIndexFromChild(child); 3724 int32_t hyperlink_index = GetHyperlinkIndexFromChild(child);
3748 if (hyperlink_index < 0) 3725 if (hyperlink_index < 0)
3749 return -1; 3726 return -1;
3750 3727
3751 return GetHypertextOffsetFromHyperlinkIndex(hyperlink_index); 3728 return GetHypertextOffsetFromHyperlinkIndex(hyperlink_index);
3752 } 3729 }
3753 3730
3754 int32_t BrowserAccessibilityWin::GetHypertextOffsetFromDescendant( 3731 int32_t BrowserAccessibilityWin::GetHypertextOffsetFromDescendant(
3755 const BrowserAccessibilityWin& descendant) const { 3732 const BrowserAccessibilityWin& descendant) const {
3756 auto parent_object = descendant.GetParent()->ToBrowserAccessibilityWin(); 3733 auto parent_object = ToBrowserAccessibilityWin(descendant.GetParent());
3757 auto current_object = const_cast<BrowserAccessibilityWin*>(&descendant); 3734 auto current_object = const_cast<BrowserAccessibilityWin*>(&descendant);
3758 while (parent_object && parent_object != this) { 3735 while (parent_object && parent_object != this) {
3759 current_object = parent_object; 3736 current_object = parent_object;
3760 parent_object = current_object->GetParent()->ToBrowserAccessibilityWin(); 3737 parent_object = ToBrowserAccessibilityWin(current_object->GetParent());
3761 } 3738 }
3762 if (!parent_object) 3739 if (!parent_object)
3763 return -1; 3740 return -1;
3764 3741
3765 return parent_object->GetHypertextOffsetFromChild(*current_object); 3742 return parent_object->GetHypertextOffsetFromChild(*current_object);
3766 } 3743 }
3767 3744
3768 int BrowserAccessibilityWin::GetHypertextOffsetFromEndpoint( 3745 int BrowserAccessibilityWin::GetHypertextOffsetFromEndpoint(
3769 const BrowserAccessibilityWin& endpoint_object, 3746 const BrowserAccessibilityWin& endpoint_object,
3770 int endpoint_offset) const { 3747 int endpoint_offset) const {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
3832 if (endpoint_index_in_common_parent > index_in_common_parent) 3809 if (endpoint_index_in_common_parent > index_in_common_parent)
3833 return GetText().size(); 3810 return GetText().size();
3834 3811
3835 NOTREACHED(); 3812 NOTREACHED();
3836 return -1; 3813 return -1;
3837 } 3814 }
3838 3815
3839 int BrowserAccessibilityWin::GetSelectionAnchor() const { 3816 int BrowserAccessibilityWin::GetSelectionAnchor() const {
3840 int32_t anchor_id = manager()->GetTreeData().sel_anchor_object_id; 3817 int32_t anchor_id = manager()->GetTreeData().sel_anchor_object_id;
3841 const auto anchor_object = 3818 const auto anchor_object =
3842 manager()->GetFromID(anchor_id)->ToBrowserAccessibilityWin(); 3819 ToBrowserAccessibilityWin(manager()->GetFromID(anchor_id));
3843 if (!anchor_object) 3820 if (!anchor_object)
3844 return -1; 3821 return -1;
3845 3822
3846 int anchor_offset = manager()->GetTreeData().sel_anchor_offset; 3823 int anchor_offset = manager()->GetTreeData().sel_anchor_offset;
3847 return GetHypertextOffsetFromEndpoint(*anchor_object, anchor_offset); 3824 return GetHypertextOffsetFromEndpoint(*anchor_object, anchor_offset);
3848 } 3825 }
3849 3826
3850 int BrowserAccessibilityWin::GetSelectionFocus() const { 3827 int BrowserAccessibilityWin::GetSelectionFocus() const {
3851 int32_t focus_id = manager()->GetTreeData().sel_focus_object_id; 3828 int32_t focus_id = manager()->GetTreeData().sel_focus_object_id;
3852 const auto focus_object = 3829 const auto focus_object =
3853 manager()->GetFromID(focus_id)->ToBrowserAccessibilityWin(); 3830 ToBrowserAccessibilityWin(manager()->GetFromID(focus_id));
3854 if (!focus_object) 3831 if (!focus_object)
3855 return -1; 3832 return -1;
3856 3833
3857 int focus_offset = manager()->GetTreeData().sel_focus_offset; 3834 int focus_offset = manager()->GetTreeData().sel_focus_offset;
3858 return GetHypertextOffsetFromEndpoint(*focus_object, focus_offset); 3835 return GetHypertextOffsetFromEndpoint(*focus_object, focus_offset);
3859 } 3836 }
3860 3837
3861 void BrowserAccessibilityWin::GetSelectionOffsets( 3838 void BrowserAccessibilityWin::GetSelectionOffsets(
3862 int* selection_start, int* selection_end) const { 3839 int* selection_start, int* selection_end) const {
3863 DCHECK(selection_start && selection_end); 3840 DCHECK(selection_start && selection_end);
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
4041 return GetWordStartBoundary(static_cast<int>(start_offset), direction); 4018 return GetWordStartBoundary(static_cast<int>(start_offset), direction);
4042 4019
4043 ui::TextBoundaryType boundary = IA2TextBoundaryToTextBoundary(ia2_boundary); 4020 ui::TextBoundaryType boundary = IA2TextBoundaryToTextBoundary(ia2_boundary);
4044 const std::vector<int32_t>& line_breaks = 4021 const std::vector<int32_t>& line_breaks =
4045 GetIntListAttribute(ui::AX_ATTR_LINE_BREAKS); 4022 GetIntListAttribute(ui::AX_ATTR_LINE_BREAKS);
4046 return ui::FindAccessibleTextBoundary( 4023 return ui::FindAccessibleTextBoundary(
4047 text, line_breaks, boundary, start_offset, direction); 4024 text, line_breaks, boundary, start_offset, direction);
4048 } 4025 }
4049 4026
4050 BrowserAccessibilityWin* BrowserAccessibilityWin::GetFromID(int32_t id) { 4027 BrowserAccessibilityWin* BrowserAccessibilityWin::GetFromID(int32_t id) {
4051 return manager()->GetFromID(id)->ToBrowserAccessibilityWin(); 4028 return ToBrowserAccessibilityWin(manager()->GetFromID(id));
4052 } 4029 }
4053 4030
4054 bool BrowserAccessibilityWin::IsListBoxOptionOrMenuListOption() { 4031 bool BrowserAccessibilityWin::IsListBoxOptionOrMenuListOption() {
4055 if (!GetParent()) 4032 if (!GetParent())
4056 return false; 4033 return false;
4057 4034
4058 int32_t role = GetRole(); 4035 int32_t role = GetRole();
4059 int32_t parent_role = GetParent()->GetRole(); 4036 int32_t parent_role = GetParent()->GetRole();
4060 4037
4061 if (role == ui::AX_ROLE_LIST_BOX_OPTION && 4038 if (role == ui::AX_ROLE_LIST_BOX_OPTION &&
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after
4696 if (!ia2_role) 4673 if (!ia2_role)
4697 ia2_role = ia_role; 4674 ia2_role = ia_role;
4698 4675
4699 win_attributes_->ia_role = ia_role; 4676 win_attributes_->ia_role = ia_role;
4700 win_attributes_->ia_state = ia_state; 4677 win_attributes_->ia_state = ia_state;
4701 win_attributes_->role_name = role_name; 4678 win_attributes_->role_name = role_name;
4702 win_attributes_->ia2_role = ia2_role; 4679 win_attributes_->ia2_role = ia2_role;
4703 win_attributes_->ia2_state = ia2_state; 4680 win_attributes_->ia2_state = ia2_state;
4704 } 4681 }
4705 4682
4683 BrowserAccessibilityWin* ToBrowserAccessibilityWin(BrowserAccessibility* obj) {
4684 DCHECK(!obj || obj->IsNative());
4685 return static_cast<BrowserAccessibilityWin*>(obj);
4686 }
4687
4688 const BrowserAccessibilityWin*
4689 ToBrowserAccessibilityWin(const BrowserAccessibility* obj) {
4690 DCHECK(!obj || obj->IsNative());
4691 return static_cast<const BrowserAccessibilityWin*>(obj);
4692 }
4693
4706 } // namespace content 4694 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698