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> 2013-09-28 Antti Koivisto <antti@apple.com>
Add first()/last() to ElementIteratorAdapters Add first()/last() to ElementIteratorAdapters
...@@ -43,7 +43,7 @@ class TextLayout { ...@@ -43,7 +43,7 @@ class TextLayout {
public: public:
static bool isNeeded(RenderText* text, const Font& font) 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; return font.codePath(run) == Font::Complex;
} }
...@@ -68,7 +68,7 @@ public: ...@@ -68,7 +68,7 @@ public:
private: private:
static TextRun constructTextRun(RenderText* text, const Font& font, float xPos) 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()); run.setCharactersLength(text->textLength());
ASSERT(run.charactersLength() >= run.length()); ASSERT(run.charactersLength() >= run.length());
......
...@@ -44,7 +44,7 @@ EllipsisBox::EllipsisBox(RenderBlock& renderer, const AtomicString& ellipsisStr, ...@@ -44,7 +44,7 @@ EllipsisBox::EllipsisBox(RenderBlock& renderer, const AtomicString& ellipsisStr,
void EllipsisBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit lineTop, LayoutUnit lineBottom) void EllipsisBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit lineTop, LayoutUnit lineBottom)
{ {
GraphicsContext* context = paintInfo.context; GraphicsContext* context = paintInfo.context;
RenderStyle& lineStyle = this->lineStyle(); const RenderStyle& lineStyle = this->lineStyle();
Color textColor = lineStyle.visitedDependentColor(CSSPropertyWebkitTextFillColor); Color textColor = lineStyle.visitedDependentColor(CSSPropertyWebkitTextFillColor);
if (textColor != context->fillColor()) if (textColor != context->fillColor())
context->setFillColor(textColor, lineStyle.colorSpace()); context->setFillColor(textColor, lineStyle.colorSpace());
...@@ -57,7 +57,7 @@ void EllipsisBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, La ...@@ -57,7 +57,7 @@ void EllipsisBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, La
const Font& font = lineStyle.font(); const Font& font = lineStyle.font();
if (selectionState() != RenderObject::SelectionNone) { if (selectionState() != RenderObject::SelectionNone) {
paintSelection(context, paintOffset, &lineStyle, font); paintSelection(context, paintOffset, lineStyle, font);
// Select the correct color for painting the text. // Select the correct color for painting the text.
Color foreground = paintInfo.forceBlackText() ? Color::black : renderer().selectionForegroundColor(); Color foreground = paintInfo.forceBlackText() ? Color::black : renderer().selectionForegroundColor();
...@@ -66,7 +66,7 @@ void EllipsisBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, La ...@@ -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. // 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. // Restore the regular fill color.
if (textColor != context->fillColor()) if (textColor != context->fillColor())
...@@ -75,7 +75,7 @@ void EllipsisBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, La ...@@ -75,7 +75,7 @@ void EllipsisBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, La
if (setShadow) if (setShadow)
context->clearShadow(); context->clearShadow();
paintMarkupBox(paintInfo, paintOffset, lineTop, lineBottom, &lineStyle); paintMarkupBox(paintInfo, paintOffset, lineTop, lineBottom, lineStyle);
} }
InlineBox* EllipsisBox::markupBox() const InlineBox* EllipsisBox::markupBox() const
...@@ -96,7 +96,7 @@ InlineBox* EllipsisBox::markupBox() const ...@@ -96,7 +96,7 @@ InlineBox* EllipsisBox::markupBox() const
return anchorBox; 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(); InlineBox* markupBox = this->markupBox();
if (!markupBox) if (!markupBox)
...@@ -104,22 +104,22 @@ void EllipsisBox::paintMarkupBox(PaintInfo& paintInfo, const LayoutPoint& paintO ...@@ -104,22 +104,22 @@ void EllipsisBox::paintMarkupBox(PaintInfo& paintInfo, const LayoutPoint& paintO
LayoutPoint adjustedPaintOffset = paintOffset; LayoutPoint adjustedPaintOffset = paintOffset;
adjustedPaintOffset.move(x() + m_logicalWidth - markupBox->x(), 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); markupBox->paint(paintInfo, adjustedPaintOffset, lineTop, lineBottom);
} }
IntRect EllipsisBox::selectionRect() IntRect EllipsisBox::selectionRect()
{ {
RenderStyle& lineStyle = this->lineStyle(); const RenderStyle& lineStyle = this->lineStyle();
const Font& font = lineStyle.font(); const Font& font = lineStyle.font();
const RootInlineBox& rootBox = root(); const RootInlineBox& rootBox = root();
// FIXME: Why is this always LTR? Fix by passing correct text run flags below. // 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(); Color c = renderer().selectionBackgroundColor();
if (!c.isValid() || !c.alpha()) if (!c.isValid() || !c.alpha())
return; return;
...@@ -138,7 +138,7 @@ void EllipsisBox::paintSelection(GraphicsContext* context, const LayoutPoint& pa ...@@ -138,7 +138,7 @@ void EllipsisBox::paintSelection(GraphicsContext* context, const LayoutPoint& pa
GraphicsContextStateSaver stateSaver(*context); GraphicsContextStateSaver stateSaver(*context);
context->clip(clipRect); context->clip(clipRect);
// FIXME: Why is this always LTR? Fix by passing correct text run flags below. // 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) 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 ...@@ -147,7 +147,7 @@ bool EllipsisBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& resu
// Hit test the markup box. // Hit test the markup box.
if (InlineBox* markupBox = this->markupBox()) { if (InlineBox* markupBox = this->markupBox()) {
RenderStyle& lineStyle = this->lineStyle(); const RenderStyle& lineStyle = this->lineStyle();
LayoutUnit mtx = adjustedLocation.x() + m_logicalWidth - markupBox->x(); LayoutUnit mtx = adjustedLocation.x() + m_logicalWidth - markupBox->x();
LayoutUnit mty = adjustedLocation.y() + lineStyle.fontMetrics().ascent() - (markupBox->y() + markupBox->lineStyle().fontMetrics().ascent()); LayoutUnit mty = adjustedLocation.y() + lineStyle.fontMetrics().ascent() - (markupBox->y() + markupBox->lineStyle().fontMetrics().ascent());
if (markupBox->nodeAtPoint(request, result, locationInContainer, LayoutPoint(mtx, mty), lineTop, lineBottom)) { if (markupBox->nodeAtPoint(request, result, locationInContainer, LayoutPoint(mtx, mty), lineTop, lineBottom)) {
......
...@@ -39,10 +39,10 @@ public: ...@@ -39,10 +39,10 @@ public:
RenderBlock& renderer() const { return toRenderBlock(InlineBox::renderer()); } RenderBlock& renderer() const { return toRenderBlock(InlineBox::renderer()); }
private: 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 int height() const { return m_height; }
virtual RenderObject::SelectionState selectionState() { return m_selectionState; } 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; InlineBox* markupBox() const;
bool m_shouldPaintMarkupBox; bool m_shouldPaintMarkupBox;
......
...@@ -280,7 +280,7 @@ public: ...@@ -280,7 +280,7 @@ public:
bool visibleToHitTesting() const { return renderer().style()->visibility() == VISIBLE && renderer().style()->pointerEvents() != PE_NONE; } 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(); } EVerticalAlign verticalAlign() const { return lineStyle().verticalAlign(); }
......
...@@ -160,7 +160,7 @@ void InlineFlowBox::addToLine(InlineBox* child) ...@@ -160,7 +160,7 @@ void InlineFlowBox::addToLine(InlineBox* child)
if (!child->renderer().isOutOfFlowPositioned()) { if (!child->renderer().isOutOfFlowPositioned()) {
const RenderStyle& childStyle = child->lineStyle(); const RenderStyle& childStyle = child->lineStyle();
if (child->behavesLikeText()) { if (child->behavesLikeText()) {
RenderStyle* childStyle = &child->lineStyle(); const RenderStyle* childStyle = &child->lineStyle();
if (childStyle->letterSpacing() < 0 || childStyle->textShadow() || childStyle->textEmphasisMark() != TextEmphasisMarkNone || childStyle->textStrokeWidth()) if (childStyle->letterSpacing() < 0 || childStyle->textShadow() || childStyle->textEmphasisMark() != TextEmphasisMarkNone || childStyle->textStrokeWidth())
child->clearKnownToHaveNoOverflow(); child->clearKnownToHaveNoOverflow();
} else if (child->renderer().isReplaced()) { } else if (child->renderer().isReplaced()) {
...@@ -661,7 +661,7 @@ void InlineFlowBox::placeBoxesInBlockDirection(LayoutUnit top, LayoutUnit maxHei ...@@ -661,7 +661,7 @@ void InlineFlowBox::placeBoxesInBlockDirection(LayoutUnit top, LayoutUnit maxHei
LayoutUnit boxHeight = curr->logicalHeight(); LayoutUnit boxHeight = curr->logicalHeight();
LayoutUnit boxHeightIncludingMargins = boxHeight; LayoutUnit boxHeightIncludingMargins = boxHeight;
RenderStyle& childLineStyle = curr->lineStyle(); const RenderStyle& childLineStyle = curr->lineStyle();
if (curr->behavesLikeText() || curr->isInlineFlowBox()) { if (curr->behavesLikeText() || curr->isInlineFlowBox()) {
const FontMetrics& fontMetrics = childLineStyle.fontMetrics(); const FontMetrics& fontMetrics = childLineStyle.fontMetrics();
newLogicalTop += curr->baselinePosition(baselineType) - fontMetrics.ascent(baselineType); newLogicalTop += curr->baselinePosition(baselineType) - fontMetrics.ascent(baselineType);
...@@ -703,7 +703,7 @@ void InlineFlowBox::placeBoxesInBlockDirection(LayoutUnit top, LayoutUnit maxHei ...@@ -703,7 +703,7 @@ void InlineFlowBox::placeBoxesInBlockDirection(LayoutUnit top, LayoutUnit maxHei
} }
if (curr->isInlineTextBox()) { if (curr->isInlineTextBox()) {
TextEmphasisPosition emphasisMarkPosition; TextEmphasisPosition emphasisMarkPosition;
if (toInlineTextBox(curr)->getEmphasisMarkPosition(&childLineStyle, emphasisMarkPosition)) { if (toInlineTextBox(curr)->getEmphasisMarkPosition(childLineStyle, emphasisMarkPosition)) {
bool emphasisMarkIsOver = emphasisMarkPosition == TextEmphasisPositionOver; bool emphasisMarkIsOver = emphasisMarkPosition == TextEmphasisPositionOver;
if (emphasisMarkIsOver != childLineStyle.isFlippedLinesWritingMode()) if (emphasisMarkIsOver != childLineStyle.isFlippedLinesWritingMode())
hasAnnotationsBefore = true; hasAnnotationsBefore = true;
...@@ -858,7 +858,7 @@ inline void InlineFlowBox::addTextBoxVisualOverflow(InlineTextBox* textBox, Glyp ...@@ -858,7 +858,7 @@ inline void InlineFlowBox::addTextBoxVisualOverflow(InlineTextBox* textBox, Glyp
if (textBox->knownToHaveNoOverflow()) if (textBox->knownToHaveNoOverflow())
return; return;
RenderStyle& lineStyle = this->lineStyle(); const RenderStyle& lineStyle = this->lineStyle();
GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.find(textBox); GlyphOverflowAndFallbackFontsMap::iterator it = textBoxDataMap.find(textBox);
GlyphOverflow* glyphOverflow = it == textBoxDataMap.end() ? 0 : &it->value.second; GlyphOverflow* glyphOverflow = it == textBoxDataMap.end() ? 0 : &it->value.second;
...@@ -876,7 +876,7 @@ inline void InlineFlowBox::addTextBoxVisualOverflow(InlineTextBox* textBox, Glyp ...@@ -876,7 +876,7 @@ inline void InlineFlowBox::addTextBoxVisualOverflow(InlineTextBox* textBox, Glyp
int rightGlyphOverflow = strokeOverflow + rightGlyphEdge; int rightGlyphOverflow = strokeOverflow + rightGlyphEdge;
TextEmphasisPosition emphasisMarkPosition; 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()); int emphasisMarkHeight = lineStyle.font().emphasisMarkHeight(lineStyle.textEmphasisMarkString());
if ((emphasisMarkPosition == TextEmphasisPositionOver) == (!lineStyle.isFlippedLinesWritingMode())) if ((emphasisMarkPosition == TextEmphasisPositionOver) == (!lineStyle.isFlippedLinesWritingMode()))
topGlyphOverflow = min(topGlyphOverflow, -emphasisMarkHeight); topGlyphOverflow = min(topGlyphOverflow, -emphasisMarkHeight);
...@@ -1238,14 +1238,14 @@ void InlineFlowBox::paintFillLayer(const PaintInfo& paintInfo, const Color& c, c ...@@ -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()) if ((!prevLineBox() && !nextLineBox()) || !parent())
boxModelObject()->paintBoxShadow(info, paintRect, s, shadowStyle); boxModelObject()->paintBoxShadow(info, paintRect, &style, shadowStyle);
else { else {
// FIXME: We can do better here in the multi-line case. We want to push a clip so that the shadow doesn't // 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 // 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& ...@@ -1314,7 +1314,7 @@ void InlineFlowBox::paintBoxDecorations(PaintInfo& paintInfo, const LayoutPoint&
// a line may actually have to paint a background. // a line may actually have to paint a background.
if (parent() && !renderer().hasBoxDecorations()) if (parent() && !renderer().hasBoxDecorations())
return; return;
RenderStyle& lineStyle = this->lineStyle(); const RenderStyle& lineStyle = this->lineStyle();
if (!parent() && (!isFirstLine() || &lineStyle == renderer().style())) if (!parent() && (!isFirstLine() || &lineStyle == renderer().style()))
return; return;
...@@ -1323,11 +1323,11 @@ void InlineFlowBox::paintBoxDecorations(PaintInfo& paintInfo, const LayoutPoint& ...@@ -1323,11 +1323,11 @@ void InlineFlowBox::paintBoxDecorations(PaintInfo& paintInfo, const LayoutPoint&
LayoutRect paintRect = LayoutRect(adjustedPaintoffset, frameRect.size()); LayoutRect paintRect = LayoutRect(adjustedPaintoffset, frameRect.size());
// Shadow comes first and is behind the background and border. // Shadow comes first and is behind the background and border.
if (!boxModelObject()->boxShadowShouldBeAppliedToBackground(BackgroundBleedNone, this)) if (!boxModelObject()->boxShadowShouldBeAppliedToBackground(BackgroundBleedNone, this))
paintBoxShadow(paintInfo, &lineStyle, Normal, paintRect); paintBoxShadow(paintInfo, lineStyle, Normal, paintRect);
Color c = lineStyle.visitedDependentColor(CSSPropertyBackgroundColor); Color c = lineStyle.visitedDependentColor(CSSPropertyBackgroundColor);
paintFillLayers(paintInfo, c, lineStyle.backgroundLayers(), paintRect); 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 // :first-line cannot be used to put borders on a line. Always paint borders with our
// non-first-line style. // non-first-line style.
...@@ -1541,9 +1541,9 @@ LayoutUnit InlineFlowBox::computeOverAnnotationAdjustment(LayoutUnit allowedPosi ...@@ -1541,9 +1541,9 @@ LayoutUnit InlineFlowBox::computeOverAnnotationAdjustment(LayoutUnit allowedPosi
} }
if (curr->isInlineTextBox()) { if (curr->isInlineTextBox()) {
RenderStyle& childLineStyle = curr->lineStyle(); const RenderStyle& childLineStyle = curr->lineStyle();
TextEmphasisPosition emphasisMarkPosition; 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()) { if (!childLineStyle.isFlippedLinesWritingMode()) {
int topOfEmphasisMark = curr->logicalTop() - childLineStyle.font().emphasisMarkHeight(childLineStyle.textEmphasisMarkString()); int topOfEmphasisMark = curr->logicalTop() - childLineStyle.font().emphasisMarkHeight(childLineStyle.textEmphasisMarkString());
result = max(result, allowedPosition - topOfEmphasisMark); result = max(result, allowedPosition - topOfEmphasisMark);
...@@ -1589,7 +1589,7 @@ LayoutUnit InlineFlowBox::computeUnderAnnotationAdjustment(LayoutUnit allowedPos ...@@ -1589,7 +1589,7 @@ LayoutUnit InlineFlowBox::computeUnderAnnotationAdjustment(LayoutUnit allowedPos
} }
if (curr->isInlineTextBox()) { if (curr->isInlineTextBox()) {
RenderStyle& childLineStyle = curr->lineStyle(); const RenderStyle& childLineStyle = curr->lineStyle();
if (childLineStyle.textEmphasisMark() != TextEmphasisMarkNone && childLineStyle.textEmphasisPosition() == TextEmphasisPositionUnder) { if (childLineStyle.textEmphasisMark() != TextEmphasisMarkNone && childLineStyle.textEmphasisPosition() == TextEmphasisPositionUnder) {
if (!childLineStyle.isFlippedLinesWritingMode()) { if (!childLineStyle.isFlippedLinesWritingMode()) {
LayoutUnit bottomOfEmphasisMark = curr->logicalBottom() + childLineStyle.font().emphasisMarkHeight(childLineStyle.textEmphasisMarkString()); LayoutUnit bottomOfEmphasisMark = curr->logicalBottom() + childLineStyle.font().emphasisMarkHeight(childLineStyle.textEmphasisMarkString());
......
...@@ -73,7 +73,7 @@ public: ...@@ -73,7 +73,7 @@ public:
#endif #endif
RenderBoxModelObject& renderer() const { return toRenderBoxModelObject(InlineBox::renderer()); } 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* prevLineBox() const { return m_prevLineBox; }
InlineFlowBox* nextLineBox() const { return m_nextLineBox; } InlineFlowBox* nextLineBox() const { return m_nextLineBox; }
...@@ -116,7 +116,7 @@ public: ...@@ -116,7 +116,7 @@ public:
void paintMask(PaintInfo&, const LayoutPoint&); void paintMask(PaintInfo&, const LayoutPoint&);
void paintFillLayers(const PaintInfo&, const Color&, const FillLayer*, const LayoutRect&, CompositeOperator = CompositeSourceOver); 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 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 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; 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() ...@@ -179,9 +179,9 @@ RenderObject::SelectionState InlineTextBox::selectionState()
return state; 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.reserveCapacity(length + hyphenString.length());
charactersWithHyphen.append(string); charactersWithHyphen.append(string);
charactersWithHyphen.append(hyphenString); charactersWithHyphen.append(hyphenString);
...@@ -211,12 +211,12 @@ LayoutRect InlineTextBox::localSelectionRect(int startPos, int endPos) ...@@ -211,12 +211,12 @@ LayoutRect InlineTextBox::localSelectionRect(int startPos, int endPos)
LayoutUnit selTop = selectionTop(); LayoutUnit selTop = selectionTop();
LayoutUnit selHeight = selectionHeight(); LayoutUnit selHeight = selectionHeight();
RenderStyle& lineStyle = this->lineStyle(); const RenderStyle& lineStyle = this->lineStyle();
const Font& font = fontToUse(lineStyle, renderer()); const Font& font = fontToUse(lineStyle, renderer());
BufferForAppendingHyphen charactersWithHyphen; BufferForAppendingHyphen charactersWithHyphen;
bool respectHyphen = ePos == m_len && hasHyphen(); bool respectHyphen = ePos == m_len && hasHyphen();
TextRun textRun = constructTextRun(&lineStyle, font, respectHyphen ? &charactersWithHyphen : 0); TextRun textRun = constructTextRun(lineStyle, font, respectHyphen ? &charactersWithHyphen : 0);
if (respectHyphen) if (respectHyphen)
endPos = textRun.length(); endPos = textRun.length();
...@@ -485,13 +485,13 @@ static void paintTextWithShadows(GraphicsContext* context, const Font& font, con ...@@ -485,13 +485,13 @@ static void paintTextWithShadows(GraphicsContext* context, const Font& font, con
} while (shadow || stroked || !opaque); } 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. // 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; return false;
emphasisPosition = style->textEmphasisPosition(); emphasisPosition = style.textEmphasisPosition();
if (emphasisPosition == TextEmphasisPositionUnder) if (emphasisPosition == TextEmphasisPositionUnder)
return true; // Ruby text is always over, so it cannot suppress emphasis marks under. 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, ...@@ -564,7 +564,7 @@ void InlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset,
GraphicsContext* context = paintInfo.context; GraphicsContext* context = paintInfo.context;
RenderStyle& lineStyle = this->lineStyle(); const RenderStyle& lineStyle = this->lineStyle();
adjustedPaintOffset.move(0, lineStyle.isHorizontalWritingMode() ? 0 : -logicalHeight()); adjustedPaintOffset.move(0, lineStyle.isHorizontalWritingMode() ? 0 : -logicalHeight());
...@@ -687,14 +687,14 @@ void InlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, ...@@ -687,14 +687,14 @@ void InlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset,
#endif #endif
if (containsComposition && !useCustomUnderlines) if (containsComposition && !useCustomUnderlines)
paintCompositionBackground(context, boxOrigin, &lineStyle, font, paintCompositionBackground(context, boxOrigin, lineStyle, font,
renderer().frame().editor().compositionStart(), renderer().frame().editor().compositionStart(),
renderer().frame().editor().compositionEnd()); renderer().frame().editor().compositionEnd());
paintDocumentMarkers(context, boxOrigin, &lineStyle, font, true); paintDocumentMarkers(context, boxOrigin, lineStyle, font, true);
if (haveSelection && !useCustomUnderlines) if (haveSelection && !useCustomUnderlines)
paintSelection(context, boxOrigin, &lineStyle, font, selectionFillColor); paintSelection(context, boxOrigin, lineStyle, font, selectionFillColor);
} }
if (Page* page = renderer().frame().page()) { if (Page* page = renderer().frame().page()) {
...@@ -723,7 +723,7 @@ void InlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, ...@@ -723,7 +723,7 @@ void InlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset,
} }
BufferForAppendingHyphen charactersWithHyphen; BufferForAppendingHyphen charactersWithHyphen;
TextRun textRun = constructTextRun(&lineStyle, font, string, maximumLength, hasHyphen() ? &charactersWithHyphen : 0); TextRun textRun = constructTextRun(lineStyle, font, string, maximumLength, hasHyphen() ? &charactersWithHyphen : 0);
if (hasHyphen()) if (hasHyphen())
length = textRun.length(); length = textRun.length();
...@@ -740,7 +740,7 @@ void InlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, ...@@ -740,7 +740,7 @@ void InlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset,
int emphasisMarkOffset = 0; int emphasisMarkOffset = 0;
TextEmphasisPosition emphasisMarkPosition; TextEmphasisPosition emphasisMarkPosition;
bool hasTextEmphasis = getEmphasisMarkPosition(&lineStyle, emphasisMarkPosition); bool hasTextEmphasis = getEmphasisMarkPosition(lineStyle, emphasisMarkPosition);
const AtomicString& emphasisMark = hasTextEmphasis ? lineStyle.textEmphasisMarkString() : nullAtom; const AtomicString& emphasisMark = hasTextEmphasis ? lineStyle.textEmphasisMarkString() : nullAtom;
if (!emphasisMark.isEmpty()) if (!emphasisMark.isEmpty())
emphasisMarkOffset = emphasisMarkPosition == TextEmphasisPositionOver ? -font.fontMetrics().ascent() - font.emphasisMarkDescent(emphasisMark) : font.fontMetrics().descent() + font.emphasisMarkAscent(emphasisMark); 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, ...@@ -811,7 +811,7 @@ void InlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset,
} }
if (paintInfo.phase == PaintPhaseForeground) { if (paintInfo.phase == PaintPhaseForeground) {
paintDocumentMarkers(context, boxOrigin, &lineStyle, font, false); paintDocumentMarkers(context, boxOrigin, lineStyle, font, false);
if (useCustomUnderlines) { if (useCustomUnderlines) {
const Vector<CompositionUnderline>& underlines = renderer().frame().editor().customCompositionUnderlines(); const Vector<CompositionUnderline>& underlines = renderer().frame().editor().customCompositionUnderlines();
...@@ -868,7 +868,7 @@ void alignSelectionRectToDevicePixels(FloatRect& rect) ...@@ -868,7 +868,7 @@ void alignSelectionRectToDevicePixels(FloatRect& rect)
rect.setWidth(roundf(maxX - rect.x())); 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()) if (context->paintingDisabled())
return; return;
...@@ -889,7 +889,7 @@ void InlineTextBox::paintSelection(GraphicsContext* context, const FloatPoint& b ...@@ -889,7 +889,7 @@ void InlineTextBox::paintSelection(GraphicsContext* context, const FloatPoint& b
c = Color(0xff - c.red(), 0xff - c.green(), 0xff - c.blue()); c = Color(0xff - c.red(), 0xff - c.green(), 0xff - c.blue());
GraphicsContextStateSaver stateSaver(*context); 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 // If the text is truncated, let the thing being painted in the truncation
// draw its own highlight. // draw its own highlight.
...@@ -920,10 +920,10 @@ void InlineTextBox::paintSelection(GraphicsContext* context, const FloatPoint& b ...@@ -920,10 +920,10 @@ void InlineTextBox::paintSelection(GraphicsContext* context, const FloatPoint& b
context->clip(clipRect); 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 offset = m_start;
int sPos = max(startPos - offset, 0); int sPos = max(startPos - offset, 0);
...@@ -936,12 +936,12 @@ void InlineTextBox::paintCompositionBackground(GraphicsContext* context, const F ...@@ -936,12 +936,12 @@ void InlineTextBox::paintCompositionBackground(GraphicsContext* context, const F