| 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 |
| 11 * contributors may be used to endorse or promote products derived from | 11 * contributors may be used to endorse or promote products derived from |
| 12 * this software without specific prior written permission. | 12 * this software without specific prior written permission. |
| 13 * | 13 * |
| 14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 15 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 15 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 16 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 16 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 17 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 17 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 18 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 18 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 19 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 19 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 20 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 20 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #ifndef StyleBuilderConverter_h | 27 #ifndef StyleBuilderConverter_h |
| 28 #define StyleBuilderConverter_h | 28 #define StyleBuilderConverter_h |
| 29 | 29 |
| 30 #include "core/css/CSSIdentifierValue.h" |
| 30 #include "core/css/CSSStringValue.h" | 31 #include "core/css/CSSStringValue.h" |
| 31 #include "core/css/CSSValue.h" | 32 #include "core/css/CSSValue.h" |
| 32 #include "core/css/CSSValueList.h" | 33 #include "core/css/CSSValueList.h" |
| 33 #include "core/css/resolver/StyleResolverState.h" | 34 #include "core/css/resolver/StyleResolverState.h" |
| 34 #include "core/style/QuotesData.h" | 35 #include "core/style/QuotesData.h" |
| 35 #include "core/style/ShadowList.h" | 36 #include "core/style/ShadowList.h" |
| 36 #include "core/style/StyleOffsetRotation.h" | 37 #include "core/style/StyleOffsetRotation.h" |
| 37 #include "core/style/StyleReflection.h" | 38 #include "core/style/StyleReflection.h" |
| 38 #include "core/style/StyleScrollSnapData.h" | 39 #include "core/style/StyleScrollSnapData.h" |
| 39 #include "core/style/TransformOrigin.h" | 40 #include "core/style/TransformOrigin.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 template <typename T> | 130 template <typename T> |
| 130 T StyleBuilderConverter::convertComputedLength(StyleResolverState& state, const
CSSValue& value) | 131 T StyleBuilderConverter::convertComputedLength(StyleResolverState& state, const
CSSValue& value) |
| 131 { | 132 { |
| 132 return toCSSPrimitiveValue(value).computeLength<T>(state.cssToLengthConversi
onData()); | 133 return toCSSPrimitiveValue(value).computeLength<T>(state.cssToLengthConversi
onData()); |
| 133 } | 134 } |
| 134 | 135 |
| 135 template <typename T> | 136 template <typename T> |
| 136 T StyleBuilderConverter::convertFlags(StyleResolverState& state, const CSSValue&
value) | 137 T StyleBuilderConverter::convertFlags(StyleResolverState& state, const CSSValue&
value) |
| 137 { | 138 { |
| 138 T flags = static_cast<T>(0); | 139 T flags = static_cast<T>(0); |
| 139 if (value.isPrimitiveValue() && toCSSPrimitiveValue(value).getValueID() == C
SSValueNone) | 140 if (value.isIdentifierValue() && toCSSIdentifierValue(value).getValueID() ==
CSSValueNone) |
| 140 return flags; | 141 return flags; |
| 141 for (auto& flagValue : toCSSValueList(value)) | 142 for (auto& flagValue : toCSSValueList(value)) |
| 142 flags |= toCSSPrimitiveValue(*flagValue).convertTo<T>(); | 143 flags |= toCSSIdentifierValue(*flagValue).convertTo<T>(); |
| 143 return flags; | 144 return flags; |
| 144 } | 145 } |
| 145 | 146 |
| 146 template <typename T> | 147 template <typename T> |
| 147 T StyleBuilderConverter::convertLineWidth(StyleResolverState& state, const CSSVa
lue& value) | 148 T StyleBuilderConverter::convertLineWidth(StyleResolverState& state, const CSSVa
lue& value) |
| 148 { | 149 { |
| 150 if (value.isIdentifierValue()) { |
| 151 CSSValueID valueID = toCSSIdentifierValue(value).getValueID(); |
| 152 if (valueID == CSSValueThin) |
| 153 return 1; |
| 154 if (valueID == CSSValueMedium) |
| 155 return 3; |
| 156 if (valueID == CSSValueThick) |
| 157 return 5; |
| 158 NOTREACHED(); |
| 159 return 0; |
| 160 } |
| 149 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); | 161 const CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); |
| 150 CSSValueID valueID = primitiveValue.getValueID(); | 162 // FIXME: We are moving to use the full page zoom implementation to handle h
igh-dpi. |
| 151 if (valueID == CSSValueThin) | 163 // In that case specyfing a border-width of less than 1px would result in a
border that is one device pixel thick. |
| 152 return 1; | 164 // With this change that would instead be rounded up to 2 device pixels. |
| 153 if (valueID == CSSValueMedium) | 165 // Consider clamping it to device pixels or zoom adjusted CSS pixels instead
of raw CSS pixels. |
| 154 return 3; | 166 // Reference crbug.com/485650 and crbug.com/382483 |
| 155 if (valueID == CSSValueThick) | 167 double result = primitiveValue.computeLength<double>(state.cssToLengthConver
sionData()); |
| 156 return 5; | 168 if (result > 0.0 && result < 1.0) |
| 157 if (valueID == CSSValueInvalid) { | 169 return 1.0; |
| 158 // FIXME: We are moving to use the full page zoom implementation to hand
le high-dpi. | 170 return clampTo<T>(roundForImpreciseConversion<T>(result), defaultMinimumForC
lamp<T>(), defaultMaximumForClamp<T>()); |
| 159 // In that case specyfing a border-width of less than 1px would result i
n a border that is one device pixel thick. | |
| 160 // With this change that would instead be rounded up to 2 device pixels. | |
| 161 // Consider clamping it to device pixels or zoom adjusted CSS pixels ins
tead of raw CSS pixels. | |
| 162 // Reference crbug.com/485650 and crbug.com/382483 | |
| 163 double result = primitiveValue.computeLength<double>(state.cssToLengthCo
nversionData()); | |
| 164 if (result > 0.0 && result < 1.0) | |
| 165 return 1.0; | |
| 166 return clampTo<T>(roundForImpreciseConversion<T>(result), defaultMinimum
ForClamp<T>(), defaultMaximumForClamp<T>()); | |
| 167 } | |
| 168 ASSERT_NOT_REACHED(); | |
| 169 return 0; | |
| 170 } | 171 } |
| 171 | 172 |
| 172 template <CSSValueID IdForNone> | 173 template <CSSValueID IdForNone> |
| 173 AtomicString StyleBuilderConverter::convertString(StyleResolverState&, const CSS
Value& value) | 174 AtomicString StyleBuilderConverter::convertString(StyleResolverState&, const CSS
Value& value) |
| 174 { | 175 { |
| 175 if (value.isStringValue()) | 176 if (value.isStringValue()) |
| 176 return AtomicString(toCSSStringValue(value).value()); | 177 return AtomicString(toCSSStringValue(value).value()); |
| 177 ASSERT(toCSSPrimitiveValue(value).getValueID() == IdForNone); | 178 DCHECK_EQ(toCSSIdentifierValue(value).getValueID(), IdForNone); |
| 178 return nullAtom; | 179 return nullAtom; |
| 179 } | 180 } |
| 180 | 181 |
| 181 } // namespace blink | 182 } // namespace blink |
| 182 | 183 |
| 183 #endif | 184 #endif |
| OLD | NEW |