Repository navigation
Commit 7d12474
Parse processing instructions in HTML
https://bugs.webkit.org/show_bug.cgi?id=326324
Reviewed by Anne van Kesteren and Darin Adler.
whatwg/html#13036
The HTML parser turns `<?target data?>` into a bogus comment, so it becomes a
Comment node whose data is `?target data?`. The DOM Standard and the work on
declarative out of order streaming both need real ProcessingInstruction nodes
from HTML parsing, and the HTML Standard is being updated to match.
Add tokenizer states for the open, target, data and question mark cases, a
ProcessingInstruction token type, and tree construction that inserts the node
into the document, on the html element, or at the current insertion point. The
target is restricted to ASCII alphanumerics, `-` and `_`, so it lives in a
small Latin-1 buffer on the token rather than a second DataVector, and the
bogus comment that a bad target falls back to is rebuilt from that buffer
instead of a second copy in the tokenizer's temporary buffer. That rebuild
appends the target as one Latin-1 span, so the comment data is not marked as
needing 16-bit storage.
`<?xml ...?>` and `<?xml-stylesheet ...?>` keep producing bogus comments, so
XML declarations pasted into HTML keep behaving as they do now.
All of this sits behind the new HTMLProcessingInstructionEnabled setting,
which is testable and off. The ProcessingInstruction node and its pseudo
attribute API, `<template for>`, and enabling the setting by default are each
left for their own change so they can be reviewed separately.
MutationObserver-characterData.html gains one expected failure. Its
ProcessingInstruction subtest asserts that the old value is
`?processing data?`, which was only ever true because the markup parsed as a
bogus comment. That needs fixing upstream to expect `data`, so the imported
copy is left untouched here and the next import will not revert it.
fast/xpath/xpath-functional-test.html improves: four processing instruction
and node() cases that were expected to fail now pass.
Parsing processing instructions also changes how the markup in two other imported
suites serializes, so their baselines are updated. They still fail, for reasons
this change does not address: processing-instruction-attributes.html now gets
past its nodeType assertion and stops at getAttribute, which the attribute API
in bug 326328 adds, and the `<template for>` tests see `<?start name="p"?>`
where they used to see a bogus comment, which bug 324175 covers.
Tests: fast/parser/html-processing-instruction-enabled.html
imported/w3c/web-platform-tests/html/syntax/parsing/html5lib_url.html?file=processing-instructions
imported/w3c/web-platform-tests/html/syntax/parsing/html5lib_write.html?file=processing-instructions
imported/w3c/web-platform-tests/html/syntax/parsing/html5lib_write_single.html?file=processing-instructions
* LayoutTests/imported/w3c/web-platform-tests/dom/nodes/processing-instruction-attributes-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-template-element/template-for/template-for-append-element-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-template-element/template-for/template-for-foster-parenting-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-template-element/template-for/template-for-move-cross-document-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-template-element/template-for/template-for-multiple-cases-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-template-element/template-for/template-for-mutation-records-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-template-element/template-for/template-for-nested-patch-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-template-element/template-for/template-for-sanitization-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-template-element/template-for/template-for-unclosed-content-expected.txt:
(WebCore::HTMLConstructionSite::insertProcessingInstruction):
(WebCore::HTMLConstructionSite::insertProcessingInstructionOnDocument):
(WebCore::HTMLConstructionSite::insertProcessingInstructionOnHTMLHtmlElement):
(WebCore::HTMLParserOptions::HTMLParserOptions):
(WebCore::HTMLToken::clear):
(WebCore::HTMLToken::processingInstructionTarget const):
(WebCore::HTMLToken::processingInstructionData const):
(WebCore::HTMLToken::beginProcessingInstruction):
(WebCore::HTMLToken::appendToProcessingInstructionTarget):
(WebCore::HTMLToken::appendToProcessingInstructionData):
(WebCore::HTMLTokenizer::emitProcessingInstruction):
(WebCore::HTMLTokenizer::rewindToBogusCommentForProcessingInstructionTarget):
(WebCore::HTMLTokenizer::processToken):
(WebCore::HTMLTreeBuilder::processProcessingInstruction):
(WebCore::AtomHTMLToken::processingInstructionTarget const):
(WebCore::AtomHTMLToken::processingInstructionData const):
Canonical link: https://commits.webkit.org/324246@main1 parent 52440c8 commit 7d12474
37 files changed
Lines changed: 1005 additions & 5680 deletions
File tree
- LayoutTests
- fast
- parser
- xpath
- imported/w3c/web-platform-tests
- dom/nodes
- html
- semantics/scripting-1/the-template-element/template-for
- syntax/parsing
- Source
- WTF/Scripts/Preferences
- WebCore
- dom
- html/parser
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | | - | |
| 132 | + | |
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
| 71 | + | |
72 | 72 | | |
73 | | - | |
| 73 | + | |
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
| 3 | + | |
| 4 | + | |
5 | 5 | | |
6 | | - | |
7 | | - | |
| 6 | + | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
0 commit comments