RESOLVED FIXED 224433
Refactor parameters to blending functions
https://bugs.webkit.org/show_bug.cgi?id=224433
Summary Refactor parameters to blending functions
Antoine Quint
Reported 2021-04-12 07:33:52 PDT
Refactor parameters to blending functions
Attachments
Patch (170.36 KB, patch)
2021-04-12 07:37 PDT, Antoine Quint
no flags
Patch (171.42 KB, patch)
2021-04-12 13:12 PDT, Antoine Quint
no flags
Patch (171.42 KB, patch)
2021-04-13 00:50 PDT, Antoine Quint
no flags
Patch (171.81 KB, patch)
2021-04-13 01:37 PDT, Antoine Quint
dino: review+
Antoine Quint
Comment 1 2021-04-12 07:37:43 PDT
Antti Koivisto
Comment 2 2021-04-12 07:44:19 PDT
Comment on attachment 425746 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=425746&action=review > Source/WebCore/animation/CSSPropertyAnimation.h:39 > +struct BlendOptions { Maybe BlendContext or something? BlendOptions sounds like an OptionSet. > Source/WebCore/animation/CSSPropertyAnimation.h:48 > + const CSSPropertyBlendingClient* client; > + double progress; > + bool isDiscrete; > + > + BlendOptions(double progress) > + : progress(progress) > + { > + } > + Using this constructor leaves client and isDiscrete uninitialized. > Source/WebCore/animation/CSSPropertyAnimation.h:58 > + // https://drafts.csswg.org/web-animations-1/#discrete > + // The property's values cannot be meaningfully combined, thus it is not additive and > + // interpolation swaps from Va to Vb at 50% (p=0.5). > + if (isDiscrete) > + this->progress = progress < 0.5 ? 0 : 1; Nor sure this is the best place to implement spec semantics. Maybe the caller could do this? Then the struct could be just a plain struct without constructors.
Antoine Quint
Comment 3 2021-04-12 11:27:50 PDT
(In reply to Antti Koivisto from comment #2) > Comment on attachment 425746 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=425746&action=review > > > Source/WebCore/animation/CSSPropertyAnimation.h:39 > > +struct BlendOptions { > > Maybe BlendContext or something? BlendOptions sounds like an OptionSet. I'll rename it to the BlendingContext, move it to AnimationUtilities.h and make a CSSPropertyBlendingContext private to CSSPropertyAnimation.cpp with the CSSPropertyBlendingClient member. > > Source/WebCore/animation/CSSPropertyAnimation.h:58 > > + // https://drafts.csswg.org/web-animations-1/#discrete > > + // The property's values cannot be meaningfully combined, thus it is not additive and > > + // interpolation swaps from Va to Vb at 50% (p=0.5). > > + if (isDiscrete) > > + this->progress = progress < 0.5 ? 0 : 1; > > Nor sure this is the best place to implement spec semantics. Maybe the > caller could do this? Then the struct could be just a plain struct without > constructors. I'll move it back to CSSPropertyAnimation::blendProperties() where it belongs.
Antoine Quint
Comment 4 2021-04-12 13:12:05 PDT
Antoine Quint
Comment 5 2021-04-12 13:12:23 PDT
*** Bug 223173 has been marked as a duplicate of this bug. ***
Simon Fraser (smfr)
Comment 6 2021-04-12 13:15:41 PDT
Comment on attachment 425778 [details] Patch Do we expect BlendingContext to gain more members? I'm not sure two members justifies the struct at this point. I would not consider "progress" a part of a "context": progress is a direct input into blending.
Antoine Quint
Comment 7 2021-04-12 22:46:15 PDT
(In reply to Simon Fraser (smfr) from comment #6) > Comment on attachment 425778 [details] > Patch > > Do we expect BlendingContext to gain more members? I'm not sure two members > justifies the struct at this point. I would not consider "progress" a part > of a "context": progress is a direct input into blending. We do: the composite operation will have to be passed through to deal with additive and accumulative animations.
Antoine Quint
Comment 8 2021-04-13 00:50:37 PDT
Antoine Quint
Comment 9 2021-04-13 00:52:17 PDT
(In reply to Antoine Quint from comment #7) > (In reply to Simon Fraser (smfr) from comment #6) > > Comment on attachment 425778 [details] > > Patch > > > > Do we expect BlendingContext to gain more members? I'm not sure two members > > justifies the struct at this point. I would not consider "progress" a part > > of a "context": progress is a direct input into blending. > > We do: the composite operation will have to be passed through to deal with > additive and accumulative animations. Note also that CSSPropertyBlendingContext also adds the CSSPropertyBlendingClient.
Antoine Quint
Comment 10 2021-04-13 01:37:48 PDT
Dean Jackson
Comment 11 2021-04-14 11:20:10 PDT
Comment on attachment 425846 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=425846&action=review > Source/WebCore/animation/CSSPropertyAnimation.cpp:77 > + const CSSPropertyBlendingClient* client; > + > + CSSPropertyBlendingContext(double progress, bool isDiscrete, const CSSPropertyBlendingClient* client) Don't people usually put the member variable after the constructor?
Darin Adler
Comment 12 2021-04-14 11:22:30 PDT
Comment on attachment 425846 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=425846&action=review >> Source/WebCore/animation/CSSPropertyAnimation.cpp:77 >> + CSSPropertyBlendingContext(double progress, bool isDiscrete, const CSSPropertyBlendingClient* client) > > Don't people usually put the member variable after the constructor? It’s a struct vs. class thing. When the interface to a class is public data members (most structs), then those should be at the top. When the private data members are an implementation detail, then those should be at the bottom along with other private things. This follows our traditions for structs. But I would ask: Do we really need a constructor here? Can we use aggregate initialization syntax instead and omit the constructor function?
Antti Koivisto
Comment 13 2021-04-14 12:39:44 PDT
Comment on attachment 425846 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=425846&action=review > Source/WebCore/animation/CSSPropertyAnimation.cpp:74 > +struct CSSPropertyBlendingContext : BlendingContext { Why do we need subtyping here? Can't we just have everything in a single BlendingContext struct? > Source/WebCore/platform/animation/AnimationUtilities.h:35 > + double progress; > + bool isDiscrete { false }; Why do some fields have defaults and some not?
Antoine Quint
Comment 14 2021-04-16 08:50:45 PDT
(In reply to Antti Koivisto from comment #13) > Comment on attachment 425846 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=425846&action=review > > > Source/WebCore/animation/CSSPropertyAnimation.cpp:74 > > +struct CSSPropertyBlendingContext : BlendingContext { > > Why do we need subtyping here? Can't we just have everything in a single > BlendingContext struct? CSSPropertyBlendingClient is really only relevant in the context of CSSPropertyAnimation.cpp, while blending of types can be done in other source files. It felt cleaner to have this member only be exposed in the context of blending work in CSSPropertyAnimation.cpp. > > Source/WebCore/platform/animation/AnimationUtilities.h:35 > > + double progress; > > + bool isDiscrete { false }; > > Why do some fields have defaults and some not?
Antoine Quint
Comment 15 2021-04-16 09:38:51 PDT
(In reply to Darin Adler from comment #12) > Comment on attachment 425846 [details] > > But I would ask: Do we really need a constructor here? Can we use aggregate > initialization syntax instead and omit the constructor function? I'll remove the BlendingContext constructor, which is indeed useless. However, I believe we need one for CSSPropertyBlendingContext blending context since it inherits from BlendingContext if we want to also have the subtype parameter in the constructor.
Antoine Quint
Comment 16 2021-04-16 09:55:58 PDT
Darin Adler
Comment 17 2021-04-16 10:13:58 PDT
Need to roll this out; build is broken on multiple platforms.
Chris Dumez
Comment 18 2021-04-16 10:16:13 PDT
Did this cause this? ./animation/CSSPropertyAnimation.cpp:78:11: error: no matching constructor for initialization of 'WebCore::BlendingContext'
Chris Dumez
Comment 19 2021-04-16 10:24:27 PDT
(In reply to Chris Dumez from comment #18) > Did this cause this? > ./animation/CSSPropertyAnimation.cpp:78:11: error: no matching constructor > for initialization of 'WebCore::BlendingContext' I landed the following build fix: <https://commits.webkit.org/r276142>
Antoine Quint
Comment 20 2021-04-16 10:33:33 PDT
(In reply to Chris Dumez from comment #19) > (In reply to Chris Dumez from comment #18) > > Did this cause this? > > ./animation/CSSPropertyAnimation.cpp:78:11: error: no matching constructor > > for initialization of 'WebCore::BlendingContext' > > I landed the following build fix: <https://commits.webkit.org/r276142> Thanks Chris!
Chris Dumez
Comment 21 2021-04-16 10:36:07 PDT
(In reply to Chris Dumez from comment #19) > (In reply to Chris Dumez from comment #18) > > Did this cause this? > > ./animation/CSSPropertyAnimation.cpp:78:11: error: no matching constructor > > for initialization of 'WebCore::BlendingContext' > > I landed the following build fix: <https://commits.webkit.org/r276142> Looks like there are still some build failures on some platforms (Windows at least). But my build fix did the trick for me locally on macOS.
Chris Dumez
Comment 22 2021-04-16 10:42:10 PDT
(In reply to Chris Dumez from comment #21) > (In reply to Chris Dumez from comment #19) > > (In reply to Chris Dumez from comment #18) > > > Did this cause this? > > > ./animation/CSSPropertyAnimation.cpp:78:11: error: no matching constructor > > > for initialization of 'WebCore::BlendingContext' > > > > I landed the following build fix: <https://commits.webkit.org/r276142> > > Looks like there are still some build failures on some platforms (Windows at > least). But my build fix did the trick for me locally on macOS. GTK too: ../../Source/WebCore/platform/graphics/nicosia/NicosiaAnimation.cpp:31:31: error: cannot convert ‘double’ to ‘const WebCore::BlendingContext&’ ../../Source/WebCore/platform/graphics/nicosia/NicosiaAnimation.cpp:141:39: error: cannot convert ‘double’ to ‘const WebCore::BlendingContext&’ ../../Source/WebCore/platform/graphics/nicosia/NicosiaAnimation.cpp:149:41: error: cannot convert ‘double’ to ‘const WebCore::BlendingContext&’ ../../Source/WebCore/platform/graphics/nicosia/NicosiaAnimation.cpp:156:52: error: cannot convert ‘double’ to ‘const WebCore::BlendingContext&’
Darin Adler
Comment 23 2021-04-16 10:48:29 PDT
The real problem is landing the revised patch without doing EWS first. A good fix for those NicosiaAnimation.cpp places is possibly to write "{ progress }" instead of just "progress".
Chris Dumez
Comment 24 2021-04-16 10:52:19 PDT
Trying this for GTK / Win's build: <https://commits.webkit.org/r276143>
Chris Dumez
Comment 25 2021-04-16 11:19:17 PDT
There were too many build failures on GTK / WinCairo. I gave up, reverted by build fixes and just added a constructor for BlendingContext in <https://commits.webkit.org/r276147> to make the bots green again. Feel free to follow-up and do better in a follow-up, relying on EWS to make sure it builds everywhere.
Ryan Haddad
Comment 26 2021-04-19 22:03:09 PDT
Note You need to log in before you can comment on or make changes to this bug.