mirror of
https://github.com/RGBCube/serenity
synced 2025-07-08 20:17:34 +00:00
LibWeb: Implement fragment parsing and use it for Element.innerHTML
This patch implements most of the HTML fragment parsing algorithm and ports Element::set_inner_html() to it. This was the last remaining user of the old HTML parser. :^)
This commit is contained in:
parent
eb33021d65
commit
92d831c25b
7 changed files with 91 additions and 18 deletions
|
@ -41,7 +41,7 @@
|
|||
#include <LibWeb/Layout/LayoutTableRow.h>
|
||||
#include <LibWeb/Layout/LayoutTableRowGroup.h>
|
||||
#include <LibWeb/Layout/LayoutTreeBuilder.h>
|
||||
#include <LibWeb/Parser/HTMLParser.h>
|
||||
#include <LibWeb/Parser/HTMLDocumentParser.h>
|
||||
|
||||
namespace Web {
|
||||
|
||||
|
@ -247,13 +247,10 @@ NonnullRefPtr<StyleProperties> Element::computed_style()
|
|||
|
||||
void Element::set_inner_html(StringView markup)
|
||||
{
|
||||
auto fragment = parse_html_fragment(document(), markup);
|
||||
auto new_children = HTMLDocumentParser::parse_html_fragment(*this, markup);
|
||||
remove_all_children();
|
||||
if (!fragment)
|
||||
return;
|
||||
while (RefPtr<Node> child = fragment->first_child()) {
|
||||
fragment->remove_child(*child);
|
||||
append_child(*child);
|
||||
while (!new_children.is_empty()) {
|
||||
append_child(new_children.take_first());
|
||||
}
|
||||
|
||||
set_needs_style_update(true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue