<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - Link preview doesn't work on XHTML pages with Content-Type header as `application/xhtml+xml`"
   href="https://bugs.webkit.org/show_bug.cgi?id=150740#c7">Comment # 7</a>
              on <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - Link preview doesn't work on XHTML pages with Content-Type header as `application/xhtml+xml`"
   href="https://bugs.webkit.org/show_bug.cgi?id=150740">bug 150740</a>
              from <span class="vcard"><a class="email" href="mailto:darin&#64;apple.com" title="Darin Adler &lt;darin&#64;apple.com&gt;"> <span class="fn">Darin Adler</span></a>
</span></b>
        <pre>(In reply to <a href="show_bug.cgi?id=150740#c6">comment #6</a>)
<span class="quote">&gt; Is it really correct to just check the tag name, or is this one of those
&gt; cases where XML namespaces should be taken into account?</span >

I was planning to comment on that but had lost track of this bug. Thanks for drawing my attention back here! As Dan implies, this new code is incorrect in the presence of non-HTML elements that happen to have the same local name as HTML elements.

This clickableElementName field is apparently a copy of the DOM nodeName attribute, shipped across processes. We can’t use nodeName alone to check if something is a particular HTML element.

If our intent is to use this attribute to check if something is a particular HTML element, then I suggest we replace this code:

    info.clickableElementName = hitNode-&gt;nodeName();

With something more like this:

    if (is&lt;HTMLElement&gt;(*hitNode))
        info.clickableElementName = downcast&lt;HTMLElement&gt;(*hitNode).localName();

This will always be lowercase, and so there will be no need to fold case on the UI process side.

If it happens that we want to use this for SVG elements as well, and there is also no practical concern about collision between HTML and SVG local names (I think there are very few such collisions), then it could instead be this:

    if (is&lt;HTMLElement&gt;(*hitNode) || is&lt;SVGElement&gt;(*hitNode))
        info.clickableElementName = downcast&lt;Element&gt;(*hitNode).localName();</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>