Commit 96910b59 authored by jhoneycutt@apple.com's avatar jhoneycutt@apple.com
Browse files

Add some methods to determine the AccessibilityObject state.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@31988 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent adf339ea
......@@ -2,6 +2,33 @@
 
Reviewed by Darin.
 
Add some methods to check AccessibilityObject state.
* page/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::AccessibilityObject): Assert that the
passed renderer is not null.
(WebCore::AccessibilityObject::isPasswordField): Refactored to use early
return.
(WebCore::AccessibilityObject::isPressed): Return true if this is a
button in the pressed state.
(WebCore::AccessibilityObject::isIndeterminate): Return true if this is
a tri-state checkbox in the indeterminate state.
(WebCore::AccessibilityObject::isChecked): True if this is a radio
button or checkbox in the checked state.
(WebCore::AccessibilityObject::isHovered): True if object is currently
under the mouse cursor.
(WebCore::AccessibilityObject::isMultiSelect): True if this is a select
element capable of multi-select.
(WebCore::AccessibilityObject::isReadOnly): False if this object has
editable content.
(WebCore::AccessibilityObject::isOffScreen): True if this object is not
in the visible portion of the view.
* page/AccessibilityObject.h: Grouped methods into is-state and is-kind.
2008-04-15 Jon Honeycutt <jhoneycutt@apple.com>
Reviewed by Darin.
Add AccessibilityObjectWrapper to Windows.
 
* WebCore.vcproj/WebCore.vcproj: Add AccessibilityObjectWrapperWin.h
......@@ -32,6 +32,7 @@
#include "AXObjectCache.h"
#include "CharacterNames.h"
#include "EventNames.h"
#include "FloatRect.h"
#include "FocusController.h"
#include "Frame.h"
#include "FrameLoader.h"
......@@ -71,6 +72,7 @@ AccessibilityObject::AccessibilityObject(RenderObject* renderer)
: m_renderer(renderer)
, m_id(0)
{
ASSERT_ARG(renderer, renderer);
#ifndef NDEBUG
m_renderer->setHasAXObject(true);
#endif
......@@ -188,15 +190,62 @@ bool AccessibilityObject::isAttachment() const
bool AccessibilityObject::isPasswordField() const
{
if (!m_renderer)
return 0;
if (!m_renderer->element())
return 0;
if (!m_renderer->element()->isHTMLElement())
return 0;
ASSERT(m_renderer);
if (!m_renderer->element() || !m_renderer->element()->isHTMLElement())
return false;
return static_cast<HTMLElement*>(m_renderer->element())->isPasswordField();
}
bool AccessibilityObject::isPressed() const
{
ASSERT(m_renderer);
if (roleValue() != ButtonRole)
return false;
return m_renderer->node() && m_renderer->node()->active();
}
bool AccessibilityObject::isIndeterminate() const
{
ASSERT(m_renderer);
return m_renderer->node() && m_renderer->node()->isIndeterminate();
}
bool AccessibilityObject::isChecked() const
{
ASSERT(m_renderer);
return m_renderer->node() && m_renderer->node()->isChecked();
}
bool AccessibilityObject::isHovered() const
{
ASSERT(m_renderer);
return m_renderer->node() && m_renderer->node()->hovered();
}
bool AccessibilityObject::isMultiSelect() const
{
ASSERT(m_renderer);
if (!m_renderer->isListBox())
return false;
return m_renderer->element() && static_cast<HTMLSelectElement*>(m_renderer->element())->multiple();
}
bool AccessibilityObject::isReadOnly() const
{
ASSERT(m_renderer);
return !m_renderer->node() || !m_renderer->node()->isContentEditable();
}
bool AccessibilityObject::isOffScreen() const
{
ASSERT(m_renderer);
IntRect contentRect = m_renderer->absoluteClippedOverflowRect();
FrameView* view = m_renderer->document()->frame()->view();
FloatRect viewRect = view->visibleContentRect();
viewRect.intersect(contentRect);
return viewRect.isEmpty();
}
int AccessibilityObject::headingLevel(Node* node)
{
// headings can be in block flow and non-block flow
......
......@@ -184,17 +184,25 @@ public:
bool isAnchor() const;
bool isAttachment() const;
bool isEnabled() const;
bool isFocused() const;
bool isHeading() const;
bool isImageButton() const;
bool isImage() const;
bool isLoaded() const;
bool isImageButton() const;
bool isPasswordField() const;
bool isTextControl() const;
bool isVisited() const;
bool isWebArea() const;
bool isChecked() const;
bool isEnabled() const;
bool isFocused() const;
bool isHovered() const;
bool isIndeterminate() const;
bool isLoaded() const;
bool isMultiSelect() const;
bool isOffScreen() const;
bool isPressed() const;
bool isReadOnly() const;
bool isVisited() const;
bool canSetFocusAttribute() const;
bool canSetTextRangeAttributes() const;
bool canSetValueAttribute() const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment