1 /* 2 * Copyright (C) 2009 Google 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 are 6 * met: 7 * 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * * Neither the name of Google Inc. nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31 #ifndef WebAccessibilityObject_h 32 #define WebAccessibilityObject_h 33 34 #include "../platform/WebCommon.h" 35 #include "../platform/WebPrivatePtr.h" 36 #include "../platform/WebVector.h" 37 #include "WebAccessibilityRole.h" 38 39 #if WEBKIT_IMPLEMENTATION 40 namespace WTF { template <typename T> class PassRefPtr; } 41 #endif 42 43 namespace WebCore { class AccessibilityObject; } 44 45 namespace WebKit { 46 47 class WebNode; 48 class WebDocument; 49 class WebString; 50 class WebURL; 51 struct WebPoint; 52 struct WebRect; 53 54 // A container for passing around a reference to AccessibilityObject. 55 class WebAccessibilityObject { 56 public: 57 ~WebAccessibilityObject() { reset(); } 58 59 WebAccessibilityObject() { } 60 WebAccessibilityObject(const WebAccessibilityObject& o) { assign(o); } 61 WebAccessibilityObject& operator=(const WebAccessibilityObject& o) 62 { 63 assign(o); 64 return *this; 65 } 66 67 WEBKIT_EXPORT void reset(); 68 WEBKIT_EXPORT void assign(const WebAccessibilityObject&); 69 WEBKIT_EXPORT bool equals(const WebAccessibilityObject&) const; 70 71 bool isNull() const { return m_private.isNull(); } 72 // isDetached also checks for null, so it's safe to just call isDetached. 73 WEBKIT_EXPORT bool isDetached() const; 74 75 // Static methods for enabling accessibility. 76 WEBKIT_EXPORT static void enableAccessibility(); 77 WEBKIT_EXPORT static bool accessibilityEnabled(); 78 79 WEBKIT_EXPORT void startCachingComputedObjectAttributesUntilTreeMutates(); 80 WEBKIT_EXPORT void stopCachingComputedObjectAttributes(); 81 82 WEBKIT_EXPORT int axID() const; 83 84 // Update the underlying tree, and return true if this object is 85 // still valid (not detached). Note that calling this method 86 // can cause other WebAccessibilityObjects to become invalid, too, 87 // so always call isDetached if updateBackingStoreAndCheckValidity 88 // has been called on any object, or if any other WebCore code has run. 89 WEBKIT_EXPORT bool updateBackingStoreAndCheckValidity(); 90 91 WEBKIT_EXPORT WebString accessibilityDescription() const; 92 WEBKIT_EXPORT unsigned childCount() const; 93 94 WEBKIT_EXPORT WebAccessibilityObject childAt(unsigned) const; 95 WEBKIT_EXPORT WebAccessibilityObject parentObject() const; 96 97 WEBKIT_EXPORT bool isAnchor() const; 98 WEBKIT_EXPORT bool isAriaReadOnly() const; 99 WEBKIT_EXPORT bool isButtonStateMixed() const; 100 WEBKIT_EXPORT bool isChecked() const; 101 WEBKIT_EXPORT bool isCollapsed() const; 102 WEBKIT_EXPORT bool isControl() const; 103 WEBKIT_EXPORT bool isEnabled() const; 104 WEBKIT_EXPORT bool isFocused() const; 105 WEBKIT_EXPORT bool isHovered() const; 106 WEBKIT_EXPORT bool isIndeterminate() const; 107 WEBKIT_EXPORT bool isLinked() const; 108 WEBKIT_EXPORT bool isLoaded() const; 109 WEBKIT_EXPORT bool isMultiSelectable() const; 110 WEBKIT_EXPORT bool isOffScreen() const; 111 WEBKIT_EXPORT bool isPasswordField() const; 112 WEBKIT_EXPORT bool isPressed() const; 113 WEBKIT_EXPORT bool isReadOnly() const; 114 WEBKIT_EXPORT bool isRequired() const; 115 WEBKIT_EXPORT bool isSelected() const; 116 WEBKIT_EXPORT bool isSelectedOptionActive() const; 117 WEBKIT_EXPORT bool isVertical() const; 118 WEBKIT_EXPORT bool isVisible() const; 119 WEBKIT_EXPORT bool isVisited() const; 120 121 WEBKIT_EXPORT WebString accessKey() const; 122 WEBKIT_EXPORT bool ariaHasPopup() const; 123 WEBKIT_EXPORT bool ariaLiveRegionAtomic() const; 124 WEBKIT_EXPORT bool ariaLiveRegionBusy() const; 125 WEBKIT_EXPORT WebString ariaLiveRegionRelevant() const; 126 WEBKIT_EXPORT WebString ariaLiveRegionStatus() const; 127 WEBKIT_EXPORT WebRect boundingBoxRect() const; 128 WEBKIT_EXPORT bool canvasHasFallbackContent() const; 129 WEBKIT_EXPORT WebPoint clickPoint() const; 130 WEBKIT_EXPORT void colorValue(int& r, int& g, int& b) const; 131 WEBKIT_EXPORT double estimatedLoadingProgress() const; 132 WEBKIT_EXPORT WebString helpText() const; 133 WEBKIT_EXPORT int headingLevel() const; 134 WEBKIT_EXPORT int hierarchicalLevel() const; 135 WEBKIT_EXPORT WebAccessibilityObject hitTest(const WebPoint&) const; 136 WEBKIT_EXPORT WebString keyboardShortcut() const; 137 WEBKIT_EXPORT WebAccessibilityRole roleValue() const; 138 WEBKIT_EXPORT unsigned selectionEnd() const; 139 WEBKIT_EXPORT unsigned selectionEndLineNumber() const; 140 WEBKIT_EXPORT unsigned selectionStart() const; 141 WEBKIT_EXPORT unsigned selectionStartLineNumber() const; 142 WEBKIT_EXPORT WebString stringValue() const; 143 WEBKIT_EXPORT WebString title() const; 144 WEBKIT_EXPORT WebAccessibilityObject titleUIElement() const; 145 WEBKIT_EXPORT WebURL url() const; 146 147 WEBKIT_EXPORT bool supportsRangeValue() const; 148 WEBKIT_EXPORT WebString valueDescription() const; 149 WEBKIT_EXPORT float valueForRange() const; 150 WEBKIT_EXPORT float maxValueForRange() const; 151 WEBKIT_EXPORT float minValueForRange() const; 152 153 WEBKIT_EXPORT WebNode node() const; 154 WEBKIT_EXPORT WebDocument document() const; 155 WEBKIT_EXPORT bool hasComputedStyle() const; 156 WEBKIT_EXPORT WebString computedStyleDisplay() const; 157 WEBKIT_EXPORT bool accessibilityIsIgnored() const; 158 WEBKIT_EXPORT bool lineBreaks(WebVector<int>&) const; 159 160 // Actions 161 WEBKIT_EXPORT WebString actionVerb() const; // The verb corresponding to performDefaultAction. 162 WEBKIT_EXPORT bool canDecrement() const; 163 WEBKIT_EXPORT bool canIncrement() const; 164 WEBKIT_EXPORT bool canPress() const; 165 WEBKIT_EXPORT bool canSetFocusAttribute() const; 166 WEBKIT_EXPORT bool canSetSelectedAttribute() const; 167 WEBKIT_EXPORT bool canSetValueAttribute() const; 168 WEBKIT_EXPORT bool performDefaultAction() const; 169 WEBKIT_EXPORT bool press() const; 170 WEBKIT_EXPORT bool increment() const; 171 WEBKIT_EXPORT bool decrement() const; 172 WEBKIT_EXPORT void setFocused(bool) const; 173 WEBKIT_EXPORT void setSelectedTextRange(int selectionStart, int selectionEnd) const; 174 175 // For a table 176 WEBKIT_EXPORT unsigned columnCount() const; 177 WEBKIT_EXPORT unsigned rowCount() const; 178 WEBKIT_EXPORT WebAccessibilityObject cellForColumnAndRow(unsigned column, unsigned row) const; 179 WEBKIT_EXPORT WebAccessibilityObject headerContainerObject() const; 180 WEBKIT_EXPORT WebAccessibilityObject rowAtIndex(unsigned rowIndex) const; 181 WEBKIT_EXPORT WebAccessibilityObject columnAtIndex(unsigned columnIndex) const; 182 183 // For a table row 184 WEBKIT_EXPORT unsigned rowIndex() const; 185 WEBKIT_EXPORT WebAccessibilityObject rowHeader() const; 186 187 // For a table column 188 WEBKIT_EXPORT unsigned columnIndex() const; 189 WEBKIT_EXPORT WebAccessibilityObject columnHeader() const; 190 191 // For a table cell 192 WEBKIT_EXPORT unsigned cellColumnIndex() const; 193 WEBKIT_EXPORT unsigned cellColumnSpan() const; 194 WEBKIT_EXPORT unsigned cellRowIndex() const; 195 WEBKIT_EXPORT unsigned cellRowSpan() const; 196 197 // Make this object visible by scrolling as many nested scrollable views as needed. 198 WEBKIT_EXPORT void scrollToMakeVisible() const; 199 // Same, but if the whole object can't be made visible, try for this subrect, in local coordinates. 200 WEBKIT_EXPORT void scrollToMakeVisibleWithSubFocus(const WebRect&) const; 201 // Scroll this object to a given point in global coordinates of the top-level window. 202 WEBKIT_EXPORT void scrollToGlobalPoint(const WebPoint&) const; 203 204 #if WEBKIT_IMPLEMENTATION 205 WebAccessibilityObject(const WTF::PassRefPtr<WebCore::AccessibilityObject>&); 206 WebAccessibilityObject& operator=(const WTF::PassRefPtr<WebCore::AccessibilityObject>&); 207 operator WTF::PassRefPtr<WebCore::AccessibilityObject>() const; 208 #endif 209 210 private: 211 WebPrivatePtr<WebCore::AccessibilityObject> m_private; 212 }; 213 214 } // namespace WebKit 215 216 #endif 217