OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <atlbase.h> | 5 #include <atlbase.h> |
6 #include <atlcom.h> | 6 #include <atlcom.h> |
7 #include <limits.h> | 7 #include <limits.h> |
8 #include <oleacc.h> | 8 #include <oleacc.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 if (bounds.IsEmpty()) | 331 if (bounds.IsEmpty()) |
332 return S_FALSE; | 332 return S_FALSE; |
333 | 333 |
334 return S_OK; | 334 return S_OK; |
335 } | 335 } |
336 | 336 |
337 STDMETHODIMP AXPlatformNodeWin::accNavigate( | 337 STDMETHODIMP AXPlatformNodeWin::accNavigate( |
338 LONG nav_dir, VARIANT start, VARIANT* end) { | 338 LONG nav_dir, VARIANT start, VARIANT* end) { |
339 AXPlatformNodeWin* target; | 339 AXPlatformNodeWin* target; |
340 COM_OBJECT_VALIDATE_VAR_ID_1_ARG_AND_GET_TARGET(start, end, target); | 340 COM_OBJECT_VALIDATE_VAR_ID_1_ARG_AND_GET_TARGET(start, end, target); |
341 IAccessible* result = nullptr; | 341 end->vt = VT_EMPTY; |
342 | 342 if ((nav_dir == NAVDIR_FIRSTCHILD || nav_dir == NAVDIR_LASTCHILD) && |
343 if ((nav_dir == NAVDIR_LASTCHILD || nav_dir == NAVDIR_FIRSTCHILD) && | 343 V_VT(&start) == VT_I4 && V_I4(&start) != CHILDID_SELF) { |
344 start.lVal != CHILDID_SELF) { | |
345 // MSAA states that navigating to first/last child can only be from self. | 344 // MSAA states that navigating to first/last child can only be from self. |
346 return E_INVALIDARG; | 345 return E_INVALIDARG; |
347 } | 346 } |
348 | 347 |
| 348 IAccessible* result = nullptr; |
349 switch (nav_dir) { | 349 switch (nav_dir) { |
350 case NAVDIR_DOWN: | 350 case NAVDIR_DOWN: |
351 case NAVDIR_UP: | 351 case NAVDIR_UP: |
352 case NAVDIR_LEFT: | 352 case NAVDIR_LEFT: |
353 case NAVDIR_RIGHT: | 353 case NAVDIR_RIGHT: |
354 // These directions are not implemented, matching Mozilla and IE. | 354 // These directions are not implemented except in tables. |
355 return E_NOTIMPL; | 355 return E_NOTIMPL; |
356 | 356 |
357 case NAVDIR_FIRSTCHILD: | 357 case NAVDIR_FIRSTCHILD: |
358 if (delegate_->GetChildCount() > 0) | 358 if (delegate_->GetChildCount() > 0) |
359 result = delegate_->ChildAtIndex(0); | 359 result = delegate_->ChildAtIndex(0); |
360 break; | 360 break; |
361 | 361 |
362 case NAVDIR_LASTCHILD: | 362 case NAVDIR_LASTCHILD: |
363 if (delegate_->GetChildCount() > 0) | 363 if (delegate_->GetChildCount() > 0) |
364 result = delegate_->ChildAtIndex(delegate_->GetChildCount() - 1); | 364 result = delegate_->ChildAtIndex(delegate_->GetChildCount() - 1); |
365 break; | 365 break; |
366 | 366 |
367 case NAVDIR_NEXT: { | 367 case NAVDIR_NEXT: { |
368 AXPlatformNodeBase* next = GetNextSibling(); | 368 AXPlatformNodeBase* next = target->GetNextSibling(); |
369 if (next) | 369 if (next) |
370 result = next->GetNativeViewAccessible(); | 370 result = next->GetNativeViewAccessible(); |
371 break; | 371 break; |
372 } | 372 } |
373 | 373 |
374 case NAVDIR_PREVIOUS: { | 374 case NAVDIR_PREVIOUS: { |
375 AXPlatformNodeBase* previous = GetPreviousSibling(); | 375 AXPlatformNodeBase* previous = target->GetPreviousSibling(); |
376 if (previous) | 376 if (previous) |
377 result = previous->GetNativeViewAccessible(); | 377 result = previous->GetNativeViewAccessible(); |
378 break; | 378 break; |
379 } | 379 } |
380 | |
381 default: | |
382 return E_INVALIDARG; | |
383 } | 380 } |
384 | 381 |
385 if (!result) { | 382 if (!result) |
386 end->vt = VT_EMPTY; | |
387 return S_FALSE; | 383 return S_FALSE; |
388 } | |
389 | 384 |
390 end->vt = VT_DISPATCH; | 385 end->vt = VT_DISPATCH; |
391 end->pdispVal = result; | 386 end->pdispVal = result; |
392 // Always increment ref when returning a reference to a COM object. | 387 // Always increment ref when returning a reference to a COM object. |
393 end->pdispVal->AddRef(); | 388 end->pdispVal->AddRef(); |
394 | 389 |
395 return S_OK; | 390 return S_OK; |
396 } | 391 } |
397 | 392 |
398 STDMETHODIMP AXPlatformNodeWin::get_accChild(VARIANT var_child, | 393 STDMETHODIMP AXPlatformNodeWin::get_accChild(VARIANT var_child, |
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1260 HandleSpecialTextOffset(&start_offset); | 1255 HandleSpecialTextOffset(&start_offset); |
1261 ui::TextBoundaryType boundary = IA2TextBoundaryToTextBoundary(ia2_boundary); | 1256 ui::TextBoundaryType boundary = IA2TextBoundaryToTextBoundary(ia2_boundary); |
1262 std::vector<int32_t> line_breaks; | 1257 std::vector<int32_t> line_breaks; |
1263 return static_cast<LONG>(ui::FindAccessibleTextBoundary( | 1258 return static_cast<LONG>(ui::FindAccessibleTextBoundary( |
1264 text, line_breaks, boundary, start_offset, direction, | 1259 text, line_breaks, boundary, start_offset, direction, |
1265 AX_TEXT_AFFINITY_DOWNSTREAM)); | 1260 AX_TEXT_AFFINITY_DOWNSTREAM)); |
1266 } | 1261 } |
1267 | 1262 |
1268 AXPlatformNodeWin* AXPlatformNodeWin::GetTargetFromChildID( | 1263 AXPlatformNodeWin* AXPlatformNodeWin::GetTargetFromChildID( |
1269 const VARIANT& var_id) { | 1264 const VARIANT& var_id) { |
| 1265 if (V_VT(&var_id) != VT_I4) |
| 1266 return nullptr; |
| 1267 |
1270 LONG child_id = V_I4(&var_id); | 1268 LONG child_id = V_I4(&var_id); |
1271 if (child_id == CHILDID_SELF) { | 1269 if (child_id == CHILDID_SELF) |
1272 return this; | 1270 return this; |
1273 } | |
1274 | 1271 |
1275 if (child_id >= 1 && child_id <= delegate_->GetChildCount()) { | 1272 if (child_id >= 1 && child_id <= delegate_->GetChildCount()) { |
1276 // Positive child ids are a 1-based child index, used by clients | 1273 // Positive child ids are a 1-based child index, used by clients |
1277 // that want to enumerate all immediate children. | 1274 // that want to enumerate all immediate children. |
1278 AXPlatformNodeBase* base = | 1275 AXPlatformNodeBase* base = |
1279 FromNativeViewAccessible(delegate_->ChildAtIndex(child_id - 1)); | 1276 FromNativeViewAccessible(delegate_->ChildAtIndex(child_id - 1)); |
1280 return static_cast<AXPlatformNodeWin*>(base); | 1277 return static_cast<AXPlatformNodeWin*>(base); |
1281 } | 1278 } |
1282 | 1279 |
1283 if (child_id >= 0) | 1280 if (child_id >= 0) |
1284 return nullptr; | 1281 return nullptr; |
1285 | 1282 |
1286 // Negative child ids can be used to map to any descendant. | 1283 // Negative child ids can be used to map to any descendant. |
1287 AXPlatformNode* node = GetFromUniqueId(-child_id); | 1284 AXPlatformNode* node = GetFromUniqueId(-child_id); |
1288 if (!node) | 1285 if (!node) |
1289 return nullptr; | 1286 return nullptr; |
1290 | 1287 |
1291 AXPlatformNodeBase* base = | 1288 AXPlatformNodeBase* base = |
1292 FromNativeViewAccessible(node->GetNativeViewAccessible()); | 1289 FromNativeViewAccessible(node->GetNativeViewAccessible()); |
1293 if (base && !IsDescendant(base)) | 1290 if (base && !IsDescendant(base)) |
1294 base = nullptr; | 1291 base = nullptr; |
1295 | 1292 |
1296 return static_cast<AXPlatformNodeWin*>(base); | 1293 return static_cast<AXPlatformNodeWin*>(base); |
1297 } | 1294 } |
1298 | 1295 |
1299 } // namespace ui | 1296 } // namespace ui |
OLD | NEW |