haikuwebkit/LayoutTests/fast/shadow-dom/shadow-style-invalidation-p...

28 lines
788 B
HTML
Raw Permalink Normal View History

REGRESSION(iOS 14): Author shadow DOM invalidated unnecessarily on pseudo element change https://bugs.webkit.org/show_bug.cgi?id=222187 <rdar://problem/74801314> Reviewed by Ryosuke Niwa. Source/WebCore: Hovering the element causes us to invalidate the entire author shadow tree style. The invalidation is triggered by the user agent stylesheet having some :hover rules targeting pseudo elements. This should not require invalidation except for those specific elements and only for UA shadow trees. This patch optimizes the case and avoids unnecessary invalidations. Test: fast/shadow-dom/shadow-style-invalidation-pseudo-element.html * html/HTMLInputElement.cpp: (WebCore::HTMLInputElement::handleFocusEvent): (WebCore::HTMLInputElement::handleBlurEvent): (WebCore::HTMLInputElement::invalidateStyleOnFocusChangeIfNeeded): Input elements with 'text-overflow:ellipsis' (which is affected by focus) were relying on spurious invalidations that we now optimize away. Invalidate properly. * html/HTMLInputElement.h: * style/ElementRuleCollector.cpp: (WebCore::Style::ElementRuleCollector::collectMatchingShadowPseudoElementRules): * style/RuleSet.cpp: (WebCore::Style::RuleSet::evaluateDynamicMediaQueryRules): (WebCore::Style::RuleSet::hasShadowPseudoElementRules const): Deleted. Handle ::cue separately. * style/RuleSet.h: (WebCore::Style::RuleSet::cuePseudoRules const): (WebCore::Style::RuleSet::hasShadowPseudoElementRules const): * style/StyleInvalidationFunctions.h: (WebCore::Style::traverseRuleFeatures): * style/StyleInvalidator.cpp: (WebCore::Style::Invalidator::collectRuleInformation): (WebCore::Style::Invalidator::invalidateShadowPseudoElements): Narrowly invalidate user agent shadow tree pseudo elements. (WebCore::Style::Invalidator::invalidateInShadowTreeIfNeeded): * style/StyleInvalidator.h: LayoutTests: * fast/shadow-dom/shadow-style-invalidation-pseudo-element-expected.txt: Added. * fast/shadow-dom/shadow-style-invalidation-pseudo-element.html: Added. Canonical link: https://commits.webkit.org/237321@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277001 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-05 04:38:19 +00:00
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<style>
:focus { color: green }
:focus::placeholder { color: blue }
</style>
<div id=host tabindex=1></div>
<script>
var host = document.getElementById('host');
var shadow = host.attachShadow({mode: 'closed'});
shadow.innerHTML = `
<div>shadow</div>
`;
test(() => {
internals.updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks();
host.focus();
var div = shadow.querySelector("div");
assert_equals(internals.styleChangeType(host), "InlineStyleChange");
assert_equals(internals.styleChangeType(div), "NoStyleChange");
}, "Author shadow tree is not invalidated in presence of user agent shadow tree targeting pseudo elements");
</script>