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 "core/frame/VisualViewport.h" | 5 #include "core/frame/VisualViewport.h" |
6 | 6 |
7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
8 #include "core/frame/BrowserControls.h" | 8 #include "core/frame/BrowserControls.h" |
9 #include "core/frame/FrameHost.h" | 9 #include "core/frame/FrameHost.h" |
10 #include "core/frame/FrameView.h" | 10 #include "core/frame/FrameView.h" |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 webViewImpl()->resize(IntSize(800, 600)); | 304 webViewImpl()->resize(IntSize(800, 600)); |
305 | 305 |
306 EXPECT_POINT_EQ( | 306 EXPECT_POINT_EQ( |
307 expectedLocation, | 307 expectedLocation, |
308 frameView.getScrollableArea()->visibleContentRect().location()); | 308 frameView.getScrollableArea()->visibleContentRect().location()); |
309 } | 309 } |
310 | 310 |
311 // Test that the VisualViewport works as expected in case of a scaled | 311 // Test that the VisualViewport works as expected in case of a scaled |
312 // and scrolled viewport - scroll down. | 312 // and scrolled viewport - scroll down. |
313 TEST_P(VisualViewportTest, TestResizeAfterVerticalScroll) { | 313 TEST_P(VisualViewportTest, TestResizeAfterVerticalScroll) { |
314 /* | 314 /* |
315 200 200 | 315 200 200 |
316 | | | | | 316 | | | | |
317 | | | | | 317 | | | | |
318 | | 800 | | 800 | 318 | | 800 | | 800 |
319 |-------------------| | | | 319 |-------------------| | | |
320 | | | | | 320 | | | | |
321 | | | | | 321 | | | | |
322 | | | | | 322 | | | | |
323 | | --------> | | | 323 | | --------> | | |
324 | 300 | | | | 324 | 300 | | | |
325 | | | | | 325 | | | | |
326 | 400 | | | | 326 | 400 | | | |
327 | | |-------------------| | 327 | | |-------------------| |
328 | | | 75 | | 328 | | | 75 | |
329 | 50 | | 50 100| | 329 | 50 | | 50 100| |
330 o----- | o---- | | 330 o----- | o---- | |
331 | | | | | 25 | | 331 | | | | | 25 | |
332 | |100 | |-------------------| | 332 | |100 | |-------------------| |
333 | | | | | | 333 | | | | | |
334 | | | | | | 334 | | | | | |
335 -------------------- -------------------- | 335 -------------------- -------------------- |
336 | 336 |
337 */ | 337 */ |
338 initializeWithAndroidSettings(); | 338 initializeWithAndroidSettings(); |
339 | 339 |
340 registerMockedHttpURLLoad("200-by-800-viewport.html"); | 340 registerMockedHttpURLLoad("200-by-800-viewport.html"); |
341 navigateTo(m_baseURL + "200-by-800-viewport.html"); | 341 navigateTo(m_baseURL + "200-by-800-viewport.html"); |
342 | 342 |
343 webViewImpl()->resize(IntSize(100, 200)); | 343 webViewImpl()->resize(IntSize(100, 200)); |
344 | 344 |
345 // Scroll main frame to the bottom of the document | 345 // Scroll main frame to the bottom of the document |
346 webViewImpl()->mainFrame()->setScrollOffset(WebSize(0, 400)); | 346 webViewImpl()->mainFrame()->setScrollOffset(WebSize(0, 400)); |
347 EXPECT_SIZE_EQ( | 347 EXPECT_SIZE_EQ( |
(...skipping 19 matching lines...) Expand all Loading... |
367 | 367 |
368 EXPECT_SIZE_EQ( | 368 EXPECT_SIZE_EQ( |
369 ScrollOffset(0, 625), | 369 ScrollOffset(0, 625), |
370 frame()->view()->layoutViewportScrollableArea()->getScrollOffset()); | 370 frame()->view()->layoutViewportScrollableArea()->getScrollOffset()); |
371 EXPECT_FLOAT_SIZE_EQ(FloatSize(0, 75), visualViewport.getScrollOffset()); | 371 EXPECT_FLOAT_SIZE_EQ(FloatSize(0, 75), visualViewport.getScrollOffset()); |
372 } | 372 } |
373 | 373 |
374 // Test that the VisualViewport works as expected in case if a scaled | 374 // Test that the VisualViewport works as expected in case if a scaled |
375 // and scrolled viewport - scroll right. | 375 // and scrolled viewport - scroll right. |
376 TEST_P(VisualViewportTest, TestResizeAfterHorizontalScroll) { | 376 TEST_P(VisualViewportTest, TestResizeAfterHorizontalScroll) { |
377 /* | 377 /* |
378 200 200 | 378 200 200 |
379 ---------------o----- ---------------o----- | 379 ---------------o----- ---------------o----- |
380 | | | | 25| | | 380 | | | | 25| | |
381 | | | | -----| | 381 | | | | -----| |
382 | 100| | |100 50 | | 382 | 100| | |100 50 | |
383 | | | | | | 383 | | | | | |
384 | ---- | |-------------------| | 384 | ---- | |-------------------| |
385 | | | | | 385 | | | | |
386 | | | | | 386 | | | | |
387 | | | | | 387 | | | | |
388 | | | | | 388 | | | | |
389 | | | | | 389 | | | | |
390 |400 | ---------> | | | 390 |400 | ---------> | | |
391 | | | | | 391 | | | | |
392 | | | | | 392 | | | | |
393 | | | | | 393 | | | | |
394 | | | | | 394 | | | | |
395 | | | | | 395 | | | | |
396 | | | | | 396 | | | | |
397 | | | | | 397 | | | | |
398 | | | | | 398 | | | | |
399 |-------------------| | | | 399 |-------------------| | | |
400 | | | | | 400 | | | | |
401 | 401 |
402 */ | 402 */ |
403 initializeWithAndroidSettings(); | 403 initializeWithAndroidSettings(); |
404 | 404 |
405 registerMockedHttpURLLoad("200-by-800-viewport.html"); | 405 registerMockedHttpURLLoad("200-by-800-viewport.html"); |
406 navigateTo(m_baseURL + "200-by-800-viewport.html"); | 406 navigateTo(m_baseURL + "200-by-800-viewport.html"); |
407 | 407 |
408 webViewImpl()->resize(IntSize(100, 200)); | 408 webViewImpl()->resize(IntSize(100, 200)); |
409 | 409 |
410 // Outer viewport takes the whole width of the document. | 410 // Outer viewport takes the whole width of the document. |
411 | 411 |
412 webViewImpl()->setPageScaleFactor(2.0); | 412 webViewImpl()->setPageScaleFactor(2.0); |
(...skipping 2059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2472 " body {" | 2472 " body {" |
2473 " margin: 0px;" | 2473 " margin: 0px;" |
2474 " }" | 2474 " }" |
2475 " div { height:110vh; width: 110vw; }" | 2475 " div { height:110vh; width: 110vw; }" |
2476 "</style>" | 2476 "</style>" |
2477 "<div></div>", | 2477 "<div></div>", |
2478 baseURL); | 2478 baseURL); |
2479 } | 2479 } |
2480 | 2480 |
2481 } // namespace | 2481 } // namespace |
OLD | NEW |