| 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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 | 293 |
| 294 RefPtr<const ShapeResult> wordResult; | 294 RefPtr<const ShapeResult> wordResult; |
| 295 CachingWordShapeIterator iterator(cache.get(), textRun, &font); | 295 CachingWordShapeIterator iterator(cache.get(), textRun, &font); |
| 296 | 296 |
| 297 ASSERT_TRUE(iterator.next(&wordResult)); | 297 ASSERT_TRUE(iterator.next(&wordResult)); |
| 298 EXPECT_EQ(22u, wordResult->numCharacters()); | 298 EXPECT_EQ(22u, wordResult->numCharacters()); |
| 299 | 299 |
| 300 ASSERT_FALSE(iterator.next(&wordResult)); | 300 ASSERT_FALSE(iterator.next(&wordResult)); |
| 301 } | 301 } |
| 302 | 302 |
| 303 TEST_F(CachingWordShaperTest, SegmentEmojiPilotJudgeSequence) { |
| 304 // A family followed by a couple with heart emoji sequence, |
| 305 // the latter including a variation selector. |
| 306 const UChar str[] = {0xD83D, 0xDC68, 0xD83C, 0xDFFB, 0x200D, 0x2696, 0xFE0F, |
| 307 0xD83D, 0xDC68, 0xD83C, 0xDFFB, 0x200D, 0x2708, 0xFE0F}; |
| 308 TextRun textRun(str, ARRAY_SIZE(str)); |
| 309 |
| 310 RefPtr<const ShapeResult> wordResult; |
| 311 CachingWordShapeIterator iterator(cache.get(), textRun, &font); |
| 312 |
| 313 ASSERT_TRUE(iterator.next(&wordResult)); |
| 314 EXPECT_EQ(ARRAY_SIZE(str), wordResult->numCharacters()); |
| 315 |
| 316 ASSERT_FALSE(iterator.next(&wordResult)); |
| 317 } |
| 318 |
| 303 TEST_F(CachingWordShaperTest, SegmentEmojiHeartZWJSequence) { | 319 TEST_F(CachingWordShaperTest, SegmentEmojiHeartZWJSequence) { |
| 304 // A ZWJ, followed by two family ZWJ Sequences. | 320 // A ZWJ, followed by two family ZWJ Sequences. |
| 305 const UChar str[] = {0xD83D, 0xDC69, 0x200D, 0x2764, 0xFE0F, 0x200D, | 321 const UChar str[] = {0xD83D, 0xDC69, 0x200D, 0x2764, 0xFE0F, 0x200D, |
| 306 0xD83D, 0xDC8B, 0x200D, 0xD83D, 0xDC68, 0x0}; | 322 0xD83D, 0xDC8B, 0x200D, 0xD83D, 0xDC68, 0x0}; |
| 307 TextRun textRun(str, 11); | 323 TextRun textRun(str, 11); |
| 308 | 324 |
| 309 RefPtr<const ShapeResult> wordResult; | 325 RefPtr<const ShapeResult> wordResult; |
| 310 CachingWordShapeIterator iterator(cache.get(), textRun, &font); | 326 CachingWordShapeIterator iterator(cache.get(), textRun, &font); |
| 311 | 327 |
| 312 ASSERT_TRUE(iterator.next(&wordResult)); | 328 ASSERT_TRUE(iterator.next(&wordResult)); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 // The total width of periods and spaces should be longer than the width of | 468 // The total width of periods and spaces should be longer than the width of |
| 453 // periods alone. | 469 // periods alone. |
| 454 ASSERT_GT(periodsAndSpacesWidth, periodsWidth); | 470 ASSERT_GT(periodsAndSpacesWidth, periodsWidth); |
| 455 | 471 |
| 456 // The glyph bounds of periods and spaces should be longer than the glyph | 472 // The glyph bounds of periods and spaces should be longer than the glyph |
| 457 // bounds of periods alone. | 473 // bounds of periods alone. |
| 458 ASSERT_GT(periodsAndSpacesGlyphBounds.width(), periodsGlyphBounds.width()); | 474 ASSERT_GT(periodsAndSpacesGlyphBounds.width(), periodsGlyphBounds.width()); |
| 459 } | 475 } |
| 460 | 476 |
| 461 } // namespace blink | 477 } // namespace blink |
| OLD | NEW |