will-change should sometimes trigger compositing
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Aug 2015 18:32:49 +0000 (18:32 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Aug 2015 18:32:49 +0000 (18:32 +0000)
commit77a771d110174df0c90143bee48d45169ab544a9
treed228d9746c67e99da3b7b8229c6abe36ab0ab98b
parent9c078a854ace1a2610629178df14a00aab7e36e9
will-change should sometimes trigger compositing
https://bugs.webkit.org/show_bug.cgi?id=148072

Reviewed by Tim Horton.
Source/JavaScriptCore:

Include will-change as a reason for compositing.

* inspector/protocol/LayerTree.json:

Source/WebCore:

Implement the compositing side-effects of will-change, if any of the
following properties are specified:
    opacity
    filter (as -webkit-filter)
    backdrop-filter (as -webkit-backdrop-filter)
    transform (on transformable elements only)

Tests: compositing/layer-creation/will-change-change.html
       compositing/layer-creation/will-change-layer-creation.html

* inspector/InspectorLayerTreeAgent.cpp:
(WebCore::InspectorLayerTreeAgent::reasonsForCompositingLayer): Tell the inspector
about will-change.
* rendering/RenderElement.cpp:
(WebCore::RenderElement::adjustStyleDifference): Need to trigger a recomposite if
will-change includes a compositing trigger property. This gets called before and
after setting the style, so this checks both states.
(WebCore::RenderElement::shouldWillChangeCreateStackingContext):
* rendering/RenderElement.h:
(WebCore::RenderElement::willChangeCreatesStackingContext): Helper function that
RenderInline uses to determine if it needs to create a RenderLayer, since RenderInline
doesn't get automatic layer RenderLayers as a side effect of having non-auto z-index
in the style.
* rendering/RenderInline.h: Need to trigger a RenderLayer if will-change includes
a property that applies to inlines.
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::requiresCompositingLayer): Call requiresCompositingForWillChange().
(WebCore::RenderLayerCompositor::requiresOwnBackingStore): Call requiresCompositingForWillChange().
(WebCore::RenderLayerCompositor::reasonsForCompositing): Include requiresCompositingForWillChange().
(WebCore::RenderLayerCompositor::requiresCompositingForWillChange): If will-change contains a
property that would trigger compositing on this element, return true.
* rendering/RenderLayerCompositor.h:
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::changeRequiresLayout): Set ContextSensitivePropertyWillChange in
changedContextSensitiveProperties if will-change changes.
* rendering/style/RenderStyle.h: Rename for clarity.
* rendering/style/RenderStyleConstants.h: Add ContextSensitivePropertyWillChange.
* rendering/style/WillChangeData.cpp:
(WebCore::propertyCreatesStackingContext): Subset of properties that create stacking
context on any element.
(WebCore::propertyCreatesStackingContextOnBoxesOnly): Additional properties that
create stacking context on boxes.
(WebCore::propertyTriggersCompositing): Properties that trigger compositing on
any element.
(WebCore::propertyTriggersCompositingOnBoxesOnly): Additional properties that
trigger compositing on boxes.
(WebCore::WillChangeData::addFeature): As features are added, manage a set of
flags to know if they trigger stacking context or compositing, on inlines and boxes.
(WebCore::WillChangeData::createsStackingContext): Deleted.
* rendering/style/WillChangeData.h:
(WebCore::WillChangeData::canCreateStackingContext):
(WebCore::WillChangeData::canCreateStackingContextOnInline):
(WebCore::WillChangeData::canTriggerCompositing):
(WebCore::WillChangeData::canTriggerCompositingOnInline):

Source/WebInspectorUI:

Have the web inspector show a correct compositing reason for will-change.
This could be improved to indicate which specific value in will-change triggered
the compositing.

* Localizations/en.lproj/localizedStrings.js:
* UserInterface/Views/LayerTreeDetailsSidebarPanel.js:
(WebInspector.LayerTreeDetailsSidebarPanel.prototype._populateListOfCompositingReasons):
(WebInspector.LayerTreeDetailsSidebarPanel):

LayoutTests:

* compositing/layer-creation/will-change-change-expected.txt: Added.
* compositing/layer-creation/will-change-change.html: Added.
* compositing/layer-creation/will-change-layer-creation-expected.txt: Added.
* compositing/layer-creation/will-change-layer-creation.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@188530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
22 files changed:
LayoutTests/ChangeLog
LayoutTests/compositing/layer-creation/will-change-change-expected.txt [new file with mode: 0644]
LayoutTests/compositing/layer-creation/will-change-change.html [new file with mode: 0644]
LayoutTests/compositing/layer-creation/will-change-layer-creation-expected.txt [new file with mode: 0644]
LayoutTests/compositing/layer-creation/will-change-layer-creation.html [new file with mode: 0644]
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/protocol/LayerTree.json
Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorLayerTreeAgent.cpp
Source/WebCore/rendering/RenderElement.cpp
Source/WebCore/rendering/RenderElement.h
Source/WebCore/rendering/RenderInline.h
Source/WebCore/rendering/RenderLayerCompositor.cpp
Source/WebCore/rendering/RenderLayerCompositor.h
Source/WebCore/rendering/style/RenderStyle.cpp
Source/WebCore/rendering/style/RenderStyle.h
Source/WebCore/rendering/style/RenderStyleConstants.h
Source/WebCore/rendering/style/WillChangeData.cpp
Source/WebCore/rendering/style/WillChangeData.h
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
Source/WebInspectorUI/UserInterface/Views/LayerTreeDetailsSidebarPanel.js