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 #ifndef RenderListMarker_h
24 #define RenderListMarker_h
25
26 #include "RenderBox.h"
27
28 namespace WebCore {
29
30 class RenderListItem;
31
32 String listMarkerText(EListStyleType, int value);
33
34 // Used to render the list item's marker.
35 // The RenderListMarker always has to be a child of a RenderListItem.
36 class RenderListMarker : public RenderBox {
37 public:
38 RenderListMarker(RenderListItem*);
39 virtual ~RenderListMarker();
40
41 virtual void computePreferredLogicalWidths();
42
text()43 const String& text() const { return m_text; }
44 String suffix() const;
45
46 bool isInside() const;
47
48 private:
renderName()49 virtual const char* renderName() const { return "RenderListMarker"; }
50
isListMarker()51 virtual bool isListMarker() const { return true; }
52
53 virtual void paint(PaintInfo&, int tx, int ty);
54
55 virtual void layout();
56
57 virtual void imageChanged(WrappedImagePtr, const IntRect* = 0);
58
59 virtual InlineBox* createInlineBox();
60
61 virtual int lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;
62 virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const;
63
64 bool isImage() const;
isText()65 bool isText() const { return !isImage(); }
66
67 virtual void setSelectionState(SelectionState);
68 virtual IntRect selectionRectForRepaint(RenderBoxModelObject* repaintContainer, bool clipToVisibleContent = true);
canBeSelectionLeaf()69 virtual bool canBeSelectionLeaf() const { return true; }
70
71 void updateMargins();
72
73 virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle);
74 virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
75
76 IntRect getRelativeMarkerRect();
77 IntRect localSelectionRect();
78
79 String m_text;
80 RefPtr<StyleImage> m_image;
81 RenderListItem* m_listItem;
82 };
83
toRenderListMarker(RenderObject * object)84 inline RenderListMarker* toRenderListMarker(RenderObject* object)
85 {
86 ASSERT(!object || object->isListMarker());
87 return static_cast<RenderListMarker*>(object);
88 }
89
toRenderListMarker(const RenderObject * object)90 inline const RenderListMarker* toRenderListMarker(const RenderObject* object)
91 {
92 ASSERT(!object || object->isListMarker());
93 return static_cast<const RenderListMarker*>(object);
94 }
95
96 // This will catch anyone doing an unnecessary cast.
97 void toRenderListMarker(const RenderListMarker*);
98
99 } // namespace WebCore
100
101 #endif // RenderListMarker_h
102