Skip to content

Commit

Permalink
Cherry-pick 270421@main (f738f43). https://bugs.webkit.org/show_bug.c…
Browse files Browse the repository at this point in the history
…gi?id=264442

    Compilation failure using gcc (GCC) 13.2.1 20231011 (Red Hat 13.2.1-4)
    https://bugs.webkit.org/show_bug.cgi?id=264442
    rdar://118141764

    Reviewed by Alex Christensen.

    Fix compilation error "error: possibly dangling reference to a temporary [-Werror=dangling-reference]"
    No change in observable behaviour.

    * Source/WebCore/dom/TreeScope.cpp:
    (WebCore::TreeScope::findAnchor):
    * Source/WebCore/dom/TreeScopeOrderedMap.cpp:
    (WebCore::TreeScopeOrderedMap::get const):

    Canonical link: https://commits.webkit.org/270421@main
  • Loading branch information
jyavenard authored and aperezdc committed Jan 25, 2024
1 parent 7d947bc commit 958bda0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions Source/WebCore/dom/TreeScope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,9 @@ Element* TreeScope::findAnchor(StringView name)
return nullptr;
if (Element* element = getElementById(name))
return element;
for (auto& anchor : descendantsOfType<HTMLAnchorElement>(m_rootNode)) {
if (m_rootNode.document().inQuirksMode()) {
Ref rootNode = m_rootNode;
for (auto& anchor : descendantsOfType<HTMLAnchorElement>(rootNode)) {
if (rootNode->document().inQuirksMode()) {
// Quirks mode, ASCII case-insensitive comparison of names.
// FIXME: This behavior is not mentioned in the HTML specification.
// We should either remove this or get this into the specification.
Expand Down
3 changes: 2 additions & 1 deletion Source/WebCore/dom/TreeScopeOrderedMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ inline Element* TreeScopeOrderedMap::get(const AtomStringImpl& key, const TreeSc
}

// We know there's at least one node that matches; iterate to find the first one.
for (auto& element : descendantsOfType<Element>(scope.rootNode())) {
Ref rootNode = scope.rootNode();
for (auto& element : descendantsOfType<Element>(rootNode)) {
if (!element.isInTreeScope())
continue;
if (!keyMatches(key, element))
Expand Down

0 comments on commit 958bda0

Please sign in to comment.