Skip to content

Commit

Permalink
Port PlatformCAAnimationRemote::Properties to the new IPC serializati…
Browse files Browse the repository at this point in the history
…on format

https://bugs.webkit.org/show_bug.cgi?id=264597

Reviewed by Alex Christensen.

* Source/WebKit/DerivedSources-input.xcfilelist:
* Source/WebKit/DerivedSources.make:
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCAAnimationRemote.h:
* Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCAAnimationRemote.mm:
(WebKit::PlatformCAAnimationRemote::Properties::encode const): Deleted.
(WebKit::PlatformCAAnimationRemote::Properties::decode): Deleted.
* Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCAAnimationRemoteProperties.h: Added.
* Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCAAnimationRemoteProperties.serialization.in: Added.

Canonical link: https://commits.webkit.org/270559@main
  • Loading branch information
cdumez committed Nov 10, 2023
1 parent 87ce4cc commit dd7791a
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 147 deletions.
1 change: 1 addition & 0 deletions Source/WebKit/DerivedSources-input.xcfilelist
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@ $(PROJECT_DIR)/WebProcess/WebCoreSupport/WebSpeechSynthesisVoice.serialization.i
$(PROJECT_DIR)/WebProcess/WebPage/Cocoa/TextCheckingControllerProxy.messages.in
$(PROJECT_DIR)/WebProcess/WebPage/DrawingArea.messages.in
$(PROJECT_DIR)/WebProcess/WebPage/EventDispatcher.messages.in
$(PROJECT_DIR)/WebProcess/WebPage/RemoteLayerTree/PlatformCAAnimationRemoteProperties.serialization.in
$(PROJECT_DIR)/WebProcess/WebPage/RemoteLayerTree/RemoteScrollingCoordinator.messages.in
$(PROJECT_DIR)/WebProcess/WebPage/ViewGestureGeometryCollector.messages.in
$(PROJECT_DIR)/WebProcess/WebPage/ViewUpdateDispatcher.messages.in
Expand Down
1 change: 1 addition & 0 deletions Source/WebKit/DerivedSources.make
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,7 @@ SERIALIZATION_DESCRIPTION_FILES = \
WebProcess/MediaStream/MediaDeviceSandboxExtensions.serialization.in \
WebProcess/Network/NetworkProcessConnectionInfo.serialization.in \
WebProcess/WebCoreSupport/WebSpeechSynthesisVoice.serialization.in \
WebProcess/WebPage/RemoteLayerTree/PlatformCAAnimationRemoteProperties.serialization.in \
#

