Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / rendering / RenderListMarker.h
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 "core/rendering/RenderBox.h"
27
28 namespace blink {
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 final : public RenderBox {
37 public:
38     static RenderListMarker* createAnonymous(RenderListItem*);
39
40     virtual ~RenderListMarker();
41     virtual void destroy() override;
42     virtual void trace(Visitor*) override;
43
44     const String& text() const { return m_text; }
45
46     bool isInside() const;
47
48     void updateMarginsAndContent();
49
50     IntRect getRelativeMarkerRect();
51     LayoutRect localSelectionRect();
52     virtual bool isImage() const override;
53     const StyleImage* image() { return m_image.get(); }
54     const RenderListItem* listItem() { return m_listItem.get(); }
55
56     static UChar listMarkerSuffix(EListStyleType, int value);
57
58     void listItemStyleDidChange();
59
60 private:
61     RenderListMarker(RenderListItem*);
62
63     virtual const char* renderName() const override { return "RenderListMarker"; }
64     virtual void computePreferredLogicalWidths() override;
65
66     virtual bool isOfType(RenderObjectType type) const override { return type == RenderObjectListMarker || RenderBox::isOfType(type); }
67
68     virtual void paint(PaintInfo&, const LayoutPoint&) override;
69
70     virtual void layout() override;
71
72     virtual void imageChanged(WrappedImagePtr, const IntRect* = 0) override;
73
74     virtual InlineBox* createInlineBox() override;
75
76     virtual LayoutUnit lineHeight(bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const override;
77     virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const override;
78
79     bool isText() const { return !isImage(); }
80
81     virtual void setSelectionState(SelectionState) override;
82     virtual LayoutRect selectionRectForPaintInvalidation(const RenderLayerModelObject* paintInvalidationContainer) const override;
83     virtual bool canBeSelectionLeaf() const override { return true; }
84
85     void updateMargins();
86     void updateContent();
87
88     virtual void styleWillChange(StyleDifference, const RenderStyle& newStyle) override;
89     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) override;
90
91     String m_text;
92     RefPtr<StyleImage> m_image;
93     RawPtrWillBeMember<RenderListItem> m_listItem;
94 };
95
96 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderListMarker, isListMarker());
97
98 } // namespace blink
99
100 #endif // RenderListMarker_h