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

Unified Diff: third_party/WebKit/Source/core/layout/TextAutosizerTest.cpp

Issue 2299213003: Fix the inconsistent problem while the content of textNodes is changed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git rebase... Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/layout/TextAutosizer.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/TextAutosizerTest.cpp
diff --git a/third_party/WebKit/Source/core/layout/TextAutosizerTest.cpp b/third_party/WebKit/Source/core/layout/TextAutosizerTest.cpp
index d08f7e425b3185b7a4572131af8c7674f08b964a..f60be84782e83130a34f20bae85a1a030b712912 100644
--- a/third_party/WebKit/Source/core/layout/TextAutosizerTest.cpp
+++ b/third_party/WebKit/Source/core/layout/TextAutosizerTest.cpp
@@ -483,4 +483,182 @@ TEST_F(TextAutosizerTest, DeviceScaleAdjustmentWithViewport) {
EXPECT_FLOAT_EQ(60.f, autosized->layoutObject()->style()->computedFontSize());
}
+TEST_F(TextAutosizerTest, ChangingSuperClusterFirstText) {
+ setBodyInnerHTML(
+ "<meta name='viewport' content='width=800'>"
+ "<style>"
+ " html { font-size: 16px; }"
+ " body { width: 800px; margin: 0; overflow-y: hidden; }"
+ " .supercluster { width:560px; }"
+ "</style>"
+ "<div class='supercluster'>"
+ " <div id='longText'>short blah blah</div>"
+ "</div>"
+ "<div class='supercluster'>"
+ " <div id='shortText'>short blah blah</div>"
+ "</div>");
+ document().view()->updateAllLifecyclePhases();
+
+ Element* longTextElement = document().getElementById("longText");
+ longTextElement->setInnerHTML(
+ " Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed "
+ "do eiusmod tempor"
+ " incididunt ut labore et dolore magna aliqua. Ut enim ad minim "
+ "veniam, quis nostrud"
+ " exercitation ullamco laboris nisi ut aliquip ex ea commodo "
+ "consequat. Duis aute irure"
+ " dolor in reprehenderit in voluptate velit esse cillum dolore eu "
+ "fugiat nulla pariatur."
+ " Excepteur sint occaecat cupidatat non proident, sunt in culpa "
+ "qui officia deserunt"
+ " mollit anim id est laborum.",
+ ASSERT_NO_EXCEPTION);
+ document().view()->updateAllLifecyclePhases();
+
+ LayoutObject* longText =
+ document().getElementById("longText")->layoutObject();
+ EXPECT_FLOAT_EQ(16.f, longText->style()->specifiedFontSize());
+ //(specified font-size = 16px) * (block width = 560px) /
+ // (window width = 320px) = 28px.
+ EXPECT_FLOAT_EQ(28.f, longText->style()->computedFontSize());
+ LayoutObject* shortText =
+ document().getElementById("shortText")->layoutObject();
+ EXPECT_FLOAT_EQ(16.f, shortText->style()->specifiedFontSize());
+ EXPECT_FLOAT_EQ(28.f, shortText->style()->computedFontSize());
+}
+
+TEST_F(TextAutosizerTest, ChangingSuperClusterSecondText) {
+ setBodyInnerHTML(
+ "<meta name='viewport' content='width=800'>"
+ "<style>"
+ " html { font-size: 16px; }"
+ " body { width: 800px; margin: 0; overflow-y: hidden; }"
+ " .supercluster { width:560px; }"
+ "</style>"
+ "<div class='supercluster'>"
+ " <div id='shortText'>short blah blah</div>"
+ "</div>"
+ "<div class='supercluster'>"
+ " <div id='longText'>short blah blah</div>"
+ "</div>");
+ document().view()->updateAllLifecyclePhases();
+
+ Element* longTextElement = document().getElementById("longText");
+ longTextElement->setInnerHTML(
+ " Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed "
+ "do eiusmod tempor"
+ " incididunt ut labore et dolore magna aliqua. Ut enim ad minim "
+ "veniam, quis nostrud"
+ " exercitation ullamco laboris nisi ut aliquip ex ea commodo "
+ "consequat. Duis aute irure"
+ " dolor in reprehenderit in voluptate velit esse cillum dolore eu "
+ "fugiat nulla pariatur."
+ " Excepteur sint occaecat cupidatat non proident, sunt in culpa "
+ "qui officia deserunt"
+ " mollit anim id est laborum.",
+ ASSERT_NO_EXCEPTION);
+ document().view()->updateAllLifecyclePhases();
+
+ LayoutObject* longText =
+ document().getElementById("longText")->layoutObject();
+ EXPECT_FLOAT_EQ(16.f, longText->style()->specifiedFontSize());
+ //(specified font-size = 16px) * (block width = 560px) /
+ // (window width = 320px) = 28px.
+ EXPECT_FLOAT_EQ(28.f, longText->style()->computedFontSize());
+ LayoutObject* shortText =
+ document().getElementById("shortText")->layoutObject();
+ EXPECT_FLOAT_EQ(16.f, shortText->style()->specifiedFontSize());
+ EXPECT_FLOAT_EQ(28.f, shortText->style()->computedFontSize());
+}
+
+TEST_F(TextAutosizerTest, AddingSuperCluster) {
+ setBodyInnerHTML(
+ "<meta name='viewport' content='width=800'>"
+ "<style>"
+ " html { font-size: 16px; }"
+ " body { width: 800px; margin: 0; overflow-y: hidden; }"
+ " .supercluster { width:560px; }"
+ "</style>"
+ "<div>"
+ " <div class='supercluster' id='shortText'>"
+ " short blah blah"
+ " </div>"
+ "</div>"
+ "<div id='container'></div>");
+ document().view()->updateAllLifecyclePhases();
+
+ Element* container = document().getElementById("container");
+ container->setInnerHTML(
+ "<div class='supercluster' id='longText'>"
+ " Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed "
+ "do eiusmod tempor"
+ " incididunt ut labore et dolore magna aliqua. Ut enim ad minim "
+ "veniam, quis nostrud"
+ " exercitation ullamco laboris nisi ut aliquip ex ea commodo "
+ "consequat. Duis aute irure"
+ " dolor in reprehenderit in voluptate velit esse cillum dolore eu "
+ "fugiat nulla pariatur."
+ " Excepteur sint occaecat cupidatat non proident, sunt in culpa "
+ "qui officia deserunt"
+ " mollit anim id est laborum."
+ "</div>",
+ ASSERT_NO_EXCEPTION);
+ document().view()->updateAllLifecyclePhases();
+
+ LayoutObject* longText =
+ document().getElementById("longText")->layoutObject();
+ EXPECT_FLOAT_EQ(16.f, longText->style()->specifiedFontSize());
+ //(specified font-size = 16px) * (block width = 560px) /
+ // (window width = 320px) = 28px.
+ EXPECT_FLOAT_EQ(28.f, longText->style()->computedFontSize());
+ LayoutObject* shortText =
+ document().getElementById("shortText")->layoutObject();
+ EXPECT_FLOAT_EQ(16.f, shortText->style()->specifiedFontSize());
+ EXPECT_FLOAT_EQ(28.f, shortText->style()->computedFontSize());
+}
+
+TEST_F(TextAutosizerTest, ChangingInheritedClusterTextInsideSuperCluster) {
+ setBodyInnerHTML(
+ "<meta name='viewport' content='width=800'>"
+ "<style>"
+ " html { font-size: 16px; }"
+ " body { width: 800px; margin: 0; overflow-y: hidden; }"
+ " .supercluster { width:560px; }"
+ " .cluster{width:560px;}"
+ "</style>"
+ "<div class='supercluster'>"
+ " <div class='cluster' id='longText'>short blah blah</div>"
+ "</div>"
+ "<div class='supercluster'>"
+ " <div class='cluster' id='shortText'>short blah blah</div>"
+ "</div>");
+ document().view()->updateAllLifecyclePhases();
+
+ Element* longTextElement = document().getElementById("longText");
+ longTextElement->setInnerHTML(
+ " Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed "
+ "do eiusmod tempor"
+ " incididunt ut labore et dolore magna aliqua. Ut enim ad minim "
+ "veniam, quis nostrud"
+ " exercitation ullamco laboris nisi ut aliquip ex ea commodo "
+ "consequat. Duis aute irure"
+ " dolor in reprehenderit in voluptate velit esse cillum dolore eu "
+ "fugiat nulla pariatur."
+ " Excepteur sint occaecat cupidatat non proident, sunt in culpa "
+ "qui officia deserunt"
+ " mollit anim id est laborum.",
+ ASSERT_NO_EXCEPTION);
+ document().view()->updateAllLifecyclePhases();
+
+ LayoutObject* longText =
+ document().getElementById("longText")->layoutObject();
+ EXPECT_FLOAT_EQ(16.f, longText->style()->specifiedFontSize());
+ //(specified font-size = 16px) * (block width = 560px) /
+ // (window width = 320px) = 28px.
+ EXPECT_FLOAT_EQ(28.f, longText->style()->computedFontSize());
+ LayoutObject* shortText =
+ document().getElementById("shortText")->layoutObject();
+ EXPECT_FLOAT_EQ(16.f, shortText->style()->specifiedFontSize());
+ EXPECT_FLOAT_EQ(28.f, shortText->style()->computedFontSize());
+}
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/layout/TextAutosizer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698