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/VisualViewportTest.cpp

Issue 2730573003: Moved FrameHost::m_visualViewport to Page (Closed)
Patch Set: Fixed some compile errors on mac and android Created 3 years, 9 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/frame/VisualViewport.h" 5 #include "core/frame/VisualViewport.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/frame/BrowserControls.h" 8 #include "core/frame/BrowserControls.h"
9 #include "core/frame/FrameHost.h" 9 #include "core/frame/FrameHost.h"
10 #include "core/frame/FrameView.h" 10 #include "core/frame/FrameView.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 196
197 // Test that resizing the VisualViewport works as expected and that resizing the 197 // Test that resizing the VisualViewport works as expected and that resizing the
198 // WebView resizes the VisualViewport. 198 // WebView resizes the VisualViewport.
199 TEST_P(VisualViewportTest, TestResize) { 199 TEST_P(VisualViewportTest, TestResize) {
200 initializeWithDesktopSettings(); 200 initializeWithDesktopSettings();
201 webViewImpl()->resize(IntSize(320, 240)); 201 webViewImpl()->resize(IntSize(320, 240));
202 202
203 navigateTo("about:blank"); 203 navigateTo("about:blank");
204 forceFullCompositingUpdate(); 204 forceFullCompositingUpdate();
205 205
206 VisualViewport& visualViewport = 206 VisualViewport& visualViewport = frame()->page()->visualViewport();
207 frame()->page()->frameHost().visualViewport();
208 207
209 IntSize webViewSize = webViewImpl()->size(); 208 IntSize webViewSize = webViewImpl()->size();
210 209
211 // Make sure the visual viewport was initialized. 210 // Make sure the visual viewport was initialized.
212 EXPECT_SIZE_EQ(webViewSize, visualViewport.size()); 211 EXPECT_SIZE_EQ(webViewSize, visualViewport.size());
213 212
214 // Resizing the WebView should change the VisualViewport. 213 // Resizing the WebView should change the VisualViewport.
215 webViewSize = IntSize(640, 480); 214 webViewSize = IntSize(640, 480);
216 webViewImpl()->resize(webViewSize); 215 webViewImpl()->resize(webViewSize);
217 EXPECT_SIZE_EQ(webViewSize, IntSize(webViewImpl()->size())); 216 EXPECT_SIZE_EQ(webViewSize, IntSize(webViewImpl()->size()));
(...skipping 17 matching lines...) Expand all
235 234
236 IntSize size = IntSize(150, 100); 235 IntSize size = IntSize(150, 100);
237 // Vertical scrollbar width and horizontal scrollbar height. 236 // Vertical scrollbar width and horizontal scrollbar height.
238 IntSize scrollbarSize = IntSize(15, 15); 237 IntSize scrollbarSize = IntSize(15, 15);
239 238
240 webViewImpl()->resize(size); 239 webViewImpl()->resize(size);
241 240
242 // Scroll layout viewport and verify visibleContentRect. 241 // Scroll layout viewport and verify visibleContentRect.
243 webViewImpl()->mainFrame()->setScrollOffset(WebSize(0, 50)); 242 webViewImpl()->mainFrame()->setScrollOffset(WebSize(0, 50));
244 243
245 VisualViewport& visualViewport = 244 VisualViewport& visualViewport = frame()->page()->visualViewport();
246 frame()->page()->frameHost().visualViewport();
247 EXPECT_EQ(IntRect(IntPoint(0, 0), size - scrollbarSize), 245 EXPECT_EQ(IntRect(IntPoint(0, 0), size - scrollbarSize),
248 visualViewport.visibleContentRect(ExcludeScrollbars)); 246 visualViewport.visibleContentRect(ExcludeScrollbars));
249 EXPECT_EQ(IntRect(IntPoint(0, 0), size), 247 EXPECT_EQ(IntRect(IntPoint(0, 0), size),
250 visualViewport.visibleContentRect(IncludeScrollbars)); 248 visualViewport.visibleContentRect(IncludeScrollbars));
251 249
252 webViewImpl()->setPageScaleFactor(2.0); 250 webViewImpl()->setPageScaleFactor(2.0);
253 251
254 // Scroll visual viewport and verify visibleContentRect. 252 // Scroll visual viewport and verify visibleContentRect.
255 size.scale(0.5); 253 size.scale(0.5);
256 scrollbarSize.scale(0.5); 254 scrollbarSize.scale(0.5);
(...skipping 10 matching lines...) Expand all
267 // the VisualViewport so we need to counter scroll the FrameView to make it 265 // the VisualViewport so we need to counter scroll the FrameView to make it
268 // appear to stay still). This caused bugs like crbug.com/453859. 266 // appear to stay still). This caused bugs like crbug.com/453859.
269 TEST_P(VisualViewportTest, TestResizeAtFullyScrolledPreservesViewportLocation) { 267 TEST_P(VisualViewportTest, TestResizeAtFullyScrolledPreservesViewportLocation) {
270 initializeWithDesktopSettings(); 268 initializeWithDesktopSettings();
271 webViewImpl()->resize(IntSize(800, 600)); 269 webViewImpl()->resize(IntSize(800, 600));
272 270
273 registerMockedHttpURLLoad("content-width-1000.html"); 271 registerMockedHttpURLLoad("content-width-1000.html");
274 navigateTo(m_baseURL + "content-width-1000.html"); 272 navigateTo(m_baseURL + "content-width-1000.html");
275 273
276 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); 274 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView();
277 VisualViewport& visualViewport = 275 VisualViewport& visualViewport = frame()->page()->visualViewport();
278 frame()->page()->frameHost().visualViewport();
279 276
280 visualViewport.setScale(2); 277 visualViewport.setScale(2);
281 278
282 // Fully scroll both viewports. 279 // Fully scroll both viewports.
283 frameView.layoutViewportScrollableArea()->setScrollOffset( 280 frameView.layoutViewportScrollableArea()->setScrollOffset(
284 ScrollOffset(10000, 10000), ProgrammaticScroll); 281 ScrollOffset(10000, 10000), ProgrammaticScroll);
285 visualViewport.move(FloatSize(10000, 10000)); 282 visualViewport.move(FloatSize(10000, 10000));
286 283
287 // Sanity check. 284 // Sanity check.
288 ASSERT_SIZE_EQ(FloatSize(400, 300), visualViewport.getScrollOffset()); 285 ASSERT_SIZE_EQ(FloatSize(400, 300), visualViewport.getScrollOffset());
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 341
345 // Scroll main frame to the bottom of the document 342 // Scroll main frame to the bottom of the document
346 webViewImpl()->mainFrame()->setScrollOffset(WebSize(0, 400)); 343 webViewImpl()->mainFrame()->setScrollOffset(WebSize(0, 400));
347 EXPECT_SIZE_EQ( 344 EXPECT_SIZE_EQ(
348 ScrollOffset(0, 400), 345 ScrollOffset(0, 400),
349 frame()->view()->layoutViewportScrollableArea()->getScrollOffset()); 346 frame()->view()->layoutViewportScrollableArea()->getScrollOffset());
350 347
351 webViewImpl()->setPageScaleFactor(2.0); 348 webViewImpl()->setPageScaleFactor(2.0);
352 349
353 // Scroll visual viewport to the bottom of the main frame 350 // Scroll visual viewport to the bottom of the main frame
354 VisualViewport& visualViewport = 351 VisualViewport& visualViewport = frame()->page()->visualViewport();
355 frame()->page()->frameHost().visualViewport();
356 visualViewport.setLocation(FloatPoint(0, 300)); 352 visualViewport.setLocation(FloatPoint(0, 300));
357 EXPECT_FLOAT_SIZE_EQ(FloatSize(0, 300), visualViewport.getScrollOffset()); 353 EXPECT_FLOAT_SIZE_EQ(FloatSize(0, 300), visualViewport.getScrollOffset());
358 354
359 // Verify the initial size of the visual viewport in the CSS pixels 355 // Verify the initial size of the visual viewport in the CSS pixels
360 EXPECT_FLOAT_SIZE_EQ(FloatSize(50, 100), visualViewport.visibleRect().size()); 356 EXPECT_FLOAT_SIZE_EQ(FloatSize(50, 100), visualViewport.visibleRect().size());
361 357
362 // Perform the resizing 358 // Perform the resizing
363 webViewImpl()->resize(IntSize(200, 100)); 359 webViewImpl()->resize(IntSize(200, 100));
364 360
365 // After resizing the scale changes 2.0 -> 4.0 361 // After resizing the scale changes 2.0 -> 4.0
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 registerMockedHttpURLLoad("200-by-800-viewport.html"); 401 registerMockedHttpURLLoad("200-by-800-viewport.html");
406 navigateTo(m_baseURL + "200-by-800-viewport.html"); 402 navigateTo(m_baseURL + "200-by-800-viewport.html");
407 403
408 webViewImpl()->resize(IntSize(100, 200)); 404 webViewImpl()->resize(IntSize(100, 200));
409 405
410 // Outer viewport takes the whole width of the document. 406 // Outer viewport takes the whole width of the document.
411 407
412 webViewImpl()->setPageScaleFactor(2.0); 408 webViewImpl()->setPageScaleFactor(2.0);
413 409
414 // Scroll visual viewport to the right edge of the frame 410 // Scroll visual viewport to the right edge of the frame
415 VisualViewport& visualViewport = 411 VisualViewport& visualViewport = frame()->page()->visualViewport();
416 frame()->page()->frameHost().visualViewport();
417 visualViewport.setLocation(FloatPoint(150, 0)); 412 visualViewport.setLocation(FloatPoint(150, 0));
418 EXPECT_FLOAT_SIZE_EQ(FloatSize(150, 0), visualViewport.getScrollOffset()); 413 EXPECT_FLOAT_SIZE_EQ(FloatSize(150, 0), visualViewport.getScrollOffset());
419 414
420 // Verify the initial size of the visual viewport in the CSS pixels 415 // Verify the initial size of the visual viewport in the CSS pixels
421 EXPECT_FLOAT_SIZE_EQ(FloatSize(50, 100), visualViewport.visibleRect().size()); 416 EXPECT_FLOAT_SIZE_EQ(FloatSize(50, 100), visualViewport.visibleRect().size());
422 417
423 webViewImpl()->resize(IntSize(200, 100)); 418 webViewImpl()->resize(IntSize(200, 100));
424 419
425 // After resizing the scale changes 2.0 -> 4.0 420 // After resizing the scale changes 2.0 -> 4.0
426 EXPECT_FLOAT_SIZE_EQ(FloatSize(50, 25), visualViewport.visibleRect().size()); 421 EXPECT_FLOAT_SIZE_EQ(FloatSize(50, 25), visualViewport.visibleRect().size());
(...skipping 13 matching lines...) Expand all
440 WebFrameWidgetBase* mainFrameWidget = 435 WebFrameWidgetBase* mainFrameWidget =
441 webViewImpl()->mainFrameImpl()->frameWidget(); 436 webViewImpl()->mainFrameImpl()->frameWidget();
442 mainFrameWidget->setRootGraphicsLayer(nullptr); 437 mainFrameWidget->setRootGraphicsLayer(nullptr);
443 webViewImpl()->resize(IntSize(320, 240)); 438 webViewImpl()->resize(IntSize(320, 240));
444 439
445 navigateTo("about:blank"); 440 navigateTo("about:blank");
446 webViewImpl()->updateAllLifecyclePhases(); 441 webViewImpl()->updateAllLifecyclePhases();
447 mainFrameWidget->setRootGraphicsLayer( 442 mainFrameWidget->setRootGraphicsLayer(
448 frameView.layoutViewItem().compositor()->rootGraphicsLayer()); 443 frameView.layoutViewItem().compositor()->rootGraphicsLayer());
449 444
450 VisualViewport& visualViewport = 445 VisualViewport& visualViewport = frame()->page()->visualViewport();
451 frame()->page()->frameHost().visualViewport();
452 EXPECT_FLOAT_SIZE_EQ(FloatSize(320, 240), 446 EXPECT_FLOAT_SIZE_EQ(FloatSize(320, 240),
453 visualViewport.containerLayer()->size()); 447 visualViewport.containerLayer()->size());
454 } 448 }
455 449
456 // Make sure that the visibleRect method acurately reflects the scale and scroll 450 // Make sure that the visibleRect method acurately reflects the scale and scroll
457 // location of the viewport. 451 // location of the viewport.
458 TEST_P(VisualViewportTest, TestVisibleRect) { 452 TEST_P(VisualViewportTest, TestVisibleRect) {
459 initializeWithDesktopSettings(); 453 initializeWithDesktopSettings();
460 webViewImpl()->resize(IntSize(320, 240)); 454 webViewImpl()->resize(IntSize(320, 240));
461 455
462 navigateTo("about:blank"); 456 navigateTo("about:blank");
463 forceFullCompositingUpdate(); 457 forceFullCompositingUpdate();
464 458
465 VisualViewport& visualViewport = 459 VisualViewport& visualViewport = frame()->page()->visualViewport();
466 frame()->page()->frameHost().visualViewport();
467 460
468 // Initial visible rect should be the whole frame. 461 // Initial visible rect should be the whole frame.
469 EXPECT_SIZE_EQ(IntSize(webViewImpl()->size()), visualViewport.size()); 462 EXPECT_SIZE_EQ(IntSize(webViewImpl()->size()), visualViewport.size());
470 463
471 // Viewport is whole frame. 464 // Viewport is whole frame.
472 IntSize size = IntSize(400, 200); 465 IntSize size = IntSize(400, 200);
473 webViewImpl()->resize(size); 466 webViewImpl()->resize(size);
474 webViewImpl()->updateAllLifecyclePhases(); 467 webViewImpl()->updateAllLifecyclePhases();
475 visualViewport.setSize(size); 468 visualViewport.setSize(size);
476 469
(...skipping 29 matching lines...) Expand all
506 499
507 // Make sure that the visibleRectInDocument method acurately reflects the scale 500 // Make sure that the visibleRectInDocument method acurately reflects the scale
508 // and scroll location of the viewport relative to the document. 501 // and scroll location of the viewport relative to the document.
509 TEST_P(VisualViewportTest, TestVisibleRectInDocument) { 502 TEST_P(VisualViewportTest, TestVisibleRectInDocument) {
510 initializeWithDesktopSettings(); 503 initializeWithDesktopSettings();
511 webViewImpl()->resize(IntSize(100, 400)); 504 webViewImpl()->resize(IntSize(100, 400));
512 505
513 registerMockedHttpURLLoad("200-by-800-viewport.html"); 506 registerMockedHttpURLLoad("200-by-800-viewport.html");
514 navigateTo(m_baseURL + "200-by-800-viewport.html"); 507 navigateTo(m_baseURL + "200-by-800-viewport.html");
515 508
516 VisualViewport& visualViewport = 509 VisualViewport& visualViewport = frame()->page()->visualViewport();
517 frame()->page()->frameHost().visualViewport();
518 510
519 // Scale the viewport to 2X and move it. 511 // Scale the viewport to 2X and move it.
520 visualViewport.setScale(2); 512 visualViewport.setScale(2);
521 visualViewport.setLocation(FloatPoint(10, 15)); 513 visualViewport.setLocation(FloatPoint(10, 15));
522 EXPECT_FLOAT_RECT_EQ(FloatRect(10, 15, 50, 200), 514 EXPECT_FLOAT_RECT_EQ(FloatRect(10, 15, 50, 200),
523 visualViewport.visibleRectInDocument()); 515 visualViewport.visibleRectInDocument());
524 516
525 // Scroll the layout viewport. Ensure its offset is reflected in 517 // Scroll the layout viewport. Ensure its offset is reflected in
526 // visibleRectInDocument(). 518 // visibleRectInDocument().
527 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); 519 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 // that the visual viewport always stays within the bounds of the main frame. 552 // that the visual viewport always stays within the bounds of the main frame.
561 TEST_P(VisualViewportTest, TestOffsetClamping) { 553 TEST_P(VisualViewportTest, TestOffsetClamping) {
562 initializeWithDesktopSettings(); 554 initializeWithDesktopSettings();
563 webViewImpl()->resize(IntSize(320, 240)); 555 webViewImpl()->resize(IntSize(320, 240));
564 556
565 navigateTo("about:blank"); 557 navigateTo("about:blank");
566 forceFullCompositingUpdate(); 558 forceFullCompositingUpdate();
567 559
568 // Visual viewport should be initialized to same size as frame so no scrolling 560 // Visual viewport should be initialized to same size as frame so no scrolling
569 // possible. 561 // possible.
570 VisualViewport& visualViewport = 562 VisualViewport& visualViewport = frame()->page()->visualViewport();
571 frame()->page()->frameHost().visualViewport();
572 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), 563 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0),
573 visualViewport.visibleRect().location()); 564 visualViewport.visibleRect().location());
574 565
575 visualViewport.setLocation(FloatPoint(-1, -2)); 566 visualViewport.setLocation(FloatPoint(-1, -2));
576 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), 567 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0),
577 visualViewport.visibleRect().location()); 568 visualViewport.visibleRect().location());
578 569
579 visualViewport.setLocation(FloatPoint(100, 200)); 570 visualViewport.setLocation(FloatPoint(100, 200));
580 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), 571 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0),
581 visualViewport.visibleRect().location()); 572 visualViewport.visibleRect().location());
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 // keyboard came up. 607 // keyboard came up.
617 TEST_P(VisualViewportTest, TestOffsetClampingWithResize) { 608 TEST_P(VisualViewportTest, TestOffsetClampingWithResize) {
618 initializeWithDesktopSettings(); 609 initializeWithDesktopSettings();
619 webViewImpl()->resize(IntSize(320, 240)); 610 webViewImpl()->resize(IntSize(320, 240));
620 611
621 navigateTo("about:blank"); 612 navigateTo("about:blank");
622 forceFullCompositingUpdate(); 613 forceFullCompositingUpdate();
623 614
624 // Visual viewport should be initialized to same size as frame so no scrolling 615 // Visual viewport should be initialized to same size as frame so no scrolling
625 // possible. 616 // possible.
626 VisualViewport& visualViewport = 617 VisualViewport& visualViewport = frame()->page()->visualViewport();
627 frame()->page()->frameHost().visualViewport();
628 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), 618 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0),
629 visualViewport.visibleRect().location()); 619 visualViewport.visibleRect().location());
630 620
631 // Shrink the viewport vertically. The resize shouldn't affect the location, 621 // Shrink the viewport vertically. The resize shouldn't affect the location,
632 // but it should allow vertical scrolling. 622 // but it should allow vertical scrolling.
633 visualViewport.setSize(IntSize(320, 200)); 623 visualViewport.setSize(IntSize(320, 200));
634 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), 624 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0),
635 visualViewport.visibleRect().location()); 625 visualViewport.visibleRect().location());
636 visualViewport.setLocation(FloatPoint(10, 20)); 626 visualViewport.setLocation(FloatPoint(10, 20));
637 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 20), 627 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 20),
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 // main frame when we apply both scaling and resizes. 675 // main frame when we apply both scaling and resizes.
686 TEST_P(VisualViewportTest, TestOffsetClampingWithResizeAndScale) { 676 TEST_P(VisualViewportTest, TestOffsetClampingWithResizeAndScale) {
687 initializeWithDesktopSettings(); 677 initializeWithDesktopSettings();
688 webViewImpl()->resize(IntSize(320, 240)); 678 webViewImpl()->resize(IntSize(320, 240));
689 679
690 navigateTo("about:blank"); 680 navigateTo("about:blank");
691 forceFullCompositingUpdate(); 681 forceFullCompositingUpdate();
692 682
693 // Visual viewport should be initialized to same size as WebView so no 683 // Visual viewport should be initialized to same size as WebView so no
694 // scrolling possible. 684 // scrolling possible.
695 VisualViewport& visualViewport = 685 VisualViewport& visualViewport = frame()->page()->visualViewport();
696 frame()->page()->frameHost().visualViewport();
697 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), 686 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0),
698 visualViewport.visibleRect().location()); 687 visualViewport.visibleRect().location());
699 688
700 // Zoom in to 2X so we can scroll the viewport to 160x120. 689 // Zoom in to 2X so we can scroll the viewport to 160x120.
701 visualViewport.setScale(2); 690 visualViewport.setScale(2);
702 visualViewport.setLocation(FloatPoint(200, 200)); 691 visualViewport.setLocation(FloatPoint(200, 200));
703 EXPECT_FLOAT_POINT_EQ(FloatPoint(160, 120), 692 EXPECT_FLOAT_POINT_EQ(FloatPoint(160, 120),
704 visualViewport.visibleRect().location()); 693 visualViewport.visibleRect().location());
705 694
706 // Now resize the viewport to make it 10px smaller. Since we're zoomed in by 695 // Now resize the viewport to make it 10px smaller. Since we're zoomed in by
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 TEST_P(VisualViewportTest, TestAttachingNewFrameSetsInnerScrollLayerSize) { 767 TEST_P(VisualViewportTest, TestAttachingNewFrameSetsInnerScrollLayerSize) {
779 initializeWithAndroidSettings(); 768 initializeWithAndroidSettings();
780 webViewImpl()->resize(IntSize(320, 240)); 769 webViewImpl()->resize(IntSize(320, 240));
781 770
782 // Load a wider page first, the navigation should resize the scroll layer to 771 // Load a wider page first, the navigation should resize the scroll layer to
783 // the smaller size on the second navigation. 772 // the smaller size on the second navigation.
784 registerMockedHttpURLLoad("content-width-1000.html"); 773 registerMockedHttpURLLoad("content-width-1000.html");
785 navigateTo(m_baseURL + "content-width-1000.html"); 774 navigateTo(m_baseURL + "content-width-1000.html");
786 webViewImpl()->updateAllLifecyclePhases(); 775 webViewImpl()->updateAllLifecyclePhases();
787 776
788 VisualViewport& visualViewport = 777 VisualViewport& visualViewport = frame()->page()->visualViewport();
789 frame()->page()->frameHost().visualViewport();
790 visualViewport.setScale(2); 778 visualViewport.setScale(2);
791 visualViewport.move(ScrollOffset(50, 60)); 779 visualViewport.move(ScrollOffset(50, 60));
792 780
793 // Move and scale the viewport to make sure it gets reset in the navigation. 781 // Move and scale the viewport to make sure it gets reset in the navigation.
794 EXPECT_SIZE_EQ(FloatSize(50, 60), visualViewport.getScrollOffset()); 782 EXPECT_SIZE_EQ(FloatSize(50, 60), visualViewport.getScrollOffset());
795 EXPECT_EQ(2, visualViewport.scale()); 783 EXPECT_EQ(2, visualViewport.scale());
796 784
797 // Navigate again, this time the FrameView should be smaller. 785 // Navigate again, this time the FrameView should be smaller.
798 registerMockedHttpURLLoad("viewport-device-width.html"); 786 registerMockedHttpURLLoad("viewport-device-width.html");
799 navigateTo(m_baseURL + "viewport-device-width.html"); 787 navigateTo(m_baseURL + "viewport-device-width.html");
(...skipping 25 matching lines...) Expand all
825 EXPECT_SIZE_EQ( 813 EXPECT_SIZE_EQ(
826 IntSize(50, 80), 814 IntSize(50, 80),
827 webViewImpl()->mainFrameImpl()->frameView()->frameRect().size()); 815 webViewImpl()->mainFrameImpl()->frameView()->frameRect().size());
828 } 816 }
829 817
830 // Test that the visual viewport still gets sized in AutoSize/AutoResize mode. 818 // Test that the visual viewport still gets sized in AutoSize/AutoResize mode.
831 TEST_P(VisualViewportTest, TestVisualViewportGetsSizeInAutoSizeMode) { 819 TEST_P(VisualViewportTest, TestVisualViewportGetsSizeInAutoSizeMode) {
832 initializeWithDesktopSettings(); 820 initializeWithDesktopSettings();
833 821
834 EXPECT_SIZE_EQ(IntSize(0, 0), IntSize(webViewImpl()->size())); 822 EXPECT_SIZE_EQ(IntSize(0, 0), IntSize(webViewImpl()->size()));
835 EXPECT_SIZE_EQ(IntSize(0, 0), 823 EXPECT_SIZE_EQ(IntSize(0, 0), frame()->page()->visualViewport().size());
836 frame()->page()->frameHost().visualViewport().size());
837 824
838 webViewImpl()->enableAutoResizeMode(WebSize(10, 10), WebSize(1000, 1000)); 825 webViewImpl()->enableAutoResizeMode(WebSize(10, 10), WebSize(1000, 1000));
839 826
840 registerMockedHttpURLLoad("200-by-300.html"); 827 registerMockedHttpURLLoad("200-by-300.html");
841 navigateTo(m_baseURL + "200-by-300.html"); 828 navigateTo(m_baseURL + "200-by-300.html");
842 829
843 EXPECT_SIZE_EQ(IntSize(200, 300), 830 EXPECT_SIZE_EQ(IntSize(200, 300), frame()->page()->visualViewport().size());
844 frame()->page()->frameHost().visualViewport().size());
845 } 831 }
846 832
847 // Test that the text selection handle's position accounts for the visual 833 // Test that the text selection handle's position accounts for the visual
848 // viewport. 834 // viewport.
849 TEST_P(VisualViewportTest, TestTextSelectionHandles) { 835 TEST_P(VisualViewportTest, TestTextSelectionHandles) {
850 initializeWithDesktopSettings(); 836 initializeWithDesktopSettings();
851 webViewImpl()->resize(IntSize(500, 800)); 837 webViewImpl()->resize(IntSize(500, 800));
852 838
853 registerMockedHttpURLLoad("pinch-viewport-input-field.html"); 839 registerMockedHttpURLLoad("pinch-viewport-input-field.html");
854 navigateTo(m_baseURL + "pinch-viewport-input-field.html"); 840 navigateTo(m_baseURL + "pinch-viewport-input-field.html");
855 841
856 VisualViewport& visualViewport = 842 VisualViewport& visualViewport = frame()->page()->visualViewport();
857 frame()->page()->frameHost().visualViewport();
858 webViewImpl()->setInitialFocus(false); 843 webViewImpl()->setInitialFocus(false);
859 844
860 WebRect originalAnchor; 845 WebRect originalAnchor;
861 WebRect originalFocus; 846 WebRect originalFocus;
862 webViewImpl()->selectionBounds(originalAnchor, originalFocus); 847 webViewImpl()->selectionBounds(originalAnchor, originalFocus);
863 848
864 webViewImpl()->setPageScaleFactor(2); 849 webViewImpl()->setPageScaleFactor(2);
865 visualViewport.setLocation(FloatPoint(100, 400)); 850 visualViewport.setLocation(FloatPoint(100, 400));
866 851
867 WebRect anchor; 852 WebRect anchor;
(...skipping 20 matching lines...) Expand all
888 873
889 registerMockedHttpURLLoad("200-by-300.html"); 874 registerMockedHttpURLLoad("200-by-300.html");
890 navigateTo(m_baseURL + "200-by-300.html"); 875 navigateTo(m_baseURL + "200-by-300.html");
891 876
892 EXPECT_SIZE_EQ(ScrollOffset(0, 0), 877 EXPECT_SIZE_EQ(ScrollOffset(0, 0),
893 toLocalFrame(webViewImpl()->page()->mainFrame()) 878 toLocalFrame(webViewImpl()->page()->mainFrame())
894 ->loader() 879 ->loader()
895 .currentItem() 880 .currentItem()
896 ->visualViewportScrollOffset()); 881 ->visualViewportScrollOffset());
897 882
898 VisualViewport& visualViewport = 883 VisualViewport& visualViewport = frame()->page()->visualViewport();
899 frame()->page()->frameHost().visualViewport();
900 visualViewport.setScale(2); 884 visualViewport.setScale(2);
901 885
902 EXPECT_EQ(2, toLocalFrame(webViewImpl()->page()->mainFrame()) 886 EXPECT_EQ(2, toLocalFrame(webViewImpl()->page()->mainFrame())
903 ->loader() 887 ->loader()
904 .currentItem() 888 .currentItem()
905 ->pageScaleFactor()); 889 ->pageScaleFactor());
906 890
907 visualViewport.setLocation(FloatPoint(10, 20)); 891 visualViewport.setLocation(FloatPoint(10, 20));
908 892
909 EXPECT_SIZE_EQ(ScrollOffset(10, 20), 893 EXPECT_SIZE_EQ(ScrollOffset(10, 20),
(...skipping 14 matching lines...) Expand all
924 item.initialize(); 908 item.initialize();
925 WebURL destinationURL(URLTestHelpers::toKURL(m_baseURL + "200-by-300.html")); 909 WebURL destinationURL(URLTestHelpers::toKURL(m_baseURL + "200-by-300.html"));
926 item.setURLString(destinationURL.string()); 910 item.setURLString(destinationURL.string());
927 item.setVisualViewportScrollOffset(WebFloatPoint(100, 120)); 911 item.setVisualViewportScrollOffset(WebFloatPoint(100, 120));
928 item.setPageScaleFactor(2); 912 item.setPageScaleFactor(2);
929 913
930 FrameTestHelpers::loadHistoryItem(webViewImpl()->mainFrame(), item, 914 FrameTestHelpers::loadHistoryItem(webViewImpl()->mainFrame(), item,
931 WebHistoryDifferentDocumentLoad, 915 WebHistoryDifferentDocumentLoad,
932 WebCachePolicy::UseProtocolCachePolicy); 916 WebCachePolicy::UseProtocolCachePolicy);
933 917
934 VisualViewport& visualViewport = 918 VisualViewport& visualViewport = frame()->page()->visualViewport();
935 frame()->page()->frameHost().visualViewport();
936 EXPECT_EQ(2, visualViewport.scale()); 919 EXPECT_EQ(2, visualViewport.scale());
937 920
938 EXPECT_FLOAT_POINT_EQ(FloatPoint(100, 120), 921 EXPECT_FLOAT_POINT_EQ(FloatPoint(100, 120),
939 visualViewport.visibleRect().location()); 922 visualViewport.visibleRect().location());
940 } 923 }
941 924
942 // Test restoring a HistoryItem without the visual viewport offset falls back to 925 // Test restoring a HistoryItem without the visual viewport offset falls back to
943 // distributing the scroll offset between the main frame and the visual 926 // distributing the scroll offset between the main frame and the visual
944 // viewport. 927 // viewport.
945 TEST_P(VisualViewportTest, TestRestoredFromLegacyHistoryItem) { 928 TEST_P(VisualViewportTest, TestRestoredFromLegacyHistoryItem) {
(...skipping 10 matching lines...) Expand all
956 // (-1, -1) will be used if the HistoryItem is an older version prior to 939 // (-1, -1) will be used if the HistoryItem is an older version prior to
957 // having visual viewport scroll offset. 940 // having visual viewport scroll offset.
958 item.setVisualViewportScrollOffset(WebFloatPoint(-1, -1)); 941 item.setVisualViewportScrollOffset(WebFloatPoint(-1, -1));
959 item.setScrollOffset(WebPoint(120, 180)); 942 item.setScrollOffset(WebPoint(120, 180));
960 item.setPageScaleFactor(2); 943 item.setPageScaleFactor(2);
961 944
962 FrameTestHelpers::loadHistoryItem(webViewImpl()->mainFrame(), item, 945 FrameTestHelpers::loadHistoryItem(webViewImpl()->mainFrame(), item,
963 WebHistoryDifferentDocumentLoad, 946 WebHistoryDifferentDocumentLoad,
964 WebCachePolicy::UseProtocolCachePolicy); 947 WebCachePolicy::UseProtocolCachePolicy);
965 948
966 VisualViewport& visualViewport = 949 VisualViewport& visualViewport = frame()->page()->visualViewport();
967 frame()->page()->frameHost().visualViewport();
968 EXPECT_EQ(2, visualViewport.scale()); 950 EXPECT_EQ(2, visualViewport.scale());
969 EXPECT_SIZE_EQ( 951 EXPECT_SIZE_EQ(
970 ScrollOffset(100, 150), 952 ScrollOffset(100, 150),
971 frame()->view()->layoutViewportScrollableArea()->getScrollOffset()); 953 frame()->view()->layoutViewportScrollableArea()->getScrollOffset());
972 EXPECT_FLOAT_POINT_EQ(FloatPoint(20, 30), 954 EXPECT_FLOAT_POINT_EQ(FloatPoint(20, 30),
973 visualViewport.visibleRect().location()); 955 visualViewport.visibleRect().location());
974 } 956 }
975 957
976 // Test that navigation to a new page with a different sized main frame doesn't 958 // Test that navigation to a new page with a different sized main frame doesn't
977 // clobber the history item's main frame scroll offset. crbug.com/371867 959 // clobber the history item's main frame scroll offset. crbug.com/371867
978 TEST_P(VisualViewportTest, 960 TEST_P(VisualViewportTest,
979 TestNavigateToSmallerFrameViewHistoryItemClobberBug) { 961 TestNavigateToSmallerFrameViewHistoryItemClobberBug) {
980 initializeWithAndroidSettings(); 962 initializeWithAndroidSettings();
981 webViewImpl()->resize(IntSize(400, 400)); 963 webViewImpl()->resize(IntSize(400, 400));
982 webViewImpl()->updateAllLifecyclePhases(); 964 webViewImpl()->updateAllLifecyclePhases();
983 965
984 registerMockedHttpURLLoad("content-width-1000.html"); 966 registerMockedHttpURLLoad("content-width-1000.html");
985 navigateTo(m_baseURL + "content-width-1000.html"); 967 navigateTo(m_baseURL + "content-width-1000.html");
986 968
987 FrameView* frameView = webViewImpl()->mainFrameImpl()->frameView(); 969 FrameView* frameView = webViewImpl()->mainFrameImpl()->frameView();
988 frameView->layoutViewportScrollableArea()->setScrollOffset( 970 frameView->layoutViewportScrollableArea()->setScrollOffset(
989 ScrollOffset(0, 1000), ProgrammaticScroll); 971 ScrollOffset(0, 1000), ProgrammaticScroll);
990 972
991 EXPECT_SIZE_EQ(IntSize(1000, 1000), frameView->frameRect().size()); 973 EXPECT_SIZE_EQ(IntSize(1000, 1000), frameView->frameRect().size());
992 974
993 VisualViewport& visualViewport = 975 VisualViewport& visualViewport = frame()->page()->visualViewport();
994 frame()->page()->frameHost().visualViewport();
995 visualViewport.setScale(2); 976 visualViewport.setScale(2);
996 visualViewport.setLocation(FloatPoint(350, 350)); 977 visualViewport.setLocation(FloatPoint(350, 350));
997 978
998 Persistent<HistoryItem> firstItem = 979 Persistent<HistoryItem> firstItem =
999 webViewImpl()->mainFrameImpl()->frame()->loader().currentItem(); 980 webViewImpl()->mainFrameImpl()->frame()->loader().currentItem();
1000 EXPECT_SIZE_EQ(ScrollOffset(0, 1000), firstItem->getScrollOffset()); 981 EXPECT_SIZE_EQ(ScrollOffset(0, 1000), firstItem->getScrollOffset());
1001 982
1002 // Now navigate to a page which causes a smaller frameView. Make sure that 983 // Now navigate to a page which causes a smaller frameView. Make sure that
1003 // navigating doesn't cause the history item to set a new scroll offset 984 // navigating doesn't cause the history item to set a new scroll offset
1004 // before the item was replaced. 985 // before the item was replaced.
(...skipping 28 matching lines...) Expand all
1033 mainFrame->executeScript(WebScriptSource("selectRange();")); 1014 mainFrame->executeScript(WebScriptSource("selectRange();"));
1034 EXPECT_EQ("ir", mainFrame->toWebLocalFrame()->selectionAsText().utf8()); 1015 EXPECT_EQ("ir", mainFrame->toWebLocalFrame()->selectionAsText().utf8());
1035 1016
1036 webViewImpl()->selectionBounds(baseRect, extentRect); 1017 webViewImpl()->selectionBounds(baseRect, extentRect);
1037 WebPoint initialPoint(baseRect.x, baseRect.y); 1018 WebPoint initialPoint(baseRect.x, baseRect.y);
1038 WebPoint endPoint(extentRect.x, extentRect.y); 1019 WebPoint endPoint(extentRect.x, extentRect.y);
1039 1020
1040 // Move the visual viewport over and make the selection in the same 1021 // Move the visual viewport over and make the selection in the same
1041 // screen-space location. The selection should change to two characters to the 1022 // screen-space location. The selection should change to two characters to the
1042 // right and down one line. 1023 // right and down one line.
1043 VisualViewport& visualViewport = 1024 VisualViewport& visualViewport = frame()->page()->visualViewport();
1044 frame()->page()->frameHost().visualViewport();
1045 visualViewport.move(ScrollOffset(60, 25)); 1025 visualViewport.move(ScrollOffset(60, 25));
1046 mainFrame->toWebLocalFrame()->moveRangeSelection(initialPoint, endPoint); 1026 mainFrame->toWebLocalFrame()->moveRangeSelection(initialPoint, endPoint);
1047 EXPECT_EQ("t ", mainFrame->toWebLocalFrame()->selectionAsText().utf8()); 1027 EXPECT_EQ("t ", mainFrame->toWebLocalFrame()->selectionAsText().utf8());
1048 } 1028 }
1049 1029
1050 // Test that the scrollFocusedEditableElementIntoRect method works with the 1030 // Test that the scrollFocusedEditableElementIntoRect method works with the
1051 // visual viewport. 1031 // visual viewport.
1052 TEST_P(VisualViewportTest, DISABLED_TestScrollFocusedEditableElementIntoRect) { 1032 TEST_P(VisualViewportTest, DISABLED_TestScrollFocusedEditableElementIntoRect) {
1053 initializeWithDesktopSettings(); 1033 initializeWithDesktopSettings();
1054 webViewImpl()->resize(IntSize(500, 300)); 1034 webViewImpl()->resize(IntSize(500, 300));
1055 1035
1056 registerMockedHttpURLLoad("pinch-viewport-input-field.html"); 1036 registerMockedHttpURLLoad("pinch-viewport-input-field.html");
1057 navigateTo(m_baseURL + "pinch-viewport-input-field.html"); 1037 navigateTo(m_baseURL + "pinch-viewport-input-field.html");
1058 1038
1059 VisualViewport& visualViewport = 1039 VisualViewport& visualViewport = frame()->page()->visualViewport();
1060 frame()->page()->frameHost().visualViewport();
1061 webViewImpl()->resizeVisualViewport(IntSize(200, 100)); 1040 webViewImpl()->resizeVisualViewport(IntSize(200, 100));
1062 webViewImpl()->setInitialFocus(false); 1041 webViewImpl()->setInitialFocus(false);
1063 visualViewport.setLocation(FloatPoint()); 1042 visualViewport.setLocation(FloatPoint());
1064 webViewImpl()->scrollFocusedEditableElementIntoRect(IntRect(0, 0, 500, 200)); 1043 webViewImpl()->scrollFocusedEditableElementIntoRect(IntRect(0, 0, 500, 200));
1065 1044
1066 EXPECT_SIZE_EQ( 1045 EXPECT_SIZE_EQ(
1067 ScrollOffset(0, frame()->view()->maximumScrollOffset().height()), 1046 ScrollOffset(0, frame()->view()->maximumScrollOffset().height()),
1068 frame()->view()->getScrollOffset()); 1047 frame()->view()->getScrollOffset());
1069 EXPECT_FLOAT_POINT_EQ(FloatPoint(150, 200), 1048 EXPECT_FLOAT_POINT_EQ(FloatPoint(150, 200),
1070 visualViewport.visibleRect().location()); 1049 visualViewport.visibleRect().location());
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 webViewImpl()->mainFrameImpl()->setClient(&mockWebFrameClient); 1149 webViewImpl()->mainFrameImpl()->setClient(&mockWebFrameClient);
1171 webViewImpl()->handleInputEvent(WebCoalescedInputEvent(mouseDownEvent)); 1150 webViewImpl()->handleInputEvent(WebCoalescedInputEvent(mouseDownEvent));
1172 webViewImpl()->handleInputEvent(WebCoalescedInputEvent(mouseUpEvent)); 1151 webViewImpl()->handleInputEvent(WebCoalescedInputEvent(mouseUpEvent));
1173 1152
1174 Mock::VerifyAndClearExpectations(&mockWebFrameClient); 1153 Mock::VerifyAndClearExpectations(&mockWebFrameClient);
1175 mouseDownEvent.button = WebMouseEvent::Button::Left; 1154 mouseDownEvent.button = WebMouseEvent::Button::Left;
1176 webViewImpl()->handleInputEvent(WebCoalescedInputEvent(mouseDownEvent)); 1155 webViewImpl()->handleInputEvent(WebCoalescedInputEvent(mouseDownEvent));
1177 1156
1178 // Now pinch zoom into the page and move the visual viewport. The context menu 1157 // Now pinch zoom into the page and move the visual viewport. The context menu
1179 // should still appear at the location of the event, relative to the WebView. 1158 // should still appear at the location of the event, relative to the WebView.
1180 VisualViewport& visualViewport = 1159 VisualViewport& visualViewport = frame()->page()->visualViewport();
1181 frame()->page()->frameHost().visualViewport();
1182 webViewImpl()->setPageScaleFactor(2); 1160 webViewImpl()->setPageScaleFactor(2);
1183 EXPECT_CALL(mockWebFrameClient, didChangeScrollOffset(_)); 1161 EXPECT_CALL(mockWebFrameClient, didChangeScrollOffset(_));
1184 visualViewport.setLocation(FloatPoint(60, 80)); 1162 visualViewport.setLocation(FloatPoint(60, 80));
1185 EXPECT_CALL(mockWebFrameClient, showContextMenu(ContextMenuAtLocation( 1163 EXPECT_CALL(mockWebFrameClient, showContextMenu(ContextMenuAtLocation(
1186 mouseDownEvent.x, mouseDownEvent.y))); 1164 mouseDownEvent.x, mouseDownEvent.y)));
1187 1165
1188 mouseDownEvent.button = WebMouseEvent::Button::Right; 1166 mouseDownEvent.button = WebMouseEvent::Button::Right;
1189 webViewImpl()->handleInputEvent(WebCoalescedInputEvent(mouseDownEvent)); 1167 webViewImpl()->handleInputEvent(WebCoalescedInputEvent(mouseDownEvent));
1190 webViewImpl()->handleInputEvent(WebCoalescedInputEvent(mouseUpEvent)); 1168 webViewImpl()->handleInputEvent(WebCoalescedInputEvent(mouseUpEvent));
1191 1169
1192 // Reset the old client so destruction can occur naturally. 1170 // Reset the old client so destruction can occur naturally.
1193 webViewImpl()->mainFrameImpl()->setClient(oldClient); 1171 webViewImpl()->mainFrameImpl()->setClient(oldClient);
1194 } 1172 }
1195 1173
1196 // Test that the client is notified if page scroll events. 1174 // Test that the client is notified if page scroll events.
1197 TEST_P(VisualViewportTest, TestClientNotifiedOfScrollEvents) { 1175 TEST_P(VisualViewportTest, TestClientNotifiedOfScrollEvents) {
1198 initializeWithAndroidSettings(); 1176 initializeWithAndroidSettings();
1199 webViewImpl()->resize(IntSize(200, 300)); 1177 webViewImpl()->resize(IntSize(200, 300));
1200 1178
1201 registerMockedHttpURLLoad("200-by-300.html"); 1179 registerMockedHttpURLLoad("200-by-300.html");
1202 navigateTo(m_baseURL + "200-by-300.html"); 1180 navigateTo(m_baseURL + "200-by-300.html");
1203 1181
1204 WebFrameClient* oldClient = webViewImpl()->mainFrameImpl()->client(); 1182 WebFrameClient* oldClient = webViewImpl()->mainFrameImpl()->client();
1205 MockWebFrameClient mockWebFrameClient; 1183 MockWebFrameClient mockWebFrameClient;
1206 webViewImpl()->mainFrameImpl()->setClient(&mockWebFrameClient); 1184 webViewImpl()->mainFrameImpl()->setClient(&mockWebFrameClient);
1207 1185
1208 webViewImpl()->setPageScaleFactor(2); 1186 webViewImpl()->setPageScaleFactor(2);
1209 VisualViewport& visualViewport = 1187 VisualViewport& visualViewport = frame()->page()->visualViewport();
1210 frame()->page()->frameHost().visualViewport();
1211 1188
1212 EXPECT_CALL(mockWebFrameClient, didChangeScrollOffset(_)); 1189 EXPECT_CALL(mockWebFrameClient, didChangeScrollOffset(_));
1213 visualViewport.setLocation(FloatPoint(60, 80)); 1190 visualViewport.setLocation(FloatPoint(60, 80));
1214 Mock::VerifyAndClearExpectations(&mockWebFrameClient); 1191 Mock::VerifyAndClearExpectations(&mockWebFrameClient);
1215 1192
1216 // Scroll vertically. 1193 // Scroll vertically.
1217 EXPECT_CALL(mockWebFrameClient, didChangeScrollOffset(_)); 1194 EXPECT_CALL(mockWebFrameClient, didChangeScrollOffset(_));
1218 visualViewport.setLocation(FloatPoint(60, 90)); 1195 visualViewport.setLocation(FloatPoint(60, 90));
1219 Mock::VerifyAndClearExpectations(&mockWebFrameClient); 1196 Mock::VerifyAndClearExpectations(&mockWebFrameClient);
1220 1197
(...skipping 11 matching lines...) Expand all
1232 initializeWithAndroidSettings(); 1209 initializeWithAndroidSettings();
1233 1210
1234 webViewImpl()->resize(IntSize(1000, 1000)); 1211 webViewImpl()->resize(IntSize(1000, 1000));
1235 1212
1236 registerMockedHttpURLLoad("scroll-into-view.html"); 1213 registerMockedHttpURLLoad("scroll-into-view.html");
1237 navigateTo(m_baseURL + "scroll-into-view.html"); 1214 navigateTo(m_baseURL + "scroll-into-view.html");
1238 1215
1239 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); 1216 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView();
1240 ScrollableArea* layoutViewportScrollableArea = 1217 ScrollableArea* layoutViewportScrollableArea =
1241 frameView.layoutViewportScrollableArea(); 1218 frameView.layoutViewportScrollableArea();
1242 VisualViewport& visualViewport = 1219 VisualViewport& visualViewport = frame()->page()->visualViewport();
1243 frame()->page()->frameHost().visualViewport();
1244 Element* inputBox = frame()->document()->getElementById("box"); 1220 Element* inputBox = frame()->document()->getElementById("box");
1245 1221
1246 webViewImpl()->setPageScaleFactor(2); 1222 webViewImpl()->setPageScaleFactor(2);
1247 1223
1248 // The element is already in the view so the scrollIntoView shouldn't move 1224 // The element is already in the view so the scrollIntoView shouldn't move
1249 // the viewport at all. 1225 // the viewport at all.
1250 webViewImpl()->setVisualViewportOffset(WebFloatPoint(250.25f, 100.25f)); 1226 webViewImpl()->setVisualViewportOffset(WebFloatPoint(250.25f, 100.25f));
1251 layoutViewportScrollableArea->setScrollOffset(ScrollOffset(0, 900.75), 1227 layoutViewportScrollableArea->setScrollOffset(ScrollOffset(0, 900.75),
1252 ProgrammaticScroll); 1228 ProgrammaticScroll);
1253 inputBox->scrollIntoViewIfNeeded(false); 1229 inputBox->scrollIntoViewIfNeeded(false);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1308 frameView.contentsSize().height() - newHeight); 1284 frameView.contentsSize().height() - newHeight);
1309 } 1285 }
1310 1286
1311 TEST_P(VisualViewportTest, TestBrowserControlsAdjustment) { 1287 TEST_P(VisualViewportTest, TestBrowserControlsAdjustment) {
1312 initializeWithAndroidSettings(); 1288 initializeWithAndroidSettings();
1313 webViewImpl()->resizeWithBrowserControls(IntSize(500, 450), 20, false); 1289 webViewImpl()->resizeWithBrowserControls(IntSize(500, 450), 20, false);
1314 1290
1315 registerMockedHttpURLLoad("content-width-1000.html"); 1291 registerMockedHttpURLLoad("content-width-1000.html");
1316 navigateTo(m_baseURL + "content-width-1000.html"); 1292 navigateTo(m_baseURL + "content-width-1000.html");
1317 1293
1318 VisualViewport& visualViewport = 1294 VisualViewport& visualViewport = frame()->page()->visualViewport();
1319 frame()->page()->frameHost().visualViewport();
1320 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); 1295 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView();
1321 1296
1322 visualViewport.setScale(1); 1297 visualViewport.setScale(1);
1323 EXPECT_SIZE_EQ(IntSize(500, 450), visualViewport.visibleRect().size()); 1298 EXPECT_SIZE_EQ(IntSize(500, 450), visualViewport.visibleRect().size());
1324 EXPECT_SIZE_EQ(IntSize(1000, 900), frameView.frameRect().size()); 1299 EXPECT_SIZE_EQ(IntSize(1000, 900), frameView.frameRect().size());
1325 1300
1326 // Simulate bringing down the browser controls by 20px. 1301 // Simulate bringing down the browser controls by 20px.
1327 webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), 1302 webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSize(),
1328 WebFloatSize(), 1, 1); 1303 WebFloatSize(), 1, 1);
1329 EXPECT_SIZE_EQ(IntSize(500, 430), visualViewport.visibleRect().size()); 1304 EXPECT_SIZE_EQ(IntSize(500, 430), visualViewport.visibleRect().size());
(...skipping 29 matching lines...) Expand all
1359 frameView.layoutViewportScrollableArea()->getScrollOffset()); 1334 frameView.layoutViewportScrollableArea()->getScrollOffset());
1360 } 1335 }
1361 1336
1362 TEST_P(VisualViewportTest, TestBrowserControlsAdjustmentWithScale) { 1337 TEST_P(VisualViewportTest, TestBrowserControlsAdjustmentWithScale) {
1363 initializeWithAndroidSettings(); 1338 initializeWithAndroidSettings();
1364 webViewImpl()->resizeWithBrowserControls(IntSize(500, 450), 20, false); 1339 webViewImpl()->resizeWithBrowserControls(IntSize(500, 450), 20, false);
1365 1340
1366 registerMockedHttpURLLoad("content-width-1000.html"); 1341 registerMockedHttpURLLoad("content-width-1000.html");
1367 navigateTo(m_baseURL + "content-width-1000.html"); 1342 navigateTo(m_baseURL + "content-width-1000.html");
1368 1343
1369 VisualViewport& visualViewport = 1344 VisualViewport& visualViewport = frame()->page()->visualViewport();
1370 frame()->page()->frameHost().visualViewport();
1371 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); 1345 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView();
1372 1346
1373 visualViewport.setScale(2); 1347 visualViewport.setScale(2);
1374 EXPECT_SIZE_EQ(IntSize(250, 225), visualViewport.visibleRect().size()); 1348 EXPECT_SIZE_EQ(IntSize(250, 225), visualViewport.visibleRect().size());
1375 EXPECT_SIZE_EQ(IntSize(1000, 900), frameView.frameRect().size()); 1349 EXPECT_SIZE_EQ(IntSize(1000, 900), frameView.frameRect().size());
1376 1350
1377 // Simulate bringing down the browser controls by 20px. Since we're zoomed in, 1351 // Simulate bringing down the browser controls by 20px. Since we're zoomed in,
1378 // the browser controls take up half as much space (in document-space) than 1352 // the browser controls take up half as much space (in document-space) than
1379 // they do at an unzoomed level. 1353 // they do at an unzoomed level.
1380 webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSize(), 1354 webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSize(),
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1443 initializeWithAndroidSettings(); 1417 initializeWithAndroidSettings();
1444 1418
1445 // Initialize with browser controls showing and shrinking the Blink size. 1419 // Initialize with browser controls showing and shrinking the Blink size.
1446 webViewImpl()->resizeWithBrowserControls( 1420 webViewImpl()->resizeWithBrowserControls(
1447 WebSize(500, visualViewportHeight - browserControlsHeight), 20, true); 1421 WebSize(500, visualViewportHeight - browserControlsHeight), 20, true);
1448 webViewImpl()->browserControls().setShownRatio(1); 1422 webViewImpl()->browserControls().setShownRatio(1);
1449 1423
1450 registerMockedHttpURLLoad("content-width-1000.html"); 1424 registerMockedHttpURLLoad("content-width-1000.html");
1451 navigateTo(m_baseURL + "content-width-1000.html"); 1425 navigateTo(m_baseURL + "content-width-1000.html");
1452 1426
1453 VisualViewport& visualViewport = 1427 VisualViewport& visualViewport = frame()->page()->visualViewport();
1454 frame()->page()->frameHost().visualViewport();
1455 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); 1428 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView();
1456 1429
1457 visualViewport.setScale(pageScale); 1430 visualViewport.setScale(pageScale);
1458 EXPECT_SIZE_EQ( 1431 EXPECT_SIZE_EQ(
1459 IntSize(250, (visualViewportHeight - browserControlsHeight) / pageScale), 1432 IntSize(250, (visualViewportHeight - browserControlsHeight) / pageScale),
1460 visualViewport.visibleRect().size()); 1433 visualViewport.visibleRect().size());
1461 EXPECT_SIZE_EQ(IntSize(1000, layoutViewportHeight - 1434 EXPECT_SIZE_EQ(IntSize(1000, layoutViewportHeight -
1462 browserControlsHeight / minPageScale), 1435 browserControlsHeight / minPageScale),
1463 frameView.frameRect().size()); 1436 frameView.frameRect().size());
1464 EXPECT_SIZE_EQ(IntSize(500, visualViewportHeight - browserControlsHeight), 1437 EXPECT_SIZE_EQ(IntSize(500, visualViewportHeight - browserControlsHeight),
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1516 initializeWithAndroidSettings(); 1489 initializeWithAndroidSettings();
1517 1490
1518 // Initialize with browser controls hidden and not shrinking the Blink size. 1491 // Initialize with browser controls hidden and not shrinking the Blink size.
1519 webViewImpl()->resizeWithBrowserControls(IntSize(500, visualViewportHeight), 1492 webViewImpl()->resizeWithBrowserControls(IntSize(500, visualViewportHeight),
1520 20, false); 1493 20, false);
1521 webViewImpl()->browserControls().setShownRatio(0); 1494 webViewImpl()->browserControls().setShownRatio(0);
1522 1495
1523 registerMockedHttpURLLoad("content-width-1000.html"); 1496 registerMockedHttpURLLoad("content-width-1000.html");
1524 navigateTo(m_baseURL + "content-width-1000.html"); 1497 navigateTo(m_baseURL + "content-width-1000.html");
1525 1498
1526 VisualViewport& visualViewport = 1499 VisualViewport& visualViewport = frame()->page()->visualViewport();
1527 frame()->page()->frameHost().visualViewport();
1528 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); 1500 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView();
1529 1501
1530 visualViewport.setScale(pageScale); 1502 visualViewport.setScale(pageScale);
1531 EXPECT_SIZE_EQ(IntSize(250, visualViewportHeight / pageScale), 1503 EXPECT_SIZE_EQ(IntSize(250, visualViewportHeight / pageScale),
1532 visualViewport.visibleRect().size()); 1504 visualViewport.visibleRect().size());
1533 EXPECT_SIZE_EQ(IntSize(1000, layoutViewportHeight), 1505 EXPECT_SIZE_EQ(IntSize(1000, layoutViewportHeight),
1534 frameView.frameRect().size()); 1506 frameView.frameRect().size());
1535 EXPECT_SIZE_EQ(IntSize(500, visualViewportHeight), visualViewport.size()); 1507 EXPECT_SIZE_EQ(IntSize(500, visualViewportHeight), visualViewport.size());
1536 1508
1537 // Scroll all the way to the bottom, showing the the browser controls in the 1509 // Scroll all the way to the bottom, showing the the browser controls in the
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1616 } 1588 }
1617 1589
1618 // Tests that scrollbar layers are not attached to the inner viewport container 1590 // Tests that scrollbar layers are not attached to the inner viewport container
1619 // layer when hideScrollbars WebSetting is true. 1591 // layer when hideScrollbars WebSetting is true.
1620 TEST_P(VisualViewportTest, 1592 TEST_P(VisualViewportTest,
1621 TestScrollbarsNotAttachedWhenHideScrollbarsSettingIsTrue) { 1593 TestScrollbarsNotAttachedWhenHideScrollbarsSettingIsTrue) {
1622 initializeWithAndroidSettings(configureHiddenScrollbarsSettings); 1594 initializeWithAndroidSettings(configureHiddenScrollbarsSettings);
1623 webViewImpl()->resize(IntSize(100, 150)); 1595 webViewImpl()->resize(IntSize(100, 150));
1624 navigateTo("about:blank"); 1596 navigateTo("about:blank");
1625 1597
1626 VisualViewport& visualViewport = 1598 VisualViewport& visualViewport = frame()->page()->visualViewport();
1627 frame()->page()->frameHost().visualViewport();
1628 EXPECT_FALSE(visualViewport.layerForHorizontalScrollbar()->parent()); 1599 EXPECT_FALSE(visualViewport.layerForHorizontalScrollbar()->parent());
1629 EXPECT_FALSE(visualViewport.layerForVerticalScrollbar()->parent()); 1600 EXPECT_FALSE(visualViewport.layerForVerticalScrollbar()->parent());
1630 } 1601 }
1631 1602
1632 // Tests that scrollbar layers are attached to the inner viewport container 1603 // Tests that scrollbar layers are attached to the inner viewport container
1633 // layer when hideScrollbars WebSetting is false. 1604 // layer when hideScrollbars WebSetting is false.
1634 TEST_P(VisualViewportTest, 1605 TEST_P(VisualViewportTest,
1635 TestScrollbarsAttachedWhenHideScrollbarsSettingIsFalse) { 1606 TestScrollbarsAttachedWhenHideScrollbarsSettingIsFalse) {
1636 initializeWithAndroidSettings(); 1607 initializeWithAndroidSettings();
1637 webViewImpl()->resize(IntSize(100, 150)); 1608 webViewImpl()->resize(IntSize(100, 150));
1638 navigateTo("about:blank"); 1609 navigateTo("about:blank");
1639 1610
1640 VisualViewport& visualViewport = 1611 VisualViewport& visualViewport = frame()->page()->visualViewport();
1641 frame()->page()->frameHost().visualViewport();
1642 EXPECT_TRUE(visualViewport.layerForHorizontalScrollbar()->parent()); 1612 EXPECT_TRUE(visualViewport.layerForHorizontalScrollbar()->parent());
1643 EXPECT_TRUE(visualViewport.layerForVerticalScrollbar()->parent()); 1613 EXPECT_TRUE(visualViewport.layerForVerticalScrollbar()->parent());
1644 } 1614 }
1645 1615
1646 // Tests that the layout viewport's scroll layer bounds are updated in a 1616 // Tests that the layout viewport's scroll layer bounds are updated in a
1647 // compositing change update. crbug.com/423188. 1617 // compositing change update. crbug.com/423188.
1648 TEST_P(VisualViewportTest, TestChangingContentSizeAffectsScrollBounds) { 1618 TEST_P(VisualViewportTest, TestChangingContentSizeAffectsScrollBounds) {
1649 initializeWithAndroidSettings(); 1619 initializeWithAndroidSettings();
1650 webViewImpl()->resize(IntSize(100, 150)); 1620 webViewImpl()->resize(IntSize(100, 150));
1651 1621
(...skipping 18 matching lines...) Expand all
1670 // viewport. 1640 // viewport.
1671 TEST_P(VisualViewportTest, ResizeVisualViewportStaysWithinOuterViewport) { 1641 TEST_P(VisualViewportTest, ResizeVisualViewportStaysWithinOuterViewport) {
1672 initializeWithDesktopSettings(); 1642 initializeWithDesktopSettings();
1673 webViewImpl()->resize(IntSize(100, 200)); 1643 webViewImpl()->resize(IntSize(100, 200));
1674 1644
1675 navigateTo("about:blank"); 1645 navigateTo("about:blank");
1676 webViewImpl()->updateAllLifecyclePhases(); 1646 webViewImpl()->updateAllLifecyclePhases();
1677 1647
1678 webViewImpl()->resizeVisualViewport(IntSize(100, 100)); 1648 webViewImpl()->resizeVisualViewport(IntSize(100, 100));
1679 1649
1680 VisualViewport& visualViewport = 1650 VisualViewport& visualViewport = frame()->page()->visualViewport();
1681 frame()->page()->frameHost().visualViewport();
1682 visualViewport.move(ScrollOffset(0, 100)); 1651 visualViewport.move(ScrollOffset(0, 100));
1683 1652
1684 EXPECT_EQ(100, visualViewport.getScrollOffset().height()); 1653 EXPECT_EQ(100, visualViewport.getScrollOffset().height());
1685 1654
1686 webViewImpl()->resizeVisualViewport(IntSize(100, 200)); 1655 webViewImpl()->resizeVisualViewport(IntSize(100, 200));
1687 1656
1688 EXPECT_EQ(0, visualViewport.getScrollOffset().height()); 1657 EXPECT_EQ(0, visualViewport.getScrollOffset().height());
1689 } 1658 }
1690 1659
1691 TEST_P(VisualViewportTest, ElementBoundsInViewportSpaceAccountsForViewport) { 1660 TEST_P(VisualViewportTest, ElementBoundsInViewportSpaceAccountsForViewport) {
1692 initializeWithAndroidSettings(); 1661 initializeWithAndroidSettings();
1693 1662
1694 webViewImpl()->resize(IntSize(500, 800)); 1663 webViewImpl()->resize(IntSize(500, 800));
1695 1664
1696 registerMockedHttpURLLoad("pinch-viewport-input-field.html"); 1665 registerMockedHttpURLLoad("pinch-viewport-input-field.html");
1697 navigateTo(m_baseURL + "pinch-viewport-input-field.html"); 1666 navigateTo(m_baseURL + "pinch-viewport-input-field.html");
1698 1667
1699 webViewImpl()->setInitialFocus(false); 1668 webViewImpl()->setInitialFocus(false);
1700 Element* inputElement = webViewImpl()->focusedElement(); 1669 Element* inputElement = webViewImpl()->focusedElement();
1701 1670
1702 IntRect bounds = inputElement->layoutObject()->absoluteBoundingBoxRect(); 1671 IntRect bounds = inputElement->layoutObject()->absoluteBoundingBoxRect();
1703 1672
1704 VisualViewport& visualViewport = 1673 VisualViewport& visualViewport = frame()->page()->visualViewport();
1705 frame()->page()->frameHost().visualViewport();
1706 IntPoint scrollDelta(250, 400); 1674 IntPoint scrollDelta(250, 400);
1707 visualViewport.setScale(2); 1675 visualViewport.setScale(2);
1708 visualViewport.setLocation(scrollDelta); 1676 visualViewport.setLocation(scrollDelta);
1709 1677
1710 const IntRect boundsInViewport = inputElement->boundsInViewport(); 1678 const IntRect boundsInViewport = inputElement->boundsInViewport();
1711 IntRect expectedBounds = bounds; 1679 IntRect expectedBounds = bounds;
1712 expectedBounds.scale(2.f); 1680 expectedBounds.scale(2.f);
1713 IntPoint expectedScrollDelta = scrollDelta; 1681 IntPoint expectedScrollDelta = scrollDelta;
1714 expectedScrollDelta.scale(2.f, 2.f); 1682 expectedScrollDelta.scale(2.f, 2.f);
1715 1683
(...skipping 21 matching lines...) Expand all
1737 // methods work unchanged from the pre-virtual viewport mode. 1705 // methods work unchanged from the pre-virtual viewport mode.
1738 TEST_P(VisualViewportTest, bodyAndWindowScrollPropertiesAccountForViewport) { 1706 TEST_P(VisualViewportTest, bodyAndWindowScrollPropertiesAccountForViewport) {
1739 initializeWithAndroidSettings(); 1707 initializeWithAndroidSettings();
1740 1708
1741 webViewImpl()->resize(IntSize(200, 300)); 1709 webViewImpl()->resize(IntSize(200, 300));
1742 1710
1743 // Load page with no main frame scrolling. 1711 // Load page with no main frame scrolling.
1744 registerMockedHttpURLLoad("200-by-300-viewport.html"); 1712 registerMockedHttpURLLoad("200-by-300-viewport.html");
1745 navigateTo(m_baseURL + "200-by-300-viewport.html"); 1713 navigateTo(m_baseURL + "200-by-300-viewport.html");
1746 1714
1747 VisualViewport& visualViewport = 1715 VisualViewport& visualViewport = frame()->page()->visualViewport();
1748 frame()->page()->frameHost().visualViewport();
1749 visualViewport.setScale(2); 1716 visualViewport.setScale(2);
1750 1717
1751 // Chrome's quirky behavior regarding viewport scrolling means we treat the 1718 // Chrome's quirky behavior regarding viewport scrolling means we treat the
1752 // body element as the viewport and don't apply scrolling to the HTML element. 1719 // body element as the viewport and don't apply scrolling to the HTML element.
1753 RuntimeEnabledFeatures::setScrollTopLeftInteropEnabled(false); 1720 RuntimeEnabledFeatures::setScrollTopLeftInteropEnabled(false);
1754 1721
1755 LocalDOMWindow* window = webViewImpl()->mainFrameImpl()->frame()->domWindow(); 1722 LocalDOMWindow* window = webViewImpl()->mainFrameImpl()->frame()->domWindow();
1756 window->scrollTo(100, 150); 1723 window->scrollTo(100, 150);
1757 EXPECT_EQ(100, window->scrollX()); 1724 EXPECT_EQ(100, window->scrollX());
1758 EXPECT_EQ(150, window->scrollY()); 1725 EXPECT_EQ(150, window->scrollY());
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1831 EXPECT_SIZE_EQ(IntSize(200, 400), frameView.frameRect().size()); 1798 EXPECT_SIZE_EQ(IntSize(200, 400), frameView.frameRect().size());
1832 frameView.dispose(); 1799 frameView.dispose();
1833 } 1800 }
1834 1801
1835 // Tests that the maximum scroll offset of the viewport can be fractional. 1802 // Tests that the maximum scroll offset of the viewport can be fractional.
1836 TEST_P(VisualViewportTest, FractionalMaxScrollOffset) { 1803 TEST_P(VisualViewportTest, FractionalMaxScrollOffset) {
1837 initializeWithDesktopSettings(); 1804 initializeWithDesktopSettings();
1838 webViewImpl()->resize(IntSize(101, 201)); 1805 webViewImpl()->resize(IntSize(101, 201));
1839 navigateTo("about:blank"); 1806 navigateTo("about:blank");
1840 1807
1841 VisualViewport& visualViewport = 1808 VisualViewport& visualViewport = frame()->page()->visualViewport();
1842 frame()->page()->frameHost().visualViewport();
1843 ScrollableArea* scrollableArea = &visualViewport; 1809 ScrollableArea* scrollableArea = &visualViewport;
1844 1810
1845 webViewImpl()->setPageScaleFactor(1.0); 1811 webViewImpl()->setPageScaleFactor(1.0);
1846 EXPECT_SIZE_EQ(ScrollOffset(), scrollableArea->maximumScrollOffset()); 1812 EXPECT_SIZE_EQ(ScrollOffset(), scrollableArea->maximumScrollOffset());
1847 1813
1848 webViewImpl()->setPageScaleFactor(2); 1814 webViewImpl()->setPageScaleFactor(2);
1849 EXPECT_SIZE_EQ(ScrollOffset(101. / 2., 201. / 2.), 1815 EXPECT_SIZE_EQ(ScrollOffset(101. / 2., 201. / 2.),
1850 scrollableArea->maximumScrollOffset()); 1816 scrollableArea->maximumScrollOffset());
1851 } 1817 }
1852 1818
1853 // Tests that the slow scrolling after an impl scroll on the visual viewport is 1819 // Tests that the slow scrolling after an impl scroll on the visual viewport is
1854 // continuous. crbug.com/453460 was caused by the impl-path not updating the 1820 // continuous. crbug.com/453460 was caused by the impl-path not updating the
1855 // ScrollAnimatorBase class. 1821 // ScrollAnimatorBase class.
1856 TEST_P(VisualViewportTest, SlowScrollAfterImplScroll) { 1822 TEST_P(VisualViewportTest, SlowScrollAfterImplScroll) {
1857 initializeWithDesktopSettings(); 1823 initializeWithDesktopSettings();
1858 webViewImpl()->resize(IntSize(800, 600)); 1824 webViewImpl()->resize(IntSize(800, 600));
1859 navigateTo("about:blank"); 1825 navigateTo("about:blank");
1860 1826
1861 VisualViewport& visualViewport = 1827 VisualViewport& visualViewport = frame()->page()->visualViewport();
1862 frame()->page()->frameHost().visualViewport();
1863 1828
1864 // Apply some scroll and scale from the impl-side. 1829 // Apply some scroll and scale from the impl-side.
1865 webViewImpl()->applyViewportDeltas(WebFloatSize(300, 200), WebFloatSize(0, 0), 1830 webViewImpl()->applyViewportDeltas(WebFloatSize(300, 200), WebFloatSize(0, 0),
1866 WebFloatSize(0, 0), 2, 0); 1831 WebFloatSize(0, 0), 2, 0);
1867 1832
1868 EXPECT_SIZE_EQ(FloatSize(300, 200), visualViewport.getScrollOffset()); 1833 EXPECT_SIZE_EQ(FloatSize(300, 200), visualViewport.getScrollOffset());
1869 1834
1870 // Send a scroll event on the main thread path. 1835 // Send a scroll event on the main thread path.
1871 WebGestureEvent gsu(WebInputEvent::GestureScrollUpdate, 1836 WebGestureEvent gsu(WebInputEvent::GestureScrollUpdate,
1872 WebInputEvent::NoModifiers, 1837 WebInputEvent::NoModifiers,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1919 EXPECT_EQ(std::string("Target4"), hitNode.name(nameFrom, nameObjects).utf8()); 1884 EXPECT_EQ(std::string("Target4"), hitNode.name(nameFrom, nameObjects).utf8());
1920 } 1885 }
1921 1886
1922 // Tests that the maximum scroll offset of the viewport can be fractional. 1887 // Tests that the maximum scroll offset of the viewport can be fractional.
1923 TEST_P(VisualViewportTest, TestCoordinateTransforms) { 1888 TEST_P(VisualViewportTest, TestCoordinateTransforms) {
1924 initializeWithAndroidSettings(); 1889 initializeWithAndroidSettings();
1925 webViewImpl()->resize(IntSize(800, 600)); 1890 webViewImpl()->resize(IntSize(800, 600));
1926 registerMockedHttpURLLoad("content-width-1000.html"); 1891 registerMockedHttpURLLoad("content-width-1000.html");
1927 navigateTo(m_baseURL + "content-width-1000.html"); 1892 navigateTo(m_baseURL + "content-width-1000.html");
1928 1893
1929 VisualViewport& visualViewport = 1894 VisualViewport& visualViewport = webViewImpl()->page()->visualViewport();
1930 webViewImpl()->page()->frameHost().visualViewport();
1931 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); 1895 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView();
1932 1896
1933 // At scale = 1 the transform should be a no-op. 1897 // At scale = 1 the transform should be a no-op.
1934 visualViewport.setScale(1); 1898 visualViewport.setScale(1);
1935 EXPECT_FLOAT_POINT_EQ( 1899 EXPECT_FLOAT_POINT_EQ(
1936 FloatPoint(314, 273), 1900 FloatPoint(314, 273),
1937 visualViewport.viewportToRootFrame(FloatPoint(314, 273))); 1901 visualViewport.viewportToRootFrame(FloatPoint(314, 273)));
1938 EXPECT_FLOAT_POINT_EQ( 1902 EXPECT_FLOAT_POINT_EQ(
1939 FloatPoint(314, 273), 1903 FloatPoint(314, 273),
1940 visualViewport.rootFrameToViewport(FloatPoint(314, 273))); 1904 visualViewport.rootFrameToViewport(FloatPoint(314, 273)));
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
2013 WebInputEvent::NoModifiers, 1977 WebInputEvent::NoModifiers,
2014 WebInputEvent::TimeStampForTesting); 1978 WebInputEvent::TimeStampForTesting);
2015 pinchUpdate.sourceDevice = WebGestureDeviceTouchpad; 1979 pinchUpdate.sourceDevice = WebGestureDeviceTouchpad;
2016 pinchUpdate.x = 100; 1980 pinchUpdate.x = 100;
2017 pinchUpdate.y = 100; 1981 pinchUpdate.y = 100;
2018 pinchUpdate.data.pinchUpdate.scale = 2; 1982 pinchUpdate.data.pinchUpdate.scale = 2;
2019 pinchUpdate.data.pinchUpdate.zoomDisabled = false; 1983 pinchUpdate.data.pinchUpdate.zoomDisabled = false;
2020 1984
2021 webViewImpl()->handleInputEvent(WebCoalescedInputEvent(pinchUpdate)); 1985 webViewImpl()->handleInputEvent(WebCoalescedInputEvent(pinchUpdate));
2022 1986
2023 VisualViewport& visualViewport = 1987 VisualViewport& visualViewport = webViewImpl()->page()->visualViewport();
2024 webViewImpl()->page()->frameHost().visualViewport();
2025 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); 1988 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView();
2026 1989
2027 EXPECT_FLOAT_SIZE_EQ(FloatSize(50, 50), visualViewport.getScrollOffset()); 1990 EXPECT_FLOAT_SIZE_EQ(FloatSize(50, 50), visualViewport.getScrollOffset());
2028 EXPECT_SIZE_EQ(ScrollOffset(0, 0), 1991 EXPECT_SIZE_EQ(ScrollOffset(0, 0),
2029 frameView.layoutViewportScrollableArea()->getScrollOffset()); 1992 frameView.layoutViewportScrollableArea()->getScrollOffset());
2030 } 1993 }
2031 1994
2032 TEST_P(VisualViewportTest, ResizeWithScrollAnchoring) { 1995 TEST_P(VisualViewportTest, ResizeWithScrollAnchoring) {
2033 bool wasScrollAnchoringEnabled = 1996 bool wasScrollAnchoringEnabled =
2034 RuntimeEnabledFeatures::scrollAnchoringEnabled(); 1997 RuntimeEnabledFeatures::scrollAnchoringEnabled();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2068 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); 2031 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView();
2069 2032
2070 Element* scroller = frame()->document()->getElementById("rootScroller"); 2033 Element* scroller = frame()->document()->getElementById("rootScroller");
2071 NonThrowableExceptionState nonThrow; 2034 NonThrowableExceptionState nonThrow;
2072 frame()->document()->setRootScroller(scroller, nonThrow); 2035 frame()->document()->setRootScroller(scroller, nonThrow);
2073 2036
2074 webViewImpl()->setPageScaleFactor(3.f); 2037 webViewImpl()->setPageScaleFactor(3.f);
2075 frameView.getScrollableArea()->setScrollOffset(ScrollOffset(0, 400), 2038 frameView.getScrollableArea()->setScrollOffset(ScrollOffset(0, 400),
2076 ProgrammaticScroll); 2039 ProgrammaticScroll);
2077 2040
2078 VisualViewport& visualViewport = 2041 VisualViewport& visualViewport = webViewImpl()->page()->visualViewport();
2079 webViewImpl()->page()->frameHost().visualViewport();
2080 visualViewport.setScrollOffset(ScrollOffset(0, 400), ProgrammaticScroll); 2042 visualViewport.setScrollOffset(ScrollOffset(0, 400), ProgrammaticScroll);
2081 2043
2082 webViewImpl()->resize(IntSize(800, 500)); 2044 webViewImpl()->resize(IntSize(800, 500));
2083 2045
2084 EXPECT_SIZE_EQ(ScrollOffset(), 2046 EXPECT_SIZE_EQ(ScrollOffset(),
2085 frameView.layoutViewportScrollableArea()->getScrollOffset()); 2047 frameView.layoutViewportScrollableArea()->getScrollOffset());
2086 2048
2087 RuntimeEnabledFeatures::setSetRootScrollerEnabled(wasRootScrollerEnabled); 2049 RuntimeEnabledFeatures::setSetRootScrollerEnabled(wasRootScrollerEnabled);
2088 } 2050 }
2089 2051
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
2471 " body {" 2433 " body {"
2472 " margin: 0px;" 2434 " margin: 0px;"
2473 " }" 2435 " }"
2474 " div { height:110vh; width: 110vw; }" 2436 " div { height:110vh; width: 110vw; }"
2475 "</style>" 2437 "</style>"
2476 "<div></div>", 2438 "<div></div>",
2477 baseURL); 2439 baseURL);
2478 } 2440 }
2479 2441
2480 } // namespace 2442 } // namespace
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/tests/TextFinderTest.cpp ('k') | third_party/WebKit/Source/web/tests/WebFrameTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698