REGRESSION (r208025) GraphicsContext state stack assertions loading webkit.org
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 3 Nov 2016 00:19:54 +0000 (00:19 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 3 Nov 2016 00:19:54 +0000 (00:19 +0000)
commite534a8aa16abb7a0c4ecea21d3edd8f688ed26bf
treece247b7299c5b29f74241bb59675c1e3e18593d3
parent5ad97452990d01a149ed4b6633bdfe9e3b97c566
REGRESSION (r208025) GraphicsContext state stack assertions loading webkit.org
https://bugs.webkit.org/show_bug.cgi?id=164350
rdar://problem/29053414

Reviewed by Dean Jackson.

Source/WebCore:

After r208025 it as possible for KeyframeAnimation::animate() to produce a RenderStyle
with a non-1 opacity, but without the explicit z-index that triggers stacking context.
This confused the RenderLayer paintWithTransparency code, triggering mismsatched GraphicsContext
save/restores.

This occurred when the runningOrFillingForwards state was mis-computed. keyframeAnim->animate()
can spit out a new style when in the StartWaitTimer sometimes, so "!keyframeAnim->waitingToStart() && !keyframeAnim->postActive()"
gave the wrong answser.

Rather than depend on the super-confusing animation state, use a bool out param from animate() to say
when it actually produced a new style, and when true, do the setZIndex(0).

Test: animations/stacking-during-opacity-animation.html

* page/animation/AnimationBase.h:
* page/animation/CSSPropertyAnimation.cpp:
(WebCore::CSSPropertyAnimation::blendProperties): Log after blending so the log shows the blended style.
* page/animation/CompositeAnimation.cpp:
(WebCore::CompositeAnimation::animate):
* page/animation/ImplicitAnimation.cpp:
(WebCore::ImplicitAnimation::animate):
* page/animation/ImplicitAnimation.h:
* page/animation/KeyframeAnimation.cpp:
(WebCore::KeyframeAnimation::animate):
* page/animation/KeyframeAnimation.h:
* platform/graphics/GraphicsContext.cpp:
(WebCore::GraphicsContext::restore):
* platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm:
(PlatformCALayer::drawLayerContents): No functional change, but created scope for the
GraphicsContext so that it didn't outlive the CGContextRestoreGState(context).
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::beginTransparencyLayers): New assertion that catches the problem earlier.

LayoutTests:

Test was reduced from webkit.org.

* animations/stacking-during-opacity-animation-expected.txt: Added.
* animations/stacking-during-opacity-animation.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208314 268f45cc-cd09-0410-ab3c-d52691b4dbfc
14 files changed:
LayoutTests/ChangeLog
LayoutTests/animations/stacking-during-opacity-animation-expected.txt [new file with mode: 0644]
LayoutTests/animations/stacking-during-opacity-animation.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/page/animation/AnimationBase.h
Source/WebCore/page/animation/CSSPropertyAnimation.cpp
Source/WebCore/page/animation/CompositeAnimation.cpp
Source/WebCore/page/animation/ImplicitAnimation.cpp
Source/WebCore/page/animation/ImplicitAnimation.h
Source/WebCore/page/animation/KeyframeAnimation.cpp
Source/WebCore/page/animation/KeyframeAnimation.h
Source/WebCore/platform/graphics/GraphicsContext.cpp
Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm
Source/WebCore/rendering/RenderLayer.cpp