OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. | 2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above | 8 * 1. Redistributions of source code must retain the above |
9 * copyright notice, this list of conditions and the following | 9 * copyright notice, this list of conditions and the following |
10 * disclaimer. | 10 * disclaimer. |
(...skipping 14 matching lines...) Expand all Loading... |
25 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF | 25 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF |
26 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 26 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
27 * SUCH DAMAGE. | 27 * SUCH DAMAGE. |
28 */ | 28 */ |
29 | 29 |
30 #include "config.h" | 30 #include "config.h" |
31 #include "core/css/BasicShapeFunctions.h" | 31 #include "core/css/BasicShapeFunctions.h" |
32 | 32 |
33 #include "core/css/CSSBasicShapes.h" | 33 #include "core/css/CSSBasicShapes.h" |
34 #include "core/css/CSSPrimitiveValueMappings.h" | 34 #include "core/css/CSSPrimitiveValueMappings.h" |
| 35 #include "core/css/CSSValuePair.h" |
35 #include "core/css/CSSValuePool.h" | 36 #include "core/css/CSSValuePool.h" |
36 #include "core/css/Pair.h" | |
37 #include "core/css/resolver/StyleResolverState.h" | 37 #include "core/css/resolver/StyleResolverState.h" |
38 #include "core/style/BasicShapes.h" | 38 #include "core/style/BasicShapes.h" |
39 #include "core/style/ComputedStyle.h" | 39 #include "core/style/ComputedStyle.h" |
40 | 40 |
41 namespace blink { | 41 namespace blink { |
42 | 42 |
43 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> valueForCenterCoordinate(CSSVal
uePool& pool, const ComputedStyle& style, const BasicShapeCenterCoordinate& cent
er, EBoxOrient orientation) | 43 static PassRefPtrWillBeRawPtr<CSSValue> valueForCenterCoordinate(CSSValuePool& p
ool, const ComputedStyle& style, const BasicShapeCenterCoordinate& center, EBoxO
rient orientation) |
44 { | 44 { |
45 if (center.direction() == BasicShapeCenterCoordinate::TopLeft) | 45 if (center.direction() == BasicShapeCenterCoordinate::TopLeft) |
46 return pool.createValue(center.length(), style); | 46 return pool.createValue(center.length(), style); |
47 | 47 |
48 CSSValueID keyword = orientation == HORIZONTAL ? CSSValueRight : CSSValueBot
tom; | 48 CSSValueID keyword = orientation == HORIZONTAL ? CSSValueRight : CSSValueBot
tom; |
49 | 49 |
50 return pool.createValue(Pair::create(pool.createIdentifierValue(keyword), po
ol.createValue(center.length(), style), Pair::DropIdenticalValues)); | 50 return CSSValuePair::create(pool.createIdentifierValue(keyword), pool.create
Value(center.length(), style), CSSValuePair::DropIdenticalValues); |
51 } | 51 } |
52 | 52 |
53 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> basicShapeRadiusToCSSValue(CSSV
aluePool& pool, const ComputedStyle& style, const BasicShapeRadius& radius) | 53 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> basicShapeRadiusToCSSValue(CSSV
aluePool& pool, const ComputedStyle& style, const BasicShapeRadius& radius) |
54 { | 54 { |
55 switch (radius.type()) { | 55 switch (radius.type()) { |
56 case BasicShapeRadius::Value: | 56 case BasicShapeRadius::Value: |
57 return pool.createValue(radius.value(), style); | 57 return pool.createValue(radius.value(), style); |
58 case BasicShapeRadius::ClosestSide: | 58 case BasicShapeRadius::ClosestSide: |
59 return pool.createIdentifierValue(CSSValueClosestSide); | 59 return pool.createIdentifierValue(CSSValueClosestSide); |
60 case BasicShapeRadius::FarthestSide: | 60 case BasicShapeRadius::FarthestSide: |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 } | 106 } |
107 case BasicShape::BasicShapeInsetType: { | 107 case BasicShape::BasicShapeInsetType: { |
108 const BasicShapeInset* inset = toBasicShapeInset(basicShape); | 108 const BasicShapeInset* inset = toBasicShapeInset(basicShape); |
109 RefPtrWillBeRawPtr<CSSBasicShapeInset> insetValue = CSSBasicShapeInset::
create(); | 109 RefPtrWillBeRawPtr<CSSBasicShapeInset> insetValue = CSSBasicShapeInset::
create(); |
110 | 110 |
111 insetValue->setTop(pool.createValue(inset->top(), style)); | 111 insetValue->setTop(pool.createValue(inset->top(), style)); |
112 insetValue->setRight(pool.createValue(inset->right(), style)); | 112 insetValue->setRight(pool.createValue(inset->right(), style)); |
113 insetValue->setBottom(pool.createValue(inset->bottom(), style)); | 113 insetValue->setBottom(pool.createValue(inset->bottom(), style)); |
114 insetValue->setLeft(pool.createValue(inset->left(), style)); | 114 insetValue->setLeft(pool.createValue(inset->left(), style)); |
115 | 115 |
116 insetValue->setTopLeftRadius(CSSPrimitiveValue::create(inset->topLeftRad
ius(), style)); | 116 insetValue->setTopLeftRadius(CSSValuePair::create(inset->topLeftRadius()
, style)); |
117 insetValue->setTopRightRadius(CSSPrimitiveValue::create(inset->topRightR
adius(), style)); | 117 insetValue->setTopRightRadius(CSSValuePair::create(inset->topRightRadius
(), style)); |
118 insetValue->setBottomRightRadius(CSSPrimitiveValue::create(inset->bottom
RightRadius(), style)); | 118 insetValue->setBottomRightRadius(CSSValuePair::create(inset->bottomRight
Radius(), style)); |
119 insetValue->setBottomLeftRadius(CSSPrimitiveValue::create(inset->bottomL
eftRadius(), style)); | 119 insetValue->setBottomLeftRadius(CSSValuePair::create(inset->bottomLeftRa
dius(), style)); |
120 | 120 |
121 basicShapeValue = insetValue.release(); | 121 basicShapeValue = insetValue.release(); |
122 break; | 122 break; |
123 } | 123 } |
124 default: | 124 default: |
125 break; | 125 break; |
126 } | 126 } |
127 | 127 |
128 return pool.createValue(basicShapeValue.release()); | 128 return pool.createValue(basicShapeValue.release()); |
129 } | 129 } |
130 | 130 |
131 static Length convertToLength(const StyleResolverState& state, CSSPrimitiveValue
* value) | 131 static Length convertToLength(const StyleResolverState& state, CSSPrimitiveValue
* value) |
132 { | 132 { |
133 if (!value) | 133 if (!value) |
134 return Length(0, Fixed); | 134 return Length(0, Fixed); |
135 return value->convertToLength(state.cssToLengthConversionData()); | 135 return value->convertToLength(state.cssToLengthConversionData()); |
136 } | 136 } |
137 | 137 |
138 static LengthSize convertToLengthSize(const StyleResolverState& state, CSSPrimit
iveValue* value) | 138 static LengthSize convertToLengthSize(const StyleResolverState& state, CSSValueP
air* value) |
139 { | 139 { |
140 if (!value) | 140 if (!value) |
141 return LengthSize(Length(0, Fixed), Length(0, Fixed)); | 141 return LengthSize(Length(0, Fixed), Length(0, Fixed)); |
142 | 142 |
143 Pair* pair = value->getPairValue(); | 143 return LengthSize(convertToLength(state, toCSSPrimitiveValue(value->first())
), convertToLength(state, toCSSPrimitiveValue(value->second()))); |
144 return LengthSize(convertToLength(state, pair->first()), convertToLength(sta
te, pair->second())); | |
145 } | 144 } |
146 | 145 |
147 static BasicShapeCenterCoordinate convertToCenterCoordinate(const StyleResolverS
tate& state, CSSPrimitiveValue* value) | 146 static BasicShapeCenterCoordinate convertToCenterCoordinate(const StyleResolverS
tate& state, CSSValue* value) |
148 { | 147 { |
149 BasicShapeCenterCoordinate::Direction direction; | 148 BasicShapeCenterCoordinate::Direction direction; |
150 Length offset = Length(0, Fixed); | 149 Length offset = Length(0, Fixed); |
151 | 150 |
152 CSSValueID keyword = CSSValueTop; | 151 CSSValueID keyword = CSSValueTop; |
153 if (!value) { | 152 if (!value) { |
154 keyword = CSSValueCenter; | 153 keyword = CSSValueCenter; |
155 } else if (value->isValueID()) { | 154 } else if (value->isPrimitiveValue() && toCSSPrimitiveValue(value)->isValueI
D()) { |
156 keyword = value->getValueID(); | 155 keyword = toCSSPrimitiveValue(value)->getValueID(); |
157 } else if (Pair* pair = value->getPairValue()) { | 156 } else if (value->isValuePair()) { |
158 keyword = pair->first()->getValueID(); | 157 keyword = toCSSPrimitiveValue(toCSSValuePair(value)->first())->getValueI
D(); |
159 offset = convertToLength(state, pair->second()); | 158 offset = convertToLength(state, toCSSPrimitiveValue(toCSSValuePair(value
)->second())); |
160 } else { | 159 } else { |
161 offset = convertToLength(state, value); | 160 offset = convertToLength(state, toCSSPrimitiveValue(value)); |
162 } | 161 } |
163 | 162 |
164 switch (keyword) { | 163 switch (keyword) { |
165 case CSSValueTop: | 164 case CSSValueTop: |
166 case CSSValueLeft: | 165 case CSSValueLeft: |
167 direction = BasicShapeCenterCoordinate::TopLeft; | 166 direction = BasicShapeCenterCoordinate::TopLeft; |
168 break; | 167 break; |
169 case CSSValueRight: | 168 case CSSValueRight: |
170 case CSSValueBottom: | 169 case CSSValueBottom: |
171 direction = BasicShapeCenterCoordinate::BottomRight; | 170 direction = BasicShapeCenterCoordinate::BottomRight; |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 } | 267 } |
269 | 268 |
270 FloatPoint floatPointForCenterCoordinate(const BasicShapeCenterCoordinate& cente
rX, const BasicShapeCenterCoordinate& centerY, FloatSize boxSize) | 269 FloatPoint floatPointForCenterCoordinate(const BasicShapeCenterCoordinate& cente
rX, const BasicShapeCenterCoordinate& centerY, FloatSize boxSize) |
271 { | 270 { |
272 float x = floatValueForLength(centerX.computedLength(), boxSize.width()); | 271 float x = floatValueForLength(centerX.computedLength(), boxSize.width()); |
273 float y = floatValueForLength(centerY.computedLength(), boxSize.height()); | 272 float y = floatValueForLength(centerY.computedLength(), boxSize.height()); |
274 return FloatPoint(x, y); | 273 return FloatPoint(x, y); |
275 } | 274 } |
276 | 275 |
277 } | 276 } |
OLD | NEW |