haikuwebkit/Source/WebCore/style/PseudoClassChangeInvalidati...

71 lines
2.5 KiB
C
Raw Permalink Normal View History

Accurate style invalidation for user action pseudo classes https://bugs.webkit.org/show_bug.cgi?id=208859 <rdar://problem/55196888> Reviewed by Zalan Bujtas. Source/WebCore: Currently :hover, :focus, :focus-within and :active lack fine grained invalidation using rule sets like we do with class and attribute selectors. This can be added easily following the same pattern. Tests: fast/selectors/style-invalidation-hover-change-descendants.html fast/selectors/style-invalidation-hover-change-siblings.html fast/selectors/style-invalidation-focus-change-descendants.html fast/selectors/style-invalidation-focus-change-siblings.html fast/selectors/style-invalidation-focus-within-change-descendants.html fast/selectors/style-invalidation-focus-within-change-siblings.html * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * dom/Element.cpp: (WebCore::Element::setActive): (WebCore::Element::setFocus): (WebCore::Element::setHasFocusWithin): (WebCore::Element::setHovered): Use PseudoClassChangeInvalidation. * dom/Element.h: (WebCore::Element::setHasFocusWithin): Deleted. * page/FrameViewLayoutContext.cpp: (WebCore::RenderTreeNeedsLayoutChecker::~RenderTreeNeedsLayoutChecker): * style/PseudoClassChangeInvalidation.cpp: Added. (WebCore::Style::PseudoClassChangeInvalidation::computeInvalidation): Compute invalidation rule set for a pseudo class change. (WebCore::Style::PseudoClassChangeInvalidation::invalidateStyleWithRuleSets): * style/PseudoClassChangeInvalidation.h: Added. (WebCore::Style::PseudoClassChangeInvalidation::PseudoClassChangeInvalidation): (WebCore::Style::PseudoClassChangeInvalidation::~PseudoClassChangeInvalidation): * style/RuleFeature.cpp: (WebCore::Style::RuleFeatureSet::recursivelyCollectFeaturesFromSelector): (WebCore::Style::RuleFeatureSet::collectFeatures): Collect pseudo class features, similar to classes/attributes. (WebCore::Style::RuleFeatureSet::add): (WebCore::Style::RuleFeatureSet::clear): (WebCore::Style::RuleFeatureSet::shrinkToFit): * style/RuleFeature.h: * style/StyleScopeRuleSets.cpp: (WebCore::Style::ScopeRuleSets::collectFeatures const): (WebCore::Style::ensureInvalidationRuleSets): Make more generic to allow enum key. (WebCore::Style::ScopeRuleSets::pseudoClassInvalidationRuleSets const): Create pseudo class invalidation ruleset. * style/StyleScopeRuleSets.h: LayoutTests: * fast/selectors/style-invalidation-focus-change-descendants-expected.txt: Added. * fast/selectors/style-invalidation-focus-change-descendants.html: Added. * fast/selectors/style-invalidation-focus-change-siblings-expected.txt: Added. * fast/selectors/style-invalidation-focus-change-siblings.html: Added. * fast/selectors/style-invalidation-focus-within-change-descendants-expected.txt: Added. * fast/selectors/style-invalidation-focus-within-change-descendants.html: Added. * fast/selectors/style-invalidation-focus-within-change-siblings-expected.txt: Added. * fast/selectors/style-invalidation-focus-within-change-siblings.html: Added. * fast/selectors/style-invalidation-hover-change-descendants-expected.txt: Added. * fast/selectors/style-invalidation-hover-change-descendants.html: Added. * fast/selectors/style-invalidation-hover-change-siblings-expected.txt: Added. * fast/selectors/style-invalidation-hover-change-siblings.html: Added. Canonical link: https://commits.webkit.org/221891@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@258321 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-03-12 13:30:10 +00:00
/*
* Copyright (C) 2020 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include "CSSSelector.h"
#include "Element.h"
#include "StyleInvalidator.h"
#include <wtf/Vector.h>
namespace WebCore {
namespace Style {
class PseudoClassChangeInvalidation {
public:
REGRESSION (r271584): Hovering slowly over and out of "Top 100" items on liberation.fr does not restore animated state https://bugs.webkit.org/show_bug.cgi?id=220862 <rdar://problem/73501684> Reviewed by Simon Fraser. Source/WebCore: The optimization in r271584 fails to invalidate hover/active style when clearing the existing state under some circumstances. Test: fast/selectors/hover-invalidation-descendant-clear.html * dom/Document.cpp: (WebCore::Document::updateHoverActiveState): We would do descendant invalidation when changing the hover/active state of the rootmost changing element. However since the state of descendants was changed before this invalidation happened we would try to invalidate them in a tree that was already in the new state. Fix by scoping the descendant invalidation over all changes. * dom/Element.cpp: (WebCore::Element::setActive): (WebCore::Element::setHovered): Switch to new 3-state enum type that allows us to skip descendant invalidation that has already been done by the caller. Skope it to Style namepace. * dom/Element.h: * html/HTMLAnchorElement.cpp: (WebCore::HTMLAnchorElement::setActive): * html/HTMLAnchorElement.h: * html/HTMLLabelElement.cpp: (WebCore::HTMLLabelElement::setActive): (WebCore::HTMLLabelElement::setHovered): * html/HTMLLabelElement.h: * html/shadow/SpinButtonElement.cpp: (WebCore::SpinButtonElement::setHovered): * html/shadow/SpinButtonElement.h: * style/PseudoClassChangeInvalidation.cpp: (WebCore::Style::PseudoClassChangeInvalidation::computeInvalidation): * style/PseudoClassChangeInvalidation.h: (WebCore::Style::PseudoClassChangeInvalidation::PseudoClassChangeInvalidation): * style/StyleValidity.h: LayoutTests: * fast/selectors/hover-invalidation-descendant-clear-expected.html: Added. * fast/selectors/hover-invalidation-descendant-clear.html: Added. Canonical link: https://commits.webkit.org/233376@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@271930 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-01-27 02:38:15 +00:00
PseudoClassChangeInvalidation(Element&, CSSSelector::PseudoClassType, InvalidationScope = InvalidationScope::All);
Accurate style invalidation for user action pseudo classes https://bugs.webkit.org/show_bug.cgi?id=208859 <rdar://problem/55196888> Reviewed by Zalan Bujtas. Source/WebCore: Currently :hover, :focus, :focus-within and :active lack fine grained invalidation using rule sets like we do with class and attribute selectors. This can be added easily following the same pattern. Tests: fast/selectors/style-invalidation-hover-change-descendants.html fast/selectors/style-invalidation-hover-change-siblings.html fast/selectors/style-invalidation-focus-change-descendants.html fast/selectors/style-invalidation-focus-change-siblings.html fast/selectors/style-invalidation-focus-within-change-descendants.html fast/selectors/style-invalidation-focus-within-change-siblings.html * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * dom/Element.cpp: (WebCore::Element::setActive): (WebCore::Element::setFocus): (WebCore::Element::setHasFocusWithin): (WebCore::Element::setHovered): Use PseudoClassChangeInvalidation. * dom/Element.h: (WebCore::Element::setHasFocusWithin): Deleted. * page/FrameViewLayoutContext.cpp: (WebCore::RenderTreeNeedsLayoutChecker::~RenderTreeNeedsLayoutChecker): * style/PseudoClassChangeInvalidation.cpp: Added. (WebCore::Style::PseudoClassChangeInvalidation::computeInvalidation): Compute invalidation rule set for a pseudo class change. (WebCore::Style::PseudoClassChangeInvalidation::invalidateStyleWithRuleSets): * style/PseudoClassChangeInvalidation.h: Added. (WebCore::Style::PseudoClassChangeInvalidation::PseudoClassChangeInvalidation): (WebCore::Style::PseudoClassChangeInvalidation::~PseudoClassChangeInvalidation): * style/RuleFeature.cpp: (WebCore::Style::RuleFeatureSet::recursivelyCollectFeaturesFromSelector): (WebCore::Style::RuleFeatureSet::collectFeatures): Collect pseudo class features, similar to classes/attributes. (WebCore::Style::RuleFeatureSet::add): (WebCore::Style::RuleFeatureSet::clear): (WebCore::Style::RuleFeatureSet::shrinkToFit): * style/RuleFeature.h: * style/StyleScopeRuleSets.cpp: (WebCore::Style::ScopeRuleSets::collectFeatures const): (WebCore::Style::ensureInvalidationRuleSets): Make more generic to allow enum key. (WebCore::Style::ScopeRuleSets::pseudoClassInvalidationRuleSets const): Create pseudo class invalidation ruleset. * style/StyleScopeRuleSets.h: LayoutTests: * fast/selectors/style-invalidation-focus-change-descendants-expected.txt: Added. * fast/selectors/style-invalidation-focus-change-descendants.html: Added. * fast/selectors/style-invalidation-focus-change-siblings-expected.txt: Added. * fast/selectors/style-invalidation-focus-change-siblings.html: Added. * fast/selectors/style-invalidation-focus-within-change-descendants-expected.txt: Added. * fast/selectors/style-invalidation-focus-within-change-descendants.html: Added. * fast/selectors/style-invalidation-focus-within-change-siblings-expected.txt: Added. * fast/selectors/style-invalidation-focus-within-change-siblings.html: Added. * fast/selectors/style-invalidation-hover-change-descendants-expected.txt: Added. * fast/selectors/style-invalidation-hover-change-descendants.html: Added. * fast/selectors/style-invalidation-hover-change-siblings-expected.txt: Added. * fast/selectors/style-invalidation-hover-change-siblings.html: Added. Canonical link: https://commits.webkit.org/221891@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@258321 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-03-12 13:30:10 +00:00
~PseudoClassChangeInvalidation();
private:
REGRESSION (r271584): Hovering slowly over and out of "Top 100" items on liberation.fr does not restore animated state https://bugs.webkit.org/show_bug.cgi?id=220862 <rdar://problem/73501684> Reviewed by Simon Fraser. Source/WebCore: The optimization in r271584 fails to invalidate hover/active style when clearing the existing state under some circumstances. Test: fast/selectors/hover-invalidation-descendant-clear.html * dom/Document.cpp: (WebCore::Document::updateHoverActiveState): We would do descendant invalidation when changing the hover/active state of the rootmost changing element. However since the state of descendants was changed before this invalidation happened we would try to invalidate them in a tree that was already in the new state. Fix by scoping the descendant invalidation over all changes. * dom/Element.cpp: (WebCore::Element::setActive): (WebCore::Element::setHovered): Switch to new 3-state enum type that allows us to skip descendant invalidation that has already been done by the caller. Skope it to Style namepace. * dom/Element.h: * html/HTMLAnchorElement.cpp: (WebCore::HTMLAnchorElement::setActive): * html/HTMLAnchorElement.h: * html/HTMLLabelElement.cpp: (WebCore::HTMLLabelElement::setActive): (WebCore::HTMLLabelElement::setHovered): * html/HTMLLabelElement.h: * html/shadow/SpinButtonElement.cpp: (WebCore::SpinButtonElement::setHovered): * html/shadow/SpinButtonElement.h: * style/PseudoClassChangeInvalidation.cpp: (WebCore::Style::PseudoClassChangeInvalidation::computeInvalidation): * style/PseudoClassChangeInvalidation.h: (WebCore::Style::PseudoClassChangeInvalidation::PseudoClassChangeInvalidation): * style/StyleValidity.h: LayoutTests: * fast/selectors/hover-invalidation-descendant-clear-expected.html: Added. * fast/selectors/hover-invalidation-descendant-clear.html: Added. Canonical link: https://commits.webkit.org/233376@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@271930 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-01-27 02:38:15 +00:00
void computeInvalidation(CSSSelector::PseudoClassType, Style::InvalidationScope);
Accurate style invalidation for user action pseudo classes https://bugs.webkit.org/show_bug.cgi?id=208859 <rdar://problem/55196888> Reviewed by Zalan Bujtas. Source/WebCore: Currently :hover, :focus, :focus-within and :active lack fine grained invalidation using rule sets like we do with class and attribute selectors. This can be added easily following the same pattern. Tests: fast/selectors/style-invalidation-hover-change-descendants.html fast/selectors/style-invalidation-hover-change-siblings.html fast/selectors/style-invalidation-focus-change-descendants.html fast/selectors/style-invalidation-focus-change-siblings.html fast/selectors/style-invalidation-focus-within-change-descendants.html fast/selectors/style-invalidation-focus-within-change-siblings.html * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * dom/Element.cpp: (WebCore::Element::setActive): (WebCore::Element::setFocus): (WebCore::Element::setHasFocusWithin): (WebCore::Element::setHovered): Use PseudoClassChangeInvalidation. * dom/Element.h: (WebCore::Element::setHasFocusWithin): Deleted. * page/FrameViewLayoutContext.cpp: (WebCore::RenderTreeNeedsLayoutChecker::~RenderTreeNeedsLayoutChecker): * style/PseudoClassChangeInvalidation.cpp: Added. (WebCore::Style::PseudoClassChangeInvalidation::computeInvalidation): Compute invalidation rule set for a pseudo class change. (WebCore::Style::PseudoClassChangeInvalidation::invalidateStyleWithRuleSets): * style/PseudoClassChangeInvalidation.h: Added. (WebCore::Style::PseudoClassChangeInvalidation::PseudoClassChangeInvalidation): (WebCore::Style::PseudoClassChangeInvalidation::~PseudoClassChangeInvalidation): * style/RuleFeature.cpp: (WebCore::Style::RuleFeatureSet::recursivelyCollectFeaturesFromSelector): (WebCore::Style::RuleFeatureSet::collectFeatures): Collect pseudo class features, similar to classes/attributes. (WebCore::Style::RuleFeatureSet::add): (WebCore::Style::RuleFeatureSet::clear): (WebCore::Style::RuleFeatureSet::shrinkToFit): * style/RuleFeature.h: * style/StyleScopeRuleSets.cpp: (WebCore::Style::ScopeRuleSets::collectFeatures const): (WebCore::Style::ensureInvalidationRuleSets): Make more generic to allow enum key. (WebCore::Style::ScopeRuleSets::pseudoClassInvalidationRuleSets const): Create pseudo class invalidation ruleset. * style/StyleScopeRuleSets.h: LayoutTests: * fast/selectors/style-invalidation-focus-change-descendants-expected.txt: Added. * fast/selectors/style-invalidation-focus-change-descendants.html: Added. * fast/selectors/style-invalidation-focus-change-siblings-expected.txt: Added. * fast/selectors/style-invalidation-focus-change-siblings.html: Added. * fast/selectors/style-invalidation-focus-within-change-descendants-expected.txt: Added. * fast/selectors/style-invalidation-focus-within-change-descendants.html: Added. * fast/selectors/style-invalidation-focus-within-change-siblings-expected.txt: Added. * fast/selectors/style-invalidation-focus-within-change-siblings.html: Added. * fast/selectors/style-invalidation-hover-change-descendants-expected.txt: Added. * fast/selectors/style-invalidation-hover-change-descendants.html: Added. * fast/selectors/style-invalidation-hover-change-siblings-expected.txt: Added. * fast/selectors/style-invalidation-hover-change-siblings.html: Added. Canonical link: https://commits.webkit.org/221891@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@258321 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-03-12 13:30:10 +00:00
void invalidateStyleWithRuleSets();
const bool m_isEnabled;
Element& m_element;
Invalidator::MatchElementRuleSets m_matchElementRuleSets;
};
REGRESSION (r271584): Hovering slowly over and out of "Top 100" items on liberation.fr does not restore animated state https://bugs.webkit.org/show_bug.cgi?id=220862 <rdar://problem/73501684> Reviewed by Simon Fraser. Source/WebCore: The optimization in r271584 fails to invalidate hover/active style when clearing the existing state under some circumstances. Test: fast/selectors/hover-invalidation-descendant-clear.html * dom/Document.cpp: (WebCore::Document::updateHoverActiveState): We would do descendant invalidation when changing the hover/active state of the rootmost changing element. However since the state of descendants was changed before this invalidation happened we would try to invalidate them in a tree that was already in the new state. Fix by scoping the descendant invalidation over all changes. * dom/Element.cpp: (WebCore::Element::setActive): (WebCore::Element::setHovered): Switch to new 3-state enum type that allows us to skip descendant invalidation that has already been done by the caller. Skope it to Style namepace. * dom/Element.h: * html/HTMLAnchorElement.cpp: (WebCore::HTMLAnchorElement::setActive): * html/HTMLAnchorElement.h: * html/HTMLLabelElement.cpp: (WebCore::HTMLLabelElement::setActive): (WebCore::HTMLLabelElement::setHovered): * html/HTMLLabelElement.h: * html/shadow/SpinButtonElement.cpp: (WebCore::SpinButtonElement::setHovered): * html/shadow/SpinButtonElement.h: * style/PseudoClassChangeInvalidation.cpp: (WebCore::Style::PseudoClassChangeInvalidation::computeInvalidation): * style/PseudoClassChangeInvalidation.h: (WebCore::Style::PseudoClassChangeInvalidation::PseudoClassChangeInvalidation): * style/StyleValidity.h: LayoutTests: * fast/selectors/hover-invalidation-descendant-clear-expected.html: Added. * fast/selectors/hover-invalidation-descendant-clear.html: Added. Canonical link: https://commits.webkit.org/233376@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@271930 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-01-27 02:38:15 +00:00
inline PseudoClassChangeInvalidation::PseudoClassChangeInvalidation(Element& element, CSSSelector::PseudoClassType pseudoClassType, Style::InvalidationScope invalidationScope)
Accurate style invalidation for user action pseudo classes https://bugs.webkit.org/show_bug.cgi?id=208859 <rdar://problem/55196888> Reviewed by Zalan Bujtas. Source/WebCore: Currently :hover, :focus, :focus-within and :active lack fine grained invalidation using rule sets like we do with class and attribute selectors. This can be added easily following the same pattern. Tests: fast/selectors/style-invalidation-hover-change-descendants.html fast/selectors/style-invalidation-hover-change-siblings.html fast/selectors/style-invalidation-focus-change-descendants.html fast/selectors/style-invalidation-focus-change-siblings.html fast/selectors/style-invalidation-focus-within-change-descendants.html fast/selectors/style-invalidation-focus-within-change-siblings.html * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * dom/Element.cpp: (WebCore::Element::setActive): (WebCore::Element::setFocus): (WebCore::Element::setHasFocusWithin): (WebCore::Element::setHovered): Use PseudoClassChangeInvalidation. * dom/Element.h: (WebCore::Element::setHasFocusWithin): Deleted. * page/FrameViewLayoutContext.cpp: (WebCore::RenderTreeNeedsLayoutChecker::~RenderTreeNeedsLayoutChecker): * style/PseudoClassChangeInvalidation.cpp: Added. (WebCore::Style::PseudoClassChangeInvalidation::computeInvalidation): Compute invalidation rule set for a pseudo class change. (WebCore::Style::PseudoClassChangeInvalidation::invalidateStyleWithRuleSets): * style/PseudoClassChangeInvalidation.h: Added. (WebCore::Style::PseudoClassChangeInvalidation::PseudoClassChangeInvalidation): (WebCore::Style::PseudoClassChangeInvalidation::~PseudoClassChangeInvalidation): * style/RuleFeature.cpp: (WebCore::Style::RuleFeatureSet::recursivelyCollectFeaturesFromSelector): (WebCore::Style::RuleFeatureSet::collectFeatures): Collect pseudo class features, similar to classes/attributes. (WebCore::Style::RuleFeatureSet::add): (WebCore::Style::RuleFeatureSet::clear): (WebCore::Style::RuleFeatureSet::shrinkToFit): * style/RuleFeature.h: * style/StyleScopeRuleSets.cpp: (WebCore::Style::ScopeRuleSets::collectFeatures const): (WebCore::Style::ensureInvalidationRuleSets): Make more generic to allow enum key. (WebCore::Style::ScopeRuleSets::pseudoClassInvalidationRuleSets const): Create pseudo class invalidation ruleset. * style/StyleScopeRuleSets.h: LayoutTests: * fast/selectors/style-invalidation-focus-change-descendants-expected.txt: Added. * fast/selectors/style-invalidation-focus-change-descendants.html: Added. * fast/selectors/style-invalidation-focus-change-siblings-expected.txt: Added. * fast/selectors/style-invalidation-focus-change-siblings.html: Added. * fast/selectors/style-invalidation-focus-within-change-descendants-expected.txt: Added. * fast/selectors/style-invalidation-focus-within-change-descendants.html: Added. * fast/selectors/style-invalidation-focus-within-change-siblings-expected.txt: Added. * fast/selectors/style-invalidation-focus-within-change-siblings.html: Added. * fast/selectors/style-invalidation-hover-change-descendants-expected.txt: Added. * fast/selectors/style-invalidation-hover-change-descendants.html: Added. * fast/selectors/style-invalidation-hover-change-siblings-expected.txt: Added. * fast/selectors/style-invalidation-hover-change-siblings.html: Added. Canonical link: https://commits.webkit.org/221891@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@258321 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-03-12 13:30:10 +00:00
: m_isEnabled(element.needsStyleInvalidation())
, m_element(element)
{
if (!m_isEnabled)
return;
REGRESSION (r271584): Hovering slowly over and out of "Top 100" items on liberation.fr does not restore animated state https://bugs.webkit.org/show_bug.cgi?id=220862 <rdar://problem/73501684> Reviewed by Simon Fraser. Source/WebCore: The optimization in r271584 fails to invalidate hover/active style when clearing the existing state under some circumstances. Test: fast/selectors/hover-invalidation-descendant-clear.html * dom/Document.cpp: (WebCore::Document::updateHoverActiveState): We would do descendant invalidation when changing the hover/active state of the rootmost changing element. However since the state of descendants was changed before this invalidation happened we would try to invalidate them in a tree that was already in the new state. Fix by scoping the descendant invalidation over all changes. * dom/Element.cpp: (WebCore::Element::setActive): (WebCore::Element::setHovered): Switch to new 3-state enum type that allows us to skip descendant invalidation that has already been done by the caller. Skope it to Style namepace. * dom/Element.h: * html/HTMLAnchorElement.cpp: (WebCore::HTMLAnchorElement::setActive): * html/HTMLAnchorElement.h: * html/HTMLLabelElement.cpp: (WebCore::HTMLLabelElement::setActive): (WebCore::HTMLLabelElement::setHovered): * html/HTMLLabelElement.h: * html/shadow/SpinButtonElement.cpp: (WebCore::SpinButtonElement::setHovered): * html/shadow/SpinButtonElement.h: * style/PseudoClassChangeInvalidation.cpp: (WebCore::Style::PseudoClassChangeInvalidation::computeInvalidation): * style/PseudoClassChangeInvalidation.h: (WebCore::Style::PseudoClassChangeInvalidation::PseudoClassChangeInvalidation): * style/StyleValidity.h: LayoutTests: * fast/selectors/hover-invalidation-descendant-clear-expected.html: Added. * fast/selectors/hover-invalidation-descendant-clear.html: Added. Canonical link: https://commits.webkit.org/233376@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@271930 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-01-27 02:38:15 +00:00
computeInvalidation(pseudoClassType, invalidationScope);
Accurate style invalidation for user action pseudo classes https://bugs.webkit.org/show_bug.cgi?id=208859 <rdar://problem/55196888> Reviewed by Zalan Bujtas. Source/WebCore: Currently :hover, :focus, :focus-within and :active lack fine grained invalidation using rule sets like we do with class and attribute selectors. This can be added easily following the same pattern. Tests: fast/selectors/style-invalidation-hover-change-descendants.html fast/selectors/style-invalidation-hover-change-siblings.html fast/selectors/style-invalidation-focus-change-descendants.html fast/selectors/style-invalidation-focus-change-siblings.html fast/selectors/style-invalidation-focus-within-change-descendants.html fast/selectors/style-invalidation-focus-within-change-siblings.html * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * dom/Element.cpp: (WebCore::Element::setActive): (WebCore::Element::setFocus): (WebCore::Element::setHasFocusWithin): (WebCore::Element::setHovered): Use PseudoClassChangeInvalidation. * dom/Element.h: (WebCore::Element::setHasFocusWithin): Deleted. * page/FrameViewLayoutContext.cpp: (WebCore::RenderTreeNeedsLayoutChecker::~RenderTreeNeedsLayoutChecker): * style/PseudoClassChangeInvalidation.cpp: Added. (WebCore::Style::PseudoClassChangeInvalidation::computeInvalidation): Compute invalidation rule set for a pseudo class change. (WebCore::Style::PseudoClassChangeInvalidation::invalidateStyleWithRuleSets): * style/PseudoClassChangeInvalidation.h: Added. (WebCore::Style::PseudoClassChangeInvalidation::PseudoClassChangeInvalidation): (WebCore::Style::PseudoClassChangeInvalidation::~PseudoClassChangeInvalidation): * style/RuleFeature.cpp: (WebCore::Style::RuleFeatureSet::recursivelyCollectFeaturesFromSelector): (WebCore::Style::RuleFeatureSet::collectFeatures): Collect pseudo class features, similar to classes/attributes. (WebCore::Style::RuleFeatureSet::add): (WebCore::Style::RuleFeatureSet::clear): (WebCore::Style::RuleFeatureSet::shrinkToFit): * style/RuleFeature.h: * style/StyleScopeRuleSets.cpp: (WebCore::Style::ScopeRuleSets::collectFeatures const): (WebCore::Style::ensureInvalidationRuleSets): Make more generic to allow enum key. (WebCore::Style::ScopeRuleSets::pseudoClassInvalidationRuleSets const): Create pseudo class invalidation ruleset. * style/StyleScopeRuleSets.h: LayoutTests: * fast/selectors/style-invalidation-focus-change-descendants-expected.txt: Added. * fast/selectors/style-invalidation-focus-change-descendants.html: Added. * fast/selectors/style-invalidation-focus-change-siblings-expected.txt: Added. * fast/selectors/style-invalidation-focus-change-siblings.html: Added. * fast/selectors/style-invalidation-focus-within-change-descendants-expected.txt: Added. * fast/selectors/style-invalidation-focus-within-change-descendants.html: Added. * fast/selectors/style-invalidation-focus-within-change-siblings-expected.txt: Added. * fast/selectors/style-invalidation-focus-within-change-siblings.html: Added. * fast/selectors/style-invalidation-hover-change-descendants-expected.txt: Added. * fast/selectors/style-invalidation-hover-change-descendants.html: Added. * fast/selectors/style-invalidation-hover-change-siblings-expected.txt: Added. * fast/selectors/style-invalidation-hover-change-siblings.html: Added. Canonical link: https://commits.webkit.org/221891@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@258321 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-03-12 13:30:10 +00:00
invalidateStyleWithRuleSets();
}
inline PseudoClassChangeInvalidation::~PseudoClassChangeInvalidation()
{
if (!m_isEnabled)
return;
invalidateStyleWithRuleSets();
}
}
}