| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2008, 2009, 2011 Apple Inc. All rights reserved. | |
| 3 * Copyright (C) 2008 Nuanti Ltd. | |
| 4 * | |
| 5 * Redistribution and use in source and binary forms, with or without | |
| 6 * modification, are permitted provided that the following conditions | |
| 7 * are met: | |
| 8 * | |
| 9 * 1. Redistributions of source code must retain the above copyright | |
| 10 * notice, this list of conditions and the following disclaimer. | |
| 11 * 2. Redistributions in binary form must reproduce the above copyright | |
| 12 * notice, this list of conditions and the following disclaimer in the | |
| 13 * documentation and/or other materials provided with the distribution. | |
| 14 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of | |
| 15 * its contributors may be used to endorse or promote products derived | |
| 16 * from this software without specific prior written permission. | |
| 17 * | |
| 18 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY | |
| 19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
| 20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
| 21 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY | |
| 22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
| 23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
| 24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |
| 25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
| 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 28 */ | |
| 29 | |
| 30 #ifndef AXObjectImpl_h | |
| 31 #define AXObjectImpl_h | |
| 32 | |
| 33 #include "core/editing/VisiblePosition.h" | |
| 34 #include "core/editing/markers/DocumentMarker.h" | |
| 35 #include "core/inspector/protocol/Accessibility.h" | |
| 36 #include "modules/ModulesExport.h" | |
| 37 #include "platform/geometry/FloatQuad.h" | |
| 38 #include "platform/geometry/LayoutRect.h" | |
| 39 #include "platform/graphics/Color.h" | |
| 40 #include "platform/wtf/Forward.h" | |
| 41 #include "platform/wtf/Vector.h" | |
| 42 | |
| 43 class SkMatrix44; | |
| 44 | |
| 45 namespace blink { | |
| 46 | |
| 47 class AXObjectImpl; | |
| 48 class AXObjectCacheImpl; | |
| 49 class Element; | |
| 50 class FrameView; | |
| 51 class IntPoint; | |
| 52 class Node; | |
| 53 class LayoutObject; | |
| 54 class ScrollableArea; | |
| 55 | |
| 56 enum class AOMStringProperty; | |
| 57 | |
| 58 typedef unsigned AXID; | |
| 59 | |
| 60 enum AccessibilityRole { | |
| 61 kUnknownRole = 0, | |
| 62 kAbbrRole, // No mapping to ARIA role. | |
| 63 kAlertDialogRole, | |
| 64 kAlertRole, | |
| 65 kAnchorRole, // No mapping to ARIA role. | |
| 66 kAnnotationRole, // No mapping to ARIA role. | |
| 67 kApplicationRole, | |
| 68 kArticleRole, | |
| 69 kAudioRole, // No mapping to ARIA role. | |
| 70 kBannerRole, | |
| 71 kBlockquoteRole, // No mapping to ARIA role. | |
| 72 kBusyIndicatorRole, // No mapping to ARIA role. | |
| 73 kButtonRole, | |
| 74 kCanvasRole, // No mapping to ARIA role. | |
| 75 kCaptionRole, // No mapping to ARIA role. | |
| 76 kCellRole, | |
| 77 kCheckBoxRole, | |
| 78 kColorWellRole, // No mapping to ARIA role. | |
| 79 kColumnHeaderRole, | |
| 80 kColumnRole, // No mapping to ARIA role. | |
| 81 kComboBoxRole, | |
| 82 kComplementaryRole, | |
| 83 kContentInfoRole, | |
| 84 kDateRole, // No mapping to ARIA role. | |
| 85 kDateTimeRole, // No mapping to ARIA role. | |
| 86 kDefinitionRole, | |
| 87 kDescriptionListDetailRole, // No mapping to ARIA role. | |
| 88 kDescriptionListRole, // No mapping to ARIA role. | |
| 89 kDescriptionListTermRole, // No mapping to ARIA role. | |
| 90 kDetailsRole, // No mapping to ARIA role. | |
| 91 kDialogRole, | |
| 92 kDirectoryRole, | |
| 93 kDisclosureTriangleRole, // No mapping to ARIA role. | |
| 94 kDivRole, // No mapping to ARIA role. | |
| 95 kDocumentRole, | |
| 96 kEmbeddedObjectRole, // No mapping to ARIA role. | |
| 97 kFeedRole, | |
| 98 kFigcaptionRole, // No mapping to ARIA role. | |
| 99 kFigureRole, | |
| 100 kFooterRole, | |
| 101 kFormRole, | |
| 102 kGridRole, | |
| 103 kGroupRole, | |
| 104 kHeadingRole, | |
| 105 kIframePresentationalRole, // No mapping to ARIA role. | |
| 106 kIframeRole, // No mapping to ARIA role. | |
| 107 kIgnoredRole, // No mapping to ARIA role. | |
| 108 kImageMapLinkRole, // No mapping to ARIA role. | |
| 109 kImageMapRole, // No mapping to ARIA role. | |
| 110 kImageRole, | |
| 111 kInlineTextBoxRole, // No mapping to ARIA role. | |
| 112 kInputTimeRole, // No mapping to ARIA role. | |
| 113 kLabelRole, | |
| 114 kLegendRole, // No mapping to ARIA role. | |
| 115 kLineBreakRole, // No mapping to ARIA role. | |
| 116 kLinkRole, | |
| 117 kListBoxOptionRole, | |
| 118 kListBoxRole, | |
| 119 kListItemRole, | |
| 120 kListMarkerRole, // No mapping to ARIA role. | |
| 121 kListRole, | |
| 122 kLogRole, | |
| 123 kMainRole, | |
| 124 kMarkRole, // No mapping to ARIA role. | |
| 125 kMarqueeRole, | |
| 126 kMathRole, | |
| 127 kMenuBarRole, | |
| 128 kMenuButtonRole, | |
| 129 kMenuItemRole, | |
| 130 kMenuItemCheckBoxRole, | |
| 131 kMenuItemRadioRole, | |
| 132 kMenuListOptionRole, | |
| 133 kMenuListPopupRole, | |
| 134 kMenuRole, | |
| 135 kMeterRole, | |
| 136 kNavigationRole, | |
| 137 kNoneRole, // No mapping to ARIA role. | |
| 138 kNoteRole, | |
| 139 kOutlineRole, // No mapping to ARIA role. | |
| 140 kParagraphRole, // No mapping to ARIA role. | |
| 141 kPopUpButtonRole, | |
| 142 kPreRole, // No mapping to ARIA role. | |
| 143 kPresentationalRole, | |
| 144 kProgressIndicatorRole, | |
| 145 kRadioButtonRole, | |
| 146 kRadioGroupRole, | |
| 147 kRegionRole, | |
| 148 kRootWebAreaRole, // No mapping to ARIA role. | |
| 149 kRowHeaderRole, | |
| 150 kRowRole, | |
| 151 kRubyRole, // No mapping to ARIA role. | |
| 152 kRulerRole, // No mapping to ARIA role. | |
| 153 kSVGRootRole, // No mapping to ARIA role. | |
| 154 kScrollAreaRole, // No mapping to ARIA role. | |
| 155 kScrollBarRole, | |
| 156 kSeamlessWebAreaRole, // No mapping to ARIA role. | |
| 157 kSearchRole, | |
| 158 kSearchBoxRole, | |
| 159 kSliderRole, | |
| 160 kSliderThumbRole, // No mapping to ARIA role. | |
| 161 kSpinButtonPartRole, // No mapping to ARIA role. | |
| 162 kSpinButtonRole, | |
| 163 kSplitterRole, | |
| 164 kStaticTextRole, // No mapping to ARIA role. | |
| 165 kStatusRole, | |
| 166 kSwitchRole, | |
| 167 kTabGroupRole, // No mapping to ARIA role. | |
| 168 kTabListRole, | |
| 169 kTabPanelRole, | |
| 170 kTabRole, | |
| 171 kTableHeaderContainerRole, // No mapping to ARIA role. | |
| 172 kTableRole, | |
| 173 kTermRole, | |
| 174 kTextFieldRole, | |
| 175 kTimeRole, // No mapping to ARIA role. | |
| 176 kTimerRole, | |
| 177 kToggleButtonRole, | |
| 178 kToolbarRole, | |
| 179 kTreeGridRole, | |
| 180 kTreeItemRole, | |
| 181 kTreeRole, | |
| 182 kUserInterfaceTooltipRole, | |
| 183 kVideoRole, // No mapping to ARIA role. | |
| 184 kWebAreaRole, // No mapping to ARIA role. | |
| 185 kWindowRole, // No mapping to ARIA role. | |
| 186 kNumRoles | |
| 187 }; | |
| 188 | |
| 189 enum AccessibilityTextSource { | |
| 190 kAlternativeText, | |
| 191 kChildrenText, | |
| 192 kSummaryText, | |
| 193 kHelpText, | |
| 194 kVisibleText, | |
| 195 kTitleTagText, | |
| 196 kPlaceholderText, | |
| 197 kLabelByElementText, | |
| 198 }; | |
| 199 | |
| 200 enum AccessibilityState { | |
| 201 kAXBusyState, | |
| 202 kAXCheckedState, | |
| 203 kAXEnabledState, | |
| 204 kAXExpandedState, | |
| 205 kAXFocusableState, | |
| 206 kAXFocusedState, | |
| 207 kAXHaspopupState, | |
| 208 kAXHoveredState, | |
| 209 kAXInvisibleState, | |
| 210 kAXLinkedState, | |
| 211 kAXMultilineState, | |
| 212 kAXMultiselectableState, | |
| 213 kAXOffscreenState, | |
| 214 kAXPressedState, | |
| 215 kAXProtectedState, | |
| 216 kAXReadonlyState, | |
| 217 kAXRequiredState, | |
| 218 kAXSelectableState, | |
| 219 kAXSelectedState, | |
| 220 kAXVerticalState, | |
| 221 kAXVisitedState | |
| 222 }; | |
| 223 | |
| 224 class AccessibilityText final | |
| 225 : public GarbageCollectedFinalized<AccessibilityText> { | |
| 226 WTF_MAKE_NONCOPYABLE(AccessibilityText); | |
| 227 | |
| 228 public: | |
| 229 DEFINE_INLINE_TRACE() { visitor->Trace(text_element_); } | |
| 230 | |
| 231 private: | |
| 232 AccessibilityText(const String& text, | |
| 233 const AccessibilityTextSource& source, | |
| 234 AXObjectImpl* element) | |
| 235 : text_(text), text_element_(element) {} | |
| 236 | |
| 237 String text_; | |
| 238 Member<AXObjectImpl> text_element_; | |
| 239 }; | |
| 240 | |
| 241 enum AccessibilityOrientation { | |
| 242 kAccessibilityOrientationUndefined = 0, | |
| 243 kAccessibilityOrientationVertical, | |
| 244 kAccessibilityOrientationHorizontal, | |
| 245 }; | |
| 246 | |
| 247 enum AXObjectInclusion { | |
| 248 kIncludeObject, | |
| 249 kIgnoreObject, | |
| 250 kDefaultBehavior, | |
| 251 }; | |
| 252 | |
| 253 enum class AXSupportedAction { | |
| 254 kNone = 0, | |
| 255 kActivate, | |
| 256 kCheck, | |
| 257 kClick, | |
| 258 kJump, | |
| 259 kOpen, | |
| 260 kPress, | |
| 261 kSelect, | |
| 262 kUncheck | |
| 263 }; | |
| 264 | |
| 265 enum AccessibilityButtonState { | |
| 266 kButtonStateOff = 0, | |
| 267 kButtonStateOn, | |
| 268 kButtonStateMixed, | |
| 269 }; | |
| 270 | |
| 271 enum AccessibilityTextDirection { | |
| 272 kAccessibilityTextDirectionLTR, | |
| 273 kAccessibilityTextDirectionRTL, | |
| 274 kAccessibilityTextDirectionTTB, | |
| 275 kAccessibilityTextDirectionBTT | |
| 276 }; | |
| 277 | |
| 278 enum SortDirection { | |
| 279 kSortDirectionUndefined = 0, | |
| 280 kSortDirectionNone, | |
| 281 kSortDirectionAscending, | |
| 282 kSortDirectionDescending, | |
| 283 kSortDirectionOther | |
| 284 }; | |
| 285 | |
| 286 enum AccessibilityExpanded { | |
| 287 kExpandedUndefined = 0, | |
| 288 kExpandedCollapsed, | |
| 289 kExpandedExpanded, | |
| 290 }; | |
| 291 | |
| 292 enum AccessibilityOptionalBool { | |
| 293 kOptionalBoolUndefined = 0, | |
| 294 kOptionalBoolTrue, | |
| 295 kOptionalBoolFalse | |
| 296 }; | |
| 297 | |
| 298 enum AriaCurrentState { | |
| 299 kAriaCurrentStateUndefined = 0, | |
| 300 kAriaCurrentStateFalse, | |
| 301 kAriaCurrentStateTrue, | |
| 302 kAriaCurrentStatePage, | |
| 303 kAriaCurrentStateStep, | |
| 304 kAriaCurrentStateLocation, | |
| 305 kAriaCurrentStateDate, | |
| 306 kAriaCurrentStateTime | |
| 307 }; | |
| 308 | |
| 309 enum InvalidState { | |
| 310 kInvalidStateUndefined = 0, | |
| 311 kInvalidStateFalse, | |
| 312 kInvalidStateTrue, | |
| 313 kInvalidStateSpelling, | |
| 314 kInvalidStateGrammar, | |
| 315 kInvalidStateOther | |
| 316 }; | |
| 317 | |
| 318 enum TextStyle { | |
| 319 kTextStyleNone = 0, | |
| 320 kTextStyleBold = 1 << 0, | |
| 321 kTextStyleItalic = 1 << 1, | |
| 322 kTextStyleUnderline = 1 << 2, | |
| 323 kTextStyleLineThrough = 1 << 3 | |
| 324 }; | |
| 325 | |
| 326 enum TextUnderElementMode { | |
| 327 kTextUnderElementAll, | |
| 328 kTextUnderElementAny // If the text is unimportant, just whether or not it's | |
| 329 // present | |
| 330 }; | |
| 331 | |
| 332 enum class AXBoolAttribute {}; | |
| 333 | |
| 334 enum class AXStringAttribute { | |
| 335 kAriaKeyShortcuts, | |
| 336 kAriaRoleDescription, | |
| 337 }; | |
| 338 | |
| 339 enum class AXObjectAttribute { | |
| 340 kAriaActiveDescendant, | |
| 341 kAriaErrorMessage, | |
| 342 }; | |
| 343 | |
| 344 enum class AXObjectVectorAttribute { | |
| 345 kAriaControls, | |
| 346 kAriaDetails, | |
| 347 kAriaFlowTo, | |
| 348 }; | |
| 349 | |
| 350 class AXSparseAttributeClient { | |
| 351 public: | |
| 352 virtual void AddBoolAttribute(AXBoolAttribute, bool) = 0; | |
| 353 virtual void AddStringAttribute(AXStringAttribute, const String&) = 0; | |
| 354 virtual void AddObjectAttribute(AXObjectAttribute, AXObjectImpl&) = 0; | |
| 355 virtual void AddObjectVectorAttribute(AXObjectVectorAttribute, | |
| 356 HeapVector<Member<AXObjectImpl>>&) = 0; | |
| 357 }; | |
| 358 | |
| 359 // The source of the accessible name of an element. This is needed | |
| 360 // because on some platforms this determines how the accessible name | |
| 361 // is exposed. | |
| 362 enum AXNameFrom { | |
| 363 kAXNameFromUninitialized = -1, | |
| 364 kAXNameFromAttribute = 0, | |
| 365 kAXNameFromAttributeExplicitlyEmpty, | |
| 366 kAXNameFromCaption, | |
| 367 kAXNameFromContents, | |
| 368 kAXNameFromPlaceholder, | |
| 369 kAXNameFromRelatedElement, | |
| 370 kAXNameFromValue, | |
| 371 kAXNameFromTitle, | |
| 372 }; | |
| 373 | |
| 374 // The potential native HTML-based text (name, description or placeholder) | |
| 375 // sources for an element. See | |
| 376 // http://rawgit.com/w3c/aria/master/html-aam/html-aam.html#accessible-name-and-
description-calculation | |
| 377 enum AXTextFromNativeHTML { | |
| 378 kAXTextFromNativeHTMLUninitialized = -1, | |
| 379 kAXTextFromNativeHTMLFigcaption, | |
| 380 kAXTextFromNativeHTMLLabel, | |
| 381 kAXTextFromNativeHTMLLabelFor, | |
| 382 kAXTextFromNativeHTMLLabelWrapped, | |
| 383 kAXTextFromNativeHTMLLegend, | |
| 384 kAXTextFromNativeHTMLTableCaption, | |
| 385 kAXTextFromNativeHTMLTitleElement, | |
| 386 }; | |
| 387 | |
| 388 // The source of the accessible description of an element. This is needed | |
| 389 // because on some platforms this determines how the accessible description | |
| 390 // is exposed. | |
| 391 enum AXDescriptionFrom { | |
| 392 kAXDescriptionFromUninitialized = -1, | |
| 393 kAXDescriptionFromAttribute = 0, | |
| 394 kAXDescriptionFromContents, | |
| 395 kAXDescriptionFromRelatedElement, | |
| 396 }; | |
| 397 | |
| 398 enum AXIgnoredReason { | |
| 399 kAXActiveModalDialog, | |
| 400 kAXAncestorDisallowsChild, | |
| 401 kAXAncestorIsLeafNode, | |
| 402 kAXAriaHidden, | |
| 403 kAXAriaHiddenRoot, | |
| 404 kAXEmptyAlt, | |
| 405 kAXEmptyText, | |
| 406 kAXInert, | |
| 407 kAXInheritsPresentation, | |
| 408 kAXLabelContainer, | |
| 409 kAXLabelFor, | |
| 410 kAXNotRendered, | |
| 411 kAXNotVisible, | |
| 412 kAXPresentationalRole, | |
| 413 kAXProbablyPresentational, | |
| 414 kAXStaticTextUsedAsNameFor, | |
| 415 kAXUninteresting | |
| 416 }; | |
| 417 | |
| 418 class IgnoredReason { | |
| 419 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | |
| 420 | |
| 421 public: | |
| 422 AXIgnoredReason reason; | |
| 423 Member<const AXObjectImpl> related_object; | |
| 424 | |
| 425 explicit IgnoredReason(AXIgnoredReason reason) | |
| 426 : reason(reason), related_object(nullptr) {} | |
| 427 | |
| 428 IgnoredReason(AXIgnoredReason r, const AXObjectImpl* obj) | |
| 429 : reason(r), related_object(obj) {} | |
| 430 | |
| 431 DEFINE_INLINE_TRACE() { visitor->Trace(related_object); } | |
| 432 }; | |
| 433 | |
| 434 class NameSourceRelatedObject | |
| 435 : public GarbageCollectedFinalized<NameSourceRelatedObject> { | |
| 436 WTF_MAKE_NONCOPYABLE(NameSourceRelatedObject); | |
| 437 | |
| 438 public: | |
| 439 WeakMember<AXObjectImpl> object; | |
| 440 String text; | |
| 441 | |
| 442 NameSourceRelatedObject(AXObjectImpl* object, String text) | |
| 443 : object(object), text(text) {} | |
| 444 | |
| 445 DEFINE_INLINE_TRACE() { visitor->Trace(object); } | |
| 446 }; | |
| 447 | |
| 448 typedef HeapVector<Member<NameSourceRelatedObject>> AXRelatedObjectVector; | |
| 449 class NameSource { | |
| 450 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | |
| 451 | |
| 452 public: | |
| 453 String text; | |
| 454 bool superseded = false; | |
| 455 bool invalid = false; | |
| 456 AXNameFrom type = kAXNameFromUninitialized; | |
| 457 const QualifiedName& attribute; | |
| 458 AtomicString attribute_value; | |
| 459 AXTextFromNativeHTML native_source = kAXTextFromNativeHTMLUninitialized; | |
| 460 AXRelatedObjectVector related_objects; | |
| 461 | |
| 462 NameSource(bool superseded, const QualifiedName& attr) | |
| 463 : superseded(superseded), attribute(attr) {} | |
| 464 | |
| 465 explicit NameSource(bool superseded) | |
| 466 : superseded(superseded), attribute(QualifiedName::Null()) {} | |
| 467 | |
| 468 DEFINE_INLINE_TRACE() { visitor->Trace(related_objects); } | |
| 469 }; | |
| 470 | |
| 471 class DescriptionSource { | |
| 472 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | |
| 473 | |
| 474 public: | |
| 475 String text; | |
| 476 bool superseded = false; | |
| 477 bool invalid = false; | |
| 478 AXDescriptionFrom type = kAXDescriptionFromUninitialized; | |
| 479 const QualifiedName& attribute; | |
| 480 AtomicString attribute_value; | |
| 481 AXTextFromNativeHTML native_source = kAXTextFromNativeHTMLUninitialized; | |
| 482 AXRelatedObjectVector related_objects; | |
| 483 | |
| 484 DescriptionSource(bool superseded, const QualifiedName& attr) | |
| 485 : superseded(superseded), attribute(attr) {} | |
| 486 | |
| 487 explicit DescriptionSource(bool superseded) | |
| 488 : superseded(superseded), attribute(QualifiedName::Null()) {} | |
| 489 | |
| 490 DEFINE_INLINE_TRACE() { visitor->Trace(related_objects); } | |
| 491 }; | |
| 492 | |
| 493 } // namespace blink | |
| 494 | |
| 495 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::IgnoredReason); | |
| 496 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::NameSource); | |
| 497 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::DescriptionSource); | |
| 498 | |
| 499 namespace blink { | |
| 500 | |
| 501 class MODULES_EXPORT AXObjectImpl | |
| 502 : public GarbageCollectedFinalized<AXObjectImpl> { | |
| 503 WTF_MAKE_NONCOPYABLE(AXObjectImpl); | |
| 504 | |
| 505 public: | |
| 506 typedef HeapVector<Member<AXObjectImpl>> AXObjectVector; | |
| 507 | |
| 508 struct AXRange { | |
| 509 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | |
| 510 // The deepest descendant in which the range starts. | |
| 511 // (nullptr means the current object.) | |
| 512 Persistent<AXObjectImpl> anchor_object; | |
| 513 // The number of characters and child objects in the anchor object | |
| 514 // before the range starts. | |
| 515 int anchor_offset; | |
| 516 // When the same character offset could correspond to two possible | |
| 517 // cursor positions, upstream means it's on the previous line rather | |
| 518 // than the next line. | |
| 519 TextAffinity anchor_affinity; | |
| 520 | |
| 521 // The deepest descendant in which the range ends. | |
| 522 // (nullptr means the current object.) | |
| 523 Persistent<AXObjectImpl> focus_object; | |
| 524 // The number of characters and child objects in the focus object | |
| 525 // before the range ends. | |
| 526 int focus_offset; | |
| 527 // When the same character offset could correspond to two possible | |
| 528 // cursor positions, upstream means it's on the previous line rather | |
| 529 // than the next line. | |
| 530 TextAffinity focus_affinity; | |
| 531 | |
| 532 AXRange() | |
| 533 : anchor_object(nullptr), | |
| 534 anchor_offset(-1), | |
| 535 anchor_affinity(TextAffinity::kUpstream), | |
| 536 focus_object(nullptr), | |
| 537 focus_offset(-1), | |
| 538 focus_affinity(TextAffinity::kDownstream) {} | |
| 539 | |
| 540 AXRange(int start_offset, int end_offset) | |
| 541 : anchor_object(nullptr), | |
| 542 anchor_offset(start_offset), | |
| 543 anchor_affinity(TextAffinity::kUpstream), | |
| 544 focus_object(nullptr), | |
| 545 focus_offset(end_offset), | |
| 546 focus_affinity(TextAffinity::kDownstream) {} | |
| 547 | |
| 548 AXRange(AXObjectImpl* anchor_object, | |
| 549 int anchor_offset, | |
| 550 TextAffinity anchor_affinity, | |
| 551 AXObjectImpl* focus_object, | |
| 552 int focus_offset, | |
| 553 TextAffinity focus_affinity) | |
| 554 : anchor_object(anchor_object), | |
| 555 anchor_offset(anchor_offset), | |
| 556 anchor_affinity(anchor_affinity), | |
| 557 focus_object(focus_object), | |
| 558 focus_offset(focus_offset), | |
| 559 focus_affinity(focus_affinity) {} | |
| 560 | |
| 561 bool IsValid() const { | |
| 562 return ((anchor_object && focus_object) || | |
| 563 (!anchor_object && !focus_object)) && | |
| 564 anchor_offset >= 0 && focus_offset >= 0; | |
| 565 } | |
| 566 | |
| 567 // Determines if the range only refers to text offsets under the current | |
| 568 // object. | |
| 569 bool IsSimple() const { | |
| 570 return anchor_object == focus_object || !anchor_object || !focus_object; | |
| 571 } | |
| 572 }; | |
| 573 | |
| 574 protected: | |
| 575 AXObjectImpl(AXObjectCacheImpl&); | |
| 576 | |
| 577 public: | |
| 578 virtual ~AXObjectImpl(); | |
| 579 DECLARE_VIRTUAL_TRACE(); | |
| 580 | |
| 581 static unsigned NumberOfLiveAXObjects() { return number_of_live_ax_objects_; } | |
| 582 | |
| 583 // After constructing an AXObjectImpl, it must be given a | |
| 584 // unique ID, then added to AXObjectCacheImpl, and finally init() must | |
| 585 // be called last. | |
| 586 void SetAXObjectID(AXID ax_object_id) { id_ = ax_object_id; } | |
| 587 virtual void Init() {} | |
| 588 | |
| 589 // When the corresponding WebCore object that this AXObjectImpl | |
| 590 // wraps is deleted, it must be detached. | |
| 591 virtual void Detach(); | |
| 592 virtual bool IsDetached() const; | |
| 593 | |
| 594 // If the parent of this object is known, this can be faster than using | |
| 595 // computeParent(). | |
| 596 virtual void SetParent(AXObjectImpl* parent) { parent_ = parent; } | |
| 597 | |
| 598 // The AXObjectCacheImpl that owns this object, and its unique ID within this | |
| 599 // cache. | |
| 600 AXObjectCacheImpl& AxObjectCache() const { | |
| 601 DCHECK(ax_object_cache_); | |
| 602 return *ax_object_cache_; | |
| 603 } | |
| 604 | |
| 605 AXID AxObjectID() const { return id_; } | |
| 606 | |
| 607 // Wrappers that retrieve either an Accessibility Object Model property, | |
| 608 // or the equivalent ARIA attribute, in that order. | |
| 609 // TODO(dmazzoni): Add equivalents for other types of properties besides | |
| 610 // just strings. | |
| 611 const AtomicString& GetAOMPropertyOrARIAAttribute(AOMStringProperty) const; | |
| 612 | |
| 613 virtual void GetSparseAXAttributes(AXSparseAttributeClient&) const {} | |
| 614 | |
| 615 // Determine subclass type. | |
| 616 virtual bool IsAXNodeObject() const { return false; } | |
| 617 virtual bool IsAXLayoutObject() const { return false; } | |
| 618 virtual bool IsAXInlineTextBox() const { return false; } | |
| 619 virtual bool IsAXListBox() const { return false; } | |
| 620 virtual bool IsAXListBoxOption() const { return false; } | |
| 621 virtual bool IsAXRadioInput() const { return false; } | |
| 622 virtual bool IsAXSVGRoot() const { return false; } | |
| 623 | |
| 624 // Check object role or purpose. | |
| 625 virtual AccessibilityRole RoleValue() const { return role_; } | |
| 626 bool IsARIATextControl() const; | |
| 627 virtual bool IsARIATreeGridRow() const { return false; } | |
| 628 virtual bool IsAXTable() const { return false; } | |
| 629 virtual bool IsAnchor() const { return false; } | |
| 630 bool IsButton() const; | |
| 631 bool IsCheckable() const; | |
| 632 bool IsCanvas() const { return RoleValue() == kCanvasRole; } | |
| 633 bool IsCheckbox() const { return RoleValue() == kCheckBoxRole; } | |
| 634 bool IsCheckboxOrRadio() const { return IsCheckbox() || IsRadioButton(); } | |
| 635 bool IsColorWell() const { return RoleValue() == kColorWellRole; } | |
| 636 bool IsComboBox() const { return RoleValue() == kComboBoxRole; } | |
| 637 virtual bool IsControl() const { return false; } | |
| 638 virtual bool IsDataTable() const { return false; } | |
| 639 virtual bool IsEmbeddedObject() const { return false; } | |
| 640 virtual bool IsFieldset() const { return false; } | |
| 641 virtual bool IsHeading() const { return false; } | |
| 642 virtual bool IsImage() const { return false; } | |
| 643 virtual bool IsImageMapLink() const { return false; } | |
| 644 virtual bool IsInputImage() const { return false; } | |
| 645 bool IsLandmarkRelated() const; | |
| 646 virtual bool IsLink() const { return false; } | |
| 647 virtual bool IsInPageLinkTarget() const { return false; } | |
| 648 virtual bool IsList() const { return false; } | |
| 649 virtual bool IsMenu() const { return false; } | |
| 650 virtual bool IsMenuButton() const { return false; } | |
| 651 virtual bool IsMenuList() const { return false; } | |
| 652 virtual bool IsMenuListOption() const { return false; } | |
| 653 virtual bool IsMenuListPopup() const { return false; } | |
| 654 bool IsMenuRelated() const; | |
| 655 virtual bool IsMeter() const { return false; } | |
| 656 virtual bool IsMockObject() const { return false; } | |
| 657 virtual bool IsNativeSpinButton() const { return false; } | |
| 658 virtual bool IsNativeTextControl() const { | |
| 659 return false; | |
| 660 } // input or textarea | |
| 661 virtual bool IsNonNativeTextControl() const { | |
| 662 return false; | |
| 663 } // contenteditable or role=textbox | |
| 664 virtual bool IsPasswordField() const { return false; } | |
| 665 virtual bool IsPasswordFieldAndShouldHideValue() const; | |
| 666 bool IsPresentational() const { | |
| 667 return RoleValue() == kNoneRole || RoleValue() == kPresentationalRole; | |
| 668 } | |
| 669 virtual bool IsProgressIndicator() const { return false; } | |
| 670 bool IsRadioButton() const { return RoleValue() == kRadioButtonRole; } | |
| 671 bool IsRange() const { | |
| 672 return RoleValue() == kProgressIndicatorRole || | |
| 673 RoleValue() == kScrollBarRole || RoleValue() == kSliderRole || | |
| 674 RoleValue() == kSpinButtonRole; | |
| 675 } | |
| 676 bool IsScrollbar() const { return RoleValue() == kScrollBarRole; } | |
| 677 virtual bool IsSlider() const { return false; } | |
| 678 virtual bool IsNativeSlider() const { return false; } | |
| 679 virtual bool IsSpinButton() const { return RoleValue() == kSpinButtonRole; } | |
| 680 virtual bool IsSpinButtonPart() const { return false; } | |
| 681 bool IsTabItem() const { return RoleValue() == kTabRole; } | |
| 682 virtual bool IsTableCell() const { return false; } | |
| 683 virtual bool IsTableRow() const { return false; } | |
| 684 virtual bool IsTextControl() const { return false; } | |
| 685 virtual bool IsTableCol() const { return false; } | |
| 686 bool IsTree() const { return RoleValue() == kTreeRole; } | |
| 687 bool IsWebArea() const { return RoleValue() == kWebAreaRole; } | |
| 688 | |
| 689 // Check object state. | |
| 690 virtual bool IsClickable() const; | |
| 691 virtual bool IsCollapsed() const { return false; } | |
| 692 virtual bool IsEnabled() const { return false; } | |
| 693 virtual AccessibilityExpanded IsExpanded() const { | |
| 694 return kExpandedUndefined; | |
| 695 } | |
| 696 virtual bool IsFocused() const { return false; } | |
| 697 virtual bool IsHovered() const { return false; } | |
| 698 virtual bool IsLinked() const { return false; } | |
| 699 virtual bool IsLoaded() const { return false; } | |
| 700 virtual bool IsModal() const { return false; } | |
| 701 virtual bool IsMultiSelectable() const { return false; } | |
| 702 virtual bool IsOffScreen() const { return false; } | |
| 703 virtual bool IsPressed() const { return false; } | |
| 704 virtual bool IsReadOnly() const { return false; } | |
| 705 virtual bool IsRequired() const { return false; } | |
| 706 virtual bool IsSelected() const { return false; } | |
| 707 virtual bool IsSelectedOptionActive() const { return false; } | |
| 708 virtual bool IsVisible() const { return true; } | |
| 709 virtual bool IsVisited() const { return false; } | |
| 710 | |
| 711 // Check whether certain properties can be modified. | |
| 712 virtual bool CanSetFocusAttribute() const { return false; } | |
| 713 virtual bool CanSetValueAttribute() const { return false; } | |
| 714 virtual bool CanSetSelectedAttribute() const { return false; } | |
| 715 | |
| 716 // Whether objects are ignored, i.e. not included in the tree. | |
| 717 bool AccessibilityIsIgnored() const; | |
| 718 typedef HeapVector<IgnoredReason> IgnoredReasons; | |
| 719 virtual bool ComputeAccessibilityIsIgnored(IgnoredReasons* = nullptr) const { | |
| 720 return true; | |
| 721 } | |
| 722 bool AccessibilityIsIgnoredByDefault(IgnoredReasons* = nullptr) const; | |
| 723 AXObjectInclusion AccessibilityPlatformIncludesObject() const; | |
| 724 virtual AXObjectInclusion DefaultObjectInclusion( | |
| 725 IgnoredReasons* = nullptr) const; | |
| 726 bool IsInertOrAriaHidden() const; | |
| 727 const AXObjectImpl* AriaHiddenRoot() const; | |
| 728 bool ComputeIsInertOrAriaHidden(IgnoredReasons* = nullptr) const; | |
| 729 bool IsDescendantOfLeafNode() const; | |
| 730 AXObjectImpl* LeafNodeAncestor() const; | |
| 731 bool IsDescendantOfDisabledNode() const; | |
| 732 const AXObjectImpl* DisabledAncestor() const; | |
| 733 bool LastKnownIsIgnoredValue(); | |
| 734 void SetLastKnownIsIgnoredValue(bool); | |
| 735 bool HasInheritedPresentationalRole() const; | |
| 736 bool IsPresentationalChild() const; | |
| 737 bool AncestorExposesActiveDescendant() const; | |
| 738 bool ComputeAncestorExposesActiveDescendant() const; | |
| 739 | |
| 740 // | |
| 741 // Accessible name calculation | |
| 742 // | |
| 743 | |
| 744 // Retrieves the accessible name of the object, an enum indicating where the | |
| 745 // name was derived from, and a list of objects that were used to derive the | |
| 746 // name, if any. | |
| 747 virtual String GetName(AXNameFrom&, AXObjectVector* name_objects) const; | |
| 748 | |
| 749 typedef HeapVector<NameSource> NameSources; | |
| 750 // Retrieves the accessible name of the object and a list of all potential | |
| 751 // sources for the name, indicating which were used. | |
| 752 virtual String GetName(NameSources*) const; | |
| 753 | |
| 754 typedef HeapVector<DescriptionSource> DescriptionSources; | |
| 755 // Takes the result of nameFrom from calling |name|, above, and retrieves the | |
| 756 // accessible description of the object, which is secondary to |name|, an enum | |
| 757 // indicating where the description was derived from, and a list of objects | |
| 758 // that were used to derive the description, if any. | |
| 759 virtual String Description(AXNameFrom, | |
| 760 AXDescriptionFrom&, | |
| 761 AXObjectVector* description_objects) const { | |
| 762 return String(); | |
| 763 } | |
| 764 | |
| 765 // Same as above, but returns a list of all potential sources for the | |
| 766 // description, indicating which were used. | |
| 767 virtual String Description(AXNameFrom, | |
| 768 AXDescriptionFrom&, | |
| 769 DescriptionSources*, | |
| 770 AXRelatedObjectVector*) const { | |
| 771 return String(); | |
| 772 } | |
| 773 | |
| 774 // Takes the result of nameFrom and descriptionFrom from calling |name| and | |
| 775 // |description|, above, and retrieves the placeholder of the object, if | |
| 776 // present and if it wasn't already exposed by one of the two functions above. | |
| 777 virtual String Placeholder(AXNameFrom) const { return String(); } | |
| 778 | |
| 779 // Internal functions used by name and description, above. | |
| 780 typedef HeapHashSet<Member<const AXObjectImpl>> AXObjectSet; | |
| 781 virtual String TextAlternative(bool recursive, | |
| 782 bool in_aria_labelled_by_traversal, | |
| 783 AXObjectSet& visited, | |
| 784 AXNameFrom& name_from, | |
| 785 AXRelatedObjectVector* related_objects, | |
| 786 NameSources* name_sources) const { | |
| 787 return String(); | |
| 788 } | |
| 789 virtual String TextFromDescendants(AXObjectSet& visited, | |
| 790 bool recursive) const { | |
| 791 return String(); | |
| 792 } | |
| 793 | |
| 794 // Returns result of Accessible Name Calculation algorithm. | |
| 795 // This is a simpler high-level interface to |name| used by Inspector. | |
| 796 String ComputedName() const; | |
| 797 | |
| 798 // Internal function used to determine whether the result of calling |name| on | |
| 799 // this object would return text that came from the an HTML label element or | |
| 800 // not. This is intended to be faster than calling |name| or | |
| 801 // |textAlternative|, and without side effects (it won't call | |
| 802 // axObjectCache->getOrCreate). | |
| 803 virtual bool NameFromLabelElement() const { return false; } | |
| 804 | |
| 805 // | |
| 806 // Properties of static elements. | |
| 807 // | |
| 808 | |
| 809 virtual const AtomicString& AccessKey() const { return g_null_atom; } | |
| 810 RGBA32 BackgroundColor() const; | |
| 811 virtual RGBA32 ComputeBackgroundColor() const { return Color::kTransparent; } | |
| 812 virtual RGBA32 GetColor() const { return Color::kBlack; } | |
| 813 // Used by objects of role ColorWellRole. | |
| 814 virtual RGBA32 ColorValue() const { return Color::kTransparent; } | |
| 815 virtual bool CanvasHasFallbackContent() const { return false; } | |
| 816 virtual String FontFamily() const { return g_null_atom; } | |
| 817 // Font size is in pixels. | |
| 818 virtual float FontSize() const { return 0.0f; } | |
| 819 // Value should be 1-based. 0 means not supported. | |
| 820 virtual int HeadingLevel() const { return 0; } | |
| 821 // Value should be 1-based. 0 means not supported. | |
| 822 virtual unsigned HierarchicalLevel() const { return 0; } | |
| 823 // Return the content of an image or canvas as an image data url in | |
| 824 // PNG format. If |maxSize| is not empty and if the image is larger than | |
| 825 // those dimensions, the image will be resized proportionally first to fit. | |
| 826 virtual String ImageDataUrl(const IntSize& max_size) const { | |
| 827 return g_null_atom; | |
| 828 } | |
| 829 virtual AXObjectImpl* InPageLinkTarget() const { return nullptr; } | |
| 830 virtual AccessibilityOrientation Orientation() const; | |
| 831 virtual String GetText() const { return String(); } | |
| 832 virtual AccessibilityTextDirection GetTextDirection() const { | |
| 833 return kAccessibilityTextDirectionLTR; | |
| 834 } | |
| 835 virtual int TextLength() const { return 0; } | |
| 836 virtual TextStyle GetTextStyle() const { return kTextStyleNone; } | |
| 837 virtual AXObjectVector RadioButtonsInGroup() const { | |
| 838 return AXObjectVector(); | |
| 839 } | |
| 840 virtual KURL Url() const { return KURL(); } | |
| 841 | |
| 842 // Load inline text boxes for just this node, even if | |
| 843 // settings->inlineTextBoxAccessibilityEnabled() is false. | |
| 844 virtual void LoadInlineTextBoxes() {} | |
| 845 | |
| 846 // Walk the AXObjects on the same line. This is supported on any | |
| 847 // object type but primarily intended to be used for inline text boxes. | |
| 848 virtual AXObjectImpl* NextOnLine() const { return nullptr; } | |
| 849 virtual AXObjectImpl* PreviousOnLine() const { return nullptr; } | |
| 850 | |
| 851 // For all node objects. The start and end character offset of each | |
| 852 // marker, such as spelling or grammar error. | |
| 853 virtual void Markers(Vector<DocumentMarker::MarkerType>&, | |
| 854 Vector<AXRange>&) const {} | |
| 855 // For an inline text box. | |
| 856 // The integer horizontal pixel offset of each character in the string; | |
| 857 // negative values for RTL. | |
| 858 virtual void TextCharacterOffsets(Vector<int>&) const {} | |
| 859 // The start and end character offset of each word in the object's text. | |
| 860 virtual void GetWordBoundaries(Vector<AXRange>&) const {} | |
| 861 | |
| 862 // Properties of interactive elements. | |
| 863 AXSupportedAction Action() const; | |
| 864 AccessibilityButtonState CheckedState() const; | |
| 865 virtual AriaCurrentState GetAriaCurrentState() const { | |
| 866 return kAriaCurrentStateUndefined; | |
| 867 } | |
| 868 virtual InvalidState GetInvalidState() const { | |
| 869 return kInvalidStateUndefined; | |
| 870 } | |
| 871 // Only used when invalidState() returns InvalidStateOther. | |
| 872 virtual String AriaInvalidValue() const { return String(); } | |
| 873 virtual String ValueDescription() const { return String(); } | |
| 874 virtual float ValueForRange() const { return 0.0f; } | |
| 875 virtual float MaxValueForRange() const { return 0.0f; } | |
| 876 virtual float MinValueForRange() const { return 0.0f; } | |
| 877 virtual String StringValue() const { return String(); } | |
| 878 | |
| 879 // ARIA attributes. | |
| 880 virtual AXObjectImpl* ActiveDescendant() { return nullptr; } | |
| 881 virtual String AriaAutoComplete() const { return String(); } | |
| 882 virtual void AriaOwnsElements(AXObjectVector& owns) const {} | |
| 883 virtual void AriaDescribedbyElements(AXObjectVector&) const {} | |
| 884 virtual void AriaLabelledbyElements(AXObjectVector&) const {} | |
| 885 virtual bool AriaHasPopup() const { return false; } | |
| 886 virtual bool IsEditable() const { return false; } | |
| 887 bool IsMultiline() const; | |
| 888 virtual bool IsRichlyEditable() const { return false; } | |
| 889 bool AriaPressedIsPresent() const; | |
| 890 virtual AccessibilityRole AriaRoleAttribute() const { return kUnknownRole; } | |
| 891 virtual bool AriaRoleHasPresentationalChildren() const { return false; } | |
| 892 virtual AXObjectImpl* AncestorForWhichThisIsAPresentationalChild() const { | |
| 893 return 0; | |
| 894 } | |
| 895 bool SupportsActiveDescendant() const; | |
| 896 bool SupportsARIAAttributes() const; | |
| 897 virtual bool SupportsARIADragging() const { return false; } | |
| 898 virtual bool SupportsARIADropping() const { return false; } | |
| 899 virtual bool SupportsARIAFlowTo() const { return false; } | |
| 900 virtual bool SupportsARIAOwns() const { return false; } | |
| 901 bool SupportsRangeValue() const; | |
| 902 virtual SortDirection GetSortDirection() const { | |
| 903 return kSortDirectionUndefined; | |
| 904 } | |
| 905 | |
| 906 // Returns 0-based index. | |
| 907 int IndexInParent() const; | |
| 908 | |
| 909 // Value should be 1-based. 0 means not supported. | |
| 910 virtual int PosInSet() const { return 0; } | |
| 911 virtual int SetSize() const { return 0; } | |
| 912 bool SupportsSetSizeAndPosInSet() const; | |
| 913 | |
| 914 // ARIA live-region features. | |
| 915 bool IsLiveRegion() const; | |
| 916 AXObjectImpl* LiveRegionRoot() const; | |
| 917 virtual const AtomicString& LiveRegionStatus() const { return g_null_atom; } | |
| 918 virtual const AtomicString& LiveRegionRelevant() const { return g_null_atom; } | |
| 919 virtual bool LiveRegionAtomic() const { return false; } | |
| 920 virtual bool LiveRegionBusy() const { return false; } | |
| 921 | |
| 922 const AtomicString& ContainerLiveRegionStatus() const; | |
| 923 const AtomicString& ContainerLiveRegionRelevant() const; | |
| 924 bool ContainerLiveRegionAtomic() const; | |
| 925 bool ContainerLiveRegionBusy() const; | |
| 926 | |
| 927 // Every object's bounding box is returned relative to a | |
| 928 // container object (which is guaranteed to be an ancestor) and | |
| 929 // optionally a transformation matrix that needs to be applied too. | |
| 930 // To compute the absolute bounding box of an element, start with its | |
| 931 // boundsInContainer and apply the transform. Then as long as its container is | |
| 932 // not null, walk up to its container and offset by the container's offset | |
| 933 // from origin, the container's scroll position if any, and apply the | |
| 934 // container's transform. Do this until you reach the root of the tree. | |
| 935 virtual void GetRelativeBounds(AXObjectImpl** out_container, | |
| 936 FloatRect& out_bounds_in_container, | |
| 937 SkMatrix44& out_container_transform) const; | |
| 938 | |
| 939 // Get the bounds in frame-relative coordinates as a LayoutRect. | |
| 940 LayoutRect GetBoundsInFrameCoordinates() const; | |
| 941 | |
| 942 // Explicitly set an object's bounding rect and offset container. | |
| 943 void SetElementRect(LayoutRect r, AXObjectImpl* container) { | |
| 944 explicit_element_rect_ = r; | |
| 945 explicit_container_id_ = container->AxObjectID(); | |
| 946 } | |
| 947 | |
| 948 // Hit testing. | |
| 949 // Called on the root AX object to return the deepest available element. | |
| 950 virtual AXObjectImpl* AccessibilityHitTest(const IntPoint&) const { | |
| 951 return 0; | |
| 952 } | |
| 953 // Called on the AX object after the layout tree determines which is the right | |
| 954 // AXLayoutObject. | |
| 955 virtual AXObjectImpl* ElementAccessibilityHitTest(const IntPoint&) const; | |
| 956 | |
| 957 // High-level accessibility tree access. Other modules should only use these | |
| 958 // functions. | |
| 959 const AXObjectVector& Children(); | |
| 960 AXObjectImpl* ParentObject() const; | |
| 961 AXObjectImpl* ParentObjectIfExists() const; | |
| 962 virtual AXObjectImpl* ComputeParent() const = 0; | |
| 963 virtual AXObjectImpl* ComputeParentIfExists() const { return 0; } | |
| 964 AXObjectImpl* CachedParentObject() const { return parent_; } | |
| 965 AXObjectImpl* ParentObjectUnignored() const; | |
| 966 | |
| 967 // Low-level accessibility tree exploration, only for use within the | |
| 968 // accessibility module. | |
| 969 virtual AXObjectImpl* RawFirstChild() const { return 0; } | |
| 970 virtual AXObjectImpl* RawNextSibling() const { return 0; } | |
| 971 virtual void AddChildren() {} | |
| 972 virtual bool CanHaveChildren() const { return true; } | |
| 973 bool HasChildren() const { return have_children_; } | |
| 974 virtual void UpdateChildrenIfNecessary(); | |
| 975 virtual bool NeedsToUpdateChildren() const { return false; } | |
| 976 virtual void SetNeedsToUpdateChildren() {} | |
| 977 virtual void ClearChildren(); | |
| 978 virtual void DetachFromParent() { parent_ = 0; } | |
| 979 virtual AXObjectImpl* ScrollBar(AccessibilityOrientation) { return 0; } | |
| 980 | |
| 981 // Properties of the object's owning document or page. | |
| 982 virtual double EstimatedLoadingProgress() const { return 0; } | |
| 983 | |
| 984 // DOM and layout tree access. | |
| 985 virtual Node* GetNode() const { return 0; } | |
| 986 virtual LayoutObject* GetLayoutObject() const { return 0; } | |
| 987 virtual Document* GetDocument() const; | |
| 988 virtual FrameView* DocumentFrameView() const; | |
| 989 virtual Element* AnchorElement() const { return 0; } | |
| 990 virtual Element* ActionElement() const { return 0; } | |
| 991 String Language() const; | |
| 992 bool HasAttribute(const QualifiedName&) const; | |
| 993 const AtomicString& GetAttribute(const QualifiedName&) const; | |
| 994 | |
| 995 // Methods that retrieve or manipulate the current selection. | |
| 996 | |
| 997 // Get the current selection from anywhere in the accessibility tree. | |
| 998 virtual AXRange Selection() const { return AXRange(); } | |
| 999 // Gets only the start and end offsets of the selection computed using the | |
| 1000 // current object as the starting point. Returns a null selection if there is | |
| 1001 // no selection in the subtree rooted at this object. | |
| 1002 virtual AXRange SelectionUnderObject() const { return AXRange(); } | |
| 1003 virtual void SetSelection(const AXRange&) {} | |
| 1004 | |
| 1005 // Scrollable containers. | |
| 1006 bool IsScrollableContainer() const; | |
| 1007 IntPoint GetScrollOffset() const; | |
| 1008 IntPoint MinimumScrollOffset() const; | |
| 1009 IntPoint MaximumScrollOffset() const; | |
| 1010 void SetScrollOffset(const IntPoint&) const; | |
| 1011 | |
| 1012 // If this object itself scrolls, return its ScrollableArea. | |
| 1013 virtual ScrollableArea* GetScrollableAreaIfScrollable() const { return 0; } | |
| 1014 | |
| 1015 // Modify or take an action on an object. | |
| 1016 virtual void Increment() {} | |
| 1017 virtual void Decrement() {} | |
| 1018 bool PerformDefaultAction() { return Press(); } | |
| 1019 virtual bool Press(); | |
| 1020 // Make this object visible by scrolling as many nested scrollable views as | |
| 1021 // needed. | |
| 1022 void ScrollToMakeVisible() const; | |
| 1023 // Same, but if the whole object can't be made visible, try for this subrect, | |
| 1024 // in local coordinates. | |
| 1025 void ScrollToMakeVisibleWithSubFocus(const IntRect&) const; | |
| 1026 // Scroll this object to a given point in global coordinates of the top-level | |
| 1027 // window. | |
| 1028 void ScrollToGlobalPoint(const IntPoint&) const; | |
| 1029 virtual void SetFocused(bool) {} | |
| 1030 virtual void SetSelected(bool) {} | |
| 1031 virtual void SetSequentialFocusNavigationStartingPoint(); | |
| 1032 virtual void SetValue(const String&) {} | |
| 1033 virtual void SetValue(float) {} | |
| 1034 | |
| 1035 // Notifications that this object may have changed. | |
| 1036 virtual void ChildrenChanged() {} | |
| 1037 virtual void HandleActiveDescendantChanged() {} | |
| 1038 virtual void HandleAriaExpandedChanged() {} | |
| 1039 void NotifyIfIgnoredValueChanged(); | |
| 1040 virtual void SelectionChanged(); | |
| 1041 virtual void TextChanged() {} | |
| 1042 virtual void UpdateAccessibilityRole() {} | |
| 1043 | |
| 1044 // Text metrics. Most of these should be deprecated, needs major cleanup. | |
| 1045 virtual VisiblePosition VisiblePositionForIndex(int) const { | |
| 1046 return VisiblePosition(); | |
| 1047 } | |
| 1048 int LineForPosition(const VisiblePosition&) const; | |
| 1049 virtual int Index(const VisiblePosition&) const { return -1; } | |
| 1050 virtual void LineBreaks(Vector<int>&) const {} | |
| 1051 | |
| 1052 // Static helper functions. | |
| 1053 static bool IsARIAControl(AccessibilityRole); | |
| 1054 static bool IsARIAInput(AccessibilityRole); | |
| 1055 static AccessibilityRole AriaRoleToWebCoreRole(const String&); | |
| 1056 static const AtomicString& RoleName(AccessibilityRole); | |
| 1057 static const AtomicString& InternalRoleName(AccessibilityRole); | |
| 1058 static bool IsInsideFocusableElementOrARIAWidget(const Node&); | |
| 1059 | |
| 1060 protected: | |
| 1061 AXID id_; | |
| 1062 AXObjectVector children_; | |
| 1063 mutable bool have_children_; | |
| 1064 AccessibilityRole role_; | |
| 1065 AXObjectInclusion last_known_is_ignored_value_; | |
| 1066 LayoutRect explicit_element_rect_; | |
| 1067 AXID explicit_container_id_; | |
| 1068 | |
| 1069 // Used only inside textAlternative(): | |
| 1070 static String CollapseWhitespace(const String&); | |
| 1071 static String RecursiveTextAlternative(const AXObjectImpl&, | |
| 1072 bool in_aria_labelled_by_traversal, | |
| 1073 AXObjectSet& visited); | |
| 1074 bool IsHiddenForTextAlternativeCalculation() const; | |
| 1075 String AriaTextAlternative(bool recursive, | |
| 1076 bool in_aria_labelled_by_traversal, | |
| 1077 AXObjectSet& visited, | |
| 1078 AXNameFrom&, | |
| 1079 AXRelatedObjectVector*, | |
| 1080 NameSources*, | |
| 1081 bool* found_text_alternative) const; | |
| 1082 String TextFromElements(bool in_aria_labelled_by_traversal, | |
| 1083 AXObjectSet& visited, | |
| 1084 HeapVector<Member<Element>>& elements, | |
| 1085 AXRelatedObjectVector* related_objects) const; | |
| 1086 void TokenVectorFromAttribute(Vector<String>&, const QualifiedName&) const; | |
| 1087 void ElementsFromAttribute(HeapVector<Member<Element>>& elements, | |
| 1088 const QualifiedName&) const; | |
| 1089 void AriaLabelledbyElementVector(HeapVector<Member<Element>>& elements) const; | |
| 1090 String TextFromAriaLabelledby(AXObjectSet& visited, | |
| 1091 AXRelatedObjectVector* related_objects) const; | |
| 1092 String TextFromAriaDescribedby(AXRelatedObjectVector* related_objects) const; | |
| 1093 | |
| 1094 virtual const AXObjectImpl* InheritsPresentationalRoleFrom() const { | |
| 1095 return 0; | |
| 1096 } | |
| 1097 | |
| 1098 virtual bool NameFromContents() const; | |
| 1099 | |
| 1100 AccessibilityRole ButtonRoleType() const; | |
| 1101 | |
| 1102 virtual LayoutObject* LayoutObjectForRelativeBounds() const { | |
| 1103 return nullptr; | |
| 1104 } | |
| 1105 | |
| 1106 mutable Member<AXObjectImpl> parent_; | |
| 1107 | |
| 1108 // The following cached attribute values (the ones starting with m_cached*) | |
| 1109 // are only valid if m_lastModificationCount matches | |
| 1110 // AXObjectCacheImpl::modificationCount(). | |
| 1111 mutable int last_modification_count_; | |
| 1112 mutable RGBA32 cached_background_color_; | |
| 1113 mutable bool cached_is_ignored_ : 1; | |
| 1114 mutable bool cached_is_inert_or_aria_hidden_ : 1; | |
| 1115 mutable bool cached_is_descendant_of_leaf_node_ : 1; | |
| 1116 mutable bool cached_is_descendant_of_disabled_node_ : 1; | |
| 1117 mutable bool cached_has_inherited_presentational_role_ : 1; | |
| 1118 mutable bool cached_is_presentational_child_ : 1; | |
| 1119 mutable bool cached_ancestor_exposes_active_descendant_ : 1; | |
| 1120 mutable Member<AXObjectImpl> cached_live_region_root_; | |
| 1121 | |
| 1122 Member<AXObjectCacheImpl> ax_object_cache_; | |
| 1123 | |
| 1124 // Updates the cached attribute values. This may be recursive, so to prevent | |
| 1125 // deadlocks, | |
| 1126 // functions called here may only search up the tree (ancestors), not down. | |
| 1127 void UpdateCachedAttributeValuesIfNeeded() const; | |
| 1128 | |
| 1129 private: | |
| 1130 static bool IsNativeInputInMixedState(const Node*); | |
| 1131 static bool IncludesARIAWidgetRole(const String&); | |
| 1132 static bool HasInteractiveARIAAttribute(const Element&); | |
| 1133 | |
| 1134 static unsigned number_of_live_ax_objects_; | |
| 1135 }; | |
| 1136 | |
| 1137 #define DEFINE_AX_OBJECT_TYPE_CASTS(thisType, predicate) \ | |
| 1138 DEFINE_TYPE_CASTS(thisType, AXObjectImpl, object, object->predicate, \ | |
| 1139 object.predicate) | |
| 1140 | |
| 1141 } // namespace blink | |
| 1142 | |
| 1143 #endif // AXObjectImpl_h | |
| OLD | NEW |