[Webkit-unassigned] [Bug 150740] Link preview doesn't work on XHTML pages with Content-Type header as `application/xhtml+xml`

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sat Oct 31 15:40:27 PDT 2015


https://bugs.webkit.org/show_bug.cgi?id=150740

--- Comment #7 from Darin Adler <darin at apple.com> ---
(In reply to comment #6)
> Is it really correct to just check the tag name, or is this one of those
> cases where XML namespaces should be taken into account?

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->nodeName();

With something more like this:

    if (is<HTMLElement>(*hitNode))
        info.clickableElementName = downcast<HTMLElement>(*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<HTMLElement>(*hitNode) || is<SVGElement>(*hitNode))
        info.clickableElementName = downcast<Element>(*hitNode).localName();

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-unassigned/attachments/20151031/285d84c4/attachment.html>


More information about the webkit-unassigned mailing list