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

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

Issue 2519163003: LayoutView's paint layer should clip to the full viewport size. (Closed)
Patch Set: Add test 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/web/tests/VisualViewportTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 10349 matching lines...) Expand 10 before | Expand all | Expand 10 after
10360 helper.initializeAndLoad(url, true); 10360 helper.initializeAndLoad(url, true);
10361 Platform::current()->getURLLoaderMockFactory()->setLoaderDelegate(nullptr); 10361 Platform::current()->getURLLoaderMockFactory()->setLoaderDelegate(nullptr);
10362 10362
10363 Document* document = 10363 Document* document =
10364 toLocalFrame(helper.webView()->page()->mainFrame())->document(); 10364 toLocalFrame(helper.webView()->page()->mainFrame())->document();
10365 EXPECT_TRUE(document->isImageDocument()); 10365 EXPECT_TRUE(document->isImageDocument());
10366 EXPECT_EQ(Resource::DecodeError, 10366 EXPECT_EQ(Resource::DecodeError,
10367 toImageDocument(document)->cachedImage()->getStatus()); 10367 toImageDocument(document)->cachedImage()->getStatus());
10368 } 10368 }
10369 10369
10370 // Ensure that the root layer -- whose size is ordinarily derived from the
10371 // content size -- maintains a minimum height matching the viewport in cases
10372 // where the content is smaller.
10373 TEST_F(WebFrameTest, RootLayerMinimumHeight) {
10374 constexpr int viewportWidth = 320;
10375 constexpr int viewportHeight = 640;
10376 constexpr int browserControlsHeight = 100;
10377
10378 FrameTestHelpers::WebViewHelper webViewHelper;
10379 webViewHelper.initialize(true, nullptr, nullptr, nullptr,
10380 enableViewportSettings);
10381 WebViewImpl* webView = webViewHelper.webView();
10382 webView->resizeWithBrowserControls(
10383 WebSize(viewportWidth, viewportHeight - browserControlsHeight),
10384 browserControlsHeight, true);
10385
10386 initializeWithHTML(*webView->mainFrameImpl()->frame(),
10387 "<!DOCTYPE html>"
10388 "<style>"
10389 " html, body {width:100%;height:540px;margin:0px}"
10390 " #elem {"
10391 " overflow: scroll;"
10392 " width: 100px;"
10393 " height: 10px;"
10394 " position: fixed;"
10395 " left: 0px;"
10396 " bottom: 0px;"
10397 " }"
10398 "</style>"
10399 "<div id='elem'></div>");
10400 webView->updateAllLifecyclePhases();
10401
10402 Document* document = webView->mainFrameImpl()->frame()->document();
10403 FrameView* frameView = webView->mainFrameImpl()->frameView();
10404 PaintLayerCompositor* compositor = frameView->layoutViewItem().compositor();
10405
10406 EXPECT_EQ(viewportHeight - browserControlsHeight,
10407 compositor->rootLayer()->boundingBoxForCompositing().height());
10408
10409 document->view()->setTracksPaintInvalidations(true);
10410
10411 webView->resizeWithBrowserControls(WebSize(viewportWidth, viewportHeight),
10412 browserControlsHeight, false);
10413
10414 EXPECT_EQ(viewportHeight,
10415 compositor->rootLayer()->boundingBoxForCompositing().height());
10416 EXPECT_EQ(viewportHeight,
10417 compositor->rootLayer()->graphicsLayerBacking()->size().height());
10418 EXPECT_EQ(viewportHeight, compositor->rootGraphicsLayer()->size().height());
10419
10420 const RasterInvalidationTracking* invalidationTracking =
10421 document->layoutView()
10422 ->layer()
10423 ->graphicsLayerBacking()
10424 ->getRasterInvalidationTracking();
10425 ASSERT_TRUE(invalidationTracking);
10426 const auto* rasterInvalidations =
10427 &invalidationTracking->trackedRasterInvalidations;
10428
10429 // The newly revealed content at the bottom of the screen should have been
10430 // invalidated. There are additional invalidations for the position: fixed
10431 // element.
10432 EXPECT_GT(rasterInvalidations->size(), 0u);
10433 EXPECT_TRUE((*rasterInvalidations)[0].rect.contains(
10434 IntRect(0, viewportHeight - browserControlsHeight, viewportWidth,
10435 browserControlsHeight)));
10436
10437 document->view()->setTracksPaintInvalidations(false);
10438 }
10439
10370 // Load a page with display:none set and try to scroll it. It shouldn't crash 10440 // Load a page with display:none set and try to scroll it. It shouldn't crash
10371 // due to lack of layoutObject. crbug.com/653327. 10441 // due to lack of layoutObject. crbug.com/653327.
10372 TEST_F(WebFrameTest, ScrollBeforeLayoutDoesntCrash) { 10442 TEST_F(WebFrameTest, ScrollBeforeLayoutDoesntCrash) {
10373 registerMockedHttpURLLoad("display-none.html"); 10443 registerMockedHttpURLLoad("display-none.html");
10374 FrameTestHelpers::WebViewHelper webViewHelper; 10444 FrameTestHelpers::WebViewHelper webViewHelper;
10375 webViewHelper.initializeAndLoad(m_baseURL + "display-none.html"); 10445 webViewHelper.initializeAndLoad(m_baseURL + "display-none.html");
10376 WebViewImpl* webView = webViewHelper.webView(); 10446 WebViewImpl* webView = webViewHelper.webView();
10377 webViewHelper.resize(WebSize(640, 480)); 10447 webViewHelper.resize(WebSize(640, 480));
10378 10448
10379 Document* document = webView->mainFrameImpl()->frame()->document(); 10449 Document* document = webView->mainFrameImpl()->frame()->document();
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
10649 Frame* mainFrame = webViewHelper.webView()->mainFrameImpl()->frame(); 10719 Frame* mainFrame = webViewHelper.webView()->mainFrameImpl()->frame();
10650 HashSet<AtomicString> names; 10720 HashSet<AtomicString> names;
10651 for (Frame* frame = mainFrame->tree().firstChild(); frame; 10721 for (Frame* frame = mainFrame->tree().firstChild(); frame;
10652 frame = frame->tree().traverseNext()) { 10722 frame = frame->tree().traverseNext()) {
10653 EXPECT_TRUE(names.add(frame->tree().uniqueName()).isNewEntry); 10723 EXPECT_TRUE(names.add(frame->tree().uniqueName()).isNewEntry);
10654 } 10724 }
10655 EXPECT_EQ(10u, names.size()); 10725 EXPECT_EQ(10u, names.size());
10656 } 10726 }
10657 10727
10658 } // namespace blink 10728 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/tests/VisualViewportTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698