Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate RenderListMarker with @counter-style #10871

Conversation

vitorroriz
Copy link
Contributor

@vitorroriz vitorroriz commented Mar 1, 2023

2e241f9

Integrate RenderListMarker with @counter-style
https://bugs.webkit.org/show_bug.cgi?id=253158
rdar://102988393

Reviewed by Tim Nguyen.

This patch integrates RenderListMarker with
the parsed counter-style at-rules and fixes
some bugs catched during rendering.

Since we are wiring things up here, we can stop
skipping the related tests.

Some tests will still fail because we are missing:
- Support to shadow DOM scope.
- Integration with counters() function.
- Integration with symbols() function.
- Complex predefined symbols.
- Allowing redefinition of predefined symbols.
- Bug on wpt references regarding prefix/suffix fallback.
The missing items are linked to their issues in TestExpectations.

* LayoutTests/TestExpectations:
- Stop skipping the related tests. We are also tagging the tests
that we still fail due to missing feature/wpt bugs and we are
linking the relevant issues.

* LayoutTests/imported/w3c/web-platform-tests/css/css-counter-styles/counter-style-at-rule/support/ref-common.css:
(div, p):
* LayoutTests/imported/w3c/web-platform-tests/css/css-counter-styles/counter-style-at-rule/support/test-common.css:
(li, p):
- Avoid fuzziness in the relevant tests. This change is also pushed to WPT (web-platform-tests/wpt#38773

* Source/WebCore/css/CSSCounterStyle.cpp:
(WebCore::CSSCounterStyle::counterForSystemCyclic const):
(WebCore::CSSCounterStyle::applyPadSymbols const):
- Fixing bugs in padding and cyclic-system.

* Source/WebCore/css/CSSCounterStyleRegistry.cpp:
(WebCore::CSSCounterStyleRegistry::resolveExtendsReference):
- We were forgetting to pass the map for reference resolution
during the resolution of author rules, which would make the
user agent map to be used instead, by default.

* Source/WebCore/css/CSSProperties.json:
- Enabling custom-ident parsing in list-style-type.

* Source/WebCore/css/counterStyles.css:
(@counter-style cjk-decimal):
(@counter-style disclosure-open):
(@counter-style disclosure-closed):
- Update the symbols for disclosure open/closed.

* Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp:
(WebCore::CSSPropertyParserHelpers::consumeCounterStyleAdditiveSymbols):
- Fixing bug where we would not invalidate additive-symbol with missing symbol.
This would cause a crash during rendering.

* Source/WebCore/rendering/style/RenderStyle.cpp:
(WebCore::rareInheritedDataChangeRequiresLayout):
- listStyleStringValue change now requires layout, since it defines the name of the counter-style.
* Source/WebCore/rendering/RenderListMarker.cpp:
(WebCore::RenderListMarker::updateContent):
* Source/WebCore/style/StyleBuilderCustom.h:
(WebCore::Style::BuilderCustom::applyValueListStyleType):
- Rendering Marker according to counter-style.

* LayoutTests/TestExpectations:
* LayoutTests/imported/w3c/web-platform-tests/css/css-lists/parsing/list-style-type-computed-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-lists/parsing/list-style-type-valid-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/list-style-type-expected.txt:
- We have new tests passing after fixing presentation hint mapping for LI and UL elements.

* Source/WebCore/css/ComputedStyleExtractor.cpp:
(WebCore::ComputedStyleExtractor::valueForPropertyInStyle):

* Source/WebCore/html/HTMLLIElement.cpp:
(WebCore::HTMLLIElement::collectPresentationalHintsForAttribute):
* Source/WebCore/html/HTMLUListElement.cpp:
(WebCore::HTMLUListElement::collectPresentationalHintsForAttribute):
- Fixing presentational hint mapping for LI and UL elements.

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

f547428

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac   πŸ›  wpe   πŸ›  wincairo
βœ… πŸ§ͺ bindings loading πŸ›  ios-sim βœ… πŸ›  mac-AS-debug ❌ πŸ§ͺ wpe-wk2
βœ… πŸ§ͺ webkitperl   πŸ§ͺ ios-wk2   πŸ§ͺ api-mac βœ… πŸ›  gtk
  πŸ§ͺ api-ios βœ… πŸ§ͺ mac-wk1   πŸ§ͺ gtk-wk2
  πŸ›  tv   πŸ§ͺ mac-wk2   πŸ§ͺ api-gtk
βœ… πŸ›  tv-sim   πŸ§ͺ mac-AS-debug-wk2
βœ… πŸ›  watch βœ… πŸ§ͺ mac-wk2-stress
βœ… πŸ›  πŸ§ͺ merge βœ… πŸ›  watch-sim

@vitorroriz vitorroriz self-assigned this Mar 1, 2023
@vitorroriz vitorroriz added the CSS Cascading Style Sheets implementation label Mar 1, 2023
@vitorroriz vitorroriz requested a review from nt1m March 1, 2023 16:26
@nt1m nt1m requested a review from alanbaradlay March 1, 2023 20:51
@vitorroriz vitorroriz force-pushed the render-list-marker-with-counter-styles branch from 1cf6c1b to 22664b4 Compare March 2, 2023 01:10
auto text = makeString(counterStyle()->prefix(), counterStyle()->text(m_listItem->value()));
m_textWithSuffix = makeString(text, counterStyle()->suffix());
m_textWithoutSuffixLength = text.length();
m_textIsLeftToRightDirection = u_charDirection(text[0]) != U_RIGHT_TO_LEFT;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it ok to just checking the first character? (or go with ubidi_getBaseDirection)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've followed the pattern that is already done for all other ListStyleTypes (case default) and case String.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, though that does not necessarily mean it is correct.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh look, there's a FIXME about this right there.
// FIXME: Depending on the string value, we may need the real bidi algorithm.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, but we don't have tests failing for now. Shouldn't we investigate this in another radar? I'm adding a new value to ListStyleType.

in RenderListMarker::textRun() there is a comment:

// Since the bidi algorithm doesn't run on this text, we instead reorder the characters here.
// We use u_charDirection to figure out if the marker text is RTL and assume the suffix matches the surrounding direction.

I've created rdar://106139180 so we can investigate it. I'll update the FIXME comment with the radar link after current pipeline finish running so it don't get reset.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect! Thanks!

@alanbaradlay
Copy link
Contributor

I have one comment on the rendering change. Someone should check the parsing part, looks ok otherwise.

@@ -1843,13 +1843,19 @@ void RenderListMarker::updateContent()
auto type = style().listStyleType();
switch (type) {
// FIXME: handle CSSCounterStyle case rdar://102988393.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove this comment?

@@ -8281,6 +8281,8 @@ RefPtr<CSSValue> consumeCounterStyleAdditiveSymbols(CSSParserTokenRange& range,
if (!integer)
return nullptr;
}
if (!symbol)
return nullptr;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we check for !symbol before checking for !integer and remove the !symbol check inside !integer?

Copy link
Contributor Author

@vitorroriz vitorroriz Mar 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the symbol and weight can appear in any order [<integer [0,∞]> && <symbol>]#

else if (valueLowerCase == "square"_s)
addPropertyToPresentationalHintStyle(style, CSSPropertyListStyleType, CSSValueSquare);
else if (valueLowerCase == "none"_s)
addPropertyToPresentationalHintStyle(style, CSSPropertyListStyleType, CSSValueNone);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please indent this

@vitorroriz vitorroriz force-pushed the render-list-marker-with-counter-styles branch from 22664b4 to 9e4bf65 Compare March 2, 2023 01:50
@vitorroriz vitorroriz added merge-queue Applied to send a pull request to merge-queue and removed merge-queue Applied to send a pull request to merge-queue labels Mar 2, 2023
@vitorroriz vitorroriz force-pushed the render-list-marker-with-counter-styles branch from 9e4bf65 to 31a2e47 Compare March 2, 2023 15:22
@vitorroriz vitorroriz force-pushed the render-list-marker-with-counter-styles branch from 31a2e47 to 516c158 Compare March 2, 2023 16:28
@vitorroriz vitorroriz force-pushed the render-list-marker-with-counter-styles branch from 516c158 to d0e52df Compare March 2, 2023 20:54
@vitorroriz vitorroriz force-pushed the render-list-marker-with-counter-styles branch 2 times, most recently from f83220e to be0825e Compare March 3, 2023 00:48
Comment on lines 49 to 50
unsigned symbolIndex { 0 };
symbolIndex = static_cast<unsigned>(value > 0 ? value : value + amountOfSymbols);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
unsigned symbolIndex { 0 };
symbolIndex = static_cast<unsigned>(value > 0 ? value : value + amountOfSymbols);
unsigned symbolIndex = static_cast<unsigned>(value > 0 ? value : value + amountOfSymbols);

A comment explaining this is to avoid substracting 1 from the minimum integer would be nice.

Comment on lines 1859 to 1860
} else
markerAsString();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems incorrect? If the counter-style doesn't exist, it should fallback to decimal I think.

@vitorroriz vitorroriz force-pushed the render-list-marker-with-counter-styles branch from be0825e to 3bf57d2 Compare March 3, 2023 02:13
@vitorroriz vitorroriz force-pushed the render-list-marker-with-counter-styles branch from 3bf57d2 to e081219 Compare March 3, 2023 02:23
@vitorroriz vitorroriz added the merge-queue Applied to send a pull request to merge-queue label Mar 3, 2023
@nt1m nt1m removed the merge-queue Applied to send a pull request to merge-queue label Mar 3, 2023
@vitorroriz vitorroriz force-pushed the render-list-marker-with-counter-styles branch from e081219 to 15612fd Compare March 3, 2023 10:29
@vitorroriz vitorroriz added merge-queue Applied to send a pull request to merge-queue and removed merge-queue Applied to send a pull request to merge-queue labels Mar 3, 2023
@vitorroriz vitorroriz force-pushed the render-list-marker-with-counter-styles branch from 15612fd to f547428 Compare March 3, 2023 11:12
@vitorroriz vitorroriz added the merge-queue Applied to send a pull request to merge-queue label Mar 3, 2023
https://bugs.webkit.org/show_bug.cgi?id=253158
rdar://102988393

Reviewed by Tim Nguyen.

This patch integrates RenderListMarker with
the parsed counter-style at-rules and fixes
some bugs catched during rendering.

Since we are wiring things up here, we can stop
skipping the related tests.

Some tests will still fail because we are missing:
- Support to shadow DOM scope.
- Integration with counters() function.
- Integration with symbols() function.
- Complex predefined symbols.
- Allowing redefinition of predefined symbols.
- Bug on wpt references regarding prefix/suffix fallback.
The missing items are linked to their issues in TestExpectations.

* LayoutTests/TestExpectations:
- Stop skipping the related tests. We are also tagging the tests
that we still fail due to missing feature/wpt bugs and we are
linking the relevant issues.

* LayoutTests/imported/w3c/web-platform-tests/css/css-counter-styles/counter-style-at-rule/support/ref-common.css:
(div, p):
* LayoutTests/imported/w3c/web-platform-tests/css/css-counter-styles/counter-style-at-rule/support/test-common.css:
(li, p):
- Avoid fuzziness in the relevant tests. This change is also pushed to WPT (web-platform-tests/wpt#38773)

* Source/WebCore/css/CSSCounterStyle.cpp:
(WebCore::CSSCounterStyle::counterForSystemCyclic const):
(WebCore::CSSCounterStyle::applyPadSymbols const):
- Fixing bugs in padding and cyclic-system.

* Source/WebCore/css/CSSCounterStyleRegistry.cpp:
(WebCore::CSSCounterStyleRegistry::resolveExtendsReference):
- We were forgetting to pass the map for reference resolution
during the resolution of author rules, which would make the
user agent map to be used instead, by default.

* Source/WebCore/css/CSSProperties.json:
- Enabling custom-ident parsing in list-style-type.

* Source/WebCore/css/counterStyles.css:
(@counter-style cjk-decimal):
(@counter-style disclosure-open):
(@counter-style disclosure-closed):
- Update the symbols for disclosure open/closed.

* Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp:
(WebCore::CSSPropertyParserHelpers::consumeCounterStyleAdditiveSymbols):
- Fixing bug where we would not invalidate additive-symbol with missing symbol.
This would cause a crash during rendering.

* Source/WebCore/rendering/style/RenderStyle.cpp:
(WebCore::rareInheritedDataChangeRequiresLayout):
- listStyleStringValue change now requires layout, since it defines the name of the counter-style.
* Source/WebCore/rendering/RenderListMarker.cpp:
(WebCore::RenderListMarker::updateContent):
* Source/WebCore/style/StyleBuilderCustom.h:
(WebCore::Style::BuilderCustom::applyValueListStyleType):
- Rendering Marker according to counter-style.

* LayoutTests/TestExpectations:
* LayoutTests/imported/w3c/web-platform-tests/css/css-lists/parsing/list-style-type-computed-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-lists/parsing/list-style-type-valid-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/the-stylepropertymap/properties/list-style-type-expected.txt:
- We have new tests passing after fixing presentation hint mapping for LI and UL elements.

* Source/WebCore/css/ComputedStyleExtractor.cpp:
(WebCore::ComputedStyleExtractor::valueForPropertyInStyle):

* Source/WebCore/html/HTMLLIElement.cpp:
(WebCore::HTMLLIElement::collectPresentationalHintsForAttribute):
* Source/WebCore/html/HTMLUListElement.cpp:
(WebCore::HTMLUListElement::collectPresentationalHintsForAttribute):
- Fixing presentational hint mapping for LI and UL elements.

Canonical link: https://commits.webkit.org/261135@main
@webkit-commit-queue
Copy link
Collaborator

Committed 261135@main (2e241f9): https://commits.webkit.org/261135@main

Reviewed commits have been landed. Closing PR #10871 and removing active labels.

@webkit-early-warning-system webkit-early-warning-system merged commit 2e241f9 into WebKit:main Mar 3, 2023
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Mar 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CSS Cascading Style Sheets implementation
Projects
None yet
5 participants