Home | History | Annotate | Download | only in accessibility
      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 AXRenderObject_h
     30 #define AXRenderObject_h
     31 
     32 #include "core/accessibility/AXNodeObject.h"
     33 #include "platform/geometry/LayoutRect.h"
     34 #include "wtf/Forward.h"
     35 
     36 namespace WebCore {
     37 
     38 class AXSVGRoot;
     39 class AXObjectCache;
     40 class Element;
     41 class LocalFrame;
     42 class FrameView;
     43 class HitTestResult;
     44 class HTMLAnchorElement;
     45 class HTMLAreaElement;
     46 class HTMLElement;
     47 class HTMLLabelElement;
     48 class HTMLMapElement;
     49 class HTMLSelectElement;
     50 class IntPoint;
     51 class IntSize;
     52 class Node;
     53 class RenderListBox;
     54 class RenderTextControl;
     55 class RenderView;
     56 class VisibleSelection;
     57 class Widget;
     58 
     59 class AXRenderObject : public AXNodeObject {
     60 protected:
     61     explicit AXRenderObject(RenderObject*);
     62 public:
     63     static PassRefPtr<AXRenderObject> create(RenderObject*);
     64     virtual ~AXRenderObject();
     65 
     66     // Public, overridden from AXObject.
     67     virtual RenderObject* renderer() const OVERRIDE FINAL { return m_renderer; }
     68     virtual LayoutRect elementRect() const OVERRIDE;
     69 
     70     void setRenderer(RenderObject*);
     71     RenderBoxModelObject* renderBoxModelObject() const;
     72     Document* topDocument() const;
     73     bool shouldNotifyActiveDescendant() const;
     74     virtual ScrollableArea* getScrollableAreaIfScrollable() const OVERRIDE FINAL;
     75     virtual AccessibilityRole determineAccessibilityRole() OVERRIDE;
     76     void checkCachedElementRect() const;
     77     void updateCachedElementRect() const;
     78 
     79 protected:
     80     RenderObject* m_renderer;
     81     mutable LayoutRect m_cachedElementRect;
     82     mutable LayoutRect m_cachedFrameRect;
     83     mutable IntPoint m_cachedScrollPosition;
     84     mutable bool m_cachedElementRectDirty;
     85 
     86     //
     87     // Overridden from AXObject.
     88     //
     89 
     90     virtual void init() OVERRIDE;
     91     virtual void detach() OVERRIDE;
     92     virtual bool isDetached() const OVERRIDE { return !m_renderer; }
     93     virtual bool isAXRenderObject() const OVERRIDE { return true; }
     94 
     95     // Check object role or purpose.
     96     virtual bool isAttachment() const OVERRIDE;
     97     virtual bool isFileUploadButton() const OVERRIDE;
     98     virtual bool isLinked() const OVERRIDE;
     99     virtual bool isLoaded() const OVERRIDE;
    100     virtual bool isOffScreen() const OVERRIDE;
    101     virtual bool isReadOnly() const OVERRIDE;
    102     virtual bool isVisited() const OVERRIDE;
    103 
    104     // Check object state.
    105     virtual bool isFocused() const OVERRIDE;
    106     virtual bool isSelected() const OVERRIDE;
    107 
    108     // Whether objects are ignored, i.e. not included in the tree.
    109     virtual AXObjectInclusion defaultObjectInclusion() const OVERRIDE;
    110     virtual bool computeAccessibilityIsIgnored() const OVERRIDE;
    111 
    112     // Properties of static elements.
    113     virtual const AtomicString& accessKey() const OVERRIDE;
    114     virtual AccessibilityOrientation orientation() const OVERRIDE;
    115     virtual String text() const OVERRIDE;
    116     virtual int textLength() const OVERRIDE;
    117     virtual KURL url() const OVERRIDE;
    118 
    119     // Properties of interactive elements.
    120     virtual String actionVerb() const OVERRIDE;
    121     virtual String stringValue() const OVERRIDE;
    122 
    123     // ARIA attributes.
    124     virtual AXObject* activeDescendant() const OVERRIDE;
    125     virtual void ariaFlowToElements(AccessibilityChildrenVector&) const OVERRIDE;
    126     virtual void ariaControlsElements(AccessibilityChildrenVector&) const OVERRIDE;
    127     virtual void ariaDescribedbyElements(AccessibilityChildrenVector&) const OVERRIDE;
    128     virtual void ariaLabelledbyElements(AccessibilityChildrenVector&) const OVERRIDE;
    129     virtual void ariaOwnsElements(AccessibilityChildrenVector&) const OVERRIDE;
    130 
    131     virtual bool ariaHasPopup() const OVERRIDE;
    132     virtual bool ariaRoleHasPresentationalChildren() const OVERRIDE;
    133     virtual bool isPresentationalChildOfAriaRole() const OVERRIDE;
    134     virtual bool shouldFocusActiveDescendant() const OVERRIDE;
    135     virtual bool supportsARIADragging() const OVERRIDE;
    136     virtual bool supportsARIADropping() const OVERRIDE;
    137     virtual bool supportsARIAFlowTo() const OVERRIDE;
    138     virtual bool supportsARIAOwns() const OVERRIDE;
    139 
    140     // ARIA live-region features.
    141     virtual const AtomicString& ariaLiveRegionStatus() const OVERRIDE;
    142     virtual const AtomicString& ariaLiveRegionRelevant() const OVERRIDE;
    143     virtual bool ariaLiveRegionAtomic() const OVERRIDE;
    144     virtual bool ariaLiveRegionBusy() const OVERRIDE;
    145 
    146     // Accessibility Text.
    147     virtual String textUnderElement() const OVERRIDE;
    148 
    149     // Accessibility Text - (To be deprecated).
    150     virtual String helpText() const OVERRIDE;
    151 
    152     // Location and click point in frame-relative coordinates.
    153     virtual void markCachedElementRectDirty() const OVERRIDE;
    154     virtual IntPoint clickPoint() OVERRIDE;
    155 
    156     // Hit testing.
    157     virtual AXObject* accessibilityHitTest(const IntPoint&) const OVERRIDE;
    158     virtual AXObject* elementAccessibilityHitTest(const IntPoint&) const OVERRIDE;
    159 
    160     // High-level accessibility tree access. Other modules should only use these functions.
    161     virtual AXObject* parentObject() const OVERRIDE;
    162     virtual AXObject* parentObjectIfExists() const OVERRIDE;
    163 
    164     // Low-level accessibility tree exploration, only for use within the accessibility module.
    165     virtual AXObject* firstChild() const OVERRIDE;
    166     virtual AXObject* nextSibling() const OVERRIDE;
    167     virtual void addChildren() OVERRIDE;
    168     virtual bool canHaveChildren() const OVERRIDE;
    169     virtual void updateChildrenIfNecessary() OVERRIDE;
    170     virtual bool needsToUpdateChildren() const { return m_childrenDirty; }
    171     virtual void setNeedsToUpdateChildren() OVERRIDE { m_childrenDirty = true; }
    172     virtual void clearChildren() OVERRIDE;
    173     virtual AXObject* observableObject() const OVERRIDE;
    174 
    175     // Properties of the object's owning document or page.
    176     virtual double estimatedLoadingProgress() const OVERRIDE;
    177 
    178     // DOM and Render tree access.
    179     virtual Node* node() const OVERRIDE;
    180     virtual Document* document() const OVERRIDE;
    181     virtual FrameView* documentFrameView() const OVERRIDE;
    182     virtual Element* anchorElement() const OVERRIDE;
    183     virtual Widget* widgetForAttachmentView() const OVERRIDE;
    184 
    185     // Selected text.
    186     virtual PlainTextRange selectedTextRange() const OVERRIDE;
    187 
    188     // Modify or take an action on an object.
    189     virtual void setSelectedTextRange(const PlainTextRange&) OVERRIDE;
    190     virtual void setValue(const String&) OVERRIDE;
    191     virtual void scrollTo(const IntPoint&) const OVERRIDE;
    192 
    193     // Notifications that this object may have changed.
    194     virtual void handleActiveDescendantChanged() OVERRIDE;
    195     virtual void handleAriaExpandedChanged() OVERRIDE;
    196     virtual void textChanged() OVERRIDE;
    197 
    198     // Text metrics. Most of these should be deprecated, needs major cleanup.
    199     virtual int index(const VisiblePosition&) const OVERRIDE;
    200     virtual VisiblePosition visiblePositionForIndex(int) const OVERRIDE;
    201     virtual void lineBreaks(Vector<int>&) const OVERRIDE;
    202 
    203 private:
    204     bool isAllowedChildOfTree() const;
    205     void ariaListboxSelectedChildren(AccessibilityChildrenVector&);
    206     PlainTextRange ariaSelectedTextRange() const;
    207     bool nodeIsTextControl(const Node*) const;
    208     bool isTabItemSelected() const;
    209     AXObject* accessibilityImageMapHitTest(HTMLAreaElement*, const IntPoint&) const;
    210     bool renderObjectIsObservable(RenderObject*) const;
    211     RenderObject* renderParentObject() const;
    212     bool isDescendantOfElementType(const QualifiedName& tagName) const;
    213     bool isSVGImage() const;
    214     void detachRemoteSVGRoot();
    215     AXSVGRoot* remoteSVGRootElement() const;
    216     AXObject* remoteSVGElementHitTest(const IntPoint&) const;
    217     void offsetBoundingBoxForRemoteSVGElement(LayoutRect&) const;
    218     void addHiddenChildren();
    219     void addTextFieldChildren();
    220     void addImageMapChildren();
    221     void addCanvasChildren();
    222     void addAttachmentChildren();
    223     void addRemoteSVGChildren();
    224     void addInlineTextBoxChildren();
    225 
    226     void ariaSelectedRows(AccessibilityChildrenVector&);
    227     bool elementAttributeValue(const QualifiedName&) const;
    228     bool inheritsPresentationalRole() const;
    229     LayoutRect computeElementRect() const;
    230     VisibleSelection selection() const;
    231     int indexForVisiblePosition(const VisiblePosition&) const;
    232     void accessibilityChildrenFromAttribute(QualifiedName attr, AccessibilityChildrenVector&) const;
    233 };
    234 
    235 DEFINE_AX_OBJECT_TYPE_CASTS(AXRenderObject, isAXRenderObject());
    236 
    237 } // namespace WebCore
    238 
    239 #endif // AXRenderObject_h
    240