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 2768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2779 break; | 2779 break; |
2780 | 2780 |
2781 default: | 2781 default: |
2782 NOTIMPLEMENTED(); | 2782 NOTIMPLEMENTED(); |
2783 break; | 2783 break; |
2784 } | 2784 } |
2785 } | 2785 } |
2786 | 2786 |
2787 bool WebViewImpl::isAcceleratedCompositingActive() const | 2787 bool WebViewImpl::isAcceleratedCompositingActive() const |
2788 { | 2788 { |
2789 // For SPv2, accelerated compositing is managed by the | |
2790 // PaintArtifactCompositor. | |
2791 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | |
2792 return m_paintArtifactCompositor.rootLayer(); | |
2793 | |
2794 return m_rootLayer; | 2789 return m_rootLayer; |
2795 } | 2790 } |
2796 | 2791 |
2797 void WebViewImpl::willCloseLayerTreeView() | 2792 void WebViewImpl::willCloseLayerTreeView() |
2798 { | 2793 { |
2799 if (m_linkHighlightsTimeline) { | 2794 if (m_linkHighlightsTimeline) { |
2800 m_linkHighlights.clear(); | 2795 m_linkHighlights.clear(); |
2801 detachCompositorAnimationTimeline(m_linkHighlightsTimeline.get()); | 2796 detachCompositorAnimationTimeline(m_linkHighlightsTimeline.get()); |
2802 m_linkHighlightsTimeline.reset(); | 2797 m_linkHighlightsTimeline.reset(); |
2803 } | 2798 } |
2804 | 2799 |
2805 if (m_layerTreeView) | 2800 if (m_layerTreeView) |
2806 page()->willCloseLayerTreeView(*m_layerTreeView); | 2801 page()->willCloseLayerTreeView(*m_layerTreeView); |
2807 | 2802 |
2808 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | 2803 setRootLayer(nullptr); |
2809 detachPaintArtifactCompositor(); | |
2810 else | |
2811 setRootGraphicsLayer(nullptr); | |
2812 | 2804 |
2813 m_mutator = nullptr; | 2805 m_mutator = nullptr; |
2814 m_layerTreeView = nullptr; | 2806 m_layerTreeView = nullptr; |
2815 } | 2807 } |
2816 | 2808 |
2817 void WebViewImpl::didAcquirePointerLock() | 2809 void WebViewImpl::didAcquirePointerLock() |
2818 { | 2810 { |
2819 if (page()) | 2811 if (page()) |
2820 page()->pointerLockController().didAcquirePointerLock(); | 2812 page()->pointerLockController().didAcquirePointerLock(); |
2821 } | 2813 } |
(...skipping 1413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4235 // the mehtod. | 4227 // the mehtod. |
4236 visualViewport.setScrollLayerOnScrollbars(layoutViewportWebLayer); | 4228 visualViewport.setScrollLayerOnScrollbars(layoutViewportWebLayer); |
4237 | 4229 |
4238 m_layerTreeView->registerViewportLayers( | 4230 m_layerTreeView->registerViewportLayers( |
4239 visualViewport.overscrollElasticityLayer()->platformLayer(), | 4231 visualViewport.overscrollElasticityLayer()->platformLayer(), |
4240 visualViewport.pageScaleLayer()->platformLayer(), | 4232 visualViewport.pageScaleLayer()->platformLayer(), |
4241 visualViewport.scrollLayer()->platformLayer(), | 4233 visualViewport.scrollLayer()->platformLayer(), |
4242 layoutViewportWebLayer); | 4234 layoutViewportWebLayer); |
4243 } | 4235 } |
4244 | 4236 |
4245 void WebViewImpl::setRootGraphicsLayer(GraphicsLayer* layer) | 4237 void WebViewImpl::setRootGraphicsLayer(GraphicsLayer* graphicsLayer) |
4246 { | 4238 { |
4247 if (!m_layerTreeView) | 4239 if (!m_layerTreeView) |
4248 return; | 4240 return; |
4249 | 4241 |
4250 // In SPv2, we attach layers via PaintArtifactCompositor, rather than | 4242 // In SPv2, setRootLayer is used instead. |
4251 // supplying a root GraphicsLayer from PaintLayerCompositor. | |
4252 DCHECK(!RuntimeEnabledFeatures::slimmingPaintV2Enabled()); | 4243 DCHECK(!RuntimeEnabledFeatures::slimmingPaintV2Enabled()); |
4253 | 4244 |
4254 VisualViewport& visualViewport = page()->frameHost().visualViewport(); | 4245 VisualViewport& visualViewport = page()->frameHost().visualViewport(); |
4255 visualViewport.attachToLayerTree(layer); | 4246 visualViewport.attachToLayerTree(graphicsLayer); |
4256 if (layer) { | 4247 if (graphicsLayer) { |
4257 m_rootGraphicsLayer = visualViewport.rootGraphicsLayer(); | 4248 m_rootGraphicsLayer = visualViewport.rootGraphicsLayer(); |
4258 m_visualViewportContainerLayer = visualViewport.containerLayer(); | 4249 m_visualViewportContainerLayer = visualViewport.containerLayer(); |
4259 m_rootLayer = m_rootGraphicsLayer->platformLayer(); | 4250 m_rootLayer = m_rootGraphicsLayer->platformLayer(); |
4260 updateRootLayerTransform(); | 4251 updateRootLayerTransform(); |
4261 m_layerTreeView->setRootLayer(*m_rootLayer); | 4252 m_layerTreeView->setRootLayer(*m_rootLayer); |
4262 // We register viewport layers here since there may not be a layer | 4253 // We register viewport layers here since there may not be a layer |
4263 // tree view prior to this point. | 4254 // tree view prior to this point. |
4264 registerViewportLayersWithCompositor(); | 4255 registerViewportLayersWithCompositor(); |
4265 | 4256 |
4266 // TODO(enne): Work around page visibility changes not being | 4257 // TODO(enne): Work around page visibility changes not being |
4267 // propagated to the WebView in some circumstances. This needs to | 4258 // propagated to the WebView in some circumstances. This needs to |
4268 // be refreshed here when setting a new root layer to avoid being | 4259 // be refreshed here when setting a new root layer to avoid being |
4269 // stuck in a presumed incorrectly invisible state. | 4260 // stuck in a presumed incorrectly invisible state. |
4270 m_layerTreeView->setVisible(page()->isPageVisible()); | 4261 m_layerTreeView->setVisible(page()->isPageVisible()); |
4271 } else { | 4262 } else { |
4272 m_rootGraphicsLayer = nullptr; | 4263 m_rootGraphicsLayer = nullptr; |
4273 m_visualViewportContainerLayer = nullptr; | 4264 m_visualViewportContainerLayer = nullptr; |
4274 m_rootLayer = nullptr; | 4265 m_rootLayer = nullptr; |
4275 // This means that we're transitioning to a new page. Suppress | 4266 // This means that we're transitioning to a new page. Suppress |
4276 // commits until Blink generates invalidations so we don't | 4267 // commits until Blink generates invalidations so we don't |
4277 // attempt to paint too early in the next page load. | 4268 // attempt to paint too early in the next page load. |
4278 m_layerTreeView->setDeferCommits(true); | 4269 m_layerTreeView->setDeferCommits(true); |
4279 m_layerTreeView->clearRootLayer(); | 4270 m_layerTreeView->clearRootLayer(); |
4280 m_layerTreeView->clearViewportLayers(); | 4271 m_layerTreeView->clearViewportLayers(); |
4281 if (WebDevToolsAgentImpl* devTools = mainFrameDevToolsAgentImpl()) | 4272 if (WebDevToolsAgentImpl* devTools = mainFrameDevToolsAgentImpl()) |
4282 devTools->rootLayerCleared(); | 4273 devTools->rootLayerCleared(); |
4283 } | 4274 } |
4284 } | 4275 } |
4285 | 4276 |
| 4277 void WebViewImpl::setRootLayer(WebLayer* layer) |
| 4278 { |
| 4279 if (!m_layerTreeView) |
| 4280 return; |
| 4281 |
| 4282 if (layer) { |
| 4283 m_rootLayer = layer; |
| 4284 m_layerTreeView->setRootLayer(*m_rootLayer); |
| 4285 m_layerTreeView->setVisible(page()->isPageVisible()); |
| 4286 } else { |
| 4287 m_rootLayer = nullptr; |
| 4288 // This means that we're transitioning to a new page. Suppress |
| 4289 // commits until Blink generates invalidations so we don't |
| 4290 // attempt to paint too early in the next page load. |
| 4291 m_layerTreeView->setDeferCommits(true); |
| 4292 m_layerTreeView->clearRootLayer(); |
| 4293 m_layerTreeView->clearViewportLayers(); |
| 4294 if (WebDevToolsAgentImpl* devTools = mainFrameDevToolsAgentImpl()) |
| 4295 devTools->rootLayerCleared(); |
| 4296 } |
| 4297 } |
| 4298 |
4286 void WebViewImpl::invalidateRect(const IntRect& rect) | 4299 void WebViewImpl::invalidateRect(const IntRect& rect) |
4287 { | 4300 { |
4288 if (m_layerTreeView) { | 4301 if (m_layerTreeView) { |
4289 updateLayerTreeViewport(); | 4302 updateLayerTreeViewport(); |
4290 } else if (m_client) { | 4303 } else if (m_client) { |
4291 // This is only for WebViewPlugin. | 4304 // This is only for WebViewPlugin. |
4292 m_client->widgetClient()->didInvalidateRect(rect); | 4305 m_client->widgetClient()->didInvalidateRect(rect); |
4293 } | 4306 } |
4294 } | 4307 } |
4295 | 4308 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4348 m_page->layerTreeViewInitialized(*m_layerTreeView); | 4361 m_page->layerTreeViewInitialized(*m_layerTreeView); |
4349 | 4362 |
4350 // FIXME: only unittests, click to play, Android printing, and printing (for
headers and footers) | 4363 // FIXME: only unittests, click to play, Android printing, and printing (for
headers and footers) |
4351 // make this assert necessary. We should make them not hit this code and the
n delete allowsBrokenNullLayerTreeView. | 4364 // make this assert necessary. We should make them not hit this code and the
n delete allowsBrokenNullLayerTreeView. |
4352 DCHECK(m_layerTreeView || !m_client || m_client->widgetClient()->allowsBroke
nNullLayerTreeView()); | 4365 DCHECK(m_layerTreeView || !m_client || m_client->widgetClient()->allowsBroke
nNullLayerTreeView()); |
4353 | 4366 |
4354 if (Platform::current()->isThreadedAnimationEnabled() && m_layerTreeView) { | 4367 if (Platform::current()->isThreadedAnimationEnabled() && m_layerTreeView) { |
4355 m_linkHighlightsTimeline = CompositorAnimationTimeline::create(); | 4368 m_linkHighlightsTimeline = CompositorAnimationTimeline::create(); |
4356 attachCompositorAnimationTimeline(m_linkHighlightsTimeline.get()); | 4369 attachCompositorAnimationTimeline(m_linkHighlightsTimeline.get()); |
4357 } | 4370 } |
4358 | |
4359 if (RuntimeEnabledFeatures::slimmingPaintV2Enabled()) | |
4360 attachPaintArtifactCompositor(); | |
4361 } | 4371 } |
4362 | 4372 |
4363 void WebViewImpl::applyViewportDeltas( | 4373 void WebViewImpl::applyViewportDeltas( |
4364 const WebFloatSize& visualViewportDelta, | 4374 const WebFloatSize& visualViewportDelta, |
4365 // TODO(bokan): This parameter is to be removed but requires adjusting many | 4375 // TODO(bokan): This parameter is to be removed but requires adjusting many |
4366 // callsites. | 4376 // callsites. |
4367 const WebFloatSize&, | 4377 const WebFloatSize&, |
4368 const WebFloatSize& elasticOverscrollDelta, | 4378 const WebFloatSize& elasticOverscrollDelta, |
4369 float pageScaleDelta, | 4379 float pageScaleDelta, |
4370 float topControlsShownRatioDelta) | 4380 float topControlsShownRatioDelta) |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4548 { | 4558 { |
4549 if (m_pageColorOverlay) | 4559 if (m_pageColorOverlay) |
4550 m_pageColorOverlay->update(); | 4560 m_pageColorOverlay->update(); |
4551 if (InspectorOverlay* overlay = inspectorOverlay()) { | 4561 if (InspectorOverlay* overlay = inspectorOverlay()) { |
4552 PageOverlay* inspectorPageOverlay = overlay->pageOverlay(); | 4562 PageOverlay* inspectorPageOverlay = overlay->pageOverlay(); |
4553 if (inspectorPageOverlay) | 4563 if (inspectorPageOverlay) |
4554 inspectorPageOverlay->update(); | 4564 inspectorPageOverlay->update(); |
4555 } | 4565 } |
4556 } | 4566 } |
4557 | 4567 |
4558 void WebViewImpl::attachPaintArtifactCompositor() | |
4559 { | |
4560 if (!m_layerTreeView) | |
4561 return; | |
4562 | |
4563 // Otherwise, PaintLayerCompositor is expected to supply a root | |
4564 // GraphicsLayer via setRootGraphicsLayer. | |
4565 DCHECK(RuntimeEnabledFeatures::slimmingPaintV2Enabled()); | |
4566 | |
4567 // TODO(jbroman): This should probably have hookups for overlays, visual | |
4568 // viewport, etc. | |
4569 | |
4570 WebLayer* rootLayer = m_paintArtifactCompositor.getWebLayer(); | |
4571 DCHECK(rootLayer); | |
4572 m_layerTreeView->setRootLayer(*rootLayer); | |
4573 | |
4574 // TODO(jbroman): This is cargo-culted from setRootGraphicsLayer. Is it | |
4575 // necessary? | |
4576 m_layerTreeView->setVisible(page()->isPageVisible()); | |
4577 } | |
4578 | |
4579 void WebViewImpl::detachPaintArtifactCompositor() | |
4580 { | |
4581 if (!m_layerTreeView) | |
4582 return; | |
4583 | |
4584 m_layerTreeView->setDeferCommits(true); | |
4585 m_layerTreeView->clearRootLayer(); | |
4586 } | |
4587 | |
4588 float WebViewImpl::deviceScaleFactor() const | 4568 float WebViewImpl::deviceScaleFactor() const |
4589 { | 4569 { |
4590 // TODO(oshima): Investigate if this should return the ScreenInfo's scale fa
ctor rather than | 4570 // TODO(oshima): Investigate if this should return the ScreenInfo's scale fa
ctor rather than |
4591 // page's scale factor, which can be 1 in use-zoom-for-dsf mode. | 4571 // page's scale factor, which can be 1 in use-zoom-for-dsf mode. |
4592 if (!page()) | 4572 if (!page()) |
4593 return 1; | 4573 return 1; |
4594 | 4574 |
4595 return page()->deviceScaleFactor(); | 4575 return page()->deviceScaleFactor(); |
4596 } | 4576 } |
4597 | 4577 |
4598 LocalFrame* WebViewImpl::focusedLocalFrameInWidget() const | 4578 LocalFrame* WebViewImpl::focusedLocalFrameInWidget() const |
4599 { | 4579 { |
4600 if (!mainFrameImpl()) | 4580 if (!mainFrameImpl()) |
4601 return nullptr; | 4581 return nullptr; |
4602 | 4582 |
4603 LocalFrame* focusedFrame = toLocalFrame(focusedCoreFrame()); | 4583 LocalFrame* focusedFrame = toLocalFrame(focusedCoreFrame()); |
4604 if (focusedFrame->localFrameRoot() != mainFrameImpl()->frame()) | 4584 if (focusedFrame->localFrameRoot() != mainFrameImpl()->frame()) |
4605 return nullptr; | 4585 return nullptr; |
4606 return focusedFrame; | 4586 return focusedFrame; |
4607 } | 4587 } |
4608 | 4588 |
4609 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const | 4589 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const |
4610 { | 4590 { |
4611 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr; | 4591 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr; |
4612 } | 4592 } |
4613 | 4593 |
4614 } // namespace blink | 4594 } // namespace blink |
OLD | NEW |