#include "config.h"
#include "RenderBR.h"
#include "Document.h"
#include "InlineTextBox.h"
#include "VisiblePosition.h"
namespace WebCore {
static PassRefPtr<StringImpl> newlineString()
{
DEFINE_STATIC_LOCAL(const String, string, (ASCIILiteral("\n")));
return string.impl();
}
RenderBR::RenderBR(Node* node)
: RenderText(node, newlineString())
, m_lineHeight(-1)
{
}
RenderBR::~RenderBR()
{
}
int RenderBR::lineHeight(bool firstLine) const
{
if (firstLine && document()->styleSheetCollection()->usesFirstLineRules()) {
RenderStyle* s = style(firstLine);
if (s != style())
return s->computedLineHeight(view());
}
if (m_lineHeight == -1)
m_lineHeight = style()->computedLineHeight(view());
return m_lineHeight;
}
void RenderBR::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
{
RenderText::styleDidChange(diff, oldStyle);
m_lineHeight = -1;
}
int RenderBR::caretMinOffset() const
{
return 0;
}
int RenderBR::caretMaxOffset() const
{
return 1;
}
VisiblePosition RenderBR::positionForPoint(const LayoutPoint&)
{
return createVisiblePosition(0, DOWNSTREAM);
}
}