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

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

Issue 1325563002: Avoid style clobbering in setCompositionFromExistingText. (2nd land) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Delete CompositionUnderlinesRangeFilter (it's now dead code) Created 5 years, 3 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
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/editing/CompositionUnderline.h" 8 #include "core/editing/CompositionUnderline.h"
9 #include "core/editing/CompositionUnderlineRangeFilter.h"
10 #include "core/editing/Editor.h" 9 #include "core/editing/Editor.h"
11 #include "core/editing/InputMethodController.h"
12 #include "core/editing/markers/DocumentMarkerController.h" 10 #include "core/editing/markers/DocumentMarkerController.h"
13 #include "core/editing/markers/RenderedDocumentMarker.h" 11 #include "core/editing/markers/RenderedDocumentMarker.h"
14 #include "core/frame/LocalFrame.h" 12 #include "core/frame/LocalFrame.h"
15 #include "core/layout/LayoutBlock.h" 13 #include "core/layout/LayoutBlock.h"
16 #include "core/layout/LayoutTextCombine.h" 14 #include "core/layout/LayoutTextCombine.h"
17 #include "core/layout/LayoutTheme.h" 15 #include "core/layout/LayoutTheme.h"
18 #include "core/layout/line/InlineTextBox.h" 16 #include "core/layout/line/InlineTextBox.h"
19 #include "core/paint/BoxPainter.h" 17 #include "core/paint/BoxPainter.h"
20 #include "core/paint/PaintInfo.h" 18 #include "core/paint/PaintInfo.h"
21 #include "core/paint/TextPainter.h" 19 #include "core/paint/TextPainter.h"
(...skipping 19 matching lines...) Expand all
41 if (!gTextBlobCache) 39 if (!gTextBlobCache)
42 gTextBlobCache = new InlineTextBoxBlobCacheMap; 40 gTextBlobCache = new InlineTextBoxBlobCacheMap;
43 return &gTextBlobCache->add(&inlineTextBox, nullptr).storedValue->value; 41 return &gTextBlobCache->add(&inlineTextBox, nullptr).storedValue->value;
44 } 42 }
45 43
46 static bool paintsMarkerHighlights(const LayoutObject& layoutObject) 44 static bool paintsMarkerHighlights(const LayoutObject& layoutObject)
47 { 45 {
48 return layoutObject.node() && layoutObject.document().markers().hasMarkers(l ayoutObject.node()); 46 return layoutObject.node() && layoutObject.document().markers().hasMarkers(l ayoutObject.node());
49 } 47 }
50 48
49 static bool paintsCompositionMarkers(const LayoutObject& layoutObject)
50 {
51 return layoutObject.node() && layoutObject.document().markers().markersFor(l ayoutObject.node(), DocumentMarker::Composition).size() > 0;
52 }
53
51 void InlineTextBoxPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffset) 54 void InlineTextBoxPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffset)
52 { 55 {
53 if (m_inlineTextBox.isLineBreak() || !paintInfo.shouldPaintWithinRoot(&m_inl ineTextBox.layoutObject()) || m_inlineTextBox.layoutObject().style()->visibility () != VISIBLE 56 if (m_inlineTextBox.isLineBreak() || !paintInfo.shouldPaintWithinRoot(&m_inl ineTextBox.layoutObject()) || m_inlineTextBox.layoutObject().style()->visibility () != VISIBLE
54 || m_inlineTextBox.truncation() == cFullTruncation || paintInfo.phase == PaintPhaseOutline || !m_inlineTextBox.len()) 57 || m_inlineTextBox.truncation() == cFullTruncation || paintInfo.phase == PaintPhaseOutline || !m_inlineTextBox.len())
55 return; 58 return;
56 59
57 ASSERT(paintInfo.phase != PaintPhaseSelfOutline && paintInfo.phase != PaintP haseChildOutlines); 60 ASSERT(paintInfo.phase != PaintPhaseSelfOutline && paintInfo.phase != PaintP haseChildOutlines);
58 61
59 LayoutRect logicalVisualOverflow = m_inlineTextBox.logicalOverflowRect(); 62 LayoutRect logicalVisualOverflow = m_inlineTextBox.logicalOverflowRect();
60 LayoutUnit logicalStart = logicalVisualOverflow.x() + (m_inlineTextBox.isHor izontal() ? paintOffset.x() : paintOffset.y()); 63 LayoutUnit logicalStart = logicalVisualOverflow.x() + (m_inlineTextBox.isHor izontal() ? paintOffset.x() : paintOffset.y());
(...skipping 10 matching lines...) Expand all
71 74
72 bool isPrinting = paintInfo.isPrinting(); 75 bool isPrinting = paintInfo.isPrinting();
73 76
74 // Determine whether or not we're selected. 77 // Determine whether or not we're selected.
75 bool haveSelection = !isPrinting && paintInfo.phase != PaintPhaseTextClip && m_inlineTextBox.selectionState() != SelectionNone; 78 bool haveSelection = !isPrinting && paintInfo.phase != PaintPhaseTextClip && m_inlineTextBox.selectionState() != SelectionNone;
76 if (!haveSelection && paintInfo.phase == PaintPhaseSelection) { 79 if (!haveSelection && paintInfo.phase == PaintPhaseSelection) {
77 // When only painting the selection, don't bother to paint if there is n one. 80 // When only painting the selection, don't bother to paint if there is n one.
78 return; 81 return;
79 } 82 }
80 83
81 // Determine whether or not we have composition underlines to draw.
82 bool containsComposition = m_inlineTextBox.layoutObject().node() && m_inline TextBox.layoutObject().frame()->inputMethodController().compositionNode() == m_i nlineTextBox.layoutObject().node();
83 bool useCustomUnderlines = containsComposition && m_inlineTextBox.layoutObje ct().frame()->inputMethodController().compositionUsesCustomUnderlines();
84
85 // The text clip phase already has a DrawingRecorder. Text clips are initiat ed only in BoxPainter::paintLayerExtended, which is already 84 // The text clip phase already has a DrawingRecorder. Text clips are initiat ed only in BoxPainter::paintLayerExtended, which is already
86 // within a DrawingRecorder. 85 // within a DrawingRecorder.
87 Optional<DrawingRecorder> drawingRecorder; 86 Optional<DrawingRecorder> drawingRecorder;
88 if (RuntimeEnabledFeatures::slimmingPaintEnabled() && paintInfo.phase != Pai ntPhaseTextClip) { 87 if (RuntimeEnabledFeatures::slimmingPaintEnabled() && paintInfo.phase != Pai ntPhaseTextClip) {
89 if (DrawingRecorder::useCachedDrawingIfPossible(*paintInfo.context, m_in lineTextBox, DisplayItem::paintPhaseToDrawingType(paintInfo.phase))) 88 if (DrawingRecorder::useCachedDrawingIfPossible(*paintInfo.context, m_in lineTextBox, DisplayItem::paintPhaseToDrawingType(paintInfo.phase)))
90 return; 89 return;
91 LayoutRect paintRect(logicalVisualOverflow); 90 LayoutRect paintRect(logicalVisualOverflow);
92 m_inlineTextBox.logicalRectToPhysicalRect(paintRect); 91 m_inlineTextBox.logicalRectToPhysicalRect(paintRect);
93 if (paintInfo.phase != PaintPhaseSelection && (haveSelection || contains Composition || paintsMarkerHighlights(m_inlineTextBox.layoutObject()))) 92 if (paintInfo.phase != PaintPhaseSelection && (haveSelection || paintsMa rkerHighlights(m_inlineTextBox.layoutObject())))
94 paintRect.unite(m_inlineTextBox.localSelectionRect(m_inlineTextBox.s tart(), m_inlineTextBox.start() + m_inlineTextBox.len())); 93 paintRect.unite(m_inlineTextBox.localSelectionRect(m_inlineTextBox.s tart(), m_inlineTextBox.start() + m_inlineTextBox.len()));
95 paintRect.moveBy(adjustedPaintOffset); 94 paintRect.moveBy(adjustedPaintOffset);
96 drawingRecorder.emplace(*paintInfo.context, m_inlineTextBox, DisplayItem ::paintPhaseToDrawingType(paintInfo.phase), FloatRect(paintRect)); 95 drawingRecorder.emplace(*paintInfo.context, m_inlineTextBox, DisplayItem ::paintPhaseToDrawingType(paintInfo.phase), FloatRect(paintRect));
97 } 96 }
98 97
99 if (m_inlineTextBox.truncation() != cNoTruncation) { 98 if (m_inlineTextBox.truncation() != cNoTruncation) {
100 if (m_inlineTextBox.layoutObject().containingBlock()->style()->isLeftToR ightDirection() != m_inlineTextBox.isLeftToRightDirection()) { 99 if (m_inlineTextBox.layoutObject().containingBlock()->style()->isLeftToR ightDirection() != m_inlineTextBox.isLeftToRightDirection()) {
101 // Make the visible fragment of text hug the edge closest to the res t of the run by moving the origin 100 // Make the visible fragment of text hug the edge closest to the res t of the run by moving the origin
102 // at which we start drawing text. 101 // at which we start drawing text.
103 // e.g. In the case of LTR text truncated in an RTL Context, the cor rect behavior is: 102 // e.g. In the case of LTR text truncated in an RTL Context, the cor rect behavior is:
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 bool paintSelectedTextSeparately = !paintSelectedTextOnly && textStyle != se lectionStyle; 144 bool paintSelectedTextSeparately = !paintSelectedTextOnly && textStyle != se lectionStyle;
146 145
147 // Set our font. 146 // Set our font.
148 const Font& font = styleToUse.font(); 147 const Font& font = styleToUse.font();
149 148
150 LayoutPoint textOrigin(boxOrigin.x(), boxOrigin.y() + font.fontMetrics().asc ent()); 149 LayoutPoint textOrigin(boxOrigin.x(), boxOrigin.y() + font.fontMetrics().asc ent());
151 150
152 // 1. Paint backgrounds behind text if needed. Examples of such backgrounds include selection 151 // 1. Paint backgrounds behind text if needed. Examples of such backgrounds include selection
153 // and composition highlights. 152 // and composition highlights.
154 if (paintInfo.phase != PaintPhaseSelection && paintInfo.phase != PaintPhaseT extClip && !isPrinting) { 153 if (paintInfo.phase != PaintPhaseSelection && paintInfo.phase != PaintPhaseT extClip && !isPrinting) {
155 if (containsComposition) {
156 paintCompositionBackgrounds(context, boxOrigin, styleToUse, font, us eCustomUnderlines);
157 }
158
159 paintDocumentMarkers(context, boxOrigin, styleToUse, font, true); 154 paintDocumentMarkers(context, boxOrigin, styleToUse, font, true);
160 155
161 if (haveSelection && !useCustomUnderlines) { 156 if (haveSelection && !paintsCompositionMarkers(m_inlineTextBox.layoutObj ect())) {
162 if (combinedText) 157 if (combinedText)
163 paintSelection<InlineTextBoxPainter::PaintOptions::CombinedText> (context, boxRect, styleToUse, font, selectionStyle.fillColor, combinedText); 158 paintSelection<InlineTextBoxPainter::PaintOptions::CombinedText> (context, boxRect, styleToUse, font, selectionStyle.fillColor, combinedText);
164 else 159 else
165 paintSelection<InlineTextBoxPainter::PaintOptions::Normal>(conte xt, boxRect, styleToUse, font, selectionStyle.fillColor); 160 paintSelection<InlineTextBoxPainter::PaintOptions::Normal>(conte xt, boxRect, styleToUse, font, selectionStyle.fillColor);
166 } 161 }
167 } 162 }
168 163
169 // 2. Now paint the foreground, including text and decorations like underlin e/overline (in quirks mode only). 164 // 2. Now paint the foreground, including text and decorations like underlin e/overline (in quirks mode only).
170 int length = m_inlineTextBox.len(); 165 int length = m_inlineTextBox.len();
171 StringView string = m_inlineTextBox.layoutObject().text().createView(); 166 StringView string = m_inlineTextBox.layoutObject().text().createView();
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 if (textDecorations != TextDecorationNone && !paintSelectedTextOnly) { 230 if (textDecorations != TextDecorationNone && !paintSelectedTextOnly) {
236 GraphicsContextStateSaver stateSaver(*context, false); 231 GraphicsContextStateSaver stateSaver(*context, false);
237 TextPainter::updateGraphicsContext(context, textStyle, m_inlineTextBox.i sHorizontal(), stateSaver); 232 TextPainter::updateGraphicsContext(context, textStyle, m_inlineTextBox.i sHorizontal(), stateSaver);
238 if (combinedText) 233 if (combinedText)
239 context->concatCTM(TextPainter::rotation(boxRect, TextPainter::Clock wise)); 234 context->concatCTM(TextPainter::rotation(boxRect, TextPainter::Clock wise));
240 paintDecoration(paintInfo, boxOrigin, textDecorations); 235 paintDecoration(paintInfo, boxOrigin, textDecorations);
241 if (combinedText) 236 if (combinedText)
242 context->concatCTM(TextPainter::rotation(boxRect, TextPainter::Count erclockwise)); 237 context->concatCTM(TextPainter::rotation(boxRect, TextPainter::Count erclockwise));
243 } 238 }
244 239
245 if (paintInfo.phase == PaintPhaseForeground) { 240 if (paintInfo.phase == PaintPhaseForeground)
246 paintDocumentMarkers(context, boxOrigin, styleToUse, font, false); 241 paintDocumentMarkers(context, boxOrigin, styleToUse, font, false);
247 242
248 // Paint custom underlines for compositions.
249 if (useCustomUnderlines) {
250 const Vector<CompositionUnderline>& underlines = m_inlineTextBox.lay outObject().frame()->inputMethodController().customCompositionUnderlines();
251 CompositionUnderlineRangeFilter filter(underlines, m_inlineTextBox.s tart(), m_inlineTextBox.end());
252 for (CompositionUnderlineRangeFilter::ConstIterator it = filter.begi n(); it != filter.end(); ++it) {
253 if (it->color == Color::transparent)
254 continue;
255 paintCompositionUnderline(context, boxOrigin, *it);
256 }
257 }
258 }
259
260 if (shouldRotate) 243 if (shouldRotate)
261 context->concatCTM(TextPainter::rotation(boxRect, TextPainter::Countercl ockwise)); 244 context->concatCTM(TextPainter::rotation(boxRect, TextPainter::Countercl ockwise));
262 } 245 }
263 246
264 unsigned InlineTextBoxPainter::underlinePaintStart(const CompositionUnderline& u nderline) 247 unsigned InlineTextBoxPainter::underlinePaintStart(const CompositionUnderline& u nderline)
265 { 248 {
266 return std::max(static_cast<unsigned>(m_inlineTextBox.start()), underline.st artOffset); 249 return std::max(static_cast<unsigned>(m_inlineTextBox.start()), underline.st artOffset);
267 } 250 }
268 251
269 unsigned InlineTextBoxPainter::underlinePaintEnd(const CompositionUnderline& und erline) 252 unsigned InlineTextBoxPainter::underlinePaintEnd(const CompositionUnderline& und erline)
270 { 253 {
271 unsigned paintEnd = std::min(m_inlineTextBox.end() + 1, underline.endOffset) ; // end() points at the last char, not past it. 254 unsigned paintEnd = std::min(m_inlineTextBox.end() + 1, underline.endOffset) ; // end() points at the last char, not past it.
272 if (m_inlineTextBox.truncation() != cNoTruncation) 255 if (m_inlineTextBox.truncation() != cNoTruncation)
273 paintEnd = std::min(paintEnd, static_cast<unsigned>(m_inlineTextBox.star t() + m_inlineTextBox.truncation())); 256 paintEnd = std::min(paintEnd, static_cast<unsigned>(m_inlineTextBox.star t() + m_inlineTextBox.truncation()));
274 return paintEnd; 257 return paintEnd;
275 } 258 }
276 259
277 void InlineTextBoxPainter::paintCompositionBackgrounds(GraphicsContext* pt, cons t LayoutPoint& boxOrigin, const ComputedStyle& style, const Font& font, bool use CustomUnderlines)
278 {
279 if (useCustomUnderlines) {
280 // Paint custom background highlights for compositions.
281 const Vector<CompositionUnderline>& underlines = m_inlineTextBox.layoutO bject().frame()->inputMethodController().customCompositionUnderlines();
282 CompositionUnderlineRangeFilter filter(underlines, m_inlineTextBox.start (), m_inlineTextBox.end());
283 for (CompositionUnderlineRangeFilter::ConstIterator it = filter.begin(); it != filter.end(); ++it) {
284 if (it->backgroundColor == Color::transparent)
285 continue;
286 paintSingleCompositionBackgroundRun(pt, boxOrigin, style, font, it-> backgroundColor, underlinePaintStart(*it), underlinePaintEnd(*it));
287 }
288
289 } else {
290 paintSingleCompositionBackgroundRun(pt, boxOrigin, style, font, LayoutTh eme::theme().platformDefaultCompositionBackgroundColor(),
291 m_inlineTextBox.layoutObject().frame()->inputMethodController().comp ositionStart(),
292 m_inlineTextBox.layoutObject().frame()->inputMethodController().comp ositionEnd());
293 }
294 }
295
296 void InlineTextBoxPainter::paintSingleCompositionBackgroundRun(GraphicsContext* context, const LayoutPoint& boxOrigin, const ComputedStyle& style, const Font& f ont, Color backgroundColor, int startPos, int endPos) 260 void InlineTextBoxPainter::paintSingleCompositionBackgroundRun(GraphicsContext* context, const LayoutPoint& boxOrigin, const ComputedStyle& style, const Font& f ont, Color backgroundColor, int startPos, int endPos)
297 { 261 {
262 if (backgroundColor == Color::transparent)
263 return;
264
298 int sPos = std::max(startPos - static_cast<int>(m_inlineTextBox.start()), 0) ; 265 int sPos = std::max(startPos - static_cast<int>(m_inlineTextBox.start()), 0) ;
299 int ePos = std::min(endPos - static_cast<int>(m_inlineTextBox.start()), stat ic_cast<int>(m_inlineTextBox.len())); 266 int ePos = std::min(endPos - static_cast<int>(m_inlineTextBox.start()), stat ic_cast<int>(m_inlineTextBox.len()));
300 if (sPos >= ePos) 267 if (sPos >= ePos)
301 return; 268 return;
302 269
303 int deltaY = m_inlineTextBox.layoutObject().style()->isFlippedLinesWritingMo de() ? m_inlineTextBox.root().selectionBottom() - m_inlineTextBox.logicalBottom( ) : m_inlineTextBox.logicalTop() - m_inlineTextBox.root().selectionTop(); 270 int deltaY = m_inlineTextBox.layoutObject().style()->isFlippedLinesWritingMo de() ? m_inlineTextBox.root().selectionBottom() - m_inlineTextBox.logicalBottom( ) : m_inlineTextBox.logicalTop() - m_inlineTextBox.root().selectionTop();
304 int selHeight = m_inlineTextBox.root().selectionHeight(); 271 int selHeight = m_inlineTextBox.root().selectionHeight();
305 FloatPoint localOrigin(boxOrigin.x().toFloat(), boxOrigin.y().toFloat() - de ltaY); 272 FloatPoint localOrigin(boxOrigin.x().toFloat(), boxOrigin.y().toFloat() - de ltaY);
306 context->drawHighlightForText(font, m_inlineTextBox.constructTextRun(style, font), localOrigin, selHeight, backgroundColor, sPos, ePos); 273 context->drawHighlightForText(font, m_inlineTextBox.constructTextRun(style, font), localOrigin, selHeight, backgroundColor, sPos, ePos);
307 } 274 }
(...skipping 15 matching lines...) Expand all
323 switch (marker->type()) { 290 switch (marker->type()) {
324 case DocumentMarker::Grammar: 291 case DocumentMarker::Grammar:
325 case DocumentMarker::Spelling: 292 case DocumentMarker::Spelling:
326 if (background) 293 if (background)
327 continue; 294 continue;
328 break; 295 break;
329 case DocumentMarker::TextMatch: 296 case DocumentMarker::TextMatch:
330 if (!background) 297 if (!background)
331 continue; 298 continue;
332 break; 299 break;
300 case DocumentMarker::Composition:
301 break;
333 default: 302 default:
334 continue; 303 continue;
335 } 304 }
336 305
337 if (marker->endOffset() <= m_inlineTextBox.start()) { 306 if (marker->endOffset() <= m_inlineTextBox.start()) {
338 // marker is completely before this run. This might be a marker tha t sits before the 307 // marker is completely before this run. This might be a marker tha t sits before the
339 // first run we draw, or markers that were within runs we skipped du e to truncation. 308 // first run we draw, or markers that were within runs we skipped du e to truncation.
340 continue; 309 continue;
341 } 310 }
342 if (marker->startOffset() > m_inlineTextBox.end()) { 311 if (marker->startOffset() > m_inlineTextBox.end()) {
343 // marker is completely after this run, bail. A later run will pain t it. 312 // marker is completely after this run, bail. A later run will pain t it.
344 break; 313 break;
345 } 314 }
346 315
347 // marker intersects this run. Paint it. 316 // marker intersects this run. Paint it.
348 switch (marker->type()) { 317 switch (marker->type()) {
349 case DocumentMarker::Spelling: 318 case DocumentMarker::Spelling:
350 m_inlineTextBox.paintDocumentMarker(pt, boxOrigin, marker, style, fo nt, false); 319 m_inlineTextBox.paintDocumentMarker(pt, boxOrigin, marker, style, fo nt, false);
351 break; 320 break;
352 case DocumentMarker::Grammar: 321 case DocumentMarker::Grammar:
353 m_inlineTextBox.paintDocumentMarker(pt, boxOrigin, marker, style, fo nt, true); 322 m_inlineTextBox.paintDocumentMarker(pt, boxOrigin, marker, style, fo nt, true);
354 break; 323 break;
355 case DocumentMarker::TextMatch: 324 case DocumentMarker::TextMatch:
356 m_inlineTextBox.paintTextMatchMarker(pt, boxOrigin, marker, style, f ont); 325 m_inlineTextBox.paintTextMatchMarker(pt, boxOrigin, marker, style, f ont);
357 break; 326 break;
327 case DocumentMarker::Composition:
328 {
329 CompositionUnderline underline(marker->startOffset(), marker->en dOffset(), marker->underlineColor(), marker->thick(), marker->backgroundColor()) ;
330 if (background)
331 paintSingleCompositionBackgroundRun(pt, boxOrigin, style, fo nt, underline.backgroundColor, underlinePaintStart(underline), underlinePaintEnd (underline));
332 else
333 paintCompositionUnderline(pt, boxOrigin, underline);
334 }
335 break;
358 default: 336 default:
359 ASSERT_NOT_REACHED(); 337 ASSERT_NOT_REACHED();
360 } 338 }
361 } 339 }
362 } 340 }
363 341
364 static GraphicsContext::DocumentMarkerLineStyle lineStyleForMarkerType(DocumentM arker::MarkerType markerType) 342 static GraphicsContext::DocumentMarkerLineStyle lineStyleForMarkerType(DocumentM arker::MarkerType markerType)
365 { 343 {
366 switch (markerType) { 344 switch (markerType) {
367 case DocumentMarker::Spelling: 345 case DocumentMarker::Spelling:
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 paintAppliedDecoration(context, FloatPoint(localOrigin), width.toFloat() , -doubleOffset, 1, overline, textDecorationThickness, antialiasDecoration, isPr inting); 736 paintAppliedDecoration(context, FloatPoint(localOrigin), width.toFloat() , -doubleOffset, 1, overline, textDecorationThickness, antialiasDecoration, isPr inting);
759 } 737 }
760 if (deco & TextDecorationLineThrough) { 738 if (deco & TextDecorationLineThrough) {
761 const float lineThroughOffset = 2 * baseline / 3; 739 const float lineThroughOffset = 2 * baseline / 3;
762 paintAppliedDecoration(context, FloatPoint(localOrigin) + FloatPoint(0, lineThroughOffset), width.toFloat(), doubleOffset, 0, linethrough, textDecoratio nThickness, antialiasDecoration, isPrinting); 740 paintAppliedDecoration(context, FloatPoint(localOrigin) + FloatPoint(0, lineThroughOffset), width.toFloat(), doubleOffset, 0, linethrough, textDecoratio nThickness, antialiasDecoration, isPrinting);
763 } 741 }
764 } 742 }
765 743
766 void InlineTextBoxPainter::paintCompositionUnderline(GraphicsContext* ctx, const LayoutPoint& boxOrigin, const CompositionUnderline& underline) 744 void InlineTextBoxPainter::paintCompositionUnderline(GraphicsContext* ctx, const LayoutPoint& boxOrigin, const CompositionUnderline& underline)
767 { 745 {
746 if (underline.color == Color::transparent)
747 return;
748
768 if (m_inlineTextBox.truncation() == cFullTruncation) 749 if (m_inlineTextBox.truncation() == cFullTruncation)
769 return; 750 return;
770 751
771 unsigned paintStart = underlinePaintStart(underline); 752 unsigned paintStart = underlinePaintStart(underline);
772 unsigned paintEnd = underlinePaintEnd(underline); 753 unsigned paintEnd = underlinePaintEnd(underline);
773 754
774 // start of line to draw, relative to paintOffset. 755 // start of line to draw, relative to paintOffset.
775 float start = paintStart == static_cast<unsigned>(m_inlineTextBox.start()) ? 0 : 756 float start = paintStart == static_cast<unsigned>(m_inlineTextBox.start()) ? 0 :
776 m_inlineTextBox.layoutObject().width(m_inlineTextBox.start(), paintStart - m_inlineTextBox.start(), m_inlineTextBox.textPos(), m_inlineTextBox.isLeftToR ightDirection() ? LTR : RTL, m_inlineTextBox.isFirstLineStyle()); 757 m_inlineTextBox.layoutObject().width(m_inlineTextBox.start(), paintStart - m_inlineTextBox.start(), m_inlineTextBox.textPos(), m_inlineTextBox.isLeftToR ightDirection() ? LTR : RTL, m_inlineTextBox.isFirstLineStyle());
777 // how much line to draw 758 // how much line to draw
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 LayoutPoint textOrigin(boxOrigin.x(), boxOrigin.y() + font.fontMetri cs().ascent()); 810 LayoutPoint textOrigin(boxOrigin.x(), boxOrigin.y() + font.fontMetri cs().ascent());
830 TextPainter textPainter(pt, font, run, textOrigin, boxRect, m_inline TextBox.isHorizontal()); 811 TextPainter textPainter(pt, font, run, textOrigin, boxRect, m_inline TextBox.isHorizontal());
831 812
832 textPainter.paint(sPos, ePos, length, textStyle, 0); 813 textPainter.paint(sPos, ePos, length, textStyle, 0);
833 } 814 }
834 } 815 }
835 } 816 }
836 817
837 818
838 } // namespace blink 819 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698