RESOLVED INVALID 201782
Replace SVGProperty/SVGPropertyOwner by DOMLiveProperty/DOMLivePropertyObserver
https://bugs.webkit.org/show_bug.cgi?id=201782
Summary Replace SVGProperty/SVGPropertyOwner by DOMLiveProperty/DOMLivePropertyObserver
Said Abou-Hallawa
Reported 2019-09-13 16:32:01 PDT
This will move some of the functionalities in SVGProperty to DOMLiveObject. It also replaces SVGPropertyOwner by a new class named DOMLiveObjectObserver.
Attachments
Patch (49.56 KB, patch)
2019-09-13 17:05 PDT, Said Abou-Hallawa
no flags
Patch (50.31 KB, patch)
2019-09-13 17:17 PDT, Said Abou-Hallawa
no flags
Patch (103.63 KB, patch)
2019-10-01 20:32 PDT, Said Abou-Hallawa
no flags
Patch (104.42 KB, patch)
2019-10-01 22:03 PDT, Said Abou-Hallawa
no flags
Patch for review (59.99 KB, patch)
2019-10-02 07:39 PDT, Said Abou-Hallawa
no flags
Said Abou-Hallawa
Comment 1 2019-09-13 17:05:12 PDT
Said Abou-Hallawa
Comment 2 2019-09-13 17:17:46 PDT
Nikolas Zimmermann
Comment 3 2019-09-17 12:34:32 PDT
Comment on attachment 378765 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=378765&action=review This is an excellent patch. I wanted to point you towards the discussion of re-introducing SVGRect, SVGPoint etc. in SVG2, until I realized that you (shallawa) were involved in the discussion on https://github.com/w3c/svgwg/issues/706. After reading the whole patch, the DOMLiveObjectObserver <-> DOMLiveObject relation is clear to me, and also why you are using a naked pointer to store the observer. > Source/WebCore/dom/DOMLiveObject.h:76 > + DOMLiveObjectObserver* m_observer { nullptr }; You used a naked pointer on purpose, I guess? > Source/WebCore/dom/DOMLiveObjectObserver.h:40 > + // Traverse the observers chain tillan Element observer is reached. typo: tillan -> until an > Source/WebCore/dom/Element.h:286 > + const Element* contextElement() const override { return this; } This is too generic for my taste, and it is not clear for what the context is used. How about naming this "domLiveObjectContextElement" / "contextElementForDOMLiveObject" ? > Source/WebCore/svg/properties/SVGAnimatedProperty.cpp:33 > +DOMLiveObjectObserver* SVGAnimatedProperty::observer() const Any special reason why observer() / contextElement() / commitChange is not inlined?
Said Abou-Hallawa
Comment 4 2019-09-18 16:39:24 PDT
Comment on attachment 378765 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=378765&action=review >> Source/WebCore/dom/DOMLiveObject.h:76 >> + DOMLiveObjectObserver* m_observer { nullptr }; > > You used a naked pointer on purpose, I guess? No really. But because the connection between object and the observer is controlled by the observer, I thought it is okay to use a raw pointer. This pointer is not going to be nullified unless the observer does it. And I made sure all the observers do it at the right time. But I think you are right. This should be changed to be WeakPtr since it will be safer even if the code changes such that detach() is not called and the observer got deleted. I will make that change. >> Source/WebCore/dom/DOMLiveObjectObserver.h:40 >> + // Traverse the observers chain tillan Element observer is reached. > > typo: tillan -> until an Will Fix. >> Source/WebCore/dom/Element.h:286 >> + const Element* contextElement() const override { return this; } > > This is too generic for my taste, and it is not clear for what the context is used. > How about naming this "domLiveObjectContextElement" / "contextElementForDOMLiveObject" ? Will change. >> Source/WebCore/svg/properties/SVGAnimatedProperty.cpp:33 >> +DOMLiveObjectObserver* SVGAnimatedProperty::observer() const > > Any special reason why observer() / contextElement() / commitChange is not inlined? The casting. In the header file, SVGElement is just forward declared. If I make these functions inline, the compiler will complain that it does not know how to cast SVGElement* to DOMLiveObjectObserver*. The complier does not know in this context that SVGElement is DOMLiveObjectObserver. Adding SVGElement.h to SVGAnimatedProperty.h is not an option because SVGElement.h has to include SVGAnimatedProperty.h. I will add a comment here about that.
Said Abou-Hallawa
Comment 5 2019-10-01 20:32:54 PDT
Said Abou-Hallawa
Comment 6 2019-10-01 22:03:57 PDT
Said Abou-Hallawa
Comment 7 2019-10-02 07:39:27 PDT
Created attachment 380019 [details] Patch for review
Sam Weinig
Comment 8 2019-10-02 15:18:43 PDT
Comment on attachment 380019 [details] Patch for review View in context: https://bugs.webkit.org/attachment.cgi?id=380019&action=review > Source/WebCore/dom/DOMLiveProperty.h:74 > + virtual String valueAsString() const { return emptyString(); } Given this is virtual, can this be moved out-of-line? Then you could avoid including WTFString.h > Source/WebCore/dom/DOMLivePropertyObserver.h:38 > + // The observer itself may have an observer. > + virtual DOMLivePropertyObserver* observer() const { return nullptr; } When does it make sense not to override observer()? > Source/WebCore/dom/DOMLivePropertyObserver.h:54 > + virtual void commitPropertyChange(DOMLiveProperty* property) Is property ever null? Can it be made into a reference?
Said Abou-Hallawa
Comment 9 2020-06-15 11:49:18 PDT
Replacing SVGRect/SVGPoint/SVGMatrix by DOM equivalents was reverted in the specs: https://github.com/w3c/svgwg/issues/706. So this bug is now invalid and the attached patch should not be considered.
Note You need to log in before you can comment on or make changes to this bug.