[filters2] Support for backdrop-filter
authordino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 6 Nov 2014 05:50:50 +0000 (05:50 +0000)
committerdino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 6 Nov 2014 05:50:50 +0000 (05:50 +0000)
commitbae7676d1ed5559fabde7111daa5ac967629bcb3
tree1a36e8a21d4d43e2ab6874783a06cc727f56d952
parent9325c84d78596017afbb476c9bca84f0d993615a
[filters2] Support for backdrop-filter
https://bugs.webkit.org/show_bug.cgi?id=138384
<rdar://problem/18874494>

Reviewed by Simon Fraser.

Source/WebCore:

Add prototype support for backdrop-filter
http://dev.w3.org/fxtf/filters-2/#BackdropFilterProperty

This adds support for parsing the new CSS property, adding
the value to RenderStyle, noticing that on the layer tree,
and the platform code in GraphicsLayer to render a backdrop
and apply an effect to the result.

Some things are missing:
- animation of the backdrop-filter is not yet supported
- backdrops will not work in cloned layers yet (e.g. reflections)

Tests: css3/filters/backdrop/backdropfilter-property-computed-style.html
       css3/filters/backdrop/backdropfilter-property-parsing-invalid.html
       css3/filters/backdrop/backdropfilter-property-parsing.html
       css3/filters/backdrop/backdropfilter-property.html
       css3/filters/backdrop/effect-hw.html

* WebCore.exp.in: Export the setBackdropFilters method so it can
be used from WebKit.

* css/CSSComputedStyleDeclaration.cpp: New property name.
(WebCore::isLayoutDependent):
(WebCore::ComputedStyleExtractor::propertyValue): Use the existing valueForFilter method.

* css/CSSParser.cpp:
(WebCore::CSSParser::parseValue): Piggyback on the filter parser.

* css/CSSPropertyNames.in: Add -webkit-backdrop-filter.

* css/StyleResolver.cpp:
(WebCore::StyleResolver::adjustRenderStyle): Add test for backdrop.
(WebCore::StyleResolver::applyProperty): Support new property.

* platform/graphics/GraphicsLayer.h:
(WebCore::GraphicsLayer::needsBackdrop): New method to test for existence of values.
(WebCore::GraphicsLayer::backdropFilters): Keeps the list of filters.
(WebCore::GraphicsLayer::setBackdropFilters):
(WebCore::GraphicsLayer::clearBackdropFilters):

* platform/graphics/ca/GraphicsLayerCA.cpp: This adds a new m_backdropLayer CALayer
that will sit behind the contents layer and provide the element's backdrop.
(WebCore::GraphicsLayerCA::willBeDestroyed):
(WebCore::GraphicsLayerCA::moveOrCopyAnimations):
(WebCore::GraphicsLayerCA::setBackdropFilters): Set a custom appearance so
remote layer hosts will notice the special layer. Also set the actual
layer properties.
(WebCore::GraphicsLayerCA::addAnimation): Remove whitespace.
(WebCore::GraphicsLayerCA::commitLayerChangesBeforeSublayers): Update backdrop if necessary.
(WebCore::GraphicsLayerCA::updateLayerNames): Give the new layer a name.
(WebCore::GraphicsLayerCA::updateSublayerList):
(WebCore::GraphicsLayerCA::updateGeometry): Make the backdrop layer match the contents
layer geometry.
(WebCore::GraphicsLayerCA::updateBackdropFilters): Create the backdrop layer if necessary,
and copy the filter values to any clones.
(WebCore::GraphicsLayerCA::ensureStructuralLayer): We need a structural layer if we
have backdrop filters.
(WebCore::GraphicsLayerCA::structuralLayerPurpose):
(WebCore::GraphicsLayerCA::createAnimationFromKeyframes):
(WebCore::GraphicsLayerCA::swapFromOrToTiledLayer):
* platform/graphics/ca/GraphicsLayerCA.h: New StructuralLayerPurpose, new LayerChangeFlag.

* platform/graphics/ca/PlatformCALayer.h: New LayerType.

* platform/graphics/ca/mac/PlatformCALayerMac.mm: Define CABackdropLayer.
(PlatformCALayerMac::PlatformCALayerMac): Create the correct CALayer type.

* rendering/RenderElement.h:
(WebCore::RenderElement::createsGroup):
(WebCore::RenderElement::hasBackdropFilter): This method is always around, but
only can return true when FILTERS_LEVEL_2 is enabled.

* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::paintsWithFilters): Remove an unnecessary comment.
(WebCore::RenderLayer::calculateClipRects):

* rendering/RenderLayer.h: Add hasBackdropFilter.

* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::RenderLayerBacking):
(WebCore::RenderLayerBacking::createPrimaryGraphicsLayer): Update the backdrop filters.
(WebCore::RenderLayerBacking::updateBackdropFilters): Set the filters on the GraphicsLayer.
(WebCore::RenderLayerBacking::updateGeometry):
* rendering/RenderLayerBacking.h:

* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::requiresOwnBackingStore): Needs backingstore if it has a backdrop filter.
(WebCore::RenderLayerCompositor::reasonsForCompositing):
(WebCore::RenderLayerCompositor::requiresCompositingForFilters): Return early if we have
a backdrop filter, because currently we absolutely require compositing.

* rendering/RenderLayerModelObject.cpp:
(WebCore::RenderLayerModelObject::styleWillChange): Add hasBackdropFilter().

* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::changeRequiresLayout): Check backdrops for change.

