This source file includes following definitions.
- create
- elementRect
- addChildren
- step
- create
- elementRect
- press
#include "config.h"
#include "core/accessibility/AXSpinButton.h"
#include "core/accessibility/AXObjectCache.h"
#include "core/rendering/RenderObject.h"
namespace WebCore {
PassRefPtr<AXSpinButton> AXSpinButton::create()
{
return adoptRef(new AXSpinButton);
}
AXSpinButton::AXSpinButton()
: m_spinButtonElement(0)
{
}
AXSpinButton::~AXSpinButton()
{
}
LayoutRect AXSpinButton::elementRect() const
{
ASSERT(m_spinButtonElement);
if (!m_spinButtonElement || !m_spinButtonElement->renderer())
return LayoutRect();
Vector<FloatQuad> quads;
m_spinButtonElement->renderer()->absoluteFocusRingQuads(quads);
return boundingBoxForQuads(m_spinButtonElement->renderer(), quads);
}
void AXSpinButton::addChildren()
{
m_haveChildren = true;
AXSpinButtonPart* incrementor = static_cast<AXSpinButtonPart*>(axObjectCache()->getOrCreate(SpinButtonPartRole));
incrementor->setIsIncrementor(true);
incrementor->setParent(this);
m_children.append(incrementor);
AXSpinButtonPart* decrementor = static_cast<AXSpinButtonPart*>(axObjectCache()->getOrCreate(SpinButtonPartRole));
decrementor->setIsIncrementor(false);
decrementor->setParent(this);
m_children.append(decrementor);
}
void AXSpinButton::step(int amount)
{
ASSERT(m_spinButtonElement);
if (!m_spinButtonElement)
return;
m_spinButtonElement->step(amount);
}
AXSpinButtonPart::AXSpinButtonPart()
: m_isIncrementor(false)
{
}
PassRefPtr<AXSpinButtonPart> AXSpinButtonPart::create()
{
return adoptRef(new AXSpinButtonPart);
}
LayoutRect AXSpinButtonPart::elementRect() const
{
LayoutRect parentRect = parentObject()->elementRect();
if (m_isIncrementor) {
parentRect.setHeight(parentRect.height() / 2);
} else {
parentRect.setY(parentRect.y() + parentRect.height() / 2);
parentRect.setHeight(parentRect.height() / 2);
}
return parentRect;
}
bool AXSpinButtonPart::press() const
{
if (!m_parent || !m_parent->isSpinButton())
return false;
AXSpinButton* spinButton = toAXSpinButton(parentObject());
if (m_isIncrementor)
spinButton->step(1);
else
spinButton->step(-1);
return true;
}
}