Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Side by Side Diff: Source/core/css/resolver/StyleBuilderConverter.h

Issue 1225553002: CSSValue Immediates: Make CSSPrimitiveValue a container (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@cssvalue_patch_1
Patch Set: Rebase Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 if (value.isPrimitiveValue() && toCSSPrimitiveValue(value).getValueID() == C SSValueNone) 118 if (value.isPrimitiveValue() && toCSSPrimitiveValue(value).getValueID() == C SSValueNone)
119 return flags; 119 return flags;
120 for (auto& flagValue : toCSSValueList(value)) 120 for (auto& flagValue : toCSSValueList(value))
121 flags |= toCSSPrimitiveValue(flagValue); 121 flags |= toCSSPrimitiveValue(flagValue);
122 return flags; 122 return flags;
123 } 123 }
124 124
125 template <typename T> 125 template <typename T>
126 T StyleBuilderConverter::convertLineWidth(StyleResolverState& state, CSSValue va lue) 126 T StyleBuilderConverter::convertLineWidth(StyleResolverState& state, CSSValue va lue)
127 { 127 {
128 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); 128 CSSPrimitiveValue primitiveValue = toCSSPrimitiveValue(value);
129 CSSValueID valueID = primitiveValue.getValueID(); 129 CSSValueID valueID = primitiveValue.getValueID();
130 if (valueID == CSSValueThin) 130 if (valueID == CSSValueThin)
131 return 1; 131 return 1;
132 if (valueID == CSSValueMedium) 132 if (valueID == CSSValueMedium)
133 return 3; 133 return 3;
134 if (valueID == CSSValueThick) 134 if (valueID == CSSValueThick)
135 return 5; 135 return 5;
136 if (valueID == CSSValueInvalid) { 136 if (valueID == CSSValueInvalid) {
137 // Any original result that was >= 1 should not be allowed to fall below 1. 137 // Any original result that was >= 1 should not be allowed to fall below 1.
138 // This keeps border lines from vanishing. 138 // This keeps border lines from vanishing.
139 T result = primitiveValue.computeLength<T>(state.cssToLengthConversionDa ta()); 139 T result = primitiveValue.computeLength<T>(state.cssToLengthConversionDa ta());
140 if (state.style()->effectiveZoom() < 1.0f && result < 1.0) { 140 if (state.style()->effectiveZoom() < 1.0f && result < 1.0) {
141 T originalLength = primitiveValue.computeLength<T>(state.cssToLength ConversionData().copyWithAdjustedZoom(1.0)); 141 T originalLength = primitiveValue.computeLength<T>(state.cssToLength ConversionData().copyWithAdjustedZoom(1.0));
142 if (originalLength >= 1.0) 142 if (originalLength >= 1.0)
143 return 1.0; 143 return 1.0;
144 } 144 }
145 return result; 145 return result;
146 } 146 }
147 ASSERT_NOT_REACHED(); 147 ASSERT_NOT_REACHED();
148 return 0; 148 return 0;
149 } 149 }
150 150
151 template <CSSValueID IdForNone> 151 template <CSSValueID IdForNone>
152 AtomicString StyleBuilderConverter::convertString(StyleResolverState&, CSSValue value) 152 AtomicString StyleBuilderConverter::convertString(StyleResolverState&, CSSValue value)
153 { 153 {
154 CSSPrimitiveValue& primitiveValue = toCSSPrimitiveValue(value); 154 CSSPrimitiveValue primitiveValue = toCSSPrimitiveValue(value);
155 if (primitiveValue.getValueID() == IdForNone) 155 if (primitiveValue.getValueID() == IdForNone)
156 return nullAtom; 156 return nullAtom;
157 return AtomicString(primitiveValue.getStringValue()); 157 return AtomicString(primitiveValue.getStringValue());
158 } 158 }
159 159
160 } // namespace blink 160 } // namespace blink
161 161
162 #endif 162 #endif
OLDNEW
« no previous file with comments | « Source/core/css/resolver/FilterOperationResolver.cpp ('k') | Source/core/css/resolver/StyleBuilderConverter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698