| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_BROWSER_ACCESSIBILITY_WIN_H_ | 5 #ifndef CHROME_BROWSER_BROWSER_ACCESSIBILITY_WIN_H_ |
| 6 #define CHROME_BROWSER_BROWSER_ACCESSIBILITY_WIN_H_ | 6 #define CHROME_BROWSER_BROWSER_ACCESSIBILITY_WIN_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <atlbase.h> | 9 #include <atlbase.h> |
| 10 #include <atlcom.h> | 10 #include <atlcom.h> |
| 11 #include <oleacc.h> | 11 #include <oleacc.h> |
| 12 | 12 |
| 13 #include <map> | 13 #include <map> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "chrome/browser/browser_accessibility_manager_win.h" | 16 #include "chrome/browser/browser_accessibility_manager_win.h" |
| 17 #include "ia2_api_all.h" // Generated | 17 #include "ia2_api_all.h" // Generated |
| 18 #include "ISimpleDOMDocument.h" // Generated | |
| 19 #include "ISimpleDOMNode.h" // Generated | |
| 20 #include "ISimpleDOMText.h" // Generated | |
| 21 #include "webkit/glue/webaccessibility.h" | 18 #include "webkit/glue/webaccessibility.h" |
| 22 | 19 |
| 23 using webkit_glue::WebAccessibility; | 20 using webkit_glue::WebAccessibility; |
| 24 | 21 |
| 25 //////////////////////////////////////////////////////////////////////////////// | 22 //////////////////////////////////////////////////////////////////////////////// |
| 26 // | 23 // |
| 27 // BrowserAccessibility | 24 // BrowserAccessibility |
| 28 // | 25 // |
| 29 // Class implementing the MSAA IAccessible COM interface for the | 26 // Class implementing the MSAA IAccessible COM interface for the |
| 30 // Browser-Renderer communication of MSAA information, providing accessibility | 27 // Browser-Renderer communication of MSAA information, providing accessibility |
| 31 // to be used by screen readers and other assistive technology (AT). | 28 // to be used by screen readers and other assistive technology (AT). |
| 32 // | 29 // |
| 33 //////////////////////////////////////////////////////////////////////////////// | 30 //////////////////////////////////////////////////////////////////////////////// |
| 34 class ATL_NO_VTABLE BrowserAccessibility | 31 class ATL_NO_VTABLE BrowserAccessibility |
| 35 : public CComObjectRootEx<CComMultiThreadModel>, | 32 : public CComObjectRootEx<CComMultiThreadModel>, |
| 36 public IDispatchImpl<IAccessible2, &IID_IAccessible2, | 33 public IDispatchImpl<IAccessible2, &IID_IAccessible2, |
| 37 &LIBID_IAccessible2Lib>, | 34 &LIBID_IAccessible2Lib>, |
| 38 public IAccessibleImage, | 35 public IAccessibleImage, |
| 39 public IAccessibleText, | 36 public IAccessibleText, |
| 40 public IServiceProvider, | 37 public IServiceProvider { |
| 41 public ISimpleDOMDocument, | |
| 42 public ISimpleDOMNode, | |
| 43 public ISimpleDOMText { | |
| 44 public: | 38 public: |
| 45 BEGIN_COM_MAP(BrowserAccessibility) | 39 BEGIN_COM_MAP(BrowserAccessibility) |
| 46 COM_INTERFACE_ENTRY2(IDispatch, IAccessible2) | 40 COM_INTERFACE_ENTRY2(IDispatch, IAccessible2) |
| 47 COM_INTERFACE_ENTRY2(IAccessible, IAccessible2) | 41 COM_INTERFACE_ENTRY2(IAccessible, IAccessible2) |
| 48 COM_INTERFACE_ENTRY(IAccessible2) | 42 COM_INTERFACE_ENTRY(IAccessible2) |
| 49 COM_INTERFACE_ENTRY(IAccessibleImage) | 43 COM_INTERFACE_ENTRY(IAccessibleImage) |
| 50 COM_INTERFACE_ENTRY(IAccessibleText) | 44 COM_INTERFACE_ENTRY(IAccessibleText) |
| 51 COM_INTERFACE_ENTRY(IServiceProvider) | 45 COM_INTERFACE_ENTRY(IServiceProvider) |
| 52 COM_INTERFACE_ENTRY(ISimpleDOMDocument) | |
| 53 COM_INTERFACE_ENTRY(ISimpleDOMNode) | |
| 54 COM_INTERFACE_ENTRY(ISimpleDOMText) | |
| 55 END_COM_MAP() | 46 END_COM_MAP() |
| 56 | 47 |
| 57 BrowserAccessibility(); | 48 BrowserAccessibility(); |
| 58 | 49 |
| 59 virtual ~BrowserAccessibility(); | 50 virtual ~BrowserAccessibility(); |
| 60 | 51 |
| 61 // Initialize this object and mark it as active. | 52 // Initialize this object and mark it as active. |
| 62 void Initialize(BrowserAccessibilityManager* manager, | 53 void Initialize(BrowserAccessibilityManager* manager, |
| 63 BrowserAccessibility* parent, | 54 BrowserAccessibility* parent, |
| 64 LONG child_id, | 55 LONG child_id, |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 return E_NOTIMPL; | 331 return E_NOTIMPL; |
| 341 } | 332 } |
| 342 STDMETHODIMP get_newText(IA2TextSegment* new_text) { | 333 STDMETHODIMP get_newText(IA2TextSegment* new_text) { |
| 343 return E_NOTIMPL; | 334 return E_NOTIMPL; |
| 344 } | 335 } |
| 345 STDMETHODIMP get_oldText(IA2TextSegment* old_text) { | 336 STDMETHODIMP get_oldText(IA2TextSegment* old_text) { |
| 346 return E_NOTIMPL; | 337 return E_NOTIMPL; |
| 347 } | 338 } |
| 348 | 339 |
| 349 // | 340 // |
| 350 // ISimpleDOMDocument methods. | |
| 351 // | |
| 352 | |
| 353 STDMETHODIMP get_URL(BSTR* url); | |
| 354 | |
| 355 STDMETHODIMP get_title(BSTR* title); | |
| 356 | |
| 357 STDMETHODIMP get_mimeType(BSTR* mime_type); | |
| 358 | |
| 359 STDMETHODIMP get_docType(BSTR* doc_type); | |
| 360 | |
| 361 STDMETHODIMP get_nameSpaceURIForID( | |
| 362 short name_space_id, BSTR *name_space_uri) { | |
| 363 return E_NOTIMPL; | |
| 364 } | |
| 365 STDMETHODIMP put_alternateViewMediaTypes( | |
| 366 BSTR *comma_separated_media_types) { | |
| 367 return E_NOTIMPL; | |
| 368 } | |
| 369 | |
| 370 // | |
| 371 // ISimpleDOMNode methods. | |
| 372 // | |
| 373 | |
| 374 STDMETHODIMP get_nodeInfo( | |
| 375 BSTR* node_name, | |
| 376 short* name_space_id, | |
| 377 BSTR* node_value, | |
| 378 unsigned int* num_children, | |
| 379 unsigned int* unique_id, | |
| 380 unsigned short* node_type); | |
| 381 | |
| 382 STDMETHODIMP get_attributes( | |
| 383 unsigned short max_attribs, | |
| 384 BSTR* attrib_names, | |
| 385 short* name_space_id, | |
| 386 BSTR* attrib_values, | |
| 387 unsigned short* num_attribs); | |
| 388 | |
| 389 STDMETHODIMP get_attributesForNames( | |
| 390 unsigned short num_attribs, | |
| 391 BSTR* attrib_names, | |
| 392 short* name_space_id, | |
| 393 BSTR* attrib_values); | |
| 394 | |
| 395 STDMETHODIMP get_computedStyle( | |
| 396 unsigned short max_style_properties, | |
| 397 boolean use_alternate_view, | |
| 398 BSTR *style_properties, | |
| 399 BSTR *style_values, | |
| 400 unsigned short *num_style_properties); | |
| 401 | |
| 402 STDMETHODIMP get_computedStyleForProperties( | |
| 403 unsigned short num_style_properties, | |
| 404 boolean use_alternate_view, | |
| 405 BSTR* style_properties, | |
| 406 BSTR* style_values); | |
| 407 | |
| 408 STDMETHODIMP scrollTo(boolean placeTopLeft); | |
| 409 | |
| 410 STDMETHODIMP get_parentNode(ISimpleDOMNode** node); | |
| 411 | |
| 412 STDMETHODIMP get_firstChild(ISimpleDOMNode** node); | |
| 413 | |
| 414 STDMETHODIMP get_lastChild(ISimpleDOMNode** node); | |
| 415 | |
| 416 STDMETHODIMP get_previousSibling(ISimpleDOMNode** node); | |
| 417 | |
| 418 STDMETHODIMP get_nextSibling(ISimpleDOMNode** node); | |
| 419 | |
| 420 STDMETHODIMP get_childAt( | |
| 421 unsigned int child_index, | |
| 422 ISimpleDOMNode** node); | |
| 423 | |
| 424 STDMETHODIMP get_innerHTML(BSTR* innerHTML) { | |
| 425 return E_NOTIMPL; | |
| 426 } | |
| 427 | |
| 428 STDMETHODIMP get_localInterface(void** local_interface) { | |
| 429 return E_NOTIMPL; | |
| 430 } | |
| 431 | |
| 432 STDMETHODIMP get_language(BSTR* language) { | |
| 433 return E_NOTIMPL; | |
| 434 } | |
| 435 | |
| 436 // | |
| 437 // ISimpleDOMText methods. | |
| 438 // | |
| 439 | |
| 440 STDMETHODIMP get_domText(BSTR* dom_text); | |
| 441 | |
| 442 STDMETHODIMP get_clippedSubstringBounds( | |
| 443 unsigned int start_index, | |
| 444 unsigned int end_index, | |
| 445 int* x, | |
| 446 int* y, | |
| 447 int* width, | |
| 448 int* height) { | |
| 449 return E_NOTIMPL; | |
| 450 } | |
| 451 | |
| 452 STDMETHODIMP get_unclippedSubstringBounds( | |
| 453 unsigned int start_index, | |
| 454 unsigned int end_index, | |
| 455 int* x, | |
| 456 int* y, | |
| 457 int* width, | |
| 458 int* height) { | |
| 459 return E_NOTIMPL; | |
| 460 } | |
| 461 | |
| 462 STDMETHODIMP scrollToSubstring( | |
| 463 unsigned int start_index, | |
| 464 unsigned int end_index) { | |
| 465 return E_NOTIMPL; | |
| 466 } | |
| 467 | |
| 468 STDMETHODIMP get_fontFamily(BSTR *font_family) { | |
| 469 return E_NOTIMPL; | |
| 470 } | |
| 471 | |
| 472 // | |
| 473 // IServiceProvider methods. | 341 // IServiceProvider methods. |
| 474 // | 342 // |
| 475 | 343 |
| 476 STDMETHODIMP QueryService(REFGUID guidService, REFIID riid, void** object); | 344 STDMETHODIMP QueryService(REFGUID guidService, REFIID riid, void** object); |
| 477 | 345 |
| 478 // | 346 // |
| 479 // CComObjectRootEx methods. | 347 // CComObjectRootEx methods. |
| 480 // | 348 // |
| 481 | 349 |
| 482 HRESULT WINAPI InternalQueryInterface(void* this_ptr, | 350 HRESULT WINAPI InternalQueryInterface(void* this_ptr, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 497 void InitRoleAndState(LONG web_accessibility_role, | 365 void InitRoleAndState(LONG web_accessibility_role, |
| 498 LONG web_accessibility_state); | 366 LONG web_accessibility_state); |
| 499 | 367 |
| 500 // Return true if this attribute is in the attributes map. | 368 // Return true if this attribute is in the attributes map. |
| 501 bool HasAttribute(WebAccessibility::Attribute attribute); | 369 bool HasAttribute(WebAccessibility::Attribute attribute); |
| 502 | 370 |
| 503 // Retrieve the string value of an attribute from the attribute map and | 371 // Retrieve the string value of an attribute from the attribute map and |
| 504 // returns true if found. | 372 // returns true if found. |
| 505 bool GetAttribute(WebAccessibility::Attribute attribute, string16* value); | 373 bool GetAttribute(WebAccessibility::Attribute attribute, string16* value); |
| 506 | 374 |
| 507 // Retrieve the string value of an attribute from the attribute map and | |
| 508 // if found and nonempty, allocate a new BSTR (with SysAllocString) | |
| 509 // and return S_OK. If not found or empty, return S_FALSE. | |
| 510 HRESULT GetAttributeAsBstr( | |
| 511 WebAccessibility::Attribute attribute, BSTR* value_bstr); | |
| 512 | |
| 513 // Escape a string like it would be escaped for a URL or HTML form. | |
| 514 string16 Escape(string16 str); | |
| 515 | |
| 516 // The manager of this tree of accessibility objects; needed for | 375 // The manager of this tree of accessibility objects; needed for |
| 517 // global operations like focus tracking. | 376 // global operations like focus tracking. |
| 518 BrowserAccessibilityManager* manager_; | 377 BrowserAccessibilityManager* manager_; |
| 519 // The parent of this object, may be NULL if we're the root object. | 378 // The parent of this object, may be NULL if we're the root object. |
| 520 BrowserAccessibility* parent_; | 379 BrowserAccessibility* parent_; |
| 521 // The ID of this object; globally unique within the browser process. | 380 // The ID of this object; globally unique within the browser process. |
| 522 LONG child_id_; | 381 LONG child_id_; |
| 523 // The index of this within its parent object. | 382 // The index of this within its parent object. |
| 524 LONG index_in_parent_; | 383 LONG index_in_parent_; |
| 525 // The ID of this object in the renderer process. | 384 // The ID of this object in the renderer process. |
| 526 int32 renderer_id_; | 385 int32 renderer_id_; |
| 527 | 386 |
| 528 // The children of this object. | 387 // The children of this object. |
| 529 std::vector<BrowserAccessibility*> children_; | 388 std::vector<BrowserAccessibility*> children_; |
| 530 | 389 |
| 531 // Accessibility metadata from the renderer, used to respond to MSAA | 390 // Accessibility metadata from the renderer, used to respond to MSAA |
| 532 // events. | 391 // events. |
| 533 string16 name_; | 392 string16 name_; |
| 534 string16 value_; | 393 string16 value_; |
| 535 std::map<int32, string16> attributes_; | 394 std::map<int32, string16> attributes_; |
| 536 std::vector<std::pair<string16, string16> > html_attributes_; | |
| 537 | 395 |
| 538 LONG role_; | 396 LONG role_; |
| 539 LONG state_; | 397 LONG state_; |
| 540 string16 role_name_; | 398 string16 role_name_; |
| 541 LONG ia2_role_; | 399 LONG ia2_role_; |
| 542 LONG ia2_state_; | 400 LONG ia2_state_; |
| 543 WebKit::WebRect location_; | 401 WebKit::WebRect location_; |
| 544 | 402 |
| 545 // COM objects are reference-counted. When we're done with this object | 403 // COM objects are reference-counted. When we're done with this object |
| 546 // and it's removed from our accessibility tree, a client may still be | 404 // and it's removed from our accessibility tree, a client may still be |
| 547 // holding onto a pointer to this object, so we mark it as inactive | 405 // holding onto a pointer to this object, so we mark it as inactive |
| 548 // so that calls to any of this object's methods immediately return | 406 // so that calls to any of this object's methods immediately return |
| 549 // failure. | 407 // failure. |
| 550 bool instance_active_; | 408 bool instance_active_; |
| 551 | 409 |
| 552 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibility); | 410 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibility); |
| 553 }; | 411 }; |
| 554 | 412 |
| 555 #endif // CHROME_BROWSER_BROWSER_ACCESSIBILITY_WIN_H_ | 413 #endif // CHROME_BROWSER_BROWSER_ACCESSIBILITY_WIN_H_ |
| OLD | NEW |