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_ACCESSIBILITY_BROWSER_ACCESSIBILITY_WIN_H_ | 5 #ifndef CHROME_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_WIN_H_ |
6 #define CHROME_BROWSER_ACCESSIBILITY_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> |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 COM_INTERFACE_ENTRY(IServiceProvider) | 53 COM_INTERFACE_ENTRY(IServiceProvider) |
54 COM_INTERFACE_ENTRY(ISimpleDOMDocument) | 54 COM_INTERFACE_ENTRY(ISimpleDOMDocument) |
55 COM_INTERFACE_ENTRY(ISimpleDOMNode) | 55 COM_INTERFACE_ENTRY(ISimpleDOMNode) |
56 COM_INTERFACE_ENTRY(ISimpleDOMText) | 56 COM_INTERFACE_ENTRY(ISimpleDOMText) |
57 END_COM_MAP() | 57 END_COM_MAP() |
58 | 58 |
59 BrowserAccessibilityWin(); | 59 BrowserAccessibilityWin(); |
60 | 60 |
61 virtual ~BrowserAccessibilityWin(); | 61 virtual ~BrowserAccessibilityWin(); |
62 | 62 |
63 // | 63 // Initialize this object and mark it as active. |
64 // BrowserAccessibility methods. | 64 void Initialize(BrowserAccessibilityManagerWin* manager, |
65 // | 65 BrowserAccessibilityWin* parent, |
66 virtual void Initialize(); | 66 LONG child_id, |
67 virtual void ReleaseTree(); | 67 LONG index_in_parent, |
68 virtual void ReleaseReference(); | 68 const webkit_glue::WebAccessibility& src); |
| 69 |
| 70 // Add a child of this object. |
| 71 void AddChild(BrowserAccessibilityWin* child); |
| 72 |
| 73 // Mark this object as inactive, and remove references to all children. |
| 74 // When no other clients hold any references to this object it will be |
| 75 // deleted, and in the meantime, calls to any methods will return E_FAIL. |
| 76 void InactivateTree(); |
| 77 |
| 78 // Return true if this object is equal to or a descendant of |ancestor|. |
| 79 bool IsDescendantOf(BrowserAccessibilityWin* ancestor); |
| 80 |
| 81 // Returns the parent of this object, or NULL if it's the |
| 82 // BrowserAccessibilityWin root. |
| 83 BrowserAccessibilityWin* GetParent(); |
| 84 |
| 85 // Returns the number of children of this BrowserAccessibilityWin object. |
| 86 uint32 GetChildCount(); |
| 87 |
| 88 // Return a pointer to the child with the given index. |
| 89 BrowserAccessibilityWin* GetChild(uint32 child_index); |
| 90 |
| 91 // Return the previous sibling of this object, or NULL if it's the first |
| 92 // child of its parent. |
| 93 BrowserAccessibilityWin* GetPreviousSibling(); |
| 94 |
| 95 // Return the next sibling of this object, or NULL if it's the last child |
| 96 // of its parent. |
| 97 BrowserAccessibilityWin* GetNextSibling(); |
| 98 |
| 99 // Replace a child BrowserAccessibilityWin object. Used when updating the |
| 100 // accessibility tree. |
| 101 void ReplaceChild( |
| 102 const BrowserAccessibilityWin* old_acc, BrowserAccessibilityWin* new_acc); |
| 103 |
| 104 // Accessors |
| 105 LONG child_id() const { return child_id_; } |
| 106 int32 renderer_id() const { return renderer_id_; } |
| 107 LONG index_in_parent() const { return index_in_parent_; } |
| 108 |
| 109 // Add one to the reference count and return the same object. Always |
| 110 // use this method when returning a BrowserAccessibilityWin object as |
| 111 // an output parameter to a COM interface, never use it otherwise. |
| 112 BrowserAccessibilityWin* NewReference(); |
69 | 113 |
70 // | 114 // |
71 // IAccessible methods. | 115 // IAccessible methods. |
72 // | 116 // |
73 | 117 |
74 // Performs the default action on a given object. | 118 // Performs the default action on a given object. |
75 STDMETHODIMP accDoDefaultAction(VARIANT var_id); | 119 STDMETHODIMP accDoDefaultAction(VARIANT var_id); |
76 | 120 |
77 // Retrieves the child element or child object at a given point on the screen. | 121 // Retrieves the child element or child object at a given point on the screen. |
78 STDMETHODIMP accHitTest(LONG x_left, LONG y_top, VARIANT* child); | 122 STDMETHODIMP accHitTest(LONG x_left, LONG y_top, VARIANT* child); |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 // | 482 // |
439 // CComObjectRootEx methods. | 483 // CComObjectRootEx methods. |
440 // | 484 // |
441 | 485 |
442 HRESULT WINAPI InternalQueryInterface(void* this_ptr, | 486 HRESULT WINAPI InternalQueryInterface(void* this_ptr, |
443 const _ATL_INTMAP_ENTRY* entries, | 487 const _ATL_INTMAP_ENTRY* entries, |
444 REFIID iid, | 488 REFIID iid, |
445 void** object); | 489 void** object); |
446 | 490 |
447 private: | 491 private: |
448 // Add one to the reference count and return the same object. Always | |
449 // use this method when returning a BrowserAccessibilityWin object as | |
450 // an output parameter to a COM interface, never use it otherwise. | |
451 BrowserAccessibilityWin* NewReference(); | |
452 | |
453 // Many MSAA methods take a var_id parameter indicating that the operation | 492 // Many MSAA methods take a var_id parameter indicating that the operation |
454 // should be performed on a particular child ID, rather than this object. | 493 // should be performed on a particular child ID, rather than this object. |
455 // This method tries to figure out the target object from |var_id| and | 494 // This method tries to figure out the target object from |var_id| and |
456 // returns a pointer to the target object if it exists, otherwise NULL. | 495 // returns a pointer to the target object if it exists, otherwise NULL. |
457 // Does not return a new reference. | 496 // Does not return a new reference. |
458 BrowserAccessibilityWin* GetTargetFromChildID(const VARIANT& var_id); | 497 BrowserAccessibilityWin* GetTargetFromChildID(const VARIANT& var_id); |
459 | 498 |
460 // Initialize the role and state metadata from the role enum and state | 499 // Initialize the role and state metadata from the role enum and state |
461 // bitmasks defined in webkit/glue/webaccessibility.h. | 500 // bitmasks defined in webkit/glue/webaccessibility.h. |
462 void InitRoleAndState(); | 501 void InitRoleAndState(LONG web_accessibility_role, |
| 502 LONG web_accessibility_state); |
463 | 503 |
464 // Return true if this attribute is in the attributes map. | 504 // Return true if this attribute is in the attributes map. |
465 bool HasAttribute(WebAccessibility::Attribute attribute); | 505 bool HasAttribute(WebAccessibility::Attribute attribute); |
466 | 506 |
467 // Retrieve the string value of an attribute from the attribute map and | 507 // Retrieve the string value of an attribute from the attribute map and |
468 // returns true if found. | 508 // returns true if found. |
469 bool GetAttribute(WebAccessibility::Attribute attribute, string16* value); | 509 bool GetAttribute(WebAccessibility::Attribute attribute, string16* value); |
470 | 510 |
471 // Retrieve the string value of an attribute from the attribute map and | 511 // Retrieve the string value of an attribute from the attribute map and |
472 // if found and nonempty, allocate a new BSTR (with SysAllocString) | 512 // if found and nonempty, allocate a new BSTR (with SysAllocString) |
473 // and return S_OK. If not found or empty, return S_FALSE. | 513 // and return S_OK. If not found or empty, return S_FALSE. |
474 HRESULT GetAttributeAsBstr( | 514 HRESULT GetAttributeAsBstr( |
475 WebAccessibility::Attribute attribute, BSTR* value_bstr); | 515 WebAccessibility::Attribute attribute, BSTR* value_bstr); |
476 | 516 |
477 // Retrieve the value of an attribute from the attribute map and | 517 // Retrieve the value of an attribute from the attribute map and |
478 // if found and nonempty, try to convert it to an integer. | 518 // if found and nonempty, try to convert it to an integer. |
479 // Returns true only if both the attribute was found and it was successfully | 519 // Returns true only if both the attribute was found and it was successfully |
480 // converted to an integer. | 520 // converted to an integer. |
481 bool GetAttributeAsInt( | 521 bool GetAttributeAsInt( |
482 WebAccessibility::Attribute attribute, int* value_int); | 522 WebAccessibility::Attribute attribute, int* value_int); |
483 | 523 |
484 // Escape a string like it would be escaped for a URL or HTML form. | 524 // Escape a string like it would be escaped for a URL or HTML form. |
485 string16 Escape(string16 str); | 525 string16 Escape(string16 str); |
486 | 526 |
| 527 // The manager of this tree of accessibility objects; needed for |
| 528 // global operations like focus tracking. |
| 529 BrowserAccessibilityManagerWin* manager_; |
| 530 // The parent of this object, may be NULL if we're the root object. |
| 531 BrowserAccessibilityWin* parent_; |
| 532 // The ID of this object; globally unique within the browser process. |
| 533 LONG child_id_; |
| 534 // The index of this within its parent object. |
| 535 LONG index_in_parent_; |
| 536 // The ID of this object in the renderer process. |
| 537 int32 renderer_id_; |
| 538 |
| 539 // The children of this object. |
| 540 std::vector<BrowserAccessibilityWin*> children_; |
| 541 |
| 542 // Accessibility metadata from the renderer, used to respond to MSAA |
| 543 // events. |
| 544 string16 name_; |
| 545 string16 value_; |
| 546 std::map<int32, string16> attributes_; |
| 547 std::vector<std::pair<string16, string16> > html_attributes_; |
| 548 |
| 549 int src_role_; |
| 550 LONG role_; |
| 551 LONG state_; |
| 552 string16 role_name_; |
| 553 LONG ia2_role_; |
| 554 LONG ia2_state_; |
| 555 WebKit::WebRect location_; |
| 556 |
487 // COM objects are reference-counted. When we're done with this object | 557 // COM objects are reference-counted. When we're done with this object |
488 // and it's removed from our accessibility tree, a client may still be | 558 // and it's removed from our accessibility tree, a client may still be |
489 // holding onto a pointer to this object, so we mark it as inactive | 559 // holding onto a pointer to this object, so we mark it as inactive |
490 // so that calls to any of this object's methods immediately return | 560 // so that calls to any of this object's methods immediately return |
491 // failure. | 561 // failure. |
492 bool instance_active_; | 562 bool instance_active_; |
493 | 563 |
494 // IAccessible role and state. | |
495 int32 ia_state_; | |
496 int32 ia_role_; | |
497 | |
498 // IAccessible2 role and state. | |
499 int32 ia2_role_; | |
500 int32 ia2_state_; | |
501 | |
502 // Give BrowserAccessibility::Create access to our constructor. | |
503 friend class BrowserAccessibility; | |
504 | |
505 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityWin); | 564 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityWin); |
506 }; | 565 }; |
507 | 566 |
508 #endif // CHROME_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_WIN_H_ | 567 #endif // CHROME_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_WIN_H_ |
OLD | NEW |