[CSS Shadow Parts] :part rules should be able to override style attribute
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 Oct 2019 16:20:17 +0000 (16:20 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 Oct 2019 16:20:17 +0000 (16:20 +0000)
commit6971d994e3cbb092d09fed9ac9229b05d51c707f
treeda68dc75398073f83dd5a407be00adea68b93f74
parentac34c90b44b96bf0aa0714fc829acdb9fa9fe8d2
[CSS Shadow Parts] :part rules should be able to override style attribute
https://bugs.webkit.org/show_bug.cgi?id=202919

Reviewed by Zalan Bujtas.

LayoutTests/imported/w3c:

* web-platform-tests/css/css-shadow-parts/simple-inline-expected.txt:

Source/WebCore:

Element inline style was simply appended to the matching declaration list and not sorted with the rest of the author style.
This used to work because before CSS Shadow Parts feature inline style would always win.

Fixing this involves refactoring the rule collection code to remove this assumption.

* css/ElementRuleCollector.cpp:
(WebCore::ElementRuleCollector::addMatchedRule):

Both initialize and update ranges here.

(WebCore::ElementRuleCollector::clearMatchedRules):
(WebCore::ElementRuleCollector::addElementStyleProperties):

Both initialize and update ranges here.

(WebCore::ElementRuleCollector::sortAndTransferMatchedRules):

Split out transfering to a separate function.

(WebCore::ElementRuleCollector::transferMatchedRules):

Add a parameter to limit transfer to rules from a scope.

(WebCore::ElementRuleCollector::matchAuthorRules):
(WebCore::ElementRuleCollector::matchesAnyAuthorRules):

Replace hasMatchedRules() with a more specific function. This can use collectMatchingAuthorRules and avoids unnecessary sorting step.

(WebCore::ElementRuleCollector::collectMatchingAuthorRules):

Split out collecting the rules from matchAuthorRules. Like other collect functions, this doesn't do any sorting.

(WebCore::ElementRuleCollector::matchAllRules):

Add element inline style before transfering rules from the containing host scope.

(WebCore::ElementRuleCollector::addElementInlineStyleProperties):

Factor adding inline style into a function.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@251285 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/simple-inline-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/css/ElementRuleCollector.cpp
Source/WebCore/css/ElementRuleCollector.h
Source/WebCore/css/StyleProperties.h
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/style/StyleInvalidator.cpp
Source/WebCore/style/StyleScope.h