]> git.saurik.com Git - iphone-api.git/blob - WebCore/FillLayer.h
Add support for new WinterBoard Settings features.
[iphone-api.git] / WebCore / FillLayer.h
1 /*
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
6 * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.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
25 #ifndef FillLayer_h
26 #define FillLayer_h
27
28 #include "GraphicsTypes.h"
29 #include "Length.h"
30 #include "LengthSize.h"
31 #include "RenderStyleConstants.h"
32 #include "StyleImage.h"
33 #include <wtf/RefPtr.h>
34
35 namespace WebCore {
36
37 struct FillLayer {
38 public:
39 FillLayer(EFillLayerType);
40 ~FillLayer();
41
42 StyleImage* image() const { return m_image.get(); }
43 Length xPosition() const { return m_xPosition; }
44 Length yPosition() const { return m_yPosition; }
45 bool attachment() const { return m_attachment; }
46 EFillBox clip() const { return static_cast<EFillBox>(m_clip); }
47 EFillBox origin() const { return static_cast<EFillBox>(m_origin); }
48 EFillRepeat repeat() const { return static_cast<EFillRepeat>(m_repeat); }
49 CompositeOperator composite() const { return static_cast<CompositeOperator>(m_composite); }
50 LengthSize size() const { return m_size; }
51
52 const FillLayer* next() const { return m_next; }
53 FillLayer* next() { return m_next; }
54
55 bool isImageSet() const { return m_imageSet; }
56 bool isXPositionSet() const { return m_xPosSet; }
57 bool isYPositionSet() const { return m_yPosSet; }
58 bool isAttachmentSet() const { return m_attachmentSet; }
59 bool isClipSet() const { return m_clipSet; }
60 bool isOriginSet() const { return m_originSet; }
61 bool isRepeatSet() const { return m_repeatSet; }
62 bool isCompositeSet() const { return m_compositeSet; }
63 bool isSizeSet() const { return m_sizeSet; }
64
65 void setImage(StyleImage* i) { m_image = i; m_imageSet = true; }
66 void setXPosition(const Length& l) { m_xPosition = l; m_xPosSet = true; }
67 void setYPosition(const Length& l) { m_yPosition = l; m_yPosSet = true; }
68 void setAttachment(bool b) { m_attachment = b; m_attachmentSet = true; }
69 void setClip(EFillBox b) { m_clip = b; m_clipSet = true; }
70 void setOrigin(EFillBox b) { m_origin = b; m_originSet = true; }
71 void setRepeat(EFillRepeat r) { m_repeat = r; m_repeatSet = true; }
72 void setComposite(CompositeOperator c) { m_composite = c; m_compositeSet = true; }
73 void setSize(const LengthSize& b) { m_size = b; m_sizeSet = true; }
74
75 void clearImage() { m_imageSet = false; }
76 void clearXPosition() { m_xPosSet = false; }
77 void clearYPosition() { m_yPosSet = false; }
78 void clearAttachment() { m_attachmentSet = false; }
79 void clearClip() { m_clipSet = false; }
80 void clearOrigin() { m_originSet = false; }
81 void clearRepeat() { m_repeatSet = false; }
82 void clearComposite() { m_compositeSet = false; }
83 void clearSize() { m_sizeSet = false; }
84
85 void setNext(FillLayer* n) { if (m_next != n) { delete m_next; m_next = n; } }
86
87 FillLayer& operator=(const FillLayer& o);
88 FillLayer(const FillLayer& o);
89
90 bool operator==(const FillLayer& o) const;
91 bool operator!=(const FillLayer& o) const
92 {
93 return !(*this == o);
94 }
95
96 bool containsImage(StyleImage*) const;
97
98 bool hasImage() const
99 {
100 if (m_image)
101 return true;
102 return m_next ? m_next->hasImage() : false;
103 }
104
105 bool hasFixedImage() const
106 {
107 if (m_image && !m_attachment)
108 return true;
109 return m_next ? m_next->hasFixedImage() : false;
110 }
111
112 EFillLayerType type() const { return static_cast<EFillLayerType>(m_type); }
113
114 void fillUnsetProperties();
115 void cullEmptyLayers();
116
117 static bool initialFillAttachment(EFillLayerType) { return true; }
118 static EFillBox initialFillClip(EFillLayerType) { return BorderFillBox; }
119 static EFillBox initialFillOrigin(EFillLayerType type) { return type == BackgroundFillLayer ? PaddingFillBox : BorderFillBox; }
120 static EFillRepeat initialFillRepeat(EFillLayerType) { return RepeatFill; }
121 static CompositeOperator initialFillComposite(EFillLayerType) { return CompositeSourceOver; }
122 static LengthSize initialFillSize(EFillLayerType) { return LengthSize(); }
123 static Length initialFillXPosition(EFillLayerType) { return Length(0.0, Percent); }
124 static Length initialFillYPosition(EFillLayerType) { return Length(0.0, Percent); }
125 static StyleImage* initialFillImage(EFillLayerType) { return 0; }
126
127 private:
128 FillLayer() { }
129
130 public:
131 RefPtr<StyleImage> m_image;
132
133 Length m_xPosition;
134 Length m_yPosition;
135
136 bool m_attachment : 1;
137 unsigned m_clip : 2; // EFillBox
138 unsigned m_origin : 2; // EFillBox
139 unsigned m_repeat : 2; // EFillRepeat
140 unsigned m_composite : 4; // CompositeOperator
141
142 LengthSize m_size;
143
144 bool m_imageSet : 1;
145 bool m_attachmentSet : 1;
146 bool m_clipSet : 1;
147 bool m_originSet : 1;
148 bool m_repeatSet : 1;
149 bool m_xPosSet : 1;
150 bool m_yPosSet : 1;
151 bool m_compositeSet : 1;
152 bool m_sizeSet : 1;
153
154 unsigned m_type : 1; // EFillLayerType
155
156 FillLayer* m_next;
157 };
158
159 } // namespace WebCore
160
161 #endif // FillLayer_h