| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "platform/fonts/shaping/CachingWordShaper.h" | 5 #include "platform/fonts/shaping/CachingWordShaper.h" |
| 6 | 6 |
| 7 #include "platform/fonts/CharacterRange.h" | 7 #include "platform/fonts/CharacterRange.h" |
| 8 #include "platform/fonts/FontCache.h" | 8 #include "platform/fonts/FontCache.h" |
| 9 #include "platform/fonts/GlyphBuffer.h" | 9 #include "platform/fonts/GlyphBuffer.h" |
| 10 #include "platform/fonts/shaping/CachingWordShapeIterator.h" | 10 #include "platform/fonts/shaping/CachingWordShapeIterator.h" |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 | 344 |
| 345 RefPtr<ShapeResult> wordResult; | 345 RefPtr<ShapeResult> wordResult; |
| 346 CachingWordShapeIterator iterator(cache.get(), textRun, &font); | 346 CachingWordShapeIterator iterator(cache.get(), textRun, &font); |
| 347 | 347 |
| 348 ASSERT_TRUE(iterator.next(&wordResult)); | 348 ASSERT_TRUE(iterator.next(&wordResult)); |
| 349 EXPECT_EQ(11u, wordResult->numCharacters()); | 349 EXPECT_EQ(11u, wordResult->numCharacters()); |
| 350 | 350 |
| 351 ASSERT_FALSE(iterator.next(&wordResult)); | 351 ASSERT_FALSE(iterator.next(&wordResult)); |
| 352 } | 352 } |
| 353 | 353 |
| 354 TEST_F(CachingWordShaperTest, SegmentEmojiSignsOfHornsModifier) |
| 355 { |
| 356 // A Sign of the Horns emoji, followed by a fitzpatrick modifer |
| 357 const UChar str[] = { |
| 358 0xD83E, 0xDD18, |
| 359 0xD83C, 0xDFFB, |
| 360 0x0 |
| 361 }; |
| 362 TextRun textRun(str, 4); |
| 363 |
| 364 RefPtr<ShapeResult> wordResult; |
| 365 CachingWordShapeIterator iterator(cache.get(), textRun, &font); |
| 366 |
| 367 ASSERT_TRUE(iterator.next(&wordResult)); |
| 368 EXPECT_EQ(4u, wordResult->numCharacters()); |
| 369 |
| 370 ASSERT_FALSE(iterator.next(&wordResult)); |
| 371 } |
| 372 |
| 354 TEST_F(CachingWordShaperTest, SegmentEmojiExtraZWJPrefix) | 373 TEST_F(CachingWordShaperTest, SegmentEmojiExtraZWJPrefix) |
| 355 { | 374 { |
| 356 // A ZWJ, followed by a family and a heart-kiss sequence. | 375 // A ZWJ, followed by a family and a heart-kiss sequence. |
| 357 const UChar str[] = { | 376 const UChar str[] = { |
| 358 0x200D, | 377 0x200D, |
| 359 0xD83D, 0xDC68, | 378 0xD83D, 0xDC68, |
| 360 0x200D, | 379 0x200D, |
| 361 0xD83D, 0xDC69, | 380 0xD83D, 0xDC69, |
| 362 0x200D, | 381 0x200D, |
| 363 0xD83D, 0xDC67, | 382 0xD83D, 0xDC67, |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 float periodsAndSpacesWidth = shaper.width(&font, periodsAndSpaces, nullptr,
&periodsAndSpacesGlyphBounds); | 481 float periodsAndSpacesWidth = shaper.width(&font, periodsAndSpaces, nullptr,
&periodsAndSpacesGlyphBounds); |
| 463 | 482 |
| 464 // The total width of periods and spaces should be longer than the width of
periods alone. | 483 // The total width of periods and spaces should be longer than the width of
periods alone. |
| 465 ASSERT_GT(periodsAndSpacesWidth, periodsWidth); | 484 ASSERT_GT(periodsAndSpacesWidth, periodsWidth); |
| 466 | 485 |
| 467 // The glyph bounds of periods and spaces should be longer than the glyph bo
unds of periods alone. | 486 // The glyph bounds of periods and spaces should be longer than the glyph bo
unds of periods alone. |
| 468 ASSERT_GT(periodsAndSpacesGlyphBounds.width(), periodsGlyphBounds.width()); | 487 ASSERT_GT(periodsAndSpacesGlyphBounds.width(), periodsGlyphBounds.width()); |
| 469 } | 488 } |
| 470 | 489 |
| 471 } // namespace blink | 490 } // namespace blink |
| OLD | NEW |