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

Side by Side Diff: third_party/WebKit/Source/web/tests/LayoutGeometryMapTest.cpp

Issue 2173963002: Ensure that we consistently check contains: paint for fixed position containment. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove trailing whitespace Created 4 years, 4 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 /* 1 /*
2 * Copyright (C) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 EXPECT_EQ(FloatQuad(FloatRect(21.0f, 20.0f, 15.0f, 25.0f)), rgm.mapToAncesto r(rect, getLayoutContainer(webView, "CenterDiv"))); 222 EXPECT_EQ(FloatQuad(FloatRect(21.0f, 20.0f, 15.0f, 25.0f)), rgm.mapToAncesto r(rect, getLayoutContainer(webView, "CenterDiv")));
223 223
224 rect = FloatRect(22.0f, 15.2f, 15.3f, 0.0f); 224 rect = FloatRect(22.0f, 15.2f, 15.3f, 0.0f);
225 EXPECT_EQ(FloatQuad(FloatRect(43.0f, 35.2f, 15.3f, 0.0f)), rgm.mapToAncestor (rect, getLayoutContainer(webView, "CenterDiv"))); 225 EXPECT_EQ(FloatQuad(FloatRect(43.0f, 35.2f, 15.3f, 0.0f)), rgm.mapToAncestor (rect, getLayoutContainer(webView, "CenterDiv")));
226 226
227 EXPECT_EQ(FloatQuad(FloatRect(43.0f, 35.2f, 15.3f, 0.0f)), rgm.mapToAncestor (rect, getLayoutContainer(webView, "InnerDiv"))); 227 EXPECT_EQ(FloatQuad(FloatRect(43.0f, 35.2f, 15.3f, 0.0f)), rgm.mapToAncestor (rect, getLayoutContainer(webView, "InnerDiv")));
228 228
229 EXPECT_EQ(FloatQuad(FloatRect(43.0f, 35.2f, 15.3f, 0.0f)), rgm.mapToAncestor (rect, nullptr)); 229 EXPECT_EQ(FloatQuad(FloatRect(43.0f, 35.2f, 15.3f, 0.0f)), rgm.mapToAncestor (rect, nullptr));
230 } 230 }
231 231
232 TEST_F(LayoutGeometryMapTest, ContainsFixedPositionTest)
233 {
234 registerMockedHttpURLLoad("rgm_contains_fixed_position_test.html");
235 FrameTestHelpers::WebViewHelper webViewHelper;
236 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "rgm_contains _fixed_position_test.html", true, 0, 0);
237 webView->resize(WebSize(1000, 1000));
238 webView->updateAllLifecyclePhases();
239
240 FloatRect rect(0.0f, 0.0f, 100.0f, 100.0f);
241 LayoutGeometryMap rgm;
242
243 // This fixed position element is not contained and so is attached at the to p of the viewport.
244 rgm.pushMappingsToAncestor(getLayoutBox(webView, "simple-container"), 0);
245 EXPECT_EQ(FloatQuad(FloatRect(8.0f, 100.0f, 100.0f, 100.0f)), rgm.mapToAnces tor(rect, nullptr));
246 rgm.pushMappingsToAncestor(getLayoutBox(webView, "fixed1"), getLayoutBox(web View, "simple-container"));
247 EXPECT_EQ(FloatQuad(FloatRect(8.0f, 50.0f, 100.0f, 100.0f)), rgm.mapToAncest or(rect, nullptr));
248 rgm.popMappingsToAncestor(static_cast<PaintLayer*>(nullptr));
249
250 // Transforms contain fixed position descendants.
251 rgm.pushMappingsToAncestor(getLayoutBox(webView, "has-transform"), 0);
252 EXPECT_EQ(FloatQuad(FloatRect(8.0f, 100.0f, 100.0f, 100.0f)), rgm.mapToAnces tor(rect, nullptr));
253 rgm.pushMappingsToAncestor(getLayoutBox(webView, "fixed2"), getLayoutBox(web View, "has-transform"));
254 EXPECT_EQ(FloatQuad(FloatRect(8.0f, 100.0f, 100.0f, 100.0f)), rgm.mapToAnces tor(rect, nullptr));
255 rgm.popMappingsToAncestor(static_cast<PaintLayer*>(nullptr));
256
257 // Paint containment contains fixed position descendants.
258 rgm.pushMappingsToAncestor(getLayoutBox(webView, "contains-paint"), 0);
259 EXPECT_EQ(FloatQuad(FloatRect(8.0f, 100.0f, 100.0f, 100.0f)), rgm.mapToAnces tor(rect, nullptr));
260 rgm.pushMappingsToAncestor(getLayoutBox(webView, "fixed3"), getLayoutBox(web View, "contains-paint"));
261 EXPECT_EQ(FloatQuad(FloatRect(8.0f, 100.0f, 100.0f, 100.0f)), rgm.mapToAnces tor(rect, nullptr));
262 rgm.popMappingsToAncestor(static_cast<PaintLayer*>(nullptr));
263 }
264
232 TEST_F(LayoutGeometryMapTest, IframeTest) 265 TEST_F(LayoutGeometryMapTest, IframeTest)
233 { 266 {
234 registerMockedHttpURLLoad("rgm_iframe_test.html"); 267 registerMockedHttpURLLoad("rgm_iframe_test.html");
235 registerMockedHttpURLLoad("rgm_test.html"); 268 registerMockedHttpURLLoad("rgm_test.html");
236 FrameTestHelpers::WebViewHelper webViewHelper; 269 FrameTestHelpers::WebViewHelper webViewHelper;
237 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "rgm_iframe_t est.html", true, 0, 0); 270 WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "rgm_iframe_t est.html", true, 0, 0);
238 webView->resize(WebSize(1000, 1000)); 271 webView->resize(WebSize(1000, 1000));
239 webView->updateAllLifecyclePhases(); 272 webView->updateAllLifecyclePhases();
240 273
241 LayoutGeometryMap rgm(TraverseDocumentBoundaries); 274 LayoutGeometryMap rgm(TraverseDocumentBoundaries);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 rgm.popMappingsToAncestor(static_cast<PaintLayer*>(nullptr)); 365 rgm.popMappingsToAncestor(static_cast<PaintLayer*>(nullptr));
333 rgm.pushMappingsToAncestor(getLayoutBox(webView, "Col3"), nullptr); 366 rgm.pushMappingsToAncestor(getLayoutBox(webView, "Col3"), nullptr);
334 EXPECT_NEAR(8.0f + offset * 2.0f, rectFromQuad(rgm.mapToAncestor(rect, nullp tr)).x(), 0.1f); 367 EXPECT_NEAR(8.0f + offset * 2.0f, rectFromQuad(rgm.mapToAncestor(rect, nullp tr)).x(), 0.1f);
335 EXPECT_NEAR(8.0f, rectFromQuad(rgm.mapToAncestor(rect, nullptr)).y(), 0.1f); 368 EXPECT_NEAR(8.0f, rectFromQuad(rgm.mapToAncestor(rect, nullptr)).y(), 0.1f);
336 EXPECT_EQ(5.0f, rectFromQuad(rgm.mapToAncestor(rect, nullptr)).width()); 369 EXPECT_EQ(5.0f, rectFromQuad(rgm.mapToAncestor(rect, nullptr)).width());
337 EXPECT_EQ(3.0f, rectFromQuad(rgm.mapToAncestor(rect, nullptr)).height()); 370 EXPECT_EQ(3.0f, rectFromQuad(rgm.mapToAncestor(rect, nullptr)).height());
338 371
339 } 372 }
340 373
341 } // namespace blink 374 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698