Chromium Code Reviews| Index: third_party/WebKit/Source/core/paint/SVGInlineTextBoxPainter.cpp |
| diff --git a/third_party/WebKit/Source/core/paint/SVGInlineTextBoxPainter.cpp b/third_party/WebKit/Source/core/paint/SVGInlineTextBoxPainter.cpp |
| index 3d41ee68dc537f3bc3e81372e612ec478cebeee8..4fb79a9accf7ac902c64cb53eef4879fffc0ebc1 100644 |
| --- a/third_party/WebKit/Source/core/paint/SVGInlineTextBoxPainter.cpp |
| +++ b/third_party/WebKit/Source/core/paint/SVGInlineTextBoxPainter.cpp |
| @@ -64,12 +64,17 @@ void SVGInlineTextBoxPainter::paint(const PaintInfo& paintInfo, const LayoutPoin |
| // TODO(chrishtr): passing the cull rect is incorrect. |
| DrawingRecorder recorder(*paintInfo.context, m_svgInlineTextBox, displayItemType, FloatRect(paintInfo.cullRect().m_rect)); |
| + |
| InlineTextBoxPainter(m_svgInlineTextBox).paintDocumentMarkers( |
| - paintInfo.context, paintOffset, style, |
| + paintInfo, paintOffset, style, |
| textLayoutObject.scaledFont(), true); |
| if (!m_svgInlineTextBox.textFragments().isEmpty()) |
| paintTextFragments(paintInfo, parentLayoutObject); |
| + |
| + InlineTextBoxPainter(m_svgInlineTextBox).paintDocumentMarkers( |
| + paintInfo, paintOffset, style, |
| + textLayoutObject.scaledFont(), false); |
| } |
| } |
| @@ -401,7 +406,59 @@ void SVGInlineTextBoxPainter::paintText(const PaintInfo& paintInfo, const Comput |
| paintTextWithShadows(paintInfo, style, textRun, fragment, endPosition, fragment.length, resourceMode); |
| } |
| -void SVGInlineTextBoxPainter::paintTextMatchMarker(GraphicsContext* context, const LayoutPoint&, DocumentMarker* marker, const ComputedStyle& style, const Font& font) |
| +void SVGInlineTextBoxPainter::paintTextMatchMarkerForeground(const PaintInfo& paintInfo, const LayoutPoint& point, DocumentMarker* marker, const ComputedStyle& style, const Font& font) |
| +{ |
| + // SVG is only interested in the TextMatch markers. |
|
pdr.
2015/12/14 22:53:26
This comment only says what the if statement below
ramya.v
2015/12/15 06:12:23
Done.
|
| + if (marker->type() != DocumentMarker::TextMatch) |
| + return; |
| + |
| + LayoutSVGInlineText& textLayoutObject = toLayoutSVGInlineText(*LineLayoutPaintShim::layoutObjectFrom(m_svgInlineTextBox.lineLayoutItem())); |
| + |
| + for (InlineTextBox* box = textLayoutObject.firstTextBox(); box; box = box->nextTextBox()) { |
|
pdr.
2015/12/14 22:53:26
This code is too much copy & paste from SVGInlineT
ramya.v
2015/12/15 06:12:23
Done.
|
| + if (!box->isSVGInlineTextBox()) |
| + continue; |
| + |
| + SVGInlineTextBox* textBox = toSVGInlineTextBox(box); |
| + |
| + int markerStartPosition = std::max<int>(marker->startOffset() - textBox->start(), 0); |
| + int markerEndPosition = std::min<int>(marker->endOffset() - textBox->start(), textBox->len()); |
| + |
| + if (markerStartPosition >= markerEndPosition) |
| + continue; |
| + |
| + const Vector<SVGTextFragment>& fragments = textBox->textFragments(); |
| + unsigned textFragmentsSize = fragments.size(); |
| + AffineTransform fragmentTransform; |
| + for (unsigned i = 0; i < textFragmentsSize; ++i) { |
| + const SVGTextFragment& fragment = fragments.at(i); |
| + |
| + int fragmentStartPosition = markerStartPosition; |
| + int fragmentEndPosition = markerEndPosition; |
| + if (!textBox->mapStartEndPositionsIntoFragmentCoordinates(fragment, fragmentStartPosition, fragmentEndPosition)) |
| + continue; |
| + |
| + if (LineLayoutPaintShim::layoutObjectFrom(m_svgInlineTextBox.lineLayoutItem())->frame()->editor().markedTextMatchesAreHighlighted()) { |
| + Color textColor = marker->activeMatch() ? |
| + LayoutTheme::theme().platformTextSearchColor(true) : |
| + LayoutTheme::theme().platformTextSearchColor(false); |
| + |
| + GraphicsContextStateSaver stateSaver(*paintInfo.context, false); |
| + fragment.buildFragmentTransform(fragmentTransform); |
| + if (!fragmentTransform.isIdentity()) { |
| + stateSaver.save(); |
| + paintInfo.context->concatCTM(fragmentTransform); |
| + } |
| + |
| + RefPtr<ComputedStyle> markerStyle = ComputedStyle::clone(style); |
| + markerStyle->setFillPaintColor(textColor); |
|
pdr.
2015/12/14 22:53:26
ComputedStyle is too big to be copying here. Can y
ramya.v
2015/12/15 06:12:23
I tried plumbing color through GraphicsContext usi
|
| + TextRun textRun = m_svgInlineTextBox.constructTextRun(*markerStyle, fragment); |
| + paintTextWithShadows(paintInfo, *markerStyle, textRun, fragment, fragmentStartPosition, fragmentEndPosition, ApplyToFillMode); |
| + } |
| + } |
| + } |
| +} |
| + |
| +void SVGInlineTextBoxPainter::paintTextMatchMarkerBackground(const PaintInfo& paintInfo, const LayoutPoint& point, DocumentMarker* marker, const ComputedStyle& style, const Font& font) |
| { |
| // SVG is only interested in the TextMatch markers. |
| if (marker->type() != DocumentMarker::TextMatch) |
| @@ -435,14 +492,15 @@ void SVGInlineTextBoxPainter::paintTextMatchMarker(GraphicsContext* context, con |
| FloatRect fragmentRect = textBox->selectionRectForTextFragment(fragment, fragmentStartPosition, fragmentEndPosition, style); |
| fragment.buildFragmentTransform(fragmentTransform); |
| - // Draw the marker highlight. |
| if (LineLayoutPaintShim::layoutObjectFrom(m_svgInlineTextBox.lineLayoutItem())->frame()->editor().markedTextMatchesAreHighlighted()) { |
| - Color color = marker->activeMatch() ? |
| - LayoutTheme::theme().platformActiveTextSearchHighlightColor() : |
| - LayoutTheme::theme().platformInactiveTextSearchHighlightColor(); |
| + GraphicsContext* context = paintInfo.context; |
| GraphicsContextStateSaver stateSaver(*context); |
| if (!fragmentTransform.isIdentity()) |
| context->concatCTM(fragmentTransform); |
| + Color color = marker->activeMatch() ? |
| + LayoutTheme::theme().platformTextSearchHighlightColor(true) : |
| + LayoutTheme::theme().platformTextSearchHighlightColor(false); |
| + |
| context->setFillColor(color); |
| context->fillRect(fragmentRect, color); |
| } |