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

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

Issue 2246383002: Remove unused Font argument from InlineTextBox::constructTextRun (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@combine
Patch Set: Created 4 years, 4 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 | « third_party/WebKit/Source/core/layout/line/InlineTextBox.cpp ('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 "core/paint/InlineTextBoxPainter.h" 5 #include "core/paint/InlineTextBoxPainter.h"
6 6
7 #include "core/editing/CompositionUnderline.h" 7 #include "core/editing/CompositionUnderline.h"
8 #include "core/editing/Editor.h" 8 #include "core/editing/Editor.h"
9 #include "core/editing/markers/DocumentMarkerController.h" 9 #include "core/editing/markers/DocumentMarkerController.h"
10 #include "core/frame/LocalFrame.h" 10 #include "core/frame/LocalFrame.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 104
105 LayoutPoint boxOrigin(m_inlineTextBox.locationIncludingFlipping()); 105 LayoutPoint boxOrigin(m_inlineTextBox.locationIncludingFlipping());
106 boxOrigin.move(adjustedPaintOffset.x(), adjustedPaintOffset.y()); 106 boxOrigin.move(adjustedPaintOffset.x(), adjustedPaintOffset.y());
107 LayoutRect boxRect(boxOrigin, LayoutSize(m_inlineTextBox.logicalWidth(), m_i nlineTextBox.logicalHeight())); 107 LayoutRect boxRect(boxOrigin, LayoutSize(m_inlineTextBox.logicalWidth(), m_i nlineTextBox.logicalHeight()));
108 108
109 int length = m_inlineTextBox.len(); 109 int length = m_inlineTextBox.len();
110 StringView string = StringView(m_inlineTextBox.getLineLayoutItem().text(), m _inlineTextBox.start(), length); 110 StringView string = StringView(m_inlineTextBox.getLineLayoutItem().text(), m _inlineTextBox.start(), length);
111 int maximumLength = m_inlineTextBox.getLineLayoutItem().textLength() - m_inl ineTextBox.start(); 111 int maximumLength = m_inlineTextBox.getLineLayoutItem().textLength() - m_inl ineTextBox.start();
112 112
113 StringBuilder charactersWithHyphen; 113 StringBuilder charactersWithHyphen;
114 TextRun textRun = m_inlineTextBox.constructTextRun(styleToUse, styleToUse.fo nt(), string, maximumLength, m_inlineTextBox.hasHyphen() ? &charactersWithHyphen : 0); 114 TextRun textRun = m_inlineTextBox.constructTextRun(styleToUse, string, maxim umLength, m_inlineTextBox.hasHyphen() ? &charactersWithHyphen : 0);
115 if (m_inlineTextBox.hasHyphen()) 115 if (m_inlineTextBox.hasHyphen())
116 length = textRun.length(); 116 length = textRun.length();
117 117
118 bool shouldRotate = false; 118 bool shouldRotate = false;
119 LayoutTextCombine* combinedText = nullptr; 119 LayoutTextCombine* combinedText = nullptr;
120 if (!m_inlineTextBox.isHorizontal()) { 120 if (!m_inlineTextBox.isHorizontal()) {
121 if (styleToUse.hasTextCombine() && m_inlineTextBox.getLineLayoutItem().i sCombineText()) { 121 if (styleToUse.hasTextCombine() && m_inlineTextBox.getLineLayoutItem().i sCombineText()) {
122 combinedText = &toLayoutTextCombine(inlineLayoutObject()); 122 combinedText = &toLayoutTextCombine(inlineLayoutObject());
123 if (!combinedText->isCombined()) 123 if (!combinedText->isCombined())
124 combinedText = nullptr; 124 combinedText = nullptr;
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 return; 282 return;
283 283
284 int sPos = std::max(startPos - static_cast<int>(m_inlineTextBox.start()), 0) ; 284 int sPos = std::max(startPos - static_cast<int>(m_inlineTextBox.start()), 0) ;
285 int ePos = std::min(endPos - static_cast<int>(m_inlineTextBox.start()), stat ic_cast<int>(m_inlineTextBox.len())); 285 int ePos = std::min(endPos - static_cast<int>(m_inlineTextBox.start()), stat ic_cast<int>(m_inlineTextBox.len()));
286 if (sPos >= ePos) 286 if (sPos >= ePos)
287 return; 287 return;
288 288
289 int deltaY = m_inlineTextBox.getLineLayoutItem().style()->isFlippedLinesWrit ingMode() ? m_inlineTextBox.root().selectionBottom() - m_inlineTextBox.logicalBo ttom() : m_inlineTextBox.logicalTop() - m_inlineTextBox.root().selectionTop(); 289 int deltaY = m_inlineTextBox.getLineLayoutItem().style()->isFlippedLinesWrit ingMode() ? m_inlineTextBox.root().selectionBottom() - m_inlineTextBox.logicalBo ttom() : m_inlineTextBox.logicalTop() - m_inlineTextBox.root().selectionTop();
290 int selHeight = m_inlineTextBox.root().selectionHeight(); 290 int selHeight = m_inlineTextBox.root().selectionHeight();
291 FloatPoint localOrigin(boxOrigin.x().toFloat(), boxOrigin.y().toFloat() - de ltaY); 291 FloatPoint localOrigin(boxOrigin.x().toFloat(), boxOrigin.y().toFloat() - de ltaY);
292 context.drawHighlightForText(font, m_inlineTextBox.constructTextRun(style, f ont), localOrigin, selHeight, backgroundColor, sPos, ePos); 292 context.drawHighlightForText(font, m_inlineTextBox.constructTextRun(style), localOrigin, selHeight, backgroundColor, sPos, ePos);
293 } 293 }
294 294
295 void InlineTextBoxPainter::paintDocumentMarkers(const PaintInfo& paintInfo, cons t LayoutPoint& boxOrigin, const ComputedStyle& style, const Font& font, Document MarkerPaintPhase markerPaintPhase) 295 void InlineTextBoxPainter::paintDocumentMarkers(const PaintInfo& paintInfo, cons t LayoutPoint& boxOrigin, const ComputedStyle& style, const Font& font, Document MarkerPaintPhase markerPaintPhase)
296 { 296 {
297 if (!m_inlineTextBox.getLineLayoutItem().node()) 297 if (!m_inlineTextBox.getLineLayoutItem().node())
298 return; 298 return;
299 299
300 DocumentMarkerVector markers = m_inlineTextBox.getLineLayoutItem().document( ).markers().markersFor(m_inlineTextBox.getLineLayoutItem().node()); 300 DocumentMarkerVector markers = m_inlineTextBox.getLineLayoutItem().document( ).markers().markersFor(m_inlineTextBox.getLineLayoutItem().node());
301 DocumentMarkerVector::const_iterator markerIt = markers.begin(); 301 DocumentMarkerVector::const_iterator markerIt = markers.begin();
302 302
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 int startPosition = std::max<int>(marker->startOffset() - m_inlineTextBo x.start(), 0); 396 int startPosition = std::max<int>(marker->startOffset() - m_inlineTextBo x.start(), 0);
397 int endPosition = std::min<int>(marker->endOffset() - static_cast<int>(m _inlineTextBox.start()), m_inlineTextBox.len()); 397 int endPosition = std::min<int>(marker->endOffset() - static_cast<int>(m _inlineTextBox.start()), m_inlineTextBox.len());
398 398
399 if (m_inlineTextBox.truncation() != cNoTruncation) 399 if (m_inlineTextBox.truncation() != cNoTruncation)
400 endPosition = std::min<int>(endPosition, m_inlineTextBox.truncation( )); 400 endPosition = std::min<int>(endPosition, m_inlineTextBox.truncation( ));
401 401
402 // Calculate start & width 402 // Calculate start & width
403 int deltaY = m_inlineTextBox.getLineLayoutItem().style()->isFlippedLines WritingMode() ? m_inlineTextBox.root().selectionBottom() - m_inlineTextBox.logic alBottom() : m_inlineTextBox.logicalTop() - m_inlineTextBox.root().selectionTop( ); 403 int deltaY = m_inlineTextBox.getLineLayoutItem().style()->isFlippedLines WritingMode() ? m_inlineTextBox.root().selectionBottom() - m_inlineTextBox.logic alBottom() : m_inlineTextBox.logicalTop() - m_inlineTextBox.root().selectionTop( );
404 int selHeight = m_inlineTextBox.root().selectionHeight(); 404 int selHeight = m_inlineTextBox.root().selectionHeight();
405 LayoutPoint startPoint(boxOrigin.x(), boxOrigin.y() - deltaY); 405 LayoutPoint startPoint(boxOrigin.x(), boxOrigin.y() - deltaY);
406 TextRun run = m_inlineTextBox.constructTextRun(style, font); 406 TextRun run = m_inlineTextBox.constructTextRun(style);
407 407
408 // FIXME: Convert the document markers to float rects. 408 // FIXME: Convert the document markers to float rects.
409 IntRect markerRect = enclosingIntRect(font.selectionRectForText(run, Flo atPoint(startPoint), selHeight, startPosition, endPosition)); 409 IntRect markerRect = enclosingIntRect(font.selectionRectForText(run, Flo atPoint(startPoint), selHeight, startPosition, endPosition));
410 start = markerRect.x() - startPoint.x(); 410 start = markerRect.x() - startPoint.x();
411 width = LayoutUnit(markerRect.width()); 411 width = LayoutUnit(markerRect.width());
412 } 412 }
413 413
414 // IMPORTANT: The misspelling underline is not considered when calculating t he text bounds, so we have to 414 // IMPORTANT: The misspelling underline is not considered when calculating t he text bounds, so we have to
415 // make sure to fit within those bounds. This means the top pixel(s) of the underline will overlap the 415 // make sure to fit within those bounds. This means the top pixel(s) of the underline will overlap the
416 // bottom pixel(s) of the glyphs in smaller font sizes. The alternatives ar e to increase the line spacing (bad!!) 416 // bottom pixel(s) of the glyphs in smaller font sizes. The alternatives ar e to increase the line spacing (bad!!)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 if (textColor == c) 449 if (textColor == c)
450 c = Color(0xff - c.red(), 0xff - c.green(), 0xff - c.blue()); 450 c = Color(0xff - c.red(), 0xff - c.green(), 0xff - c.blue());
451 451
452 // If the text is truncated, let the thing being painted in the truncation 452 // If the text is truncated, let the thing being painted in the truncation
453 // draw its own highlight. 453 // draw its own highlight.
454 int length = m_inlineTextBox.truncation() != cNoTruncation ? m_inlineTextBox .truncation() : m_inlineTextBox.len(); 454 int length = m_inlineTextBox.truncation() != cNoTruncation ? m_inlineTextBox .truncation() : m_inlineTextBox.len();
455 StringView string(m_inlineTextBox.getLineLayoutItem().text(), m_inlineTextBo x.start(), static_cast<unsigned>(length)); 455 StringView string(m_inlineTextBox.getLineLayoutItem().text(), m_inlineTextBo x.start(), static_cast<unsigned>(length));
456 456
457 StringBuilder charactersWithHyphen; 457 StringBuilder charactersWithHyphen;
458 bool respectHyphen = ePos == length && m_inlineTextBox.hasHyphen(); 458 bool respectHyphen = ePos == length && m_inlineTextBox.hasHyphen();
459 TextRun textRun = m_inlineTextBox.constructTextRun(style, font, string, m_in lineTextBox.getLineLayoutItem().textLength() - m_inlineTextBox.start(), respectH yphen ? &charactersWithHyphen : 0); 459 TextRun textRun = m_inlineTextBox.constructTextRun(style, string, m_inlineTe xtBox.getLineLayoutItem().textLength() - m_inlineTextBox.start(), respectHyphen ? &charactersWithHyphen : 0);
460 if (respectHyphen) 460 if (respectHyphen)
461 ePos = textRun.length(); 461 ePos = textRun.length();
462 462
463 GraphicsContextStateSaver stateSaver(context); 463 GraphicsContextStateSaver stateSaver(context);
464 464
465 if (options == InlineTextBoxPainter::PaintOptions::CombinedText) { 465 if (options == InlineTextBoxPainter::PaintOptions::CombinedText) {
466 ASSERT(combinedText); 466 ASSERT(combinedText);
467 // We can't use the height of m_inlineTextBox because LayoutTextCombine' s inlineTextBox is horizontal within vertical flow 467 // We can't use the height of m_inlineTextBox because LayoutTextCombine' s inlineTextBox is horizontal within vertical flow
468 combinedText->transformToInlineCoordinates(context, boxRect, true); 468 combinedText->transformToInlineCoordinates(context, boxRect, true);
469 context.drawHighlightForText(font, textRun, FloatPoint(boxRect.location( )), boxRect.height(), c, sPos, ePos); 469 context.drawHighlightForText(font, textRun, FloatPoint(boxRect.location( )), boxRect.height(), c, sPos, ePos);
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 } 829 }
830 830
831 void InlineTextBoxPainter::paintTextMatchMarkerForeground(const PaintInfo& paint Info, const LayoutPoint& boxOrigin, DocumentMarker* marker, const ComputedStyle& style, const Font& font) 831 void InlineTextBoxPainter::paintTextMatchMarkerForeground(const PaintInfo& paint Info, const LayoutPoint& boxOrigin, DocumentMarker* marker, const ComputedStyle& style, const Font& font)
832 { 832 {
833 if (!inlineLayoutObject().frame()->editor().markedTextMatchesAreHighlighted( )) 833 if (!inlineLayoutObject().frame()->editor().markedTextMatchesAreHighlighted( ))
834 return; 834 return;
835 835
836 // TODO(ramya.v): Extract this into a helper function and share many copies of this code. 836 // TODO(ramya.v): Extract this into a helper function and share many copies of this code.
837 int sPos = std::max(marker->startOffset() - m_inlineTextBox.start(), (unsign ed)0); 837 int sPos = std::max(marker->startOffset() - m_inlineTextBox.start(), (unsign ed)0);
838 int ePos = std::min(marker->endOffset() - m_inlineTextBox.start(), m_inlineT extBox.len()); 838 int ePos = std::min(marker->endOffset() - m_inlineTextBox.start(), m_inlineT extBox.len());
839 TextRun run = m_inlineTextBox.constructTextRun(style, font); 839 TextRun run = m_inlineTextBox.constructTextRun(style);
840 840
841 Color textColor = LayoutTheme::theme().platformTextSearchColor(marker->activ eMatch()); 841 Color textColor = LayoutTheme::theme().platformTextSearchColor(marker->activ eMatch());
842 if (style.visitedDependentColor(CSSPropertyColor) == textColor) 842 if (style.visitedDependentColor(CSSPropertyColor) == textColor)
843 return; 843 return;
844 TextPainter::Style textStyle; 844 TextPainter::Style textStyle;
845 textStyle.currentColor = textStyle.fillColor = textStyle.strokeColor = textS tyle.emphasisMarkColor = textColor; 845 textStyle.currentColor = textStyle.fillColor = textStyle.strokeColor = textS tyle.emphasisMarkColor = textColor;
846 textStyle.strokeWidth = style.textStrokeWidth(); 846 textStyle.strokeWidth = style.textStrokeWidth();
847 textStyle.shadow = 0; 847 textStyle.shadow = 0;
848 848
849 LayoutRect boxRect(boxOrigin, LayoutSize(m_inlineTextBox.logicalWidth(), m_i nlineTextBox.logicalHeight())); 849 LayoutRect boxRect(boxOrigin, LayoutSize(m_inlineTextBox.logicalWidth(), m_i nlineTextBox.logicalHeight()));
850 LayoutPoint textOrigin(boxOrigin.x(), boxOrigin.y() + font.getFontMetrics(). ascent()); 850 LayoutPoint textOrigin(boxOrigin.x(), boxOrigin.y() + font.getFontMetrics(). ascent());
851 TextPainter textPainter(paintInfo.context, font, run, textOrigin, boxRect, m _inlineTextBox.isHorizontal()); 851 TextPainter textPainter(paintInfo.context, font, run, textOrigin, boxRect, m _inlineTextBox.isHorizontal());
852 852
853 textPainter.paint(sPos, ePos, m_inlineTextBox.len(), textStyle, 0); 853 textPainter.paint(sPos, ePos, m_inlineTextBox.len(), textStyle, 0);
854 } 854 }
855 855
856 void InlineTextBoxPainter::paintTextMatchMarkerBackground(const PaintInfo& paint Info, const LayoutPoint& boxOrigin, DocumentMarker* marker, const ComputedStyle& style, const Font& font) 856 void InlineTextBoxPainter::paintTextMatchMarkerBackground(const PaintInfo& paint Info, const LayoutPoint& boxOrigin, DocumentMarker* marker, const ComputedStyle& style, const Font& font)
857 { 857 {
858 if (!LineLayoutAPIShim::layoutObjectFrom(m_inlineTextBox.getLineLayoutItem() )->frame()->editor().markedTextMatchesAreHighlighted()) 858 if (!LineLayoutAPIShim::layoutObjectFrom(m_inlineTextBox.getLineLayoutItem() )->frame()->editor().markedTextMatchesAreHighlighted())
859 return; 859 return;
860 860
861 int sPos = std::max(marker->startOffset() - m_inlineTextBox.start(), (unsign ed)0); 861 int sPos = std::max(marker->startOffset() - m_inlineTextBox.start(), (unsign ed)0);
862 int ePos = std::min(marker->endOffset() - m_inlineTextBox.start(), m_inlineT extBox.len()); 862 int ePos = std::min(marker->endOffset() - m_inlineTextBox.start(), m_inlineT extBox.len());
863 TextRun run = m_inlineTextBox.constructTextRun(style, font); 863 TextRun run = m_inlineTextBox.constructTextRun(style);
864 864
865 Color color = LayoutTheme::theme().platformTextSearchHighlightColor(marker-> activeMatch()); 865 Color color = LayoutTheme::theme().platformTextSearchHighlightColor(marker-> activeMatch());
866 GraphicsContext& context = paintInfo.context; 866 GraphicsContext& context = paintInfo.context;
867 GraphicsContextStateSaver stateSaver(context); 867 GraphicsContextStateSaver stateSaver(context);
868 868
869 LayoutRect boxRect(boxOrigin, LayoutSize(m_inlineTextBox.logicalWidth(), m_i nlineTextBox.logicalHeight())); 869 LayoutRect boxRect(boxOrigin, LayoutSize(m_inlineTextBox.logicalWidth(), m_i nlineTextBox.logicalHeight()));
870 context.clip(FloatRect(boxRect)); 870 context.clip(FloatRect(boxRect));
871 context.drawHighlightForText(font, run, FloatPoint(boxOrigin), boxRect.heigh t(), color, sPos, ePos); 871 context.drawHighlightForText(font, run, FloatPoint(boxOrigin), boxRect.heigh t(), color, sPos, ePos);
872 } 872 }
873 873
874 874
875 } // namespace blink 875 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/line/InlineTextBox.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698