Skip to content

Commit

Permalink
Inline DOMTokenList::associatedAttributeValueChanged
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=274041

Reviewed by Chris Dumez.

Inlined this function and remove the unused argument.

Also made the class final since there is no subclass.

* Source/WebCore/dom/Element.cpp:
(WebCore::Element::classAttributeChanged):
(WebCore::Element::partAttributeChanged):
* Source/WebCore/html/DOMTokenList.cpp:
(WebCore::DOMTokenList::associatedAttributeValueChanged): Deleted.
* Source/WebCore/html/DOMTokenList.h:
(WebCore::DOMTokenList::associatedAttributeValueChanged):
(WebCore::DOMTokenList::DOMTokenList): Deleted.
(WebCore::DOMTokenList::ref): Deleted.
(WebCore::DOMTokenList::deref): Deleted.
(WebCore::DOMTokenList::isSupportedPropertyIndex const): Deleted.
(WebCore::DOMTokenList::element const): Deleted.
(WebCore::DOMTokenList::tokens const): Deleted.
* Source/WebCore/html/HTMLAnchorElement.cpp:
(WebCore::HTMLAnchorElement::attributeChanged):
* Source/WebCore/html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::attributeChanged):
* Source/WebCore/html/HTMLIFrameElement.cpp:
(WebCore::HTMLIFrameElement::attributeChanged):
* Source/WebCore/html/HTMLLinkElement.cpp:
(WebCore::HTMLLinkElement::attributeChanged):
* Source/WebCore/html/HTMLOutputElement.cpp:
(WebCore::HTMLOutputElement::attributeChanged):
* Source/WebCore/svg/SVGAElement.cpp:
(WebCore::SVGAElement::attributeChanged):

Canonical link: https://commits.webkit.org/278728@main
  • Loading branch information
rniwa committed May 14, 2024
1 parent 2ab063f commit 27f9caa
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 20 deletions.
4 changes: 2 additions & 2 deletions Source/WebCore/dom/Element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2314,7 +2314,7 @@ void Element::classAttributeChanged(const AtomString& newClassString)

if (hasRareData()) {
if (auto* classList = elementRareData()->classList())
classList->associatedAttributeValueChanged(newClassString);
classList->associatedAttributeValueChanged();
}
}

Expand All @@ -2326,7 +2326,7 @@ void Element::partAttributeChanged(const AtomString& newValue)

if (hasRareData()) {
if (auto* partList = elementRareData()->partList())
partList->associatedAttributeValueChanged(newValue);
partList->associatedAttributeValueChanged();
}

if (needsStyleInvalidation() && isInShadowTree())
Expand Down
9 changes: 0 additions & 9 deletions Source/WebCore/html/DOMTokenList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,15 +254,6 @@ void DOMTokenList::updateTokensFromAttributeValue(const AtomString& value)
m_tokensNeedUpdating = false;
}

void DOMTokenList::associatedAttributeValueChanged(const AtomString&)
{
// Do not reset the DOMTokenList value if the attribute value was changed by us.
if (m_inUpdateAssociatedAttributeFromTokens)
return;

m_tokensNeedUpdating = true;
}

// https://dom.spec.whatwg.org/#concept-dtl-update
void DOMTokenList::updateAssociatedAttributeFromTokens()
{
Expand Down
12 changes: 10 additions & 2 deletions Source/WebCore/html/DOMTokenList.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@

namespace WebCore {

class DOMTokenList {
class DOMTokenList final {
WTF_MAKE_FAST_ALLOCATED;
public:
using IsSupportedTokenFunction = Function<bool(Document&, StringView)>;
DOMTokenList(Element&, const QualifiedName& attributeName, IsSupportedTokenFunction&& isSupportedToken = { });

void associatedAttributeValueChanged(const AtomString&);
inline void associatedAttributeValueChanged();

void ref() { m_element.ref(); }
void deref() { m_element.deref(); }
Expand Down Expand Up @@ -90,4 +90,12 @@ inline const AtomString& DOMTokenList::item(unsigned index) const
return index < tokens.size() ? tokens[index] : nullAtom();
}

inline void DOMTokenList::associatedAttributeValueChanged()
{
// Do not reset the DOMTokenList value if the attribute value was changed by us.
if (m_inUpdateAssociatedAttributeFromTokens)
return;
m_tokensNeedUpdating = true;
}

} // namespace WebCore
2 changes: 1 addition & 1 deletion Source/WebCore/html/HTMLAnchorElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ void HTMLAnchorElement::attributeChanged(const QualifiedName& name, const AtomSt
if (relValue.contains(opener))
m_linkRelations.add(Relation::Opener);
if (m_relList)
m_relList->associatedAttributeValueChanged(newValue);
m_relList->associatedAttributeValueChanged();
}
}

Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/html/HTMLFormElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ void HTMLFormElement::attributeChanged(const QualifiedName& name, const AtomStri
break;
case AttributeNames::relAttr:
if (m_relList)
m_relList->associatedAttributeValueChanged(newValue);
m_relList->associatedAttributeValueChanged();
break;
default:
HTMLElement::attributeChanged(name, oldValue, newValue, attributeModificationReason);
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/html/HTMLIFrameElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void HTMLIFrameElement::attributeChanged(const QualifiedName& name, const AtomSt
switch (name.nodeName()) {
case AttributeNames::sandboxAttr: {
if (m_sandbox)
m_sandbox->associatedAttributeValueChanged(newValue);
m_sandbox->associatedAttributeValueChanged();

String invalidTokens;
setSandboxFlags(newValue.isNull() ? SandboxNone : SecurityContext::parseSandboxPolicy(newValue, invalidTokens));
Expand Down
4 changes: 2 additions & 2 deletions Source/WebCore/html/HTMLLinkElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ void HTMLLinkElement::attributeChanged(const QualifiedName& name, const AtomStri
auto didMutateRel = parsedRel != m_relAttribute;
m_relAttribute = WTFMove(parsedRel);
if (m_relList)
m_relList->associatedAttributeValueChanged(newValue);
m_relList->associatedAttributeValueChanged();
if (didMutateRel)
process();
break;
Expand All @@ -191,7 +191,7 @@ void HTMLLinkElement::attributeChanged(const QualifiedName& name, const AtomStri
break;
case AttributeNames::sizesAttr:
if (m_sizes)
m_sizes->associatedAttributeValueChanged(newValue);
m_sizes->associatedAttributeValueChanged();
process();
break;
case AttributeNames::mediaAttr: {
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/html/HTMLOutputElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ bool HTMLOutputElement::supportsFocus() const
void HTMLOutputElement::attributeChanged(const QualifiedName& name, const AtomString& oldValue, const AtomString& newValue, AttributeModificationReason attributeModificationReason)
{
if (name == HTMLNames::forAttr && m_forTokens)
m_forTokens->associatedAttributeValueChanged(newValue);
m_forTokens->associatedAttributeValueChanged();
HTMLFormControlElement::attributeChanged(name, oldValue, newValue, attributeModificationReason);
}

Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/svg/SVGAElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void SVGAElement::attributeChanged(const QualifiedName& name, const AtomString&
return;
} else if (name == SVGNames::relAttr) {
if (m_relList)
m_relList->associatedAttributeValueChanged(newValue);
m_relList->associatedAttributeValueChanged();
}

SVGURIReference::parseAttribute(name, newValue);
Expand Down

0 comments on commit 27f9caa

Please sign in to comment.