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 793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 ASSERT_NO_EXCEPTION); | 804 ASSERT_NO_EXCEPTION); |
805 GetDocument().View()->UpdateAllLifecyclePhases(); | 805 GetDocument().View()->UpdateAllLifecyclePhases(); |
806 | 806 |
807 Element* content = GetDocument().getElementById("content"); | 807 Element* content = GetDocument().getElementById("content"); |
808 //(content width = 200px) / (window width = 320px) < 1.0f, multiplier = 1.0, | 808 //(content width = 200px) / (window width = 320px) < 1.0f, multiplier = 1.0, |
809 // font-size = 16px; | 809 // font-size = 16px; |
810 EXPECT_FLOAT_EQ(16.f, | 810 EXPECT_FLOAT_EQ(16.f, |
811 content->GetLayoutObject()->Style()->ComputedFontSize()); | 811 content->GetLayoutObject()->Style()->ComputedFontSize()); |
812 } | 812 } |
813 | 813 |
| 814 TEST_F(TextAutosizerTest, LayoutViewWidthProvider) { |
| 815 Element* html = GetDocument().body()->parentElement(); |
| 816 html->setInnerHTML( |
| 817 "<head>" |
| 818 " <meta name='viewport' content='width=800'>" |
| 819 " <style>" |
| 820 " html { font-size:16px;}" |
| 821 " #content {margin-left: 140px;}" |
| 822 " </style>" |
| 823 "</head>" |
| 824 "<body>" |
| 825 " <div id='content'>" |
| 826 " Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do" |
| 827 " eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim" |
| 828 " ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut" |
| 829 " aliquip ex ea commodo consequat. Duis aute irure dolor in" |
| 830 " reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla" |
| 831 " pariatur. Excepteur sint occaecat cupidatat non proident, sunt in" |
| 832 " culpa qui officia deserunt mollit anim id est laborum." |
| 833 " </div>" |
| 834 " <div id='panel'></div>" |
| 835 "</body>", |
| 836 ASSERT_NO_EXCEPTION); |
| 837 GetDocument().View()->UpdateAllLifecyclePhases(); |
| 838 |
| 839 Element* content = GetDocument().getElementById("content"); |
| 840 // (specified font-size = 16px) * (viewport width = 800px) / |
| 841 // (window width = 320px) = 40px. |
| 842 EXPECT_FLOAT_EQ(40.f, |
| 843 content->GetLayoutObject()->Style()->ComputedFontSize()); |
| 844 |
| 845 GetDocument().getElementById("panel")->setInnerHTML("insert text"); |
| 846 content->setInnerHTML(content->innerHTML()); |
| 847 GetDocument().View()->UpdateAllLifecyclePhases(); |
| 848 |
| 849 // (specified font-size = 16px) * (viewport width = 800px) / |
| 850 // (window width = 320px) = 40px. |
| 851 EXPECT_FLOAT_EQ(40.f, |
| 852 content->GetLayoutObject()->Style()->ComputedFontSize()); |
| 853 } |
| 854 |
814 } // namespace blink | 855 } // namespace blink |
OLD | NEW |