mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-20 09:11:53 +00:00
We've long claimed to support this, but then silently ignored string
values, until 4cb2063577
which would
not-so-silently crash instead. (Oops)
So, actually pass the string value along and use it in the list marker.
As part of this, rename our `list-style-type` enum to
`counter-style-name-keyword`. This is an awkward name, attempting to be
spec-based. (The spec says `<counter-style>`, which is either a
`<counter-style-name>` or a function, and the `<counter-style-name>` is
a `<custom-ident>` that also has a few predefined values. So this is the
best I could come up with.)
Unfortunately only one WPT test for this passes - the others fail
because we produce a different layout when text is in `::before` than
when it's in `::marker`, and similar issues.
44 lines
1.4 KiB
C++
44 lines
1.4 KiB
C++
/*
|
|
* Copyright (c) 2018-2022, Andreas Kling <andreas@ladybird.org>
|
|
* Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org>
|
|
* Copyright (c) 2025, Sam Atkins <sam@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibWeb/Layout/Box.h>
|
|
|
|
namespace Web::Layout {
|
|
|
|
class ListItemMarkerBox final : public Box {
|
|
GC_CELL(ListItemMarkerBox, Box);
|
|
GC_DECLARE_ALLOCATOR(ListItemMarkerBox);
|
|
|
|
public:
|
|
explicit ListItemMarkerBox(DOM::Document&, CSS::ListStyleType, CSS::ListStylePosition, size_t index, GC::Ref<CSS::ComputedProperties>);
|
|
virtual ~ListItemMarkerBox() override;
|
|
|
|
Optional<String> const& text() const { return m_text; }
|
|
|
|
virtual GC::Ptr<Painting::Paintable> create_paintable() const override;
|
|
|
|
CSS::ListStyleType const& list_style_type() const { return m_list_style_type; }
|
|
CSS::ListStylePosition list_style_position() const { return m_list_style_position; }
|
|
|
|
private:
|
|
virtual bool is_list_item_marker_box() const final { return true; }
|
|
virtual bool can_have_children() const override { return false; }
|
|
|
|
CSS::ListStyleType m_list_style_type { CSS::CounterStyleNameKeyword::None };
|
|
CSS::ListStylePosition m_list_style_position { CSS::ListStylePosition::Outside };
|
|
size_t m_index;
|
|
|
|
Optional<String> m_text {};
|
|
};
|
|
|
|
template<>
|
|
inline bool Node::fast_is<ListItemMarkerBox>() const { return is_list_item_marker_box(); }
|
|
|
|
}
|