WEBCORE_SERIALIZATION_DESCRIPTION_FILES = \
Expand Down
6 changes: 6 additions & 0 deletions Source/WebKit/WebKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,7 @@
46C71AC92A942E2900E459AF /* GoToBackForwardItemParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 46C71AC72A942E1800E459AF /* GoToBackForwardItemParameters.h */; };
46C916AA2799D0A2001A4E7C /* WebSharedWorkerServer.h in Headers */ = {isa = PBXBuildFile; fileRef = 46C916A92799D09D001A4E7C /* WebSharedWorkerServer.h */; };
46CE3B1123D8C8490016A96A /* WebBackForwardListCounts.h in Headers */ = {isa = PBXBuildFile; fileRef = 46CE3B1023D8C83D0016A96A /* WebBackForwardListCounts.h */; };
46D246262AFE956500F24C94 /* PlatformCAAnimationRemoteProperties.h in Headers */ = {isa = PBXBuildFile; fileRef = 46D246242AFE954F00F24C94 /* PlatformCAAnimationRemoteProperties.h */; };
46D48FCE2799D7E1007D2014 /* WebSharedWorkerServerToContextConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 46D48FCD2799D7DE007D2014 /* WebSharedWorkerServerToContextConnection.h */; };
46DBC28C2AF96B9F00E6B63A /* ITPThirdPartyData.h in Headers */ = {isa = PBXBuildFile; fileRef = 46DBC28A2AF96B9700E6B63A /* ITPThirdPartyData.h */; };
46DBC28D2AF96BA400E6B63A /* ITPThirdPartyDataForSpecificFirstParty.h in Headers */ = {isa = PBXBuildFile; fileRef = 46DBC28B2AF96B9700E6B63A /* ITPThirdPartyDataForSpecificFirstParty.h */; };
Expand Down Expand Up @@ -4958,6 +4959,8 @@
46C916A82799D09D001A4E7C /* WebSharedWorkerServer.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebSharedWorkerServer.cpp; sourceTree = "<group>"; };
46C916A92799D09D001A4E7C /* WebSharedWorkerServer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebSharedWorkerServer.h; sourceTree = "<group>"; };
46CE3B1023D8C83D0016A96A /* WebBackForwardListCounts.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebBackForwardListCounts.h; sourceTree = "<group>"; };
46D246242AFE954F00F24C94 /* PlatformCAAnimationRemoteProperties.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PlatformCAAnimationRemoteProperties.h; sourceTree = "<group>"; };
46D246252AFE954F00F24C94 /* PlatformCAAnimationRemoteProperties.serialization.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = PlatformCAAnimationRemoteProperties.serialization.in; sourceTree = "<group>"; };
46D48FCC2799D7DD007D2014 /* WebSharedWorkerServerToContextConnection.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebSharedWorkerServerToContextConnection.cpp; sourceTree = "<group>"; };
46D48FCD2799D7DE007D2014 /* WebSharedWorkerServerToContextConnection.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebSharedWorkerServerToContextConnection.h; sourceTree = "<group>"; };
46DA285727B73E760089D339 /* WebGeolocationManagerProxyCocoa.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebGeolocationManagerProxyCocoa.cpp; sourceTree = "<group>"; };
Expand Down Expand Up @@ -9522,6 +9525,8 @@
2DA049B5180CCD0A00AAFA9E /* GraphicsLayerCARemote.mm */,
0F5E200218E77051003EC3E5 /* PlatformCAAnimationRemote.h */,
0F5E200118E77051003EC3E5 /* PlatformCAAnimationRemote.mm */,
46D246242AFE954F00F24C94 /* PlatformCAAnimationRemoteProperties.h */,
46D246252AFE954F00F24C94 /* PlatformCAAnimationRemoteProperties.serialization.in */,
2DA049B2180CCCD300AAFA9E /* PlatformCALayerRemote.h */,
2DA049B1180CCCD300AAFA9E /* PlatformCALayerRemote.mm */,
2D8710151828415D0018FA01 /* PlatformCALayerRemoteCustom.h */,
Expand Down Expand Up @@ -15154,6 +15159,7 @@
E5DEFA6826F8F42600AB68DB /* PhotosUISPI.h in Headers */,
5CE85B201C88E64B0070BFCE /* PingLoad.h in Headers */,
0F5E200418E77051003EC3E5 /* PlatformCAAnimationRemote.h in Headers */,
46D246262AFE956500F24C94 /* PlatformCAAnimationRemoteProperties.h in Headers */,
2DA049B4180CCCD300AAFA9E /* PlatformCALayerRemote.h in Headers */,
2D8710171828415D0018FA01 /* PlatformCALayerRemoteCustom.h in Headers */,
2D8949F1182044F600E898AA /* PlatformCALayerRemoteTiledBacking.h in Headers */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,12 @@

#pragma once

#include "PlatformCAAnimationRemoteProperties.h"
#include <WebCore/PlatformCAAnimation.h>
#include <wtf/EnumTraits.h>
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>

namespace IPC {
class Encoder;
class Decoder;
};

namespace WTF {
class TextStream;
};
Expand Down Expand Up @@ -129,57 +125,8 @@ class PlatformCAAnimationRemote final : public WebCore::PlatformCAAnimation {

void didStart(CFTimeInterval beginTime) { m_properties.beginTime = beginTime; }


using KeyframeValue = std::variant<float, WebCore::Color, WebCore::FloatPoint3D, WebCore::TransformationMatrix, RefPtr<WebCore::FilterOperation>>;

struct Properties {
Properties()
: animationType(Basic)
, beginTime(0)
, duration(0)
, timeOffset(0)
, repeatCount(1)
, speed(1)
, fillMode(NoFillMode)
, valueFunction(NoValueFunction)
, autoReverses(false)
, removedOnCompletion(true)
, additive(false)
, reverseTimingFunctions(false)
, hasExplicitBeginTime(false)
{
}

void encode(IPC::Encoder&) const;
static std::optional<Properties> decode(IPC::Decoder&);

String keyPath;
PlatformCAAnimation::AnimationType animationType;

CFTimeInterval beginTime;
double duration;
double timeOffset;
float repeatCount;
float speed;

PlatformCAAnimation::FillModeType fillMode;
PlatformCAAnimation::ValueFunctionType valueFunction;
RefPtr<WebCore::TimingFunction> timingFunction;

bool autoReverses;
bool removedOnCompletion;
bool additive;
bool reverseTimingFunctions;
bool hasExplicitBeginTime;

// For basic animations, these vectors have two entries. For keyframe animations, two or more.
// timingFunctions has n-1 entries.
Vector<KeyframeValue> keyValues;
Vector<float> keyTimes;
Vector<Ref<WebCore::TimingFunction>> timingFunctions;

Vector<Properties> animations;
};
using KeyframeValue = PlatformCAAnimationRemoteProperties::KeyframeValue;
using Properties = PlatformCAAnimationRemoteProperties;

const Properties& properties() const { return m_properties; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,97 +105,6 @@ - (void)animationDidStop:(CAAnimation *)animation finished:(BOOL)finished
});
}

