| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009, 2010, 2011 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 21 matching lines...) Expand all Loading... |
| 32 #include "RuntimeEnabledFeatures.h" | 32 #include "RuntimeEnabledFeatures.h" |
| 33 #include "core/animation/ActiveAnimations.h" | 33 #include "core/animation/ActiveAnimations.h" |
| 34 #include "core/fetch/ImageResource.h" | 34 #include "core/fetch/ImageResource.h" |
| 35 #include "core/html/HTMLIFrameElement.h" | 35 #include "core/html/HTMLIFrameElement.h" |
| 36 #include "core/html/HTMLMediaElement.h" | 36 #include "core/html/HTMLMediaElement.h" |
| 37 #include "core/html/canvas/CanvasRenderingContext.h" | 37 #include "core/html/canvas/CanvasRenderingContext.h" |
| 38 #include "core/inspector/InspectorInstrumentation.h" | 38 #include "core/inspector/InspectorInstrumentation.h" |
| 39 #include "core/page/Chrome.h" | 39 #include "core/page/Chrome.h" |
| 40 #include "core/frame/FrameView.h" | 40 #include "core/frame/FrameView.h" |
| 41 #include "core/frame/Settings.h" | 41 #include "core/frame/Settings.h" |
| 42 #include "core/frame/animation/AnimationController.h" | |
| 43 #include "core/page/scrolling/ScrollingCoordinator.h" | 42 #include "core/page/scrolling/ScrollingCoordinator.h" |
| 44 #include "core/plugins/PluginView.h" | 43 #include "core/plugins/PluginView.h" |
| 45 #include "core/rendering/FilterEffectRenderer.h" | 44 #include "core/rendering/FilterEffectRenderer.h" |
| 46 #include "core/rendering/RenderApplet.h" | 45 #include "core/rendering/RenderApplet.h" |
| 47 #include "core/rendering/RenderEmbeddedObject.h" | 46 #include "core/rendering/RenderEmbeddedObject.h" |
| 48 #include "core/rendering/RenderIFrame.h" | 47 #include "core/rendering/RenderIFrame.h" |
| 49 #include "core/rendering/RenderImage.h" | 48 #include "core/rendering/RenderImage.h" |
| 50 #include "core/rendering/RenderLayerCompositor.h" | 49 #include "core/rendering/RenderLayerCompositor.h" |
| 51 #include "core/rendering/RenderLayerStackingNodeIterator.h" | 50 #include "core/rendering/RenderLayerStackingNodeIterator.h" |
| 52 #include "core/rendering/RenderVideo.h" | 51 #include "core/rendering/RenderVideo.h" |
| 53 #include "core/rendering/RenderView.h" | 52 #include "core/rendering/RenderView.h" |
| 54 #include "core/rendering/animation/WebAnimationProvider.h" | |
| 55 #include "core/rendering/style/KeyframeList.h" | 53 #include "core/rendering/style/KeyframeList.h" |
| 56 #include "platform/LengthFunctions.h" | 54 #include "platform/LengthFunctions.h" |
| 57 #include "platform/fonts/FontCache.h" | 55 #include "platform/fonts/FontCache.h" |
| 58 #include "platform/graphics/GraphicsContext.h" | 56 #include "platform/graphics/GraphicsContext.h" |
| 59 #include "wtf/CurrentTime.h" | 57 #include "wtf/CurrentTime.h" |
| 60 #include "wtf/text/StringBuilder.h" | 58 #include "wtf/text/StringBuilder.h" |
| 61 | 59 |
| 62 using namespace std; | 60 using namespace std; |
| 63 | 61 |
| 64 namespace WebCore { | 62 namespace WebCore { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 { | 147 { |
| 150 Page* page = layer->renderer()->frame()->page(); | 148 Page* page = layer->renderer()->frame()->page(); |
| 151 if (!page) | 149 if (!page) |
| 152 return 0; | 150 return 0; |
| 153 | 151 |
| 154 return page->scrollingCoordinator(); | 152 return page->scrollingCoordinator(); |
| 155 } | 153 } |
| 156 | 154 |
| 157 CompositedLayerMapping::CompositedLayerMapping(RenderLayer* layer) | 155 CompositedLayerMapping::CompositedLayerMapping(RenderLayer* layer) |
| 158 : m_owningLayer(layer) | 156 : m_owningLayer(layer) |
| 159 , m_animationProvider(adoptPtr(new WebAnimationProvider)) | |
| 160 , m_artificiallyInflatedBounds(false) | 157 , m_artificiallyInflatedBounds(false) |
| 161 , m_isMainFrameRenderViewLayer(false) | 158 , m_isMainFrameRenderViewLayer(false) |
| 162 , m_requiresOwnBackingStoreForIntrinsicReasons(true) | 159 , m_requiresOwnBackingStoreForIntrinsicReasons(true) |
| 163 , m_requiresOwnBackingStoreForAncestorReasons(true) | 160 , m_requiresOwnBackingStoreForAncestorReasons(true) |
| 164 , m_canCompositeFilters(false) | 161 , m_canCompositeFilters(false) |
| 165 , m_backgroundLayerPaintsFixedRootBackground(false) | 162 , m_backgroundLayerPaintsFixedRootBackground(false) |
| 166 { | 163 { |
| 167 if (layer->isRootLayer() && renderer()->frame()->isMainFrame()) | 164 if (layer->isRootLayer() && renderer()->frame()->isMainFrame()) |
| 168 m_isMainFrameRenderViewLayer = true; | 165 m_isMainFrameRenderViewLayer = true; |
| 169 | 166 |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 } | 611 } |
| 615 | 612 |
| 616 void CompositedLayerMapping::updateGraphicsLayerGeometry() | 613 void CompositedLayerMapping::updateGraphicsLayerGeometry() |
| 617 { | 614 { |
| 618 // If we haven't built z-order lists yet, wait until later. | 615 // If we haven't built z-order lists yet, wait until later. |
| 619 if (m_owningLayer->stackingNode()->isStackingContainer() && m_owningLayer->s
tackingNode()->zOrderListsDirty()) | 616 if (m_owningLayer->stackingNode()->isStackingContainer() && m_owningLayer->s
tackingNode()->zOrderListsDirty()) |
| 620 return; | 617 return; |
| 621 | 618 |
| 622 // Set transform property, if it is not animating. We have to do this here b
ecause the transform | 619 // Set transform property, if it is not animating. We have to do this here b
ecause the transform |
| 623 // is affected by the layer dimensions. | 620 // is affected by the layer dimensions. |
| 624 if (RuntimeEnabledFeatures::webAnimationsCSSEnabled() | 621 if (!RuntimeEnabledFeatures::webAnimationsCSSEnabled() || !hasActiveAnimatio
nsOnCompositor(*renderer(), CSSPropertyWebkitTransform)) |
| 625 ? !hasActiveAnimationsOnCompositor(*renderer(), CSSPropertyWebkitTransfo
rm) | |
| 626 : !renderer()->animation().isRunningAcceleratedAnimationOnRenderer(rende
rer(), CSSPropertyWebkitTransform)) | |
| 627 updateTransform(renderer()->style()); | 622 updateTransform(renderer()->style()); |
| 628 | 623 |
| 629 // Set opacity, if it is not animating. | 624 // Set opacity, if it is not animating. |
| 630 if (RuntimeEnabledFeatures::webAnimationsCSSEnabled() | 625 if (!RuntimeEnabledFeatures::webAnimationsCSSEnabled() || !hasActiveAnimatio
nsOnCompositor(*renderer(), CSSPropertyOpacity)) |
| 631 ? !hasActiveAnimationsOnCompositor(*renderer(), CSSPropertyOpacity) | |
| 632 : !renderer()->animation().isRunningAcceleratedAnimationOnRenderer(rende
rer(), CSSPropertyOpacity)) | |
| 633 updateOpacity(renderer()->style()); | 626 updateOpacity(renderer()->style()); |
| 634 | 627 |
| 635 bool isSimpleContainer = isSimpleContainerCompositingLayer(); | 628 bool isSimpleContainer = isSimpleContainerCompositingLayer(); |
| 636 | 629 |
| 637 m_owningLayer->updateDescendantDependentFlags(); | 630 m_owningLayer->updateDescendantDependentFlags(); |
| 638 | 631 |
| 639 // m_graphicsLayer is the corresponding GraphicsLayer for this RenderLayer a
nd its non-compositing | 632 // m_graphicsLayer is the corresponding GraphicsLayer for this RenderLayer a
nd its non-compositing |
| 640 // descendants. So, the visibility flag for m_graphicsLayer should be true i
f there are any | 633 // descendants. So, the visibility flag for m_graphicsLayer should be true i
f there are any |
| 641 // non-compositing visible layers. | 634 // non-compositing visible layers. |
| 642 bool contentsVisible = m_owningLayer->hasVisibleContent() || hasVisibleNonCo
mpositingDescendantLayers(); | 635 bool contentsVisible = m_owningLayer->hasVisibleContent() || hasVisibleNonCo
mpositingDescendantLayers(); |
| (...skipping 1386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2029 return rects.release(); | 2022 return rects.release(); |
| 2030 } | 2023 } |
| 2031 | 2024 |
| 2032 #ifndef NDEBUG | 2025 #ifndef NDEBUG |
| 2033 void CompositedLayerMapping::verifyNotPainting() | 2026 void CompositedLayerMapping::verifyNotPainting() |
| 2034 { | 2027 { |
| 2035 ASSERT(!renderer()->frame()->page() || !renderer()->frame()->page()->isPaint
ing()); | 2028 ASSERT(!renderer()->frame()->page() || !renderer()->frame()->page()->isPaint
ing()); |
| 2036 } | 2029 } |
| 2037 #endif | 2030 #endif |
| 2038 | 2031 |
| 2039 bool CompositedLayerMapping::startAnimation(double timeOffset, const CSSAnimatio
nData* anim, const KeyframeList& keyframes) | |
| 2040 { | |
| 2041 bool hasTransform = renderer()->isBox() && keyframes.containsProperty(CSSPro
pertyWebkitTransform); | |
| 2042 IntSize boxSize; | |
| 2043 if (hasTransform) | |
| 2044 boxSize = toRenderBox(renderer())->pixelSnappedBorderBoxRect().size(); | |
| 2045 WebAnimations animations(m_animationProvider->startAnimation(timeOffset, ani
m, keyframes, hasTransform, boxSize)); | |
| 2046 if (animations.isEmpty()) | |
| 2047 return false; | |
| 2048 | |
| 2049 bool hasOpacity = keyframes.containsProperty(CSSPropertyOpacity); | |
| 2050 bool hasFilter = keyframes.containsProperty(CSSPropertyWebkitFilter); | |
| 2051 int animationId = m_animationProvider->getWebAnimationId(keyframes.animation
Name()); | |
| 2052 | |
| 2053 // Animating only some properties of the animation is not supported. So if t
he | |
| 2054 // GraphicsLayer rejects any property of the animation, we have to remove th
e | |
| 2055 // animation and return false to indicate un-accelerated animation is requir
ed. | |
| 2056 if (hasTransform) { | |
| 2057 if (!animations.m_transformAnimation || !m_graphicsLayer->addAnimation(a
nimations.m_transformAnimation.release())) | |
| 2058 return false; | |
| 2059 } | |
| 2060 if (hasOpacity) { | |
| 2061 if (!animations.m_opacityAnimation || !m_graphicsLayer->addAnimation(ani
mations.m_opacityAnimation.release())) { | |
| 2062 if (hasTransform) | |
| 2063 m_graphicsLayer->removeAnimation(animationId); | |
| 2064 return false; | |
| 2065 } | |
| 2066 } | |
| 2067 if (hasFilter) { | |
| 2068 if (!animations.m_filterAnimation || !m_graphicsLayer->addAnimation(anim
ations.m_filterAnimation.release())) { | |
| 2069 if (hasTransform || hasOpacity) | |
| 2070 m_graphicsLayer->removeAnimation(animationId); | |
| 2071 return false; | |
| 2072 } | |
| 2073 } | |
| 2074 return true; | |
| 2075 } | |
| 2076 | |
| 2077 void CompositedLayerMapping::animationPaused(double timeOffset, const String& an
imationName) | |
| 2078 { | |
| 2079 int animationId = m_animationProvider->getWebAnimationId(animationName); | |
| 2080 ASSERT(animationId); | |
| 2081 m_graphicsLayer->pauseAnimation(animationId, timeOffset); | |
| 2082 } | |
| 2083 | |
| 2084 void CompositedLayerMapping::animationFinished(const String& animationName) | |
| 2085 { | |
| 2086 int animationId = m_animationProvider->getWebAnimationId(animationName); | |
| 2087 ASSERT(animationId); | |
| 2088 m_graphicsLayer->removeAnimation(animationId); | |
| 2089 } | |
| 2090 | |
| 2091 bool CompositedLayerMapping::startTransition(double timeOffset, CSSPropertyID pr
operty, const RenderStyle* fromStyle, const RenderStyle* toStyle) | |
| 2092 { | |
| 2093 ASSERT(property != CSSPropertyInvalid); | |
| 2094 IntSize boxSize; | |
| 2095 if (property == CSSPropertyWebkitTransform && m_owningLayer->hasTransform())
{ | |
| 2096 ASSERT(renderer()->isBox()); | |
| 2097 boxSize = toRenderBox(renderer())->pixelSnappedBorderBoxRect().size(); | |
| 2098 } | |
| 2099 float fromOpacity = 0; | |
| 2100 float toOpacity = 0; | |
| 2101 if (property == CSSPropertyOpacity) { | |
| 2102 fromOpacity = compositingOpacity(fromStyle->opacity()); | |
| 2103 toOpacity = compositingOpacity(toStyle->opacity()); | |
| 2104 } | |
| 2105 | |
| 2106 // Although KeyframeAnimation can have multiple properties of the animation,
ImplicitAnimation (= Transition) has only one animation property. | |
| 2107 WebAnimations animations(m_animationProvider->startTransition(timeOffset, pr
operty, fromStyle, | |
| 2108 toStyle, m_owningLayer->hasTransform(), m_owningLayer->hasFilter(), boxS
ize, fromOpacity, toOpacity)); | |
| 2109 if (animations.m_transformAnimation && m_graphicsLayer->addAnimation(animati
ons.m_transformAnimation.release())) { | |
| 2110 // To ensure that the correct transform is visible when the animation en
ds, also set the final transform. | |
| 2111 updateTransform(toStyle); | |
| 2112 return true; | |
| 2113 } | |
| 2114 if (animations.m_opacityAnimation && m_graphicsLayer->addAnimation(animation
s.m_opacityAnimation.release())) { | |
| 2115 // To ensure that the correct opacity is visible when the animation ends
, also set the final opacity. | |
| 2116 updateOpacity(toStyle); | |
| 2117 return true; | |
| 2118 } | |
| 2119 if (animations.m_filterAnimation && m_graphicsLayer->addAnimation(animations
.m_filterAnimation.release())) { | |
| 2120 // To ensure that the correct filter is visible when the animation ends,
also set the final filter. | |
| 2121 updateFilters(toStyle); | |
| 2122 return true; | |
| 2123 } | |
| 2124 | |
| 2125 return false; | |
| 2126 } | |
| 2127 | |
| 2128 void CompositedLayerMapping::transitionPaused(double timeOffset, CSSPropertyID p
roperty) | |
| 2129 { | |
| 2130 int animationId = m_animationProvider->getWebAnimationId(property); | |
| 2131 ASSERT(animationId); | |
| 2132 m_graphicsLayer->pauseAnimation(animationId, timeOffset); | |
| 2133 } | |
| 2134 | |
| 2135 void CompositedLayerMapping::transitionFinished(CSSPropertyID property) | |
| 2136 { | |
| 2137 int animationId = m_animationProvider->getWebAnimationId(property); | |
| 2138 ASSERT(animationId); | |
| 2139 m_graphicsLayer->removeAnimation(animationId); | |
| 2140 } | |
| 2141 | |
| 2142 void CompositedLayerMapping::notifyAnimationStarted(const GraphicsLayer*, double
wallClockTime, double monotonicTime) | 2032 void CompositedLayerMapping::notifyAnimationStarted(const GraphicsLayer*, double
wallClockTime, double monotonicTime) |
| 2143 { | 2033 { |
| 2144 if (RuntimeEnabledFeatures::webAnimationsCSSEnabled()) | 2034 if (RuntimeEnabledFeatures::webAnimationsCSSEnabled()) |
| 2145 renderer()->node()->document().cssPendingAnimations().notifyCompositorAn
imationStarted(monotonicTime); | 2035 renderer()->node()->document().cssPendingAnimations().notifyCompositorAn
imationStarted(monotonicTime); |
| 2146 else | |
| 2147 renderer()->animation().notifyAnimationStarted(renderer(), wallClockTime
); | |
| 2148 } | 2036 } |
| 2149 | 2037 |
| 2150 LayoutRect CompositedLayerMapping::compositedBounds() const | 2038 LayoutRect CompositedLayerMapping::compositedBounds() const |
| 2151 { | 2039 { |
| 2152 return m_compositedBounds; | 2040 return m_compositedBounds; |
| 2153 } | 2041 } |
| 2154 | 2042 |
| 2155 void CompositedLayerMapping::setCompositedBounds(const LayoutRect& bounds) | 2043 void CompositedLayerMapping::setCompositedBounds(const LayoutRect& bounds) |
| 2156 { | 2044 { |
| 2157 m_compositedBounds = bounds; | 2045 m_compositedBounds = bounds; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2260 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { | 2148 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { |
| 2261 name = "Scrolling Contents Layer"; | 2149 name = "Scrolling Contents Layer"; |
| 2262 } else { | 2150 } else { |
| 2263 ASSERT_NOT_REACHED(); | 2151 ASSERT_NOT_REACHED(); |
| 2264 } | 2152 } |
| 2265 | 2153 |
| 2266 return name; | 2154 return name; |
| 2267 } | 2155 } |
| 2268 | 2156 |
| 2269 } // namespace WebCore | 2157 } // namespace WebCore |
| OLD | NEW |