Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1015)

Unified Diff: third_party/WebKit/Source/core/paint/InlineTextBoxPainter.cpp

Issue 1468913002: Find In Page hides the text when text color matches text search hightlight color. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updating test case expectations Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/paint/InlineTextBoxPainter.cpp
diff --git a/third_party/WebKit/Source/core/paint/InlineTextBoxPainter.cpp b/third_party/WebKit/Source/core/paint/InlineTextBoxPainter.cpp
index 8b6925bc2d5d9971948b5becc75219e255cde858..f4503ce2d7f57f54d2adc6698d33433566d311cc 100644
--- a/third_party/WebKit/Source/core/paint/InlineTextBoxPainter.cpp
+++ b/third_party/WebKit/Source/core/paint/InlineTextBoxPainter.cpp
@@ -156,7 +156,7 @@ void InlineTextBoxPainter::paint(const PaintInfo& paintInfo, const LayoutPoint&
// 1. Paint backgrounds behind text if needed. Examples of such backgrounds include selection
// and composition highlights.
if (paintInfo.phase != PaintPhaseSelection && paintInfo.phase != PaintPhaseTextClip && !isPrinting) {
- paintDocumentMarkers(context, boxOrigin, styleToUse, font, true);
+ paintDocumentMarkers(paintInfo, boxOrigin, styleToUse, font, true);
if (haveSelection && !paintsCompositionMarkers(textBoxLayoutObject)) {
if (combinedText)
@@ -243,7 +243,7 @@ void InlineTextBoxPainter::paint(const PaintInfo& paintInfo, const LayoutPoint&
}
if (paintInfo.phase == PaintPhaseForeground)
- paintDocumentMarkers(context, boxOrigin, styleToUse, font, false);
+ paintDocumentMarkers(paintInfo, boxOrigin, styleToUse, font, false);
if (shouldRotate)
context->concatCTM(TextPainter::rotation(boxRect, TextPainter::Counterclockwise));
@@ -298,7 +298,7 @@ void InlineTextBoxPainter::paintSingleCompositionBackgroundRun(GraphicsContext*
context->drawHighlightForText(font, m_inlineTextBox.constructTextRun(style, font), localOrigin, selHeight, backgroundColor, sPos, ePos);
}
-void InlineTextBoxPainter::paintDocumentMarkers(GraphicsContext* pt, const LayoutPoint& boxOrigin, const ComputedStyle& style, const Font& font, bool background)
+void InlineTextBoxPainter::paintDocumentMarkers(const PaintInfo& paintInfo, const LayoutPoint& boxOrigin, const ComputedStyle& style, const Font& font, bool background)
{
if (!m_inlineTextBox.lineLayoutItem().node())
return;
@@ -319,8 +319,6 @@ void InlineTextBoxPainter::paintDocumentMarkers(GraphicsContext* pt, const Layou
continue;
break;
case DocumentMarker::TextMatch:
- if (!background)
- continue;
break;
case DocumentMarker::Composition:
break;
@@ -341,21 +339,24 @@ void InlineTextBoxPainter::paintDocumentMarkers(GraphicsContext* pt, const Layou
// marker intersects this run. Paint it.
switch (marker->type()) {
case DocumentMarker::Spelling:
- m_inlineTextBox.paintDocumentMarker(pt, boxOrigin, marker, style, font, false);
+ m_inlineTextBox.paintDocumentMarker(paintInfo.context, boxOrigin, marker, style, font, false);
break;
case DocumentMarker::Grammar:
- m_inlineTextBox.paintDocumentMarker(pt, boxOrigin, marker, style, font, true);
+ m_inlineTextBox.paintDocumentMarker(paintInfo.context, boxOrigin, marker, style, font, true);
break;
case DocumentMarker::TextMatch:
- m_inlineTextBox.paintTextMatchMarker(pt, boxOrigin, marker, style, font);
+ if (background)
+ m_inlineTextBox.paintTextMatchMarkerBackground(paintInfo, boxOrigin, marker, style, font);
+ else
+ m_inlineTextBox.paintTextMatchMarkerForeground(paintInfo, boxOrigin, marker, style, font);
break;
case DocumentMarker::Composition:
{
CompositionUnderline underline(marker->startOffset(), marker->endOffset(), marker->underlineColor(), marker->thick(), marker->backgroundColor());
if (background)
- paintSingleCompositionBackgroundRun(pt, boxOrigin, style, font, underline.backgroundColor, underlinePaintStart(underline), underlinePaintEnd(underline));
+ paintSingleCompositionBackgroundRun(paintInfo.context, boxOrigin, style, font, underline.backgroundColor, underlinePaintStart(underline), underlinePaintEnd(underline));
else
- paintCompositionUnderline(pt, boxOrigin, underline);
+ paintCompositionUnderline(paintInfo.context, boxOrigin, underline);
}
break;
default:
@@ -830,7 +831,33 @@ void InlineTextBoxPainter::paintCompositionUnderline(GraphicsContext* ctx, const
ctx->drawLineForText(FloatPoint(boxOrigin.x() + start, (boxOrigin.y() + m_inlineTextBox.logicalHeight() - lineThickness).toFloat()), width, m_inlineTextBox.lineLayoutItem().document().printing());
}
-void InlineTextBoxPainter::paintTextMatchMarker(GraphicsContext* pt, const LayoutPoint& boxOrigin, DocumentMarker* marker, const ComputedStyle& style, const Font& font)
+void InlineTextBoxPainter::paintTextMatchMarkerForeground(const PaintInfo& paintInfo, const LayoutPoint& boxOrigin, DocumentMarker* marker, const ComputedStyle& style, const Font& font)
+{
+ int sPos = std::max(marker->startOffset() - m_inlineTextBox.start(), (unsigned)0);
pdr. 2015/12/14 22:53:26 I'm okay with doing this as a followup, but lets a
ramya.v 2015/12/15 06:12:23 Done.
+ int ePos = std::min(marker->endOffset() - m_inlineTextBox.start(), m_inlineTextBox.len());
+ TextRun run = m_inlineTextBox.constructTextRun(style, font);
+
+ if (LineLayoutPaintShim::layoutObjectFrom(m_inlineTextBox.lineLayoutItem())->frame()->editor().markedTextMatchesAreHighlighted()) {
pdr. 2015/12/14 22:53:26 Lets move this up (here, and in paintTextMatchMark
ramya.v 2015/12/15 06:12:23 Done.
+ Color textColor = marker->activeMatch() ?
+ LayoutTheme::theme().platformTextSearchColor(true) :
+ LayoutTheme::theme().platformTextSearchColor(false);
+ if (style.visitedDependentColor(CSSPropertyColor) == textColor)
+ return;
+ TextPainter::Style textStyle;
+ // When we use the text as a clip, we only care about the alpha, thus we make all the colors black.
+ textStyle.currentColor = textStyle.fillColor = textStyle.strokeColor = textStyle.emphasisMarkColor = textColor;
+ textStyle.strokeWidth = style.textStrokeWidth();
+ textStyle.shadow = 0;
+
+ LayoutRect boxRect(boxOrigin, LayoutSize(m_inlineTextBox.logicalWidth(), m_inlineTextBox.logicalHeight()));
+ LayoutPoint textOrigin(boxOrigin.x(), boxOrigin.y() + font.fontMetrics().ascent());
+ TextPainter textPainter(paintInfo.context, font, run, textOrigin, boxRect, m_inlineTextBox.isHorizontal());
+
+ textPainter.paint(sPos, ePos, m_inlineTextBox.len(), textStyle, 0);
+ }
+}
+
+void InlineTextBoxPainter::paintTextMatchMarkerBackground(const PaintInfo& paintInfo, const LayoutPoint& boxOrigin, DocumentMarker* marker, const ComputedStyle& 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.
@@ -841,32 +868,15 @@ void InlineTextBoxPainter::paintTextMatchMarker(GraphicsContext* pt, const Layou
int ePos = std::min(marker->endOffset() - m_inlineTextBox.start(), m_inlineTextBox.len());
TextRun run = m_inlineTextBox.constructTextRun(style, font);
- // Optionally highlight the text
if (LineLayoutPaintShim::layoutObjectFrom(m_inlineTextBox.lineLayoutItem())->frame()->editor().markedTextMatchesAreHighlighted()) {
Color color = marker->activeMatch() ?
- LayoutTheme::theme().platformActiveTextSearchHighlightColor() :
- LayoutTheme::theme().platformInactiveTextSearchHighlightColor();
+ LayoutTheme::theme().platformTextSearchHighlightColor(true) :
+ LayoutTheme::theme().platformTextSearchHighlightColor(false);
+ GraphicsContext* pt = paintInfo.context;
GraphicsContextStateSaver stateSaver(*pt);
pt->clip(FloatRect(boxOrigin.x().toFloat(), (boxOrigin.y() - deltaY).toFloat(), m_inlineTextBox.logicalWidth().toFloat(), selHeight));
pt->drawHighlightForText(font, run, FloatPoint(boxOrigin.x().toFloat(), (boxOrigin.y() - deltaY).toFloat()), selHeight, color, sPos, ePos);
-
- // Also Highlight the text with color:transparent
- if (style.visitedDependentColor(CSSPropertyColor) == Color::transparent) {
- int length = m_inlineTextBox.len();
- TextPainter::Style textStyle;
- // When we use the text as a clip, we only care about the alpha, thus we make all the colors black.
- textStyle.currentColor = textStyle.fillColor = textStyle.strokeColor = textStyle.emphasisMarkColor = Color::black;
- textStyle.strokeWidth = style.textStrokeWidth();
- textStyle.shadow = 0;
-
- LayoutRect boxRect(boxOrigin, LayoutSize(m_inlineTextBox.logicalWidth(), m_inlineTextBox.logicalHeight()));
- LayoutPoint textOrigin(boxOrigin.x(), boxOrigin.y() + font.fontMetrics().ascent());
- TextPainter textPainter(pt, font, run, textOrigin, boxRect, m_inlineTextBox.isHorizontal());
-
- textPainter.paint(sPos, ePos, length, textStyle, 0);
- }
}
}
-
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698