OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) |
3 * (C) 2000 Antti Koivisto (koivisto@kde.org) | 3 * (C) 2000 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2003, 2005, 2006, 2007, 2008, 2013 Apple Inc. All rights reserv
ed. | 5 * Copyright (C) 2003, 2005, 2006, 2007, 2008, 2013 Apple Inc. All rights reserv
ed. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
11 * | 11 * |
12 * This library is distributed in the hope that it will be useful, | 12 * This library is distributed in the hope that it will be useful, |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 * Library General Public License for more details. | 15 * Library General Public License for more details. |
16 * | 16 * |
17 * You should have received a copy of the GNU Library General Public License | 17 * You should have received a copy of the GNU Library General Public License |
18 * along with this library; see the file COPYING.LIB. If not, write to | 18 * along with this library; see the file COPYING.LIB. If not, write to |
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 * Boston, MA 02110-1301, USA. | 20 * Boston, MA 02110-1301, USA. |
21 * | 21 * |
22 */ | 22 */ |
23 | 23 |
24 #ifndef NinePieceImage_h | 24 #ifndef NinePieceImage_h |
25 #define NinePieceImage_h | 25 #define NinePieceImage_h |
26 | 26 |
| 27 #include "core/rendering/style/BorderImageLengthBox.h" |
27 #include "core/rendering/style/DataRef.h" | 28 #include "core/rendering/style/DataRef.h" |
28 #include "core/rendering/style/StyleImage.h" | 29 #include "core/rendering/style/StyleImage.h" |
29 #include "platform/LayoutUnit.h" | 30 #include "platform/LayoutUnit.h" |
30 #include "platform/LengthBox.h" | 31 #include "platform/LengthBox.h" |
31 | 32 |
32 namespace WebCore { | 33 namespace WebCore { |
33 | 34 |
34 enum ENinePieceImageRule { | 35 enum ENinePieceImageRule { |
35 StretchImageRule, RoundImageRule, SpaceImageRule, RepeatImageRule | 36 StretchImageRule, RoundImageRule, SpaceImageRule, RepeatImageRule |
36 }; | 37 }; |
37 | 38 |
38 class NinePieceImageData : public RefCounted<NinePieceImageData> { | 39 class NinePieceImageData : public RefCounted<NinePieceImageData> { |
39 public: | 40 public: |
40 static PassRefPtr<NinePieceImageData> create() { return adoptRef(new NinePie
ceImageData); } | 41 static PassRefPtr<NinePieceImageData> create() { return adoptRef(new NinePie
ceImageData); } |
41 PassRefPtr<NinePieceImageData> copy() const { return adoptRef(new NinePieceI
mageData(*this)); } | 42 PassRefPtr<NinePieceImageData> copy() const { return adoptRef(new NinePieceI
mageData(*this)); } |
42 | 43 |
43 bool operator==(const NinePieceImageData&) const; | 44 bool operator==(const NinePieceImageData&) const; |
44 bool operator!=(const NinePieceImageData& o) const { return !(*this == o); } | 45 bool operator!=(const NinePieceImageData& o) const { return !(*this == o); } |
45 | 46 |
46 bool fill : 1; | 47 bool fill : 1; |
47 unsigned horizontalRule : 2; // ENinePieceImageRule | 48 unsigned horizontalRule : 2; // ENinePieceImageRule |
48 unsigned verticalRule : 2; // ENinePieceImageRule | 49 unsigned verticalRule : 2; // ENinePieceImageRule |
49 RefPtr<StyleImage> image; | 50 RefPtr<StyleImage> image; |
50 LengthBox imageSlices; | 51 LengthBox imageSlices; |
51 LengthBox borderSlices; | 52 BorderImageLengthBox borderSlices; |
52 LengthBox outset; | 53 BorderImageLengthBox outset; |
53 | 54 |
54 private: | 55 private: |
55 NinePieceImageData(); | 56 NinePieceImageData(); |
56 NinePieceImageData(const NinePieceImageData&); | 57 NinePieceImageData(const NinePieceImageData&); |
57 }; | 58 }; |
58 | 59 |
59 class NinePieceImage { | 60 class NinePieceImage { |
60 public: | 61 public: |
61 NinePieceImage(); | 62 NinePieceImage(); |
62 NinePieceImage(PassRefPtr<StyleImage>, LengthBox imageSlices, bool fill, Len
gthBox borderSlices, LengthBox outset, ENinePieceImageRule horizontalRule, ENine
PieceImageRule verticalRule); | 63 NinePieceImage(PassRefPtr<StyleImage>, LengthBox imageSlices, bool fill, con
st BorderImageLengthBox& borderSlices, |
| 64 const BorderImageLengthBox& outset, ENinePieceImageRule horizontalRule,
ENinePieceImageRule verticalRule); |
63 | 65 |
64 bool operator==(const NinePieceImage& other) const { return m_data == other.
m_data; } | 66 bool operator==(const NinePieceImage& other) const { return m_data == other.
m_data; } |
65 bool operator!=(const NinePieceImage& other) const { return m_data != other.
m_data; } | 67 bool operator!=(const NinePieceImage& other) const { return m_data != other.
m_data; } |
66 | 68 |
67 bool hasImage() const { return m_data->image; } | 69 bool hasImage() const { return m_data->image; } |
68 StyleImage* image() const { return m_data->image.get(); } | 70 StyleImage* image() const { return m_data->image.get(); } |
69 void setImage(PassRefPtr<StyleImage> image) { m_data.access()->image = image
; } | 71 void setImage(PassRefPtr<StyleImage> image) { m_data.access()->image = image
; } |
70 | 72 |
71 const LengthBox& imageSlices() const { return m_data->imageSlices; } | 73 const LengthBox& imageSlices() const { return m_data->imageSlices; } |
72 void setImageSlices(const LengthBox& slices) { m_data.access()->imageSlices
= slices; } | 74 void setImageSlices(const LengthBox& slices) { m_data.access()->imageSlices
= slices; } |
73 | 75 |
74 bool fill() const { return m_data->fill; } | 76 bool fill() const { return m_data->fill; } |
75 void setFill(bool fill) { m_data.access()->fill = fill; } | 77 void setFill(bool fill) { m_data.access()->fill = fill; } |
76 | 78 |
77 const LengthBox& borderSlices() const { return m_data->borderSlices; } | 79 const BorderImageLengthBox& borderSlices() const { return m_data->borderSlic
es; } |
78 void setBorderSlices(const LengthBox& slices) { m_data.access()->borderSlice
s = slices; } | 80 void setBorderSlices(const BorderImageLengthBox& slices) { m_data.access()->
borderSlices = slices; } |
79 | 81 |
80 const LengthBox& outset() const { return m_data->outset; } | 82 const BorderImageLengthBox& outset() const { return m_data->outset; } |
81 void setOutset(const LengthBox& outset) { m_data.access()->outset = outset;
} | 83 void setOutset(const BorderImageLengthBox& outset) { m_data.access()->outset
= outset; } |
82 | 84 |
83 ENinePieceImageRule horizontalRule() const { return static_cast<ENinePieceIm
ageRule>(m_data->horizontalRule); } | 85 ENinePieceImageRule horizontalRule() const { return static_cast<ENinePieceIm
ageRule>(m_data->horizontalRule); } |
84 void setHorizontalRule(ENinePieceImageRule rule) { m_data.access()->horizont
alRule = rule; } | 86 void setHorizontalRule(ENinePieceImageRule rule) { m_data.access()->horizont
alRule = rule; } |
85 | 87 |
86 ENinePieceImageRule verticalRule() const { return static_cast<ENinePieceImag
eRule>(m_data->verticalRule); } | 88 ENinePieceImageRule verticalRule() const { return static_cast<ENinePieceImag
eRule>(m_data->verticalRule); } |
87 void setVerticalRule(ENinePieceImageRule rule) { m_data.access()->verticalRu
le = rule; } | 89 void setVerticalRule(ENinePieceImageRule rule) { m_data.access()->verticalRu
le = rule; } |
88 | 90 |
89 void copyImageSlicesFrom(const NinePieceImage& other) | 91 void copyImageSlicesFrom(const NinePieceImage& other) |
90 { | 92 { |
91 m_data.access()->imageSlices = other.m_data->imageSlices; | 93 m_data.access()->imageSlices = other.m_data->imageSlices; |
(...skipping 13 matching lines...) Expand all Loading... |
105 void copyRepeatFrom(const NinePieceImage& other) | 107 void copyRepeatFrom(const NinePieceImage& other) |
106 { | 108 { |
107 m_data.access()->horizontalRule = other.m_data->horizontalRule; | 109 m_data.access()->horizontalRule = other.m_data->horizontalRule; |
108 m_data.access()->verticalRule = other.m_data->verticalRule; | 110 m_data.access()->verticalRule = other.m_data->verticalRule; |
109 } | 111 } |
110 | 112 |
111 void setMaskDefaults() | 113 void setMaskDefaults() |
112 { | 114 { |
113 m_data.access()->imageSlices = LengthBox(0); | 115 m_data.access()->imageSlices = LengthBox(0); |
114 m_data.access()->fill = true; | 116 m_data.access()->fill = true; |
115 m_data.access()->borderSlices = LengthBox(); | 117 m_data.access()->borderSlices = BorderImageLengthBox(); |
116 } | 118 } |
117 | 119 |
118 static LayoutUnit computeOutset(Length outsetSide, LayoutUnit borderSide) | 120 static LayoutUnit computeOutset(const BorderImageLength& outsetSide, LayoutU
nit borderSide) |
119 { | 121 { |
120 if (outsetSide.isRelative()) | 122 if (outsetSide.isNumber()) |
121 return outsetSide.value() * borderSide; | 123 return outsetSide.number() * borderSide; |
122 return outsetSide.value(); | 124 return outsetSide.length().value(); |
123 } | 125 } |
124 | 126 |
125 private: | 127 private: |
126 DataRef<NinePieceImageData> m_data; | 128 DataRef<NinePieceImageData> m_data; |
127 }; | 129 }; |
128 | 130 |
129 } // namespace WebCore | 131 } // namespace WebCore |
130 | 132 |
131 #endif // NinePieceImage_h | 133 #endif // NinePieceImage_h |
OLD | NEW |