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

:has(~:dir(~)) should work #3801

Merged
merged 1 commit into from
Sep 1, 2022
Merged

Conversation

rniwa
Copy link
Member

@rniwa rniwa commented Aug 30, 2022

ded49fa

:has(~:dir(~)) should work
https://bugs.webkit.org/show_bug.cgi?id=243093

Reviewed by Antti Koivisto.

Implement :dir pseudo class invalidation. This patch introduces the notion of effective text direction
which is stored in Node's rareDataBitfields. To signify whether this is used for text direction or not,
another boolean value usesEffectiveTextDirection has been added to rareDataBitfields.

Like https://commits.webkit.org/253764@main for :lang, this patch has an optimization to avoid using
rareDataBitfields when the text direction matches that of the document element.

* LayoutTests/TestExpectations: Removed image only failures from tests that are now passing.
* LayoutTests/fast/css/dir-pseudo-container-query-expected.html: Added.
* LayoutTests/fast/css/dir-pseudo-container-query-invalidation-expected.html: Added.
* LayoutTests/fast/css/dir-pseudo-container-query-invalidation.html: Added.
* LayoutTests/fast/css/dir-pseudo-container-query.html: Added.
* LayoutTests/platform/win/TestExpectations: Skip the newly added tests since :dir isn't enabled yet.

* Source/WebCore/css/SelectorCheckerTestFunctions.h
(WebCore::matchesDirPseudoClass): Now uses effectiveTextDirection instead of computeDirectionality.

* Source/WebCore/dom/Document.cpp:
(WebCore::Document::childrenChanged): Calls setDocumentElementTextDirection. Note we need to explicitly
check usesEffectiveTextDirection since effectiveTextDirection falls back to documentElementTextDirection.

* Source/WebCore/dom/Document.h:
(WebCore::Document::documentElementTextDirection const): Added.
(WebCore::Document::setDocumentElementTextDirection): Added.

* Source/WebCore/dom/Node.cpp:
(WebCore::Node::incrementConnectedSubframeCount):
(WebCore::Node::effectiveTextDirection const): Added.
(WebCore::Node::setEffectiveTextDirection): Added.
(WebCore::Node::setUsesEffectiveTextDirection): Added.

* Source/WebCore/dom/Node.h:
(WebCore::Node::usesEffectiveTextDirection const): Added.

* Source/WebCore/html/HTMLElement.cpp:
(WebCore::TextDirectionDirective): Added.
(WebCore::parseTextDirection): Added.
(WebCore::isValidDirValue): Now uses parseTextDirection.
(WebCore::elementAffectsDirectionality): Moved up to be used in insertedIntoAncestor.
(WebCore::HTMLElement::insertedIntoAncestor): Inherit the effective text direction from parent unless
this is an input type=telephone.
(WebCore::HTMLElement::removedFromAncestor): Added. Clear the inherited effective text direction.
(WebCore::HTMLElement::computeDirectionality const): Removed.
(WebCore::HTMLElement::dirAttributeChanged): Added the invalidation logic for each value type. Notably,
when the new value is invalid, we inherit from the parent node unless this is an input type=telephone.
(WebCore::HTMLElement::updateEffectiveDirectionality): Added. Implements the recursive invalidation
for :dir pseudo class.
(WebCore::HTMLElement::adjustDirectionalityIfNeededAfterChildAttributeChanged): Update the effective
text direction instead of simply invalidating the style.
(WebCore::HTMLElement::updateEffectiveDirectionalityOfDirAuto): Ditto.
(WebCore::HTMLElement::adjustDirectionalityIfNeededAfterChildrenChanged):

* Source/WebCore/html/HTMLElement.h:

