1 /* 2 * Copyright (C) 2008 Apple Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of 14 * its contributors may be used to endorse or promote products derived 15 * from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 #ifndef AccessibilityRenderObject_h 30 #define AccessibilityRenderObject_h 31 32 #include "AccessibilityObject.h" 33 34 namespace WebCore { 35 36 class AXObjectCache; 37 class Element; 38 class Frame; 39 class FrameView; 40 class HitTestResult; 41 class HTMLAnchorElement; 42 class HTMLAreaElement; 43 class HTMLElement; 44 class HTMLLabelElement; 45 class HTMLMapElement; 46 class HTMLSelectElement; 47 class IntPoint; 48 class IntSize; 49 class Node; 50 class RenderObject; 51 class RenderListBox; 52 class RenderTextControl; 53 class RenderView; 54 class VisibleSelection; 55 class String; 56 class Widget; 57 58 class AccessibilityRenderObject : public AccessibilityObject { 59 protected: 60 AccessibilityRenderObject(RenderObject*); 61 public: 62 static PassRefPtr<AccessibilityRenderObject> create(RenderObject*); 63 virtual ~AccessibilityRenderObject(); 64 isAccessibilityRenderObject()65 bool isAccessibilityRenderObject() const { return true; } 66 67 virtual bool isAnchor() const; 68 virtual bool isAttachment() const; 69 virtual bool isHeading() const; 70 virtual bool isLink() const; 71 virtual bool isImageButton() const; 72 virtual bool isImage() const; 73 virtual bool isNativeImage() const; 74 virtual bool isPasswordField() const; 75 virtual bool isTextControl() const; 76 virtual bool isNativeTextControl() const; 77 virtual bool isWebArea() const; 78 virtual bool isCheckboxOrRadio() const; 79 virtual bool isFileUploadButton() const; 80 virtual bool isInputImage() const; 81 virtual bool isProgressIndicator() const; 82 virtual bool isSlider() const; 83 virtual bool isMenuRelated() const; 84 virtual bool isMenu() const; 85 virtual bool isMenuBar() const; 86 virtual bool isMenuButton() const; 87 virtual bool isMenuItem() const; 88 virtual bool isControl() const; 89 virtual bool isFieldset() const; 90 virtual bool isGroup() const; 91 92 virtual bool isEnabled() const; 93 virtual bool isSelected() const; 94 virtual bool isFocused() const; 95 virtual bool isChecked() const; 96 virtual bool isHovered() const; 97 virtual bool isIndeterminate() const; 98 virtual bool isLoaded() const; 99 virtual bool isMultiSelectable() const; 100 virtual bool isOffScreen() const; 101 virtual bool isPressed() const; 102 virtual bool isReadOnly() const; 103 virtual bool isVisited() const; 104 virtual bool isRequired() const; 105 virtual bool isLinked() const; 106 virtual bool isExpanded() const; 107 virtual void setIsExpanded(bool); 108 109 const AtomicString& getAttribute(const QualifiedName&) const; 110 virtual bool canSetFocusAttribute() const; 111 virtual bool canSetTextRangeAttributes() const; 112 virtual bool canSetValueAttribute() const; 113 virtual bool canSetExpandedAttribute() const; 114 115 virtual bool hasIntValue() const; 116 117 virtual bool accessibilityIsIgnored() const; 118 119 virtual int headingLevel() const; 120 virtual int intValue() const; 121 virtual String valueDescription() const; 122 virtual float valueForRange() const; 123 virtual float maxValueForRange() const; 124 virtual float minValueForRange() const; 125 virtual AccessibilityObject* selectedRadioButton(); 126 virtual AccessibilityObject* selectedTabItem(); 127 virtual int layoutCount() const; 128 virtual double estimatedLoadingProgress() const; 129 130 virtual AccessibilityObject* doAccessibilityHitTest(const IntPoint&) const; 131 virtual AccessibilityObject* focusedUIElement() const; 132 virtual AccessibilityObject* firstChild() const; 133 virtual AccessibilityObject* lastChild() const; 134 virtual AccessibilityObject* previousSibling() const; 135 virtual AccessibilityObject* nextSibling() const; 136 virtual AccessibilityObject* parentObject() const; 137 virtual AccessibilityObject* parentObjectIfExists() const; 138 virtual AccessibilityObject* observableObject() const; 139 virtual void linkedUIElements(AccessibilityChildrenVector&) const; 140 virtual bool exposesTitleUIElement() const; 141 virtual AccessibilityObject* titleUIElement() const; 142 virtual AccessibilityObject* correspondingControlForLabelElement() const; 143 virtual AccessibilityObject* correspondingLabelForControlElement() const; 144 145 virtual void ariaOwnsElements(AccessibilityChildrenVector&) const; 146 virtual bool supportsARIAOwns() const; 147 virtual AccessibilityRole ariaRoleAttribute() const; 148 virtual bool isPresentationalChildOfAriaRole() const; 149 virtual bool ariaRoleHasPresentationalChildren() const; 150 void updateAccessibilityRole(); 151 152 virtual AXObjectCache* axObjectCache() const; 153 154 virtual Element* actionElement() const; 155 Element* mouseButtonListener() const; 156 FrameView* frameViewIfRenderView() const; 157 virtual Element* anchorElement() const; 158 AccessibilityObject* menuForMenuButton() const; 159 AccessibilityObject* menuButtonForMenu() const; 160 161 virtual IntRect boundingBoxRect() const; 162 virtual IntRect elementRect() const; 163 virtual IntSize size() const; 164 virtual IntPoint clickPoint() const; 165 setRenderer(RenderObject * renderer)166 void setRenderer(RenderObject* renderer) { m_renderer = renderer; } renderer()167 RenderObject* renderer() const { return m_renderer; } 168 RenderView* topRenderer() const; 169 RenderTextControl* textControl() const; 170 Document* document() const; 171 FrameView* topDocumentFrameView() const; 172 HTMLLabelElement* labelElementContainer() const; 173 174 virtual KURL url() const; 175 virtual PlainTextRange selectedTextRange() const; 176 virtual VisibleSelection selection() const; 177 virtual String stringValue() const; 178 virtual String ariaLabeledByAttribute() const; 179 virtual String title() const; 180 virtual String ariaDescribedByAttribute() const; 181 virtual String accessibilityDescription() const; 182 virtual String helpText() const; 183 virtual String textUnderElement() const; 184 virtual String text() const; 185 virtual int textLength() const; 186 virtual PassRefPtr<Range> ariaSelectedTextDOMRange() const; 187 virtual String selectedText() const; 188 virtual const AtomicString& accessKey() const; 189 virtual const String& actionVerb() const; 190 virtual Widget* widget() const; 191 virtual Widget* widgetForAttachmentView() const; 192 virtual void getDocumentLinks(AccessibilityChildrenVector&); 193 virtual FrameView* documentFrameView() const; 194 virtual String language() const; 195 virtual unsigned hierarchicalLevel() const; 196 197 virtual const AccessibilityChildrenVector& children(); 198 199 virtual void setFocused(bool); 200 virtual void setSelectedTextRange(const PlainTextRange&); 201 virtual void setValue(const String&); 202 virtual void setSelected(bool); 203 virtual void setSelectedRows(AccessibilityChildrenVector&); 204 virtual void changeValueByPercent(float percentChange); 205 virtual AccessibilityOrientation orientation() const; 206 virtual void increment(); 207 virtual void decrement(); 208 209 virtual void detach(); 210 virtual void childrenChanged(); 211 virtual void contentChanged(); 212 virtual void addChildren(); 213 virtual bool canHaveChildren() const; 214 virtual void selectedChildren(AccessibilityChildrenVector&); 215 virtual void visibleChildren(AccessibilityChildrenVector&); 216 virtual void tabChildren(AccessibilityChildrenVector&); 217 virtual bool shouldFocusActiveDescendant() const; 218 virtual AccessibilityObject* activeDescendant() const; 219 virtual void handleActiveDescendantChanged(); 220 221 virtual VisiblePositionRange visiblePositionRange() const; 222 virtual VisiblePositionRange visiblePositionRangeForLine(unsigned) const; 223 virtual IntRect boundsForVisiblePositionRange(const VisiblePositionRange&) const; 224 virtual void setSelectedVisiblePositionRange(const VisiblePositionRange&) const; 225 virtual bool supportsARIAFlowTo() const; 226 virtual void ariaFlowToElements(AccessibilityChildrenVector&) const; 227 228 virtual bool supportsARIADropping(); 229 virtual bool supportsARIADragging(); 230 virtual bool isARIAGrabbed(); 231 virtual void setARIAGrabbed(bool); 232 virtual void determineARIADropEffects(Vector<String>&); 233 234 virtual VisiblePosition visiblePositionForPoint(const IntPoint&) const; 235 virtual VisiblePosition visiblePositionForIndex(unsigned indexValue, bool lastIndexOK) const; 236 virtual int index(const VisiblePosition&) const; 237 238 virtual VisiblePosition visiblePositionForIndex(int) const; 239 virtual int indexForVisiblePosition(const VisiblePosition&) const; 240 241 virtual PlainTextRange doAXRangeForLine(unsigned) const; 242 virtual PlainTextRange doAXRangeForIndex(unsigned) const; 243 244 virtual String doAXStringForRange(const PlainTextRange&) const; 245 virtual IntRect doAXBoundsForRange(const PlainTextRange&) const; 246 247 virtual void updateBackingStore(); 248 249 virtual String stringValueForMSAA() const; 250 virtual String stringRoleForMSAA() const; 251 virtual String nameForMSAA() const; 252 virtual String descriptionForMSAA() const; 253 virtual AccessibilityRole roleValueForMSAA() const; 254 255 protected: 256 RenderObject* m_renderer; 257 AccessibilityRole m_ariaRole; 258 mutable bool m_childrenDirty; 259 setRenderObject(RenderObject * renderer)260 void setRenderObject(RenderObject* renderer) { m_renderer = renderer; } 261 void ariaLabeledByElements(Vector<Element*>& elements) const; 262 isDetached()263 virtual bool isDetached() const { return !m_renderer; } 264 265 private: 266 void ariaListboxSelectedChildren(AccessibilityChildrenVector&); 267 void ariaListboxVisibleChildren(AccessibilityChildrenVector&); 268 bool ariaIsHidden() const; 269 bool isDescendantOfBarrenParent() const; 270 bool isAllowedChildOfTree() const; 271 bool hasTextAlternative() const; 272 String positionalDescriptionForMSAA() const; 273 274 Element* menuElementForMenuButton() const; 275 Element* menuItemElementForMenu() const; 276 AccessibilityRole determineAccessibilityRole(); 277 AccessibilityRole determineAriaRoleAttribute() const; 278 279 bool isTabItemSelected() const; 280 IntRect checkboxOrRadioRect() const; 281 void addRadioButtonGroupMembers(AccessibilityChildrenVector& linkedUIElements) const; 282 AccessibilityObject* internalLinkElement() const; 283 AccessibilityObject* accessibilityImageMapHitTest(HTMLAreaElement*, const IntPoint&) const; 284 AccessibilityObject* accessibilityParentForImageMap(HTMLMapElement* map) const; 285 286 void ariaSelectedRows(AccessibilityChildrenVector&); 287 288 bool elementAttributeValue(const QualifiedName&) const; 289 void setElementAttributeValue(const QualifiedName&, bool); 290 291 String accessibilityDescriptionForElements(Vector<Element*> &elements) const; 292 void elementsFromAttribute(Vector<Element*>& elements, const QualifiedName& name) const; 293 294 virtual const AtomicString& ariaLiveRegionStatus() const; 295 virtual const AtomicString& ariaLiveRegionRelevant() const; 296 virtual bool ariaLiveRegionAtomic() const; 297 virtual bool ariaLiveRegionBusy() const; 298 setNeedsToUpdateChildren()299 void setNeedsToUpdateChildren() const { m_childrenDirty = true; } needsToUpdateChildren()300 bool needsToUpdateChildren() const { return m_childrenDirty; } 301 302 mutable AccessibilityRole m_roleForMSAA; 303 }; 304 305 } // namespace WebCore 306 307 #endif // AccessibilityRenderObject_h 308