Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: third_party/WebKit/Source/core/layout/TextAutosizerTest.cpp

Issue 2817443003: Fix font-size shaking issue in some pages (Closed)
Patch Set: fix font-size shaking issue only Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
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());
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698