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

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

Powered by Google App Engine
This is Rietveld 408576698