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 AccessibilityObject_h 31 #define AccessibilityObject_h 32 33 #include "IntRect.h" 34 #include "VisiblePosition.h" 35 #include "VisibleSelection.h" 36 #include <wtf/Forward.h> 37 #include <wtf/RefPtr.h> 38 #include <wtf/Vector.h> 39 40 #if PLATFORM(MAC) 41 #include <wtf/RetainPtr.h> 42 #elif PLATFORM(WIN) && !OS(WINCE) 43 #include "AccessibilityObjectWrapperWin.h" 44 #include "COMPtr.h" 45 #elif PLATFORM(CHROMIUM) 46 #include "AccessibilityObjectWrapper.h" 47 #endif 48 49 typedef struct _NSRange NSRange; 50 51 #ifdef __OBJC__ 52 @class AccessibilityObjectWrapper; 53 @class NSArray; 54 @class NSAttributedString; 55 @class NSData; 56 @class NSMutableAttributedString; 57 @class NSString; 58 @class NSValue; 59 @class NSView; 60 #else 61 class NSArray; 62 class NSAttributedString; 63 class NSData; 64 class NSMutableAttributedString; 65 class NSString; 66 class NSValue; 67 class NSView; 68 #if PLATFORM(GTK) 69 typedef struct _AtkObject AtkObject; 70 typedef struct _AtkObject AccessibilityObjectWrapper; 71 #else 72 class AccessibilityObjectWrapper; 73 #endif 74 #endif 75 76 namespace WebCore { 77 78 class AXObjectCache; 79 class Element; 80 class Frame; 81 class FrameView; 82 class HTMLAnchorElement; 83 class HTMLAreaElement; 84 class IntPoint; 85 class IntSize; 86 class Node; 87 class RenderObject; 88 class RenderListItem; 89 class VisibleSelection; 90 class Widget; 91 92 typedef unsigned AXID; 93 94 enum AccessibilityRole { 95 UnknownRole = 1, 96 ButtonRole, 97 RadioButtonRole, 98 CheckBoxRole, 99 SliderRole, 100 TabGroupRole, 101 TextFieldRole, 102 StaticTextRole, 103 TextAreaRole, 104 ScrollAreaRole, 105 PopUpButtonRole, 106 MenuButtonRole, 107 TableRole, 108 ApplicationRole, 109 GroupRole, 110 RadioGroupRole, 111 ListRole, 112 ScrollBarRole, 113 ValueIndicatorRole, 114 ImageRole, 115 MenuBarRole, 116 MenuRole, 117 MenuItemRole, 118 ColumnRole, 119 RowRole, 120 ToolbarRole, 121 BusyIndicatorRole, 122 ProgressIndicatorRole, 123 WindowRole, 124 DrawerRole, 125 SystemWideRole, 126 OutlineRole, 127 IncrementorRole, 128 BrowserRole, 129 ComboBoxRole, 130 SplitGroupRole, 131 SplitterRole, 132 ColorWellRole, 133 GrowAreaRole, 134 SheetRole, 135 HelpTagRole, 136 MatteRole, 137 RulerRole, 138 RulerMarkerRole, 139 LinkRole, 140 DisclosureTriangleRole, 141 GridRole, 142 CellRole, 143 ColumnHeaderRole, 144 RowHeaderRole, 145 // AppKit includes SortButtonRole but it is misnamed and really a subrole of ButtonRole so we do not include it here. 146 147 // WebCore-specific roles 148 WebCoreLinkRole, 149 ImageMapLinkRole, 150 ImageMapRole, 151 ListMarkerRole, 152 WebAreaRole, 153 HeadingRole, 154 ListBoxRole, 155 ListBoxOptionRole, 156 TableHeaderContainerRole, 157 DefinitionListTermRole, 158 DefinitionListDefinitionRole, 159 AnnotationRole, 160 SliderThumbRole, 161 IgnoredRole, 162 PresentationalRole, 163 TabRole, 164 TabListRole, 165 TabPanelRole, 166 TreeRole, 167 TreeGridRole, 168 TreeItemRole, 169 DirectoryRole, 170 EditableTextRole, 171 ListItemRole, 172 MenuListPopupRole, 173 MenuListOptionRole, 174 ParagraphRole, 175 LabelRole, 176 DivRole, 177 FormRole, 178 179 // ARIA Grouping roles 180 LandmarkApplicationRole, 181 LandmarkBannerRole, 182 LandmarkComplementaryRole, 183 LandmarkContentInfoRole, 184 LandmarkMainRole, 185 LandmarkNavigationRole, 186 LandmarkSearchRole, 187 188 ApplicationAlertRole, 189 ApplicationAlertDialogRole, 190 ApplicationDialogRole, 191 ApplicationLogRole, 192 ApplicationMarqueeRole, 193 ApplicationStatusRole, 194 ApplicationTimerRole, 195 196 DocumentRole, 197 DocumentArticleRole, 198 DocumentMathRole, 199 DocumentNoteRole, 200 DocumentRegionRole, 201 202 UserInterfaceTooltipRole 203 }; 204 205 enum AccessibilityOrientation { 206 AccessibilityOrientationVertical, 207 AccessibilityOrientationHorizontal, 208 }; 209 210 enum AccessibilityObjectInclusion { 211 IncludeObject, 212 IgnoreObject, 213 DefaultBehavior, 214 }; 215 216 enum AccessibilityButtonState { 217 ButtonStateOff = 0, 218 ButtonStateOn, 219 ButtonStateMixed, 220 }; 221 222 enum AccessibilitySortDirection { 223 SortDirectionNone, 224 SortDirectionAscending, 225 SortDirectionDescending, 226 }; 227 228 struct VisiblePositionRange { 229 230 VisiblePosition start; 231 VisiblePosition end; 232 VisiblePositionRangeVisiblePositionRange233 VisiblePositionRange() {} 234 VisiblePositionRangeVisiblePositionRange235 VisiblePositionRange(const VisiblePosition& s, const VisiblePosition& e) 236 : start(s) 237 , end(e) 238 { } 239 isNullVisiblePositionRange240 bool isNull() const { return start.isNull() || end.isNull(); } 241 }; 242 243 struct PlainTextRange { 244 245 unsigned start; 246 unsigned length; 247 PlainTextRangePlainTextRange248 PlainTextRange() 249 : start(0) 250 , length(0) 251 { } 252 PlainTextRangePlainTextRange253 PlainTextRange(unsigned s, unsigned l) 254 : start(s) 255 , length(l) 256 { } 257 isNullPlainTextRange258 bool isNull() const { return !start && !length; } 259 }; 260 261 class AccessibilityObject : public RefCounted<AccessibilityObject> { 262 protected: 263 AccessibilityObject(); 264 public: 265 virtual ~AccessibilityObject(); 266 virtual void detach(); 267 268 typedef Vector<RefPtr<AccessibilityObject> > AccessibilityChildrenVector; 269 isAccessibilityRenderObject()270 virtual bool isAccessibilityRenderObject() const { return false; } isAccessibilityScrollbar()271 virtual bool isAccessibilityScrollbar() const { return false; } isAccessibilityScrollView()272 virtual bool isAccessibilityScrollView() const { return false; } 273 isAnchor()274 virtual bool isAnchor() const { return false; } isAttachment()275 virtual bool isAttachment() const { return false; } isHeading()276 virtual bool isHeading() const { return false; } isLink()277 virtual bool isLink() const { return false; } isImage()278 virtual bool isImage() const { return false; } isNativeImage()279 virtual bool isNativeImage() const { return false; } isImageButton()280 virtual bool isImageButton() const { return false; } isPasswordField()281 virtual bool isPasswordField() const { return false; } isNativeTextControl()282 virtual bool isNativeTextControl() const { return false; } isWebArea()283 virtual bool isWebArea() const { return false; } isCheckbox()284 virtual bool isCheckbox() const { return roleValue() == CheckBoxRole; } isRadioButton()285 virtual bool isRadioButton() const { return roleValue() == RadioButtonRole; } isListBox()286 virtual bool isListBox() const { return roleValue() == ListBoxRole; } isMediaTimeline()287 virtual bool isMediaTimeline() const { return false; } isMenuRelated()288 virtual bool isMenuRelated() const { return false; } isMenu()289 virtual bool isMenu() const { return false; } isMenuBar()290 virtual bool isMenuBar() const { return false; } isMenuButton()291 virtual bool isMenuButton() const { return false; } isMenuItem()292 virtual bool isMenuItem() const { return false; } isFileUploadButton()293 virtual bool isFileUploadButton() const { return false; } isInputImage()294 virtual bool isInputImage() const { return false; } isProgressIndicator()295 virtual bool isProgressIndicator() const { return false; } isSlider()296 virtual bool isSlider() const { return false; } isInputSlider()297 virtual bool isInputSlider() const { return false; } isControl()298 virtual bool isControl() const { return false; } isList()299 virtual bool isList() const { return false; } isAccessibilityTable()300 virtual bool isAccessibilityTable() const { return false; } isDataTable()301 virtual bool isDataTable() const { return false; } isTableRow()302 virtual bool isTableRow() const { return false; } isTableColumn()303 virtual bool isTableColumn() const { return false; } isTableCell()304 virtual bool isTableCell() const { return false; } isFieldset()305 virtual bool isFieldset() const { return false; } isGroup()306 virtual bool isGroup() const { return false; } isARIATreeGridRow()307 virtual bool isARIATreeGridRow() const { return false; } isImageMapLink()308 virtual bool isImageMapLink() const { return false; } isMenuList()309 virtual bool isMenuList() const { return false; } isMenuListPopup()310 virtual bool isMenuListPopup() const { return false; } isMenuListOption()311 virtual bool isMenuListOption() const { return false; } isTextControl()312 bool isTextControl() const { return roleValue() == TextAreaRole || roleValue() == TextFieldRole; } isTabList()313 bool isTabList() const { return roleValue() == TabListRole; } isTabItem()314 bool isTabItem() const { return roleValue() == TabRole; } isRadioGroup()315 bool isRadioGroup() const { return roleValue() == RadioGroupRole; } isComboBox()316 bool isComboBox() const { return roleValue() == ComboBoxRole; } isTree()317 bool isTree() const { return roleValue() == TreeRole; } isTreeItem()318 bool isTreeItem() const { return roleValue() == TreeItemRole; } isScrollbar()319 bool isScrollbar() const { return roleValue() == ScrollBarRole; } isButton()320 bool isButton() const { return roleValue() == ButtonRole; } isListItem()321 bool isListItem() const { return roleValue() == ListItemRole; } isCheckboxOrRadio()322 bool isCheckboxOrRadio() const { return isCheckbox() || isRadioButton(); } isScrollView()323 bool isScrollView() const { return roleValue() == ScrollAreaRole; } 324 isChecked()325 virtual bool isChecked() const { return false; } isEnabled()326 virtual bool isEnabled() const { return false; } isSelected()327 virtual bool isSelected() const { return false; } isFocused()328 virtual bool isFocused() const { return false; } isHovered()329 virtual bool isHovered() const { return false; } isIndeterminate()330 virtual bool isIndeterminate() const { return false; } isLoaded()331 virtual bool isLoaded() const { return false; } isMultiSelectable()332 virtual bool isMultiSelectable() const { return false; } isOffScreen()333 virtual bool isOffScreen() const { return false; } isPressed()334 virtual bool isPressed() const { return false; } isReadOnly()335 virtual bool isReadOnly() const { return false; } isVisited()336 virtual bool isVisited() const { return false; } isRequired()337 virtual bool isRequired() const { return false; } isLinked()338 virtual bool isLinked() const { return false; } 339 virtual bool isExpanded() const; isVisible()340 virtual bool isVisible() const { return true; } isCollapsed()341 virtual bool isCollapsed() const { return false; } setIsExpanded(bool)342 virtual void setIsExpanded(bool) { } 343 canSetFocusAttribute()344 virtual bool canSetFocusAttribute() const { return false; } canSetTextRangeAttributes()345 virtual bool canSetTextRangeAttributes() const { return false; } canSetValueAttribute()346 virtual bool canSetValueAttribute() const { return false; } canSetNumericValue()347 virtual bool canSetNumericValue() const { return false; } canSetSelectedAttribute()348 virtual bool canSetSelectedAttribute() const { return false; } canSetSelectedChildrenAttribute()349 virtual bool canSetSelectedChildrenAttribute() const { return false; } canSetExpandedAttribute()350 virtual bool canSetExpandedAttribute() const { return false; } 351 352 // A programmatic way to set a name on an AccessibleObject. setAccessibleName(String &)353 virtual void setAccessibleName(String&) { } 354 node()355 virtual Node* node() const { return 0; } renderer()356 virtual RenderObject* renderer() const { return 0; } accessibilityIsIgnored()357 virtual bool accessibilityIsIgnored() const { return true; } 358 headingLevel()359 virtual int headingLevel() const { return 0; } 360 virtual AccessibilityButtonState checkboxOrRadioValue() const; valueDescription()361 virtual String valueDescription() const { return String(); } valueForRange()362 virtual float valueForRange() const { return 0.0f; } maxValueForRange()363 virtual float maxValueForRange() const { return 0.0f; } minValueForRange()364 virtual float minValueForRange() const { return 0.0f; } selectedRadioButton()365 virtual AccessibilityObject* selectedRadioButton() { return 0; } selectedTabItem()366 virtual AccessibilityObject* selectedTabItem() { return 0; } layoutCount()367 virtual int layoutCount() const { return 0; } estimatedLoadingProgress()368 virtual double estimatedLoadingProgress() const { return 0; } 369 static bool isARIAControl(AccessibilityRole); 370 static bool isARIAInput(AccessibilityRole); supportsARIAOwns()371 virtual bool supportsARIAOwns() const { return false; } ariaOwnsElements(AccessibilityChildrenVector &)372 virtual void ariaOwnsElements(AccessibilityChildrenVector&) const { } supportsARIAFlowTo()373 virtual bool supportsARIAFlowTo() const { return false; } ariaFlowToElements(AccessibilityChildrenVector &)374 virtual void ariaFlowToElements(AccessibilityChildrenVector&) const { } ariaHasPopup()375 virtual bool ariaHasPopup() const { return false; } 376 bool ariaIsMultiline() const; 377 virtual const AtomicString& invalidStatus() const; 378 bool supportsARIAExpanded() const; 379 AccessibilitySortDirection sortDirection() const; 380 381 // ARIA drag and drop supportsARIADropping()382 virtual bool supportsARIADropping() const { return false; } supportsARIADragging()383 virtual bool supportsARIADragging() const { return false; } isARIAGrabbed()384 virtual bool isARIAGrabbed() { return false; } setARIAGrabbed(bool)385 virtual void setARIAGrabbed(bool) { } determineARIADropEffects(Vector<String> &)386 virtual void determineARIADropEffects(Vector<String>&) { } 387 388 // Called on the root AX object to return the deepest available element. accessibilityHitTest(const IntPoint &)389 virtual AccessibilityObject* accessibilityHitTest(const IntPoint&) const { return 0; } 390 // Called on the AX object after the render tree determines which is the right AccessibilityRenderObject. 391 virtual AccessibilityObject* elementAccessibilityHitTest(const IntPoint&) const; 392 393 virtual AccessibilityObject* focusedUIElement() const; 394 firstChild()395 virtual AccessibilityObject* firstChild() const { return 0; } lastChild()396 virtual AccessibilityObject* lastChild() const { return 0; } previousSibling()397 virtual AccessibilityObject* previousSibling() const { return 0; } nextSibling()398 virtual AccessibilityObject* nextSibling() const { return 0; } 399 virtual AccessibilityObject* parentObject() const = 0; 400 virtual AccessibilityObject* parentObjectUnignored() const; parentObjectIfExists()401 virtual AccessibilityObject* parentObjectIfExists() const { return 0; } 402 static AccessibilityObject* firstAccessibleObjectFromNode(const Node*); 403 observableObject()404 virtual AccessibilityObject* observableObject() const { return 0; } linkedUIElements(AccessibilityChildrenVector &)405 virtual void linkedUIElements(AccessibilityChildrenVector&) const { } titleUIElement()406 virtual AccessibilityObject* titleUIElement() const { return 0; } exposesTitleUIElement()407 virtual bool exposesTitleUIElement() const { return true; } correspondingLabelForControlElement()408 virtual AccessibilityObject* correspondingLabelForControlElement() const { return 0; } correspondingControlForLabelElement()409 virtual AccessibilityObject* correspondingControlForLabelElement() const { return 0; } scrollBar(AccessibilityOrientation)410 virtual AccessibilityObject* scrollBar(AccessibilityOrientation) const { return 0; } 411 ariaRoleAttribute()412 virtual AccessibilityRole ariaRoleAttribute() const { return UnknownRole; } isPresentationalChildOfAriaRole()413 virtual bool isPresentationalChildOfAriaRole() const { return false; } ariaRoleHasPresentationalChildren()414 virtual bool ariaRoleHasPresentationalChildren() const { return false; } 415 setRoleValue(AccessibilityRole role)416 void setRoleValue(AccessibilityRole role) { m_role = role; } roleValue()417 virtual AccessibilityRole roleValue() const { return m_role; } ariaLabeledByAttribute()418 virtual String ariaLabeledByAttribute() const { return String(); } ariaDescribedByAttribute()419 virtual String ariaDescribedByAttribute() const { return String(); } accessibilityDescription()420 virtual String accessibilityDescription() const { return String(); } 421 422 virtual AXObjectCache* axObjectCache() const; axObjectID()423 AXID axObjectID() const { return m_id; } setAXObjectID(AXID axObjectID)424 void setAXObjectID(AXID axObjectID) { m_id = axObjectID; } 425 426 static AccessibilityObject* anchorElementForNode(Node*); anchorElement()427 virtual Element* anchorElement() const { return 0; } actionElement()428 virtual Element* actionElement() const { return 0; } boundingBoxRect()429 virtual IntRect boundingBoxRect() const { return IntRect(); } 430 virtual IntRect elementRect() const = 0; size()431 virtual IntSize size() const { return elementRect().size(); } 432 virtual IntPoint clickPoint() const; 433 selectedTextRange()434 virtual PlainTextRange selectedTextRange() const { return PlainTextRange(); } selectionStart()435 unsigned selectionStart() const { return selectedTextRange().start; } selectionEnd()436 unsigned selectionEnd() const { return selectedTextRange().length; } 437 url()438 virtual KURL url() const { return KURL(); } selection()439 virtual VisibleSelection selection() const { return VisibleSelection(); } stringValue()440 virtual String stringValue() const { return String(); } title()441 virtual String title() const { return String(); } helpText()442 virtual String helpText() const { return String(); } textUnderElement()443 virtual String textUnderElement() const { return String(); } text()444 virtual String text() const { return String(); } textLength()445 virtual int textLength() const { return 0; } selectedText()446 virtual String selectedText() const { return String(); } accessKey()447 virtual const AtomicString& accessKey() const { return nullAtom; } 448 const String& actionVerb() const; widget()449 virtual Widget* widget() const { return 0; } widgetForAttachmentView()450 virtual Widget* widgetForAttachmentView() const { return 0; } 451 virtual Document* document() const; topDocumentFrameView()452 virtual FrameView* topDocumentFrameView() const { return 0; } 453 virtual FrameView* documentFrameView() const; 454 String language() const; hierarchicalLevel()455 virtual unsigned hierarchicalLevel() const { return 0; } 456 const AtomicString& placeholderValue() const; 457 setFocused(bool)458 virtual void setFocused(bool) { } setSelectedText(const String &)459 virtual void setSelectedText(const String&) { } setSelectedTextRange(const PlainTextRange &)460 virtual void setSelectedTextRange(const PlainTextRange&) { } setValue(const String &)461 virtual void setValue(const String&) { } setValue(float)462 virtual void setValue(float) { } setSelected(bool)463 virtual void setSelected(bool) { } setSelectedRows(AccessibilityChildrenVector &)464 virtual void setSelectedRows(AccessibilityChildrenVector&) { } 465 makeRangeVisible(const PlainTextRange &)466 virtual void makeRangeVisible(const PlainTextRange&) { } 467 virtual bool press() const; performDefaultAction()468 bool performDefaultAction() const { return press(); } 469 470 virtual AccessibilityOrientation orientation() const; increment()471 virtual void increment() { } decrement()472 virtual void decrement() { } 473 childrenChanged()474 virtual void childrenChanged() { } contentChanged()475 virtual void contentChanged() { } children()476 virtual const AccessibilityChildrenVector& children() { return m_children; } addChildren()477 virtual void addChildren() { } canHaveChildren()478 virtual bool canHaveChildren() const { return true; } hasChildren()479 virtual bool hasChildren() const { return m_haveChildren; } 480 virtual void updateChildrenIfNecessary(); selectedChildren(AccessibilityChildrenVector &)481 virtual void selectedChildren(AccessibilityChildrenVector&) { } visibleChildren(AccessibilityChildrenVector &)482 virtual void visibleChildren(AccessibilityChildrenVector&) { } tabChildren(AccessibilityChildrenVector &)483 virtual void tabChildren(AccessibilityChildrenVector&) { } shouldFocusActiveDescendant()484 virtual bool shouldFocusActiveDescendant() const { return false; } activeDescendant()485 virtual AccessibilityObject* activeDescendant() const { return 0; } handleActiveDescendantChanged()486 virtual void handleActiveDescendantChanged() { } handleAriaExpandedChanged()487 virtual void handleAriaExpandedChanged() { } 488 489 static AccessibilityRole ariaRoleToWebCoreRole(const String&); 490 const AtomicString& getAttribute(const QualifiedName&) const; 491 visiblePositionRange()492 virtual VisiblePositionRange visiblePositionRange() const { return VisiblePositionRange(); } visiblePositionRangeForLine(unsigned)493 virtual VisiblePositionRange visiblePositionRangeForLine(unsigned) const { return VisiblePositionRange(); } 494 495 VisiblePositionRange visiblePositionRangeForUnorderedPositions(const VisiblePosition&, const VisiblePosition&) const; 496 VisiblePositionRange positionOfLeftWord(const VisiblePosition&) const; 497 VisiblePositionRange positionOfRightWord(const VisiblePosition&) const; 498 VisiblePositionRange leftLineVisiblePositionRange(const VisiblePosition&) const; 499 VisiblePositionRange rightLineVisiblePositionRange(const VisiblePosition&) const; 500 VisiblePositionRange sentenceForPosition(const VisiblePosition&) const; 501 VisiblePositionRange paragraphForPosition(const VisiblePosition&) const; 502 VisiblePositionRange styleRangeForPosition(const VisiblePosition&) const; 503 VisiblePositionRange visiblePositionRangeForRange(const PlainTextRange&) const; 504 505 String stringForVisiblePositionRange(const VisiblePositionRange&) const; boundsForVisiblePositionRange(const VisiblePositionRange &)506 virtual IntRect boundsForVisiblePositionRange(const VisiblePositionRange&) const { return IntRect(); } 507 int lengthForVisiblePositionRange(const VisiblePositionRange&) const; setSelectedVisiblePositionRange(const VisiblePositionRange &)508 virtual void setSelectedVisiblePositionRange(const VisiblePositionRange&) const { } 509 visiblePositionForPoint(const IntPoint &)510 virtual VisiblePosition visiblePositionForPoint(const IntPoint&) const { return VisiblePosition(); } nextVisiblePosition(const VisiblePosition & visiblePos)511 VisiblePosition nextVisiblePosition(const VisiblePosition& visiblePos) const { return visiblePos.next(); } previousVisiblePosition(const VisiblePosition & visiblePos)512 VisiblePosition previousVisiblePosition(const VisiblePosition& visiblePos) const { return visiblePos.previous(); } 513 VisiblePosition nextWordEnd(const VisiblePosition&) const; 514 VisiblePosition previousWordStart(const VisiblePosition&) const; 515 VisiblePosition nextLineEndPosition(const VisiblePosition&) const; 516 VisiblePosition previousLineStartPosition(const VisiblePosition&) const; 517 VisiblePosition nextSentenceEndPosition(const VisiblePosition&) const; 518 VisiblePosition previousSentenceStartPosition(const VisiblePosition&) const; 519 VisiblePosition nextParagraphEndPosition(const VisiblePosition&) const; 520 VisiblePosition previousParagraphStartPosition(const VisiblePosition&) const; visiblePositionForIndex(unsigned,bool)521 virtual VisiblePosition visiblePositionForIndex(unsigned, bool /*lastIndexOK */) const { return VisiblePosition(); } 522 visiblePositionForIndex(int)523 virtual VisiblePosition visiblePositionForIndex(int) const { return VisiblePosition(); } indexForVisiblePosition(const VisiblePosition &)524 virtual int indexForVisiblePosition(const VisiblePosition&) const { return 0; } 525 526 AccessibilityObject* accessibilityObjectForPosition(const VisiblePosition&) const; 527 int lineForPosition(const VisiblePosition&) const; 528 PlainTextRange plainTextRangeForVisiblePositionRange(const VisiblePositionRange&) const; index(const VisiblePosition &)529 virtual int index(const VisiblePosition&) const { return -1; } 530 doAXRangeForLine(unsigned)531 virtual PlainTextRange doAXRangeForLine(unsigned) const { return PlainTextRange(); } 532 PlainTextRange doAXRangeForPosition(const IntPoint&) const; doAXRangeForIndex(unsigned)533 virtual PlainTextRange doAXRangeForIndex(unsigned) const { return PlainTextRange(); } 534 PlainTextRange doAXStyleRangeForIndex(unsigned) const; 535 doAXStringForRange(const PlainTextRange &)536 virtual String doAXStringForRange(const PlainTextRange&) const { return String(); } doAXBoundsForRange(const PlainTextRange &)537 virtual IntRect doAXBoundsForRange(const PlainTextRange&) const { return IntRect(); } 538 String listMarkerTextForNodeAndPosition(Node*, const VisiblePosition&) const; 539 540 unsigned doAXLineForIndex(unsigned); 541 stringValueForMSAA()542 virtual String stringValueForMSAA() const { return String(); } stringRoleForMSAA()543 virtual String stringRoleForMSAA() const { return String(); } nameForMSAA()544 virtual String nameForMSAA() const { return String(); } descriptionForMSAA()545 virtual String descriptionForMSAA() const { return String(); } roleValueForMSAA()546 virtual AccessibilityRole roleValueForMSAA() const { return roleValue(); } 547 548 // Used by an ARIA tree to get all its rows. 549 void ariaTreeRows(AccessibilityChildrenVector&); 550 // Used by an ARIA tree item to get all of its direct rows that it can disclose. 551 void ariaTreeItemDisclosedRows(AccessibilityChildrenVector&); 552 // Used by an ARIA tree item to get only its content, and not its child tree items and groups. 553 void ariaTreeItemContent(AccessibilityChildrenVector&); 554 555 // ARIA live-region features. 556 bool supportsARIALiveRegion() const; 557 bool isInsideARIALiveRegion() const; ariaLiveRegionStatus()558 virtual const AtomicString& ariaLiveRegionStatus() const { return nullAtom; } ariaLiveRegionRelevant()559 virtual const AtomicString& ariaLiveRegionRelevant() const { return nullAtom; } ariaLiveRegionAtomic()560 virtual bool ariaLiveRegionAtomic() const { return false; } ariaLiveRegionBusy()561 virtual bool ariaLiveRegionBusy() const { return false; } 562 563 bool supportsARIAAttributes() const; 564 565 // CSS3 Speech properties. speakProperty()566 virtual ESpeak speakProperty() const { return SpeakNormal; } 567 568 #if HAVE(ACCESSIBILITY) 569 #if PLATFORM(GTK) 570 AccessibilityObjectWrapper* wrapper() const; 571 void setWrapper(AccessibilityObjectWrapper*); 572 #else wrapper()573 AccessibilityObjectWrapper* wrapper() const { return m_wrapper.get(); } setWrapper(AccessibilityObjectWrapper * wrapper)574 void setWrapper(AccessibilityObjectWrapper* wrapper) 575 { 576 m_wrapper = wrapper; 577 } 578 #endif 579 #endif 580 581 #if HAVE(ACCESSIBILITY) 582 // a platform-specific method for determining if an attachment is ignored 583 bool accessibilityIgnoreAttachment() const; 584 // gives platforms the opportunity to indicate if and how an object should be included 585 AccessibilityObjectInclusion accessibilityPlatformIncludesObject() const; 586 #else accessibilityIgnoreAttachment()587 bool accessibilityIgnoreAttachment() const { return true; } accessibilityPlatformIncludesObject()588 AccessibilityObjectInclusion accessibilityPlatformIncludesObject() const { return DefaultBehavior; } 589 #endif 590 591 // allows for an AccessibilityObject to update its render tree or perform 592 // other operations update type operations updateBackingStore()593 virtual void updateBackingStore() { } 594 595 protected: 596 AXID m_id; 597 AccessibilityChildrenVector m_children; 598 mutable bool m_haveChildren; 599 AccessibilityRole m_role; 600 601 virtual void clearChildren(); isDetached()602 virtual bool isDetached() const { return true; } 603 604 #if PLATFORM(GTK) 605 bool allowsTextRanges() const; 606 unsigned getLengthForTextRange() const; 607 #else allowsTextRanges()608 bool allowsTextRanges() const { return isTextControl(); } getLengthForTextRange()609 unsigned getLengthForTextRange() const { return text().length(); } 610 #endif 611 612 #if PLATFORM(MAC) 613 RetainPtr<AccessibilityObjectWrapper> m_wrapper; 614 #elif PLATFORM(WIN) && !OS(WINCE) 615 COMPtr<AccessibilityObjectWrapper> m_wrapper; 616 #elif PLATFORM(GTK) 617 AtkObject* m_wrapper; 618 #elif PLATFORM(CHROMIUM) 619 RefPtr<AccessibilityObjectWrapper> m_wrapper; 620 #endif 621 }; 622 623 } // namespace WebCore 624 625 #endif // AccessibilityObject_h 626