Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 51965fbac8b7d44d52321c3bb81a881a9a59923a
      
https://github.com/WebKit/WebKit/commit/51965fbac8b7d44d52321c3bb81a881a9a59923a
  Author: Wenson Hsieh <[email protected]>
  Date:   2024-11-05 (Tue, 05 Nov 2024)

  Changed paths:
    M LayoutTests/fast/dom/linkify-phone-numbers-expected.html
    M LayoutTests/fast/dom/linkify-phone-numbers.html
    M Source/WebCore/html/parser/HTMLTreeBuilder.cpp

  Log Message:
  -----------
  [iOS] Rendering in Jupyter notebook (MathJAX.js converting LaTeX) is broken 
due to data detection
https://bugs.webkit.org/show_bug.cgi?id=282567
rdar://116407458

Reviewed by Richard Robinson, Ryosuke Niwa, and Abrar Rahman Protyasha.

Since at least iOS 7, the HTML parser automatically tries to detect phone 
numbers that appear within
plain text, and replaces them with links; for instance, a normal text node 
`+1234567` would be
replaced by an anchor element, `<a href="tel:+1234567">+1234567</a>`. This 
sometimes causes
incompatibilities with certain JavaScript libraries that try to parse text at 
load time and use it
to convert the text nodes (and their container element) into formatted LaTeX.

Unfortunately, there isn't any obvious indication that we must avoid running 
data detection for this
text (e.g. based on the element type, style, or other attributes); the only 
indication of this comes
in the form of a `data-mime-type="text/latex"` DOM attribute on a parent 
container of the text node.

* LayoutTests/fast/dom/linkify-phone-numbers-expected.html:
* LayoutTests/fast/dom/linkify-phone-numbers.html:

Adjust an existing layout test to cover this scenario.

* Source/WebCore/html/parser/HTMLTreeBuilder.cpp:
(WebCore::HTMLTreeBuilder::linkifyPhoneNumbers):

Walk up the tree to check for ancestor elements with 
`data-mime-type="text/latex"`; I'm doing this
here (when a phone number is about to be inserted) instead of in 
`disallowTelephoneNumberParsing`,
so that we don't incur the cost of a potentially expensive attribute lookup 
multiple times, for
every ancestor element of every text node in the DOM.

(WebCore::shouldParseTelephoneNumbersInNode):

Leave a FIXME here about the fact that on iOS, we perform an ancestor walk when 
parsing every single
text node in the DOM.

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to