| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright (C) 2008, 2009, 2011 Apple Inc. All rights reserved. | 3 * Copyright (C) 2008, 2009, 2011 Apple Inc. All rights reserved. |
| 4 * Copyright (C) 2008 Nuanti Ltd. | 4 * Copyright (C) 2008 Nuanti Ltd. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * | 9 * |
| 10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 kTextUnderElementAny // If the text is unimportant, just whether or not it's | 114 kTextUnderElementAny // If the text is unimportant, just whether or not it's |
| 115 // present | 115 // present |
| 116 }; | 116 }; |
| 117 | 117 |
| 118 enum class AXBoolAttribute {}; | 118 enum class AXBoolAttribute {}; |
| 119 | 119 |
| 120 class AXSparseAttributeClient { | 120 class AXSparseAttributeClient { |
| 121 public: | 121 public: |
| 122 virtual void AddBoolAttribute(AXBoolAttribute, bool) = 0; | 122 virtual void AddBoolAttribute(AXBoolAttribute, bool) = 0; |
| 123 virtual void AddStringAttribute(AXStringAttribute, const String&) = 0; | 123 virtual void AddStringAttribute(AXStringAttribute, const String&) = 0; |
| 124 virtual void AddObjectAttribute(AXObjectAttribute, AXObjectImpl&) = 0; | 124 virtual void AddObjectAttribute(AXObjectAttribute, AXObject&) = 0; |
| 125 virtual void AddObjectVectorAttribute(AXObjectVectorAttribute, | 125 virtual void AddObjectVectorAttribute(AXObjectVectorAttribute, |
| 126 HeapVector<Member<AXObjectImpl>>&) = 0; | 126 HeapVector<Member<AXObject>>&) = 0; |
| 127 }; | 127 }; |
| 128 | 128 |
| 129 // The potential native HTML-based text (name, description or placeholder) | 129 // The potential native HTML-based text (name, description or placeholder) |
| 130 // sources for an element. See | 130 // sources for an element. See |
| 131 // http://rawgit.com/w3c/aria/master/html-aam/html-aam.html#accessible-name-and-
description-calculation | 131 // http://rawgit.com/w3c/aria/master/html-aam/html-aam.html#accessible-name-and-
description-calculation |
| 132 enum AXTextFromNativeHTML { | 132 enum AXTextFromNativeHTML { |
| 133 kAXTextFromNativeHTMLUninitialized = -1, | 133 kAXTextFromNativeHTMLUninitialized = -1, |
| 134 kAXTextFromNativeHTMLFigcaption, | 134 kAXTextFromNativeHTMLFigcaption, |
| 135 kAXTextFromNativeHTMLLabel, | 135 kAXTextFromNativeHTMLLabel, |
| 136 kAXTextFromNativeHTMLLabelFor, | 136 kAXTextFromNativeHTMLLabelFor, |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::DescriptionSource); | 243 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::DescriptionSource); |
| 244 | 244 |
| 245 namespace blink { | 245 namespace blink { |
| 246 | 246 |
| 247 class MODULES_EXPORT AXObjectImpl | 247 class MODULES_EXPORT AXObjectImpl |
| 248 : public GarbageCollectedFinalized<AXObjectImpl>, | 248 : public GarbageCollectedFinalized<AXObjectImpl>, |
| 249 public AXObject { | 249 public AXObject { |
| 250 WTF_MAKE_NONCOPYABLE(AXObjectImpl); | 250 WTF_MAKE_NONCOPYABLE(AXObjectImpl); |
| 251 | 251 |
| 252 public: | 252 public: |
| 253 typedef HeapVector<Member<AXObjectImpl>> AXObjectVector; | 253 typedef HeapVector<Member<AXObjectImpl>> AXObjectImplVector; |
| 254 | |
| 255 struct AXRange { | |
| 256 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | |
| 257 // The deepest descendant in which the range starts. | |
| 258 // (nullptr means the current object.) | |
| 259 Persistent<AXObjectImpl> anchor_object; | |
| 260 // The number of characters and child objects in the anchor object | |
| 261 // before the range starts. | |
| 262 int anchor_offset; | |
| 263 // When the same character offset could correspond to two possible | |
| 264 // cursor positions, upstream means it's on the previous line rather | |
| 265 // than the next line. | |
| 266 TextAffinity anchor_affinity; | |
| 267 | |
| 268 // The deepest descendant in which the range ends. | |
| 269 // (nullptr means the current object.) | |
| 270 Persistent<AXObjectImpl> focus_object; | |
| 271 // The number of characters and child objects in the focus object | |
| 272 // before the range ends. | |
| 273 int focus_offset; | |
| 274 // When the same character offset could correspond to two possible | |
| 275 // cursor positions, upstream means it's on the previous line rather | |
| 276 // than the next line. | |
| 277 TextAffinity focus_affinity; | |
| 278 | |
| 279 AXRange() | |
| 280 : anchor_object(nullptr), | |
| 281 anchor_offset(-1), | |
| 282 anchor_affinity(TextAffinity::kUpstream), | |
| 283 focus_object(nullptr), | |
| 284 focus_offset(-1), | |
| 285 focus_affinity(TextAffinity::kDownstream) {} | |
| 286 | |
| 287 AXRange(int start_offset, int end_offset) | |
| 288 : anchor_object(nullptr), | |
| 289 anchor_offset(start_offset), | |
| 290 anchor_affinity(TextAffinity::kUpstream), | |
| 291 focus_object(nullptr), | |
| 292 focus_offset(end_offset), | |
| 293 focus_affinity(TextAffinity::kDownstream) {} | |
| 294 | |
| 295 AXRange(AXObjectImpl* anchor_object, | |
| 296 int anchor_offset, | |
| 297 TextAffinity anchor_affinity, | |
| 298 AXObjectImpl* focus_object, | |
| 299 int focus_offset, | |
| 300 TextAffinity focus_affinity) | |
| 301 : anchor_object(anchor_object), | |
| 302 anchor_offset(anchor_offset), | |
| 303 anchor_affinity(anchor_affinity), | |
| 304 focus_object(focus_object), | |
| 305 focus_offset(focus_offset), | |
| 306 focus_affinity(focus_affinity) {} | |
| 307 | |
| 308 bool IsValid() const { | |
| 309 return ((anchor_object && focus_object) || | |
| 310 (!anchor_object && !focus_object)) && | |
| 311 anchor_offset >= 0 && focus_offset >= 0; | |
| 312 } | |
| 313 | |
| 314 // Determines if the range only refers to text offsets under the current | |
| 315 // object. | |
| 316 bool IsSimple() const { | |
| 317 return anchor_object == focus_object || !anchor_object || !focus_object; | |
| 318 } | |
| 319 }; | |
| 320 | 254 |
| 321 protected: | 255 protected: |
| 322 AXObjectImpl(AXObjectCacheImpl&); | 256 AXObjectImpl(AXObjectCacheImpl&); |
| 323 | 257 |
| 324 public: | 258 public: |
| 325 virtual ~AXObjectImpl(); | 259 virtual ~AXObjectImpl(); |
| 326 DECLARE_VIRTUAL_TRACE(); | 260 DECLARE_VIRTUAL_TRACE(); |
| 327 | 261 |
| 328 static unsigned NumberOfLiveAXObjects() { return number_of_live_ax_objects_; } | 262 static unsigned NumberOfLiveAXObjects() { return number_of_live_ax_objects_; } |
| 329 | 263 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 // Determine subclass type. | 300 // Determine subclass type. |
| 367 virtual bool IsAXNodeObject() const { return false; } | 301 virtual bool IsAXNodeObject() const { return false; } |
| 368 virtual bool IsAXLayoutObject() const { return false; } | 302 virtual bool IsAXLayoutObject() const { return false; } |
| 369 virtual bool IsAXInlineTextBox() const { return false; } | 303 virtual bool IsAXInlineTextBox() const { return false; } |
| 370 virtual bool IsAXListBox() const { return false; } | 304 virtual bool IsAXListBox() const { return false; } |
| 371 virtual bool IsAXListBoxOption() const { return false; } | 305 virtual bool IsAXListBoxOption() const { return false; } |
| 372 virtual bool IsAXRadioInput() const { return false; } | 306 virtual bool IsAXRadioInput() const { return false; } |
| 373 virtual bool IsAXSVGRoot() const { return false; } | 307 virtual bool IsAXSVGRoot() const { return false; } |
| 374 | 308 |
| 375 // Check object role or purpose. | 309 // Check object role or purpose. |
| 376 virtual AccessibilityRole RoleValue() const { return role_; } | 310 virtual AccessibilityRole RoleValue() const override { return role_; } |
| 377 bool IsARIATextControl() const; | 311 bool IsARIATextControl() const; |
| 378 virtual bool IsARIATreeGridRow() const { return false; } | 312 virtual bool IsARIATreeGridRow() const { return false; } |
| 379 virtual bool IsAXTable() const { return false; } | 313 virtual bool IsAXTable() const { return false; } |
| 380 virtual bool IsAnchor() const { return false; } | 314 virtual bool IsAnchor() const { return false; } |
| 381 bool IsButton() const; | 315 bool IsButton() const; |
| 382 bool IsCheckable() const; | 316 bool IsCheckable() const; |
| 383 bool IsCanvas() const { return RoleValue() == kCanvasRole; } | 317 bool IsCanvas() const { return RoleValue() == kCanvasRole; } |
| 384 bool IsCheckbox() const { return RoleValue() == kCheckBoxRole; } | 318 bool IsCheckbox() const { return RoleValue() == kCheckBoxRole; } |
| 385 bool IsCheckboxOrRadio() const { return IsCheckbox() || IsRadioButton(); } | 319 bool IsCheckboxOrRadio() const { return IsCheckbox() || IsRadioButton(); } |
| 386 bool IsColorWell() const { return RoleValue() == kColorWellRole; } | 320 bool IsColorWell() const { return RoleValue() == kColorWellRole; } |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 virtual bool IsSelectedOptionActive() const { return false; } | 393 virtual bool IsSelectedOptionActive() const { return false; } |
| 460 virtual bool IsVisible() const { return true; } | 394 virtual bool IsVisible() const { return true; } |
| 461 virtual bool IsVisited() const { return false; } | 395 virtual bool IsVisited() const { return false; } |
| 462 | 396 |
| 463 // Check whether certain properties can be modified. | 397 // Check whether certain properties can be modified. |
| 464 virtual bool CanSetFocusAttribute() const { return false; } | 398 virtual bool CanSetFocusAttribute() const { return false; } |
| 465 virtual bool CanSetValueAttribute() const { return false; } | 399 virtual bool CanSetValueAttribute() const { return false; } |
| 466 virtual bool CanSetSelectedAttribute() const { return false; } | 400 virtual bool CanSetSelectedAttribute() const { return false; } |
| 467 | 401 |
| 468 // Whether objects are ignored, i.e. not included in the tree. | 402 // Whether objects are ignored, i.e. not included in the tree. |
| 469 bool AccessibilityIsIgnored(); | 403 bool AccessibilityIsIgnored() override; |
| 470 typedef HeapVector<IgnoredReason> IgnoredReasons; | 404 typedef HeapVector<IgnoredReason> IgnoredReasons; |
| 471 virtual bool ComputeAccessibilityIsIgnored(IgnoredReasons* = nullptr) const { | 405 virtual bool ComputeAccessibilityIsIgnored(IgnoredReasons* = nullptr) const { |
| 472 return true; | 406 return true; |
| 473 } | 407 } |
| 474 bool AccessibilityIsIgnoredByDefault(IgnoredReasons* = nullptr) const; | 408 bool AccessibilityIsIgnoredByDefault(IgnoredReasons* = nullptr) const; |
| 475 AXObjectInclusion AccessibilityPlatformIncludesObject() const; | 409 AXObjectInclusion AccessibilityPlatformIncludesObject() const; |
| 476 virtual AXObjectInclusion DefaultObjectInclusion( | 410 virtual AXObjectInclusion DefaultObjectInclusion( |
| 477 IgnoredReasons* = nullptr) const; | 411 IgnoredReasons* = nullptr) const; |
| 478 bool IsInertOrAriaHidden() const; | 412 bool IsInertOrAriaHidden() const; |
| 479 const AXObjectImpl* AriaHiddenRoot() const; | 413 const AXObjectImpl* AriaHiddenRoot() const; |
| 480 bool ComputeIsInertOrAriaHidden(IgnoredReasons* = nullptr) const; | 414 bool ComputeIsInertOrAriaHidden(IgnoredReasons* = nullptr) const; |
| 481 bool IsDescendantOfLeafNode() const; | 415 bool IsDescendantOfLeafNode() const; |
| 482 AXObjectImpl* LeafNodeAncestor() const; | 416 AXObjectImpl* LeafNodeAncestor() const; |
| 483 bool IsDescendantOfDisabledNode() const; | 417 bool IsDescendantOfDisabledNode() const; |
| 484 const AXObjectImpl* DisabledAncestor() const; | 418 const AXObjectImpl* DisabledAncestor() const; |
| 485 bool LastKnownIsIgnoredValue(); | 419 bool LastKnownIsIgnoredValue(); |
| 486 void SetLastKnownIsIgnoredValue(bool); | 420 void SetLastKnownIsIgnoredValue(bool); |
| 487 bool HasInheritedPresentationalRole() const; | 421 bool HasInheritedPresentationalRole() const; |
| 488 bool IsPresentationalChild() const; | 422 bool IsPresentationalChild() const; |
| 489 bool AncestorExposesActiveDescendant() const; | 423 bool AncestorExposesActiveDescendant() const; |
| 490 bool ComputeAncestorExposesActiveDescendant() const; | 424 bool ComputeAncestorExposesActiveDescendant() const; |
| 491 | 425 |
| 492 // | 426 // |
| 493 // Accessible name calculation | 427 // Accessible name calculation |
| 494 // | 428 // |
| 495 | 429 |
| 496 // Retrieves the accessible name of the object, an enum indicating where the | 430 virtual String GetName(AXNameFrom&, |
| 497 // name was derived from, and a list of objects that were used to derive the | 431 AXObjectVector* name_objects) const override; |
| 498 // name, if any. | |
| 499 virtual String GetName(AXNameFrom&, AXObjectVector* name_objects) const; | |
| 500 | 432 |
| 501 typedef HeapVector<NameSource> NameSources; | 433 typedef HeapVector<NameSource> NameSources; |
| 502 // Retrieves the accessible name of the object and a list of all potential | 434 // Retrieves the accessible name of the object and a list of all potential |
| 503 // sources for the name, indicating which were used. | 435 // sources for the name, indicating which were used. |
| 504 virtual String GetName(NameSources*) const; | 436 virtual String GetName(NameSources*) const; |
| 505 | 437 |
| 506 typedef HeapVector<DescriptionSource> DescriptionSources; | 438 virtual String Description( |
| 507 // Takes the result of nameFrom from calling |name|, above, and retrieves the | 439 AXNameFrom, |
| 508 // accessible description of the object, which is secondary to |name|, an enum | 440 AXDescriptionFrom&, |
| 509 // indicating where the description was derived from, and a list of objects | 441 AXObjectVector* description_objects) const override { |
| 510 // that were used to derive the description, if any. | |
| 511 virtual String Description(AXNameFrom, | |
| 512 AXDescriptionFrom&, | |
| 513 AXObjectVector* description_objects) const { | |
| 514 return String(); | 442 return String(); |
| 515 } | 443 } |
| 516 | 444 |
| 517 // Same as above, but returns a list of all potential sources for the | 445 // Same as above, but returns a list of all potential sources for the |
| 518 // description, indicating which were used. | 446 // description, indicating which were used. |
| 519 virtual String Description(AXNameFrom, | 447 virtual String Description(AXNameFrom, |
| 520 AXDescriptionFrom&, | 448 AXDescriptionFrom&, |
| 521 DescriptionSources*, | 449 DescriptionSources*, |
| 522 AXRelatedObjectVector*) const { | 450 AXRelatedObjectVector*) const { |
| 523 return String(); | 451 return String(); |
| 524 } | 452 } |
| 525 | 453 |
| 526 // Takes the result of nameFrom and descriptionFrom from calling |name| and | 454 virtual String Placeholder(AXNameFrom) const override { return String(); } |
| 527 // |description|, above, and retrieves the placeholder of the object, if | |
| 528 // present and if it wasn't already exposed by one of the two functions above. | |
| 529 virtual String Placeholder(AXNameFrom) const { return String(); } | |
| 530 | 455 |
| 531 // Internal functions used by name and description, above. | 456 // Internal functions used by name and description, above. |
| 532 typedef HeapHashSet<Member<const AXObjectImpl>> AXObjectSet; | 457 typedef HeapHashSet<Member<const AXObjectImpl>> AXObjectSet; |
| 533 virtual String TextAlternative(bool recursive, | 458 virtual String TextAlternative(bool recursive, |
| 534 bool in_aria_labelled_by_traversal, | 459 bool in_aria_labelled_by_traversal, |
| 535 AXObjectSet& visited, | 460 AXObjectSet& visited, |
| 536 AXNameFrom& name_from, | 461 AXNameFrom& name_from, |
| 537 AXRelatedObjectVector* related_objects, | 462 AXRelatedObjectVector* related_objects, |
| 538 NameSources* name_sources) const { | 463 NameSources* name_sources) const { |
| 539 return String(); | 464 return String(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 551 // this object would return text that came from the an HTML label element or | 476 // this object would return text that came from the an HTML label element or |
| 552 // not. This is intended to be faster than calling |name| or | 477 // not. This is intended to be faster than calling |name| or |
| 553 // |textAlternative|, and without side effects (it won't call | 478 // |textAlternative|, and without side effects (it won't call |
| 554 // axObjectCache->getOrCreate). | 479 // axObjectCache->getOrCreate). |
| 555 virtual bool NameFromLabelElement() const { return false; } | 480 virtual bool NameFromLabelElement() const { return false; } |
| 556 | 481 |
| 557 // | 482 // |
| 558 // Properties of static elements. | 483 // Properties of static elements. |
| 559 // | 484 // |
| 560 | 485 |
| 561 virtual const AtomicString& AccessKey() const { return g_null_atom; } | 486 virtual const AtomicString& AccessKey() const override { return g_null_atom; } |
| 562 RGBA32 BackgroundColor() const; | 487 RGBA32 BackgroundColor() const; |
| 563 virtual RGBA32 ComputeBackgroundColor() const { return Color::kTransparent; } | 488 virtual RGBA32 ComputeBackgroundColor() const { return Color::kTransparent; } |
| 564 virtual RGBA32 GetColor() const { return Color::kBlack; } | 489 virtual RGBA32 GetColor() const { return Color::kBlack; } |
| 565 // Used by objects of role ColorWellRole. | 490 // Used by objects of role ColorWellRole. |
| 566 virtual RGBA32 ColorValue() const { return Color::kTransparent; } | 491 virtual RGBA32 ColorValue() const { return Color::kTransparent; } |
| 567 virtual bool CanvasHasFallbackContent() const { return false; } | 492 virtual bool CanvasHasFallbackContent() const override { return false; } |
| 568 virtual String FontFamily() const { return g_null_atom; } | 493 virtual String FontFamily() const override { return g_null_atom; } |
| 569 // Font size is in pixels. | 494 virtual float FontSize() const override { return 0.0f; } |
| 570 virtual float FontSize() const { return 0.0f; } | |
| 571 // Value should be 1-based. 0 means not supported. | 495 // Value should be 1-based. 0 means not supported. |
| 572 virtual int HeadingLevel() const { return 0; } | 496 virtual int HeadingLevel() const override { return 0; } |
| 573 // Value should be 1-based. 0 means not supported. | 497 // Value should be 1-based. 0 means not supported. |
| 574 virtual unsigned HierarchicalLevel() const { return 0; } | 498 virtual unsigned HierarchicalLevel() const override { return 0; } |
| 575 // Return the content of an image or canvas as an image data url in | 499 virtual String ImageDataUrl(const IntSize& max_size) const override { |
| 576 // PNG format. If |maxSize| is not empty and if the image is larger than | |
| 577 // those dimensions, the image will be resized proportionally first to fit. | |
| 578 virtual String ImageDataUrl(const IntSize& max_size) const { | |
| 579 return g_null_atom; | 500 return g_null_atom; |
| 580 } | 501 } |
| 581 virtual AXObjectImpl* InPageLinkTarget() const { return nullptr; } | 502 virtual AXObject* InPageLinkTarget() const override { return nullptr; } |
| 582 virtual AccessibilityOrientation Orientation() const; | 503 virtual AccessibilityOrientation Orientation() const override; |
| 583 virtual String GetText() const { return String(); } | 504 virtual String GetText() const { return String(); } |
| 584 virtual AccessibilityTextDirection GetTextDirection() const { | 505 virtual AccessibilityTextDirection GetTextDirection() const override { |
| 585 return kAccessibilityTextDirectionLTR; | 506 return kAccessibilityTextDirectionLTR; |
| 586 } | 507 } |
| 587 virtual int TextLength() const { return 0; } | 508 virtual int TextLength() const { return 0; } |
| 588 virtual TextStyle GetTextStyle() const { return kTextStyleNone; } | 509 virtual TextStyle GetTextStyle() const override { return kTextStyleNone; } |
| 589 virtual AXObjectVector RadioButtonsInGroup() const { | 510 virtual AXObjectVector RadioButtonsInGroup() const override { |
| 590 return AXObjectVector(); | 511 return AXObjectVector(); |
| 591 } | 512 } |
| 592 virtual KURL Url() const { return KURL(); } | 513 virtual KURL Url() const override { return KURL(); } |
| 593 | 514 |
| 594 // Load inline text boxes for just this node, even if | 515 virtual void LoadInlineTextBoxes() override {} |
| 595 // settings->inlineTextBoxAccessibilityEnabled() is false. | |
| 596 virtual void LoadInlineTextBoxes() {} | |
| 597 | 516 |
| 598 // Walk the AXObjects on the same line. This is supported on any | 517 virtual AXObject* NextOnLine() const override { return nullptr; } |
| 599 // object type but primarily intended to be used for inline text boxes. | 518 virtual AXObject* PreviousOnLine() const override { return nullptr; } |
| 600 virtual AXObjectImpl* NextOnLine() const { return nullptr; } | |
| 601 virtual AXObjectImpl* PreviousOnLine() const { return nullptr; } | |
| 602 | 519 |
| 603 // For all node objects. The start and end character offset of each | |
| 604 // marker, such as spelling or grammar error. | |
| 605 virtual void Markers(Vector<DocumentMarker::MarkerType>&, | 520 virtual void Markers(Vector<DocumentMarker::MarkerType>&, |
| 606 Vector<AXRange>&) const {} | 521 Vector<AXRange>&) const override {} |
| 607 // For an inline text box. | 522 virtual void TextCharacterOffsets(Vector<int>&) const override {} |
| 608 // The integer horizontal pixel offset of each character in the string; | 523 virtual void GetWordBoundaries(Vector<AXRange>&) const override {} |
| 609 // negative values for RTL. | |
| 610 virtual void TextCharacterOffsets(Vector<int>&) const {} | |
| 611 // The start and end character offset of each word in the object's text. | |
| 612 virtual void GetWordBoundaries(Vector<AXRange>&) const {} | |
| 613 | 524 |
| 614 // Properties of interactive elements. | 525 // Properties of interactive elements. |
| 615 AXDefaultActionVerb Action() const; | 526 AXDefaultActionVerb Action() const; |
| 616 AccessibilityButtonState CheckedState() const; | 527 AccessibilityButtonState CheckedState() const; |
| 617 virtual AriaCurrentState GetAriaCurrentState() const { | 528 virtual AriaCurrentState GetAriaCurrentState() const { |
| 618 return kAriaCurrentStateUndefined; | 529 return kAriaCurrentStateUndefined; |
| 619 } | 530 } |
| 620 virtual InvalidState GetInvalidState() const { | 531 virtual InvalidState GetInvalidState() const override { |
| 621 return kInvalidStateUndefined; | 532 return kInvalidStateUndefined; |
| 622 } | 533 } |
| 623 // Only used when invalidState() returns InvalidStateOther. | 534 // Only used when invalidState() returns InvalidStateOther. |
| 624 virtual String AriaInvalidValue() const { return String(); } | 535 virtual String AriaInvalidValue() const override { return String(); } |
| 625 virtual String ValueDescription() const { return String(); } | 536 virtual String ValueDescription() const override { return String(); } |
| 626 virtual float ValueForRange() const { return 0.0f; } | 537 virtual float ValueForRange() const override { return 0.0f; } |
| 627 virtual float MaxValueForRange() const { return 0.0f; } | 538 virtual float MaxValueForRange() const override { return 0.0f; } |
| 628 virtual float MinValueForRange() const { return 0.0f; } | 539 virtual float MinValueForRange() const override { return 0.0f; } |
| 629 virtual String StringValue() const { return String(); } | 540 virtual String StringValue() const override { return String(); } |
| 630 | 541 |
| 631 // ARIA attributes. | 542 // ARIA attributes. |
| 632 virtual AXObjectImpl* ActiveDescendant() { return nullptr; } | 543 virtual AXObjectImpl* ActiveDescendant() { return nullptr; } |
| 633 virtual String AriaAutoComplete() const { return String(); } | 544 virtual String AriaAutoComplete() const { return String(); } |
| 634 virtual void AriaOwnsElements(AXObjectVector& owns) const {} | 545 virtual void AriaOwnsElements(AXObjectImplVector& owns) const {} |
| 635 virtual void AriaDescribedbyElements(AXObjectVector&) const {} | 546 virtual void AriaDescribedbyElements(AXObjectImplVector&) const {} |
| 636 virtual void AriaLabelledbyElements(AXObjectVector&) const {} | 547 virtual void AriaLabelledbyElements(AXObjectImplVector&) const {} |
| 637 virtual bool AriaHasPopup() const { return false; } | 548 virtual bool AriaHasPopup() const { return false; } |
| 638 virtual bool IsEditable() const { return false; } | 549 virtual bool IsEditable() const { return false; } |
| 639 bool IsMultiline() const; | 550 bool IsMultiline() const; |
| 640 virtual bool IsRichlyEditable() const { return false; } | 551 virtual bool IsRichlyEditable() const { return false; } |
| 641 bool AriaPressedIsPresent() const; | 552 bool AriaPressedIsPresent() const; |
| 642 virtual AccessibilityRole AriaRoleAttribute() const { return kUnknownRole; } | 553 virtual AccessibilityRole AriaRoleAttribute() const { return kUnknownRole; } |
| 643 virtual bool AriaRoleHasPresentationalChildren() const { return false; } | 554 virtual bool AriaRoleHasPresentationalChildren() const { return false; } |
| 644 virtual AXObjectImpl* AncestorForWhichThisIsAPresentationalChild() const { | 555 virtual AXObjectImpl* AncestorForWhichThisIsAPresentationalChild() const { |
| 645 return 0; | 556 return 0; |
| 646 } | 557 } |
| 647 bool SupportsActiveDescendant() const; | 558 bool SupportsActiveDescendant() const; |
| 648 bool SupportsARIAAttributes() const; | 559 bool SupportsARIAAttributes() const; |
| 649 virtual bool SupportsARIADragging() const { return false; } | 560 virtual bool SupportsARIADragging() const { return false; } |
| 650 virtual bool SupportsARIADropping() const { return false; } | 561 virtual bool SupportsARIADropping() const { return false; } |
| 651 virtual bool SupportsARIAFlowTo() const { return false; } | 562 virtual bool SupportsARIAFlowTo() const { return false; } |
| 652 virtual bool SupportsARIAOwns() const { return false; } | 563 virtual bool SupportsARIAOwns() const { return false; } |
| 653 bool SupportsRangeValue() const; | 564 bool SupportsRangeValue() const override; |
| 654 virtual SortDirection GetSortDirection() const { | 565 virtual SortDirection GetSortDirection() const { |
| 655 return kSortDirectionUndefined; | 566 return kSortDirectionUndefined; |
| 656 } | 567 } |
| 657 | 568 |
| 658 // Returns 0-based index. | 569 // Returns 0-based index. |
| 659 int IndexInParent() const; | 570 int IndexInParent() const; |
| 660 | 571 |
| 661 // Value should be 1-based. 0 means not supported. | 572 // Value should be 1-based. 0 means not supported. |
| 662 virtual int PosInSet() const { return 0; } | 573 virtual int PosInSet() const { return 0; } |
| 663 virtual int SetSize() const { return 0; } | 574 virtual int SetSize() const { return 0; } |
| 664 bool SupportsSetSizeAndPosInSet() const; | 575 bool SupportsSetSizeAndPosInSet() const; |
| 665 | 576 |
| 666 // ARIA live-region features. | 577 // ARIA live-region features. |
| 667 bool IsLiveRegion() const; | 578 bool IsLiveRegion() const; |
| 668 AXObjectImpl* LiveRegionRoot() const; | 579 AXObject* LiveRegionRoot() const override; |
| 669 virtual const AtomicString& LiveRegionStatus() const { return g_null_atom; } | 580 virtual const AtomicString& LiveRegionStatus() const { return g_null_atom; } |
| 670 virtual const AtomicString& LiveRegionRelevant() const { return g_null_atom; } | 581 virtual const AtomicString& LiveRegionRelevant() const { return g_null_atom; } |
| 671 virtual bool LiveRegionAtomic() const { return false; } | 582 virtual bool LiveRegionAtomic() const { return false; } |
| 672 virtual bool LiveRegionBusy() const { return false; } | 583 virtual bool LiveRegionBusy() const { return false; } |
| 673 | 584 |
| 674 const AtomicString& ContainerLiveRegionStatus() const; | 585 const AtomicString& ContainerLiveRegionStatus() const override; |
| 675 const AtomicString& ContainerLiveRegionRelevant() const; | 586 const AtomicString& ContainerLiveRegionRelevant() const override; |
| 676 bool ContainerLiveRegionAtomic() const; | 587 bool ContainerLiveRegionAtomic() const override; |
| 677 bool ContainerLiveRegionBusy() const; | 588 bool ContainerLiveRegionBusy() const override; |
| 678 | 589 |
| 679 // Every object's bounding box is returned relative to a | 590 virtual void GetRelativeBounds( |
| 680 // container object (which is guaranteed to be an ancestor) and | 591 AXObject** out_container, |
| 681 // optionally a transformation matrix that needs to be applied too. | 592 FloatRect& out_bounds_in_container, |
| 682 // To compute the absolute bounding box of an element, start with its | 593 SkMatrix44& out_container_transform) const override; |
| 683 // boundsInContainer and apply the transform. Then as long as its container is | |
| 684 // not null, walk up to its container and offset by the container's offset | |
| 685 // from origin, the container's scroll position if any, and apply the | |
| 686 // container's transform. Do this until you reach the root of the tree. | |
| 687 virtual void GetRelativeBounds(AXObjectImpl** out_container, | |
| 688 FloatRect& out_bounds_in_container, | |
| 689 SkMatrix44& out_container_transform) const; | |
| 690 | 594 |
| 691 // Get the bounds in frame-relative coordinates as a LayoutRect. | 595 LayoutRect GetBoundsInFrameCoordinates() const override; |
| 692 LayoutRect GetBoundsInFrameCoordinates() const; | |
| 693 | 596 |
| 694 // Explicitly set an object's bounding rect and offset container. | 597 // Explicitly set an object's bounding rect and offset container. |
| 695 void SetElementRect(LayoutRect r, AXObjectImpl* container) { | 598 void SetElementRect(LayoutRect r, AXObjectImpl* container) { |
| 696 explicit_element_rect_ = r; | 599 explicit_element_rect_ = r; |
| 697 explicit_container_id_ = container->AxObjectID(); | 600 explicit_container_id_ = container->AxObjectID(); |
| 698 } | 601 } |
| 699 | 602 |
| 700 // Hit testing. | 603 // Hit testing. |
| 701 // Called on the root AX object to return the deepest available element. | 604 virtual AXObject* AccessibilityHitTest(const IntPoint&) const override { |
| 702 virtual AXObjectImpl* AccessibilityHitTest(const IntPoint&) const { | |
| 703 return 0; | 605 return 0; |
| 704 } | 606 } |
| 705 // Called on the AX object after the layout tree determines which is the right | 607 // Called on the AX object after the layout tree determines which is the right |
| 706 // AXLayoutObject. | 608 // AXLayoutObject. |
| 707 virtual AXObjectImpl* ElementAccessibilityHitTest(const IntPoint&) const; | 609 virtual AXObjectImpl* ElementAccessibilityHitTest(const IntPoint&) const; |
| 708 | 610 |
| 709 // High-level accessibility tree access. Other modules should only use these | 611 // High-level accessibility tree access. Other modules should only use these |
| 710 // functions. | 612 // functions. |
| 711 const AXObjectVector& Children(); | 613 const AXObjectImplVector& Children(); |
| 712 AXObjectImpl* ParentObject() const; | 614 AXObjectImpl* ParentObject() const; |
| 713 AXObjectImpl* ParentObjectIfExists() const; | 615 AXObjectImpl* ParentObjectIfExists() const; |
| 714 virtual AXObjectImpl* ComputeParent() const = 0; | 616 virtual AXObjectImpl* ComputeParent() const = 0; |
| 715 virtual AXObjectImpl* ComputeParentIfExists() const { return 0; } | 617 virtual AXObjectImpl* ComputeParentIfExists() const { return 0; } |
| 716 AXObjectImpl* CachedParentObject() const { return parent_; } | 618 AXObjectImpl* CachedParentObject() const { return parent_; } |
| 717 AXObjectImpl* ParentObjectUnignored() const; | 619 AXObjectImpl* ParentObjectUnignored() const; |
| 718 AXObjectImpl* ContainerWidget() const; | 620 AXObjectImpl* ContainerWidget() const; |
| 719 bool IsContainerWidget() const; | 621 bool IsContainerWidget() const; |
| 720 | 622 |
| 721 // Low-level accessibility tree exploration, only for use within the | 623 // Low-level accessibility tree exploration, only for use within the |
| 722 // accessibility module. | 624 // accessibility module. |
| 723 virtual AXObjectImpl* RawFirstChild() const { return 0; } | 625 virtual AXObjectImpl* RawFirstChild() const { return 0; } |
| 724 virtual AXObjectImpl* RawNextSibling() const { return 0; } | 626 virtual AXObjectImpl* RawNextSibling() const { return 0; } |
| 725 virtual void AddChildren() {} | 627 virtual void AddChildren() {} |
| 726 virtual bool CanHaveChildren() const { return true; } | 628 virtual bool CanHaveChildren() const { return true; } |
| 727 bool HasChildren() const { return have_children_; } | 629 bool HasChildren() const { return have_children_; } |
| 728 virtual void UpdateChildrenIfNecessary(); | 630 virtual void UpdateChildrenIfNecessary(); |
| 729 virtual bool NeedsToUpdateChildren() const { return false; } | 631 virtual bool NeedsToUpdateChildren() const { return false; } |
| 730 virtual void SetNeedsToUpdateChildren() {} | 632 virtual void SetNeedsToUpdateChildren() {} |
| 731 virtual void ClearChildren(); | 633 virtual void ClearChildren(); |
| 732 virtual void DetachFromParent() { parent_ = 0; } | 634 virtual void DetachFromParent() { parent_ = 0; } |
| 733 virtual AXObjectImpl* ScrollBar(AccessibilityOrientation) { return 0; } | 635 virtual AXObjectImpl* ScrollBar(AccessibilityOrientation) { return 0; } |
| 734 | 636 |
| 735 // Properties of the object's owning document or page. | 637 // Properties of the object's owning document or page. |
| 736 virtual double EstimatedLoadingProgress() const { return 0; } | 638 virtual double EstimatedLoadingProgress() const override { return 0; } |
| 737 | 639 |
| 738 // DOM and layout tree access. | 640 // DOM and layout tree access. |
| 739 virtual Node* GetNode() const { return nullptr; } | 641 virtual Node* GetNode() const override { return nullptr; } |
| 740 virtual Element* GetElement() const; // Same as GetNode, if it's an Element. | 642 virtual Element* GetElement() const; // Same as GetNode, if it's an Element. |
| 741 virtual LayoutObject* GetLayoutObject() const { return nullptr; } | 643 virtual LayoutObject* GetLayoutObject() const { return nullptr; } |
| 742 virtual Document* GetDocument() const; | 644 virtual Document* GetDocument() const override; |
| 743 virtual LocalFrameView* DocumentFrameView() const; | 645 virtual LocalFrameView* DocumentFrameView() const override; |
| 744 virtual Element* AnchorElement() const { return nullptr; } | 646 virtual Element* AnchorElement() const { return nullptr; } |
| 745 virtual Element* ActionElement() const { return nullptr; } | 647 virtual Element* ActionElement() const { return nullptr; } |
| 746 String Language() const; | 648 String Language() const override; |
| 747 bool HasAttribute(const QualifiedName&) const; | 649 bool HasAttribute(const QualifiedName&) const; |
| 748 const AtomicString& GetAttribute(const QualifiedName&) const; | 650 const AtomicString& GetAttribute(const QualifiedName&) const; |
| 749 | 651 |
| 750 // Methods that retrieve or manipulate the current selection. | 652 virtual AXRange Selection() const override { return AXRange(); } |
| 653 virtual AXRange SelectionUnderObject() const override { return AXRange(); } |
| 654 virtual void SetSelection(const AXRange&) override {} |
| 751 | 655 |
| 752 // Get the current selection from anywhere in the accessibility tree. | 656 bool IsScrollableContainer() const override; |
| 753 virtual AXRange Selection() const { return AXRange(); } | 657 IntPoint GetScrollOffset() const override; |
| 754 // Gets only the start and end offsets of the selection computed using the | 658 IntPoint MinimumScrollOffset() const override; |
| 755 // current object as the starting point. Returns a null selection if there is | 659 IntPoint MaximumScrollOffset() const override; |
| 756 // no selection in the subtree rooted at this object. | 660 void SetScrollOffset(const IntPoint&) const override; |
| 757 virtual AXRange SelectionUnderObject() const { return AXRange(); } | |
| 758 virtual void SetSelection(const AXRange&) {} | |
| 759 | |
| 760 // Scrollable containers. | |
| 761 bool IsScrollableContainer() const; | |
| 762 IntPoint GetScrollOffset() const; | |
| 763 IntPoint MinimumScrollOffset() const; | |
| 764 IntPoint MaximumScrollOffset() const; | |
| 765 void SetScrollOffset(const IntPoint&) const; | |
| 766 | 661 |
| 767 // If this object itself scrolls, return its ScrollableArea. | 662 // If this object itself scrolls, return its ScrollableArea. |
| 768 virtual ScrollableArea* GetScrollableAreaIfScrollable() const { return 0; } | 663 virtual ScrollableArea* GetScrollableAreaIfScrollable() const { return 0; } |
| 769 | 664 |
| 770 // Modify or take an action on an object. | 665 // Modify or take an action on an object. |
| 771 virtual void Increment() {} | 666 virtual void Increment() override {} |
| 772 virtual void Decrement() {} | 667 virtual void Decrement() override {} |
| 773 bool PerformDefaultAction() { return Press(); } | 668 bool PerformDefaultAction() override { return Press(); } |
| 774 virtual bool Press(); | 669 virtual bool Press() override; |
| 775 // Make this object visible by scrolling as many nested scrollable views as | 670 void ScrollToMakeVisible() const override; |
| 776 // needed. | 671 void ScrollToMakeVisibleWithSubFocus(const IntRect&) const override; |
| 777 void ScrollToMakeVisible() const; | 672 void ScrollToGlobalPoint(const IntPoint&) const override; |
| 778 // Same, but if the whole object can't be made visible, try for this subrect, | 673 virtual void SetFocused(bool) override {} |
| 779 // in local coordinates. | |
| 780 void ScrollToMakeVisibleWithSubFocus(const IntRect&) const; | |
| 781 // Scroll this object to a given point in global coordinates of the top-level | |
| 782 // window. | |
| 783 void ScrollToGlobalPoint(const IntPoint&) const; | |
| 784 virtual void SetFocused(bool) {} | |
| 785 virtual void SetSelected(bool) {} | 674 virtual void SetSelected(bool) {} |
| 786 virtual void SetSequentialFocusNavigationStartingPoint(); | 675 virtual void SetSequentialFocusNavigationStartingPoint() override; |
| 787 virtual void SetValue(const String&) {} | 676 virtual void SetValue(const String&) override {} |
| 788 virtual void SetValue(float) {} | 677 virtual void SetValue(float) {} |
| 789 | 678 |
| 790 // Notifications that this object may have changed. | 679 // Notifications that this object may have changed. |
| 791 virtual void ChildrenChanged() {} | 680 virtual void ChildrenChanged() {} |
| 792 virtual void HandleActiveDescendantChanged() {} | 681 virtual void HandleActiveDescendantChanged() {} |
| 793 virtual void HandleAriaExpandedChanged() {} | 682 virtual void HandleAriaExpandedChanged() {} |
| 794 void NotifyIfIgnoredValueChanged(); | 683 void NotifyIfIgnoredValueChanged(); |
| 795 virtual void SelectionChanged(); | 684 virtual void SelectionChanged(); |
| 796 virtual void TextChanged() {} | 685 virtual void TextChanged() {} |
| 797 virtual void UpdateAccessibilityRole() {} | 686 virtual void UpdateAccessibilityRole() {} |
| 798 | 687 |
| 799 // Text metrics. Most of these should be deprecated, needs major cleanup. | 688 // Text metrics. Most of these should be deprecated, needs major cleanup. |
| 800 virtual VisiblePosition VisiblePositionForIndex(int) const { | 689 virtual VisiblePosition VisiblePositionForIndex(int) const override { |
| 801 return VisiblePosition(); | 690 return VisiblePosition(); |
| 802 } | 691 } |
| 803 int LineForPosition(const VisiblePosition&) const; | 692 int LineForPosition(const VisiblePosition&) const override; |
| 804 virtual int Index(const VisiblePosition&) const { return -1; } | 693 virtual int Index(const VisiblePosition&) const { return -1; } |
| 805 virtual void LineBreaks(Vector<int>&) const {} | 694 virtual void LineBreaks(Vector<int>&) const override {} |
| 695 |
| 696 virtual int AriaColumnCount() const; |
| 697 virtual unsigned AriaColumnIndex() const; |
| 698 virtual int AriaRowCount() const; |
| 699 virtual unsigned AriaRowIndex() const; |
| 700 virtual unsigned ColumnCount() const; |
| 701 virtual unsigned RowCount() const; |
| 702 virtual WebAXObject CellForColumnAndRow(unsigned column, unsigned row) const; |
| 703 virtual WebAXObject HeaderContainerObject() const; |
| 704 virtual WebAXObject RowAtIndex(unsigned row_index) const; |
| 705 virtual WebAXObject ColumnAtIndex(unsigned column_index) const; |
| 706 virtual void RowHeaders(WebVector<WebAXObject>&) const; |
| 707 virtual void ColumnHeaders(WebVector<WebAXObject>&) const; |
| 708 virtual unsigned RowIndex() const; |
| 709 virtual WebAXObject RowHeader() const; |
| 710 virtual unsigned ColumnIndex() const; |
| 711 virtual WebAXObject ColumnHeader() const; |
| 712 virtual unsigned CellColumnIndex() const; |
| 713 virtual unsigned CellColumnSpan() const; |
| 714 virtual unsigned CellRowIndex() const; |
| 715 virtual unsigned CellRowSpan() const; |
| 716 virtual WebAXSortDirection SortDirection() const; |
| 806 | 717 |
| 807 // Static helper functions. | 718 // Static helper functions. |
| 808 static bool IsARIAControl(AccessibilityRole); | 719 static bool IsARIAControl(AccessibilityRole); |
| 809 static bool IsARIAInput(AccessibilityRole); | 720 static bool IsARIAInput(AccessibilityRole); |
| 810 static AccessibilityRole AriaRoleToWebCoreRole(const String&); | 721 static AccessibilityRole AriaRoleToWebCoreRole(const String&); |
| 811 static const AtomicString& RoleName(AccessibilityRole); | 722 static const AtomicString& RoleName(AccessibilityRole); |
| 812 static const AtomicString& InternalRoleName(AccessibilityRole); | 723 static const AtomicString& InternalRoleName(AccessibilityRole); |
| 813 | 724 |
| 814 protected: | 725 protected: |
| 815 AXID id_; | 726 AXID id_; |
| 816 AXObjectVector children_; | 727 AXObjectImplVector children_; |
| 817 mutable bool have_children_; | 728 mutable bool have_children_; |
| 818 AccessibilityRole role_; | 729 AccessibilityRole role_; |
| 819 AXObjectInclusion last_known_is_ignored_value_; | 730 AXObjectInclusion last_known_is_ignored_value_; |
| 820 LayoutRect explicit_element_rect_; | 731 LayoutRect explicit_element_rect_; |
| 821 AXID explicit_container_id_; | 732 AXID explicit_container_id_; |
| 822 | 733 |
| 823 // Used only inside textAlternative(): | 734 // Used only inside textAlternative(): |
| 824 static String CollapseWhitespace(const String&); | 735 static String CollapseWhitespace(const String&); |
| 825 static String RecursiveTextAlternative(const AXObjectImpl&, | 736 static String RecursiveTextAlternative(const AXObjectImpl&, |
| 826 bool in_aria_labelled_by_traversal, | 737 bool in_aria_labelled_by_traversal, |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 891 | 802 |
| 892 DEFINE_TYPE_CASTS(AXObjectImpl, AXObject, obj, true, true); | 803 DEFINE_TYPE_CASTS(AXObjectImpl, AXObject, obj, true, true); |
| 893 | 804 |
| 894 #define DEFINE_AX_OBJECT_TYPE_CASTS(thisType, predicate) \ | 805 #define DEFINE_AX_OBJECT_TYPE_CASTS(thisType, predicate) \ |
| 895 DEFINE_TYPE_CASTS(thisType, AXObjectImpl, object, object->predicate, \ | 806 DEFINE_TYPE_CASTS(thisType, AXObjectImpl, object, object->predicate, \ |
| 896 object.predicate) | 807 object.predicate) |
| 897 | 808 |
| 898 } // namespace blink | 809 } // namespace blink |
| 899 | 810 |
| 900 #endif // AXObjectImpl_h | 811 #endif // AXObjectImpl_h |
| OLD | NEW |