[webkit-changes] [WebKit/WebKit] 35c672: [css-lists] Implement `counter-set` property

Tim Nguyen noreply at github.com
Tue Aug 22 09:59:03 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 35c672ab42641db0295b649a694a3355bf2b03e2
      https://github.com/WebKit/WebKit/commit/35c672ab42641db0295b649a694a3355bf2b03e2
  Author: Tim Nguyen <ntim at apple.com>
  Date:   2023-08-22 (Tue, 22 Aug 2023)

  Changed paths:
    M LayoutTests/TestExpectations
    M LayoutTests/fast/css/counters/counter-list-item-expected.html
    M LayoutTests/fast/css/counters/counter-list-item.html
    M LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/all-prop-initial-xml-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/all-prop-revert-layer-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-lists/css-lists-no-interpolation-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-lists/parsing/counter-set-computed-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-lists/parsing/counter-set-valid-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/counter-set-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-values/calc-rounds-to-integer-expected.txt
    M LayoutTests/platform/gtk/imported/w3c/web-platform-tests/css/css-cascade/all-prop-initial-xml-expected.txt
    M LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/css/css-cascade/all-prop-initial-xml-expected.txt
    M LayoutTests/platform/ipad/imported/w3c/web-platform-tests/css/css-cascade/all-prop-initial-xml-expected.txt
    M LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/css/css-cascade/all-prop-initial-xml-expected.txt
    M LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/css/css-cascade/all-prop-revert-layer-expected.txt
    M LayoutTests/platform/wpe/imported/w3c/web-platform-tests/css/css-cascade/all-prop-initial-xml-expected.txt
    M Source/WebCore/animation/CSSPropertyAnimation.cpp
    M Source/WebCore/css/CSSProperties.json
    M Source/WebCore/css/ComputedStyleExtractor.cpp
    M Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp
    M Source/WebCore/css/parser/CSSPropertyParserHelpers.h
    M Source/WebCore/html/HTMLLIElement.cpp
    M Source/WebCore/html/HTMLLIElement.h
    M Source/WebCore/rendering/CounterNode.cpp
    M Source/WebCore/rendering/CounterNode.h
    M Source/WebCore/rendering/RenderCounter.cpp
    M Source/WebCore/rendering/RenderListItem.cpp
    M Source/WebCore/rendering/RenderListItem.h
    M Source/WebCore/rendering/style/CounterDirectives.h
    M Source/WebCore/style/StyleBuilderCustom.h

  Log Message:
  -----------
  [css-lists] Implement `counter-set` property
https://bugs.webkit.org/show_bug.cgi?id=97337
rdar://88663348

Reviewed by Cameron McCormack and Darin Adler.

This implements the `counter-set` property as per https://drafts.csswg.org/css-lists/#propdef-counter-set .

This property applies at the final step after:
- counter-reset
- counter-increment

Unlike counter-reset, counter-set does not create new counters if they already exist.

In order for interactions with the `list-item` counter to be correct, it does these changes per the HTML spec:
- It starts using a `counter-set` presentional hint to implement the `<li>` value attribute
- `counter-reset`, `counter-set` and `counter-increment` can now be overriden on list-item

This matches Firefox's behavior and is also closer to Chrome's.

* LayoutTests/fast/css/counters/counter-list-item-expected.html:
* LayoutTests/fast/css/counters/counter-list-item.html:
* LayoutTests/TestExpectations:
* LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/all-prop-initial-xml-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/all-prop-revert-layer-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-lists/css-lists-no-interpolation-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-lists/parsing/counter-set-computed-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-lists/parsing/counter-set-valid-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/counter-set-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-values/calc-rounds-to-integer-expected.txt:
* LayoutTests/platform/gtk/imported/w3c/web-platform-tests/css/css-cascade/all-prop-initial-xml-expected.txt:
* LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/css/css-cascade/all-prop-initial-xml-expected.txt:
* LayoutTests/platform/ipad/imported/w3c/web-platform-tests/css/css-cascade/all-prop-initial-xml-expected.txt:
* LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/css/css-cascade/all-prop-initial-xml-expected.txt:
* LayoutTests/platform/wpe/imported/w3c/web-platform-tests/css/css-cascade/all-prop-initial-xml-expected.txt:

Rebaselines.

* Source/WebCore/animation/CSSPropertyAnimation.cpp:
(WebCore::CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap):

Add animation support for counter-set.

* Source/WebCore/css/CSSProperties.json:
* Source/WebCore/css/ComputedStyleExtractor.cpp:
(WebCore::counterToCSSValue):
(WebCore::ComputedStyleExtractor::valueForPropertyInStyle const):
* Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp:
(WebCore::CSSPropertyParserHelpers::consumeCounterSet):
* Source/WebCore/css/parser/CSSPropertyParserHelpers.h:

Parse and define the counter-set property.

* Source/WebCore/html/HTMLLIElement.cpp:
(WebCore::HTMLLIElement::hasPresentationalHintsForAttribute const):
(WebCore::HTMLLIElement::collectPresentationalHintsForAttribute):
(WebCore::HTMLLIElement::didAttachRenderers):
(WebCore::HTMLLIElement::attributeChanged): Deleted.
(WebCore::HTMLLIElement::parseValue): Deleted.
* Source/WebCore/html/HTMLLIElement.h:

Implement <li value> as counter-set presentiational hint.

* Source/WebCore/rendering/CounterNode.cpp:
(WebCore::CounterNode::CounterNode):
(WebCore::CounterNode::create):
(WebCore::CounterNode::computeCountInParent const):
(WebCore::CounterNode::insertAfter):
* Source/WebCore/rendering/CounterNode.h:
(WebCore::CounterNode::actsAsReset const):
(WebCore::CounterNode::hasResetType const):
(WebCore::CounterNode::hasSetType const):
* Source/WebCore/rendering/RenderCounter.cpp:
(WebCore::listItemCounterDirectives):
(WebCore::planCounter):
(WebCore::findPlaceForCounter):
(WebCore::makeCounterNode):

Integrate counter-set with counters.

* Source/WebCore/rendering/RenderListItem.cpp:
(WebCore::RenderListItem::updateValueNow const):
(WebCore::RenderListItem::updateValue):

Take in account counter-set / counter-increment when calculating the value.

(WebCore::RenderListItem::styleDidChange):
(WebCore::RenderListItem::counterDirectivesChanged):

Invalidate list markers when counter properties change.

(WebCore::RenderListItem::explicitValueChanged): Deleted.
(WebCore::RenderListItem::setExplicitValue): Deleted.

Delete old <li value> code, replaced by presentational hints.

* Source/WebCore/rendering/RenderListItem.h:
* Source/WebCore/rendering/style/CounterDirectives.h:
(WebCore::operator==):

Expand equality operator.

* Source/WebCore/style/StyleBuilderCustom.h:
(WebCore::Style::BuilderCustom::applyInheritCounter):
(WebCore::Style::BuilderCustom::applyValueCounter):
(WebCore::Style::BuilderCustom::applyInitialCounterSet):
(WebCore::Style::BuilderCustom::applyInheritCounterSet):
(WebCore::Style::BuilderCustom::applyValueCounterSet):

Convert CSSValues to counter directives.

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




More information about the webkit-changes mailing list