[webkit-changes] [WebKit/WebKit] e154df: Cache lowercase version of the localName in Qualif...

Antti Koivisto noreply at github.com
Fri Apr 7 13:13:51 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: e154df3cee52425f8b218d270d812ee0af5fc06c
      https://github.com/WebKit/WebKit/commit/e154df3cee52425f8b218d270d812ee0af5fc06c
  Author: Antti Koivisto <antti at apple.com>
  Date:   2023-04-07 (Fri, 07 Apr 2023)

  Changed paths:
    M Source/WebCore/css/CSSSelector.cpp
    M Source/WebCore/css/CSSSelector.h
    M Source/WebCore/css/SelectorChecker.cpp
    M Source/WebCore/css/SelectorFilter.cpp
    M Source/WebCore/css/parser/CSSParserSelector.h
    M Source/WebCore/css/parser/CSSSelectorParser.cpp
    M Source/WebCore/css/parser/CSSSelectorParser.h
    M Source/WebCore/cssjit/SelectorCompiler.cpp
    M Source/WebCore/dom/Attribute.h
    M Source/WebCore/dom/Element.cpp
    M Source/WebCore/dom/Element.h
    M Source/WebCore/dom/QualifiedName.cpp
    M Source/WebCore/dom/QualifiedName.h
    M Source/WebCore/dom/QualifiedNameCache.cpp
    M Source/WebCore/html/HTMLElement.cpp
    M Source/WebCore/html/parser/HTMLTreeBuilder.cpp
    M Source/WebCore/style/AttributeChangeInvalidation.cpp
    M Source/WebCore/style/PseudoClassChangeInvalidation.cpp
    M Source/WebCore/style/RuleFeature.cpp
    M Source/WebCore/style/RuleFeature.h
    M Source/WebCore/style/RuleSet.cpp
    M Source/WebCore/style/RuleSet.h
    M Source/WebCore/style/StyleResolver.cpp
    M Source/WebCore/style/StyleResolver.h

  Log Message:
  -----------
  Cache lowercase version of the localName in QualifiedName
https://bugs.webkit.org/show_bug.cgi?id=255123
rdar://problem/107757119

Reviewed by Ryosuke Niwa and Chris Dumez.

This allows significant simplification of CSSSelector and some other things.

* Source/WebCore/css/CSSSelector.cpp:
(WebCore::CSSSelector::CSSSelector):
(WebCore::CSSSelector::createRareData):
(WebCore::CSSSelector::setAttribute):
(WebCore::CSSSelector::RareData::RareData):

No need to save the lowercase version of the attribute in the rare data anymore.
This shrinks and simplifies the type.

* Source/WebCore/css/CSSSelector.h:
(WebCore::CSSSelector::~CSSSelector):
(WebCore::CSSSelector::tagQName const):
(WebCore::CSSSelector::tagLowercaseLocalName const):
(WebCore::CSSSelector::NameWithCase::NameWithCase): Deleted.
(WebCore::CSSSelector::attributeCanonicalLocalName const): Deleted.
* Source/WebCore/css/SelectorChecker.cpp:
(WebCore::anyAttributeMatches):
(WebCore::SelectorChecker::attributeSelectorMatches):

Use lowercase versions for HTML elements in a HTML document.

* Source/WebCore/css/SelectorFilter.cpp:
(WebCore::SelectorFilter::collectElementIdentifierHashes):
(WebCore::SelectorFilter::collectSimpleSelectorHash):
(WebCore::localNameIsKnownToBeLowercase): Deleted.
* Source/WebCore/css/parser/CSSParserSelector.h:
(WebCore::CSSParserSelector::setAttribute):

We now pick whether to use lowercase or original version of the localName during selector matching,
similar to how tags are handled. This means selector parsing no longer depends on knowing if the document
is HTML or not.

* Source/WebCore/css/parser/CSSSelectorParser.cpp:
(WebCore::CSSSelectorParserContext::CSSSelectorParserContext):
(WebCore::CSSSelectorParserContext::operator== const):
(WebCore::add):
(WebCore::CSSSelectorParser::consumeAttribute):
* Source/WebCore/css/parser/CSSSelectorParser.h:
* Source/WebCore/cssjit/SelectorCompiler.cpp:
(WebCore::SelectorCompiler::canMatchStyleAttribute):
(WebCore::SelectorCompiler::canMatchAnimatableSVGAttribute):
(WebCore::SelectorCompiler::testIsHTMLClassOnDocument):
(WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementAndDocumentIsHTML):

Use lowercase versions for HTML elements in a HTML document.
Share code generation between tag and attribute matching. These are now handled the same way.

(WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementAttributeMatching):
(WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementAttributeValueExactMatching):
(WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementHasTagName):
* Source/WebCore/dom/Attribute.h:
(WebCore::Attribute::localNameLowercase const):
* Source/WebCore/dom/Element.cpp:
(WebCore::Element::isNonceable const):
* Source/WebCore/dom/Element.h:
(WebCore::Element::localNameLowercase const):
* Source/WebCore/dom/QualifiedName.cpp:
(WebCore::QualifiedName::QualifiedNameImpl::QualifiedNameImpl):
* Source/WebCore/dom/QualifiedName.h:
* Source/WebCore/dom/QualifiedNameCache.cpp:
(WebCore::updateImplWithNamespaceAndElementName):
(WebCore::QualifiedNameCache::getOrCreate):

Cache the lowercase localName. HTML names are always lowercase.

(WebCore::QualifiedName::localNameUppercase const):
(WebCore::QualifiedName::localNameUpper const): Deleted.
* Source/WebCore/dom/QualifiedName.h:
(WebCore::QualifiedName::localNameLowercase const):
* Source/WebCore/html/HTMLElement.cpp:
(WebCore::HTMLElement::nodeName const):
* Source/WebCore/style/AttributeChangeInvalidation.cpp:
(WebCore::Style::mayBeAffectedByAttributeChange):
(WebCore::Style::AttributeChangeInvalidation::invalidateStyle):
* Source/WebCore/style/PseudoClassChangeInvalidation.cpp:
(WebCore::Style::makePseudoClassInvalidationKeys):
* Source/WebCore/style/RuleFeature.cpp:
(WebCore::Style::RuleFeatureSet::recursivelyCollectFeaturesFromSelector):
(WebCore::Style::RuleFeatureSet::collectFeatures):
(WebCore::Style::RuleFeatureSet::add):
(WebCore::Style::RuleFeatureSet::registerContentAttribute):
(WebCore::Style::RuleFeatureSet::clear):
* Source/WebCore/style/RuleFeature.h:
* Source/WebCore/style/RuleSet.cpp:
(WebCore::Style::shouldHaveBucketForAttributeName):
(WebCore::Style::RuleSet::addRule):
(WebCore::Style::RuleSet::traverseRuleDatas):
(WebCore::Style::RuleSet::shrinkToFit):
* Source/WebCore/style/RuleSet.h:
(WebCore::Style::RuleSet::attributeRules const):

Replace "canonical" with "lowercase" similar to the tag case. Which name is used is decided at matching time.

* Source/WebCore/style/StyleResolver.cpp:
(WebCore::Style::Resolver::hasSelectorForAttribute const):
(WebCore::Style::Resolver::hasSelectorForId const):
* Source/WebCore/style/StyleResolver.h:
(WebCore::Style::Resolver::hasSelectorForAttribute const): Deleted.
(WebCore::Style::Resolver::hasSelectorForId const): Deleted.

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




More information about the webkit-changes mailing list