Branch: refs/heads/main Home: https://github.com/WebKit/WebKit Commit: 55a286438b239e94c5a355a1f7510cfa7b4dd033 https://github.com/WebKit/WebKit/commit/55a286438b239e94c5a355a1f7510cfa7b4dd033 Author: Jean-Yves Avenard <j...@apple.com> Date: 2023-10-18 (Wed, 18 Oct 2023)
Changed paths: M LayoutTests/fast/dom/document-contentType-DOMParser-expected.txt M LayoutTests/fast/dom/document-contentType-DOMParser.html M Source/WebCore/html/parser/HTMLDocumentParserFastPath.cpp M Source/WebCore/html/parser/HTMLDocumentParserFastPath.h M Source/WebCore/xml/DOMParser.cpp Log Message: ----------- REGRESSION (STP): Video won't play on bilibili.com https://bugs.webkit.org/show_bug.cgi?id=263196 rdar://117020123 Reviewed by Chris Dumez. bilibili injects DOM objects in the tree by calling: ``` var t = (new DOMParser).parseFromString(e, "text/html"); return document.adoptNode(t.body.firstChild) ``` Per spec, when parsing HTML to create a document through DOMParser::parseFromString() [1] you are to skip the whitespace tokens for the "initial" insertion mode [2]. The trailing spaces however must be kept [3] This behaviour was regressed by 267202@main. On this site, the observable behaviour was that the firstChild became a "#text" node rather the expected first DIV one. So we trim the leading whitespaces before calling the fast parser. Which restore the original behaviour prior 267202@main [1] https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#parse-html-from-a-string [2] https://html.spec.whatwg.org/multipage/parsing.html#the-initial-insertion-mode [3] https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-afterbody * LayoutTests/fast/dom/document-contentType-DOMParser-expected.txt: * LayoutTests/fast/dom/document-contentType-DOMParser.html: Added tests. * Source/WebCore/html/parser/HTMLDocumentParserFastPath.cpp: (WebCore::tryFastParsingHTMLFragment): * Source/WebCore/html/parser/HTMLDocumentParserFastPath.h: Change type to StringView (WebCore::requires): * Source/WebCore/xml/DOMParser.cpp: (WebCore::DOMParser::parseFromString): Canonical link: https://commits.webkit.org/269457@main _______________________________________________ webkit-changes mailing list webkit-changes@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-changes