| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 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 4274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4285 | 4285 |
| 4286 EXPECT_EQ(expectedWidth, vwElement->offsetWidth()); | 4286 EXPECT_EQ(expectedWidth, vwElement->offsetWidth()); |
| 4287 EXPECT_EQ(expectedHeight, vwElement->offsetHeight()); | 4287 EXPECT_EQ(expectedHeight, vwElement->offsetHeight()); |
| 4288 | 4288 |
| 4289 webView->resize(WebSize(800, 600)); | 4289 webView->resize(WebSize(800, 600)); |
| 4290 frame->printEnd(); | 4290 frame->printEnd(); |
| 4291 | 4291 |
| 4292 EXPECT_EQ(800, vwElement->offsetWidth()); | 4292 EXPECT_EQ(800, vwElement->offsetWidth()); |
| 4293 } | 4293 } |
| 4294 | 4294 |
| 4295 TEST_P(WebViewTest, DeviceEmulationResetScrollbars) { |
| 4296 WebViewImpl* webView = m_webViewHelper.initialize(); |
| 4297 webView->resize(WebSize(800, 600)); |
| 4298 |
| 4299 WebURL baseURL = URLTestHelpers::toKURL("http://example.com/"); |
| 4300 FrameTestHelpers::loadHTMLString(webView->mainFrame(), |
| 4301 "<!doctype html>" |
| 4302 "<meta name='viewport'" |
| 4303 " content='width=device-width'>" |
| 4304 "<style>" |
| 4305 " body {margin: 0px; height:3000px;}" |
| 4306 "</style>", |
| 4307 baseURL); |
| 4308 |
| 4309 WebLocalFrameImpl* frame = webView->mainFrameImpl(); |
| 4310 auto* frameView = frame->frameView(); |
| 4311 EXPECT_FALSE(frameView->visualViewportSuppliesScrollbars()); |
| 4312 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
| 4313 EXPECT_NE(nullptr, |
| 4314 frameView->layoutViewportScrollableArea()->verticalScrollbar()); |
| 4315 } else { |
| 4316 EXPECT_NE(nullptr, frameView->verticalScrollbar()); |
| 4317 } |
| 4318 |
| 4319 WebDeviceEmulationParams params; |
| 4320 params.screenPosition = WebDeviceEmulationParams::Mobile; |
| 4321 params.deviceScaleFactor = 0; |
| 4322 params.fitToView = false; |
| 4323 params.offset = WebFloatPoint(); |
| 4324 params.scale = 1; |
| 4325 |
| 4326 webView->enableDeviceEmulation(params); |
| 4327 |
| 4328 // The visual viewport should now proivde the scrollbars instead of the view. |
| 4329 EXPECT_TRUE(frameView->visualViewportSuppliesScrollbars()); |
| 4330 EXPECT_EQ(nullptr, frameView->verticalScrollbar()); |
| 4331 |
| 4332 webView->disableDeviceEmulation(); |
| 4333 |
| 4334 // The view should once again provide the scrollbars. |
| 4335 EXPECT_FALSE(frameView->visualViewportSuppliesScrollbars()); |
| 4336 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
| 4337 EXPECT_NE(nullptr, |
| 4338 frameView->layoutViewportScrollableArea()->verticalScrollbar()); |
| 4339 } else { |
| 4340 EXPECT_NE(nullptr, frameView->verticalScrollbar()); |
| 4341 } |
| 4342 } |
| 4343 |
| 4295 } // namespace blink | 4344 } // namespace blink |
| OLD | NEW |