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

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

Issue 1647473002: [Line Layout API] Add LineLayoutItem::resolveColor() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 "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/editing/markers/RenderedDocumentMarker.h" 10 #include "core/editing/markers/RenderedDocumentMarker.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 if (combinedText) { 134 if (combinedText) {
135 combinedText->updateFont(); 135 combinedText->updateFont();
136 boxRect.setWidth(combinedText->inlineWidthForLayout()); 136 boxRect.setWidth(combinedText->inlineWidthForLayout());
137 } else { 137 } else {
138 shouldRotate = true; 138 shouldRotate = true;
139 context.concatCTM(TextPainter::rotation(boxRect, TextPainter::Clockw ise)); 139 context.concatCTM(TextPainter::rotation(boxRect, TextPainter::Clockw ise));
140 } 140 }
141 } 141 }
142 142
143 // Determine text colors. 143 // Determine text colors.
144 const LayoutObject& textBoxLayoutObject = *LineLayoutAPIShim::layoutObjectFr om(m_inlineTextBox.lineLayoutItem()); 144 TextPainter::Style textStyle = TextPainter::textPaintingStyle(m_inlineTextBo x.lineLayoutItem(), styleToUse, paintInfo);
145 TextPainter::Style textStyle = TextPainter::textPaintingStyle(textBoxLayoutO bject, styleToUse, paintInfo); 145 TextPainter::Style selectionStyle = TextPainter::selectionPaintingStyle(m_in lineTextBox.lineLayoutItem(), haveSelection, paintInfo, textStyle);
146 TextPainter::Style selectionStyle = TextPainter::selectionPaintingStyle(text BoxLayoutObject, haveSelection, paintInfo, textStyle);
147 bool paintSelectedTextOnly = (paintInfo.phase == PaintPhaseSelection); 146 bool paintSelectedTextOnly = (paintInfo.phase == PaintPhaseSelection);
148 bool paintSelectedTextSeparately = !paintSelectedTextOnly && textStyle != se lectionStyle; 147 bool paintSelectedTextSeparately = !paintSelectedTextOnly && textStyle != se lectionStyle;
149 148
150 // Set our font. 149 // Set our font.
151 const Font& font = styleToUse.font(); 150 const Font& font = styleToUse.font();
152 151
153 LayoutPoint textOrigin(boxOrigin.x(), boxOrigin.y() + font.fontMetrics().asc ent()); 152 LayoutPoint textOrigin(boxOrigin.x(), boxOrigin.y() + font.fontMetrics().asc ent());
154 153
155 // 1. Paint backgrounds behind text if needed. Examples of such backgrounds include selection 154 // 1. Paint backgrounds behind text if needed. Examples of such backgrounds include selection
156 // and composition highlights. 155 // and composition highlights.
157 if (paintInfo.phase != PaintPhaseSelection && paintInfo.phase != PaintPhaseT extClip && !isPrinting) { 156 if (paintInfo.phase != PaintPhaseSelection && paintInfo.phase != PaintPhaseT extClip && !isPrinting) {
158 paintDocumentMarkers(paintInfo, boxOrigin, styleToUse, font, DocumentMar kerPaintPhase::Background); 157 paintDocumentMarkers(paintInfo, boxOrigin, styleToUse, font, DocumentMar kerPaintPhase::Background);
159 158
159 const LayoutObject& textBoxLayoutObject = *LineLayoutAPIShim::layoutObje ctFrom(m_inlineTextBox.lineLayoutItem());
160 if (haveSelection && !paintsCompositionMarkers(textBoxLayoutObject)) { 160 if (haveSelection && !paintsCompositionMarkers(textBoxLayoutObject)) {
161 if (combinedText) 161 if (combinedText)
162 paintSelection<InlineTextBoxPainter::PaintOptions::CombinedText> (context, boxRect, styleToUse, font, selectionStyle.fillColor, combinedText); 162 paintSelection<InlineTextBoxPainter::PaintOptions::CombinedText> (context, boxRect, styleToUse, font, selectionStyle.fillColor, combinedText);
163 else 163 else
164 paintSelection<InlineTextBoxPainter::PaintOptions::Normal>(conte xt, boxRect, styleToUse, font, selectionStyle.fillColor); 164 paintSelection<InlineTextBoxPainter::PaintOptions::Normal>(conte xt, boxRect, styleToUse, font, selectionStyle.fillColor);
165 } 165 }
166 } 166 }
167 167
168 // 2. Now paint the foreground, including text and decorations like underlin e/overline (in quirks mode only). 168 // 2. Now paint the foreground, including text and decorations like underlin e/overline (in quirks mode only).
169 int length = m_inlineTextBox.len(); 169 int length = m_inlineTextBox.len();
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 869
870 Color color = LayoutTheme::theme().platformTextSearchHighlightColor(marker-> activeMatch()); 870 Color color = LayoutTheme::theme().platformTextSearchHighlightColor(marker-> activeMatch());
871 GraphicsContext& context = paintInfo.context; 871 GraphicsContext& context = paintInfo.context;
872 GraphicsContextStateSaver stateSaver(context); 872 GraphicsContextStateSaver stateSaver(context);
873 context.clip(FloatRect(boxOrigin.x().toFloat(), (boxOrigin.y() - deltaY).toF loat(), m_inlineTextBox.logicalWidth().toFloat(), selHeight)); 873 context.clip(FloatRect(boxOrigin.x().toFloat(), (boxOrigin.y() - deltaY).toF loat(), m_inlineTextBox.logicalWidth().toFloat(), selHeight));
874 context.drawHighlightForText(font, run, FloatPoint(boxOrigin.x().toFloat(), (boxOrigin.y() - deltaY).toFloat()), selHeight, color, sPos, ePos); 874 context.drawHighlightForText(font, run, FloatPoint(boxOrigin.x().toFloat(), (boxOrigin.y() - deltaY).toFloat()), selHeight, color, sPos, ePos);
875 } 875 }
876 876
877 877
878 } // namespace blink 878 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/EllipsisBoxPainter.cpp ('k') | third_party/WebKit/Source/core/paint/TextPainter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698