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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 static LengthSize convertRadius(StyleResolverState&, CSSValue*); | 52 static LengthSize convertRadius(StyleResolverState&, CSSValue*); |
53 static PassRefPtr<ShadowList> convertShadow(StyleResolverState&, CSSValue*); | 53 static PassRefPtr<ShadowList> convertShadow(StyleResolverState&, CSSValue*); |
54 static float convertSpacing(StyleResolverState&, CSSValue*); | 54 static float convertSpacing(StyleResolverState&, CSSValue*); |
55 template <CSSValueID IdForNone> static AtomicString convertString(StyleResol
verState&, CSSValue*); | 55 template <CSSValueID IdForNone> static AtomicString convertString(StyleResol
verState&, CSSValue*); |
56 static SVGLength convertSVGLength(StyleResolverState&, CSSValue*); | 56 static SVGLength convertSVGLength(StyleResolverState&, CSSValue*); |
57 }; | 57 }; |
58 | 58 |
59 template <typename T> | 59 template <typename T> |
60 T StyleBuilderConverter::convertComputedLength(StyleResolverState& state, CSSVal
ue* value) | 60 T StyleBuilderConverter::convertComputedLength(StyleResolverState& state, CSSVal
ue* value) |
61 { | 61 { |
62 float zoom = state.style()->effectiveZoom(); | 62 return toCSSPrimitiveValue(value)->computeLength<T>(state.cssToLengthConvers
ionData()); |
63 return toCSSPrimitiveValue(value)->computeLength<T>(state.style(), state.roo
tElementStyle(), zoom); | |
64 } | 63 } |
65 | 64 |
66 template <typename T> | 65 template <typename T> |
67 T StyleBuilderConverter::convertLineWidth(StyleResolverState& state, CSSValue* v
alue) | 66 T StyleBuilderConverter::convertLineWidth(StyleResolverState& state, CSSValue* v
alue) |
68 { | 67 { |
69 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 68 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
70 CSSValueID valueID = primitiveValue->getValueID(); | 69 CSSValueID valueID = primitiveValue->getValueID(); |
71 if (valueID == CSSValueThin) | 70 if (valueID == CSSValueThin) |
72 return 1; | 71 return 1; |
73 if (valueID == CSSValueMedium) | 72 if (valueID == CSSValueMedium) |
74 return 3; | 73 return 3; |
75 if (valueID == CSSValueThick) | 74 if (valueID == CSSValueThick) |
76 return 5; | 75 return 5; |
77 if (primitiveValue->isViewportPercentageLength()) | 76 if (primitiveValue->isViewportPercentageLength()) |
78 return intValueForLength(primitiveValue->viewportPercentageLength(), 0,
state.document().renderView()); | 77 return intValueForLength(primitiveValue->viewportPercentageLength(), 0,
state.document().renderView()); |
79 if (valueID == CSSValueInvalid) { | 78 if (valueID == CSSValueInvalid) { |
80 float zoom = state.style()->effectiveZoom(); | |
81 // Any original result that was >= 1 should not be allowed to fall below
1. | 79 // Any original result that was >= 1 should not be allowed to fall below
1. |
82 // This keeps border lines from vanishing. | 80 // This keeps border lines from vanishing. |
83 T result = primitiveValue->computeLength<T>(state.style(), state.rootEle
mentStyle(), zoom); | 81 T result = primitiveValue->computeLength<T>(state.cssToLengthConversionD
ata()); |
84 if (zoom < 1.0f && result < 1.0) { | 82 if (state.style()->effectiveZoom() < 1.0f && result < 1.0) { |
85 T originalLength = primitiveValue->computeLength<T>(state.style(), s
tate.rootElementStyle(), 1.0); | 83 T originalLength = primitiveValue->computeLength<T>(state.cssToLengt
hConversionData().copyWithAdjustedZoom(1.0)); |
86 if (originalLength >= 1.0) | 84 if (originalLength >= 1.0) |
87 return 1.0; | 85 return 1.0; |
88 } | 86 } |
89 return result; | 87 return result; |
90 } | 88 } |
91 ASSERT_NOT_REACHED(); | 89 ASSERT_NOT_REACHED(); |
92 return 0; | 90 return 0; |
93 } | 91 } |
94 | 92 |
95 template <CSSValueID IdForNone> | 93 template <CSSValueID IdForNone> |
96 AtomicString StyleBuilderConverter::convertString(StyleResolverState&, CSSValue*
value) | 94 AtomicString StyleBuilderConverter::convertString(StyleResolverState&, CSSValue*
value) |
97 { | 95 { |
98 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 96 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
99 if (primitiveValue->getValueID() == IdForNone) | 97 if (primitiveValue->getValueID() == IdForNone) |
100 return nullAtom; | 98 return nullAtom; |
101 return primitiveValue->getStringValue(); | 99 return primitiveValue->getStringValue(); |
102 } | 100 } |
103 | 101 |
104 } // namespace WebCore | 102 } // namespace WebCore |
105 | 103 |
106 #endif | 104 #endif |
OLD | NEW |