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

Side by Side Diff: Source/core/paint/InlineTextBoxPainter.cpp

Issue 1220733012: Display transparent text when it's being searched and selected. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 5 months 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 unified diff | Download patch
« no previous file with comments | « Source/core/paint/InlineTextBoxPainter.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/paint/InlineTextBoxPainter.h" 6 #include "core/paint/InlineTextBoxPainter.h"
7 7
8 #include "core/dom/DocumentMarkerController.h" 8 #include "core/dom/DocumentMarkerController.h"
9 #include "core/dom/RenderedDocumentMarker.h" 9 #include "core/dom/RenderedDocumentMarker.h"
10 #include "core/editing/CompositionUnderline.h" 10 #include "core/editing/CompositionUnderline.h"
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 } 211 }
212 212
213 // FIXME: This cache should probably ultimately be held somewhere else. 213 // FIXME: This cache should probably ultimately be held somewhere else.
214 // A hashmap is convenient to avoid a memory hit when the 214 // A hashmap is convenient to avoid a memory hit when the
215 // RuntimeEnabledFeature is off. 215 // RuntimeEnabledFeature is off.
216 bool textBlobIsCacheable = RuntimeEnabledFeatures::textBlobEnabled() && startOffset == 0 && endOffset == length; 216 bool textBlobIsCacheable = RuntimeEnabledFeatures::textBlobEnabled() && startOffset == 0 && endOffset == length;
217 TextBlobPtr* cachedTextBlob = 0; 217 TextBlobPtr* cachedTextBlob = 0;
218 if (textBlobIsCacheable) 218 if (textBlobIsCacheable)
219 cachedTextBlob = addToTextBlobCache(m_inlineTextBox); 219 cachedTextBlob = addToTextBlobCache(m_inlineTextBox);
220 textPainter.paint(startOffset, endOffset, length, textStyle, cachedTextB lob); 220 textPainter.paint(startOffset, endOffset, length, textStyle, cachedTextB lob);
221
222 // Paint the text with color:transparent here in Find In Page Scenario.
223 if (styleToUse.visitedDependentColor(CSSPropertyColor) == Color::transpa rent)
224 paintTextMatchMarkerText(textPainter, length, styleToUse);
221 } 225 }
222 226
223 if ((paintSelectedTextOnly || paintSelectedTextSeparately) && selectionStart < selectionEnd) { 227 if ((paintSelectedTextOnly || paintSelectedTextSeparately) && selectionStart < selectionEnd) {
224 // paint only the text that is selected 228 // paint only the text that is selected
225 bool textBlobIsCacheable = RuntimeEnabledFeatures::textBlobEnabled() && selectionStart == 0 && selectionEnd == length; 229 bool textBlobIsCacheable = RuntimeEnabledFeatures::textBlobEnabled() && selectionStart == 0 && selectionEnd == length;
226 TextBlobPtr* cachedTextBlob = 0; 230 TextBlobPtr* cachedTextBlob = 0;
227 if (textBlobIsCacheable) 231 if (textBlobIsCacheable)
228 cachedTextBlob = addToTextBlobCache(m_inlineTextBox); 232 cachedTextBlob = addToTextBlobCache(m_inlineTextBox);
229 textPainter.paint(selectionStart, selectionEnd, length, selectionStyle, cachedTextBlob); 233 textPainter.paint(selectionStart, selectionEnd, length, selectionStyle, cachedTextBlob);
230 } 234 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 int ePos = std::min(endPos - static_cast<int>(m_inlineTextBox.start()), stat ic_cast<int>(m_inlineTextBox.len())); 302 int ePos = std::min(endPos - static_cast<int>(m_inlineTextBox.start()), stat ic_cast<int>(m_inlineTextBox.len()));
299 if (sPos >= ePos) 303 if (sPos >= ePos)
300 return; 304 return;
301 305
302 int deltaY = m_inlineTextBox.layoutObject().style()->isFlippedLinesWritingMo de() ? m_inlineTextBox.root().selectionBottom() - m_inlineTextBox.logicalBottom( ) : m_inlineTextBox.logicalTop() - m_inlineTextBox.root().selectionTop(); 306 int deltaY = m_inlineTextBox.layoutObject().style()->isFlippedLinesWritingMo de() ? m_inlineTextBox.root().selectionBottom() - m_inlineTextBox.logicalBottom( ) : m_inlineTextBox.logicalTop() - m_inlineTextBox.root().selectionTop();
303 int selHeight = m_inlineTextBox.root().selectionHeight(); 307 int selHeight = m_inlineTextBox.root().selectionHeight();
304 FloatPoint localOrigin(boxOrigin.x().toFloat(), boxOrigin.y().toFloat() - de ltaY); 308 FloatPoint localOrigin(boxOrigin.x().toFloat(), boxOrigin.y().toFloat() - de ltaY);
305 context->drawHighlightForText(font, m_inlineTextBox.constructTextRun(style, font), localOrigin, selHeight, backgroundColor, sPos, ePos); 309 context->drawHighlightForText(font, m_inlineTextBox.constructTextRun(style, font), localOrigin, selHeight, backgroundColor, sPos, ePos);
306 } 310 }
307 311
312 void InlineTextBoxPainter::paintTextMatchMarkerText(TextPainter textPainter, in t length, const ComputedStyle& style)
pdr. 2015/07/06 22:09:16 extra spaces around int length
Sk.kumar 2015/07/07 12:45:02 Done.
313 {
314 if (!m_inlineTextBox.layoutObject().node())
315 return;
316
317 TextPainter::Style textStyle = TextPainter::textPaintingStyle(m_inlineTextBo x.layoutObject(), style, true, false);
pdr. 2015/07/06 22:09:16 We shouldn't add all of this code. Can you modify
Sk.kumar 2015/07/07 12:45:02 This is being done to maintain the flow of Paint.
318 DocumentMarkerVector markers = m_inlineTextBox.layoutObject().document().mar kers().markersFor(m_inlineTextBox.layoutObject().node());
319 DocumentMarkerVector::const_iterator markerIt = markers.begin();
320 for ( ; markerIt != markers.end(); ++markerIt) {
321 DocumentMarker* marker = *markerIt;
322 if (marker->type() == DocumentMarker::TextMatch) {
323 int sPos = std::max(marker->startOffset() - m_inlineTextBox.start(), (unsigned)0);
324 int ePos = std::min(marker->endOffset() - m_inlineTextBox.start(), m _inlineTextBox.len());
325 textPainter.paint(sPos, ePos, length, textStyle, 0);
326 }
327 }
328 }
329
308 void InlineTextBoxPainter::paintDocumentMarkers(GraphicsContext* pt, const Layou tPoint& boxOrigin, const ComputedStyle& style, const Font& font, bool background ) 330 void InlineTextBoxPainter::paintDocumentMarkers(GraphicsContext* pt, const Layou tPoint& boxOrigin, const ComputedStyle& style, const Font& font, bool background )
309 { 331 {
310 if (!m_inlineTextBox.layoutObject().node()) 332 if (!m_inlineTextBox.layoutObject().node())
311 return; 333 return;
312 334
313 DocumentMarkerVector markers = m_inlineTextBox.layoutObject().document().mar kers().markersFor(m_inlineTextBox.layoutObject().node()); 335 DocumentMarkerVector markers = m_inlineTextBox.layoutObject().document().mar kers().markersFor(m_inlineTextBox.layoutObject().node());
314 DocumentMarkerVector::const_iterator markerIt = markers.begin(); 336 DocumentMarkerVector::const_iterator markerIt = markers.begin();
315 337
316 // Give any document markers that touch this run a chance to draw before the text has been drawn. 338 // Give any document markers that touch this run a chance to draw before the text has been drawn.
317 // Note end() points at the last char, not one past it like endOffset and ra nges do. 339 // Note end() points at the last char, not one past it like endOffset and ra nges do.
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 LayoutTheme::theme().platformActiveTextSearchHighlightColor() : 833 LayoutTheme::theme().platformActiveTextSearchHighlightColor() :
812 LayoutTheme::theme().platformInactiveTextSearchHighlightColor(); 834 LayoutTheme::theme().platformInactiveTextSearchHighlightColor();
813 GraphicsContextStateSaver stateSaver(*pt); 835 GraphicsContextStateSaver stateSaver(*pt);
814 pt->clip(FloatRect(boxOrigin.x().toFloat(), (boxOrigin.y() - deltaY).toF loat(), m_inlineTextBox.logicalWidth().toFloat(), selHeight)); 836 pt->clip(FloatRect(boxOrigin.x().toFloat(), (boxOrigin.y() - deltaY).toF loat(), m_inlineTextBox.logicalWidth().toFloat(), selHeight));
815 pt->drawHighlightForText(font, run, FloatPoint(boxOrigin.x().toFloat(), (boxOrigin.y() - deltaY).toFloat()), selHeight, color, sPos, ePos); 837 pt->drawHighlightForText(font, run, FloatPoint(boxOrigin.x().toFloat(), (boxOrigin.y() - deltaY).toFloat()), selHeight, color, sPos, ePos);
816 } 838 }
817 } 839 }
818 840
819 841
820 } // namespace blink 842 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/paint/InlineTextBoxPainter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698