[webkit-changes] [WebKit/WebKit] 11adcf: Shorthands are still using "initial" for longhands...

Darin Adler noreply at github.com
Sat Dec 17 22:33:10 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 11adcf008ef8a0287a435298802c45749dd17cc1
      https://github.com/WebKit/WebKit/commit/11adcf008ef8a0287a435298802c45749dd17cc1
  Author: Darin Adler <darin at apple.com>
  Date:   2022-12-17 (Sat, 17 Dec 2022)

  Changed paths:
    M LayoutTests/editing/pasteboard/copy-paste-inserts-clearing-div-expected.txt
    M LayoutTests/fast/backgrounds/background-shorthand-after-set-backgroundSize-expected.txt
    M LayoutTests/fast/backgrounds/background-shorthand-with-backgroundSize-style-expected.txt
    M LayoutTests/fast/css/background-clip-text-expected.txt
    M LayoutTests/fast/css/background-position-serialize-expected.txt
    M LayoutTests/fast/css/border-shorthand-initialize-longhands-expected.txt
    M LayoutTests/fast/css/longhand-overrides-shorthand-prefixing-expected.txt
    M LayoutTests/fast/css/parsing-text-emphasis-expected.txt
    M LayoutTests/fast/css/remove-shorthand-expected.txt
    M LayoutTests/fast/css/shorthand-mismatched-list-crash-expected.txt
    M LayoutTests/fast/css/transform-inline-style-expected.txt
    M LayoutTests/fast/css/transform-inline-style-remove-expected.txt
    M LayoutTests/fast/dom/background-shorthand-csstext-expected.txt
    M LayoutTests/fast/masking/parsing-mask-expected.txt
    M LayoutTests/fast/masking/parsing-webkit-mask-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/content-security-policy/style-src/inline-style-allowed-while-cloning-objects.sub-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-backgrounds/parsing/border-shorthand-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-masking/parsing/mask-position-valid-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-masking/parsing/mask-valid.sub-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-multicol/parsing/column-rule-shorthand-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-variables/variable-cssText-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/cssom/border-shorthand-serialization-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/cssom/serialize-values-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/cssom/shorthand-values-expected.txt
    M LayoutTests/platform/glib/imported/w3c/web-platform-tests/css/css-masking/parsing/mask-valid.sub-expected.txt
    M Source/WebCore/css/CSSProperties.json
    M Source/WebCore/css/StyleProperties.cpp
    M Source/WebCore/css/StyleProperties.h
    M Source/WebCore/css/parser/CSSPropertyParser.cpp
    M Source/WebCore/css/parser/CSSPropertyParser.h

  Log Message:
  -----------
  Shorthands are still using "initial" for longhands that are set implicitly
https://bugs.webkit.org/show_bug.cgi?id=248913
rdar://problem/103092939

Reviewed by Sam Weinig.

This removes all the remaining cases that use "initial" for longhands, moving to initial values.
Also, as a result we need to start serializing some properties based on checking if longhands
have their initial values, not just use the implicit flag. That's because in the case of layered
shorthands, we can no longer use the implicit flag; there is nothing that stores those in the
layers. Before the special implicit initial value was used to work around that. It's a good
direction to have done that for layered shorthands and for border, since we plan to do that
universally; in another change soon we will finish the job.

I have additional removal and tidying, including removing the now unused
createImplicitInitialValue function entirely. But since this is already a large change, holding
those for followup.

* LayoutTests/editing/pasteboard/copy-paste-inserts-clearing-div-expected.txt:
Updated for progression where we use the background shorthand, not background-color.

* LayoutTests/fast/backgrounds/background-shorthand-after-set-backgroundSize-expected.txt:
* LayoutTests/fast/backgrounds/background-shorthand-with-backgroundSize-style-expected.txt:
* LayoutTests/fast/css/background-clip-text-expected.txt:
Expect more tests to pass.

* LayoutTests/fast/css/background-position-serialize-expected.txt: Progression where we serialize
background shorthand instead of background-image and background-position longhands.

* LayoutTests/fast/css/border-shorthand-initialize-longhands-expected.txt:
* LayoutTests/fast/css/longhand-overrides-shorthand-prefixing-expected.txt:
* LayoutTests/fast/css/parsing-text-emphasis-expected.txt:
Expect more tests to pass.

* LayoutTests/fast/css/remove-shorthand-expected.txt: Expect various shorthands to be handled
correctly, such as adding border-image, handling the background shorthand, and others.

* LayoutTests/fast/css/shorthand-mismatched-list-crash-expected.txt:
Expect test to pass.

* LayoutTests/fast/css/transform-inline-style-expected.txt: Don't expect initial values "ease" and
"0s" to be serialized.
* LayoutTests/fast/css/transform-inline-style-remove-expected.txt: Ditto, also initial values
"none" and "running".

