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

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

Issue 1844013002: Fix main thread top controls scrolling to mirror CC. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@propertyTreesBoundsDelta
Patch Set: Override top controls resize() in classes that override resize() Created 4 years, 8 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) 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 6414 matching lines...) Expand 10 before | Expand all | Expand 10 after
6425 { 6425 {
6426 FakeCompositingWebViewClient client; 6426 FakeCompositingWebViewClient client;
6427 registerMockedHttpURLLoad("long_scroll.html"); 6427 registerMockedHttpURLLoad("long_scroll.html");
6428 FrameTestHelpers::WebViewHelper webViewHelper; 6428 FrameTestHelpers::WebViewHelper webViewHelper;
6429 webViewHelper.initializeAndLoad(m_baseURL + "long_scroll.html", true, 0, &cl ient, configureAndroid); 6429 webViewHelper.initializeAndLoad(m_baseURL + "long_scroll.html", true, 0, &cl ient, configureAndroid);
6430 6430
6431 WebViewImpl* webView = webViewHelper.webViewImpl(); 6431 WebViewImpl* webView = webViewHelper.webViewImpl();
6432 FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameVi ew(); 6432 FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameVi ew();
6433 6433
6434 float topControlsHeight = 40; 6434 float topControlsHeight = 40;
6435 webView->setTopControlsHeight(topControlsHeight, false); 6435 webView->resize(WebSize(100, 100), topControlsHeight, false);
6436 webViewHelper.resize(WebSize(100, 100));
6437 webView->setPageScaleFactor(2.0f); 6436 webView->setPageScaleFactor(2.0f);
6438 webView->updateAllLifecyclePhases(); 6437 webView->updateAllLifecyclePhases();
6439 6438
6440 webView->mainFrame()->setScrollOffset(WebSize(0, 2000)); 6439 webView->mainFrame()->setScrollOffset(WebSize(0, 2000));
6441 EXPECT_POINT_EQ(IntPoint(0, 1900), IntPoint(frameView->scrollOffset())); 6440 EXPECT_POINT_EQ(IntPoint(0, 1900), IntPoint(frameView->scrollOffset()));
6442 6441
6443 // Simulate the top controls showing by 20px, thus shrinking the viewport 6442 // Simulate the top controls showing by 20px, thus shrinking the viewport
6444 // and allowing it to scroll an additional 20px. 6443 // and allowing it to scroll an additional 20px.
6445 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(), 1.0f, 20.0f / topControlsHeight); 6444 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(), 1.0f, 20.0f / topControlsHeight);
6446 EXPECT_POINT_EQ(IntPoint(0, 1920), frameView->maximumScrollPosition()); 6445 EXPECT_POINT_EQ(IntPoint(0, 1920), frameView->maximumScrollPosition());
6447 6446
6448 // Show more, make sure the scroll actually gets clamped. 6447 // Show more, make sure the scroll actually gets clamped.
6449 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(), 1.0f, 20.0f / topControlsHeight); 6448 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(), 1.0f, 20.0f / topControlsHeight);
6450 webView->mainFrame()->setScrollOffset(WebSize(0, 2000)); 6449 webView->mainFrame()->setScrollOffset(WebSize(0, 2000));
6451 EXPECT_POINT_EQ(IntPoint(0, 1940), IntPoint(frameView->scrollOffset())); 6450 EXPECT_POINT_EQ(IntPoint(0, 1940), IntPoint(frameView->scrollOffset()));
6452 6451
6453 // Hide until there's 10px showing. 6452 // Hide until there's 10px showing.
6454 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(), 1.0f, -30.0f / topControlsHeight); 6453 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(), 1.0f, -30.0f / topControlsHeight);
6455 EXPECT_POINT_EQ(IntPoint(0, 1910), frameView->maximumScrollPosition()); 6454 EXPECT_POINT_EQ(IntPoint(0, 1910), frameView->maximumScrollPosition());
6456 6455
6457 // Simulate a LayoutPart::resize. The frame is resized to accomodate 6456 // Simulate a LayoutPart::resize. The frame is resized to accomodate
6458 // the top controls and Blink's view of the top controls matches that of 6457 // the top controls and Blink's view of the top controls matches that of
6459 // the CC 6458 // the CC
6460 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(), 1.0f, 30.0f / topControlsHeight); 6459 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(), 1.0f, 30.0f / topControlsHeight);
6461 webView->setTopControlsHeight(40.0f, true); 6460 webView->resize(WebSize(100, 60), 40.0f, true);
6462 webViewHelper.resize(WebSize(100, 60));
6463 webView->updateAllLifecyclePhases(); 6461 webView->updateAllLifecyclePhases();
6464 EXPECT_POINT_EQ(IntPoint(0, 1940), frameView->maximumScrollPosition()); 6462 EXPECT_POINT_EQ(IntPoint(0, 1940), frameView->maximumScrollPosition());
6465 6463
6466 // Now simulate hiding. 6464 // Now simulate hiding.
6467 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(), 1.0f, -10.0f / topControlsHeight); 6465 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(), 1.0f, -10.0f / topControlsHeight);
6468 EXPECT_POINT_EQ(IntPoint(0, 1930), frameView->maximumScrollPosition()); 6466 EXPECT_POINT_EQ(IntPoint(0, 1930), frameView->maximumScrollPosition());
6469 6467
6470 // Reset to original state: 100px widget height, top controls fully hidden. 6468 // Reset to original state: 100px widget height, top controls fully hidden.
6471 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(), 1.0f, -30.0f / topControlsHeight); 6469 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(), 1.0f, -30.0f / topControlsHeight);
6472 webView->setTopControlsHeight(topControlsHeight, false); 6470 webView->resize(WebSize(100, 100), topControlsHeight, false);
6473 webViewHelper.resize(WebSize(100, 100));
6474 webView->updateAllLifecyclePhases(); 6471 webView->updateAllLifecyclePhases();
6475 EXPECT_POINT_EQ(IntPoint(0, 1900), frameView->maximumScrollPosition()); 6472 EXPECT_POINT_EQ(IntPoint(0, 1900), frameView->maximumScrollPosition());
6476 6473
6477 // Show the top controls by just 1px, since we're zoomed in to 2X, that 6474 // Show the top controls by just 1px, since we're zoomed in to 2X, that
6478 // should allow an extra 0.5px of scrolling in the visual viewport. Make 6475 // should allow an extra 0.5px of scrolling in the visual viewport. Make
6479 // sure we're not losing any pixels when applying the adjustment on the 6476 // sure we're not losing any pixels when applying the adjustment on the
6480 // main frame. 6477 // main frame.
6481 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(), 1.0f, 1.0f / topControlsHeight); 6478 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(), 1.0f, 1.0f / topControlsHeight);
6482 EXPECT_POINT_EQ(IntPoint(0, 1901), frameView->maximumScrollPosition()); 6479 EXPECT_POINT_EQ(IntPoint(0, 1901), frameView->maximumScrollPosition());
6483 6480
(...skipping 2015 matching lines...) Expand 10 before | Expand all | Expand 10 after
8499 } 8496 }
8500 8497
8501 TEST_F(WebFrameVisibilityChangeTest, RemoteFrameParentVisibilityChange) 8498 TEST_F(WebFrameVisibilityChangeTest, RemoteFrameParentVisibilityChange)
8502 { 8499 {
8503 swapLocalFrameToRemoteFrame(); 8500 swapLocalFrameToRemoteFrame();
8504 executeScriptOnMainFrame(WebScriptSource("document.querySelector('iframe').p arentElement.style.display = 'none';")); 8501 executeScriptOnMainFrame(WebScriptSource("document.querySelector('iframe').p arentElement.style.display = 'none';"));
8505 EXPECT_FALSE(remoteFrameClient()->isVisible()); 8502 EXPECT_FALSE(remoteFrameClient()->isVisible());
8506 } 8503 }
8507 8504
8508 } // namespace blink 8505 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698