| 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 12 matching lines...) Expand all Loading... |
| 23 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR | 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR |
| 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 "core/css/BasicShapeFunctions.h" | 30 #include "core/css/BasicShapeFunctions.h" |
| 31 | 31 |
| 32 #include "core/css/CSSBasicShapeValues.h" | 32 #include "core/css/CSSBasicShapeValues.h" |
| 33 #include "core/css/CSSIdentifierValue.h" |
| 33 #include "core/css/CSSPrimitiveValueMappings.h" | 34 #include "core/css/CSSPrimitiveValueMappings.h" |
| 34 #include "core/css/CSSValuePair.h" | 35 #include "core/css/CSSValuePair.h" |
| 35 #include "core/css/resolver/StyleResolverState.h" | 36 #include "core/css/resolver/StyleResolverState.h" |
| 36 #include "core/style/BasicShapes.h" | 37 #include "core/style/BasicShapes.h" |
| 37 #include "core/style/ComputedStyle.h" | 38 #include "core/style/ComputedStyle.h" |
| 38 | 39 |
| 39 namespace blink { | 40 namespace blink { |
| 40 | 41 |
| 41 static CSSValue* valueForCenterCoordinate( | 42 static CSSValue* valueForCenterCoordinate( |
| 42 const ComputedStyle& style, | 43 const ComputedStyle& style, |
| 43 const BasicShapeCenterCoordinate& center, | 44 const BasicShapeCenterCoordinate& center, |
| 44 EBoxOrient orientation) { | 45 EBoxOrient orientation) { |
| 45 if (center.getDirection() == BasicShapeCenterCoordinate::TopLeft) | 46 if (center.getDirection() == BasicShapeCenterCoordinate::TopLeft) |
| 46 return CSSPrimitiveValue::create(center.length(), style.effectiveZoom()); | 47 return CSSValue::create(center.length(), style.effectiveZoom()); |
| 47 | 48 |
| 48 CSSValueID keyword = | 49 CSSValueID keyword = |
| 49 orientation == HORIZONTAL ? CSSValueRight : CSSValueBottom; | 50 orientation == HORIZONTAL ? CSSValueRight : CSSValueBottom; |
| 50 | 51 |
| 51 return CSSValuePair::create( | 52 return CSSValuePair::create( |
| 52 CSSPrimitiveValue::createIdentifier(keyword), | 53 CSSIdentifierValue::create(keyword), |
| 53 CSSPrimitiveValue::create(center.length(), style.effectiveZoom()), | 54 CSSValue::create(center.length(), style.effectiveZoom()), |
| 54 CSSValuePair::DropIdenticalValues); | 55 CSSValuePair::DropIdenticalValues); |
| 55 } | 56 } |
| 56 | 57 |
| 57 static CSSValuePair* valueForLengthSize(const LengthSize& lengthSize, | 58 static CSSValuePair* valueForLengthSize(const LengthSize& lengthSize, |
| 58 const ComputedStyle& style) { | 59 const ComputedStyle& style) { |
| 59 return CSSValuePair::create( | 60 return CSSValuePair::create( |
| 60 CSSPrimitiveValue::create(lengthSize.width(), style.effectiveZoom()), | 61 CSSValue::create(lengthSize.width(), style.effectiveZoom()), |
| 61 CSSPrimitiveValue::create(lengthSize.height(), style.effectiveZoom()), | 62 CSSValue::create(lengthSize.height(), style.effectiveZoom()), |
| 62 CSSValuePair::KeepIdenticalValues); | 63 CSSValuePair::KeepIdenticalValues); |
| 63 } | 64 } |
| 64 | 65 |
| 65 static CSSPrimitiveValue* basicShapeRadiusToCSSValue( | 66 static CSSValue* basicShapeRadiusToCSSValue(const ComputedStyle& style, |
| 66 const ComputedStyle& style, | 67 const BasicShapeRadius& radius) { |
| 67 const BasicShapeRadius& radius) { | |
| 68 switch (radius.type()) { | 68 switch (radius.type()) { |
| 69 case BasicShapeRadius::Value: | 69 case BasicShapeRadius::Value: |
| 70 return CSSPrimitiveValue::create(radius.value(), style.effectiveZoom()); | 70 return CSSValue::create(radius.value(), style.effectiveZoom()); |
| 71 case BasicShapeRadius::ClosestSide: | 71 case BasicShapeRadius::ClosestSide: |
| 72 return CSSPrimitiveValue::createIdentifier(CSSValueClosestSide); | 72 return CSSIdentifierValue::create(CSSValueClosestSide); |
| 73 case BasicShapeRadius::FarthestSide: | 73 case BasicShapeRadius::FarthestSide: |
| 74 return CSSPrimitiveValue::createIdentifier(CSSValueFarthestSide); | 74 return CSSIdentifierValue::create(CSSValueFarthestSide); |
| 75 } | 75 } |
| 76 | 76 |
| 77 ASSERT_NOT_REACHED(); | 77 ASSERT_NOT_REACHED(); |
| 78 return nullptr; | 78 return nullptr; |
| 79 } | 79 } |
| 80 | 80 |
| 81 CSSValue* valueForBasicShape(const ComputedStyle& style, | 81 CSSValue* valueForBasicShape(const ComputedStyle& style, |
| 82 const BasicShape* basicShape) { | 82 const BasicShape* basicShape) { |
| 83 switch (basicShape->type()) { | 83 switch (basicShape->type()) { |
| 84 case BasicShape::BasicShapeCircleType: { | 84 case BasicShape::BasicShapeCircleType: { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 | 171 |
| 172 static BasicShapeCenterCoordinate convertToCenterCoordinate( | 172 static BasicShapeCenterCoordinate convertToCenterCoordinate( |
| 173 const StyleResolverState& state, | 173 const StyleResolverState& state, |
| 174 CSSValue* value) { | 174 CSSValue* value) { |
| 175 BasicShapeCenterCoordinate::Direction direction; | 175 BasicShapeCenterCoordinate::Direction direction; |
| 176 Length offset = Length(0, Fixed); | 176 Length offset = Length(0, Fixed); |
| 177 | 177 |
| 178 CSSValueID keyword = CSSValueTop; | 178 CSSValueID keyword = CSSValueTop; |
| 179 if (!value) { | 179 if (!value) { |
| 180 keyword = CSSValueCenter; | 180 keyword = CSSValueCenter; |
| 181 } else if (value->isPrimitiveValue() && | 181 } else if (value->isIdentifierValue()) { |
| 182 toCSSPrimitiveValue(value)->isValueID()) { | 182 keyword = toCSSIdentifierValue(value)->getValueID(); |
| 183 keyword = toCSSPrimitiveValue(value)->getValueID(); | |
| 184 } else if (value->isValuePair()) { | 183 } else if (value->isValuePair()) { |
| 185 keyword = toCSSPrimitiveValue(toCSSValuePair(value)->first()).getValueID(); | 184 keyword = toCSSIdentifierValue(toCSSValuePair(value)->first()).getValueID(); |
| 186 offset = convertToLength( | 185 offset = convertToLength( |
| 187 state, &toCSSPrimitiveValue(toCSSValuePair(value)->second())); | 186 state, &toCSSPrimitiveValue(toCSSValuePair(value)->second())); |
| 188 } else { | 187 } else { |
| 189 offset = convertToLength(state, toCSSPrimitiveValue(value)); | 188 offset = convertToLength(state, toCSSPrimitiveValue(value)); |
| 190 } | 189 } |
| 191 | 190 |
| 192 switch (keyword) { | 191 switch (keyword) { |
| 193 case CSSValueTop: | 192 case CSSValueTop: |
| 194 case CSSValueLeft: | 193 case CSSValueLeft: |
| 195 direction = BasicShapeCenterCoordinate::TopLeft; | 194 direction = BasicShapeCenterCoordinate::TopLeft; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 206 ASSERT_NOT_REACHED(); | 205 ASSERT_NOT_REACHED(); |
| 207 direction = BasicShapeCenterCoordinate::TopLeft; | 206 direction = BasicShapeCenterCoordinate::TopLeft; |
| 208 break; | 207 break; |
| 209 } | 208 } |
| 210 | 209 |
| 211 return BasicShapeCenterCoordinate(direction, offset); | 210 return BasicShapeCenterCoordinate(direction, offset); |
| 212 } | 211 } |
| 213 | 212 |
| 214 static BasicShapeRadius cssValueToBasicShapeRadius( | 213 static BasicShapeRadius cssValueToBasicShapeRadius( |
| 215 const StyleResolverState& state, | 214 const StyleResolverState& state, |
| 216 const CSSPrimitiveValue* radius) { | 215 const CSSValue* radius) { |
| 217 if (!radius) | 216 if (!radius) |
| 218 return BasicShapeRadius(BasicShapeRadius::ClosestSide); | 217 return BasicShapeRadius(BasicShapeRadius::ClosestSide); |
| 219 | 218 |
| 220 if (radius->isValueID()) { | 219 if (radius->isIdentifierValue()) { |
| 221 switch (radius->getValueID()) { | 220 switch (toCSSIdentifierValue(radius)->getValueID()) { |
| 222 case CSSValueClosestSide: | 221 case CSSValueClosestSide: |
| 223 return BasicShapeRadius(BasicShapeRadius::ClosestSide); | 222 return BasicShapeRadius(BasicShapeRadius::ClosestSide); |
| 224 case CSSValueFarthestSide: | 223 case CSSValueFarthestSide: |
| 225 return BasicShapeRadius(BasicShapeRadius::FarthestSide); | 224 return BasicShapeRadius(BasicShapeRadius::FarthestSide); |
| 226 default: | 225 default: |
| 227 ASSERT_NOT_REACHED(); | 226 ASSERT_NOT_REACHED(); |
| 228 break; | 227 break; |
| 229 } | 228 } |
| 230 } | 229 } |
| 231 | 230 |
| 232 return BasicShapeRadius(convertToLength(state, radius)); | 231 return BasicShapeRadius(convertToLength(state, toCSSPrimitiveValue(radius))); |
| 233 } | 232 } |
| 234 | 233 |
| 235 PassRefPtr<BasicShape> basicShapeForValue(const StyleResolverState& state, | 234 PassRefPtr<BasicShape> basicShapeForValue(const StyleResolverState& state, |
| 236 const CSSValue& basicShapeValue) { | 235 const CSSValue& basicShapeValue) { |
| 237 RefPtr<BasicShape> basicShape; | 236 RefPtr<BasicShape> basicShape; |
| 238 | 237 |
| 239 if (basicShapeValue.isBasicShapeCircleValue()) { | 238 if (basicShapeValue.isBasicShapeCircleValue()) { |
| 240 const CSSBasicShapeCircleValue& circleValue = | 239 const CSSBasicShapeCircleValue& circleValue = |
| 241 toCSSBasicShapeCircleValue(basicShapeValue); | 240 toCSSBasicShapeCircleValue(basicShapeValue); |
| 242 RefPtr<BasicShapeCircle> circle = BasicShapeCircle::create(); | 241 RefPtr<BasicShapeCircle> circle = BasicShapeCircle::create(); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 FloatPoint floatPointForCenterCoordinate( | 302 FloatPoint floatPointForCenterCoordinate( |
| 304 const BasicShapeCenterCoordinate& centerX, | 303 const BasicShapeCenterCoordinate& centerX, |
| 305 const BasicShapeCenterCoordinate& centerY, | 304 const BasicShapeCenterCoordinate& centerY, |
| 306 FloatSize boxSize) { | 305 FloatSize boxSize) { |
| 307 float x = floatValueForLength(centerX.computedLength(), boxSize.width()); | 306 float x = floatValueForLength(centerX.computedLength(), boxSize.width()); |
| 308 float y = floatValueForLength(centerY.computedLength(), boxSize.height()); | 307 float y = floatValueForLength(centerY.computedLength(), boxSize.height()); |
| 309 return FloatPoint(x, y); | 308 return FloatPoint(x, y); |
| 310 } | 309 } |
| 311 | 310 |
| 312 } // namespace blink | 311 } // namespace blink |
| OLD | NEW |