RESOLVED FIXED 223892
Omit default position/angle when serializing radial & conic gradients
https://bugs.webkit.org/show_bug.cgi?id=223892
Summary Omit default position/angle when serializing radial & conic gradients
Tim Nguyen (:ntim)
Reported 2021-03-29 12:05:20 PDT
Attachments
Patch (13.88 KB, patch)
2021-04-06 02:32 PDT, Tim Nguyen (:ntim)
no flags
Patch (63.83 KB, patch)
2021-04-06 03:42 PDT, Tim Nguyen (:ntim)
no flags
Patch (63.81 KB, patch)
2021-04-14 07:47 PDT, Tim Nguyen (:ntim)
no flags
Patch (63.84 KB, patch)
2021-04-14 10:43 PDT, Tim Nguyen (:ntim)
no flags
Radar WebKit Bug Importer
Comment 1 2021-04-05 12:08:51 PDT
Tim Nguyen (:ntim)
Comment 2 2021-04-06 02:32:15 PDT
Tim Nguyen (:ntim)
Comment 3 2021-04-06 03:42:09 PDT
Tyler Wilcock
Comment 4 2021-04-06 07:45:55 PDT
Comment on attachment 425259 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=425259&action=review > Source/WebCore/css/CSSPrimitiveValue.cpp:866 > +bool CSSPrimitiveValue::isCenterPosition() const > +{ > + switch (primitiveUnitType()) { > + case CSSUnitType::CSS_VALUE_ID: > + return valueID() == CSSValueCenter; > + case CSSUnitType::CSS_PERCENTAGE: > + return m_value.num == 50; > + default: > + return false; > + } > +} Being "center position", or at least this definition of it, seems specific to gradient values, no? Would it make sense to add a static bool method to CSSGradientValue.cpp instead? static bool isCenterPosition(const CSSPrimitiveValue& primitiveValue) { } Also, I don't think you need to switch on unit type. If the primitive value is not a value ID and not a percent, it will return CSSValueInvalid and 0 respectively, meaning neither bool (== CSSValueCenter, == 50) would evaluate to true. I think this method could become: return primitiveValue.valueID() == CSSValueCenter || primitiveValue.doubleValue(CSSUnitType::CSS_PERCENTAGE) == 50; > LayoutTests/fast/gradients/unprefixed-gradient-parsing.html:106 > +var computedStr = s.replace(" at 50% 50%", ""); Can you explain why this is added?
Tim Nguyen (:ntim)
Comment 5 2021-04-06 11:08:56 PDT
(In reply to Tyler Wilcock from comment #4) > Comment on attachment 425259 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=425259&action=review > > > Source/WebCore/css/CSSPrimitiveValue.cpp:866 > > +bool CSSPrimitiveValue::isCenterPosition() const > > +{ > > + switch (primitiveUnitType()) { > > + case CSSUnitType::CSS_VALUE_ID: > > + return valueID() == CSSValueCenter; > > + case CSSUnitType::CSS_PERCENTAGE: > > + return m_value.num == 50; > > + default: > > + return false; > > + } > > +} > > Being "center position", or at least this definition of it, seems specific > to gradient values, no? Would it make sense to add a static bool method to > CSSGradientValue.cpp instead? > > static bool isCenterPosition(const CSSPrimitiveValue& primitiveValue) > { > > } > > Also, I don't think you need to switch on unit type. If the primitive value > is not a value ID and not a percent, it will return CSSValueInvalid and 0 > respectively, meaning neither bool (== CSSValueCenter, == 50) would evaluate > to true. I think this method could become: > > return primitiveValue.valueID() == CSSValueCenter || > primitiveValue.doubleValue(CSSUnitType::CSS_PERCENTAGE) == 50; I don't mind either way. center also makes sense for `background-position` or `object-position`, or anything using the `<position>` CSS type. Ideally, we'd have a `Position` type reflected in the style code as well, with a `isCenter` checking for both coordinates being center, rather than doing each one individually outside. > > LayoutTests/fast/gradients/unprefixed-gradient-parsing.html:106 > > +var computedStr = s.replace(" at 50% 50%", ""); > > Can you explain why this is added? I'll add a comment, but this is needed, since this patch strips the default center position when serializing the gradient, so it reflects this in the test as well.
Tim Nguyen (:ntim)
Comment 6 2021-04-14 07:47:42 PDT
Tim Nguyen (:ntim)
Comment 7 2021-04-14 10:43:42 PDT
Tim Nguyen (:ntim)
Comment 8 2021-04-14 10:46:18 PDT
Comment on attachment 426009 [details] Patch Antti reviewed this, thanks Antti!
EWS
Comment 9 2021-04-14 23:16:00 PDT
Committed r276002 (236554@main): <https://commits.webkit.org/236554@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 426009 [details].
Note You need to log in before you can comment on or make changes to this bug.