| 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 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 characterWidths[glyph.characterIndex] += glyph.advance; | 408 characterWidths[glyph.characterIndex] += glyph.advance; |
| 409 | 409 |
| 410 for (unsigned characterIndex = 0; characterIndex < runInfo.m_numCharacters; | 410 for (unsigned characterIndex = 0; characterIndex < runInfo.m_numCharacters; |
| 411 characterIndex++) { | 411 characterIndex++) { |
| 412 float start = offset; | 412 float start = offset; |
| 413 offset += characterWidths[characterIndex]; | 413 offset += characterWidths[characterIndex]; |
| 414 float end = offset; | 414 float end = offset; |
| 415 | 415 |
| 416 // To match getCharacterRange we flip ranges to ensure start <= end. | 416 // To match getCharacterRange we flip ranges to ensure start <= end. |
| 417 if (end < start) | 417 if (end < start) |
| 418 ranges.append(CharacterRange(end, start)); | 418 ranges.push_back(CharacterRange(end, start)); |
| 419 else | 419 else |
| 420 ranges.append(CharacterRange(start, end)); | 420 ranges.push_back(CharacterRange(start, end)); |
| 421 } | 421 } |
| 422 } | 422 } |
| 423 | 423 |
| 424 Vector<CharacterRange> ShapeResultBuffer::individualCharacterRanges( | 424 Vector<CharacterRange> ShapeResultBuffer::individualCharacterRanges( |
| 425 TextDirection direction, | 425 TextDirection direction, |
| 426 float totalWidth) const { | 426 float totalWidth) const { |
| 427 Vector<CharacterRange> ranges; | 427 Vector<CharacterRange> ranges; |
| 428 float currentX = direction == TextDirection::Rtl ? totalWidth : 0; | 428 float currentX = direction == TextDirection::Rtl ? totalWidth : 0; |
| 429 for (const RefPtr<const ShapeResult> result : m_results) { | 429 for (const RefPtr<const ShapeResult> result : m_results) { |
| 430 if (direction == TextDirection::Rtl) | 430 if (direction == TextDirection::Rtl) |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 totalOffset += offsetForWord; | 471 totalOffset += offsetForWord; |
| 472 if (targetX >= 0 && targetX <= wordResult->width()) | 472 if (targetX >= 0 && targetX <= wordResult->width()) |
| 473 return totalOffset; | 473 return totalOffset; |
| 474 targetX -= wordResult->width(); | 474 targetX -= wordResult->width(); |
| 475 } | 475 } |
| 476 } | 476 } |
| 477 return totalOffset; | 477 return totalOffset; |
| 478 } | 478 } |
| 479 | 479 |
| 480 } // namespace blink | 480 } // namespace blink |
| OLD | NEW |