1/*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2009 Apple Inc. All rights reserved.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 *
21 */
22
23#pragma once
24
25#include "RenderBox.h"
26
27namespace WebCore {
28
29class RenderListItem;
30
31String listMarkerText(ListStyleType, int value);
32
33// Used to render the list item's marker.
34// The RenderListMarker always has to be a child of a RenderListItem.
35class RenderListMarker final : public RenderBox {
36 WTF_MAKE_ISO_ALLOCATED(RenderListMarker);
37public:
38 RenderListMarker(RenderListItem&, RenderStyle&&);
39 virtual ~RenderListMarker();
40
41 const String& text() const { return m_text; }
42 String suffix() const;
43
44 bool isInside() const;
45
46 LayoutUnit lineOffsetForListItem() const { return m_lineOffsetForListItem; }
47
48 void updateMarginsAndContent();
49
50private:
51 void willBeDestroyed() override;
52
53 void element() const = delete;
54
55 const char* renderName() const override { return "RenderListMarker"; }
56 void computePreferredLogicalWidths() override;
57
58 bool isListMarker() const override { return true; }
59 bool canHaveChildren() const override { return false; }
60
61 void paint(PaintInfo&, const LayoutPoint&) override;
62
63 void layout() override;
64
65 void imageChanged(WrappedImagePtr, const IntRect* = 0) override;
66
67 std::unique_ptr<InlineElementBox> createInlineBox() override;
68
69 LayoutUnit lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const override;
70 int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const override;
71
72 bool isImage() const override;
73 bool isText() const { return !isImage(); }
74
75 void setSelectionState(SelectionState) override;
76 LayoutRect selectionRectForRepaint(const RenderLayerModelObject* repaintContainer, bool clipToVisibleContent = true) override;
77 bool canBeSelectionLeaf() const override { return true; }
78
79 void updateMargins();
80 void updateContent();
81
82 void styleDidChange(StyleDifference, const RenderStyle* oldStyle) override;
83
84 FloatRect getRelativeMarkerRect();
85 LayoutRect localSelectionRect();
86
87 String m_text;
88 RefPtr<StyleImage> m_image;
89 WeakPtr<RenderListItem> m_listItem;
90 LayoutUnit m_lineOffsetForListItem;
91};
92
93} // namespace WebCore
94
95SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderListMarker, isListMarker())
96