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)
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.
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.
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.
28 #include "GraphicsTypes.h"
30 #include "LengthSize.h"
31 #include "RenderStyleConstants.h"
32 #include "StyleImage.h"
33 #include <wtf/RefPtr.h>
43 FillSize(EFillSizeType t, LengthSize l)
49 bool operator==(const FillSize& o) const
51 return type == o.type && size == o.size;
53 bool operator!=(const FillSize& o) const
63 WTF_MAKE_FAST_ALLOCATED;
65 FillLayer(EFillLayerType);
68 StyleImage* image() const { return m_image.get(); }
69 Length xPosition() const { return m_xPosition; }
70 Length yPosition() const { return m_yPosition; }
71 EFillAttachment attachment() const { return static_cast<EFillAttachment>(m_attachment); }
72 EFillBox clip() const { return static_cast<EFillBox>(m_clip); }
73 EFillBox origin() const { return static_cast<EFillBox>(m_origin); }
74 EFillRepeat repeatX() const { return static_cast<EFillRepeat>(m_repeatX); }
75 EFillRepeat repeatY() const { return static_cast<EFillRepeat>(m_repeatY); }
76 CompositeOperator composite() const { return static_cast<CompositeOperator>(m_composite); }
77 LengthSize sizeLength() const { return m_sizeLength; }
78 EFillSizeType sizeType() const { return static_cast<EFillSizeType>(m_sizeType); }
79 FillSize size() const { return FillSize(static_cast<EFillSizeType>(m_sizeType), m_sizeLength); }
81 const FillLayer* next() const { return m_next; }
82 FillLayer* next() { return m_next; }
84 bool isImageSet() const { return m_imageSet; }
85 bool isXPositionSet() const { return m_xPosSet; }
86 bool isYPositionSet() const { return m_yPosSet; }
87 bool isAttachmentSet() const { return m_attachmentSet; }
88 bool isClipSet() const { return m_clipSet; }
89 bool isOriginSet() const { return m_originSet; }
90 bool isRepeatXSet() const { return m_repeatXSet; }
91 bool isRepeatYSet() const { return m_repeatYSet; }
92 bool isCompositeSet() const { return m_compositeSet; }
93 bool isSizeSet() const { return m_sizeType != SizeNone; }
95 void setImage(StyleImage* i) { m_image = i; m_imageSet = true; }
96 void setXPosition(Length l) { m_xPosition = l; m_xPosSet = true; }
97 void setYPosition(Length l) { m_yPosition = l; m_yPosSet = true; }
98 void setAttachment(EFillAttachment attachment) { m_attachment = attachment; m_attachmentSet = true; }
99 void setClip(EFillBox b) { m_clip = b; m_clipSet = true; }
100 void setOrigin(EFillBox b) { m_origin = b; m_originSet = true; }
101 void setRepeatX(EFillRepeat r) { m_repeatX = r; m_repeatXSet = true; }
102 void setRepeatY(EFillRepeat r) { m_repeatY = r; m_repeatYSet = true; }
103 void setComposite(CompositeOperator c) { m_composite = c; m_compositeSet = true; }
104 void setSizeType(EFillSizeType b) { m_sizeType = b; }
105 void setSizeLength(LengthSize l) { m_sizeLength = l; }
106 void setSize(FillSize f) { m_sizeType = f.type; m_sizeLength = f.size; }
108 void clearImage() { m_imageSet = false; }
109 void clearXPosition() { m_xPosSet = false; }
110 void clearYPosition() { m_yPosSet = false; }
111 void clearAttachment() { m_attachmentSet = false; }
112 void clearClip() { m_clipSet = false; }
113 void clearOrigin() { m_originSet = false; }
114 void clearRepeatX() { m_repeatXSet = false; }
115 void clearRepeatY() { m_repeatYSet = false; }
116 void clearComposite() { m_compositeSet = false; }
117 void clearSize() { m_sizeType = SizeNone; }
119 void setNext(FillLayer* n) { if (m_next != n) { delete m_next; m_next = n; } }
121 FillLayer& operator=(const FillLayer& o);
122 FillLayer(const FillLayer& o);
124 bool operator==(const FillLayer& o) const;
125 bool operator!=(const FillLayer& o) const
127 return !(*this == o);
130 bool containsImage(StyleImage*) const;
131 bool imagesAreLoaded() const;
133 bool hasImage() const
137 return m_next ? m_next->hasImage() : false;
140 bool hasFixedImage() const
142 if (m_image && m_attachment == FixedBackgroundAttachment)
144 return m_next ? m_next->hasFixedImage() : false;
147 EFillLayerType type() const { return static_cast<EFillLayerType>(m_type); }
149 void fillUnsetProperties();
150 void cullEmptyLayers();
152 static EFillAttachment initialFillAttachment(EFillLayerType) { return ScrollBackgroundAttachment; }
153 static EFillBox initialFillClip(EFillLayerType) { return BorderFillBox; }
154 static EFillBox initialFillOrigin(EFillLayerType type) { return type == BackgroundFillLayer ? PaddingFillBox : BorderFillBox; }
155 static EFillRepeat initialFillRepeatX(EFillLayerType) { return RepeatFill; }
156 static EFillRepeat initialFillRepeatY(EFillLayerType) { return RepeatFill; }
157 static CompositeOperator initialFillComposite(EFillLayerType) { return CompositeSourceOver; }
158 static EFillSizeType initialFillSizeType(EFillLayerType) { return SizeLength; }
159 static LengthSize initialFillSizeLength(EFillLayerType) { return LengthSize(); }
160 static FillSize initialFillSize(EFillLayerType) { return FillSize(); }
161 static Length initialFillXPosition(EFillLayerType) { return Length(0.0, Percent); }
162 static Length initialFillYPosition(EFillLayerType) { return Length(0.0, Percent); }
163 static StyleImage* initialFillImage(EFillLayerType) { return 0; }
166 friend class RenderStyle;
172 RefPtr<StyleImage> m_image;
177 unsigned m_attachment : 2; // EFillAttachment
178 unsigned m_clip : 2; // EFillBox
179 unsigned m_origin : 2; // EFillBox
180 unsigned m_repeatX : 3; // EFillRepeat
181 unsigned m_repeatY : 3; // EFillRepeat
182 unsigned m_composite : 4; // CompositeOperator
183 unsigned m_sizeType : 2; // EFillSizeType
185 LengthSize m_sizeLength;
188 bool m_attachmentSet : 1;
190 bool m_originSet : 1;
191 bool m_repeatXSet : 1;
192 bool m_repeatYSet : 1;
195 bool m_compositeSet : 1;
197 unsigned m_type : 1; // EFillLayerType
200 } // namespace WebCore
202 #endif // FillLayer_h