From a4c29ba8d1ea1065ce6bd4a34382d53140cf1924 Mon Sep 17 00:00:00 2001
From: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
Date: Mon, 14 Aug 2023 20:18:51 +0200
Subject: [PATCH 2/6] Track implied added nodes for options use in PHP

---
 source/lexbor/html/tree.h                            | 3 +++
 source/lexbor/html/tree/insertion_mode/after_head.c  | 1 +
 source/lexbor/html/tree/insertion_mode/before_head.c | 2 ++
 source/lexbor/html/tree/insertion_mode/before_html.c | 2 ++
 4 files changed, 8 insertions(+)

diff --git a/source/lexbor/html/tree.h b/source/lexbor/html/tree.h
index 4912efb..7b2c620 100644
--- a/source/lexbor/html/tree.h
+++ b/source/lexbor/html/tree.h
@@ -55,6 +55,9 @@ struct lxb_html_tree {
     bool                           foster_parenting;
     bool                           frameset_ok;
     bool                           scripting;
+    bool                           has_explicit_html_tag;
+    bool                           has_explicit_head_tag;
+    bool                           has_explicit_body_tag;
 
     lxb_html_tree_insertion_mode_f mode;
     lxb_html_tree_insertion_mode_f original_mode;
diff --git a/source/lexbor/html/tree/insertion_mode/after_head.c b/source/lexbor/html/tree/insertion_mode/after_head.c
index ad551b5..1448654 100644
--- a/source/lexbor/html/tree/insertion_mode/after_head.c
+++ b/source/lexbor/html/tree/insertion_mode/after_head.c
@@ -71,6 +71,7 @@ lxb_html_tree_insertion_mode_after_head_open(lxb_html_tree_t *tree,
                 return lxb_html_tree_process_abort(tree);
             }
 
+            tree->has_explicit_body_tag = true;
             tree->frameset_ok = false;
             tree->mode = lxb_html_tree_insertion_mode_in_body;
 
diff --git a/source/lexbor/html/tree/insertion_mode/before_head.c b/source/lexbor/html/tree/insertion_mode/before_head.c
index 14621f2..cd2ac2a 100644
--- a/source/lexbor/html/tree/insertion_mode/before_head.c
+++ b/source/lexbor/html/tree/insertion_mode/before_head.c
@@ -67,6 +67,8 @@ lxb_html_tree_insertion_mode_before_head_open(lxb_html_tree_t *tree,
                 return lxb_html_tree_process_abort(tree);
             }
 
+            tree->has_explicit_head_tag = true;
+
             tree->mode = lxb_html_tree_insertion_mode_in_head;
 
             break;
diff --git a/source/lexbor/html/tree/insertion_mode/before_html.c b/source/lexbor/html/tree/insertion_mode/before_html.c
index 05fe738..1e09cda 100644
--- a/source/lexbor/html/tree/insertion_mode/before_html.c
+++ b/source/lexbor/html/tree/insertion_mode/before_html.c
@@ -78,6 +78,8 @@ lxb_html_tree_insertion_mode_before_html_open(lxb_html_tree_t *tree,
                 return lxb_html_tree_process_abort(tree);
             }
 
+            tree->has_explicit_html_tag = true;
+
             tree->mode = lxb_html_tree_insertion_mode_before_head;
 
             break;
-- 
2.51.2

