OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * * Redistributions of source code must retain the above copyright | 4 * * Redistributions of source code must retain the above copyright |
5 * notice, this list of conditions and the following disclaimer. | 5 * notice, this list of conditions and the following disclaimer. |
6 * * Redistributions in binary form must reproduce the above | 6 * * Redistributions in binary form must reproduce the above |
7 * copyright notice, this list of conditions and the following disclaimer | 7 * copyright notice, this list of conditions and the following disclaimer |
8 * in the documentation and/or other materials provided with the | 8 * in the documentation and/or other materials provided with the |
9 * distribution. | 9 * distribution. |
10 * * Neither the name of Google Inc. nor the names of its | 10 * * Neither the name of Google Inc. nor the names of its |
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
991 LengthSize StyleBuilderConverter::convertRadius(StyleResolverState& state, | 991 LengthSize StyleBuilderConverter::convertRadius(StyleResolverState& state, |
992 const CSSValue& value) { | 992 const CSSValue& value) { |
993 const CSSValuePair& pair = toCSSValuePair(value); | 993 const CSSValuePair& pair = toCSSValuePair(value); |
994 Length radiusWidth = toCSSPrimitiveValue(pair.first()) | 994 Length radiusWidth = toCSSPrimitiveValue(pair.first()) |
995 .convertToLength(state.cssToLengthConversionData()); | 995 .convertToLength(state.cssToLengthConversionData()); |
996 Length radiusHeight = toCSSPrimitiveValue(pair.second()) | 996 Length radiusHeight = toCSSPrimitiveValue(pair.second()) |
997 .convertToLength(state.cssToLengthConversionData()); | 997 .convertToLength(state.cssToLengthConversionData()); |
998 return LengthSize(radiusWidth, radiusHeight); | 998 return LengthSize(radiusWidth, radiusHeight); |
999 } | 999 } |
1000 | 1000 |
1001 PassRefPtr<ShadowList> StyleBuilderConverter::convertShadow( | 1001 ShadowData StyleBuilderConverter::convertShadow(StyleResolverState& state, |
| 1002 const CSSValue& value) { |
| 1003 const CSSShadowValue& shadow = toCSSShadowValue(value); |
| 1004 float x = shadow.x->computeLength<float>(state.cssToLengthConversionData()); |
| 1005 float y = shadow.y->computeLength<float>(state.cssToLengthConversionData()); |
| 1006 float blur = |
| 1007 shadow.blur |
| 1008 ? shadow.blur->computeLength<float>(state.cssToLengthConversionData()) |
| 1009 : 0; |
| 1010 float spread = shadow.spread |
| 1011 ? shadow.spread->computeLength<float>( |
| 1012 state.cssToLengthConversionData()) |
| 1013 : 0; |
| 1014 ShadowStyle shadowStyle = |
| 1015 shadow.style && shadow.style->getValueID() == CSSValueInset ? Inset |
| 1016 : Normal; |
| 1017 StyleColor color = StyleColor::currentColor(); |
| 1018 if (shadow.color) |
| 1019 color = convertStyleColor(state, *shadow.color); |
| 1020 return ShadowData(FloatPoint(x, y), blur, spread, shadowStyle, color); |
| 1021 } |
| 1022 |
| 1023 PassRefPtr<ShadowList> StyleBuilderConverter::convertShadowList( |
1002 StyleResolverState& state, | 1024 StyleResolverState& state, |
1003 const CSSValue& value) { | 1025 const CSSValue& value) { |
1004 if (value.isIdentifierValue()) { | 1026 if (value.isIdentifierValue()) { |
1005 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNone); | 1027 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNone); |
1006 return PassRefPtr<ShadowList>(); | 1028 return PassRefPtr<ShadowList>(); |
1007 } | 1029 } |
1008 | 1030 |
1009 const CSSValueList& valueList = toCSSValueList(value); | |
1010 size_t shadowCount = valueList.length(); | |
1011 ShadowDataVector shadows; | 1031 ShadowDataVector shadows; |
1012 for (size_t i = 0; i < shadowCount; ++i) { | 1032 for (const auto& item : toCSSValueList(value)) |
1013 const CSSShadowValue& item = toCSSShadowValue(valueList.item(i)); | 1033 shadows.append(convertShadow(state, *item)); |
1014 float x = item.x->computeLength<float>(state.cssToLengthConversionData()); | 1034 |
1015 float y = item.y->computeLength<float>(state.cssToLengthConversionData()); | |
1016 float blur = | |
1017 item.blur | |
1018 ? item.blur->computeLength<float>(state.cssToLengthConversionData()) | |
1019 : 0; | |
1020 float spread = item.spread | |
1021 ? item.spread->computeLength<float>( | |
1022 state.cssToLengthConversionData()) | |
1023 : 0; | |
1024 ShadowStyle shadowStyle = | |
1025 item.style && item.style->getValueID() == CSSValueInset ? Inset | |
1026 : Normal; | |
1027 StyleColor color = StyleColor::currentColor(); | |
1028 if (item.color) | |
1029 color = convertStyleColor(state, *item.color); | |
1030 shadows.append( | |
1031 ShadowData(FloatPoint(x, y), blur, spread, shadowStyle, color)); | |
1032 } | |
1033 return ShadowList::adopt(shadows); | 1035 return ShadowList::adopt(shadows); |
1034 } | 1036 } |
1035 | 1037 |
1036 ShapeValue* StyleBuilderConverter::convertShapeValue(StyleResolverState& state, | 1038 ShapeValue* StyleBuilderConverter::convertShapeValue(StyleResolverState& state, |
1037 const CSSValue& value) { | 1039 const CSSValue& value) { |
1038 if (value.isIdentifierValue()) { | 1040 if (value.isIdentifierValue()) { |
1039 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNone); | 1041 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), CSSValueNone); |
1040 return nullptr; | 1042 return nullptr; |
1041 } | 1043 } |
1042 | 1044 |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1295 // Instead of the actual zoom, use 1 to avoid potential rounding errors | 1297 // Instead of the actual zoom, use 1 to avoid potential rounding errors |
1296 Length length = primitiveValue.convertToLength( | 1298 Length length = primitiveValue.convertToLength( |
1297 state.cssToLengthConversionData().copyWithAdjustedZoom(1)); | 1299 state.cssToLengthConversionData().copyWithAdjustedZoom(1)); |
1298 return *CSSPrimitiveValue::create(length, 1); | 1300 return *CSSPrimitiveValue::create(length, 1); |
1299 } | 1301 } |
1300 } | 1302 } |
1301 return value; | 1303 return value; |
1302 } | 1304 } |
1303 | 1305 |
1304 } // namespace blink | 1306 } // namespace blink |
OLD | NEW |