* rendering/style/RenderStyle.h: Add the backdropFilter style stuff.
* rendering/style/StyleRareNonInheritedData.cpp:
(WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
(WebCore::StyleRareNonInheritedData::operator==):
(WebCore::StyleRareNonInheritedData::hasBackdropFilters):
* rendering/style/StyleRareNonInheritedData.h:

Source/WebKit2:

* Shared/mac/RemoteLayerBackingStore.mm:
(WebKit::RemoteLayerBackingStore::drawInContext): Handle LayerTypeBackdropLayer in the switch.
* Shared/mac/RemoteLayerTreeTransaction.mm:
(WebKit::RemoteLayerTreeTransaction::description): Describe a backdrop layer.
* UIProcess/ios/RemoteLayerTreeHostIOS.mm:
(+[WKBackdropView layerClass]): Define CABackdropLayer and use it as the class.
(WebKit::RemoteLayerTreeHost::createLayer):
* UIProcess/mac/RemoteLayerTreeHost.mm: Ditto.
(WebKit::RemoteLayerTreeHost::createLayer):

LayoutTests:

Tests for backdrop-filter. These are skipped on non-Apple platforms.

* platform/win/TestExpections: Skip these tests.
* platform/efl/TestExpections:
* platform/gtk/TestExpections:
* platform/mac-mavericks/TestExpectations: Yosemite only.

* css3/filters/backdrop/backdropfilter-property-computed-style-expected.txt: Added.
* css3/filters/backdrop/backdropfilter-property-computed-style.html: Added.
* css3/filters/backdrop/backdropfilter-property-expected.txt: Added.
* css3/filters/backdrop/backdropfilter-property-parsing-expected.txt: Added.
* css3/filters/backdrop/backdropfilter-property-parsing-invalid-expected.txt: Added.
* css3/filters/backdrop/backdropfilter-property-parsing-invalid.html: Added.
* css3/filters/backdrop/backdropfilter-property-parsing.html: Added.
* css3/filters/backdrop/backdropfilter-property.html: Added.
* css3/filters/backdrop/effect-hw-expected.html: Added.
* css3/filters/backdrop/effect-hw.html: Added.
* css3/filters/backdrop/script-tests/backdropfilter-property-computed-style.js: Added.
(testComputedFilterRule):
* css3/filters/backdrop/script-tests/backdropfilter-property-parsing-invalid.js: Added.
(testInvalidFilterRule):
* css3/filters/backdrop/script-tests/backdropfilter-property-parsing.js: Added.
(jsWrapperClass):
(shouldBeType):
(testFilterRule):
* css3/filters/backdrop/script-tests/backdropfilter-property.js: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@175672 268f45cc-cd09-0410-ab3c-d52691b4dbfc
48 files changed:
LayoutTests/ChangeLog
LayoutTests/css3/filters/backdrop/backdropfilter-property-computed-style-expected.txt [new file with mode: 0644]
LayoutTests/css3/filters/backdrop/backdropfilter-property-computed-style.html [new file with mode: 0644]
LayoutTests/css3/filters/backdrop/backdropfilter-property-expected.txt [new file with mode: 0644]
LayoutTests/css3/filters/backdrop/backdropfilter-property-parsing-expected.txt [new file with mode: 0644]
LayoutTests/css3/filters/backdrop/backdropfilter-property-parsing-invalid-expected.txt [new file with mode: 0644]
LayoutTests/css3/filters/backdrop/backdropfilter-property-parsing-invalid.html [new file with mode: 0644]
LayoutTests/css3/filters/backdrop/backdropfilter-property-parsing.html [new file with mode: 0644]
LayoutTests/css3/filters/backdrop/backdropfilter-property.html [new file with mode: 0644]
LayoutTests/css3/filters/backdrop/effect-hw-expected.html [new file with mode: 0644]
LayoutTests/css3/filters/backdrop/effect-hw.html [new file with mode: 0644]
LayoutTests/css3/filters/backdrop/script-tests/backdropfilter-property-computed-style.js [new file with mode: 0644]
LayoutTests/css3/filters/backdrop/script-tests/backdropfilter-property-parsing-invalid.js [new file with mode: 0644]
LayoutTests/css3/filters/backdrop/script-tests/backdropfilter-property-parsing.js [new file with mode: 0644]
LayoutTests/css3/filters/backdrop/script-tests/backdropfilter-property.js [new file with mode: 0644]
LayoutTests/platform/efl/TestExpectations
LayoutTests/platform/gtk/TestExpectations
LayoutTests/platform/mac-mavericks/TestExpectations
LayoutTests/platform/win/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/css/CSSComputedStyleDeclaration.cpp
Source/WebCore/css/CSSParser.cpp
Source/WebCore/css/CSSPropertyNames.in
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/page/animation/KeyframeAnimation.cpp
Source/WebCore/platform/graphics/GraphicsLayer.h
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h
Source/WebCore/platform/graphics/ca/PlatformCALayer.h
Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm
Source/WebCore/rendering/RenderElement.h
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderLayer.h
Source/WebCore/rendering/RenderLayerBacking.cpp
Source/WebCore/rendering/RenderLayerBacking.h
Source/WebCore/rendering/RenderLayerCompositor.cpp
Source/WebCore/rendering/RenderLayerModelObject.cpp
Source/WebCore/rendering/style/RenderStyle.cpp
Source/WebCore/rendering/style/RenderStyle.h
Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp
Source/WebCore/rendering/style/StyleRareNonInheritedData.h
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/mac/RemoteLayerBackingStore.mm
Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm
Source/WebKit2/UIProcess/ios/RemoteLayerTreeHostIOS.mm
Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.mm
Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h