Skip to content

Commit

Permalink
Quirk getElementsByName() on older iPadOS apps
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=270229
rdar://122548304

Reviewed by Ryosuke Niwa.

272530@main aligned us with the HTML Standard for getElementsByName()
by making it only work for HTML elements.

There is at least one iPadOS app that is impacted by that change. This
change should give them a bit of time to catch up by making
getElementsByName() look at all elements again for older iPadOS apps.

* Source/WTF/wtf/cocoa/RuntimeApplicationChecksCocoa.h:
* Source/WebCore/dom/NameNodeList.cpp:
(WebCore::NameNodeList::NameNodeList):
(WebCore::NameNodeList::elementMatches const):
* Source/WebCore/dom/NameNodeList.h:
* Source/WebCore/page/Quirks.cpp:
(WebCore::Quirks::needsGetElementsByNameQuirk const):
* Source/WebCore/page/Quirks.h:

Canonical link: https://commits.webkit.org/275779@main
  • Loading branch information
annevk committed Mar 7, 2024
1 parent 211b6e1 commit 290968e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions Source/WTF/wtf/cocoa/RuntimeApplicationChecksCocoa.h
Expand Up @@ -67,6 +67,7 @@ enum class SDKAlignedBehavior {
ModernCompabilityModeByDefault,
NoClientCertificateLookup,
NoExpandoIndexedPropertiesOnWindow,
NoGetElementsByNameQuirk,
NoIMDbCSSOMViewScrollingQuirk,
NoLaBanquePostaleQuirks,
NoMoviStarPlusCORSPreflightQuirk,
Expand Down
4 changes: 3 additions & 1 deletion Source/WebCore/dom/NameNodeList.cpp
Expand Up @@ -26,6 +26,7 @@
#include "ElementInlines.h"
#include "LiveNodeListInlines.h"
#include "NodeRareData.h"
#include "Quirks.h"
#include <wtf/IsoMallocInlines.h>

namespace WebCore {
Expand All @@ -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())
{
}

Expand All @@ -52,7 +54,7 @@ NameNodeList::~NameNodeList()

bool NameNodeList::elementMatches(Element& element) const
{
return element.isHTMLElement() && element.getNameAttribute() == m_name;
return (is<HTMLElement>(element) || m_needsGetElementsByNameQuirk) && element.getNameAttribute() == m_name;
}

} // namespace WebCore
1 change: 1 addition & 0 deletions Source/WebCore/dom/NameNodeList.h
Expand Up @@ -40,6 +40,7 @@ class NameNodeList final : public CachedLiveNodeList<NameNodeList> {
NameNodeList(ContainerNode& rootNode, const AtomString& name);

AtomString m_name;
bool m_needsGetElementsByNameQuirk;
};

} // namespace WebCore
11 changes: 11 additions & 0 deletions Source/WebCore/page/Quirks.cpp
Expand Up @@ -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. <rdar://122548304>
bool Quirks::needsGetElementsByNameQuirk() const
{
#if PLATFORM(IOS)
return needsQuirks() && !PAL::currentUserInterfaceIdiomIsSmallScreen() && !linkedOnOrAfterSDKWithBehavior(SDKAlignedBehavior::NoGetElementsByNameQuirk);
#else
return false;
#endif
}

}
2 changes: 2 additions & 0 deletions Source/WebCore/page/Quirks.h
Expand Up @@ -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;
Expand Down

0 comments on commit 290968e

Please sign in to comment.