Bug 229699 - Addition of CSSNumericFactory in CSS Typed OM
Summary: Addition of CSSNumericFactory in CSS Typed OM
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Qiaosong Zhou
URL:
Keywords: InRadar
Depends on:
Blocks: 175733
  Show dependency treegraph
 
Reported: 2021-08-31 00:32 PDT by Qiaosong Zhou
Modified: 2021-09-03 17:30 PDT (History)
15 users (show)

See Also:


Attachments
Patch (23.96 KB, patch)
2021-08-31 00:33 PDT, Qiaosong Zhou
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (23.93 KB, patch)
2021-08-31 00:38 PDT, Qiaosong Zhou
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (24.53 KB, patch)
2021-08-31 01:03 PDT, Qiaosong Zhou
no flags Details | Formatted Diff | Diff
Patch (81.13 KB, patch)
2021-08-31 01:24 PDT, Qiaosong Zhou
no flags Details | Formatted Diff | Diff
Patch (80.04 KB, patch)
2021-08-31 17:28 PDT, Qiaosong Zhou
no flags Details | Formatted Diff | Diff
Patch (78.35 KB, patch)
2021-09-01 00:42 PDT, Qiaosong Zhou
no flags Details | Formatted Diff | Diff
Patch (80.86 KB, patch)
2021-09-01 02:53 PDT, Qiaosong Zhou
no flags Details | Formatted Diff | Diff
Patch (81.38 KB, patch)
2021-09-02 00:57 PDT, Qiaosong Zhou
no flags Details | Formatted Diff | Diff
Patch (87.25 KB, patch)
2021-09-02 02:40 PDT, Qiaosong Zhou
no flags Details | Formatted Diff | Diff
Patch (90.77 KB, patch)
2021-09-02 02:50 PDT, Qiaosong Zhou
no flags Details | Formatted Diff | Diff
Patch (85.70 KB, patch)
2021-09-02 02:55 PDT, Qiaosong Zhou
no flags Details | Formatted Diff | Diff
Patch (81.25 KB, patch)
2021-09-03 14:45 PDT, Qiaosong Zhou
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Qiaosong Zhou 2021-08-31 00:32:29 PDT
Addition of CSSNumericFactory in CSS Typed OM
Comment 1 Qiaosong Zhou 2021-08-31 00:33:35 PDT
Created attachment 436849 [details]
Patch
Comment 2 Qiaosong Zhou 2021-08-31 00:38:33 PDT
Created attachment 436850 [details]
Patch
Comment 3 Qiaosong Zhou 2021-08-31 01:03:18 PDT
Created attachment 436851 [details]
Patch
Comment 4 Qiaosong Zhou 2021-08-31 01:24:16 PDT
Created attachment 436854 [details]
Patch
Comment 5 Alex Christensen 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.
Comment 6 Alex Christensen 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.
Comment 7 Qiaosong Zhou 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.
Comment 8 Qiaosong Zhou 2021-08-31 17:28:30 PDT
Created attachment 436972 [details]
Patch
Comment 9 Qiaosong Zhou 2021-09-01 00:42:31 PDT
Created attachment 436999 [details]
Patch
Comment 10 Qiaosong Zhou 2021-09-01 02:53:11 PDT
Created attachment 437006 [details]
Patch
Comment 11 Qiaosong Zhou 2021-09-02 00:57:21 PDT
Created attachment 437121 [details]
Patch
Comment 12 Qiaosong Zhou 2021-09-02 02:40:05 PDT
Created attachment 437129 [details]
Patch
Comment 13 Qiaosong Zhou 2021-09-02 02:50:16 PDT
Created attachment 437130 [details]
Patch
Comment 14 Qiaosong Zhou 2021-09-02 02:55:03 PDT
Created attachment 437131 [details]
Patch
Comment 15 Alex Christensen 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.
Comment 16 Qiaosong Zhou 2021-09-03 14:45:31 PDT
Created attachment 437314 [details]
Patch
Comment 17 EWS 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].
Comment 18 Radar WebKit Bug Importer 2021-09-03 17:30:33 PDT
<rdar://problem/82746215>