| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009, 2010 Apple 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 // No tests fail if it's deleted. | 130 // No tests fail if it's deleted. |
| 131 setNeedsCompositingUpdate(CompositingUpdateRebuildTree); | 131 setNeedsCompositingUpdate(CompositingUpdateRebuildTree); |
| 132 setCompositingModeEnabled(true); | 132 setCompositingModeEnabled(true); |
| 133 } | 133 } |
| 134 } | 134 } |
| 135 | 135 |
| 136 bool RenderLayerCompositor::rootShouldAlwaysComposite() const | 136 bool RenderLayerCompositor::rootShouldAlwaysComposite() const |
| 137 { | 137 { |
| 138 if (!m_hasAcceleratedCompositing) | 138 if (!m_hasAcceleratedCompositing) |
| 139 return false; | 139 return false; |
| 140 return m_renderView.frame()->isMainFrame() || m_compositingReasonFinder.requ
iresCompositingForScrollableFrame(); | 140 return m_renderView.frame()->isMainFrame() || m_renderView.frame()->isLocalR
oot() || |
| 141 m_compositingReasonFinder.requiresCompositingForScrollableFrame(); |
| 141 } | 142 } |
| 142 | 143 |
| 143 void RenderLayerCompositor::updateAcceleratedCompositingSettings() | 144 void RenderLayerCompositor::updateAcceleratedCompositingSettings() |
| 144 { | 145 { |
| 145 m_compositingReasonFinder.updateTriggers(); | 146 m_compositingReasonFinder.updateTriggers(); |
| 146 m_hasAcceleratedCompositing = m_renderView.document().settings()->accelerate
dCompositingEnabled(); | 147 m_hasAcceleratedCompositing = m_renderView.document().settings()->accelerate
dCompositingEnabled(); |
| 147 m_rootShouldAlwaysCompositeDirty = true; | 148 m_rootShouldAlwaysCompositeDirty = true; |
| 148 } | 149 } |
| 149 | 150 |
| 150 bool RenderLayerCompositor::layerSquashingEnabled() const | 151 bool RenderLayerCompositor::layerSquashingEnabled() const |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 } | 244 } |
| 244 | 245 |
| 245 #endif | 246 #endif |
| 246 | 247 |
| 247 void RenderLayerCompositor::applyOverlayFullscreenVideoAdjustment() | 248 void RenderLayerCompositor::applyOverlayFullscreenVideoAdjustment() |
| 248 { | 249 { |
| 249 m_inOverlayFullscreenVideo = false; | 250 m_inOverlayFullscreenVideo = false; |
| 250 if (!m_rootContentLayer) | 251 if (!m_rootContentLayer) |
| 251 return; | 252 return; |
| 252 | 253 |
| 253 bool isMainFrame = m_renderView.frame()->isMainFrame(); | 254 bool isLocalRoot = m_renderView.frame()->isLocalRoot(); |
| 254 RenderVideo* video = findFullscreenVideoRenderer(m_renderView.document()); | 255 RenderVideo* video = findFullscreenVideoRenderer(m_renderView.document()); |
| 255 if (!video || !video->hasCompositedLayerMapping()) { | 256 if (!video || !video->hasCompositedLayerMapping()) { |
| 256 if (isMainFrame) { | 257 if (isLocalRoot) { |
| 257 GraphicsLayer* backgroundLayer = fixedRootBackgroundLayer(); | 258 GraphicsLayer* backgroundLayer = fixedRootBackgroundLayer(); |
| 258 if (backgroundLayer && !backgroundLayer->parent()) | 259 if (backgroundLayer && !backgroundLayer->parent()) |
| 259 rootFixedBackgroundsChanged(); | 260 rootFixedBackgroundsChanged(); |
| 260 } | 261 } |
| 261 return; | 262 return; |
| 262 } | 263 } |
| 263 | 264 |
| 264 GraphicsLayer* videoLayer = video->compositedLayerMapping()->mainGraphicsLay
er(); | 265 GraphicsLayer* videoLayer = video->compositedLayerMapping()->mainGraphicsLay
er(); |
| 265 | 266 |
| 266 // The fullscreen video has layer position equal to its enclosing frame's sc
roll position because fullscreen container is fixed-positioned. | 267 // The fullscreen video has layer position equal to its enclosing frame's sc
roll position because fullscreen container is fixed-positioned. |
| 267 // We should reset layer position here since we are going to reattach the la
yer at the very top level. | 268 // We should reset layer position here since we are going to reattach the la
yer at the very top level. |
| 268 videoLayer->setPosition(IntPoint()); | 269 videoLayer->setPosition(IntPoint()); |
| 269 | 270 |
| 270 // Only steal fullscreen video layer and clear all other layers if we are th
e main frame. | 271 // Only steal fullscreen video layer and clear all other layers if we are th
e main frame. |
| 271 if (!isMainFrame) | 272 if (!isLocalRoot) |
| 272 return; | 273 return; |
| 273 | 274 |
| 274 m_rootContentLayer->removeAllChildren(); | 275 m_rootContentLayer->removeAllChildren(); |
| 275 m_overflowControlsHostLayer->addChild(videoLayer); | 276 m_overflowControlsHostLayer->addChild(videoLayer); |
| 276 if (GraphicsLayer* backgroundLayer = fixedRootBackgroundLayer()) | 277 if (GraphicsLayer* backgroundLayer = fixedRootBackgroundLayer()) |
| 277 backgroundLayer->removeFromParent(); | 278 backgroundLayer->removeFromParent(); |
| 278 m_inOverlayFullscreenVideo = true; | 279 m_inOverlayFullscreenVideo = true; |
| 279 } | 280 } |
| 280 | 281 |
| 281 void RenderLayerCompositor::updateIfNeeded() | 282 void RenderLayerCompositor::updateIfNeeded() |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 } | 351 } |
| 351 | 352 |
| 352 for (unsigned i = 0; i < layersNeedingRepaint.size(); i++) { | 353 for (unsigned i = 0; i < layersNeedingRepaint.size(); i++) { |
| 353 RenderLayer* layer = layersNeedingRepaint[i]; | 354 RenderLayer* layer = layersNeedingRepaint[i]; |
| 354 layer->repainter().computeRepaintRectsIncludingNonCompositingDescendants
(); | 355 layer->repainter().computeRepaintRectsIncludingNonCompositingDescendants
(); |
| 355 | 356 |
| 356 repaintOnCompositingChange(layer); | 357 repaintOnCompositingChange(layer); |
| 357 } | 358 } |
| 358 | 359 |
| 359 // Inform the inspector that the layer tree has changed. | 360 // Inform the inspector that the layer tree has changed. |
| 360 if (m_renderView.frame()->isMainFrame()) | 361 if (m_renderView.frame()->isLocalRoot()) |
| 361 InspectorInstrumentation::layerTreeDidChange(m_renderView.frame()); | 362 InspectorInstrumentation::layerTreeDidChange(m_renderView.frame()); |
| 362 } | 363 } |
| 363 | 364 |
| 364 bool RenderLayerCompositor::allocateOrClearCompositedLayerMapping(RenderLayer* l
ayer, const CompositingStateTransitionType compositedLayerUpdate) | 365 bool RenderLayerCompositor::allocateOrClearCompositedLayerMapping(RenderLayer* l
ayer, const CompositingStateTransitionType compositedLayerUpdate) |
| 365 { | 366 { |
| 366 bool compositedLayerMappingChanged = false; | 367 bool compositedLayerMappingChanged = false; |
| 367 bool nonCompositedReasonChanged = updateLayerIfViewportConstrained(layer); | 368 bool nonCompositedReasonChanged = updateLayerIfViewportConstrained(layer); |
| 368 | 369 |
| 369 // FIXME: It would be nice to directly use the layer's compositing reason, | 370 // FIXME: It would be nice to directly use the layer's compositing reason, |
| 370 // but allocateOrClearCompositedLayerMapping also gets called without having
updated compositing | 371 // but allocateOrClearCompositedLayerMapping also gets called without having
updated compositing |
| (...skipping 10 matching lines...) Expand all Loading... |
| 381 // sorts of compositingState transitions. | 382 // sorts of compositingState transitions. |
| 382 layer->setLostGroupedMapping(false); | 383 layer->setLostGroupedMapping(false); |
| 383 layer->setGroupedMapping(0); | 384 layer->setGroupedMapping(0); |
| 384 | 385 |
| 385 // If we need to repaint, do so before allocating the compositedLayerMap
ping | 386 // If we need to repaint, do so before allocating the compositedLayerMap
ping |
| 386 repaintOnCompositingChange(layer); | 387 repaintOnCompositingChange(layer); |
| 387 layer->ensureCompositedLayerMapping(); | 388 layer->ensureCompositedLayerMapping(); |
| 388 compositedLayerMappingChanged = true; | 389 compositedLayerMappingChanged = true; |
| 389 | 390 |
| 390 // At this time, the ScrollingCooridnator only supports the top-level fr
ame. | 391 // At this time, the ScrollingCooridnator only supports the top-level fr
ame. |
| 391 if (layer->isRootLayer() && m_renderView.frame()->isMainFrame()) { | 392 if (layer->isRootLayer() && m_renderView.frame()->isLocalRoot()) { |
| 392 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoor
dinator()) | 393 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoor
dinator()) |
| 393 scrollingCoordinator->frameViewRootLayerDidChange(m_renderView.f
rameView()); | 394 scrollingCoordinator->frameViewRootLayerDidChange(m_renderView.f
rameView()); |
| 394 } | 395 } |
| 395 break; | 396 break; |
| 396 case RemoveOwnCompositedLayerMapping: | 397 case RemoveOwnCompositedLayerMapping: |
| 397 // PutInSquashingLayer means you might have to remove the composited layer m
apping first. | 398 // PutInSquashingLayer means you might have to remove the composited layer m
apping first. |
| 398 case PutInSquashingLayer: | 399 case PutInSquashingLayer: |
| 399 if (layer->hasCompositedLayerMapping()) { | 400 if (layer->hasCompositedLayerMapping()) { |
| 400 // If we're removing the compositedLayerMapping from a reflection, c
lear the source GraphicsLayer's pointer to | 401 // If we're removing the compositedLayerMapping from a reflection, c
lear the source GraphicsLayer's pointer to |
| 401 // its replica GraphicsLayer. In practice this should never happen b
ecause reflectee and reflection | 402 // its replica GraphicsLayer. In practice this should never happen b
ecause reflectee and reflection |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 { | 538 { |
| 538 FrameView* frameView = m_renderView.frameView(); | 539 FrameView* frameView = m_renderView.frameView(); |
| 539 IntPoint scrollPosition = frameView->scrollPosition(); | 540 IntPoint scrollPosition = frameView->scrollPosition(); |
| 540 | 541 |
| 541 if (!m_scrollLayer) | 542 if (!m_scrollLayer) |
| 542 return; | 543 return; |
| 543 | 544 |
| 544 bool scrollingCoordinatorHandlesOffset = false; | 545 bool scrollingCoordinatorHandlesOffset = false; |
| 545 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator(
)) { | 546 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator(
)) { |
| 546 if (Settings* settings = m_renderView.document().settings()) { | 547 if (Settings* settings = m_renderView.document().settings()) { |
| 547 if (m_renderView.frame()->isMainFrame() || settings->compositedScrol
lingForFramesEnabled()) | 548 if (m_renderView.frame()->isLocalRoot() || settings->compositedScrol
lingForFramesEnabled()) |
| 548 scrollingCoordinatorHandlesOffset = scrollingCoordinator->scroll
ableAreaScrollLayerDidChange(frameView); | 549 scrollingCoordinatorHandlesOffset = scrollingCoordinator->scroll
ableAreaScrollLayerDidChange(frameView); |
| 549 } | 550 } |
| 550 } | 551 } |
| 551 | 552 |
| 552 // Scroll position = scroll minimum + scroll offset. Adjust the layer's | 553 // Scroll position = scroll minimum + scroll offset. Adjust the layer's |
| 553 // position to handle whatever the scroll coordinator isn't handling. | 554 // position to handle whatever the scroll coordinator isn't handling. |
| 554 // The minimum scroll position is non-zero for RTL pages with overflow. | 555 // The minimum scroll position is non-zero for RTL pages with overflow. |
| 555 if (scrollingCoordinatorHandlesOffset) | 556 if (scrollingCoordinatorHandlesOffset) |
| 556 m_scrollLayer->setPosition(-frameView->minimumScrollPosition()); | 557 m_scrollLayer->setPosition(-frameView->minimumScrollPosition()); |
| 557 else | 558 else |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 | 724 |
| 724 void RenderLayerCompositor::setIsInWindow(bool isInWindow) | 725 void RenderLayerCompositor::setIsInWindow(bool isInWindow) |
| 725 { | 726 { |
| 726 if (!staleInCompositingMode()) | 727 if (!staleInCompositingMode()) |
| 727 return; | 728 return; |
| 728 | 729 |
| 729 if (isInWindow) { | 730 if (isInWindow) { |
| 730 if (m_rootLayerAttachment != RootLayerUnattached) | 731 if (m_rootLayerAttachment != RootLayerUnattached) |
| 731 return; | 732 return; |
| 732 | 733 |
| 733 RootLayerAttachment attachment = m_renderView.frame()->isMainFrame() ? R
ootLayerAttachedViaChromeClient : RootLayerAttachedViaEnclosingFrame; | 734 RootLayerAttachment attachment = m_renderView.frame()->isLocalRoot() ? R
ootLayerAttachedViaChromeClient : RootLayerAttachedViaEnclosingFrame; |
| 734 attachRootLayer(attachment); | 735 attachRootLayer(attachment); |
| 735 } else { | 736 } else { |
| 736 if (m_rootLayerAttachment == RootLayerUnattached) | 737 if (m_rootLayerAttachment == RootLayerUnattached) |
| 737 return; | 738 return; |
| 738 | 739 |
| 739 detachRootLayer(); | 740 detachRootLayer(); |
| 740 } | 741 } |
| 741 } | 742 } |
| 742 | 743 |
| 743 void RenderLayerCompositor::updateRootLayerPosition() | 744 void RenderLayerCompositor::updateRootLayerPosition() |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 945 | 946 |
| 946 bool RenderLayerCompositor::requiresScrollCornerLayer() const | 947 bool RenderLayerCompositor::requiresScrollCornerLayer() const |
| 947 { | 948 { |
| 948 FrameView* view = m_renderView.frameView(); | 949 FrameView* view = m_renderView.frameView(); |
| 949 return shouldCompositeOverflowControls(view) && view->isScrollCornerVisible(
); | 950 return shouldCompositeOverflowControls(view) && view->isScrollCornerVisible(
); |
| 950 } | 951 } |
| 951 | 952 |
| 952 void RenderLayerCompositor::updateOverflowControlsLayers() | 953 void RenderLayerCompositor::updateOverflowControlsLayers() |
| 953 { | 954 { |
| 954 #if USE(RUBBER_BANDING) | 955 #if USE(RUBBER_BANDING) |
| 955 if (m_renderView.frame()->isMainFrame()) { | 956 if (m_renderView.frame()->isLocalRoot()) { |
| 956 if (!m_layerForOverhangShadow) { | 957 if (!m_layerForOverhangShadow) { |
| 957 m_layerForOverhangShadow = GraphicsLayer::create(graphicsLayerFactor
y(), this); | 958 m_layerForOverhangShadow = GraphicsLayer::create(graphicsLayerFactor
y(), this); |
| 958 OverscrollTheme::theme()->setUpOverhangShadowLayer(m_layerForOverhan
gShadow.get()); | 959 OverscrollTheme::theme()->setUpOverhangShadowLayer(m_layerForOverhan
gShadow.get()); |
| 959 OverscrollTheme::theme()->updateOverhangShadowLayer(m_layerForOverha
ngShadow.get(), m_rootContentLayer.get()); | 960 OverscrollTheme::theme()->updateOverhangShadowLayer(m_layerForOverha
ngShadow.get(), m_rootContentLayer.get()); |
| 960 m_scrollLayer->addChild(m_layerForOverhangShadow.get()); | 961 m_scrollLayer->addChild(m_layerForOverhangShadow.get()); |
| 961 } | 962 } |
| 962 } else { | 963 } else { |
| 963 ASSERT(!m_layerForOverhangShadow); | 964 ASSERT(!m_layerForOverhangShadow); |
| 964 } | 965 } |
| 965 #endif | 966 #endif |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1011 } else if (m_layerForScrollCorner) { | 1012 } else if (m_layerForScrollCorner) { |
| 1012 m_layerForScrollCorner->removeFromParent(); | 1013 m_layerForScrollCorner->removeFromParent(); |
| 1013 m_layerForScrollCorner = nullptr; | 1014 m_layerForScrollCorner = nullptr; |
| 1014 } | 1015 } |
| 1015 | 1016 |
| 1016 m_renderView.frameView()->positionScrollbarLayers(); | 1017 m_renderView.frameView()->positionScrollbarLayers(); |
| 1017 } | 1018 } |
| 1018 | 1019 |
| 1019 void RenderLayerCompositor::ensureRootLayer() | 1020 void RenderLayerCompositor::ensureRootLayer() |
| 1020 { | 1021 { |
| 1021 RootLayerAttachment expectedAttachment = m_renderView.frame()->isMainFrame()
? RootLayerAttachedViaChromeClient : RootLayerAttachedViaEnclosingFrame; | 1022 RootLayerAttachment expectedAttachment = m_renderView.frame()->isLocalRoot()
? RootLayerAttachedViaChromeClient : RootLayerAttachedViaEnclosingFrame; |
| 1022 if (expectedAttachment == m_rootLayerAttachment) | 1023 if (expectedAttachment == m_rootLayerAttachment) |
| 1023 return; | 1024 return; |
| 1024 | 1025 |
| 1025 if (!m_rootContentLayer) { | 1026 if (!m_rootContentLayer) { |
| 1026 m_rootContentLayer = GraphicsLayer::create(graphicsLayerFactory(), this)
; | 1027 m_rootContentLayer = GraphicsLayer::create(graphicsLayerFactory(), this)
; |
| 1027 IntRect overflowRect = m_renderView.pixelSnappedLayoutOverflowRect(); | 1028 IntRect overflowRect = m_renderView.pixelSnappedLayoutOverflowRect(); |
| 1028 m_rootContentLayer->setSize(FloatSize(overflowRect.maxX(), overflowRect.
maxY())); | 1029 m_rootContentLayer->setSize(FloatSize(overflowRect.maxX(), overflowRect.
maxY())); |
| 1029 m_rootContentLayer->setPosition(FloatPoint()); | 1030 m_rootContentLayer->setPosition(FloatPoint()); |
| 1030 m_rootContentLayer->setOwnerNodeId(InspectorNodeIds::idForNode(m_renderV
iew.generatingNode())); | 1031 m_rootContentLayer->setOwnerNodeId(InspectorNodeIds::idForNode(m_renderV
iew.generatingNode())); |
| 1031 | 1032 |
| 1032 // Need to clip to prevent transformed content showing outside this fram
e | 1033 // Need to clip to prevent transformed content showing outside this fram
e |
| 1033 m_rootContentLayer->setMasksToBounds(true); | 1034 m_rootContentLayer->setMasksToBounds(true); |
| 1034 } | 1035 } |
| 1035 | 1036 |
| 1036 if (!m_overflowControlsHostLayer) { | 1037 if (!m_overflowControlsHostLayer) { |
| 1037 ASSERT(!m_scrollLayer); | 1038 ASSERT(!m_scrollLayer); |
| 1038 ASSERT(!m_containerLayer); | 1039 ASSERT(!m_containerLayer); |
| 1039 | 1040 |
| 1040 // Create a layer to host the clipping layer and the overflow controls l
ayers. | 1041 // Create a layer to host the clipping layer and the overflow controls l
ayers. |
| 1041 m_overflowControlsHostLayer = GraphicsLayer::create(graphicsLayerFactory
(), this); | 1042 m_overflowControlsHostLayer = GraphicsLayer::create(graphicsLayerFactory
(), this); |
| 1042 | 1043 |
| 1043 // Create a clipping layer if this is an iframe or settings require to c
lip. | 1044 // Create a clipping layer if this is an iframe or settings require to c
lip. |
| 1044 m_containerLayer = GraphicsLayer::create(graphicsLayerFactory(), this); | 1045 m_containerLayer = GraphicsLayer::create(graphicsLayerFactory(), this); |
| 1045 bool containerMasksToBounds = !m_renderView.frame()->isMainFrame(); | 1046 bool containerMasksToBounds = !m_renderView.frame()->isLocalRoot(); |
| 1046 if (Settings* settings = m_renderView.document().settings()) { | 1047 if (Settings* settings = m_renderView.document().settings()) { |
| 1047 if (settings->mainFrameClipsContent()) | 1048 if (settings->mainFrameClipsContent()) |
| 1048 containerMasksToBounds = true; | 1049 containerMasksToBounds = true; |
| 1049 } | 1050 } |
| 1050 m_containerLayer->setMasksToBounds(containerMasksToBounds); | 1051 m_containerLayer->setMasksToBounds(containerMasksToBounds); |
| 1051 | 1052 |
| 1052 m_scrollLayer = GraphicsLayer::create(graphicsLayerFactory(), this); | 1053 m_scrollLayer = GraphicsLayer::create(graphicsLayerFactory(), this); |
| 1053 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordina
tor()) | 1054 if (ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordina
tor()) |
| 1054 scrollingCoordinator->setLayerIsContainerForFixedPositionLayers(m_sc
rollLayer.get(), true); | 1055 scrollingCoordinator->setLayerIsContainerForFixedPositionLayers(m_sc
rollLayer.get(), true); |
| 1055 | 1056 |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1232 } else if (graphicsLayer == m_scrollLayer.get()) { | 1233 } else if (graphicsLayer == m_scrollLayer.get()) { |
| 1233 name = "LocalFrame Scrolling Layer"; | 1234 name = "LocalFrame Scrolling Layer"; |
| 1234 } else { | 1235 } else { |
| 1235 ASSERT_NOT_REACHED(); | 1236 ASSERT_NOT_REACHED(); |
| 1236 } | 1237 } |
| 1237 | 1238 |
| 1238 return name; | 1239 return name; |
| 1239 } | 1240 } |
| 1240 | 1241 |
| 1241 } // namespace WebCore | 1242 } // namespace WebCore |
| OLD | NEW |