void PlatformCAAnimationRemote::Properties::encode(IPC::Encoder& encoder) const
{
encoder << keyPath;
encoder << animationType;

encoder << beginTime;
encoder << duration;
encoder << timeOffset;
encoder << repeatCount;
encoder << speed;

encoder << fillMode;
encoder << valueFunction;
encoder << timingFunction;

encoder << autoReverses;
encoder << removedOnCompletion;
encoder << additive;
encoder << reverseTimingFunctions;
encoder << hasExplicitBeginTime;

encoder << keyValues;
encoder << keyTimes;
encoder << timingFunctions;

encoder << animations;
}

std::optional<PlatformCAAnimationRemote::Properties> PlatformCAAnimationRemote::Properties::decode(IPC::Decoder& decoder)
{
PlatformCAAnimationRemote::Properties properties;
if (!decoder.decode(properties.keyPath))
return std::nullopt;

if (!decoder.decode(properties.animationType))
return std::nullopt;

if (!decoder.decode(properties.beginTime))
return std::nullopt;

if (!decoder.decode(properties.duration))
return std::nullopt;

if (!decoder.decode(properties.timeOffset))
return std::nullopt;

if (!decoder.decode(properties.repeatCount))
return std::nullopt;

if (!decoder.decode(properties.speed))
return std::nullopt;

if (!decoder.decode(properties.fillMode))
return std::nullopt;

if (!decoder.decode(properties.valueFunction))
return std::nullopt;

if (!decoder.decode(properties.timingFunction))
return std::nullopt;

if (!decoder.decode(properties.autoReverses))
return std::nullopt;

if (!decoder.decode(properties.removedOnCompletion))
return std::nullopt;

if (!decoder.decode(properties.additive))
return std::nullopt;

if (!decoder.decode(properties.reverseTimingFunctions))
return std::nullopt;

if (!decoder.decode(properties.hasExplicitBeginTime))
return std::nullopt;

if (!decoder.decode(properties.keyValues))
return std::nullopt;

if (!decoder.decode(properties.keyTimes))
return std::nullopt;

if (!decoder.decode(properties.timingFunctions))
return std::nullopt;

if (!decoder.decode(properties.animations))
return std::nullopt;

return WTFMove(properties);
}

Ref<PlatformCAAnimation> PlatformCAAnimationRemote::create(PlatformCAAnimation::AnimationType type, const String& keyPath)
{
return adoptRef(*new PlatformCAAnimationRemote(type, keyPath));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright (C) 2014-2023 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#pragma once

#include <WebCore/PlatformCAAnimation.h>
#include <wtf/Forward.h>

namespace WebKit {

struct PlatformCAAnimationRemoteProperties {
String keyPath;
WebCore::PlatformCAAnimation::AnimationType animationType { WebCore::PlatformCAAnimation::Basic };

CFTimeInterval beginTime { 0 };
double duration { 0 };
double timeOffset { 0 };
float repeatCount { 1 };
float speed { 1 };

WebCore::PlatformCAAnimation::FillModeType fillMode { WebCore::PlatformCAAnimation::NoFillMode };
WebCore::PlatformCAAnimation::ValueFunctionType valueFunction { WebCore::PlatformCAAnimation::NoValueFunction };
RefPtr<WebCore::TimingFunction> timingFunction;

bool autoReverses { false };
bool removedOnCompletion { true };
bool additive { false };
bool reverseTimingFunctions { false };
bool hasExplicitBeginTime { false };

// For basic animations, these vectors have two entries. For keyframe animations, two or more.
// timingFunctions has n-1 entries.
using KeyframeValue = std::variant<float, WebCore::Color, WebCore::FloatPoint3D, WebCore::TransformationMatrix, RefPtr<WebCore::FilterOperation>>;
Vector<KeyframeValue> keyValues;
Vector<float> keyTimes;
Vector<Ref<WebCore::TimingFunction>> timingFunctions;

Vector<PlatformCAAnimationRemoteProperties> animations;
};

} // namespace WebKit
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright (C) 2022 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

struct WebKit::PlatformCAAnimationRemoteProperties {
String keyPath;
WebCore::PlatformCAAnimation::AnimationType animationType;

CFTimeInterval beginTime;
double duration;
double timeOffset;
float repeatCount;
float speed;

WebCore::PlatformCAAnimation::FillModeType fillMode;
WebCore::PlatformCAAnimation::ValueFunctionType valueFunction;
RefPtr<WebCore::TimingFunction> timingFunction;

bool autoReverses;
bool removedOnCompletion;
bool additive;
bool reverseTimingFunctions;
bool hasExplicitBeginTime;

Vector<WebKit::PlatformCAAnimationRemoteProperties::KeyframeValue> keyValues;
Vector<float> keyTimes;
Vector<Ref<WebCore::TimingFunction>> timingFunctions;

Vector<WebKit::PlatformCAAnimationRemoteProperties> animations;
};

0 comments on commit dd7791a

Please sign in to comment.