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 "core/layout/LayoutObject.h" | 5 #include "core/layout/LayoutObject.h" |
6 #include "core/layout/LayoutTestHelper.h" | 6 #include "core/layout/LayoutTestHelper.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 | 8 |
9 namespace blink { | 9 namespace blink { |
10 | 10 |
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 document().getElementById("longText")->layoutObject(); | 654 document().getElementById("longText")->layoutObject(); |
655 EXPECT_FLOAT_EQ(16.f, longText->style()->specifiedFontSize()); | 655 EXPECT_FLOAT_EQ(16.f, longText->style()->specifiedFontSize()); |
656 //(specified font-size = 16px) * (block width = 560px) / | 656 //(specified font-size = 16px) * (block width = 560px) / |
657 // (window width = 320px) = 28px. | 657 // (window width = 320px) = 28px. |
658 EXPECT_FLOAT_EQ(28.f, longText->style()->computedFontSize()); | 658 EXPECT_FLOAT_EQ(28.f, longText->style()->computedFontSize()); |
659 LayoutObject* shortText = | 659 LayoutObject* shortText = |
660 document().getElementById("shortText")->layoutObject(); | 660 document().getElementById("shortText")->layoutObject(); |
661 EXPECT_FLOAT_EQ(16.f, shortText->style()->specifiedFontSize()); | 661 EXPECT_FLOAT_EQ(16.f, shortText->style()->specifiedFontSize()); |
662 EXPECT_FLOAT_EQ(28.f, shortText->style()->computedFontSize()); | 662 EXPECT_FLOAT_EQ(28.f, shortText->style()->computedFontSize()); |
663 } | 663 } |
| 664 |
| 665 TEST_F(TextAutosizerTest, AutosizeInnerContentOfRuby) { |
| 666 setBodyInnerHTML( |
| 667 "<meta name='viewport' content='width=800'>" |
| 668 "<style>" |
| 669 " html { font-size: 16px; }" |
| 670 " body { width: 800px; margin: 0; overflow-y: hidden; }" |
| 671 "</style>" |
| 672 "<div id='autosized'>" |
| 673 " 東京特許許可局許可局長 今日" |
| 674 " <ruby>" |
| 675 " <rb id='rubyInline'>急遽</rb>" |
| 676 " <rp>(</rp>" |
| 677 " <rt>きゅうきょ</rt>" |
| 678 " <rp>)</rp>" |
| 679 " </ruby>" |
| 680 " 許可却下、<br><br>" |
| 681 " <span>" |
| 682 " Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec " |
| 683 " sed diam facilisis, elementum elit at, elementum sem. Aliquam " |
| 684 " consectetur leo at nisi fermentum, vitae maximus libero " |
| 685 "sodales. Sed " |
| 686 " laoreet congue ipsum, at tincidunt ante tempor sed. Cras eget " |
| 687 "erat " |
| 688 " mattis urna vestibulum porta. Sed tempus vitae dui et suscipit. " |
| 689 " Curabitur laoreet accumsan pharetra. Nunc facilisis, elit sit " |
| 690 "amet " |
| 691 " sollicitudin condimentum, ipsum velit ultricies mi, eget " |
| 692 "dapibus nunc " |
| 693 " nulla nec sapien. Fusce dictum imperdiet aliquet." |
| 694 " </span>" |
| 695 " <ruby style='display:block'>" |
| 696 " <rb id='rubyBlock'>拼音</rb>" |
| 697 " <rt>pin yin</rt>" |
| 698 " </ruby>" |
| 699 "</div>"); |
| 700 document().view()->updateAllLifecyclePhases(); |
| 701 |
| 702 Element* rubyInline = document().getElementById("rubyInline"); |
| 703 EXPECT_FLOAT_EQ(16.f, |
| 704 rubyInline->layoutObject()->style()->specifiedFontSize()); |
| 705 // (specified font-size = 16px) * (viewport width = 800px) / |
| 706 // (window width = 320px) = 40px. |
| 707 EXPECT_FLOAT_EQ(40.f, |
| 708 rubyInline->layoutObject()->style()->computedFontSize()); |
| 709 |
| 710 Element* rubyBlock = document().getElementById("rubyBlock"); |
| 711 EXPECT_FLOAT_EQ(16.f, |
| 712 rubyBlock->layoutObject()->style()->specifiedFontSize()); |
| 713 // (specified font-size = 16px) * (viewport width = 800px) / |
| 714 // (window width = 320px) = 40px. |
| 715 EXPECT_FLOAT_EQ(40.f, rubyBlock->layoutObject()->style()->computedFontSize()); |
| 716 } |
664 } // namespace blink | 717 } // namespace blink |
OLD | NEW |