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

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

Issue 799123003: text-combine should scale rather than fall back to none when wide (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remove one expected.txt and rebase-update (there was a directory rename) Created 5 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
« no previous file with comments | « Source/core/layout/line/LineBreaker.cpp ('k') | Source/core/paint/TextPainter.cpp » ('j') | 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 100
101 GraphicsContext* context = paintInfo.context; 101 GraphicsContext* context = paintInfo.context;
102 RenderStyle* styleToUse = m_inlineTextBox.renderer().style(m_inlineTextBox.i sFirstLineStyle()); 102 RenderStyle* styleToUse = m_inlineTextBox.renderer().style(m_inlineTextBox.i sFirstLineStyle());
103 103
104 adjustedPaintOffset.move(0, styleToUse->isHorizontalWritingMode() ? LayoutUn it() : -m_inlineTextBox.logicalHeight().toLayoutUnit()); 104 adjustedPaintOffset.move(0, styleToUse->isHorizontalWritingMode() ? LayoutUn it() : -m_inlineTextBox.logicalHeight().toLayoutUnit());
105 105
106 FloatPoint boxOrigin = m_inlineTextBox.locationIncludingFlipping().toFloatPo int(); 106 FloatPoint boxOrigin = m_inlineTextBox.locationIncludingFlipping().toFloatPo int();
107 boxOrigin.move(adjustedPaintOffset.x().toFloat(), adjustedPaintOffset.y().to Float()); 107 boxOrigin.move(adjustedPaintOffset.x().toFloat(), adjustedPaintOffset.y().to Float());
108 FloatRect boxRect(boxOrigin, FloatSize(m_inlineTextBox.logicalWidth(), m_inl ineTextBox.logicalHeight())); 108 FloatRect boxRect(boxOrigin, FloatSize(m_inlineTextBox.logicalWidth(), m_inl ineTextBox.logicalHeight()));
109 109
110 RenderCombineText* combinedText = styleToUse->hasTextCombine() && m_inlineTe xtBox.renderer().isCombineText() && toRenderCombineText(m_inlineTextBox.renderer ()).isCombined() ? &toRenderCombineText(m_inlineTextBox.renderer()) : 0; 110 bool shouldRotate = false;
111 111 RenderCombineText* combinedText = nullptr;
112 bool shouldRotate = !m_inlineTextBox.isHorizontal() && !combinedText; 112 if (!m_inlineTextBox.isHorizontal()) {
113 if (shouldRotate) 113 if (styleToUse->hasTextCombine() && m_inlineTextBox.renderer().isCombine Text()) {
114 context->concatCTM(TextPainter::rotation(boxRect, TextPainter::Clockwise )); 114 combinedText = &toRenderCombineText(m_inlineTextBox.renderer());
115 if (!combinedText->isCombined())
116 combinedText = nullptr;
117 }
118 if (combinedText) {
119 combinedText->updateFont();
120 } else {
121 shouldRotate = true;
122 context->concatCTM(TextPainter::rotation(boxRect, TextPainter::Clock wise));
123 }
124 }
115 125
116 // Determine whether or not we have composition underlines to draw. 126 // Determine whether or not we have composition underlines to draw.
117 bool containsComposition = m_inlineTextBox.renderer().node() && m_inlineText Box.renderer().frame()->inputMethodController().compositionNode() == m_inlineTex tBox.renderer().node(); 127 bool containsComposition = m_inlineTextBox.renderer().node() && m_inlineText Box.renderer().frame()->inputMethodController().compositionNode() == m_inlineTex tBox.renderer().node();
118 bool useCustomUnderlines = containsComposition && m_inlineTextBox.renderer() .frame()->inputMethodController().compositionUsesCustomUnderlines(); 128 bool useCustomUnderlines = containsComposition && m_inlineTextBox.renderer() .frame()->inputMethodController().compositionUsesCustomUnderlines();
119 129
120 // Determine text colors. 130 // Determine text colors.
121 TextPainter::Style textStyle = TextPainter::textPaintingStyle(m_inlineTextBo x.renderer(), styleToUse, paintInfo.forceBlackText(), isPrinting); 131 TextPainter::Style textStyle = TextPainter::textPaintingStyle(m_inlineTextBo x.renderer(), styleToUse, paintInfo.forceBlackText(), isPrinting);
122 TextPainter::Style selectionStyle = TextPainter::selectionPaintingStyle(m_in lineTextBox.renderer(), haveSelection, paintInfo.forceBlackText(), isPrinting, t extStyle); 132 TextPainter::Style selectionStyle = TextPainter::selectionPaintingStyle(m_in lineTextBox.renderer(), haveSelection, paintInfo.forceBlackText(), isPrinting, t extStyle);
123 bool paintSelectedTextOnly = (paintInfo.phase == PaintPhaseSelection); 133 bool paintSelectedTextOnly = (paintInfo.phase == PaintPhaseSelection);
124 bool paintSelectedTextSeparately = !paintSelectedTextOnly && textStyle != se lectionStyle; 134 bool paintSelectedTextSeparately = !paintSelectedTextOnly && textStyle != se lectionStyle;
(...skipping 13 matching lines...) Expand all
138 } 148 }
139 149
140 paintDocumentMarkers(context, boxOrigin, styleToUse, font, true); 150 paintDocumentMarkers(context, boxOrigin, styleToUse, font, true);
141 151
142 if (haveSelection && !useCustomUnderlines) 152 if (haveSelection && !useCustomUnderlines)
143 paintSelection(context, boxOrigin, styleToUse, font, selectionStyle. fillColor); 153 paintSelection(context, boxOrigin, styleToUse, font, selectionStyle. fillColor);
144 } 154 }
145 155
146 // 2. Now paint the foreground, including text and decorations like underlin e/overline (in quirks mode only). 156 // 2. Now paint the foreground, including text and decorations like underlin e/overline (in quirks mode only).
147 int length = m_inlineTextBox.len(); 157 int length = m_inlineTextBox.len();
148 int maximumLength; 158 StringView string = m_inlineTextBox.renderer().text().createView();
149 StringView string; 159 ASSERT(m_inlineTextBox.start() + length <= string.length());
150 if (!combinedText) { 160 if (static_cast<unsigned>(length) != string.length() || m_inlineTextBox.star t())
151 string = m_inlineTextBox.renderer().text().createView(); 161 string.narrow(m_inlineTextBox.start(), length);
152 ASSERT(m_inlineTextBox.start() + length <= string.length()); 162 int maximumLength = m_inlineTextBox.renderer().textLength() - m_inlineTextBo x.start();
153 if (static_cast<unsigned>(length) != string.length() || m_inlineTextBox. start())
154 string.narrow(m_inlineTextBox.start(), length);
155 maximumLength = m_inlineTextBox.renderer().textLength() - m_inlineTextBo x.start();
156 } else {
157 combinedText->getStringToRender(m_inlineTextBox.start(), string, length) ;
158 maximumLength = length;
159 }
160 163
161 StringBuilder charactersWithHyphen; 164 StringBuilder charactersWithHyphen;
162 TextRun textRun = m_inlineTextBox.constructTextRun(styleToUse, font, string, maximumLength, m_inlineTextBox.hasHyphen() ? &charactersWithHyphen : 0); 165 TextRun textRun = m_inlineTextBox.constructTextRun(styleToUse, font, string, maximumLength, m_inlineTextBox.hasHyphen() ? &charactersWithHyphen : 0);
163 if (m_inlineTextBox.hasHyphen()) 166 if (m_inlineTextBox.hasHyphen())
164 length = textRun.length(); 167 length = textRun.length();
165 168
166 int selectionStart = 0; 169 int selectionStart = 0;
167 int selectionEnd = 0; 170 int selectionEnd = 0;
168 if (paintSelectedTextOnly || paintSelectedTextSeparately) 171 if (paintSelectedTextOnly || paintSelectedTextSeparately)
169 m_inlineTextBox.selectionStartEnd(selectionStart, selectionEnd); 172 m_inlineTextBox.selectionStartEnd(selectionStart, selectionEnd);
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 LayoutTheme::theme().platformActiveTextSearchHighlightColor() : 799 LayoutTheme::theme().platformActiveTextSearchHighlightColor() :
797 LayoutTheme::theme().platformInactiveTextSearchHighlightColor(); 800 LayoutTheme::theme().platformInactiveTextSearchHighlightColor();
798 GraphicsContextStateSaver stateSaver(*pt); 801 GraphicsContextStateSaver stateSaver(*pt);
799 pt->clip(FloatRect(boxOrigin.x(), boxOrigin.y() - deltaY, m_inlineTextBo x.logicalWidth(), selHeight)); 802 pt->clip(FloatRect(boxOrigin.x(), boxOrigin.y() - deltaY, m_inlineTextBo x.logicalWidth(), selHeight));
800 pt->drawHighlightForText(font, run, FloatPoint(boxOrigin.x(), boxOrigin. y() - deltaY), selHeight, color, sPos, ePos); 803 pt->drawHighlightForText(font, run, FloatPoint(boxOrigin.x(), boxOrigin. y() - deltaY), selHeight, color, sPos, ePos);
801 } 804 }
802 } 805 }
803 806
804 807
805 } // namespace blink 808 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/layout/line/LineBreaker.cpp ('k') | Source/core/paint/TextPainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698