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/DataRef.h" | 27 #include "core/rendering/style/DataRef.h" |
28 #include "core/rendering/style/StyleImage.h" | 28 #include "core/rendering/style/StyleImage.h" |
29 #include "platform/BorderImageLengthBox.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, Bor derImageLengthBox borderSlices, BorderImageLengthBox outset, ENinePieceImageRule horizontalRule, ENinePieceImageRule verticalRule); |
Julien - ping for review
2013/11/04 16:31:40
Nit: const BorderImageLengthBox& ?
| |
63 | 64 |
64 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; } |
65 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; } |
66 | 67 |
67 bool hasImage() const { return m_data->image; } | 68 bool hasImage() const { return m_data->image; } |
68 StyleImage* image() const { return m_data->image.get(); } | 69 StyleImage* image() const { return m_data->image.get(); } |
69 void setImage(PassRefPtr<StyleImage> image) { m_data.access()->image = image ; } | 70 void setImage(PassRefPtr<StyleImage> image) { m_data.access()->image = image ; } |
70 | 71 |
71 const LengthBox& imageSlices() const { return m_data->imageSlices; } | 72 const LengthBox& imageSlices() const { return m_data->imageSlices; } |
72 void setImageSlices(const LengthBox& slices) { m_data.access()->imageSlices = slices; } | 73 void setImageSlices(const LengthBox& slices) { m_data.access()->imageSlices = slices; } |
73 | 74 |
74 bool fill() const { return m_data->fill; } | 75 bool fill() const { return m_data->fill; } |
75 void setFill(bool fill) { m_data.access()->fill = fill; } | 76 void setFill(bool fill) { m_data.access()->fill = fill; } |
76 | 77 |
77 const LengthBox& borderSlices() const { return m_data->borderSlices; } | 78 const BorderImageLengthBox& borderSlices() const { return m_data->borderSlic es; } |
78 void setBorderSlices(const LengthBox& slices) { m_data.access()->borderSlice s = slices; } | 79 void setBorderSlices(const BorderImageLengthBox& slices) { m_data.access()-> borderSlices = slices; } |
79 | 80 |
80 const LengthBox& outset() const { return m_data->outset; } | 81 const BorderImageLengthBox& outset() const { return m_data->outset; } |
81 void setOutset(const LengthBox& outset) { m_data.access()->outset = outset; } | 82 void setOutset(const BorderImageLengthBox& outset) { m_data.access()->outset = outset; } |
82 | 83 |
83 ENinePieceImageRule horizontalRule() const { return static_cast<ENinePieceIm ageRule>(m_data->horizontalRule); } | 84 ENinePieceImageRule horizontalRule() const { return static_cast<ENinePieceIm ageRule>(m_data->horizontalRule); } |
84 void setHorizontalRule(ENinePieceImageRule rule) { m_data.access()->horizont alRule = rule; } | 85 void setHorizontalRule(ENinePieceImageRule rule) { m_data.access()->horizont alRule = rule; } |
85 | 86 |
86 ENinePieceImageRule verticalRule() const { return static_cast<ENinePieceImag eRule>(m_data->verticalRule); } | 87 ENinePieceImageRule verticalRule() const { return static_cast<ENinePieceImag eRule>(m_data->verticalRule); } |
87 void setVerticalRule(ENinePieceImageRule rule) { m_data.access()->verticalRu le = rule; } | 88 void setVerticalRule(ENinePieceImageRule rule) { m_data.access()->verticalRu le = rule; } |
88 | 89 |
89 void copyImageSlicesFrom(const NinePieceImage& other) | 90 void copyImageSlicesFrom(const NinePieceImage& other) |
90 { | 91 { |
91 m_data.access()->imageSlices = other.m_data->imageSlices; | 92 m_data.access()->imageSlices = other.m_data->imageSlices; |
(...skipping 13 matching lines...) Expand all Loading... | |
105 void copyRepeatFrom(const NinePieceImage& other) | 106 void copyRepeatFrom(const NinePieceImage& other) |
106 { | 107 { |
107 m_data.access()->horizontalRule = other.m_data->horizontalRule; | 108 m_data.access()->horizontalRule = other.m_data->horizontalRule; |
108 m_data.access()->verticalRule = other.m_data->verticalRule; | 109 m_data.access()->verticalRule = other.m_data->verticalRule; |
109 } | 110 } |
110 | 111 |
111 void setMaskDefaults() | 112 void setMaskDefaults() |
112 { | 113 { |
113 m_data.access()->imageSlices = LengthBox(0); | 114 m_data.access()->imageSlices = LengthBox(0); |
114 m_data.access()->fill = true; | 115 m_data.access()->fill = true; |
115 m_data.access()->borderSlices = LengthBox(); | 116 m_data.access()->borderSlices = BorderImageLengthBox(); |
116 } | 117 } |
117 | 118 |
118 static LayoutUnit computeOutset(Length outsetSide, LayoutUnit borderSide) | 119 static LayoutUnit computeOutset(const BorderImageLength& outsetSide, LayoutU nit borderSide) |
119 { | 120 { |
120 if (outsetSide.isRelative()) | 121 if (outsetSide.isNumber()) |
121 return outsetSide.value() * borderSide; | 122 return outsetSide.number() * borderSide; |
122 return outsetSide.value(); | 123 return outsetSide.length().value(); |
123 } | 124 } |
124 | 125 |
125 private: | 126 private: |
126 DataRef<NinePieceImageData> m_data; | 127 DataRef<NinePieceImageData> m_data; |
127 }; | 128 }; |
128 | 129 |
129 } // namespace WebCore | 130 } // namespace WebCore |
130 | 131 |
131 #endif // NinePieceImage_h | 132 #endif // NinePieceImage_h |
OLD | NEW |