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_ACCESSIBILITY_BROWSER_ACCESSIBILITY_WIN_H_ |
6 #define CHROME_BROWSER_BROWSER_ACCESSIBILITY_WIN_H_ | 6 #define CHROME_BROWSER_ACCESSIBILITY_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> | |
14 #include <vector> | 13 #include <vector> |
15 | 14 |
16 #include "chrome/browser/browser_accessibility_manager_win.h" | 15 #include "chrome/browser/accessibility/browser_accessibility.h" |
17 #include "ia2_api_all.h" // Generated | 16 #include "ia2_api_all.h" // Generated |
18 #include "ISimpleDOMDocument.h" // Generated | 17 #include "ISimpleDOMDocument.h" // Generated |
19 #include "ISimpleDOMNode.h" // Generated | 18 #include "ISimpleDOMNode.h" // Generated |
20 #include "ISimpleDOMText.h" // Generated | 19 #include "ISimpleDOMText.h" // Generated |
21 #include "webkit/glue/webaccessibility.h" | 20 #include "webkit/glue/webaccessibility.h" |
22 | 21 |
| 22 class BrowserAccessibilityManagerWin; |
| 23 |
23 using webkit_glue::WebAccessibility; | 24 using webkit_glue::WebAccessibility; |
24 | 25 |
25 //////////////////////////////////////////////////////////////////////////////// | 26 //////////////////////////////////////////////////////////////////////////////// |
26 // | 27 // |
27 // BrowserAccessibility | 28 // BrowserAccessibilityWin |
28 // | 29 // |
29 // Class implementing the MSAA IAccessible COM interface for the | 30 // Class implementing the windows accessible interface for the Browser-Renderer |
30 // Browser-Renderer communication of MSAA information, providing accessibility | 31 // communication of accessibility information, providing accessibility |
31 // to be used by screen readers and other assistive technology (AT). | 32 // to be used by screen readers and other assistive technology (AT). |
32 // | 33 // |
33 //////////////////////////////////////////////////////////////////////////////// | 34 //////////////////////////////////////////////////////////////////////////////// |
34 class ATL_NO_VTABLE BrowserAccessibility | 35 class BrowserAccessibilityWin |
35 : public CComObjectRootEx<CComMultiThreadModel>, | 36 : public BrowserAccessibility, |
36 public IDispatchImpl<IAccessible2, &IID_IAccessible2, | 37 public CComObjectRootEx<CComMultiThreadModel>, |
37 &LIBID_IAccessible2Lib>, | 38 public IDispatchImpl<IAccessible2, &IID_IAccessible2, |
38 public IAccessibleImage, | 39 &LIBID_IAccessible2Lib>, |
39 public IAccessibleText, | 40 public IAccessibleImage, |
40 public IServiceProvider, | 41 public IAccessibleText, |
41 public ISimpleDOMDocument, | 42 public IServiceProvider, |
42 public ISimpleDOMNode, | 43 public ISimpleDOMDocument, |
43 public ISimpleDOMText { | 44 public ISimpleDOMNode, |
| 45 public ISimpleDOMText { |
44 public: | 46 public: |
45 BEGIN_COM_MAP(BrowserAccessibility) | 47 BEGIN_COM_MAP(BrowserAccessibilityWin) |
46 COM_INTERFACE_ENTRY2(IDispatch, IAccessible2) | 48 COM_INTERFACE_ENTRY2(IDispatch, IAccessible2) |
47 COM_INTERFACE_ENTRY2(IAccessible, IAccessible2) | 49 COM_INTERFACE_ENTRY2(IAccessible, IAccessible2) |
48 COM_INTERFACE_ENTRY(IAccessible2) | 50 COM_INTERFACE_ENTRY(IAccessible2) |
49 COM_INTERFACE_ENTRY(IAccessibleImage) | 51 COM_INTERFACE_ENTRY(IAccessibleImage) |
50 COM_INTERFACE_ENTRY(IAccessibleText) | 52 COM_INTERFACE_ENTRY(IAccessibleText) |
51 COM_INTERFACE_ENTRY(IServiceProvider) | 53 COM_INTERFACE_ENTRY(IServiceProvider) |
52 COM_INTERFACE_ENTRY(ISimpleDOMDocument) | 54 COM_INTERFACE_ENTRY(ISimpleDOMDocument) |
53 COM_INTERFACE_ENTRY(ISimpleDOMNode) | 55 COM_INTERFACE_ENTRY(ISimpleDOMNode) |
54 COM_INTERFACE_ENTRY(ISimpleDOMText) | 56 COM_INTERFACE_ENTRY(ISimpleDOMText) |
55 END_COM_MAP() | 57 END_COM_MAP() |
56 | 58 |
57 BrowserAccessibility(); | 59 BrowserAccessibilityWin(); |
58 | 60 |
59 virtual ~BrowserAccessibility(); | 61 virtual ~BrowserAccessibilityWin(); |
60 | 62 |
61 // Initialize this object and mark it as active. | 63 // Initialize this object and mark it as active. |
62 void Initialize(BrowserAccessibilityManager* manager, | 64 void Initialize(BrowserAccessibilityManagerWin* manager, |
63 BrowserAccessibility* parent, | 65 BrowserAccessibilityWin* parent, |
64 LONG child_id, | 66 LONG child_id, |
65 LONG index_in_parent, | 67 LONG index_in_parent, |
66 const webkit_glue::WebAccessibility& src); | 68 const webkit_glue::WebAccessibility& src); |
67 | 69 |
68 // Add a child of this object. | 70 // Add a child of this object. |
69 void AddChild(BrowserAccessibility* child); | 71 void AddChild(BrowserAccessibilityWin* child); |
70 | 72 |
71 // Mark this object as inactive, and remove references to all children. | 73 // Mark this object as inactive, and remove references to all children. |
72 // When no other clients hold any references to this object it will be | 74 // When no other clients hold any references to this object it will be |
73 // deleted, and in the meantime, calls to any methods will return E_FAIL. | 75 // deleted, and in the meantime, calls to any methods will return E_FAIL. |
74 void InactivateTree(); | 76 void InactivateTree(); |
75 | 77 |
76 // Return true if this object is equal to or a descendant of |ancestor|. | 78 // Return true if this object is equal to or a descendant of |ancestor|. |
77 bool IsDescendantOf(BrowserAccessibility* ancestor); | 79 bool IsDescendantOf(BrowserAccessibilityWin* ancestor); |
78 | 80 |
79 // Returns the parent of this object, or NULL if it's the BrowserAccessibility | 81 // Returns the parent of this object, or NULL if it's the |
80 // root. | 82 // BrowserAccessibilityWin root. |
81 BrowserAccessibility* GetParent(); | 83 BrowserAccessibilityWin* GetParent(); |
82 | 84 |
83 // Returns the number of children of this BrowserAccessibility object. | 85 // Returns the number of children of this BrowserAccessibilityWin object. |
84 uint32 GetChildCount(); | 86 uint32 GetChildCount(); |
85 | 87 |
86 // Return the previous sibling of this object, or NULL if it's the first | 88 // Return the previous sibling of this object, or NULL if it's the first |
87 // child of its parent. | 89 // child of its parent. |
88 BrowserAccessibility* GetPreviousSibling(); | 90 BrowserAccessibilityWin* GetPreviousSibling(); |
89 | 91 |
90 // Return the next sibling of this object, or NULL if it's the last child | 92 // Return the next sibling of this object, or NULL if it's the last child |
91 // of its parent. | 93 // of its parent. |
92 BrowserAccessibility* GetNextSibling(); | 94 BrowserAccessibilityWin* GetNextSibling(); |
93 | 95 |
94 // Replace a child BrowserAccessibility object. Used when updating the | 96 // Replace a child BrowserAccessibilityWin object. Used when updating the |
95 // accessibility tree. | 97 // accessibility tree. |
96 void ReplaceChild( | 98 void ReplaceChild( |
97 const BrowserAccessibility* old_acc, BrowserAccessibility* new_acc); | 99 const BrowserAccessibilityWin* old_acc, BrowserAccessibilityWin* new_acc); |
98 | 100 |
99 // Accessors | 101 // Accessors |
100 LONG child_id() const { return child_id_; } | 102 LONG child_id() const { return child_id_; } |
101 int32 renderer_id() const { return renderer_id_; } | 103 int32 renderer_id() const { return renderer_id_; } |
102 LONG index_in_parent() const { return index_in_parent_; } | 104 LONG index_in_parent() const { return index_in_parent_; } |
103 | 105 |
104 // Add one to the reference count and return the same object. Always | 106 // Add one to the reference count and return the same object. Always |
105 // use this method when returning a BrowserAccessibility object as | 107 // use this method when returning a BrowserAccessibilityWin object as |
106 // an output parameter to a COM interface, never use it otherwise. | 108 // an output parameter to a COM interface, never use it otherwise. |
107 BrowserAccessibility* NewReference(); | 109 BrowserAccessibilityWin* NewReference(); |
108 | 110 |
109 // | 111 // |
110 // IAccessible methods. | 112 // IAccessible methods. |
111 // | 113 // |
112 | 114 |
113 // Performs the default action on a given object. | 115 // Performs the default action on a given object. |
114 STDMETHODIMP accDoDefaultAction(VARIANT var_id); | 116 STDMETHODIMP accDoDefaultAction(VARIANT var_id); |
115 | 117 |
116 // Retrieves the child element or child object at a given point on the screen. | 118 // Retrieves the child element or child object at a given point on the screen. |
117 STDMETHODIMP accHitTest(LONG x_left, LONG y_top, VARIANT* child); | 119 STDMETHODIMP accHitTest(LONG x_left, LONG y_top, VARIANT* child); |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 const _ATL_INTMAP_ENTRY* entries, | 485 const _ATL_INTMAP_ENTRY* entries, |
484 REFIID iid, | 486 REFIID iid, |
485 void** object); | 487 void** object); |
486 | 488 |
487 private: | 489 private: |
488 // Many MSAA methods take a var_id parameter indicating that the operation | 490 // Many MSAA methods take a var_id parameter indicating that the operation |
489 // should be performed on a particular child ID, rather than this object. | 491 // should be performed on a particular child ID, rather than this object. |
490 // This method tries to figure out the target object from |var_id| and | 492 // This method tries to figure out the target object from |var_id| and |
491 // returns a pointer to the target object if it exists, otherwise NULL. | 493 // returns a pointer to the target object if it exists, otherwise NULL. |
492 // Does not return a new reference. | 494 // Does not return a new reference. |
493 BrowserAccessibility* GetTargetFromChildID(const VARIANT& var_id); | 495 BrowserAccessibilityWin* GetTargetFromChildID(const VARIANT& var_id); |
494 | 496 |
495 // Initialize the role and state metadata from the role enum and state | 497 // Initialize the role and state metadata from the role enum and state |
496 // bitmasks defined in webkit/glue/webaccessibility.h. | 498 // bitmasks defined in webkit/glue/webaccessibility.h. |
497 void InitRoleAndState(LONG web_accessibility_role, | 499 void InitRoleAndState(LONG web_accessibility_role, |
498 LONG web_accessibility_state); | 500 LONG web_accessibility_state); |
499 | 501 |
500 // Return true if this attribute is in the attributes map. | 502 // Return true if this attribute is in the attributes map. |
501 bool HasAttribute(WebAccessibility::Attribute attribute); | 503 bool HasAttribute(WebAccessibility::Attribute attribute); |
502 | 504 |
503 // Retrieve the string value of an attribute from the attribute map and | 505 // Retrieve the string value of an attribute from the attribute map and |
504 // returns true if found. | 506 // returns true if found. |
505 bool GetAttribute(WebAccessibility::Attribute attribute, string16* value); | 507 bool GetAttribute(WebAccessibility::Attribute attribute, string16* value); |
506 | 508 |
507 // Retrieve the string value of an attribute from the attribute map and | 509 // Retrieve the string value of an attribute from the attribute map and |
508 // if found and nonempty, allocate a new BSTR (with SysAllocString) | 510 // if found and nonempty, allocate a new BSTR (with SysAllocString) |
509 // and return S_OK. If not found or empty, return S_FALSE. | 511 // and return S_OK. If not found or empty, return S_FALSE. |
510 HRESULT GetAttributeAsBstr( | 512 HRESULT GetAttributeAsBstr( |
511 WebAccessibility::Attribute attribute, BSTR* value_bstr); | 513 WebAccessibility::Attribute attribute, BSTR* value_bstr); |
512 | 514 |
513 // Escape a string like it would be escaped for a URL or HTML form. | 515 // Escape a string like it would be escaped for a URL or HTML form. |
514 string16 Escape(string16 str); | 516 string16 Escape(string16 str); |
515 | 517 |
516 // The manager of this tree of accessibility objects; needed for | 518 // The manager of this tree of accessibility objects; needed for |
517 // global operations like focus tracking. | 519 // global operations like focus tracking. |
518 BrowserAccessibilityManager* manager_; | 520 BrowserAccessibilityManagerWin* manager_; |
519 // The parent of this object, may be NULL if we're the root object. | 521 // The parent of this object, may be NULL if we're the root object. |
520 BrowserAccessibility* parent_; | 522 BrowserAccessibilityWin* parent_; |
521 // The ID of this object; globally unique within the browser process. | 523 // The ID of this object; globally unique within the browser process. |
522 LONG child_id_; | 524 LONG child_id_; |
523 // The index of this within its parent object. | 525 // The index of this within its parent object. |
524 LONG index_in_parent_; | 526 LONG index_in_parent_; |
525 // The ID of this object in the renderer process. | 527 // The ID of this object in the renderer process. |
526 int32 renderer_id_; | 528 int32 renderer_id_; |
527 | 529 |
528 // The children of this object. | 530 // The children of this object. |
529 std::vector<BrowserAccessibility*> children_; | 531 std::vector<BrowserAccessibilityWin*> children_; |
530 | 532 |
531 // Accessibility metadata from the renderer, used to respond to MSAA | 533 // Accessibility metadata from the renderer, used to respond to MSAA |
532 // events. | 534 // events. |
533 string16 name_; | 535 string16 name_; |
534 string16 value_; | 536 string16 value_; |
535 std::map<int32, string16> attributes_; | 537 std::map<int32, string16> attributes_; |
536 std::vector<std::pair<string16, string16> > html_attributes_; | 538 std::vector<std::pair<string16, string16> > html_attributes_; |
537 | 539 |
538 LONG role_; | 540 LONG role_; |
539 LONG state_; | 541 LONG state_; |
540 string16 role_name_; | 542 string16 role_name_; |
541 LONG ia2_role_; | 543 LONG ia2_role_; |
542 LONG ia2_state_; | 544 LONG ia2_state_; |
543 WebKit::WebRect location_; | 545 WebKit::WebRect location_; |
544 | 546 |
545 // COM objects are reference-counted. When we're done with this object | 547 // 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 | 548 // 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 | 549 // 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 | 550 // so that calls to any of this object's methods immediately return |
549 // failure. | 551 // failure. |
550 bool instance_active_; | 552 bool instance_active_; |
551 | 553 |
552 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibility); | 554 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityWin); |
553 }; | 555 }; |
554 | 556 |
555 #endif // CHROME_BROWSER_BROWSER_ACCESSIBILITY_WIN_H_ | 557 #endif // CHROME_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_WIN_H_ |
OLD | NEW |