OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 22 matching lines...) Expand all Loading... |
33 #include "WebFrame.h" | 33 #include "WebFrame.h" |
34 | 34 |
35 #include <gmock/gmock.h> | 35 #include <gmock/gmock.h> |
36 #include <gtest/gtest.h> | 36 #include <gtest/gtest.h> |
37 #include <v8.h> | 37 #include <v8.h> |
38 #include "FrameTestHelpers.h" | 38 #include "FrameTestHelpers.h" |
39 #include "RuntimeEnabledFeatures.h" | 39 #include "RuntimeEnabledFeatures.h" |
40 #include "SkBitmap.h" | 40 #include "SkBitmap.h" |
41 #include "SkCanvas.h" | 41 #include "SkCanvas.h" |
42 #include "URLTestHelpers.h" | 42 #include "URLTestHelpers.h" |
| 43 #include "UserAgentStyleSheets.h" |
43 #include "WebDataSource.h" | 44 #include "WebDataSource.h" |
44 #include "WebDocument.h" | 45 #include "WebDocument.h" |
45 #include "WebFindOptions.h" | 46 #include "WebFindOptions.h" |
46 #include "WebFormElement.h" | 47 #include "WebFormElement.h" |
47 #include "WebFrameClient.h" | 48 #include "WebFrameClient.h" |
48 #include "WebFrameImpl.h" | 49 #include "WebFrameImpl.h" |
49 #include "WebHistoryItem.h" | 50 #include "WebHistoryItem.h" |
50 #include "WebRange.h" | 51 #include "WebRange.h" |
51 #include "WebScriptSource.h" | 52 #include "WebScriptSource.h" |
52 #include "WebSearchableFormData.h" | 53 #include "WebSearchableFormData.h" |
53 #include "WebSecurityOrigin.h" | 54 #include "WebSecurityOrigin.h" |
54 #include "WebSecurityPolicy.h" | 55 #include "WebSecurityPolicy.h" |
55 #include "WebSettings.h" | 56 #include "WebSettings.h" |
56 #include "WebSpellCheckClient.h" | 57 #include "WebSpellCheckClient.h" |
57 #include "WebTextCheckingCompletion.h" | 58 #include "WebTextCheckingCompletion.h" |
58 #include "WebTextCheckingResult.h" | 59 #include "WebTextCheckingResult.h" |
59 #include "WebViewClient.h" | 60 #include "WebViewClient.h" |
60 #include "WebViewImpl.h" | 61 #include "WebViewImpl.h" |
61 #include "core/clipboard/Clipboard.h" | 62 #include "core/clipboard/Clipboard.h" |
| 63 #include "core/css/StyleSheetContents.h" |
| 64 #include "core/css/resolver/ViewportStyleResolver.h" |
62 #include "core/dom/DocumentMarkerController.h" | 65 #include "core/dom/DocumentMarkerController.h" |
63 #include "core/dom/FullscreenElementStack.h" | 66 #include "core/dom/FullscreenElementStack.h" |
64 #include "core/dom/Range.h" | 67 #include "core/dom/Range.h" |
65 #include "core/editing/Editor.h" | 68 #include "core/editing/Editor.h" |
66 #include "core/editing/FrameSelection.h" | 69 #include "core/editing/FrameSelection.h" |
67 #include "core/editing/SpellChecker.h" | 70 #include "core/editing/SpellChecker.h" |
68 #include "core/editing/VisiblePosition.h" | 71 #include "core/editing/VisiblePosition.h" |
69 #include "core/events/MouseEvent.h" | 72 #include "core/events/MouseEvent.h" |
70 #include "core/frame/FrameView.h" | 73 #include "core/frame/FrameView.h" |
71 #include "core/frame/LocalFrame.h" | 74 #include "core/frame/LocalFrame.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 void registerMockedHttpURLLoad(const std::string& fileName) | 153 void registerMockedHttpURLLoad(const std::string& fileName) |
151 { | 154 { |
152 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseU
RL.c_str()), WebString::fromUTF8(fileName.c_str())); | 155 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseU
RL.c_str()), WebString::fromUTF8(fileName.c_str())); |
153 } | 156 } |
154 | 157 |
155 void registerMockedChromeURLLoad(const std::string& fileName) | 158 void registerMockedChromeURLLoad(const std::string& fileName) |
156 { | 159 { |
157 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_chrom
eURL.c_str()), WebString::fromUTF8(fileName.c_str())); | 160 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_chrom
eURL.c_str()), WebString::fromUTF8(fileName.c_str())); |
158 } | 161 } |
159 | 162 |
| 163 void applyViewportStyleOverride(FrameTestHelpers::WebViewHelper* webViewHelp
er) |
| 164 { |
| 165 RefPtrWillBeRawPtr<WebCore::StyleSheetContents> styleSheet = WebCore::St
yleSheetContents::create(WebCore::CSSParserContext(WebCore::UASheetMode, 0)); |
| 166 styleSheet->parseString(String(WebCore::viewportAndroidUserAgentStyleShe
et, sizeof(WebCore::viewportAndroidUserAgentStyleSheet))); |
| 167 OwnPtrWillBeRawPtr<WebCore::RuleSet> ruleSet = WebCore::RuleSet::create(
); |
| 168 ruleSet->addRulesFromSheet(styleSheet.get(), WebCore::MediaQueryEvaluato
r("screen")); |
| 169 |
| 170 Document* document = webViewHelper->webViewImpl()->page()->mainFrame()->
document(); |
| 171 document->ensureStyleResolver().viewportStyleResolver()->collectViewport
Rules(ruleSet.get(), WebCore::ViewportStyleResolver::UserAgentOrigin); |
| 172 document->ensureStyleResolver().viewportStyleResolver()->resolve(); |
| 173 } |
| 174 |
160 static void configueCompositingWebView(WebSettings* settings) | 175 static void configueCompositingWebView(WebSettings* settings) |
161 { | 176 { |
162 settings->setForceCompositingMode(true); | 177 settings->setForceCompositingMode(true); |
163 settings->setAcceleratedCompositingEnabled(true); | 178 settings->setAcceleratedCompositingEnabled(true); |
164 settings->setAcceleratedCompositingForFixedPositionEnabled(true); | 179 settings->setAcceleratedCompositingForFixedPositionEnabled(true); |
165 settings->setAcceleratedCompositingForOverflowScrollEnabled(true); | 180 settings->setAcceleratedCompositingForOverflowScrollEnabled(true); |
166 settings->setAcceleratedCompositingForScrollableFramesEnabled(true); | 181 settings->setAcceleratedCompositingForScrollableFramesEnabled(true); |
167 settings->setCompositedScrollingForFramesEnabled(true); | 182 settings->setCompositedScrollingForFramesEnabled(true); |
168 } | 183 } |
169 | 184 |
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 UseMockScrollbarSettings mockScrollbarSettings; | 890 UseMockScrollbarSettings mockScrollbarSettings; |
876 registerMockedHttpURLLoad("no_viewport_tag.html"); | 891 registerMockedHttpURLLoad("no_viewport_tag.html"); |
877 | 892 |
878 FixedLayoutTestWebViewClient client; | 893 FixedLayoutTestWebViewClient client; |
879 client.m_screenInfo.deviceScaleFactor = 1; | 894 client.m_screenInfo.deviceScaleFactor = 1; |
880 int viewportWidth = 640; | 895 int viewportWidth = 640; |
881 int viewportHeight = 480; | 896 int viewportHeight = 480; |
882 | 897 |
883 FrameTestHelpers::WebViewHelper webViewHelper; | 898 FrameTestHelpers::WebViewHelper webViewHelper; |
884 webViewHelper.initializeAndLoad(m_baseURL + "no_viewport_tag.html", true, 0,
&client, enableViewportSettings); | 899 webViewHelper.initializeAndLoad(m_baseURL + "no_viewport_tag.html", true, 0,
&client, enableViewportSettings); |
| 900 applyViewportStyleOverride(&webViewHelper); |
885 webViewHelper.webView()->settings()->setSupportDeprecatedTargetDensityDPI(tr
ue); | 901 webViewHelper.webView()->settings()->setSupportDeprecatedTargetDensityDPI(tr
ue); |
886 webViewHelper.webView()->settings()->setUseWideViewport(true); | 902 webViewHelper.webView()->settings()->setUseWideViewport(true); |
887 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 903 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
888 | 904 |
889 webViewHelper.webView()->setFixedLayoutSize(WebSize(viewportWidth, viewportH
eight)); | 905 webViewHelper.webView()->setFixedLayoutSize(WebSize(viewportWidth, viewportH
eight)); |
890 EXPECT_TRUE(webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->needs
Layout()); | 906 EXPECT_TRUE(webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->needs
Layout()); |
891 webViewHelper.webView()->layout(); | 907 webViewHelper.webView()->layout(); |
892 EXPECT_EQ(viewportWidth, webViewHelper.webViewImpl()->mainFrameImpl()->frame
View()->contentsSize().width()); | 908 EXPECT_EQ(viewportWidth, webViewHelper.webViewImpl()->mainFrameImpl()->frame
View()->contentsSize().width()); |
893 | 909 |
894 webViewHelper.webView()->setFixedLayoutSize(WebSize(0, 0)); | 910 webViewHelper.webView()->setFixedLayoutSize(WebSize(0, 0)); |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1130 UseMockScrollbarSettings mockScrollbarSettings; | 1146 UseMockScrollbarSettings mockScrollbarSettings; |
1131 registerMockedHttpURLLoad("no_viewport_tag.html"); | 1147 registerMockedHttpURLLoad("no_viewport_tag.html"); |
1132 | 1148 |
1133 FixedLayoutTestWebViewClient client; | 1149 FixedLayoutTestWebViewClient client; |
1134 client.m_screenInfo.deviceScaleFactor = 1; | 1150 client.m_screenInfo.deviceScaleFactor = 1; |
1135 int viewportWidth = 640; | 1151 int viewportWidth = 640; |
1136 int viewportHeight = 480; | 1152 int viewportHeight = 480; |
1137 | 1153 |
1138 FrameTestHelpers::WebViewHelper webViewHelper; | 1154 FrameTestHelpers::WebViewHelper webViewHelper; |
1139 webViewHelper.initializeAndLoad(m_baseURL + "no_viewport_tag.html", true, 0,
&client, enableViewportSettings); | 1155 webViewHelper.initializeAndLoad(m_baseURL + "no_viewport_tag.html", true, 0,
&client, enableViewportSettings); |
| 1156 applyViewportStyleOverride(&webViewHelper); |
1140 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); | 1157 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); |
1141 webViewHelper.webView()->settings()->setUseWideViewport(true); | 1158 webViewHelper.webView()->settings()->setUseWideViewport(true); |
1142 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 1159 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
1143 | 1160 |
1144 EXPECT_EQ(980, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->co
ntentsSize().width()); | 1161 EXPECT_EQ(980, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->co
ntentsSize().width()); |
1145 EXPECT_EQ(980.0 / viewportWidth * viewportHeight, webViewHelper.webViewImpl(
)->mainFrameImpl()->frameView()->contentsSize().height()); | 1162 EXPECT_EQ(980.0 / viewportWidth * viewportHeight, webViewHelper.webViewImpl(
)->mainFrameImpl()->frameView()->contentsSize().height()); |
1146 } | 1163 } |
1147 | 1164 |
1148 TEST_F(WebFrameTest, NoWideViewportAndHeightInMeta) | 1165 TEST_F(WebFrameTest, NoWideViewportAndHeightInMeta) |
1149 { | 1166 { |
(...skipping 19 matching lines...) Expand all Loading... |
1169 UseMockScrollbarSettings mockScrollbarSettings; | 1186 UseMockScrollbarSettings mockScrollbarSettings; |
1170 registerMockedHttpURLLoad("viewport-2x-initial-scale.html"); | 1187 registerMockedHttpURLLoad("viewport-2x-initial-scale.html"); |
1171 | 1188 |
1172 FixedLayoutTestWebViewClient client; | 1189 FixedLayoutTestWebViewClient client; |
1173 client.m_screenInfo.deviceScaleFactor = 1; | 1190 client.m_screenInfo.deviceScaleFactor = 1; |
1174 int viewportWidth = 640; | 1191 int viewportWidth = 640; |
1175 int viewportHeight = 480; | 1192 int viewportHeight = 480; |
1176 | 1193 |
1177 FrameTestHelpers::WebViewHelper webViewHelper; | 1194 FrameTestHelpers::WebViewHelper webViewHelper; |
1178 webViewHelper.initializeAndLoad(m_baseURL + "viewport-2x-initial-scale.html"
, true, 0, &client, enableViewportSettings); | 1195 webViewHelper.initializeAndLoad(m_baseURL + "viewport-2x-initial-scale.html"
, true, 0, &client, enableViewportSettings); |
| 1196 applyViewportStyleOverride(&webViewHelper); |
1179 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); | 1197 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); |
1180 webViewHelper.webView()->settings()->setUseWideViewport(true); | 1198 webViewHelper.webView()->settings()->setUseWideViewport(true); |
1181 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 1199 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
1182 | 1200 |
1183 EXPECT_EQ(980, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->co
ntentsSize().width()); | 1201 EXPECT_EQ(980, webViewHelper.webViewImpl()->mainFrameImpl()->frameView()->co
ntentsSize().width()); |
1184 EXPECT_EQ(980.0 / viewportWidth * viewportHeight, webViewHelper.webViewImpl(
)->mainFrameImpl()->frameView()->contentsSize().height()); | 1202 EXPECT_EQ(980.0 / viewportWidth * viewportHeight, webViewHelper.webViewImpl(
)->mainFrameImpl()->frameView()->contentsSize().height()); |
1185 } | 1203 } |
1186 | 1204 |
1187 TEST_F(WebFrameTest, PageViewportInitialScaleOverridesLoadWithOverviewMode) | 1205 TEST_F(WebFrameTest, PageViewportInitialScaleOverridesLoadWithOverviewMode) |
1188 { | 1206 { |
(...skipping 19 matching lines...) Expand all Loading... |
1208 UseMockScrollbarSettings mockScrollbarSettings; | 1226 UseMockScrollbarSettings mockScrollbarSettings; |
1209 | 1227 |
1210 registerMockedHttpURLLoad("fixed_layout.html"); | 1228 registerMockedHttpURLLoad("fixed_layout.html"); |
1211 | 1229 |
1212 FixedLayoutTestWebViewClient client; | 1230 FixedLayoutTestWebViewClient client; |
1213 client.m_screenInfo.deviceScaleFactor = 1; | 1231 client.m_screenInfo.deviceScaleFactor = 1; |
1214 float enforcedPageScaleFactor = 2.0f; | 1232 float enforcedPageScaleFactor = 2.0f; |
1215 | 1233 |
1216 FrameTestHelpers::WebViewHelper webViewHelper; | 1234 FrameTestHelpers::WebViewHelper webViewHelper; |
1217 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, 0, &c
lient, enableViewportSettings); | 1235 webViewHelper.initializeAndLoad(m_baseURL + "fixed_layout.html", true, 0, &c
lient, enableViewportSettings); |
| 1236 applyViewportStyleOverride(&webViewHelper); |
1218 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); | 1237 webViewHelper.webView()->settings()->setWideViewportQuirkEnabled(true); |
1219 webViewHelper.webView()->settings()->setLoadWithOverviewMode(false); | 1238 webViewHelper.webView()->settings()->setLoadWithOverviewMode(false); |
1220 webViewHelper.webView()->setInitialPageScaleOverride(enforcedPageScaleFactor
); | 1239 webViewHelper.webView()->setInitialPageScaleOverride(enforcedPageScaleFactor
); |
1221 webViewHelper.webView()->layout(); | 1240 webViewHelper.webView()->layout(); |
1222 | 1241 |
1223 EXPECT_EQ(enforcedPageScaleFactor, webViewHelper.webView()->pageScaleFactor(
)); | 1242 EXPECT_EQ(enforcedPageScaleFactor, webViewHelper.webView()->pageScaleFactor(
)); |
1224 | 1243 |
1225 int viewportWidth = 640; | 1244 int viewportWidth = 640; |
1226 int viewportHeight = 480; | 1245 int viewportHeight = 480; |
1227 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); | 1246 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeight)); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1291 FixedLayoutTestWebViewClient client; | 1310 FixedLayoutTestWebViewClient client; |
1292 client.m_screenInfo.deviceScaleFactor = 1; | 1311 client.m_screenInfo.deviceScaleFactor = 1; |
1293 int viewportWidth = 400; | 1312 int viewportWidth = 400; |
1294 int viewportHeight = 300; | 1313 int viewportHeight = 300; |
1295 float enforcedPageScaleFactor = 0.75f; | 1314 float enforcedPageScaleFactor = 0.75f; |
1296 | 1315 |
1297 for (size_t i = 0; i < ARRAY_SIZE(pages); ++i) { | 1316 for (size_t i = 0; i < ARRAY_SIZE(pages); ++i) { |
1298 for (int quirkEnabled = 0; quirkEnabled <= 1; ++quirkEnabled) { | 1317 for (int quirkEnabled = 0; quirkEnabled <= 1; ++quirkEnabled) { |
1299 FrameTestHelpers::WebViewHelper webViewHelper; | 1318 FrameTestHelpers::WebViewHelper webViewHelper; |
1300 webViewHelper.initializeAndLoad(m_baseURL + pages[i], true, 0, &clie
nt, enableViewportSettings); | 1319 webViewHelper.initializeAndLoad(m_baseURL + pages[i], true, 0, &clie
nt, enableViewportSettings); |
| 1320 applyViewportStyleOverride(&webViewHelper); |
1301 webViewHelper.webView()->settings()->setClobberUserAgentInitialScale
Quirk(quirkEnabled); | 1321 webViewHelper.webView()->settings()->setClobberUserAgentInitialScale
Quirk(quirkEnabled); |
1302 webViewHelper.webView()->setInitialPageScaleOverride(enforcedPageSca
leFactor); | 1322 webViewHelper.webView()->setInitialPageScaleOverride(enforcedPageSca
leFactor); |
1303 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeigh
t)); | 1323 webViewHelper.webView()->resize(WebSize(viewportWidth, viewportHeigh
t)); |
1304 | 1324 |
1305 float expectedPageScaleFactor = quirkEnabled && i < ARRAY_SIZE(pageS
caleFactors) ? pageScaleFactors[i] : enforcedPageScaleFactor; | 1325 float expectedPageScaleFactor = quirkEnabled && i < ARRAY_SIZE(pageS
caleFactors) ? pageScaleFactors[i] : enforcedPageScaleFactor; |
1306 EXPECT_EQ(expectedPageScaleFactor, webViewHelper.webView()->pageScal
eFactor()); | 1326 EXPECT_EQ(expectedPageScaleFactor, webViewHelper.webView()->pageScal
eFactor()); |
1307 } | 1327 } |
1308 } | 1328 } |
1309 } | 1329 } |
1310 | 1330 |
(...skipping 4079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5390 EXPECT_EQ(2U, container->percentHeightDescendants()->size()); | 5410 EXPECT_EQ(2U, container->percentHeightDescendants()->size()); |
5391 EXPECT_TRUE(container->percentHeightDescendants()->contains(percentHeightInA
nonymous)); | 5411 EXPECT_TRUE(container->percentHeightDescendants()->contains(percentHeightInA
nonymous)); |
5392 EXPECT_TRUE(container->percentHeightDescendants()->contains(percentHeightDir
ectChild)); | 5412 EXPECT_TRUE(container->percentHeightDescendants()->contains(percentHeightDir
ectChild)); |
5393 | 5413 |
5394 WebCore::RenderBlock* anonymousBlock = percentHeightInAnonymous->containingB
lock(); | 5414 WebCore::RenderBlock* anonymousBlock = percentHeightInAnonymous->containingB
lock(); |
5395 EXPECT_TRUE(anonymousBlock->isAnonymous()); | 5415 EXPECT_TRUE(anonymousBlock->isAnonymous()); |
5396 EXPECT_FALSE(anonymousBlock->hasPercentHeightDescendants()); | 5416 EXPECT_FALSE(anonymousBlock->hasPercentHeightDescendants()); |
5397 } | 5417 } |
5398 | 5418 |
5399 } // namespace | 5419 } // namespace |
OLD | NEW |