* Source/WebCore/html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::subtreeHasChanged): Don't call updateEffectiveDirectionalityOfDirAuto
if this element hasn't been marked with selfOrPrecedingNodesAffectDirAuto. Otherwise, we'd set
selfOrPrecedingNodesAffectDirAuto on input element without dir=auto. This was caught by new assertions.
(WebCore::HTMLInputElement::setValue): Added a call to updateEffectiveDirectionalityOfDirAuto when
selfOrPrecedingNodesAffectDirAuto is set. This is needed now that the effective text direction is cached
as opposed to re-computed each time in computeDirectionality.

* Source/WebCore/html/HTMLTextAreaElement.cpp:
(WebCore::HTMLTextAreaElement::subtreeHasChanged): Same as HTMLInputElement.
(WebCore::HTMLTextAreaElement::setValueCommon): Ditto.

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

760a9df

Misc iOS, tvOS & watchOS macOS Linux Windows
❌ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe 🛠 🧪 win
✅ 🧪 bindings ✅ 🛠 ios-sim 🛠 mac-debug ✅ 🛠 gtk ✅ 🛠 wincairo
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🛠 mac-AS-debug ✅ 🧪 gtk-wk2
✅ 🧪 api-ios 🧪 api-mac ✅ 🧪 api-gtk
✅ 🛠 tv 🧪 mac-wk1
✅ 🛠 tv-sim ✅ 🧪 mac-wk2
✅ 🛠 🧪 merge ✅ 🛠 watch ✅ 🧪 mac-AS-debug-wk2
✅ 🛠 watch-sim ✅ 🧪 mac-wk2-stress

@rniwa rniwa requested a review from cdumez as a code owner August 30, 2022 13:41
@rniwa rniwa self-assigned this Aug 30, 2022
@rniwa rniwa added CSS Cascading Style Sheets implementation WebKit Nightly Build labels Aug 30, 2022
@rniwa rniwa requested a review from anttijk August 30, 2022 13:42
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Aug 30, 2022
@rniwa rniwa removed the merging-blocked Applied to prevent a change from being merged label Aug 30, 2022
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Aug 30, 2022
@rniwa rniwa removed the merging-blocked Applied to prevent a change from being merged label Aug 30, 2022
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Aug 31, 2022
@rniwa rniwa removed the merging-blocked Applied to prevent a change from being merged label Aug 31, 2022
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Aug 31, 2022
@rniwa rniwa removed the merging-blocked Applied to prevent a change from being merged label Aug 31, 2022
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Aug 31, 2022
@rniwa rniwa removed the merging-blocked Applied to prevent a change from being merged label Aug 31, 2022
Comment on lines 1582 to 1598
webkit.org/b/64861 imported/w3c/web-platform-tests/css/selectors/dir-style-01a.html [ ImageOnlyFailure ]
webkit.org/b/64861 imported/w3c/web-platform-tests/css/selectors/dir-style-01b.html [ ImageOnlyFailure ]
Copy link
Contributor

Choose a reason for hiding this comment

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

wonder what is still wrong with these?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's anti-aliasing issue. See #3842

@rniwa rniwa added the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Aug 31, 2022
@webkit-commit-queue
Copy link
Collaborator

No reviewer information in commit message, blocking PR #3801

@webkit-commit-queue webkit-commit-queue removed the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Aug 31, 2022
@webkit-commit-queue webkit-commit-queue added the merging-blocked Applied to prevent a change from being merged label Aug 31, 2022
@rniwa rniwa removed the merging-blocked Applied to prevent a change from being merged label Aug 31, 2022
@rniwa rniwa added the merge-queue Applied to send a pull request to merge-queue label Aug 31, 2022
https://bugs.webkit.org/show_bug.cgi?id=243093

Reviewed by Antti Koivisto.

Implement :dir pseudo class invalidation. This patch introduces the notion of effective text direction
which is stored in Node's rareDataBitfields. To signify whether this is used for text direction or not,
another boolean value usesEffectiveTextDirection has been added to rareDataBitfields.

Like https://commits.webkit.org/253764@main for :lang, this patch has an optimization to avoid using
rareDataBitfields when the text direction matches that of the document element.

