summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb
diff options
context:
space:
mode:
authorTobias Christiansen <tobi@tobyase.de>2021-04-17 23:10:10 +0200
committerAndreas Kling <kling@serenityos.org>2021-04-20 18:29:19 +0200
commitbfcfe8424001476e4d59e27f548678544a975ebc (patch)
treea2bd6278a25ec43b43ca78e1f0a3e286f108cb3c /Userland/Libraries/LibWeb
parentc09ac536c5c7630888eee4376a33492a93bae541 (diff)
downloadserenity-bfcfe8424001476e4d59e27f548678544a975ebc.zip
LibWeb: Make the ListItemMarkerBox index-aware.
In the ListItemBox we get the index of the current <li> element in the parent and pass it to the ListItemMarkerBox. This patch is work towards #2059
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r--Userland/Libraries/LibWeb/Layout/ListItemBox.cpp4
-rw-r--r--Userland/Libraries/LibWeb/Layout/ListItemMarkerBox.cpp5
-rw-r--r--Userland/Libraries/LibWeb/Layout/ListItemMarkerBox.h7
3 files changed, 13 insertions, 3 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/ListItemBox.cpp b/Userland/Libraries/LibWeb/Layout/ListItemBox.cpp
index 3a731fb171..fc93c62de2 100644
--- a/Userland/Libraries/LibWeb/Layout/ListItemBox.cpp
+++ b/Userland/Libraries/LibWeb/Layout/ListItemBox.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
+ * Copyright (c) 2021, Tobias Christiansen <tobi@tobyase.de>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -49,7 +50,8 @@ void ListItemBox::layout_marker()
return;
if (!m_marker) {
- m_marker = adopt(*new ListItemMarkerBox(document()));
+ int child_index = parent()->index_of_child<ListItemBox>(*this).value();
+ m_marker = adopt(*new ListItemMarkerBox(document(), computed_values().list_style_type(), child_index + 1));
if (first_child())
m_marker->set_inline(first_child()->is_inline());
append_child(*m_marker);
diff --git a/Userland/Libraries/LibWeb/Layout/ListItemMarkerBox.cpp b/Userland/Libraries/LibWeb/Layout/ListItemMarkerBox.cpp
index 995f8039a2..0289783d54 100644
--- a/Userland/Libraries/LibWeb/Layout/ListItemMarkerBox.cpp
+++ b/Userland/Libraries/LibWeb/Layout/ListItemMarkerBox.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
+ * Copyright (c) 2021, Tobias Christiansen <tobi@tobyase.de>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,8 +30,10 @@
namespace Web::Layout {
-ListItemMarkerBox::ListItemMarkerBox(DOM::Document& document)
+ListItemMarkerBox::ListItemMarkerBox(DOM::Document& document, CSS::ListStyleType style_type, size_t index)
: Box(document, nullptr, CSS::StyleProperties::create())
+ , m_list_style_type(style_type)
+ , m_index(index)
{
}
diff --git a/Userland/Libraries/LibWeb/Layout/ListItemMarkerBox.h b/Userland/Libraries/LibWeb/Layout/ListItemMarkerBox.h
index e570fd21df..f23b79c260 100644
--- a/Userland/Libraries/LibWeb/Layout/ListItemMarkerBox.h
+++ b/Userland/Libraries/LibWeb/Layout/ListItemMarkerBox.h
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
+ * Copyright (c) 2021, Tobias Christiansen <tobi@tobyase.de>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -32,10 +33,14 @@ namespace Web::Layout {
class ListItemMarkerBox final : public Box {
public:
- explicit ListItemMarkerBox(DOM::Document&);
+ explicit ListItemMarkerBox(DOM::Document&, CSS::ListStyleType, size_t index);
virtual ~ListItemMarkerBox() override;
virtual void paint(PaintContext&, PaintPhase) override;
+
+private:
+ CSS::ListStyleType m_list_style_type { CSS::ListStyleType::None };
+ size_t m_index;
};
}