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 21 matching lines...) Expand all Loading... |
32 #include "core/css/CSSBasicShapeValues.h" | 32 #include "core/css/CSSBasicShapeValues.h" |
33 #include "core/css/CSSPrimitiveValueMappings.h" | 33 #include "core/css/CSSPrimitiveValueMappings.h" |
34 #include "core/css/CSSValuePair.h" | 34 #include "core/css/CSSValuePair.h" |
35 #include "core/css/CSSValuePool.h" | 35 #include "core/css/CSSValuePool.h" |
36 #include "core/css/resolver/StyleResolverState.h" | 36 #include "core/css/resolver/StyleResolverState.h" |
37 #include "core/style/BasicShapes.h" | 37 #include "core/style/BasicShapes.h" |
38 #include "core/style/ComputedStyle.h" | 38 #include "core/style/ComputedStyle.h" |
39 | 39 |
40 namespace blink { | 40 namespace blink { |
41 | 41 |
42 static RawPtr<CSSValue> valueForCenterCoordinate(CSSValuePool& pool, const Compu
tedStyle& style, const BasicShapeCenterCoordinate& center, EBoxOrient orientatio
n) | 42 static CSSValue* valueForCenterCoordinate(CSSValuePool& pool, const ComputedStyl
e& style, const BasicShapeCenterCoordinate& center, EBoxOrient orientation) |
43 { | 43 { |
44 if (center.getDirection() == BasicShapeCenterCoordinate::TopLeft) | 44 if (center.getDirection() == BasicShapeCenterCoordinate::TopLeft) |
45 return pool.createValue(center.length(), style); | 45 return pool.createValue(center.length(), style); |
46 | 46 |
47 CSSValueID keyword = orientation == HORIZONTAL ? CSSValueRight : CSSValueBot
tom; | 47 CSSValueID keyword = orientation == HORIZONTAL ? CSSValueRight : CSSValueBot
tom; |
48 | 48 |
49 return CSSValuePair::create(pool.createIdentifierValue(keyword), pool.create
Value(center.length(), style), CSSValuePair::DropIdenticalValues); | 49 return CSSValuePair::create(pool.createIdentifierValue(keyword), pool.create
Value(center.length(), style), CSSValuePair::DropIdenticalValues); |
50 } | 50 } |
51 | 51 |
52 static RawPtr<CSSPrimitiveValue> basicShapeRadiusToCSSValue(CSSValuePool& pool,
const ComputedStyle& style, const BasicShapeRadius& radius) | 52 static CSSPrimitiveValue* basicShapeRadiusToCSSValue(CSSValuePool& pool, const C
omputedStyle& style, const BasicShapeRadius& radius) |
53 { | 53 { |
54 switch (radius.type()) { | 54 switch (radius.type()) { |
55 case BasicShapeRadius::Value: | 55 case BasicShapeRadius::Value: |
56 return pool.createValue(radius.value(), style); | 56 return pool.createValue(radius.value(), style); |
57 case BasicShapeRadius::ClosestSide: | 57 case BasicShapeRadius::ClosestSide: |
58 return pool.createIdentifierValue(CSSValueClosestSide); | 58 return pool.createIdentifierValue(CSSValueClosestSide); |
59 case BasicShapeRadius::FarthestSide: | 59 case BasicShapeRadius::FarthestSide: |
60 return pool.createIdentifierValue(CSSValueFarthestSide); | 60 return pool.createIdentifierValue(CSSValueFarthestSide); |
61 } | 61 } |
62 | 62 |
63 ASSERT_NOT_REACHED(); | 63 ASSERT_NOT_REACHED(); |
64 return nullptr; | 64 return nullptr; |
65 } | 65 } |
66 | 66 |
67 RawPtr<CSSValue> valueForBasicShape(const ComputedStyle& style, const BasicShape
* basicShape) | 67 CSSValue* valueForBasicShape(const ComputedStyle& style, const BasicShape* basic
Shape) |
68 { | 68 { |
69 CSSValuePool& pool = cssValuePool(); | 69 CSSValuePool& pool = cssValuePool(); |
70 switch (basicShape->type()) { | 70 switch (basicShape->type()) { |
71 case BasicShape::BasicShapeCircleType: { | 71 case BasicShape::BasicShapeCircleType: { |
72 const BasicShapeCircle* circle = toBasicShapeCircle(basicShape); | 72 const BasicShapeCircle* circle = toBasicShapeCircle(basicShape); |
73 RawPtr<CSSBasicShapeCircleValue> circleValue = CSSBasicShapeCircleValue:
:create(); | 73 CSSBasicShapeCircleValue* circleValue = CSSBasicShapeCircleValue::create
(); |
74 | 74 |
75 circleValue->setCenterX(valueForCenterCoordinate(pool, style, circle->ce
nterX(), HORIZONTAL)); | 75 circleValue->setCenterX(valueForCenterCoordinate(pool, style, circle->ce
nterX(), HORIZONTAL)); |
76 circleValue->setCenterY(valueForCenterCoordinate(pool, style, circle->ce
nterY(), VERTICAL)); | 76 circleValue->setCenterY(valueForCenterCoordinate(pool, style, circle->ce
nterY(), VERTICAL)); |
77 circleValue->setRadius(basicShapeRadiusToCSSValue(pool, style, circle->r
adius())); | 77 circleValue->setRadius(basicShapeRadiusToCSSValue(pool, style, circle->r
adius())); |
78 return circleValue.release(); | 78 return circleValue; |
79 } | 79 } |
80 case BasicShape::BasicShapeEllipseType: { | 80 case BasicShape::BasicShapeEllipseType: { |
81 const BasicShapeEllipse* ellipse = toBasicShapeEllipse(basicShape); | 81 const BasicShapeEllipse* ellipse = toBasicShapeEllipse(basicShape); |
82 RawPtr<CSSBasicShapeEllipseValue> ellipseValue = CSSBasicShapeEllipseVal
ue::create(); | 82 CSSBasicShapeEllipseValue* ellipseValue = CSSBasicShapeEllipseValue::cre
ate(); |
83 | 83 |
84 ellipseValue->setCenterX(valueForCenterCoordinate(pool, style, ellipse->
centerX(), HORIZONTAL)); | 84 ellipseValue->setCenterX(valueForCenterCoordinate(pool, style, ellipse->
centerX(), HORIZONTAL)); |
85 ellipseValue->setCenterY(valueForCenterCoordinate(pool, style, ellipse->
centerY(), VERTICAL)); | 85 ellipseValue->setCenterY(valueForCenterCoordinate(pool, style, ellipse->
centerY(), VERTICAL)); |
86 ellipseValue->setRadiusX(basicShapeRadiusToCSSValue(pool, style, ellipse
->radiusX())); | 86 ellipseValue->setRadiusX(basicShapeRadiusToCSSValue(pool, style, ellipse
->radiusX())); |
87 ellipseValue->setRadiusY(basicShapeRadiusToCSSValue(pool, style, ellipse
->radiusY())); | 87 ellipseValue->setRadiusY(basicShapeRadiusToCSSValue(pool, style, ellipse
->radiusY())); |
88 return ellipseValue.release(); | 88 return ellipseValue; |
89 } | 89 } |
90 case BasicShape::BasicShapePolygonType: { | 90 case BasicShape::BasicShapePolygonType: { |
91 const BasicShapePolygon* polygon = toBasicShapePolygon(basicShape); | 91 const BasicShapePolygon* polygon = toBasicShapePolygon(basicShape); |
92 RawPtr<CSSBasicShapePolygonValue> polygonValue = CSSBasicShapePolygonVal
ue::create(); | 92 CSSBasicShapePolygonValue* polygonValue = CSSBasicShapePolygonValue::cre
ate(); |
93 | 93 |
94 polygonValue->setWindRule(polygon->getWindRule()); | 94 polygonValue->setWindRule(polygon->getWindRule()); |
95 const Vector<Length>& values = polygon->values(); | 95 const Vector<Length>& values = polygon->values(); |
96 for (unsigned i = 0; i < values.size(); i += 2) | 96 for (unsigned i = 0; i < values.size(); i += 2) |
97 polygonValue->appendPoint(pool.createValue(values.at(i), style), poo
l.createValue(values.at(i + 1), style)); | 97 polygonValue->appendPoint(pool.createValue(values.at(i), style), poo
l.createValue(values.at(i + 1), style)); |
98 | 98 |
99 return polygonValue.release(); | 99 return polygonValue; |
100 } | 100 } |
101 case BasicShape::BasicShapeInsetType: { | 101 case BasicShape::BasicShapeInsetType: { |
102 const BasicShapeInset* inset = toBasicShapeInset(basicShape); | 102 const BasicShapeInset* inset = toBasicShapeInset(basicShape); |
103 RawPtr<CSSBasicShapeInsetValue> insetValue = CSSBasicShapeInsetValue::cr
eate(); | 103 CSSBasicShapeInsetValue* insetValue = CSSBasicShapeInsetValue::create(); |
104 | 104 |
105 insetValue->setTop(pool.createValue(inset->top(), style)); | 105 insetValue->setTop(pool.createValue(inset->top(), style)); |
106 insetValue->setRight(pool.createValue(inset->right(), style)); | 106 insetValue->setRight(pool.createValue(inset->right(), style)); |
107 insetValue->setBottom(pool.createValue(inset->bottom(), style)); | 107 insetValue->setBottom(pool.createValue(inset->bottom(), style)); |
108 insetValue->setLeft(pool.createValue(inset->left(), style)); | 108 insetValue->setLeft(pool.createValue(inset->left(), style)); |
109 | 109 |
110 insetValue->setTopLeftRadius(CSSValuePair::create(inset->topLeftRadius()
, style)); | 110 insetValue->setTopLeftRadius(CSSValuePair::create(inset->topLeftRadius()
, style)); |
111 insetValue->setTopRightRadius(CSSValuePair::create(inset->topRightRadius
(), style)); | 111 insetValue->setTopRightRadius(CSSValuePair::create(inset->topRightRadius
(), style)); |
112 insetValue->setBottomRightRadius(CSSValuePair::create(inset->bottomRight
Radius(), style)); | 112 insetValue->setBottomRightRadius(CSSValuePair::create(inset->bottomRight
Radius(), style)); |
113 insetValue->setBottomLeftRadius(CSSValuePair::create(inset->bottomLeftRa
dius(), style)); | 113 insetValue->setBottomLeftRadius(CSSValuePair::create(inset->bottomLeftRa
dius(), style)); |
114 | 114 |
115 return insetValue.release(); | 115 return insetValue; |
116 } | 116 } |
117 default: | 117 default: |
118 return nullptr; | 118 return nullptr; |
119 } | 119 } |
120 } | 120 } |
121 | 121 |
122 static Length convertToLength(const StyleResolverState& state, CSSPrimitiveValue
* value) | 122 static Length convertToLength(const StyleResolverState& state, CSSPrimitiveValue
* value) |
123 { | 123 { |
124 if (!value) | 124 if (!value) |
125 return Length(0, Fixed); | 125 return Length(0, Fixed); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 break; | 166 break; |
167 default: | 167 default: |
168 ASSERT_NOT_REACHED(); | 168 ASSERT_NOT_REACHED(); |
169 direction = BasicShapeCenterCoordinate::TopLeft; | 169 direction = BasicShapeCenterCoordinate::TopLeft; |
170 break; | 170 break; |
171 } | 171 } |
172 | 172 |
173 return BasicShapeCenterCoordinate(direction, offset); | 173 return BasicShapeCenterCoordinate(direction, offset); |
174 } | 174 } |
175 | 175 |
176 static BasicShapeRadius cssValueToBasicShapeRadius(const StyleResolverState& sta
te, RawPtr<CSSPrimitiveValue> radius) | 176 static BasicShapeRadius cssValueToBasicShapeRadius(const StyleResolverState& sta
te, CSSPrimitiveValue* radius) |
177 { | 177 { |
178 if (!radius) | 178 if (!radius) |
179 return BasicShapeRadius(BasicShapeRadius::ClosestSide); | 179 return BasicShapeRadius(BasicShapeRadius::ClosestSide); |
180 | 180 |
181 if (radius->isValueID()) { | 181 if (radius->isValueID()) { |
182 switch (radius->getValueID()) { | 182 switch (radius->getValueID()) { |
183 case CSSValueClosestSide: | 183 case CSSValueClosestSide: |
184 return BasicShapeRadius(BasicShapeRadius::ClosestSide); | 184 return BasicShapeRadius(BasicShapeRadius::ClosestSide); |
185 case CSSValueFarthestSide: | 185 case CSSValueFarthestSide: |
186 return BasicShapeRadius(BasicShapeRadius::FarthestSide); | 186 return BasicShapeRadius(BasicShapeRadius::FarthestSide); |
187 default: | 187 default: |
188 ASSERT_NOT_REACHED(); | 188 ASSERT_NOT_REACHED(); |
189 break; | 189 break; |
190 } | 190 } |
191 } | 191 } |
192 | 192 |
193 return BasicShapeRadius(convertToLength(state, radius.get())); | 193 return BasicShapeRadius(convertToLength(state, radius)); |
194 } | 194 } |
195 | 195 |
196 PassRefPtr<BasicShape> basicShapeForValue(const StyleResolverState& state, const
CSSValue& basicShapeValue) | 196 PassRefPtr<BasicShape> basicShapeForValue(const StyleResolverState& state, const
CSSValue& basicShapeValue) |
197 { | 197 { |
198 RefPtr<BasicShape> basicShape; | 198 RefPtr<BasicShape> basicShape; |
199 | 199 |
200 if (basicShapeValue.isBasicShapeCircleValue()) { | 200 if (basicShapeValue.isBasicShapeCircleValue()) { |
201 const CSSBasicShapeCircleValue& circleValue = toCSSBasicShapeCircleValue
(basicShapeValue); | 201 const CSSBasicShapeCircleValue& circleValue = toCSSBasicShapeCircleValue
(basicShapeValue); |
202 RefPtr<BasicShapeCircle> circle = BasicShapeCircle::create(); | 202 RefPtr<BasicShapeCircle> circle = BasicShapeCircle::create(); |
203 | 203 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 } | 249 } |
250 | 250 |
251 FloatPoint floatPointForCenterCoordinate(const BasicShapeCenterCoordinate& cente
rX, const BasicShapeCenterCoordinate& centerY, FloatSize boxSize) | 251 FloatPoint floatPointForCenterCoordinate(const BasicShapeCenterCoordinate& cente
rX, const BasicShapeCenterCoordinate& centerY, FloatSize boxSize) |
252 { | 252 { |
253 float x = floatValueForLength(centerX.computedLength(), boxSize.width()); | 253 float x = floatValueForLength(centerX.computedLength(), boxSize.width()); |
254 float y = floatValueForLength(centerY.computedLength(), boxSize.height()); | 254 float y = floatValueForLength(centerY.computedLength(), boxSize.height()); |
255 return FloatPoint(x, y); | 255 return FloatPoint(x, y); |
256 } | 256 } |
257 | 257 |
258 } // namespace blink | 258 } // namespace blink |
OLD | NEW |