• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
imageFillLayer42     StyleImage* image() const { return m_image.get(); }
xPositionFillLayer43     Length xPosition() const { return m_xPosition; }
yPositionFillLayer44     Length yPosition() const { return m_yPosition; }
attachmentFillLayer45     EFillAttachment attachment() const { return static_cast<EFillAttachment>(m_attachment); }
clipFillLayer46     EFillBox clip() const { return static_cast<EFillBox>(m_clip); }
originFillLayer47     EFillBox origin() const { return static_cast<EFillBox>(m_origin); }
repeatFillLayer48     EFillRepeat repeat() const { return static_cast<EFillRepeat>(m_repeat); }
compositeFillLayer49     CompositeOperator composite() const { return static_cast<CompositeOperator>(m_composite); }
sizeFillLayer50     LengthSize size() const { return m_size; }
51 
nextFillLayer52     const FillLayer* next() const { return m_next; }
nextFillLayer53     FillLayer* next() { return m_next; }
54 
isImageSetFillLayer55     bool isImageSet() const { return m_imageSet; }
isXPositionSetFillLayer56     bool isXPositionSet() const { return m_xPosSet; }
isYPositionSetFillLayer57     bool isYPositionSet() const { return m_yPosSet; }
isAttachmentSetFillLayer58     bool isAttachmentSet() const { return m_attachmentSet; }
isClipSetFillLayer59     bool isClipSet() const { return m_clipSet; }
isOriginSetFillLayer60     bool isOriginSet() const { return m_originSet; }
isRepeatSetFillLayer61     bool isRepeatSet() const { return m_repeatSet; }
isCompositeSetFillLayer62     bool isCompositeSet() const { return m_compositeSet; }
isSizeSetFillLayer63     bool isSizeSet() const { return m_sizeSet; }
64 
setImageFillLayer65     void setImage(StyleImage* i) { m_image = i; m_imageSet = true; }
setXPositionFillLayer66     void setXPosition(const Length& l) { m_xPosition = l; m_xPosSet = true; }
setYPositionFillLayer67     void setYPosition(const Length& l) { m_yPosition = l; m_yPosSet = true; }
setAttachmentFillLayer68     void setAttachment(EFillAttachment attachment) { m_attachment = attachment; m_attachmentSet = true; }
setClipFillLayer69     void setClip(EFillBox b) { m_clip = b; m_clipSet = true; }
setOriginFillLayer70     void setOrigin(EFillBox b) { m_origin = b; m_originSet = true; }
setRepeatFillLayer71     void setRepeat(EFillRepeat r) { m_repeat = r; m_repeatSet = true; }
setCompositeFillLayer72     void setComposite(CompositeOperator c) { m_composite = c; m_compositeSet = true; }
setSizeFillLayer73     void setSize(const LengthSize& b) { m_size = b; m_sizeSet = true; }
74 
clearImageFillLayer75     void clearImage() { m_imageSet = false; }
clearXPositionFillLayer76     void clearXPosition() { m_xPosSet = false; }
clearYPositionFillLayer77     void clearYPosition() { m_yPosSet = false; }
clearAttachmentFillLayer78     void clearAttachment() { m_attachmentSet = false; }
clearClipFillLayer79     void clearClip() { m_clipSet = false; }
clearOriginFillLayer80     void clearOrigin() { m_originSet = false; }
clearRepeatFillLayer81     void clearRepeat() { m_repeatSet = false; }
clearCompositeFillLayer82     void clearComposite() { m_compositeSet = false; }
clearSizeFillLayer83     void clearSize() { m_sizeSet = false; }
84 
setNextFillLayer85     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 
hasImageFillLayer98     bool hasImage() const
99     {
100         if (m_image)
101             return true;
102         return m_next ? m_next->hasImage() : false;
103     }
104 
hasFixedImageFillLayer105     bool hasFixedImage() const
106     {
107         if (m_image && m_attachment == FixedBackgroundAttachment)
108             return true;
109         return m_next ? m_next->hasFixedImage() : false;
110     }
111 
typeFillLayer112     EFillLayerType type() const { return static_cast<EFillLayerType>(m_type); }
113 
114     void fillUnsetProperties();
115     void cullEmptyLayers();
116 
initialFillAttachmentFillLayer117     static EFillAttachment initialFillAttachment(EFillLayerType) { return ScrollBackgroundAttachment; }
initialFillClipFillLayer118     static EFillBox initialFillClip(EFillLayerType) { return BorderFillBox; }
initialFillOriginFillLayer119     static EFillBox initialFillOrigin(EFillLayerType type) { return type == BackgroundFillLayer ? PaddingFillBox : BorderFillBox; }
initialFillRepeatFillLayer120     static EFillRepeat initialFillRepeat(EFillLayerType) { return RepeatFill; }
initialFillCompositeFillLayer121     static CompositeOperator initialFillComposite(EFillLayerType) { return CompositeSourceOver; }
initialFillSizeFillLayer122     static LengthSize initialFillSize(EFillLayerType) { return LengthSize(); }
initialFillXPositionFillLayer123     static Length initialFillXPosition(EFillLayerType) { return Length(0.0, Percent); }
initialFillYPositionFillLayer124     static Length initialFillYPosition(EFillLayerType) { return Length(0.0, Percent); }
initialFillImageFillLayer125     static StyleImage* initialFillImage(EFillLayerType) { return 0; }
126 
127 private:
FillLayerFillLayer128     FillLayer() { }
129 
130 public:
131     RefPtr<StyleImage> m_image;
132 
133     Length m_xPosition;
134     Length m_yPosition;
135 
136     unsigned m_attachment : 2; // EFillAttachment
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
162