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 class TextAutosizerTest : public RenderingTest { | 10 class TextAutosizerTest : public RenderingTest { |
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 // (specified font-size = 16px) * (viewport width = 800px) / | 712 // (specified font-size = 16px) * (viewport width = 800px) / |
713 // (window width = 320px) = 40px. | 713 // (window width = 320px) = 40px. |
714 EXPECT_FLOAT_EQ(40.f, rubyBlock->layoutObject()->style()->computedFontSize()); | 714 EXPECT_FLOAT_EQ(40.f, rubyBlock->layoutObject()->style()->computedFontSize()); |
715 } | 715 } |
716 | 716 |
717 TEST_F(TextAutosizerTest, ResizeAndGlyphOverflowChanged) { | 717 TEST_F(TextAutosizerTest, ResizeAndGlyphOverflowChanged) { |
718 document().settings()->setTextAutosizingWindowSizeOverride(IntSize(360, 640)); | 718 document().settings()->setTextAutosizingWindowSizeOverride(IntSize(360, 640)); |
719 Element* html = document().body()->parentElement(); | 719 Element* html = document().body()->parentElement(); |
720 html->setInnerHTML( | 720 html->setInnerHTML( |
721 "<head>" | 721 "<head>" |
722 " <meta name='viewport' content='800'>" | 722 " <meta name='viewport' content='width=800'>" |
723 " <style>" | 723 " <style>" |
724 " html { font-size:16px; font-family:'Times New Roman';}" | 724 " html { font-size:16px; font-family:'Times New Roman';}" |
725 " </style>" | 725 " </style>" |
726 "</head>" | 726 "</head>" |
727 "<body>" | 727 "<body>" |
728 " <span id='autosized' style='font-size:10px'>" | 728 " <span id='autosized' style='font-size:10px'>" |
729 " Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do" | 729 " Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do" |
730 " eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim" | 730 " eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim" |
731 " ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut" | 731 " ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut" |
732 " aliquip ex ea commodo consequat. Duis aute irure dolor in" | 732 " aliquip ex ea commodo consequat. Duis aute irure dolor in" |
(...skipping 12 matching lines...) Expand all Loading... |
745 "</body>", | 745 "</body>", |
746 ASSERT_NO_EXCEPTION); | 746 ASSERT_NO_EXCEPTION); |
747 document().view()->updateAllLifecyclePhases(); | 747 document().view()->updateAllLifecyclePhases(); |
748 | 748 |
749 document().settings()->setTextAutosizingWindowSizeOverride(IntSize(640, 360)); | 749 document().settings()->setTextAutosizingWindowSizeOverride(IntSize(640, 360)); |
750 document().view()->updateAllLifecyclePhases(); | 750 document().view()->updateAllLifecyclePhases(); |
751 | 751 |
752 document().settings()->setTextAutosizingWindowSizeOverride(IntSize(360, 640)); | 752 document().settings()->setTextAutosizingWindowSizeOverride(IntSize(360, 640)); |
753 document().view()->updateAllLifecyclePhases(); | 753 document().view()->updateAllLifecyclePhases(); |
754 } | 754 } |
| 755 |
| 756 TEST_F(TextAutosizerTest, LayoutViewWidthProvider) { |
| 757 Element* html = document().body()->parentElement(); |
| 758 html->setInnerHTML( |
| 759 "<head>" |
| 760 " <meta name='viewport' content='width=800'>" |
| 761 " <style>" |
| 762 " html { font-size:16px;}" |
| 763 " #content {margin-left: 140px;}" |
| 764 " </style>" |
| 765 "</head>" |
| 766 "<body>" |
| 767 " <div id='content'>" |
| 768 " Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do" |
| 769 " eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim" |
| 770 " ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut" |
| 771 " aliquip ex ea commodo consequat. Duis aute irure dolor in" |
| 772 " reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla" |
| 773 " pariatur. Excepteur sint occaecat cupidatat non proident, sunt in" |
| 774 " culpa qui officia deserunt mollit anim id est laborum." |
| 775 " </div>" |
| 776 " <div id='panel'></div>" |
| 777 "</body>", |
| 778 ASSERT_NO_EXCEPTION); |
| 779 document().view()->updateAllLifecyclePhases(); |
| 780 |
| 781 Element* content = document().getElementById("content"); |
| 782 // (specified font-size = 16px) * (viewport width = 800px) / |
| 783 // (window width = 320px) = 40px. |
| 784 EXPECT_FLOAT_EQ(40.f, content->layoutObject()->style()->computedFontSize()); |
| 785 |
| 786 document().getElementById("panel")->setInnerHTML("insert text"); |
| 787 content->setInnerHTML(content->innerHTML()); |
| 788 document().view()->updateAllLifecyclePhases(); |
| 789 |
| 790 // (specified font-size = 16px) * (viewport width = 800px) / |
| 791 // (window width = 320px) = 40px. |
| 792 EXPECT_FLOAT_EQ(40.f, content->layoutObject()->style()->computedFontSize()); |
| 793 } |
| 794 |
755 } // namespace blink | 795 } // namespace blink |
OLD | NEW |