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

Side by Side Diff: Source/platform/fonts/shaping/SimpleShaper.cpp

Issue 986493002: Simplify text emphasis painting (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: review comments Created 5 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « Source/platform/fonts/shaping/SimpleShaper.h ('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 /* 1 /*
2 * Copyright (C) 2003, 2006, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2003, 2006, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed.
3 * Copyright (C) 2008 Holger Hans Peter Freyther 3 * Copyright (C) 2008 Holger Hans Peter Freyther
4 * Copyright (C) 2014 Google Inc. All rights reserved. 4 * Copyright (C) 2014 Google Inc. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 19 matching lines...) Expand all
30 #include "platform/fonts/SimpleFontData.h" 30 #include "platform/fonts/SimpleFontData.h"
31 #include "platform/text/SurrogatePairAwareTextIterator.h" 31 #include "platform/text/SurrogatePairAwareTextIterator.h"
32 #include "wtf/MathExtras.h" 32 #include "wtf/MathExtras.h"
33 #include "wtf/unicode/CharacterNames.h" 33 #include "wtf/unicode/CharacterNames.h"
34 34
35 using namespace WTF; 35 using namespace WTF;
36 using namespace Unicode; 36 using namespace Unicode;
37 37
38 namespace blink { 38 namespace blink {
39 39
40 SimpleShaper::SimpleShaper(const Font* font, const TextRun& run, 40 SimpleShaper::SimpleShaper(const Font* font, const TextRun& run, const GlyphData * emphasisData,
41 HashSet<const SimpleFontData*>* fallbackFonts, FloatRect* bounds, bool forTe xtEmphasis) 41 HashSet<const SimpleFontData*>* fallbackFonts, FloatRect* bounds)
42 : Shaper(font, run, forTextEmphasis ? ForTextEmphasis : NotForTextEmphasis, fallbackFonts, bounds) 42 : Shaper(font, run, emphasisData, fallbackFonts, bounds)
43 , m_currentCharacter(0) 43 , m_currentCharacter(0)
44 , m_runWidthSoFar(0) 44 , m_runWidthSoFar(0)
45 { 45 {
46 // If the padding is non-zero, count the number of spaces in the run 46 // If the padding is non-zero, count the number of spaces in the run
47 // and divide that by the padding for per space addition. 47 // and divide that by the padding for per space addition.
48 m_expansion = m_run.expansion(); 48 m_expansion = m_run.expansion();
49 if (!m_expansion) { 49 if (!m_expansion) {
50 m_expansionPerOpportunity = 0; 50 m_expansionPerOpportunity = 0;
51 } else { 51 } else {
52 bool isAfterExpansion = m_isAfterExpansion; 52 bool isAfterExpansion = m_isAfterExpansion;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 if (hasExtraSpacing && !spaceUsedAsZeroWidthSpace) 166 if (hasExtraSpacing && !spaceUsedAsZeroWidthSpace)
167 width = adjustSpacing(width, charData); 167 width = adjustSpacing(width, charData);
168 168
169 if (m_glyphBoundingBox) { 169 if (m_glyphBoundingBox) {
170 ASSERT(glyphData.fontData); 170 ASSERT(glyphData.fontData);
171 glyphBounds = glyphData.fontData->boundsForGlyph(glyphData.glyph); 171 glyphBounds = glyphData.fontData->boundsForGlyph(glyphData.glyph);
172 glyphBounds.move(glyphOrigin.x(), glyphOrigin.y()); 172 glyphBounds.move(glyphOrigin.x(), glyphOrigin.y());
173 m_glyphBoundingBox->unite(glyphBounds); 173 m_glyphBoundingBox->unite(glyphBounds);
174 } 174 }
175 175
176 if (m_forTextEmphasis) { 176 if (glyphBuffer) {
177 if (!Character::canReceiveTextEmphasis(charData.character)) 177 if (!forTextEmphasis()) {
178 glyph = 0; 178 glyphBuffer->add(glyph, fontData, m_runWidthSoFar);
179 179 } else if (Character::canReceiveTextEmphasis(charData.character)) {
180 // The emphasis code expects mid-glyph offsets. 180 addEmphasisMark(glyphBuffer, m_runWidthSoFar + width / 2);
181 width /= 2; 181 }
182 m_runWidthSoFar += width;
183 } 182 }
184 183
185 if (glyphBuffer)
186 glyphBuffer->add(glyph, fontData, m_runWidthSoFar);
187
188 // Advance past the character we just dealt with. 184 // Advance past the character we just dealt with.
189 textIterator.advance(charData.clusterLength); 185 textIterator.advance(charData.clusterLength);
190 m_runWidthSoFar += width; 186 m_runWidthSoFar += width;
191 // We are handling simple text run here, so Y-Offset will be zero. 187 // We are handling simple text run here, so Y-Offset will be zero.
192 glyphOrigin += FloatSize(width, 0); 188 glyphOrigin += FloatSize(width, 0);
193 } 189 }
194 190
195 unsigned consumedCharacters = textIterator.currentCharacter() - m_currentCha racter; 191 unsigned consumedCharacters = textIterator.currentCharacter() - m_currentCha racter;
196 m_currentCharacter = textIterator.currentCharacter(); 192 m_currentCharacter = textIterator.currentCharacter();
197 193
(...skipping 24 matching lines...) Expand all
222 float initialWidth = m_runWidthSoFar; 218 float initialWidth = m_runWidthSoFar;
223 219
224 if (!advance(m_currentCharacter + 1)) 220 if (!advance(m_currentCharacter + 1))
225 return false; 221 return false;
226 222
227 width = m_runWidthSoFar - initialWidth; 223 width = m_runWidthSoFar - initialWidth;
228 return true; 224 return true;
229 } 225 }
230 226
231 } // namespace blink 227 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/fonts/shaping/SimpleShaper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698