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 WebAXObject_h 32 #define WebAXObject_h 33 34 #include "../platform/WebCommon.h" 35 #include "../platform/WebPrivatePtr.h" 36 #include "../platform/WebVector.h" 37 #include "WebAXEnums.h" 38 39 #if BLINK_IMPLEMENTATION 40 namespace WTF { template <typename T> class PassRefPtr; } 41 #endif 42 43 namespace WebCore { class AXObject; } 44 45 namespace blink { 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 AXObject. 55 class WebAXObject { 56 public: ~WebAXObject()57 ~WebAXObject() { reset(); } 58 WebAXObject()59 WebAXObject() { } WebAXObject(const WebAXObject & o)60 WebAXObject(const WebAXObject& o) { assign(o); } 61 WebAXObject& operator=(const WebAXObject& o) 62 { 63 assign(o); 64 return *this; 65 } 66 67 BLINK_EXPORT void reset(); 68 BLINK_EXPORT void assign(const WebAXObject&); 69 BLINK_EXPORT bool equals(const WebAXObject&) const; 70 isNull()71 bool isNull() const { return m_private.isNull(); } 72 // isDetached also checks for null, so it's safe to just call isDetached. 73 BLINK_EXPORT bool isDetached() const; 74 75 // Static methods for enabling accessibility. 76 BLINK_EXPORT static void enableAccessibility(); 77 BLINK_EXPORT static bool accessibilityEnabled(); 78 79 BLINK_EXPORT void startCachingComputedObjectAttributesUntilTreeMutates(); 80 BLINK_EXPORT void stopCachingComputedObjectAttributes(); 81 82 // Temporary: this flag will only be toggleable until Chromium has it on by default. 83 BLINK_EXPORT static void enableInlineTextBoxAccessibility(); 84 85 BLINK_EXPORT int axID() const; 86 87 // Update the underlying tree, and return true if this object is 88 // still valid (not detached). Note that calling this method 89 // can cause other WebAXObjects to become invalid, too, 90 // so always call isDetached if updateBackingStoreAndCheckValidity 91 // has been called on any object, or if any other WebCore code has run. 92 BLINK_EXPORT bool updateBackingStoreAndCheckValidity(); 93 94 BLINK_EXPORT WebString accessibilityDescription() const; 95 BLINK_EXPORT unsigned childCount() const; 96 97 BLINK_EXPORT WebAXObject childAt(unsigned) const; 98 BLINK_EXPORT WebAXObject parentObject() const; 99 100 BLINK_EXPORT bool isAnchor() const; 101 BLINK_EXPORT bool isAriaReadOnly() const; 102 BLINK_EXPORT bool isButtonStateMixed() const; 103 BLINK_EXPORT bool isChecked() const; 104 BLINK_EXPORT bool isClickable() const; 105 BLINK_EXPORT bool isCollapsed() const; 106 BLINK_EXPORT bool isControl() const; 107 BLINK_EXPORT bool isEnabled() const; 108 BLINK_EXPORT bool isFocused() const; 109 BLINK_EXPORT bool isHovered() const; 110 BLINK_EXPORT bool isIndeterminate() const; 111 BLINK_EXPORT bool isLinked() const; 112 BLINK_EXPORT bool isLoaded() const; 113 BLINK_EXPORT bool isMultiSelectable() const; 114 BLINK_EXPORT bool isOffScreen() const; 115 BLINK_EXPORT bool isPasswordField() const; 116 BLINK_EXPORT bool isPressed() const; 117 BLINK_EXPORT bool isReadOnly() const; 118 BLINK_EXPORT bool isRequired() const; 119 BLINK_EXPORT bool isSelected() const; 120 BLINK_EXPORT bool isSelectedOptionActive() const; 121 BLINK_EXPORT bool isVertical() const; 122 BLINK_EXPORT bool isVisible() const; 123 BLINK_EXPORT bool isVisited() const; 124 125 BLINK_EXPORT WebString accessKey() const; 126 BLINK_EXPORT bool ariaHasPopup() const; 127 BLINK_EXPORT bool ariaLiveRegionAtomic() const; 128 BLINK_EXPORT bool ariaLiveRegionBusy() const; 129 BLINK_EXPORT WebString ariaLiveRegionRelevant() const; 130 BLINK_EXPORT WebString ariaLiveRegionStatus() const; 131 BLINK_EXPORT WebRect boundingBoxRect() const; 132 BLINK_EXPORT bool canvasHasFallbackContent() const; 133 BLINK_EXPORT WebPoint clickPoint() const; 134 BLINK_EXPORT void colorValue(int& r, int& g, int& b) const; 135 BLINK_EXPORT double estimatedLoadingProgress() const; 136 BLINK_EXPORT WebString helpText() const; 137 BLINK_EXPORT int headingLevel() const; 138 BLINK_EXPORT int hierarchicalLevel() const; 139 BLINK_EXPORT WebAXObject hitTest(const WebPoint&) const; 140 BLINK_EXPORT WebString keyboardShortcut() const; 141 BLINK_EXPORT WebAXRole role() const; 142 BLINK_EXPORT unsigned selectionEnd() const; 143 BLINK_EXPORT unsigned selectionEndLineNumber() const; 144 BLINK_EXPORT unsigned selectionStart() const; 145 BLINK_EXPORT unsigned selectionStartLineNumber() const; 146 BLINK_EXPORT WebString stringValue() const; 147 BLINK_EXPORT WebString title() const; 148 BLINK_EXPORT WebAXObject titleUIElement() const; 149 BLINK_EXPORT WebURL url() const; 150 151 BLINK_EXPORT bool supportsRangeValue() const; 152 BLINK_EXPORT WebString valueDescription() const; 153 BLINK_EXPORT float valueForRange() const; 154 BLINK_EXPORT float maxValueForRange() const; 155 BLINK_EXPORT float minValueForRange() const; 156 157 BLINK_EXPORT WebNode node() const; 158 BLINK_EXPORT WebDocument document() const; 159 BLINK_EXPORT bool hasComputedStyle() const; 160 BLINK_EXPORT WebString computedStyleDisplay() const; 161 BLINK_EXPORT bool accessibilityIsIgnored() const; 162 BLINK_EXPORT bool lineBreaks(WebVector<int>&) const; 163 164 // Actions 165 BLINK_EXPORT WebString actionVerb() const; // The verb corresponding to performDefaultAction. 166 BLINK_EXPORT bool canDecrement() const; 167 BLINK_EXPORT bool canIncrement() const; 168 BLINK_EXPORT bool canPress() const; 169 BLINK_EXPORT bool canSetFocusAttribute() const; 170 BLINK_EXPORT bool canSetSelectedAttribute() const; 171 BLINK_EXPORT bool canSetValueAttribute() const; 172 BLINK_EXPORT bool performDefaultAction() const; 173 BLINK_EXPORT bool press() const; 174 BLINK_EXPORT bool increment() const; 175 BLINK_EXPORT bool decrement() const; 176 BLINK_EXPORT void setFocused(bool) const; 177 BLINK_EXPORT void setSelectedTextRange(int selectionStart, int selectionEnd) const; 178 179 // For a table 180 BLINK_EXPORT unsigned columnCount() const; 181 BLINK_EXPORT unsigned rowCount() const; 182 BLINK_EXPORT WebAXObject cellForColumnAndRow(unsigned column, unsigned row) const; 183 BLINK_EXPORT WebAXObject headerContainerObject() const; 184 BLINK_EXPORT WebAXObject rowAtIndex(unsigned rowIndex) const; 185 BLINK_EXPORT WebAXObject columnAtIndex(unsigned columnIndex) const; 186 187 // For a table row 188 BLINK_EXPORT unsigned rowIndex() const; 189 BLINK_EXPORT WebAXObject rowHeader() const; 190 191 // For a table column 192 BLINK_EXPORT unsigned columnIndex() const; 193 BLINK_EXPORT WebAXObject columnHeader() const; 194 195 // For a table cell 196 BLINK_EXPORT unsigned cellColumnIndex() const; 197 BLINK_EXPORT unsigned cellColumnSpan() const; 198 BLINK_EXPORT unsigned cellRowIndex() const; 199 BLINK_EXPORT unsigned cellRowSpan() const; 200 201 // For an inline text box. 202 BLINK_EXPORT WebAXTextDirection textDirection() const; 203 BLINK_EXPORT void characterOffsets(WebVector<int>&) const; 204 BLINK_EXPORT void wordBoundaries(WebVector<int>& starts, WebVector<int>& ends) const; 205 206 // Make this object visible by scrolling as many nested scrollable views as needed. 207 BLINK_EXPORT void scrollToMakeVisible() const; 208 // Same, but if the whole object can't be made visible, try for this subrect, in local coordinates. 209 BLINK_EXPORT void scrollToMakeVisibleWithSubFocus(const WebRect&) const; 210 // Scroll this object to a given point in global coordinates of the top-level window. 211 BLINK_EXPORT void scrollToGlobalPoint(const WebPoint&) const; 212 213 #if BLINK_IMPLEMENTATION 214 WebAXObject(const WTF::PassRefPtr<WebCore::AXObject>&); 215 WebAXObject& operator=(const WTF::PassRefPtr<WebCore::AXObject>&); 216 operator WTF::PassRefPtr<WebCore::AXObject>() const; 217 #endif 218 219 private: 220 WebPrivatePtr<WebCore::AXObject> m_private; 221 }; 222 223 } // namespace blink 224 225 #endif 226