Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2017 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_com_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> |
| 11 #include <iterator> | 11 #include <iterator> |
| 12 #include <utility> | 12 #include <utility> |
| 13 | 13 |
| 14 #include "base/metrics/histogram_macros.h" | 14 #include "base/metrics/histogram_macros.h" |
| 15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/strings/string_split.h" | 16 #include "base/strings/string_split.h" |
| 17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
| 18 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 19 #include "base/win/enum_variant.h" | 19 #include "base/win/enum_variant.h" |
| 20 #include "base/win/scoped_comptr.h" | 20 #include "base/win/scoped_comptr.h" |
| 21 #include "base/win/windows_version.h" | 21 #include "base/win/windows_version.h" |
| 22 #include "content/browser/accessibility/browser_accessibility_event_win.h" | 22 #include "content/browser/accessibility/browser_accessibility_event_win.h" |
| 23 #include "content/browser/accessibility/browser_accessibility_manager_win.h" | 23 #include "content/browser/accessibility/browser_accessibility_manager_win.h" |
| 24 #include "content/browser/accessibility/browser_accessibility_state_impl.h" | 24 #include "content/browser/accessibility/browser_accessibility_state_impl.h" |
| 25 #include "content/browser/accessibility/browser_accessibility_win.h" | |
| 25 #include "content/common/accessibility_messages.h" | 26 #include "content/common/accessibility_messages.h" |
| 26 #include "content/common/accessibility_mode.h" | 27 #include "content/common/accessibility_mode.h" |
| 27 #include "content/public/common/content_client.h" | 28 #include "content/public/common/content_client.h" |
| 28 #include "third_party/skia/include/core/SkColor.h" | 29 #include "third_party/skia/include/core/SkColor.h" |
| 29 #include "ui/accessibility/ax_text_utils.h" | 30 #include "ui/accessibility/ax_text_utils.h" |
| 30 #include "ui/base/win/accessibility_ids_win.h" | 31 #include "ui/base/win/accessibility_ids_win.h" |
| 31 #include "ui/base/win/accessibility_misc_utils.h" | 32 #include "ui/base/win/accessibility_misc_utils.h" |
| 32 #include "ui/base/win/atl_module.h" | 33 #include "ui/base/win/atl_module.h" |
| 33 | 34 |
| 34 namespace { | 35 namespace { |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 195 UMA_API_TABLECELL_GET_ROW_INDEX = 155, | 196 UMA_API_TABLECELL_GET_ROW_INDEX = 155, |
| 196 UMA_API_UNSELECT_COLUMN = 156, | 197 UMA_API_UNSELECT_COLUMN = 156, |
| 197 UMA_API_UNSELECT_ROW = 157, | 198 UMA_API_UNSELECT_ROW = 157, |
| 198 | 199 |
| 199 // This must always be the last enum. It's okay for its value to | 200 // This must always be the last enum. It's okay for its value to |
| 200 // increase, but none of the other enum values may change. | 201 // increase, but none of the other enum values may change. |
| 201 UMA_API_MAX | 202 UMA_API_MAX |
| 202 }; | 203 }; |
| 203 | 204 |
| 204 #define WIN_ACCESSIBILITY_API_HISTOGRAM(enum_value) \ | 205 #define WIN_ACCESSIBILITY_API_HISTOGRAM(enum_value) \ |
| 205 UMA_HISTOGRAM_ENUMERATION("Accessibility.WinAPIs", enum_value, UMA_API_MAX) | 206 UMA_HISTOGRAM_ENUMERATION("Accessibility.WinAPIs", enum_value, UMA_API_MAX) |
| 206 | 207 |
| 207 // There is no easy way to decouple |kScreenReader| and |kHTML| accessibility | 208 // There is no easy way to decouple |kScreenReader| and |kHTML| accessibility |
| 208 // modes when Windows screen readers are used. For example, certain roles use | 209 // modes when Windows screen readers are used. For example, certain roles use |
| 209 // the HTML tag name. Input fields require their type attribute to be exposed. | 210 // the HTML tag name. Input fields require their type attribute to be exposed. |
| 210 const uint32_t kScreenReaderAndHTMLAccessibilityModes = | 211 const uint32_t kScreenReaderAndHTMLAccessibilityModes = |
| 211 content::AccessibilityMode::kScreenReader | | 212 content::AccessibilityMode::kScreenReader | |
| 212 content::AccessibilityMode::kHTML; | 213 content::AccessibilityMode::kHTML; |
| 213 | 214 |
| 214 const WCHAR *const IA2_RELATION_DETAILS = L"details"; | 215 const WCHAR* const IA2_RELATION_DETAILS = L"details"; |
| 215 const WCHAR *const IA2_RELATION_DETAILS_FOR = L"detailsFor"; | 216 const WCHAR* const IA2_RELATION_DETAILS_FOR = L"detailsFor"; |
| 216 const WCHAR *const IA2_RELATION_ERROR_MESSAGE = L"errorMessage"; | 217 const WCHAR* const IA2_RELATION_ERROR_MESSAGE = L"errorMessage"; |
| 217 | 218 |
| 218 } // namespace | 219 } // namespace |
| 219 | 220 |
| 220 namespace content { | 221 namespace content { |
| 221 | 222 |
| 223 using AXPlatformPositionInstance = AXPlatformPosition::AXPositionInstance; | |
| 224 using AXPlatformRange = ui::AXRange<AXPlatformPositionInstance::element_type>; | |
| 225 | |
| 222 // These nonstandard GUIDs are taken directly from the Mozilla sources | 226 // These nonstandard GUIDs are taken directly from the Mozilla sources |
| 223 // (accessible/src/msaa/nsAccessNodeWrap.cpp); some documentation is here: | 227 // (accessible/src/msaa/nsAccessNodeWrap.cpp); some documentation is here: |
| 224 // http://developer.mozilla.org/en/Accessibility/AT-APIs/ImplementationFeatures/ MSAA | 228 // http://developer.mozilla.org/en/Accessibility/AT-APIs/ImplementationFeatures/ MSAA |
| 225 const GUID GUID_ISimpleDOM = {0x0c539790, | 229 const GUID GUID_ISimpleDOM = {0x0c539790, |
| 226 0x12e4, | 230 0x12e4, |
| 227 0x11cf, | 231 0x11cf, |
| 228 {0xb6, 0x61, 0x00, 0xaa, 0x00, 0x4c, 0xd6, 0xd8}}; | 232 {0xb6, 0x61, 0x00, 0xaa, 0x00, 0x4c, 0xd6, 0xd8}}; |
| 229 const GUID GUID_IAccessibleContentDocument = { | 233 const GUID GUID_IAccessibleContentDocument = { |
| 230 0xa5d8e1f3, | 234 0xa5d8e1f3, |
| 231 0x3571, | 235 0x3571, |
| 232 0x4d8f, | 236 0x4d8f, |
| 233 {0x95, 0x21, 0x07, 0xed, 0x28, 0xfb, 0x07, 0x2e}}; | 237 {0x95, 0x21, 0x07, 0xed, 0x28, 0xfb, 0x07, 0x2e}}; |
| 234 | 238 |
| 235 const base::char16 BrowserAccessibilityWin::kEmbeddedCharacter = L'\xfffc'; | 239 const base::char16 BrowserAccessibilityComWin::kEmbeddedCharacter = L'\xfffc'; |
| 236 | 240 |
| 237 void AddAccessibilityModeFlags(AccessibilityMode mode_flags) { | 241 void AddAccessibilityModeFlags(AccessibilityMode mode_flags) { |
| 238 BrowserAccessibilityStateImpl::GetInstance()->AddAccessibilityModeFlags( | 242 BrowserAccessibilityStateImpl::GetInstance()->AddAccessibilityModeFlags( |
| 239 mode_flags); | 243 mode_flags); |
| 240 } | 244 } |
| 241 | 245 |
| 242 // | 246 // |
| 243 // BrowserAccessibilityRelation | 247 // BrowserAccessibilityRelation |
| 244 // | 248 // |
| 245 // A simple implementation of IAccessibleRelation, used to represent | 249 // A simple implementation of IAccessibleRelation, used to represent |
| 246 // a relationship between two accessible nodes in the tree. | 250 // a relationship between two accessible nodes in the tree. |
| 247 // | 251 // |
| 248 | 252 |
| 249 class BrowserAccessibilityRelation | 253 class BrowserAccessibilityRelation |
| 250 : public CComObjectRootEx<CComMultiThreadModel>, | 254 : public CComObjectRootEx<CComMultiThreadModel>, |
| 251 public IAccessibleRelation { | 255 public IAccessibleRelation { |
| 252 BEGIN_COM_MAP(BrowserAccessibilityRelation) | 256 BEGIN_COM_MAP(BrowserAccessibilityRelation) |
| 253 COM_INTERFACE_ENTRY(IAccessibleRelation) | 257 COM_INTERFACE_ENTRY(IAccessibleRelation) |
| 254 END_COM_MAP() | 258 END_COM_MAP() |
| 255 | 259 |
| 256 CONTENT_EXPORT BrowserAccessibilityRelation() {} | 260 CONTENT_EXPORT BrowserAccessibilityRelation() {} |
| 257 CONTENT_EXPORT virtual ~BrowserAccessibilityRelation() {} | 261 CONTENT_EXPORT virtual ~BrowserAccessibilityRelation() {} |
| 258 | 262 |
| 259 CONTENT_EXPORT void Initialize(BrowserAccessibilityWin* owner, | 263 CONTENT_EXPORT void Initialize(BrowserAccessibilityComWin* owner, |
| 260 const base::string16& type); | 264 const base::string16& type); |
| 261 CONTENT_EXPORT void AddTarget(int target_id); | 265 CONTENT_EXPORT void AddTarget(int target_id); |
| 262 CONTENT_EXPORT void RemoveTarget(int target_id); | 266 CONTENT_EXPORT void RemoveTarget(int target_id); |
| 263 | 267 |
| 264 // Accessors. | 268 // Accessors. |
| 265 const base::string16& get_type() const { return type_; } | 269 const base::string16& get_type() const { return type_; } |
| 266 const std::vector<int>& get_target_ids() const { return target_ids_; } | 270 const std::vector<int>& get_target_ids() const { return target_ids_; } |
| 267 | 271 |
| 268 // IAccessibleRelation methods. | 272 // IAccessibleRelation methods. |
| 269 CONTENT_EXPORT STDMETHODIMP get_relationType(BSTR* relation_type) override; | 273 CONTENT_EXPORT STDMETHODIMP get_relationType(BSTR* relation_type) override; |
| 270 CONTENT_EXPORT STDMETHODIMP get_nTargets(long* n_targets) override; | 274 CONTENT_EXPORT STDMETHODIMP get_nTargets(long* n_targets) override; |
| 271 CONTENT_EXPORT STDMETHODIMP | 275 CONTENT_EXPORT STDMETHODIMP get_target(long target_index, |
| 272 get_target(long target_index, IUnknown** target) override; | 276 IUnknown** target) override; |
| 273 CONTENT_EXPORT STDMETHODIMP | 277 CONTENT_EXPORT STDMETHODIMP get_targets(long max_targets, |
| 274 get_targets(long max_targets, IUnknown** targets, long* n_targets) override; | 278 IUnknown** targets, |
| 279 long* n_targets) override; | |
| 275 | 280 |
| 276 // IAccessibleRelation methods not implemented. | 281 // IAccessibleRelation methods not implemented. |
| 277 CONTENT_EXPORT STDMETHODIMP | 282 CONTENT_EXPORT STDMETHODIMP |
| 278 get_localizedRelationType(BSTR* relation_type) override { | 283 get_localizedRelationType(BSTR* relation_type) override { |
| 279 return E_NOTIMPL; | 284 return E_NOTIMPL; |
| 280 } | 285 } |
| 281 | 286 |
| 282 private: | 287 private: |
| 283 base::string16 type_; | 288 base::string16 type_; |
| 284 base::win::ScopedComPtr<BrowserAccessibilityWin> owner_; | 289 base::win::ScopedComPtr<BrowserAccessibilityComWin> owner_; |
| 285 std::vector<int> target_ids_; | 290 std::vector<int> target_ids_; |
| 286 }; | 291 }; |
| 287 | 292 |
| 288 void BrowserAccessibilityRelation::Initialize(BrowserAccessibilityWin* owner, | 293 void BrowserAccessibilityRelation::Initialize(BrowserAccessibilityComWin* owner, |
| 289 const base::string16& type) { | 294 const base::string16& type) { |
| 290 owner_ = owner; | 295 owner_ = owner; |
| 291 type_ = type; | 296 type_ = type; |
| 292 } | 297 } |
| 293 | 298 |
| 294 void BrowserAccessibilityRelation::AddTarget(int target_id) { | 299 void BrowserAccessibilityRelation::AddTarget(int target_id) { |
| 295 target_ids_.push_back(target_id); | 300 target_ids_.push_back(target_id); |
| 296 } | 301 } |
| 297 | 302 |
| 298 void BrowserAccessibilityRelation::RemoveTarget(int target_id) { | 303 void BrowserAccessibilityRelation::RemoveTarget(int target_id) { |
| 299 target_ids_.erase( | 304 target_ids_.erase( |
| 300 std::remove(target_ids_.begin(), target_ids_.end(), target_id), | 305 std::remove(target_ids_.begin(), target_ids_.end(), target_id), |
| 301 target_ids_.end()); | 306 target_ids_.end()); |
| 302 } | 307 } |
| 303 | 308 |
| 304 STDMETHODIMP BrowserAccessibilityRelation::get_relationType( | 309 STDMETHODIMP BrowserAccessibilityRelation::get_relationType( |
| 305 BSTR* relation_type) { | 310 BSTR* relation_type) { |
| 306 if (!relation_type) | 311 if (!relation_type) |
| 307 return E_INVALIDARG; | 312 return E_INVALIDARG; |
| 308 | 313 |
| 309 if (!owner_->instance_active()) | 314 if (!owner_->GetOwner()->instance_active()) |
| 310 return E_FAIL; | 315 return E_FAIL; |
| 311 | 316 |
| 312 *relation_type = SysAllocString(type_.c_str()); | 317 *relation_type = SysAllocString(type_.c_str()); |
| 313 DCHECK(*relation_type); | 318 DCHECK(*relation_type); |
| 314 return S_OK; | 319 return S_OK; |
| 315 } | 320 } |
| 316 | 321 |
| 317 STDMETHODIMP BrowserAccessibilityRelation::get_nTargets(long* n_targets) { | 322 STDMETHODIMP BrowserAccessibilityRelation::get_nTargets(long* n_targets) { |
| 318 if (!n_targets) | 323 if (!n_targets) |
| 319 return E_INVALIDARG; | 324 return E_INVALIDARG; |
| 320 | 325 |
| 321 if (!owner_->instance_active()) | 326 if (!owner_->GetOwner()->instance_active()) |
| 322 return E_FAIL; | 327 return E_FAIL; |
| 323 | 328 |
| 324 *n_targets = static_cast<long>(target_ids_.size()); | 329 *n_targets = static_cast<long>(target_ids_.size()); |
| 325 | 330 |
| 326 for (long i = *n_targets - 1; i >= 0; --i) { | 331 for (long i = *n_targets - 1; i >= 0; --i) { |
| 327 BrowserAccessibilityWin* result = owner_->GetFromID(target_ids_[i]); | 332 BrowserAccessibilityComWin* result = owner_->GetFromID(target_ids_[i]); |
| 328 if (!result || !result->instance_active()) { | 333 if (!result || !result->GetOwner()->instance_active()) { |
| 329 *n_targets = 0; | 334 *n_targets = 0; |
| 330 break; | 335 break; |
| 331 } | 336 } |
| 332 } | 337 } |
| 333 return S_OK; | 338 return S_OK; |
| 334 } | 339 } |
| 335 | 340 |
| 336 STDMETHODIMP BrowserAccessibilityRelation::get_target(long target_index, | 341 STDMETHODIMP BrowserAccessibilityRelation::get_target(long target_index, |
| 337 IUnknown** target) { | 342 IUnknown** target) { |
| 338 if (!target) | 343 if (!target) |
| 339 return E_INVALIDARG; | 344 return E_INVALIDARG; |
| 340 | 345 |
| 341 if (!owner_->instance_active()) | 346 if (!owner_->GetOwner()->instance_active()) |
| 347 return E_FAIL; | |
| 348 | |
| 349 auto* manager = owner_->GetOwner()->manager(); | |
| 350 if (!manager) | |
| 342 return E_FAIL; | 351 return E_FAIL; |
| 343 | 352 |
| 344 if (target_index < 0 || | 353 if (target_index < 0 || |
| 345 target_index >= static_cast<long>(target_ids_.size())) { | 354 target_index >= static_cast<long>(target_ids_.size())) { |
| 346 return E_INVALIDARG; | 355 return E_INVALIDARG; |
| 347 } | 356 } |
| 348 | 357 |
| 349 BrowserAccessibility* result = owner_->GetFromID(target_ids_[target_index]); | 358 BrowserAccessibility* result = manager->GetFromID(target_ids_[target_index]); |
| 350 if (!result || !result->instance_active()) | 359 if (!result || !result->instance_active()) |
| 351 return E_FAIL; | 360 return E_FAIL; |
| 352 | 361 |
| 353 *target = static_cast<IAccessible*>( | 362 *target = static_cast<IAccessible*>( |
| 354 ToBrowserAccessibilityWin(result)->NewReference()); | 363 ToBrowserAccessibilityComWin(result)->NewReference()); |
| 355 return S_OK; | 364 return S_OK; |
| 356 } | 365 } |
| 357 | 366 |
| 358 STDMETHODIMP BrowserAccessibilityRelation::get_targets(long max_targets, | 367 STDMETHODIMP BrowserAccessibilityRelation::get_targets(long max_targets, |
| 359 IUnknown** targets, | 368 IUnknown** targets, |
| 360 long* n_targets) { | 369 long* n_targets) { |
| 361 if (!targets || !n_targets) | 370 if (!targets || !n_targets) |
| 362 return E_INVALIDARG; | 371 return E_INVALIDARG; |
| 363 | 372 |
| 364 if (!owner_->instance_active()) | 373 if (!owner_->GetOwner()->instance_active()) |
| 365 return E_FAIL; | 374 return E_FAIL; |
| 366 | 375 |
| 367 long count = static_cast<long>(target_ids_.size()); | 376 long count = static_cast<long>(target_ids_.size()); |
| 368 if (count > max_targets) | 377 if (count > max_targets) |
| 369 count = max_targets; | 378 count = max_targets; |
| 370 | 379 |
| 371 *n_targets = count; | 380 *n_targets = count; |
| 372 if (count == 0) | 381 if (count == 0) |
| 373 return S_FALSE; | 382 return S_FALSE; |
| 374 | 383 |
| 375 for (long i = 0; i < count; ++i) { | 384 for (long i = 0; i < count; ++i) { |
| 376 HRESULT result = get_target(i, &targets[i]); | 385 HRESULT result = get_target(i, &targets[i]); |
| 377 if (result != S_OK) | 386 if (result != S_OK) |
| 378 return result; | 387 return result; |
| 379 } | 388 } |
| 380 | 389 |
| 381 return S_OK; | 390 return S_OK; |
| 382 } | 391 } |
| 383 | 392 |
| 384 // | 393 // |
| 385 // BrowserAccessibilityWin::WinAttributes | 394 // BrowserAccessibilityComWin::WinAttributes |
| 386 // | 395 // |
| 387 | 396 |
| 388 BrowserAccessibilityWin::WinAttributes::WinAttributes() | 397 BrowserAccessibilityComWin::WinAttributes::WinAttributes() |
| 389 : ia_role(0), | 398 : ia_role(0), ia_state(0), ia2_role(0), ia2_state(0) {} |
| 390 ia_state(0), | |
| 391 ia2_role(0), | |
| 392 ia2_state(0) { | |
| 393 } | |
| 394 | 399 |
| 395 BrowserAccessibilityWin::WinAttributes::~WinAttributes() { | 400 BrowserAccessibilityComWin::WinAttributes::~WinAttributes() {} |
| 396 } | |
| 397 | 401 |
| 398 // | 402 // |
| 399 // BrowserAccessibilityWin | 403 // BrowserAccessibilityComWin |
| 400 // | 404 // |
| 405 BrowserAccessibilityComWin::BrowserAccessibilityComWin() | |
| 406 : owner_(nullptr), | |
| 407 win_attributes_(new WinAttributes()), | |
| 408 previous_scroll_x_(0), | |
| 409 previous_scroll_y_(0) {} | |
| 401 | 410 |
| 402 // static | 411 BrowserAccessibilityComWin::~BrowserAccessibilityComWin() { |
| 403 BrowserAccessibility* BrowserAccessibility::Create() { | |
| 404 ui::win::CreateATLModuleIfNeeded(); | |
| 405 CComObject<BrowserAccessibilityWin>* instance; | |
| 406 HRESULT hr = CComObject<BrowserAccessibilityWin>::CreateInstance(&instance); | |
| 407 DCHECK(SUCCEEDED(hr)); | |
| 408 return instance->NewReference(); | |
| 409 } | |
| 410 | |
| 411 BrowserAccessibilityWin::BrowserAccessibilityWin() | |
| 412 : win_attributes_(new WinAttributes()), | |
| 413 previous_scroll_x_(0), | |
| 414 previous_scroll_y_(0) { | |
| 415 } | |
| 416 | |
| 417 BrowserAccessibilityWin::~BrowserAccessibilityWin() { | |
| 418 for (BrowserAccessibilityRelation* relation : relations_) | 412 for (BrowserAccessibilityRelation* relation : relations_) |
| 419 relation->Release(); | 413 relation->Release(); |
| 420 } | 414 } |
| 421 | 415 |
| 422 // | 416 // |
| 423 // IAccessible methods. | 417 // IAccessible methods. |
| 424 // | 418 // |
| 425 // Conventions: | 419 // Conventions: |
| 426 // * Always test for instance_active() first and return E_FAIL if it's false. | 420 // * Always test for GetOwner() and GetOwner()->instance_active first and |
| 421 // return E_FAIL if either are false. | |
| 427 // * Always check for invalid arguments first, even if they're unused. | 422 // * Always check for invalid arguments first, even if they're unused. |
| 428 // * Return S_FALSE if the only output is a string argument and it's empty. | 423 // * Return S_FALSE if the only output is a string argument and it's empty. |
| 429 // | 424 // |
| 430 | 425 |
| 431 HRESULT BrowserAccessibilityWin::accDoDefaultAction(VARIANT var_id) { | 426 HRESULT BrowserAccessibilityComWin::accDoDefaultAction(VARIANT var_id) { |
| 432 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_DO_DEFAULT_ACTION); | 427 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_DO_DEFAULT_ACTION); |
| 433 if (!instance_active()) | 428 |
| 429 if (!GetOwner() || !GetOwner()->instance_active()) | |
| 434 return E_FAIL; | 430 return E_FAIL; |
| 435 | 431 |
| 436 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); | 432 auto* manager = GetOwner()->manager(); |
| 433 if (!manager) | |
| 434 return E_FAIL; | |
| 435 | |
| 436 BrowserAccessibilityComWin* target = GetTargetFromChildID(var_id); | |
| 437 if (!target) | 437 if (!target) |
| 438 return E_INVALIDARG; | 438 return E_INVALIDARG; |
| 439 | 439 |
| 440 // Return an error if it's not clickable. | 440 // Return an error if it's not clickable. |
| 441 if (!target->HasIntAttribute(ui::AX_ATTR_ACTION)) | 441 if (!target->GetOwner()->HasIntAttribute(ui::AX_ATTR_ACTION)) |
| 442 return DISP_E_MEMBERNOTFOUND; | 442 return DISP_E_MEMBERNOTFOUND; |
| 443 | 443 |
| 444 manager_->DoDefaultAction(*target); | 444 manager->DoDefaultAction(*target->GetOwner()); |
| 445 return S_OK; | 445 return S_OK; |
| 446 } | 446 } |
| 447 | 447 |
| 448 STDMETHODIMP BrowserAccessibilityWin::accHitTest(LONG x_left, | 448 STDMETHODIMP BrowserAccessibilityComWin::accHitTest(LONG x_left, |
| 449 LONG y_top, | 449 LONG y_top, |
| 450 VARIANT* child) { | 450 VARIANT* child) { |
| 451 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_HIT_TEST); | 451 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_HIT_TEST); |
| 452 if (!instance_active()) | 452 |
| 453 if (!GetOwner() || !GetOwner()->instance_active()) | |
| 454 return E_FAIL; | |
| 455 | |
| 456 auto* manager = GetOwner()->manager(); | |
| 457 if (!manager) | |
| 453 return E_FAIL; | 458 return E_FAIL; |
| 454 | 459 |
| 455 if (!child) | 460 if (!child) |
| 456 return E_INVALIDARG; | 461 return E_INVALIDARG; |
| 457 | 462 |
| 458 gfx::Point point(x_left, y_top); | 463 gfx::Point point(x_left, y_top); |
| 459 if (!GetScreenBoundsRect().Contains(point)) { | 464 if (!GetOwner()->GetScreenBoundsRect().Contains(point)) { |
| 460 // Return S_FALSE and VT_EMPTY when outside the object's boundaries. | 465 // Return S_FALSE and VT_EMPTY when outside the object's boundaries. |
| 461 child->vt = VT_EMPTY; | 466 child->vt = VT_EMPTY; |
| 462 return S_FALSE; | 467 return S_FALSE; |
| 463 } | 468 } |
| 464 | 469 |
| 465 BrowserAccessibility* result = manager_->CachingAsyncHitTest(point); | 470 BrowserAccessibility* result = manager->CachingAsyncHitTest(point); |
| 466 if (result == this) { | 471 if (result == GetOwner()) { |
| 467 // Point is within this object. | 472 // Point is within this object. |
| 468 child->vt = VT_I4; | 473 child->vt = VT_I4; |
| 469 child->lVal = CHILDID_SELF; | 474 child->lVal = CHILDID_SELF; |
| 470 } else { | 475 } else { |
| 471 child->vt = VT_DISPATCH; | 476 child->vt = VT_DISPATCH; |
| 472 child->pdispVal = ToBrowserAccessibilityWin(result)->NewReference(); | 477 child->pdispVal = ToBrowserAccessibilityComWin(result)->NewReference(); |
| 473 } | 478 } |
| 474 return S_OK; | 479 return S_OK; |
| 475 } | 480 } |
| 476 | 481 |
| 477 STDMETHODIMP BrowserAccessibilityWin::accLocation(LONG* x_left, | 482 STDMETHODIMP BrowserAccessibilityComWin::accLocation(LONG* x_left, |
| 478 LONG* y_top, | 483 LONG* y_top, |
| 479 LONG* width, | 484 LONG* width, |
| 480 LONG* height, | 485 LONG* height, |
| 481 VARIANT var_id) { | 486 VARIANT var_id) { |
| 482 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_LOCATION); | 487 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_LOCATION); |
| 483 if (!instance_active()) | 488 if (!GetOwner() || !GetOwner()->instance_active()) |
| 484 return E_FAIL; | 489 return E_FAIL; |
| 485 | 490 |
| 486 return GetPlatformNodeWin()->accLocation(x_left, y_top, width, height, | 491 return AXPlatformNodeWin::accLocation(x_left, y_top, width, height, var_id); |
| 487 var_id); | |
| 488 } | 492 } |
| 489 | 493 |
| 490 STDMETHODIMP BrowserAccessibilityWin::accNavigate(LONG nav_dir, | 494 STDMETHODIMP BrowserAccessibilityComWin::accNavigate(LONG nav_dir, |
| 491 VARIANT start, | 495 VARIANT start, |
| 492 VARIANT* end) { | 496 VARIANT* end) { |
| 493 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_NAVIGATE); | 497 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_NAVIGATE); |
| 498 if (!GetOwner() || !GetOwner()->instance_active()) | |
| 499 return E_FAIL; | |
| 494 | 500 |
| 495 // Forward all directions but NAVDIR_ to the platform node implementation. | 501 // Forward all directions but NAVDIR_ to the platform node implementation. |
| 496 if (nav_dir != NAVDIR_DOWN && nav_dir != NAVDIR_UP && | 502 if (nav_dir != NAVDIR_DOWN && nav_dir != NAVDIR_UP && |
| 497 nav_dir != NAVDIR_LEFT && nav_dir != NAVDIR_RIGHT) { | 503 nav_dir != NAVDIR_LEFT && nav_dir != NAVDIR_RIGHT) { |
| 498 return GetPlatformNodeWin()->accNavigate(nav_dir, start, end); | 504 return AXPlatformNodeWin::accNavigate(nav_dir, start, end); |
| 499 } | 505 } |
| 500 | 506 |
| 501 BrowserAccessibilityWin* target = GetTargetFromChildID(start); | 507 BrowserAccessibilityComWin* target = GetTargetFromChildID(start); |
| 502 if (!target) | 508 if (!target) |
| 503 return E_INVALIDARG; | 509 return E_INVALIDARG; |
| 504 | 510 |
| 505 BrowserAccessibility* result = nullptr; | 511 BrowserAccessibility* result = nullptr; |
| 506 switch (nav_dir) { | 512 switch (nav_dir) { |
| 507 case NAVDIR_DOWN: | 513 case NAVDIR_DOWN: |
| 508 result = target->GetTableCell(GetTableRow() + GetTableRowSpan(), | 514 result = target->GetOwner()->GetTableCell( |
| 509 GetTableColumn()); | 515 GetOwner()->GetTableRow() + GetOwner()->GetTableRowSpan(), |
| 516 GetOwner()->GetTableColumn()); | |
| 510 break; | 517 break; |
| 511 case NAVDIR_UP: | 518 case NAVDIR_UP: |
| 512 result = target->GetTableCell(GetTableRow() - 1, GetTableColumn()); | 519 result = target->GetOwner()->GetTableCell(GetOwner()->GetTableRow() - 1, |
| 520 GetOwner()->GetTableColumn()); | |
| 513 break; | 521 break; |
| 514 case NAVDIR_LEFT: | 522 case NAVDIR_LEFT: |
| 515 result = target->GetTableCell(GetTableRow(), GetTableColumn() - 1); | 523 result = target->GetOwner()->GetTableCell( |
| 524 GetOwner()->GetTableRow(), GetOwner()->GetTableColumn() - 1); | |
| 516 break; | 525 break; |
| 517 case NAVDIR_RIGHT: | 526 case NAVDIR_RIGHT: |
| 518 result = target->GetTableCell(GetTableRow(), | 527 result = target->GetOwner()->GetTableCell( |
| 519 GetTableColumn() + GetTableColumnSpan()); | 528 GetOwner()->GetTableRow(), |
| 529 GetOwner()->GetTableColumn() + GetOwner()->GetTableColumnSpan()); | |
| 520 break; | 530 break; |
| 521 } | 531 } |
| 522 | 532 |
| 523 if (!result) { | 533 if (!result) { |
| 524 end->vt = VT_EMPTY; | 534 end->vt = VT_EMPTY; |
| 525 return S_FALSE; | 535 return S_FALSE; |
| 526 } | 536 } |
| 527 | 537 |
| 528 end->vt = VT_DISPATCH; | 538 end->vt = VT_DISPATCH; |
| 529 end->pdispVal = ToBrowserAccessibilityWin(result)->NewReference(); | 539 end->pdispVal = ToBrowserAccessibilityComWin(result)->NewReference(); |
| 530 return S_OK; | 540 return S_OK; |
| 531 } | 541 } |
| 532 | 542 |
| 533 STDMETHODIMP BrowserAccessibilityWin::get_accChild(VARIANT var_child, | 543 STDMETHODIMP BrowserAccessibilityComWin::get_accChild(VARIANT var_child, |
| 534 IDispatch** disp_child) { | 544 IDispatch** disp_child) { |
| 535 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_CHILD); | 545 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_CHILD); |
| 536 if (!instance_active()) | 546 if (!GetOwner() || !GetOwner()->instance_active()) |
| 537 return E_FAIL; | 547 return E_FAIL; |
| 538 | 548 |
| 539 if (!disp_child) | 549 if (!disp_child) |
| 540 return E_INVALIDARG; | 550 return E_INVALIDARG; |
| 541 | 551 |
| 542 *disp_child = NULL; | 552 *disp_child = NULL; |
| 543 | 553 |
| 544 BrowserAccessibilityWin* target = GetTargetFromChildID(var_child); | 554 BrowserAccessibilityComWin* target = GetTargetFromChildID(var_child); |
| 545 if (!target) | 555 if (!target) |
| 546 return E_INVALIDARG; | 556 return E_INVALIDARG; |
| 547 | 557 |
| 548 (*disp_child) = target->NewReference(); | 558 (*disp_child) = target->NewReference(); |
| 549 return S_OK; | 559 return S_OK; |
| 550 } | 560 } |
| 551 | 561 |
| 552 STDMETHODIMP BrowserAccessibilityWin::get_accChildCount(LONG* child_count) { | 562 STDMETHODIMP BrowserAccessibilityComWin::get_accChildCount(LONG* child_count) { |
| 553 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_CHILD_COUNT); | 563 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_CHILD_COUNT); |
| 554 if (!instance_active()) | 564 if (!GetOwner() || !GetOwner()->instance_active()) |
| 555 return E_FAIL; | 565 return E_FAIL; |
| 556 | 566 |
| 557 if (!child_count) | 567 if (!child_count) |
| 558 return E_INVALIDARG; | 568 return E_INVALIDARG; |
| 559 | 569 |
| 560 *child_count = PlatformChildCount(); | 570 *child_count = GetOwner()->PlatformChildCount(); |
| 561 | 571 |
| 562 return S_OK; | 572 return S_OK; |
| 563 } | 573 } |
| 564 | 574 |
| 565 STDMETHODIMP BrowserAccessibilityWin::get_accDefaultAction(VARIANT var_id, | 575 STDMETHODIMP BrowserAccessibilityComWin::get_accDefaultAction( |
| 566 BSTR* def_action) { | 576 VARIANT var_id, |
| 577 BSTR* def_action) { | |
| 567 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_DEFAULT_ACTION); | 578 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_DEFAULT_ACTION); |
| 568 if (!instance_active()) | 579 if (!GetOwner() || !GetOwner()->instance_active()) |
| 569 return E_FAIL; | 580 return E_FAIL; |
| 570 | 581 |
| 571 if (!def_action) | 582 if (!def_action) |
| 572 return E_INVALIDARG; | 583 return E_INVALIDARG; |
| 573 | 584 |
| 574 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); | 585 BrowserAccessibilityComWin* target = GetTargetFromChildID(var_id); |
| 575 if (!target) | 586 if (!target) |
| 576 return E_INVALIDARG; | 587 return E_INVALIDARG; |
| 577 | 588 |
| 578 return target->get_localizedName(0, def_action); | 589 return target->get_localizedName(0, def_action); |
| 579 } | 590 } |
| 580 | 591 |
| 581 STDMETHODIMP BrowserAccessibilityWin::get_accDescription(VARIANT var_id, | 592 STDMETHODIMP BrowserAccessibilityComWin::get_accDescription(VARIANT var_id, |
| 582 BSTR* desc) { | 593 BSTR* desc) { |
| 583 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_DESCRIPTION); | 594 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_DESCRIPTION); |
| 584 if (!instance_active()) | 595 if (!GetOwner() || !GetOwner()->instance_active()) |
| 585 return E_FAIL; | 596 return E_FAIL; |
| 586 | 597 |
| 587 if (!desc) | 598 if (!desc) |
| 588 return E_INVALIDARG; | 599 return E_INVALIDARG; |
| 589 | 600 |
| 590 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); | 601 BrowserAccessibilityComWin* target = GetTargetFromChildID(var_id); |
| 591 if (!target) | 602 if (!target) |
| 592 return E_INVALIDARG; | 603 return E_INVALIDARG; |
| 593 | 604 |
| 594 base::string16 description_str = target->description(); | 605 base::string16 description_str = target->description(); |
| 595 if (description_str.empty()) | 606 if (description_str.empty()) |
| 596 return S_FALSE; | 607 return S_FALSE; |
| 597 | 608 |
| 598 *desc = SysAllocString(description_str.c_str()); | 609 *desc = SysAllocString(description_str.c_str()); |
| 599 | 610 |
| 600 DCHECK(*desc); | 611 DCHECK(*desc); |
| 601 return S_OK; | 612 return S_OK; |
| 602 } | 613 } |
| 603 | 614 |
| 604 STDMETHODIMP BrowserAccessibilityWin::get_accFocus(VARIANT* focus_child) { | 615 STDMETHODIMP BrowserAccessibilityComWin::get_accFocus(VARIANT* focus_child) { |
| 605 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_FOCUS); | 616 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_FOCUS); |
| 606 if (!instance_active()) | 617 if (!GetOwner() || !GetOwner()->instance_active()) |
| 618 return E_FAIL; | |
| 619 | |
| 620 auto* manager = GetOwner()->manager(); | |
| 621 if (!manager) | |
| 607 return E_FAIL; | 622 return E_FAIL; |
| 608 | 623 |
| 609 if (!focus_child) | 624 if (!focus_child) |
| 610 return E_INVALIDARG; | 625 return E_INVALIDARG; |
| 611 | 626 |
| 612 BrowserAccessibilityWin* focus = | 627 BrowserAccessibilityWin* focus = |
| 613 static_cast<BrowserAccessibilityWin*>(manager_->GetFocus()); | 628 static_cast<BrowserAccessibilityWin*>(manager->GetFocus()); |
| 614 if (focus == this) { | 629 if (focus == GetOwner()) { |
| 615 focus_child->vt = VT_I4; | 630 focus_child->vt = VT_I4; |
| 616 focus_child->lVal = CHILDID_SELF; | 631 focus_child->lVal = CHILDID_SELF; |
| 617 } else if (focus == NULL) { | 632 } else if (focus == NULL) { |
| 618 focus_child->vt = VT_EMPTY; | 633 focus_child->vt = VT_EMPTY; |
| 619 } else { | 634 } else { |
| 620 focus_child->vt = VT_DISPATCH; | 635 focus_child->vt = VT_DISPATCH; |
| 621 focus_child->pdispVal = focus->NewReference(); | 636 focus_child->pdispVal = focus->GetCOM()->NewReference(); |
| 622 } | 637 } |
| 623 | 638 |
| 624 return S_OK; | 639 return S_OK; |
| 625 } | 640 } |
| 626 | 641 |
| 627 STDMETHODIMP BrowserAccessibilityWin::get_accHelp(VARIANT var_id, BSTR* help) { | 642 STDMETHODIMP BrowserAccessibilityComWin::get_accHelp(VARIANT var_id, |
| 643 BSTR* help) { | |
| 628 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_HELP); | 644 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_HELP); |
| 629 if (!instance_active()) | 645 if (!GetOwner() || !GetOwner()->instance_active()) |
| 630 return E_FAIL; | 646 return E_FAIL; |
| 631 | 647 |
| 632 return GetPlatformNodeWin()->get_accHelp(var_id, help); | 648 return AXPlatformNodeWin::get_accHelp(var_id, help); |
| 633 } | 649 } |
| 634 | 650 |
| 635 STDMETHODIMP BrowserAccessibilityWin::get_accKeyboardShortcut(VARIANT var_id, | 651 STDMETHODIMP BrowserAccessibilityComWin::get_accKeyboardShortcut( |
| 636 BSTR* acc_key) { | 652 VARIANT var_id, |
| 653 BSTR* acc_key) { | |
| 637 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_KEYBOARD_SHORTCUT); | 654 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_KEYBOARD_SHORTCUT); |
| 638 if (!instance_active()) | 655 if (!GetOwner() || !GetOwner()->instance_active()) |
| 639 return E_FAIL; | 656 return E_FAIL; |
| 640 | 657 |
| 641 if (!acc_key) | 658 if (!acc_key) |
| 642 return E_INVALIDARG; | 659 return E_INVALIDARG; |
| 643 | 660 |
| 644 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); | 661 BrowserAccessibilityComWin* target = GetTargetFromChildID(var_id); |
| 645 if (!target) | 662 if (!target) |
| 646 return E_INVALIDARG; | 663 return E_INVALIDARG; |
| 647 | 664 |
| 648 if (target->HasStringAttribute(ui::AX_ATTR_KEY_SHORTCUTS)) { | 665 if (target->HasStringAttribute(ui::AX_ATTR_KEY_SHORTCUTS)) { |
| 649 return target->GetStringAttributeAsBstr( | 666 return target->GetStringAttributeAsBstr(ui::AX_ATTR_KEY_SHORTCUTS, acc_key); |
| 650 ui::AX_ATTR_KEY_SHORTCUTS, acc_key); | |
| 651 } | 667 } |
| 652 | 668 |
| 653 return target->GetStringAttributeAsBstr( | 669 return target->GetStringAttributeAsBstr(ui::AX_ATTR_SHORTCUT, acc_key); |
| 654 ui::AX_ATTR_SHORTCUT, acc_key); | |
| 655 } | 670 } |
| 656 | 671 |
| 657 STDMETHODIMP BrowserAccessibilityWin::get_accName(VARIANT var_id, BSTR* name) { | 672 STDMETHODIMP BrowserAccessibilityComWin::get_accName(VARIANT var_id, |
| 673 BSTR* name) { | |
| 658 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_NAME); | 674 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_NAME); |
| 659 if (!instance_active()) | 675 if (!GetOwner() || !GetOwner()->instance_active()) |
| 660 return E_FAIL; | 676 return E_FAIL; |
| 661 | 677 |
| 662 return GetPlatformNodeWin()->get_accName(var_id, name); | 678 return AXPlatformNodeWin::get_accName(var_id, name); |
| 663 } | 679 } |
| 664 | 680 |
| 665 STDMETHODIMP BrowserAccessibilityWin::get_accParent(IDispatch** disp_parent) { | 681 STDMETHODIMP BrowserAccessibilityComWin::get_accParent( |
| 682 IDispatch** disp_parent) { | |
| 666 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_PARENT); | 683 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_PARENT); |
| 667 if (!instance_active()) | 684 if (!GetOwner() || !GetOwner()->instance_active()) |
| 668 return E_FAIL; | 685 return E_FAIL; |
| 669 | 686 |
| 670 if (!disp_parent) | 687 if (!disp_parent) |
| 671 return E_INVALIDARG; | 688 return E_INVALIDARG; |
| 672 | 689 |
| 673 IAccessible* parent_obj = ToBrowserAccessibilityWin(PlatformGetParent()); | 690 IAccessible* parent_obj = |
| 691 ToBrowserAccessibilityComWin(GetOwner()->PlatformGetParent()); | |
| 674 if (parent_obj == NULL) { | 692 if (parent_obj == NULL) { |
| 675 // This happens if we're the root of the tree; | 693 // This happens if we're the root of the tree; |
| 676 // return the IAccessible for the window. | 694 // return the IAccessible for the window. |
| 677 parent_obj = | 695 parent_obj = GetOwner() |
| 678 manager_->ToBrowserAccessibilityManagerWin()->GetParentIAccessible(); | 696 ->manager() |
| 697 ->ToBrowserAccessibilityManagerWin() | |
| 698 ->GetParentIAccessible(); | |
| 679 // |parent| can only be NULL if the manager was created before the parent | 699 // |parent| can only be NULL if the manager was created before the parent |
| 680 // IAccessible was known and it wasn't subsequently set before a client | 700 // IAccessible was known and it wasn't subsequently set before a client |
| 681 // requested it. This has been fixed. |parent| may also be NULL during | 701 // requested it. This has been fixed. |parent| may also be NULL during |
| 682 // destruction. Possible cases where this could occur include tabs being | 702 // destruction. Possible cases where this could occur include tabs being |
| 683 // dragged to a new window, etc. | 703 // dragged to a new window, etc. |
| 684 if (!parent_obj) { | 704 if (!parent_obj) { |
| 685 DVLOG(1) << "In Function: " << __func__ | 705 DVLOG(1) << "In Function: " << __func__ |
| 686 << ". Parent IAccessible interface is NULL. Returning failure"; | 706 << ". Parent IAccessible interface is NULL. Returning failure"; |
| 687 return E_FAIL; | 707 return E_FAIL; |
| 688 } | 708 } |
| 689 } | 709 } |
| 690 parent_obj->AddRef(); | 710 parent_obj->AddRef(); |
| 691 *disp_parent = parent_obj; | 711 *disp_parent = parent_obj; |
| 692 return S_OK; | 712 return S_OK; |
| 693 } | 713 } |
| 694 | 714 |
| 695 STDMETHODIMP BrowserAccessibilityWin::get_accRole(VARIANT var_id, | 715 STDMETHODIMP BrowserAccessibilityComWin::get_accRole(VARIANT var_id, |
| 696 VARIANT* role) { | 716 VARIANT* role) { |
| 697 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_ROLE); | 717 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_ROLE); |
| 698 if (!instance_active()) | 718 if (!GetOwner() || !GetOwner()->instance_active()) |
| 699 return E_FAIL; | 719 return E_FAIL; |
| 700 | 720 |
| 701 if (!role) | 721 if (!role) |
| 702 return E_INVALIDARG; | 722 return E_INVALIDARG; |
| 703 | 723 |
| 704 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); | 724 BrowserAccessibilityComWin* target = GetTargetFromChildID(var_id); |
| 705 if (!target) | 725 if (!target) |
| 706 return E_INVALIDARG; | 726 return E_INVALIDARG; |
| 707 | 727 |
| 708 if (!target->role_name().empty()) { | 728 if (!target->role_name().empty()) { |
| 709 role->vt = VT_BSTR; | 729 role->vt = VT_BSTR; |
| 710 role->bstrVal = SysAllocString(target->role_name().c_str()); | 730 role->bstrVal = SysAllocString(target->role_name().c_str()); |
| 711 } else { | 731 } else { |
| 712 role->vt = VT_I4; | 732 role->vt = VT_I4; |
| 713 role->lVal = target->ia_role(); | 733 role->lVal = target->ia_role(); |
| 714 } | 734 } |
| 715 return S_OK; | 735 return S_OK; |
| 716 } | 736 } |
| 717 | 737 |
| 718 STDMETHODIMP BrowserAccessibilityWin::get_accState(VARIANT var_id, | 738 STDMETHODIMP BrowserAccessibilityComWin::get_accState(VARIANT var_id, |
| 719 VARIANT* state) { | 739 VARIANT* state) { |
| 720 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_STATE); | 740 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_STATE); |
| 721 if (!instance_active()) | 741 if (!GetOwner() || !GetOwner()->instance_active()) |
| 742 return E_FAIL; | |
| 743 | |
| 744 auto* manager = GetOwner()->manager(); | |
| 745 if (!manager) | |
| 722 return E_FAIL; | 746 return E_FAIL; |
| 723 | 747 |
| 724 if (!state) | 748 if (!state) |
| 725 return E_INVALIDARG; | 749 return E_INVALIDARG; |
| 726 | 750 |
| 727 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); | 751 BrowserAccessibilityComWin* target = GetTargetFromChildID(var_id); |
| 728 if (!target) | 752 if (!target) |
| 729 return E_INVALIDARG; | 753 return E_INVALIDARG; |
| 730 | 754 |
| 731 state->vt = VT_I4; | 755 state->vt = VT_I4; |
| 732 state->lVal = target->ia_state(); | 756 state->lVal = target->ia_state(); |
| 733 if (manager_->GetFocus() == this) | 757 if (manager->GetFocus() == GetOwner()) |
| 734 state->lVal |= STATE_SYSTEM_FOCUSED; | 758 state->lVal |= STATE_SYSTEM_FOCUSED; |
| 735 | 759 |
| 736 return S_OK; | 760 return S_OK; |
| 737 } | 761 } |
| 738 | 762 |
| 739 STDMETHODIMP BrowserAccessibilityWin::get_accValue(VARIANT var_id, | 763 STDMETHODIMP BrowserAccessibilityComWin::get_accValue(VARIANT var_id, |
| 740 BSTR* value) { | 764 BSTR* value) { |
| 741 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_VALUE); | 765 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_VALUE); |
| 742 if (!instance_active()) | 766 if (!GetOwner() || !GetOwner()->instance_active()) |
| 743 return E_FAIL; | 767 return E_FAIL; |
| 744 | 768 |
| 745 if (!value) | 769 if (!value) |
| 746 return E_INVALIDARG; | 770 return E_INVALIDARG; |
| 747 | 771 |
| 748 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); | 772 BrowserAccessibilityComWin* target = GetTargetFromChildID(var_id); |
| 749 if (!target) | 773 if (!target) |
| 750 return E_INVALIDARG; | 774 return E_INVALIDARG; |
| 751 | 775 |
| 752 if (target->ia_role() == ROLE_SYSTEM_PROGRESSBAR || | 776 if (target->ia_role() == ROLE_SYSTEM_PROGRESSBAR || |
| 753 target->ia_role() == ROLE_SYSTEM_SCROLLBAR || | 777 target->ia_role() == ROLE_SYSTEM_SCROLLBAR || |
| 754 target->ia_role() == ROLE_SYSTEM_SLIDER) { | 778 target->ia_role() == ROLE_SYSTEM_SLIDER) { |
| 755 base::string16 value_text = target->GetValueText(); | 779 base::string16 value_text = target->GetValueText(); |
| 756 *value = SysAllocString(value_text.c_str()); | 780 *value = SysAllocString(value_text.c_str()); |
| 757 DCHECK(*value); | 781 DCHECK(*value); |
| 758 return S_OK; | 782 return S_OK; |
| 759 } | 783 } |
| 760 | 784 |
| 761 // Expose color well value. | 785 // Expose color well value. |
| 762 if (target->ia2_role() == IA2_ROLE_COLOR_CHOOSER) { | 786 if (target->ia2_role() == IA2_ROLE_COLOR_CHOOSER) { |
| 763 unsigned int color = static_cast<unsigned int>( | 787 unsigned int color = static_cast<unsigned int>( |
| 764 target->GetIntAttribute(ui::AX_ATTR_COLOR_VALUE)); | 788 target->GetOwner()->GetIntAttribute(ui::AX_ATTR_COLOR_VALUE)); |
| 765 unsigned int red = SkColorGetR(color); | 789 unsigned int red = SkColorGetR(color); |
| 766 unsigned int green = SkColorGetG(color); | 790 unsigned int green = SkColorGetG(color); |
| 767 unsigned int blue = SkColorGetB(color); | 791 unsigned int blue = SkColorGetB(color); |
| 768 base::string16 value_text; | 792 base::string16 value_text; |
| 769 value_text = base::UintToString16(red * 100 / 255) + L"% red " + | 793 value_text = base::UintToString16(red * 100 / 255) + L"% red " + |
| 770 base::UintToString16(green * 100 / 255) + L"% green " + | 794 base::UintToString16(green * 100 / 255) + L"% green " + |
| 771 base::UintToString16(blue * 100 / 255) + L"% blue"; | 795 base::UintToString16(blue * 100 / 255) + L"% blue"; |
| 772 *value = SysAllocString(value_text.c_str()); | 796 *value = SysAllocString(value_text.c_str()); |
| 773 DCHECK(*value); | 797 DCHECK(*value); |
| 774 return S_OK; | 798 return S_OK; |
| 775 } | 799 } |
| 776 | 800 |
| 777 *value = SysAllocString(target->value().c_str()); | 801 *value = SysAllocString(target->value().c_str()); |
| 778 DCHECK(*value); | 802 DCHECK(*value); |
| 779 return S_OK; | 803 return S_OK; |
| 780 } | 804 } |
| 781 | 805 |
| 782 STDMETHODIMP BrowserAccessibilityWin::get_accHelpTopic(BSTR* help_file, | 806 STDMETHODIMP BrowserAccessibilityComWin::get_accHelpTopic(BSTR* help_file, |
| 783 VARIANT var_id, | 807 VARIANT var_id, |
| 784 LONG* topic_id) { | 808 LONG* topic_id) { |
| 785 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_HELP_TOPIC); | 809 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_HELP_TOPIC); |
| 786 return E_NOTIMPL; | 810 return E_NOTIMPL; |
| 787 } | 811 } |
| 788 | 812 |
| 789 STDMETHODIMP BrowserAccessibilityWin::get_accSelection(VARIANT* selected) { | 813 STDMETHODIMP BrowserAccessibilityComWin::get_accSelection(VARIANT* selected) { |
| 790 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_SELECTION); | 814 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_SELECTION); |
| 791 if (!instance_active()) | 815 if (!GetOwner() || !GetOwner()->instance_active()) |
|
dmazzoni
2017/05/08 04:45:24
I don't see any purpose for BrowserAccessibility::
dougt
2017/05/08 16:53:36
I would like to only test GetOwner() in a follow u
| |
| 792 return E_FAIL; | 816 return E_FAIL; |
| 793 | 817 |
| 794 if (GetRole() != ui::AX_ROLE_LIST_BOX) | 818 if (GetOwner()->GetRole() != ui::AX_ROLE_LIST_BOX) |
| 795 return E_NOTIMPL; | 819 return E_NOTIMPL; |
| 796 | 820 |
| 797 unsigned long selected_count = 0; | 821 unsigned long selected_count = 0; |
| 798 for (size_t i = 0; i < InternalChildCount(); ++i) { | 822 for (size_t i = 0; i < GetOwner()->InternalChildCount(); ++i) { |
| 799 if (InternalGetChild(i)->HasState(ui::AX_STATE_SELECTED)) | 823 if (GetOwner()->InternalGetChild(i)->HasState(ui::AX_STATE_SELECTED)) |
| 800 ++selected_count; | 824 ++selected_count; |
| 801 } | 825 } |
| 802 | 826 |
| 803 if (selected_count == 0) { | 827 if (selected_count == 0) { |
| 804 selected->vt = VT_EMPTY; | 828 selected->vt = VT_EMPTY; |
| 805 return S_OK; | 829 return S_OK; |
| 806 } | 830 } |
| 807 | 831 |
| 808 if (selected_count == 1) { | 832 if (selected_count == 1) { |
| 809 for (size_t i = 0; i < InternalChildCount(); ++i) { | 833 for (size_t i = 0; i < GetOwner()->InternalChildCount(); ++i) { |
| 810 if (InternalGetChild(i)->HasState(ui::AX_STATE_SELECTED)) { | 834 if (GetOwner()->InternalGetChild(i)->HasState(ui::AX_STATE_SELECTED)) { |
| 811 selected->vt = VT_DISPATCH; | 835 selected->vt = VT_DISPATCH; |
| 812 selected->pdispVal = | 836 selected->pdispVal = |
| 813 ToBrowserAccessibilityWin(InternalGetChild(i))->NewReference(); | 837 ToBrowserAccessibilityComWin(GetOwner()->InternalGetChild(i)) |
| 838 ->NewReference(); | |
| 814 return S_OK; | 839 return S_OK; |
| 815 } | 840 } |
| 816 } | 841 } |
| 817 } | 842 } |
| 818 | 843 |
| 819 // Multiple items are selected. | 844 // Multiple items are selected. |
| 820 base::win::EnumVariant* enum_variant = | 845 base::win::EnumVariant* enum_variant = |
| 821 new base::win::EnumVariant(selected_count); | 846 new base::win::EnumVariant(selected_count); |
| 822 enum_variant->AddRef(); | 847 enum_variant->AddRef(); |
| 823 unsigned long index = 0; | 848 unsigned long index = 0; |
| 824 for (size_t i = 0; i < InternalChildCount(); ++i) { | 849 for (size_t i = 0; i < GetOwner()->InternalChildCount(); ++i) { |
| 825 if (InternalGetChild(i)->HasState(ui::AX_STATE_SELECTED)) { | 850 if (GetOwner()->InternalGetChild(i)->HasState(ui::AX_STATE_SELECTED)) { |
| 826 enum_variant->ItemAt(index)->vt = VT_DISPATCH; | 851 enum_variant->ItemAt(index)->vt = VT_DISPATCH; |
| 827 enum_variant->ItemAt(index)->pdispVal = | 852 enum_variant->ItemAt(index)->pdispVal = |
| 828 ToBrowserAccessibilityWin(InternalGetChild(i))->NewReference(); | 853 ToBrowserAccessibilityComWin(GetOwner()->InternalGetChild(i)) |
| 854 ->NewReference(); | |
| 829 ++index; | 855 ++index; |
| 830 } | 856 } |
| 831 } | 857 } |
| 832 selected->vt = VT_UNKNOWN; | 858 selected->vt = VT_UNKNOWN; |
| 833 selected->punkVal = static_cast<IUnknown*>( | 859 selected->punkVal = static_cast<IUnknown*>( |
| 834 static_cast<base::win::IUnknownImpl*>(enum_variant)); | 860 static_cast<base::win::IUnknownImpl*>(enum_variant)); |
| 835 return S_OK; | 861 return S_OK; |
| 836 } | 862 } |
| 837 | 863 |
| 838 STDMETHODIMP BrowserAccessibilityWin::accSelect( | 864 STDMETHODIMP BrowserAccessibilityComWin::accSelect(LONG flags_sel, |
| 839 LONG flags_sel, VARIANT var_id) { | 865 VARIANT var_id) { |
| 840 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_SELECT); | 866 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_SELECT); |
| 841 if (!instance_active()) | 867 if (!GetOwner() || !GetOwner()->instance_active()) |
| 868 return E_FAIL; | |
| 869 | |
| 870 auto* manager = GetOwner()->manager(); | |
| 871 if (!manager) | |
| 842 return E_FAIL; | 872 return E_FAIL; |
| 843 | 873 |
| 844 if (flags_sel & SELFLAG_TAKEFOCUS) { | 874 if (flags_sel & SELFLAG_TAKEFOCUS) { |
| 845 manager_->SetFocus(*this); | 875 manager->SetFocus(*GetOwner()); |
| 846 return S_OK; | 876 return S_OK; |
| 847 } | 877 } |
| 848 | 878 |
| 849 return S_FALSE; | 879 return S_FALSE; |
| 850 } | 880 } |
| 851 | 881 |
| 852 STDMETHODIMP | 882 STDMETHODIMP |
| 853 BrowserAccessibilityWin::put_accName(VARIANT var_id, BSTR put_name) { | 883 BrowserAccessibilityComWin::put_accName(VARIANT var_id, BSTR put_name) { |
| 854 return E_NOTIMPL; | 884 return E_NOTIMPL; |
| 855 } | 885 } |
| 856 STDMETHODIMP | 886 STDMETHODIMP |
| 857 BrowserAccessibilityWin::put_accValue(VARIANT var_id, BSTR put_val) { | 887 BrowserAccessibilityComWin::put_accValue(VARIANT var_id, BSTR put_val) { |
| 858 return E_NOTIMPL; | 888 return E_NOTIMPL; |
| 859 } | 889 } |
| 860 | 890 |
| 861 // | 891 // |
| 862 // IAccessible2 methods. | 892 // IAccessible2 methods. |
| 863 // | 893 // |
| 864 | 894 |
| 865 STDMETHODIMP BrowserAccessibilityWin::role(LONG* role) { | 895 STDMETHODIMP BrowserAccessibilityComWin::role(LONG* role) { |
| 866 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ROLE); | 896 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ROLE); |
| 867 if (!instance_active()) | 897 if (!GetOwner() || !GetOwner()->instance_active()) |
| 868 return E_FAIL; | 898 return E_FAIL; |
| 869 | 899 |
| 870 if (!role) | 900 if (!role) |
| 871 return E_INVALIDARG; | 901 return E_INVALIDARG; |
| 872 | 902 |
| 873 *role = ia2_role(); | 903 *role = ia2_role(); |
| 874 return S_OK; | 904 return S_OK; |
| 875 } | 905 } |
| 876 | 906 |
| 877 STDMETHODIMP BrowserAccessibilityWin::get_attributes(BSTR* attributes) { | 907 STDMETHODIMP BrowserAccessibilityComWin::get_attributes(BSTR* attributes) { |
| 878 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_IA2_GET_ATTRIBUTES); | 908 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_IA2_GET_ATTRIBUTES); |
| 909 if (!GetOwner() || !GetOwner()->instance_active()) | |
| 910 return E_FAIL; | |
| 879 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 911 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 880 if (!attributes) | 912 if (!attributes) |
| 881 return E_INVALIDARG; | 913 return E_INVALIDARG; |
| 882 *attributes = nullptr; | 914 *attributes = nullptr; |
| 883 | 915 |
| 884 if (!instance_active()) | 916 if (!GetOwner() || !GetOwner()->instance_active()) |
| 885 return E_FAIL; | 917 return E_FAIL; |
| 886 | 918 |
| 887 base::string16 str; | 919 base::string16 str; |
| 888 for (const base::string16& attribute : ia2_attributes()) | 920 for (const base::string16& attribute : ia2_attributes()) |
| 889 str += attribute + L';'; | 921 str += attribute + L';'; |
| 890 | 922 |
| 891 if (str.empty()) | 923 if (str.empty()) |
| 892 return S_FALSE; | 924 return S_FALSE; |
| 893 | 925 |
| 894 *attributes = SysAllocString(str.c_str()); | 926 *attributes = SysAllocString(str.c_str()); |
| 895 DCHECK(*attributes); | 927 DCHECK(*attributes); |
| 896 return S_OK; | 928 return S_OK; |
| 897 } | 929 } |
| 898 | 930 |
| 899 STDMETHODIMP BrowserAccessibilityWin::get_states(AccessibleStates* states) { | 931 STDMETHODIMP BrowserAccessibilityComWin::get_states(AccessibleStates* states) { |
| 900 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_STATES); | 932 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_STATES); |
| 933 if (!GetOwner() || !GetOwner()->instance_active()) | |
| 934 return E_FAIL; | |
| 901 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 935 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 902 if (!instance_active()) | |
| 903 return E_FAIL; | |
| 904 | 936 |
| 905 if (!states) | 937 if (!states) |
| 906 return E_INVALIDARG; | 938 return E_INVALIDARG; |
| 907 | 939 |
| 908 *states = ia2_state(); | 940 *states = ia2_state(); |
| 909 | 941 |
| 910 return S_OK; | 942 return S_OK; |
| 911 } | 943 } |
| 912 | 944 |
| 913 STDMETHODIMP BrowserAccessibilityWin::get_uniqueID(LONG* unique_id) { | 945 STDMETHODIMP BrowserAccessibilityComWin::get_uniqueID(LONG* unique_id) { |
| 914 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_UNIQUE_ID); | 946 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_UNIQUE_ID); |
| 915 if (!instance_active()) | 947 if (!GetOwner() || !GetOwner()->instance_active()) |
| 916 return E_FAIL; | 948 return E_FAIL; |
| 917 | 949 |
| 918 if (!unique_id) | 950 if (!unique_id) |
| 919 return E_INVALIDARG; | 951 return E_INVALIDARG; |
| 920 | 952 |
| 921 *unique_id = -this->unique_id(); | 953 *unique_id = -GetOwner()->unique_id(); |
| 922 return S_OK; | 954 return S_OK; |
| 923 } | 955 } |
| 924 | 956 |
| 925 STDMETHODIMP BrowserAccessibilityWin::get_windowHandle(HWND* window_handle) { | 957 STDMETHODIMP BrowserAccessibilityComWin::get_windowHandle(HWND* window_handle) { |
| 926 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_WINDOW_HANDLE); | 958 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_WINDOW_HANDLE); |
| 927 if (!instance_active()) | 959 if (!GetOwner() || !GetOwner()->instance_active()) |
| 928 return E_FAIL; | 960 return E_FAIL; |
| 929 | 961 |
| 930 if (!window_handle) | 962 if (!window_handle) |
| 931 return E_INVALIDARG; | 963 return E_INVALIDARG; |
| 932 | 964 |
| 933 *window_handle = | 965 *window_handle = GetOwner() |
| 934 manager_->ToBrowserAccessibilityManagerWin()->GetParentHWND(); | 966 ->manager() |
| 967 ->ToBrowserAccessibilityManagerWin() | |
|
dmazzoni
2017/05/08 04:45:24
Optional:
Since GetOwner()->manager() is used a lo
dougt
2017/05/08 16:53:36
Acknowledged. Good follow up. Noted.
| |
| 968 ->GetParentHWND(); | |
| 935 if (!*window_handle) | 969 if (!*window_handle) |
| 936 return E_FAIL; | 970 return E_FAIL; |
| 937 | 971 |
| 938 return S_OK; | 972 return S_OK; |
| 939 } | 973 } |
| 940 | 974 |
| 941 STDMETHODIMP BrowserAccessibilityWin::get_indexInParent(LONG* index_in_parent) { | 975 STDMETHODIMP BrowserAccessibilityComWin::get_indexInParent( |
| 976 LONG* index_in_parent) { | |
| 942 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_INDEX_IN_PARENT); | 977 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_INDEX_IN_PARENT); |
| 943 if (!instance_active()) | 978 if (!GetOwner() || !GetOwner()->instance_active()) |
| 944 return E_FAIL; | 979 return E_FAIL; |
| 945 | 980 |
| 946 if (!index_in_parent) | 981 if (!index_in_parent) |
| 947 return E_INVALIDARG; | 982 return E_INVALIDARG; |
| 948 | 983 |
| 949 *index_in_parent = this->GetIndexInParent(); | 984 *index_in_parent = GetIndexInParent(); |
| 950 return S_OK; | 985 return S_OK; |
| 951 } | 986 } |
| 952 | 987 |
| 953 STDMETHODIMP BrowserAccessibilityWin::get_nRelations(LONG* n_relations) { | 988 STDMETHODIMP BrowserAccessibilityComWin::get_nRelations(LONG* n_relations) { |
| 954 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_RELATIONS); | 989 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_RELATIONS); |
| 955 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 990 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 956 if (!instance_active()) | 991 if (!GetOwner() || !GetOwner()->instance_active()) |
| 957 return E_FAIL; | 992 return E_FAIL; |
| 958 | 993 |
| 959 if (!n_relations) | 994 if (!n_relations) |
| 960 return E_INVALIDARG; | 995 return E_INVALIDARG; |
| 961 | 996 |
| 962 *n_relations = relations_.size(); | 997 *n_relations = relations_.size(); |
| 963 return S_OK; | 998 return S_OK; |
| 964 } | 999 } |
| 965 | 1000 |
| 966 STDMETHODIMP BrowserAccessibilityWin::get_relation( | 1001 STDMETHODIMP BrowserAccessibilityComWin::get_relation( |
| 967 LONG relation_index, | 1002 LONG relation_index, |
| 968 IAccessibleRelation** relation) { | 1003 IAccessibleRelation** relation) { |
| 969 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_RELATION); | 1004 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_RELATION); |
| 970 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1005 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 971 if (!instance_active()) | 1006 if (!GetOwner() || !GetOwner()->instance_active()) |
| 972 return E_FAIL; | 1007 return E_FAIL; |
| 973 | 1008 |
| 974 if (relation_index < 0 || | 1009 if (relation_index < 0 || |
| 975 relation_index >= static_cast<long>(relations_.size())) { | 1010 relation_index >= static_cast<long>(relations_.size())) { |
| 976 return E_INVALIDARG; | 1011 return E_INVALIDARG; |
| 977 } | 1012 } |
| 978 | 1013 |
| 979 if (!relation) | 1014 if (!relation) |
| 980 return E_INVALIDARG; | 1015 return E_INVALIDARG; |
| 981 | 1016 |
| 982 relations_[relation_index]->AddRef(); | 1017 relations_[relation_index]->AddRef(); |
| 983 *relation = relations_[relation_index]; | 1018 *relation = relations_[relation_index]; |
| 984 return S_OK; | 1019 return S_OK; |
| 985 } | 1020 } |
| 986 | 1021 |
| 987 STDMETHODIMP BrowserAccessibilityWin::get_relations( | 1022 STDMETHODIMP BrowserAccessibilityComWin::get_relations( |
| 988 LONG max_relations, | 1023 LONG max_relations, |
| 989 IAccessibleRelation** relations, | 1024 IAccessibleRelation** relations, |
| 990 LONG* n_relations) { | 1025 LONG* n_relations) { |
| 991 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_RELATIONS); | 1026 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_RELATIONS); |
| 992 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1027 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 993 if (!instance_active()) | 1028 if (!GetOwner() || !GetOwner()->instance_active()) |
| 994 return E_FAIL; | 1029 return E_FAIL; |
| 995 | 1030 |
| 996 if (!relations || !n_relations) | 1031 if (!relations || !n_relations) |
| 997 return E_INVALIDARG; | 1032 return E_INVALIDARG; |
| 998 | 1033 |
| 999 long count = static_cast<long>(relations_.size()); | 1034 long count = static_cast<long>(relations_.size()); |
| 1000 *n_relations = count; | 1035 *n_relations = count; |
| 1001 if (count == 0) | 1036 if (count == 0) |
| 1002 return S_FALSE; | 1037 return S_FALSE; |
| 1003 | 1038 |
| 1004 for (long i = 0; i < count; ++i) { | 1039 for (long i = 0; i < count; ++i) { |
| 1005 relations_[i]->AddRef(); | 1040 relations_[i]->AddRef(); |
| 1006 relations[i] = relations_[i]; | 1041 relations[i] = relations_[i]; |
| 1007 } | 1042 } |
| 1008 | 1043 |
| 1009 return S_OK; | 1044 return S_OK; |
| 1010 } | 1045 } |
| 1011 | 1046 |
| 1012 STDMETHODIMP BrowserAccessibilityWin::scrollTo(IA2ScrollType scroll_type) { | 1047 STDMETHODIMP BrowserAccessibilityComWin::scrollTo(IA2ScrollType scroll_type) { |
| 1013 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_IA2_SCROLL_TO); | 1048 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_IA2_SCROLL_TO); |
| 1014 if (!instance_active()) | 1049 if (!GetOwner() || !GetOwner()->instance_active()) |
| 1015 return E_FAIL; | 1050 return E_FAIL; |
| 1016 | 1051 |
| 1017 gfx::Rect r = GetFrameBoundsRect(); | 1052 auto* manager = GetOwner()->manager(); |
| 1018 switch(scroll_type) { | 1053 |
| 1054 if (!manager) | |
| 1055 return E_FAIL; | |
| 1056 | |
| 1057 gfx::Rect r = GetOwner()->GetFrameBoundsRect(); | |
| 1058 switch (scroll_type) { | |
| 1019 case IA2_SCROLL_TYPE_TOP_LEFT: | 1059 case IA2_SCROLL_TYPE_TOP_LEFT: |
| 1020 manager_->ScrollToMakeVisible(*this, gfx::Rect(r.x(), r.y(), 0, 0)); | 1060 manager->ScrollToMakeVisible(*GetOwner(), gfx::Rect(r.x(), r.y(), 0, 0)); |
| 1021 break; | 1061 break; |
| 1022 case IA2_SCROLL_TYPE_BOTTOM_RIGHT: | 1062 case IA2_SCROLL_TYPE_BOTTOM_RIGHT: |
| 1023 manager_->ScrollToMakeVisible(*this, | 1063 manager->ScrollToMakeVisible(*GetOwner(), |
| 1024 gfx::Rect(r.right(), r.bottom(), 0, 0)); | 1064 gfx::Rect(r.right(), r.bottom(), 0, 0)); |
| 1025 break; | 1065 break; |
| 1026 case IA2_SCROLL_TYPE_TOP_EDGE: | 1066 case IA2_SCROLL_TYPE_TOP_EDGE: |
| 1027 manager_->ScrollToMakeVisible(*this, | 1067 manager->ScrollToMakeVisible(*GetOwner(), |
| 1028 gfx::Rect(r.x(), r.y(), r.width(), 0)); | 1068 gfx::Rect(r.x(), r.y(), r.width(), 0)); |
| 1029 break; | 1069 break; |
| 1030 case IA2_SCROLL_TYPE_BOTTOM_EDGE: | 1070 case IA2_SCROLL_TYPE_BOTTOM_EDGE: |
| 1031 manager_->ScrollToMakeVisible(*this, | 1071 manager->ScrollToMakeVisible(*GetOwner(), |
| 1032 gfx::Rect(r.x(), r.bottom(), r.width(), 0)); | 1072 gfx::Rect(r.x(), r.bottom(), r.width(), 0)); |
| 1033 break; | 1073 break; |
| 1034 case IA2_SCROLL_TYPE_LEFT_EDGE: | 1074 case IA2_SCROLL_TYPE_LEFT_EDGE: |
| 1035 manager_->ScrollToMakeVisible(*this, | 1075 manager->ScrollToMakeVisible(*GetOwner(), |
| 1036 gfx::Rect(r.x(), r.y(), 0, r.height())); | 1076 gfx::Rect(r.x(), r.y(), 0, r.height())); |
| 1037 break; | 1077 break; |
| 1038 case IA2_SCROLL_TYPE_RIGHT_EDGE: | 1078 case IA2_SCROLL_TYPE_RIGHT_EDGE: |
| 1039 manager_->ScrollToMakeVisible(*this, | 1079 manager->ScrollToMakeVisible(*GetOwner(), |
| 1040 gfx::Rect(r.right(), r.y(), 0, r.height())); | 1080 gfx::Rect(r.right(), r.y(), 0, r.height())); |
| 1041 break; | 1081 break; |
| 1042 case IA2_SCROLL_TYPE_ANYWHERE: | 1082 case IA2_SCROLL_TYPE_ANYWHERE: |
| 1043 default: | 1083 default: |
| 1044 manager_->ScrollToMakeVisible(*this, r); | 1084 manager->ScrollToMakeVisible(*GetOwner(), r); |
| 1045 break; | 1085 break; |
| 1046 } | 1086 } |
| 1047 | 1087 |
| 1048 return S_OK; | 1088 return S_OK; |
| 1049 } | 1089 } |
| 1050 | 1090 |
| 1051 STDMETHODIMP BrowserAccessibilityWin::scrollToPoint( | 1091 STDMETHODIMP BrowserAccessibilityComWin::scrollToPoint( |
| 1052 IA2CoordinateType coordinate_type, | 1092 IA2CoordinateType coordinate_type, |
| 1053 LONG x, | 1093 LONG x, |
| 1054 LONG y) { | 1094 LONG y) { |
| 1055 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SCROLL_TO_POINT); | 1095 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SCROLL_TO_POINT); |
| 1056 if (!instance_active()) | 1096 if (!GetOwner() || !GetOwner()->instance_active()) |
| 1097 return E_FAIL; | |
| 1098 | |
| 1099 auto* manager = GetOwner()->manager(); | |
| 1100 if (!manager) | |
| 1057 return E_FAIL; | 1101 return E_FAIL; |
| 1058 | 1102 |
| 1059 gfx::Point scroll_to(x, y); | 1103 gfx::Point scroll_to(x, y); |
| 1060 | 1104 |
| 1061 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { | 1105 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { |
| 1062 scroll_to -= manager_->GetViewBounds().OffsetFromOrigin(); | 1106 scroll_to -= manager->GetViewBounds().OffsetFromOrigin(); |
| 1063 } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) { | 1107 } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) { |
| 1064 if (PlatformGetParent()) | 1108 if (GetOwner()->PlatformGetParent()) |
| 1065 scroll_to += PlatformGetParent()->GetFrameBoundsRect().OffsetFromOrigin(); | 1109 scroll_to += GetOwner() |
| 1110 ->PlatformGetParent() | |
|
dmazzoni
2017/05/08 04:45:24
I think we want braces for readability since this
dougt
2017/05/08 16:53:36
Done. Two places fixed.
| |
| 1111 ->GetFrameBoundsRect() | |
| 1112 .OffsetFromOrigin(); | |
| 1066 } else { | 1113 } else { |
| 1067 return E_INVALIDARG; | 1114 return E_INVALIDARG; |
| 1068 } | 1115 } |
| 1069 | 1116 |
| 1070 manager_->ScrollToPoint(*this, scroll_to); | 1117 manager->ScrollToPoint(*GetOwner(), scroll_to); |
| 1071 | 1118 |
| 1072 return S_OK; | 1119 return S_OK; |
| 1073 } | 1120 } |
| 1074 | 1121 |
| 1075 STDMETHODIMP BrowserAccessibilityWin::get_groupPosition( | 1122 STDMETHODIMP BrowserAccessibilityComWin::get_groupPosition( |
| 1076 LONG* group_level, | 1123 LONG* group_level, |
| 1077 LONG* similar_items_in_group, | 1124 LONG* similar_items_in_group, |
| 1078 LONG* position_in_group) { | 1125 LONG* position_in_group) { |
| 1079 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_GROUP_POSITION); | 1126 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_GROUP_POSITION); |
| 1080 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1127 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1081 if (!instance_active()) | 1128 if (!GetOwner() || !GetOwner()->instance_active()) |
| 1082 return E_FAIL; | 1129 return E_FAIL; |
| 1083 | 1130 |
| 1084 if (!group_level || !similar_items_in_group || !position_in_group) | 1131 if (!group_level || !similar_items_in_group || !position_in_group) |
| 1085 return E_INVALIDARG; | 1132 return E_INVALIDARG; |
| 1086 | 1133 |
| 1087 *group_level = GetIntAttribute(ui::AX_ATTR_HIERARCHICAL_LEVEL); | 1134 *group_level = GetOwner()->GetIntAttribute(ui::AX_ATTR_HIERARCHICAL_LEVEL); |
| 1088 *similar_items_in_group = GetIntAttribute(ui::AX_ATTR_SET_SIZE); | 1135 *similar_items_in_group = GetOwner()->GetIntAttribute(ui::AX_ATTR_SET_SIZE); |
| 1089 *position_in_group = GetIntAttribute(ui::AX_ATTR_POS_IN_SET); | 1136 *position_in_group = GetOwner()->GetIntAttribute(ui::AX_ATTR_POS_IN_SET); |
| 1090 | 1137 |
| 1091 if (*group_level == *similar_items_in_group == *position_in_group == 0) | 1138 if (*group_level == *similar_items_in_group == *position_in_group == 0) |
| 1092 return S_FALSE; | 1139 return S_FALSE; |
| 1093 return S_OK; | 1140 return S_OK; |
| 1094 } | 1141 } |
| 1095 | 1142 |
| 1096 STDMETHODIMP | 1143 STDMETHODIMP |
| 1097 BrowserAccessibilityWin::get_localizedExtendedRole( | 1144 BrowserAccessibilityComWin::get_localizedExtendedRole( |
| 1098 BSTR* localized_extended_role) { | 1145 BSTR* localized_extended_role) { |
| 1099 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LOCALIZED_EXTENDED_ROLE); | 1146 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LOCALIZED_EXTENDED_ROLE); |
| 1100 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1147 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1101 | 1148 if (!GetOwner() || !GetOwner()->instance_active()) |
| 1102 if (!instance_active()) | |
| 1103 return E_FAIL; | 1149 return E_FAIL; |
| 1104 | 1150 |
| 1105 if (!localized_extended_role) | 1151 if (!localized_extended_role) |
| 1106 return E_INVALIDARG; | 1152 return E_INVALIDARG; |
| 1107 | 1153 |
| 1108 return GetStringAttributeAsBstr( | 1154 return GetStringAttributeAsBstr(ui::AX_ATTR_ROLE_DESCRIPTION, |
| 1109 ui::AX_ATTR_ROLE_DESCRIPTION, localized_extended_role); | 1155 localized_extended_role); |
| 1110 } | 1156 } |
| 1111 | 1157 |
| 1112 // | 1158 // |
| 1113 // IAccessible2 methods not implemented. | 1159 // IAccessible2 methods not implemented. |
| 1114 // | 1160 // |
| 1115 | 1161 |
| 1116 STDMETHODIMP BrowserAccessibilityWin::get_extendedRole(BSTR* extended_role) { | 1162 STDMETHODIMP BrowserAccessibilityComWin::get_extendedRole(BSTR* extended_role) { |
| 1117 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_EXTENDED_ROLE); | 1163 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_EXTENDED_ROLE); |
| 1118 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1164 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1119 return E_NOTIMPL; | 1165 return E_NOTIMPL; |
| 1120 } | 1166 } |
| 1121 STDMETHODIMP | 1167 STDMETHODIMP |
| 1122 BrowserAccessibilityWin::get_nExtendedStates(LONG* n_extended_states) { | 1168 BrowserAccessibilityComWin::get_nExtendedStates(LONG* n_extended_states) { |
| 1123 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_EXTENDED_STATES); | 1169 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_EXTENDED_STATES); |
| 1124 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1170 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1125 return E_NOTIMPL; | 1171 return E_NOTIMPL; |
| 1126 } | 1172 } |
| 1127 STDMETHODIMP | 1173 STDMETHODIMP |
| 1128 BrowserAccessibilityWin::get_extendedStates(LONG max_extended_states, | 1174 BrowserAccessibilityComWin::get_extendedStates(LONG max_extended_states, |
| 1129 BSTR** extended_states, | 1175 BSTR** extended_states, |
| 1130 LONG* n_extended_states) { | 1176 LONG* n_extended_states) { |
| 1131 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_EXTENDED_STATES); | 1177 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_EXTENDED_STATES); |
| 1132 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1178 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1133 return E_NOTIMPL; | 1179 return E_NOTIMPL; |
| 1134 } | 1180 } |
| 1135 STDMETHODIMP | 1181 STDMETHODIMP |
| 1136 BrowserAccessibilityWin::get_localizedExtendedStates( | 1182 BrowserAccessibilityComWin::get_localizedExtendedStates( |
| 1137 LONG max_localized_extended_states, | 1183 LONG max_localized_extended_states, |
| 1138 BSTR** localized_extended_states, | 1184 BSTR** localized_extended_states, |
| 1139 LONG* n_localized_extended_states) { | 1185 LONG* n_localized_extended_states) { |
| 1140 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LOCALIZED_EXTENDED_STATES); | 1186 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LOCALIZED_EXTENDED_STATES); |
| 1141 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1187 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1142 return E_NOTIMPL; | 1188 return E_NOTIMPL; |
| 1143 } | 1189 } |
| 1144 STDMETHODIMP BrowserAccessibilityWin::get_locale(IA2Locale* locale) { | 1190 STDMETHODIMP BrowserAccessibilityComWin::get_locale(IA2Locale* locale) { |
| 1145 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LOCALE); | 1191 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LOCALE); |
| 1146 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1192 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1147 return E_NOTIMPL; | 1193 return E_NOTIMPL; |
| 1148 } | 1194 } |
| 1149 | 1195 |
| 1150 // | 1196 // |
| 1151 // IAccessibleApplication methods. | 1197 // IAccessibleApplication methods. |
| 1152 // | 1198 // |
| 1153 | 1199 |
| 1154 STDMETHODIMP BrowserAccessibilityWin::get_appName(BSTR* app_name) { | 1200 STDMETHODIMP BrowserAccessibilityComWin::get_appName(BSTR* app_name) { |
| 1155 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_APP_NAME); | 1201 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_APP_NAME); |
| 1156 // No need to check |instance_active()| because this interface is | 1202 // No need to check |GetOwner()| or |GetOwner->manager()| because this |
| 1157 // global, and doesn't depend on any local state. | 1203 // interface is global, and doesn't depend on any local state. |
| 1158 | 1204 |
| 1159 if (!app_name) | 1205 if (!app_name) |
| 1160 return E_INVALIDARG; | 1206 return E_INVALIDARG; |
| 1161 | 1207 |
| 1162 // GetProduct() returns a string like "Chrome/aa.bb.cc.dd", split out | 1208 // GetProduct() returns a string like "Chrome/aa.bb.cc.dd", split out |
| 1163 // the part before the "/". | 1209 // the part before the "/". |
| 1164 std::vector<std::string> product_components = base::SplitString( | 1210 std::vector<std::string> product_components = |
| 1165 GetContentClient()->GetProduct(), "/", | 1211 base::SplitString(GetContentClient()->GetProduct(), "/", |
| 1166 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 1212 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 1167 DCHECK_EQ(2U, product_components.size()); | 1213 DCHECK_EQ(2U, product_components.size()); |
| 1168 if (product_components.size() != 2) | 1214 if (product_components.size() != 2) |
| 1169 return E_FAIL; | 1215 return E_FAIL; |
| 1170 *app_name = SysAllocString(base::UTF8ToUTF16(product_components[0]).c_str()); | 1216 *app_name = SysAllocString(base::UTF8ToUTF16(product_components[0]).c_str()); |
| 1171 DCHECK(*app_name); | 1217 DCHECK(*app_name); |
| 1172 return *app_name ? S_OK : E_FAIL; | 1218 return *app_name ? S_OK : E_FAIL; |
| 1173 } | 1219 } |
| 1174 | 1220 |
| 1175 STDMETHODIMP BrowserAccessibilityWin::get_appVersion(BSTR* app_version) { | 1221 STDMETHODIMP BrowserAccessibilityComWin::get_appVersion(BSTR* app_version) { |
| 1176 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_APP_VERSION); | 1222 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_APP_VERSION); |
| 1177 // No need to check |instance_active()| because this interface is | 1223 // No need to check |GetOwner()->manager()| because this interface is |
| 1178 // global, and doesn't depend on any local state. | 1224 // global, and doesn't depend on any local state. |
| 1179 | 1225 |
| 1180 if (!app_version) | 1226 if (!app_version) |
| 1181 return E_INVALIDARG; | 1227 return E_INVALIDARG; |
| 1182 | 1228 |
| 1183 // GetProduct() returns a string like "Chrome/aa.bb.cc.dd", split out | 1229 // GetProduct() returns a string like "Chrome/aa.bb.cc.dd", split out |
| 1184 // the part after the "/". | 1230 // the part after the "/". |
| 1185 std::vector<std::string> product_components = base::SplitString( | 1231 std::vector<std::string> product_components = |
| 1186 GetContentClient()->GetProduct(), "/", | 1232 base::SplitString(GetContentClient()->GetProduct(), "/", |
| 1187 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 1233 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 1188 DCHECK_EQ(2U, product_components.size()); | 1234 DCHECK_EQ(2U, product_components.size()); |
| 1189 if (product_components.size() != 2) | 1235 if (product_components.size() != 2) |
| 1190 return E_FAIL; | 1236 return E_FAIL; |
| 1191 *app_version = | 1237 *app_version = |
| 1192 SysAllocString(base::UTF8ToUTF16(product_components[1]).c_str()); | 1238 SysAllocString(base::UTF8ToUTF16(product_components[1]).c_str()); |
| 1193 DCHECK(*app_version); | 1239 DCHECK(*app_version); |
| 1194 return *app_version ? S_OK : E_FAIL; | 1240 return *app_version ? S_OK : E_FAIL; |
| 1195 } | 1241 } |
| 1196 | 1242 |
| 1197 STDMETHODIMP BrowserAccessibilityWin::get_toolkitName(BSTR* toolkit_name) { | 1243 STDMETHODIMP BrowserAccessibilityComWin::get_toolkitName(BSTR* toolkit_name) { |
| 1198 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_TOOLKIT_NAME); | 1244 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_TOOLKIT_NAME); |
| 1199 // No need to check |instance_active()| because this interface is | 1245 // No need to check |GetOwner()->manager()| because this interface is |
|
dmazzoni
2017/05/08 04:45:24
This is slightly confusing, how about just |GetOwn
dougt
2017/05/08 16:53:36
yeah, this comment is useless.
Basically what it'
| |
| 1200 // global, and doesn't depend on any local state. | 1246 // global, and doesn't depend on any local state. |
| 1201 | 1247 |
| 1202 if (!toolkit_name) | 1248 if (!toolkit_name) |
| 1203 return E_INVALIDARG; | 1249 return E_INVALIDARG; |
| 1204 | 1250 |
| 1205 // This is hard-coded; all products based on the Chromium engine | 1251 // This is hard-coded; all products based on the Chromium engine |
| 1206 // will have the same toolkit name, so that assistive technology can | 1252 // will have the same toolkit name, so that assistive technology can |
| 1207 // detect any Chrome-based product. | 1253 // detect any Chrome-based product. |
| 1208 *toolkit_name = SysAllocString(L"Chrome"); | 1254 *toolkit_name = SysAllocString(L"Chrome"); |
| 1209 DCHECK(*toolkit_name); | 1255 DCHECK(*toolkit_name); |
| 1210 return *toolkit_name ? S_OK : E_FAIL; | 1256 return *toolkit_name ? S_OK : E_FAIL; |
| 1211 } | 1257 } |
| 1212 | 1258 |
| 1213 STDMETHODIMP BrowserAccessibilityWin::get_toolkitVersion( | 1259 STDMETHODIMP BrowserAccessibilityComWin::get_toolkitVersion( |
| 1214 BSTR* toolkit_version) { | 1260 BSTR* toolkit_version) { |
| 1215 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_TOOLKIT_VERSION); | 1261 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_TOOLKIT_VERSION); |
| 1216 // No need to check |instance_active()| because this interface is | 1262 // No need to check |GetOwner()->manager()| because this interface is |
| 1217 // global, and doesn't depend on any local state. | 1263 // global, and doesn't depend on any local state. |
| 1218 | 1264 |
| 1219 if (!toolkit_version) | 1265 if (!toolkit_version) |
| 1220 return E_INVALIDARG; | 1266 return E_INVALIDARG; |
| 1221 | 1267 |
| 1222 std::string user_agent = GetContentClient()->GetUserAgent(); | 1268 std::string user_agent = GetContentClient()->GetUserAgent(); |
| 1223 *toolkit_version = SysAllocString(base::UTF8ToUTF16(user_agent).c_str()); | 1269 *toolkit_version = SysAllocString(base::UTF8ToUTF16(user_agent).c_str()); |
| 1224 DCHECK(*toolkit_version); | 1270 DCHECK(*toolkit_version); |
| 1225 return *toolkit_version ? S_OK : E_FAIL; | 1271 return *toolkit_version ? S_OK : E_FAIL; |
| 1226 } | 1272 } |
| 1227 | 1273 |
| 1228 // | 1274 // |
| 1229 // IAccessibleImage methods. | 1275 // IAccessibleImage methods. |
| 1230 // | 1276 // |
| 1231 | 1277 |
| 1232 STDMETHODIMP BrowserAccessibilityWin::get_description(BSTR* desc) { | 1278 STDMETHODIMP BrowserAccessibilityComWin::get_description(BSTR* desc) { |
| 1233 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_DESCRIPTION); | 1279 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_DESCRIPTION); |
| 1234 if (!instance_active()) | 1280 if (!GetOwner() || !GetOwner()->instance_active()) |
| 1235 return E_FAIL; | 1281 return E_FAIL; |
| 1236 | 1282 |
| 1237 if (!desc) | 1283 if (!desc) |
| 1238 return E_INVALIDARG; | 1284 return E_INVALIDARG; |
| 1239 | 1285 |
| 1240 if (description().empty()) | 1286 if (description().empty()) |
| 1241 return S_FALSE; | 1287 return S_FALSE; |
| 1242 | 1288 |
| 1243 *desc = SysAllocString(description().c_str()); | 1289 *desc = SysAllocString(description().c_str()); |
| 1244 | 1290 |
| 1245 DCHECK(*desc); | 1291 DCHECK(*desc); |
| 1246 return S_OK; | 1292 return S_OK; |
| 1247 } | 1293 } |
| 1248 | 1294 |
| 1249 STDMETHODIMP BrowserAccessibilityWin::get_imagePosition( | 1295 STDMETHODIMP BrowserAccessibilityComWin::get_imagePosition( |
| 1250 IA2CoordinateType coordinate_type, | 1296 IA2CoordinateType coordinate_type, |
| 1251 LONG* x, | 1297 LONG* x, |
| 1252 LONG* y) { | 1298 LONG* y) { |
| 1253 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_IMAGE_POSITION); | 1299 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_IMAGE_POSITION); |
| 1254 if (!instance_active()) | 1300 if (!GetOwner() || !GetOwner()->instance_active()) |
| 1255 return E_FAIL; | 1301 return E_FAIL; |
| 1256 | 1302 |
| 1257 if (!x || !y) | 1303 if (!x || !y) |
| 1258 return E_INVALIDARG; | 1304 return E_INVALIDARG; |
| 1259 | 1305 |
| 1260 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { | 1306 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { |
| 1261 gfx::Rect bounds = GetScreenBoundsRect(); | 1307 gfx::Rect bounds = GetOwner()->GetScreenBoundsRect(); |
| 1262 *x = bounds.x(); | 1308 *x = bounds.x(); |
| 1263 *y = bounds.y(); | 1309 *y = bounds.y(); |
| 1264 } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) { | 1310 } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) { |
| 1265 gfx::Rect bounds = GetPageBoundsRect(); | 1311 gfx::Rect bounds = GetOwner()->GetPageBoundsRect(); |
| 1266 gfx::Rect parent_bounds = PlatformGetParent() | 1312 gfx::Rect parent_bounds = |
| 1267 ? PlatformGetParent()->GetPageBoundsRect() | 1313 GetOwner()->PlatformGetParent() |
| 1268 : gfx::Rect(); | 1314 ? GetOwner()->PlatformGetParent()->GetPageBoundsRect() |
| 1315 : gfx::Rect(); | |
| 1269 *x = bounds.x() - parent_bounds.x(); | 1316 *x = bounds.x() - parent_bounds.x(); |
| 1270 *y = bounds.y() - parent_bounds.y(); | 1317 *y = bounds.y() - parent_bounds.y(); |
| 1271 } else { | 1318 } else { |
| 1272 return E_INVALIDARG; | 1319 return E_INVALIDARG; |
| 1273 } | 1320 } |
| 1274 | 1321 |
| 1275 return S_OK; | 1322 return S_OK; |
| 1276 } | 1323 } |
| 1277 | 1324 |
| 1278 STDMETHODIMP BrowserAccessibilityWin::get_imageSize(LONG* height, LONG* width) { | 1325 STDMETHODIMP BrowserAccessibilityComWin::get_imageSize(LONG* height, |
| 1326 LONG* width) { | |
| 1279 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_IMAGE_SIZE); | 1327 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_IMAGE_SIZE); |
| 1280 if (!instance_active()) | 1328 if (!GetOwner() || !GetOwner()->instance_active()) |
| 1281 return E_FAIL; | 1329 return E_FAIL; |
| 1282 | 1330 |
| 1283 if (!height || !width) | 1331 if (!height || !width) |
| 1284 return E_INVALIDARG; | 1332 return E_INVALIDARG; |
| 1285 | 1333 |
| 1286 *height = GetPageBoundsRect().height(); | 1334 *height = GetOwner()->GetPageBoundsRect().height(); |
| 1287 *width = GetPageBoundsRect().width(); | 1335 *width = GetOwner()->GetPageBoundsRect().width(); |
| 1288 return S_OK; | 1336 return S_OK; |
| 1289 } | 1337 } |
| 1290 | 1338 |
| 1291 // | 1339 // |
| 1292 // IAccessibleTable methods. | 1340 // IAccessibleTable methods. |
| 1293 // | 1341 // |
| 1294 | 1342 |
| 1295 STDMETHODIMP BrowserAccessibilityWin::get_accessibleAt( | 1343 STDMETHODIMP BrowserAccessibilityComWin::get_accessibleAt( |
| 1296 long row, | 1344 long row, |
| 1297 long column, | 1345 long column, |
| 1298 IUnknown** accessible) { | 1346 IUnknown** accessible) { |
| 1299 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACCESSIBLE_AT); | 1347 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACCESSIBLE_AT); |
| 1300 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1348 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1301 if (!instance_active()) | 1349 if (!GetOwner() || !GetOwner()->instance_active()) |
| 1302 return E_FAIL; | 1350 return E_FAIL; |
| 1303 | 1351 |
| 1304 if (!accessible) | 1352 if (!accessible) |
| 1305 return E_INVALIDARG; | 1353 return E_INVALIDARG; |
| 1306 | 1354 |
| 1307 BrowserAccessibility* cell = | 1355 BrowserAccessibility* cell = |
| 1308 GetTableCell(static_cast<int>(row), static_cast<int>(column)); | 1356 GetOwner()->GetTableCell(static_cast<int>(row), static_cast<int>(column)); |
| 1309 if (cell && ToBrowserAccessibilityWin(cell)) { | 1357 if (cell && ToBrowserAccessibilityComWin(cell)) { |
| 1310 *accessible = static_cast<IAccessible*>( | 1358 *accessible = static_cast<IAccessible*>( |
| 1311 ToBrowserAccessibilityWin(cell)->NewReference()); | 1359 ToBrowserAccessibilityComWin(cell)->NewReference()); |
| 1312 return S_OK; | 1360 return S_OK; |
| 1313 } | 1361 } |
| 1314 | 1362 |
| 1315 *accessible = nullptr; | 1363 *accessible = nullptr; |
| 1316 return E_INVALIDARG; | 1364 return E_INVALIDARG; |
| 1317 } | 1365 } |
| 1318 | 1366 |
| 1319 STDMETHODIMP BrowserAccessibilityWin::get_caption(IUnknown** accessible) { | 1367 STDMETHODIMP BrowserAccessibilityComWin::get_caption(IUnknown** accessible) { |
| 1320 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CAPTION); | 1368 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CAPTION); |
| 1321 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1369 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1322 if (!instance_active()) | 1370 if (!GetOwner() || !GetOwner()->instance_active()) |
| 1323 return E_FAIL; | 1371 return E_FAIL; |
| 1324 | 1372 |
| 1325 if (!accessible) | 1373 if (!accessible) |
| 1326 return E_INVALIDARG; | 1374 return E_INVALIDARG; |
| 1327 | 1375 |
| 1328 // TODO(dmazzoni): implement | 1376 // TODO(dmazzoni): implement |
| 1329 *accessible = nullptr; | 1377 *accessible = nullptr; |
| 1330 return S_FALSE; | 1378 return S_FALSE; |
| 1331 } | 1379 } |
| 1332 | 1380 |
| 1333 STDMETHODIMP BrowserAccessibilityWin::get_childIndex(long row, | 1381 STDMETHODIMP BrowserAccessibilityComWin::get_childIndex(long row, |
| 1334 long column, | 1382 long column, |
| 1335 long* cell_index) { | 1383 long* cell_index) { |
| 1336 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CHILD_INDEX); | 1384 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CHILD_INDEX); |
| 1337 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1385 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1338 if (!instance_active()) | 1386 if (!GetOwner() || !GetOwner()->instance_active()) |
| 1339 return E_FAIL; | 1387 return E_FAIL; |
| 1340 | 1388 |
| 1341 if (!cell_index) | 1389 if (!cell_index) |
| 1342 return E_INVALIDARG; | 1390 return E_INVALIDARG; |
| 1343 | 1391 |
| 1344 BrowserAccessibility* cell = | 1392 BrowserAccessibility* cell = |
| 1345 GetTableCell(static_cast<int>(row), static_cast<int>(column)); | 1393 GetOwner()->GetTableCell(static_cast<int>(row), static_cast<int>(column)); |
| 1346 if (cell) { | 1394 if (cell) { |
| 1347 *cell_index = static_cast<LONG>(cell->GetTableCellIndex()); | 1395 *cell_index = static_cast<LONG>(cell->GetTableCellIndex()); |
| 1348 return S_OK; | 1396 return S_OK; |
| 1349 } | 1397 } |
| 1350 | 1398 |
| 1351 *cell_index = 0; | 1399 *cell_index = 0; |
| 1352 return E_INVALIDARG; | 1400 return E_INVALIDARG; |
| 1353 } | 1401 } |
| 1354 | 1402 |
| 1355 STDMETHODIMP BrowserAccessibilityWin::get_columnDescription(long column, | 1403 STDMETHODIMP BrowserAccessibilityComWin::get_columnDescription( |
| 1356 BSTR* description) { | 1404 long column, |
| 1405 BSTR* description) { | |
| 1357 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COLUMN_DESCRIPTION); | 1406 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COLUMN_DESCRIPTION); |
| 1358 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1407 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1359 if (!instance_active()) | 1408 if (!GetOwner() || !GetOwner()->instance_active()) |
| 1360 return E_FAIL; | 1409 return E_FAIL; |
| 1361 | 1410 |
| 1362 if (!description) | 1411 if (!description) |
| 1363 return E_INVALIDARG; | 1412 return E_INVALIDARG; |
| 1364 | 1413 |
| 1365 int columns = GetTableColumnCount(); | 1414 int columns = GetOwner()->GetTableColumnCount(); |
| 1366 if (column < 0 || column >= columns) | 1415 if (column < 0 || column >= columns) |
| 1367 return E_INVALIDARG; | 1416 return E_INVALIDARG; |
| 1368 | 1417 |
| 1369 int rows = GetTableRowCount(); | 1418 int rows = GetOwner()->GetTableRowCount(); |
| 1370 if (rows <= 0) { | 1419 if (rows <= 0) { |
| 1371 *description = nullptr; | 1420 *description = nullptr; |
| 1372 return S_FALSE; | 1421 return S_FALSE; |
| 1373 } | 1422 } |
| 1374 | 1423 |
| 1375 for (int i = 0; i < rows; ++i) { | 1424 for (int i = 0; i < rows; ++i) { |
| 1376 const BrowserAccessibility* cell = GetTableCell(i, column); | 1425 BrowserAccessibility* cell = GetOwner()->GetTableCell(i, column); |
| 1377 if (ToBrowserAccessibilityWin(cell) && | 1426 if (ToBrowserAccessibilityComWin(cell) && |
| 1378 cell->GetRole() == ui::AX_ROLE_COLUMN_HEADER) { | 1427 cell->GetRole() == ui::AX_ROLE_COLUMN_HEADER) { |
| 1379 base::string16 cell_name = cell->GetString16Attribute( | 1428 base::string16 cell_name = cell->GetString16Attribute(ui::AX_ATTR_NAME); |
| 1380 ui::AX_ATTR_NAME); | |
| 1381 if (cell_name.size() > 0) { | 1429 if (cell_name.size() > 0) { |
| 1382 *description = SysAllocString(cell_name.c_str()); | 1430 *description = SysAllocString(cell_name.c_str()); |
| 1383 return S_OK; | 1431 return S_OK; |
| 1384 } | 1432 } |
| 1385 | 1433 |
| 1386 if (ToBrowserAccessibilityWin(cell)->description().size() > 0) { | 1434 if (ToBrowserAccessibilityComWin(cell)->description().size() > 0) { |
| 1387 *description = SysAllocString( | 1435 *description = SysAllocString( |
| 1388 ToBrowserAccessibilityWin(cell)->description().c_str()); | 1436 ToBrowserAccessibilityComWin(cell)->description().c_str()); |
| 1389 return S_OK; | 1437 return S_OK; |
| 1390 } | 1438 } |
| 1391 } | 1439 } |
| 1392 } | 1440 } |
| 1393 | 1441 |
| 1394 *description = nullptr; | 1442 *description = nullptr; |
| 1395 return S_FALSE; | 1443 return S_FALSE; |
| 1396 } | 1444 } |
| 1397 | 1445 |
| 1398 STDMETHODIMP BrowserAccessibilityWin::get_columnExtentAt( | 1446 STDMETHODIMP BrowserAccessibilityComWin::get_columnExtentAt( |
| 1399 long row, | 1447 long row, |
| 1400 long column, | 1448 long column, |
| 1401 long* n_columns_spanned) { | 1449 long* n_columns_spanned) { |
| 1402 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COLUMN_EXTENT_AT); | 1450 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COLUMN_EXTENT_AT); |
| 1403 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1451 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1404 if (!instance_active()) | 1452 if (!GetOwner() || !GetOwner()->instance_active()) |
| 1405 return E_FAIL; | 1453 return E_FAIL; |
| 1406 | 1454 |
| 1407 if (!n_columns_spanned) | 1455 if (!n_columns_spanned) |
| 1408 return E_INVALIDARG; | 1456 return E_INVALIDARG; |
| 1409 | 1457 |
| 1410 BrowserAccessibility* cell = | 1458 BrowserAccessibility* cell = |
| 1411 GetTableCell(static_cast<int>(row), static_cast<int>(column)); | 1459 GetOwner()->GetTableCell(static_cast<int>(row), static_cast<int>(column)); |
| 1412 if (!cell) | 1460 if (!cell) |
| 1413 return E_INVALIDARG; | 1461 return E_INVALIDARG; |
| 1414 | 1462 |
| 1415 *n_columns_spanned = cell->GetTableColumnSpan(); | 1463 *n_columns_spanned = cell->GetTableColumnSpan(); |
| 1416 return S_OK; | 1464 return S_OK; |
| 1417 } | 1465 } |
| 1418 | 1466 |
| 1419 STDMETHODIMP BrowserAccessibilityWin::get_columnHeader( | 1467 STDMETHODIMP BrowserAccessibilityComWin::get_columnHeader( |
| 1420 IAccessibleTable** accessible_table, | 1468 IAccessibleTable** accessible_table, |
| 1421 long* starting_row_index) { | 1469 long* starting_row_index) { |
| 1422 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COLUMN_HEADER); | 1470 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COLUMN_HEADER); |
| 1423 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1471 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1424 // TODO(dmazzoni): implement | 1472 // TODO(dmazzoni): implement |
| 1425 return E_NOTIMPL; | 1473 return E_NOTIMPL; |
| 1426 } | 1474 } |
| 1427 | 1475 |
| 1428 STDMETHODIMP BrowserAccessibilityWin::get_columnIndex(long cell_index, | 1476 STDMETHODIMP BrowserAccessibilityComWin::get_columnIndex(long cell_index, |
| 1429 long* column_index) { | 1477 long* column_index) { |
| 1430 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COLUMN_INDEX); | 1478 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COLUMN_INDEX); |
| 1431 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1479 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1432 if (!instance_active()) | 1480 if (!GetOwner() || !GetOwner()->instance_active()) |
| 1433 return E_FAIL; | 1481 return E_FAIL; |
| 1434 | 1482 |
| 1435 if (!column_index) | 1483 if (!column_index) |
| 1436 return E_INVALIDARG; | 1484 return E_INVALIDARG; |
| 1437 | 1485 |
| 1438 BrowserAccessibility* cell = GetTableCell(cell_index); | 1486 BrowserAccessibility* cell = GetOwner()->GetTableCell(cell_index); |
| 1439 if (!cell) | 1487 if (!cell) |
| 1440 return E_INVALIDARG; | 1488 return E_INVALIDARG; |
| 1441 *column_index = cell->GetTableColumn(); | 1489 *column_index = cell->GetTableColumn(); |
| 1442 return S_OK; | 1490 return S_OK; |
| 1443 } | 1491 } |
| 1444 | 1492 |
| 1445 STDMETHODIMP BrowserAccessibilityWin::get_nColumns(long* column_count) { | 1493 STDMETHODIMP BrowserAccessibilityComWin::get_nColumns(long* column_count) { |
| 1446 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_COLUMNS); | 1494 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_COLUMNS); |
| 1447 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1495 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1448 if (!instance_active()) | 1496 if (!GetOwner() || !GetOwner()->instance_active()) |
| 1449 return E_FAIL; | 1497 return E_FAIL; |
| 1450 | 1498 |
| 1451 if (!column_count) | 1499 if (!column_count) |
| 1452 return E_INVALIDARG; | 1500 return E_INVALIDARG; |
| 1453 | 1501 |
| 1454 *column_count = GetTableColumnCount(); | 1502 *column_count = GetOwner()->GetTableColumnCount(); |
| 1455 return S_OK; | 1503 return S_OK; |
| 1456 } | 1504 } |
| 1457 | 1505 |
| 1458 STDMETHODIMP BrowserAccessibilityWin::get_nRows(long* row_count) { | 1506 STDMETHODIMP BrowserAccessibilityComWin::get_nRows(long* row_count) { |
| 1459 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_ROWS); | 1507 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_ROWS); |
| 1460 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1508 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1461 if (!instance_active()) | 1509 if (!GetOwner() || !GetOwner()->instance_active()) |
| 1462 return E_FAIL; | 1510 return E_FAIL; |
| 1463 | 1511 |
| 1464 if (!row_count) | 1512 if (!row_count) |
| 1465 return E_INVALIDARG; | 1513 return E_INVALIDARG; |
| 1466 | 1514 |
| 1467 *row_count = GetTableRowCount(); | 1515 *row_count = GetOwner()->GetTableRowCount(); |
| 1468 return S_OK; | 1516 return S_OK; |
| 1469 } | 1517 } |
| 1470 | 1518 |
| 1471 STDMETHODIMP BrowserAccessibilityWin::get_nSelectedChildren(long* cell_count) { | 1519 STDMETHODIMP BrowserAccessibilityComWin::get_nSelectedChildren( |
| 1520 long* cell_count) { | |
| 1472 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_SELECTED_CHILDREN); | 1521 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_SELECTED_CHILDREN); |
| 1473 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1522 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1474 if (!instance_active()) | 1523 if (!GetOwner() || !GetOwner()->instance_active()) |
| 1475 return E_FAIL; | 1524 return E_FAIL; |
| 1476 | 1525 |
| 1477 if (!cell_count) | 1526 if (!cell_count) |
| 1478 return E_INVALIDARG; | 1527 return E_INVALIDARG; |
| 1479 | 1528 |
| 1480 // TODO(dmazzoni): add support for selected cells/rows/columns in tables. | 1529 // TODO(dmazzoni): add support for selected cells/rows/columns in tables. |
| 1481 *cell_count = 0; | 1530 *cell_count = 0; |
| 1482 return S_FALSE; | 1531 return S_FALSE; |
| 1483 } | 1532 } |
| 1484 | 1533 |
| 1485 STDMETHODIMP BrowserAccessibilityWin::get_nSelectedColumns(long* column_count) { | 1534 STDMETHODIMP BrowserAccessibilityComWin::get_nSelectedColumns( |
| 1535 long* column_count) { | |
| 1486 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_SELECTED_COLUMNS); | 1536 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_SELECTED_COLUMNS); |
| 1487 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1537 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1488 if (!instance_active()) | 1538 if (!GetOwner() || !GetOwner()->instance_active()) |
| 1489 return E_FAIL; | 1539 return E_FAIL; |
| 1490 | 1540 |
| 1491 if (!column_count) | 1541 if (!column_count) |
| 1492 return E_INVALIDARG; | 1542 return E_INVALIDARG; |
| 1493 | 1543 |
| 1494 *column_count = 0; | 1544 *column_count = 0; |
| 1495 return S_FALSE; | 1545 return S_FALSE; |
| 1496 } | 1546 } |
| 1497 | 1547 |
| 1498 STDMETHODIMP BrowserAccessibilityWin::get_nSelectedRows(long* row_count) { | 1548 STDMETHODIMP BrowserAccessibilityComWin::get_nSelectedRows(long* row_count) { |
| 1499 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_SELECTED_ROWS); | 1549 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_SELECTED_ROWS); |
| 1500 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1550 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1501 if (!instance_active()) | 1551 if (!GetOwner() || !GetOwner()->instance_active()) |
| 1502 return E_FAIL; | 1552 return E_FAIL; |
| 1503 | 1553 |
| 1504 if (!row_count) | 1554 if (!row_count) |
| 1505 return E_INVALIDARG; | 1555 return E_INVALIDARG; |
| 1506 | 1556 |
| 1507 *row_count = 0; | 1557 *row_count = 0; |
| 1508 return S_FALSE; | 1558 return S_FALSE; |
| 1509 } | 1559 } |
| 1510 | 1560 |
| 1511 STDMETHODIMP BrowserAccessibilityWin::get_rowDescription(long row, | 1561 STDMETHODIMP BrowserAccessibilityComWin::get_rowDescription(long row, |
| 1512 BSTR* description) { | 1562 BSTR* description) { |
| 1513 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_DESCRIPTION); | 1563 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_DESCRIPTION); |
| 1514 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1564 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1515 if (!instance_active()) | 1565 if (!GetOwner() || !GetOwner()->instance_active()) |
| 1516 return E_FAIL; | 1566 return E_FAIL; |
| 1517 | 1567 |
| 1518 if (!description) | 1568 if (!description) |
| 1519 return E_INVALIDARG; | 1569 return E_INVALIDARG; |
| 1520 | 1570 |
| 1521 if (row < 0 || row >= GetTableRowCount()) | 1571 if (row < 0 || row >= GetOwner()->GetTableRowCount()) |
| 1522 return E_INVALIDARG; | 1572 return E_INVALIDARG; |
| 1523 | 1573 |
| 1524 int columns = GetTableColumnCount(); | 1574 int columns = GetOwner()->GetTableColumnCount(); |
| 1525 if (columns <= 0) { | 1575 if (columns <= 0) { |
| 1526 *description = nullptr; | 1576 *description = nullptr; |
| 1527 return S_FALSE; | 1577 return S_FALSE; |
| 1528 } | 1578 } |
| 1529 | 1579 |
| 1530 for (int i = 0; i < columns; ++i) { | 1580 for (int i = 0; i < columns; ++i) { |
| 1531 const BrowserAccessibility* cell = GetTableCell(row, i); | 1581 BrowserAccessibility* cell = GetOwner()->GetTableCell(row, i); |
| 1532 if (ToBrowserAccessibilityWin(cell) && | 1582 if (ToBrowserAccessibilityComWin(cell) && |
| 1533 cell->GetRole() == ui::AX_ROLE_ROW_HEADER) { | 1583 cell->GetRole() == ui::AX_ROLE_ROW_HEADER) { |
| 1534 base::string16 cell_name = cell->GetString16Attribute( | 1584 base::string16 cell_name = cell->GetString16Attribute(ui::AX_ATTR_NAME); |
| 1535 ui::AX_ATTR_NAME); | |
| 1536 if (cell_name.size() > 0) { | 1585 if (cell_name.size() > 0) { |
| 1537 *description = SysAllocString(cell_name.c_str()); | 1586 *description = SysAllocString(cell_name.c_str()); |
| 1538 return S_OK; | 1587 return S_OK; |
| 1539 } | 1588 } |
| 1540 | 1589 |
| 1541 if (ToBrowserAccessibilityWin(cell)->description().size() > 0) { | 1590 if (ToBrowserAccessibilityComWin(cell)->description().size() > 0) { |
| 1542 *description = SysAllocString( | 1591 *description = SysAllocString( |
| 1543 ToBrowserAccessibilityWin(cell)->description().c_str()); | 1592 ToBrowserAccessibilityComWin(cell)->description().c_str()); |
| 1544 return S_OK; | 1593 return S_OK; |
| 1545 } | 1594 } |
| 1546 } | 1595 } |
| 1547 } | 1596 } |
| 1548 | 1597 |
| 1549 *description = nullptr; | 1598 *description = nullptr; |
| 1550 return S_FALSE; | 1599 return S_FALSE; |
| 1551 } | 1600 } |
| 1552 | 1601 |
| 1553 STDMETHODIMP BrowserAccessibilityWin::get_rowExtentAt(long row, | 1602 STDMETHODIMP BrowserAccessibilityComWin::get_rowExtentAt(long row, |
| 1554 long column, | 1603 long column, |
| 1555 long* n_rows_spanned) { | 1604 long* n_rows_spanned) { |
| 1556 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_EXTENT_AT); | 1605 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_EXTENT_AT); |
| 1557 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1606 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1558 if (!instance_active()) | 1607 if (!GetOwner() || !GetOwner()->instance_active()) |
| 1559 return E_FAIL; | 1608 return E_FAIL; |
| 1560 | 1609 |
| 1561 if (!n_rows_spanned) | 1610 if (!n_rows_spanned) |
| 1562 return E_INVALIDARG; | 1611 return E_INVALIDARG; |
| 1563 | 1612 |
| 1564 BrowserAccessibility* cell = GetTableCell(row, column); | 1613 BrowserAccessibility* cell = GetOwner()->GetTableCell(row, column); |
| 1565 if (!cell) | 1614 if (!cell) |
| 1566 return E_INVALIDARG; | 1615 return E_INVALIDARG; |
| 1567 | 1616 |
| 1568 *n_rows_spanned = GetTableRowSpan(); | 1617 *n_rows_spanned = GetOwner()->GetTableRowSpan(); |
| 1569 return S_OK; | 1618 return S_OK; |
| 1570 } | 1619 } |
| 1571 | 1620 |
| 1572 STDMETHODIMP BrowserAccessibilityWin::get_rowHeader( | 1621 STDMETHODIMP BrowserAccessibilityComWin::get_rowHeader( |
| 1573 IAccessibleTable** accessible_table, | 1622 IAccessibleTable** accessible_table, |
| 1574 long* starting_column_index) { | 1623 long* starting_column_index) { |
| 1575 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_HEADER); | 1624 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_HEADER); |
| 1576 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1625 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1577 // TODO(dmazzoni): implement | 1626 // TODO(dmazzoni): implement |
| 1578 return E_NOTIMPL; | 1627 return E_NOTIMPL; |
| 1579 } | 1628 } |
| 1580 | 1629 |
| 1581 STDMETHODIMP BrowserAccessibilityWin::get_rowIndex(long cell_index, | 1630 STDMETHODIMP BrowserAccessibilityComWin::get_rowIndex(long cell_index, |
| 1582 long* row_index) { | 1631 long* row_index) { |
| 1583 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_INDEX); | 1632 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_INDEX); |
| 1584 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1633 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1585 if (!instance_active()) | 1634 if (!GetOwner() || !GetOwner()->instance_active()) |
| 1586 return E_FAIL; | 1635 return E_FAIL; |
| 1587 | 1636 |
| 1588 if (!row_index) | 1637 if (!row_index) |
| 1589 return E_INVALIDARG; | 1638 return E_INVALIDARG; |
| 1590 | 1639 |
| 1591 BrowserAccessibility* cell = GetTableCell(cell_index); | 1640 BrowserAccessibility* cell = GetOwner()->GetTableCell(cell_index); |
| 1592 if (!cell) | 1641 if (!cell) |
| 1593 return E_INVALIDARG; | 1642 return E_INVALIDARG; |
| 1594 | 1643 |
| 1595 *row_index = cell->GetTableRow(); | 1644 *row_index = cell->GetTableRow(); |
| 1596 return S_OK; | 1645 return S_OK; |
| 1597 } | 1646 } |
| 1598 | 1647 |
| 1599 STDMETHODIMP BrowserAccessibilityWin::get_selectedChildren(long max_children, | 1648 STDMETHODIMP BrowserAccessibilityComWin::get_selectedChildren( |
| 1600 long** children, | 1649 long max_children, |
| 1601 long* n_children) { | 1650 long** children, |
| 1651 long* n_children) { | |
| 1602 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_SELECTED_CHILDREN); | 1652 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_SELECTED_CHILDREN); |
| 1603 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1653 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1604 if (!instance_active()) | 1654 if (!GetOwner() || !GetOwner()->instance_active()) |
| 1605 return E_FAIL; | 1655 return E_FAIL; |
| 1606 | 1656 |
| 1607 if (!children || !n_children) | 1657 if (!children || !n_children) |
| 1608 return E_INVALIDARG; | 1658 return E_INVALIDARG; |
| 1609 | 1659 |
| 1610 // TODO(dmazzoni): Implement this. | 1660 // TODO(dmazzoni): Implement this. |
| 1611 *n_children = 0; | 1661 *n_children = 0; |
| 1612 return S_FALSE; | 1662 return S_FALSE; |
| 1613 } | 1663 } |
| 1614 | 1664 |
| 1615 STDMETHODIMP BrowserAccessibilityWin::get_selectedColumns(long max_columns, | 1665 STDMETHODIMP BrowserAccessibilityComWin::get_selectedColumns(long max_columns, |
| 1616 long** columns, | 1666 long** columns, |
| 1617 long* n_columns) { | 1667 long* n_columns) { |
| 1618 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_SELECTED_COLUMNS); | 1668 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_SELECTED_COLUMNS); |
| 1619 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1669 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1620 if (!instance_active()) | 1670 if (!GetOwner() || !GetOwner()->instance_active()) |
| 1621 return E_FAIL; | 1671 return E_FAIL; |
| 1622 | 1672 |
| 1623 if (!columns || !n_columns) | 1673 if (!columns || !n_columns) |
| 1624 return E_INVALIDARG; | 1674 return E_INVALIDARG; |
| 1625 | 1675 |
| 1626 // TODO(dmazzoni): Implement this. | 1676 // TODO(dmazzoni): Implement this. |
| 1627 *n_columns = 0; | 1677 *n_columns = 0; |
| 1628 return S_FALSE; | 1678 return S_FALSE; |
| 1629 } | 1679 } |
| 1630 | 1680 |
| 1631 STDMETHODIMP BrowserAccessibilityWin::get_selectedRows(long max_rows, | 1681 STDMETHODIMP BrowserAccessibilityComWin::get_selectedRows(long max_rows, |
| 1632 long** rows, | 1682 long** rows, |
| 1633 long* n_rows) { | 1683 long* n_rows) { |
| 1634 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_SELECTED_ROWS); | 1684 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_SELECTED_ROWS); |
| 1635 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1685 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1636 if (!instance_active()) | 1686 if (!GetOwner() || !GetOwner()->instance_active()) |
| 1637 return E_FAIL; | 1687 return E_FAIL; |
| 1638 | 1688 |
| 1639 if (!rows || !n_rows) | 1689 if (!rows || !n_rows) |
| 1640 return E_INVALIDARG; | 1690 return E_INVALIDARG; |
| 1641 | 1691 |
| 1642 // TODO(dmazzoni): Implement this. | 1692 // TODO(dmazzoni): Implement this. |
| 1643 *n_rows = 0; | 1693 *n_rows = 0; |
| 1644 return S_FALSE; | 1694 return S_FALSE; |
| 1645 } | 1695 } |
| 1646 | 1696 |
| 1647 STDMETHODIMP BrowserAccessibilityWin::get_summary(IUnknown** accessible) { | 1697 STDMETHODIMP BrowserAccessibilityComWin::get_summary(IUnknown** accessible) { |
| 1648 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_SUMMARY); | 1698 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_SUMMARY); |
| 1649 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1699 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1650 if (!instance_active()) | 1700 if (!GetOwner() || !GetOwner()->instance_active()) |
| 1651 return E_FAIL; | 1701 return E_FAIL; |
| 1652 | 1702 |
| 1653 if (!accessible) | 1703 if (!accessible) |
| 1654 return E_INVALIDARG; | 1704 return E_INVALIDARG; |
| 1655 | 1705 |
| 1656 // TODO(dmazzoni): implement | 1706 // TODO(dmazzoni): implement |
| 1657 *accessible = nullptr; | 1707 *accessible = nullptr; |
| 1658 return S_FALSE; | 1708 return S_FALSE; |
| 1659 } | 1709 } |
| 1660 | 1710 |
| 1661 STDMETHODIMP BrowserAccessibilityWin::get_isColumnSelected( | 1711 STDMETHODIMP BrowserAccessibilityComWin::get_isColumnSelected( |
| 1662 long column, | 1712 long column, |
| 1663 boolean* is_selected) { | 1713 boolean* is_selected) { |
| 1664 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_IS_COLUMN_SELECTED); | 1714 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_IS_COLUMN_SELECTED); |
| 1665 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1715 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1666 if (!instance_active()) | 1716 if (!GetOwner() || !GetOwner()->instance_active()) |
| 1667 return E_FAIL; | 1717 return E_FAIL; |
| 1668 | 1718 |
| 1669 if (!is_selected) | 1719 if (!is_selected) |
| 1670 return E_INVALIDARG; | 1720 return E_INVALIDARG; |
| 1671 | 1721 |
| 1672 // TODO(dmazzoni): Implement this. | 1722 // TODO(dmazzoni): Implement this. |
| 1673 *is_selected = false; | 1723 *is_selected = false; |
| 1674 return S_OK; | 1724 return S_OK; |
| 1675 } | 1725 } |
| 1676 | 1726 |
| 1677 STDMETHODIMP BrowserAccessibilityWin::get_isRowSelected(long row, | 1727 STDMETHODIMP BrowserAccessibilityComWin::get_isRowSelected( |
| 1678 boolean* is_selected) { | 1728 long row, |
| 1729 boolean* is_selected) { | |
| 1679 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_IS_ROW_SELECTED); | 1730 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_IS_ROW_SELECTED); |
| 1680 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1731 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1681 if (!instance_active()) | 1732 if (!GetOwner() || !GetOwner()->instance_active()) |
| 1682 return E_FAIL; | 1733 return E_FAIL; |
| 1683 | 1734 |
| 1684 if (!is_selected) | 1735 if (!is_selected) |
| 1685 return E_INVALIDARG; | 1736 return E_INVALIDARG; |
| 1686 | 1737 |
| 1687 // TODO(dmazzoni): Implement this. | 1738 // TODO(dmazzoni): Implement this. |
| 1688 *is_selected = false; | 1739 *is_selected = false; |
| 1689 return S_OK; | 1740 return S_OK; |
| 1690 } | 1741 } |
| 1691 | 1742 |
| 1692 STDMETHODIMP BrowserAccessibilityWin::get_isSelected(long row, | 1743 STDMETHODIMP BrowserAccessibilityComWin::get_isSelected(long row, |
| 1693 long column, | 1744 long column, |
| 1694 boolean* is_selected) { | 1745 boolean* is_selected) { |
| 1695 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_IS_SELECTED); | 1746 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_IS_SELECTED); |
| 1696 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1747 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1697 if (!instance_active()) | 1748 if (!GetOwner() || !GetOwner()->instance_active()) |
| 1698 return E_FAIL; | 1749 return E_FAIL; |
| 1699 | 1750 |
| 1700 if (!is_selected) | 1751 if (!is_selected) |
| 1701 return E_INVALIDARG; | 1752 return E_INVALIDARG; |
| 1702 | 1753 |
| 1703 // TODO(dmazzoni): Implement this. | 1754 // TODO(dmazzoni): Implement this. |
| 1704 *is_selected = false; | 1755 *is_selected = false; |
| 1705 return S_OK; | 1756 return S_OK; |
| 1706 } | 1757 } |
| 1707 | 1758 |
| 1708 STDMETHODIMP BrowserAccessibilityWin::get_rowColumnExtentsAtIndex( | 1759 STDMETHODIMP BrowserAccessibilityComWin::get_rowColumnExtentsAtIndex( |
| 1709 long index, | 1760 long index, |
| 1710 long* row, | 1761 long* row, |
| 1711 long* column, | 1762 long* column, |
| 1712 long* row_extents, | 1763 long* row_extents, |
| 1713 long* column_extents, | 1764 long* column_extents, |
| 1714 boolean* is_selected) { | 1765 boolean* is_selected) { |
| 1715 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_COLUMN_EXTENTS_AT_INDEX); | 1766 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_COLUMN_EXTENTS_AT_INDEX); |
| 1716 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1767 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1717 if (!instance_active()) | 1768 if (!GetOwner() || !GetOwner()->instance_active()) |
| 1718 return E_FAIL; | 1769 return E_FAIL; |
| 1719 | 1770 |
| 1720 if (!row || !column || !row_extents || !column_extents || !is_selected) | 1771 if (!row || !column || !row_extents || !column_extents || !is_selected) |
| 1721 return E_INVALIDARG; | 1772 return E_INVALIDARG; |
| 1722 | 1773 |
| 1723 BrowserAccessibility* cell = GetTableCell(index); | 1774 BrowserAccessibility* cell = GetOwner()->GetTableCell(index); |
| 1724 if (!cell) | 1775 if (!cell) |
| 1725 return E_INVALIDARG; | 1776 return E_INVALIDARG; |
| 1726 | 1777 |
| 1727 *row = cell->GetTableRow(); | 1778 *row = cell->GetTableRow(); |
| 1728 *column = cell->GetTableColumn(); | 1779 *column = cell->GetTableColumn(); |
| 1729 *row_extents = GetTableRowSpan(); | 1780 *row_extents = GetOwner()->GetTableRowSpan(); |
| 1730 *column_extents = GetTableColumnSpan(); | 1781 *column_extents = GetOwner()->GetTableColumnSpan(); |
| 1731 *is_selected = false; // Not supported. | 1782 *is_selected = false; // Not supported. |
| 1732 | 1783 |
| 1733 return S_OK; | 1784 return S_OK; |
| 1734 } | 1785 } |
| 1735 | 1786 |
| 1736 STDMETHODIMP BrowserAccessibilityWin::selectRow(long row) { | 1787 STDMETHODIMP BrowserAccessibilityComWin::selectRow(long row) { |
| 1737 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SELECT_ROW); | 1788 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SELECT_ROW); |
| 1738 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1789 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1739 return E_NOTIMPL; | 1790 return E_NOTIMPL; |
| 1740 } | 1791 } |
| 1741 | 1792 |
| 1742 STDMETHODIMP BrowserAccessibilityWin::selectColumn(long column) { | 1793 STDMETHODIMP BrowserAccessibilityComWin::selectColumn(long column) { |
| 1743 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SELECT_COLUMN); | 1794 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SELECT_COLUMN); |
| 1744 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1795 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1745 return E_NOTIMPL; | 1796 return E_NOTIMPL; |
| 1746 } | 1797 } |
| 1747 | 1798 |
| 1748 STDMETHODIMP BrowserAccessibilityWin::unselectRow(long row) { | 1799 STDMETHODIMP BrowserAccessibilityComWin::unselectRow(long row) { |
| 1749 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_UNSELECT_ROW); | 1800 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_UNSELECT_ROW); |
| 1750 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1801 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1751 return E_NOTIMPL; | 1802 return E_NOTIMPL; |
| 1752 } | 1803 } |
| 1753 | 1804 |
| 1754 STDMETHODIMP BrowserAccessibilityWin::unselectColumn(long column) { | 1805 STDMETHODIMP BrowserAccessibilityComWin::unselectColumn(long column) { |
| 1755 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_UNSELECT_COLUMN); | 1806 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_UNSELECT_COLUMN); |
| 1756 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1807 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1757 return E_NOTIMPL; | 1808 return E_NOTIMPL; |
| 1758 } | 1809 } |
| 1759 | 1810 |
| 1760 STDMETHODIMP | 1811 STDMETHODIMP |
| 1761 BrowserAccessibilityWin::get_modelChange(IA2TableModelChange* model_change) { | 1812 BrowserAccessibilityComWin::get_modelChange(IA2TableModelChange* model_change) { |
| 1762 return E_NOTIMPL; | 1813 return E_NOTIMPL; |
| 1763 } | 1814 } |
| 1764 | 1815 |
| 1765 // | 1816 // |
| 1766 // IAccessibleTable2 methods. | 1817 // IAccessibleTable2 methods. |
| 1767 // | 1818 // |
| 1768 | 1819 |
| 1769 STDMETHODIMP BrowserAccessibilityWin::get_cellAt(long row, | 1820 STDMETHODIMP BrowserAccessibilityComWin::get_cellAt(long row, |
| 1770 long column, | 1821 long column, |
| 1771 IUnknown** cell) { | 1822 IUnknown** cell) { |
| 1772 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CELL_AT); | 1823 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CELL_AT); |
| 1773 AddAccessibilityModeFlags(AccessibilityMode::kScreenReader); | 1824 AddAccessibilityModeFlags(AccessibilityMode::kScreenReader); |
| 1774 if (!instance_active()) | 1825 if (!GetOwner() || !GetOwner()->instance_active()) |
| 1775 return E_FAIL; | 1826 return E_FAIL; |
| 1776 | 1827 |
| 1777 if (!cell) | 1828 if (!cell) |
| 1778 return E_INVALIDARG; | 1829 return E_INVALIDARG; |
| 1779 | 1830 |
| 1780 BrowserAccessibility* table_cell = | 1831 BrowserAccessibility* table_cell = |
| 1781 GetTableCell(static_cast<int>(row), static_cast<int>(column)); | 1832 GetOwner()->GetTableCell(static_cast<int>(row), static_cast<int>(column)); |
| 1782 if (ToBrowserAccessibilityWin(table_cell)) { | 1833 if (ToBrowserAccessibilityComWin(table_cell)) { |
| 1783 return ToBrowserAccessibilityWin(table_cell) | 1834 return ToBrowserAccessibilityComWin(table_cell) |
| 1784 ->QueryInterface(IID_IUnknown, reinterpret_cast<void**>(cell)); | 1835 ->QueryInterface(IID_IUnknown, reinterpret_cast<void**>(cell)); |
| 1785 } | 1836 } |
| 1786 | 1837 |
| 1787 *cell = nullptr; | 1838 *cell = nullptr; |
| 1788 return E_INVALIDARG; | 1839 return E_INVALIDARG; |
| 1789 } | 1840 } |
| 1790 | 1841 |
| 1791 STDMETHODIMP BrowserAccessibilityWin::get_nSelectedCells(long* cell_count) { | 1842 STDMETHODIMP BrowserAccessibilityComWin::get_nSelectedCells(long* cell_count) { |
| 1792 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_SELECTED_CELLS); | 1843 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_SELECTED_CELLS); |
| 1793 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1844 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1794 return get_nSelectedChildren(cell_count); | 1845 return get_nSelectedChildren(cell_count); |
| 1795 } | 1846 } |
| 1796 | 1847 |
| 1797 STDMETHODIMP BrowserAccessibilityWin::get_selectedCells( | 1848 STDMETHODIMP BrowserAccessibilityComWin::get_selectedCells( |
| 1798 IUnknown*** cells, | 1849 IUnknown*** cells, |
| 1799 long* n_selected_cells) { | 1850 long* n_selected_cells) { |
| 1800 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_SELECTED_CELLS); | 1851 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_SELECTED_CELLS); |
| 1801 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1852 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1802 if (!instance_active()) | 1853 if (!GetOwner() || !GetOwner()->instance_active()) |
| 1803 return E_FAIL; | 1854 return E_FAIL; |
| 1804 | 1855 |
| 1805 if (!cells || !n_selected_cells) | 1856 if (!cells || !n_selected_cells) |
| 1806 return E_INVALIDARG; | 1857 return E_INVALIDARG; |
| 1807 | 1858 |
| 1808 // TODO(dmazzoni): Implement this. | 1859 // TODO(dmazzoni): Implement this. |
| 1809 *n_selected_cells = 0; | 1860 *n_selected_cells = 0; |
| 1810 return S_OK; | 1861 return S_OK; |
| 1811 } | 1862 } |
| 1812 | 1863 |
| 1813 STDMETHODIMP BrowserAccessibilityWin::get_selectedColumns(long** columns, | 1864 STDMETHODIMP BrowserAccessibilityComWin::get_selectedColumns(long** columns, |
| 1814 long* n_columns) { | 1865 long* n_columns) { |
| 1815 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_TABLE2_GET_SELECTED_COLUMNS); | 1866 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_TABLE2_GET_SELECTED_COLUMNS); |
| 1816 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1867 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1817 if (!instance_active()) | 1868 if (!GetOwner() || !GetOwner()->instance_active()) |
| 1818 return E_FAIL; | 1869 return E_FAIL; |
| 1819 | 1870 |
| 1820 if (!columns || !n_columns) | 1871 if (!columns || !n_columns) |
| 1821 return E_INVALIDARG; | 1872 return E_INVALIDARG; |
| 1822 | 1873 |
| 1823 // TODO(dmazzoni): Implement this. | 1874 // TODO(dmazzoni): Implement this. |
| 1824 *n_columns = 0; | 1875 *n_columns = 0; |
| 1825 return S_OK; | 1876 return S_OK; |
| 1826 } | 1877 } |
| 1827 | 1878 |
| 1828 STDMETHODIMP BrowserAccessibilityWin::get_selectedRows(long** rows, | 1879 STDMETHODIMP BrowserAccessibilityComWin::get_selectedRows(long** rows, |
| 1829 long* n_rows) { | 1880 long* n_rows) { |
| 1830 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_TABLE2_GET_SELECTED_ROWS); | 1881 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_TABLE2_GET_SELECTED_ROWS); |
| 1831 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1882 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1832 if (!instance_active()) | 1883 if (!GetOwner() || !GetOwner()->instance_active()) |
| 1833 return E_FAIL; | 1884 return E_FAIL; |
| 1834 | 1885 |
| 1835 if (!rows || !n_rows) | 1886 if (!rows || !n_rows) |
| 1836 return E_INVALIDARG; | 1887 return E_INVALIDARG; |
| 1837 | 1888 |
| 1838 // TODO(dmazzoni): Implement this. | 1889 // TODO(dmazzoni): Implement this. |
| 1839 *n_rows = 0; | 1890 *n_rows = 0; |
| 1840 return S_OK; | 1891 return S_OK; |
| 1841 } | 1892 } |
| 1842 | 1893 |
| 1843 | |
| 1844 // | 1894 // |
| 1845 // IAccessibleTableCell methods. | 1895 // IAccessibleTableCell methods. |
| 1846 // | 1896 // |
| 1847 | 1897 |
| 1848 STDMETHODIMP BrowserAccessibilityWin::get_columnExtent( | 1898 STDMETHODIMP BrowserAccessibilityComWin::get_columnExtent( |
| 1849 long* n_columns_spanned) { | 1899 long* n_columns_spanned) { |
| 1850 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COLUMN_EXTENT); | 1900 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COLUMN_EXTENT); |
| 1851 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1901 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1852 if (!instance_active()) | 1902 if (!GetOwner() || !GetOwner()->instance_active()) |
| 1853 return E_FAIL; | 1903 return E_FAIL; |
| 1854 | 1904 |
| 1855 if (!n_columns_spanned) | 1905 if (!n_columns_spanned) |
| 1856 return E_INVALIDARG; | 1906 return E_INVALIDARG; |
| 1857 | 1907 |
| 1858 *n_columns_spanned = GetTableColumnSpan(); | 1908 *n_columns_spanned = GetOwner()->GetTableColumnSpan(); |
| 1859 return S_OK; | 1909 return S_OK; |
| 1860 } | 1910 } |
| 1861 | 1911 |
| 1862 STDMETHODIMP BrowserAccessibilityWin::get_columnHeaderCells( | 1912 STDMETHODIMP BrowserAccessibilityComWin::get_columnHeaderCells( |
| 1863 IUnknown*** cell_accessibles, | 1913 IUnknown*** cell_accessibles, |
| 1864 long* n_column_header_cells) { | 1914 long* n_column_header_cells) { |
| 1865 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COLUMN_HEADER_CELLS); | 1915 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COLUMN_HEADER_CELLS); |
| 1866 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1916 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1867 if (!instance_active()) | 1917 if (!GetOwner() || !GetOwner()->instance_active()) |
| 1868 return E_FAIL; | 1918 return E_FAIL; |
| 1869 | 1919 |
| 1870 if (!cell_accessibles || !n_column_header_cells) | 1920 if (!cell_accessibles || !n_column_header_cells) |
| 1871 return E_INVALIDARG; | 1921 return E_INVALIDARG; |
| 1872 | 1922 |
| 1873 *n_column_header_cells = 0; | 1923 *n_column_header_cells = 0; |
| 1874 BrowserAccessibility* table = GetTable(); | 1924 BrowserAccessibility* table = GetOwner()->GetTable(); |
| 1875 if (!table) { | 1925 if (!table) { |
| 1876 NOTREACHED(); | 1926 NOTREACHED(); |
| 1877 return S_FALSE; | 1927 return S_FALSE; |
| 1878 } | 1928 } |
| 1879 | 1929 |
| 1880 int column = GetTableColumn(); | 1930 int column = GetOwner()->GetTableColumn(); |
| 1881 int columns = GetTableColumnCount(); | 1931 int columns = GetOwner()->GetTableColumnCount(); |
| 1882 int rows = GetTableRowCount(); | 1932 int rows = GetOwner()->GetTableRowCount(); |
| 1883 if (columns <= 0 || rows <= 0 || column < 0 || column >= columns) | 1933 if (columns <= 0 || rows <= 0 || column < 0 || column >= columns) |
| 1884 return S_FALSE; | 1934 return S_FALSE; |
| 1885 | 1935 |
| 1886 for (int i = 0; i < rows; ++i) { | 1936 for (int i = 0; i < rows; ++i) { |
| 1887 BrowserAccessibility* cell = GetTableCell(i, column); | 1937 BrowserAccessibility* cell = GetOwner()->GetTableCell(i, column); |
| 1888 if (cell && cell->GetRole() == ui::AX_ROLE_COLUMN_HEADER) | 1938 if (cell && cell->GetRole() == ui::AX_ROLE_COLUMN_HEADER) |
| 1889 (*n_column_header_cells)++; | 1939 (*n_column_header_cells)++; |
| 1890 } | 1940 } |
| 1891 | 1941 |
| 1892 *cell_accessibles = static_cast<IUnknown**>(CoTaskMemAlloc( | 1942 *cell_accessibles = static_cast<IUnknown**>( |
| 1893 (*n_column_header_cells) * sizeof(cell_accessibles[0]))); | 1943 CoTaskMemAlloc((*n_column_header_cells) * sizeof(cell_accessibles[0]))); |
| 1894 int index = 0; | 1944 int index = 0; |
| 1895 for (int i = 0; i < rows; ++i) { | 1945 for (int i = 0; i < rows; ++i) { |
| 1896 BrowserAccessibility* cell = GetTableCell(i, column); | 1946 BrowserAccessibility* cell = GetOwner()->GetTableCell(i, column); |
| 1897 if (cell && cell->GetRole() == ui::AX_ROLE_COLUMN_HEADER) { | 1947 if (cell && cell->GetRole() == ui::AX_ROLE_COLUMN_HEADER) { |
| 1898 (*cell_accessibles)[index] = static_cast<IAccessible*>( | 1948 (*cell_accessibles)[index] = static_cast<IAccessible*>( |
| 1899 ToBrowserAccessibilityWin(cell)->NewReference()); | 1949 ToBrowserAccessibilityComWin(cell)->NewReference()); |
| 1900 ++index; | 1950 ++index; |
| 1901 } | 1951 } |
| 1902 } | 1952 } |
| 1903 | 1953 |
| 1904 return S_OK; | 1954 return S_OK; |
| 1905 } | 1955 } |
| 1906 | 1956 |
| 1907 STDMETHODIMP BrowserAccessibilityWin::get_columnIndex(long* column_index) { | 1957 STDMETHODIMP BrowserAccessibilityComWin::get_columnIndex(long* column_index) { |
| 1908 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_TABLECELL_GET_COLUMN_INDEX); | 1958 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_TABLECELL_GET_COLUMN_INDEX); |
| 1909 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1959 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1910 if (!instance_active()) | 1960 if (!GetOwner() || !GetOwner()->instance_active()) |
| 1911 return E_FAIL; | 1961 return E_FAIL; |
| 1912 | 1962 |
| 1913 if (!column_index) | 1963 if (!column_index) |
| 1914 return E_INVALIDARG; | 1964 return E_INVALIDARG; |
| 1915 | 1965 |
| 1916 *column_index = GetTableColumn(); | 1966 *column_index = GetOwner()->GetTableColumn(); |
| 1917 return S_OK; | 1967 return S_OK; |
| 1918 } | 1968 } |
| 1919 | 1969 |
| 1920 STDMETHODIMP BrowserAccessibilityWin::get_rowExtent(long* n_rows_spanned) { | 1970 STDMETHODIMP BrowserAccessibilityComWin::get_rowExtent(long* n_rows_spanned) { |
| 1921 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_EXTENT); | 1971 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_EXTENT); |
| 1922 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1972 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1923 if (!instance_active()) | 1973 if (!GetOwner() || !GetOwner()->instance_active()) |
| 1924 return E_FAIL; | 1974 return E_FAIL; |
| 1925 | 1975 |
| 1926 if (!n_rows_spanned) | 1976 if (!n_rows_spanned) |
| 1927 return E_INVALIDARG; | 1977 return E_INVALIDARG; |
| 1928 | 1978 |
| 1929 *n_rows_spanned = GetTableRowSpan(); | 1979 *n_rows_spanned = GetOwner()->GetTableRowSpan(); |
| 1930 return S_OK; | 1980 return S_OK; |
| 1931 } | 1981 } |
| 1932 | 1982 |
| 1933 STDMETHODIMP BrowserAccessibilityWin::get_rowHeaderCells( | 1983 STDMETHODIMP BrowserAccessibilityComWin::get_rowHeaderCells( |
| 1934 IUnknown*** cell_accessibles, | 1984 IUnknown*** cell_accessibles, |
| 1935 long* n_row_header_cells) { | 1985 long* n_row_header_cells) { |
| 1936 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_HEADER_CELLS); | 1986 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_HEADER_CELLS); |
| 1937 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 1987 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1938 if (!instance_active()) | 1988 if (!GetOwner() || !GetOwner()->instance_active()) |
| 1939 return E_FAIL; | 1989 return E_FAIL; |
| 1940 | 1990 |
| 1941 if (!cell_accessibles || !n_row_header_cells) | 1991 if (!cell_accessibles || !n_row_header_cells) |
| 1942 return E_INVALIDARG; | 1992 return E_INVALIDARG; |
| 1943 | 1993 |
| 1944 *n_row_header_cells = 0; | 1994 *n_row_header_cells = 0; |
| 1945 BrowserAccessibility* table = GetTable(); | 1995 BrowserAccessibility* table = GetOwner()->GetTable(); |
| 1946 if (!table) { | 1996 if (!table) { |
| 1947 NOTREACHED(); | 1997 NOTREACHED(); |
| 1948 return S_FALSE; | 1998 return S_FALSE; |
| 1949 } | 1999 } |
| 1950 | 2000 |
| 1951 int row = GetTableRow(); | 2001 int row = GetOwner()->GetTableRow(); |
| 1952 int columns = GetTableColumnCount(); | 2002 int columns = GetOwner()->GetTableColumnCount(); |
| 1953 int rows = GetTableRowCount(); | 2003 int rows = GetOwner()->GetTableRowCount(); |
| 1954 if (columns <= 0 || rows <= 0 || row < 0 || row >= rows) | 2004 if (columns <= 0 || rows <= 0 || row < 0 || row >= rows) |
| 1955 return S_FALSE; | 2005 return S_FALSE; |
| 1956 | 2006 |
| 1957 for (int i = 0; i < columns; ++i) { | 2007 for (int i = 0; i < columns; ++i) { |
| 1958 BrowserAccessibility* cell = GetTableCell(row, i); | 2008 BrowserAccessibility* cell = GetOwner()->GetTableCell(row, i); |
| 1959 if (cell && cell->GetRole() == ui::AX_ROLE_ROW_HEADER) | 2009 if (cell && cell->GetRole() == ui::AX_ROLE_ROW_HEADER) |
| 1960 (*n_row_header_cells)++; | 2010 (*n_row_header_cells)++; |
| 1961 } | 2011 } |
| 1962 | 2012 |
| 1963 *cell_accessibles = static_cast<IUnknown**>(CoTaskMemAlloc( | 2013 *cell_accessibles = static_cast<IUnknown**>( |
| 1964 (*n_row_header_cells) * sizeof(cell_accessibles[0]))); | 2014 CoTaskMemAlloc((*n_row_header_cells) * sizeof(cell_accessibles[0]))); |
| 1965 int index = 0; | 2015 int index = 0; |
| 1966 for (int i = 0; i < columns; ++i) { | 2016 for (int i = 0; i < columns; ++i) { |
| 1967 BrowserAccessibility* cell = GetTableCell(row, i); | 2017 BrowserAccessibility* cell = GetOwner()->GetTableCell(row, i); |
| 1968 if (cell && cell->GetRole() == ui::AX_ROLE_ROW_HEADER) { | 2018 if (cell && cell->GetRole() == ui::AX_ROLE_ROW_HEADER) { |
| 1969 (*cell_accessibles)[index] = static_cast<IAccessible*>( | 2019 (*cell_accessibles)[index] = static_cast<IAccessible*>( |
| 1970 ToBrowserAccessibilityWin(cell)->NewReference()); | 2020 ToBrowserAccessibilityComWin(cell)->NewReference()); |
| 1971 ++index; | 2021 ++index; |
| 1972 } | 2022 } |
| 1973 } | 2023 } |
| 1974 | 2024 |
| 1975 return S_OK; | 2025 return S_OK; |
| 1976 } | 2026 } |
| 1977 | 2027 |
| 1978 STDMETHODIMP BrowserAccessibilityWin::get_rowIndex(long* row_index) { | 2028 STDMETHODIMP BrowserAccessibilityComWin::get_rowIndex(long* row_index) { |
| 1979 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_TABLECELL_GET_ROW_INDEX); | 2029 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_TABLECELL_GET_ROW_INDEX); |
| 1980 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2030 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1981 if (!instance_active()) | 2031 if (!GetOwner() || !GetOwner()->instance_active()) |
| 1982 return E_FAIL; | 2032 return E_FAIL; |
| 1983 | 2033 |
| 1984 if (!row_index) | 2034 if (!row_index) |
| 1985 return E_INVALIDARG; | 2035 return E_INVALIDARG; |
| 1986 | 2036 |
| 1987 *row_index = GetTableRow(); | 2037 *row_index = GetOwner()->GetTableRow(); |
| 1988 return S_OK; | 2038 return S_OK; |
| 1989 } | 2039 } |
| 1990 | 2040 |
| 1991 STDMETHODIMP BrowserAccessibilityWin::get_isSelected(boolean* is_selected) { | 2041 STDMETHODIMP BrowserAccessibilityComWin::get_isSelected(boolean* is_selected) { |
| 1992 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_TABLECELL_GET_IS_SELECTED); | 2042 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_TABLECELL_GET_IS_SELECTED); |
| 1993 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2043 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 1994 if (!instance_active()) | 2044 if (!GetOwner() || !GetOwner()->instance_active()) |
| 1995 return E_FAIL; | 2045 return E_FAIL; |
| 1996 | 2046 |
| 1997 if (!is_selected) | 2047 if (!is_selected) |
| 1998 return E_INVALIDARG; | 2048 return E_INVALIDARG; |
| 1999 | 2049 |
| 2000 *is_selected = false; | 2050 *is_selected = false; |
| 2001 return S_OK; | 2051 return S_OK; |
| 2002 } | 2052 } |
| 2003 | 2053 |
| 2004 STDMETHODIMP BrowserAccessibilityWin::get_rowColumnExtents( | 2054 STDMETHODIMP BrowserAccessibilityComWin::get_rowColumnExtents( |
| 2005 long* row_index, | 2055 long* row_index, |
| 2006 long* column_index, | 2056 long* column_index, |
| 2007 long* row_extents, | 2057 long* row_extents, |
| 2008 long* column_extents, | 2058 long* column_extents, |
| 2009 boolean* is_selected) { | 2059 boolean* is_selected) { |
| 2010 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_COLUMN_EXTENTS); | 2060 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_COLUMN_EXTENTS); |
| 2011 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2061 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2012 if (!instance_active()) | 2062 if (!GetOwner() || !GetOwner()->instance_active()) |
| 2013 return E_FAIL; | 2063 return E_FAIL; |
| 2014 | 2064 |
| 2015 if (!row_index || | 2065 if (!row_index || !column_index || !row_extents || !column_extents || |
| 2016 !column_index || | |
| 2017 !row_extents || | |
| 2018 !column_extents || | |
| 2019 !is_selected) { | 2066 !is_selected) { |
| 2020 return E_INVALIDARG; | 2067 return E_INVALIDARG; |
| 2021 } | 2068 } |
| 2022 | 2069 |
| 2023 *row_index = GetTableRow(); | 2070 *row_index = GetOwner()->GetTableRow(); |
| 2024 *column_index = GetTableColumn(); | 2071 *column_index = GetOwner()->GetTableColumn(); |
| 2025 *row_extents = GetTableRowSpan(); | 2072 *row_extents = GetOwner()->GetTableRowSpan(); |
| 2026 *column_extents = GetTableColumnSpan(); | 2073 *column_extents = GetOwner()->GetTableColumnSpan(); |
| 2027 *is_selected = false; // Not supported. | 2074 *is_selected = false; // Not supported. |
| 2028 | 2075 |
| 2029 return S_OK; | 2076 return S_OK; |
| 2030 } | 2077 } |
| 2031 | 2078 |
| 2032 STDMETHODIMP BrowserAccessibilityWin::get_table(IUnknown** table) { | 2079 STDMETHODIMP BrowserAccessibilityComWin::get_table(IUnknown** table) { |
| 2033 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_TABLE); | 2080 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_TABLE); |
| 2034 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2081 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2035 if (!instance_active()) | 2082 if (!GetOwner() || !GetOwner()->instance_active()) |
| 2036 return E_FAIL; | 2083 return E_FAIL; |
| 2037 | 2084 |
| 2038 if (!table) | 2085 if (!table) |
| 2039 return E_INVALIDARG; | 2086 return E_INVALIDARG; |
| 2040 | 2087 |
| 2041 BrowserAccessibility* find_table = GetTable(); | 2088 BrowserAccessibility* find_table = GetOwner()->GetTable(); |
| 2042 if (!find_table || !ToBrowserAccessibilityWin(find_table)) { | 2089 if (!find_table || !ToBrowserAccessibilityComWin(find_table)) { |
| 2043 *table = nullptr; | 2090 *table = nullptr; |
| 2044 return S_FALSE; | 2091 return S_FALSE; |
| 2045 } | 2092 } |
| 2046 | 2093 |
| 2047 *table = static_cast<IAccessibleTable*>( | 2094 *table = static_cast<IAccessibleTable*>( |
| 2048 ToBrowserAccessibilityWin(find_table)->NewReference()); | 2095 ToBrowserAccessibilityComWin(find_table)->NewReference()); |
| 2049 return S_OK; | 2096 return S_OK; |
| 2050 } | 2097 } |
| 2051 | 2098 |
| 2052 // | 2099 // |
| 2053 // IAccessibleText methods. | 2100 // IAccessibleText methods. |
| 2054 // | 2101 // |
| 2055 | 2102 |
| 2056 STDMETHODIMP BrowserAccessibilityWin::get_nCharacters(LONG* n_characters) { | 2103 STDMETHODIMP BrowserAccessibilityComWin::get_nCharacters(LONG* n_characters) { |
| 2057 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_CHARACTERS); | 2104 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_CHARACTERS); |
| 2058 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | | 2105 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | |
| 2059 AccessibilityMode::kInlineTextBoxes); | 2106 AccessibilityMode::kInlineTextBoxes); |
| 2060 if (!instance_active()) | 2107 if (!GetOwner() || !GetOwner()->instance_active()) |
| 2061 return E_FAIL; | 2108 return E_FAIL; |
| 2062 | 2109 |
| 2063 if (!n_characters) | 2110 if (!n_characters) |
| 2064 return E_INVALIDARG; | 2111 return E_INVALIDARG; |
| 2065 | 2112 |
| 2066 *n_characters = static_cast<LONG>(GetText().size()); | 2113 *n_characters = static_cast<LONG>(GetOwner()->GetText().size()); |
| 2067 return S_OK; | 2114 return S_OK; |
| 2068 } | 2115 } |
| 2069 | 2116 |
| 2070 STDMETHODIMP BrowserAccessibilityWin::get_caretOffset(LONG* offset) { | 2117 STDMETHODIMP BrowserAccessibilityComWin::get_caretOffset(LONG* offset) { |
| 2071 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CARET_OFFSET); | 2118 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CARET_OFFSET); |
| 2072 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2119 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2073 if (!instance_active()) | 2120 if (!GetOwner() || !GetOwner()->instance_active()) |
| 2074 return E_FAIL; | 2121 return E_FAIL; |
| 2075 | 2122 |
| 2076 if (!offset) | 2123 if (!offset) |
| 2077 return E_INVALIDARG; | 2124 return E_INVALIDARG; |
| 2078 | 2125 |
| 2079 if (!HasCaret()) | 2126 if (!GetOwner()->HasCaret()) |
| 2080 return S_FALSE; | 2127 return S_FALSE; |
| 2081 | 2128 |
| 2082 int selection_start, selection_end; | 2129 int selection_start, selection_end; |
| 2083 GetSelectionOffsets(&selection_start, &selection_end); | 2130 GetSelectionOffsets(&selection_start, &selection_end); |
| 2084 // The caret is always at the end of the selection. | 2131 // The caret is always at the end of the selection. |
| 2085 *offset = selection_end; | 2132 *offset = selection_end; |
| 2086 if (*offset < 0) | 2133 if (*offset < 0) |
| 2087 return S_FALSE; | 2134 return S_FALSE; |
| 2088 | 2135 |
| 2089 return S_OK; | 2136 return S_OK; |
| 2090 } | 2137 } |
| 2091 | 2138 |
| 2092 STDMETHODIMP BrowserAccessibilityWin::get_characterExtents( | 2139 STDMETHODIMP BrowserAccessibilityComWin::get_characterExtents( |
| 2093 LONG offset, | 2140 LONG offset, |
| 2094 IA2CoordinateType coordinate_type, | 2141 IA2CoordinateType coordinate_type, |
| 2095 LONG* out_x, | 2142 LONG* out_x, |
| 2096 LONG* out_y, | 2143 LONG* out_y, |
| 2097 LONG* out_width, | 2144 LONG* out_width, |
| 2098 LONG* out_height) { | 2145 LONG* out_height) { |
| 2099 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CHARACTER_EXTENTS); | 2146 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CHARACTER_EXTENTS); |
| 2100 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | | 2147 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | |
| 2101 AccessibilityMode::kInlineTextBoxes); | 2148 AccessibilityMode::kInlineTextBoxes); |
| 2102 if (!instance_active()) | 2149 if (!GetOwner() || !GetOwner()->instance_active()) |
| 2103 return E_FAIL; | 2150 return E_FAIL; |
| 2104 | 2151 |
| 2105 if (!out_x || !out_y || !out_width || !out_height) | 2152 if (!out_x || !out_y || !out_width || !out_height) |
| 2106 return E_INVALIDARG; | 2153 return E_INVALIDARG; |
| 2107 | 2154 |
| 2108 const base::string16& text_str = GetText(); | 2155 const base::string16& text_str = GetOwner()->GetText(); |
| 2109 HandleSpecialTextOffset(&offset); | 2156 HandleSpecialTextOffset(&offset); |
| 2110 if (offset < 0 || offset > static_cast<LONG>(text_str.size())) | 2157 if (offset < 0 || offset > static_cast<LONG>(text_str.size())) |
| 2111 return E_INVALIDARG; | 2158 return E_INVALIDARG; |
| 2112 | 2159 |
| 2113 gfx::Rect character_bounds; | 2160 gfx::Rect character_bounds; |
| 2114 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { | 2161 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { |
| 2115 character_bounds = GetScreenBoundsForRange(offset, 1); | 2162 character_bounds = GetOwner()->GetScreenBoundsForRange(offset, 1); |
| 2116 } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) { | 2163 } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) { |
| 2117 character_bounds = GetPageBoundsForRange(offset, 1); | 2164 character_bounds = GetOwner()->GetPageBoundsForRange(offset, 1); |
| 2118 if (PlatformGetParent()) | 2165 if (GetOwner()->PlatformGetParent()) |
| 2119 character_bounds -= | 2166 character_bounds -= GetOwner() |
| 2120 PlatformGetParent()->GetPageBoundsRect().OffsetFromOrigin(); | 2167 ->PlatformGetParent() |
| 2168 ->GetPageBoundsRect() | |
| 2169 .OffsetFromOrigin(); | |
| 2121 } else { | 2170 } else { |
| 2122 return E_INVALIDARG; | 2171 return E_INVALIDARG; |
| 2123 } | 2172 } |
| 2124 | 2173 |
| 2125 *out_x = character_bounds.x(); | 2174 *out_x = character_bounds.x(); |
| 2126 *out_y = character_bounds.y(); | 2175 *out_y = character_bounds.y(); |
| 2127 *out_width = character_bounds.width(); | 2176 *out_width = character_bounds.width(); |
| 2128 *out_height = character_bounds.height(); | 2177 *out_height = character_bounds.height(); |
| 2129 | 2178 |
| 2130 return S_OK; | 2179 return S_OK; |
| 2131 } | 2180 } |
| 2132 | 2181 |
| 2133 STDMETHODIMP BrowserAccessibilityWin::get_nSelections(LONG* n_selections) { | 2182 STDMETHODIMP BrowserAccessibilityComWin::get_nSelections(LONG* n_selections) { |
| 2134 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_SELECTIONS); | 2183 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_SELECTIONS); |
| 2135 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2184 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2136 if (!instance_active()) | 2185 if (!GetOwner() || !GetOwner()->instance_active()) |
| 2137 return E_FAIL; | 2186 return E_FAIL; |
| 2138 | 2187 |
| 2139 if (!n_selections) | 2188 if (!n_selections) |
| 2140 return E_INVALIDARG; | 2189 return E_INVALIDARG; |
| 2141 | 2190 |
| 2142 *n_selections = 0; | 2191 *n_selections = 0; |
| 2143 int selection_start, selection_end; | 2192 int selection_start, selection_end; |
| 2144 GetSelectionOffsets(&selection_start, &selection_end); | 2193 GetSelectionOffsets(&selection_start, &selection_end); |
| 2145 if (selection_start >= 0 && selection_end >= 0 && | 2194 if (selection_start >= 0 && selection_end >= 0 && |
| 2146 selection_start != selection_end) { | 2195 selection_start != selection_end) { |
| 2147 *n_selections = 1; | 2196 *n_selections = 1; |
| 2148 } | 2197 } |
| 2149 | 2198 |
| 2150 return S_OK; | 2199 return S_OK; |
| 2151 } | 2200 } |
| 2152 | 2201 |
| 2153 STDMETHODIMP BrowserAccessibilityWin::get_selection(LONG selection_index, | 2202 STDMETHODIMP BrowserAccessibilityComWin::get_selection(LONG selection_index, |
| 2154 LONG* start_offset, | 2203 LONG* start_offset, |
| 2155 LONG* end_offset) { | 2204 LONG* end_offset) { |
| 2156 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_SELECTION); | 2205 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_SELECTION); |
| 2157 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2206 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2158 if (!instance_active()) | 2207 if (!GetOwner() || !GetOwner()->instance_active()) |
| 2159 return E_FAIL; | 2208 return E_FAIL; |
| 2160 | 2209 |
| 2161 if (!start_offset || !end_offset || selection_index != 0) | 2210 if (!start_offset || !end_offset || selection_index != 0) |
| 2162 return E_INVALIDARG; | 2211 return E_INVALIDARG; |
| 2163 | 2212 |
| 2164 *start_offset = 0; | 2213 *start_offset = 0; |
| 2165 *end_offset = 0; | 2214 *end_offset = 0; |
| 2166 int selection_start, selection_end; | 2215 int selection_start, selection_end; |
| 2167 GetSelectionOffsets(&selection_start, &selection_end); | 2216 GetSelectionOffsets(&selection_start, &selection_end); |
| 2168 if (selection_start >= 0 && selection_end >= 0 && | 2217 if (selection_start >= 0 && selection_end >= 0 && |
| 2169 selection_start != selection_end) { | 2218 selection_start != selection_end) { |
| 2170 // We should ignore the direction of the selection when exposing start and | 2219 // We should ignore the direction of the selection when exposing start and |
| 2171 // end offsets. According to the IA2 Spec the end offset is always increased | 2220 // end offsets. According to the IA2 Spec the end offset is always increased |
| 2172 // by one past the end of the selection. This wouldn't make sense if | 2221 // by one past the end of the selection. This wouldn't make sense if |
| 2173 // end < start. | 2222 // end < start. |
| 2174 if (selection_end < selection_start) | 2223 if (selection_end < selection_start) |
| 2175 std::swap(selection_start, selection_end); | 2224 std::swap(selection_start, selection_end); |
| 2176 | 2225 |
| 2177 *start_offset = selection_start; | 2226 *start_offset = selection_start; |
| 2178 *end_offset = selection_end; | 2227 *end_offset = selection_end; |
| 2179 return S_OK; | 2228 return S_OK; |
| 2180 } | 2229 } |
| 2181 | 2230 |
| 2182 return E_INVALIDARG; | 2231 return E_INVALIDARG; |
| 2183 } | 2232 } |
| 2184 | 2233 |
| 2185 STDMETHODIMP BrowserAccessibilityWin::get_text(LONG start_offset, | 2234 STDMETHODIMP BrowserAccessibilityComWin::get_text(LONG start_offset, |
| 2186 LONG end_offset, | 2235 LONG end_offset, |
| 2187 BSTR* text) { | 2236 BSTR* text) { |
| 2188 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_TEXT); | 2237 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_TEXT); |
| 2189 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2238 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2190 if (!instance_active()) | 2239 if (!GetOwner() || !GetOwner()->instance_active()) |
| 2191 return E_FAIL; | 2240 return E_FAIL; |
| 2192 | 2241 |
| 2193 if (!text) | 2242 if (!text) |
| 2194 return E_INVALIDARG; | 2243 return E_INVALIDARG; |
| 2195 | 2244 |
| 2196 const base::string16& text_str = GetText(); | 2245 const base::string16& text_str = GetOwner()->GetText(); |
| 2197 HandleSpecialTextOffset(&start_offset); | 2246 HandleSpecialTextOffset(&start_offset); |
| 2198 HandleSpecialTextOffset(&end_offset); | 2247 HandleSpecialTextOffset(&end_offset); |
| 2199 | 2248 |
| 2200 // The spec allows the arguments to be reversed. | 2249 // The spec allows the arguments to be reversed. |
| 2201 if (start_offset > end_offset) { | 2250 if (start_offset > end_offset) { |
| 2202 LONG tmp = start_offset; | 2251 LONG tmp = start_offset; |
| 2203 start_offset = end_offset; | 2252 start_offset = end_offset; |
| 2204 end_offset = tmp; | 2253 end_offset = tmp; |
| 2205 } | 2254 } |
| 2206 | 2255 |
| 2207 // The spec does not allow the start or end offsets to be out or range; | 2256 // The spec does not allow the start or end offsets to be out or range; |
| 2208 // we must return an error if so. | 2257 // we must return an error if so. |
| 2209 LONG len = text_str.length(); | 2258 LONG len = text_str.length(); |
| 2210 if (start_offset < 0) | 2259 if (start_offset < 0) |
| 2211 return E_INVALIDARG; | 2260 return E_INVALIDARG; |
| 2212 if (end_offset > len) | 2261 if (end_offset > len) |
| 2213 return E_INVALIDARG; | 2262 return E_INVALIDARG; |
| 2214 | 2263 |
| 2215 base::string16 substr = text_str.substr(start_offset, | 2264 base::string16 substr = |
| 2216 end_offset - start_offset); | 2265 text_str.substr(start_offset, end_offset - start_offset); |
| 2217 | 2266 |
| 2218 if (substr.empty()) | 2267 if (substr.empty()) |
| 2219 return S_FALSE; | 2268 return S_FALSE; |
| 2220 | 2269 |
| 2221 *text = SysAllocString(substr.c_str()); | 2270 *text = SysAllocString(substr.c_str()); |
| 2222 DCHECK(*text); | 2271 DCHECK(*text); |
| 2223 return S_OK; | 2272 return S_OK; |
| 2224 } | 2273 } |
| 2225 | 2274 |
| 2226 STDMETHODIMP BrowserAccessibilityWin::get_textAtOffset( | 2275 STDMETHODIMP BrowserAccessibilityComWin::get_textAtOffset( |
| 2227 LONG offset, | 2276 LONG offset, |
| 2228 IA2TextBoundaryType boundary_type, | 2277 IA2TextBoundaryType boundary_type, |
| 2229 LONG* start_offset, | 2278 LONG* start_offset, |
| 2230 LONG* end_offset, | 2279 LONG* end_offset, |
| 2231 BSTR* text) { | 2280 BSTR* text) { |
| 2232 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_TEXT_AT_OFFSET); | 2281 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_TEXT_AT_OFFSET); |
| 2233 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | | 2282 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | |
| 2234 AccessibilityMode::kInlineTextBoxes); | 2283 AccessibilityMode::kInlineTextBoxes); |
| 2235 if (!instance_active()) | 2284 if (!GetOwner() || !GetOwner()->instance_active()) |
| 2236 return E_FAIL; | 2285 return E_FAIL; |
| 2237 | 2286 |
| 2238 if (!start_offset || !end_offset || !text) | 2287 if (!start_offset || !end_offset || !text) |
| 2239 return E_INVALIDARG; | 2288 return E_INVALIDARG; |
| 2240 | 2289 |
| 2241 HandleSpecialTextOffset(&offset); | 2290 HandleSpecialTextOffset(&offset); |
| 2242 if (offset < 0) | 2291 if (offset < 0) |
| 2243 return E_INVALIDARG; | 2292 return E_INVALIDARG; |
| 2244 | 2293 |
| 2245 const base::string16& text_str = GetText(); | 2294 const base::string16& text_str = GetOwner()->GetText(); |
| 2246 LONG text_len = text_str.length(); | 2295 LONG text_len = text_str.length(); |
| 2247 if (offset > text_len) | 2296 if (offset > text_len) |
| 2248 return E_INVALIDARG; | 2297 return E_INVALIDARG; |
| 2249 | 2298 |
| 2250 // The IAccessible2 spec says we don't have to implement the "sentence" | 2299 // The IAccessible2 spec says we don't have to implement the "sentence" |
| 2251 // boundary type, we can just let the screenreader handle it. | 2300 // boundary type, we can just let the screenreader handle it. |
| 2252 if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) { | 2301 if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) { |
| 2253 *start_offset = 0; | 2302 *start_offset = 0; |
| 2254 *end_offset = 0; | 2303 *end_offset = 0; |
| 2255 *text = NULL; | 2304 *text = NULL; |
| 2256 return S_FALSE; | 2305 return S_FALSE; |
| 2257 } | 2306 } |
| 2258 | 2307 |
| 2259 // According to the IA2 Spec, only line boundaries should succeed when | 2308 // According to the IA2 Spec, only line boundaries should succeed when |
| 2260 // the offset is one past the end of the text. | 2309 // the offset is one past the end of the text. |
| 2261 if (offset == text_len) { | 2310 if (offset == text_len) { |
| 2262 if (boundary_type == IA2_TEXT_BOUNDARY_LINE) { | 2311 if (boundary_type == IA2_TEXT_BOUNDARY_LINE) { |
| 2263 --offset; | 2312 --offset; |
| 2264 } else { | 2313 } else { |
| 2265 *start_offset = 0; | 2314 *start_offset = 0; |
| 2266 *end_offset = 0; | 2315 *end_offset = 0; |
| 2267 *text = nullptr; | 2316 *text = nullptr; |
| 2268 return S_FALSE; | 2317 return S_FALSE; |
| 2269 } | 2318 } |
| 2270 } | 2319 } |
| 2271 | 2320 |
| 2272 *start_offset = FindBoundary( | 2321 *start_offset = |
| 2273 text_str, boundary_type, offset, ui::BACKWARDS_DIRECTION); | 2322 FindBoundary(text_str, boundary_type, offset, ui::BACKWARDS_DIRECTION); |
| 2274 *end_offset = FindBoundary( | 2323 *end_offset = |
| 2275 text_str, boundary_type, offset, ui::FORWARDS_DIRECTION); | 2324 FindBoundary(text_str, boundary_type, offset, ui::FORWARDS_DIRECTION); |
| 2276 return get_text(*start_offset, *end_offset, text); | 2325 return get_text(*start_offset, *end_offset, text); |
| 2277 } | 2326 } |
| 2278 | 2327 |
| 2279 STDMETHODIMP BrowserAccessibilityWin::get_textBeforeOffset( | 2328 STDMETHODIMP BrowserAccessibilityComWin::get_textBeforeOffset( |
| 2280 LONG offset, | 2329 LONG offset, |
| 2281 IA2TextBoundaryType boundary_type, | 2330 IA2TextBoundaryType boundary_type, |
| 2282 LONG* start_offset, | 2331 LONG* start_offset, |
| 2283 LONG* end_offset, | 2332 LONG* end_offset, |
| 2284 BSTR* text) { | 2333 BSTR* text) { |
| 2285 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_TEXT_BEFORE_OFFSET); | 2334 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_TEXT_BEFORE_OFFSET); |
| 2286 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | | 2335 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | |
| 2287 AccessibilityMode::kInlineTextBoxes); | 2336 AccessibilityMode::kInlineTextBoxes); |
| 2288 if (!instance_active()) | 2337 if (!GetOwner() || !GetOwner()->instance_active()) |
| 2289 return E_FAIL; | 2338 return E_FAIL; |
| 2290 | 2339 |
| 2291 if (!start_offset || !end_offset || !text) | 2340 if (!start_offset || !end_offset || !text) |
| 2292 return E_INVALIDARG; | 2341 return E_INVALIDARG; |
| 2293 | 2342 |
| 2294 // The IAccessible2 spec says we don't have to implement the "sentence" | 2343 // The IAccessible2 spec says we don't have to implement the "sentence" |
| 2295 // boundary type, we can just let the screenreader handle it. | 2344 // boundary type, we can just let the screenreader handle it. |
| 2296 if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) { | 2345 if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) { |
| 2297 *start_offset = 0; | 2346 *start_offset = 0; |
| 2298 *end_offset = 0; | 2347 *end_offset = 0; |
| 2299 *text = NULL; | 2348 *text = NULL; |
| 2300 return S_FALSE; | 2349 return S_FALSE; |
| 2301 } | 2350 } |
| 2302 | 2351 |
| 2303 const base::string16& text_str = GetText(); | 2352 const base::string16& text_str = GetOwner()->GetText(); |
| 2304 | 2353 |
| 2305 *start_offset = FindBoundary( | 2354 *start_offset = |
| 2306 text_str, boundary_type, offset, ui::BACKWARDS_DIRECTION); | 2355 FindBoundary(text_str, boundary_type, offset, ui::BACKWARDS_DIRECTION); |
| 2307 *end_offset = offset; | 2356 *end_offset = offset; |
| 2308 return get_text(*start_offset, *end_offset, text); | 2357 return get_text(*start_offset, *end_offset, text); |
| 2309 } | 2358 } |
| 2310 | 2359 |
| 2311 STDMETHODIMP BrowserAccessibilityWin::get_textAfterOffset( | 2360 STDMETHODIMP BrowserAccessibilityComWin::get_textAfterOffset( |
| 2312 LONG offset, | 2361 LONG offset, |
| 2313 IA2TextBoundaryType boundary_type, | 2362 IA2TextBoundaryType boundary_type, |
| 2314 LONG* start_offset, | 2363 LONG* start_offset, |
| 2315 LONG* end_offset, | 2364 LONG* end_offset, |
| 2316 BSTR* text) { | 2365 BSTR* text) { |
| 2317 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_TEXT_AFTER_OFFSET); | 2366 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_TEXT_AFTER_OFFSET); |
| 2318 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | | 2367 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | |
| 2319 AccessibilityMode::kInlineTextBoxes); | 2368 AccessibilityMode::kInlineTextBoxes); |
| 2320 if (!instance_active()) | 2369 if (!GetOwner() || !GetOwner()->instance_active()) |
| 2321 return E_FAIL; | 2370 return E_FAIL; |
| 2322 | 2371 |
| 2323 if (!start_offset || !end_offset || !text) | 2372 if (!start_offset || !end_offset || !text) |
| 2324 return E_INVALIDARG; | 2373 return E_INVALIDARG; |
| 2325 | 2374 |
| 2326 // The IAccessible2 spec says we don't have to implement the "sentence" | 2375 // The IAccessible2 spec says we don't have to implement the "sentence" |
| 2327 // boundary type, we can just let the screenreader handle it. | 2376 // boundary type, we can just let the screenreader handle it. |
| 2328 if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) { | 2377 if (boundary_type == IA2_TEXT_BOUNDARY_SENTENCE) { |
| 2329 *start_offset = 0; | 2378 *start_offset = 0; |
| 2330 *end_offset = 0; | 2379 *end_offset = 0; |
| 2331 *text = NULL; | 2380 *text = NULL; |
| 2332 return S_FALSE; | 2381 return S_FALSE; |
| 2333 } | 2382 } |
| 2334 | 2383 |
| 2335 const base::string16& text_str = GetText(); | 2384 const base::string16& text_str = GetOwner()->GetText(); |
| 2336 | 2385 |
| 2337 *start_offset = offset; | 2386 *start_offset = offset; |
| 2338 *end_offset = FindBoundary( | 2387 *end_offset = |
| 2339 text_str, boundary_type, offset, ui::FORWARDS_DIRECTION); | 2388 FindBoundary(text_str, boundary_type, offset, ui::FORWARDS_DIRECTION); |
| 2340 return get_text(*start_offset, *end_offset, text); | 2389 return get_text(*start_offset, *end_offset, text); |
| 2341 } | 2390 } |
| 2342 | 2391 |
| 2343 STDMETHODIMP BrowserAccessibilityWin::get_newText(IA2TextSegment* new_text) { | 2392 STDMETHODIMP BrowserAccessibilityComWin::get_newText(IA2TextSegment* new_text) { |
| 2344 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_NEW_TEXT); | 2393 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_NEW_TEXT); |
| 2345 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2394 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2346 if (!instance_active()) | 2395 if (!GetOwner() || !GetOwner()->instance_active()) |
| 2347 return E_FAIL; | 2396 return E_FAIL; |
| 2348 | 2397 |
| 2349 if (!new_text) | 2398 if (!new_text) |
| 2350 return E_INVALIDARG; | 2399 return E_INVALIDARG; |
| 2351 | 2400 |
| 2352 if (!old_win_attributes_) | 2401 if (!old_win_attributes_) |
| 2353 return E_FAIL; | 2402 return E_FAIL; |
| 2354 | 2403 |
| 2355 int start, old_len, new_len; | 2404 int start, old_len, new_len; |
| 2356 ComputeHypertextRemovedAndInserted(&start, &old_len, &new_len); | 2405 ComputeHypertextRemovedAndInserted(&start, &old_len, &new_len); |
| 2357 if (new_len == 0) | 2406 if (new_len == 0) |
| 2358 return E_FAIL; | 2407 return E_FAIL; |
| 2359 | 2408 |
| 2360 base::string16 substr = GetText().substr(start, new_len); | 2409 base::string16 substr = GetOwner()->GetText().substr(start, new_len); |
| 2361 new_text->text = SysAllocString(substr.c_str()); | 2410 new_text->text = SysAllocString(substr.c_str()); |
| 2362 new_text->start = static_cast<long>(start); | 2411 new_text->start = static_cast<long>(start); |
| 2363 new_text->end = static_cast<long>(start + new_len); | 2412 new_text->end = static_cast<long>(start + new_len); |
| 2364 return S_OK; | 2413 return S_OK; |
| 2365 } | 2414 } |
| 2366 | 2415 |
| 2367 STDMETHODIMP BrowserAccessibilityWin::get_oldText(IA2TextSegment* old_text) { | 2416 STDMETHODIMP BrowserAccessibilityComWin::get_oldText(IA2TextSegment* old_text) { |
| 2368 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_OLD_TEXT); | 2417 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_OLD_TEXT); |
| 2369 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2418 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2370 if (!instance_active()) | 2419 if (!GetOwner() || !GetOwner()->instance_active()) |
| 2371 return E_FAIL; | 2420 return E_FAIL; |
| 2372 | 2421 |
| 2373 if (!old_text) | 2422 if (!old_text) |
| 2374 return E_INVALIDARG; | 2423 return E_INVALIDARG; |
| 2375 | 2424 |
| 2376 if (!old_win_attributes_) | 2425 if (!old_win_attributes_) |
| 2377 return E_FAIL; | 2426 return E_FAIL; |
| 2378 | 2427 |
| 2379 int start, old_len, new_len; | 2428 int start, old_len, new_len; |
| 2380 ComputeHypertextRemovedAndInserted(&start, &old_len, &new_len); | 2429 ComputeHypertextRemovedAndInserted(&start, &old_len, &new_len); |
| 2381 if (old_len == 0) | 2430 if (old_len == 0) |
| 2382 return E_FAIL; | 2431 return E_FAIL; |
| 2383 | 2432 |
| 2384 base::string16 old_hypertext = old_win_attributes_->hypertext; | 2433 base::string16 old_hypertext = old_win_attributes_->hypertext; |
| 2385 base::string16 substr = old_hypertext.substr(start, old_len); | 2434 base::string16 substr = old_hypertext.substr(start, old_len); |
| 2386 old_text->text = SysAllocString(substr.c_str()); | 2435 old_text->text = SysAllocString(substr.c_str()); |
| 2387 old_text->start = static_cast<long>(start); | 2436 old_text->start = static_cast<long>(start); |
| 2388 old_text->end = static_cast<long>(start + old_len); | 2437 old_text->end = static_cast<long>(start + old_len); |
| 2389 return S_OK; | 2438 return S_OK; |
| 2390 } | 2439 } |
| 2391 | 2440 |
| 2392 STDMETHODIMP BrowserAccessibilityWin::get_offsetAtPoint( | 2441 STDMETHODIMP BrowserAccessibilityComWin::get_offsetAtPoint( |
| 2393 LONG x, | 2442 LONG x, |
| 2394 LONG y, | 2443 LONG y, |
| 2395 IA2CoordinateType coord_type, | 2444 IA2CoordinateType coord_type, |
| 2396 LONG* offset) { | 2445 LONG* offset) { |
| 2397 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_OFFSET_AT_POINT); | 2446 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_OFFSET_AT_POINT); |
| 2398 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | | 2447 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | |
| 2399 AccessibilityMode::kInlineTextBoxes); | 2448 AccessibilityMode::kInlineTextBoxes); |
| 2400 if (!instance_active()) | 2449 if (!GetOwner() || !GetOwner()->instance_active()) |
| 2401 return E_FAIL; | 2450 return E_FAIL; |
| 2402 | 2451 |
| 2403 if (!offset) | 2452 if (!offset) |
| 2404 return E_INVALIDARG; | 2453 return E_INVALIDARG; |
| 2405 | 2454 |
| 2406 // TODO(dmazzoni): implement this. We're returning S_OK for now so that | 2455 // TODO(dmazzoni): implement this. We're returning S_OK for now so that |
| 2407 // screen readers still return partially accurate results rather than | 2456 // screen readers still return partially accurate results rather than |
| 2408 // completely failing. | 2457 // completely failing. |
| 2409 *offset = 0; | 2458 *offset = 0; |
| 2410 return S_OK; | 2459 return S_OK; |
| 2411 } | 2460 } |
| 2412 | 2461 |
| 2413 STDMETHODIMP BrowserAccessibilityWin::scrollSubstringTo( | 2462 STDMETHODIMP BrowserAccessibilityComWin::scrollSubstringTo( |
| 2414 LONG start_index, | 2463 LONG start_index, |
| 2415 LONG end_index, | 2464 LONG end_index, |
| 2416 IA2ScrollType scroll_type) { | 2465 IA2ScrollType scroll_type) { |
| 2417 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SCROLL_SUBSTRING_TO); | 2466 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SCROLL_SUBSTRING_TO); |
| 2418 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | | 2467 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | |
| 2419 AccessibilityMode::kInlineTextBoxes); | 2468 AccessibilityMode::kInlineTextBoxes); |
| 2420 // TODO(dmazzoni): adjust this for the start and end index, too. | 2469 // TODO(dmazzoni): adjust this for the start and end index, too. |
| 2421 return scrollTo(scroll_type); | 2470 return scrollTo(scroll_type); |
| 2422 } | 2471 } |
| 2423 | 2472 |
| 2424 STDMETHODIMP BrowserAccessibilityWin::scrollSubstringToPoint( | 2473 STDMETHODIMP BrowserAccessibilityComWin::scrollSubstringToPoint( |
| 2425 LONG start_index, | 2474 LONG start_index, |
| 2426 LONG end_index, | 2475 LONG end_index, |
| 2427 IA2CoordinateType coordinate_type, | 2476 IA2CoordinateType coordinate_type, |
| 2428 LONG x, | 2477 LONG x, |
| 2429 LONG y) { | 2478 LONG y) { |
| 2430 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SCROLL_SUBSTRING_TO_POINT); | 2479 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SCROLL_SUBSTRING_TO_POINT); |
| 2431 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | | 2480 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | |
| 2432 AccessibilityMode::kInlineTextBoxes); | 2481 AccessibilityMode::kInlineTextBoxes); |
| 2482 if (!GetOwner() || !GetOwner()->instance_active()) | |
| 2483 return E_FAIL; | |
| 2484 | |
| 2433 if (start_index > end_index) | 2485 if (start_index > end_index) |
| 2434 std::swap(start_index, end_index); | 2486 std::swap(start_index, end_index); |
| 2435 LONG length = end_index - start_index + 1; | 2487 LONG length = end_index - start_index + 1; |
| 2436 DCHECK_GE(length, 0); | 2488 DCHECK_GE(length, 0); |
| 2437 | 2489 |
| 2438 gfx::Rect string_bounds = GetPageBoundsForRange(start_index, length); | 2490 gfx::Rect string_bounds = |
| 2439 string_bounds -= GetPageBoundsRect().OffsetFromOrigin(); | 2491 GetOwner()->GetPageBoundsForRange(start_index, length); |
| 2492 string_bounds -= GetOwner()->GetPageBoundsRect().OffsetFromOrigin(); | |
| 2440 x -= string_bounds.x(); | 2493 x -= string_bounds.x(); |
| 2441 y -= string_bounds.y(); | 2494 y -= string_bounds.y(); |
| 2442 | 2495 |
| 2443 return scrollToPoint(coordinate_type, x, y); | 2496 return scrollToPoint(coordinate_type, x, y); |
| 2444 } | 2497 } |
| 2445 | 2498 |
| 2446 STDMETHODIMP BrowserAccessibilityWin::addSelection(LONG start_offset, | 2499 STDMETHODIMP BrowserAccessibilityComWin::addSelection(LONG start_offset, |
| 2447 LONG end_offset) { | 2500 LONG end_offset) { |
| 2448 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ADD_SELECTION); | 2501 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ADD_SELECTION); |
| 2449 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2502 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2450 if (!instance_active()) | 2503 if (!GetOwner() || !GetOwner()->instance_active()) |
| 2451 return E_FAIL; | 2504 return E_FAIL; |
| 2452 | 2505 |
| 2453 // We only support one selection. | 2506 // We only support one selection. |
| 2454 SetIA2HypertextSelection(start_offset, end_offset); | 2507 SetIA2HypertextSelection(start_offset, end_offset); |
| 2455 return S_OK; | 2508 return S_OK; |
| 2456 } | 2509 } |
| 2457 | 2510 |
| 2458 STDMETHODIMP BrowserAccessibilityWin::removeSelection(LONG selection_index) { | 2511 STDMETHODIMP BrowserAccessibilityComWin::removeSelection(LONG selection_index) { |
| 2459 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_REMOVE_SELECTION); | 2512 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_REMOVE_SELECTION); |
| 2460 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2513 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2461 if (!instance_active()) | 2514 if (!GetOwner() || !GetOwner()->instance_active()) |
| 2462 return E_FAIL; | 2515 return E_FAIL; |
| 2463 | 2516 |
| 2464 if (selection_index != 0) | 2517 if (selection_index != 0) |
| 2465 return E_INVALIDARG; | 2518 return E_INVALIDARG; |
| 2466 | 2519 |
| 2467 // Simply collapse the selection to the position of the caret if a caret is | 2520 // Simply collapse the selection to the position of the caret if a caret is |
| 2468 // visible, otherwise set the selection to 0. | 2521 // visible, otherwise set the selection to 0. |
| 2469 LONG caret_offset = 0; | 2522 LONG caret_offset = 0; |
| 2470 int selection_start, selection_end; | 2523 int selection_start, selection_end; |
| 2471 GetSelectionOffsets(&selection_start, &selection_end); | 2524 GetSelectionOffsets(&selection_start, &selection_end); |
| 2472 if (HasCaret() && selection_end >= 0) | 2525 if (GetOwner()->HasCaret() && selection_end >= 0) |
| 2473 caret_offset = selection_end; | 2526 caret_offset = selection_end; |
| 2474 SetIA2HypertextSelection(caret_offset, caret_offset); | 2527 SetIA2HypertextSelection(caret_offset, caret_offset); |
| 2475 return S_OK; | 2528 return S_OK; |
| 2476 } | 2529 } |
| 2477 | 2530 |
| 2478 STDMETHODIMP BrowserAccessibilityWin::setCaretOffset(LONG offset) { | 2531 STDMETHODIMP BrowserAccessibilityComWin::setCaretOffset(LONG offset) { |
| 2479 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SET_CARET_OFFSET); | 2532 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SET_CARET_OFFSET); |
| 2480 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2533 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2481 if (!instance_active()) | 2534 if (!GetOwner() || !GetOwner()->instance_active()) |
| 2482 return E_FAIL; | 2535 return E_FAIL; |
| 2483 SetIA2HypertextSelection(offset, offset); | 2536 SetIA2HypertextSelection(offset, offset); |
| 2484 return S_OK; | 2537 return S_OK; |
| 2485 } | 2538 } |
| 2486 | 2539 |
| 2487 STDMETHODIMP BrowserAccessibilityWin::setSelection(LONG selection_index, | 2540 STDMETHODIMP BrowserAccessibilityComWin::setSelection(LONG selection_index, |
| 2488 LONG start_offset, | 2541 LONG start_offset, |
| 2489 LONG end_offset) { | 2542 LONG end_offset) { |
| 2490 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SET_SELECTION); | 2543 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SET_SELECTION); |
| 2491 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2544 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2492 if (!instance_active()) | 2545 if (!GetOwner() || !GetOwner()->instance_active()) |
| 2493 return E_FAIL; | 2546 return E_FAIL; |
| 2494 if (selection_index != 0) | 2547 if (selection_index != 0) |
| 2495 return E_INVALIDARG; | 2548 return E_INVALIDARG; |
| 2496 SetIA2HypertextSelection(start_offset, end_offset); | 2549 SetIA2HypertextSelection(start_offset, end_offset); |
| 2497 return S_OK; | 2550 return S_OK; |
| 2498 } | 2551 } |
| 2499 | 2552 |
| 2500 STDMETHODIMP BrowserAccessibilityWin::get_attributes(LONG offset, | 2553 STDMETHODIMP BrowserAccessibilityComWin::get_attributes(LONG offset, |
| 2501 LONG* start_offset, | 2554 LONG* start_offset, |
| 2502 LONG* end_offset, | 2555 LONG* end_offset, |
| 2503 BSTR* text_attributes) { | 2556 BSTR* text_attributes) { |
| 2504 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_IATEXT_GET_ATTRIBUTES); | 2557 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_IATEXT_GET_ATTRIBUTES); |
| 2505 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2558 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2506 if (!start_offset || !end_offset || !text_attributes) | 2559 if (!start_offset || !end_offset || !text_attributes) |
| 2507 return E_INVALIDARG; | 2560 return E_INVALIDARG; |
| 2508 | 2561 |
| 2509 *start_offset = *end_offset = 0; | 2562 *start_offset = *end_offset = 0; |
| 2510 *text_attributes = nullptr; | 2563 *text_attributes = nullptr; |
| 2511 if (!instance_active()) | 2564 if (!GetOwner() || !GetOwner()->instance_active()) |
| 2512 return E_FAIL; | 2565 return E_FAIL; |
| 2513 | 2566 |
| 2514 const base::string16 text = GetText(); | 2567 const base::string16 text = GetOwner()->GetText(); |
| 2515 HandleSpecialTextOffset(&offset); | 2568 HandleSpecialTextOffset(&offset); |
| 2516 if (offset < 0 || offset > static_cast<LONG>(text.size())) | 2569 if (offset < 0 || offset > static_cast<LONG>(text.size())) |
| 2517 return E_INVALIDARG; | 2570 return E_INVALIDARG; |
| 2518 | 2571 |
| 2519 ComputeStylesIfNeeded(); | 2572 ComputeStylesIfNeeded(); |
| 2520 *start_offset = FindStartOfStyle(offset, ui::BACKWARDS_DIRECTION); | 2573 *start_offset = FindStartOfStyle(offset, ui::BACKWARDS_DIRECTION); |
| 2521 *end_offset = FindStartOfStyle(offset, ui::FORWARDS_DIRECTION); | 2574 *end_offset = FindStartOfStyle(offset, ui::FORWARDS_DIRECTION); |
| 2522 | 2575 |
| 2523 base::string16 attributes_str; | 2576 base::string16 attributes_str; |
| 2524 const std::vector<base::string16>& attributes = | 2577 const std::vector<base::string16>& attributes = |
| 2525 offset_to_text_attributes().find(*start_offset)->second; | 2578 offset_to_text_attributes().find(*start_offset)->second; |
| 2526 for (const base::string16& attribute : attributes) { | 2579 for (const base::string16& attribute : attributes) { |
| 2527 attributes_str += attribute + L';'; | 2580 attributes_str += attribute + L';'; |
| 2528 } | 2581 } |
| 2529 | 2582 |
| 2530 if (attributes.empty()) | 2583 if (attributes.empty()) |
| 2531 return S_FALSE; | 2584 return S_FALSE; |
| 2532 | 2585 |
| 2533 *text_attributes = SysAllocString(attributes_str.c_str()); | 2586 *text_attributes = SysAllocString(attributes_str.c_str()); |
| 2534 DCHECK(*text_attributes); | 2587 DCHECK(*text_attributes); |
| 2535 return S_OK; | 2588 return S_OK; |
| 2536 } | 2589 } |
| 2537 | 2590 |
| 2538 // | 2591 // |
| 2539 // IAccessibleHypertext methods. | 2592 // IAccessibleHypertext methods. |
| 2540 // | 2593 // |
| 2541 | 2594 |
| 2542 STDMETHODIMP BrowserAccessibilityWin::get_nHyperlinks(long* hyperlink_count) { | 2595 STDMETHODIMP BrowserAccessibilityComWin::get_nHyperlinks( |
| 2596 long* hyperlink_count) { | |
| 2543 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_HYPERLINKS); | 2597 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_HYPERLINKS); |
| 2544 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2598 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2545 if (!instance_active()) | 2599 if (!GetOwner() || !GetOwner()->instance_active()) |
| 2546 return E_FAIL; | 2600 return E_FAIL; |
| 2547 | 2601 |
| 2548 if (!hyperlink_count) | 2602 if (!hyperlink_count) |
| 2549 return E_INVALIDARG; | 2603 return E_INVALIDARG; |
| 2550 | 2604 |
| 2551 *hyperlink_count = hyperlink_offset_to_index().size(); | 2605 *hyperlink_count = hyperlink_offset_to_index().size(); |
| 2552 return S_OK; | 2606 return S_OK; |
| 2553 } | 2607 } |
| 2554 | 2608 |
| 2555 STDMETHODIMP BrowserAccessibilityWin::get_hyperlink( | 2609 STDMETHODIMP BrowserAccessibilityComWin::get_hyperlink( |
| 2556 long index, | 2610 long index, |
| 2557 IAccessibleHyperlink** hyperlink) { | 2611 IAccessibleHyperlink** hyperlink) { |
| 2558 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_HYPERLINK); | 2612 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_HYPERLINK); |
| 2559 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2613 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2560 if (!instance_active()) | 2614 if (!GetOwner() || !GetOwner()->instance_active()) |
| 2561 return E_FAIL; | 2615 return E_FAIL; |
| 2562 | 2616 |
| 2563 if (!hyperlink || | 2617 if (!hyperlink || index < 0 || |
| 2564 index < 0 || | |
| 2565 index >= static_cast<long>(hyperlinks().size())) { | 2618 index >= static_cast<long>(hyperlinks().size())) { |
| 2566 return E_INVALIDARG; | 2619 return E_INVALIDARG; |
| 2567 } | 2620 } |
| 2568 | 2621 |
| 2569 int32_t id = hyperlinks()[index]; | 2622 int32_t id = hyperlinks()[index]; |
| 2570 BrowserAccessibilityWin* link = | 2623 BrowserAccessibilityComWin* link = |
| 2571 ToBrowserAccessibilityWin(GetFromUniqueID(id)); | 2624 ToBrowserAccessibilityComWin(GetOwner()->GetFromUniqueID(id)); |
| 2572 if (!link) | 2625 if (!link) |
| 2573 return E_FAIL; | 2626 return E_FAIL; |
| 2574 | 2627 |
| 2575 *hyperlink = static_cast<IAccessibleHyperlink*>(link->NewReference()); | 2628 *hyperlink = static_cast<IAccessibleHyperlink*>(link->NewReference()); |
| 2576 return S_OK; | 2629 return S_OK; |
| 2577 } | 2630 } |
| 2578 | 2631 |
| 2579 STDMETHODIMP BrowserAccessibilityWin::get_hyperlinkIndex( | 2632 STDMETHODIMP BrowserAccessibilityComWin::get_hyperlinkIndex( |
| 2580 long char_index, | 2633 long char_index, |
| 2581 long* hyperlink_index) { | 2634 long* hyperlink_index) { |
| 2582 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_HYPERLINK_INDEX); | 2635 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_HYPERLINK_INDEX); |
| 2583 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2636 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2584 if (!instance_active()) | 2637 if (!GetOwner() || !GetOwner()->instance_active()) |
| 2585 return E_FAIL; | 2638 return E_FAIL; |
| 2586 | 2639 |
| 2587 if (!hyperlink_index) | 2640 if (!hyperlink_index) |
| 2588 return E_INVALIDARG; | 2641 return E_INVALIDARG; |
| 2589 | 2642 |
| 2590 if (char_index < 0 || char_index >= static_cast<long>(GetText().size())) { | 2643 if (char_index < 0 || |
| 2644 char_index >= static_cast<long>(GetOwner()->GetText().size())) { | |
| 2591 return E_INVALIDARG; | 2645 return E_INVALIDARG; |
| 2592 } | 2646 } |
| 2593 | 2647 |
| 2594 std::map<int32_t, int32_t>::iterator it = | 2648 std::map<int32_t, int32_t>::iterator it = |
| 2595 hyperlink_offset_to_index().find(char_index); | 2649 hyperlink_offset_to_index().find(char_index); |
| 2596 if (it == hyperlink_offset_to_index().end()) { | 2650 if (it == hyperlink_offset_to_index().end()) { |
| 2597 *hyperlink_index = -1; | 2651 *hyperlink_index = -1; |
| 2598 return S_FALSE; | 2652 return S_FALSE; |
| 2599 } | 2653 } |
| 2600 | 2654 |
| 2601 *hyperlink_index = it->second; | 2655 *hyperlink_index = it->second; |
| 2602 return S_OK; | 2656 return S_OK; |
| 2603 } | 2657 } |
| 2604 | 2658 |
| 2605 // | 2659 // |
| 2606 // IAccessibleHyperlink methods. | 2660 // IAccessibleHyperlink methods. |
| 2607 // | 2661 // |
| 2608 | 2662 |
| 2609 // Currently, only text links are supported. | 2663 // Currently, only text links are supported. |
| 2610 STDMETHODIMP BrowserAccessibilityWin::get_anchor(long index, VARIANT* anchor) { | 2664 STDMETHODIMP BrowserAccessibilityComWin::get_anchor(long index, |
| 2665 VARIANT* anchor) { | |
| 2611 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ANCHOR); | 2666 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ANCHOR); |
| 2612 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2667 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2613 if (!instance_active() || !IsHyperlink()) | 2668 if (!GetOwner()->instance_active() || !IsHyperlink()) |
| 2614 return E_FAIL; | 2669 return E_FAIL; |
| 2615 | 2670 |
| 2616 // IA2 text links can have only one anchor, that is the text inside them. | 2671 // IA2 text links can have only one anchor, that is the text inside them. |
| 2617 if (index != 0 || !anchor) | 2672 if (index != 0 || !anchor) |
| 2618 return E_INVALIDARG; | 2673 return E_INVALIDARG; |
| 2619 | 2674 |
| 2620 BSTR ia2_hypertext = SysAllocString(GetText().c_str()); | 2675 BSTR ia2_hypertext = SysAllocString(GetOwner()->GetText().c_str()); |
| 2621 DCHECK(ia2_hypertext); | 2676 DCHECK(ia2_hypertext); |
| 2622 anchor->vt = VT_BSTR; | 2677 anchor->vt = VT_BSTR; |
| 2623 anchor->bstrVal = ia2_hypertext; | 2678 anchor->bstrVal = ia2_hypertext; |
| 2624 | 2679 |
| 2625 // Returning S_FALSE is not mentioned in the IA2 Spec, but it might have been | 2680 // Returning S_FALSE is not mentioned in the IA2 Spec, but it might have been |
| 2626 // an oversight. | 2681 // an oversight. |
| 2627 if (!SysStringLen(ia2_hypertext)) | 2682 if (!SysStringLen(ia2_hypertext)) |
| 2628 return S_FALSE; | 2683 return S_FALSE; |
| 2629 | 2684 |
| 2630 return S_OK; | 2685 return S_OK; |
| 2631 } | 2686 } |
| 2632 | 2687 |
| 2633 // Currently, only text links are supported. | 2688 // Currently, only text links are supported. |
| 2634 STDMETHODIMP BrowserAccessibilityWin::get_anchorTarget(long index, | 2689 STDMETHODIMP BrowserAccessibilityComWin::get_anchorTarget( |
| 2635 VARIANT* anchor_target) { | 2690 long index, |
| 2691 VARIANT* anchor_target) { | |
| 2636 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ANCHOR_TARGET); | 2692 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ANCHOR_TARGET); |
| 2637 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2693 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2638 if (!instance_active() || !IsHyperlink()) | 2694 if (!GetOwner()->instance_active() || !IsHyperlink()) |
| 2639 return E_FAIL; | 2695 return E_FAIL; |
| 2640 | 2696 |
| 2641 // IA2 text links can have at most one target, that is when they represent an | 2697 // IA2 text links can have at most one target, that is when they represent an |
| 2642 // HTML hyperlink, i.e. an <a> element with a "href" attribute. | 2698 // HTML hyperlink, i.e. an <a> element with a "href" attribute. |
| 2643 if (index != 0 || !anchor_target) | 2699 if (index != 0 || !anchor_target) |
| 2644 return E_INVALIDARG; | 2700 return E_INVALIDARG; |
| 2645 | 2701 |
| 2646 BSTR target; | 2702 BSTR target; |
| 2647 if (!(ia_state() & STATE_SYSTEM_LINKED) || | 2703 if (!(ia_state() & STATE_SYSTEM_LINKED) || |
| 2648 FAILED(GetStringAttributeAsBstr(ui::AX_ATTR_URL, &target))) { | 2704 FAILED(GetStringAttributeAsBstr(ui::AX_ATTR_URL, &target))) { |
| 2649 target = SysAllocString(L""); | 2705 target = SysAllocString(L""); |
| 2650 } | 2706 } |
| 2651 DCHECK(target); | 2707 DCHECK(target); |
| 2652 anchor_target->vt = VT_BSTR; | 2708 anchor_target->vt = VT_BSTR; |
| 2653 anchor_target->bstrVal = target; | 2709 anchor_target->bstrVal = target; |
| 2654 | 2710 |
| 2655 // Returning S_FALSE is not mentioned in the IA2 Spec, but it might have been | 2711 // Returning S_FALSE is not mentioned in the IA2 Spec, but it might have been |
| 2656 // an oversight. | 2712 // an oversight. |
| 2657 if (!SysStringLen(target)) | 2713 if (!SysStringLen(target)) |
| 2658 return S_FALSE; | 2714 return S_FALSE; |
| 2659 | 2715 |
| 2660 return S_OK; | 2716 return S_OK; |
| 2661 } | 2717 } |
| 2662 | 2718 |
| 2663 STDMETHODIMP BrowserAccessibilityWin::get_startIndex(long* index) { | 2719 STDMETHODIMP BrowserAccessibilityComWin::get_startIndex(long* index) { |
| 2664 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_START_INDEX); | 2720 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_START_INDEX); |
| 2665 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2721 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2666 if (!instance_active() || !IsHyperlink()) | 2722 if (!GetOwner()->instance_active() || !IsHyperlink()) |
| 2667 return E_FAIL; | 2723 return E_FAIL; |
| 2668 | 2724 |
| 2669 if (!index) | 2725 if (!index) |
| 2670 return E_INVALIDARG; | 2726 return E_INVALIDARG; |
| 2671 | 2727 |
| 2672 int32_t hypertext_offset = 0; | 2728 int32_t hypertext_offset = 0; |
| 2673 auto* parent = PlatformGetParent(); | 2729 auto* parent = GetOwner()->PlatformGetParent(); |
| 2674 if (parent) { | 2730 if (parent) { |
| 2675 hypertext_offset = | 2731 hypertext_offset = |
| 2676 ToBrowserAccessibilityWin(parent)->GetHypertextOffsetFromChild(*this); | 2732 ToBrowserAccessibilityComWin(parent)->GetHypertextOffsetFromChild( |
| 2733 *this); | |
| 2677 } | 2734 } |
| 2678 *index = static_cast<LONG>(hypertext_offset); | 2735 *index = static_cast<LONG>(hypertext_offset); |
| 2679 return S_OK; | 2736 return S_OK; |
| 2680 } | 2737 } |
| 2681 | 2738 |
| 2682 STDMETHODIMP BrowserAccessibilityWin::get_endIndex(long* index) { | 2739 STDMETHODIMP BrowserAccessibilityComWin::get_endIndex(long* index) { |
| 2683 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_END_INDEX); | 2740 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_END_INDEX); |
| 2684 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2741 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2685 LONG start_index; | 2742 LONG start_index; |
| 2686 HRESULT hr = get_startIndex(&start_index); | 2743 HRESULT hr = get_startIndex(&start_index); |
| 2687 if (hr == S_OK) | 2744 if (hr == S_OK) |
| 2688 *index = start_index + 1; | 2745 *index = start_index + 1; |
| 2689 return hr; | 2746 return hr; |
| 2690 } | 2747 } |
| 2691 | 2748 |
| 2692 // This method is deprecated in the IA2 Spec. | 2749 // This method is deprecated in the IA2 Spec. |
| 2693 STDMETHODIMP BrowserAccessibilityWin::get_valid(boolean* valid) { | 2750 STDMETHODIMP BrowserAccessibilityComWin::get_valid(boolean* valid) { |
| 2694 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_VALID); | 2751 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_VALID); |
| 2695 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2752 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2696 return E_NOTIMPL; | 2753 return E_NOTIMPL; |
| 2697 } | 2754 } |
| 2698 | 2755 |
| 2699 // | 2756 // |
| 2700 // IAccessibleAction partly implemented. | 2757 // IAccessibleAction partly implemented. |
| 2701 // | 2758 // |
| 2702 | 2759 |
| 2703 STDMETHODIMP BrowserAccessibilityWin::nActions(long* n_actions) { | 2760 STDMETHODIMP BrowserAccessibilityComWin::nActions(long* n_actions) { |
| 2704 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_N_ACTIONS); | 2761 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_N_ACTIONS); |
| 2705 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2762 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2706 if (!instance_active()) | 2763 if (!GetOwner() || !GetOwner()->instance_active()) |
| 2707 return E_FAIL; | 2764 return E_FAIL; |
| 2708 | 2765 |
| 2709 if (!n_actions) | 2766 if (!n_actions) |
| 2710 return E_INVALIDARG; | 2767 return E_INVALIDARG; |
| 2711 | 2768 |
| 2712 // |IsHyperlink| is required for |IAccessibleHyperlink::anchor/anchorTarget| | 2769 // |IsHyperlink| is required for |IAccessibleHyperlink::anchor/anchorTarget| |
| 2713 // to work properly because the |IAccessibleHyperlink| interface inherits from | 2770 // to work properly because the |IAccessibleHyperlink| interface inherits from |
| 2714 // |IAccessibleAction|. | 2771 // |IAccessibleAction|. |
| 2715 if (IsHyperlink() || HasIntAttribute(ui::AX_ATTR_ACTION)) { | 2772 if (IsHyperlink() || GetOwner()->HasIntAttribute(ui::AX_ATTR_ACTION)) { |
| 2716 *n_actions = 1; | 2773 *n_actions = 1; |
| 2717 } else { | 2774 } else { |
| 2718 *n_actions = 0; | 2775 *n_actions = 0; |
| 2719 } | 2776 } |
| 2720 | 2777 |
| 2721 return S_OK; | 2778 return S_OK; |
| 2722 } | 2779 } |
| 2723 | 2780 |
| 2724 STDMETHODIMP BrowserAccessibilityWin::doAction(long action_index) { | 2781 STDMETHODIMP BrowserAccessibilityComWin::doAction(long action_index) { |
| 2725 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_DO_ACTION); | 2782 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_DO_ACTION); |
| 2726 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2783 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2727 if (!instance_active()) | 2784 if (!GetOwner() || !GetOwner()->instance_active()) |
| 2728 return E_FAIL; | 2785 return E_FAIL; |
| 2729 | 2786 |
| 2730 if (!HasIntAttribute(ui::AX_ATTR_ACTION) || action_index != 0) | 2787 if (!GetOwner()->HasIntAttribute(ui::AX_ATTR_ACTION) || action_index != 0) |
| 2731 return E_INVALIDARG; | 2788 return E_INVALIDARG; |
| 2732 | 2789 |
| 2733 manager_->DoDefaultAction(*this); | 2790 GetOwner()->manager()->DoDefaultAction(*GetOwner()); |
| 2734 return S_OK; | 2791 return S_OK; |
| 2735 } | 2792 } |
| 2736 | 2793 |
| 2737 STDMETHODIMP | 2794 STDMETHODIMP |
| 2738 BrowserAccessibilityWin::get_description(long action_index, BSTR* description) { | 2795 BrowserAccessibilityComWin::get_description(long action_index, |
| 2796 BSTR* description) { | |
| 2739 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_IAACTION_GET_DESCRIPTION); | 2797 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_IAACTION_GET_DESCRIPTION); |
| 2740 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2798 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2741 return E_NOTIMPL; | 2799 return E_NOTIMPL; |
| 2742 } | 2800 } |
| 2743 | 2801 |
| 2744 STDMETHODIMP BrowserAccessibilityWin::get_keyBinding(long action_index, | 2802 STDMETHODIMP BrowserAccessibilityComWin::get_keyBinding(long action_index, |
| 2745 long n_max_bindings, | 2803 long n_max_bindings, |
| 2746 BSTR** key_bindings, | 2804 BSTR** key_bindings, |
| 2747 long* n_bindings) { | 2805 long* n_bindings) { |
| 2748 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_KEY_BINDING); | 2806 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_KEY_BINDING); |
| 2749 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2807 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2750 return E_NOTIMPL; | 2808 return E_NOTIMPL; |
| 2751 } | 2809 } |
| 2752 | 2810 |
| 2753 STDMETHODIMP BrowserAccessibilityWin::get_name(long action_index, BSTR* name) { | 2811 STDMETHODIMP BrowserAccessibilityComWin::get_name(long action_index, |
| 2812 BSTR* name) { | |
| 2754 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_NAME); | 2813 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_NAME); |
| 2755 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2814 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2756 if (!instance_active()) | 2815 if (!GetOwner() || !GetOwner()->instance_active()) |
| 2757 return E_FAIL; | 2816 return E_FAIL; |
| 2758 | 2817 |
| 2759 if (!name) | 2818 if (!name) |
| 2760 return E_INVALIDARG; | 2819 return E_INVALIDARG; |
| 2761 | 2820 |
| 2762 int action; | 2821 int action; |
| 2763 if (!GetIntAttribute(ui::AX_ATTR_ACTION, &action) || action_index != 0) { | 2822 if (!GetOwner()->GetIntAttribute(ui::AX_ATTR_ACTION, &action) || |
| 2823 action_index != 0) { | |
| 2764 *name = nullptr; | 2824 *name = nullptr; |
| 2765 return E_INVALIDARG; | 2825 return E_INVALIDARG; |
| 2766 } | 2826 } |
| 2767 | 2827 |
| 2768 base::string16 action_verb = | 2828 base::string16 action_verb = |
| 2769 ui::ActionToUnlocalizedString(static_cast<ui::AXSupportedAction>(action)); | 2829 ui::ActionToUnlocalizedString(static_cast<ui::AXSupportedAction>(action)); |
| 2770 if (action_verb.empty() || action_verb == L"none") { | 2830 if (action_verb.empty() || action_verb == L"none") { |
| 2771 *name = nullptr; | 2831 *name = nullptr; |
| 2772 return S_FALSE; | 2832 return S_FALSE; |
| 2773 } | 2833 } |
| 2774 | 2834 |
| 2775 *name = SysAllocString(action_verb.c_str()); | 2835 *name = SysAllocString(action_verb.c_str()); |
| 2776 DCHECK(name); | 2836 DCHECK(name); |
| 2777 return S_OK; | 2837 return S_OK; |
| 2778 } | 2838 } |
| 2779 | 2839 |
| 2780 STDMETHODIMP | 2840 STDMETHODIMP |
| 2781 BrowserAccessibilityWin::get_localizedName(long action_index, | 2841 BrowserAccessibilityComWin::get_localizedName(long action_index, |
| 2782 BSTR* localized_name) { | 2842 BSTR* localized_name) { |
| 2783 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LOCALIZED_NAME); | 2843 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LOCALIZED_NAME); |
| 2784 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2844 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2785 if (!instance_active()) | 2845 if (!GetOwner() || !GetOwner()->instance_active()) |
| 2786 return E_FAIL; | 2846 return E_FAIL; |
| 2787 | 2847 |
| 2788 if (!localized_name) | 2848 if (!localized_name) |
| 2789 return E_INVALIDARG; | 2849 return E_INVALIDARG; |
| 2790 | 2850 |
| 2791 int action; | 2851 int action; |
| 2792 if (!GetIntAttribute(ui::AX_ATTR_ACTION, &action) || action_index != 0) { | 2852 if (!GetOwner()->GetIntAttribute(ui::AX_ATTR_ACTION, &action) || |
| 2853 action_index != 0) { | |
| 2793 *localized_name = nullptr; | 2854 *localized_name = nullptr; |
| 2794 return E_INVALIDARG; | 2855 return E_INVALIDARG; |
| 2795 } | 2856 } |
| 2796 | 2857 |
| 2797 base::string16 action_verb = | 2858 base::string16 action_verb = |
| 2798 ui::ActionToString(static_cast<ui::AXSupportedAction>(action)); | 2859 ui::ActionToString(static_cast<ui::AXSupportedAction>(action)); |
| 2799 if (action_verb.empty()) { | 2860 if (action_verb.empty()) { |
| 2800 *localized_name = nullptr; | 2861 *localized_name = nullptr; |
| 2801 return S_FALSE; | 2862 return S_FALSE; |
| 2802 } | 2863 } |
| 2803 | 2864 |
| 2804 *localized_name = SysAllocString(action_verb.c_str()); | 2865 *localized_name = SysAllocString(action_verb.c_str()); |
| 2805 DCHECK(localized_name); | 2866 DCHECK(localized_name); |
| 2806 return S_OK; | 2867 return S_OK; |
| 2807 } | 2868 } |
| 2808 | 2869 |
| 2809 // | 2870 // |
| 2810 // IAccessibleValue methods. | 2871 // IAccessibleValue methods. |
| 2811 // | 2872 // |
| 2812 | 2873 |
| 2813 STDMETHODIMP BrowserAccessibilityWin::get_currentValue(VARIANT* value) { | 2874 STDMETHODIMP BrowserAccessibilityComWin::get_currentValue(VARIANT* value) { |
| 2814 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CURRENT_VALUE); | 2875 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CURRENT_VALUE); |
| 2815 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2876 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2816 if (!instance_active()) | 2877 if (!GetOwner() || !GetOwner()->instance_active()) |
| 2817 return E_FAIL; | 2878 return E_FAIL; |
| 2818 | 2879 |
| 2819 if (!value) | 2880 if (!value) |
| 2820 return E_INVALIDARG; | 2881 return E_INVALIDARG; |
| 2821 | 2882 |
| 2822 float float_val; | 2883 float float_val; |
| 2823 if (GetFloatAttribute( | 2884 if (GetFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE, &float_val)) { |
| 2824 ui::AX_ATTR_VALUE_FOR_RANGE, &float_val)) { | |
| 2825 value->vt = VT_R8; | 2885 value->vt = VT_R8; |
| 2826 value->dblVal = float_val; | 2886 value->dblVal = float_val; |
| 2827 return S_OK; | 2887 return S_OK; |
| 2828 } | 2888 } |
| 2829 | 2889 |
| 2830 value->vt = VT_EMPTY; | 2890 value->vt = VT_EMPTY; |
| 2831 return S_FALSE; | 2891 return S_FALSE; |
| 2832 } | 2892 } |
| 2833 | 2893 |
| 2834 STDMETHODIMP BrowserAccessibilityWin::get_minimumValue(VARIANT* value) { | 2894 STDMETHODIMP BrowserAccessibilityComWin::get_minimumValue(VARIANT* value) { |
| 2835 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_MINIMUM_VALUE); | 2895 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_MINIMUM_VALUE); |
| 2836 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2896 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2837 if (!instance_active()) | 2897 if (!GetOwner() || !GetOwner()->instance_active()) |
| 2838 return E_FAIL; | 2898 return E_FAIL; |
| 2839 | 2899 |
| 2840 if (!value) | 2900 if (!value) |
| 2841 return E_INVALIDARG; | 2901 return E_INVALIDARG; |
| 2842 | 2902 |
| 2843 float float_val; | 2903 float float_val; |
| 2844 if (GetFloatAttribute(ui::AX_ATTR_MIN_VALUE_FOR_RANGE, | 2904 if (GetFloatAttribute(ui::AX_ATTR_MIN_VALUE_FOR_RANGE, &float_val)) { |
| 2845 &float_val)) { | |
| 2846 value->vt = VT_R8; | 2905 value->vt = VT_R8; |
| 2847 value->dblVal = float_val; | 2906 value->dblVal = float_val; |
| 2848 return S_OK; | 2907 return S_OK; |
| 2849 } | 2908 } |
| 2850 | 2909 |
| 2851 value->vt = VT_EMPTY; | 2910 value->vt = VT_EMPTY; |
| 2852 return S_FALSE; | 2911 return S_FALSE; |
| 2853 } | 2912 } |
| 2854 | 2913 |
| 2855 STDMETHODIMP BrowserAccessibilityWin::get_maximumValue(VARIANT* value) { | 2914 STDMETHODIMP BrowserAccessibilityComWin::get_maximumValue(VARIANT* value) { |
| 2856 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_MAXIMUM_VALUE); | 2915 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_MAXIMUM_VALUE); |
| 2857 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2916 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2858 if (!instance_active()) | 2917 if (!GetOwner() || !GetOwner()->instance_active()) |
| 2859 return E_FAIL; | 2918 return E_FAIL; |
| 2860 | 2919 |
| 2861 if (!value) | 2920 if (!value) |
| 2862 return E_INVALIDARG; | 2921 return E_INVALIDARG; |
| 2863 | 2922 |
| 2864 float float_val; | 2923 float float_val; |
| 2865 if (GetFloatAttribute(ui::AX_ATTR_MAX_VALUE_FOR_RANGE, | 2924 if (GetFloatAttribute(ui::AX_ATTR_MAX_VALUE_FOR_RANGE, &float_val)) { |
| 2866 &float_val)) { | |
| 2867 value->vt = VT_R8; | 2925 value->vt = VT_R8; |
| 2868 value->dblVal = float_val; | 2926 value->dblVal = float_val; |
| 2869 return S_OK; | 2927 return S_OK; |
| 2870 } | 2928 } |
| 2871 | 2929 |
| 2872 value->vt = VT_EMPTY; | 2930 value->vt = VT_EMPTY; |
| 2873 return S_FALSE; | 2931 return S_FALSE; |
| 2874 } | 2932 } |
| 2875 | 2933 |
| 2876 STDMETHODIMP BrowserAccessibilityWin::setCurrentValue(VARIANT new_value) { | 2934 STDMETHODIMP BrowserAccessibilityComWin::setCurrentValue(VARIANT new_value) { |
| 2877 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SET_CURRENT_VALUE); | 2935 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SET_CURRENT_VALUE); |
| 2878 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2936 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2879 // TODO(dmazzoni): Implement this. | 2937 // TODO(dmazzoni): Implement this. |
| 2880 return E_NOTIMPL; | 2938 return E_NOTIMPL; |
| 2881 } | 2939 } |
| 2882 | 2940 |
| 2883 // | 2941 // |
| 2884 // ISimpleDOMDocument methods. | 2942 // ISimpleDOMDocument methods. |
| 2885 // | 2943 // |
| 2886 | 2944 |
| 2887 STDMETHODIMP BrowserAccessibilityWin::get_URL(BSTR* url) { | 2945 STDMETHODIMP BrowserAccessibilityComWin::get_URL(BSTR* url) { |
| 2888 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_URL); | 2946 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_URL); |
| 2889 if (!instance_active()) | 2947 if (!GetOwner() || !GetOwner()->instance_active()) |
| 2948 return E_FAIL; | |
| 2949 | |
| 2950 auto* manager = GetOwner()->manager(); | |
| 2951 if (!manager) | |
| 2890 return E_FAIL; | 2952 return E_FAIL; |
| 2891 | 2953 |
| 2892 if (!url) | 2954 if (!url) |
| 2893 return E_INVALIDARG; | 2955 return E_INVALIDARG; |
| 2894 | 2956 |
| 2895 if (this != manager_->GetRoot()) | 2957 if (GetOwner() != manager->GetRoot()) |
| 2896 return E_FAIL; | 2958 return E_FAIL; |
| 2897 | 2959 |
| 2898 std::string str = manager_->GetTreeData().url; | 2960 std::string str = manager->GetTreeData().url; |
| 2899 if (str.empty()) | 2961 if (str.empty()) |
| 2900 return S_FALSE; | 2962 return S_FALSE; |
| 2901 | 2963 |
| 2902 *url = SysAllocString(base::UTF8ToUTF16(str).c_str()); | 2964 *url = SysAllocString(base::UTF8ToUTF16(str).c_str()); |
| 2903 DCHECK(*url); | 2965 DCHECK(*url); |
| 2904 | 2966 |
| 2905 return S_OK; | 2967 return S_OK; |
| 2906 } | 2968 } |
| 2907 | 2969 |
| 2908 STDMETHODIMP BrowserAccessibilityWin::get_title(BSTR* title) { | 2970 STDMETHODIMP BrowserAccessibilityComWin::get_title(BSTR* title) { |
| 2909 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_TITLE); | 2971 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_TITLE); |
| 2910 if (!instance_active()) | 2972 if (!GetOwner() || !GetOwner()->instance_active()) |
| 2973 return E_FAIL; | |
| 2974 | |
| 2975 auto* manager = GetOwner()->manager(); | |
| 2976 if (!manager) | |
| 2911 return E_FAIL; | 2977 return E_FAIL; |
| 2912 | 2978 |
| 2913 if (!title) | 2979 if (!title) |
| 2914 return E_INVALIDARG; | 2980 return E_INVALIDARG; |
| 2915 | 2981 |
| 2916 std::string str = manager_->GetTreeData().title; | 2982 std::string str = manager->GetTreeData().title; |
| 2917 if (str.empty()) | 2983 if (str.empty()) |
| 2918 return S_FALSE; | 2984 return S_FALSE; |
| 2919 | 2985 |
| 2920 *title = SysAllocString(base::UTF8ToUTF16(str).c_str()); | 2986 *title = SysAllocString(base::UTF8ToUTF16(str).c_str()); |
| 2921 DCHECK(*title); | 2987 DCHECK(*title); |
| 2922 | 2988 |
| 2923 return S_OK; | 2989 return S_OK; |
| 2924 } | 2990 } |
| 2925 | 2991 |
| 2926 STDMETHODIMP BrowserAccessibilityWin::get_mimeType(BSTR* mime_type) { | 2992 STDMETHODIMP BrowserAccessibilityComWin::get_mimeType(BSTR* mime_type) { |
| 2927 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_MIME_TYPE); | 2993 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_MIME_TYPE); |
| 2928 if (!instance_active()) | 2994 if (!GetOwner() || !GetOwner()->instance_active()) |
| 2995 return E_FAIL; | |
| 2996 | |
| 2997 auto* manager = GetOwner()->manager(); | |
| 2998 if (!manager) | |
| 2929 return E_FAIL; | 2999 return E_FAIL; |
| 2930 | 3000 |
| 2931 if (!mime_type) | 3001 if (!mime_type) |
| 2932 return E_INVALIDARG; | 3002 return E_INVALIDARG; |
| 2933 | 3003 |
| 2934 std::string str = manager_->GetTreeData().mimetype; | 3004 std::string str = manager->GetTreeData().mimetype; |
| 2935 if (str.empty()) | 3005 if (str.empty()) |
| 2936 return S_FALSE; | 3006 return S_FALSE; |
| 2937 | 3007 |
| 2938 *mime_type = SysAllocString(base::UTF8ToUTF16(str).c_str()); | 3008 *mime_type = SysAllocString(base::UTF8ToUTF16(str).c_str()); |
| 2939 DCHECK(*mime_type); | 3009 DCHECK(*mime_type); |
| 2940 | 3010 |
| 2941 return S_OK; | 3011 return S_OK; |
| 2942 } | 3012 } |
| 2943 | 3013 |
| 2944 STDMETHODIMP BrowserAccessibilityWin::get_docType(BSTR* doc_type) { | 3014 STDMETHODIMP BrowserAccessibilityComWin::get_docType(BSTR* doc_type) { |
| 2945 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_DOC_TYPE); | 3015 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_DOC_TYPE); |
| 2946 if (!instance_active()) | 3016 if (!GetOwner() || !GetOwner()->instance_active()) |
| 3017 return E_FAIL; | |
| 3018 | |
| 3019 auto* manager = GetOwner()->manager(); | |
| 3020 if (!manager) | |
| 2947 return E_FAIL; | 3021 return E_FAIL; |
| 2948 | 3022 |
| 2949 if (!doc_type) | 3023 if (!doc_type) |
| 2950 return E_INVALIDARG; | 3024 return E_INVALIDARG; |
| 2951 | 3025 |
| 2952 std::string str = manager_->GetTreeData().doctype; | 3026 std::string str = manager->GetTreeData().doctype; |
| 2953 if (str.empty()) | 3027 if (str.empty()) |
| 2954 return S_FALSE; | 3028 return S_FALSE; |
| 2955 | 3029 |
| 2956 *doc_type = SysAllocString(base::UTF8ToUTF16(str).c_str()); | 3030 *doc_type = SysAllocString(base::UTF8ToUTF16(str).c_str()); |
| 2957 DCHECK(*doc_type); | 3031 DCHECK(*doc_type); |
| 2958 | 3032 |
| 2959 return S_OK; | 3033 return S_OK; |
| 2960 } | 3034 } |
| 2961 | 3035 |
| 2962 STDMETHODIMP | 3036 STDMETHODIMP |
| 2963 BrowserAccessibilityWin::get_nameSpaceURIForID(short name_space_id, | 3037 BrowserAccessibilityComWin::get_nameSpaceURIForID(short name_space_id, |
| 2964 BSTR* name_space_uri) { | 3038 BSTR* name_space_uri) { |
| 2965 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_NAMESPACE_URI_FOR_ID); | 3039 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_NAMESPACE_URI_FOR_ID); |
| 2966 return E_NOTIMPL; | 3040 return E_NOTIMPL; |
| 2967 } | 3041 } |
| 2968 | 3042 |
| 2969 STDMETHODIMP | 3043 STDMETHODIMP |
| 2970 BrowserAccessibilityWin::put_alternateViewMediaTypes( | 3044 BrowserAccessibilityComWin::put_alternateViewMediaTypes( |
| 2971 BSTR* comma_separated_media_types) { | 3045 BSTR* comma_separated_media_types) { |
| 2972 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_PUT_ALTERNATE_VIEW_MEDIA_TYPES); | 3046 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_PUT_ALTERNATE_VIEW_MEDIA_TYPES); |
| 2973 return E_NOTIMPL; | 3047 return E_NOTIMPL; |
| 2974 } | 3048 } |
| 2975 | 3049 |
| 2976 // | 3050 // |
| 2977 // ISimpleDOMNode methods. | 3051 // ISimpleDOMNode methods. |
| 2978 // | 3052 // |
| 2979 | 3053 |
| 2980 STDMETHODIMP BrowserAccessibilityWin::get_nodeInfo( | 3054 STDMETHODIMP BrowserAccessibilityComWin::get_nodeInfo( |
| 2981 BSTR* node_name, | 3055 BSTR* node_name, |
| 2982 short* name_space_id, | 3056 short* name_space_id, |
| 2983 BSTR* node_value, | 3057 BSTR* node_value, |
| 2984 unsigned int* num_children, | 3058 unsigned int* num_children, |
| 2985 unsigned int* unique_id, | 3059 unsigned int* unique_id, |
| 2986 unsigned short* node_type) { | 3060 unsigned short* node_type) { |
| 2987 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_NODE_INFO); | 3061 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_NODE_INFO); |
| 2988 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 3062 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 2989 if (!instance_active()) | 3063 if (!GetOwner() || !GetOwner()->instance_active()) |
| 2990 return E_FAIL; | 3064 return E_FAIL; |
| 2991 | 3065 |
| 2992 if (!node_name || !name_space_id || !node_value || !num_children || | 3066 if (!node_name || !name_space_id || !node_value || !num_children || |
| 2993 !unique_id || !node_type) { | 3067 !unique_id || !node_type) { |
| 2994 return E_INVALIDARG; | 3068 return E_INVALIDARG; |
| 2995 } | 3069 } |
| 2996 | 3070 |
| 2997 base::string16 tag; | 3071 base::string16 tag; |
| 2998 if (GetString16Attribute(ui::AX_ATTR_HTML_TAG, &tag)) | 3072 if (GetOwner()->GetString16Attribute(ui::AX_ATTR_HTML_TAG, &tag)) |
| 2999 *node_name = SysAllocString(tag.c_str()); | 3073 *node_name = SysAllocString(tag.c_str()); |
| 3000 else | 3074 else |
| 3001 *node_name = nullptr; | 3075 *node_name = nullptr; |
| 3002 | 3076 |
| 3003 *name_space_id = 0; | 3077 *name_space_id = 0; |
| 3004 *node_value = SysAllocString(value().c_str()); | 3078 *node_value = SysAllocString(value().c_str()); |
| 3005 *num_children = PlatformChildCount(); | 3079 *num_children = GetOwner()->PlatformChildCount(); |
| 3006 *unique_id = -this->unique_id(); | 3080 *unique_id = -GetOwner()->unique_id(); |
| 3007 | 3081 |
| 3008 if (GetRole() == ui::AX_ROLE_ROOT_WEB_AREA || | 3082 if (GetOwner()->GetRole() == ui::AX_ROLE_ROOT_WEB_AREA || |
| 3009 GetRole() == ui::AX_ROLE_WEB_AREA) { | 3083 GetOwner()->GetRole() == ui::AX_ROLE_WEB_AREA) { |
| 3010 *node_type = NODETYPE_DOCUMENT; | 3084 *node_type = NODETYPE_DOCUMENT; |
| 3011 } else if (IsTextOnlyObject()) { | 3085 } else if (GetOwner()->IsTextOnlyObject()) { |
| 3012 *node_type = NODETYPE_TEXT; | 3086 *node_type = NODETYPE_TEXT; |
| 3013 } else { | 3087 } else { |
| 3014 *node_type = NODETYPE_ELEMENT; | 3088 *node_type = NODETYPE_ELEMENT; |
| 3015 } | 3089 } |
| 3016 | 3090 |
| 3017 return S_OK; | 3091 return S_OK; |
| 3018 } | 3092 } |
| 3019 | 3093 |
| 3020 STDMETHODIMP BrowserAccessibilityWin::get_attributes( | 3094 STDMETHODIMP BrowserAccessibilityComWin::get_attributes( |
| 3021 unsigned short max_attribs, | 3095 unsigned short max_attribs, |
| 3022 BSTR* attrib_names, | 3096 BSTR* attrib_names, |
| 3023 short* name_space_id, | 3097 short* name_space_id, |
| 3024 BSTR* attrib_values, | 3098 BSTR* attrib_values, |
| 3025 unsigned short* num_attribs) { | 3099 unsigned short* num_attribs) { |
| 3026 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ISIMPLEDOMNODE_GET_ATTRIBUTES); | 3100 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ISIMPLEDOMNODE_GET_ATTRIBUTES); |
| 3027 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 3101 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 3028 if (!instance_active()) | 3102 if (!GetOwner() || !GetOwner()->instance_active()) |
| 3029 return E_FAIL; | 3103 return E_FAIL; |
| 3030 | 3104 |
| 3031 if (!attrib_names || !name_space_id || !attrib_values || !num_attribs) | 3105 if (!attrib_names || !name_space_id || !attrib_values || !num_attribs) |
| 3032 return E_INVALIDARG; | 3106 return E_INVALIDARG; |
| 3033 | 3107 |
| 3034 *num_attribs = max_attribs; | 3108 *num_attribs = max_attribs; |
| 3035 if (*num_attribs > GetHtmlAttributes().size()) | 3109 if (*num_attribs > GetOwner()->GetHtmlAttributes().size()) |
| 3036 *num_attribs = GetHtmlAttributes().size(); | 3110 *num_attribs = GetOwner()->GetHtmlAttributes().size(); |
| 3037 | 3111 |
| 3038 for (unsigned short i = 0; i < *num_attribs; ++i) { | 3112 for (unsigned short i = 0; i < *num_attribs; ++i) { |
| 3039 attrib_names[i] = SysAllocString( | 3113 attrib_names[i] = SysAllocString( |
| 3040 base::UTF8ToUTF16(GetHtmlAttributes()[i].first).c_str()); | 3114 base::UTF8ToUTF16(GetOwner()->GetHtmlAttributes()[i].first).c_str()); |
| 3041 name_space_id[i] = 0; | 3115 name_space_id[i] = 0; |
| 3042 attrib_values[i] = SysAllocString( | 3116 attrib_values[i] = SysAllocString( |
| 3043 base::UTF8ToUTF16(GetHtmlAttributes()[i].second).c_str()); | 3117 base::UTF8ToUTF16(GetOwner()->GetHtmlAttributes()[i].second).c_str()); |
| 3044 } | 3118 } |
| 3045 return S_OK; | 3119 return S_OK; |
| 3046 } | 3120 } |
| 3047 | 3121 |
| 3048 STDMETHODIMP BrowserAccessibilityWin::get_attributesForNames( | 3122 STDMETHODIMP BrowserAccessibilityComWin::get_attributesForNames( |
| 3049 unsigned short num_attribs, | 3123 unsigned short num_attribs, |
| 3050 BSTR* attrib_names, | 3124 BSTR* attrib_names, |
| 3051 short* name_space_id, | 3125 short* name_space_id, |
| 3052 BSTR* attrib_values) { | 3126 BSTR* attrib_values) { |
| 3053 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ATTRIBUTES_FOR_NAMES); | 3127 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ATTRIBUTES_FOR_NAMES); |
| 3054 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 3128 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 3055 if (!instance_active()) | 3129 if (!GetOwner() || !GetOwner()->instance_active()) |
| 3056 return E_FAIL; | 3130 return E_FAIL; |
| 3057 | 3131 |
| 3058 if (!attrib_names || !name_space_id || !attrib_values) | 3132 if (!attrib_names || !name_space_id || !attrib_values) |
| 3059 return E_INVALIDARG; | 3133 return E_INVALIDARG; |
| 3060 | 3134 |
| 3061 for (unsigned short i = 0; i < num_attribs; ++i) { | 3135 for (unsigned short i = 0; i < num_attribs; ++i) { |
| 3062 name_space_id[i] = 0; | 3136 name_space_id[i] = 0; |
| 3063 bool found = false; | 3137 bool found = false; |
| 3064 std::string name = base::UTF16ToUTF8((LPCWSTR)attrib_names[i]); | 3138 std::string name = base::UTF16ToUTF8((LPCWSTR)attrib_names[i]); |
| 3065 for (unsigned int j = 0; j < GetHtmlAttributes().size(); ++j) { | 3139 for (unsigned int j = 0; j < GetOwner()->GetHtmlAttributes().size(); ++j) { |
| 3066 if (GetHtmlAttributes()[j].first == name) { | 3140 if (GetOwner()->GetHtmlAttributes()[j].first == name) { |
| 3067 attrib_values[i] = SysAllocString( | 3141 attrib_values[i] = SysAllocString( |
| 3068 base::UTF8ToUTF16(GetHtmlAttributes()[j].second).c_str()); | 3142 base::UTF8ToUTF16(GetOwner()->GetHtmlAttributes()[j].second) |
| 3143 .c_str()); | |
| 3069 found = true; | 3144 found = true; |
| 3070 break; | 3145 break; |
| 3071 } | 3146 } |
| 3072 } | 3147 } |
| 3073 if (!found) { | 3148 if (!found) { |
| 3074 attrib_values[i] = NULL; | 3149 attrib_values[i] = NULL; |
| 3075 } | 3150 } |
| 3076 } | 3151 } |
| 3077 return S_OK; | 3152 return S_OK; |
| 3078 } | 3153 } |
| 3079 | 3154 |
| 3080 STDMETHODIMP BrowserAccessibilityWin::get_computedStyle( | 3155 STDMETHODIMP BrowserAccessibilityComWin::get_computedStyle( |
| 3081 unsigned short max_style_properties, | 3156 unsigned short max_style_properties, |
| 3082 boolean use_alternate_view, | 3157 boolean use_alternate_view, |
| 3083 BSTR* style_properties, | 3158 BSTR* style_properties, |
| 3084 BSTR* style_values, | 3159 BSTR* style_values, |
| 3085 unsigned short *num_style_properties) { | 3160 unsigned short* num_style_properties) { |
| 3086 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COMPUTED_STYLE); | 3161 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COMPUTED_STYLE); |
| 3087 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 3162 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 3088 if (!instance_active()) | 3163 if (!GetOwner() || !GetOwner()->instance_active()) |
| 3089 return E_FAIL; | 3164 return E_FAIL; |
| 3090 | 3165 |
| 3091 if (!style_properties || !style_values) | 3166 if (!style_properties || !style_values) |
| 3092 return E_INVALIDARG; | 3167 return E_INVALIDARG; |
| 3093 | 3168 |
| 3094 // We only cache a single style property for now: DISPLAY | 3169 // We only cache a single style property for now: DISPLAY |
| 3095 | 3170 |
| 3096 base::string16 display; | 3171 base::string16 display; |
| 3097 if (max_style_properties == 0 || | 3172 if (max_style_properties == 0 || |
| 3098 !GetString16Attribute(ui::AX_ATTR_DISPLAY, &display)) { | 3173 !GetOwner()->GetString16Attribute(ui::AX_ATTR_DISPLAY, &display)) { |
| 3099 *num_style_properties = 0; | 3174 *num_style_properties = 0; |
| 3100 return S_OK; | 3175 return S_OK; |
| 3101 } | 3176 } |
| 3102 | 3177 |
| 3103 *num_style_properties = 1; | 3178 *num_style_properties = 1; |
| 3104 style_properties[0] = SysAllocString(L"display"); | 3179 style_properties[0] = SysAllocString(L"display"); |
| 3105 style_values[0] = SysAllocString(display.c_str()); | 3180 style_values[0] = SysAllocString(display.c_str()); |
| 3106 | 3181 |
| 3107 return S_OK; | 3182 return S_OK; |
| 3108 } | 3183 } |
| 3109 | 3184 |
| 3110 STDMETHODIMP BrowserAccessibilityWin::get_computedStyleForProperties( | 3185 STDMETHODIMP BrowserAccessibilityComWin::get_computedStyleForProperties( |
| 3111 unsigned short num_style_properties, | 3186 unsigned short num_style_properties, |
| 3112 boolean use_alternate_view, | 3187 boolean use_alternate_view, |
| 3113 BSTR* style_properties, | 3188 BSTR* style_properties, |
| 3114 BSTR* style_values) { | 3189 BSTR* style_values) { |
| 3115 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COMPUTED_STYLE_FOR_PROPERTIES); | 3190 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COMPUTED_STYLE_FOR_PROPERTIES); |
| 3116 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 3191 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 3117 if (!instance_active()) | 3192 if (!GetOwner() || !GetOwner()->instance_active()) |
| 3118 return E_FAIL; | 3193 return E_FAIL; |
| 3119 | 3194 |
| 3120 if (!style_properties || !style_values) | 3195 if (!style_properties || !style_values) |
| 3121 return E_INVALIDARG; | 3196 return E_INVALIDARG; |
| 3122 | 3197 |
| 3123 // We only cache a single style property for now: DISPLAY | 3198 // We only cache a single style property for now: DISPLAY |
| 3124 | 3199 |
| 3125 for (unsigned short i = 0; i < num_style_properties; ++i) { | 3200 for (unsigned short i = 0; i < num_style_properties; ++i) { |
| 3126 base::string16 name = base::ToLowerASCII( | 3201 base::string16 name = base::ToLowerASCII( |
| 3127 reinterpret_cast<const base::char16*>(style_properties[i])); | 3202 reinterpret_cast<const base::char16*>(style_properties[i])); |
| 3128 if (name == L"display") { | 3203 if (name == L"display") { |
| 3129 base::string16 display = GetString16Attribute( | 3204 base::string16 display = |
| 3130 ui::AX_ATTR_DISPLAY); | 3205 GetOwner()->GetString16Attribute(ui::AX_ATTR_DISPLAY); |
| 3131 style_values[i] = SysAllocString(display.c_str()); | 3206 style_values[i] = SysAllocString(display.c_str()); |
| 3132 } else { | 3207 } else { |
| 3133 style_values[i] = NULL; | 3208 style_values[i] = NULL; |
| 3134 } | 3209 } |
| 3135 } | 3210 } |
| 3136 | 3211 |
| 3137 return S_OK; | 3212 return S_OK; |
| 3138 } | 3213 } |
| 3139 | 3214 |
| 3140 STDMETHODIMP BrowserAccessibilityWin::scrollTo(boolean placeTopLeft) { | 3215 STDMETHODIMP BrowserAccessibilityComWin::scrollTo(boolean placeTopLeft) { |
| 3141 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ISIMPLEDOMNODE_SCROLL_TO); | 3216 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ISIMPLEDOMNODE_SCROLL_TO); |
| 3142 return scrollTo(placeTopLeft ? | 3217 return scrollTo(placeTopLeft ? IA2_SCROLL_TYPE_TOP_LEFT |
| 3143 IA2_SCROLL_TYPE_TOP_LEFT : IA2_SCROLL_TYPE_ANYWHERE); | 3218 : IA2_SCROLL_TYPE_ANYWHERE); |
| 3144 } | 3219 } |
| 3145 | 3220 |
| 3146 STDMETHODIMP BrowserAccessibilityWin::get_parentNode(ISimpleDOMNode** node) { | 3221 STDMETHODIMP BrowserAccessibilityComWin::get_parentNode(ISimpleDOMNode** node) { |
| 3147 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_PARENT_NODE); | 3222 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_PARENT_NODE); |
| 3148 if (!instance_active()) | 3223 if (!GetOwner() || !GetOwner()->instance_active()) |
| 3149 return E_FAIL; | 3224 return E_FAIL; |
| 3150 | 3225 |
| 3151 if (!node) | 3226 if (!node) |
| 3152 return E_INVALIDARG; | 3227 return E_INVALIDARG; |
| 3153 | 3228 |
| 3154 *node = ToBrowserAccessibilityWin(PlatformGetParent())->NewReference(); | 3229 *node = ToBrowserAccessibilityComWin(GetOwner()->PlatformGetParent()) |
| 3230 ->NewReference(); | |
| 3155 return S_OK; | 3231 return S_OK; |
| 3156 } | 3232 } |
| 3157 | 3233 |
| 3158 STDMETHODIMP BrowserAccessibilityWin::get_firstChild(ISimpleDOMNode** node) { | 3234 STDMETHODIMP BrowserAccessibilityComWin::get_firstChild(ISimpleDOMNode** node) { |
| 3159 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_FIRST_CHILD); | 3235 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_FIRST_CHILD); |
| 3160 if (!instance_active()) | 3236 if (!GetOwner() || !GetOwner()->instance_active()) |
| 3161 return E_FAIL; | 3237 return E_FAIL; |
| 3162 | 3238 |
| 3163 if (!node) | 3239 if (!node) |
| 3164 return E_INVALIDARG; | 3240 return E_INVALIDARG; |
| 3165 | 3241 |
| 3166 if (PlatformChildCount() == 0) { | 3242 if (GetOwner()->PlatformChildCount() == 0) { |
| 3167 *node = NULL; | 3243 *node = NULL; |
| 3168 return S_FALSE; | 3244 return S_FALSE; |
| 3169 } | 3245 } |
| 3170 | 3246 |
| 3171 *node = ToBrowserAccessibilityWin(PlatformGetChild(0))->NewReference(); | 3247 *node = ToBrowserAccessibilityComWin(GetOwner()->PlatformGetChild(0)) |
| 3248 ->NewReference(); | |
| 3172 return S_OK; | 3249 return S_OK; |
| 3173 } | 3250 } |
| 3174 | 3251 |
| 3175 STDMETHODIMP BrowserAccessibilityWin::get_lastChild(ISimpleDOMNode** node) { | 3252 STDMETHODIMP BrowserAccessibilityComWin::get_lastChild(ISimpleDOMNode** node) { |
| 3176 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LAST_CHILD); | 3253 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LAST_CHILD); |
| 3177 if (!instance_active()) | 3254 if (!GetOwner() || !GetOwner()->instance_active()) |
| 3178 return E_FAIL; | 3255 return E_FAIL; |
| 3179 | 3256 |
| 3180 if (!node) | 3257 if (!node) |
| 3181 return E_INVALIDARG; | 3258 return E_INVALIDARG; |
| 3182 | 3259 |
| 3183 if (PlatformChildCount() == 0) { | 3260 if (GetOwner()->PlatformChildCount() == 0) { |
| 3184 *node = NULL; | 3261 *node = NULL; |
| 3185 return S_FALSE; | 3262 return S_FALSE; |
| 3186 } | 3263 } |
| 3187 | 3264 |
| 3188 *node = ToBrowserAccessibilityWin( | 3265 *node = |
| 3189 PlatformGetChild(PlatformChildCount() - 1))->NewReference(); | 3266 ToBrowserAccessibilityComWin( |
| 3267 GetOwner()->PlatformGetChild(GetOwner()->PlatformChildCount() - 1)) | |
| 3268 ->NewReference(); | |
| 3190 return S_OK; | 3269 return S_OK; |
| 3191 } | 3270 } |
| 3192 | 3271 |
| 3193 STDMETHODIMP BrowserAccessibilityWin::get_previousSibling( | 3272 STDMETHODIMP BrowserAccessibilityComWin::get_previousSibling( |
| 3194 ISimpleDOMNode** node) { | 3273 ISimpleDOMNode** node) { |
| 3195 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_PREVIOUS_SIBLING); | 3274 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_PREVIOUS_SIBLING); |
| 3196 if (!instance_active()) | 3275 if (!GetOwner() || !GetOwner()->instance_active()) |
| 3197 return E_FAIL; | 3276 return E_FAIL; |
| 3198 | 3277 |
| 3199 if (!node) | 3278 if (!node) |
| 3200 return E_INVALIDARG; | 3279 return E_INVALIDARG; |
| 3201 | 3280 |
| 3202 if (!PlatformGetParent() || GetIndexInParent() <= 0) { | 3281 if (!GetOwner()->PlatformGetParent() || GetIndexInParent() <= 0) { |
| 3203 *node = NULL; | 3282 *node = NULL; |
| 3204 return S_FALSE; | 3283 return S_FALSE; |
| 3205 } | 3284 } |
| 3206 | 3285 |
| 3207 *node = ToBrowserAccessibilityWin( | 3286 *node = ToBrowserAccessibilityComWin( |
| 3208 PlatformGetParent()->InternalGetChild(GetIndexInParent() - 1)) | 3287 GetOwner()->PlatformGetParent()->InternalGetChild( |
| 3288 GetIndexInParent() - 1)) | |
| 3209 ->NewReference(); | 3289 ->NewReference(); |
| 3210 return S_OK; | 3290 return S_OK; |
| 3211 } | 3291 } |
| 3212 | 3292 |
| 3213 STDMETHODIMP BrowserAccessibilityWin::get_nextSibling(ISimpleDOMNode** node) { | 3293 STDMETHODIMP BrowserAccessibilityComWin::get_nextSibling( |
| 3294 ISimpleDOMNode** node) { | |
| 3214 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_NEXT_SIBLING); | 3295 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_NEXT_SIBLING); |
| 3215 if (!instance_active()) | 3296 if (!GetOwner() || !GetOwner()->instance_active()) |
| 3216 return E_FAIL; | 3297 return E_FAIL; |
| 3217 | 3298 |
| 3218 if (!node) | 3299 if (!node) |
| 3219 return E_INVALIDARG; | 3300 return E_INVALIDARG; |
| 3220 | 3301 |
| 3221 if (!PlatformGetParent() || GetIndexInParent() < 0 || | 3302 if (!GetOwner()->PlatformGetParent() || GetIndexInParent() < 0 || |
| 3222 GetIndexInParent() >= | 3303 GetIndexInParent() >= |
| 3223 static_cast<int>(PlatformGetParent()->InternalChildCount()) - 1) { | 3304 static_cast<int>( |
| 3305 GetOwner()->PlatformGetParent()->InternalChildCount()) - | |
| 3306 1) { | |
| 3224 *node = NULL; | 3307 *node = NULL; |
| 3225 return S_FALSE; | 3308 return S_FALSE; |
| 3226 } | 3309 } |
| 3227 | 3310 |
| 3228 *node = ToBrowserAccessibilityWin( | 3311 *node = ToBrowserAccessibilityComWin( |
| 3229 PlatformGetParent()->InternalGetChild(GetIndexInParent() + 1)) | 3312 GetOwner()->PlatformGetParent()->InternalGetChild( |
| 3313 GetIndexInParent() + 1)) | |
| 3230 ->NewReference(); | 3314 ->NewReference(); |
| 3231 return S_OK; | 3315 return S_OK; |
| 3232 } | 3316 } |
| 3233 | 3317 |
| 3234 STDMETHODIMP BrowserAccessibilityWin::get_childAt( | 3318 STDMETHODIMP BrowserAccessibilityComWin::get_childAt(unsigned int child_index, |
| 3235 unsigned int child_index, | 3319 ISimpleDOMNode** node) { |
| 3236 ISimpleDOMNode** node) { | |
| 3237 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CHILD_AT); | 3320 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CHILD_AT); |
| 3238 if (!instance_active()) | 3321 if (!GetOwner() || !GetOwner()->instance_active()) |
| 3239 return E_FAIL; | 3322 return E_FAIL; |
| 3240 | 3323 |
| 3241 if (!node) | 3324 if (!node) |
| 3242 return E_INVALIDARG; | 3325 return E_INVALIDARG; |
| 3243 | 3326 |
| 3244 if (child_index >= PlatformChildCount()) | 3327 if (child_index >= GetOwner()->PlatformChildCount()) |
| 3245 return E_INVALIDARG; | 3328 return E_INVALIDARG; |
| 3246 | 3329 |
| 3247 BrowserAccessibility* child = PlatformGetChild(child_index); | 3330 BrowserAccessibility* child = GetOwner()->PlatformGetChild(child_index); |
| 3248 if (!child) { | 3331 if (!child) { |
| 3249 *node = NULL; | 3332 *node = NULL; |
| 3250 return S_FALSE; | 3333 return S_FALSE; |
| 3251 } | 3334 } |
| 3252 | 3335 |
| 3253 *node = ToBrowserAccessibilityWin(child)->NewReference(); | 3336 *node = ToBrowserAccessibilityComWin(child)->NewReference(); |
| 3254 return S_OK; | 3337 return S_OK; |
| 3255 } | 3338 } |
| 3256 | 3339 |
| 3257 // We only support this method for retrieving MathML content. | 3340 // We only support this method for retrieving MathML content. |
| 3258 STDMETHODIMP BrowserAccessibilityWin::get_innerHTML(BSTR* innerHTML) { | 3341 STDMETHODIMP BrowserAccessibilityComWin::get_innerHTML(BSTR* innerHTML) { |
| 3259 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_INNER_HTML); | 3342 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_INNER_HTML); |
| 3260 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 3343 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 3261 if (GetRole() != ui::AX_ROLE_MATH) | 3344 if (!GetOwner() || !GetOwner()->instance_active()) |
| 3345 return E_FAIL; | |
| 3346 if (GetOwner()->GetRole() != ui::AX_ROLE_MATH) | |
| 3262 return E_NOTIMPL; | 3347 return E_NOTIMPL; |
| 3263 if (!instance_active()) | |
| 3264 return E_FAIL; | |
| 3265 | 3348 |
| 3266 base::string16 inner_html = GetString16Attribute(ui::AX_ATTR_INNER_HTML); | 3349 base::string16 inner_html = |
| 3350 GetOwner()->GetString16Attribute(ui::AX_ATTR_INNER_HTML); | |
| 3267 *innerHTML = SysAllocString(inner_html.c_str()); | 3351 *innerHTML = SysAllocString(inner_html.c_str()); |
| 3268 DCHECK(*innerHTML); | 3352 DCHECK(*innerHTML); |
| 3269 return S_OK; | 3353 return S_OK; |
| 3270 } | 3354 } |
| 3271 | 3355 |
| 3272 STDMETHODIMP | 3356 STDMETHODIMP |
| 3273 BrowserAccessibilityWin::get_localInterface(void** local_interface) { | 3357 BrowserAccessibilityComWin::get_localInterface(void** local_interface) { |
| 3274 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LOCAL_INTERFACE); | 3358 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LOCAL_INTERFACE); |
| 3275 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 3359 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 3276 return E_NOTIMPL; | 3360 return E_NOTIMPL; |
| 3277 } | 3361 } |
| 3278 | 3362 |
| 3279 STDMETHODIMP BrowserAccessibilityWin::get_language(BSTR* language) { | 3363 STDMETHODIMP BrowserAccessibilityComWin::get_language(BSTR* language) { |
| 3280 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LANGUAGE); | 3364 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LANGUAGE); |
| 3281 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 3365 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 3282 if (!language) | 3366 if (!language) |
| 3283 return E_INVALIDARG; | 3367 return E_INVALIDARG; |
| 3284 *language = nullptr; | 3368 *language = nullptr; |
| 3285 | 3369 |
| 3286 if (!instance_active()) | 3370 if (!GetOwner() || !GetOwner()->instance_active()) |
| 3287 return E_FAIL; | 3371 return E_FAIL; |
| 3288 | 3372 |
| 3289 base::string16 lang = GetInheritedString16Attribute(ui::AX_ATTR_LANGUAGE); | 3373 base::string16 lang = |
| 3374 GetOwner()->GetInheritedString16Attribute(ui::AX_ATTR_LANGUAGE); | |
| 3290 if (lang.empty()) | 3375 if (lang.empty()) |
| 3291 lang = L"en-US"; | 3376 lang = L"en-US"; |
| 3292 | 3377 |
| 3293 *language = SysAllocString(lang.c_str()); | 3378 *language = SysAllocString(lang.c_str()); |
| 3294 DCHECK(*language); | 3379 DCHECK(*language); |
| 3295 return S_OK; | 3380 return S_OK; |
| 3296 } | 3381 } |
| 3297 | 3382 |
| 3298 // | 3383 // |
| 3299 // ISimpleDOMText methods. | 3384 // ISimpleDOMText methods. |
| 3300 // | 3385 // |
| 3301 | 3386 |
| 3302 STDMETHODIMP BrowserAccessibilityWin::get_domText(BSTR* dom_text) { | 3387 STDMETHODIMP BrowserAccessibilityComWin::get_domText(BSTR* dom_text) { |
| 3303 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_DOM_TEXT); | 3388 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_DOM_TEXT); |
| 3304 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 3389 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 3305 if (!instance_active()) | 3390 if (!GetOwner() || !GetOwner()->instance_active()) |
| 3306 return E_FAIL; | 3391 return E_FAIL; |
| 3307 | 3392 |
| 3308 if (!dom_text) | 3393 if (!dom_text) |
| 3309 return E_INVALIDARG; | 3394 return E_INVALIDARG; |
| 3310 | 3395 |
| 3311 return GetStringAttributeAsBstr( | 3396 return GetStringAttributeAsBstr(ui::AX_ATTR_NAME, dom_text); |
| 3312 ui::AX_ATTR_NAME, dom_text); | |
| 3313 } | 3397 } |
| 3314 | 3398 |
| 3315 STDMETHODIMP BrowserAccessibilityWin::get_clippedSubstringBounds( | 3399 STDMETHODIMP BrowserAccessibilityComWin::get_clippedSubstringBounds( |
| 3316 unsigned int start_index, | 3400 unsigned int start_index, |
| 3317 unsigned int end_index, | 3401 unsigned int end_index, |
| 3318 int* out_x, | 3402 int* out_x, |
| 3319 int* out_y, | 3403 int* out_y, |
| 3320 int* out_width, | 3404 int* out_width, |
| 3321 int* out_height) { | 3405 int* out_height) { |
| 3322 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CLIPPED_SUBSTRING_BOUNDS); | 3406 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CLIPPED_SUBSTRING_BOUNDS); |
| 3323 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | | 3407 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | |
| 3324 AccessibilityMode::kInlineTextBoxes); | 3408 AccessibilityMode::kInlineTextBoxes); |
| 3325 // TODO(dmazzoni): fully support this API by intersecting the | 3409 // TODO(dmazzoni): fully support this API by intersecting the |
| 3326 // rect with the container's rect. | 3410 // rect with the container's rect. |
| 3327 return get_unclippedSubstringBounds( | 3411 return get_unclippedSubstringBounds(start_index, end_index, out_x, out_y, |
| 3328 start_index, end_index, out_x, out_y, out_width, out_height); | 3412 out_width, out_height); |
| 3329 } | 3413 } |
| 3330 | 3414 |
| 3331 STDMETHODIMP BrowserAccessibilityWin::get_unclippedSubstringBounds( | 3415 STDMETHODIMP BrowserAccessibilityComWin::get_unclippedSubstringBounds( |
| 3332 unsigned int start_index, | 3416 unsigned int start_index, |
| 3333 unsigned int end_index, | 3417 unsigned int end_index, |
| 3334 int* out_x, | 3418 int* out_x, |
| 3335 int* out_y, | 3419 int* out_y, |
| 3336 int* out_width, | 3420 int* out_width, |
| 3337 int* out_height) { | 3421 int* out_height) { |
| 3338 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_UNCLIPPED_SUBSTRING_BOUNDS); | 3422 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_UNCLIPPED_SUBSTRING_BOUNDS); |
| 3339 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | | 3423 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | |
| 3340 AccessibilityMode::kInlineTextBoxes); | 3424 AccessibilityMode::kInlineTextBoxes); |
| 3341 if (!instance_active()) | 3425 if (!GetOwner() || !GetOwner()->instance_active()) |
| 3342 return E_FAIL; | 3426 return E_FAIL; |
| 3343 | 3427 |
| 3344 if (!out_x || !out_y || !out_width || !out_height) | 3428 if (!out_x || !out_y || !out_width || !out_height) |
| 3345 return E_INVALIDARG; | 3429 return E_INVALIDARG; |
| 3346 | 3430 |
| 3347 unsigned int text_length = static_cast<unsigned int>(GetText().size()); | 3431 unsigned int text_length = |
| 3432 static_cast<unsigned int>(GetOwner()->GetText().size()); | |
| 3348 if (start_index > text_length || end_index > text_length || | 3433 if (start_index > text_length || end_index > text_length || |
| 3349 start_index > end_index) { | 3434 start_index > end_index) { |
| 3350 return E_INVALIDARG; | 3435 return E_INVALIDARG; |
| 3351 } | 3436 } |
| 3352 | 3437 |
| 3353 gfx::Rect bounds = GetScreenBoundsForRange( | 3438 gfx::Rect bounds = |
| 3354 start_index, end_index - start_index); | 3439 GetOwner()->GetScreenBoundsForRange(start_index, end_index - start_index); |
| 3355 *out_x = bounds.x(); | 3440 *out_x = bounds.x(); |
| 3356 *out_y = bounds.y(); | 3441 *out_y = bounds.y(); |
| 3357 *out_width = bounds.width(); | 3442 *out_width = bounds.width(); |
| 3358 *out_height = bounds.height(); | 3443 *out_height = bounds.height(); |
| 3359 return S_OK; | 3444 return S_OK; |
| 3360 } | 3445 } |
| 3361 | 3446 |
| 3362 STDMETHODIMP BrowserAccessibilityWin::scrollToSubstring( | 3447 STDMETHODIMP BrowserAccessibilityComWin::scrollToSubstring( |
| 3363 unsigned int start_index, | 3448 unsigned int start_index, |
| 3364 unsigned int end_index) { | 3449 unsigned int end_index) { |
| 3365 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SCROLL_TO_SUBSTRING); | 3450 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SCROLL_TO_SUBSTRING); |
| 3366 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | | 3451 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes | |
| 3367 AccessibilityMode::kInlineTextBoxes); | 3452 AccessibilityMode::kInlineTextBoxes); |
| 3368 if (!instance_active()) | 3453 if (!GetOwner() || !GetOwner()->instance_active()) |
| 3369 return E_FAIL; | 3454 return E_FAIL; |
| 3370 | 3455 |
| 3371 unsigned int text_length = static_cast<unsigned int>(GetText().size()); | 3456 auto* manager = GetOwner()->manager(); |
| 3457 if (!manager) | |
| 3458 return E_FAIL; | |
| 3459 | |
| 3460 unsigned int text_length = | |
| 3461 static_cast<unsigned int>(GetOwner()->GetText().size()); | |
| 3372 if (start_index > text_length || end_index > text_length || | 3462 if (start_index > text_length || end_index > text_length || |
| 3373 start_index > end_index) { | 3463 start_index > end_index) { |
| 3374 return E_INVALIDARG; | 3464 return E_INVALIDARG; |
| 3375 } | 3465 } |
| 3376 | 3466 |
| 3377 manager_->ScrollToMakeVisible( | 3467 manager->ScrollToMakeVisible( |
| 3378 *this, GetPageBoundsForRange(start_index, end_index - start_index)); | 3468 *GetOwner(), |
| 3469 GetOwner()->GetPageBoundsForRange(start_index, end_index - start_index)); | |
| 3379 | 3470 |
| 3380 return S_OK; | 3471 return S_OK; |
| 3381 } | 3472 } |
| 3382 | 3473 |
| 3383 STDMETHODIMP BrowserAccessibilityWin::get_fontFamily(BSTR* font_family) { | 3474 STDMETHODIMP BrowserAccessibilityComWin::get_fontFamily(BSTR* font_family) { |
| 3384 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_FONT_FAMILY); | 3475 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_FONT_FAMILY); |
| 3385 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 3476 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
| 3386 if (!font_family) | 3477 if (!font_family) |
| 3387 return E_INVALIDARG; | 3478 return E_INVALIDARG; |
| 3388 *font_family = nullptr; | 3479 *font_family = nullptr; |
| 3389 | 3480 |
| 3390 if (!instance_active()) | 3481 if (!GetOwner() || !GetOwner()->instance_active()) |
| 3391 return E_FAIL; | 3482 return E_FAIL; |
| 3392 | 3483 |
| 3393 base::string16 family = | 3484 base::string16 family = |
| 3394 GetInheritedString16Attribute(ui::AX_ATTR_FONT_FAMILY); | 3485 GetOwner()->GetInheritedString16Attribute(ui::AX_ATTR_FONT_FAMILY); |
| 3395 if (family.empty()) | 3486 if (family.empty()) |
| 3396 return S_FALSE; | 3487 return S_FALSE; |
| 3397 | 3488 |
| 3398 *font_family = SysAllocString(family.c_str()); | 3489 *font_family = SysAllocString(family.c_str()); |
| 3399 DCHECK(*font_family); | 3490 DCHECK(*font_family); |
| 3400 return S_OK; | 3491 return S_OK; |
| 3401 } | 3492 } |
| 3402 | 3493 |
| 3403 // | 3494 // |
| 3404 // IServiceProvider methods. | 3495 // IServiceProvider methods. |
| 3405 // | 3496 // |
| 3406 | 3497 |
| 3407 STDMETHODIMP BrowserAccessibilityWin::QueryService(REFGUID guid_service, | 3498 STDMETHODIMP BrowserAccessibilityComWin::QueryService(REFGUID guid_service, |
| 3408 REFIID riid, | 3499 REFIID riid, |
| 3409 void** object) { | 3500 void** object) { |
| 3410 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_QUERY_SERVICE); | 3501 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_QUERY_SERVICE); |
| 3411 if (!instance_active()) | 3502 if (!GetOwner() || !GetOwner()->instance_active()) |
| 3412 return E_FAIL; | 3503 return E_FAIL; |
| 3413 | 3504 |
| 3414 if (guid_service == GUID_IAccessibleContentDocument) { | 3505 if (guid_service == GUID_IAccessibleContentDocument) { |
| 3415 // Special Mozilla extension: return the accessible for the root document. | 3506 // Special Mozilla extension: return the accessible for the root document. |
| 3416 // Screen readers use this to distinguish between a document loaded event | 3507 // Screen readers use this to distinguish between a document loaded event |
| 3417 // on the root document vs on an iframe. | 3508 // on the root document vs on an iframe. |
| 3418 BrowserAccessibility* node = this; | 3509 BrowserAccessibility* node = GetOwner(); |
| 3419 while (node->PlatformGetParent()) | 3510 while (node->PlatformGetParent()) |
| 3420 node = node->PlatformGetParent()->manager()->GetRoot(); | 3511 node = node->PlatformGetParent()->manager()->GetRoot(); |
| 3421 return ToBrowserAccessibilityWin(node)->QueryInterface( | 3512 return ToBrowserAccessibilityComWin(node)->QueryInterface(IID_IAccessible2, |
| 3422 IID_IAccessible2, object); | 3513 object); |
| 3423 } | 3514 } |
| 3424 | 3515 |
| 3425 if (guid_service == IID_IAccessible || | 3516 if (guid_service == IID_IAccessible || guid_service == IID_IAccessible2 || |
| 3426 guid_service == IID_IAccessible2 || | |
| 3427 guid_service == IID_IAccessibleAction || | 3517 guid_service == IID_IAccessibleAction || |
| 3428 guid_service == IID_IAccessibleApplication || | 3518 guid_service == IID_IAccessibleApplication || |
| 3429 guid_service == IID_IAccessibleHyperlink || | 3519 guid_service == IID_IAccessibleHyperlink || |
| 3430 guid_service == IID_IAccessibleHypertext || | 3520 guid_service == IID_IAccessibleHypertext || |
| 3431 guid_service == IID_IAccessibleImage || | 3521 guid_service == IID_IAccessibleImage || |
| 3432 guid_service == IID_IAccessibleTable || | 3522 guid_service == IID_IAccessibleTable || |
| 3433 guid_service == IID_IAccessibleTable2 || | 3523 guid_service == IID_IAccessibleTable2 || |
| 3434 guid_service == IID_IAccessibleTableCell || | 3524 guid_service == IID_IAccessibleTableCell || |
| 3435 guid_service == IID_IAccessibleText || | 3525 guid_service == IID_IAccessibleText || |
| 3436 guid_service == IID_IAccessibleValue || | 3526 guid_service == IID_IAccessibleValue || |
| 3437 guid_service == IID_ISimpleDOMDocument || | 3527 guid_service == IID_ISimpleDOMDocument || |
| 3438 guid_service == IID_ISimpleDOMNode || | 3528 guid_service == IID_ISimpleDOMNode || |
| 3439 guid_service == IID_ISimpleDOMText || | 3529 guid_service == IID_ISimpleDOMText || guid_service == GUID_ISimpleDOM) { |
| 3440 guid_service == GUID_ISimpleDOM) { | |
| 3441 return QueryInterface(riid, object); | 3530 return QueryInterface(riid, object); |
| 3442 } | 3531 } |
| 3443 | 3532 |
| 3444 // We only support the IAccessibleEx interface on Windows 8 and above. This | 3533 // We only support the IAccessibleEx interface on Windows 8 and above. This |
| 3445 // is needed for the on-screen Keyboard to show up in metro mode, when the | 3534 // is needed for the on-screen Keyboard to show up in metro mode, when the |
| 3446 // user taps an editable portion on the page. | 3535 // user taps an editable portion on the page. |
| 3447 // All methods in the IAccessibleEx interface are unimplemented. | 3536 // All methods in the IAccessibleEx interface are unimplemented. |
| 3448 if (riid == IID_IAccessibleEx && | 3537 if (riid == IID_IAccessibleEx && |
| 3449 base::win::GetVersion() >= base::win::VERSION_WIN8) { | 3538 base::win::GetVersion() >= base::win::VERSION_WIN8) { |
| 3450 return QueryInterface(riid, object); | 3539 return QueryInterface(riid, object); |
| 3451 } | 3540 } |
| 3452 | 3541 |
| 3453 *object = NULL; | 3542 *object = NULL; |
| 3454 return E_FAIL; | 3543 return E_FAIL; |
| 3455 } | 3544 } |
| 3456 | 3545 |
| 3457 STDMETHODIMP | 3546 STDMETHODIMP |
| 3458 BrowserAccessibilityWin::GetObjectForChild(long child_id, IAccessibleEx** ret) { | 3547 BrowserAccessibilityComWin::GetObjectForChild(long child_id, |
| 3548 IAccessibleEx** ret) { | |
| 3459 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_OBJECT_FOR_CHILD); | 3549 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_OBJECT_FOR_CHILD); |
| 3460 return E_NOTIMPL; | 3550 return E_NOTIMPL; |
| 3461 } | 3551 } |
| 3462 | 3552 |
| 3463 STDMETHODIMP | 3553 STDMETHODIMP |
| 3464 BrowserAccessibilityWin::GetIAccessiblePair(IAccessible** acc, long* child_id) { | 3554 BrowserAccessibilityComWin::GetIAccessiblePair(IAccessible** acc, |
| 3555 long* child_id) { | |
| 3465 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_IACCESSIBLE_PAIR); | 3556 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_IACCESSIBLE_PAIR); |
| 3466 return E_NOTIMPL; | 3557 return E_NOTIMPL; |
| 3467 } | 3558 } |
| 3468 | 3559 |
| 3469 STDMETHODIMP BrowserAccessibilityWin::GetRuntimeId(SAFEARRAY** runtime_id) { | 3560 STDMETHODIMP BrowserAccessibilityComWin::GetRuntimeId(SAFEARRAY** runtime_id) { |
| 3470 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_RUNTIME_ID); | 3561 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_RUNTIME_ID); |
| 3471 return E_NOTIMPL; | 3562 return E_NOTIMPL; |
| 3472 } | 3563 } |
| 3473 | 3564 |
| 3474 STDMETHODIMP | 3565 STDMETHODIMP |
| 3475 BrowserAccessibilityWin::ConvertReturnedElement( | 3566 BrowserAccessibilityComWin::ConvertReturnedElement( |
| 3476 IRawElementProviderSimple* element, | 3567 IRawElementProviderSimple* element, |
| 3477 IAccessibleEx** acc) { | 3568 IAccessibleEx** acc) { |
| 3478 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_CONVERT_RETURNED_ELEMENT); | 3569 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_CONVERT_RETURNED_ELEMENT); |
| 3479 return E_NOTIMPL; | 3570 return E_NOTIMPL; |
| 3480 } | 3571 } |
| 3481 | 3572 |
| 3482 STDMETHODIMP BrowserAccessibilityWin::GetPatternProvider(PATTERNID id, | 3573 STDMETHODIMP BrowserAccessibilityComWin::GetPatternProvider( |
| 3483 IUnknown** provider) { | 3574 PATTERNID id, |
| 3575 IUnknown** provider) { | |
| 3484 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_PATTERN_PROVIDER); | 3576 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_PATTERN_PROVIDER); |
| 3485 DVLOG(1) << "In Function: " << __func__ << " for pattern id: " << id; | 3577 DVLOG(1) << "In Function: " << __func__ << " for pattern id: " << id; |
| 3578 if (!GetOwner() || !GetOwner()->instance_active()) | |
| 3579 return E_FAIL; | |
| 3580 | |
| 3486 if (id == UIA_ValuePatternId || id == UIA_TextPatternId) { | 3581 if (id == UIA_ValuePatternId || id == UIA_TextPatternId) { |
| 3487 if (HasState(ui::AX_STATE_EDITABLE)) { | 3582 if (GetOwner()->HasState(ui::AX_STATE_EDITABLE)) { |
| 3488 DVLOG(1) << "Returning UIA text provider"; | 3583 DVLOG(1) << "Returning UIA text provider"; |
| 3489 base::win::UIATextProvider::CreateTextProvider( | 3584 base::win::UIATextProvider::CreateTextProvider(GetValueText(), true, |
| 3490 GetValueText(), true, provider); | 3585 provider); |
| 3491 return S_OK; | 3586 return S_OK; |
| 3492 } | 3587 } |
| 3493 } | 3588 } |
| 3494 return E_NOTIMPL; | 3589 return E_NOTIMPL; |
| 3495 } | 3590 } |
| 3496 | 3591 |
| 3497 STDMETHODIMP BrowserAccessibilityWin::GetPropertyValue(PROPERTYID id, | 3592 STDMETHODIMP BrowserAccessibilityComWin::GetPropertyValue(PROPERTYID id, |
| 3498 VARIANT* ret) { | 3593 VARIANT* ret) { |
| 3499 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_PROPERTY_VALUE); | 3594 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_PROPERTY_VALUE); |
| 3500 DVLOG(1) << "In Function: " << __func__ << " for property id: " << id; | 3595 DVLOG(1) << "In Function: " << __func__ << " for property id: " << id; |
| 3596 if (!GetOwner() || !GetOwner()->instance_active()) | |
| 3597 return E_FAIL; | |
| 3598 | |
| 3501 V_VT(ret) = VT_EMPTY; | 3599 V_VT(ret) = VT_EMPTY; |
| 3502 if (id == UIA_ControlTypePropertyId) { | 3600 if (id == UIA_ControlTypePropertyId) { |
| 3503 if (HasState(ui::AX_STATE_EDITABLE)) { | 3601 if (GetOwner()->HasState(ui::AX_STATE_EDITABLE)) { |
| 3504 V_VT(ret) = VT_I4; | 3602 V_VT(ret) = VT_I4; |
| 3505 ret->lVal = UIA_EditControlTypeId; | 3603 ret->lVal = UIA_EditControlTypeId; |
| 3506 DVLOG(1) << "Returning Edit control type"; | 3604 DVLOG(1) << "Returning Edit control type"; |
| 3507 } else { | 3605 } else { |
| 3508 DVLOG(1) << "Returning empty control type"; | 3606 DVLOG(1) << "Returning empty control type"; |
| 3509 } | 3607 } |
| 3510 } | 3608 } |
| 3511 return S_OK; | 3609 return S_OK; |
| 3512 } | 3610 } |
| 3513 | 3611 |
| 3514 STDMETHODIMP BrowserAccessibilityWin::get_ProviderOptions( | 3612 STDMETHODIMP BrowserAccessibilityComWin::get_ProviderOptions( |
| 3515 ProviderOptions* ret) { | 3613 ProviderOptions* ret) { |
| 3516 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_PROVIDER_OPTIONS); | 3614 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_PROVIDER_OPTIONS); |
| 3517 return E_NOTIMPL; | 3615 return E_NOTIMPL; |
| 3518 } | 3616 } |
| 3519 | 3617 |
| 3520 STDMETHODIMP BrowserAccessibilityWin::get_HostRawElementProvider( | 3618 STDMETHODIMP BrowserAccessibilityComWin::get_HostRawElementProvider( |
| 3521 IRawElementProviderSimple** provider) { | 3619 IRawElementProviderSimple** provider) { |
| 3522 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_HOST_RAW_ELEMENT_PROVIDER); | 3620 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_HOST_RAW_ELEMENT_PROVIDER); |
| 3523 return E_NOTIMPL; | 3621 return E_NOTIMPL; |
| 3524 } | 3622 } |
| 3525 | 3623 |
| 3526 // | 3624 // |
| 3527 // CComObjectRootEx methods. | 3625 // CComObjectRootEx methods. |
| 3528 // | 3626 // |
| 3529 | 3627 |
| 3530 // static | 3628 // static |
| 3531 HRESULT WINAPI BrowserAccessibilityWin::InternalQueryInterface( | 3629 HRESULT WINAPI BrowserAccessibilityComWin::InternalQueryInterface( |
| 3532 void* this_ptr, | 3630 void* this_ptr, |
| 3533 const _ATL_INTMAP_ENTRY* entries, | 3631 const _ATL_INTMAP_ENTRY* entries, |
| 3534 REFIID iid, | 3632 REFIID iid, |
| 3535 void** object) { | 3633 void** object) { |
| 3536 BrowserAccessibilityWin* accessibility = | 3634 BrowserAccessibilityComWin* accessibility = |
| 3537 reinterpret_cast<BrowserAccessibilityWin*>(this_ptr); | 3635 reinterpret_cast<BrowserAccessibilityComWin*>(this_ptr); |
| 3538 int32_t ia_role = accessibility->ia_role(); | 3636 int32_t ia_role = accessibility->ia_role(); |
| 3539 if (iid == IID_IAccessibleImage) { | 3637 if (iid == IID_IAccessibleImage) { |
| 3540 if (ia_role != ROLE_SYSTEM_GRAPHIC) { | 3638 if (ia_role != ROLE_SYSTEM_GRAPHIC) { |
| 3541 *object = NULL; | 3639 *object = NULL; |
| 3542 return E_NOINTERFACE; | 3640 return E_NOINTERFACE; |
| 3543 } | 3641 } |
| 3544 } else if (iid == IID_IAccessibleTable || iid == IID_IAccessibleTable2) { | 3642 } else if (iid == IID_IAccessibleTable || iid == IID_IAccessibleTable2) { |
| 3545 if (ia_role != ROLE_SYSTEM_TABLE) { | 3643 if (ia_role != ROLE_SYSTEM_TABLE) { |
| 3546 *object = NULL; | 3644 *object = NULL; |
| 3547 return E_NOINTERFACE; | 3645 return E_NOINTERFACE; |
| 3548 } | 3646 } |
| 3549 } else if (iid == IID_IAccessibleTableCell) { | 3647 } else if (iid == IID_IAccessibleTableCell) { |
| 3550 if (!accessibility->IsCellOrTableHeaderRole()) { | 3648 if (!accessibility->GetOwner()->IsCellOrTableHeaderRole()) { |
| 3551 *object = NULL; | 3649 *object = NULL; |
| 3552 return E_NOINTERFACE; | 3650 return E_NOINTERFACE; |
| 3553 } | 3651 } |
| 3554 } else if (iid == IID_IAccessibleValue) { | 3652 } else if (iid == IID_IAccessibleValue) { |
| 3555 if (ia_role != ROLE_SYSTEM_PROGRESSBAR && | 3653 if (ia_role != ROLE_SYSTEM_PROGRESSBAR && |
| 3556 ia_role != ROLE_SYSTEM_SCROLLBAR && | 3654 ia_role != ROLE_SYSTEM_SCROLLBAR && ia_role != ROLE_SYSTEM_SLIDER) { |
| 3557 ia_role != ROLE_SYSTEM_SLIDER) { | |
| 3558 *object = NULL; | 3655 *object = NULL; |
| 3559 return E_NOINTERFACE; | 3656 return E_NOINTERFACE; |
| 3560 } | 3657 } |
| 3561 } else if (iid == IID_ISimpleDOMDocument) { | 3658 } else if (iid == IID_ISimpleDOMDocument) { |
| 3562 if (ia_role != ROLE_SYSTEM_DOCUMENT) { | 3659 if (ia_role != ROLE_SYSTEM_DOCUMENT) { |
| 3563 *object = NULL; | 3660 *object = NULL; |
| 3564 return E_NOINTERFACE; | 3661 return E_NOINTERFACE; |
| 3565 } | 3662 } |
| 3566 } else if (iid == IID_IAccessibleHyperlink) { | 3663 } else if (iid == IID_IAccessibleHyperlink) { |
| 3567 auto* ax_object = | 3664 auto* ax_object = |
| 3568 reinterpret_cast<const BrowserAccessibilityWin*>(this_ptr); | 3665 reinterpret_cast<const BrowserAccessibilityComWin*>(this_ptr); |
| 3569 if (!ax_object || !ax_object->IsHyperlink()) { | 3666 if (!ax_object || !ax_object->IsHyperlink()) { |
| 3570 *object = nullptr; | 3667 *object = nullptr; |
| 3571 return E_NOINTERFACE; | 3668 return E_NOINTERFACE; |
| 3572 } | 3669 } |
| 3573 } | 3670 } |
| 3574 | 3671 |
| 3575 return CComObjectRootBase::InternalQueryInterface( | 3672 return CComObjectRootBase::InternalQueryInterface(this_ptr, entries, iid, |
| 3576 this_ptr, entries, iid, object); | 3673 object); |
| 3577 } | 3674 } |
| 3578 | 3675 |
| 3579 void BrowserAccessibilityWin::ComputeStylesIfNeeded() { | 3676 void BrowserAccessibilityComWin::ComputeStylesIfNeeded() { |
| 3580 if (!offset_to_text_attributes().empty()) | 3677 if (!offset_to_text_attributes().empty()) |
| 3581 return; | 3678 return; |
| 3582 | 3679 |
| 3583 std::map<int, std::vector<base::string16>> attributes_map; | 3680 std::map<int, std::vector<base::string16>> attributes_map; |
| 3584 if (PlatformIsLeaf() || IsSimpleTextControl()) { | 3681 if (GetOwner()->PlatformIsLeaf() || GetOwner()->IsSimpleTextControl()) { |
| 3585 attributes_map[0] = ComputeTextAttributes(); | 3682 attributes_map[0] = ComputeTextAttributes(); |
| 3586 std::map<int, std::vector<base::string16>> spelling_attributes = | 3683 std::map<int, std::vector<base::string16>> spelling_attributes = |
| 3587 GetSpellingAttributes(); | 3684 GetSpellingAttributes(); |
| 3588 for (auto& spelling_attribute : spelling_attributes) { | 3685 for (auto& spelling_attribute : spelling_attributes) { |
| 3589 auto attributes_iterator = attributes_map.find(spelling_attribute.first); | 3686 auto attributes_iterator = attributes_map.find(spelling_attribute.first); |
| 3590 if (attributes_iterator == attributes_map.end()) { | 3687 if (attributes_iterator == attributes_map.end()) { |
| 3591 attributes_map[spelling_attribute.first] = | 3688 attributes_map[spelling_attribute.first] = |
| 3592 std::move(spelling_attribute.second); | 3689 std::move(spelling_attribute.second); |
| 3593 } else { | 3690 } else { |
| 3594 std::vector<base::string16>& existing_attributes = | 3691 std::vector<base::string16>& existing_attributes = |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 3605 existing_attributes.insert(existing_attributes.end(), | 3702 existing_attributes.insert(existing_attributes.end(), |
| 3606 spelling_attribute.second.begin(), | 3703 spelling_attribute.second.begin(), |
| 3607 spelling_attribute.second.end()); | 3704 spelling_attribute.second.end()); |
| 3608 } | 3705 } |
| 3609 } | 3706 } |
| 3610 win_attributes_->offset_to_text_attributes.swap(attributes_map); | 3707 win_attributes_->offset_to_text_attributes.swap(attributes_map); |
| 3611 return; | 3708 return; |
| 3612 } | 3709 } |
| 3613 | 3710 |
| 3614 int start_offset = 0; | 3711 int start_offset = 0; |
| 3615 for (size_t i = 0; i < PlatformChildCount(); ++i) { | 3712 for (size_t i = 0; i < GetOwner()->PlatformChildCount(); ++i) { |
| 3616 auto* child = ToBrowserAccessibilityWin(PlatformGetChild(i)); | 3713 auto* child = ToBrowserAccessibilityComWin(GetOwner()->PlatformGetChild(i)); |
| 3617 DCHECK(child); | 3714 DCHECK(child); |
| 3618 std::vector<base::string16> attributes(child->ComputeTextAttributes()); | 3715 std::vector<base::string16> attributes(child->ComputeTextAttributes()); |
| 3619 | 3716 |
| 3620 if (attributes_map.empty()) { | 3717 if (attributes_map.empty()) { |
| 3621 attributes_map[start_offset] = attributes; | 3718 attributes_map[start_offset] = attributes; |
| 3622 } else { | 3719 } else { |
| 3623 // Only add the attributes for this child if we are at the start of a new | 3720 // Only add the attributes for this child if we are at the start of a new |
| 3624 // style span. | 3721 // style span. |
| 3625 std::vector<base::string16> previous_attributes = | 3722 std::vector<base::string16> previous_attributes = |
| 3626 attributes_map.rbegin()->second; | 3723 attributes_map.rbegin()->second; |
| 3627 if (!std::equal(attributes.begin(), attributes.end(), | 3724 if (!std::equal(attributes.begin(), attributes.end(), |
| 3628 previous_attributes.begin())) { | 3725 previous_attributes.begin())) { |
| 3629 attributes_map[start_offset] = attributes; | 3726 attributes_map[start_offset] = attributes; |
| 3630 } | 3727 } |
| 3631 } | 3728 } |
| 3632 | 3729 |
| 3633 if (child->IsTextOnlyObject()) | 3730 if (child->GetOwner()->IsTextOnlyObject()) |
| 3634 start_offset += child->GetText().length(); | 3731 start_offset += child->GetOwner()->GetText().length(); |
| 3635 else | 3732 else |
| 3636 start_offset += 1; | 3733 start_offset += 1; |
| 3637 } | 3734 } |
| 3638 | 3735 |
| 3639 win_attributes_->offset_to_text_attributes.swap(attributes_map); | 3736 win_attributes_->offset_to_text_attributes.swap(attributes_map); |
| 3640 } | 3737 } |
| 3641 | 3738 |
| 3642 // |offset| could either be a text character or a child index in case of | 3739 // |offset| could either be a text character or a child index in case of |
| 3643 // non-text objects. | 3740 // non-text objects. |
| 3644 // TODO(nektar): Remove this function once selection bugs are fixed in Blink. | 3741 // TODO(nektar): Remove this function once selection bugs are fixed in Blink. |
| 3645 BrowserAccessibilityWin::AXPlatformPositionInstance | 3742 AXPlatformPosition::AXPositionInstance |
| 3646 BrowserAccessibilityWin::CreatePositionForSelectionAt(int offset) const { | 3743 BrowserAccessibilityComWin::CreatePositionForSelectionAt(int offset) const { |
| 3647 if (!IsNativeTextControl() && !IsTextOnlyObject()) { | 3744 if (!GetOwner()->IsNativeTextControl() && !GetOwner()->IsTextOnlyObject()) { |
| 3648 DCHECK(manager_); | 3745 auto* manager = GetOwner()->manager(); |
| 3649 const BrowserAccessibilityWin* child = this; | 3746 DCHECK(manager); |
| 3747 const BrowserAccessibilityComWin* child = this; | |
| 3650 // TODO(nektar): Make parents of text-only objects not include the text of | 3748 // TODO(nektar): Make parents of text-only objects not include the text of |
| 3651 // children in their hypertext. | 3749 // children in their hypertext. |
| 3652 for (size_t i = 0; i < InternalChildCount(); ++i) { | 3750 for (size_t i = 0; i < GetOwner()->InternalChildCount(); ++i) { |
| 3653 int new_offset = offset; | 3751 int new_offset = offset; |
| 3654 child = ToBrowserAccessibilityWin(InternalGetChild(i)); | 3752 child = ToBrowserAccessibilityComWin(GetOwner()->InternalGetChild(i)); |
| 3655 DCHECK(child); | 3753 DCHECK(child); |
| 3656 if (child->IsTextOnlyObject()) { | 3754 if (child->GetOwner()->IsTextOnlyObject()) { |
| 3657 new_offset -= child->GetText().length(); | 3755 new_offset -= child->GetOwner()->GetText().length(); |
| 3658 } else { | 3756 } else { |
| 3659 new_offset -= 1; | 3757 new_offset -= 1; |
| 3660 } | 3758 } |
| 3661 if (new_offset <= 0) | 3759 if (new_offset <= 0) |
| 3662 break; | 3760 break; |
| 3663 offset = new_offset; | 3761 offset = new_offset; |
| 3664 } | 3762 } |
| 3665 AXPlatformPositionInstance position = | 3763 AXPlatformPositionInstance position = |
| 3666 AXPlatformPosition::CreateTextPosition(manager_->ax_tree_id(), | 3764 AXPlatformPosition::CreateTextPosition( |
| 3667 child->GetId(), offset, | 3765 manager->ax_tree_id(), child->GetOwner()->GetId(), offset, |
| 3668 ui::AX_TEXT_AFFINITY_DOWNSTREAM) | 3766 ui::AX_TEXT_AFFINITY_DOWNSTREAM) |
| 3669 ->AsLeafTextPosition(); | 3767 ->AsLeafTextPosition(); |
| 3670 if (position->GetAnchor() && | 3768 if (position->GetAnchor() && |
| 3671 position->GetAnchor()->GetRole() == ui::AX_ROLE_INLINE_TEXT_BOX) { | 3769 position->GetAnchor()->GetRole() == ui::AX_ROLE_INLINE_TEXT_BOX) { |
| 3672 return position->CreateParentPosition(); | 3770 return position->CreateParentPosition(); |
| 3673 } | 3771 } |
| 3674 return position; | 3772 return position; |
| 3675 } | 3773 } |
| 3676 return CreatePositionAt(offset); | 3774 return GetOwner()->CreatePositionAt(offset); |
| 3677 } | |
| 3678 | |
| 3679 base::string16 BrowserAccessibilityWin::GetText() const { | |
| 3680 if (PlatformIsChildOfLeaf()) | |
| 3681 return BrowserAccessibility::GetText(); | |
| 3682 return win_attributes_->hypertext; | |
| 3683 } | 3775 } |
| 3684 | 3776 |
| 3685 // | 3777 // |
| 3686 // Private methods. | 3778 // Private methods. |
| 3687 // | 3779 // |
| 3688 | 3780 |
| 3689 void BrowserAccessibilityWin::UpdateStep1ComputeWinAttributes() { | 3781 void BrowserAccessibilityComWin::UpdateStep1ComputeWinAttributes() { |
| 3690 // Swap win_attributes_ to old_win_attributes_, allowing us to see | 3782 // Swap win_attributes_ to old_win_attributes_, allowing us to see |
| 3691 // exactly what changed and fire appropriate events. Note that | 3783 // exactly what changed and fire appropriate events. Note that |
| 3692 // old_win_attributes_ is cleared at the end of UpdateStep3FireEvents. | 3784 // old_win_attributes_ is cleared at the end of UpdateStep3FireEvents. |
| 3693 old_win_attributes_.swap(win_attributes_); | 3785 old_win_attributes_.swap(win_attributes_); |
| 3694 win_attributes_.reset(new WinAttributes()); | 3786 win_attributes_.reset(new WinAttributes()); |
| 3695 | 3787 |
| 3696 InitRoleAndState(); | 3788 InitRoleAndState(); |
| 3697 | 3789 |
| 3698 win_attributes_->ia2_attributes.clear(); | 3790 win_attributes_->ia2_attributes.clear(); |
| 3699 | 3791 |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 3722 win_attributes_->ia2_attributes.push_back(L"checkable:true"); | 3814 win_attributes_->ia2_attributes.push_back(L"checkable:true"); |
| 3723 } | 3815 } |
| 3724 | 3816 |
| 3725 // Expose live region attributes. | 3817 // Expose live region attributes. |
| 3726 StringAttributeToIA2(ui::AX_ATTR_LIVE_STATUS, "live"); | 3818 StringAttributeToIA2(ui::AX_ATTR_LIVE_STATUS, "live"); |
| 3727 StringAttributeToIA2(ui::AX_ATTR_LIVE_RELEVANT, "relevant"); | 3819 StringAttributeToIA2(ui::AX_ATTR_LIVE_RELEVANT, "relevant"); |
| 3728 BoolAttributeToIA2(ui::AX_ATTR_LIVE_ATOMIC, "atomic"); | 3820 BoolAttributeToIA2(ui::AX_ATTR_LIVE_ATOMIC, "atomic"); |
| 3729 BoolAttributeToIA2(ui::AX_ATTR_LIVE_BUSY, "busy"); | 3821 BoolAttributeToIA2(ui::AX_ATTR_LIVE_BUSY, "busy"); |
| 3730 | 3822 |
| 3731 // Expose container live region attributes. | 3823 // Expose container live region attributes. |
| 3732 StringAttributeToIA2(ui::AX_ATTR_CONTAINER_LIVE_STATUS, | 3824 StringAttributeToIA2(ui::AX_ATTR_CONTAINER_LIVE_STATUS, "container-live"); |
| 3733 "container-live"); | |
| 3734 StringAttributeToIA2(ui::AX_ATTR_CONTAINER_LIVE_RELEVANT, | 3825 StringAttributeToIA2(ui::AX_ATTR_CONTAINER_LIVE_RELEVANT, |
| 3735 "container-relevant"); | 3826 "container-relevant"); |
| 3736 BoolAttributeToIA2(ui::AX_ATTR_CONTAINER_LIVE_ATOMIC, | 3827 BoolAttributeToIA2(ui::AX_ATTR_CONTAINER_LIVE_ATOMIC, "container-atomic"); |
| 3737 "container-atomic"); | 3828 BoolAttributeToIA2(ui::AX_ATTR_CONTAINER_LIVE_BUSY, "container-busy"); |
| 3738 BoolAttributeToIA2(ui::AX_ATTR_CONTAINER_LIVE_BUSY, | |
| 3739 "container-busy"); | |
| 3740 | 3829 |
| 3741 // Expose the non-standard explicit-name IA2 attribute. | 3830 // Expose the non-standard explicit-name IA2 attribute. |
| 3742 int name_from; | 3831 int name_from; |
| 3743 if (GetIntAttribute(ui::AX_ATTR_NAME_FROM, &name_from) && | 3832 if (GetOwner()->GetIntAttribute(ui::AX_ATTR_NAME_FROM, &name_from) && |
| 3744 name_from != ui::AX_NAME_FROM_CONTENTS) { | 3833 name_from != ui::AX_NAME_FROM_CONTENTS) { |
| 3745 win_attributes_->ia2_attributes.push_back(L"explicit-name:true"); | 3834 win_attributes_->ia2_attributes.push_back(L"explicit-name:true"); |
| 3746 } | 3835 } |
| 3747 | 3836 |
| 3748 // Expose the aria-current attribute. | 3837 // Expose the aria-current attribute. |
| 3749 int32_t aria_current_state; | 3838 int32_t aria_current_state; |
| 3750 if (GetIntAttribute(ui::AX_ATTR_ARIA_CURRENT_STATE, &aria_current_state)) { | 3839 if (GetOwner()->GetIntAttribute(ui::AX_ATTR_ARIA_CURRENT_STATE, |
| 3840 &aria_current_state)) { | |
| 3751 switch (static_cast<ui::AXAriaCurrentState>(aria_current_state)) { | 3841 switch (static_cast<ui::AXAriaCurrentState>(aria_current_state)) { |
| 3752 case ui::AX_ARIA_CURRENT_STATE_NONE: | 3842 case ui::AX_ARIA_CURRENT_STATE_NONE: |
| 3753 break; | 3843 break; |
| 3754 case ui::AX_ARIA_CURRENT_STATE_FALSE: | 3844 case ui::AX_ARIA_CURRENT_STATE_FALSE: |
| 3755 win_attributes_->ia2_attributes.push_back(L"current:false"); | 3845 win_attributes_->ia2_attributes.push_back(L"current:false"); |
| 3756 break; | 3846 break; |
| 3757 case ui::AX_ARIA_CURRENT_STATE_TRUE: | 3847 case ui::AX_ARIA_CURRENT_STATE_TRUE: |
| 3758 win_attributes_->ia2_attributes.push_back(L"current:true"); | 3848 win_attributes_->ia2_attributes.push_back(L"current:true"); |
| 3759 break; | 3849 break; |
| 3760 case ui::AX_ARIA_CURRENT_STATE_PAGE: | 3850 case ui::AX_ARIA_CURRENT_STATE_PAGE: |
| 3761 win_attributes_->ia2_attributes.push_back(L"current:page"); | 3851 win_attributes_->ia2_attributes.push_back(L"current:page"); |
| 3762 break; | 3852 break; |
| 3763 case ui::AX_ARIA_CURRENT_STATE_STEP: | 3853 case ui::AX_ARIA_CURRENT_STATE_STEP: |
| 3764 win_attributes_->ia2_attributes.push_back(L"current:step"); | 3854 win_attributes_->ia2_attributes.push_back(L"current:step"); |
| 3765 break; | 3855 break; |
| 3766 case ui::AX_ARIA_CURRENT_STATE_LOCATION: | 3856 case ui::AX_ARIA_CURRENT_STATE_LOCATION: |
| 3767 win_attributes_->ia2_attributes.push_back(L"current:location"); | 3857 win_attributes_->ia2_attributes.push_back(L"current:location"); |
| 3768 break; | 3858 break; |
| 3769 case ui::AX_ARIA_CURRENT_STATE_DATE: | 3859 case ui::AX_ARIA_CURRENT_STATE_DATE: |
| 3770 win_attributes_->ia2_attributes.push_back(L"current:date"); | 3860 win_attributes_->ia2_attributes.push_back(L"current:date"); |
| 3771 break; | 3861 break; |
| 3772 case ui::AX_ARIA_CURRENT_STATE_TIME: | 3862 case ui::AX_ARIA_CURRENT_STATE_TIME: |
| 3773 win_attributes_->ia2_attributes.push_back(L"current:time"); | 3863 win_attributes_->ia2_attributes.push_back(L"current:time"); |
| 3774 break; | 3864 break; |
| 3775 } | 3865 } |
| 3776 } | 3866 } |
| 3777 | 3867 |
| 3778 // Expose table cell index. | 3868 // Expose table cell index. |
| 3779 if (IsCellOrTableHeaderRole()) { | 3869 if (GetOwner()->IsCellOrTableHeaderRole()) { |
| 3780 BrowserAccessibility* table = PlatformGetParent(); | 3870 BrowserAccessibility* table = GetOwner()->PlatformGetParent(); |
| 3781 while (table && !table->IsTableLikeRole()) | 3871 while (table && !table->IsTableLikeRole()) |
| 3782 table = table->PlatformGetParent(); | 3872 table = table->PlatformGetParent(); |
| 3783 if (table) { | 3873 if (table) { |
| 3784 const std::vector<int32_t>& unique_cell_ids = | 3874 const std::vector<int32_t>& unique_cell_ids = |
| 3785 table->GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS); | 3875 table->GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS); |
| 3786 for (size_t i = 0; i < unique_cell_ids.size(); ++i) { | 3876 for (size_t i = 0; i < unique_cell_ids.size(); ++i) { |
| 3787 if (unique_cell_ids[i] == GetId()) { | 3877 if (unique_cell_ids[i] == GetOwner()->GetId()) { |
| 3788 win_attributes_->ia2_attributes.push_back( | 3878 win_attributes_->ia2_attributes.push_back( |
| 3789 base::string16(L"table-cell-index:") + base::IntToString16(i)); | 3879 base::string16(L"table-cell-index:") + base::IntToString16(i)); |
| 3790 } | 3880 } |
| 3791 } | 3881 } |
| 3792 } | 3882 } |
| 3793 } | 3883 } |
| 3794 | 3884 |
| 3795 // Expose aria-colcount and aria-rowcount in a table, grid or treegrid. | 3885 // Expose aria-colcount and aria-rowcount in a table, grid or treegrid. |
| 3796 if (IsTableLikeRole()) { | 3886 if (GetOwner()->IsTableLikeRole()) { |
| 3797 IntAttributeToIA2(ui::AX_ATTR_ARIA_COLUMN_COUNT, "colcount"); | 3887 IntAttributeToIA2(ui::AX_ATTR_ARIA_COLUMN_COUNT, "colcount"); |
| 3798 IntAttributeToIA2(ui::AX_ATTR_ARIA_ROW_COUNT, "rowcount"); | 3888 IntAttributeToIA2(ui::AX_ATTR_ARIA_ROW_COUNT, "rowcount"); |
| 3799 } | 3889 } |
| 3800 | 3890 |
| 3801 // Expose aria-colindex and aria-rowindex in a cell or row. | 3891 // Expose aria-colindex and aria-rowindex in a cell or row. |
| 3802 if (IsCellOrTableHeaderRole() || GetRole() == ui::AX_ROLE_ROW) { | 3892 if (GetOwner()->IsCellOrTableHeaderRole() || |
| 3803 if (GetRole() != ui::AX_ROLE_ROW) | 3893 GetOwner()->GetRole() == ui::AX_ROLE_ROW) { |
| 3894 if (GetOwner()->GetRole() != ui::AX_ROLE_ROW) | |
| 3804 IntAttributeToIA2(ui::AX_ATTR_ARIA_CELL_COLUMN_INDEX, "colindex"); | 3895 IntAttributeToIA2(ui::AX_ATTR_ARIA_CELL_COLUMN_INDEX, "colindex"); |
| 3805 IntAttributeToIA2(ui::AX_ATTR_ARIA_CELL_ROW_INDEX, "rowindex"); | 3896 IntAttributeToIA2(ui::AX_ATTR_ARIA_CELL_ROW_INDEX, "rowindex"); |
| 3806 } | 3897 } |
| 3807 | 3898 |
| 3808 // Expose row or column header sort direction. | 3899 // Expose row or column header sort direction. |
| 3809 int32_t sort_direction; | 3900 int32_t sort_direction; |
| 3810 if ((ia_role() == ROLE_SYSTEM_COLUMNHEADER || | 3901 if ((ia_role() == ROLE_SYSTEM_COLUMNHEADER || |
| 3811 ia_role() == ROLE_SYSTEM_ROWHEADER) && | 3902 ia_role() == ROLE_SYSTEM_ROWHEADER) && |
| 3812 GetIntAttribute(ui::AX_ATTR_SORT_DIRECTION, &sort_direction)) { | 3903 GetOwner()->GetIntAttribute(ui::AX_ATTR_SORT_DIRECTION, |
| 3904 &sort_direction)) { | |
| 3813 switch (static_cast<ui::AXSortDirection>(sort_direction)) { | 3905 switch (static_cast<ui::AXSortDirection>(sort_direction)) { |
| 3814 case ui::AX_SORT_DIRECTION_NONE: | 3906 case ui::AX_SORT_DIRECTION_NONE: |
| 3815 break; | 3907 break; |
| 3816 case ui::AX_SORT_DIRECTION_UNSORTED: | 3908 case ui::AX_SORT_DIRECTION_UNSORTED: |
| 3817 win_attributes_->ia2_attributes.push_back(L"sort:none"); | 3909 win_attributes_->ia2_attributes.push_back(L"sort:none"); |
| 3818 break; | 3910 break; |
| 3819 case ui::AX_SORT_DIRECTION_ASCENDING: | 3911 case ui::AX_SORT_DIRECTION_ASCENDING: |
| 3820 win_attributes_->ia2_attributes.push_back(L"sort:ascending"); | 3912 win_attributes_->ia2_attributes.push_back(L"sort:ascending"); |
| 3821 break; | 3913 break; |
| 3822 case ui::AX_SORT_DIRECTION_DESCENDING: | 3914 case ui::AX_SORT_DIRECTION_DESCENDING: |
| 3823 win_attributes_->ia2_attributes.push_back(L"sort:descending"); | 3915 win_attributes_->ia2_attributes.push_back(L"sort:descending"); |
| 3824 break; | 3916 break; |
| 3825 case ui::AX_SORT_DIRECTION_OTHER: | 3917 case ui::AX_SORT_DIRECTION_OTHER: |
| 3826 win_attributes_->ia2_attributes.push_back(L"sort:other"); | 3918 win_attributes_->ia2_attributes.push_back(L"sort:other"); |
| 3827 break; | 3919 break; |
| 3828 } | 3920 } |
| 3829 } | 3921 } |
| 3830 | 3922 |
| 3831 win_attributes_->name = GetString16Attribute(ui::AX_ATTR_NAME); | 3923 win_attributes_->name = GetOwner()->GetString16Attribute(ui::AX_ATTR_NAME); |
| 3832 win_attributes_->description = GetString16Attribute(ui::AX_ATTR_DESCRIPTION); | 3924 win_attributes_->description = |
| 3925 GetOwner()->GetString16Attribute(ui::AX_ATTR_DESCRIPTION); | |
| 3833 StringAttributeToIA2(ui::AX_ATTR_PLACEHOLDER, "placeholder"); | 3926 StringAttributeToIA2(ui::AX_ATTR_PLACEHOLDER, "placeholder"); |
| 3834 | 3927 |
| 3835 base::string16 value = GetValue(); | 3928 base::string16 value = GetOwner()->GetValue(); |
| 3836 // On Windows, the value of a document should be its url. | 3929 // On Windows, the value of a document should be its url. |
| 3837 if (GetRole() == ui::AX_ROLE_ROOT_WEB_AREA || | 3930 if (GetOwner()->GetRole() == ui::AX_ROLE_ROOT_WEB_AREA || |
| 3838 GetRole() == ui::AX_ROLE_WEB_AREA) { | 3931 GetOwner()->GetRole() == ui::AX_ROLE_WEB_AREA) { |
| 3839 value = base::UTF8ToUTF16(manager_->GetTreeData().url); | 3932 value = base::UTF8ToUTF16(GetOwner()->manager()->GetTreeData().url); |
| 3840 } | 3933 } |
| 3841 // If this doesn't have a value and is linked then set its value to the url | 3934 // If this doesn't have a value and is linked then set its value to the url |
| 3842 // attribute. This allows screen readers to read an empty link's destination. | 3935 // attribute. This allows screen readers to read an empty link's destination. |
| 3843 if (value.empty() && (ia_state() & STATE_SYSTEM_LINKED)) | 3936 if (value.empty() && (ia_state() & STATE_SYSTEM_LINKED)) |
| 3844 value = GetString16Attribute(ui::AX_ATTR_URL); | 3937 value = GetOwner()->GetString16Attribute(ui::AX_ATTR_URL); |
| 3845 win_attributes_->value = value; | 3938 win_attributes_->value = value; |
| 3846 | 3939 |
| 3847 ClearOwnRelations(); | 3940 ClearOwnRelations(); |
| 3848 AddBidirectionalRelations(IA2_RELATION_CONTROLLER_FOR, | 3941 AddBidirectionalRelations(IA2_RELATION_CONTROLLER_FOR, |
| 3849 IA2_RELATION_CONTROLLED_BY, | 3942 IA2_RELATION_CONTROLLED_BY, |
| 3850 ui::AX_ATTR_CONTROLS_IDS); | 3943 ui::AX_ATTR_CONTROLS_IDS); |
| 3851 AddBidirectionalRelations(IA2_RELATION_DESCRIBED_BY, | 3944 AddBidirectionalRelations(IA2_RELATION_DESCRIBED_BY, |
| 3852 IA2_RELATION_DESCRIPTION_FOR, | 3945 IA2_RELATION_DESCRIPTION_FOR, |
| 3853 ui::AX_ATTR_DESCRIBEDBY_IDS); | 3946 ui::AX_ATTR_DESCRIBEDBY_IDS); |
| 3854 AddBidirectionalRelations(IA2_RELATION_FLOWS_TO, IA2_RELATION_FLOWS_FROM, | 3947 AddBidirectionalRelations(IA2_RELATION_FLOWS_TO, IA2_RELATION_FLOWS_FROM, |
| 3855 ui::AX_ATTR_FLOWTO_IDS); | 3948 ui::AX_ATTR_FLOWTO_IDS); |
| 3856 AddBidirectionalRelations(IA2_RELATION_LABELLED_BY, IA2_RELATION_LABEL_FOR, | 3949 AddBidirectionalRelations(IA2_RELATION_LABELLED_BY, IA2_RELATION_LABEL_FOR, |
| 3857 ui::AX_ATTR_LABELLEDBY_IDS); | 3950 ui::AX_ATTR_LABELLEDBY_IDS); |
| 3858 AddBidirectionalRelations(IA2_RELATION_DETAILS, IA2_RELATION_DETAILS_FOR, | 3951 AddBidirectionalRelations(IA2_RELATION_DETAILS, IA2_RELATION_DETAILS_FOR, |
| 3859 ui::AX_ATTR_DETAILS_IDS); | 3952 ui::AX_ATTR_DETAILS_IDS); |
| 3860 | 3953 |
| 3861 int member_of_id; | 3954 int member_of_id; |
| 3862 if (GetIntAttribute(ui::AX_ATTR_MEMBER_OF_ID, &member_of_id)) | 3955 if (GetOwner()->GetIntAttribute(ui::AX_ATTR_MEMBER_OF_ID, &member_of_id)) |
| 3863 AddRelation(IA2_RELATION_MEMBER_OF, member_of_id); | 3956 AddRelation(IA2_RELATION_MEMBER_OF, member_of_id); |
| 3864 | 3957 |
| 3865 int error_message_id; | 3958 int error_message_id; |
| 3866 if (GetIntAttribute(ui::AX_ATTR_ERRORMESSAGE_ID, &error_message_id)) | 3959 if (GetOwner()->GetIntAttribute(ui::AX_ATTR_ERRORMESSAGE_ID, |
| 3960 &error_message_id)) | |
| 3867 AddRelation(IA2_RELATION_ERROR_MESSAGE, error_message_id); | 3961 AddRelation(IA2_RELATION_ERROR_MESSAGE, error_message_id); |
| 3868 | 3962 |
| 3869 // Expose slider value. | 3963 // Expose slider value. |
| 3870 if (ia_role() == ROLE_SYSTEM_PROGRESSBAR || | 3964 if (ia_role() == ROLE_SYSTEM_PROGRESSBAR || |
| 3871 ia_role() == ROLE_SYSTEM_SCROLLBAR || | 3965 ia_role() == ROLE_SYSTEM_SCROLLBAR || ia_role() == ROLE_SYSTEM_SLIDER) { |
| 3872 ia_role() == ROLE_SYSTEM_SLIDER) { | |
| 3873 base::string16 value_text = GetValueText(); | 3966 base::string16 value_text = GetValueText(); |
| 3874 SanitizeStringAttributeForIA2(value_text, &value_text); | 3967 SanitizeStringAttributeForIA2(value_text, &value_text); |
| 3875 win_attributes_->ia2_attributes.push_back(L"valuetext:" + value_text); | 3968 win_attributes_->ia2_attributes.push_back(L"valuetext:" + value_text); |
| 3876 } | 3969 } |
| 3877 | 3970 |
| 3878 UpdateRequiredAttributes(); | 3971 UpdateRequiredAttributes(); |
| 3879 // If this is a web area for a presentational iframe, give it a role of | 3972 // If this is a web area for a presentational iframe, give it a role of |
| 3880 // something other than DOCUMENT so that the fact that it's a separate doc | 3973 // something other than DOCUMENT so that the fact that it's a separate doc |
| 3881 // is not exposed to AT. | 3974 // is not exposed to AT. |
| 3882 if (IsWebAreaForPresentationalIframe()) { | 3975 if (GetOwner()->IsWebAreaForPresentationalIframe()) { |
| 3883 win_attributes_->ia_role = ROLE_SYSTEM_GROUPING; | 3976 win_attributes_->ia_role = ROLE_SYSTEM_GROUPING; |
| 3884 win_attributes_->ia2_role = ROLE_SYSTEM_GROUPING; | 3977 win_attributes_->ia2_role = ROLE_SYSTEM_GROUPING; |
| 3885 } | 3978 } |
| 3886 } | 3979 } |
| 3887 | 3980 |
| 3888 void BrowserAccessibilityWin::UpdateStep2ComputeHypertext() { | 3981 void BrowserAccessibilityComWin::UpdateStep2ComputeHypertext() { |
| 3889 if (IsSimpleTextControl()) { | 3982 if (GetOwner()->IsSimpleTextControl()) { |
| 3890 win_attributes_->hypertext = value(); | 3983 win_attributes_->hypertext = value(); |
| 3891 return; | 3984 return; |
| 3892 } | 3985 } |
| 3893 | 3986 |
| 3894 if (!PlatformChildCount()) { | 3987 if (!GetOwner()->PlatformChildCount()) { |
| 3895 if (IsRichTextControl()) { | 3988 if (GetOwner()->IsRichTextControl()) { |
| 3896 // We don't want to expose any associated label in IA2 Hypertext. | 3989 // We don't want to expose any associated label in IA2 Hypertext. |
| 3897 return; | 3990 return; |
| 3898 } | 3991 } |
| 3899 win_attributes_->hypertext = name(); | 3992 win_attributes_->hypertext = name(); |
| 3900 return; | 3993 return; |
| 3901 } | 3994 } |
| 3902 | 3995 |
| 3903 // Construct the hypertext for this node, which contains the concatenation | 3996 // Construct the hypertext for this node, which contains the concatenation |
| 3904 // of all of the static text and widespace of this node's children and an | 3997 // of all of the static text and widespace of this node's children and an |
| 3905 // embedded object character for all the other children. Build up a map from | 3998 // embedded object character for all the other children. Build up a map from |
| 3906 // the character index of each embedded object character to the id of the | 3999 // the character index of each embedded object character to the id of the |
| 3907 // child object it points to. | 4000 // child object it points to. |
| 3908 for (unsigned int i = 0; i < PlatformChildCount(); ++i) { | 4001 for (unsigned int i = 0; i < GetOwner()->PlatformChildCount(); ++i) { |
| 3909 auto* child = ToBrowserAccessibilityWin(PlatformGetChild(i)); | 4002 auto* child = ToBrowserAccessibilityComWin(GetOwner()->PlatformGetChild(i)); |
| 3910 DCHECK(child); | 4003 DCHECK(child); |
| 3911 // Similar to Firefox, we don't expose text-only objects in IA2 hypertext. | 4004 // Similar to Firefox, we don't expose text-only objects in IA2 hypertext. |
| 3912 if (child->IsTextOnlyObject()) { | 4005 if (child->GetOwner()->IsTextOnlyObject()) { |
| 3913 win_attributes_->hypertext += child->name(); | 4006 win_attributes_->hypertext += child->name(); |
| 3914 } else { | 4007 } else { |
| 3915 int32_t char_offset = static_cast<int32_t>(GetText().size()); | 4008 int32_t char_offset = static_cast<int32_t>(GetOwner()->GetText().size()); |
| 3916 int32_t child_unique_id = child->unique_id(); | 4009 int32_t child_unique_id = child->GetOwner()->unique_id(); |
| 3917 int32_t index = hyperlinks().size(); | 4010 int32_t index = hyperlinks().size(); |
| 3918 win_attributes_->hyperlink_offset_to_index[char_offset] = index; | 4011 win_attributes_->hyperlink_offset_to_index[char_offset] = index; |
| 3919 win_attributes_->hyperlinks.push_back(child_unique_id); | 4012 win_attributes_->hyperlinks.push_back(child_unique_id); |
| 3920 win_attributes_->hypertext += kEmbeddedCharacter; | 4013 win_attributes_->hypertext += kEmbeddedCharacter; |
| 3921 } | 4014 } |
| 3922 } | 4015 } |
| 3923 } | 4016 } |
| 3924 | 4017 |
| 3925 void BrowserAccessibilityWin::UpdateStep3FireEvents(bool is_subtree_creation) { | 4018 void BrowserAccessibilityComWin::UpdateStep3FireEvents( |
| 4019 bool is_subtree_creation) { | |
| 3926 // Fire an event when a new subtree is created. | 4020 // Fire an event when a new subtree is created. |
| 3927 if (is_subtree_creation) | 4021 if (is_subtree_creation) |
| 3928 FireNativeEvent(EVENT_OBJECT_SHOW); | 4022 FireNativeEvent(EVENT_OBJECT_SHOW); |
| 3929 | 4023 |
| 3930 // The rest of the events only fire on changes, not on new objects. | 4024 // The rest of the events only fire on changes, not on new objects. |
| 3931 if (old_win_attributes_->ia_role != 0 || | 4025 if (old_win_attributes_->ia_role != 0 || |
| 3932 !old_win_attributes_->role_name.empty()) { | 4026 !old_win_attributes_->role_name.empty()) { |
| 3933 // Fire an event if the name, description, help, or value changes. | 4027 // Fire an event if the name, description, help, or value changes. |
| 3934 if (name() != old_win_attributes_->name) | 4028 if (name() != old_win_attributes_->name) |
| 3935 FireNativeEvent(EVENT_OBJECT_NAMECHANGE); | 4029 FireNativeEvent(EVENT_OBJECT_NAMECHANGE); |
| 3936 if (description() != old_win_attributes_->description) | 4030 if (description() != old_win_attributes_->description) |
| 3937 FireNativeEvent(EVENT_OBJECT_DESCRIPTIONCHANGE); | 4031 FireNativeEvent(EVENT_OBJECT_DESCRIPTIONCHANGE); |
| 3938 if (value() != old_win_attributes_->value) | 4032 if (value() != old_win_attributes_->value) |
| 3939 FireNativeEvent(EVENT_OBJECT_VALUECHANGE); | 4033 FireNativeEvent(EVENT_OBJECT_VALUECHANGE); |
| 3940 if (ia_state() != old_win_attributes_->ia_state) | 4034 if (ia_state() != old_win_attributes_->ia_state) |
| 3941 FireNativeEvent(EVENT_OBJECT_STATECHANGE); | 4035 FireNativeEvent(EVENT_OBJECT_STATECHANGE); |
| 3942 | 4036 |
| 3943 // Handle selection being added or removed. | 4037 // Handle selection being added or removed. |
| 3944 bool is_selected_now = (ia_state() & STATE_SYSTEM_SELECTED) != 0; | 4038 bool is_selected_now = (ia_state() & STATE_SYSTEM_SELECTED) != 0; |
| 3945 bool was_selected_before = | 4039 bool was_selected_before = |
| 3946 (old_win_attributes_->ia_state & STATE_SYSTEM_SELECTED) != 0; | 4040 (old_win_attributes_->ia_state & STATE_SYSTEM_SELECTED) != 0; |
| 3947 if (is_selected_now || was_selected_before) { | 4041 if (is_selected_now || was_selected_before) { |
| 3948 bool multiselect = false; | 4042 bool multiselect = false; |
| 3949 if (PlatformGetParent() && | 4043 if (GetOwner()->PlatformGetParent() && |
| 3950 PlatformGetParent()->HasState(ui::AX_STATE_MULTISELECTABLE)) | 4044 GetOwner()->PlatformGetParent()->HasState( |
| 4045 ui::AX_STATE_MULTISELECTABLE)) | |
| 3951 multiselect = true; | 4046 multiselect = true; |
| 3952 | 4047 |
| 3953 if (multiselect) { | 4048 if (multiselect) { |
| 3954 // In a multi-select box, fire SELECTIONADD and SELECTIONREMOVE events. | 4049 // In a multi-select box, fire SELECTIONADD and SELECTIONREMOVE events. |
| 3955 if (is_selected_now && !was_selected_before) { | 4050 if (is_selected_now && !was_selected_before) { |
| 3956 FireNativeEvent(EVENT_OBJECT_SELECTIONADD); | 4051 FireNativeEvent(EVENT_OBJECT_SELECTIONADD); |
| 3957 } else if (!is_selected_now && was_selected_before) { | 4052 } else if (!is_selected_now && was_selected_before) { |
| 3958 FireNativeEvent(EVENT_OBJECT_SELECTIONREMOVE); | 4053 FireNativeEvent(EVENT_OBJECT_SELECTIONREMOVE); |
| 3959 } | 4054 } |
| 3960 } else if (is_selected_now && !was_selected_before) { | 4055 } else if (is_selected_now && !was_selected_before) { |
| 3961 // In a single-select box, only fire SELECTION events. | 4056 // In a single-select box, only fire SELECTION events. |
| 3962 FireNativeEvent(EVENT_OBJECT_SELECTION); | 4057 FireNativeEvent(EVENT_OBJECT_SELECTION); |
| 3963 } | 4058 } |
| 3964 } | 4059 } |
| 3965 | 4060 |
| 3966 // Fire an event if this container object has scrolled. | 4061 // Fire an event if this container object has scrolled. |
| 3967 int sx = 0; | 4062 int sx = 0; |
| 3968 int sy = 0; | 4063 int sy = 0; |
| 3969 if (GetIntAttribute(ui::AX_ATTR_SCROLL_X, &sx) && | 4064 if (GetOwner()->GetIntAttribute(ui::AX_ATTR_SCROLL_X, &sx) && |
| 3970 GetIntAttribute(ui::AX_ATTR_SCROLL_Y, &sy)) { | 4065 GetOwner()->GetIntAttribute(ui::AX_ATTR_SCROLL_Y, &sy)) { |
| 3971 if (sx != previous_scroll_x_ || sy != previous_scroll_y_) | 4066 if (sx != previous_scroll_x_ || sy != previous_scroll_y_) |
| 3972 FireNativeEvent(EVENT_SYSTEM_SCROLLINGEND); | 4067 FireNativeEvent(EVENT_SYSTEM_SCROLLINGEND); |
| 3973 previous_scroll_x_ = sx; | 4068 previous_scroll_x_ = sx; |
| 3974 previous_scroll_y_ = sy; | 4069 previous_scroll_y_ = sy; |
| 3975 } | 4070 } |
| 3976 | 4071 |
| 3977 // Fire hypertext-related events. | 4072 // Fire hypertext-related events. |
| 3978 int start, old_len, new_len; | 4073 int start, old_len, new_len; |
| 3979 ComputeHypertextRemovedAndInserted(&start, &old_len, &new_len); | 4074 ComputeHypertextRemovedAndInserted(&start, &old_len, &new_len); |
| 3980 if (old_len > 0) { | 4075 if (old_len > 0) { |
| 3981 // In-process screen readers may call IAccessibleText::get_oldText | 4076 // In-process screen readers may call IAccessibleText::get_oldText |
| 3982 // in reaction to this event to retrieve the text that was removed. | 4077 // in reaction to this event to retrieve the text that was removed. |
| 3983 FireNativeEvent(IA2_EVENT_TEXT_REMOVED); | 4078 FireNativeEvent(IA2_EVENT_TEXT_REMOVED); |
| 3984 } | 4079 } |
| 3985 if (new_len > 0) { | 4080 if (new_len > 0) { |
| 3986 // In-process screen readers may call IAccessibleText::get_newText | 4081 // In-process screen readers may call IAccessibleText::get_newText |
| 3987 // in reaction to this event to retrieve the text that was inserted. | 4082 // in reaction to this event to retrieve the text that was inserted. |
| 3988 FireNativeEvent(IA2_EVENT_TEXT_INSERTED); | 4083 FireNativeEvent(IA2_EVENT_TEXT_INSERTED); |
| 3989 } | 4084 } |
| 3990 | 4085 |
| 3991 // Changing a static text node can affect the IAccessibleText hypertext | 4086 // Changing a static text node can affect the IAccessibleText hypertext |
| 3992 // of the parent node, so force an update on the parent. | 4087 // of the parent node, so force an update on the parent. |
| 3993 BrowserAccessibilityWin* parent = | 4088 BrowserAccessibilityComWin* parent = |
| 3994 ToBrowserAccessibilityWin(PlatformGetParent()); | 4089 ToBrowserAccessibilityComWin(GetOwner()->PlatformGetParent()); |
| 3995 if (parent && IsTextOnlyObject() && | 4090 if (parent && GetOwner()->IsTextOnlyObject() && |
| 3996 name() != old_win_attributes_->name) { | 4091 name() != old_win_attributes_->name) { |
| 3997 parent->UpdatePlatformAttributes(); | 4092 parent->GetOwner()->UpdatePlatformAttributes(); |
| 3998 } | 4093 } |
| 3999 } | 4094 } |
| 4000 | 4095 |
| 4001 old_win_attributes_.reset(nullptr); | 4096 old_win_attributes_.reset(nullptr); |
| 4002 } | 4097 } |
| 4003 | 4098 |
| 4004 void BrowserAccessibilityWin::UpdatePlatformAttributes() { | 4099 std::vector<base::string16> BrowserAccessibilityComWin::ComputeTextAttributes() |
| 4005 UpdateStep1ComputeWinAttributes(); | |
| 4006 UpdateStep2ComputeHypertext(); | |
| 4007 UpdateStep3FireEvents(false); | |
| 4008 } | |
| 4009 | |
| 4010 void BrowserAccessibilityWin::OnSubtreeWillBeDeleted() { | |
| 4011 FireNativeEvent(EVENT_OBJECT_HIDE); | |
| 4012 } | |
| 4013 | |
| 4014 void BrowserAccessibilityWin::NativeAddReference() { | |
| 4015 AddRef(); | |
| 4016 } | |
| 4017 | |
| 4018 void BrowserAccessibilityWin::NativeReleaseReference() { | |
| 4019 Release(); | |
| 4020 } | |
| 4021 | |
| 4022 bool BrowserAccessibilityWin::IsNative() const { | |
| 4023 return true; | |
| 4024 } | |
| 4025 | |
| 4026 void BrowserAccessibilityWin::OnLocationChanged() { | |
| 4027 FireNativeEvent(EVENT_OBJECT_LOCATIONCHANGE); | |
| 4028 } | |
| 4029 | |
| 4030 std::vector<base::string16> BrowserAccessibilityWin::ComputeTextAttributes() | |
| 4031 const { | 4100 const { |
| 4032 std::vector<base::string16> attributes; | 4101 std::vector<base::string16> attributes; |
| 4033 | 4102 |
| 4034 // We include list markers for now, but there might be other objects that are | 4103 // We include list markers for now, but there might be other objects that are |
| 4035 // auto generated. | 4104 // auto generated. |
| 4036 // TODO(nektar): Compute what objects are auto-generated in Blink. | 4105 // TODO(nektar): Compute what objects are auto-generated in Blink. |
| 4037 if (GetRole() == ui::AX_ROLE_LIST_MARKER) | 4106 if (GetOwner()->GetRole() == ui::AX_ROLE_LIST_MARKER) |
| 4038 attributes.push_back(L"auto-generated:true"); | 4107 attributes.push_back(L"auto-generated:true"); |
| 4039 else | 4108 else |
| 4040 attributes.push_back(L"auto-generated:false"); | 4109 attributes.push_back(L"auto-generated:false"); |
| 4041 | 4110 |
| 4042 int color; | 4111 int color; |
| 4043 base::string16 color_value(L"transparent"); | 4112 base::string16 color_value(L"transparent"); |
| 4044 if (GetIntAttribute(ui::AX_ATTR_BACKGROUND_COLOR, &color)) { | 4113 if (GetOwner()->GetIntAttribute(ui::AX_ATTR_BACKGROUND_COLOR, &color)) { |
| 4045 unsigned int alpha = SkColorGetA(color); | 4114 unsigned int alpha = SkColorGetA(color); |
| 4046 unsigned int red = SkColorGetR(color); | 4115 unsigned int red = SkColorGetR(color); |
| 4047 unsigned int green = SkColorGetG(color); | 4116 unsigned int green = SkColorGetG(color); |
| 4048 unsigned int blue = SkColorGetB(color); | 4117 unsigned int blue = SkColorGetB(color); |
| 4049 if (alpha) { | 4118 if (alpha) { |
| 4050 color_value = L"rgb(" + base::UintToString16(red) + L',' + | 4119 color_value = L"rgb(" + base::UintToString16(red) + L',' + |
| 4051 base::UintToString16(green) + L',' + | 4120 base::UintToString16(green) + L',' + |
| 4052 base::UintToString16(blue) + L')'; | 4121 base::UintToString16(blue) + L')'; |
| 4053 } | 4122 } |
| 4054 } | 4123 } |
| 4055 SanitizeStringAttributeForIA2(color_value, &color_value); | 4124 SanitizeStringAttributeForIA2(color_value, &color_value); |
| 4056 attributes.push_back(L"background-color:" + color_value); | 4125 attributes.push_back(L"background-color:" + color_value); |
| 4057 | 4126 |
| 4058 if (GetIntAttribute(ui::AX_ATTR_COLOR, &color)) { | 4127 if (GetOwner()->GetIntAttribute(ui::AX_ATTR_COLOR, &color)) { |
| 4059 unsigned int red = SkColorGetR(color); | 4128 unsigned int red = SkColorGetR(color); |
| 4060 unsigned int green = SkColorGetG(color); | 4129 unsigned int green = SkColorGetG(color); |
| 4061 unsigned int blue = SkColorGetB(color); | 4130 unsigned int blue = SkColorGetB(color); |
| 4062 color_value = L"rgb(" + base::UintToString16(red) + L',' + | 4131 color_value = L"rgb(" + base::UintToString16(red) + L',' + |
| 4063 base::UintToString16(green) + L',' + | 4132 base::UintToString16(green) + L',' + |
| 4064 base::UintToString16(blue) + L')'; | 4133 base::UintToString16(blue) + L')'; |
| 4065 } else { | 4134 } else { |
| 4066 color_value = L"rgb(0,0,0)"; | 4135 color_value = L"rgb(0,0,0)"; |
| 4067 } | 4136 } |
| 4068 SanitizeStringAttributeForIA2(color_value, &color_value); | 4137 SanitizeStringAttributeForIA2(color_value, &color_value); |
| 4069 attributes.push_back(L"color:" + color_value); | 4138 attributes.push_back(L"color:" + color_value); |
| 4070 | 4139 |
| 4071 base::string16 font_family( | 4140 base::string16 font_family( |
| 4072 GetInheritedString16Attribute(ui::AX_ATTR_FONT_FAMILY)); | 4141 GetOwner()->GetInheritedString16Attribute(ui::AX_ATTR_FONT_FAMILY)); |
| 4073 // Attribute has no default value. | 4142 // Attribute has no default value. |
| 4074 if (!font_family.empty()) { | 4143 if (!font_family.empty()) { |
| 4075 SanitizeStringAttributeForIA2(font_family, &font_family); | 4144 SanitizeStringAttributeForIA2(font_family, &font_family); |
| 4076 attributes.push_back(L"font-family:" + font_family); | 4145 attributes.push_back(L"font-family:" + font_family); |
| 4077 } | 4146 } |
| 4078 | 4147 |
| 4079 float font_size; | 4148 float font_size; |
| 4080 // Attribute has no default value. | 4149 // Attribute has no default value. |
| 4081 if (GetFloatAttribute(ui::AX_ATTR_FONT_SIZE, &font_size)) { | 4150 if (GetFloatAttribute(ui::AX_ATTR_FONT_SIZE, &font_size)) { |
| 4082 // The IA2 Spec requires the value to be in pt, not in pixels. | 4151 // The IA2 Spec requires the value to be in pt, not in pixels. |
| 4083 // There are 72 points per inch. | 4152 // There are 72 points per inch. |
| 4084 // We assume that there are 96 pixels per inch on a standard display. | 4153 // We assume that there are 96 pixels per inch on a standard display. |
| 4085 // TODO(nektar): Figure out the current value of pixels per inch. | 4154 // TODO(nektar): Figure out the current value of pixels per inch. |
| 4086 float points = font_size * 72.0 / 96.0; | 4155 float points = font_size * 72.0 / 96.0; |
| 4087 attributes.push_back(L"font-size:" + | 4156 attributes.push_back(L"font-size:" + |
| 4088 base::UTF8ToUTF16(base::DoubleToString(points)) + | 4157 base::UTF8ToUTF16(base::DoubleToString(points)) + |
| 4089 L"pt"); | 4158 L"pt"); |
| 4090 } | 4159 } |
| 4091 | 4160 |
| 4092 auto text_style = | 4161 auto text_style = static_cast<ui::AXTextStyle>( |
| 4093 static_cast<ui::AXTextStyle>(GetIntAttribute(ui::AX_ATTR_TEXT_STYLE)); | 4162 GetOwner()->GetIntAttribute(ui::AX_ATTR_TEXT_STYLE)); |
| 4094 if (text_style == ui::AX_TEXT_STYLE_NONE) { | 4163 if (text_style == ui::AX_TEXT_STYLE_NONE) { |
| 4095 attributes.push_back(L"font-style:normal"); | 4164 attributes.push_back(L"font-style:normal"); |
| 4096 attributes.push_back(L"font-weight:normal"); | 4165 attributes.push_back(L"font-weight:normal"); |
| 4097 } else { | 4166 } else { |
| 4098 if (text_style & ui::AX_TEXT_STYLE_ITALIC) { | 4167 if (text_style & ui::AX_TEXT_STYLE_ITALIC) { |
| 4099 attributes.push_back(L"font-style:italic"); | 4168 attributes.push_back(L"font-style:italic"); |
| 4100 } else { | 4169 } else { |
| 4101 attributes.push_back(L"font-style:normal"); | 4170 attributes.push_back(L"font-style:normal"); |
| 4102 } | 4171 } |
| 4103 | 4172 |
| 4104 if (text_style & ui::AX_TEXT_STYLE_BOLD) { | 4173 if (text_style & ui::AX_TEXT_STYLE_BOLD) { |
| 4105 attributes.push_back(L"font-weight:bold"); | 4174 attributes.push_back(L"font-weight:bold"); |
| 4106 } else { | 4175 } else { |
| 4107 attributes.push_back(L"font-weight:normal"); | 4176 attributes.push_back(L"font-weight:normal"); |
| 4108 } | 4177 } |
| 4109 } | 4178 } |
| 4110 | 4179 |
| 4111 auto invalid_state = static_cast<ui::AXInvalidState>( | 4180 auto invalid_state = static_cast<ui::AXInvalidState>( |
| 4112 GetIntAttribute(ui::AX_ATTR_INVALID_STATE)); | 4181 GetOwner()->GetIntAttribute(ui::AX_ATTR_INVALID_STATE)); |
| 4113 switch (invalid_state) { | 4182 switch (invalid_state) { |
| 4114 case ui::AX_INVALID_STATE_NONE: | 4183 case ui::AX_INVALID_STATE_NONE: |
| 4115 case ui::AX_INVALID_STATE_FALSE: | 4184 case ui::AX_INVALID_STATE_FALSE: |
| 4116 attributes.push_back(L"invalid:false"); | 4185 attributes.push_back(L"invalid:false"); |
| 4117 break; | 4186 break; |
| 4118 case ui::AX_INVALID_STATE_TRUE: | 4187 case ui::AX_INVALID_STATE_TRUE: |
| 4119 attributes.push_back(L"invalid:true"); | 4188 attributes.push_back(L"invalid:true"); |
| 4120 break; | 4189 break; |
| 4121 case ui::AX_INVALID_STATE_SPELLING: | 4190 case ui::AX_INVALID_STATE_SPELLING: |
| 4122 case ui::AX_INVALID_STATE_GRAMMAR: { | 4191 case ui::AX_INVALID_STATE_GRAMMAR: { |
| 4123 base::string16 spelling_grammar_value; | 4192 base::string16 spelling_grammar_value; |
| 4124 if (invalid_state & ui::AX_INVALID_STATE_SPELLING) | 4193 if (invalid_state & ui::AX_INVALID_STATE_SPELLING) |
| 4125 spelling_grammar_value = L"spelling"; | 4194 spelling_grammar_value = L"spelling"; |
| 4126 else if (invalid_state & ui::AX_INVALID_STATE_GRAMMAR) | 4195 else if (invalid_state & ui::AX_INVALID_STATE_GRAMMAR) |
| 4127 spelling_grammar_value = L"grammar"; | 4196 spelling_grammar_value = L"grammar"; |
| 4128 else | 4197 else |
| 4129 spelling_grammar_value = L"spelling,grammar"; | 4198 spelling_grammar_value = L"spelling,grammar"; |
| 4130 attributes.push_back(L"invalid:" + spelling_grammar_value); | 4199 attributes.push_back(L"invalid:" + spelling_grammar_value); |
| 4131 break; | 4200 break; |
| 4132 } | 4201 } |
| 4133 case ui::AX_INVALID_STATE_OTHER: { | 4202 case ui::AX_INVALID_STATE_OTHER: { |
| 4134 base::string16 aria_invalid_value; | 4203 base::string16 aria_invalid_value; |
| 4135 if (GetString16Attribute(ui::AX_ATTR_ARIA_INVALID_VALUE, | 4204 if (GetOwner()->GetString16Attribute(ui::AX_ATTR_ARIA_INVALID_VALUE, |
| 4136 &aria_invalid_value)) { | 4205 &aria_invalid_value)) { |
| 4137 SanitizeStringAttributeForIA2(aria_invalid_value, &aria_invalid_value); | 4206 SanitizeStringAttributeForIA2(aria_invalid_value, &aria_invalid_value); |
| 4138 attributes.push_back(L"invalid:" + aria_invalid_value); | 4207 attributes.push_back(L"invalid:" + aria_invalid_value); |
| 4139 } else { | 4208 } else { |
| 4140 // Set the attribute to L"true", since we cannot be more specific. | 4209 // Set the attribute to L"true", since we cannot be more specific. |
| 4141 attributes.push_back(L"invalid:true"); | 4210 attributes.push_back(L"invalid:true"); |
| 4142 } | 4211 } |
| 4143 break; | 4212 break; |
| 4144 } | 4213 } |
| 4145 } | 4214 } |
| 4146 | 4215 |
| 4147 base::string16 language(GetInheritedString16Attribute(ui::AX_ATTR_LANGUAGE)); | 4216 base::string16 language( |
| 4217 GetOwner()->GetInheritedString16Attribute(ui::AX_ATTR_LANGUAGE)); | |
| 4148 // Default value should be L"en-US". | 4218 // Default value should be L"en-US". |
| 4149 if (language.empty()) { | 4219 if (language.empty()) { |
| 4150 attributes.push_back(L"language:en-US"); | 4220 attributes.push_back(L"language:en-US"); |
| 4151 } else { | 4221 } else { |
| 4152 SanitizeStringAttributeForIA2(language, &language); | 4222 SanitizeStringAttributeForIA2(language, &language); |
| 4153 attributes.push_back(L"language:" + language); | 4223 attributes.push_back(L"language:" + language); |
| 4154 } | 4224 } |
| 4155 | 4225 |
| 4156 // TODO(nektar): Add Blink support for the following attributes. | 4226 // TODO(nektar): Add Blink support for the following attributes. |
| 4157 // Currently set to their default values as dictated by the IA2 Spec. | 4227 // Currently set to their default values as dictated by the IA2 Spec. |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 4179 // TODO(nektar): Figure out a more specific value. | 4249 // TODO(nektar): Figure out a more specific value. |
| 4180 attributes.push_back(L"text-underline-style:solid"); | 4250 attributes.push_back(L"text-underline-style:solid"); |
| 4181 attributes.push_back(L"text-underline-type:single"); | 4251 attributes.push_back(L"text-underline-type:single"); |
| 4182 } else { | 4252 } else { |
| 4183 attributes.push_back(L"text-underline-style:none"); | 4253 attributes.push_back(L"text-underline-style:none"); |
| 4184 attributes.push_back(L"text-underline-type:none"); | 4254 attributes.push_back(L"text-underline-type:none"); |
| 4185 } | 4255 } |
| 4186 attributes.push_back(L"text-underline-width:auto"); | 4256 attributes.push_back(L"text-underline-width:auto"); |
| 4187 | 4257 |
| 4188 auto text_direction = static_cast<ui::AXTextDirection>( | 4258 auto text_direction = static_cast<ui::AXTextDirection>( |
| 4189 GetIntAttribute(ui::AX_ATTR_TEXT_DIRECTION)); | 4259 GetOwner()->GetIntAttribute(ui::AX_ATTR_TEXT_DIRECTION)); |
| 4190 switch (text_direction) { | 4260 switch (text_direction) { |
| 4191 case ui::AX_TEXT_DIRECTION_NONE: | 4261 case ui::AX_TEXT_DIRECTION_NONE: |
| 4192 case ui::AX_TEXT_DIRECTION_LTR: | 4262 case ui::AX_TEXT_DIRECTION_LTR: |
| 4193 attributes.push_back(L"writing-mode:lr"); | 4263 attributes.push_back(L"writing-mode:lr"); |
| 4194 break; | 4264 break; |
| 4195 case ui::AX_TEXT_DIRECTION_RTL: | 4265 case ui::AX_TEXT_DIRECTION_RTL: |
| 4196 attributes.push_back(L"writing-mode:rl"); | 4266 attributes.push_back(L"writing-mode:rl"); |
| 4197 break; | 4267 break; |
| 4198 case ui::AX_TEXT_DIRECTION_TTB: | 4268 case ui::AX_TEXT_DIRECTION_TTB: |
| 4199 attributes.push_back(L"writing-mode:tb"); | 4269 attributes.push_back(L"writing-mode:tb"); |
| 4200 break; | 4270 break; |
| 4201 case ui::AX_TEXT_DIRECTION_BTT: | 4271 case ui::AX_TEXT_DIRECTION_BTT: |
| 4202 // Not listed in the IA2 Spec. | 4272 // Not listed in the IA2 Spec. |
| 4203 attributes.push_back(L"writing-mode:bt"); | 4273 attributes.push_back(L"writing-mode:bt"); |
| 4204 break; | 4274 break; |
| 4205 } | 4275 } |
| 4206 | 4276 |
| 4207 return attributes; | 4277 return attributes; |
| 4208 } | 4278 } |
| 4209 | 4279 |
| 4210 BrowserAccessibilityWin* BrowserAccessibilityWin::NewReference() { | 4280 BrowserAccessibilityComWin* BrowserAccessibilityComWin::NewReference() { |
| 4211 AddRef(); | 4281 AddRef(); |
| 4212 return this; | 4282 return this; |
| 4213 } | 4283 } |
| 4214 | 4284 |
| 4215 std::map<int, std::vector<base::string16>> | 4285 std::map<int, std::vector<base::string16>> |
| 4216 BrowserAccessibilityWin::GetSpellingAttributes() const { | 4286 BrowserAccessibilityComWin::GetSpellingAttributes() { |
| 4217 std::map<int, std::vector<base::string16>> spelling_attributes; | 4287 std::map<int, std::vector<base::string16>> spelling_attributes; |
| 4218 if (IsTextOnlyObject()) { | 4288 if (GetOwner()->IsTextOnlyObject()) { |
| 4219 const std::vector<int32_t>& marker_types = | 4289 const std::vector<int32_t>& marker_types = |
| 4220 GetIntListAttribute(ui::AX_ATTR_MARKER_TYPES); | 4290 GetOwner()->GetIntListAttribute(ui::AX_ATTR_MARKER_TYPES); |
| 4221 const std::vector<int>& marker_starts = | 4291 const std::vector<int>& marker_starts = |
| 4222 GetIntListAttribute(ui::AX_ATTR_MARKER_STARTS); | 4292 GetOwner()->GetIntListAttribute(ui::AX_ATTR_MARKER_STARTS); |
| 4223 const std::vector<int>& marker_ends = | 4293 const std::vector<int>& marker_ends = |
| 4224 GetIntListAttribute(ui::AX_ATTR_MARKER_ENDS); | 4294 GetOwner()->GetIntListAttribute(ui::AX_ATTR_MARKER_ENDS); |
| 4225 for (size_t i = 0; i < marker_types.size(); ++i) { | 4295 for (size_t i = 0; i < marker_types.size(); ++i) { |
| 4226 if (!(static_cast<ui::AXMarkerType>(marker_types[i]) & | 4296 if (!(static_cast<ui::AXMarkerType>(marker_types[i]) & |
| 4227 ui::AX_MARKER_TYPE_SPELLING)) | 4297 ui::AX_MARKER_TYPE_SPELLING)) |
| 4228 continue; | 4298 continue; |
| 4229 int start_offset = marker_starts[i]; | 4299 int start_offset = marker_starts[i]; |
| 4230 int end_offset = marker_ends[i]; | 4300 int end_offset = marker_ends[i]; |
| 4231 std::vector<base::string16> start_attributes; | 4301 std::vector<base::string16> start_attributes; |
| 4232 start_attributes.push_back(L"invalid:spelling"); | 4302 start_attributes.push_back(L"invalid:spelling"); |
| 4233 std::vector<base::string16> end_attributes; | 4303 std::vector<base::string16> end_attributes; |
| 4234 end_attributes.push_back(L"invalid:false"); | 4304 end_attributes.push_back(L"invalid:false"); |
| 4235 spelling_attributes[start_offset] = start_attributes; | 4305 spelling_attributes[start_offset] = start_attributes; |
| 4236 spelling_attributes[end_offset] = end_attributes; | 4306 spelling_attributes[end_offset] = end_attributes; |
| 4237 } | 4307 } |
| 4238 } | 4308 } |
| 4239 if (IsSimpleTextControl()) { | 4309 if (GetOwner()->IsSimpleTextControl()) { |
| 4240 int start_offset = 0; | 4310 int start_offset = 0; |
| 4241 for (const BrowserAccessibility* static_text = | 4311 for (BrowserAccessibility* static_text = |
| 4242 BrowserAccessibilityManager::NextTextOnlyObject( | 4312 BrowserAccessibilityManager::NextTextOnlyObject( |
| 4243 InternalGetChild(0)); | 4313 GetOwner()->InternalGetChild(0)); |
| 4244 static_text; static_text = static_text->GetNextSibling()) { | 4314 static_text; static_text = static_text->GetNextSibling()) { |
| 4245 auto* text_win = ToBrowserAccessibilityWin(static_text); | 4315 auto* text_win = ToBrowserAccessibilityComWin(static_text); |
| 4246 if (text_win) { | 4316 if (text_win) { |
| 4247 std::map<int, std::vector<base::string16>> text_spelling_attributes = | 4317 std::map<int, std::vector<base::string16>> text_spelling_attributes = |
| 4248 text_win->GetSpellingAttributes(); | 4318 text_win->GetSpellingAttributes(); |
| 4249 for (auto& attribute : text_spelling_attributes) { | 4319 for (auto& attribute : text_spelling_attributes) { |
| 4250 spelling_attributes[start_offset + attribute.first] = | 4320 spelling_attributes[start_offset + attribute.first] = |
| 4251 std::move(attribute.second); | 4321 std::move(attribute.second); |
| 4252 } | 4322 } |
| 4253 start_offset += static_cast<int>(text_win->GetText().length()); | 4323 start_offset += |
| 4324 static_cast<int>(text_win->GetOwner()->GetText().length()); | |
| 4254 } | 4325 } |
| 4255 } | 4326 } |
| 4256 } | 4327 } |
| 4257 return spelling_attributes; | 4328 return spelling_attributes; |
| 4258 } | 4329 } |
| 4259 | 4330 |
| 4260 BrowserAccessibilityWin* BrowserAccessibilityWin::GetTargetFromChildID( | 4331 BrowserAccessibilityComWin* BrowserAccessibilityComWin::GetTargetFromChildID( |
| 4261 const VARIANT& var_id) { | 4332 const VARIANT& var_id) { |
| 4333 if (!GetOwner() || !GetOwner()->instance_active()) | |
| 4334 return nullptr; | |
| 4335 | |
| 4262 if (var_id.vt != VT_I4) | 4336 if (var_id.vt != VT_I4) |
| 4263 return nullptr; | 4337 return nullptr; |
| 4264 | 4338 |
| 4265 LONG child_id = var_id.lVal; | 4339 LONG child_id = var_id.lVal; |
| 4266 if (child_id == CHILDID_SELF) | 4340 if (child_id == CHILDID_SELF) |
| 4267 return this; | 4341 return this; |
| 4268 | 4342 |
| 4269 if (child_id >= 1 && child_id <= static_cast<LONG>(PlatformChildCount())) | 4343 if (child_id >= 1 && |
| 4270 return ToBrowserAccessibilityWin(PlatformGetChild(child_id - 1)); | 4344 child_id <= static_cast<LONG>(GetOwner()->PlatformChildCount())) |
| 4345 return ToBrowserAccessibilityComWin( | |
| 4346 GetOwner()->PlatformGetChild(child_id - 1)); | |
| 4271 | 4347 |
| 4272 BrowserAccessibilityWin* child = ToBrowserAccessibilityWin( | 4348 BrowserAccessibilityComWin* child = ToBrowserAccessibilityComWin( |
| 4273 BrowserAccessibility::GetFromUniqueID(-child_id)); | 4349 BrowserAccessibility::GetFromUniqueID(-child_id)); |
| 4274 if (child && child->IsDescendantOf(this)) | 4350 if (child && child->GetOwner()->IsDescendantOf(GetOwner())) |
| 4275 return child; | 4351 return child; |
| 4276 | 4352 |
| 4277 return nullptr; | 4353 return nullptr; |
| 4278 } | 4354 } |
| 4279 | 4355 |
| 4280 HRESULT BrowserAccessibilityWin::GetStringAttributeAsBstr( | 4356 HRESULT BrowserAccessibilityComWin::GetStringAttributeAsBstr( |
| 4281 ui::AXStringAttribute attribute, | 4357 ui::AXStringAttribute attribute, |
| 4282 BSTR* value_bstr) { | 4358 BSTR* value_bstr) { |
| 4283 base::string16 str; | 4359 base::string16 str; |
| 4360 if (!GetOwner() || !GetOwner()->instance_active()) | |
| 4361 return E_FAIL; | |
| 4284 | 4362 |
| 4285 if (!GetString16Attribute(attribute, &str)) | 4363 if (!GetOwner()->GetString16Attribute(attribute, &str)) |
| 4286 return S_FALSE; | 4364 return S_FALSE; |
| 4287 | 4365 |
| 4288 *value_bstr = SysAllocString(str.c_str()); | 4366 *value_bstr = SysAllocString(str.c_str()); |
| 4289 DCHECK(*value_bstr); | 4367 DCHECK(*value_bstr); |
| 4290 | 4368 |
| 4291 return S_OK; | 4369 return S_OK; |
| 4292 } | 4370 } |
| 4293 | 4371 |
| 4294 // Static | 4372 // Static |
| 4295 void BrowserAccessibilityWin::SanitizeStringAttributeForIA2( | 4373 void BrowserAccessibilityComWin::SanitizeStringAttributeForIA2( |
| 4296 const base::string16& input, | 4374 const base::string16& input, |
| 4297 base::string16* output) { | 4375 base::string16* output) { |
| 4298 DCHECK(output); | 4376 DCHECK(output); |
| 4299 // According to the IA2 Spec, these characters need to be escaped with a | 4377 // According to the IA2 Spec, these characters need to be escaped with a |
| 4300 // backslash: backslash, colon, comma, equals and semicolon. | 4378 // backslash: backslash, colon, comma, equals and semicolon. |
| 4301 // Note that backslash must be replaced first. | 4379 // Note that backslash must be replaced first. |
| 4302 base::ReplaceChars(input, L"\\", L"\\\\", output); | 4380 base::ReplaceChars(input, L"\\", L"\\\\", output); |
| 4303 base::ReplaceChars(*output, L":", L"\\:", output); | 4381 base::ReplaceChars(*output, L":", L"\\:", output); |
| 4304 base::ReplaceChars(*output, L",", L"\\,", output); | 4382 base::ReplaceChars(*output, L",", L"\\,", output); |
| 4305 base::ReplaceChars(*output, L"=", L"\\=", output); | 4383 base::ReplaceChars(*output, L"=", L"\\=", output); |
| 4306 base::ReplaceChars(*output, L";", L"\\;", output); | 4384 base::ReplaceChars(*output, L";", L"\\;", output); |
| 4307 } | 4385 } |
| 4308 | 4386 |
| 4309 void BrowserAccessibilityWin::SetIA2HypertextSelection(LONG start_offset, | 4387 void BrowserAccessibilityComWin::SetIA2HypertextSelection(LONG start_offset, |
| 4310 LONG end_offset) { | 4388 LONG end_offset) { |
| 4311 HandleSpecialTextOffset(&start_offset); | 4389 HandleSpecialTextOffset(&start_offset); |
| 4312 HandleSpecialTextOffset(&end_offset); | 4390 HandleSpecialTextOffset(&end_offset); |
| 4313 AXPlatformPositionInstance start_position = | 4391 AXPlatformPositionInstance start_position = |
| 4314 CreatePositionForSelectionAt(static_cast<int>(start_offset)); | 4392 CreatePositionForSelectionAt(static_cast<int>(start_offset)); |
| 4315 AXPlatformPositionInstance end_position = | 4393 AXPlatformPositionInstance end_position = |
| 4316 CreatePositionForSelectionAt(static_cast<int>(end_offset)); | 4394 CreatePositionForSelectionAt(static_cast<int>(end_offset)); |
| 4317 manager_->SetSelection(AXPlatformRange(start_position->AsTextPosition(), | 4395 GetOwner()->manager()->SetSelection(AXPlatformRange( |
| 4318 end_position->AsTextPosition())); | 4396 start_position->AsTextPosition(), end_position->AsTextPosition())); |
| 4319 } | 4397 } |
| 4320 | 4398 |
| 4321 void BrowserAccessibilityWin::StringAttributeToIA2( | 4399 void BrowserAccessibilityComWin::StringAttributeToIA2( |
| 4322 ui::AXStringAttribute attribute, | 4400 ui::AXStringAttribute attribute, |
| 4323 const char* ia2_attr) { | 4401 const char* ia2_attr) { |
| 4324 base::string16 value; | 4402 base::string16 value; |
| 4325 if (GetString16Attribute(attribute, &value)) { | 4403 if (GetOwner()->GetString16Attribute(attribute, &value)) { |
| 4326 SanitizeStringAttributeForIA2(value, &value); | 4404 SanitizeStringAttributeForIA2(value, &value); |
| 4327 win_attributes_->ia2_attributes.push_back( | 4405 win_attributes_->ia2_attributes.push_back(base::ASCIIToUTF16(ia2_attr) + |
| 4328 base::ASCIIToUTF16(ia2_attr) + L":" + value); | 4406 L":" + value); |
| 4329 } | 4407 } |
| 4330 } | 4408 } |
| 4331 | 4409 |
| 4332 void BrowserAccessibilityWin::BoolAttributeToIA2( | 4410 void BrowserAccessibilityComWin::BoolAttributeToIA2( |
| 4333 ui::AXBoolAttribute attribute, | 4411 ui::AXBoolAttribute attribute, |
| 4334 const char* ia2_attr) { | 4412 const char* ia2_attr) { |
| 4335 bool value; | 4413 bool value; |
| 4336 if (GetBoolAttribute(attribute, &value)) { | 4414 if (GetOwner()->GetBoolAttribute(attribute, &value)) { |
| 4337 win_attributes_->ia2_attributes.push_back( | 4415 win_attributes_->ia2_attributes.push_back( |
| 4338 (base::ASCIIToUTF16(ia2_attr) + L":") + | 4416 (base::ASCIIToUTF16(ia2_attr) + L":") + (value ? L"true" : L"false")); |
| 4339 (value ? L"true" : L"false")); | |
| 4340 } | 4417 } |
| 4341 } | 4418 } |
| 4342 | 4419 |
| 4343 void BrowserAccessibilityWin::IntAttributeToIA2( | 4420 void BrowserAccessibilityComWin::IntAttributeToIA2(ui::AXIntAttribute attribute, |
| 4344 ui::AXIntAttribute attribute, | 4421 const char* ia2_attr) { |
| 4345 const char* ia2_attr) { | |
| 4346 int value; | 4422 int value; |
| 4347 if (GetIntAttribute(attribute, &value)) { | 4423 if (GetOwner()->GetIntAttribute(attribute, &value)) { |
| 4348 win_attributes_->ia2_attributes.push_back( | 4424 win_attributes_->ia2_attributes.push_back( |
| 4349 base::ASCIIToUTF16(ia2_attr) + L":" + | 4425 base::ASCIIToUTF16(ia2_attr) + L":" + base::IntToString16(value)); |
| 4350 base::IntToString16(value)); | |
| 4351 } | 4426 } |
| 4352 } | 4427 } |
| 4353 | 4428 |
| 4354 bool BrowserAccessibilityWin::IsHyperlink() const { | 4429 bool BrowserAccessibilityComWin::IsHyperlink() const { |
| 4355 int32_t hyperlink_index = -1; | 4430 int32_t hyperlink_index = -1; |
| 4356 auto* parent = PlatformGetParent(); | 4431 auto* parent = GetOwner()->PlatformGetParent(); |
| 4357 if (parent) { | 4432 if (parent) { |
| 4358 hyperlink_index = | 4433 hyperlink_index = |
| 4359 ToBrowserAccessibilityWin(parent)->GetHyperlinkIndexFromChild(*this); | 4434 ToBrowserAccessibilityComWin(parent)->GetHyperlinkIndexFromChild(*this); |
| 4360 } | 4435 } |
| 4361 | 4436 |
| 4362 if (hyperlink_index >= 0) | 4437 if (hyperlink_index >= 0) |
| 4363 return true; | 4438 return true; |
| 4364 return false; | 4439 return false; |
| 4365 } | 4440 } |
| 4366 | 4441 |
| 4367 BrowserAccessibilityWin* | 4442 BrowserAccessibilityComWin* |
| 4368 BrowserAccessibilityWin::GetHyperlinkFromHypertextOffset(int offset) const { | 4443 BrowserAccessibilityComWin::GetHyperlinkFromHypertextOffset(int offset) const { |
| 4369 std::map<int32_t, int32_t>::iterator iterator = | 4444 std::map<int32_t, int32_t>::iterator iterator = |
| 4370 hyperlink_offset_to_index().find(offset); | 4445 hyperlink_offset_to_index().find(offset); |
| 4371 if (iterator == hyperlink_offset_to_index().end()) | 4446 if (iterator == hyperlink_offset_to_index().end()) |
| 4372 return nullptr; | 4447 return nullptr; |
| 4373 | 4448 |
| 4374 int32_t index = iterator->second; | 4449 int32_t index = iterator->second; |
| 4375 DCHECK_GE(index, 0); | 4450 DCHECK_GE(index, 0); |
| 4376 DCHECK_LT(index, static_cast<int32_t>(hyperlinks().size())); | 4451 DCHECK_LT(index, static_cast<int32_t>(hyperlinks().size())); |
| 4377 int32_t id = hyperlinks()[index]; | 4452 int32_t id = hyperlinks()[index]; |
| 4378 BrowserAccessibilityWin* hyperlink = | 4453 BrowserAccessibilityComWin* hyperlink = |
| 4379 ToBrowserAccessibilityWin(GetFromUniqueID(id)); | 4454 ToBrowserAccessibilityComWin(GetOwner()->GetFromUniqueID(id)); |
| 4380 if (!hyperlink) | 4455 if (!hyperlink) |
| 4381 return nullptr; | 4456 return nullptr; |
| 4382 return hyperlink; | 4457 return hyperlink; |
| 4383 } | 4458 } |
| 4384 | 4459 |
| 4385 int32_t BrowserAccessibilityWin::GetHyperlinkIndexFromChild( | 4460 int32_t BrowserAccessibilityComWin::GetHyperlinkIndexFromChild( |
| 4386 const BrowserAccessibilityWin& child) const { | 4461 const BrowserAccessibilityComWin& child) const { |
| 4387 if (hyperlinks().empty()) | 4462 if (hyperlinks().empty()) |
| 4388 return -1; | 4463 return -1; |
| 4389 | 4464 |
| 4390 auto iterator = | 4465 auto iterator = std::find(hyperlinks().begin(), hyperlinks().end(), |
| 4391 std::find(hyperlinks().begin(), hyperlinks().end(), child.unique_id()); | 4466 child.GetOwner()->unique_id()); |
| 4392 if (iterator == hyperlinks().end()) | 4467 if (iterator == hyperlinks().end()) |
| 4393 return -1; | 4468 return -1; |
| 4394 | 4469 |
| 4395 return static_cast<int32_t>(iterator - hyperlinks().begin()); | 4470 return static_cast<int32_t>(iterator - hyperlinks().begin()); |
| 4396 } | 4471 } |
| 4397 | 4472 |
| 4398 int32_t BrowserAccessibilityWin::GetHypertextOffsetFromHyperlinkIndex( | 4473 int32_t BrowserAccessibilityComWin::GetHypertextOffsetFromHyperlinkIndex( |
| 4399 int32_t hyperlink_index) const { | 4474 int32_t hyperlink_index) const { |
| 4400 for (auto& offset_index : hyperlink_offset_to_index()) { | 4475 for (auto& offset_index : hyperlink_offset_to_index()) { |
| 4401 if (offset_index.second == hyperlink_index) | 4476 if (offset_index.second == hyperlink_index) |
| 4402 return offset_index.first; | 4477 return offset_index.first; |
| 4403 } | 4478 } |
| 4404 | 4479 |
| 4405 return -1; | 4480 return -1; |
| 4406 } | 4481 } |
| 4407 | 4482 |
| 4408 int32_t BrowserAccessibilityWin::GetHypertextOffsetFromChild( | 4483 int32_t BrowserAccessibilityComWin::GetHypertextOffsetFromChild( |
| 4409 const BrowserAccessibilityWin& child) const { | 4484 BrowserAccessibilityComWin& child) { |
| 4410 DCHECK(child.PlatformGetParent() == this); | 4485 DCHECK(child.GetOwner()->PlatformGetParent() == GetOwner()); |
| 4411 | 4486 |
| 4412 // Handle the case when we are dealing with a direct text-only child. | 4487 // Handle the case when we are dealing with a direct text-only child. |
| 4413 // (Note that this object might be a platform leaf, e.g. an ARIA searchbox, | 4488 // (Note that this object might be a platform leaf, e.g. an ARIA searchbox, |
| 4414 // and so |InternalChild...| functions need to be used. Also, direct text-only | 4489 // and so |GetOwner()->InternalChild...| functions need to be used. Also, |
| 4415 // children should not be present at tree roots and so no cross-tree traversal | 4490 // direct text-only children should not be present at tree roots and so no |
| 4416 // is necessary.) | 4491 // cross-tree traversal is necessary.) |
| 4417 if (child.IsTextOnlyObject()) { | 4492 if (child.GetOwner()->IsTextOnlyObject()) { |
| 4418 int32_t hypertextOffset = 0; | 4493 int32_t hypertextOffset = 0; |
| 4419 int32_t index_in_parent = child.GetIndexInParent(); | 4494 int32_t index_in_parent = child.GetIndexInParent(); |
| 4420 DCHECK_GE(index_in_parent, 0); | 4495 DCHECK_GE(index_in_parent, 0); |
| 4421 DCHECK_LT(index_in_parent, static_cast<int32_t>(InternalChildCount())); | 4496 DCHECK_LT(index_in_parent, |
| 4497 static_cast<int32_t>(GetOwner()->InternalChildCount())); | |
| 4422 for (uint32_t i = 0; i < static_cast<uint32_t>(index_in_parent); ++i) { | 4498 for (uint32_t i = 0; i < static_cast<uint32_t>(index_in_parent); ++i) { |
| 4423 const BrowserAccessibilityWin* sibling = | 4499 const BrowserAccessibilityComWin* sibling = |
| 4424 ToBrowserAccessibilityWin(InternalGetChild(i)); | 4500 ToBrowserAccessibilityComWin(GetOwner()->InternalGetChild(i)); |
| 4425 DCHECK(sibling); | 4501 DCHECK(sibling); |
| 4426 if (sibling->IsTextOnlyObject()) | 4502 if (sibling->GetOwner()->IsTextOnlyObject()) |
| 4427 hypertextOffset += sibling->GetText().size(); | 4503 hypertextOffset += sibling->GetOwner()->GetText().size(); |
| 4428 else | 4504 else |
| 4429 ++hypertextOffset; | 4505 ++hypertextOffset; |
| 4430 } | 4506 } |
| 4431 return hypertextOffset; | 4507 return hypertextOffset; |
| 4432 } | 4508 } |
| 4433 | 4509 |
| 4434 int32_t hyperlink_index = GetHyperlinkIndexFromChild(child); | 4510 int32_t hyperlink_index = GetHyperlinkIndexFromChild(child); |
| 4435 if (hyperlink_index < 0) | 4511 if (hyperlink_index < 0) |
| 4436 return -1; | 4512 return -1; |
| 4437 | 4513 |
| 4438 return GetHypertextOffsetFromHyperlinkIndex(hyperlink_index); | 4514 return GetHypertextOffsetFromHyperlinkIndex(hyperlink_index); |
| 4439 } | 4515 } |
| 4440 | 4516 |
| 4441 int32_t BrowserAccessibilityWin::GetHypertextOffsetFromDescendant( | 4517 int32_t BrowserAccessibilityComWin::GetHypertextOffsetFromDescendant( |
| 4442 const BrowserAccessibilityWin& descendant) const { | 4518 const BrowserAccessibilityComWin& descendant) const { |
| 4443 auto* parent_object = | 4519 auto* parent_object = |
| 4444 ToBrowserAccessibilityWin(descendant.PlatformGetParent()); | 4520 ToBrowserAccessibilityComWin(descendant.GetOwner()->PlatformGetParent()); |
| 4445 auto* current_object = const_cast<BrowserAccessibilityWin*>(&descendant); | 4521 auto* current_object = const_cast<BrowserAccessibilityComWin*>(&descendant); |
| 4446 while (parent_object && parent_object != this) { | 4522 while (parent_object && parent_object != this) { |
| 4447 current_object = parent_object; | 4523 current_object = parent_object; |
| 4448 parent_object = | 4524 parent_object = ToBrowserAccessibilityComWin( |
| 4449 ToBrowserAccessibilityWin(current_object->PlatformGetParent()); | 4525 current_object->GetOwner()->PlatformGetParent()); |
| 4450 } | 4526 } |
| 4451 if (!parent_object) | 4527 if (!parent_object) |
| 4452 return -1; | 4528 return -1; |
| 4453 | 4529 |
| 4454 return parent_object->GetHypertextOffsetFromChild(*current_object); | 4530 return parent_object->GetHypertextOffsetFromChild(*current_object); |
| 4455 } | 4531 } |
| 4456 | 4532 |
| 4457 int BrowserAccessibilityWin::GetHypertextOffsetFromEndpoint( | 4533 int BrowserAccessibilityComWin::GetHypertextOffsetFromEndpoint( |
| 4458 const BrowserAccessibilityWin& endpoint_object, | 4534 const BrowserAccessibilityComWin& endpoint_object, |
| 4459 int endpoint_offset) const { | 4535 int endpoint_offset) const { |
| 4460 // There are three cases: | 4536 // There are three cases: |
| 4461 // 1. Either the selection endpoint is inside this object or is an ancestor of | 4537 // 1. Either the selection endpoint is inside this object or is an ancestor of |
| 4462 // of this object. endpoint_offset should be returned. | 4538 // of this object. endpoint_offset should be returned. |
| 4463 // 2. The selection endpoint is a pure descendant of this object. The offset | 4539 // 2. The selection endpoint is a pure descendant of this object. The offset |
| 4464 // of the character corresponding to the subtree in which the endpoint is | 4540 // of the character corresponding to the subtree in which the endpoint is |
| 4465 // located should be returned. | 4541 // located should be returned. |
| 4466 // 3. The selection endpoint is in a completely different part of the tree. | 4542 // 3. The selection endpoint is in a completely different part of the tree. |
| 4467 // Either 0 or text_length should be returned depending on the direction that | 4543 // Either 0 or text_length should be returned depending on the direction that |
| 4468 // one needs to travel to find the endpoint. | 4544 // one needs to travel to find the endpoint. |
| 4469 | 4545 |
| 4470 // Case 1. | 4546 // Case 1. |
| 4471 // | 4547 // |
| 4472 // IsDescendantOf includes the case when endpoint_object == this. | 4548 // IsDescendantOf includes the case when endpoint_object == this. |
| 4473 if (IsDescendantOf(&endpoint_object)) | 4549 if (GetOwner()->IsDescendantOf(endpoint_object.GetOwner())) |
| 4474 return endpoint_offset; | 4550 return endpoint_offset; |
| 4475 | 4551 |
| 4476 const BrowserAccessibility* common_parent = this; | 4552 const BrowserAccessibility* common_parent = GetOwner(); |
| 4477 int32_t index_in_common_parent = GetIndexInParent(); | 4553 int32_t index_in_common_parent = GetOwner()->GetIndexInParent(); |
| 4478 while (common_parent && !endpoint_object.IsDescendantOf(common_parent)) { | 4554 while (common_parent && |
| 4555 !endpoint_object.GetOwner()->IsDescendantOf(common_parent)) { | |
| 4479 index_in_common_parent = common_parent->GetIndexInParent(); | 4556 index_in_common_parent = common_parent->GetIndexInParent(); |
| 4480 common_parent = common_parent->PlatformGetParent(); | 4557 common_parent = common_parent->PlatformGetParent(); |
| 4481 } | 4558 } |
| 4482 if (!common_parent) | 4559 if (!common_parent) |
| 4483 return -1; | 4560 return -1; |
| 4484 | 4561 |
| 4485 DCHECK_GE(index_in_common_parent, 0); | 4562 DCHECK_GE(index_in_common_parent, 0); |
| 4486 DCHECK(!(common_parent->IsTextOnlyObject())); | 4563 DCHECK(!(common_parent->IsTextOnlyObject())); |
| 4487 | 4564 |
| 4488 // Case 2. | 4565 // Case 2. |
| 4489 // | 4566 // |
| 4490 // We already checked in case 1 if our endpoint is inside this object. | 4567 // We already checked in case 1 if our endpoint is inside this object. |
| 4491 // We can safely assume that it is a descendant or in a completely different | 4568 // We can safely assume that it is a descendant or in a completely different |
| 4492 // part of the tree. | 4569 // part of the tree. |
| 4493 if (common_parent == this) { | 4570 if (common_parent == GetOwner()) { |
| 4494 int32_t hypertext_offset = | 4571 int32_t hypertext_offset = |
| 4495 GetHypertextOffsetFromDescendant(endpoint_object); | 4572 GetHypertextOffsetFromDescendant(endpoint_object); |
| 4496 if (endpoint_object.PlatformGetParent() == this && | 4573 if (endpoint_object.GetOwner()->PlatformGetParent() == GetOwner() && |
| 4497 endpoint_object.IsTextOnlyObject()) { | 4574 endpoint_object.GetOwner()->IsTextOnlyObject()) { |
| 4498 hypertext_offset += endpoint_offset; | 4575 hypertext_offset += endpoint_offset; |
| 4499 } | 4576 } |
| 4500 | 4577 |
| 4501 return hypertext_offset; | 4578 return hypertext_offset; |
| 4502 } | 4579 } |
| 4503 | 4580 |
| 4504 // Case 3. | 4581 // Case 3. |
| 4505 // | 4582 // |
| 4506 // We can safely assume that the endpoint is in another part of the tree or | 4583 // We can safely assume that the endpoint is in another part of the tree or |
| 4507 // at common parent, and that this object is a descendant of common parent. | 4584 // at common parent, and that this object is a descendant of common parent. |
| 4508 int32_t endpoint_index_in_common_parent = -1; | 4585 int32_t endpoint_index_in_common_parent = -1; |
| 4509 for (uint32_t i = 0; i < common_parent->InternalChildCount(); ++i) { | 4586 for (uint32_t i = 0; i < common_parent->InternalChildCount(); ++i) { |
| 4510 const BrowserAccessibility* child = common_parent->InternalGetChild(i); | 4587 const BrowserAccessibility* child = common_parent->InternalGetChild(i); |
| 4511 DCHECK(child); | 4588 DCHECK(child); |
| 4512 if (endpoint_object.IsDescendantOf(child)) { | 4589 if (endpoint_object.GetOwner()->IsDescendantOf(child)) { |
| 4513 endpoint_index_in_common_parent = child->GetIndexInParent(); | 4590 endpoint_index_in_common_parent = child->GetIndexInParent(); |
| 4514 break; | 4591 break; |
| 4515 } | 4592 } |
| 4516 } | 4593 } |
| 4517 DCHECK_GE(endpoint_index_in_common_parent, 0); | 4594 DCHECK_GE(endpoint_index_in_common_parent, 0); |
| 4518 | 4595 |
| 4519 if (endpoint_index_in_common_parent < index_in_common_parent) | 4596 if (endpoint_index_in_common_parent < index_in_common_parent) |
| 4520 return 0; | 4597 return 0; |
| 4521 if (endpoint_index_in_common_parent > index_in_common_parent) | 4598 if (endpoint_index_in_common_parent > index_in_common_parent) |
| 4522 return GetText().size(); | 4599 return GetOwner()->GetText().size(); |
| 4523 | 4600 |
| 4524 NOTREACHED(); | 4601 NOTREACHED(); |
| 4525 return -1; | 4602 return -1; |
| 4526 } | 4603 } |
| 4527 | 4604 |
| 4528 int BrowserAccessibilityWin::GetSelectionAnchor() const { | 4605 int BrowserAccessibilityComWin::GetSelectionAnchor() const { |
| 4529 int32_t anchor_id = manager_->GetTreeData().sel_anchor_object_id; | 4606 int32_t anchor_id = GetOwner()->manager()->GetTreeData().sel_anchor_object_id; |
| 4530 const BrowserAccessibilityWin* anchor_object = GetFromID(anchor_id); | 4607 const BrowserAccessibilityComWin* anchor_object = GetFromID(anchor_id); |
| 4531 if (!anchor_object) | 4608 if (!anchor_object) |
| 4532 return -1; | 4609 return -1; |
| 4533 | 4610 |
| 4534 int anchor_offset = manager_->GetTreeData().sel_anchor_offset; | 4611 int anchor_offset = GetOwner()->manager()->GetTreeData().sel_anchor_offset; |
| 4535 return GetHypertextOffsetFromEndpoint(*anchor_object, anchor_offset); | 4612 return GetHypertextOffsetFromEndpoint(*anchor_object, anchor_offset); |
| 4536 } | 4613 } |
| 4537 | 4614 |
| 4538 int BrowserAccessibilityWin::GetSelectionFocus() const { | 4615 int BrowserAccessibilityComWin::GetSelectionFocus() const { |
| 4539 int32_t focus_id = manager_->GetTreeData().sel_focus_object_id; | 4616 int32_t focus_id = GetOwner()->manager()->GetTreeData().sel_focus_object_id; |
| 4540 const BrowserAccessibilityWin* focus_object = GetFromID(focus_id); | 4617 const BrowserAccessibilityComWin* focus_object = GetFromID(focus_id); |
| 4541 if (!focus_object) | 4618 if (!focus_object) |
| 4542 return -1; | 4619 return -1; |
| 4543 | 4620 |
| 4544 int focus_offset = manager_->GetTreeData().sel_focus_offset; | 4621 int focus_offset = GetOwner()->manager()->GetTreeData().sel_focus_offset; |
| 4545 return GetHypertextOffsetFromEndpoint(*focus_object, focus_offset); | 4622 return GetHypertextOffsetFromEndpoint(*focus_object, focus_offset); |
| 4546 } | 4623 } |
| 4547 | 4624 |
| 4548 void BrowserAccessibilityWin::GetSelectionOffsets( | 4625 void BrowserAccessibilityComWin::GetSelectionOffsets(int* selection_start, |
| 4549 int* selection_start, int* selection_end) const { | 4626 int* selection_end) const { |
| 4550 DCHECK(selection_start && selection_end); | 4627 DCHECK(selection_start && selection_end); |
| 4551 | 4628 |
| 4552 if (IsSimpleTextControl() && | 4629 if (GetOwner()->IsSimpleTextControl() && |
| 4553 GetIntAttribute(ui::AX_ATTR_TEXT_SEL_START, selection_start) && | 4630 GetOwner()->GetIntAttribute(ui::AX_ATTR_TEXT_SEL_START, |
| 4554 GetIntAttribute(ui::AX_ATTR_TEXT_SEL_END, selection_end)) { | 4631 selection_start) && |
| 4632 GetOwner()->GetIntAttribute(ui::AX_ATTR_TEXT_SEL_END, selection_end)) { | |
| 4555 return; | 4633 return; |
| 4556 } | 4634 } |
| 4557 | 4635 |
| 4558 *selection_start = GetSelectionAnchor(); | 4636 *selection_start = GetSelectionAnchor(); |
| 4559 *selection_end = GetSelectionFocus(); | 4637 *selection_end = GetSelectionFocus(); |
| 4560 if (*selection_start < 0 || *selection_end < 0) | 4638 if (*selection_start < 0 || *selection_end < 0) |
| 4561 return; | 4639 return; |
| 4562 | 4640 |
| 4563 // There are three cases when a selection would start and end on the same | 4641 // There are three cases when a selection would start and end on the same |
| 4564 // character: | 4642 // character: |
| 4565 // 1. Anchor and focus are both in a subtree that is to the right of this | 4643 // 1. Anchor and focus are both in a subtree that is to the right of this |
| 4566 // object. | 4644 // object. |
| 4567 // 2. Anchor and focus are both in a subtree that is to the left of this | 4645 // 2. Anchor and focus are both in a subtree that is to the left of this |
| 4568 // object. | 4646 // object. |
| 4569 // 3. Anchor and focus are in a subtree represented by a single embedded | 4647 // 3. Anchor and focus are in a subtree represented by a single embedded |
| 4570 // object character. | 4648 // object character. |
| 4571 // Only case 3 refers to a valid selection because cases 1 and 2 fall | 4649 // Only case 3 refers to a valid selection because cases 1 and 2 fall |
| 4572 // outside this object in their entirety. | 4650 // outside this object in their entirety. |
| 4573 // Selections that span more than one character are by definition inside this | 4651 // Selections that span more than one character are by definition inside this |
| 4574 // object, so checking them is not necessary. | 4652 // object, so checking them is not necessary. |
| 4575 if (*selection_start == *selection_end && !HasCaret()) { | 4653 if (*selection_start == *selection_end && !GetOwner()->HasCaret()) { |
| 4576 *selection_start = -1; | 4654 *selection_start = -1; |
| 4577 *selection_end = -1; | 4655 *selection_end = -1; |
| 4578 return; | 4656 return; |
| 4579 } | 4657 } |
| 4580 | 4658 |
| 4581 // The IA2 Spec says that if the largest of the two offsets falls on an | 4659 // The IA2 Spec says that if the largest of the two offsets falls on an |
| 4582 // embedded object character and if there is a selection in that embedded | 4660 // embedded object character and if there is a selection in that embedded |
| 4583 // object, it should be incremented by one so that it points after the | 4661 // object, it should be incremented by one so that it points after the |
| 4584 // embedded object character. | 4662 // embedded object character. |
| 4585 // This is a signal to AT software that the embedded object is also part of | 4663 // This is a signal to AT software that the embedded object is also part of |
| 4586 // the selection. | 4664 // the selection. |
| 4587 int* largest_offset = | 4665 int* largest_offset = |
| 4588 (*selection_start <= *selection_end) ? selection_end : selection_start; | 4666 (*selection_start <= *selection_end) ? selection_end : selection_start; |
| 4589 BrowserAccessibilityWin* hyperlink = | 4667 BrowserAccessibilityComWin* hyperlink = |
| 4590 GetHyperlinkFromHypertextOffset(*largest_offset); | 4668 GetHyperlinkFromHypertextOffset(*largest_offset); |
| 4591 if (!hyperlink) | 4669 if (!hyperlink) |
| 4592 return; | 4670 return; |
| 4593 | 4671 |
| 4594 LONG n_selections = 0; | 4672 LONG n_selections = 0; |
| 4595 HRESULT hr = hyperlink->get_nSelections(&n_selections); | 4673 HRESULT hr = hyperlink->get_nSelections(&n_selections); |
| 4596 DCHECK(SUCCEEDED(hr)); | 4674 DCHECK(SUCCEEDED(hr)); |
| 4597 if (n_selections > 0) | 4675 if (n_selections > 0) |
| 4598 ++(*largest_offset); | 4676 ++(*largest_offset); |
| 4599 } | 4677 } |
| 4600 | 4678 |
| 4601 base::string16 BrowserAccessibilityWin::GetValueText() { | 4679 base::string16 BrowserAccessibilityComWin::GetValueText() { |
| 4602 float fval; | 4680 float fval; |
| 4603 base::string16 value = this->value(); | 4681 base::string16 result = value(); |
| 4604 | 4682 |
| 4605 if (value.empty() && | 4683 if (result.empty() && GetFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE, &fval)) { |
| 4606 GetFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE, &fval)) { | 4684 result = base::UTF8ToUTF16(base::DoubleToString(fval)); |
| 4607 value = base::UTF8ToUTF16(base::DoubleToString(fval)); | |
| 4608 } | 4685 } |
| 4609 return value; | 4686 return result; |
| 4610 } | 4687 } |
| 4611 | 4688 |
| 4612 bool BrowserAccessibilityWin::IsSameHypertextCharacter(size_t old_char_index, | 4689 bool BrowserAccessibilityComWin::IsSameHypertextCharacter( |
| 4613 size_t new_char_index) { | 4690 size_t old_char_index, |
| 4691 size_t new_char_index) { | |
| 4614 CHECK(old_win_attributes_); | 4692 CHECK(old_win_attributes_); |
| 4615 | 4693 |
| 4616 // For anything other than the "embedded character", we just compare the | 4694 // For anything other than the "embedded character", we just compare the |
| 4617 // characters directly. | 4695 // characters directly. |
| 4618 base::char16 old_ch = old_win_attributes_->hypertext[old_char_index]; | 4696 base::char16 old_ch = old_win_attributes_->hypertext[old_char_index]; |
| 4619 base::char16 new_ch = win_attributes_->hypertext[new_char_index]; | 4697 base::char16 new_ch = win_attributes_->hypertext[new_char_index]; |
| 4620 if (old_ch != new_ch) | 4698 if (old_ch != new_ch) |
| 4621 return false; | 4699 return false; |
| 4622 if (old_ch == new_ch && new_ch != kEmbeddedCharacter) | 4700 if (old_ch == new_ch && new_ch != kEmbeddedCharacter) |
| 4623 return true; | 4701 return true; |
| 4624 | 4702 |
| 4625 // If it's an embedded character, they're only identical if the child id | 4703 // If it's an embedded character, they're only identical if the child id |
| 4626 // the hyperlink points to is the same. | 4704 // the hyperlink points to is the same. |
| 4627 std::map<int32_t, int32_t>& old_offset_to_index = | 4705 std::map<int32_t, int32_t>& old_offset_to_index = |
| 4628 old_win_attributes_->hyperlink_offset_to_index; | 4706 old_win_attributes_->hyperlink_offset_to_index; |
| 4629 std::vector<int32_t>& old_hyperlinks = old_win_attributes_->hyperlinks; | 4707 std::vector<int32_t>& old_hyperlinks = old_win_attributes_->hyperlinks; |
| 4630 int32_t old_hyperlinks_count = static_cast<int32_t>(old_hyperlinks.size()); | 4708 int32_t old_hyperlinks_count = static_cast<int32_t>(old_hyperlinks.size()); |
| 4631 std::map<int32_t, int32_t>::iterator iter; | 4709 std::map<int32_t, int32_t>::iterator iter; |
| 4632 iter = old_offset_to_index.find(old_char_index); | 4710 iter = old_offset_to_index.find(old_char_index); |
| 4633 int old_index = (iter != old_offset_to_index.end()) ? iter->second : -1; | 4711 int old_index = (iter != old_offset_to_index.end()) ? iter->second : -1; |
| 4634 int old_child_id = (old_index >= 0 && old_index < old_hyperlinks_count) ? | 4712 int old_child_id = (old_index >= 0 && old_index < old_hyperlinks_count) |
| 4635 old_hyperlinks[old_index] : -1; | 4713 ? old_hyperlinks[old_index] |
| 4714 : -1; | |
| 4636 | 4715 |
| 4637 std::map<int32_t, int32_t>& new_offset_to_index = | 4716 std::map<int32_t, int32_t>& new_offset_to_index = |
| 4638 win_attributes_->hyperlink_offset_to_index; | 4717 win_attributes_->hyperlink_offset_to_index; |
| 4639 std::vector<int32_t>& new_hyperlinks = win_attributes_->hyperlinks; | 4718 std::vector<int32_t>& new_hyperlinks = win_attributes_->hyperlinks; |
| 4640 int32_t new_hyperlinks_count = static_cast<int32_t>(new_hyperlinks.size()); | 4719 int32_t new_hyperlinks_count = static_cast<int32_t>(new_hyperlinks.size()); |
| 4641 iter = new_offset_to_index.find(new_char_index); | 4720 iter = new_offset_to_index.find(new_char_index); |
| 4642 int new_index = (iter != new_offset_to_index.end()) ? iter->second : -1; | 4721 int new_index = (iter != new_offset_to_index.end()) ? iter->second : -1; |
| 4643 int new_child_id = (new_index >= 0 && new_index < new_hyperlinks_count) ? | 4722 int new_child_id = (new_index >= 0 && new_index < new_hyperlinks_count) |
| 4644 new_hyperlinks[new_index] : -1; | 4723 ? new_hyperlinks[new_index] |
| 4724 : -1; | |
| 4645 | 4725 |
| 4646 return old_child_id == new_child_id; | 4726 return old_child_id == new_child_id; |
| 4647 } | 4727 } |
| 4648 | 4728 |
| 4649 void BrowserAccessibilityWin::ComputeHypertextRemovedAndInserted( | 4729 void BrowserAccessibilityComWin::ComputeHypertextRemovedAndInserted( |
| 4650 int* start, int* old_len, int* new_len) { | 4730 int* start, |
| 4731 int* old_len, | |
| 4732 int* new_len) { | |
| 4651 CHECK(old_win_attributes_); | 4733 CHECK(old_win_attributes_); |
| 4652 | 4734 |
| 4653 *start = 0; | 4735 *start = 0; |
| 4654 *old_len = 0; | 4736 *old_len = 0; |
| 4655 *new_len = 0; | 4737 *new_len = 0; |
| 4656 | 4738 |
| 4657 const base::string16& old_text = old_win_attributes_->hypertext; | 4739 const base::string16& old_text = old_win_attributes_->hypertext; |
| 4658 const base::string16& new_text = GetText(); | 4740 const base::string16& new_text = GetOwner()->GetText(); |
| 4659 | 4741 |
| 4660 size_t common_prefix = 0; | 4742 size_t common_prefix = 0; |
| 4661 while (common_prefix < old_text.size() && | 4743 while (common_prefix < old_text.size() && common_prefix < new_text.size() && |
| 4662 common_prefix < new_text.size() && | |
| 4663 IsSameHypertextCharacter(common_prefix, common_prefix)) { | 4744 IsSameHypertextCharacter(common_prefix, common_prefix)) { |
| 4664 ++common_prefix; | 4745 ++common_prefix; |
| 4665 } | 4746 } |
| 4666 | 4747 |
| 4667 size_t common_suffix = 0; | 4748 size_t common_suffix = 0; |
| 4668 while (common_prefix + common_suffix < old_text.size() && | 4749 while (common_prefix + common_suffix < old_text.size() && |
| 4669 common_prefix + common_suffix < new_text.size() && | 4750 common_prefix + common_suffix < new_text.size() && |
| 4670 IsSameHypertextCharacter( | 4751 IsSameHypertextCharacter(old_text.size() - common_suffix - 1, |
| 4671 old_text.size() - common_suffix - 1, | 4752 new_text.size() - common_suffix - 1)) { |
| 4672 new_text.size() - common_suffix - 1)) { | |
| 4673 ++common_suffix; | 4753 ++common_suffix; |
| 4674 } | 4754 } |
| 4675 | 4755 |
| 4676 *start = common_prefix; | 4756 *start = common_prefix; |
| 4677 *old_len = old_text.size() - common_prefix - common_suffix; | 4757 *old_len = old_text.size() - common_prefix - common_suffix; |
| 4678 *new_len = new_text.size() - common_prefix - common_suffix; | 4758 *new_len = new_text.size() - common_prefix - common_suffix; |
| 4679 } | 4759 } |
| 4680 | 4760 |
| 4681 void BrowserAccessibilityWin::HandleSpecialTextOffset(LONG* offset) { | 4761 void BrowserAccessibilityComWin::HandleSpecialTextOffset(LONG* offset) { |
| 4682 if (*offset == IA2_TEXT_OFFSET_LENGTH) { | 4762 if (*offset == IA2_TEXT_OFFSET_LENGTH) { |
| 4683 *offset = static_cast<LONG>(GetText().length()); | 4763 *offset = static_cast<LONG>(GetOwner()->GetText().length()); |
| 4684 } else if (*offset == IA2_TEXT_OFFSET_CARET) { | 4764 } else if (*offset == IA2_TEXT_OFFSET_CARET) { |
| 4685 // We shouldn't call |get_caretOffset| here as it affects UMA counts. | 4765 // We shouldn't call |get_caretOffset| here as it affects UMA counts. |
| 4686 int selection_start, selection_end; | 4766 int selection_start, selection_end; |
| 4687 GetSelectionOffsets(&selection_start, &selection_end); | 4767 GetSelectionOffsets(&selection_start, &selection_end); |
| 4688 *offset = selection_end; | 4768 *offset = selection_end; |
| 4689 } | 4769 } |
| 4690 } | 4770 } |
| 4691 | 4771 |
| 4692 ui::TextBoundaryType BrowserAccessibilityWin::IA2TextBoundaryToTextBoundary( | 4772 ui::TextBoundaryType BrowserAccessibilityComWin::IA2TextBoundaryToTextBoundary( |
| 4693 IA2TextBoundaryType ia2_boundary) { | 4773 IA2TextBoundaryType ia2_boundary) { |
| 4694 switch(ia2_boundary) { | 4774 switch (ia2_boundary) { |
| 4695 case IA2_TEXT_BOUNDARY_CHAR: | 4775 case IA2_TEXT_BOUNDARY_CHAR: |
| 4696 return ui::CHAR_BOUNDARY; | 4776 return ui::CHAR_BOUNDARY; |
| 4697 case IA2_TEXT_BOUNDARY_WORD: | 4777 case IA2_TEXT_BOUNDARY_WORD: |
| 4698 return ui::WORD_BOUNDARY; | 4778 return ui::WORD_BOUNDARY; |
| 4699 case IA2_TEXT_BOUNDARY_LINE: | 4779 case IA2_TEXT_BOUNDARY_LINE: |
| 4700 return ui::LINE_BOUNDARY; | 4780 return ui::LINE_BOUNDARY; |
| 4701 case IA2_TEXT_BOUNDARY_SENTENCE: | 4781 case IA2_TEXT_BOUNDARY_SENTENCE: |
| 4702 return ui::SENTENCE_BOUNDARY; | 4782 return ui::SENTENCE_BOUNDARY; |
| 4703 case IA2_TEXT_BOUNDARY_PARAGRAPH: | 4783 case IA2_TEXT_BOUNDARY_PARAGRAPH: |
| 4704 return ui::PARAGRAPH_BOUNDARY; | 4784 return ui::PARAGRAPH_BOUNDARY; |
| 4705 case IA2_TEXT_BOUNDARY_ALL: | 4785 case IA2_TEXT_BOUNDARY_ALL: |
| 4706 return ui::ALL_BOUNDARY; | 4786 return ui::ALL_BOUNDARY; |
| 4707 } | 4787 } |
| 4708 NOTREACHED(); | 4788 NOTREACHED(); |
| 4709 return ui::CHAR_BOUNDARY; | 4789 return ui::CHAR_BOUNDARY; |
| 4710 } | 4790 } |
| 4711 | 4791 |
| 4712 LONG BrowserAccessibilityWin::FindBoundary( | 4792 LONG BrowserAccessibilityComWin::FindBoundary( |
| 4713 const base::string16& text, | 4793 const base::string16& text, |
| 4714 IA2TextBoundaryType ia2_boundary, | 4794 IA2TextBoundaryType ia2_boundary, |
| 4715 LONG start_offset, | 4795 LONG start_offset, |
| 4716 ui::TextBoundaryDirection direction) { | 4796 ui::TextBoundaryDirection direction) { |
| 4717 // If the boundary is relative to the caret, use the selection | 4797 // If the boundary is relative to the caret, use the selection |
| 4718 // affinity, otherwise default to downstream affinity. | 4798 // affinity, otherwise default to downstream affinity. |
| 4719 ui::AXTextAffinity affinity = start_offset == IA2_TEXT_OFFSET_CARET | 4799 ui::AXTextAffinity affinity = |
| 4720 ? manager_->GetTreeData().sel_focus_affinity | 4800 start_offset == IA2_TEXT_OFFSET_CARET |
| 4721 : ui::AX_TEXT_AFFINITY_DOWNSTREAM; | 4801 ? GetOwner()->manager()->GetTreeData().sel_focus_affinity |
| 4802 : ui::AX_TEXT_AFFINITY_DOWNSTREAM; | |
| 4722 | 4803 |
| 4723 HandleSpecialTextOffset(&start_offset); | 4804 HandleSpecialTextOffset(&start_offset); |
| 4724 if (ia2_boundary == IA2_TEXT_BOUNDARY_WORD) { | 4805 if (ia2_boundary == IA2_TEXT_BOUNDARY_WORD) { |
| 4725 switch (direction) { | 4806 switch (direction) { |
| 4726 case ui::FORWARDS_DIRECTION: { | 4807 case ui::FORWARDS_DIRECTION: { |
| 4727 AXPlatformPositionInstance position = | 4808 AXPlatformPositionInstance position = GetOwner()->CreatePositionAt( |
| 4728 CreatePositionAt(static_cast<int>(start_offset), affinity); | 4809 static_cast<int>(start_offset), affinity); |
| 4729 AXPlatformPositionInstance next_word = | 4810 AXPlatformPositionInstance next_word = |
| 4730 position->CreateNextWordStartPosition(); | 4811 position->CreateNextWordStartPosition(); |
| 4731 if (next_word->anchor_id() != GetId()) | 4812 if (next_word->anchor_id() != GetOwner()->GetId()) |
| 4732 next_word = position->CreatePositionAtEndOfAnchor(); | 4813 next_word = position->CreatePositionAtEndOfAnchor(); |
| 4733 return next_word->text_offset(); | 4814 return next_word->text_offset(); |
| 4734 } | 4815 } |
| 4735 case ui::BACKWARDS_DIRECTION: { | 4816 case ui::BACKWARDS_DIRECTION: { |
| 4736 AXPlatformPositionInstance position = | 4817 AXPlatformPositionInstance position = GetOwner()->CreatePositionAt( |
| 4737 CreatePositionAt(static_cast<int>(start_offset), affinity); | 4818 static_cast<int>(start_offset), affinity); |
| 4738 AXPlatformPositionInstance previous_word; | 4819 AXPlatformPositionInstance previous_word; |
| 4739 if (!position->AtStartOfWord()) { | 4820 if (!position->AtStartOfWord()) { |
| 4740 previous_word = position->CreatePreviousWordStartPosition(); | 4821 previous_word = position->CreatePreviousWordStartPosition(); |
| 4741 if (previous_word->anchor_id() != GetId()) | 4822 if (previous_word->anchor_id() != GetOwner()->GetId()) |
| 4742 previous_word = position->CreatePositionAtStartOfAnchor(); | 4823 previous_word = position->CreatePositionAtStartOfAnchor(); |
| 4743 } else { | 4824 } else { |
| 4744 previous_word = std::move(position); | 4825 previous_word = std::move(position); |
| 4745 } | 4826 } |
| 4746 return previous_word->text_offset(); | 4827 return previous_word->text_offset(); |
| 4747 } | 4828 } |
| 4748 } | 4829 } |
| 4749 } | 4830 } |
| 4750 | 4831 |
| 4751 if (ia2_boundary == IA2_TEXT_BOUNDARY_LINE) { | 4832 if (ia2_boundary == IA2_TEXT_BOUNDARY_LINE) { |
| 4752 switch (direction) { | 4833 switch (direction) { |
| 4753 case ui::FORWARDS_DIRECTION: { | 4834 case ui::FORWARDS_DIRECTION: { |
| 4754 AXPlatformPositionInstance position = | 4835 AXPlatformPositionInstance position = GetOwner()->CreatePositionAt( |
| 4755 CreatePositionAt(static_cast<int>(start_offset), affinity); | 4836 static_cast<int>(start_offset), affinity); |
| 4756 AXPlatformPositionInstance next_line = | 4837 AXPlatformPositionInstance next_line = |
| 4757 position->CreateNextLineStartPosition(); | 4838 position->CreateNextLineStartPosition(); |
| 4758 if (next_line->anchor_id() != GetId()) | 4839 if (next_line->anchor_id() != GetOwner()->GetId()) |
| 4759 next_line = position->CreatePositionAtEndOfAnchor(); | 4840 next_line = position->CreatePositionAtEndOfAnchor(); |
| 4760 return next_line->text_offset(); | 4841 return next_line->text_offset(); |
| 4761 } | 4842 } |
| 4762 case ui::BACKWARDS_DIRECTION: { | 4843 case ui::BACKWARDS_DIRECTION: { |
| 4763 AXPlatformPositionInstance position = | 4844 AXPlatformPositionInstance position = GetOwner()->CreatePositionAt( |
| 4764 CreatePositionAt(static_cast<int>(start_offset), affinity); | 4845 static_cast<int>(start_offset), affinity); |
| 4765 AXPlatformPositionInstance previous_line; | 4846 AXPlatformPositionInstance previous_line; |
| 4766 if (!position->AtStartOfLine()) { | 4847 if (!position->AtStartOfLine()) { |
| 4767 previous_line = position->CreatePreviousLineStartPosition(); | 4848 previous_line = position->CreatePreviousLineStartPosition(); |
| 4768 if (previous_line->anchor_id() != GetId()) | 4849 if (previous_line->anchor_id() != GetOwner()->GetId()) |
| 4769 previous_line = position->CreatePositionAtStartOfAnchor(); | 4850 previous_line = position->CreatePositionAtStartOfAnchor(); |
| 4770 } else { | 4851 } else { |
| 4771 previous_line = std::move(position); | 4852 previous_line = std::move(position); |
| 4772 } | 4853 } |
| 4773 return previous_line->text_offset(); | 4854 return previous_line->text_offset(); |
| 4774 } | 4855 } |
| 4775 } | 4856 } |
| 4776 } | 4857 } |
| 4777 | 4858 |
| 4778 // TODO(nektar): |AXPosition| can handle other types of boundaries as well. | 4859 // TODO(nektar): |AXPosition| can handle other types of boundaries as well. |
| 4779 ui::TextBoundaryType boundary = IA2TextBoundaryToTextBoundary(ia2_boundary); | 4860 ui::TextBoundaryType boundary = IA2TextBoundaryToTextBoundary(ia2_boundary); |
| 4780 return ui::FindAccessibleTextBoundary(text, GetLineStartOffsets(), boundary, | 4861 return ui::FindAccessibleTextBoundary(text, GetOwner()->GetLineStartOffsets(), |
| 4781 start_offset, direction, affinity); | 4862 boundary, start_offset, direction, |
| 4863 affinity); | |
| 4782 } | 4864 } |
| 4783 | 4865 |
| 4784 LONG BrowserAccessibilityWin::FindStartOfStyle( | 4866 LONG BrowserAccessibilityComWin::FindStartOfStyle( |
| 4785 LONG start_offset, | 4867 LONG start_offset, |
| 4786 ui::TextBoundaryDirection direction) const { | 4868 ui::TextBoundaryDirection direction) const { |
| 4787 LONG text_length = static_cast<LONG>(GetText().length()); | 4869 LONG text_length = static_cast<LONG>(GetOwner()->GetText().length()); |
| 4788 DCHECK_GE(start_offset, 0); | 4870 DCHECK_GE(start_offset, 0); |
| 4789 DCHECK_LE(start_offset, text_length); | 4871 DCHECK_LE(start_offset, text_length); |
| 4790 | 4872 |
| 4791 switch (direction) { | 4873 switch (direction) { |
| 4792 case ui::BACKWARDS_DIRECTION: { | 4874 case ui::BACKWARDS_DIRECTION: { |
| 4793 if (offset_to_text_attributes().empty()) | 4875 if (offset_to_text_attributes().empty()) |
| 4794 return 0; | 4876 return 0; |
| 4795 | 4877 |
| 4796 auto iterator = offset_to_text_attributes().upper_bound(start_offset); | 4878 auto iterator = offset_to_text_attributes().upper_bound(start_offset); |
| 4797 --iterator; | 4879 --iterator; |
| 4798 return static_cast<LONG>(iterator->first); | 4880 return static_cast<LONG>(iterator->first); |
| 4799 } | 4881 } |
| 4800 case ui::FORWARDS_DIRECTION: { | 4882 case ui::FORWARDS_DIRECTION: { |
| 4801 const auto iterator = | 4883 const auto iterator = |
| 4802 offset_to_text_attributes().upper_bound(start_offset); | 4884 offset_to_text_attributes().upper_bound(start_offset); |
| 4803 if (iterator == offset_to_text_attributes().end()) | 4885 if (iterator == offset_to_text_attributes().end()) |
| 4804 return text_length; | 4886 return text_length; |
| 4805 return static_cast<LONG>(iterator->first); | 4887 return static_cast<LONG>(iterator->first); |
| 4806 } | 4888 } |
| 4807 } | 4889 } |
| 4808 | 4890 |
| 4809 NOTREACHED(); | 4891 NOTREACHED(); |
| 4810 return start_offset; | 4892 return start_offset; |
| 4811 } | 4893 } |
| 4812 | 4894 |
| 4813 BrowserAccessibilityWin* BrowserAccessibilityWin::GetFromID(int32_t id) const { | 4895 BrowserAccessibilityComWin* BrowserAccessibilityComWin::GetFromID( |
| 4814 if (!instance_active()) | 4896 int32_t id) const { |
| 4897 if (!GetOwner() || !GetOwner()->instance_active()) | |
| 4815 return nullptr; | 4898 return nullptr; |
| 4816 return ToBrowserAccessibilityWin(manager_->GetFromID(id)); | 4899 return ToBrowserAccessibilityComWin(GetOwner()->manager()->GetFromID(id)); |
| 4817 } | 4900 } |
| 4818 | 4901 |
| 4819 bool BrowserAccessibilityWin::IsListBoxOptionOrMenuListOption() { | 4902 bool BrowserAccessibilityComWin::IsListBoxOptionOrMenuListOption() { |
| 4820 if (!PlatformGetParent()) | 4903 if (!GetOwner()->PlatformGetParent()) |
| 4821 return false; | 4904 return false; |
| 4822 | 4905 |
| 4823 int32_t role = GetRole(); | 4906 int32_t role = GetOwner()->GetRole(); |
| 4824 int32_t parent_role = PlatformGetParent()->GetRole(); | 4907 int32_t parent_role = GetOwner()->PlatformGetParent()->GetRole(); |
| 4825 | 4908 |
| 4826 if (role == ui::AX_ROLE_LIST_BOX_OPTION && | 4909 if (role == ui::AX_ROLE_LIST_BOX_OPTION && |
| 4827 parent_role == ui::AX_ROLE_LIST_BOX) { | 4910 parent_role == ui::AX_ROLE_LIST_BOX) { |
| 4828 return true; | 4911 return true; |
| 4829 } | 4912 } |
| 4830 | 4913 |
| 4831 if (role == ui::AX_ROLE_MENU_LIST_OPTION && | 4914 if (role == ui::AX_ROLE_MENU_LIST_OPTION && |
| 4832 parent_role == ui::AX_ROLE_MENU_LIST_POPUP) { | 4915 parent_role == ui::AX_ROLE_MENU_LIST_POPUP) { |
| 4833 return true; | 4916 return true; |
| 4834 } | 4917 } |
| 4835 | 4918 |
| 4836 return false; | 4919 return false; |
| 4837 } | 4920 } |
| 4838 | 4921 |
| 4839 void BrowserAccessibilityWin::AddRelation(const base::string16& relation_type, | 4922 void BrowserAccessibilityComWin::AddRelation( |
| 4840 int target_id) { | 4923 const base::string16& relation_type, |
| 4924 int target_id) { | |
| 4841 // Reflexive relations don't need to be exposed through IA2. | 4925 // Reflexive relations don't need to be exposed through IA2. |
| 4842 if (target_id == GetId()) | 4926 if (target_id == GetOwner()->GetId()) |
| 4843 return; | 4927 return; |
| 4844 | 4928 |
| 4845 CComObject<BrowserAccessibilityRelation>* relation; | 4929 CComObject<BrowserAccessibilityRelation>* relation; |
| 4846 HRESULT hr = | 4930 HRESULT hr = |
| 4847 CComObject<BrowserAccessibilityRelation>::CreateInstance(&relation); | 4931 CComObject<BrowserAccessibilityRelation>::CreateInstance(&relation); |
| 4848 DCHECK(SUCCEEDED(hr)); | 4932 DCHECK(SUCCEEDED(hr)); |
| 4849 relation->AddRef(); | 4933 relation->AddRef(); |
| 4850 relation->Initialize(this, relation_type); | 4934 relation->Initialize(this, relation_type); |
| 4851 relation->AddTarget(target_id); | 4935 relation->AddTarget(target_id); |
| 4852 relations_.push_back(relation); | 4936 relations_.push_back(relation); |
| 4853 } | 4937 } |
| 4854 | 4938 |
| 4855 void BrowserAccessibilityWin::AddBidirectionalRelations( | 4939 void BrowserAccessibilityComWin::AddBidirectionalRelations( |
| 4856 const base::string16& relation_type, | 4940 const base::string16& relation_type, |
| 4857 const base::string16& reverse_relation_type, | 4941 const base::string16& reverse_relation_type, |
| 4858 ui::AXIntListAttribute attribute) { | 4942 ui::AXIntListAttribute attribute) { |
| 4859 if (!HasIntListAttribute(attribute)) | 4943 if (!GetOwner()->HasIntListAttribute(attribute)) |
| 4860 return; | 4944 return; |
| 4861 | 4945 |
| 4862 const std::vector<int32_t>& target_ids = GetIntListAttribute(attribute); | 4946 const std::vector<int32_t>& target_ids = |
| 4947 GetOwner()->GetIntListAttribute(attribute); | |
| 4863 // Reflexive relations don't need to be exposed through IA2. | 4948 // Reflexive relations don't need to be exposed through IA2. |
| 4864 std::vector<int32_t> filtered_target_ids; | 4949 std::vector<int32_t> filtered_target_ids; |
| 4865 int32_t current_id = GetId(); | 4950 int32_t current_id = GetOwner()->GetId(); |
| 4866 std::copy_if(target_ids.begin(), target_ids.end(), | 4951 std::copy_if(target_ids.begin(), target_ids.end(), |
| 4867 std::back_inserter(filtered_target_ids), | 4952 std::back_inserter(filtered_target_ids), |
| 4868 [current_id](int32_t id) { return id != current_id; }); | 4953 [current_id](int32_t id) { return id != current_id; }); |
| 4869 if (filtered_target_ids.empty()) | 4954 if (filtered_target_ids.empty()) |
| 4870 return; | 4955 return; |
| 4871 | 4956 |
| 4872 CComObject<BrowserAccessibilityRelation>* relation; | 4957 CComObject<BrowserAccessibilityRelation>* relation; |
| 4873 HRESULT hr = | 4958 HRESULT hr = |
| 4874 CComObject<BrowserAccessibilityRelation>::CreateInstance(&relation); | 4959 CComObject<BrowserAccessibilityRelation>::CreateInstance(&relation); |
| 4875 DCHECK(SUCCEEDED(hr)); | 4960 DCHECK(SUCCEEDED(hr)); |
| 4876 relation->AddRef(); | 4961 relation->AddRef(); |
| 4877 relation->Initialize(this, relation_type); | 4962 relation->Initialize(this, relation_type); |
| 4878 | 4963 |
| 4879 for (int target_id : filtered_target_ids) { | 4964 for (int target_id : filtered_target_ids) { |
| 4880 BrowserAccessibilityWin* target = | 4965 BrowserAccessibilityComWin* target = |
| 4881 GetFromID(static_cast<int32_t>(target_id)); | 4966 GetFromID(static_cast<int32_t>(target_id)); |
| 4882 if (!target || !target->instance_active()) | 4967 if (!target || !target->GetOwner()->instance_active()) |
| 4883 continue; | 4968 continue; |
| 4884 relation->AddTarget(target_id); | 4969 relation->AddTarget(target_id); |
| 4885 target->AddRelation(reverse_relation_type, GetId()); | 4970 target->AddRelation(reverse_relation_type, GetOwner()->GetId()); |
| 4886 } | 4971 } |
| 4887 | 4972 |
| 4888 relations_.push_back(relation); | 4973 relations_.push_back(relation); |
| 4889 } | 4974 } |
| 4890 | 4975 |
| 4891 // Clears all the forward relations from this object to any other object and the | 4976 // Clears all the forward relations from this object to any other object and the |
| 4892 // associated reverse relations on the other objects, but leaves any reverse | 4977 // associated reverse relations on the other objects, but leaves any reverse |
| 4893 // relations on this object alone. | 4978 // relations on this object alone. |
| 4894 void BrowserAccessibilityWin::ClearOwnRelations() { | 4979 void BrowserAccessibilityComWin::ClearOwnRelations() { |
| 4895 RemoveBidirectionalRelationsOfType(IA2_RELATION_CONTROLLER_FOR, | 4980 RemoveBidirectionalRelationsOfType(IA2_RELATION_CONTROLLER_FOR, |
| 4896 IA2_RELATION_CONTROLLED_BY); | 4981 IA2_RELATION_CONTROLLED_BY); |
| 4897 RemoveBidirectionalRelationsOfType(IA2_RELATION_DESCRIBED_BY, | 4982 RemoveBidirectionalRelationsOfType(IA2_RELATION_DESCRIBED_BY, |
| 4898 IA2_RELATION_DESCRIPTION_FOR); | 4983 IA2_RELATION_DESCRIPTION_FOR); |
| 4899 RemoveBidirectionalRelationsOfType(IA2_RELATION_FLOWS_TO, | 4984 RemoveBidirectionalRelationsOfType(IA2_RELATION_FLOWS_TO, |
| 4900 IA2_RELATION_FLOWS_FROM); | 4985 IA2_RELATION_FLOWS_FROM); |
| 4901 RemoveBidirectionalRelationsOfType(IA2_RELATION_LABELLED_BY, | 4986 RemoveBidirectionalRelationsOfType(IA2_RELATION_LABELLED_BY, |
| 4902 IA2_RELATION_LABEL_FOR); | 4987 IA2_RELATION_LABEL_FOR); |
| 4903 | 4988 |
| 4904 relations_.erase( | 4989 relations_.erase( |
| 4905 std::remove_if(relations_.begin(), relations_.end(), | 4990 std::remove_if(relations_.begin(), relations_.end(), |
| 4906 [](BrowserAccessibilityRelation* relation) { | 4991 [](BrowserAccessibilityRelation* relation) { |
| 4907 if (relation->get_type() == IA2_RELATION_MEMBER_OF) { | 4992 if (relation->get_type() == IA2_RELATION_MEMBER_OF) { |
| 4908 relation->Release(); | 4993 relation->Release(); |
| 4909 return true; | 4994 return true; |
| 4910 } | 4995 } |
| 4911 return false; | 4996 return false; |
| 4912 }), | 4997 }), |
| 4913 relations_.end()); | 4998 relations_.end()); |
| 4914 } | 4999 } |
| 4915 | 5000 |
| 4916 void BrowserAccessibilityWin::RemoveBidirectionalRelationsOfType( | 5001 void BrowserAccessibilityComWin::RemoveBidirectionalRelationsOfType( |
| 4917 const base::string16& relation_type, | 5002 const base::string16& relation_type, |
| 4918 const base::string16& reverse_relation_type) { | 5003 const base::string16& reverse_relation_type) { |
| 4919 for (auto iter = relations_.begin(); iter != relations_.end();) { | 5004 for (auto iter = relations_.begin(); iter != relations_.end();) { |
| 4920 BrowserAccessibilityRelation* relation = *iter; | 5005 BrowserAccessibilityRelation* relation = *iter; |
| 4921 DCHECK(relation); | 5006 DCHECK(relation); |
| 4922 if (relation->get_type() == relation_type) { | 5007 if (relation->get_type() == relation_type) { |
| 4923 for (int target_id : relation->get_target_ids()) { | 5008 for (int target_id : relation->get_target_ids()) { |
| 4924 BrowserAccessibilityWin* target = | 5009 BrowserAccessibilityComWin* target = |
| 4925 GetFromID(static_cast<int32_t>(target_id)); | 5010 GetFromID(static_cast<int32_t>(target_id)); |
| 4926 if (!target || !target->instance_active()) | 5011 if (!target || !target->GetOwner()->instance_active()) |
| 4927 continue; | 5012 continue; |
| 4928 DCHECK_NE(target, this); | 5013 DCHECK_NE(target, this); |
| 4929 target->RemoveTargetFromRelation(reverse_relation_type, GetId()); | 5014 target->RemoveTargetFromRelation(reverse_relation_type, |
| 5015 GetOwner()->GetId()); | |
| 4930 } | 5016 } |
| 4931 iter = relations_.erase(iter); | 5017 iter = relations_.erase(iter); |
| 4932 relation->Release(); | 5018 relation->Release(); |
| 4933 } else { | 5019 } else { |
| 4934 ++iter; | 5020 ++iter; |
| 4935 } | 5021 } |
| 4936 } | 5022 } |
| 4937 } | 5023 } |
| 4938 | 5024 |
| 4939 void BrowserAccessibilityWin::RemoveTargetFromRelation( | 5025 void BrowserAccessibilityComWin::RemoveTargetFromRelation( |
| 4940 const base::string16& relation_type, | 5026 const base::string16& relation_type, |
| 4941 int target_id) { | 5027 int target_id) { |
| 4942 for (auto iter = relations_.begin(); iter != relations_.end();) { | 5028 for (auto iter = relations_.begin(); iter != relations_.end();) { |
| 4943 BrowserAccessibilityRelation* relation = *iter; | 5029 BrowserAccessibilityRelation* relation = *iter; |
| 4944 DCHECK(relation); | 5030 DCHECK(relation); |
| 4945 if (relation->get_type() == relation_type) { | 5031 if (relation->get_type() == relation_type) { |
| 4946 // If |target_id| is not present, |RemoveTarget| will do nothing. | 5032 // If |target_id| is not present, |RemoveTarget| will do nothing. |
| 4947 relation->RemoveTarget(target_id); | 5033 relation->RemoveTarget(target_id); |
| 4948 } | 5034 } |
| 4949 if (relation->get_target_ids().empty()) { | 5035 if (relation->get_target_ids().empty()) { |
| 4950 iter = relations_.erase(iter); | 5036 iter = relations_.erase(iter); |
| 4951 relation->Release(); | 5037 relation->Release(); |
| 4952 } else { | 5038 } else { |
| 4953 ++iter; | 5039 ++iter; |
| 4954 } | 5040 } |
| 4955 } | 5041 } |
| 4956 } | 5042 } |
| 4957 | 5043 |
| 4958 void BrowserAccessibilityWin::UpdateRequiredAttributes() { | 5044 void BrowserAccessibilityComWin::UpdateRequiredAttributes() { |
| 4959 if (IsCellOrTableHeaderRole()) { | 5045 if (GetOwner()->IsCellOrTableHeaderRole()) { |
| 4960 // Expose colspan attribute. | 5046 // Expose colspan attribute. |
| 4961 base::string16 colspan; | 5047 base::string16 colspan; |
| 4962 if (GetHtmlAttribute("aria-colspan", &colspan)) { | 5048 if (GetOwner()->GetHtmlAttribute("aria-colspan", &colspan)) { |
| 4963 SanitizeStringAttributeForIA2(colspan, &colspan); | 5049 SanitizeStringAttributeForIA2(colspan, &colspan); |
| 4964 win_attributes_->ia2_attributes.push_back(L"colspan:" + colspan); | 5050 win_attributes_->ia2_attributes.push_back(L"colspan:" + colspan); |
| 4965 } | 5051 } |
| 4966 // Expose rowspan attribute. | 5052 // Expose rowspan attribute. |
| 4967 base::string16 rowspan; | 5053 base::string16 rowspan; |
| 4968 if (GetHtmlAttribute("aria-rowspan", &rowspan)) { | 5054 if (GetOwner()->GetHtmlAttribute("aria-rowspan", &rowspan)) { |
| 4969 SanitizeStringAttributeForIA2(rowspan, &rowspan); | 5055 SanitizeStringAttributeForIA2(rowspan, &rowspan); |
| 4970 win_attributes_->ia2_attributes.push_back(L"rowspan:" + rowspan); | 5056 win_attributes_->ia2_attributes.push_back(L"rowspan:" + rowspan); |
| 4971 } | 5057 } |
| 4972 } | 5058 } |
| 4973 | 5059 |
| 4974 // Expose dropeffect attribute. | 5060 // Expose dropeffect attribute. |
| 4975 base::string16 drop_effect; | 5061 base::string16 drop_effect; |
| 4976 if (GetHtmlAttribute("aria-dropeffect", &drop_effect)) { | 5062 if (GetOwner()->GetHtmlAttribute("aria-dropeffect", &drop_effect)) { |
| 4977 SanitizeStringAttributeForIA2(drop_effect, &drop_effect); | 5063 SanitizeStringAttributeForIA2(drop_effect, &drop_effect); |
| 4978 win_attributes_->ia2_attributes.push_back(L"dropeffect:" + drop_effect); | 5064 win_attributes_->ia2_attributes.push_back(L"dropeffect:" + drop_effect); |
| 4979 } | 5065 } |
| 4980 | 5066 |
| 4981 // Expose grabbed attribute. | 5067 // Expose grabbed attribute. |
| 4982 base::string16 grabbed; | 5068 base::string16 grabbed; |
| 4983 if (GetHtmlAttribute("aria-grabbed", &grabbed)) { | 5069 if (GetOwner()->GetHtmlAttribute("aria-grabbed", &grabbed)) { |
| 4984 SanitizeStringAttributeForIA2(grabbed, &grabbed); | 5070 SanitizeStringAttributeForIA2(grabbed, &grabbed); |
| 4985 win_attributes_->ia2_attributes.push_back(L"grabbed:" + grabbed); | 5071 win_attributes_->ia2_attributes.push_back(L"grabbed:" + grabbed); |
| 4986 } | 5072 } |
| 4987 | 5073 |
| 4988 // Expose class attribute. | 5074 // Expose class attribute. |
| 4989 base::string16 class_attr; | 5075 base::string16 class_attr; |
| 4990 if (GetHtmlAttribute("class", &class_attr)) { | 5076 if (GetOwner()->GetHtmlAttribute("class", &class_attr)) { |
| 4991 SanitizeStringAttributeForIA2(class_attr, &class_attr); | 5077 SanitizeStringAttributeForIA2(class_attr, &class_attr); |
| 4992 win_attributes_->ia2_attributes.push_back(L"class:" + class_attr); | 5078 win_attributes_->ia2_attributes.push_back(L"class:" + class_attr); |
| 4993 } | 5079 } |
| 4994 | 5080 |
| 4995 // Expose datetime attribute. | 5081 // Expose datetime attribute. |
| 4996 base::string16 datetime; | 5082 base::string16 datetime; |
| 4997 if (GetRole() == ui::AX_ROLE_TIME && | 5083 if (GetOwner()->GetRole() == ui::AX_ROLE_TIME && |
| 4998 GetHtmlAttribute("datetime", &datetime)) { | 5084 GetOwner()->GetHtmlAttribute("datetime", &datetime)) { |
| 4999 SanitizeStringAttributeForIA2(datetime, &datetime); | 5085 SanitizeStringAttributeForIA2(datetime, &datetime); |
| 5000 win_attributes_->ia2_attributes.push_back(L"datetime:" + datetime); | 5086 win_attributes_->ia2_attributes.push_back(L"datetime:" + datetime); |
| 5001 } | 5087 } |
| 5002 | 5088 |
| 5003 // Expose id attribute. | 5089 // Expose id attribute. |
| 5004 base::string16 id; | 5090 base::string16 id; |
| 5005 if (GetHtmlAttribute("id", &id)) { | 5091 if (GetOwner()->GetHtmlAttribute("id", &id)) { |
| 5006 SanitizeStringAttributeForIA2(id, &id); | 5092 SanitizeStringAttributeForIA2(id, &id); |
| 5007 win_attributes_->ia2_attributes.push_back(L"id:" + id); | 5093 win_attributes_->ia2_attributes.push_back(L"id:" + id); |
| 5008 } | 5094 } |
| 5009 | 5095 |
| 5010 // Expose src attribute. | 5096 // Expose src attribute. |
| 5011 base::string16 src; | 5097 base::string16 src; |
| 5012 if (GetRole() == ui::AX_ROLE_IMAGE && GetHtmlAttribute("src", &src)) { | 5098 if (GetOwner()->GetRole() == ui::AX_ROLE_IMAGE && |
| 5099 GetOwner()->GetHtmlAttribute("src", &src)) { | |
| 5013 SanitizeStringAttributeForIA2(src, &src); | 5100 SanitizeStringAttributeForIA2(src, &src); |
| 5014 win_attributes_->ia2_attributes.push_back(L"src:" + src); | 5101 win_attributes_->ia2_attributes.push_back(L"src:" + src); |
| 5015 } | 5102 } |
| 5016 | 5103 |
| 5017 // Expose input-text type attribute. | 5104 // Expose input-text type attribute. |
| 5018 base::string16 type; | 5105 base::string16 type; |
| 5019 base::string16 html_tag = GetString16Attribute(ui::AX_ATTR_HTML_TAG); | 5106 base::string16 html_tag = |
| 5020 if (IsSimpleTextControl() && html_tag == L"input" && | 5107 GetOwner()->GetString16Attribute(ui::AX_ATTR_HTML_TAG); |
| 5021 GetHtmlAttribute("type", &type)) { | 5108 if (GetOwner()->IsSimpleTextControl() && html_tag == L"input" && |
| 5109 GetOwner()->GetHtmlAttribute("type", &type)) { | |
| 5022 SanitizeStringAttributeForIA2(type, &type); | 5110 SanitizeStringAttributeForIA2(type, &type); |
| 5023 win_attributes_->ia2_attributes.push_back(L"text-input-type:" + type); | 5111 win_attributes_->ia2_attributes.push_back(L"text-input-type:" + type); |
| 5024 } | 5112 } |
| 5025 } | 5113 } |
| 5026 | 5114 |
| 5027 void BrowserAccessibilityWin::FireNativeEvent(LONG win_event_type) const { | 5115 void BrowserAccessibilityComWin::FireNativeEvent(LONG win_event_type) const { |
| 5028 (new BrowserAccessibilityEventWin( | 5116 (new BrowserAccessibilityEventWin(BrowserAccessibilityEvent::FromTreeChange, |
| 5029 BrowserAccessibilityEvent::FromTreeChange, | 5117 ui::AX_EVENT_NONE, win_event_type, |
| 5030 ui::AX_EVENT_NONE, | 5118 GetOwner())) |
| 5031 win_event_type, | 5119 ->Fire(); |
| 5032 this))->Fire(); | |
| 5033 } | 5120 } |
| 5034 | 5121 |
| 5035 ui::AXPlatformNodeWin* BrowserAccessibilityWin::GetPlatformNodeWin() const { | 5122 void BrowserAccessibilityComWin::InitRoleAndState() { |
| 5036 DCHECK(platform_node_); | |
| 5037 return static_cast<ui::AXPlatformNodeWin*>(platform_node_); | |
| 5038 } | |
| 5039 | |
| 5040 void BrowserAccessibilityWin::InitRoleAndState() { | |
| 5041 int32_t ia_role = 0; | 5123 int32_t ia_role = 0; |
| 5042 int32_t ia_state = 0; | 5124 int32_t ia_state = 0; |
| 5043 base::string16 role_name; | 5125 base::string16 role_name; |
| 5044 int32_t ia2_role = 0; | 5126 int32_t ia2_role = 0; |
| 5045 int32_t ia2_state = IA2_STATE_OPAQUE; | 5127 int32_t ia2_state = IA2_STATE_OPAQUE; |
| 5046 | 5128 |
| 5047 if (HasState(ui::AX_STATE_BUSY)) | 5129 if (GetOwner()->HasState(ui::AX_STATE_BUSY)) |
| 5048 ia_state |= STATE_SYSTEM_BUSY; | 5130 ia_state |= STATE_SYSTEM_BUSY; |
| 5049 | 5131 |
| 5050 const auto checked_state = static_cast<ui::AXCheckedState>( | 5132 const auto checked_state = static_cast<ui::AXCheckedState>( |
| 5051 GetIntAttribute(ui::AX_ATTR_CHECKED_STATE)); | 5133 GetOwner()->GetIntAttribute(ui::AX_ATTR_CHECKED_STATE)); |
| 5052 switch (checked_state) { | 5134 switch (checked_state) { |
| 5053 case ui::AX_CHECKED_STATE_TRUE: | 5135 case ui::AX_CHECKED_STATE_TRUE: |
| 5054 ia_state |= STATE_SYSTEM_CHECKED; | 5136 ia_state |= STATE_SYSTEM_CHECKED; |
| 5055 break; | 5137 break; |
| 5056 case ui::AX_CHECKED_STATE_MIXED: | 5138 case ui::AX_CHECKED_STATE_MIXED: |
| 5057 ia_state |= STATE_SYSTEM_MIXED; | 5139 ia_state |= STATE_SYSTEM_MIXED; |
| 5058 break; | 5140 break; |
| 5059 default: | 5141 default: |
| 5060 break; | 5142 break; |
| 5061 } | 5143 } |
| 5062 | 5144 |
| 5063 if (HasState(ui::AX_STATE_COLLAPSED)) | 5145 if (GetOwner()->HasState(ui::AX_STATE_COLLAPSED)) |
| 5064 ia_state |= STATE_SYSTEM_COLLAPSED; | 5146 ia_state |= STATE_SYSTEM_COLLAPSED; |
| 5065 if (HasState(ui::AX_STATE_EXPANDED)) | 5147 if (GetOwner()->HasState(ui::AX_STATE_EXPANDED)) |
| 5066 ia_state |= STATE_SYSTEM_EXPANDED; | 5148 ia_state |= STATE_SYSTEM_EXPANDED; |
| 5067 if (HasState(ui::AX_STATE_FOCUSABLE)) | 5149 if (GetOwner()->HasState(ui::AX_STATE_FOCUSABLE)) |
| 5068 ia_state |= STATE_SYSTEM_FOCUSABLE; | 5150 ia_state |= STATE_SYSTEM_FOCUSABLE; |
| 5069 if (HasState(ui::AX_STATE_HASPOPUP)) | 5151 if (GetOwner()->HasState(ui::AX_STATE_HASPOPUP)) |
| 5070 ia_state |= STATE_SYSTEM_HASPOPUP; | 5152 ia_state |= STATE_SYSTEM_HASPOPUP; |
| 5071 if (HasIntAttribute(ui::AX_ATTR_INVALID_STATE) && | 5153 if (GetOwner()->HasIntAttribute(ui::AX_ATTR_INVALID_STATE) && |
| 5072 GetIntAttribute(ui::AX_ATTR_INVALID_STATE) != ui::AX_INVALID_STATE_FALSE) | 5154 GetOwner()->GetIntAttribute(ui::AX_ATTR_INVALID_STATE) != |
| 5155 ui::AX_INVALID_STATE_FALSE) | |
| 5073 ia2_state |= IA2_STATE_INVALID_ENTRY; | 5156 ia2_state |= IA2_STATE_INVALID_ENTRY; |
| 5074 if (HasState(ui::AX_STATE_INVISIBLE)) | 5157 if (GetOwner()->HasState(ui::AX_STATE_INVISIBLE)) |
| 5075 ia_state |= STATE_SYSTEM_INVISIBLE; | 5158 ia_state |= STATE_SYSTEM_INVISIBLE; |
| 5076 if (HasState(ui::AX_STATE_LINKED)) | 5159 if (GetOwner()->HasState(ui::AX_STATE_LINKED)) |
| 5077 ia_state |= STATE_SYSTEM_LINKED; | 5160 ia_state |= STATE_SYSTEM_LINKED; |
| 5078 if (HasState(ui::AX_STATE_MULTISELECTABLE)) { | 5161 if (GetOwner()->HasState(ui::AX_STATE_MULTISELECTABLE)) { |
| 5079 ia_state |= STATE_SYSTEM_EXTSELECTABLE; | 5162 ia_state |= STATE_SYSTEM_EXTSELECTABLE; |
| 5080 ia_state |= STATE_SYSTEM_MULTISELECTABLE; | 5163 ia_state |= STATE_SYSTEM_MULTISELECTABLE; |
| 5081 } | 5164 } |
| 5082 // TODO(ctguil): Support STATE_SYSTEM_EXTSELECTABLE/accSelect. | 5165 // TODO(ctguil): Support STATE_SYSTEM_EXTSELECTABLE/accSelect. |
| 5083 if (HasState(ui::AX_STATE_OFFSCREEN)) | 5166 if (GetOwner()->HasState(ui::AX_STATE_OFFSCREEN)) |
| 5084 ia_state |= STATE_SYSTEM_OFFSCREEN; | 5167 ia_state |= STATE_SYSTEM_OFFSCREEN; |
| 5085 if (HasState(ui::AX_STATE_PRESSED)) | 5168 if (GetOwner()->HasState(ui::AX_STATE_PRESSED)) |
| 5086 ia_state |= STATE_SYSTEM_PRESSED; | 5169 ia_state |= STATE_SYSTEM_PRESSED; |
| 5087 if (HasState(ui::AX_STATE_PROTECTED)) | 5170 if (GetOwner()->HasState(ui::AX_STATE_PROTECTED)) |
| 5088 ia_state |= STATE_SYSTEM_PROTECTED; | 5171 ia_state |= STATE_SYSTEM_PROTECTED; |
| 5089 if (HasState(ui::AX_STATE_REQUIRED)) | 5172 if (GetOwner()->HasState(ui::AX_STATE_REQUIRED)) |
| 5090 ia2_state |= IA2_STATE_REQUIRED; | 5173 ia2_state |= IA2_STATE_REQUIRED; |
| 5091 if (HasState(ui::AX_STATE_SELECTABLE)) | 5174 if (GetOwner()->HasState(ui::AX_STATE_SELECTABLE)) |
| 5092 ia_state |= STATE_SYSTEM_SELECTABLE; | 5175 ia_state |= STATE_SYSTEM_SELECTABLE; |
| 5093 if (HasState(ui::AX_STATE_SELECTED)) | 5176 if (GetOwner()->HasState(ui::AX_STATE_SELECTED)) |
| 5094 ia_state |= STATE_SYSTEM_SELECTED; | 5177 ia_state |= STATE_SYSTEM_SELECTED; |
| 5095 if (HasState(ui::AX_STATE_VISITED)) | 5178 if (GetOwner()->HasState(ui::AX_STATE_VISITED)) |
| 5096 ia_state |= STATE_SYSTEM_TRAVERSED; | 5179 ia_state |= STATE_SYSTEM_TRAVERSED; |
| 5097 if (HasState(ui::AX_STATE_DISABLED)) | 5180 if (GetOwner()->HasState(ui::AX_STATE_DISABLED)) |
| 5098 ia_state |= STATE_SYSTEM_UNAVAILABLE; | 5181 ia_state |= STATE_SYSTEM_UNAVAILABLE; |
| 5099 if (HasState(ui::AX_STATE_VERTICAL)) | 5182 if (GetOwner()->HasState(ui::AX_STATE_VERTICAL)) |
| 5100 ia2_state |= IA2_STATE_VERTICAL; | 5183 ia2_state |= IA2_STATE_VERTICAL; |
| 5101 if (HasState(ui::AX_STATE_HORIZONTAL)) | 5184 if (GetOwner()->HasState(ui::AX_STATE_HORIZONTAL)) |
| 5102 ia2_state |= IA2_STATE_HORIZONTAL; | 5185 ia2_state |= IA2_STATE_HORIZONTAL; |
| 5103 if (HasState(ui::AX_STATE_VISITED)) | 5186 if (GetOwner()->HasState(ui::AX_STATE_VISITED)) |
| 5104 ia_state |= STATE_SYSTEM_TRAVERSED; | 5187 ia_state |= STATE_SYSTEM_TRAVERSED; |
| 5105 | 5188 |
| 5106 // Expose whether or not the mouse is over an element, but suppress | 5189 // Expose whether or not the mouse is over an element, but suppress |
| 5107 // this for tests because it can make the test results flaky depending | 5190 // this for tests because it can make the test results flaky depending |
| 5108 // on the position of the mouse. | 5191 // on the position of the mouse. |
| 5109 BrowserAccessibilityStateImpl* accessibility_state = | 5192 BrowserAccessibilityStateImpl* accessibility_state = |
| 5110 BrowserAccessibilityStateImpl::GetInstance(); | 5193 BrowserAccessibilityStateImpl::GetInstance(); |
| 5111 if (!accessibility_state->disable_hot_tracking_for_testing()) { | 5194 if (!accessibility_state->disable_hot_tracking_for_testing()) { |
| 5112 if (HasState(ui::AX_STATE_HOVERED)) | 5195 if (GetOwner()->HasState(ui::AX_STATE_HOVERED)) |
| 5113 ia_state |= STATE_SYSTEM_HOTTRACKED; | 5196 ia_state |= STATE_SYSTEM_HOTTRACKED; |
| 5114 } | 5197 } |
| 5115 | 5198 |
| 5116 if (HasState(ui::AX_STATE_EDITABLE)) | 5199 if (GetOwner()->HasState(ui::AX_STATE_EDITABLE)) |
| 5117 ia2_state |= IA2_STATE_EDITABLE; | 5200 ia2_state |= IA2_STATE_EDITABLE; |
| 5118 | 5201 |
| 5119 if (GetBoolAttribute(ui::AX_ATTR_CAN_SET_VALUE)) | 5202 if (GetOwner()->GetBoolAttribute(ui::AX_ATTR_CAN_SET_VALUE)) |
| 5120 ia2_state |= IA2_STATE_EDITABLE; | 5203 ia2_state |= IA2_STATE_EDITABLE; |
| 5121 | 5204 |
| 5122 if (!GetStringAttribute(ui::AX_ATTR_AUTO_COMPLETE).empty()) | 5205 if (!GetOwner()->GetStringAttribute(ui::AX_ATTR_AUTO_COMPLETE).empty()) |
| 5123 ia2_state |= IA2_STATE_SUPPORTS_AUTOCOMPLETION; | 5206 ia2_state |= IA2_STATE_SUPPORTS_AUTOCOMPLETION; |
| 5124 | 5207 |
| 5125 if (GetBoolAttribute(ui::AX_ATTR_MODAL)) | 5208 if (GetOwner()->GetBoolAttribute(ui::AX_ATTR_MODAL)) |
| 5126 ia2_state |= IA2_STATE_MODAL; | 5209 ia2_state |= IA2_STATE_MODAL; |
| 5127 | 5210 |
| 5128 base::string16 html_tag = GetString16Attribute( | 5211 base::string16 html_tag = |
| 5129 ui::AX_ATTR_HTML_TAG); | 5212 GetOwner()->GetString16Attribute(ui::AX_ATTR_HTML_TAG); |
| 5130 switch (GetRole()) { | 5213 switch (GetOwner()->GetRole()) { |
| 5131 case ui::AX_ROLE_ALERT: | 5214 case ui::AX_ROLE_ALERT: |
| 5132 ia_role = ROLE_SYSTEM_ALERT; | 5215 ia_role = ROLE_SYSTEM_ALERT; |
| 5133 break; | 5216 break; |
| 5134 case ui::AX_ROLE_ALERT_DIALOG: | 5217 case ui::AX_ROLE_ALERT_DIALOG: |
| 5135 ia_role = ROLE_SYSTEM_DIALOG; | 5218 ia_role = ROLE_SYSTEM_DIALOG; |
| 5136 break; | 5219 break; |
| 5137 case ui::AX_ROLE_ANCHOR: | 5220 case ui::AX_ROLE_ANCHOR: |
| 5138 ia_role = ROLE_SYSTEM_LINK; | 5221 ia_role = ROLE_SYSTEM_LINK; |
| 5139 break; | 5222 break; |
| 5140 case ui::AX_ROLE_APPLICATION: | 5223 case ui::AX_ROLE_APPLICATION: |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 5156 ia2_role = IA2_ROLE_SECTION; | 5239 ia2_role = IA2_ROLE_SECTION; |
| 5157 break; | 5240 break; |
| 5158 case ui::AX_ROLE_BUSY_INDICATOR: | 5241 case ui::AX_ROLE_BUSY_INDICATOR: |
| 5159 ia_role = ROLE_SYSTEM_ANIMATION; | 5242 ia_role = ROLE_SYSTEM_ANIMATION; |
| 5160 ia_state |= STATE_SYSTEM_READONLY; | 5243 ia_state |= STATE_SYSTEM_READONLY; |
| 5161 break; | 5244 break; |
| 5162 case ui::AX_ROLE_BUTTON: | 5245 case ui::AX_ROLE_BUTTON: |
| 5163 ia_role = ROLE_SYSTEM_PUSHBUTTON; | 5246 ia_role = ROLE_SYSTEM_PUSHBUTTON; |
| 5164 break; | 5247 break; |
| 5165 case ui::AX_ROLE_CANVAS: | 5248 case ui::AX_ROLE_CANVAS: |
| 5166 if (GetBoolAttribute(ui::AX_ATTR_CANVAS_HAS_FALLBACK)) { | 5249 if (GetOwner()->GetBoolAttribute(ui::AX_ATTR_CANVAS_HAS_FALLBACK)) { |
| 5167 role_name = L"canvas"; | 5250 role_name = L"canvas"; |
| 5168 ia2_role = IA2_ROLE_CANVAS; | 5251 ia2_role = IA2_ROLE_CANVAS; |
| 5169 } else { | 5252 } else { |
| 5170 ia_role = ROLE_SYSTEM_GRAPHIC; | 5253 ia_role = ROLE_SYSTEM_GRAPHIC; |
| 5171 } | 5254 } |
| 5172 break; | 5255 break; |
| 5173 case ui::AX_ROLE_CAPTION: | 5256 case ui::AX_ROLE_CAPTION: |
| 5174 ia_role = ROLE_SYSTEM_TEXT; | 5257 ia_role = ROLE_SYSTEM_TEXT; |
| 5175 ia2_role = IA2_ROLE_CAPTION; | 5258 ia2_role = IA2_ROLE_CAPTION; |
| 5176 break; | 5259 break; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5242 ia_role = ROLE_SYSTEM_PUSHBUTTON; | 5325 ia_role = ROLE_SYSTEM_PUSHBUTTON; |
| 5243 break; | 5326 break; |
| 5244 case ui::AX_ROLE_DOCUMENT: | 5327 case ui::AX_ROLE_DOCUMENT: |
| 5245 case ui::AX_ROLE_ROOT_WEB_AREA: | 5328 case ui::AX_ROLE_ROOT_WEB_AREA: |
| 5246 case ui::AX_ROLE_WEB_AREA: | 5329 case ui::AX_ROLE_WEB_AREA: |
| 5247 ia_role = ROLE_SYSTEM_DOCUMENT; | 5330 ia_role = ROLE_SYSTEM_DOCUMENT; |
| 5248 ia_state |= STATE_SYSTEM_READONLY; | 5331 ia_state |= STATE_SYSTEM_READONLY; |
| 5249 ia_state |= STATE_SYSTEM_FOCUSABLE; | 5332 ia_state |= STATE_SYSTEM_FOCUSABLE; |
| 5250 break; | 5333 break; |
| 5251 case ui::AX_ROLE_EMBEDDED_OBJECT: | 5334 case ui::AX_ROLE_EMBEDDED_OBJECT: |
| 5252 if (PlatformChildCount()) { | 5335 if (GetOwner()->PlatformChildCount()) { |
| 5253 // Windows screen readers assume that IA2_ROLE_EMBEDDED_OBJECT | 5336 // Windows screen readers assume that IA2_ROLE_EMBEDDED_OBJECT |
| 5254 // doesn't have any children, but it may be something like a | 5337 // doesn't have any children, but it may be something like a |
| 5255 // browser plugin that has a document inside. | 5338 // browser plugin that has a document inside. |
| 5256 ia_role = ROLE_SYSTEM_GROUPING; | 5339 ia_role = ROLE_SYSTEM_GROUPING; |
| 5257 } else { | 5340 } else { |
| 5258 ia_role = ROLE_SYSTEM_CLIENT; | 5341 ia_role = ROLE_SYSTEM_CLIENT; |
| 5259 ia2_role = IA2_ROLE_EMBEDDED_OBJECT; | 5342 ia2_role = IA2_ROLE_EMBEDDED_OBJECT; |
| 5260 } | 5343 } |
| 5261 break; | 5344 break; |
| 5262 case ui::AX_ROLE_FIGCAPTION: | 5345 case ui::AX_ROLE_FIGCAPTION: |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 5278 ia2_role = IA2_ROLE_FOOTER; | 5361 ia2_role = IA2_ROLE_FOOTER; |
| 5279 break; | 5362 break; |
| 5280 case ui::AX_ROLE_GRID: | 5363 case ui::AX_ROLE_GRID: |
| 5281 ia_role = ROLE_SYSTEM_TABLE; | 5364 ia_role = ROLE_SYSTEM_TABLE; |
| 5282 // TODO(aleventhal) this changed between ARIA 1.0 and 1.1, | 5365 // TODO(aleventhal) this changed between ARIA 1.0 and 1.1, |
| 5283 // need to determine whether grids/treegrids should really be readonly | 5366 // need to determine whether grids/treegrids should really be readonly |
| 5284 // or editable by default | 5367 // or editable by default |
| 5285 // ia_state |= STATE_SYSTEM_READONLY; | 5368 // ia_state |= STATE_SYSTEM_READONLY; |
| 5286 break; | 5369 break; |
| 5287 case ui::AX_ROLE_GROUP: { | 5370 case ui::AX_ROLE_GROUP: { |
| 5288 base::string16 aria_role = GetString16Attribute( | 5371 base::string16 aria_role = |
| 5289 ui::AX_ATTR_ROLE); | 5372 GetOwner()->GetString16Attribute(ui::AX_ATTR_ROLE); |
| 5290 if (aria_role == L"group" || html_tag == L"fieldset") { | 5373 if (aria_role == L"group" || html_tag == L"fieldset") { |
| 5291 ia_role = ROLE_SYSTEM_GROUPING; | 5374 ia_role = ROLE_SYSTEM_GROUPING; |
| 5292 } else if (html_tag == L"li") { | 5375 } else if (html_tag == L"li") { |
| 5293 ia_role = ROLE_SYSTEM_LISTITEM; | 5376 ia_role = ROLE_SYSTEM_LISTITEM; |
| 5294 ia_state |= STATE_SYSTEM_READONLY; | 5377 ia_state |= STATE_SYSTEM_READONLY; |
| 5295 } else { | 5378 } else { |
| 5296 if (html_tag.empty()) | 5379 if (html_tag.empty()) |
| 5297 role_name = L"div"; | 5380 role_name = L"div"; |
| 5298 else | 5381 else |
| 5299 role_name = html_tag; | 5382 role_name = html_tag; |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5448 if (html_tag == L"section") { | 5531 if (html_tag == L"section") { |
| 5449 ia_role = ROLE_SYSTEM_GROUPING; | 5532 ia_role = ROLE_SYSTEM_GROUPING; |
| 5450 ia2_role = IA2_ROLE_SECTION; | 5533 ia2_role = IA2_ROLE_SECTION; |
| 5451 } else { | 5534 } else { |
| 5452 ia_role = ROLE_SYSTEM_PANE; | 5535 ia_role = ROLE_SYSTEM_PANE; |
| 5453 } | 5536 } |
| 5454 break; | 5537 break; |
| 5455 case ui::AX_ROLE_ROW: { | 5538 case ui::AX_ROLE_ROW: { |
| 5456 // Role changes depending on whether row is inside a treegrid | 5539 // Role changes depending on whether row is inside a treegrid |
| 5457 // https://www.w3.org/TR/core-aam-1.1/#role-map-row | 5540 // https://www.w3.org/TR/core-aam-1.1/#role-map-row |
| 5458 ia_role = IsInTreeGrid(this) ? ROLE_SYSTEM_OUTLINEITEM : ROLE_SYSTEM_ROW; | 5541 ia_role = |
| 5542 IsInTreeGrid(GetOwner()) ? ROLE_SYSTEM_OUTLINEITEM : ROLE_SYSTEM_ROW; | |
| 5459 break; | 5543 break; |
| 5460 } | 5544 } |
| 5461 case ui::AX_ROLE_ROW_HEADER: | 5545 case ui::AX_ROLE_ROW_HEADER: |
| 5462 ia_role = ROLE_SYSTEM_ROWHEADER; | 5546 ia_role = ROLE_SYSTEM_ROWHEADER; |
| 5463 break; | 5547 break; |
| 5464 case ui::AX_ROLE_RUBY: | 5548 case ui::AX_ROLE_RUBY: |
| 5465 ia_role = ROLE_SYSTEM_TEXT; | 5549 ia_role = ROLE_SYSTEM_TEXT; |
| 5466 ia2_role = IA2_ROLE_TEXT_FRAME; | 5550 ia2_role = IA2_ROLE_TEXT_FRAME; |
| 5467 break; | 5551 break; |
| 5468 case ui::AX_ROLE_RULER: | 5552 case ui::AX_ROLE_RULER: |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5531 ia_role = ROLE_SYSTEM_LISTITEM; | 5615 ia_role = ROLE_SYSTEM_LISTITEM; |
| 5532 ia_state |= STATE_SYSTEM_READONLY; | 5616 ia_state |= STATE_SYSTEM_READONLY; |
| 5533 break; | 5617 break; |
| 5534 case ui::AX_ROLE_TOGGLE_BUTTON: | 5618 case ui::AX_ROLE_TOGGLE_BUTTON: |
| 5535 ia_role = ROLE_SYSTEM_PUSHBUTTON; | 5619 ia_role = ROLE_SYSTEM_PUSHBUTTON; |
| 5536 ia2_role = IA2_ROLE_TOGGLE_BUTTON; | 5620 ia2_role = IA2_ROLE_TOGGLE_BUTTON; |
| 5537 break; | 5621 break; |
| 5538 case ui::AX_ROLE_TEXT_FIELD: | 5622 case ui::AX_ROLE_TEXT_FIELD: |
| 5539 case ui::AX_ROLE_SEARCH_BOX: | 5623 case ui::AX_ROLE_SEARCH_BOX: |
| 5540 ia_role = ROLE_SYSTEM_TEXT; | 5624 ia_role = ROLE_SYSTEM_TEXT; |
| 5541 if (HasState(ui::AX_STATE_MULTILINE)) { | 5625 if (GetOwner()->HasState(ui::AX_STATE_MULTILINE)) { |
| 5542 ia2_state |= IA2_STATE_MULTI_LINE; | 5626 ia2_state |= IA2_STATE_MULTI_LINE; |
| 5543 } else { | 5627 } else { |
| 5544 ia2_state |= IA2_STATE_SINGLE_LINE; | 5628 ia2_state |= IA2_STATE_SINGLE_LINE; |
| 5545 } | 5629 } |
| 5546 if (HasState(ui::AX_STATE_READ_ONLY)) | 5630 if (GetOwner()->HasState(ui::AX_STATE_READ_ONLY)) |
| 5547 ia_state |= STATE_SYSTEM_READONLY; | 5631 ia_state |= STATE_SYSTEM_READONLY; |
| 5548 ia2_state |= IA2_STATE_SELECTABLE_TEXT; | 5632 ia2_state |= IA2_STATE_SELECTABLE_TEXT; |
| 5549 break; | 5633 break; |
| 5550 case ui::AX_ROLE_ABBR: | 5634 case ui::AX_ROLE_ABBR: |
| 5551 case ui::AX_ROLE_TIME: | 5635 case ui::AX_ROLE_TIME: |
| 5552 role_name = html_tag; | 5636 role_name = html_tag; |
| 5553 ia_role = ROLE_SYSTEM_TEXT; | 5637 ia_role = ROLE_SYSTEM_TEXT; |
| 5554 ia2_role = IA2_ROLE_TEXT_FRAME; | 5638 ia2_role = IA2_ROLE_TEXT_FRAME; |
| 5555 break; | 5639 break; |
| 5556 case ui::AX_ROLE_TIMER: | 5640 case ui::AX_ROLE_TIMER: |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5595 ia_role = ROLE_SYSTEM_CLIENT; | 5679 ia_role = ROLE_SYSTEM_CLIENT; |
| 5596 break; | 5680 break; |
| 5597 } | 5681 } |
| 5598 | 5682 |
| 5599 // Compute the final value of READONLY for MSAA. | 5683 // Compute the final value of READONLY for MSAA. |
| 5600 // | 5684 // |
| 5601 // We always set the READONLY state for elements that have the | 5685 // We always set the READONLY state for elements that have the |
| 5602 // aria-readonly attribute and for a few roles (in the switch above), | 5686 // aria-readonly attribute and for a few roles (in the switch above), |
| 5603 // including read-only text fields. | 5687 // including read-only text fields. |
| 5604 // The majority of focusable controls should not have the read-only state set. | 5688 // The majority of focusable controls should not have the read-only state set. |
| 5605 if (HasState(ui::AX_STATE_FOCUSABLE) && ia_role != ROLE_SYSTEM_DOCUMENT && | 5689 if (GetOwner()->HasState(ui::AX_STATE_FOCUSABLE) && |
| 5606 ia_role != ROLE_SYSTEM_TEXT) { | 5690 ia_role != ROLE_SYSTEM_DOCUMENT && ia_role != ROLE_SYSTEM_TEXT) { |
| 5607 ia_state &= ~(STATE_SYSTEM_READONLY); | 5691 ia_state &= ~(STATE_SYSTEM_READONLY); |
| 5608 } | 5692 } |
| 5609 if (!HasState(ui::AX_STATE_READ_ONLY)) | 5693 if (!GetOwner()->HasState(ui::AX_STATE_READ_ONLY)) |
| 5610 ia_state &= ~(STATE_SYSTEM_READONLY); | 5694 ia_state &= ~(STATE_SYSTEM_READONLY); |
| 5611 if (GetBoolAttribute(ui::AX_ATTR_ARIA_READONLY)) | 5695 if (GetOwner()->GetBoolAttribute(ui::AX_ATTR_ARIA_READONLY)) |
| 5612 ia_state |= STATE_SYSTEM_READONLY; | 5696 ia_state |= STATE_SYSTEM_READONLY; |
| 5613 | 5697 |
| 5614 // The role should always be set. | 5698 // The role should always be set. |
| 5615 DCHECK(!role_name.empty() || ia_role); | 5699 DCHECK(!role_name.empty() || ia_role); |
| 5616 | 5700 |
| 5617 // If we didn't explicitly set the IAccessible2 role, make it the same | 5701 // If we didn't explicitly set the IAccessible2 role, make it the same |
| 5618 // as the MSAA role. | 5702 // as the MSAA role. |
| 5619 if (!ia2_role) | 5703 if (!ia2_role) |
| 5620 ia2_role = ia_role; | 5704 ia2_role = ia_role; |
| 5621 | 5705 |
| 5622 win_attributes_->ia_role = ia_role; | 5706 win_attributes_->ia_role = ia_role; |
| 5623 win_attributes_->ia_state = ia_state; | 5707 win_attributes_->ia_state = ia_state; |
| 5624 win_attributes_->role_name = role_name; | 5708 win_attributes_->role_name = role_name; |
| 5625 win_attributes_->ia2_role = ia2_role; | 5709 win_attributes_->ia2_role = ia2_role; |
| 5626 win_attributes_->ia2_state = ia2_state; | 5710 win_attributes_->ia2_state = ia2_state; |
| 5627 } | 5711 } |
| 5628 | 5712 |
| 5629 bool BrowserAccessibilityWin::IsInTreeGrid(const BrowserAccessibility* item) { | 5713 bool BrowserAccessibilityComWin::IsInTreeGrid( |
| 5714 const BrowserAccessibility* item) { | |
| 5630 BrowserAccessibility* container = item->PlatformGetParent(); | 5715 BrowserAccessibility* container = item->PlatformGetParent(); |
| 5631 if (container && container->GetRole() == ui::AX_ROLE_GROUP) { | 5716 if (container && container->GetRole() == ui::AX_ROLE_GROUP) { |
| 5632 // If parent was a rowgroup, we need to look at the grandparent | 5717 // If parent was a rowgroup, we need to look at the grandparent |
| 5633 container = container->PlatformGetParent(); | 5718 container = container->PlatformGetParent(); |
| 5634 } | 5719 } |
| 5635 | 5720 |
| 5636 if (!container) { | 5721 if (!container) { |
| 5637 return false; | 5722 return false; |
| 5638 } | 5723 } |
| 5639 | 5724 |
| 5640 return container->GetRole() == ui::AX_ROLE_TREE_GRID; | 5725 return container->GetRole() == ui::AX_ROLE_TREE_GRID; |
| 5641 } | 5726 } |
| 5642 | 5727 |
| 5643 BrowserAccessibilityWin* ToBrowserAccessibilityWin(BrowserAccessibility* obj) { | 5728 BrowserAccessibilityComWin* ToBrowserAccessibilityComWin( |
| 5644 DCHECK(!obj || obj->IsNative()); | 5729 BrowserAccessibility* obj) { |
| 5645 return static_cast<BrowserAccessibilityWin*>(obj); | 5730 if (!obj || !obj->IsNative()) |
| 5646 } | 5731 return nullptr; |
| 5647 | 5732 auto* result = static_cast<BrowserAccessibilityWin*>(obj)->GetCOM(); |
| 5648 const BrowserAccessibilityWin* | 5733 return result; |
| 5649 ToBrowserAccessibilityWin(const BrowserAccessibility* obj) { | |
| 5650 DCHECK(!obj || obj->IsNative()); | |
| 5651 return static_cast<const BrowserAccessibilityWin*>(obj); | |
| 5652 } | 5734 } |
| 5653 | 5735 |
| 5654 } // namespace content | 5736 } // namespace content |
| OLD | NEW |