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