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, narrowContentInsideNestedWideBlock) { |
| 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 " </style>" |
| 786 "</head>" |
| 787 "<body>" |
| 788 " <div style='width:800px'>" |
| 789 " <div style='width:800px'>" |
| 790 " <div style='width:200px' id='content'>" |
| 791 " Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed " |
| 792 " do eiusmod tempor incididunt ut labore et dolore magna aliqua." |
| 793 " Ut enim ad minim veniam, quis nostrud exercitation ullamco " |
| 794 " laboris nisi ut aliquip ex ea commodo consequat. Duis aute " |
| 795 " irure dolor in reprehenderit in voluptate velit esse cillum " |
| 796 " dolore eu fugiat nulla pariatur. Excepteur sint occaecat " |
| 797 " cupidatat non proident, sunt in culpa qui officia deserunt " |
| 798 " mollit anim id est laborum." |
| 799 " </div>" |
| 800 " </div>" |
| 801 " Content belong to first wide block." |
| 802 " </div>" |
| 803 "</body>", |
| 804 ASSERT_NO_EXCEPTION); |
| 805 GetDocument().View()->UpdateAllLifecyclePhases(); |
| 806 |
| 807 Element* content = GetDocument().getElementById("content"); |
| 808 //(content width = 200px) / (window width = 320px) < 1.0f, multiplier = 1.0, |
| 809 // font-size = 16px; |
| 810 EXPECT_FLOAT_EQ(16.f, |
| 811 content->GetLayoutObject()->Style()->ComputedFontSize()); |
| 812 } |
| 813 |
777 } // namespace blink | 814 } // namespace blink |
OLD | NEW |