Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 { |
|
jbroman
2015/03/07 18:50:25
nit: consider
} else if (...) {
to avoid the ext
f(malita)
2015/03/09 15:04:55
Done.
| |
| 180 // The emphasis code expects mid-glyph offsets. | 180 if (Character::canReceiveTextEmphasis(charData.character)) |
| 181 width /= 2; | 181 addEmphasisMark(glyphBuffer, m_runWidthSoFar + width / 2); |
| 182 m_runWidthSoFar += width; | 182 } |
| 183 } | 183 } |
| 184 | 184 |
| 185 if (glyphBuffer) | |
| 186 glyphBuffer->add(glyph, fontData, m_runWidthSoFar); | |
| 187 | |
| 188 // Advance past the character we just dealt with. | 185 // Advance past the character we just dealt with. |
| 189 textIterator.advance(charData.clusterLength); | 186 textIterator.advance(charData.clusterLength); |
| 190 m_runWidthSoFar += width; | 187 m_runWidthSoFar += width; |
| 191 // We are handling simple text run here, so Y-Offset will be zero. | 188 // We are handling simple text run here, so Y-Offset will be zero. |
| 192 glyphOrigin += FloatSize(width, 0); | 189 glyphOrigin += FloatSize(width, 0); |
| 193 } | 190 } |
| 194 | 191 |
| 195 unsigned consumedCharacters = textIterator.currentCharacter() - m_currentCha racter; | 192 unsigned consumedCharacters = textIterator.currentCharacter() - m_currentCha racter; |
| 196 m_currentCharacter = textIterator.currentCharacter(); | 193 m_currentCharacter = textIterator.currentCharacter(); |
| 197 | 194 |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 222 float initialWidth = m_runWidthSoFar; | 219 float initialWidth = m_runWidthSoFar; |
| 223 | 220 |
| 224 if (!advance(m_currentCharacter + 1)) | 221 if (!advance(m_currentCharacter + 1)) |
| 225 return false; | 222 return false; |
| 226 | 223 |
| 227 width = m_runWidthSoFar - initialWidth; | 224 width = m_runWidthSoFar - initialWidth; |
| 228 return true; | 225 return true; |
| 229 } | 226 } |
| 230 | 227 |
| 231 } // namespace blink | 228 } // namespace blink |
| OLD | NEW |