RESOLVED FIXED Bug 229699
Addition of CSSNumericFactory in CSS Typed OM
https://bugs.webkit.org/show_bug.cgi?id=229699
Summary Addition of CSSNumericFactory in CSS Typed OM
Qiaosong Zhou
Reported 2021-08-31 00:32:29 PDT
Addition of CSSNumericFactory in CSS Typed OM
Attachments
Patch (23.96 KB, patch)
2021-08-31 00:33 PDT, Qiaosong Zhou
ews-feeder: commit-queue-
Patch (23.93 KB, patch)
2021-08-31 00:38 PDT, Qiaosong Zhou
ews-feeder: commit-queue-
Patch (24.53 KB, patch)
2021-08-31 01:03 PDT, Qiaosong Zhou
no flags
Patch (81.13 KB, patch)
2021-08-31 01:24 PDT, Qiaosong Zhou
no flags
Patch (80.04 KB, patch)
2021-08-31 17:28 PDT, Qiaosong Zhou
no flags
Patch (78.35 KB, patch)
2021-09-01 00:42 PDT, Qiaosong Zhou
no flags
Patch (80.86 KB, patch)
2021-09-01 02:53 PDT, Qiaosong Zhou
no flags
Patch (81.38 KB, patch)
2021-09-02 00:57 PDT, Qiaosong Zhou
no flags
Patch (87.25 KB, patch)
2021-09-02 02:40 PDT, Qiaosong Zhou
no flags
Patch (90.77 KB, patch)
2021-09-02 02:50 PDT, Qiaosong Zhou
no flags
Patch (85.70 KB, patch)
2021-09-02 02:55 PDT, Qiaosong Zhou
no flags
Patch (81.25 KB, patch)
2021-09-03 14:45 PDT, Qiaosong Zhou
no flags
Qiaosong Zhou
Comment 1 2021-08-31 00:33:35 PDT
Qiaosong Zhou
Comment 2 2021-08-31 00:38:33 PDT
Qiaosong Zhou
Comment 3 2021-08-31 01:03:18 PDT
Qiaosong Zhou
Comment 4 2021-08-31 01:24:16 PDT
Alex Christensen
Comment 5 2021-08-31 11:17:40 PDT
Comment on attachment 436854 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=436854&action=review Looks like there's still one test failing. > Source/WebCore/css/typedom/CSSNumericFactory.cpp:2 > + * Copyright (C) 2018 Apple Inc. All rights reserved. 2021 > Source/WebCore/css/typedom/CSSNumericFactory.cpp:37 > +CSSNumericFactory* CSSNumericFactory::from(DOMCSSNamespace& css) This should probably return a CSSNumericFactory& because it makes a new 37CSSNumericFactory if there isn't one already. > Source/WebCore/css/typedom/CSSNumericFactory.h:41 > +class CSSNumericFactory final : public Supplement<DOMCSSNamespace> { I've never been a fan of the whole Supplementable/Supplement pattern which does a hash lookup just to access a member variable. I think just making a std::unique_ptr instead of a SupplementMap would be cleaner, but for some reason DOMCSSNamespace is already Supplementable so this is just following an existing pattern. Maybe we shouldn't change it in this patch. > Source/WebCore/css/typedom/CSSNumericFactory.h:46 > + static Ref<CSSUnitValue> number(double value) { return CSSUnitValue::create(value, "number"); } Can someone make custom units, or could we change CSSUnitValue::m_unit to be an enum class instead of a String? > Source/WebCore/css/typedom/CSSNumericFactory.idl:1 > +partial namespace CSS { This needs a copyright.
Alex Christensen
Comment 6 2021-08-31 11:25:03 PDT
(In reply to Alex Christensen from comment #5) > Can someone make custom units, or could we change CSSUnitValue::m_unit to be > an enum class instead of a String? Maybe CSSUnitType, which already seems to exist.
Qiaosong Zhou
Comment 7 2021-08-31 14:57:40 PDT
(In reply to Alex Christensen from comment #5) > Looks like there's still one test failing. I'm confused as to why that test is failing. It seems related to my patch. > > > Source/WebCore/css/typedom/CSSNumericFactory.cpp:37 > > +CSSNumericFactory* CSSNumericFactory::from(DOMCSSNamespace& css) > > This should probably return a CSSNumericFactory& because it makes a new > 37CSSNumericFactory if there isn't one already. I think it might be the standard of using Supplemental to return a pointer for the from function. I copied this format from another DOMCSSNamespace supplement, and in the Supplementable.h example it also returns a pointer. Should I use a lvalue ref here instead? > > Source/WebCore/css/typedom/CSSNumericFactory.h:46 > > + static Ref<CSSUnitValue> number(double value) { return CSSUnitValue::create(value, "number"); } > > Can someone make custom units, or could we change CSSUnitValue::m_unit to be > an enum class instead of a String? > I don't think custom units are allowed. But the whole unit system is quite convoluted and needs another patch. I think I'll just add a FIXME here for now.
Qiaosong Zhou
Comment 8 2021-08-31 17:28:30 PDT
Qiaosong Zhou
Comment 9 2021-09-01 00:42:31 PDT
Qiaosong Zhou
Comment 10 2021-09-01 02:53:11 PDT
Qiaosong Zhou
Comment 11 2021-09-02 00:57:21 PDT
Qiaosong Zhou
Comment 12 2021-09-02 02:40:05 PDT
Qiaosong Zhou
Comment 13 2021-09-02 02:50:16 PDT
Qiaosong Zhou
Comment 14 2021-09-02 02:55:03 PDT
Alex Christensen
Comment 15 2021-09-02 12:05:26 PDT
Comment on attachment 437131 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=437131&action=review > Source/WebCore/css/typedom/CSSUnitValue.h:-46 > - // FIXME: not correct. > - String toString() const final { return makeString((int) m_value, m_unit); } Removing this caused the change to LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/stylevalue-serialization/cssUnitValue.tentative-expected.txt and LayoutTests/fast/css-custom-paint/properties.html and LayoutTests/fast/css-custom-paint/properties-expected.html I suggest you remove this change and revert those two test expectations files and do those in a separate patch. As it stands now, this change is unrelated to the other changes in this patch and changes one incorrect result for another incorrect result.
Qiaosong Zhou
Comment 16 2021-09-03 14:45:31 PDT
EWS
Comment 17 2021-09-03 17:29:41 PDT
Committed r282039 (241339@main): <https://commits.webkit.org/241339@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 437314 [details].
Radar WebKit Bug Importer
Comment 18 2021-09-03 17:30:33 PDT
Note You need to log in before you can comment on or make changes to this bug.