| 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 // Initialize this object and mark it as active. | 63 // |
| 64 void Initialize(BrowserAccessibilityManagerWin* manager, | 64 // BrowserAccessibility methods. |
| 65 BrowserAccessibilityWin* parent, | 65 // |
| 66 LONG child_id, | 66 virtual void Initialize(); |
| 67 LONG index_in_parent, | 67 virtual void ReleaseTree(); |
| 68 const webkit_glue::WebAccessibility& src); | 68 virtual void ReleaseReference(); |
| 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(); | |
| 113 | 69 |
| 114 // | 70 // |
| 115 // IAccessible methods. | 71 // IAccessible methods. |
| 116 // | 72 // |
| 117 | 73 |
| 118 // Performs the default action on a given object. | 74 // Performs the default action on a given object. |
| 119 STDMETHODIMP accDoDefaultAction(VARIANT var_id); | 75 STDMETHODIMP accDoDefaultAction(VARIANT var_id); |
| 120 | 76 |
| 121 // Retrieves the child element or child object at a given point on the screen. | 77 // Retrieves the child element or child object at a given point on the screen. |
| 122 STDMETHODIMP accHitTest(LONG x_left, LONG y_top, VARIANT* child); | 78 STDMETHODIMP accHitTest(LONG x_left, LONG y_top, VARIANT* child); |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 // | 438 // |
| 483 // CComObjectRootEx methods. | 439 // CComObjectRootEx methods. |
| 484 // | 440 // |
| 485 | 441 |
| 486 HRESULT WINAPI InternalQueryInterface(void* this_ptr, | 442 HRESULT WINAPI InternalQueryInterface(void* this_ptr, |
| 487 const _ATL_INTMAP_ENTRY* entries, | 443 const _ATL_INTMAP_ENTRY* entries, |
| 488 REFIID iid, | 444 REFIID iid, |
| 489 void** object); | 445 void** object); |
| 490 | 446 |
| 491 private: | 447 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 |
| 492 // Many MSAA methods take a var_id parameter indicating that the operation | 453 // Many MSAA methods take a var_id parameter indicating that the operation |
| 493 // should be performed on a particular child ID, rather than this object. | 454 // should be performed on a particular child ID, rather than this object. |
| 494 // This method tries to figure out the target object from |var_id| and | 455 // This method tries to figure out the target object from |var_id| and |
| 495 // returns a pointer to the target object if it exists, otherwise NULL. | 456 // returns a pointer to the target object if it exists, otherwise NULL. |
| 496 // Does not return a new reference. | 457 // Does not return a new reference. |
| 497 BrowserAccessibilityWin* GetTargetFromChildID(const VARIANT& var_id); | 458 BrowserAccessibilityWin* GetTargetFromChildID(const VARIANT& var_id); |
| 498 | 459 |
| 499 // Initialize the role and state metadata from the role enum and state | 460 // Initialize the role and state metadata from the role enum and state |
| 500 // bitmasks defined in webkit/glue/webaccessibility.h. | 461 // bitmasks defined in webkit/glue/webaccessibility.h. |
| 501 void InitRoleAndState(LONG web_accessibility_role, | 462 void InitRoleAndState(); |
| 502 LONG web_accessibility_state); | |
| 503 | 463 |
| 504 // Return true if this attribute is in the attributes map. | 464 // Return true if this attribute is in the attributes map. |
| 505 bool HasAttribute(WebAccessibility::Attribute attribute); | 465 bool HasAttribute(WebAccessibility::Attribute attribute); |
| 506 | 466 |
| 507 // Retrieve the string value of an attribute from the attribute map and | 467 // Retrieve the string value of an attribute from the attribute map and |
| 508 // returns true if found. | 468 // returns true if found. |
| 509 bool GetAttribute(WebAccessibility::Attribute attribute, string16* value); | 469 bool GetAttribute(WebAccessibility::Attribute attribute, string16* value); |
| 510 | 470 |
| 511 // Retrieve the string value of an attribute from the attribute map and | 471 // Retrieve the string value of an attribute from the attribute map and |
| 512 // if found and nonempty, allocate a new BSTR (with SysAllocString) | 472 // if found and nonempty, allocate a new BSTR (with SysAllocString) |
| 513 // and return S_OK. If not found or empty, return S_FALSE. | 473 // and return S_OK. If not found or empty, return S_FALSE. |
| 514 HRESULT GetAttributeAsBstr( | 474 HRESULT GetAttributeAsBstr( |
| 515 WebAccessibility::Attribute attribute, BSTR* value_bstr); | 475 WebAccessibility::Attribute attribute, BSTR* value_bstr); |
| 516 | 476 |
| 517 // Retrieve the value of an attribute from the attribute map and | 477 // Retrieve the value of an attribute from the attribute map and |
| 518 // if found and nonempty, try to convert it to an integer. | 478 // if found and nonempty, try to convert it to an integer. |
| 519 // Returns true only if both the attribute was found and it was successfully | 479 // Returns true only if both the attribute was found and it was successfully |
| 520 // converted to an integer. | 480 // converted to an integer. |
| 521 bool GetAttributeAsInt( | 481 bool GetAttributeAsInt( |
| 522 WebAccessibility::Attribute attribute, int* value_int); | 482 WebAccessibility::Attribute attribute, int* value_int); |
| 523 | 483 |
| 524 // Escape a string like it would be escaped for a URL or HTML form. | 484 // Escape a string like it would be escaped for a URL or HTML form. |
| 525 string16 Escape(string16 str); | 485 string16 Escape(string16 str); |
| 526 | 486 |
| 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 | |
| 557 // COM objects are reference-counted. When we're done with this object | 487 // COM objects are reference-counted. When we're done with this object |
| 558 // and it's removed from our accessibility tree, a client may still be | 488 // and it's removed from our accessibility tree, a client may still be |
| 559 // holding onto a pointer to this object, so we mark it as inactive | 489 // holding onto a pointer to this object, so we mark it as inactive |
| 560 // so that calls to any of this object's methods immediately return | 490 // so that calls to any of this object's methods immediately return |
| 561 // failure. | 491 // failure. |
| 562 bool instance_active_; | 492 bool instance_active_; |
| 563 | 493 |
| 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 |
| 564 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityWin); | 505 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityWin); |
| 565 }; | 506 }; |
| 566 | 507 |
| 567 #endif // CHROME_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_WIN_H_ | 508 #endif // CHROME_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_WIN_H_ |
| OLD | NEW |