Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: f8d6173df229a9ed92ba8175d23789e4bfe75bff
      
https://github.com/WebKit/WebKit/commit/f8d6173df229a9ed92ba8175d23789e4bfe75bff
  Author: Ahmad Saleem <[email protected]>
  Date:   2026-03-18 (Wed, 18 Mar 2026)

  Changed paths:
    A 
LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/image-maps/image-map-processing-model/hash-name-reference-dynamic-expected.txt
    A 
LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/image-maps/image-map-processing-model/hash-name-reference-dynamic.html
    M 
LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/image-maps/image-map-processing-model/hash-name-reference-expected.txt
    A 
LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/image-maps/image-map-processing-model/hash-name-reference-id-update-expected.txt
    A 
LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/image-maps/image-map-processing-model/hash-name-reference-id-update.html
    M 
LayoutTests/imported/w3c/web-platform-tests/uievents/mouse/mouse_boundary_events_on_image_map-expected.txt
    M Source/WebCore/dom/TreeScope.cpp
    M Source/WebCore/dom/TreeScope.h
    M Source/WebCore/dom/TreeScopeOrderedMap.cpp
    M Source/WebCore/html/HTMLMapElement.cpp
    M Source/WebCore/html/parser/HTMLParserIdioms.cpp

  Log Message:
  -----------
  Fix HTML map element not matching image using id attribute
https://bugs.webkit.org/show_bug.cgi?id=91228
rdar://12359382

Reviewed by Ryosuke Niwa.

The spec says that parsing a hash-name reference to a map element [1]
should find the first map element in tree order whose name or id
attribute matches the fragment, regardless of HTML versus XML syntax.

WebKit was only using the name attribute for HTML documents (ignoring
id entirely), and for XML documents it used whichever of name/id was
parsed last, ignoring the other.

This patch also fixes parseHTMLHashNameReference to handle the case
where the '#' is the last character in the string, which per spec [2]
should return null, fixing usemap="#" and usemap="hash-last#" cases.

Lastly, this also fixes the code that considers both id and name to pass
old attribute values explicitly to removeImageMap, since by the time
attributeChanged is called the element's attribute is already updated
to the new value.

[1] 
https://html.spec.whatwg.org/multipage/image-maps.html#image-map-processing-model
[2] 
https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#syntax-references

* Source/WebCore/html/parser/HTMLParserIdioms.cpp:
(WebCore::parseHTMLHashNameReference): Return nullAtom() for empty fragments.
* Source/WebCore/html/HTMLMapElement.cpp:
(WebCore::HTMLMapElement::attributeChanged): Remove HTML-only restriction;
handle both name and id attributes uniformly; remove redundant base class call.
* Source/WebCore/dom/TreeScope.cpp:
(WebCore::TreeScope::addImageMap): Register by both name and id.
(WebCore::TreeScope::removeImageMap): Unregister by both name and id.
* Source/WebCore/dom/TreeScopeOrderedMap.cpp:
(WebCore::TreeScopeOrderedMap::getElementByMapName): Match by either name or id.
* 
LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/image-maps/image-map-processing-model/hash-name-reference-dynamic-expected.txt:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/image-maps/image-map-processing-model/hash-name-reference-dynamic.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/image-maps/image-map-processing-model/hash-name-reference-id-update-expected.txt:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/image-maps/image-map-processing-model/hash-name-reference-id-update.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/image-maps/image-map-processing-model/hash-name-reference-expected.txt:
 Progressions
* 
LayoutTests/imported/w3c/web-platform-tests/uievents/mouse/mouse_boundary_events_on_image_map-expected.txt:
 Ditto

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to