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 20 matching lines...) Expand all Loading... |
31 #include "config.h" | 31 #include "config.h" |
32 | 32 |
33 #include "WebFrame.h" | 33 #include "WebFrame.h" |
34 | 34 |
35 #include "FloatRect.h" | 35 #include "FloatRect.h" |
36 #include "Frame.h" | 36 #include "Frame.h" |
37 #include "FrameTestHelpers.h" | 37 #include "FrameTestHelpers.h" |
38 #include "FrameView.h" | 38 #include "FrameView.h" |
39 #include "Range.h" | 39 #include "Range.h" |
40 #include "ResourceError.h" | 40 #include "ResourceError.h" |
| 41 #include "Settings.h" |
41 #include "URLTestHelpers.h" | 42 #include "URLTestHelpers.h" |
42 #include "WebDataSource.h" | 43 #include "WebDataSource.h" |
43 #include "WebDocument.h" | 44 #include "WebDocument.h" |
44 #include "WebFindOptions.h" | 45 #include "WebFindOptions.h" |
45 #include "WebFormElement.h" | 46 #include "WebFormElement.h" |
46 #include "WebFrameClient.h" | 47 #include "WebFrameClient.h" |
47 #include "WebFrameImpl.h" | 48 #include "WebFrameImpl.h" |
48 #include "WebHistoryItem.h" | 49 #include "WebHistoryItem.h" |
49 #include "WebRange.h" | 50 #include "WebRange.h" |
50 #include "WebScriptSource.h" | 51 #include "WebScriptSource.h" |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 registerMockedHttpURLLoad("get_scale_bounds_check_for_auto_zoom_test.html"); | 445 registerMockedHttpURLLoad("get_scale_bounds_check_for_auto_zoom_test.html"); |
445 | 446 |
446 int viewportWidth = 640; | 447 int viewportWidth = 640; |
447 int viewportHeight = 480; | 448 int viewportHeight = 480; |
448 float doubleTapZoomAlreadyLegibleRatio = 1.2f; | 449 float doubleTapZoomAlreadyLegibleRatio = 1.2f; |
449 WebKit::WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL
+ "get_scale_bounds_check_for_auto_zoom_test.html"); | 450 WebKit::WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL
+ "get_scale_bounds_check_for_auto_zoom_test.html"); |
450 webView->enableFixedLayoutMode(true); | 451 webView->enableFixedLayoutMode(true); |
451 webView->resize(WebSize(viewportWidth, viewportHeight)); | 452 webView->resize(WebSize(viewportWidth, viewportHeight)); |
452 webView->setPageScaleFactorLimits(1, 4); | 453 webView->setPageScaleFactorLimits(1, 4); |
453 webView->layout(); | 454 webView->layout(); |
454 webView->setDeviceScaleFactor(1.5f); | |
455 | 455 |
456 WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(webView); | 456 WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(webView); |
457 webViewImpl->shouldUseAnimateDoubleTapTimeZeroForTesting(true); | 457 webViewImpl->shouldUseAnimateDoubleTapTimeZeroForTesting(true); |
458 float doubleTapZoomAlreadyLegibleScale = webViewImpl->minimumPageScaleFactor
() * doubleTapZoomAlreadyLegibleRatio; | 458 float doubleTapZoomAlreadyLegibleScale = webViewImpl->minimumPageScaleFactor
() * doubleTapZoomAlreadyLegibleRatio; |
459 | 459 |
460 WebRect div(200, 100, 200, 150); | 460 WebRect div(200, 100, 200, 150); |
461 WebPoint doubleTapPoint(div.x + 50, div.y + 50); | 461 WebPoint doubleTapPoint(div.x + 50, div.y + 50); |
462 float scale; | 462 float scale; |
463 | 463 |
464 // Test double tap scale bounds. | 464 // Test double tap scale bounds. |
465 // minimumPageScale < doubleTapZoomAlreadyLegibleScale < deviceDpiScale | 465 // minimumPageScale < doubleTapZoomAlreadyLegibleScale < deviceDpiScale |
| 466 webViewImpl->setDeviceScaleFactor(1.5f); |
466 setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimu
mPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2); | 467 setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimu
mPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2); |
467 simulateDoubleTap(webViewImpl, doubleTapPoint, scale); | 468 simulateDoubleTap(webViewImpl, doubleTapPoint, scale); |
468 EXPECT_FLOAT_EQ(webViewImpl->deviceScaleFactor(), scale); | 469 EXPECT_FLOAT_EQ(webViewImpl->deviceScaleFactor(), scale); |
469 simulateDoubleTap(webViewImpl, doubleTapPoint, scale); | 470 simulateDoubleTap(webViewImpl, doubleTapPoint, scale); |
470 EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale); | 471 EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale); |
471 simulateDoubleTap(webViewImpl, doubleTapPoint, scale); | 472 simulateDoubleTap(webViewImpl, doubleTapPoint, scale); |
472 EXPECT_FLOAT_EQ(webViewImpl->deviceScaleFactor(), scale); | 473 EXPECT_FLOAT_EQ(webViewImpl->deviceScaleFactor(), scale); |
473 | 474 |
474 // Zoom in to reset double_tap_zoom_in_effect flag. | 475 // Zoom in to reset double_tap_zoom_in_effect flag. |
475 webViewImpl->applyScrollAndScale(WebSize(), 1.1f); | 476 webViewImpl->applyScrollAndScale(WebSize(), 1.1f); |
476 // deviceDpiScale < minimumPageScale < doubleTapZoomAlreadyLegibleScale | 477 // deviceDpiScale < minimumPageScale < doubleTapZoomAlreadyLegibleScale |
477 webViewImpl->setDeviceScaleFactor(0.5f); | 478 webViewImpl->setDeviceScaleFactor(0.5f); |
478 setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimu
mPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2); | 479 setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimu
mPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2); |
479 simulateDoubleTap(webViewImpl, doubleTapPoint, scale); | 480 simulateDoubleTap(webViewImpl, doubleTapPoint, scale); |
480 EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale); | 481 EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale); |
481 simulateDoubleTap(webViewImpl, doubleTapPoint, scale); | 482 simulateDoubleTap(webViewImpl, doubleTapPoint, scale); |
482 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); | 483 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); |
483 simulateDoubleTap(webViewImpl, doubleTapPoint, scale); | 484 simulateDoubleTap(webViewImpl, doubleTapPoint, scale); |
484 EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale); | 485 EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale); |
485 | 486 |
486 // Zoom in to reset double_tap_zoom_in_effect flag. | 487 // Zoom in to reset double_tap_zoom_in_effect flag. |
487 webViewImpl->applyScrollAndScale(WebSize(), 1.1f); | 488 webViewImpl->applyScrollAndScale(WebSize(), 1.1f); |
488 // minimumPageScale < doubleTapZoomAlreadyLegibleScale < deviceDpiScale | 489 // minimumPageScale < deviceDpiScale < doubleTapZoomAlreadyLegibleScale |
489 webViewImpl->setDeviceScaleFactor(1.1f); | 490 webViewImpl->setDeviceScaleFactor(1.1f); |
490 setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimu
mPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2); | 491 setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimu
mPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2); |
491 simulateDoubleTap(webViewImpl, doubleTapPoint, scale); | 492 simulateDoubleTap(webViewImpl, doubleTapPoint, scale); |
492 EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale); | 493 EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale); |
493 simulateDoubleTap(webViewImpl, doubleTapPoint, scale); | 494 simulateDoubleTap(webViewImpl, doubleTapPoint, scale); |
494 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); | 495 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); |
495 simulateDoubleTap(webViewImpl, doubleTapPoint, scale); | 496 simulateDoubleTap(webViewImpl, doubleTapPoint, scale); |
496 EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale); | 497 EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale); |
497 } | 498 } |
498 | 499 |
| 500 #if ENABLE(TEXT_AUTOSIZING) |
| 501 TEST_F(WebFrameTest, DivAutoZoomScaleFontScaleFactorTest) |
| 502 { |
| 503 registerMockedHttpURLLoad("get_scale_bounds_check_for_auto_zoom_test.html"); |
| 504 |
| 505 int viewportWidth = 640; |
| 506 int viewportHeight = 480; |
| 507 float doubleTapZoomAlreadyLegibleRatio = 1.2f; |
| 508 float textAutosizingFontScaleFactor = 1.13f; |
| 509 WebKit::WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_baseURL
+ "get_scale_bounds_check_for_auto_zoom_test.html"); |
| 510 webView->enableFixedLayoutMode(true); |
| 511 webView->resize(WebSize(viewportWidth, viewportHeight)); |
| 512 webView->setPageScaleFactorLimits(1, 4); |
| 513 webView->layout(); |
| 514 |
| 515 WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(webView); |
| 516 webViewImpl->shouldUseAnimateDoubleTapTimeZeroForTesting(true); |
| 517 webViewImpl->page()->settings()->setTextAutosizingFontScaleFactor(textAutosi
zingFontScaleFactor); |
| 518 float doubleTapZoomAlreadyLegibleScale = webViewImpl->minimumPageScaleFactor
() * doubleTapZoomAlreadyLegibleRatio; |
| 519 |
| 520 WebRect div(200, 100, 200, 150); |
| 521 WebPoint doubleTapPoint(div.x + 50, div.y + 50); |
| 522 float scale; |
| 523 |
| 524 // Test double tap scale bounds. |
| 525 // minimumPageScale < doubleTapZoomAlreadyLegibleScale < deviceDpiScale < de
viceDpiScale * textAutosizingFontScaleFactor |
| 526 webViewImpl->setDeviceScaleFactor(1.5f); |
| 527 float legibleScale = webViewImpl->deviceScaleFactor() * textAutosizingFontSc
aleFactor; |
| 528 setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimu
mPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2); |
| 529 simulateDoubleTap(webViewImpl, doubleTapPoint, scale); |
| 530 EXPECT_FLOAT_EQ(legibleScale, scale); |
| 531 simulateDoubleTap(webViewImpl, doubleTapPoint, scale); |
| 532 EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale); |
| 533 simulateDoubleTap(webViewImpl, doubleTapPoint, scale); |
| 534 EXPECT_FLOAT_EQ(legibleScale, scale); |
| 535 |
| 536 // Zoom in to reset double_tap_zoom_in_effect flag. |
| 537 webViewImpl->applyScrollAndScale(WebSize(), 1.1f); |
| 538 // deviceDpiScale < deviceDpiScale * textAutosizingFontScaleFactor < minimum
PageScale < doubleTapZoomAlreadyLegibleScale |
| 539 webViewImpl->setDeviceScaleFactor(0.5f); |
| 540 legibleScale = webViewImpl->deviceScaleFactor() * textAutosizingFontScaleFac
tor; |
| 541 setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimu
mPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2); |
| 542 simulateDoubleTap(webViewImpl, doubleTapPoint, scale); |
| 543 EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale); |
| 544 simulateDoubleTap(webViewImpl, doubleTapPoint, scale); |
| 545 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); |
| 546 simulateDoubleTap(webViewImpl, doubleTapPoint, scale); |
| 547 EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale); |
| 548 |
| 549 // Zoom in to reset double_tap_zoom_in_effect flag. |
| 550 webViewImpl->applyScrollAndScale(WebSize(), 1.1f); |
| 551 // minimumPageScale < deviceDpiScale < deviceDpiScale * textAutosizingFontSc
aleFactor < doubleTapZoomAlreadyLegibleScale |
| 552 webViewImpl->setDeviceScaleFactor(1.05f); |
| 553 legibleScale = webViewImpl->deviceScaleFactor() * textAutosizingFontScaleFac
tor; |
| 554 setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimu
mPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2); |
| 555 simulateDoubleTap(webViewImpl, doubleTapPoint, scale); |
| 556 EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale); |
| 557 simulateDoubleTap(webViewImpl, doubleTapPoint, scale); |
| 558 EXPECT_FLOAT_EQ(doubleTapZoomAlreadyLegibleScale, scale); |
| 559 simulateDoubleTap(webViewImpl, doubleTapPoint, scale); |
| 560 EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale); |
| 561 |
| 562 // Zoom in to reset double_tap_zoom_in_effect flag. |
| 563 webViewImpl->applyScrollAndScale(WebSize(), 1.1f); |
| 564 // minimumPageScale < deviceDpiScale < doubleTapZoomAlreadyLegibleScale < de
viceDpiScale * textAutosizingFontScaleFactor |
| 565 webViewImpl->setDeviceScaleFactor(1.1f); |
| 566 legibleScale = webViewImpl->deviceScaleFactor() * textAutosizingFontScaleFac
tor; |
| 567 setScaleAndScrollAndLayout(webViewImpl, WebPoint(0, 0), (webViewImpl->minimu
mPageScaleFactor()) * (1 + doubleTapZoomAlreadyLegibleRatio) / 2); |
| 568 simulateDoubleTap(webViewImpl, doubleTapPoint, scale); |
| 569 EXPECT_FLOAT_EQ(legibleScale, scale); |
| 570 simulateDoubleTap(webViewImpl, doubleTapPoint, scale); |
| 571 EXPECT_FLOAT_EQ(webViewImpl->minimumPageScaleFactor(), scale); |
| 572 simulateDoubleTap(webViewImpl, doubleTapPoint, scale); |
| 573 EXPECT_FLOAT_EQ(legibleScale, scale); |
| 574 } |
| 575 #endif |
| 576 |
499 // This test depends on code that is compiled conditionally. We likely need to | 577 // This test depends on code that is compiled conditionally. We likely need to |
500 // add the proper ifdef when re-enabling it. See | 578 // add the proper ifdef when re-enabling it. See |
501 // https://bugs.webkit.org/show_bug.cgi?id=98558 | 579 // https://bugs.webkit.org/show_bug.cgi?id=98558 |
502 TEST_F(WebFrameTest, DISABLED_DivScrollIntoEditableTest) | 580 TEST_F(WebFrameTest, DISABLED_DivScrollIntoEditableTest) |
503 { | 581 { |
504 registerMockedHttpURLLoad("get_scale_for_zoom_into_editable_test.html"); | 582 registerMockedHttpURLLoad("get_scale_for_zoom_into_editable_test.html"); |
505 | 583 |
506 int viewportWidth = 640; | 584 int viewportWidth = 640; |
507 int viewportHeight = 480; | 585 int viewportHeight = 480; |
508 float leftBoxRatio = 0.3f; | 586 float leftBoxRatio = 0.3f; |
(...skipping 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1656 webkit_support::RegisterMockedErrorURL(URLTestHelpers::toKURL(errorURL), res
ponse, error); | 1734 webkit_support::RegisterMockedErrorURL(URLTestHelpers::toKURL(errorURL), res
ponse, error); |
1657 frame->loadHistoryItem(errorHistoryItem); | 1735 frame->loadHistoryItem(errorHistoryItem); |
1658 webkit_support::ServeAsynchronousMockedRequests(); | 1736 webkit_support::ServeAsynchronousMockedRequests(); |
1659 | 1737 |
1660 WebString text = frame->contentAsText(std::numeric_limits<size_t>::max()); | 1738 WebString text = frame->contentAsText(std::numeric_limits<size_t>::max()); |
1661 EXPECT_EQ("This should appear", std::string(text.utf8().data())); | 1739 EXPECT_EQ("This should appear", std::string(text.utf8().data())); |
1662 EXPECT_TRUE(webFrameClient.commitCalled()); | 1740 EXPECT_TRUE(webFrameClient.commitCalled()); |
1663 } | 1741 } |
1664 | 1742 |
1665 } // namespace | 1743 } // namespace |
OLD | NEW |