Skip to content

Commit

Permalink
HTML parser: allow <hr> to be used inside <select> as a separator
Browse files Browse the repository at this point in the history
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
  • Loading branch information
annevk committed May 3, 2023
1 parent 0c07f17 commit d9e3a62
Show file tree
Hide file tree
Showing 2 changed files with 139 additions and 0 deletions.
132 changes: 132 additions & 0 deletions LayoutTests/html5lib/resources/webkit02.dat
Original file line number Diff line number Diff line change
Expand Up @@ -235,3 +235,135 @@ select
| <body>
| <math math>
| definitionURL=""

#data
<select><hr>
#errors
#document
| <html>
| <head>
| <body>
| <select>
| <hr>

#data
<select><option><hr>
#errors
#document
| <html>
| <head>
| <body>
| <select>
| <option>
| <hr>

#data
<select><optgroup><option><hr>
#errors
#document
| <html>
| <head>
| <body>
| <select>
| <optgroup>
| <option>
| <hr>

#data
<select><optgroup><hr>
#errors
#document
| <html>
| <head>
| <body>
| <select>
| <optgroup>
| <hr>

#data
<select><option><optgroup><hr>
#errors
#document
| <html>
| <head>
| <body>
| <select>
| <option>
| <optgroup>
| <hr>

#data
<table><tr><td><select><hr>
#errors
#document
| <html>
| <head>
| <body>
| <table>
| <tbody>
| <tr>
| <td>
| <select>
| <hr>

#data
<table><tr><td><select><option><hr>
#errors
#document
| <html>
| <head>
| <body>
| <table>
| <tbody>
| <tr>
| <td>
| <select>
| <option>
| <hr>

#data
<table><tr><td><select><optgroup><option><hr>
#errors
#document
| <html>
| <head>
| <body>
| <table>
| <tbody>
| <tr>
| <td>
| <select>
| <optgroup>
| <option>
| <hr>

#data
<table><tr><td><select><optgroup><hr>
#errors
#document
| <html>
| <head>
| <body>
| <table>
| <tbody>
| <tr>
| <td>
| <select>
| <optgroup>
| <hr>

#data
<table><tr><td><select><option><optgroup><hr>
#errors
#document
| <html>
| <head>
| <body>
| <table>
| <tbody>
| <tr>
| <td>
| <select>
| <option>
| <optgroup>
| <hr>
7 changes: 7 additions & 0 deletions Source/WebCore/html/parser/HTMLTreeBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1424,6 +1424,13 @@ void HTMLTreeBuilder::processStartTag(AtomHTMLToken&& token)
processFakeEndTag(TagName::optgroup);
m_tree.insertHTMLElement(WTFMove(token));
return;
case TagName::hr:
if (m_tree.currentStackItem().elementName() == HTML::option)
processFakeEndTag(TagName::option);
if (m_tree.currentStackItem().elementName() == HTML::optgroup)
processFakeEndTag(TagName::optgroup);
m_tree.insertSelfClosingHTMLElement(WTFMove(token));
return;
case TagName::select: {
parseError(token);
AtomHTMLToken endSelect(HTMLToken::Type::EndTag, TagName::select);
Expand Down

0 comments on commit d9e3a62

Please sign in to comment.