This source file includes following definitions.
- nodeAtPoint
- getAvgCharWidth
- preferredContentLogicalWidth
- computeControlLogicalHeight
- baselinePosition
- createInnerTextStyle
- layoutSpecialExcludedChild
#include "config.h"
#include "core/rendering/RenderTextControlMultiLine.h"
#include "core/html/HTMLTextAreaElement.h"
#include "core/rendering/HitTestResult.h"
namespace WebCore {
RenderTextControlMultiLine::RenderTextControlMultiLine(HTMLTextAreaElement* element)
: RenderTextControl(element)
{
ASSERT(element);
}
RenderTextControlMultiLine::~RenderTextControlMultiLine()
{
}
bool RenderTextControlMultiLine::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction hitTestAction)
{
if (!RenderTextControl::nodeAtPoint(request, result, locationInContainer, accumulatedOffset, hitTestAction))
return false;
if (result.innerNode() == node() || result.innerNode() == innerTextElement())
hitInnerTextElement(result, locationInContainer.point(), accumulatedOffset);
return true;
}
float RenderTextControlMultiLine::getAvgCharWidth(AtomicString family)
{
if (family == "Lucida Grande")
return scaleEmToUnits(1229);
return RenderTextControl::getAvgCharWidth(family);
}
LayoutUnit RenderTextControlMultiLine::preferredContentLogicalWidth(float charWidth) const
{
int factor = toHTMLTextAreaElement(node())->cols();
return static_cast<LayoutUnit>(ceilf(charWidth * factor)) + scrollbarThickness();
}
LayoutUnit RenderTextControlMultiLine::computeControlLogicalHeight(LayoutUnit lineHeight, LayoutUnit nonContentHeight) const
{
return lineHeight * toHTMLTextAreaElement(node())->rows() + nonContentHeight;
}
int RenderTextControlMultiLine::baselinePosition(FontBaseline baselineType, bool firstLine, LineDirectionMode direction, LinePositionMode linePositionMode) const
{
return RenderBox::baselinePosition(baselineType, firstLine, direction, linePositionMode);
}
PassRefPtr<RenderStyle> RenderTextControlMultiLine::createInnerTextStyle(const RenderStyle* startStyle) const
{
RefPtr<RenderStyle> textBlockStyle = RenderStyle::create();
textBlockStyle->inheritFrom(startStyle);
adjustInnerTextStyle(textBlockStyle.get());
textBlockStyle->setDisplay(BLOCK);
textBlockStyle->setUnique();
return textBlockStyle.release();
}
RenderObject* RenderTextControlMultiLine::layoutSpecialExcludedChild(bool relayoutChildren, SubtreeLayoutScope& layoutScope)
{
RenderObject* placeholderRenderer = RenderTextControl::layoutSpecialExcludedChild(relayoutChildren, layoutScope);
if (!placeholderRenderer)
return 0;
if (!placeholderRenderer->isBox())
return placeholderRenderer;
RenderBox* placeholderBox = toRenderBox(placeholderRenderer);
placeholderBox->style()->setLogicalWidth(Length(contentLogicalWidth() - placeholderBox->borderAndPaddingLogicalWidth(), Fixed));
placeholderBox->layoutIfNeeded();
placeholderBox->setX(borderLeft() + paddingLeft());
placeholderBox->setY(borderTop() + paddingTop());
return placeholderRenderer;
}
}