
Previously they were positioned with a fixed offset. However this lead to wider markers with more than one character to collide with the element itself. Now the ListItemMarkerBox generates and stores the appropriate String in its constructor and sets its own width according to that. The ListItemBox then lays out the Marker taking this width into account. This also made the painting a lot easier since we don't generate the needed Strings every time we repaint, just once.
28 lines
618 B
C++
28 lines
618 B
C++
/*
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
* Copyright (c) 2021, Tobias Christiansen <tobi@tobyase.de>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibWeb/Layout/Box.h>
|
|
|
|
namespace Web::Layout {
|
|
|
|
class ListItemMarkerBox final : public Box {
|
|
public:
|
|
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;
|
|
|
|
String m_text {};
|
|
};
|
|
|
|
}
|