This source file includes following definitions.
- m_childrenDirty
- detach
- create
- scrollBar
- isAttachment
- widgetForAttachmentView
- updateChildrenIfNecessary
- updateScrollbars
- removeChildScrollbar
- addChildScrollbar
- clearChildren
- computeAccessibilityIsIgnored
- addChildren
- webAreaObject
- accessibilityHitTest
- elementRect
- documentFrameView
- parentObject
- parentObjectIfExists
- getScrollableAreaIfScrollable
- scrollTo
#include "config.h"
#include "core/accessibility/AXScrollView.h"
#include "core/accessibility/AXObjectCache.h"
#include "core/accessibility/AXScrollbar.h"
#include "core/frame/FrameView.h"
#include "core/frame/LocalFrame.h"
#include "core/html/HTMLFrameOwnerElement.h"
namespace WebCore {
AXScrollView::AXScrollView(ScrollView* view)
: m_scrollView(view)
, m_childrenDirty(false)
{
}
AXScrollView::~AXScrollView()
{
ASSERT(isDetached());
}
void AXScrollView::detach()
{
AXObject::detach();
m_scrollView = 0;
}
PassRefPtr<AXScrollView> AXScrollView::create(ScrollView* view)
{
return adoptRef(new AXScrollView(view));
}
AXObject* AXScrollView::scrollBar(AccessibilityOrientation orientation)
{
updateScrollbars();
switch (orientation) {
case AccessibilityOrientationVertical:
return m_verticalScrollbar ? m_verticalScrollbar.get() : 0;
case AccessibilityOrientationHorizontal:
return m_horizontalScrollbar ? m_horizontalScrollbar.get() : 0;
}
return 0;
}
bool AXScrollView::isAttachment() const
{
return false;
}
Widget* AXScrollView::widgetForAttachmentView() const
{
return m_scrollView;
}
void AXScrollView::updateChildrenIfNecessary()
{
if (m_childrenDirty)
clearChildren();
if (!m_haveChildren)
addChildren();
updateScrollbars();
}
void AXScrollView::updateScrollbars()
{
if (!m_scrollView)
return;
if (m_scrollView->horizontalScrollbar() && !m_horizontalScrollbar) {
m_horizontalScrollbar = addChildScrollbar(m_scrollView->horizontalScrollbar());
} else if (!m_scrollView->horizontalScrollbar() && m_horizontalScrollbar) {
removeChildScrollbar(m_horizontalScrollbar.get());
m_horizontalScrollbar = nullptr;
}
if (m_scrollView->verticalScrollbar() && !m_verticalScrollbar) {
m_verticalScrollbar = addChildScrollbar(m_scrollView->verticalScrollbar());
} else if (!m_scrollView->verticalScrollbar() && m_verticalScrollbar) {
removeChildScrollbar(m_verticalScrollbar.get());
m_verticalScrollbar = nullptr;
}
}
void AXScrollView::removeChildScrollbar(AXObject* scrollbar)
{
size_t pos = m_children.find(scrollbar);
if (pos != kNotFound) {
m_children[pos]->detachFromParent();
m_children.remove(pos);
}
}
AXScrollbar* AXScrollView::addChildScrollbar(Scrollbar* scrollbar)
{
if (!scrollbar)
return 0;
AXScrollbar* scrollBarObject = toAXScrollbar(axObjectCache()->getOrCreate(scrollbar));
scrollBarObject->setParent(this);
m_children.append(scrollBarObject);
return scrollBarObject;
}
void AXScrollView::clearChildren()
{
AXObject::clearChildren();
m_verticalScrollbar = nullptr;
m_horizontalScrollbar = nullptr;
}
bool AXScrollView::computeAccessibilityIsIgnored() const
{
AXObject* webArea = webAreaObject();
if (!webArea)
return true;
return webArea->accessibilityIsIgnored();
}
void AXScrollView::addChildren()
{
ASSERT(!m_haveChildren);
m_haveChildren = true;
AXObject* webArea = webAreaObject();
if (webArea && !webArea->accessibilityIsIgnored())
m_children.append(webArea);
updateScrollbars();
}
AXObject* AXScrollView::webAreaObject() const
{
if (!m_scrollView || !m_scrollView->isFrameView())
return 0;
Document* doc = toFrameView(m_scrollView)->frame().document();
if (!doc || !doc->renderer())
return 0;
return axObjectCache()->getOrCreate(doc);
}
AXObject* AXScrollView::accessibilityHitTest(const IntPoint& point) const
{
AXObject* webArea = webAreaObject();
if (!webArea)
return 0;
if (m_horizontalScrollbar && m_horizontalScrollbar->elementRect().contains(point))
return m_horizontalScrollbar.get();
if (m_verticalScrollbar && m_verticalScrollbar->elementRect().contains(point))
return m_verticalScrollbar.get();
return webArea->accessibilityHitTest(point);
}
LayoutRect AXScrollView::elementRect() const
{
if (!m_scrollView)
return LayoutRect();
return m_scrollView->frameRect();
}
FrameView* AXScrollView::documentFrameView() const
{
if (!m_scrollView || !m_scrollView->isFrameView())
return 0;
return toFrameView(m_scrollView);
}
AXObject* AXScrollView::parentObject() const
{
if (!m_scrollView || !m_scrollView->isFrameView())
return 0;
HTMLFrameOwnerElement* owner = toFrameView(m_scrollView)->frame().ownerElement();
if (owner && owner->renderer())
return axObjectCache()->getOrCreate(owner);
return 0;
}
AXObject* AXScrollView::parentObjectIfExists() const
{
if (!m_scrollView || !m_scrollView->isFrameView())
return 0;
HTMLFrameOwnerElement* owner = toFrameView(m_scrollView)->frame().ownerElement();
if (owner && owner->renderer())
return axObjectCache()->get(owner);
return 0;
}
ScrollableArea* AXScrollView::getScrollableAreaIfScrollable() const
{
return m_scrollView;
}
void AXScrollView::scrollTo(const IntPoint& point) const
{
if (m_scrollView)
m_scrollView->setScrollPosition(point);
}
}