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 |
18 #include "webkit/glue/webaccessibility.h" | 21 #include "webkit/glue/webaccessibility.h" |
19 | 22 |
20 using webkit_glue::WebAccessibility; | 23 using webkit_glue::WebAccessibility; |
21 | 24 |
22 //////////////////////////////////////////////////////////////////////////////// | 25 //////////////////////////////////////////////////////////////////////////////// |
23 // | 26 // |
24 // BrowserAccessibility | 27 // BrowserAccessibility |
25 // | 28 // |
26 // Class implementing the MSAA IAccessible COM interface for the | 29 // Class implementing the MSAA IAccessible COM interface for the |
27 // Browser-Renderer communication of MSAA information, providing accessibility | 30 // Browser-Renderer communication of MSAA information, providing accessibility |
28 // to be used by screen readers and other assistive technology (AT). | 31 // to be used by screen readers and other assistive technology (AT). |
29 // | 32 // |
30 //////////////////////////////////////////////////////////////////////////////// | 33 //////////////////////////////////////////////////////////////////////////////// |
31 class ATL_NO_VTABLE BrowserAccessibility | 34 class ATL_NO_VTABLE BrowserAccessibility |
32 : public CComObjectRootEx<CComMultiThreadModel>, | 35 : public CComObjectRootEx<CComMultiThreadModel>, |
33 public IDispatchImpl<IAccessible2, &IID_IAccessible2, | 36 public IDispatchImpl<IAccessible2, &IID_IAccessible2, |
34 &LIBID_IAccessible2Lib>, | 37 &LIBID_IAccessible2Lib>, |
35 public IAccessibleImage, | 38 public IAccessibleImage, |
36 public IAccessibleText, | 39 public IAccessibleText, |
37 public IServiceProvider { | 40 public IServiceProvider, |
| 41 public ISimpleDOMDocument, |
| 42 public ISimpleDOMNode, |
| 43 public ISimpleDOMText { |
38 public: | 44 public: |
39 BEGIN_COM_MAP(BrowserAccessibility) | 45 BEGIN_COM_MAP(BrowserAccessibility) |
40 COM_INTERFACE_ENTRY2(IDispatch, IAccessible2) | 46 COM_INTERFACE_ENTRY2(IDispatch, IAccessible2) |
41 COM_INTERFACE_ENTRY2(IAccessible, IAccessible2) | 47 COM_INTERFACE_ENTRY2(IAccessible, IAccessible2) |
42 COM_INTERFACE_ENTRY(IAccessible2) | 48 COM_INTERFACE_ENTRY(IAccessible2) |
43 COM_INTERFACE_ENTRY(IAccessibleImage) | 49 COM_INTERFACE_ENTRY(IAccessibleImage) |
44 COM_INTERFACE_ENTRY(IAccessibleText) | 50 COM_INTERFACE_ENTRY(IAccessibleText) |
45 COM_INTERFACE_ENTRY(IServiceProvider) | 51 COM_INTERFACE_ENTRY(IServiceProvider) |
| 52 COM_INTERFACE_ENTRY(ISimpleDOMDocument) |
| 53 COM_INTERFACE_ENTRY(ISimpleDOMNode) |
| 54 COM_INTERFACE_ENTRY(ISimpleDOMText) |
46 END_COM_MAP() | 55 END_COM_MAP() |
47 | 56 |
48 BrowserAccessibility(); | 57 BrowserAccessibility(); |
49 | 58 |
50 virtual ~BrowserAccessibility(); | 59 virtual ~BrowserAccessibility(); |
51 | 60 |
52 // Initialize this object and mark it as active. | 61 // Initialize this object and mark it as active. |
53 void Initialize(BrowserAccessibilityManager* manager, | 62 void Initialize(BrowserAccessibilityManager* manager, |
54 BrowserAccessibility* parent, | 63 BrowserAccessibility* parent, |
55 LONG child_id, | 64 LONG child_id, |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 return E_NOTIMPL; | 340 return E_NOTIMPL; |
332 } | 341 } |
333 STDMETHODIMP get_newText(IA2TextSegment* new_text) { | 342 STDMETHODIMP get_newText(IA2TextSegment* new_text) { |
334 return E_NOTIMPL; | 343 return E_NOTIMPL; |
335 } | 344 } |
336 STDMETHODIMP get_oldText(IA2TextSegment* old_text) { | 345 STDMETHODIMP get_oldText(IA2TextSegment* old_text) { |
337 return E_NOTIMPL; | 346 return E_NOTIMPL; |
338 } | 347 } |
339 | 348 |
340 // | 349 // |
| 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 // |
341 // IServiceProvider methods. | 473 // IServiceProvider methods. |
342 // | 474 // |
343 | 475 |
344 STDMETHODIMP QueryService(REFGUID guidService, REFIID riid, void** object); | 476 STDMETHODIMP QueryService(REFGUID guidService, REFIID riid, void** object); |
345 | 477 |
346 // | 478 // |
347 // CComObjectRootEx methods. | 479 // CComObjectRootEx methods. |
348 // | 480 // |
349 | 481 |
350 HRESULT WINAPI InternalQueryInterface(void* this_ptr, | 482 HRESULT WINAPI InternalQueryInterface(void* this_ptr, |
(...skipping 14 matching lines...) Expand all Loading... |
365 void InitRoleAndState(LONG web_accessibility_role, | 497 void InitRoleAndState(LONG web_accessibility_role, |
366 LONG web_accessibility_state); | 498 LONG web_accessibility_state); |
367 | 499 |
368 // Return true if this attribute is in the attributes map. | 500 // Return true if this attribute is in the attributes map. |
369 bool HasAttribute(WebAccessibility::Attribute attribute); | 501 bool HasAttribute(WebAccessibility::Attribute attribute); |
370 | 502 |
371 // Retrieve the string value of an attribute from the attribute map and | 503 // Retrieve the string value of an attribute from the attribute map and |
372 // returns true if found. | 504 // returns true if found. |
373 bool GetAttribute(WebAccessibility::Attribute attribute, string16* value); | 505 bool GetAttribute(WebAccessibility::Attribute attribute, string16* value); |
374 | 506 |
| 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 |
375 // The manager of this tree of accessibility objects; needed for | 516 // The manager of this tree of accessibility objects; needed for |
376 // global operations like focus tracking. | 517 // global operations like focus tracking. |
377 BrowserAccessibilityManager* manager_; | 518 BrowserAccessibilityManager* manager_; |
378 // The parent of this object, may be NULL if we're the root object. | 519 // The parent of this object, may be NULL if we're the root object. |
379 BrowserAccessibility* parent_; | 520 BrowserAccessibility* parent_; |
380 // The ID of this object; globally unique within the browser process. | 521 // The ID of this object; globally unique within the browser process. |
381 LONG child_id_; | 522 LONG child_id_; |
382 // The index of this within its parent object. | 523 // The index of this within its parent object. |
383 LONG index_in_parent_; | 524 LONG index_in_parent_; |
384 // The ID of this object in the renderer process. | 525 // The ID of this object in the renderer process. |
385 int32 renderer_id_; | 526 int32 renderer_id_; |
386 | 527 |
387 // The children of this object. | 528 // The children of this object. |
388 std::vector<BrowserAccessibility*> children_; | 529 std::vector<BrowserAccessibility*> children_; |
389 | 530 |
390 // Accessibility metadata from the renderer, used to respond to MSAA | 531 // Accessibility metadata from the renderer, used to respond to MSAA |
391 // events. | 532 // events. |
392 string16 name_; | 533 string16 name_; |
393 string16 value_; | 534 string16 value_; |
394 std::map<int32, string16> attributes_; | 535 std::map<int32, string16> attributes_; |
| 536 std::vector<std::pair<string16, string16> > html_attributes_; |
395 | 537 |
396 LONG role_; | 538 LONG role_; |
397 LONG state_; | 539 LONG state_; |
398 string16 role_name_; | 540 string16 role_name_; |
399 LONG ia2_role_; | 541 LONG ia2_role_; |
400 LONG ia2_state_; | 542 LONG ia2_state_; |
401 WebKit::WebRect location_; | 543 WebKit::WebRect location_; |
402 | 544 |
403 // COM objects are reference-counted. When we're done with this object | 545 // COM objects are reference-counted. When we're done with this object |
404 // and it's removed from our accessibility tree, a client may still be | 546 // and it's removed from our accessibility tree, a client may still be |
405 // holding onto a pointer to this object, so we mark it as inactive | 547 // holding onto a pointer to this object, so we mark it as inactive |
406 // so that calls to any of this object's methods immediately return | 548 // so that calls to any of this object's methods immediately return |
407 // failure. | 549 // failure. |
408 bool instance_active_; | 550 bool instance_active_; |
409 | 551 |
410 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibility); | 552 DISALLOW_COPY_AND_ASSIGN(BrowserAccessibility); |
411 }; | 553 }; |
412 | 554 |
413 #endif // CHROME_BROWSER_BROWSER_ACCESSIBILITY_WIN_H_ | 555 #endif // CHROME_BROWSER_BROWSER_ACCESSIBILITY_WIN_H_ |
OLD | NEW |