OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "platform/fonts/shaping/ShapeResultBuffer.h" | 5 #include "platform/fonts/shaping/ShapeResultBuffer.h" |
6 | 6 |
7 #include "platform/fonts/CharacterRange.h" | 7 #include "platform/fonts/CharacterRange.h" |
8 #include "platform/fonts/GlyphBuffer.h" | 8 #include "platform/fonts/GlyphBuffer.h" |
9 #include "platform/fonts/SimpleFontData.h" | 9 #include "platform/fonts/SimpleFontData.h" |
10 #include "platform/fonts/shaping/ShapeResultInlineHeaders.h" | 10 #include "platform/fonts/shaping/ShapeResultInlineHeaders.h" |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 ? run->m_startIndex + run->m_numCharacters + runOffset | 153 ? run->m_startIndex + run->m_numCharacters + runOffset |
154 : run->glyphToCharacterIndex(0) + runOffset); | 154 : run->glyphToCharacterIndex(0) + runOffset); |
155 | 155 |
156 float advanceSoFar = initialAdvance; | 156 float advanceSoFar = initialAdvance; |
157 const unsigned numGlyphs = run->m_glyphData.size(); | 157 const unsigned numGlyphs = run->m_glyphData.size(); |
158 for (unsigned i = 0; i < numGlyphs; ++i) { | 158 for (unsigned i = 0; i < numGlyphs; ++i) { |
159 const HarfBuzzRunGlyphData& glyphData = run->m_glyphData[i]; | 159 const HarfBuzzRunGlyphData& glyphData = run->m_glyphData[i]; |
160 uint16_t currentCharacterIndex = | 160 uint16_t currentCharacterIndex = |
161 run->m_startIndex + glyphData.characterIndex + runOffset; | 161 run->m_startIndex + glyphData.characterIndex + runOffset; |
162 bool isRunEnd = (i + 1 == numGlyphs); | 162 bool isRunEnd = (i + 1 == numGlyphs); |
163 bool isClusterEnd = | 163 bool isClusterEnd = isRunEnd || |
164 isRunEnd || (run->glyphToCharacterIndex(i + 1) + runOffset != | 164 (run->glyphToCharacterIndex(i + 1) + runOffset != |
165 currentCharacterIndex); | 165 currentCharacterIndex); |
166 | 166 |
167 if ((direction == TextDirection::kRtl && currentCharacterIndex >= to) || | 167 if ((direction == TextDirection::kRtl && currentCharacterIndex >= to) || |
168 (direction != TextDirection::kRtl && currentCharacterIndex < from)) { | 168 (direction != TextDirection::kRtl && currentCharacterIndex < from)) { |
169 advanceSoFar += glyphData.advance; | 169 advanceSoFar += glyphData.advance; |
170 direction == TextDirection::kRtl ? --clusterStart : ++clusterStart; | 170 direction == TextDirection::kRtl ? --clusterStart : ++clusterStart; |
171 continue; | 171 continue; |
172 } | 172 } |
173 | 173 |
174 clusterAdvance += glyphData.advance; | 174 clusterAdvance += glyphData.advance; |
175 | 175 |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 totalOffset += offsetForWord; | 478 totalOffset += offsetForWord; |
479 if (targetX >= 0 && targetX <= wordResult->width()) | 479 if (targetX >= 0 && targetX <= wordResult->width()) |
480 return totalOffset; | 480 return totalOffset; |
481 targetX -= wordResult->width(); | 481 targetX -= wordResult->width(); |
482 } | 482 } |
483 } | 483 } |
484 return totalOffset; | 484 return totalOffset; |
485 } | 485 } |
486 | 486 |
487 } // namespace blink | 487 } // namespace blink |
OLD | NEW |