From 966bc05fefe526168b4cd52a1b4c15ec6d5d810e Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 21 Jun 2020 17:00:55 +0200 Subject: [PATCH] LibWeb: Implement more of the foster parenting algorithm in the parser --- .../LibWeb/Parser/HTMLDocumentParser.cpp | 35 +++++++++++++------ Libraries/LibWeb/Parser/HTMLDocumentParser.h | 9 ++++- .../LibWeb/Parser/StackOfOpenElements.cpp | 23 ++++++++++++ Libraries/LibWeb/Parser/StackOfOpenElements.h | 3 ++ 4 files changed, 58 insertions(+), 12 deletions(-) diff --git a/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp b/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp index 8bee4459f3..9019461bce 100644 --- a/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp +++ b/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp @@ -253,13 +253,19 @@ Element& HTMLDocumentParser::node_before_current_node() return m_stack_of_open_elements.elements().at(m_stack_of_open_elements.elements().size() - 2); } -RefPtr HTMLDocumentParser::find_appropriate_place_for_inserting_node() +HTMLDocumentParser::AdjustedInsertionLocation HTMLDocumentParser::find_appropriate_place_for_inserting_node() { auto& target = current_node(); - if (m_foster_parenting) { - TODO(); + if (m_foster_parenting && target.tag_name().is_one_of(HTML::TagNames::table, HTML::TagNames::tbody, HTML::TagNames::tfoot, HTML::TagNames::thead, HTML::TagNames::tr)) { + // FIXME: There's a bunch of steps for