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