| 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 6402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6413 { | 6413 { |
| 6414 FakeCompositingWebViewClient client; | 6414 FakeCompositingWebViewClient client; |
| 6415 registerMockedHttpURLLoad("long_scroll.html"); | 6415 registerMockedHttpURLLoad("long_scroll.html"); |
| 6416 FrameTestHelpers::WebViewHelper webViewHelper; | 6416 FrameTestHelpers::WebViewHelper webViewHelper; |
| 6417 webViewHelper.initializeAndLoad(m_baseURL + "long_scroll.html", true, 0, &cl
ient, configureAndroid); | 6417 webViewHelper.initializeAndLoad(m_baseURL + "long_scroll.html", true, 0, &cl
ient, configureAndroid); |
| 6418 | 6418 |
| 6419 WebViewImpl* webView = webViewHelper.webViewImpl(); | 6419 WebViewImpl* webView = webViewHelper.webViewImpl(); |
| 6420 FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameVi
ew(); | 6420 FrameView* frameView = webViewHelper.webViewImpl()->mainFrameImpl()->frameVi
ew(); |
| 6421 | 6421 |
| 6422 float topControlsHeight = 40; | 6422 float topControlsHeight = 40; |
| 6423 webView->setTopControlsHeight(topControlsHeight, false); | 6423 webView->resizeWithTopControls(WebSize(100, 100), topControlsHeight, false); |
| 6424 webViewHelper.resize(WebSize(100, 100)); | |
| 6425 webView->setPageScaleFactor(2.0f); | 6424 webView->setPageScaleFactor(2.0f); |
| 6426 webView->updateAllLifecyclePhases(); | 6425 webView->updateAllLifecyclePhases(); |
| 6427 | 6426 |
| 6428 webView->mainFrame()->setScrollOffset(WebSize(0, 2000)); | 6427 webView->mainFrame()->setScrollOffset(WebSize(0, 2000)); |
| 6429 EXPECT_POINT_EQ(IntPoint(0, 1900), IntPoint(frameView->scrollOffset())); | 6428 EXPECT_POINT_EQ(IntPoint(0, 1900), IntPoint(frameView->scrollOffset())); |
| 6430 | 6429 |
| 6431 // Simulate the top controls showing by 20px, thus shrinking the viewport | 6430 // Simulate the top controls showing by 20px, thus shrinking the viewport |
| 6432 // and allowing it to scroll an additional 20px. | 6431 // and allowing it to scroll an additional 20px. |
| 6433 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
1.0f, 20.0f / topControlsHeight); | 6432 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
1.0f, 20.0f / topControlsHeight); |
| 6434 EXPECT_POINT_EQ(IntPoint(0, 1920), frameView->maximumScrollPosition()); | 6433 EXPECT_POINT_EQ(IntPoint(0, 1920), frameView->maximumScrollPosition()); |
| 6435 | 6434 |
| 6436 // Show more, make sure the scroll actually gets clamped. | 6435 // Show more, make sure the scroll actually gets clamped. |
| 6437 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
1.0f, 20.0f / topControlsHeight); | 6436 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
1.0f, 20.0f / topControlsHeight); |
| 6438 webView->mainFrame()->setScrollOffset(WebSize(0, 2000)); | 6437 webView->mainFrame()->setScrollOffset(WebSize(0, 2000)); |
| 6439 EXPECT_POINT_EQ(IntPoint(0, 1940), IntPoint(frameView->scrollOffset())); | 6438 EXPECT_POINT_EQ(IntPoint(0, 1940), IntPoint(frameView->scrollOffset())); |
| 6440 | 6439 |
| 6441 // Hide until there's 10px showing. | 6440 // Hide until there's 10px showing. |
| 6442 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
1.0f, -30.0f / topControlsHeight); | 6441 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
1.0f, -30.0f / topControlsHeight); |
| 6443 EXPECT_POINT_EQ(IntPoint(0, 1910), frameView->maximumScrollPosition()); | 6442 EXPECT_POINT_EQ(IntPoint(0, 1910), frameView->maximumScrollPosition()); |
| 6444 | 6443 |
| 6445 // Simulate a LayoutPart::resize. The frame is resized to accomodate | 6444 // Simulate a LayoutPart::resize. The frame is resized to accomodate |
| 6446 // the top controls and Blink's view of the top controls matches that of | 6445 // the top controls and Blink's view of the top controls matches that of |
| 6447 // the CC | 6446 // the CC |
| 6448 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
1.0f, 30.0f / topControlsHeight); | 6447 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
1.0f, 30.0f / topControlsHeight); |
| 6449 webView->setTopControlsHeight(40.0f, true); | 6448 webView->resizeWithTopControls(WebSize(100, 60), 40.0f, true); |
| 6450 webViewHelper.resize(WebSize(100, 60)); | |
| 6451 webView->updateAllLifecyclePhases(); | 6449 webView->updateAllLifecyclePhases(); |
| 6452 EXPECT_POINT_EQ(IntPoint(0, 1940), frameView->maximumScrollPosition()); | 6450 EXPECT_POINT_EQ(IntPoint(0, 1940), frameView->maximumScrollPosition()); |
| 6453 | 6451 |
| 6454 // Now simulate hiding. | 6452 // Now simulate hiding. |
| 6455 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
1.0f, -10.0f / topControlsHeight); | 6453 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
1.0f, -10.0f / topControlsHeight); |
| 6456 EXPECT_POINT_EQ(IntPoint(0, 1930), frameView->maximumScrollPosition()); | 6454 EXPECT_POINT_EQ(IntPoint(0, 1930), frameView->maximumScrollPosition()); |
| 6457 | 6455 |
| 6458 // Reset to original state: 100px widget height, top controls fully hidden. | 6456 // Reset to original state: 100px widget height, top controls fully hidden. |
| 6459 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
1.0f, -30.0f / topControlsHeight); | 6457 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
1.0f, -30.0f / topControlsHeight); |
| 6460 webView->setTopControlsHeight(topControlsHeight, false); | 6458 webView->resizeWithTopControls(WebSize(100, 100), topControlsHeight, false); |
| 6461 webViewHelper.resize(WebSize(100, 100)); | |
| 6462 webView->updateAllLifecyclePhases(); | 6459 webView->updateAllLifecyclePhases(); |
| 6463 EXPECT_POINT_EQ(IntPoint(0, 1900), frameView->maximumScrollPosition()); | 6460 EXPECT_POINT_EQ(IntPoint(0, 1900), frameView->maximumScrollPosition()); |
| 6464 | 6461 |
| 6465 // Show the top controls by just 1px, since we're zoomed in to 2X, that | 6462 // Show the top controls by just 1px, since we're zoomed in to 2X, that |
| 6466 // should allow an extra 0.5px of scrolling in the visual viewport. Make | 6463 // should allow an extra 0.5px of scrolling in the visual viewport. Make |
| 6467 // sure we're not losing any pixels when applying the adjustment on the | 6464 // sure we're not losing any pixels when applying the adjustment on the |
| 6468 // main frame. | 6465 // main frame. |
| 6469 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
1.0f, 1.0f / topControlsHeight); | 6466 webView->applyViewportDeltas(WebFloatSize(), WebFloatSize(), WebFloatSize(),
1.0f, 1.0f / topControlsHeight); |
| 6470 EXPECT_POINT_EQ(IntPoint(0, 1901), frameView->maximumScrollPosition()); | 6467 EXPECT_POINT_EQ(IntPoint(0, 1901), frameView->maximumScrollPosition()); |
| 6471 | 6468 |
| (...skipping 2184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8656 WebLocalFrame* mainFrame = helper.webView()->mainFrame()->toWebLocalFrame(); | 8653 WebLocalFrame* mainFrame = helper.webView()->mainFrame()->toWebLocalFrame(); |
| 8657 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 8654 v8::HandleScope scope(v8::Isolate::GetCurrent()); |
| 8658 mainFrame->executeScript(WebScriptSource("hello = 'world';")); | 8655 mainFrame->executeScript(WebScriptSource("hello = 'world';")); |
| 8659 FrameTestHelpers::loadFrame(mainFrame, "data:text/html,new page"); | 8656 FrameTestHelpers::loadFrame(mainFrame, "data:text/html,new page"); |
| 8660 v8::Local<v8::Value> result = mainFrame->executeScriptAndReturnValue(WebScri
ptSource("hello")); | 8657 v8::Local<v8::Value> result = mainFrame->executeScriptAndReturnValue(WebScri
ptSource("hello")); |
| 8661 ASSERT_TRUE(result->IsString()); | 8658 ASSERT_TRUE(result->IsString()); |
| 8662 EXPECT_EQ("world", toCoreString(result->ToString(mainFrame->mainWorldScriptC
ontext()).ToLocalChecked())); | 8659 EXPECT_EQ("world", toCoreString(result->ToString(mainFrame->mainWorldScriptC
ontext()).ToLocalChecked())); |
| 8663 } | 8660 } |
| 8664 | 8661 |
| 8665 } // namespace blink | 8662 } // namespace blink |
| OLD | NEW |