Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(318)

Side by Side Diff: Source/core/layout/style/FillLayer.h

Issue 1045723009: Move core/layout/style to core/style (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/layout/style/DataRef.h ('k') | Source/core/layout/style/FillLayer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 "core/layout/style/ComputedStyleConstants.h"
29 #include "core/layout/style/StyleImage.h"
30 #include "platform/Length.h"
31 #include "platform/LengthSize.h"
32 #include "platform/graphics/GraphicsTypes.h"
33 #include "wtf/RefPtr.h"
34
35 namespace blink {
36
37 struct FillSize {
38 FillSize()
39 : type(SizeLength)
40 {
41 }
42
43 FillSize(EFillSizeType t, const LengthSize& l)
44 : type(t)
45 , size(l)
46 {
47 }
48
49 bool operator==(const FillSize& o) const
50 {
51 return type == o.type && size == o.size;
52 }
53 bool operator!=(const FillSize& o) const
54 {
55 return !(*this == o);
56 }
57
58 EFillSizeType type;
59 LengthSize size;
60 };
61
62 class FillLayer {
63 WTF_MAKE_FAST_ALLOCATED(FillLayer);
64 public:
65 FillLayer(EFillLayerType, bool useInitialValues = false);
66 ~FillLayer();
67
68 StyleImage* image() const { return m_image.get(); }
69 const Length& xPosition() const { return m_xPosition; }
70 const Length& yPosition() const { return m_yPosition; }
71 BackgroundEdgeOrigin backgroundXOrigin() const { return static_cast<Backgrou ndEdgeOrigin>(m_backgroundXOrigin); }
72 BackgroundEdgeOrigin backgroundYOrigin() const { return static_cast<Backgrou ndEdgeOrigin>(m_backgroundYOrigin); }
73 EFillAttachment attachment() const { return static_cast<EFillAttachment>(m_a ttachment); }
74 EFillBox clip() const { return static_cast<EFillBox>(m_clip); }
75 EFillBox origin() const { return static_cast<EFillBox>(m_origin); }
76 EFillRepeat repeatX() const { return static_cast<EFillRepeat>(m_repeatX); }
77 EFillRepeat repeatY() const { return static_cast<EFillRepeat>(m_repeatY); }
78 CompositeOperator composite() const { return static_cast<CompositeOperator>( m_composite); }
79 WebBlendMode blendMode() const { return static_cast<WebBlendMode>(m_blendMod e); }
80 const LengthSize& sizeLength() const { return m_sizeLength; }
81 EFillSizeType sizeType() const { return static_cast<EFillSizeType>(m_sizeTyp e); }
82 FillSize size() const { return FillSize(static_cast<EFillSizeType>(m_sizeTyp e), m_sizeLength); }
83 EMaskSourceType maskSourceType() const { return static_cast<EMaskSourceType> (m_maskSourceType); }
84
85 const FillLayer* next() const { return m_next; }
86 FillLayer* next() { return m_next; }
87 FillLayer* ensureNext()
88 {
89 if (!m_next)
90 m_next = new FillLayer(type());
91 return m_next;
92 }
93
94 bool isImageSet() const { return m_imageSet; }
95 bool isXPositionSet() const { return m_xPosSet; }
96 bool isYPositionSet() const { return m_yPosSet; }
97 bool isBackgroundXOriginSet() const { return m_backgroundXOriginSet; }
98 bool isBackgroundYOriginSet() const { return m_backgroundYOriginSet; }
99 bool isAttachmentSet() const { return m_attachmentSet; }
100 bool isClipSet() const { return m_clipSet; }
101 bool isOriginSet() const { return m_originSet; }
102 bool isRepeatXSet() const { return m_repeatXSet; }
103 bool isRepeatYSet() const { return m_repeatYSet; }
104 bool isCompositeSet() const { return m_compositeSet; }
105 bool isBlendModeSet() const { return m_blendModeSet; }
106 bool isSizeSet() const { return m_sizeType != SizeNone; }
107 bool isMaskSourceTypeSet() const { return m_maskSourceTypeSet; }
108
109 void setImage(PassRefPtr<StyleImage> i) { m_image = i; m_imageSet = true; }
110 void setXPosition(const Length& position) { m_xPosition = position; m_xPosSe t = true; m_backgroundXOriginSet = false; m_backgroundXOrigin = LeftEdge; }
111 void setYPosition(const Length& position) { m_yPosition = position; m_yPosSe t = true; m_backgroundYOriginSet = false; m_backgroundYOrigin = TopEdge; }
112 void setBackgroundXOrigin(BackgroundEdgeOrigin origin) { m_backgroundXOrigin = origin; m_backgroundXOriginSet = true; }
113 void setBackgroundYOrigin(BackgroundEdgeOrigin origin) { m_backgroundYOrigin = origin; m_backgroundYOriginSet = true; }
114 void setAttachment(EFillAttachment attachment) { m_attachment = attachment; m_attachmentSet = true; }
115 void setClip(EFillBox b) { m_clip = b; m_clipSet = true; }
116 void setOrigin(EFillBox b) { m_origin = b; m_originSet = true; }
117 void setRepeatX(EFillRepeat r) { m_repeatX = r; m_repeatXSet = true; }
118 void setRepeatY(EFillRepeat r) { m_repeatY = r; m_repeatYSet = true; }
119 void setComposite(CompositeOperator c) { m_composite = c; m_compositeSet = t rue; }
120 void setBlendMode(WebBlendMode b) { m_blendMode = b; m_blendModeSet = true; }
121 void setSizeType(EFillSizeType b) { m_sizeType = b; }
122 void setSizeLength(const LengthSize& length) { m_sizeLength = length; }
123 void setSize(FillSize f) { m_sizeType = f.type; m_sizeLength = f.size; }
124 void setMaskSourceType(EMaskSourceType m) { m_maskSourceType = m; m_maskSour ceTypeSet = true; }
125
126 void clearImage() { m_image.clear(); m_imageSet = false; }
127 void clearXPosition()
128 {
129 m_xPosSet = false;
130 m_backgroundXOriginSet = false;
131 }
132 void clearYPosition()
133 {
134 m_yPosSet = false;
135 m_backgroundYOriginSet = false;
136 }
137
138 void clearAttachment() { m_attachmentSet = false; }
139 void clearClip() { m_clipSet = false; }
140 void clearOrigin() { m_originSet = false; }
141 void clearRepeatX() { m_repeatXSet = false; }
142 void clearRepeatY() { m_repeatYSet = false; }
143 void clearComposite() { m_compositeSet = false; }
144 void clearBlendMode() { m_blendModeSet = false; }
145 void clearSize() { m_sizeType = SizeNone; }
146 void clearMaskSourceType() { m_maskSourceTypeSet = false; }
147
148 FillLayer& operator=(const FillLayer&);
149 FillLayer(const FillLayer&);
150
151 bool operator==(const FillLayer&) const;
152 bool operator!=(const FillLayer& o) const
153 {
154 return !(*this == o);
155 }
156
157 bool containsImage(StyleImage*) const;
158 bool imagesAreLoaded() const;
159
160 bool hasImage() const
161 {
162 if (m_image)
163 return true;
164 return m_next ? m_next->hasImage() : false;
165 }
166
167 bool hasFixedImage() const
168 {
169 if (m_image && m_attachment == FixedBackgroundAttachment)
170 return true;
171 return m_next ? m_next->hasFixedImage() : false;
172 }
173
174 bool hasOpaqueImage(const LayoutObject*) const;
175 bool hasRepeatXY() const;
176 bool clipOccludesNextLayers(bool firstLayer) const;
177
178 EFillLayerType type() const { return static_cast<EFillLayerType>(m_type); }
179
180 void fillUnsetProperties();
181 void cullEmptyLayers();
182
183 static EFillAttachment initialFillAttachment(EFillLayerType) { return Scroll BackgroundAttachment; }
184 static EFillBox initialFillClip(EFillLayerType) { return BorderFillBox; }
185 static EFillBox initialFillOrigin(EFillLayerType type) { return type == Back groundFillLayer ? PaddingFillBox : BorderFillBox; }
186 static EFillRepeat initialFillRepeatX(EFillLayerType) { return RepeatFill; }
187 static EFillRepeat initialFillRepeatY(EFillLayerType) { return RepeatFill; }
188 static CompositeOperator initialFillComposite(EFillLayerType) { return Compo siteSourceOver; }
189 static WebBlendMode initialFillBlendMode(EFillLayerType) { return WebBlendMo deNormal; }
190 static EFillSizeType initialFillSizeType(EFillLayerType) { return SizeLength ; }
191 static LengthSize initialFillSizeLength(EFillLayerType) { return LengthSize( ); }
192 static FillSize initialFillSize(EFillLayerType type) { return FillSize(initi alFillSizeType(type), initialFillSizeLength(type)); }
193 static Length initialFillXPosition(EFillLayerType) { return Length(0.0, Perc ent); }
194 static Length initialFillYPosition(EFillLayerType) { return Length(0.0, Perc ent); }
195 static StyleImage* initialFillImage(EFillLayerType) { return 0; }
196 static EMaskSourceType initialFillMaskSourceType(EFillLayerType) { return Ma skAlpha; }
197
198 private:
199 friend class ComputedStyle;
200
201 void computeClipMax() const;
202
203 FillLayer() { }
204
205 FillLayer* m_next;
206
207 RefPtr<StyleImage> m_image;
208
209 Length m_xPosition;
210 Length m_yPosition;
211
212 LengthSize m_sizeLength;
213
214 unsigned m_attachment : 2; // EFillAttachment
215 unsigned m_clip : 2; // EFillBox
216 unsigned m_origin : 2; // EFillBox
217 unsigned m_repeatX : 3; // EFillRepeat
218 unsigned m_repeatY : 3; // EFillRepeat
219 unsigned m_composite : 4; // CompositeOperator
220 unsigned m_sizeType : 2; // EFillSizeType
221 unsigned m_blendMode : 5; // WebBlendMode
222 unsigned m_maskSourceType : 1; // EMaskSourceType
223 unsigned m_backgroundXOrigin : 2; // BackgroundEdgeOrigin
224 unsigned m_backgroundYOrigin : 2; // BackgroundEdgeOrigin
225
226 unsigned m_imageSet : 1;
227 unsigned m_attachmentSet : 1;
228 unsigned m_clipSet : 1;
229 unsigned m_originSet : 1;
230 unsigned m_repeatXSet : 1;
231 unsigned m_repeatYSet : 1;
232 unsigned m_xPosSet : 1;
233 unsigned m_yPosSet : 1;
234 unsigned m_backgroundXOriginSet : 1;
235 unsigned m_backgroundYOriginSet : 1;
236 unsigned m_compositeSet : 1;
237 unsigned m_blendModeSet : 1;
238 unsigned m_maskSourceTypeSet : 1;
239
240 unsigned m_type : 1; // EFillLayerType
241
242 mutable unsigned m_clipMax : 2; // EFillBox, maximum m_clip value from this to bottom layer
243 };
244
245 } // namespace blink
246
247 #endif // FillLayer_h
OLDNEW
« no previous file with comments | « Source/core/layout/style/DataRef.h ('k') | Source/core/layout/style/FillLayer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698