1 /*
2  * This file is part of the HTML rendering engine for KDE.
3  *
4  * Copyright (C) 1999-2003 Lars Knoll (knoll@kde.org)
5  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
6  *           (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com)
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public License
19  * along with this library; see the file COPYING.LIB.  If not, write to
20  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  * Boston, MA 02110-1301, USA.
22  *
23  */
24 #ifndef RENDER_LIST_H
25 #define RENDER_LIST_H
26 
27 #include "rendering/render_block.h"
28 
29 // ### list-style-position, list-style-image is still missing
30 
31 namespace khtml
32 {
33 
34 class RenderListItem;
35 class RenderListMarker;
36 class CounterNode;
37 
38 // -----------------------------------------------------------------------------
39 
40 class RenderListItem : public RenderBlock
41 {
42     friend class RenderListMarker;
43 //    friend class CounterListItem;
44 
45 public:
46     RenderListItem(DOM::NodeImpl *);
47 
renderName()48     const char *renderName() const override
49     {
50         return "RenderListItem";
51     }
52 
53     void setStyle(RenderStyle *style) override;
54 
isListItem()55     bool isListItem() const override
56     {
57         return true;
58     }
59 
setValue(long v)60     void setValue(long v)
61     {
62         predefVal = v;
63     }
64 
65     void layout() override;
66     void detach() override;
67     void calcMinMaxWidth() override;
68     //virtual short marginLeft() const;
69     //virtual short marginRight() const;
70 
setInsideList(bool b)71     void setInsideList(bool b)
72     {
73         m_insideList = b;
74     }
75 
76 protected:
77 
78     void updateMarkerLocation();
resetListMarker()79     void resetListMarker()
80     {
81         m_marker = nullptr;
82     }
83 
84     RenderListMarker *m_marker;
85     CounterNode *m_counter;
86     signed long predefVal : 30;
87     bool m_insideList  : 1;
88     bool m_deleteMarker: 1;
89 };
90 
91 // -----------------------------------------------------------------------------
92 
93 class RenderListMarker : public RenderBox
94 {
95 public:
96     RenderListMarker(DOM::NodeImpl *node);
97     ~RenderListMarker();
98 
99     void setStyle(RenderStyle *style) override;
100 
renderName()101     const char *renderName() const override
102     {
103         return "RenderListMarker";
104     }
105     // so the marker gets to layout itself. Only needed for
106     // list-style-position: inside
107 
108     void paint(PaintInfo &i, int xoff, int yoff) override;
109     void layout() override;
110     void calcMinMaxWidth() override;
111 
112     short lineHeight(bool firstLine) const override;
113     short baselinePosition(bool firstLine) const override;
114 
115     void updatePixmap(const QRect &, CachedImage *) override;
116 
117     void calcWidth() override;
118 
isListMarker()119     bool isListMarker() const override
120     {
121         return true;
122     }
123 
markerWidth()124     virtual short markerWidth() const
125     {
126         return m_markerWidth;
127     }
128 
listItem()129     RenderListItem *listItem() const
130     {
131         return m_listItem;
132     }
setListItem(RenderListItem * listItem)133     void setListItem(RenderListItem *listItem)
134     {
135         m_listItem = listItem;
136     }
137 
listPositionInside()138     bool listPositionInside() const
139     {
140         return !m_listItem->m_insideList || style()->listStylePosition() == INSIDE;
141     }
142 
143 protected:
144     friend class RenderListItem;
145 
146     QString m_item;
147     CachedImage *m_listImage;
148     short m_markerWidth;
149     RenderListItem *m_listItem;
150 };
151 
152 // Implementation of list-item counter
153 // ### should replace most list-item specific code in renderObject::getCounter
154 /*
155 class CounterListItem : public CounterNode
156 {
157 public:
158     int count() const;
159 
160     virtual void recount( bool first = false );
161     virtual void setSelfDirty();
162 
163 }; */
164 
165 } //namespace
166 
167 #endif
168