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 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
732 EXPECT_FLOAT_EQ(40.f, | 732 EXPECT_FLOAT_EQ(40.f, |
733 ruby_block->GetLayoutObject()->Style()->ComputedFontSize()); | 733 ruby_block->GetLayoutObject()->Style()->ComputedFontSize()); |
734 } | 734 } |
735 | 735 |
736 TEST_F(TextAutosizerTest, ResizeAndGlyphOverflowChanged) { | 736 TEST_F(TextAutosizerTest, ResizeAndGlyphOverflowChanged) { |
737 GetDocument().GetSettings()->SetTextAutosizingWindowSizeOverride( | 737 GetDocument().GetSettings()->SetTextAutosizingWindowSizeOverride( |
738 IntSize(360, 640)); | 738 IntSize(360, 640)); |
739 Element* html = GetDocument().body()->parentElement(); | 739 Element* html = GetDocument().body()->parentElement(); |
740 html->setInnerHTML( | 740 html->setInnerHTML( |
741 "<head>" | 741 "<head>" |
742 " <meta name='viewport' content='800'>" | 742 " <meta name='viewport' content='width=800'>" |
743 " <style>" | 743 " <style>" |
744 " html { font-size:16px; font-family:'Times New Roman';}" | 744 " html { font-size:16px; font-family:'Times New Roman';}" |
745 " </style>" | 745 " </style>" |
746 "</head>" | 746 "</head>" |
747 "<body>" | 747 "<body>" |
748 " <span id='autosized' style='font-size:10px'>" | 748 " <span id='autosized' style='font-size:10px'>" |
749 " Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do" | 749 " Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do" |
750 " eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim" | 750 " eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim" |
751 " ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut" | 751 " ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut" |
752 " aliquip ex ea commodo consequat. Duis aute irure dolor in" | 752 " aliquip ex ea commodo consequat. Duis aute irure dolor in" |
(...skipping 14 matching lines...) Expand all Loading... | |
767 GetDocument().View()->UpdateAllLifecyclePhases(); | 767 GetDocument().View()->UpdateAllLifecyclePhases(); |
768 | 768 |
769 GetDocument().GetSettings()->SetTextAutosizingWindowSizeOverride( | 769 GetDocument().GetSettings()->SetTextAutosizingWindowSizeOverride( |
770 IntSize(640, 360)); | 770 IntSize(640, 360)); |
771 GetDocument().View()->UpdateAllLifecyclePhases(); | 771 GetDocument().View()->UpdateAllLifecyclePhases(); |
772 | 772 |
773 GetDocument().GetSettings()->SetTextAutosizingWindowSizeOverride( | 773 GetDocument().GetSettings()->SetTextAutosizingWindowSizeOverride( |
774 IntSize(360, 640)); | 774 IntSize(360, 640)); |
775 GetDocument().View()->UpdateAllLifecyclePhases(); | 775 GetDocument().View()->UpdateAllLifecyclePhases(); |
776 } | 776 } |
777 | |
778 TEST_F(TextAutosizerTest, LayoutViewWidthProvider) { | |
779 Element* html = GetDocument().body()->parentElement(); | |
780 html->setInnerHTML( | |
781 "<head>" | |
782 " <meta name='viewport' content='width=800'>" | |
783 " <style>" | |
784 " html { font-size:16px;}" | |
785 " #content {margin-left: 140px;}" | |
786 " </style>" | |
787 "</head>" | |
788 "<body>" | |
789 " <div id='content'>" | |
790 " Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do" | |
791 " eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim" | |
792 " ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut" | |
793 " aliquip ex ea commodo consequat. Duis aute irure dolor in" | |
794 " reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla" | |
795 " pariatur. Excepteur sint occaecat cupidatat non proident, sunt in" | |
796 " culpa qui officia deserunt mollit anim id est laborum." | |
797 " </div>" | |
798 " <div id='panel'></div>" | |
799 "</body>", | |
800 ASSERT_NO_EXCEPTION); | |
801 GetDocument().View()->UpdateAllLifecyclePhases(); | |
802 | |
803 Element* content = GetDocument().GetElementById("content"); | |
804 // (specified font-size = 16px) * (viewport width = 800px) / | |
805 // (window width = 320px) = 40px. | |
806 EXPECT_FLOAT_EQ(40.f, | |
807 content->GetLayoutObject()->Style()->ComputedFontSize()); | |
808 | |
809 GetDocument().GetElementById("panel")->setInnerHTML("insert text"); | |
810 content->setInnerHTML(content->innerHTML()); | |
pdr.
2017/04/20 06:25:46
Sorry I missed this before. Why is this needed?
cathiechentx
2017/04/27 10:51:42
This is to trigger layout of <div id='content'>. S
| |
811 GetDocument().View()->UpdateAllLifecyclePhases(); | |
812 | |
813 // (specified font-size = 16px) * (viewport width = 800px) / | |
814 // (window width = 320px) = 40px. | |
815 EXPECT_FLOAT_EQ(40.f, | |
816 content->GetLayoutObject()->Style()->ComputedFontSize()); | |
817 } | |
818 | |
777 } // namespace blink | 819 } // namespace blink |
OLD | NEW |