#include "config.h"
#include "EllipsisBox.h"
#include "GraphicsContext.h"
namespace WebCore {
void EllipsisBox::paint(RenderObject::PaintInfo& i, int _tx, int _ty)
{
GraphicsContext* p = i.p;
RenderStyle* _style = m_firstLine ? m_object->firstLineStyle() : m_object->style();
if (_style->font() != p->font())
p->setFont(_style->font());
Color textColor = _style->color();
if (textColor != p->pen().color())
p->setPen(textColor);
bool setShadow = false;
if (_style->textShadow()) {
p->setShadow(IntSize(_style->textShadow()->x, _style->textShadow()->y),
_style->textShadow()->blur, _style->textShadow()->color);
setShadow = true;
}
const String& str = m_str;
p->drawText(TextRun(str.impl()), IntPoint(m_x + _tx, m_y + _ty + m_baseline), TextStyle(0, 0, 0, false, _style->visuallyOrdered()));
if (setShadow)
p->clearShadow();
if (m_markupBox) {
_tx += m_x + m_width - m_markupBox->xPos();
_ty += m_y + m_baseline - (m_markupBox->yPos() + m_markupBox->baseline());
m_markupBox->paint(i, _tx, _ty);
}
}
bool EllipsisBox::nodeAtPoint(RenderObject::NodeInfo& info, int x, int y, int tx, int ty)
{
tx += m_x;
ty += m_y;
if (m_markupBox) {
int mtx = tx + m_width - m_markupBox->xPos();
int mty = ty + m_baseline - (m_markupBox->yPos() + m_markupBox->baseline());
if (m_markupBox->nodeAtPoint(info, x, y, mtx, mty)) {
object()->setInnerNode(info);
return true;
}
}
if (object()->style()->visibility() == VISIBLE && IntRect(tx, ty, m_width, m_height).contains(x, y)) {
object()->setInnerNode(info);
return true;
}
return false;
}
}