Skip to content

Commit d9e3a62

Browse files
committed
HTML parser: allow <hr> to be used inside <select> as a separator
https://bugs.webkit.org/show_bug.cgi?id=80686 rdar://107656886 Reviewed by Ryosuke Niwa. Revive support in the HTML parser for <hr>-in-<select>, thereby making an existing UI feature much more accessible to web developers. This reflects a recent change in the HTML Standard: whatwg/html#9124. * LayoutTests/html5lib/resources/webkit02.dat: These are being upstreamed via html5lib/html5lib-tests#167 and will then be incorporated into web-platform-tests. * Source/WebCore/html/parser/HTMLTreeBuilder.cpp: (WebCore::HTMLTreeBuilder::processStartTag): Canonical link: https://commits.webkit.org/263624@main
1 parent 0c07f17 commit d9e3a62

File tree

2 files changed

+139
-0
lines changed

2 files changed

+139
-0
lines changed

LayoutTests/html5lib/resources/webkit02.dat

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,3 +235,135 @@ select
235235
| <body>
236236
| <math math>
237237
| definitionURL=""
238+
239+
#data
240+
<select><hr>
241+
#errors
242+
#document
243+
| <html>
244+
| <head>
245+
| <body>
246+
| <select>
247+
| <hr>
248+
249+
#data
250+
<select><option><hr>
251+
#errors
252+
#document
253+
| <html>
254+
| <head>
255+
| <body>
256+
| <select>
257+
| <option>
258+
| <hr>
259+
260+
#data
261+
<select><optgroup><option><hr>
262+
#errors
263+
#document
264+
| <html>
265+
| <head>
266+
| <body>
267+
| <select>
268+
| <optgroup>
269+
| <option>
270+
| <hr>
271+
272+
#data
273+
<select><optgroup><hr>
274+
#errors
275+
#document
276+
| <html>
277+
| <head>
278+
| <body>
279+
| <select>
280+
| <optgroup>
281+
| <hr>
282+
283+
#data
284+
<select><option><optgroup><hr>
285+
#errors
286+
#document
287+
| <html>
288+
| <head>
289+
| <body>
290+
| <select>
291+
| <option>
292+
| <optgroup>
293+
| <hr>
294+
295+
#data
296+
<table><tr><td><select><hr>
297+
#errors
298+
#document
299+
| <html>
300+
| <head>
301+
| <body>
302+
| <table>
303+
| <tbody>
304+
| <tr>
305+
| <td>
306+
| <select>
307+
| <hr>
308+
309+
#data
310+
<table><tr><td><select><option><hr>
311+
#errors
312+
#document
313+
| <html>
314+
| <head>
315+
| <body>
316+
| <table>
317+
| <tbody>
318+
| <tr>
319+
| <td>
320+
| <select>
321+
| <option>
322+
| <hr>
323+
324+
#data
325+
<table><tr><td><select><optgroup><option><hr>
326+
#errors
327+
#document
328+
| <html>
329+
| <head>
330+
| <body>
331+
| <table>
332+
| <tbody>
333+
| <tr>
334+
| <td>
335+
| <select>
336+
| <optgroup>
337+
| <option>
338+
| <hr>
339+
340+
#data
341+
<table><tr><td><select><optgroup><hr>
342+
#errors
343+
#document
344+
| <html>
345+
| <head>
346+
| <body>
347+
| <table>
348+
| <tbody>
349+
| <tr>
350+
| <td>
351+
| <select>
352+
| <optgroup>
353+
| <hr>
354+
355+
#data
356+
<table><tr><td><select><option><optgroup><hr>
357+
#errors
358+
#document
359+
| <html>
360+
| <head>
361+
| <body>
362+
| <table>
363+
| <tbody>
364+
| <tr>
365+
| <td>
366+
| <select>
367+
| <option>
368+
| <optgroup>
369+
| <hr>

Source/WebCore/html/parser/HTMLTreeBuilder.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,6 +1424,13 @@ void HTMLTreeBuilder::processStartTag(AtomHTMLToken&& token)
14241424
processFakeEndTag(TagName::optgroup);
14251425
m_tree.insertHTMLElement(WTFMove(token));
14261426
return;
1427+
case TagName::hr:
1428+
if (m_tree.currentStackItem().elementName() == HTML::option)
1429+
processFakeEndTag(TagName::option);
1430+
if (m_tree.currentStackItem().elementName() == HTML::optgroup)
1431+
processFakeEndTag(TagName::optgroup);
1432+
m_tree.insertSelfClosingHTMLElement(WTFMove(token));
1433+
return;
14271434
case TagName::select: {
14281435
parseError(token);
14291436
AtomHTMLToken endSelect(HTMLToken::Type::EndTag, TagName::select);

0 commit comments

Comments
 (0)