| OLD | NEW |
| 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "core/frame/PinchViewport.h" | 7 #include "core/frame/PinchViewport.h" |
| 8 | 8 |
| 9 #include "core/dom/Document.h" | 9 #include "core/dom/Document.h" |
| 10 #include "core/frame/FrameHost.h" | 10 #include "core/frame/FrameHost.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 ::std::ostream& operator<<(::std::ostream& os, const WebContextMenuData& data) | 92 ::std::ostream& operator<<(::std::ostream& os, const WebContextMenuData& data) |
| 93 { | 93 { |
| 94 return os << "Context menu location: [" | 94 return os << "Context menu location: [" |
| 95 << data.mousePosition.x << ", " << data.mousePosition.y << "]"; | 95 << data.mousePosition.x << ", " << data.mousePosition.y << "]"; |
| 96 } | 96 } |
| 97 } | 97 } |
| 98 | 98 |
| 99 | 99 |
| 100 namespace { | 100 namespace { |
| 101 | 101 |
| 102 class PinchViewportTest : public testing::Test { | 102 class PinchViewportTest |
| 103 : public testing::Test |
| 104 , public FrameTestHelpers::SettingOverrider { |
| 103 public: | 105 public: |
| 104 PinchViewportTest() | 106 PinchViewportTest() |
| 105 : m_baseURL("http://www.test.com/") | 107 : m_baseURL("http://www.test.com/") |
| 108 , m_helper(this) |
| 106 { | 109 { |
| 107 } | 110 } |
| 108 | 111 |
| 112 void overrideSettings(WebSettings *settings) override |
| 113 { |
| 114 } |
| 115 |
| 109 void initializeWithDesktopSettings(void (*overrideSettingsFunc)(WebSettings*
) = 0) | 116 void initializeWithDesktopSettings(void (*overrideSettingsFunc)(WebSettings*
) = 0) |
| 110 { | 117 { |
| 111 if (!overrideSettingsFunc) | 118 if (!overrideSettingsFunc) |
| 112 overrideSettingsFunc = &configureSettings; | 119 overrideSettingsFunc = &configureSettings; |
| 113 m_helper.initialize(true, 0, &m_mockWebViewClient, overrideSettingsFunc)
; | 120 m_helper.initialize(true, 0, &m_mockWebViewClient, overrideSettingsFunc)
; |
| 114 webViewImpl()->setDefaultPageScaleLimits(1, 4); | 121 webViewImpl()->setDefaultPageScaleLimits(1, 4); |
| 115 } | 122 } |
| 116 | 123 |
| 117 void initializeWithAndroidSettings(void (*overrideSettingsFunc)(WebSettings*
) = 0) | 124 void initializeWithAndroidSettings(void (*overrideSettingsFunc)(WebSettings*
) = 0) |
| 118 { | 125 { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 private: | 185 private: |
| 179 FrameTestHelpers::WebViewHelper m_helper; | 186 FrameTestHelpers::WebViewHelper m_helper; |
| 180 | 187 |
| 181 // To prevent platform differneces in content layout, use mock | 188 // To prevent platform differneces in content layout, use mock |
| 182 // scrollbars. This is especially needed for Mac, where the presence | 189 // scrollbars. This is especially needed for Mac, where the presence |
| 183 // or absence of a mouse will change frame sizes because of different | 190 // or absence of a mouse will change frame sizes because of different |
| 184 // scrollbar themes. | 191 // scrollbar themes. |
| 185 FrameTestHelpers::UseMockScrollbarSettings m_useMockScrollbars; | 192 FrameTestHelpers::UseMockScrollbarSettings m_useMockScrollbars; |
| 186 }; | 193 }; |
| 187 | 194 |
| 195 typedef void (*SettingOverrideFunction)(WebSettings*); |
| 196 |
| 197 static void DefaultSettingOverride(WebSettings *) |
| 198 { |
| 199 } |
| 200 |
| 201 static void RootLayerScrollsSettingOverride(WebSettings *settings) |
| 202 { |
| 203 settings->setRootLayerScrolls(true); |
| 204 } |
| 205 |
| 206 class ParameterizedPinchViewportTest |
| 207 : public PinchViewportTest |
| 208 , public testing::WithParamInterface<SettingOverrideFunction> { |
| 209 public: |
| 210 void overrideSettings(WebSettings *settings) override |
| 211 { |
| 212 GetParam()(settings); |
| 213 } |
| 214 }; |
| 215 |
| 216 INSTANTIATE_TEST_CASE_P(All, ParameterizedPinchViewportTest, ::testing::Values( |
| 217 DefaultSettingOverride, |
| 218 RootLayerScrollsSettingOverride)); |
| 219 |
| 188 // Test that resizing the PinchViewport works as expected and that resizing the | 220 // Test that resizing the PinchViewport works as expected and that resizing the |
| 189 // WebView resizes the PinchViewport. | 221 // WebView resizes the PinchViewport. |
| 190 TEST_F(PinchViewportTest, TestResize) | 222 TEST_P(ParameterizedPinchViewportTest, TestResize) |
| 191 { | 223 { |
| 192 initializeWithDesktopSettings(); | 224 initializeWithDesktopSettings(); |
| 193 webViewImpl()->resize(IntSize(320, 240)); | 225 webViewImpl()->resize(IntSize(320, 240)); |
| 194 | 226 |
| 195 navigateTo("about:blank"); | 227 navigateTo("about:blank"); |
| 196 forceFullCompositingUpdate(); | 228 forceFullCompositingUpdate(); |
| 197 | 229 |
| 198 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); | 230 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); |
| 199 | 231 |
| 200 IntSize webViewSize = webViewImpl()->size(); | 232 IntSize webViewSize = webViewImpl()->size(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 213 pinchViewport.setSize(newViewportSize); | 245 pinchViewport.setSize(newViewportSize); |
| 214 EXPECT_SIZE_EQ(webViewSize, IntSize(webViewImpl()->size())); | 246 EXPECT_SIZE_EQ(webViewSize, IntSize(webViewImpl()->size())); |
| 215 EXPECT_SIZE_EQ(newViewportSize, pinchViewport.size()); | 247 EXPECT_SIZE_EQ(newViewportSize, pinchViewport.size()); |
| 216 } | 248 } |
| 217 | 249 |
| 218 // This tests that shrinking the WebView while the page is fully scrolled | 250 // This tests that shrinking the WebView while the page is fully scrolled |
| 219 // doesn't move the viewport up/left, it should keep the visible viewport | 251 // doesn't move the viewport up/left, it should keep the visible viewport |
| 220 // unchanged from the user's perspective (shrinking the FrameView will clamp | 252 // unchanged from the user's perspective (shrinking the FrameView will clamp |
| 221 // the PinchViewport so we need to counter scroll the FrameView to make it | 253 // the PinchViewport so we need to counter scroll the FrameView to make it |
| 222 // appear to stay still). This caused bugs like crbug.com/453859. | 254 // appear to stay still). This caused bugs like crbug.com/453859. |
| 223 TEST_F(PinchViewportTest, TestResizeAtFullyScrolledPreservesViewportLocation) | 255 TEST_P(ParameterizedPinchViewportTest, TestResizeAtFullyScrolledPreservesViewpor
tLocation) |
| 224 { | 256 { |
| 225 initializeWithDesktopSettings(); | 257 initializeWithDesktopSettings(); |
| 226 webViewImpl()->resize(IntSize(800, 600)); | 258 webViewImpl()->resize(IntSize(800, 600)); |
| 227 | 259 |
| 228 registerMockedHttpURLLoad("content-width-1000.html"); | 260 registerMockedHttpURLLoad("content-width-1000.html"); |
| 229 navigateTo(m_baseURL + "content-width-1000.html"); | 261 navigateTo(m_baseURL + "content-width-1000.html"); |
| 230 | 262 |
| 231 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); | 263 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); |
| 232 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); | 264 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); |
| 233 | 265 |
| 234 pinchViewport.setScale(2); | 266 pinchViewport.setScale(2); |
| 235 | 267 |
| 236 // Fully scroll both viewports. | 268 // Fully scroll both viewports. |
| 237 frameView.setScrollPosition(DoublePoint(10000, 10000), ProgrammaticScroll); | 269 frameView.layoutViewportScrollableArea()->setScrollPosition(DoublePoint(1000
0, 10000), ProgrammaticScroll); |
| 238 pinchViewport.move(FloatSize(10000, 10000)); | 270 pinchViewport.move(FloatSize(10000, 10000)); |
| 239 | 271 |
| 240 // Sanity check. | 272 // Sanity check. |
| 241 ASSERT_POINT_EQ(FloatPoint(400, 300), pinchViewport.location()); | 273 ASSERT_POINT_EQ(FloatPoint(400, 300), pinchViewport.location()); |
| 242 ASSERT_POINT_EQ(DoublePoint(200, 1400), frameView.scrollPositionDouble()); | 274 ASSERT_POINT_EQ(DoublePoint(200, 1400), frameView.layoutViewportScrollableAr
ea()->scrollPositionDouble()); |
| 243 | 275 |
| 244 DoublePoint expectedLocation = frameView.scrollableArea()->visibleContentRec
tDouble().location(); | 276 DoublePoint expectedLocation = frameView.scrollableArea()->visibleContentRec
tDouble().location(); |
| 245 | 277 |
| 246 // Shrink the WebView, this should cause both viewports to shrink and | 278 // Shrink the WebView, this should cause both viewports to shrink and |
| 247 // WebView should do whatever it needs to do to preserve the visible | 279 // WebView should do whatever it needs to do to preserve the visible |
| 248 // location. | 280 // location. |
| 249 webViewImpl()->resize(IntSize(700, 550)); | 281 webViewImpl()->resize(IntSize(700, 550)); |
| 250 | 282 |
| 251 EXPECT_POINT_EQ(expectedLocation, frameView.scrollableArea()->visibleContent
RectDouble().location()); | 283 EXPECT_POINT_EQ(expectedLocation, frameView.scrollableArea()->visibleContent
RectDouble().location()); |
| 252 | 284 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 | 349 |
| 318 // After resizing the scale changes 2.0 -> 4.0 | 350 // After resizing the scale changes 2.0 -> 4.0 |
| 319 EXPECT_FLOAT_SIZE_EQ(FloatSize(50, 25), pinchViewport.visibleRect().size()); | 351 EXPECT_FLOAT_SIZE_EQ(FloatSize(50, 25), pinchViewport.visibleRect().size()); |
| 320 | 352 |
| 321 EXPECT_POINT_EQ(IntPoint(0, 625), frame()->view()->scrollPosition()); | 353 EXPECT_POINT_EQ(IntPoint(0, 625), frame()->view()->scrollPosition()); |
| 322 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 75), pinchViewport.location()); | 354 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 75), pinchViewport.location()); |
| 323 } | 355 } |
| 324 | 356 |
| 325 // Test that the PinchViewport works as expected in case if a scaled | 357 // Test that the PinchViewport works as expected in case if a scaled |
| 326 // and scrolled viewport - scroll right. | 358 // and scrolled viewport - scroll right. |
| 327 TEST_F(PinchViewportTest, TestResizeAfterHorizontalScroll) | 359 TEST_P(ParameterizedPinchViewportTest, TestResizeAfterHorizontalScroll) |
| 328 { | 360 { |
| 329 /* | 361 /* |
| 330 200 200 | 362 200 200 |
| 331 ---------------o----- ---------------o----- | 363 ---------------o----- ---------------o----- |
| 332 | | | | 25| | | 364 | | | | 25| | |
| 333 | | | | -----| | 365 | | | | -----| |
| 334 | 100| | |100 50 | | 366 | 100| | |100 50 | |
| 335 | | | | | | 367 | | | | | |
| 336 | ---- | |-------------------| | 368 | ---- | |-------------------| |
| 337 | | | | | 369 | | | | |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 static void disableAcceleratedCompositing(WebSettings* settings) | 422 static void disableAcceleratedCompositing(WebSettings* settings) |
| 391 { | 423 { |
| 392 PinchViewportTest::configureSettings(settings); | 424 PinchViewportTest::configureSettings(settings); |
| 393 // FIXME: This setting is being removed, so this test needs to be rewritten
to | 425 // FIXME: This setting is being removed, so this test needs to be rewritten
to |
| 394 // do something else. crbug.com/173949 | 426 // do something else. crbug.com/173949 |
| 395 settings->setAcceleratedCompositingEnabled(false); | 427 settings->setAcceleratedCompositingEnabled(false); |
| 396 } | 428 } |
| 397 | 429 |
| 398 // Test that the container layer gets sized properly if the WebView is resized | 430 // Test that the container layer gets sized properly if the WebView is resized |
| 399 // prior to the PinchViewport being attached to the layer tree. | 431 // prior to the PinchViewport being attached to the layer tree. |
| 400 TEST_F(PinchViewportTest, TestWebViewResizedBeforeAttachment) | 432 TEST_P(ParameterizedPinchViewportTest, TestWebViewResizedBeforeAttachment) |
| 401 { | 433 { |
| 402 initializeWithDesktopSettings(disableAcceleratedCompositing); | 434 initializeWithDesktopSettings(disableAcceleratedCompositing); |
| 403 webViewImpl()->resize(IntSize(320, 240)); | 435 webViewImpl()->resize(IntSize(320, 240)); |
| 404 | 436 |
| 405 navigateTo("about:blank"); | 437 navigateTo("about:blank"); |
| 406 forceFullCompositingUpdate(); | 438 forceFullCompositingUpdate(); |
| 407 webViewImpl()->settings()->setAcceleratedCompositingEnabled(true); | 439 webViewImpl()->settings()->setAcceleratedCompositingEnabled(true); |
| 408 webViewImpl()->layout(); | 440 webViewImpl()->layout(); |
| 409 | 441 |
| 410 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); | 442 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); |
| 411 EXPECT_FLOAT_SIZE_EQ(FloatSize(320, 240), pinchViewport.containerLayer()->si
ze()); | 443 EXPECT_FLOAT_SIZE_EQ(FloatSize(320, 240), pinchViewport.containerLayer()->si
ze()); |
| 412 } | 444 } |
| 413 | 445 |
| 414 // Make sure that the visibleRect method acurately reflects the scale and scroll
location | 446 // Make sure that the visibleRect method acurately reflects the scale and scroll
location |
| 415 // of the viewport. | 447 // of the viewport. |
| 416 TEST_F(PinchViewportTest, TestVisibleRect) | 448 TEST_P(ParameterizedPinchViewportTest, TestVisibleRect) |
| 417 { | 449 { |
| 418 initializeWithDesktopSettings(); | 450 initializeWithDesktopSettings(); |
| 419 webViewImpl()->resize(IntSize(320, 240)); | 451 webViewImpl()->resize(IntSize(320, 240)); |
| 420 | 452 |
| 421 navigateTo("about:blank"); | 453 navigateTo("about:blank"); |
| 422 forceFullCompositingUpdate(); | 454 forceFullCompositingUpdate(); |
| 423 | 455 |
| 424 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); | 456 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); |
| 425 | 457 |
| 426 // Initial visible rect should be the whole frame. | 458 // Initial visible rect should be the whole frame. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 pinchViewport.setScale(2); | 510 pinchViewport.setScale(2); |
| 479 pinchViewport.setLocation(FloatPoint(10, 15)); | 511 pinchViewport.setLocation(FloatPoint(10, 15)); |
| 480 EXPECT_FLOAT_RECT_EQ(FloatRect(10, 15, 50, 200), pinchViewport.visibleRectIn
Document()); | 512 EXPECT_FLOAT_RECT_EQ(FloatRect(10, 15, 50, 200), pinchViewport.visibleRectIn
Document()); |
| 481 | 513 |
| 482 // Scroll the layout viewport. Ensure its offset is reflected in visibleRect
InDocument(). | 514 // Scroll the layout viewport. Ensure its offset is reflected in visibleRect
InDocument(). |
| 483 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); | 515 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); |
| 484 frameView.setScrollPosition(DoublePoint(40, 100), ProgrammaticScroll); | 516 frameView.setScrollPosition(DoublePoint(40, 100), ProgrammaticScroll); |
| 485 EXPECT_FLOAT_RECT_EQ(FloatRect(50, 115, 50, 200), pinchViewport.visibleRectI
nDocument()); | 517 EXPECT_FLOAT_RECT_EQ(FloatRect(50, 115, 50, 200), pinchViewport.visibleRectI
nDocument()); |
| 486 } | 518 } |
| 487 | 519 |
| 488 TEST_F(PinchViewportTest, TestFractionalScrollOffsetIsNotOverwritten) | 520 TEST_P(ParameterizedPinchViewportTest, TestFractionalScrollOffsetIsNotOverwritte
n) |
| 489 { | 521 { |
| 490 initializeWithAndroidSettings(); | 522 initializeWithAndroidSettings(); |
| 491 webViewImpl()->resize(IntSize(200, 250)); | 523 webViewImpl()->resize(IntSize(200, 250)); |
| 492 | 524 |
| 493 registerMockedHttpURLLoad("200-by-800-viewport.html"); | 525 registerMockedHttpURLLoad("200-by-800-viewport.html"); |
| 494 navigateTo(m_baseURL + "200-by-800-viewport.html"); | 526 navigateTo(m_baseURL + "200-by-800-viewport.html"); |
| 495 | 527 |
| 496 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); | 528 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); |
| 497 frameView.scrollTo(DoublePoint(0, 10.5)); | 529 frameView.layoutViewportScrollableArea()->setScrollPosition(DoublePoint(0, 1
0.5), ProgrammaticScroll); |
| 498 webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSize(10, 20), Web
FloatSize(), 1, 0); | 530 webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSize(10, 20), Web
FloatSize(), 1, 0); |
| 499 | 531 |
| 500 EXPECT_EQ(30.5, frameView.scrollPositionDouble().y()); | 532 EXPECT_EQ(30.5, frameView.layoutViewportScrollableArea()->scrollPositionDoub
le().y()); |
| 501 } | 533 } |
| 502 | 534 |
| 503 // Test that the viewport's scroll offset is always appropriately bounded such t
hat the | 535 // Test that the viewport's scroll offset is always appropriately bounded such t
hat the |
| 504 // pinch viewport always stays within the bounds of the main frame. | 536 // pinch viewport always stays within the bounds of the main frame. |
| 505 TEST_F(PinchViewportTest, TestOffsetClamping) | 537 TEST_P(ParameterizedPinchViewportTest, TestOffsetClamping) |
| 506 { | 538 { |
| 507 initializeWithDesktopSettings(); | 539 initializeWithDesktopSettings(); |
| 508 webViewImpl()->resize(IntSize(320, 240)); | 540 webViewImpl()->resize(IntSize(320, 240)); |
| 509 | 541 |
| 510 navigateTo("about:blank"); | 542 navigateTo("about:blank"); |
| 511 forceFullCompositingUpdate(); | 543 forceFullCompositingUpdate(); |
| 512 | 544 |
| 513 // Pinch viewport should be initialized to same size as frame so no scrollin
g possible. | 545 // Pinch viewport should be initialized to same size as frame so no scrollin
g possible. |
| 514 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); | 546 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); |
| 515 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), pinchViewport.visibleRect().location
()); | 547 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), pinchViewport.visibleRect().location
()); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 540 pinchViewport.setScale(1.25); | 572 pinchViewport.setScale(1.25); |
| 541 EXPECT_FLOAT_POINT_EQ(FloatPoint(64, 48), pinchViewport.visibleRect().locati
on()); | 573 EXPECT_FLOAT_POINT_EQ(FloatPoint(64, 48), pinchViewport.visibleRect().locati
on()); |
| 542 | 574 |
| 543 // Scale out smaller than 1. | 575 // Scale out smaller than 1. |
| 544 pinchViewport.setScale(0.25); | 576 pinchViewport.setScale(0.25); |
| 545 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), pinchViewport.visibleRect().location
()); | 577 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), pinchViewport.visibleRect().location
()); |
| 546 } | 578 } |
| 547 | 579 |
| 548 // Test that the viewport can be scrolled around only within the main frame in t
he presence | 580 // Test that the viewport can be scrolled around only within the main frame in t
he presence |
| 549 // of viewport resizes, as would be the case if the on screen keyboard came up. | 581 // of viewport resizes, as would be the case if the on screen keyboard came up. |
| 550 TEST_F(PinchViewportTest, TestOffsetClampingWithResize) | 582 TEST_P(ParameterizedPinchViewportTest, TestOffsetClampingWithResize) |
| 551 { | 583 { |
| 552 initializeWithDesktopSettings(); | 584 initializeWithDesktopSettings(); |
| 553 webViewImpl()->resize(IntSize(320, 240)); | 585 webViewImpl()->resize(IntSize(320, 240)); |
| 554 | 586 |
| 555 navigateTo("about:blank"); | 587 navigateTo("about:blank"); |
| 556 forceFullCompositingUpdate(); | 588 forceFullCompositingUpdate(); |
| 557 | 589 |
| 558 // Pinch viewport should be initialized to same size as frame so no scrollin
g possible. | 590 // Pinch viewport should be initialized to same size as frame so no scrollin
g possible. |
| 559 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); | 591 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); |
| 560 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), pinchViewport.visibleRect().location
()); | 592 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), pinchViewport.visibleRect().location
()); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 pinchViewport.setLocation(FloatPoint(100, 100)); | 624 pinchViewport.setLocation(FloatPoint(100, 100)); |
| 593 EXPECT_FLOAT_POINT_EQ(FloatPoint(40, 40), pinchViewport.visibleRect().locati
on()); | 625 EXPECT_FLOAT_POINT_EQ(FloatPoint(40, 40), pinchViewport.visibleRect().locati
on()); |
| 594 pinchViewport.setLocation(FloatPoint(10, 3)); | 626 pinchViewport.setLocation(FloatPoint(10, 3)); |
| 595 EXPECT_FLOAT_POINT_EQ(FloatPoint(10, 3), pinchViewport.visibleRect().locatio
n()); | 627 EXPECT_FLOAT_POINT_EQ(FloatPoint(10, 3), pinchViewport.visibleRect().locatio
n()); |
| 596 pinchViewport.setLocation(FloatPoint(-10, -4)); | 628 pinchViewport.setLocation(FloatPoint(-10, -4)); |
| 597 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), pinchViewport.visibleRect().location
()); | 629 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), pinchViewport.visibleRect().location
()); |
| 598 } | 630 } |
| 599 | 631 |
| 600 // Test that the viewport is scrollable but bounded appropriately within the mai
n frame | 632 // Test that the viewport is scrollable but bounded appropriately within the mai
n frame |
| 601 // when we apply both scaling and resizes. | 633 // when we apply both scaling and resizes. |
| 602 TEST_F(PinchViewportTest, TestOffsetClampingWithResizeAndScale) | 634 TEST_P(ParameterizedPinchViewportTest, TestOffsetClampingWithResizeAndScale) |
| 603 { | 635 { |
| 604 initializeWithDesktopSettings(); | 636 initializeWithDesktopSettings(); |
| 605 webViewImpl()->resize(IntSize(320, 240)); | 637 webViewImpl()->resize(IntSize(320, 240)); |
| 606 | 638 |
| 607 navigateTo("about:blank"); | 639 navigateTo("about:blank"); |
| 608 forceFullCompositingUpdate(); | 640 forceFullCompositingUpdate(); |
| 609 | 641 |
| 610 // Pinch viewport should be initialized to same size as WebView so no scroll
ing possible. | 642 // Pinch viewport should be initialized to same size as WebView so no scroll
ing possible. |
| 611 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); | 643 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); |
| 612 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), pinchViewport.visibleRect().location
()); | 644 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), pinchViewport.visibleRect().location
()); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 638 // Make sure resizing the viewport doesn't change its offset if the resize d
oesn't make | 670 // Make sure resizing the viewport doesn't change its offset if the resize d
oesn't make |
| 639 // the viewport go out of bounds. | 671 // the viewport go out of bounds. |
| 640 pinchViewport.setLocation(FloatPoint(200, 200)); | 672 pinchViewport.setLocation(FloatPoint(200, 200)); |
| 641 pinchViewport.setSize(IntSize(880, 560)); | 673 pinchViewport.setSize(IntSize(880, 560)); |
| 642 EXPECT_FLOAT_POINT_EQ(FloatPoint(200, 200), pinchViewport.visibleRect().loca
tion()); | 674 EXPECT_FLOAT_POINT_EQ(FloatPoint(200, 200), pinchViewport.visibleRect().loca
tion()); |
| 643 } | 675 } |
| 644 | 676 |
| 645 // The main FrameView's size should be set such that its the size of the pinch v
iewport | 677 // The main FrameView's size should be set such that its the size of the pinch v
iewport |
| 646 // at minimum scale. If there's no explicit minimum scale set, the FrameView sho
uld be | 678 // at minimum scale. If there's no explicit minimum scale set, the FrameView sho
uld be |
| 647 // set to the content width and height derived by the aspect ratio. | 679 // set to the content width and height derived by the aspect ratio. |
| 648 TEST_F(PinchViewportTest, TestFrameViewSizedToContent) | 680 TEST_P(ParameterizedPinchViewportTest, TestFrameViewSizedToContent) |
| 649 { | 681 { |
| 650 initializeWithAndroidSettings(); | 682 initializeWithAndroidSettings(); |
| 651 webViewImpl()->resize(IntSize(320, 240)); | 683 webViewImpl()->resize(IntSize(320, 240)); |
| 652 | 684 |
| 653 registerMockedHttpURLLoad("200-by-300-viewport.html"); | 685 registerMockedHttpURLLoad("200-by-300-viewport.html"); |
| 654 navigateTo(m_baseURL + "200-by-300-viewport.html"); | 686 navigateTo(m_baseURL + "200-by-300-viewport.html"); |
| 655 | 687 |
| 656 webViewImpl()->resize(IntSize(600, 800)); | 688 webViewImpl()->resize(IntSize(600, 800)); |
| 657 webViewImpl()->layout(); | 689 webViewImpl()->layout(); |
| 658 | 690 |
| 659 // Note: the size is ceiled and should match the behavior in CC's LayerImpl:
:bounds(). | 691 // Note: the size is ceiled and should match the behavior in CC's LayerImpl:
:bounds(). |
| 660 EXPECT_SIZE_EQ(IntSize(200, 267), | 692 EXPECT_SIZE_EQ(IntSize(200, 267), |
| 661 webViewImpl()->mainFrameImpl()->frameView()->frameRect().size()); | 693 webViewImpl()->mainFrameImpl()->frameView()->frameRect().size()); |
| 662 } | 694 } |
| 663 | 695 |
| 664 // The main FrameView's size should be set such that its the size of the pinch v
iewport | 696 // The main FrameView's size should be set such that its the size of the pinch v
iewport |
| 665 // at minimum scale. On Desktop, the minimum scale is set at 1 so make sure the
FrameView | 697 // at minimum scale. On Desktop, the minimum scale is set at 1 so make sure the
FrameView |
| 666 // is sized to the viewport. | 698 // is sized to the viewport. |
| 667 TEST_F(PinchViewportTest, TestFrameViewSizedToMinimumScale) | 699 TEST_P(ParameterizedPinchViewportTest, TestFrameViewSizedToMinimumScale) |
| 668 { | 700 { |
| 669 initializeWithDesktopSettings(); | 701 initializeWithDesktopSettings(); |
| 670 webViewImpl()->resize(IntSize(320, 240)); | 702 webViewImpl()->resize(IntSize(320, 240)); |
| 671 | 703 |
| 672 registerMockedHttpURLLoad("200-by-300.html"); | 704 registerMockedHttpURLLoad("200-by-300.html"); |
| 673 navigateTo(m_baseURL + "200-by-300.html"); | 705 navigateTo(m_baseURL + "200-by-300.html"); |
| 674 | 706 |
| 675 webViewImpl()->resize(IntSize(100, 160)); | 707 webViewImpl()->resize(IntSize(100, 160)); |
| 676 webViewImpl()->layout(); | 708 webViewImpl()->layout(); |
| 677 | 709 |
| 678 EXPECT_SIZE_EQ(IntSize(100, 160), | 710 EXPECT_SIZE_EQ(IntSize(100, 160), |
| 679 webViewImpl()->mainFrameImpl()->frameView()->frameRect().size()); | 711 webViewImpl()->mainFrameImpl()->frameView()->frameRect().size()); |
| 680 } | 712 } |
| 681 | 713 |
| 682 // Test that attaching a new frame view resets the size of the inner viewport sc
roll | 714 // Test that attaching a new frame view resets the size of the inner viewport sc
roll |
| 683 // layer. crbug.com/423189. | 715 // layer. crbug.com/423189. |
| 684 TEST_F(PinchViewportTest, TestAttachingNewFrameSetsInnerScrollLayerSize) | 716 TEST_P(ParameterizedPinchViewportTest, TestAttachingNewFrameSetsInnerScrollLayer
Size) |
| 685 { | 717 { |
| 686 initializeWithAndroidSettings(); | 718 initializeWithAndroidSettings(); |
| 687 webViewImpl()->resize(IntSize(320, 240)); | 719 webViewImpl()->resize(IntSize(320, 240)); |
| 688 | 720 |
| 689 // Load a wider page first, the navigation should resize the scroll layer to | 721 // Load a wider page first, the navigation should resize the scroll layer to |
| 690 // the smaller size on the second navigation. | 722 // the smaller size on the second navigation. |
| 691 registerMockedHttpURLLoad("content-width-1000.html"); | 723 registerMockedHttpURLLoad("content-width-1000.html"); |
| 692 navigateTo(m_baseURL + "content-width-1000.html"); | 724 navigateTo(m_baseURL + "content-width-1000.html"); |
| 693 webViewImpl()->layout(); | 725 webViewImpl()->layout(); |
| 694 | 726 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 708 EXPECT_SIZE_EQ(FloatSize(320, 240), pinchViewport.scrollLayer()->size()); | 740 EXPECT_SIZE_EQ(FloatSize(320, 240), pinchViewport.scrollLayer()->size()); |
| 709 | 741 |
| 710 // Ensure the location and scale were reset. | 742 // Ensure the location and scale were reset. |
| 711 EXPECT_POINT_EQ(FloatPoint(), pinchViewport.location()); | 743 EXPECT_POINT_EQ(FloatPoint(), pinchViewport.location()); |
| 712 EXPECT_EQ(1, pinchViewport.scale()); | 744 EXPECT_EQ(1, pinchViewport.scale()); |
| 713 } | 745 } |
| 714 | 746 |
| 715 // The main FrameView's size should be set such that its the size of the pinch v
iewport | 747 // The main FrameView's size should be set such that its the size of the pinch v
iewport |
| 716 // at minimum scale. Test that the FrameView is appropriately sized in the prese
nce | 748 // at minimum scale. Test that the FrameView is appropriately sized in the prese
nce |
| 717 // of a viewport <meta> tag. | 749 // of a viewport <meta> tag. |
| 718 TEST_F(PinchViewportTest, TestFrameViewSizedToViewportMetaMinimumScale) | 750 TEST_P(ParameterizedPinchViewportTest, TestFrameViewSizedToViewportMetaMinimumSc
ale) |
| 719 { | 751 { |
| 720 initializeWithAndroidSettings(); | 752 initializeWithAndroidSettings(); |
| 721 webViewImpl()->resize(IntSize(320, 240)); | 753 webViewImpl()->resize(IntSize(320, 240)); |
| 722 | 754 |
| 723 registerMockedHttpURLLoad("200-by-300-min-scale-2.html"); | 755 registerMockedHttpURLLoad("200-by-300-min-scale-2.html"); |
| 724 navigateTo(m_baseURL + "200-by-300-min-scale-2.html"); | 756 navigateTo(m_baseURL + "200-by-300-min-scale-2.html"); |
| 725 | 757 |
| 726 webViewImpl()->resize(IntSize(100, 160)); | 758 webViewImpl()->resize(IntSize(100, 160)); |
| 727 webViewImpl()->layout(); | 759 webViewImpl()->layout(); |
| 728 | 760 |
| 729 EXPECT_SIZE_EQ(IntSize(50, 80), | 761 EXPECT_SIZE_EQ(IntSize(50, 80), |
| 730 webViewImpl()->mainFrameImpl()->frameView()->frameRect().size()); | 762 webViewImpl()->mainFrameImpl()->frameView()->frameRect().size()); |
| 731 } | 763 } |
| 732 | 764 |
| 733 // Test that the pinch viewport still gets sized in AutoSize/AutoResize mode. | 765 // Test that the pinch viewport still gets sized in AutoSize/AutoResize mode. |
| 734 TEST_F(PinchViewportTest, TestPinchViewportGetsSizeInAutoSizeMode) | 766 TEST_P(ParameterizedPinchViewportTest, TestPinchViewportGetsSizeInAutoSizeMode) |
| 735 { | 767 { |
| 736 initializeWithDesktopSettings(); | 768 initializeWithDesktopSettings(); |
| 737 | 769 |
| 738 EXPECT_SIZE_EQ(IntSize(0, 0), IntSize(webViewImpl()->size())); | 770 EXPECT_SIZE_EQ(IntSize(0, 0), IntSize(webViewImpl()->size())); |
| 739 EXPECT_SIZE_EQ(IntSize(0, 0), frame()->page()->frameHost().pinchViewport().s
ize()); | 771 EXPECT_SIZE_EQ(IntSize(0, 0), frame()->page()->frameHost().pinchViewport().s
ize()); |
| 740 | 772 |
| 741 webViewImpl()->enableAutoResizeMode(WebSize(10, 10), WebSize(1000, 1000)); | 773 webViewImpl()->enableAutoResizeMode(WebSize(10, 10), WebSize(1000, 1000)); |
| 742 | 774 |
| 743 registerMockedHttpURLLoad("200-by-300.html"); | 775 registerMockedHttpURLLoad("200-by-300.html"); |
| 744 navigateTo(m_baseURL + "200-by-300.html"); | 776 navigateTo(m_baseURL + "200-by-300.html"); |
| 745 | 777 |
| 746 EXPECT_SIZE_EQ(IntSize(200, 300), frame()->page()->frameHost().pinchViewport
().size()); | 778 EXPECT_SIZE_EQ(IntSize(200, 300), frame()->page()->frameHost().pinchViewport
().size()); |
| 747 } | 779 } |
| 748 | 780 |
| 749 // Test that the text selection handle's position accounts for the pinch viewpor
t. | 781 // Test that the text selection handle's position accounts for the pinch viewpor
t. |
| 750 TEST_F(PinchViewportTest, TestTextSelectionHandles) | 782 TEST_P(ParameterizedPinchViewportTest, TestTextSelectionHandles) |
| 751 { | 783 { |
| 752 initializeWithDesktopSettings(); | 784 initializeWithDesktopSettings(); |
| 753 webViewImpl()->resize(IntSize(500, 800)); | 785 webViewImpl()->resize(IntSize(500, 800)); |
| 754 | 786 |
| 755 registerMockedHttpURLLoad("pinch-viewport-input-field.html"); | 787 registerMockedHttpURLLoad("pinch-viewport-input-field.html"); |
| 756 navigateTo(m_baseURL + "pinch-viewport-input-field.html"); | 788 navigateTo(m_baseURL + "pinch-viewport-input-field.html"); |
| 757 | 789 |
| 758 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); | 790 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); |
| 759 webViewImpl()->setInitialFocus(false); | 791 webViewImpl()->setInitialFocus(false); |
| 760 | 792 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 774 expected.scale(pinchViewport.scale(), pinchViewport.scale()); | 806 expected.scale(pinchViewport.scale(), pinchViewport.scale()); |
| 775 | 807 |
| 776 EXPECT_POINT_EQ(expected, IntRect(anchor).location()); | 808 EXPECT_POINT_EQ(expected, IntRect(anchor).location()); |
| 777 EXPECT_POINT_EQ(expected, IntRect(focus).location()); | 809 EXPECT_POINT_EQ(expected, IntRect(focus).location()); |
| 778 | 810 |
| 779 // FIXME(bokan) - http://crbug.com/364154 - Figure out how to test text sele
ction | 811 // FIXME(bokan) - http://crbug.com/364154 - Figure out how to test text sele
ction |
| 780 // as well rather than just carret. | 812 // as well rather than just carret. |
| 781 } | 813 } |
| 782 | 814 |
| 783 // Test that the HistoryItem for the page stores the pinch viewport's offset and
scale. | 815 // Test that the HistoryItem for the page stores the pinch viewport's offset and
scale. |
| 784 TEST_F(PinchViewportTest, TestSavedToHistoryItem) | 816 TEST_P(ParameterizedPinchViewportTest, TestSavedToHistoryItem) |
| 785 { | 817 { |
| 786 initializeWithDesktopSettings(); | 818 initializeWithDesktopSettings(); |
| 787 webViewImpl()->resize(IntSize(200, 300)); | 819 webViewImpl()->resize(IntSize(200, 300)); |
| 788 webViewImpl()->layout(); | 820 webViewImpl()->layout(); |
| 789 | 821 |
| 790 registerMockedHttpURLLoad("200-by-300.html"); | 822 registerMockedHttpURLLoad("200-by-300.html"); |
| 791 navigateTo(m_baseURL + "200-by-300.html"); | 823 navigateTo(m_baseURL + "200-by-300.html"); |
| 792 | 824 |
| 793 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), | 825 EXPECT_FLOAT_POINT_EQ(FloatPoint(0, 0), |
| 794 toLocalFrame(webViewImpl()->page()->mainFrame())->loader().currentItem()
->pinchViewportScrollPoint()); | 826 toLocalFrame(webViewImpl()->page()->mainFrame())->loader().currentItem()
->pinchViewportScrollPoint()); |
| 795 | 827 |
| 796 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); | 828 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); |
| 797 pinchViewport.setScale(2); | 829 pinchViewport.setScale(2); |
| 798 | 830 |
| 799 EXPECT_EQ(2, toLocalFrame(webViewImpl()->page()->mainFrame())->loader().curr
entItem()->pageScaleFactor()); | 831 EXPECT_EQ(2, toLocalFrame(webViewImpl()->page()->mainFrame())->loader().curr
entItem()->pageScaleFactor()); |
| 800 | 832 |
| 801 pinchViewport.setLocation(FloatPoint(10, 20)); | 833 pinchViewport.setLocation(FloatPoint(10, 20)); |
| 802 | 834 |
| 803 EXPECT_FLOAT_POINT_EQ(FloatPoint(10, 20), | 835 EXPECT_FLOAT_POINT_EQ(FloatPoint(10, 20), |
| 804 toLocalFrame(webViewImpl()->page()->mainFrame())->loader().currentItem()
->pinchViewportScrollPoint()); | 836 toLocalFrame(webViewImpl()->page()->mainFrame())->loader().currentItem()
->pinchViewportScrollPoint()); |
| 805 } | 837 } |
| 806 | 838 |
| 807 // Test restoring a HistoryItem properly restores the pinch viewport's state. | 839 // Test restoring a HistoryItem properly restores the pinch viewport's state. |
| 808 TEST_F(PinchViewportTest, TestRestoredFromHistoryItem) | 840 TEST_P(ParameterizedPinchViewportTest, TestRestoredFromHistoryItem) |
| 809 { | 841 { |
| 810 initializeWithDesktopSettings(); | 842 initializeWithDesktopSettings(); |
| 811 webViewImpl()->resize(IntSize(200, 300)); | 843 webViewImpl()->resize(IntSize(200, 300)); |
| 812 | 844 |
| 813 registerMockedHttpURLLoad("200-by-300.html"); | 845 registerMockedHttpURLLoad("200-by-300.html"); |
| 814 | 846 |
| 815 WebHistoryItem item; | 847 WebHistoryItem item; |
| 816 item.initialize(); | 848 item.initialize(); |
| 817 WebURL destinationURL(URLTestHelpers::toKURL(m_baseURL + "200-by-300.html"))
; | 849 WebURL destinationURL(URLTestHelpers::toKURL(m_baseURL + "200-by-300.html"))
; |
| 818 item.setURLString(destinationURL.string()); | 850 item.setURLString(destinationURL.string()); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 TEST_F(PinchViewportTest, TestNavigateToSmallerFrameViewHistoryItemClobberBug) | 891 TEST_F(PinchViewportTest, TestNavigateToSmallerFrameViewHistoryItemClobberBug) |
| 860 { | 892 { |
| 861 initializeWithAndroidSettings(); | 893 initializeWithAndroidSettings(); |
| 862 webViewImpl()->resize(IntSize(400, 400)); | 894 webViewImpl()->resize(IntSize(400, 400)); |
| 863 webViewImpl()->layout(); | 895 webViewImpl()->layout(); |
| 864 | 896 |
| 865 registerMockedHttpURLLoad("content-width-1000.html"); | 897 registerMockedHttpURLLoad("content-width-1000.html"); |
| 866 navigateTo(m_baseURL + "content-width-1000.html"); | 898 navigateTo(m_baseURL + "content-width-1000.html"); |
| 867 | 899 |
| 868 FrameView* frameView = webViewImpl()->mainFrameImpl()->frameView(); | 900 FrameView* frameView = webViewImpl()->mainFrameImpl()->frameView(); |
| 869 frameView->setScrollPosition(IntPoint(0, 1000), ProgrammaticScroll); | 901 frameView->layoutViewportScrollableArea()->setScrollPosition(IntPoint(0, 100
0), ProgrammaticScroll); |
| 870 | 902 |
| 871 EXPECT_SIZE_EQ(IntSize(1000, 1000), frameView->frameRect().size()); | 903 EXPECT_SIZE_EQ(IntSize(1000, 1000), frameView->frameRect().size()); |
| 872 | 904 |
| 873 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); | 905 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); |
| 874 pinchViewport.setScale(2); | 906 pinchViewport.setScale(2); |
| 875 pinchViewport.setLocation(FloatPoint(350, 350)); | 907 pinchViewport.setLocation(FloatPoint(350, 350)); |
| 876 | 908 |
| 877 RefPtrWillBePersistent<HistoryItem> firstItem = webViewImpl()->mainFrameImpl
()->frame()->loader().currentItem(); | 909 RefPtrWillBePersistent<HistoryItem> firstItem = webViewImpl()->mainFrameImpl
()->frame()->loader().currentItem(); |
| 878 EXPECT_POINT_EQ(IntPoint(0, 1000), firstItem->scrollPoint()); | 910 EXPECT_POINT_EQ(IntPoint(0, 1000), firstItem->scrollPoint()); |
| 879 | 911 |
| 880 // Now navigate to a page which causes a smaller frameView. Make sure that | 912 // Now navigate to a page which causes a smaller frameView. Make sure that |
| 881 // navigating doesn't cause the history item to set a new scroll offset | 913 // navigating doesn't cause the history item to set a new scroll offset |
| 882 // before the item was replaced. | 914 // before the item was replaced. |
| 883 navigateTo("about:blank"); | 915 navigateTo("about:blank"); |
| 884 frameView = webViewImpl()->mainFrameImpl()->frameView(); | 916 frameView = webViewImpl()->mainFrameImpl()->frameView(); |
| 885 | 917 |
| 886 EXPECT_NE(firstItem, webViewImpl()->mainFrameImpl()->frame()->loader().curre
ntItem()); | 918 EXPECT_NE(firstItem, webViewImpl()->mainFrameImpl()->frame()->loader().curre
ntItem()); |
| 887 EXPECT_LT(frameView->frameRect().size().width(), 1000); | 919 EXPECT_LT(frameView->frameRect().size().width(), 1000); |
| 888 EXPECT_POINT_EQ(IntPoint(0, 1000), firstItem->scrollPoint()); | 920 EXPECT_POINT_EQ(IntPoint(0, 1000), firstItem->scrollPoint()); |
| 889 } | 921 } |
| 890 | 922 |
| 891 // Test that the coordinates sent into moveRangeSelection are offset by the | 923 // Test that the coordinates sent into moveRangeSelection are offset by the |
| 892 // pinch viewport's location. | 924 // pinch viewport's location. |
| 893 TEST_F(PinchViewportTest, DISABLED_TestWebFrameRangeAccountsForPinchViewportScro
ll) | 925 TEST_P(ParameterizedPinchViewportTest, DISABLED_TestWebFrameRangeAccountsForPinc
hViewportScroll) |
| 894 { | 926 { |
| 895 initializeWithDesktopSettings(); | 927 initializeWithDesktopSettings(); |
| 896 webViewImpl()->settings()->setDefaultFontSize(12); | 928 webViewImpl()->settings()->setDefaultFontSize(12); |
| 897 webViewImpl()->resize(WebSize(640, 480)); | 929 webViewImpl()->resize(WebSize(640, 480)); |
| 898 registerMockedHttpURLLoad("move_range.html"); | 930 registerMockedHttpURLLoad("move_range.html"); |
| 899 navigateTo(m_baseURL + "move_range.html"); | 931 navigateTo(m_baseURL + "move_range.html"); |
| 900 | 932 |
| 901 WebRect baseRect; | 933 WebRect baseRect; |
| 902 WebRect extentRect; | 934 WebRect extentRect; |
| 903 | 935 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 917 // Move the pinch viewport over and make the selection in the same | 949 // Move the pinch viewport over and make the selection in the same |
| 918 // screen-space location. The selection should change to two characters to | 950 // screen-space location. The selection should change to two characters to |
| 919 // the right and down one line. | 951 // the right and down one line. |
| 920 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); | 952 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); |
| 921 pinchViewport.move(FloatPoint(60, 25)); | 953 pinchViewport.move(FloatPoint(60, 25)); |
| 922 mainFrame->moveRangeSelection(initialPoint, endPoint); | 954 mainFrame->moveRangeSelection(initialPoint, endPoint); |
| 923 EXPECT_EQ("t ", mainFrame->selectionAsText().utf8()); | 955 EXPECT_EQ("t ", mainFrame->selectionAsText().utf8()); |
| 924 } | 956 } |
| 925 | 957 |
| 926 // Test that the scrollFocusedNodeIntoRect method works with the pinch viewport. | 958 // Test that the scrollFocusedNodeIntoRect method works with the pinch viewport. |
| 927 TEST_F(PinchViewportTest, DISABLED_TestScrollFocusedNodeIntoRect) | 959 TEST_P(ParameterizedPinchViewportTest, DISABLED_TestScrollFocusedNodeIntoRect) |
| 928 { | 960 { |
| 929 initializeWithDesktopSettings(); | 961 initializeWithDesktopSettings(); |
| 930 webViewImpl()->resize(IntSize(500, 300)); | 962 webViewImpl()->resize(IntSize(500, 300)); |
| 931 | 963 |
| 932 registerMockedHttpURLLoad("pinch-viewport-input-field.html"); | 964 registerMockedHttpURLLoad("pinch-viewport-input-field.html"); |
| 933 navigateTo(m_baseURL + "pinch-viewport-input-field.html"); | 965 navigateTo(m_baseURL + "pinch-viewport-input-field.html"); |
| 934 | 966 |
| 935 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); | 967 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); |
| 936 webViewImpl()->resizePinchViewport(IntSize(200, 100)); | 968 webViewImpl()->resizePinchViewport(IntSize(200, 100)); |
| 937 webViewImpl()->setInitialFocus(false); | 969 webViewImpl()->setInitialFocus(false); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 962 webViewImpl()->resizePinchViewport(IntSize(500, 300)); | 994 webViewImpl()->resizePinchViewport(IntSize(500, 300)); |
| 963 pinchViewport.setLocation(FloatPoint(30, 50)); | 995 pinchViewport.setLocation(FloatPoint(30, 50)); |
| 964 | 996 |
| 965 webViewImpl()->setPageScaleFactor(2); | 997 webViewImpl()->setPageScaleFactor(2); |
| 966 webViewImpl()->scrollFocusedNodeIntoRect(IntRect(0, 0, 500, 200)); | 998 webViewImpl()->scrollFocusedNodeIntoRect(IntRect(0, 0, 500, 200)); |
| 967 EXPECT_POINT_EQ(IntPoint(200-30-75, 600-50-65), frame()->view()->scrollPosit
ion()); | 999 EXPECT_POINT_EQ(IntPoint(200-30-75, 600-50-65), frame()->view()->scrollPosit
ion()); |
| 968 EXPECT_FLOAT_POINT_EQ(FloatPoint(30, 50), pinchViewport.visibleRect().locati
on()); | 1000 EXPECT_FLOAT_POINT_EQ(FloatPoint(30, 50), pinchViewport.visibleRect().locati
on()); |
| 969 } | 1001 } |
| 970 | 1002 |
| 971 // Test that resizing the WebView causes ViewportConstrained objects to relayout
. | 1003 // Test that resizing the WebView causes ViewportConstrained objects to relayout
. |
| 972 TEST_F(PinchViewportTest, TestWebViewResizeCausesViewportConstrainedLayout) | 1004 TEST_P(ParameterizedPinchViewportTest, TestWebViewResizeCausesViewportConstraine
dLayout) |
| 973 { | 1005 { |
| 974 initializeWithDesktopSettings(); | 1006 initializeWithDesktopSettings(); |
| 975 webViewImpl()->resize(IntSize(500, 300)); | 1007 webViewImpl()->resize(IntSize(500, 300)); |
| 976 | 1008 |
| 977 registerMockedHttpURLLoad("pinch-viewport-fixed-pos.html"); | 1009 registerMockedHttpURLLoad("pinch-viewport-fixed-pos.html"); |
| 978 navigateTo(m_baseURL + "pinch-viewport-fixed-pos.html"); | 1010 navigateTo(m_baseURL + "pinch-viewport-fixed-pos.html"); |
| 979 | 1011 |
| 980 LayoutObject* navbar = frame()->document()->getElementById("navbar")->layout
Object(); | 1012 LayoutObject* navbar = frame()->document()->getElementById("navbar")->layout
Object(); |
| 981 | 1013 |
| 982 EXPECT_FALSE(navbar->needsLayout()); | 1014 EXPECT_FALSE(navbar->needsLayout()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 995 MATCHER_P2(ContextMenuAtLocation, x, y, | 1027 MATCHER_P2(ContextMenuAtLocation, x, y, |
| 996 std::string(negation ? "is" : "isn't") | 1028 std::string(negation ? "is" : "isn't") |
| 997 + " at expected location [" | 1029 + " at expected location [" |
| 998 + PrintToString(x) + ", " + PrintToString(y) + "]") | 1030 + PrintToString(x) + ", " + PrintToString(y) + "]") |
| 999 { | 1031 { |
| 1000 return arg.mousePosition.x == x && arg.mousePosition.y == y; | 1032 return arg.mousePosition.x == x && arg.mousePosition.y == y; |
| 1001 } | 1033 } |
| 1002 | 1034 |
| 1003 // Test that the context menu's location is correct in the presence of pinch | 1035 // Test that the context menu's location is correct in the presence of pinch |
| 1004 // viewport offset. | 1036 // viewport offset. |
| 1005 TEST_F(PinchViewportTest, TestContextMenuShownInCorrectLocation) | 1037 TEST_P(ParameterizedPinchViewportTest, TestContextMenuShownInCorrectLocation) |
| 1006 { | 1038 { |
| 1007 initializeWithDesktopSettings(); | 1039 initializeWithDesktopSettings(); |
| 1008 webViewImpl()->resize(IntSize(200, 300)); | 1040 webViewImpl()->resize(IntSize(200, 300)); |
| 1009 | 1041 |
| 1010 registerMockedHttpURLLoad("200-by-300.html"); | 1042 registerMockedHttpURLLoad("200-by-300.html"); |
| 1011 navigateTo(m_baseURL + "200-by-300.html"); | 1043 navigateTo(m_baseURL + "200-by-300.html"); |
| 1012 | 1044 |
| 1013 WebMouseEvent mouseDownEvent; | 1045 WebMouseEvent mouseDownEvent; |
| 1014 mouseDownEvent.type = WebInputEvent::MouseDown; | 1046 mouseDownEvent.type = WebInputEvent::MouseDown; |
| 1015 mouseDownEvent.x = 10; | 1047 mouseDownEvent.x = 10; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1048 | 1080 |
| 1049 mouseDownEvent.button = WebMouseEvent::ButtonRight; | 1081 mouseDownEvent.button = WebMouseEvent::ButtonRight; |
| 1050 webViewImpl()->handleInputEvent(mouseDownEvent); | 1082 webViewImpl()->handleInputEvent(mouseDownEvent); |
| 1051 webViewImpl()->handleInputEvent(mouseUpEvent); | 1083 webViewImpl()->handleInputEvent(mouseUpEvent); |
| 1052 | 1084 |
| 1053 // Reset the old client so destruction can occur naturally. | 1085 // Reset the old client so destruction can occur naturally. |
| 1054 webViewImpl()->mainFrameImpl()->setClient(oldClient); | 1086 webViewImpl()->mainFrameImpl()->setClient(oldClient); |
| 1055 } | 1087 } |
| 1056 | 1088 |
| 1057 // Test that the client is notified if page scroll events. | 1089 // Test that the client is notified if page scroll events. |
| 1058 TEST_F(PinchViewportTest, TestClientNotifiedOfScrollEvents) | 1090 TEST_P(ParameterizedPinchViewportTest, TestClientNotifiedOfScrollEvents) |
| 1059 { | 1091 { |
| 1060 initializeWithAndroidSettings(); | 1092 initializeWithAndroidSettings(); |
| 1061 webViewImpl()->resize(IntSize(200, 300)); | 1093 webViewImpl()->resize(IntSize(200, 300)); |
| 1062 | 1094 |
| 1063 registerMockedHttpURLLoad("200-by-300.html"); | 1095 registerMockedHttpURLLoad("200-by-300.html"); |
| 1064 navigateTo(m_baseURL + "200-by-300.html"); | 1096 navigateTo(m_baseURL + "200-by-300.html"); |
| 1065 | 1097 |
| 1066 WebFrameClient* oldClient = webViewImpl()->mainFrameImpl()->client(); | 1098 WebFrameClient* oldClient = webViewImpl()->mainFrameImpl()->client(); |
| 1067 MockWebFrameClient mockWebFrameClient; | 1099 MockWebFrameClient mockWebFrameClient; |
| 1068 webViewImpl()->mainFrameImpl()->setClient(&mockWebFrameClient); | 1100 webViewImpl()->mainFrameImpl()->setClient(&mockWebFrameClient); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1082 // Scroll horizontally. | 1114 // Scroll horizontally. |
| 1083 EXPECT_CALL(mockWebFrameClient, didChangeScrollOffset(_)); | 1115 EXPECT_CALL(mockWebFrameClient, didChangeScrollOffset(_)); |
| 1084 pinchViewport.setLocation(FloatPoint(70, 90)); | 1116 pinchViewport.setLocation(FloatPoint(70, 90)); |
| 1085 | 1117 |
| 1086 // Reset the old client so destruction can occur naturally. | 1118 // Reset the old client so destruction can occur naturally. |
| 1087 webViewImpl()->mainFrameImpl()->setClient(oldClient); | 1119 webViewImpl()->mainFrameImpl()->setClient(oldClient); |
| 1088 } | 1120 } |
| 1089 | 1121 |
| 1090 // Tests that calling scroll into view on a visible element doesn cause | 1122 // Tests that calling scroll into view on a visible element doesn cause |
| 1091 // a scroll due to a fractional offset. Bug crbug.com/463356. | 1123 // a scroll due to a fractional offset. Bug crbug.com/463356. |
| 1092 TEST_F(PinchViewportTest, ScrollIntoViewFractionalOffset) | 1124 TEST_P(ParameterizedPinchViewportTest, ScrollIntoViewFractionalOffset) |
| 1093 { | 1125 { |
| 1094 initializeWithAndroidSettings(); | 1126 initializeWithAndroidSettings(); |
| 1095 | 1127 |
| 1096 webViewImpl()->resize(IntSize(1000, 1000)); | 1128 webViewImpl()->resize(IntSize(1000, 1000)); |
| 1097 | 1129 |
| 1098 registerMockedHttpURLLoad("scroll-into-view.html"); | 1130 registerMockedHttpURLLoad("scroll-into-view.html"); |
| 1099 navigateTo(m_baseURL + "scroll-into-view.html"); | 1131 navigateTo(m_baseURL + "scroll-into-view.html"); |
| 1100 | 1132 |
| 1101 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); | 1133 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); |
| 1134 ScrollableArea* layoutViewportScrollableArea = frameView.layoutViewportScrol
lableArea(); |
| 1102 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); | 1135 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); |
| 1103 Element* inputBox = frame()->document()->getElementById("box"); | 1136 Element* inputBox = frame()->document()->getElementById("box"); |
| 1104 | 1137 |
| 1105 webViewImpl()->setPageScaleFactor(2); | 1138 webViewImpl()->setPageScaleFactor(2); |
| 1106 | 1139 |
| 1107 // The element is already in the view so the scrollIntoView shouldn't move | 1140 // The element is already in the view so the scrollIntoView shouldn't move |
| 1108 // the viewport at all. | 1141 // the viewport at all. |
| 1109 webViewImpl()->setPinchViewportOffset(WebFloatPoint(250.25f, 100.25f)); | 1142 webViewImpl()->setPinchViewportOffset(WebFloatPoint(250.25f, 100.25f)); |
| 1110 frameView.setScrollPosition(DoublePoint(0, 900.75), ProgrammaticScroll); | 1143 layoutViewportScrollableArea->setScrollPosition(DoublePoint(0, 900.75), Prog
rammaticScroll); |
| 1111 inputBox->scrollIntoViewIfNeeded(false); | 1144 inputBox->scrollIntoViewIfNeeded(false); |
| 1112 | 1145 |
| 1113 EXPECT_POINT_EQ(DoublePoint(0, 900.75), frameView.scrollPositionDouble()); | 1146 EXPECT_POINT_EQ(DoublePoint(0, 900.75), layoutViewportScrollableArea->scroll
PositionDouble()); |
| 1114 EXPECT_POINT_EQ(FloatPoint(250.25f, 100.25f), pinchViewport.location()); | 1147 EXPECT_POINT_EQ(FloatPoint(250.25f, 100.25f), pinchViewport.location()); |
| 1115 | 1148 |
| 1116 // Change the fractional part of the frameview to one that would round down. | 1149 // Change the fractional part of the frameview to one that would round down. |
| 1117 frameView.setScrollPosition(DoublePoint(0, 900.125), ProgrammaticScroll); | 1150 layoutViewportScrollableArea->setScrollPosition(DoublePoint(0, 900.125), Pro
grammaticScroll); |
| 1118 inputBox->scrollIntoViewIfNeeded(false); | 1151 inputBox->scrollIntoViewIfNeeded(false); |
| 1119 | 1152 |
| 1120 EXPECT_POINT_EQ(DoublePoint(0, 900.125), frameView.scrollPositionDouble()); | 1153 EXPECT_POINT_EQ(DoublePoint(0, 900.125), layoutViewportScrollableArea->scrol
lPositionDouble()); |
| 1121 EXPECT_POINT_EQ(FloatPoint(250.25f, 100.25f), pinchViewport.location()); | 1154 EXPECT_POINT_EQ(FloatPoint(250.25f, 100.25f), pinchViewport.location()); |
| 1122 | 1155 |
| 1123 // Repeat both tests above with the pinch viewport at a high fractional. | 1156 // Repeat both tests above with the pinch viewport at a high fractional. |
| 1124 webViewImpl()->setPinchViewportOffset(WebFloatPoint(250.875f, 100.875f)); | 1157 webViewImpl()->setPinchViewportOffset(WebFloatPoint(250.875f, 100.875f)); |
| 1125 frameView.setScrollPosition(DoublePoint(0, 900.75), ProgrammaticScroll); | 1158 layoutViewportScrollableArea->setScrollPosition(DoublePoint(0, 900.75), Prog
rammaticScroll); |
| 1126 inputBox->scrollIntoViewIfNeeded(false); | 1159 inputBox->scrollIntoViewIfNeeded(false); |
| 1127 | 1160 |
| 1128 EXPECT_POINT_EQ(DoublePoint(0, 900.75), frameView.scrollPositionDouble()); | 1161 EXPECT_POINT_EQ(DoublePoint(0, 900.75), layoutViewportScrollableArea->scroll
PositionDouble()); |
| 1129 EXPECT_POINT_EQ(FloatPoint(250.875f, 100.875f), pinchViewport.location()); | 1162 EXPECT_POINT_EQ(FloatPoint(250.875f, 100.875f), pinchViewport.location()); |
| 1130 | 1163 |
| 1131 // Change the fractional part of the frameview to one that would round down. | 1164 // Change the fractional part of the frameview to one that would round down. |
| 1132 frameView.setScrollPosition(DoublePoint(0, 900.125), ProgrammaticScroll); | 1165 layoutViewportScrollableArea->setScrollPosition(DoublePoint(0, 900.125), Pro
grammaticScroll); |
| 1133 inputBox->scrollIntoViewIfNeeded(false); | 1166 inputBox->scrollIntoViewIfNeeded(false); |
| 1134 | 1167 |
| 1135 EXPECT_POINT_EQ(DoublePoint(0, 900.125), frameView.scrollPositionDouble()); | 1168 EXPECT_POINT_EQ(DoublePoint(0, 900.125), layoutViewportScrollableArea->scrol
lPositionDouble()); |
| 1136 EXPECT_POINT_EQ(FloatPoint(250.875f, 100.875f), pinchViewport.location()); | 1169 EXPECT_POINT_EQ(FloatPoint(250.875f, 100.875f), pinchViewport.location()); |
| 1137 | 1170 |
| 1138 // Both viewports with a 0.5 fraction. | 1171 // Both viewports with a 0.5 fraction. |
| 1139 webViewImpl()->setPinchViewportOffset(WebFloatPoint(250.5f, 100.5f)); | 1172 webViewImpl()->setPinchViewportOffset(WebFloatPoint(250.5f, 100.5f)); |
| 1140 frameView.setScrollPosition(DoublePoint(0, 900.5), ProgrammaticScroll); | 1173 layoutViewportScrollableArea->setScrollPosition(DoublePoint(0, 900.5), Progr
ammaticScroll); |
| 1141 inputBox->scrollIntoViewIfNeeded(false); | 1174 inputBox->scrollIntoViewIfNeeded(false); |
| 1142 | 1175 |
| 1143 EXPECT_POINT_EQ(DoublePoint(0, 900.5), frameView.scrollPositionDouble()); | 1176 EXPECT_POINT_EQ(DoublePoint(0, 900.5), layoutViewportScrollableArea->scrollP
ositionDouble()); |
| 1144 EXPECT_POINT_EQ(FloatPoint(250.5f, 100.5f), pinchViewport.location()); | 1177 EXPECT_POINT_EQ(FloatPoint(250.5f, 100.5f), pinchViewport.location()); |
| 1145 } | 1178 } |
| 1146 | 1179 |
| 1147 // Top controls can make an unscrollable page temporarily scrollable, causing | 1180 // Top controls can make an unscrollable page temporarily scrollable, causing |
| 1148 // a scroll clamp when the page is resized. Make sure this bug is fixed. | 1181 // a scroll clamp when the page is resized. Make sure this bug is fixed. |
| 1149 // crbug.com/437620 | 1182 // crbug.com/437620 |
| 1150 TEST_F(PinchViewportTest, TestResizeDoesntChangeScrollOffset) | 1183 TEST_F(PinchViewportTest, TestResizeDoesntChangeScrollOffset) |
| 1151 { | 1184 { |
| 1152 initializeWithAndroidSettings(); | 1185 initializeWithAndroidSettings(); |
| 1153 webViewImpl()->resize(IntSize(980, 650)); | 1186 webViewImpl()->resize(IntSize(980, 650)); |
| 1154 | 1187 |
| 1155 navigateTo("about:blank"); | 1188 navigateTo("about:blank"); |
| 1156 | 1189 |
| 1157 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); | 1190 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); |
| 1158 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); | 1191 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); |
| 1159 | 1192 |
| 1160 webViewImpl()->setTopControlsHeight(20, false); | 1193 webViewImpl()->setTopControlsHeight(20, false); |
| 1161 | 1194 |
| 1162 // Outer viewport isn't scrollable | 1195 // Outer viewport isn't scrollable |
| 1163 EXPECT_SIZE_EQ(IntSize(980, 650), frameView.visibleContentRect().size()); | 1196 EXPECT_SIZE_EQ(IntSize(980, 650), frameView.visibleContentRect().size()); |
| 1164 | 1197 |
| 1165 pinchViewport.setScale(2); | 1198 pinchViewport.setScale(2); |
| 1166 pinchViewport.move(FloatPoint(0, 40)); | 1199 pinchViewport.move(FloatPoint(0, 40)); |
| 1167 | 1200 |
| 1168 // Simulate bringing down the top controls by 20px but counterscrolling the
outer viewport. | 1201 // Simulate bringing down the top controls by 20px but counterscrolling the
outer viewport. |
| 1169 webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSize(0, 20), WebF
loatSize(), 1, 1); | 1202 webViewImpl()->applyViewportDeltas(WebFloatSize(), WebFloatSize(0, 20), WebF
loatSize(), 1, 1); |
| 1170 | 1203 |
| 1171 EXPECT_EQ(20, frameView.scrollPosition().y()); | 1204 EXPECT_EQ(20, frameView.layoutViewportScrollableArea()->scrollPosition().y()
); |
| 1172 | 1205 |
| 1173 webViewImpl()->setTopControlsHeight(20, true); | 1206 webViewImpl()->setTopControlsHeight(20, true); |
| 1174 webViewImpl()->resize(WebSize(980, 630)); | 1207 webViewImpl()->resize(WebSize(980, 630)); |
| 1175 | 1208 |
| 1176 EXPECT_EQ(0, frameView.scrollPosition().y()); | 1209 EXPECT_EQ(0, frameView.layoutViewportScrollableArea()->scrollPosition().y())
; |
| 1177 EXPECT_EQ(60, pinchViewport.location().y()); | 1210 EXPECT_EQ(60, pinchViewport.location().y()); |
| 1178 } | 1211 } |
| 1179 | 1212 |
| 1180 static IntPoint expectedMaxFrameViewScrollOffset(PinchViewport& pinchViewport, F
rameView& frameView) | 1213 static IntPoint expectedMaxFrameViewScrollOffset(PinchViewport& pinchViewport, F
rameView& frameView) |
| 1181 { | 1214 { |
| 1182 float aspectRatio = pinchViewport.visibleRect().width() / pinchViewport.visi
bleRect().height(); | 1215 float aspectRatio = pinchViewport.visibleRect().width() / pinchViewport.visi
bleRect().height(); |
| 1183 float newHeight = frameView.frameRect().width() / aspectRatio; | 1216 float newHeight = frameView.frameRect().width() / aspectRatio; |
| 1184 return IntPoint( | 1217 return IntPoint( |
| 1185 frameView.contentsSize().width() - frameView.frameRect().width(), | 1218 frameView.contentsSize().width() - frameView.frameRect().width(), |
| 1186 frameView.contentsSize().height() - newHeight); | 1219 frameView.contentsSize().height() - newHeight); |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1361 EXPECT_EQ(500, frameView.scrollPositionDouble().y()); | 1394 EXPECT_EQ(500, frameView.scrollPositionDouble().y()); |
| 1362 | 1395 |
| 1363 // Now send the resize, make sure the scroll offset doesn't change. | 1396 // Now send the resize, make sure the scroll offset doesn't change. |
| 1364 webViewImpl()->setTopControlsHeight(500, false); | 1397 webViewImpl()->setTopControlsHeight(500, false); |
| 1365 webViewImpl()->resize(IntSize(1000, 1500)); | 1398 webViewImpl()->resize(IntSize(1000, 1500)); |
| 1366 EXPECT_EQ(500, frameView.scrollPositionDouble().y()); | 1399 EXPECT_EQ(500, frameView.scrollPositionDouble().y()); |
| 1367 } | 1400 } |
| 1368 | 1401 |
| 1369 // Tests that the layout viewport's scroll layer bounds are updated in a composi
ting | 1402 // Tests that the layout viewport's scroll layer bounds are updated in a composi
ting |
| 1370 // change update. crbug.com/423188. | 1403 // change update. crbug.com/423188. |
| 1371 TEST_F(PinchViewportTest, TestChangingContentSizeAffectsScrollBounds) | 1404 TEST_P(ParameterizedPinchViewportTest, TestChangingContentSizeAffectsScrollBound
s) |
| 1372 { | 1405 { |
| 1373 initializeWithAndroidSettings(); | 1406 initializeWithAndroidSettings(); |
| 1374 webViewImpl()->resize(IntSize(100, 150)); | 1407 webViewImpl()->resize(IntSize(100, 150)); |
| 1375 | 1408 |
| 1376 registerMockedHttpURLLoad("content-width-1000.html"); | 1409 registerMockedHttpURLLoad("content-width-1000.html"); |
| 1377 navigateTo(m_baseURL + "content-width-1000.html"); | 1410 navigateTo(m_baseURL + "content-width-1000.html"); |
| 1378 | 1411 |
| 1379 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); | 1412 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); |
| 1380 WebLayer* scrollLayer = frameView.layerForScrolling()->platformLayer(); | 1413 WebLayer* scrollLayer = frameView.layerForScrolling()->platformLayer(); |
| 1381 | 1414 |
| 1382 webViewImpl()->mainFrame()->executeScript(WebScriptSource( | 1415 webViewImpl()->mainFrame()->executeScript(WebScriptSource( |
| 1383 "var content = document.getElementById(\"content\");" | 1416 "var content = document.getElementById(\"content\");" |
| 1384 "content.style.width = \"1500px\";" | 1417 "content.style.width = \"1500px\";" |
| 1385 "content.style.height = \"2400px\";")); | 1418 "content.style.height = \"2400px\";")); |
| 1386 frameView.updateLayoutAndStyleForPainting(); | 1419 frameView.updateLayoutAndStyleForPainting(); |
| 1387 | 1420 |
| 1388 EXPECT_SIZE_EQ(IntSize(1500, 2400), IntSize(scrollLayer->bounds())); | 1421 EXPECT_SIZE_EQ(IntSize(1500, 2400), IntSize(scrollLayer->bounds())); |
| 1389 } | 1422 } |
| 1390 | 1423 |
| 1391 // Tests that resizing the pinch viepwort keeps its bounds within the outer | 1424 // Tests that resizing the pinch viepwort keeps its bounds within the outer |
| 1392 // viewport. | 1425 // viewport. |
| 1393 TEST_F(PinchViewportTest, ResizePinchViewportStaysWithinOuterViewport) | 1426 TEST_P(ParameterizedPinchViewportTest, ResizePinchViewportStaysWithinOuterViewpo
rt) |
| 1394 { | 1427 { |
| 1395 initializeWithDesktopSettings(); | 1428 initializeWithDesktopSettings(); |
| 1396 webViewImpl()->resize(IntSize(100, 200)); | 1429 webViewImpl()->resize(IntSize(100, 200)); |
| 1397 | 1430 |
| 1398 navigateTo("about:blank"); | 1431 navigateTo("about:blank"); |
| 1399 webViewImpl()->layout(); | 1432 webViewImpl()->layout(); |
| 1400 | 1433 |
| 1401 webViewImpl()->resizePinchViewport(IntSize(100, 100)); | 1434 webViewImpl()->resizePinchViewport(IntSize(100, 100)); |
| 1402 | 1435 |
| 1403 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); | 1436 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); |
| 1404 pinchViewport.move(FloatPoint(0, 100)); | 1437 pinchViewport.move(FloatPoint(0, 100)); |
| 1405 | 1438 |
| 1406 EXPECT_EQ(100, pinchViewport.location().y()); | 1439 EXPECT_EQ(100, pinchViewport.location().y()); |
| 1407 | 1440 |
| 1408 webViewImpl()->resizePinchViewport(IntSize(100, 200)); | 1441 webViewImpl()->resizePinchViewport(IntSize(100, 200)); |
| 1409 | 1442 |
| 1410 EXPECT_EQ(0, pinchViewport.location().y()); | 1443 EXPECT_EQ(0, pinchViewport.location().y()); |
| 1411 } | 1444 } |
| 1412 | 1445 |
| 1413 TEST_F(PinchViewportTest, ElementBoundsInViewportSpaceAccountsForViewport) | 1446 TEST_P(ParameterizedPinchViewportTest, ElementBoundsInViewportSpaceAccountsForVi
ewport) |
| 1414 { | 1447 { |
| 1415 initializeWithAndroidSettings(); | 1448 initializeWithAndroidSettings(); |
| 1416 | 1449 |
| 1417 webViewImpl()->resize(IntSize(500, 800)); | 1450 webViewImpl()->resize(IntSize(500, 800)); |
| 1418 | 1451 |
| 1419 registerMockedHttpURLLoad("pinch-viewport-input-field.html"); | 1452 registerMockedHttpURLLoad("pinch-viewport-input-field.html"); |
| 1420 navigateTo(m_baseURL + "pinch-viewport-input-field.html"); | 1453 navigateTo(m_baseURL + "pinch-viewport-input-field.html"); |
| 1421 | 1454 |
| 1422 webViewImpl()->setInitialFocus(false); | 1455 webViewImpl()->setInitialFocus(false); |
| 1423 Element* inputElement = webViewImpl()->focusedElement(); | 1456 Element* inputElement = webViewImpl()->focusedElement(); |
| 1424 | 1457 |
| 1425 IntRect bounds = inputElement->layoutObject()->absoluteBoundingBoxRect(); | 1458 IntRect bounds = inputElement->layoutObject()->absoluteBoundingBoxRect(); |
| 1426 | 1459 |
| 1427 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); | 1460 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); |
| 1428 IntPoint scrollDelta(250, 400); | 1461 IntPoint scrollDelta(250, 400); |
| 1429 pinchViewport.setScale(2); | 1462 pinchViewport.setScale(2); |
| 1430 pinchViewport.setLocation(scrollDelta); | 1463 pinchViewport.setLocation(scrollDelta); |
| 1431 | 1464 |
| 1432 IntRect boundsInViewport = inputElement->boundsInViewportSpace(); | 1465 IntRect boundsInViewport = inputElement->boundsInViewportSpace(); |
| 1433 | 1466 |
| 1434 EXPECT_POINT_EQ(IntPoint(bounds.location() - scrollDelta), | 1467 EXPECT_POINT_EQ(IntPoint(bounds.location() - scrollDelta), |
| 1435 boundsInViewport.location()); | 1468 boundsInViewport.location()); |
| 1436 EXPECT_SIZE_EQ(bounds.size(), boundsInViewport.size()); | 1469 EXPECT_SIZE_EQ(bounds.size(), boundsInViewport.size()); |
| 1437 } | 1470 } |
| 1438 | 1471 |
| 1439 // Test that the various window.scroll and document.body.scroll properties and | 1472 // Test that the various window.scroll and document.body.scroll properties and |
| 1440 // methods work unchanged from the pre-virtual viewport mode. | 1473 // methods work unchanged from the pre-virtual viewport mode. |
| 1441 TEST_F(PinchViewportTest, bodyAndWindowScrollPropertiesAccountForViewport) | 1474 TEST_P(ParameterizedPinchViewportTest, bodyAndWindowScrollPropertiesAccountForVi
ewport) |
| 1442 { | 1475 { |
| 1443 initializeWithAndroidSettings(); | 1476 initializeWithAndroidSettings(); |
| 1444 | 1477 |
| 1445 webViewImpl()->resize(IntSize(200, 300)); | 1478 webViewImpl()->resize(IntSize(200, 300)); |
| 1446 | 1479 |
| 1447 // Load page with no main frame scrolling. | 1480 // Load page with no main frame scrolling. |
| 1448 registerMockedHttpURLLoad("200-by-300-viewport.html"); | 1481 registerMockedHttpURLLoad("200-by-300-viewport.html"); |
| 1449 navigateTo(m_baseURL + "200-by-300-viewport.html"); | 1482 navigateTo(m_baseURL + "200-by-300-viewport.html"); |
| 1450 | 1483 |
| 1451 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); | 1484 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1509 EXPECT_EQ(0, body->scrollLeft()); | 1542 EXPECT_EQ(0, body->scrollLeft()); |
| 1510 EXPECT_EQ(0, body->scrollTop()); | 1543 EXPECT_EQ(0, body->scrollTop()); |
| 1511 EXPECT_EQ(10, documentElement->scrollLeft()); | 1544 EXPECT_EQ(10, documentElement->scrollLeft()); |
| 1512 EXPECT_EQ(20, documentElement->scrollTop()); | 1545 EXPECT_EQ(20, documentElement->scrollTop()); |
| 1513 EXPECT_EQ(10, window->scrollX()); | 1546 EXPECT_EQ(10, window->scrollX()); |
| 1514 EXPECT_EQ(20, window->scrollY()); | 1547 EXPECT_EQ(20, window->scrollY()); |
| 1515 } | 1548 } |
| 1516 | 1549 |
| 1517 // Tests that when a new frame is created, it is created with the intended | 1550 // Tests that when a new frame is created, it is created with the intended |
| 1518 // size (i.e. viewport at minimum scale, 100x200 / 0.5). | 1551 // size (i.e. viewport at minimum scale, 100x200 / 0.5). |
| 1519 TEST_F(PinchViewportTest, TestMainFrameInitializationSizing) | 1552 TEST_P(ParameterizedPinchViewportTest, TestMainFrameInitializationSizing) |
| 1520 { | 1553 { |
| 1521 initializeWithAndroidSettings(); | 1554 initializeWithAndroidSettings(); |
| 1522 | 1555 |
| 1523 webViewImpl()->resize(IntSize(100, 200)); | 1556 webViewImpl()->resize(IntSize(100, 200)); |
| 1524 | 1557 |
| 1525 registerMockedHttpURLLoad("content-width-1000-min-scale.html"); | 1558 registerMockedHttpURLLoad("content-width-1000-min-scale.html"); |
| 1526 navigateTo(m_baseURL + "content-width-1000-min-scale.html"); | 1559 navigateTo(m_baseURL + "content-width-1000-min-scale.html"); |
| 1527 | 1560 |
| 1528 WebLocalFrameImpl* localFrame = webViewImpl()->mainFrameImpl(); | 1561 WebLocalFrameImpl* localFrame = webViewImpl()->mainFrameImpl(); |
| 1529 // The detach() and dispose() calls are a hack to prevent this test | 1562 // The detach() and dispose() calls are a hack to prevent this test |
| 1530 // from violating invariants about frame state during navigation/detach. | 1563 // from violating invariants about frame state during navigation/detach. |
| 1531 localFrame->frame()->document()->detach(); | 1564 localFrame->frame()->document()->detach(); |
| 1532 localFrame->createFrameView(); | 1565 localFrame->createFrameView(); |
| 1533 | 1566 |
| 1534 FrameView& frameView = *localFrame->frameView(); | 1567 FrameView& frameView = *localFrame->frameView(); |
| 1535 EXPECT_SIZE_EQ(IntSize(200, 400), frameView.frameRect().size()); | 1568 EXPECT_SIZE_EQ(IntSize(200, 400), frameView.frameRect().size()); |
| 1536 frameView.dispose(); | 1569 frameView.dispose(); |
| 1537 } | 1570 } |
| 1538 | 1571 |
| 1539 // Tests that the maximum scroll offset of the viewport can be fractional. | 1572 // Tests that the maximum scroll offset of the viewport can be fractional. |
| 1540 TEST_F(PinchViewportTest, FractionalMaxScrollOffset) | 1573 TEST_P(ParameterizedPinchViewportTest, FractionalMaxScrollOffset) |
| 1541 { | 1574 { |
| 1542 initializeWithDesktopSettings(); | 1575 initializeWithDesktopSettings(); |
| 1543 webViewImpl()->resize(IntSize(101, 201)); | 1576 webViewImpl()->resize(IntSize(101, 201)); |
| 1544 navigateTo("about:blank"); | 1577 navigateTo("about:blank"); |
| 1545 | 1578 |
| 1546 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); | 1579 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); |
| 1547 ScrollableArea* scrollableArea = &pinchViewport; | 1580 ScrollableArea* scrollableArea = &pinchViewport; |
| 1548 | 1581 |
| 1549 webViewImpl()->setPageScaleFactor(1.0); | 1582 webViewImpl()->setPageScaleFactor(1.0); |
| 1550 EXPECT_FLOAT_POINT_EQ(DoublePoint(), scrollableArea->maximumScrollPositionDo
uble()); | 1583 EXPECT_FLOAT_POINT_EQ(DoublePoint(), scrollableArea->maximumScrollPositionDo
uble()); |
| 1551 | 1584 |
| 1552 webViewImpl()->setPageScaleFactor(2); | 1585 webViewImpl()->setPageScaleFactor(2); |
| 1553 EXPECT_FLOAT_POINT_EQ(DoublePoint(101. / 2., 201. / 2.), scrollableArea->max
imumScrollPositionDouble()); | 1586 EXPECT_FLOAT_POINT_EQ(DoublePoint(101. / 2., 201. / 2.), scrollableArea->max
imumScrollPositionDouble()); |
| 1554 } | 1587 } |
| 1555 | 1588 |
| 1556 // Tests that the slow scrolling after an impl scroll on the pinch viewport | 1589 // Tests that the slow scrolling after an impl scroll on the pinch viewport |
| 1557 // is continuous. crbug.com/453460 was caused by the impl-path not updating the | 1590 // is continuous. crbug.com/453460 was caused by the impl-path not updating the |
| 1558 // ScrollAnimator class. | 1591 // ScrollAnimator class. |
| 1559 TEST_F(PinchViewportTest, SlowScrollAfterImplScroll) | 1592 TEST_P(ParameterizedPinchViewportTest, SlowScrollAfterImplScroll) |
| 1560 { | 1593 { |
| 1561 initializeWithDesktopSettings(); | 1594 initializeWithDesktopSettings(); |
| 1562 webViewImpl()->resize(IntSize(800, 600)); | 1595 webViewImpl()->resize(IntSize(800, 600)); |
| 1563 navigateTo("about:blank"); | 1596 navigateTo("about:blank"); |
| 1564 | 1597 |
| 1565 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); | 1598 PinchViewport& pinchViewport = frame()->page()->frameHost().pinchViewport(); |
| 1566 | 1599 |
| 1567 // Apply some scroll and scale from the impl-side. | 1600 // Apply some scroll and scale from the impl-side. |
| 1568 webViewImpl()->applyViewportDeltas( | 1601 webViewImpl()->applyViewportDeltas( |
| 1569 WebFloatSize(300, 200), | 1602 WebFloatSize(300, 200), |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1588 // The scroll sent from the impl-side must not be overwritten. | 1621 // The scroll sent from the impl-side must not be overwritten. |
| 1589 EXPECT_POINT_EQ(FloatPoint(350, 260), pinchViewport.location()); | 1622 EXPECT_POINT_EQ(FloatPoint(350, 260), pinchViewport.location()); |
| 1590 } | 1623 } |
| 1591 | 1624 |
| 1592 static void accessibilitySettings(WebSettings* settings) | 1625 static void accessibilitySettings(WebSettings* settings) |
| 1593 { | 1626 { |
| 1594 PinchViewportTest::configureSettings(settings); | 1627 PinchViewportTest::configureSettings(settings); |
| 1595 settings->setAccessibilityEnabled(true); | 1628 settings->setAccessibilityEnabled(true); |
| 1596 } | 1629 } |
| 1597 | 1630 |
| 1598 TEST_F(PinchViewportTest, AccessibilityHitTestWhileZoomedIn) | 1631 TEST_P(ParameterizedPinchViewportTest, AccessibilityHitTestWhileZoomedIn) |
| 1599 { | 1632 { |
| 1600 initializeWithDesktopSettings(accessibilitySettings); | 1633 initializeWithDesktopSettings(accessibilitySettings); |
| 1601 | 1634 |
| 1602 registerMockedHttpURLLoad("hit-test.html"); | 1635 registerMockedHttpURLLoad("hit-test.html"); |
| 1603 navigateTo(m_baseURL + "hit-test.html"); | 1636 navigateTo(m_baseURL + "hit-test.html"); |
| 1604 | 1637 |
| 1605 webViewImpl()->resize(IntSize(500, 500)); | 1638 webViewImpl()->resize(IntSize(500, 500)); |
| 1606 webViewImpl()->layout(); | 1639 webViewImpl()->layout(); |
| 1607 | 1640 |
| 1608 WebDocument webDoc = webViewImpl()->mainFrame()->document(); | 1641 WebDocument webDoc = webViewImpl()->mainFrame()->document(); |
| 1609 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); | 1642 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); |
| 1610 | 1643 |
| 1611 webViewImpl()->setPageScaleFactor(2); | 1644 webViewImpl()->setPageScaleFactor(2); |
| 1612 webViewImpl()->setPinchViewportOffset(WebFloatPoint(200, 230)); | 1645 webViewImpl()->setPinchViewportOffset(WebFloatPoint(200, 230)); |
| 1613 frameView.setScrollPosition(DoublePoint(400, 1100), ProgrammaticScroll); | 1646 frameView.layoutViewportScrollableArea()->setScrollPosition(DoublePoint(400,
1100), ProgrammaticScroll); |
| 1647 |
| 1648 // FIXME(504057): DeprecatedPaintLayerScrollableArea dirties the compositing
state. |
| 1649 forceFullCompositingUpdate(); |
| 1614 | 1650 |
| 1615 // Because of where the pinch viewport is located, this should hit the botto
m right | 1651 // Because of where the pinch viewport is located, this should hit the botto
m right |
| 1616 // target (target 4). | 1652 // target (target 4). |
| 1617 WebAXObject hitNode = webDoc.accessibilityObject().hitTest(WebPoint(154, 165
)); | 1653 WebAXObject hitNode = webDoc.accessibilityObject().hitTest(WebPoint(154, 165
)); |
| 1618 EXPECT_EQ(std::string("Target4"), hitNode.title().utf8()); | 1654 EXPECT_EQ(std::string("Target4"), hitNode.title().utf8()); |
| 1619 } | 1655 } |
| 1620 | 1656 |
| 1621 // Tests that the maximum scroll offset of the viewport can be fractional. | 1657 // Tests that the maximum scroll offset of the viewport can be fractional. |
| 1622 TEST_F(PinchViewportTest, TestCoordinateTransforms) | 1658 TEST_P(ParameterizedPinchViewportTest, TestCoordinateTransforms) |
| 1623 { | 1659 { |
| 1624 initializeWithAndroidSettings(); | 1660 initializeWithAndroidSettings(); |
| 1625 webViewImpl()->resize(IntSize(800, 600)); | 1661 webViewImpl()->resize(IntSize(800, 600)); |
| 1626 registerMockedHttpURLLoad("content-width-1000.html"); | 1662 registerMockedHttpURLLoad("content-width-1000.html"); |
| 1627 navigateTo(m_baseURL + "content-width-1000.html"); | 1663 navigateTo(m_baseURL + "content-width-1000.html"); |
| 1628 | 1664 |
| 1629 PinchViewport& pinchViewport = webViewImpl()->page()->frameHost().pinchViewp
ort(); | 1665 PinchViewport& pinchViewport = webViewImpl()->page()->frameHost().pinchViewp
ort(); |
| 1630 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); | 1666 FrameView& frameView = *webViewImpl()->mainFrameImpl()->frameView(); |
| 1631 | 1667 |
| 1632 // At scale = 1 the transform should be a no-op. | 1668 // At scale = 1 the transform should be a no-op. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1643 pinchViewport.setLocation(FloatPoint(10, 12)); | 1679 pinchViewport.setLocation(FloatPoint(10, 12)); |
| 1644 EXPECT_FLOAT_POINT_EQ(FloatPoint(50, 62), pinchViewport.viewportToRootFrame(
FloatPoint(80, 100))); | 1680 EXPECT_FLOAT_POINT_EQ(FloatPoint(50, 62), pinchViewport.viewportToRootFrame(
FloatPoint(80, 100))); |
| 1645 EXPECT_FLOAT_POINT_EQ(FloatPoint(80, 100), pinchViewport.rootFrameToViewport
(FloatPoint(50, 62))); | 1681 EXPECT_FLOAT_POINT_EQ(FloatPoint(80, 100), pinchViewport.rootFrameToViewport
(FloatPoint(50, 62))); |
| 1646 | 1682 |
| 1647 // Test points that will cause non-integer values. | 1683 // Test points that will cause non-integer values. |
| 1648 EXPECT_FLOAT_POINT_EQ(FloatPoint(50.5, 62.4), pinchViewport.viewportToRootFr
ame(FloatPoint(81, 100.8))); | 1684 EXPECT_FLOAT_POINT_EQ(FloatPoint(50.5, 62.4), pinchViewport.viewportToRootFr
ame(FloatPoint(81, 100.8))); |
| 1649 EXPECT_FLOAT_POINT_EQ(FloatPoint(81, 100.8), pinchViewport.rootFrameToViewpo
rt(FloatPoint(50.5, 62.4))); | 1685 EXPECT_FLOAT_POINT_EQ(FloatPoint(81, 100.8), pinchViewport.rootFrameToViewpo
rt(FloatPoint(50.5, 62.4))); |
| 1650 | 1686 |
| 1651 | 1687 |
| 1652 // Scrolling the main frame should have no effect. | 1688 // Scrolling the main frame should have no effect. |
| 1653 frameView.scrollTo(DoublePoint(100, 120)); | 1689 frameView.layoutViewportScrollableArea()->setScrollPosition(DoublePoint(100,
120), ProgrammaticScroll); |
| 1654 EXPECT_FLOAT_POINT_EQ(FloatPoint(50, 62), pinchViewport.viewportToRootFrame(
FloatPoint(80, 100))); | 1690 EXPECT_FLOAT_POINT_EQ(FloatPoint(50, 62), pinchViewport.viewportToRootFrame(
FloatPoint(80, 100))); |
| 1655 EXPECT_FLOAT_POINT_EQ(FloatPoint(80, 100), pinchViewport.rootFrameToViewport
(FloatPoint(50, 62))); | 1691 EXPECT_FLOAT_POINT_EQ(FloatPoint(80, 100), pinchViewport.rootFrameToViewport
(FloatPoint(50, 62))); |
| 1656 } | 1692 } |
| 1657 | 1693 |
| 1658 // Tests that the window dimensions are available before a full layout occurs. | 1694 // Tests that the window dimensions are available before a full layout occurs. |
| 1659 // More specifically, it checks that the innerWidth and innerHeight window | 1695 // More specifically, it checks that the innerWidth and innerHeight window |
| 1660 // properties will trigger a layout which will cause an update to viewport | 1696 // properties will trigger a layout which will cause an update to viewport |
| 1661 // constraints and a refreshed initial scale. crbug.com/466718 | 1697 // constraints and a refreshed initial scale. crbug.com/466718 |
| 1662 TEST_F(PinchViewportTest, WindowDimensionsOnLoad) | 1698 TEST_P(ParameterizedPinchViewportTest, WindowDimensionsOnLoad) |
| 1663 { | 1699 { |
| 1664 initializeWithAndroidSettings(); | 1700 initializeWithAndroidSettings(); |
| 1665 registerMockedHttpURLLoad("window_dimensions.html"); | 1701 registerMockedHttpURLLoad("window_dimensions.html"); |
| 1666 webViewImpl()->resize(IntSize(800, 600)); | 1702 webViewImpl()->resize(IntSize(800, 600)); |
| 1667 navigateTo(m_baseURL + "window_dimensions.html"); | 1703 navigateTo(m_baseURL + "window_dimensions.html"); |
| 1668 | 1704 |
| 1669 Element* output = frame()->document()->getElementById("output"); | 1705 Element* output = frame()->document()->getElementById("output"); |
| 1670 ASSERT(output); | 1706 ASSERT(output); |
| 1671 EXPECT_EQ(std::string("1600x1200"), std::string(output->innerHTML().ascii().
data())); | 1707 EXPECT_EQ(std::string("1600x1200"), std::string(output->innerHTML().ascii().
data())); |
| 1672 } | 1708 } |
| 1673 | 1709 |
| 1674 // Similar to above but make sure the initial scale is updated with the content | 1710 // Similar to above but make sure the initial scale is updated with the content |
| 1675 // width for a very wide page. That is, make that innerWidth/Height actually | 1711 // width for a very wide page. That is, make that innerWidth/Height actually |
| 1676 // trigger a layout of the content, and not just an update of the viepwort. | 1712 // trigger a layout of the content, and not just an update of the viepwort. |
| 1677 // crbug.com/466718 | 1713 // crbug.com/466718 |
| 1678 TEST_F(PinchViewportTest, WindowDimensionsOnLoadWideContent) | 1714 TEST_P(ParameterizedPinchViewportTest, WindowDimensionsOnLoadWideContent) |
| 1679 { | 1715 { |
| 1680 initializeWithAndroidSettings(); | 1716 initializeWithAndroidSettings(); |
| 1681 registerMockedHttpURLLoad("window_dimensions_wide_div.html"); | 1717 registerMockedHttpURLLoad("window_dimensions_wide_div.html"); |
| 1682 webViewImpl()->resize(IntSize(800, 600)); | 1718 webViewImpl()->resize(IntSize(800, 600)); |
| 1683 navigateTo(m_baseURL + "window_dimensions_wide_div.html"); | 1719 navigateTo(m_baseURL + "window_dimensions_wide_div.html"); |
| 1684 | 1720 |
| 1685 Element* output = frame()->document()->getElementById("output"); | 1721 Element* output = frame()->document()->getElementById("output"); |
| 1686 ASSERT(output); | 1722 ASSERT(output); |
| 1687 EXPECT_EQ(std::string("2000x1500"), std::string(output->innerHTML().ascii().
data())); | 1723 EXPECT_EQ(std::string("2000x1500"), std::string(output->innerHTML().ascii().
data())); |
| 1688 } | 1724 } |
| 1689 | 1725 |
| 1690 } // namespace | 1726 } // namespace |
| OLD | NEW |