Chromium Code Reviews| 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 28 matching lines...) Expand all Loading... | |
| 39 #include "core/frame/EventHandlerRegistry.h" | 39 #include "core/frame/EventHandlerRegistry.h" |
| 40 #include "core/frame/FrameHost.h" | 40 #include "core/frame/FrameHost.h" |
| 41 #include "core/frame/FrameView.h" | 41 #include "core/frame/FrameView.h" |
| 42 #include "core/frame/LocalFrame.h" | 42 #include "core/frame/LocalFrame.h" |
| 43 #include "core/frame/Settings.h" | 43 #include "core/frame/Settings.h" |
| 44 #include "core/frame/VisualViewport.h" | 44 #include "core/frame/VisualViewport.h" |
| 45 #include "core/html/HTMLIFrameElement.h" | 45 #include "core/html/HTMLIFrameElement.h" |
| 46 #include "core/html/HTMLInputElement.h" | 46 #include "core/html/HTMLInputElement.h" |
| 47 #include "core/html/HTMLTextAreaElement.h" | 47 #include "core/html/HTMLTextAreaElement.h" |
| 48 #include "core/layout/api/LayoutViewItem.h" | 48 #include "core/layout/api/LayoutViewItem.h" |
| 49 #include "core/layout/compositing/PaintLayerCompositor.h" | |
| 49 #include "core/loader/DocumentLoader.h" | 50 #include "core/loader/DocumentLoader.h" |
| 50 #include "core/loader/FrameLoadRequest.h" | 51 #include "core/loader/FrameLoadRequest.h" |
| 51 #include "core/page/Page.h" | 52 #include "core/page/Page.h" |
| 52 #include "core/page/ScopedPageLoadDeferrer.h" | 53 #include "core/page/ScopedPageLoadDeferrer.h" |
| 53 #include "core/paint/PaintLayer.h" | 54 #include "core/paint/PaintLayer.h" |
| 54 #include "core/paint/PaintLayerPainter.h" | 55 #include "core/paint/PaintLayerPainter.h" |
| 55 #include "core/timing/DOMWindowPerformance.h" | 56 #include "core/timing/DOMWindowPerformance.h" |
| 56 #include "core/timing/Performance.h" | 57 #include "core/timing/Performance.h" |
| 57 #include "platform/KeyboardCodes.h" | 58 #include "platform/KeyboardCodes.h" |
| 58 #include "platform/UserGestureIndicator.h" | 59 #include "platform/UserGestureIndicator.h" |
| (...skipping 4190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4249 .translate(-50, -55) | 4250 .translate(-50, -55) |
| 4250 .translate(50, 55) | 4251 .translate(50, 55) |
| 4251 .scale(1. / 2.f); | 4252 .scale(1. / 2.f); |
| 4252 EXPECT_EQ(expectedMatrix, | 4253 EXPECT_EQ(expectedMatrix, |
| 4253 webViewImpl->getDeviceEmulationTransformForTesting()); | 4254 webViewImpl->getDeviceEmulationTransformForTesting()); |
| 4254 // visibleContentRect doesn't change. | 4255 // visibleContentRect doesn't change. |
| 4255 EXPECT_EQ(IntRect(50, 55, 50, 75), | 4256 EXPECT_EQ(IntRect(50, 55, 50, 75), |
| 4256 *devToolsEmulator->visibleContentRectForPainting()); | 4257 *devToolsEmulator->visibleContentRectForPainting()); |
| 4257 } | 4258 } |
| 4258 | 4259 |
| 4260 static void configureAndroidCompositing(WebSettings* settings) { | |
| 4261 settings->setAcceleratedCompositingEnabled(true); | |
| 4262 settings->setPreferCompositingToLCDTextEnabled(true); | |
| 4263 settings->setViewportMetaEnabled(true); | |
| 4264 settings->setViewportEnabled(true); | |
| 4265 settings->setMainFrameResizesAreOrientationChanges(true); | |
| 4266 settings->setShrinksViewportContentToFit(true); | |
| 4267 } | |
| 4268 | |
| 4269 TEST_F(WebViewTest, ResizeCompositedAndFixedBackground) { | |
|
flackr
2016/10/31 18:17:55
We should test with/without root layer scrolls rig
bokan
2016/11/01 20:27:58
Good point, I've moved this to VisualViewportTest
| |
| 4270 bool originalInertTopControls = | |
| 4271 RuntimeEnabledFeatures::inertTopControlsEnabled(); | |
| 4272 RuntimeEnabledFeatures::setInertTopControlsEnabled(true); | |
| 4273 | |
| 4274 std::unique_ptr<FrameTestHelpers::TestWebViewClient> | |
| 4275 fakeCompositingWebViewClient = | |
| 4276 wrapUnique(new FrameTestHelpers::TestWebViewClient()); | |
| 4277 FrameTestHelpers::WebViewHelper webViewHelper; | |
| 4278 WebViewImpl* webViewImpl = webViewHelper.initialize( | |
| 4279 true, nullptr, fakeCompositingWebViewClient.get(), nullptr, | |
| 4280 &configureAndroidCompositing); | |
| 4281 | |
| 4282 int pageWidth = 640; | |
| 4283 int pageHeight = 480; | |
| 4284 float browserControlsHeight = 50.0f; | |
| 4285 int smallestHeight = pageHeight - browserControlsHeight; | |
| 4286 | |
| 4287 webViewImpl->resizeWithBrowserControls(WebSize(pageWidth, pageHeight), | |
| 4288 browserControlsHeight, false); | |
| 4289 | |
| 4290 URLTestHelpers::registerMockedURLLoad(toKURL("http://example.com/foo.png"), | |
| 4291 "white-1x1.png"); | |
| 4292 WebURL baseURL = URLTestHelpers::toKURL("http://example.com/"); | |
| 4293 FrameTestHelpers::loadHTMLString(webViewImpl->mainFrame(), | |
| 4294 "<!DOCTYPE html>" | |
| 4295 "<style>" | |
| 4296 " body {" | |
| 4297 " background: url('foo.png');" | |
| 4298 " background-attachment: fixed;" | |
| 4299 " background-size: cover;" | |
| 4300 " background-repeat: no-repeat;" | |
| 4301 " }" | |
| 4302 " div { height:1000px; width: 200px; }" | |
| 4303 "</style>" | |
| 4304 "<div></div>", | |
| 4305 baseURL); | |
| 4306 webViewImpl->updateAllLifecyclePhases(); | |
| 4307 | |
| 4308 Document* document = | |
| 4309 toLocalFrame(webViewImpl->page()->mainFrame())->document(); | |
| 4310 PaintLayerCompositor* compositor = document->layoutView()->compositor(); | |
| 4311 | |
| 4312 ASSERT_TRUE(compositor->needsFixedRootBackgroundLayer( | |
| 4313 document->layoutView()->layer())); | |
| 4314 ASSERT_TRUE(compositor->fixedRootBackgroundLayer()); | |
| 4315 | |
| 4316 ASSERT_EQ(pageWidth, compositor->fixedRootBackgroundLayer()->size().width()); | |
| 4317 ASSERT_EQ(pageHeight, | |
| 4318 compositor->fixedRootBackgroundLayer()->size().height()); | |
| 4319 ASSERT_EQ(pageWidth, document->view()->layoutSize().width()); | |
| 4320 ASSERT_EQ(smallestHeight, document->view()->layoutSize().height()); | |
| 4321 | |
| 4322 webViewImpl->resizeWithBrowserControls(WebSize(pageWidth, smallestHeight), | |
| 4323 browserControlsHeight, true); | |
| 4324 | |
| 4325 // The layout size should not have changed. | |
| 4326 ASSERT_EQ(pageWidth, document->view()->layoutSize().width()); | |
| 4327 ASSERT_EQ(smallestHeight, document->view()->layoutSize().height()); | |
| 4328 | |
| 4329 // The background layer's size should have changed though. | |
| 4330 EXPECT_EQ(pageWidth, compositor->fixedRootBackgroundLayer()->size().width()); | |
| 4331 EXPECT_EQ(smallestHeight, | |
| 4332 compositor->fixedRootBackgroundLayer()->size().height()); | |
|
flackr
2016/10/31 18:17:55
Is the invalidation tested?
bokan
2016/11/01 20:27:58
I figured out how to test invalidations. Added a s
| |
| 4333 | |
| 4334 webViewImpl->resizeWithBrowserControls(WebSize(pageWidth, pageHeight), | |
| 4335 browserControlsHeight, true); | |
| 4336 | |
| 4337 // The background layer's size should change again. | |
| 4338 EXPECT_EQ(pageWidth, compositor->fixedRootBackgroundLayer()->size().width()); | |
| 4339 EXPECT_EQ(pageHeight, | |
| 4340 compositor->fixedRootBackgroundLayer()->size().height()); | |
| 4341 | |
| 4342 RuntimeEnabledFeatures::setInertTopControlsEnabled(originalInertTopControls); | |
| 4343 } | |
| 4344 | |
| 4259 } // namespace blink | 4345 } // namespace blink |
| OLD | NEW |