summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-02-21 01:43:37 +0100
committerAndreas Kling <kling@serenityos.org>2022-02-21 18:35:12 +0100
commit92266d2247aae2b528307bab40fd0bbcbe491765 (patch)
tree369822c3286319162683a181f61c6e553996228a /Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp
parentc9700e100e1cfe463b837b7a1337a5a7b7df63d9 (diff)
downloadserenity-92266d2247aae2b528307bab40fd0bbcbe491765.zip
LibWeb: Create list-item markers during layout tree construction
Previously, these were added during layout. This didn't fit into the new world where layout doesn't mutate the tree incrementally, so this patch adds logic to Layout::TreeBuilder for adding a marker to each list-item box after its children have been constructed.
Diffstat (limited to 'Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp')
-rw-r--r--Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp b/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp
index d5ccbc8ece..aff5847572 100644
--- a/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp
+++ b/Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
+ * Copyright (c) 2018-2022, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -12,6 +12,8 @@
#include <LibWeb/DOM/ShadowRoot.h>
#include <LibWeb/Dump.h>
#include <LibWeb/Layout/InitialContainingBlock.h>
+#include <LibWeb/Layout/ListItemBox.h>
+#include <LibWeb/Layout/ListItemMarkerBox.h>
#include <LibWeb/Layout/Node.h>
#include <LibWeb/Layout/TableBox.h>
#include <LibWeb/Layout/TableCellBox.h>
@@ -147,6 +149,16 @@ void TreeBuilder::create_layout_tree(DOM::Node& dom_node, TreeBuilder::Context&
});
pop_parent();
}
+
+ if (is<ListItemBox>(*layout_node)) {
+ int child_index = layout_node->parent()->index_of_child<ListItemBox>(*layout_node).value();
+ auto marker_style = static_cast<DOM::Element const&>(dom_node).specified_css_values();
+ auto list_item_marker = adopt_ref(*new ListItemMarkerBox(document, layout_node->computed_values().list_style_type(), child_index + 1, *marker_style));
+ if (layout_node->first_child())
+ list_item_marker->set_inline(layout_node->first_child()->is_inline());
+ static_cast<ListItemBox&>(*layout_node).set_marker(list_item_marker);
+ layout_node->append_child(move(list_item_marker));
+ }
}
RefPtr<Node> TreeBuilder::build(DOM::Node& dom_node)