* LayoutTests/TestExpectations: Removed image only failures from tests that are now passing.
* LayoutTests/fast/css/dir-pseudo-container-query-expected.html: Added.
* LayoutTests/fast/css/dir-pseudo-container-query-invalidation-expected.html: Added.
* LayoutTests/fast/css/dir-pseudo-container-query-invalidation.html: Added.
* LayoutTests/fast/css/dir-pseudo-container-query.html: Added.
* LayoutTests/platform/win/TestExpectations: Skip the newly added tests since :dir isn't enabled yet.

* Source/WebCore/css/SelectorCheckerTestFunctions.h
(WebCore::matchesDirPseudoClass): Now uses effectiveTextDirection instead of computeDirectionality.

* Source/WebCore/dom/Document.cpp:
(WebCore::Document::childrenChanged): Calls setDocumentElementTextDirection. Note we need to explicitly
check usesEffectiveTextDirection since effectiveTextDirection falls back to documentElementTextDirection.

* Source/WebCore/dom/Document.h:
(WebCore::Document::documentElementTextDirection const): Added.
(WebCore::Document::setDocumentElementTextDirection): Added.

* Source/WebCore/dom/Node.cpp:
(WebCore::Node::incrementConnectedSubframeCount):
(WebCore::Node::effectiveTextDirection const): Added.
(WebCore::Node::setEffectiveTextDirection): Added.
(WebCore::Node::setUsesEffectiveTextDirection): Added.

* Source/WebCore/dom/Node.h:
(WebCore::Node::usesEffectiveTextDirection const): Added.

* Source/WebCore/html/HTMLElement.cpp:
(WebCore::TextDirectionDirective): Added.
(WebCore::parseTextDirection): Added.
(WebCore::isValidDirValue): Now uses parseTextDirection.
(WebCore::elementAffectsDirectionality): Moved up to be used in insertedIntoAncestor.
(WebCore::HTMLElement::insertedIntoAncestor): Inherit the effective text direction from parent unless
this is an input type=telephone.
(WebCore::HTMLElement::removedFromAncestor): Added. Clear the inherited effective text direction.
(WebCore::HTMLElement::computeDirectionality const): Removed.
(WebCore::HTMLElement::dirAttributeChanged): Added the invalidation logic for each value type. Notably,
when the new value is invalid, we inherit from the parent node unless this is an input type=telephone.
(WebCore::HTMLElement::updateEffectiveDirectionality): Added. Implements the recursive invalidation
for :dir pseudo class.
(WebCore::HTMLElement::adjustDirectionalityIfNeededAfterChildAttributeChanged): Update the effective
text direction instead of simply invalidating the style.
(WebCore::HTMLElement::updateEffectiveDirectionalityOfDirAuto): Ditto.
(WebCore::HTMLElement::adjustDirectionalityIfNeededAfterChildrenChanged):

* Source/WebCore/html/HTMLElement.h:

* Source/WebCore/html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::subtreeHasChanged): Don't call updateEffectiveDirectionalityOfDirAuto
if this element hasn't been marked with selfOrPrecedingNodesAffectDirAuto. Otherwise, we'd set
selfOrPrecedingNodesAffectDirAuto on input element without dir=auto. This was caught by new assertions.
(WebCore::HTMLInputElement::setValue): Added a call to updateEffectiveDirectionalityOfDirAuto when
selfOrPrecedingNodesAffectDirAuto is set. This is needed now that the effective text direction is cached
as opposed to re-computed each time in computeDirectionality.

* Source/WebCore/html/HTMLTextAreaElement.cpp:
(WebCore::HTMLTextAreaElement::subtreeHasChanged): Same as HTMLInputElement.
(WebCore::HTMLTextAreaElement::setValueCommon): Ditto.

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

Committed 254017@main (ded49fa): https://commits.webkit.org/254017@main

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

@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Sep 1, 2022
@rniwa rniwa deleted the fix243093 branch September 21, 2022 05:20
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
Development

Successfully merging this pull request may close these issues.

5 participants