Commit 78e56776 authored by antti@apple.com's avatar antti@apple.com

Switch inline boxes to use const RenderStyle&

https://bugs.webkit.org/show_bug.cgi?id=122068

Reviewed by Sam Weinig.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@156613 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1cff4b46
2013-09-28 Antti Koivisto <antti@apple.com>
Switch inline boxes to use const RenderStyle&
https://bugs.webkit.org/show_bug.cgi?id=122068
Reviewed by Sam Weinig.
2013-09-28 Antti Koivisto <antti@apple.com>
Add first()/last() to ElementIteratorAdapters
......@@ -43,7 +43,7 @@ class TextLayout {
public:
static bool isNeeded(RenderText* text, const Font& font)
{
TextRun run = RenderBlock::constructTextRun(text, font, text, text->style());
TextRun run = RenderBlock::constructTextRun(text, font, text, *text->style());
return font.codePath(run) == Font::Complex;
}
......@@ -68,7 +68,7 @@ public:
private:
static TextRun constructTextRun(RenderText* text, const Font& font, float xPos)
{
TextRun run = RenderBlock::constructTextRun(text, font, text, text->style());
TextRun run = RenderBlock::constructTextRun(text, font, text, *text->style());
run.setCharactersLength(text->textLength());
ASSERT(run.charactersLength() >= run.length());
......
......@@ -44,7 +44,7 @@ EllipsisBox::EllipsisBox(RenderBlock& renderer, const AtomicString& ellipsisStr,
void EllipsisBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit lineTop, LayoutUnit lineBottom)
{
GraphicsContext* context = paintInfo.context;
RenderStyle& lineStyle = this->lineStyle();
const RenderStyle& lineStyle = this->lineStyle();
Color textColor = lineStyle.visitedDependentColor(CSSPropertyWebkitTextFillColor);
if (textColor != context->fillColor())
context->setFillColor(textColor, lineStyle.colorSpace());
......@@ -57,7 +57,7 @@ void EllipsisBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, La
const Font& font = lineStyle.font();
if (selectionState() != RenderObject::SelectionNone) {
paintSelection(context, paintOffset, &lineStyle, font);
paintSelection(context, paintOffset, lineStyle, font);
// Select the correct color for painting the text.
Color foreground = paintInfo.forceBlackText() ? Color::black : renderer().selectionForegroundColor();
......@@ -66,7 +66,7 @@ void EllipsisBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, La
}
// FIXME: Why is this always LTR? Fix by passing correct text run flags below.
context->drawText(font, RenderBlock::constructTextRun(&renderer(), font, m_str, &lineStyle, TextRun::AllowTrailingExpansion), LayoutPoint(x() + paintOffset.x(), y() + paintOffset.y() + lineStyle.fontMetrics().ascent()));
context->drawText(font, RenderBlock::constructTextRun(&renderer(), font, m_str, lineStyle, TextRun::AllowTrailingExpansion), LayoutPoint(x() + paintOffset.x(), y() + paintOffset.y() + lineStyle.fontMetrics().ascent()));
// Restore the regular fill color.
if (textColor != context->fillColor())
......@@ -75,7 +75,7 @@ void EllipsisBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, La
if (setShadow)
context->clearShadow();
paintMarkupBox(paintInfo, paintOffset, lineTop, lineBottom, &lineStyle);
paintMarkupBox(paintInfo, paintOffset, lineTop, lineBottom, lineStyle);
}
InlineBox* EllipsisBox::markupBox() const
......@@ -96,7 +96,7 @@ InlineBox* EllipsisBox::markupBox() const
return anchorBox;
}
void EllipsisBox::paintMarkupBox(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit lineTop, LayoutUnit lineBottom, RenderStyle* style)
void EllipsisBox::paintMarkupBox(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit lineTop, LayoutUnit lineBottom, const RenderStyle& style)
{
InlineBox* markupBox = this->markupBox();
if (!markupBox)
......@@ -104,22 +104,22 @@ void EllipsisBox::paintMarkupBox(PaintInfo& paintInfo, const LayoutPoint& paintO
LayoutPoint adjustedPaintOffset = paintOffset;
adjustedPaintOffset.move(x() + m_logicalWidth - markupBox->x(),
y() + style->fontMetrics().ascent() - (markupBox->y() + markupBox->lineStyle().fontMetrics().ascent()));
y() + style.fontMetrics().ascent() - (markupBox->y() + markupBox->lineStyle().fontMetrics().ascent()));
markupBox->paint(paintInfo, adjustedPaintOffset, lineTop, lineBottom);
}
IntRect EllipsisBox::selectionRect()
{
RenderStyle& lineStyle = this->lineStyle();
const RenderStyle& lineStyle = this->lineStyle();
const Font& font = lineStyle.font();
const RootInlineBox& rootBox = root();
// FIXME: Why is this always LTR? Fix by passing correct text run flags below.
return enclosingIntRect(font.selectionRectForText(RenderBlock::constructTextRun(&renderer(), font, m_str, &lineStyle, TextRun::AllowTrailingExpansion), IntPoint(x(), y() + rootBox.selectionTopAdjustedForPrecedingBlock()), rootBox.selectionHeightAdjustedForPrecedingBlock()));
return enclosingIntRect(font.selectionRectForText(RenderBlock::constructTextRun(&renderer(), font, m_str, lineStyle, TextRun::AllowTrailingExpansion), IntPoint(x(), y() + rootBox.selectionTopAdjustedForPrecedingBlock()), rootBox.selectionHeightAdjustedForPrecedingBlock()));
}
void EllipsisBox::paintSelection(GraphicsContext* context, const LayoutPoint& paintOffset, RenderStyle* style, const Font& font)
void EllipsisBox::paintSelection(GraphicsContext* context, const LayoutPoint& paintOffset, const RenderStyle& style, const Font& font)
{
Color textColor = style->visitedDependentColor(CSSPropertyColor);
Color textColor = style.visitedDependentColor(CSSPropertyColor);
Color c = renderer().selectionBackgroundColor();
if (!c.isValid() || !c.alpha())
return;
......@@ -138,7 +138,7 @@ void EllipsisBox::paintSelection(GraphicsContext* context, const LayoutPoint& pa
GraphicsContextStateSaver stateSaver(*context);
context->clip(clipRect);
// FIXME: Why is this always LTR? Fix by passing correct text run flags below.
context->drawHighlightForText(font, RenderBlock::constructTextRun(&renderer(), font, m_str, style, TextRun::AllowTrailingExpansion), roundedIntPoint(LayoutPoint(x() + paintOffset.x(), y() + paintOffset.y() + top)), h, c, style->colorSpace());
context->drawHighlightForText(font, RenderBlock::constructTextRun(&renderer(), font, m_str, style, TextRun::AllowTrailingExpansion), roundedIntPoint(LayoutPoint(x() + paintOffset.x(), y() + paintOffset.y() + top)), h, c, style.colorSpace());
}
bool EllipsisBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, LayoutUnit lineBottom)
......@@ -147,7 +147,7 @@ bool EllipsisBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& resu
// Hit test the markup box.
if (InlineBox* markupBox = this->markupBox()) {
RenderStyle& lineStyle = this->lineStyle();
const RenderStyle& lineStyle = this->lineStyle();
LayoutUnit mtx = adjustedLocation.x() + m_logicalWidth - markupBox->x();
LayoutUnit mty = adjustedLocation.y() + lineStyle.fontMetrics().ascent() - (markupBox->y() + markupBox->lineStyle().fontMetrics().ascent());
if (markupBox->nodeAtPoint(request, result, locationInContainer, LayoutPoint(mtx, mty), lineTop, lineBottom)) {
......
......@@ -39,10 +39,10 @@ public:
RenderBlock& renderer() const { return toRenderBlock(InlineBox::renderer()); }
private:
void paintMarkupBox(PaintInfo&, const LayoutPoint& paintOffset, LayoutUnit lineTop, LayoutUnit lineBottom, RenderStyle*);
void paintMarkupBox(PaintInfo&, const LayoutPoint& paintOffset, LayoutUnit lineTop, LayoutUnit lineBottom, const RenderStyle&);
virtual int height() const { return m_height; }
virtual RenderObject::SelectionState selectionState() { return m_selectionState; }
void paintSelection(GraphicsContext*, const LayoutPoint&, RenderStyle*, const Font&);
void paintSelection(GraphicsContext*, const LayoutPoint&, const RenderStyle&, const Font&);
InlineBox* markupBox() const;
bool m_shouldPaintMarkupBox;
......
......@@ -280,7 +280,7 @@ public:
bool visibleToHitTesting() const { return renderer().style()->visibility() == VISIBLE && renderer().style()->pointerEvents() != PE_NONE; }
RenderStyle& lineStyle() const { return m_bitfields.firstLine() ? *renderer().firstLineStyle() : *renderer().style(); }
const RenderStyle& lineStyle() const { return m_bitfields.firstLine() ? *renderer().firstLineStyle() : *renderer().style(); }
EVerticalAlign verticalAlign() const { return lineStyle().verticalAlign(); }
......
......@@ -160,7 +160,7 @@ void InlineFlowBox::addToLine(InlineBox* child)
if (!child->renderer().isOutOfFlowPositioned()) {
const RenderStyle& childStyle = child->lineStyle();
if (child->behavesLikeText()) {
RenderStyle* childStyle = &child->lineStyle();
const RenderStyle* childStyle = &child->lineStyle();
if (childStyle->letterSpacing() < 0 || childStyle->textShadow() || childStyle->textEmphasisMark() != TextEmphasisMarkNone || childStyle->textStrokeWidth())
child->clearKnownToHaveNoOverflow();
} else if (child->renderer().isReplaced()) {
......@@ -661,7 +661,7 @@ void InlineFlowBox::placeBoxesInBlockDirection(LayoutUnit top, LayoutUnit maxHei
LayoutUnit boxHeight = curr->logicalHeight();
LayoutUnit boxHeightIncludingMargins = boxHeight;
RenderStyle& childLineStyle = curr->lineStyle();
const RenderStyle& childLineStyle = curr->lineStyle();
if (curr->behavesLikeText() || curr->isInlineFlowBox()) {
const FontMetrics& fontMetrics = childLineStyle.fontMetrics();
newLogicalTop += curr->baselinePosition(baselineType) - fontMetrics.ascent(baselineType);
......@@ -703,7 +703,7 @@ void InlineFlowBox::placeBoxesInBlockDirection(LayoutUnit top, LayoutUnit maxHei
}
if (curr->isInlineTextBox()) {
TextEmphasisPosition emphasisMarkPosition;
if (toInlineTextBox(curr)->getEmphasisMarkPosition(&childLineStyle, emphasisMarkPosition)) {
if (toInlineTextBox(curr)->getEmphasisMarkPosition(childLineStyle, emphasisMarkPosition)) {
bool emphasisMarkIsOver = emphasisMarkPosition == TextEmphasisPositionOver;
if (emphasisMarkIsOver != childLineStyle.isFlippedLinesWritingMode())
hasAnnotationsBefore = true;
......@@ -858,7 +858,7 @@ inline void InlineFlowBox::addTextBoxVisualOverflow(InlineTextBox* textBox, Glyp
if (textBox->knownToHaveNoOverflow())
return;
RenderStyle& lineStyle = this->lineStyle();
const RenderStyle& lineStyle = this->lineStyle();
GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.find(textBox);
GlyphOverflow* glyphOverflow = it == textBoxDataMap.end() ? 0 : &it->value.second;
......@@ -876,7 +876,7 @@ inline void InlineFlowBox::addTextBoxVisualOverflow(InlineTextBox* textBox, Glyp
int rightGlyphOverflow = strokeOverflow + rightGlyphEdge;
TextEmphasisPosition emphasisMarkPosition;
if (lineStyle.textEmphasisMark() != TextEmphasisMarkNone && textBox->getEmphasisMarkPosition(&lineStyle, emphasisMarkPosition)) {
if (lineStyle.textEmphasisMark() != TextEmphasisMarkNone && textBox->getEmphasisMarkPosition(lineStyle, emphasisMarkPosition)) {
int emphasisMarkHeight = lineStyle.font().emphasisMarkHeight(lineStyle.textEmphasisMarkString());
if ((emphasisMarkPosition == TextEmphasisPositionOver) == (!lineStyle.isFlippedLinesWritingMode()))
topGlyphOverflow = min(topGlyphOverflow, -emphasisMarkHeight);
......@@ -1238,14 +1238,14 @@ void InlineFlowBox::paintFillLayer(const PaintInfo& paintInfo, const Color& c, c
}
}
void InlineFlowBox::paintBoxShadow(const PaintInfo& info, RenderStyle* s, ShadowStyle shadowStyle, const LayoutRect& paintRect)
void InlineFlowBox::paintBoxShadow(const PaintInfo& info, const RenderStyle& style, ShadowStyle shadowStyle, const LayoutRect& paintRect)
{
if ((!prevLineBox() && !nextLineBox()) || !parent())
boxModelObject()->paintBoxShadow(info, paintRect, s, shadowStyle);
boxModelObject()->paintBoxShadow(info, paintRect, &style, shadowStyle);
else {
// FIXME: We can do better here in the multi-line case. We want to push a clip so that the shadow doesn't
// protrude incorrectly at the edges, and we want to possibly include shadows cast from the previous/following lines
boxModelObject()->paintBoxShadow(info, paintRect, s, shadowStyle, includeLogicalLeftEdge(), includeLogicalRightEdge());
boxModelObject()->paintBoxShadow(info, paintRect, &style, shadowStyle, includeLogicalLeftEdge(), includeLogicalRightEdge());
}
}
......@@ -1314,7 +1314,7 @@ void InlineFlowBox::paintBoxDecorations(PaintInfo& paintInfo, const LayoutPoint&
// a line may actually have to paint a background.
if (parent() && !renderer().hasBoxDecorations())
return;
RenderStyle& lineStyle = this->lineStyle();
const RenderStyle& lineStyle = this->lineStyle();
if (!parent() && (!isFirstLine() || &lineStyle == renderer().style()))
return;
......@@ -1323,11 +1323,11 @@ void InlineFlowBox::paintBoxDecorations(PaintInfo& paintInfo, const LayoutPoint&
LayoutRect paintRect = LayoutRect(adjustedPaintoffset, frameRect.size());
// Shadow comes first and is behind the background and border.
if (!boxModelObject()->boxShadowShouldBeAppliedToBackground(BackgroundBleedNone, this))
paintBoxShadow(paintInfo, &lineStyle, Normal, paintRect);
paintBoxShadow(paintInfo, lineStyle, Normal, paintRect);
Color c = lineStyle.visitedDependentColor(CSSPropertyBackgroundColor);
paintFillLayers(paintInfo, c, lineStyle.backgroundLayers(), paintRect);
paintBoxShadow(paintInfo, &lineStyle, Inset, paintRect);
paintBoxShadow(paintInfo, lineStyle, Inset, paintRect);
// :first-line cannot be used to put borders on a line. Always paint borders with our
// non-first-line style.
......@@ -1541,9 +1541,9 @@ LayoutUnit InlineFlowBox::computeOverAnnotationAdjustment(LayoutUnit allowedPosi
}
if (curr->isInlineTextBox()) {
RenderStyle& childLineStyle = curr->lineStyle();
const RenderStyle& childLineStyle = curr->lineStyle();
TextEmphasisPosition emphasisMarkPosition;
if (childLineStyle.textEmphasisMark() != TextEmphasisMarkNone && toInlineTextBox(curr)->getEmphasisMarkPosition(&childLineStyle, emphasisMarkPosition) && emphasisMarkPosition == TextEmphasisPositionOver) {
if (childLineStyle.textEmphasisMark() != TextEmphasisMarkNone && toInlineTextBox(curr)->getEmphasisMarkPosition(childLineStyle, emphasisMarkPosition) && emphasisMarkPosition == TextEmphasisPositionOver) {
if (!childLineStyle.isFlippedLinesWritingMode()) {
int topOfEmphasisMark = curr->logicalTop() - childLineStyle.font().emphasisMarkHeight(childLineStyle.textEmphasisMarkString());
result = max(result, allowedPosition - topOfEmphasisMark);
......@@ -1589,7 +1589,7 @@ LayoutUnit InlineFlowBox::computeUnderAnnotationAdjustment(LayoutUnit allowedPos
}
if (curr->isInlineTextBox()) {
RenderStyle& childLineStyle = curr->lineStyle();
const RenderStyle& childLineStyle = curr->lineStyle();
if (childLineStyle.textEmphasisMark() != TextEmphasisMarkNone && childLineStyle.textEmphasisPosition() == TextEmphasisPositionUnder) {
if (!childLineStyle.isFlippedLinesWritingMode()) {
LayoutUnit bottomOfEmphasisMark = curr->logicalBottom() + childLineStyle.font().emphasisMarkHeight(childLineStyle.textEmphasisMarkString());
......
......@@ -73,7 +73,7 @@ public:
#endif
RenderBoxModelObject& renderer() const { return toRenderBoxModelObject(InlineBox::renderer()); }
RenderStyle& lineStyle() const { return isFirstLine() ? *renderer().firstLineStyle() : *renderer().style(); }
const RenderStyle& lineStyle() const { return isFirstLine() ? *renderer().firstLineStyle() : *renderer().style(); }
InlineFlowBox* prevLineBox() const { return m_prevLineBox; }
InlineFlowBox* nextLineBox() const { return m_nextLineBox; }
......@@ -116,7 +116,7 @@ public:
void paintMask(PaintInfo&, const LayoutPoint&);
void paintFillLayers(const PaintInfo&, const Color&, const FillLayer*, const LayoutRect&, CompositeOperator = CompositeSourceOver);
void paintFillLayer(const PaintInfo&, const Color&, const FillLayer*, const LayoutRect&, CompositeOperator = CompositeSourceOver);
void paintBoxShadow(const PaintInfo&, RenderStyle*, ShadowStyle, const LayoutRect&);
void paintBoxShadow(const PaintInfo&, const RenderStyle&, ShadowStyle, const LayoutRect&);
virtual void paint(PaintInfo&, const LayoutPoint&, LayoutUnit lineTop, LayoutUnit lineBottom);
virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, LayoutUnit lineBottom) OVERRIDE;
......
......@@ -179,9 +179,9 @@ RenderObject::SelectionState InlineTextBox::selectionState()
return state;
}
static void adjustCharactersAndLengthForHyphen(BufferForAppendingHyphen& charactersWithHyphen, RenderStyle* style, String& string, int& length)
static void adjustCharactersAndLengthForHyphen(BufferForAppendingHyphen& charactersWithHyphen, const RenderStyle& style, String& string, int& length)
{
const AtomicString& hyphenString = style->hyphenString();
const AtomicString& hyphenString = style.hyphenString();
charactersWithHyphen.reserveCapacity(length + hyphenString.length());
charactersWithHyphen.append(string);
charactersWithHyphen.append(hyphenString);
......@@ -211,12 +211,12 @@ LayoutRect InlineTextBox::localSelectionRect(int startPos, int endPos)
LayoutUnit selTop = selectionTop();
LayoutUnit selHeight = selectionHeight();
RenderStyle& lineStyle = this->lineStyle();
const RenderStyle& lineStyle = this->lineStyle();
const Font& font = fontToUse(lineStyle, renderer());
BufferForAppendingHyphen charactersWithHyphen;
bool respectHyphen = ePos == m_len && hasHyphen();
TextRun textRun = constructTextRun(&lineStyle, font, respectHyphen ? &charactersWithHyphen : 0);
TextRun textRun = constructTextRun(lineStyle, font, respectHyphen ? &charactersWithHyphen : 0);
if (respectHyphen)
endPos = textRun.length();
......@@ -485,13 +485,13 @@ static void paintTextWithShadows(GraphicsContext* context, const Font& font, con
} while (shadow || stroked || !opaque);
}
bool InlineTextBox::getEmphasisMarkPosition(RenderStyle* style, TextEmphasisPosition& emphasisPosition) const
bool InlineTextBox::getEmphasisMarkPosition(const RenderStyle& style, TextEmphasisPosition& emphasisPosition) const
{
// This function returns true if there are text emphasis marks and they are suppressed by ruby text.
if (style->textEmphasisMark() == TextEmphasisMarkNone)
if (style.textEmphasisMark() == TextEmphasisMarkNone)
return false;
emphasisPosition = style->textEmphasisPosition();
emphasisPosition = style.textEmphasisPosition();
if (emphasisPosition == TextEmphasisPositionUnder)
return true; // Ruby text is always over, so it cannot suppress emphasis marks under.
......@@ -564,7 +564,7 @@ void InlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset,
GraphicsContext* context = paintInfo.context;
RenderStyle& lineStyle = this->lineStyle();
const RenderStyle& lineStyle = this->lineStyle();
adjustedPaintOffset.move(0, lineStyle.isHorizontalWritingMode() ? 0 : -logicalHeight());
......@@ -687,14 +687,14 @@ void InlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset,
#endif
if (containsComposition && !useCustomUnderlines)
paintCompositionBackground(context, boxOrigin, &lineStyle, font,
paintCompositionBackground(context, boxOrigin, lineStyle, font,
renderer().frame().editor().compositionStart(),
renderer().frame().editor().compositionEnd());
paintDocumentMarkers(context, boxOrigin, &lineStyle, font, true);
paintDocumentMarkers(context, boxOrigin, lineStyle, font, true);
if (haveSelection && !useCustomUnderlines)
paintSelection(context, boxOrigin, &lineStyle, font, selectionFillColor);
paintSelection(context, boxOrigin, lineStyle, font, selectionFillColor);
}
if (Page* page = renderer().frame().page()) {
......@@ -723,7 +723,7 @@ void InlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset,
}
BufferForAppendingHyphen charactersWithHyphen;
TextRun textRun = constructTextRun(&lineStyle, font, string, maximumLength, hasHyphen() ? &charactersWithHyphen : 0);
TextRun textRun = constructTextRun(lineStyle, font, string, maximumLength, hasHyphen() ? &charactersWithHyphen : 0);
if (hasHyphen())
length = textRun.length();
......@@ -740,7 +740,7 @@ void InlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset,
int emphasisMarkOffset = 0;
TextEmphasisPosition emphasisMarkPosition;
bool hasTextEmphasis = getEmphasisMarkPosition(&lineStyle, emphasisMarkPosition);
bool hasTextEmphasis = getEmphasisMarkPosition(lineStyle, emphasisMarkPosition);
const AtomicString& emphasisMark = hasTextEmphasis ? lineStyle.textEmphasisMarkString() : nullAtom;
if (!emphasisMark.isEmpty())
emphasisMarkOffset = emphasisMarkPosition == TextEmphasisPositionOver ? -font.fontMetrics().ascent() - font.emphasisMarkDescent(emphasisMark) : font.fontMetrics().descent() + font.emphasisMarkAscent(emphasisMark);
......@@ -811,7 +811,7 @@ void InlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset,
}
if (paintInfo.phase == PaintPhaseForeground) {
paintDocumentMarkers(context, boxOrigin, &lineStyle, font, false);
paintDocumentMarkers(context, boxOrigin, lineStyle, font, false);
if (useCustomUnderlines) {
const Vector<CompositionUnderline>& underlines = renderer().frame().editor().customCompositionUnderlines();
......@@ -868,7 +868,7 @@ void alignSelectionRectToDevicePixels(FloatRect& rect)
rect.setWidth(roundf(maxX - rect.x()));
}
void InlineTextBox::paintSelection(GraphicsContext* context, const FloatPoint& boxOrigin, RenderStyle* style, const Font& font, Color textColor)
void InlineTextBox::paintSelection(GraphicsContext* context, const FloatPoint& boxOrigin, const RenderStyle& style, const Font& font, Color textColor)
{
if (context->paintingDisabled())
return;
......@@ -889,7 +889,7 @@ void InlineTextBox::paintSelection(GraphicsContext* context, const FloatPoint& b
c = Color(0xff - c.red(), 0xff - c.green(), 0xff - c.blue());
GraphicsContextStateSaver stateSaver(*context);
updateGraphicsContext(context, c, c, 0, style->colorSpace()); // Don't draw text at all!
updateGraphicsContext(context, c, c, 0, style.colorSpace()); // Don't draw text at all!
// If the text is truncated, let the thing being painted in the truncation
// draw its own highlight.
......@@ -920,10 +920,10 @@ void InlineTextBox::paintSelection(GraphicsContext* context, const FloatPoint& b
context->clip(clipRect);
context->drawHighlightForText(font, textRun, localOrigin, selHeight, c, style->colorSpace(), sPos, ePos);
context->drawHighlightForText(font, textRun, localOrigin, selHeight, c, style.colorSpace(), sPos, ePos);
}
void InlineTextBox::paintCompositionBackground(GraphicsContext* context, const FloatPoint& boxOrigin, RenderStyle* style, const Font& font, int startPos, int endPos)
void InlineTextBox::paintCompositionBackground(GraphicsContext* context, const FloatPoint& boxOrigin, const RenderStyle& style, const Font& font, int startPos, int endPos)
{
int offset = m_start;
int sPos = max(startPos - offset, 0);
......@@ -936,12 +936,12 @@ void InlineTextBox::paintCompositionBackground(GraphicsContext* context, const F
Color c = Color(225, 221, 85);
updateGraphicsContext(context, c, c, 0, style->colorSpace()); // Don't draw text at all!
updateGraphicsContext(context, c, c, 0, style.colorSpace()); // Don't draw text at all!
int deltaY = renderer().style()->isFlippedLinesWritingMode() ? selectionBottom() - logicalBottom() : logicalTop() - selectionTop();
int selHeight = selectionHeight();
FloatPoint localOrigin(boxOrigin.x(), boxOrigin.y() - deltaY);
context->drawHighlightForText(font, constructTextRun(style, font), localOrigin, selHeight, c, style->colorSpace(), sPos, ePos);
context->drawHighlightForText(font, constructTextRun(style, font), localOrigin, selHeight, c, style.colorSpace(), sPos, ePos);
}
#if PLATFORM(MAC)
......@@ -1167,7 +1167,7 @@ void InlineTextBox::paintDecoration(GraphicsContext* context, const FloatPoint&
bool linesAreOpaque = !isPrinting && (!(deco & TextDecorationUnderline) || underline.alpha() == 255) && (!(deco & TextDecorationOverline) || overline.alpha() == 255) && (!(deco & TextDecorationLineThrough) || linethrough.alpha() == 255);
RenderStyle& lineStyle = this->lineStyle();
const RenderStyle& lineStyle = this->lineStyle();
int baseline = lineStyle.fontMetrics().ascent();
bool setClip = false;
......@@ -1300,7 +1300,7 @@ static GraphicsContext::DocumentMarkerLineStyle lineStyleForMarkerType(DocumentM
}
}
void InlineTextBox::paintDocumentMarker(GraphicsContext* pt, const FloatPoint& boxOrigin, DocumentMarker* marker, RenderStyle* style, const Font& font, bool grammar)
void InlineTextBox::paintDocumentMarker(GraphicsContext* pt, const FloatPoint& boxOrigin, DocumentMarker* marker, const RenderStyle& style, const Font& font, bool grammar)
{
// Never print spelling/grammar markers (5327887)
if (renderer().document().printing())
......@@ -1369,7 +1369,7 @@ void InlineTextBox::paintDocumentMarker(GraphicsContext* pt, const FloatPoint& b
pt->drawLineForDocumentMarker(FloatPoint(boxOrigin.x() + start, boxOrigin.y() + underlineOffset), width, lineStyleForMarkerType(marker->type()));
}
void InlineTextBox::paintTextMatchMarker(GraphicsContext* pt, const FloatPoint& boxOrigin, DocumentMarker* marker, RenderStyle* style, const Font& font)
void InlineTextBox::paintTextMatchMarker(GraphicsContext* pt, const FloatPoint& boxOrigin, DocumentMarker* marker, const RenderStyle& style, const Font& font)
{
// Use same y positioning and height as for selection, so that when the selection and this highlight are on
// the same word there are no pieces sticking out.
......@@ -1391,13 +1391,13 @@ void InlineTextBox::paintTextMatchMarker(GraphicsContext* pt, const FloatPoint&
renderer().theme()->platformActiveTextSearchHighlightColor() :
renderer().theme()->platformInactiveTextSearchHighlightColor();
GraphicsContextStateSaver stateSaver(*pt);
updateGraphicsContext(pt, color, color, 0, style->colorSpace()); // Don't draw text at all!
updateGraphicsContext(pt, color, color, 0, style.colorSpace()); // Don't draw text at all!
pt->clip(FloatRect(boxOrigin.x(), boxOrigin.y() - deltaY, m_logicalWidth, selHeight));
pt->drawHighlightForText(font, run, FloatPoint(boxOrigin.x(), boxOrigin.y() - deltaY), selHeight, color, style->colorSpace(), sPos, ePos);
pt->drawHighlightForText(font, run, FloatPoint(boxOrigin.x(), boxOrigin.y() - deltaY), selHeight, color, style.colorSpace(), sPos, ePos);
}
}
void InlineTextBox::computeRectForReplacementMarker(DocumentMarker* marker, RenderStyle* style, const Font& font)
void InlineTextBox::computeRectForReplacementMarker(DocumentMarker* marker, const RenderStyle& style, const Font& font)
{
// Replacement markers are not actually drawn, but their rects need to be computed for hit testing.
int top = selectionTop();
......@@ -1414,7 +1414,7 @@ void InlineTextBox::computeRectForReplacementMarker(DocumentMarker* marker, Rend
toRenderedDocumentMarker(marker)->setRenderedRect(markerRect);
}
void InlineTextBox::paintDocumentMarkers(GraphicsContext* pt, const FloatPoint& boxOrigin, RenderStyle* style, const Font& font, bool background)
void InlineTextBox::paintDocumentMarkers(GraphicsContext* pt, const FloatPoint& boxOrigin, const RenderStyle& style, const Font& font, bool background)
{
if (!renderer().textNode())
return;
......@@ -1553,9 +1553,9 @@ int InlineTextBox::offsetForPosition(float lineOffset, bool includePartialGlyphs
FontCachePurgePreventer fontCachePurgePreventer;
RenderStyle& lineStyle = this->lineStyle();
const RenderStyle& lineStyle = this->lineStyle();
const Font& font = fontToUse(lineStyle, renderer());
return font.offsetForPosition(constructTextRun(&lineStyle, font), lineOffset - logicalLeft(), includePartialGlyphs);
return font.offsetForPosition(constructTextRun(lineStyle, font), lineOffset - logicalLeft(), includePartialGlyphs);
}
float InlineTextBox::positionForOffset(int offset) const
......@@ -1568,12 +1568,12 @@ float InlineTextBox::positionForOffset(int offset) const
FontCachePurgePreventer fontCachePurgePreventer;
RenderStyle& lineStyle = this->lineStyle();
const RenderStyle& lineStyle = this->lineStyle();
const Font& font = fontToUse(lineStyle, renderer());
int from = !isLeftToRightDirection() ? offset - m_start : 0;
int to = !isLeftToRightDirection() ? m_len : offset - m_start;
// FIXME: Do we need to add rightBearing here?
return font.selectionRectForText(constructTextRun(&lineStyle, font), IntPoint(logicalLeft(), 0), 0, from, to).maxX();
return font.selectionRectForText(constructTextRun(lineStyle, font), IntPoint(logicalLeft(), 0), 0, from, to).maxX();
}
bool InlineTextBox::containsCaretOffset(int offset) const
......@@ -1600,9 +1600,8 @@ bool InlineTextBox::containsCaretOffset(int offset) const
return true;
}
TextRun InlineTextBox::constructTextRun(RenderStyle* style, const Font& font, BufferForAppendingHyphen* charactersWithHyphen) const
TextRun InlineTextBox::constructTextRun(const RenderStyle& style, const Font& font, BufferForAppendingHyphen* charactersWithHyphen) const
{
ASSERT(style);
ASSERT(renderer().text());
String string = renderer().text();
......@@ -1615,10 +1614,8 @@ TextRun InlineTextBox::constructTextRun(RenderStyle* style, const Font& font, Bu
return constructTextRun(style, font, string, renderer().textLength() - startPos, charactersWithHyphen);
}
TextRun InlineTextBox::constructTextRun(RenderStyle* style, const Font& font, String string, int maximumLength, BufferForAppendingHyphen* charactersWithHyphen) const
TextRun InlineTextBox::constructTextRun(const RenderStyle& style, const Font& font, String string, int maximumLength, BufferForAppendingHyphen* charactersWithHyphen) const
{
ASSERT(style);
int length = string.length();
if (charactersWithHyphen) {
......@@ -1628,8 +1625,8 @@ TextRun InlineTextBox::constructTextRun(RenderStyle* style, const Font& font, St
ASSERT(maximumLength >= length);
TextRun run(string, textPos(), expansion(), expansionBehavior(), direction(), dirOverride() || style->rtlOrdering() == VisualOrder, !renderer().canUseSimpleFontCodePath());
run.setTabSize(!style->collapseWhiteSpace(), style->tabSize());
TextRun run(string, textPos(), expansion(), expansionBehavior(), direction(), dirOverride() || style.rtlOrdering() == VisualOrder, !renderer().canUseSimpleFontCodePath());
run.setTabSize(!style.collapseWhiteSpace(), style.tabSize());
if (textRunNeedsRenderingContext(font))
run.setRenderingContext(SVGTextRunRenderingContext::create(&renderer()));
......
......@@ -58,7 +58,7 @@ public:
}
RenderText& renderer() const { return toRenderText(InlineBox::renderer()); }
RenderStyle& lineStyle() const { return isFirstLine() ? *renderer().firstLineStyle() : *renderer().style(); }
const RenderStyle& lineStyle() const { return isFirstLine() ? *renderer().firstLineStyle() : *renderer().style(); }
virtual void destroy(RenderArena&) OVERRIDE FINAL;
......@@ -91,7 +91,7 @@ public:
virtual int baselinePosition(FontBaseline) const OVERRIDE FINAL;
virtual LayoutUnit lineHeight() const OVERRIDE FINAL;
bool getEmphasisMarkPosition(RenderStyle*, TextEmphasisPosition&) const;
bool getEmphasisMarkPosition(const RenderStyle&, TextEmphasisPosition&) const;
LayoutRect logicalOverflowRect() const;
void setLogicalOverflowRect(const LayoutRect&);
......@@ -110,8 +110,8 @@ private:
LayoutUnit selectionBottom();
LayoutUnit selectionHeight();
TextRun constructTextRun(RenderStyle*, const Font&, BufferForAppendingHyphen* = 0) const;
TextRun constructTextRun(RenderStyle*, const Font&, String, int maximumLength, BufferForAppendingHyphen* = 0) const;
TextRun constructTextRun(const RenderStyle&, const Font&, BufferForAppendingHyphen* = 0) const;
TextRun constructTextRun(const RenderStyle&, const Font&, String, int maximumLength, BufferForAppendingHyphen* = 0) const;
public:
virtual FloatRect calculateBoundaries() const { return FloatRect(x(), y(), width(), height()); }
......@@ -176,8 +176,8 @@ private:
// denote no truncation (the whole run paints) and full truncation (nothing paints at all).
protected:
void paintCompositionBackground(GraphicsContext*, const FloatPoint& boxOrigin, RenderStyle*, const Font&, int startPos, int endPos);
void paintDocumentMarkers(GraphicsContext*, const FloatPoint& boxOrigin, RenderStyle*, const Font&, bool background);
void paintCompositionBackground(GraphicsContext*, const FloatPoint& boxOrigin, const RenderStyle&, const Font&, int startPos, int endPos);
void paintDocumentMarkers(GraphicsContext*, const FloatPoint& boxOrigin, const RenderStyle&, const Font&, bool background);
void paintCompositionUnderline(GraphicsContext*, const FloatPoint& boxOrigin, const CompositionUnderline&);
#if PLATFORM(MAC)
void paintCustomHighlight(const LayoutPoint&, const AtomicString& type);
......@@ -185,10 +185,10 @@ protected:
private:
void paintDecoration(GraphicsContext*, const FloatPoint& boxOrigin, TextDecoration, TextDecorationStyle, const ShadowData*);
void paintSelection(GraphicsContext*, const FloatPoint& boxOrigin, RenderStyle*, const Font&, Color textColor);
void paintDocumentMarker(GraphicsContext*, const FloatPoint& boxOrigin, DocumentMarker*, RenderStyle*, const Font&, bool grammar);
void paintTextMatchMarker(GraphicsContext*, const FloatPoint& boxOrigin, DocumentMarker*, RenderStyle*, const Font&);
void computeRectForReplacementMarker(DocumentMarker*, RenderStyle*, const Font&);
void paintSelection(GraphicsContext*, const FloatPoint& boxOrigin, const RenderStyle&, const Font&, Color textColor);
void paintDocumentMarker(GraphicsContext*, const FloatPoint& boxOrigin, DocumentMarker*, const RenderStyle&, const Font&, bool grammar);
void paintTextMatchMarker(GraphicsContext*, const FloatPoint& boxOrigin, DocumentMarker*, const RenderStyle&, const Font&);
void computeRectForReplacementMarker(DocumentMarker*, const RenderStyle&, const Font&);
TextRun::ExpansionBehavior expansionBehavior() const
{
......
......@@ -5163,7 +5163,7 @@ static inline void stripTrailingSpace(float& inlineMax, float& inlineMin,
RenderText* t = toRenderText(trailingSpaceChild);
const UChar space = ' ';
const Font& font = t->style()->font(); // FIXME: This ignores first-line.
float spaceWidth = font.width(RenderBlock::constructTextRun(t, font, &space, 1, t->style()));
float spaceWidth = font.width(RenderBlock::constructTextRun(t, font, &space, 1, *t->style()));
inlineMax -= spaceWidth + font.wordSpacing();
if (inlineMin > inlineMax)
inlineMin = inlineMax;
......@@ -6724,12 +6724,10 @@ void RenderBlock::createFloatingObjects()
}
template <typename CharacterType>
static inline TextRun constructTextRunInternal(RenderObject* context, const Font& font, const CharacterType* characters, int length, RenderStyle* style, TextRun::ExpansionBehavior expansion)
static inline TextRun constructTextRunInternal(RenderObject* context, const Font& font, const CharacterType* characters, int length, const RenderStyle& style, TextRun::ExpansionBehavior expansion)
{
ASSERT(style);
TextDirection textDirection = LTR;