* LayoutTests/fast/dom/background-shorthand-csstext-expected.txt:
* LayoutTests/fast/masking/parsing-mask-expected.txt:
* LayoutTests/fast/masking/parsing-webkit-mask-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/content-security-policy/style-src/inline-style-allowed-while-cloning-objects.sub-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-backgrounds/parsing/border-shorthand-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-masking/parsing/mask-position-valid-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-masking/parsing/mask-valid.sub-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-multicol/parsing/column-rule-shorthand-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-variables/variable-cssText-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/cssom/border-shorthand-serialization-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/cssom/serialize-values-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/cssom/shorthand-values-expected.txt:
* LayoutTests/platform/glib/imported/w3c/web-platform-tests/css/css-masking/parsing/mask-valid.sub-expected.txt:
Expect more tests to pass.

* Source/WebCore/css/CSSProperties.json: Added the border-image longhands to the border shorthand,
because the border shorthand sets all these properties to initial values. Also sort the offset
shorthand longhands in the order from the specification.

* Source/WebCore/css/StyleProperties.cpp:
(WebCore::StyleProperties::getPropertyValue const): If border-image shorthand values don't all
have their initial values, then do not serialize the border shorthand.
(WebCore::StyleProperties::get2Values const): Rewrote more simply, removing the isInitialValue
checks since commonShorthandChecks takes care of that now. Also use makeString instead of
StringBuilder since we can and it's more efficient.
(WebCore::StyleProperties::get4Values const): Rewrote more simply, removing the isInherited
and isInitialValue checks since commonShorthandChecks takes care of that now. Also use makeString
instead of StringBuilder since we can and it's more efficient.
(WebCore::isValueID): Added.
(WebCore::isPair): Added.
(WebCore::StyleProperties::getLayeredShorthandValue const): Rewrote this to use initial values
instead of relying on implicit flags to know what to not serialize. Added various rules that were
not present in the old version that are now needed for round tripping and omitting any value that
can be without changing the meaning.
(WebCore::StyleProperties::borderImagePropertyValue const): Serialize as "none" when everything
has the implicit flag set.
(WebCore::StyleProperties::borderPropertyValue const): Rewrote for simplicitly. Now checks for
initial values instead of depending on the implicit flag, using string comparisons since that's
the easiest way to build on getCommonValue. Also use makeString instead of StringBuilder.
(WebCore::StyleProperties::hasAllInitialValues const): Added.
(WebCore::canUseShorthandForLonghand): Allow use of the CSSPropertyBackground shorthand,
which did not work well before getLayeredShorthandValue omitted initial values.

* Source/WebCore/css/StyleProperties.h: Added hasAllInitialValues.

* Source/WebCore/css/parser/CSSPropertyParser.cpp:
(WebCore::CSSPropertyParser::addExpandedProperty): Renamed from addExpandedPropertyForValue
and added an implicit flag.
(WebCore::CSSPropertyParser::addExpandedPropertyWithImplicitDefault): Added.
(WebCore::CSSPropertyParser::parseValueStart): Updated for addExpandedProperty name change.
(WebCore::CSSPropertyParser::consumeCSSWideKeyword): Ditto.
(WebCore::initialValueForLonghand): Added.
(WebCore::initialCSSValueForLonghand): Added.
(WebCore::isNumber): Added.
(WebCore::pairValue): Added.
(WebCore::quadValue): Added.
(WebCore::isValueIDPair): Added.
(WebCore::isNumericQuad): Added.
(WebCore::isInitialValueForLonghand): Added.
(WebCore::initialValueTextForLonghand): Added.
(WebCore::CSSPropertyParser::consumeShorthandGreedily): Use initialCSSValueForLonghand for
implicit defaults rather than the implicit initial value.
(WebCore::CSSPropertyParser::consumeBorderShorthand): Renamed from consumeBorder. Do the calls
to addExpandedPropertyWithImplicitDefault here instead of in the caller, continuing to treat
the defaults as implicit values for now.
(WebCore::CSSPropertyParser::consumeBorderImage): Fixed CSSPropertyWebkitMaskBoxImageRepeat and
CSSPropertyBorderImageRepeat to use coalesced pairs of "stretch" for their initial values
rather than a single "stretch".
(WebCore::CSSPropertyParser::consumeAnimationShorthand): Use initialCSSValueForLonghand instead
of ComputedStyleExtractor::addValueForAnimationPropertyToList.
(WebCore::CSSPropertyParser::consumeBackgroundShorthand): Removed local variable "implicit"
that was always false. Use initialCSSValueForLonghand for implicit defaults rather than
implicit initial value.
(WebCore::CSSPropertyParser::parseShorthand): Use consumeBorderShorthand. For CSSPropertyBorder
itself, also set all the border-image longhands to their initial values.

* Source/WebCore/css/parser/CSSPropertyParser.h: Updated the addExpandedProperty functions.
Also added isInitialValueForLonghand and initialValueTextForLonghand, exported by the parser
but used by the serialization code.

Canonical link: https://commits.webkit.org/258061@main




More information about the webkit-changes mailing list