/
761.txt
284 lines (208 loc) · 15.8 KB
/
761.txt
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
[9] [DFN[[RUBYB[HTML構文]@en[The HTML syntax]]]] は、 [[HTML]] の構文の一種で、最もよく使われているものです。 [[HTML構文]]は [[SGML]] 風の構文を持っていますが、 [[SGML]] の[[部分集合]]でも[[超集合]]でもなく、
互換性はありません。[[HTML構文]]の第5版は特に [DFN[[[HTML5]]]] と呼ばれています。
;;
[10] [[HTML構文]]に対して、 [[XML]] を構文として採用したものを [[XHTML構文]]と呼びます。
[[XHTML構文]]の第5版は特に [DFN[[[XHTML5]]]] と呼ばれています。
[[XHTML構文]]は実際にはほとんど使われていません。
[11] [[HTML5]] (構文) や [[XHTML5]] は、どちらも [[HTML5]] 仕様書で定義されています
(紛らわしいですね)。
[12]
また、 [[DOM]] における [CODE(DOMi)@en[[[Document]]]] には
[DFN[[RUBYB[[[HTML文書]]]@en[HTML document]]]]と[[XML文書]]の2種類があります
[SRC[[[HTML5]]]]。両者は、元々どちらの構文で書かれていたかとおおむね一致します。
;; 「おおむね」なのは、 [[DOM]] 上の操作で作られた [CODE(DOMi)@en[[[Document]]]]
も存在するからです。
;; ただし、両者を特に区別せずに「[[HTML文書]]」ということもあります ([[HTML5]]
仕様書の章節名自体がそうなっています)。
* 仕様書
[REFS[
-[13] [CITE@en-US-x-hixie[HTML Standard]] ([TIME[2012-12-31 05:55:07 +09:00]] 版) <http://www.whatwg.org/specs/web-apps/current-work/#syntax>
]REFS]
* 媒体型
[14] [[HTML文書]] ([[HTML構文]]で記述された[[文書]]) は、[[媒体型]]
[CODE(MIME)@en[[[text/html]]]] として[[札付け]]しなければ[['''なりません''']]
[SRC@en[[[HTML5]]]]。
[15] 逆に、[CODE(MIME)@en[[[text/html]]]] と[[札付け]]された[[文書]]は
[[HTML構文]]として解釈されます [SRC[[[HTML5]]]]。
* 構文解析
** 仕様書
[REFS[
- [50] [CITE@en-US-x-hixie[HTML Standard]] ([TIME[2012-12-31 05:55:07 +09:00]] 版) <http://www.whatwg.org/specs/web-apps/current-work/#parsing>
- [51] [CITE@en-US-x-hixie[HTML Standard]] ([TIME[2012-12-31 05:55:07 +09:00]] 版) <http://www.whatwg.org/specs/web-apps/current-work/#parsing-html-fragments>
]REFS]
[52] >>50 では単独の[[文書]]としての[[構文解析]]が、>>51 では特定の [CODE(DOMi)@en[[[Element]]]]
の文脈や任意の [CODE(DOMi)@en[[[Document]]]] の文脈での[[構文解析]] ([CODE(DOMa)@en[[[innerHTML]]]]) が規定されています。
** 刺激的な概念
- [18] [[DOCTYPEスイッチ]]
- [16] [[里親付け]]
- [17] [[養子縁組代理店算法]] ([[AAA]])
- [40] [[多妻ノアの箱舟]]
- [63] [[frameset-ok]]
* その他の話題
- [34] [[HTMLのレンダリングの開始]]
* 歴史
** Web Forms 2.0 HTML 構文の構文解析
[1] [[Web Forms 2.0]] は従来の [[HTML]] と
[[XHTML]] の両方の構文を認めています。
この章では、 [[HTML]] 構文の[[構文解析]]について扱います。
[2] 仕様書:
- [[Web Forms 2.0]]
-- [CSECTION@en[2.18. Handling unexpected elements and values]]
<IW:WF2:"#handling">
[3] '''誤り処理'''
[[Web Forms 2.0]] は、 [[SGML]]
で規定されない曖昧な場合にどう[[構文解析]]するか正確には規定しません。
[[利用者エージェント]]の実装者は、
既存の製品を[[逆工学]]し、適当な動作を模倣[['''するべきです''']]。
[SRC@en[WF2 2.18]]
[5]
[[Web Forms 2.0]] は [[HTML 4]] の拡張として定義されており、
その [[HTML 4]] が [[SGML]] に基づいているので、
>>3 のように規定されているのだと思われます。
しかし、 [[Web Forms 2.0]] の [[HTML]]
[[文書]]は一般に[[妥当]]な [[SGML]]
[[文書]]ではありません ([[DTD]] がないので)。
誤っている[[文書]]は >>4 のように処理するとして、
誤っていない[[文書]]をどう[[構文解析]]するのがいいのかは
[[Web Forms 2.0]] は (わざと) 曖昧にしています。
** HTML5 仕様書による構文解析算法の明確化
[8] [CITE['''['''whatwg''']''' HTML5 Parsing spec first draft ready]] ([TIME[2008-04-02 11:17:11 +09:00]] 版) <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2006-February/005807.html>
[67] [[HTML5]] の[[構文解析]]の仕様は既存の [[Webブラウザー]]の[[HTML構文解析器]]を[[逆工学]]したものでしたが、
既存の[[構文解析器]]は細部においては異なっていましたから、どの [[Webブラウザー]]とも完全には一致していませんでした。
そのためすべての主要 [[Webブラウザー]]が[[構文解析器]]を書き直すことになりました。
この新世代の[[構文解析器]]は一般に[DFN[[RUBYB[HTML5構文解析器]@en[HTML5 parser]]]]と呼ばれています。
[REFS[
- [68] [CITE[Surfin' Safari - Blog Archive » The HTML5 Parsing Algorithm]] ([TIME[2014-04-24 10:47:09 +09:00]] 版) <https://www.webkit.org/blog/1273/the-html5-parsing-algorithm/>
- [69] [CITE@en-US[HTML5 Parser - Web developer guide | MDN]] ([TIME[2014-03-21 12:22:14 +09:00]] 版) <https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5/HTML5_Parser>
- [71] [CITE@en[Dev.Opera — 100% Ragnarök’n’roll]] ([TIME[2014-04-24 08:33:46 +09:00]] 版) <http://dev.opera.com/blog/100-ragnarok-n-roll/>
- [70] [CITE@en[HTML5 Parsing in IE10 - IEBlog - Site Home - MSDN Blogs]] ([TIME[2014-04-24 10:49:14 +09:00]] 版) <http://blogs.msdn.com/b/ie/archive/2011/07/06/html5-parsing-in-ie10.aspx>
]REFS]
* メモ
[6]
[CITE@en[Tag Soup: How Mac IE 5 and Safari handle <x> <y> </x> </y>]] ([[Henri Sivonen]] 著, [CODE[2005-07-28 02:07:37 +09:00]] 版) <http://hsivonen.iki.fi/soup-dom/>
[7]
[CITE[Bug 311366 – should make custom elements able to contain blocks (<section>)]] ([TIME[2007-09-17 12:38:22 +09:00]] 版) <https://bugzilla.mozilla.org/show_bug.cgi?id=311366>
[19] [CITE[IRC logs: freenode / #whatwg / 20090813]]
([TIME[2009-10-10 21:27:36 +09:00]] 版)
<http://krijnhoetmer.nl/irc-logs/whatwg/20090813#l-171>
[20] [CITE[IRC logs: freenode / #whatwg / 20100324]]
([TIME[2010-04-03 01:03:00 +09:00]] 版)
<http://krijnhoetmer.nl/irc-logs/whatwg/20100324>
[21] [CITE[Notes on HTML5 Parser History — Anne’s Weblog]]
([TIME[2010-06-03 08:06:42 +09:00]] 版)
<http://annevankesteren.nl/2010/05/html5-parser-history>
[22] [CITE['''['''webkit-dev''']''' HTML5 tokenizer landing soon]]
([TIME[2010-06-22 06:33:13 +09:00]] 版)
<https://lists.webkit.org/pipermail/webkit-dev/2010-June/013244.html>
[23] [CITE[IRC logs: freenode / #whatwg / 20100727]]
([TIME[2010-08-11 00:06:17 +09:00]] 版)
<http://krijnhoetmer.nl/irc-logs/whatwg/20100727#l-1210>
[24] [CITE[IRC logs: freenode / #whatwg / 20100805]]
([TIME[2010-08-12 23:43:53 +09:00]] 版)
<http://krijnhoetmer.nl/irc-logs/whatwg/20100805#l-303>
[25] [CITE[IRC logs: freenode / #whatwg / 20100913]]
( ([TIME[2010-09-26 22:31:37 +09:00]] 版))
<http://krijnhoetmer.nl/irc-logs/whatwg/20100913#l-265>
[26] [CITE[IRC logs: freenode / #whatwg / 20100915]]
( ([TIME[2010-09-28 00:57:22 +09:00]] 版))
<http://krijnhoetmer.nl/irc-logs/whatwg/20100915#l-454>
[27] [CITE@en[Web Applications 1.0 r5521 Parser foreign lands: Get rid of secondary insertion mode, always use 'in body', scope HTML in foreign lands so that we won't try to close elements cross-namespace (e.g. <svg><p><desc><form> won't imply a </p> that closes the <p>...; <td> won't close all the SVG if the SVG is in a cell).Fixing http://www.w3.org/Bugs/Public/show_bug.cgi?id=10314]]
( ([TIME[2010-09-28 08:45:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=5520&to=5521>
[28] [CITE@en[Web Applications 1.0 r5522 Parser foreign lands: Oops, I missed one of the ways that scoping happens.Fixing http://www.w3.org/Bugs/Public/show_bug.cgi?id=10314]]
( ([TIME[2010-09-28 08:54:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=5521&to=5522>
[29] [CITE@en[Web Applications 1.0 r5563 Revamp how the foreign lands are defined to make it easier to add the U+0000 handling. This checkin should have no normative effect. If there are any normative changes in this patch, that's a bug, pleasel let me know ASAP.Fixing http://www.w3.org/Bugs/Public/show_bug.cgi?id=9659]]
( ([TIME[2010-09-30 10:40:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=5562&to=5563>
[30] [CITE@en[Web Applications 1.0 r5638 Add in some hard-coded limits for dealing with unclosed formatting elements to limit the explosive growth of the list of formatting elements in commonly-seen cases.Fixing http://www.w3.org/Bugs/Public/show_bug.cgi?id=10802]]
( ([TIME[2010-10-16 07:56:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=5637&to=5638>
[31] [CITE[Bug 10802 – Limit the number of identical items on the list of active formatting elements by removing previous duplicates when adding new items]]
( ([TIME[2010-10-16 08:37:29 +09:00]] 版))
<http://www.w3.org/Bugs/Public/show_bug.cgi?id=10802>
[32] [CITE[Bug 10801 – Limit the number of iterations in the loops in the AAA]]
( ([TIME[2010-10-16 08:38:38 +09:00]] 版))
<http://www.w3.org/Bugs/Public/show_bug.cgi?id=10801>
[33] [CITE[IRC logs: freenode / #whatwg / 20101021]]
( ([TIME[2010-10-29 23:31:18 +09:00]] 版))
<http://krijnhoetmer.nl/irc-logs/whatwg/20101021>
[35] [CITE@en[Web Applications 1.0 r5920 Change how MathML and SVG are parsed in text/html: use a three-level tree constructor design instead of the two-level design we had before.]]
( ([TIME[2011-03-01 08:56:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=5919&to=5920>
[36] [CITE[IRC logs: freenode / #whatwg / 20110203]]
( ([TIME[2011-03-19 11:46:31 +09:00]] 版))
<http://krijnhoetmer.nl/irc-logs/whatwg/20110203#l-1313>
[37] [CITE@en-US[htmlparser: Summary]]
( ([TIME[2011-03-19 16:38:17 +09:00]] 版))
<http://hg.mozilla.org/projects/htmlparser/>
[38] [CITE[IRC logs: freenode / #whatwg / 20110608]]
( ([TIME[2011-06-11 01:00:34 +09:00]] 版))
<http://krijnhoetmer.nl/irc-logs/whatwg/20110608>
[39] [CITE[IRC logs: freenode / #whatwg / 20110724]]
( ([TIME[2011-08-06 17:45:59 +09:00]] 版))
<http://krijnhoetmer.nl/irc-logs/whatwg/20110724#l-388>
[41] [CITE[''''''[''''''whatwg'''''']'''''' <!DOCTYPE html><body><table><math><mi>foo</mi></math></table> and other parser questions]]
( ([TIME[2011-12-14 08:37:32 +09:00]] 版))
<http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2011-December/034163.html>
[42] [CITE@en[Web Applications 1.0 r6870 Try to fix the problem David Flanagan raised a while back with the <!DOCTYPE html><body><table><math><mi>foo</mi></math></table> test case.]]
( ([TIME[2011-12-14 07:36:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=6869&to=6870>
[43] [CITE[IRC logs: freenode / #whatwg / 20120107]]
( ([TIME[2012-01-08 00:12:25 +09:00]] 版))
<http://krijnhoetmer.nl/irc-logs/whatwg/20120107>
[44] [CITE[''''''[''''''whatwg'''''']'''''' HTMLLinkElement.disabled and HTMLLinkElement.sheet behavior]]
( ([TIME[2012-01-28 11:20:09 +09:00]] 版))
<http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2012-January/034544.html>
[45] [CITE[''''''[''''''whatwg'''''']'''''' document.write("\r"): the spec doesn't say how to handle it.]]
( ([TIME[2012-02-14 08:40:30 +09:00]] 版))
<http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2012-February/034867.html>
[46] [CITE@en[Web Applications 1.0 r6991 Rejig the wording of the character encoding section to make it more precise and in particular to not make CR processing require look-ahead.]]
( ([TIME[2012-02-14 07:48:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=6990&to=6991>
[47] [CITE[''''''[''''''whatwg'''''']'''''' A plea to Hixie to adopt <main>, and main element parsing behaviour]]
( ([TIME[2012-11-08 07:11:56 +09:00]] 版))
<http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2012-November/037828.html>
[48] ( ([TIME[2012-11-09 02:23:02 +09:00]] 版))
<http://www.score.is.tsukuba.ac.jp/~minamide/papers/minamide-FM2012.pdf>
[49] ( ([TIME[2012-03-12 04:52:17 +09:00]] 版))
<http://www.score.cs.tsukuba.ac.jp/~minamide/html5spec/model.html5>
[53] [CITE[''''''[''''''webkit-dev'''''']'''''' Feature Announcement: Moving HTML Parser off the Main Thread]]
( ([TIME[2013-01-10 19:57:20 +09:00]] 版))
<http://lists.webkit.org/pipermail/webkit-dev/2013-January/023271.html>
[54] [CITE[HTML parser design - Google ドライブ]] ([TIME[2013-02-16 05:58:52 +09:00]] 版) <https://docs.google.com/a/google.com/drawings/d/1hwYyvkT7HFLAtTX_7LQp2lxA6LkaEWkXONmjtGCQjK0/edit>
[55] [CITE[Threaded HTML parser enabled on trunk - Google グループ]]
( ([TIME[2013-05-26 05:42:39 +09:00]] 版))
<https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/hBUVtg7gacE>
[56] [[Chrome]] は [[JavaScript]] の実行をドメインごとにブロックできますが、
ブロックまたはブロック解除の直後は [[JavaScript]] の実行のみオン・オフされ、[[HTML]]
の構文解析器は従前のモードのままになります。[[ウィンドウ]]を閉じて開き直すと完全に反映されます。
このため構文解析器は [CODE(HTMLe)@en[[[noscript]]]] の中身を解釈するのに [[JavaScript]]
が実行されたり、その逆になったりします。 [TIME[2013-06-07T05:52:05.700Z]]
[57] [CITE@en[Web Applications 1.0 r7999 Another very risky change! Please review! This attempts to refactor the parser logic so that the ownerDocument is explicitly set at each place a node is created by the parser. This actually fixes an ambiguity, which was what should happen when a script has transplated a node that is still on the stack of open elements into a Document without a browsing context, if the node created has some magic (e.g. <img src>, <script>).]]
( ([TIME[2013-06-26 05:55:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=7998&to=7999>
[58] [CITE@en[Web Applications 1.0 r7998 Very risky editorial change! Please review! This attempts to refactor the parser logic so that the foster parenting is actually done inline in a single algorithm that is called by anywhere in the parser that could be affected by it. This will allow us to add the <template> magic with minimal actual magic in the prose, hopefully.]]
( ([TIME[2013-06-25 14:37:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=7997&to=7998>
[59] [CITE[''''''[''''''whatwg'''''']'''''' Namespaces and tag names in the HTML parser]]
( ([TIME[2013-07-02 07:53:15 +09:00]] 版))
<http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2013-July/039913.html>
[60] [CITE[''''''[''''''whatwg'''''']'''''' Another issue in 12.2.5.5 parsing tokens in foreign content]]
( ([TIME[2013-08-01 01:41:59 +09:00]] 版))
<http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2013-July/040314.html>
[61] [CITE@en-GB-x-Hixie[Hixie's Natural Log: Tag Soup: How UAs handle <x> <y> </x> </y>]]
( ([TIME[2013-08-18 19:11:22 +09:00]] 版))
<http://ln.hixie.ch/?start=1037910467&count=1>
[62] [CITE@en[Streamable non-fatal non-conforming HTML parser error recovery strategy]]
( ([[Simon Pieters]] 著, [TIME[2013-10-03 23:25:16 +09:00]] 版))
<http://lists.w3.org/Archives/Public/www-archive/2013Oct/0009.html>
[64] [CITE@en[Parsing (Windows)]]
( ([TIME[2013-11-13 13:54:34 +09:00]] 版))
<http://msdn.microsoft.com/en-us/library/ie/hh673554(v=vs.85).aspx>
[65] [CITE[''''''[''''''whatwg'''''']'''''' Should ambiguous ampersand be a parse error?]]
( ([TIME[2014-01-22 23:54:55 +09:00]] 版))
<http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2014-January/041905.html>
[66] [CITE@en[Web Applications 1.0 r8554 Drop filterRes SVG attribute from the HTML parser, since it has fallen into disrepute.]]
( ([TIME[2014-03-19 03:36:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=8553&to=8554>