RESOLVED FIXED 208356
updateCSSTransitionsForElementAndProperty should clone RenderStyles
https://bugs.webkit.org/show_bug.cgi?id=208356
Summary updateCSSTransitionsForElementAndProperty should clone RenderStyles
Dean Jackson
Reported 2020-02-27 17:04:55 PST
updateCSSTransitionsForElementAndProperty should clone RenderStyles
Attachments
Patch (4.21 KB, patch)
2020-02-27 17:07 PST, Dean Jackson
koivisto: review+
Dean Jackson
Comment 1 2020-02-27 17:05:39 PST
Dean Jackson
Comment 2 2020-02-27 17:07:27 PST
Simon Fraser (smfr)
Comment 3 2020-02-27 17:34:15 PST
Comment on attachment 391944 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=391944&action=review > Source/WebCore/animation/AnimationTimeline.cpp:462 > + auto beforeChangeStyle = [&]() -> RenderStyle { Why not return Ref<RenderStyle>?
Ryosuke Niwa
Comment 4 2020-02-27 21:28:36 PST
Comment on attachment 391944 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=391944&action=review >> Source/WebCore/animation/AnimationTimeline.cpp:462 >> + auto beforeChangeStyle = [&]() -> RenderStyle { > > Why not return Ref<RenderStyle>? RenderStyle isn't a Ref counted object, right? > Source/WebCore/animation/AnimationTimeline.cpp:472 > + return animatedStyle; Another approach is to have an unique_ptr declared outside of this function to which this code stores RenderStyle. > Source/WebCore/animation/AnimationTimeline.cpp:482 > - return *unanimatedStyle; > + return RenderStyle::clone(*unanimatedStyle); That way, we don't have to make a clone here.
Antti Koivisto
Comment 5 2020-02-28 01:10:16 PST
Comment on attachment 391944 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=391944&action=review >>> Source/WebCore/animation/AnimationTimeline.cpp:462 >>> + auto beforeChangeStyle = [&]() -> RenderStyle { >> >> Why not return Ref<RenderStyle>? > > RenderStyle isn't a Ref counted object, right? Probably don't need to specify the return type explicitly, that is [&] { should be sufficient. >> Source/WebCore/animation/AnimationTimeline.cpp:482 >> + return RenderStyle::clone(*unanimatedStyle); > > That way, we don't have to make a clone here. RenderStyle is an internally refcounted copy-on-write type. Cloning it is ok.
Dean Jackson
Comment 6 2020-02-28 02:52:20 PST
Comment on attachment 391944 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=391944&action=review >>>> Source/WebCore/animation/AnimationTimeline.cpp:462 >>>> + auto beforeChangeStyle = [&]() -> RenderStyle { >>> >>> Why not return Ref<RenderStyle>? >> >> RenderStyle isn't a Ref counted object, right? > > Probably don't need to specify the return type explicitly, that is [&] { should be sufficient. Nice! (and yes, can't make a Ref<>) >> Source/WebCore/animation/AnimationTimeline.cpp:472 >> + return animatedStyle; > > Another approach is to have an unique_ptr declared outside of this function to which this code stores RenderStyle. I considered that. >>> Source/WebCore/animation/AnimationTimeline.cpp:482 >>> + return RenderStyle::clone(*unanimatedStyle); >> >> That way, we don't have to make a clone here. > > RenderStyle is an internally refcounted copy-on-write type. Cloning it is ok. My unnamed "expert" gave me the same advice. It would be nice if you could just return foo directly without calling clone, but I guess that would mean the copy constructor would have to not be deleted?
Antti Koivisto
Comment 7 2020-02-28 04:31:06 PST
> My unnamed "expert" gave me the same advice. It would be nice if you could > just return foo directly without calling clone, but I guess that would mean > the copy constructor would have to not be deleted? It is movable so if you have a local instance just returning it will work. I haven't made it copyable so far since it has a bunch of refcounted subobjects and copies are not entirely trivial. But it should probably be, for ease of use.
Dean Jackson
Comment 8 2020-02-28 09:34:45 PST
Note You need to log in before you can comment on or make changes to this bug.