This source file includes following definitions.
- detachFromParent
- create
- elementRect
- document
- orientation
- isEnabled
- valueForRange
- setValue
#include "config.h"
#include "core/accessibility/AXScrollbar.h"
#include "platform/scroll/ScrollView.h"
namespace WebCore {
AXScrollbar::AXScrollbar(Scrollbar* scrollbar)
: m_scrollbar(scrollbar)
{
ASSERT(scrollbar);
}
void AXScrollbar::detachFromParent()
{
m_scrollbar = nullptr;
AXMockObject::detachFromParent();
}
PassRefPtr<AXScrollbar> AXScrollbar::create(Scrollbar* scrollbar)
{
return adoptRef(new AXScrollbar(scrollbar));
}
LayoutRect AXScrollbar::elementRect() const
{
if (!m_scrollbar)
return LayoutRect();
return m_scrollbar->frameRect();
}
Document* AXScrollbar::document() const
{
AXObject* parent = parentObject();
if (!parent)
return 0;
return parent->document();
}
AccessibilityOrientation AXScrollbar::orientation() const
{
if (!m_scrollbar)
return AccessibilityOrientationHorizontal;
if (m_scrollbar->orientation() == HorizontalScrollbar)
return AccessibilityOrientationHorizontal;
if (m_scrollbar->orientation() == VerticalScrollbar)
return AccessibilityOrientationVertical;
return AccessibilityOrientationHorizontal;
}
bool AXScrollbar::isEnabled() const
{
if (!m_scrollbar)
return false;
return m_scrollbar->enabled();
}
float AXScrollbar::valueForRange() const
{
if (!m_scrollbar)
return 0;
return m_scrollbar->currentPos() / m_scrollbar->maximum();
}
void AXScrollbar::setValue(float value)
{
if (!m_scrollbar)
return;
if (!m_scrollbar->scrollableArea())
return;
float newValue = value * m_scrollbar->maximum();
m_scrollbar->scrollableArea()->scrollToOffsetWithoutAnimation(m_scrollbar->orientation(), newValue);
}
}