diff --git a/Source/WTF/wtf/cocoa/RuntimeApplicationChecksCocoa.h b/Source/WTF/wtf/cocoa/RuntimeApplicationChecksCocoa.h index 96a6d856e4886..9585794a4cdf0 100644 --- a/Source/WTF/wtf/cocoa/RuntimeApplicationChecksCocoa.h +++ b/Source/WTF/wtf/cocoa/RuntimeApplicationChecksCocoa.h @@ -67,6 +67,7 @@ enum class SDKAlignedBehavior { ModernCompabilityModeByDefault, NoClientCertificateLookup, NoExpandoIndexedPropertiesOnWindow, + NoGetElementsByNameQuirk, NoIMDbCSSOMViewScrollingQuirk, NoLaBanquePostaleQuirks, NoMoviStarPlusCORSPreflightQuirk, diff --git a/Source/WebCore/dom/NameNodeList.cpp b/Source/WebCore/dom/NameNodeList.cpp index 68bd796e80e87..13830f2f133da 100644 --- a/Source/WebCore/dom/NameNodeList.cpp +++ b/Source/WebCore/dom/NameNodeList.cpp @@ -26,6 +26,7 @@ #include "ElementInlines.h" #include "LiveNodeListInlines.h" #include "NodeRareData.h" +#include "Quirks.h" #include namespace WebCore { @@ -37,6 +38,7 @@ WTF_MAKE_ISO_ALLOCATED_IMPL(NameNodeList); NameNodeList::NameNodeList(ContainerNode& rootNode, const AtomString& name) : CachedLiveNodeList(rootNode, NodeListInvalidationType::InvalidateOnNameAttrChange) , m_name(name) + , m_needsGetElementsByNameQuirk(rootNode.document().quirks().needsGetElementsByNameQuirk()) { } @@ -52,7 +54,7 @@ NameNodeList::~NameNodeList() bool NameNodeList::elementMatches(Element& element) const { - return element.isHTMLElement() && element.getNameAttribute() == m_name; + return (is(element) || m_needsGetElementsByNameQuirk) && element.getNameAttribute() == m_name; } } // namespace WebCore diff --git a/Source/WebCore/dom/NameNodeList.h b/Source/WebCore/dom/NameNodeList.h index f8d8c2bff8b9e..7f55fd2003593 100644 --- a/Source/WebCore/dom/NameNodeList.h +++ b/Source/WebCore/dom/NameNodeList.h @@ -40,6 +40,7 @@ class NameNodeList final : public CachedLiveNodeList { NameNodeList(ContainerNode& rootNode, const AtomString& name); AtomString m_name; + bool m_needsGetElementsByNameQuirk; }; } // namespace WebCore diff --git a/Source/WebCore/page/Quirks.cpp b/Source/WebCore/page/Quirks.cpp index 3310109b0a92d..4005e10a9b8a6 100644 --- a/Source/WebCore/page/Quirks.cpp +++ b/Source/WebCore/page/Quirks.cpp @@ -1853,4 +1853,15 @@ bool Quirks::shouldUseEphemeralPartitionedStorageForDOMCookies(const URL& url) c return false; } +// This quirk has intentionally limited exposure to increase the odds of being able to remove it +// again within a reasonable timeframe as the impacted apps are being updated. +bool Quirks::needsGetElementsByNameQuirk() const +{ +#if PLATFORM(IOS) + return needsQuirks() && !PAL::currentUserInterfaceIdiomIsSmallScreen() && !linkedOnOrAfterSDKWithBehavior(SDKAlignedBehavior::NoGetElementsByNameQuirk); +#else + return false; +#endif +} + } diff --git a/Source/WebCore/page/Quirks.h b/Source/WebCore/page/Quirks.h index 990370007bbaa..c7070a31160cb 100644 --- a/Source/WebCore/page/Quirks.h +++ b/Source/WebCore/page/Quirks.h @@ -189,6 +189,8 @@ class Quirks { bool shouldIgnorePlaysInlineRequirementQuirk() const; WEBCORE_EXPORT bool shouldUseEphemeralPartitionedStorageForDOMCookies(const URL&) const; + bool needsGetElementsByNameQuirk() const; + private: bool needsQuirks() const; bool isDomain(const String&) const;