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 AXObject_h | |
31 #define AXObject_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 AXObject; | |
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 AXObject* element) | |
235 : text_(text), text_element_(element) {} | |
236 | |
237 String text_; | |
238 Member<AXObject> 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, AXObject&) = 0; | |
355 virtual void AddObjectVectorAttribute(AXObjectVectorAttribute, | |
356 HeapVector<Member<AXObject>>&) = 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 AXObject> related_object; | |
424 | |
425 explicit IgnoredReason(AXIgnoredReason reason) | |
426 : reason(reason), related_object(nullptr) {} | |
427 | |
428 IgnoredReason(AXIgnoredReason r, const AXObject* 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<AXObject> object; | |
440 String text; | |
441 | |
442 NameSourceRelatedObject(AXObject* 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 AXObject : public GarbageCollectedFinalized<AXObject> { | |
502 WTF_MAKE_NONCOPYABLE(AXObject); | |
503 | |
504 public: | |
505 typedef HeapVector<Member<AXObject>> AXObjectVector; | |
506 | |
507 struct AXRange { | |
508 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | |
509 // The deepest descendant in which the range starts. | |
510 // (nullptr means the current object.) | |
511 Persistent<AXObject> anchor_object; | |
512 // The number of characters and child objects in the anchor object | |
513 // before the range starts. | |
514 int anchor_offset; | |
515 // When the same character offset could correspond to two possible | |
516 // cursor positions, upstream means it's on the previous line rather | |
517 // than the next line. | |
518 TextAffinity anchor_affinity; | |
519 | |
520 // The deepest descendant in which the range ends. | |
521 // (nullptr means the current object.) | |
522 Persistent<AXObject> focus_object; | |
523 // The number of characters and child objects in the focus object | |
524 // before the range ends. | |
525 int focus_offset; | |
526 // When the same character offset could correspond to two possible | |
527 // cursor positions, upstream means it's on the previous line rather | |
528 // than the next line. | |
529 TextAffinity focus_affinity; | |
530 | |
531 AXRange() | |
532 : anchor_object(nullptr), | |
533 anchor_offset(-1), | |
534 anchor_affinity(TextAffinity::kUpstream), | |
535 focus_object(nullptr), | |
536 focus_offset(-1), | |
537 focus_affinity(TextAffinity::kDownstream) {} | |
538 | |
539 AXRange(int start_offset, int end_offset) | |
540 : anchor_object(nullptr), | |
541 anchor_offset(start_offset), | |
542 anchor_affinity(TextAffinity::kUpstream), | |
543 focus_object(nullptr), | |
544 focus_offset(end_offset), | |
545 focus_affinity(TextAffinity::kDownstream) {} | |
546 | |
547 AXRange(AXObject* anchor_object, | |
548 int anchor_offset, | |
549 TextAffinity anchor_affinity, | |
550 AXObject* focus_object, | |
551 int focus_offset, | |
552 TextAffinity focus_affinity) | |
553 : anchor_object(anchor_object), | |
554 anchor_offset(anchor_offset), | |
555 anchor_affinity(anchor_affinity), | |
556 focus_object(focus_object), | |
557 focus_offset(focus_offset), | |
558 focus_affinity(focus_affinity) {} | |
559 | |
560 bool IsValid() const { | |
561 return ((anchor_object && focus_object) || | |
562 (!anchor_object && !focus_object)) && | |
563 anchor_offset >= 0 && focus_offset >= 0; | |
564 } | |
565 | |
566 // Determines if the range only refers to text offsets under the current | |
567 // object. | |
568 bool IsSimple() const { | |
569 return anchor_object == focus_object || !anchor_object || !focus_object; | |
570 } | |
571 }; | |
572 | |
573 protected: | |
574 AXObject(AXObjectCacheImpl&); | |
575 | |
576 public: | |
577 virtual ~AXObject(); | |
578 DECLARE_VIRTUAL_TRACE(); | |
579 | |
580 static unsigned NumberOfLiveAXObjects() { return number_of_live_ax_objects_; } | |
581 | |
582 // After constructing an AXObject, it must be given a | |
583 // unique ID, then added to AXObjectCacheImpl, and finally init() must | |
584 // be called last. | |
585 void SetAXObjectID(AXID ax_object_id) { id_ = ax_object_id; } | |
586 virtual void Init() {} | |
587 | |
588 // When the corresponding WebCore object that this AXObject | |
589 // wraps is deleted, it must be detached. | |
590 virtual void Detach(); | |
591 virtual bool IsDetached() const; | |
592 | |
593 // If the parent of this object is known, this can be faster than using | |
594 // computeParent(). | |
595 virtual void SetParent(AXObject* parent) { parent_ = parent; } | |
596 | |
597 // The AXObjectCacheImpl that owns this object, and its unique ID within this | |
598 // cache. | |
599 AXObjectCacheImpl& AxObjectCache() const { | |
600 DCHECK(ax_object_cache_); | |
601 return *ax_object_cache_; | |
602 } | |
603 | |
604 AXID AxObjectID() const { return id_; } | |
605 | |
606 // Wrappers that retrieve either an Accessibility Object Model property, | |
607 // or the equivalent ARIA attribute, in that order. | |
608 // TODO(dmazzoni): Add equivalents for other types of properties besides | |
609 // just strings. | |
610 const AtomicString& GetAOMPropertyOrARIAAttribute(AOMStringProperty) const; | |
611 | |
612 virtual void GetSparseAXAttributes(AXSparseAttributeClient&) const {} | |
613 | |
614 // Determine subclass type. | |
615 virtual bool IsAXNodeObject() const { return false; } | |
616 virtual bool IsAXLayoutObject() const { return false; } | |
617 virtual bool IsAXInlineTextBox() const { return false; } | |
618 virtual bool IsAXListBox() const { return false; } | |
619 virtual bool IsAXListBoxOption() const { return false; } | |
620 virtual bool IsAXRadioInput() const { return false; } | |
621 virtual bool IsAXSVGRoot() const { return false; } | |
622 | |
623 // Check object role or purpose. | |
624 virtual AccessibilityRole RoleValue() const { return role_; } | |
625 bool IsARIATextControl() const; | |
626 virtual bool IsARIATreeGridRow() const { return false; } | |
627 virtual bool IsAXTable() const { return false; } | |
628 virtual bool IsAnchor() const { return false; } | |
629 bool IsButton() const; | |
630 bool IsCheckable() const; | |
631 bool IsCanvas() const { return RoleValue() == kCanvasRole; } | |
632 bool IsCheckbox() const { return RoleValue() == kCheckBoxRole; } | |
633 bool IsCheckboxOrRadio() const { return IsCheckbox() || IsRadioButton(); } | |
634 bool IsColorWell() const { return RoleValue() == kColorWellRole; } | |
635 bool IsComboBox() const { return RoleValue() == kComboBoxRole; } | |
636 virtual bool IsControl() const { return false; } | |
637 virtual bool IsDataTable() const { return false; } | |
638 virtual bool IsEmbeddedObject() const { return false; } | |
639 virtual bool IsFieldset() const { return false; } | |
640 virtual bool IsHeading() const { return false; } | |
641 virtual bool IsImage() const { return false; } | |
642 virtual bool IsImageMapLink() const { return false; } | |
643 virtual bool IsInputImage() const { return false; } | |
644 bool IsLandmarkRelated() const; | |
645 virtual bool IsLink() const { return false; } | |
646 virtual bool IsInPageLinkTarget() const { return false; } | |
647 virtual bool IsList() const { return false; } | |
648 virtual bool IsMenu() const { return false; } | |
649 virtual bool IsMenuButton() const { return false; } | |
650 virtual bool IsMenuList() const { return false; } | |
651 virtual bool IsMenuListOption() const { return false; } | |
652 virtual bool IsMenuListPopup() const { return false; } | |
653 bool IsMenuRelated() const; | |
654 virtual bool IsMeter() const { return false; } | |
655 virtual bool IsMockObject() const { return false; } | |
656 virtual bool IsNativeSpinButton() const { return false; } | |
657 virtual bool IsNativeTextControl() const { | |
658 return false; | |
659 } // input or textarea | |
660 virtual bool IsNonNativeTextControl() const { | |
661 return false; | |
662 } // contenteditable or role=textbox | |
663 virtual bool IsPasswordField() const { return false; } | |
664 virtual bool IsPasswordFieldAndShouldHideValue() const; | |
665 bool IsPresentational() const { | |
666 return RoleValue() == kNoneRole || RoleValue() == kPresentationalRole; | |
667 } | |
668 virtual bool IsProgressIndicator() const { return false; } | |
669 bool IsRadioButton() const { return RoleValue() == kRadioButtonRole; } | |
670 bool IsRange() const { | |
671 return RoleValue() == kProgressIndicatorRole || | |
672 RoleValue() == kScrollBarRole || RoleValue() == kSliderRole || | |
673 RoleValue() == kSpinButtonRole; | |
674 } | |
675 bool IsScrollbar() const { return RoleValue() == kScrollBarRole; } | |
676 virtual bool IsSlider() const { return false; } | |
677 virtual bool IsNativeSlider() const { return false; } | |
678 virtual bool IsSpinButton() const { return RoleValue() == kSpinButtonRole; } | |
679 virtual bool IsSpinButtonPart() const { return false; } | |
680 bool IsTabItem() const { return RoleValue() == kTabRole; } | |
681 virtual bool IsTableCell() const { return false; } | |
682 virtual bool IsTableRow() const { return false; } | |
683 virtual bool IsTextControl() const { return false; } | |
684 virtual bool IsTableCol() const { return false; } | |
685 bool IsTree() const { return RoleValue() == kTreeRole; } | |
686 bool IsWebArea() const { return RoleValue() == kWebAreaRole; } | |
687 | |
688 // Check object state. | |
689 virtual bool IsClickable() const; | |
690 virtual bool IsCollapsed() const { return false; } | |
691 virtual bool IsEnabled() const { return false; } | |
692 virtual AccessibilityExpanded IsExpanded() const { | |
693 return kExpandedUndefined; | |
694 } | |
695 virtual bool IsFocused() const { return false; } | |
696 virtual bool IsHovered() const { return false; } | |
697 virtual bool IsLinked() const { return false; } | |
698 virtual bool IsLoaded() const { return false; } | |
699 virtual bool IsModal() const { return false; } | |
700 virtual bool IsMultiSelectable() const { return false; } | |
701 virtual bool IsOffScreen() const { return false; } | |
702 virtual bool IsPressed() const { return false; } | |
703 virtual bool IsReadOnly() const { return false; } | |
704 virtual bool IsRequired() const { return false; } | |
705 virtual bool IsSelected() const { return false; } | |
706 virtual bool IsSelectedOptionActive() const { return false; } | |
707 virtual bool IsVisible() const { return true; } | |
708 virtual bool IsVisited() const { return false; } | |
709 | |
710 // Check whether certain properties can be modified. | |
711 virtual bool CanSetFocusAttribute() const { return false; } | |
712 virtual bool CanSetValueAttribute() const { return false; } | |
713 virtual bool CanSetSelectedAttribute() const { return false; } | |
714 | |
715 // Whether objects are ignored, i.e. not included in the tree. | |
716 bool AccessibilityIsIgnored() const; | |
717 typedef HeapVector<IgnoredReason> IgnoredReasons; | |
718 virtual bool ComputeAccessibilityIsIgnored(IgnoredReasons* = nullptr) const { | |
719 return true; | |
720 } | |
721 bool AccessibilityIsIgnoredByDefault(IgnoredReasons* = nullptr) const; | |
722 AXObjectInclusion AccessibilityPlatformIncludesObject() const; | |
723 virtual AXObjectInclusion DefaultObjectInclusion( | |
724 IgnoredReasons* = nullptr) const; | |
725 bool IsInertOrAriaHidden() const; | |
726 const AXObject* AriaHiddenRoot() const; | |
727 bool ComputeIsInertOrAriaHidden(IgnoredReasons* = nullptr) const; | |
728 bool IsDescendantOfLeafNode() const; | |
729 AXObject* LeafNodeAncestor() const; | |
730 bool IsDescendantOfDisabledNode() const; | |
731 const AXObject* DisabledAncestor() const; | |
732 bool LastKnownIsIgnoredValue(); | |
733 void SetLastKnownIsIgnoredValue(bool); | |
734 bool HasInheritedPresentationalRole() const; | |
735 bool IsPresentationalChild() const; | |
736 bool AncestorExposesActiveDescendant() const; | |
737 bool ComputeAncestorExposesActiveDescendant() const; | |
738 | |
739 // | |
740 // Accessible name calculation | |
741 // | |
742 | |
743 // Retrieves the accessible name of the object, an enum indicating where the | |
744 // name was derived from, and a list of objects that were used to derive the | |
745 // name, if any. | |
746 virtual String GetName(AXNameFrom&, AXObjectVector* name_objects) const; | |
747 | |
748 typedef HeapVector<NameSource> NameSources; | |
749 // Retrieves the accessible name of the object and a list of all potential | |
750 // sources for the name, indicating which were used. | |
751 virtual String GetName(NameSources*) const; | |
752 | |
753 typedef HeapVector<DescriptionSource> DescriptionSources; | |
754 // Takes the result of nameFrom from calling |name|, above, and retrieves the | |
755 // accessible description of the object, which is secondary to |name|, an enum | |
756 // indicating where the description was derived from, and a list of objects | |
757 // that were used to derive the description, if any. | |
758 virtual String Description(AXNameFrom, | |
759 AXDescriptionFrom&, | |
760 AXObjectVector* description_objects) const { | |
761 return String(); | |
762 } | |
763 | |
764 // Same as above, but returns a list of all potential sources for the | |
765 // description, indicating which were used. | |
766 virtual String Description(AXNameFrom, | |
767 AXDescriptionFrom&, | |
768 DescriptionSources*, | |
769 AXRelatedObjectVector*) const { | |
770 return String(); | |
771 } | |
772 | |
773 // Takes the result of nameFrom and descriptionFrom from calling |name| and | |
774 // |description|, above, and retrieves the placeholder of the object, if | |
775 // present and if it wasn't already exposed by one of the two functions above. | |
776 virtual String Placeholder(AXNameFrom) const { return String(); } | |
777 | |
778 // Internal functions used by name and description, above. | |
779 typedef HeapHashSet<Member<const AXObject>> AXObjectSet; | |
780 virtual String TextAlternative(bool recursive, | |
781 bool in_aria_labelled_by_traversal, | |
782 AXObjectSet& visited, | |
783 AXNameFrom& name_from, | |
784 AXRelatedObjectVector* related_objects, | |
785 NameSources* name_sources) const { | |
786 return String(); | |
787 } | |
788 virtual String TextFromDescendants(AXObjectSet& visited, | |
789 bool recursive) const { | |
790 return String(); | |
791 } | |
792 | |
793 // Returns result of Accessible Name Calculation algorithm. | |
794 // This is a simpler high-level interface to |name| used by Inspector. | |
795 String ComputedName() const; | |
796 | |
797 // Internal function used to determine whether the result of calling |name| on | |
798 // this object would return text that came from the an HTML label element or | |
799 // not. This is intended to be faster than calling |name| or | |
800 // |textAlternative|, and without side effects (it won't call | |
801 // axObjectCache->getOrCreate). | |
802 virtual bool NameFromLabelElement() const { return false; } | |
803 | |
804 // | |
805 // Properties of static elements. | |
806 // | |
807 | |
808 virtual const AtomicString& AccessKey() const { return g_null_atom; } | |
809 RGBA32 BackgroundColor() const; | |
810 virtual RGBA32 ComputeBackgroundColor() const { return Color::kTransparent; } | |
811 virtual RGBA32 GetColor() const { return Color::kBlack; } | |
812 // Used by objects of role ColorWellRole. | |
813 virtual RGBA32 ColorValue() const { return Color::kTransparent; } | |
814 virtual bool CanvasHasFallbackContent() const { return false; } | |
815 virtual String FontFamily() const { return g_null_atom; } | |
816 // Font size is in pixels. | |
817 virtual float FontSize() const { return 0.0f; } | |
818 // Value should be 1-based. 0 means not supported. | |
819 virtual int HeadingLevel() const { return 0; } | |
820 // Value should be 1-based. 0 means not supported. | |
821 virtual unsigned HierarchicalLevel() const { return 0; } | |
822 // Return the content of an image or canvas as an image data url in | |
823 // PNG format. If |maxSize| is not empty and if the image is larger than | |
824 // those dimensions, the image will be resized proportionally first to fit. | |
825 virtual String ImageDataUrl(const IntSize& max_size) const { | |
826 return g_null_atom; | |
827 } | |
828 virtual AXObject* InPageLinkTarget() const { return nullptr; } | |
829 virtual AccessibilityOrientation Orientation() const; | |
830 virtual String GetText() const { return String(); } | |
831 virtual AccessibilityTextDirection GetTextDirection() const { | |
832 return kAccessibilityTextDirectionLTR; | |
833 } | |
834 virtual int TextLength() const { return 0; } | |
835 virtual TextStyle GetTextStyle() const { return kTextStyleNone; } | |
836 virtual AXObjectVector RadioButtonsInGroup() const { | |
837 return AXObjectVector(); | |
838 } | |
839 virtual KURL Url() const { return KURL(); } | |
840 | |
841 // Load inline text boxes for just this node, even if | |
842 // settings->inlineTextBoxAccessibilityEnabled() is false. | |
843 virtual void LoadInlineTextBoxes() {} | |
844 | |
845 // Walk the AXObjects on the same line. This is supported on any | |
846 // object type but primarily intended to be used for inline text boxes. | |
847 virtual AXObject* NextOnLine() const { return nullptr; } | |
848 virtual AXObject* PreviousOnLine() const { return nullptr; } | |
849 | |
850 // For all node objects. The start and end character offset of each | |
851 // marker, such as spelling or grammar error. | |
852 virtual void Markers(Vector<DocumentMarker::MarkerType>&, | |
853 Vector<AXRange>&) const {} | |
854 // For an inline text box. | |
855 // The integer horizontal pixel offset of each character in the string; | |
856 // negative values for RTL. | |
857 virtual void TextCharacterOffsets(Vector<int>&) const {} | |
858 // The start and end character offset of each word in the object's text. | |
859 virtual void GetWordBoundaries(Vector<AXRange>&) const {} | |
860 | |
861 // Properties of interactive elements. | |
862 AXSupportedAction Action() const; | |
863 AccessibilityButtonState CheckedState() const; | |
864 virtual AriaCurrentState GetAriaCurrentState() const { | |
865 return kAriaCurrentStateUndefined; | |
866 } | |
867 virtual InvalidState GetInvalidState() const { | |
868 return kInvalidStateUndefined; | |
869 } | |
870 // Only used when invalidState() returns InvalidStateOther. | |
871 virtual String AriaInvalidValue() const { return String(); } | |
872 virtual String ValueDescription() const { return String(); } | |
873 virtual float ValueForRange() const { return 0.0f; } | |
874 virtual float MaxValueForRange() const { return 0.0f; } | |
875 virtual float MinValueForRange() const { return 0.0f; } | |
876 virtual String StringValue() const { return String(); } | |
877 | |
878 // ARIA attributes. | |
879 virtual AXObject* ActiveDescendant() { return nullptr; } | |
880 virtual String AriaAutoComplete() const { return String(); } | |
881 virtual void AriaOwnsElements(AXObjectVector& owns) const {} | |
882 virtual void AriaDescribedbyElements(AXObjectVector&) const {} | |
883 virtual void AriaLabelledbyElements(AXObjectVector&) const {} | |
884 virtual bool AriaHasPopup() const { return false; } | |
885 virtual bool IsEditable() const { return false; } | |
886 bool IsMultiline() const; | |
887 virtual bool IsRichlyEditable() const { return false; } | |
888 bool AriaPressedIsPresent() const; | |
889 virtual AccessibilityRole AriaRoleAttribute() const { return kUnknownRole; } | |
890 virtual bool AriaRoleHasPresentationalChildren() const { return false; } | |
891 virtual AXObject* AncestorForWhichThisIsAPresentationalChild() const { | |
892 return 0; | |
893 } | |
894 bool SupportsActiveDescendant() const; | |
895 bool SupportsARIAAttributes() const; | |
896 virtual bool SupportsARIADragging() const { return false; } | |
897 virtual bool SupportsARIADropping() const { return false; } | |
898 virtual bool SupportsARIAFlowTo() const { return false; } | |
899 virtual bool SupportsARIAOwns() const { return false; } | |
900 bool SupportsRangeValue() const; | |
901 virtual SortDirection GetSortDirection() const { | |
902 return kSortDirectionUndefined; | |
903 } | |
904 | |
905 // Returns 0-based index. | |
906 int IndexInParent() const; | |
907 | |
908 // Value should be 1-based. 0 means not supported. | |
909 virtual int PosInSet() const { return 0; } | |
910 virtual int SetSize() const { return 0; } | |
911 bool SupportsSetSizeAndPosInSet() const; | |
912 | |
913 // ARIA live-region features. | |
914 bool IsLiveRegion() const; | |
915 AXObject* LiveRegionRoot() const; | |
916 virtual const AtomicString& LiveRegionStatus() const { return g_null_atom; } | |
917 virtual const AtomicString& LiveRegionRelevant() const { return g_null_atom; } | |
918 virtual bool LiveRegionAtomic() const { return false; } | |
919 virtual bool LiveRegionBusy() const { return false; } | |
920 | |
921 const AtomicString& ContainerLiveRegionStatus() const; | |
922 const AtomicString& ContainerLiveRegionRelevant() const; | |
923 bool ContainerLiveRegionAtomic() const; | |
924 bool ContainerLiveRegionBusy() const; | |
925 | |
926 // Every object's bounding box is returned relative to a | |
927 // container object (which is guaranteed to be an ancestor) and | |
928 // optionally a transformation matrix that needs to be applied too. | |
929 // To compute the absolute bounding box of an element, start with its | |
930 // boundsInContainer and apply the transform. Then as long as its container is | |
931 // not null, walk up to its container and offset by the container's offset | |
932 // from origin, the container's scroll position if any, and apply the | |
933 // container's transform. Do this until you reach the root of the tree. | |
934 virtual void GetRelativeBounds(AXObject** out_container, | |
935 FloatRect& out_bounds_in_container, | |
936 SkMatrix44& out_container_transform) const; | |
937 | |
938 // Get the bounds in frame-relative coordinates as a LayoutRect. | |
939 LayoutRect GetBoundsInFrameCoordinates() const; | |
940 | |
941 // Explicitly set an object's bounding rect and offset container. | |
942 void SetElementRect(LayoutRect r, AXObject* container) { | |
943 explicit_element_rect_ = r; | |
944 explicit_container_id_ = container->AxObjectID(); | |
945 } | |
946 | |
947 // Hit testing. | |
948 // Called on the root AX object to return the deepest available element. | |
949 virtual AXObject* AccessibilityHitTest(const IntPoint&) const { return 0; } | |
950 // Called on the AX object after the layout tree determines which is the right | |
951 // AXLayoutObject. | |
952 virtual AXObject* ElementAccessibilityHitTest(const IntPoint&) const; | |
953 | |
954 // High-level accessibility tree access. Other modules should only use these | |
955 // functions. | |
956 const AXObjectVector& Children(); | |
957 AXObject* ParentObject() const; | |
958 AXObject* ParentObjectIfExists() const; | |
959 virtual AXObject* ComputeParent() const = 0; | |
960 virtual AXObject* ComputeParentIfExists() const { return 0; } | |
961 AXObject* CachedParentObject() const { return parent_; } | |
962 AXObject* ParentObjectUnignored() const; | |
963 | |
964 // Low-level accessibility tree exploration, only for use within the | |
965 // accessibility module. | |
966 virtual AXObject* RawFirstChild() const { return 0; } | |
967 virtual AXObject* RawNextSibling() const { return 0; } | |
968 virtual void AddChildren() {} | |
969 virtual bool CanHaveChildren() const { return true; } | |
970 bool HasChildren() const { return have_children_; } | |
971 virtual void UpdateChildrenIfNecessary(); | |
972 virtual bool NeedsToUpdateChildren() const { return false; } | |
973 virtual void SetNeedsToUpdateChildren() {} | |
974 virtual void ClearChildren(); | |
975 virtual void DetachFromParent() { parent_ = 0; } | |
976 virtual AXObject* ScrollBar(AccessibilityOrientation) { return 0; } | |
977 | |
978 // Properties of the object's owning document or page. | |
979 virtual double EstimatedLoadingProgress() const { return 0; } | |
980 | |
981 // DOM and layout tree access. | |
982 virtual Node* GetNode() const { return 0; } | |
983 virtual LayoutObject* GetLayoutObject() const { return 0; } | |
984 virtual Document* GetDocument() const; | |
985 virtual FrameView* DocumentFrameView() const; | |
986 virtual Element* AnchorElement() const { return 0; } | |
987 virtual Element* ActionElement() const { return 0; } | |
988 String Language() const; | |
989 bool HasAttribute(const QualifiedName&) const; | |
990 const AtomicString& GetAttribute(const QualifiedName&) const; | |
991 | |
992 // Methods that retrieve or manipulate the current selection. | |
993 | |
994 // Get the current selection from anywhere in the accessibility tree. | |
995 virtual AXRange Selection() const { return AXRange(); } | |
996 // Gets only the start and end offsets of the selection computed using the | |
997 // current object as the starting point. Returns a null selection if there is | |
998 // no selection in the subtree rooted at this object. | |
999 virtual AXRange SelectionUnderObject() const { return AXRange(); } | |
1000 virtual void SetSelection(const AXRange&) {} | |
1001 | |
1002 // Scrollable containers. | |
1003 bool IsScrollableContainer() const; | |
1004 IntPoint GetScrollOffset() const; | |
1005 IntPoint MinimumScrollOffset() const; | |
1006 IntPoint MaximumScrollOffset() const; | |
1007 void SetScrollOffset(const IntPoint&) const; | |
1008 | |
1009 // If this object itself scrolls, return its ScrollableArea. | |
1010 virtual ScrollableArea* GetScrollableAreaIfScrollable() const { return 0; } | |
1011 | |
1012 // Modify or take an action on an object. | |
1013 virtual void Increment() {} | |
1014 virtual void Decrement() {} | |
1015 bool PerformDefaultAction() { return Press(); } | |
1016 virtual bool Press(); | |
1017 // Make this object visible by scrolling as many nested scrollable views as | |
1018 // needed. | |
1019 void ScrollToMakeVisible() const; | |
1020 // Same, but if the whole object can't be made visible, try for this subrect, | |
1021 // in local coordinates. | |
1022 void ScrollToMakeVisibleWithSubFocus(const IntRect&) const; | |
1023 // Scroll this object to a given point in global coordinates of the top-level | |
1024 // window. | |
1025 void ScrollToGlobalPoint(const IntPoint&) const; | |
1026 virtual void SetFocused(bool) {} | |
1027 virtual void SetSelected(bool) {} | |
1028 virtual void SetSequentialFocusNavigationStartingPoint(); | |
1029 virtual void SetValue(const String&) {} | |
1030 virtual void SetValue(float) {} | |
1031 | |
1032 // Notifications that this object may have changed. | |
1033 virtual void ChildrenChanged() {} | |
1034 virtual void HandleActiveDescendantChanged() {} | |
1035 virtual void HandleAriaExpandedChanged() {} | |
1036 void NotifyIfIgnoredValueChanged(); | |
1037 virtual void SelectionChanged(); | |
1038 virtual void TextChanged() {} | |
1039 virtual void UpdateAccessibilityRole() {} | |
1040 | |
1041 // Text metrics. Most of these should be deprecated, needs major cleanup. | |
1042 virtual VisiblePosition VisiblePositionForIndex(int) const { | |
1043 return VisiblePosition(); | |
1044 } | |
1045 int LineForPosition(const VisiblePosition&) const; | |
1046 virtual int Index(const VisiblePosition&) const { return -1; } | |
1047 virtual void LineBreaks(Vector<int>&) const {} | |
1048 | |
1049 // Static helper functions. | |
1050 static bool IsARIAControl(AccessibilityRole); | |
1051 static bool IsARIAInput(AccessibilityRole); | |
1052 static AccessibilityRole AriaRoleToWebCoreRole(const String&); | |
1053 static const AtomicString& RoleName(AccessibilityRole); | |
1054 static const AtomicString& InternalRoleName(AccessibilityRole); | |
1055 static bool IsInsideFocusableElementOrARIAWidget(const Node&); | |
1056 | |
1057 protected: | |
1058 AXID id_; | |
1059 AXObjectVector children_; | |
1060 mutable bool have_children_; | |
1061 AccessibilityRole role_; | |
1062 AXObjectInclusion last_known_is_ignored_value_; | |
1063 LayoutRect explicit_element_rect_; | |
1064 AXID explicit_container_id_; | |
1065 | |
1066 // Used only inside textAlternative(): | |
1067 static String CollapseWhitespace(const String&); | |
1068 static String RecursiveTextAlternative(const AXObject&, | |
1069 bool in_aria_labelled_by_traversal, | |
1070 AXObjectSet& visited); | |
1071 bool IsHiddenForTextAlternativeCalculation() const; | |
1072 String AriaTextAlternative(bool recursive, | |
1073 bool in_aria_labelled_by_traversal, | |
1074 AXObjectSet& visited, | |
1075 AXNameFrom&, | |
1076 AXRelatedObjectVector*, | |
1077 NameSources*, | |
1078 bool* found_text_alternative) const; | |
1079 String TextFromElements(bool in_aria_labelled_by_traversal, | |
1080 AXObjectSet& visited, | |
1081 HeapVector<Member<Element>>& elements, | |
1082 AXRelatedObjectVector* related_objects) const; | |
1083 void TokenVectorFromAttribute(Vector<String>&, const QualifiedName&) const; | |
1084 void ElementsFromAttribute(HeapVector<Member<Element>>& elements, | |
1085 const QualifiedName&) const; | |
1086 void AriaLabelledbyElementVector(HeapVector<Member<Element>>& elements) const; | |
1087 String TextFromAriaLabelledby(AXObjectSet& visited, | |
1088 AXRelatedObjectVector* related_objects) const; | |
1089 String TextFromAriaDescribedby(AXRelatedObjectVector* related_objects) const; | |
1090 | |
1091 virtual const AXObject* InheritsPresentationalRoleFrom() const { return 0; } | |
1092 | |
1093 virtual bool NameFromContents() const; | |
1094 | |
1095 AccessibilityRole ButtonRoleType() const; | |
1096 | |
1097 virtual LayoutObject* LayoutObjectForRelativeBounds() const { | |
1098 return nullptr; | |
1099 } | |
1100 | |
1101 mutable Member<AXObject> parent_; | |
1102 | |
1103 // The following cached attribute values (the ones starting with m_cached*) | |
1104 // are only valid if m_lastModificationCount matches | |
1105 // AXObjectCacheImpl::modificationCount(). | |
1106 mutable int last_modification_count_; | |
1107 mutable RGBA32 cached_background_color_; | |
1108 mutable bool cached_is_ignored_ : 1; | |
1109 mutable bool cached_is_inert_or_aria_hidden_ : 1; | |
1110 mutable bool cached_is_descendant_of_leaf_node_ : 1; | |
1111 mutable bool cached_is_descendant_of_disabled_node_ : 1; | |
1112 mutable bool cached_has_inherited_presentational_role_ : 1; | |
1113 mutable bool cached_is_presentational_child_ : 1; | |
1114 mutable bool cached_ancestor_exposes_active_descendant_ : 1; | |
1115 mutable Member<AXObject> cached_live_region_root_; | |
1116 | |
1117 Member<AXObjectCacheImpl> ax_object_cache_; | |
1118 | |
1119 // Updates the cached attribute values. This may be recursive, so to prevent | |
1120 // deadlocks, | |
1121 // functions called here may only search up the tree (ancestors), not down. | |
1122 void UpdateCachedAttributeValuesIfNeeded() const; | |
1123 | |
1124 private: | |
1125 static bool IsNativeInputInMixedState(const Node*); | |
1126 static bool IncludesARIAWidgetRole(const String&); | |
1127 static bool HasInteractiveARIAAttribute(const Element&); | |
1128 | |
1129 static unsigned number_of_live_ax_objects_; | |
1130 }; | |
1131 | |
1132 #define DEFINE_AX_OBJECT_TYPE_CASTS(thisType, predicate) \ | |
1133 DEFINE_TYPE_CASTS(thisType, AXObject, object, object->predicate, \ | |
1134 object.predicate) | |
1135 | |
1136 } // namespace blink | |
1137 | |
1138 #endif // AXObject_h | |
OLD | NEW |