OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) | 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) |
4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) | 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) |
5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. | 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. |
6 * All rights reserved. | 6 * All rights reserved. |
7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> | 8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> |
9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
10 * (http://www.torchmobile.com/) | 10 * (http://www.torchmobile.com/) |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 feature = UseCounter::CSSFilterBlur; | 112 feature = UseCounter::CSSFilterBlur; |
113 break; | 113 break; |
114 case FilterOperation::DROP_SHADOW: | 114 case FilterOperation::DROP_SHADOW: |
115 feature = UseCounter::CSSFilterDropShadow; | 115 feature = UseCounter::CSSFilterDropShadow; |
116 break; | 116 break; |
117 }; | 117 }; |
118 UseCounter::count(document, feature); | 118 UseCounter::count(document, feature); |
119 } | 119 } |
120 | 120 |
121 FilterOperations FilterOperationResolver::createFilterOperations( | 121 FilterOperations FilterOperationResolver::createFilterOperations( |
122 StyleResolverState& state, | 122 StyleResolverState* state, |
Justin Novosad
2016/10/24 18:51:22
This approach seems reasonable to me, but I'll def
esprehn
2016/11/22 01:38:37
Lets refactor this into two methods, one that take
| |
123 const CSSValue& inValue) { | 123 const CSSValue& inValue) { |
124 FilterOperations operations; | 124 FilterOperations operations; |
125 | 125 |
126 if (inValue.isIdentifierValue()) { | 126 if (inValue.isIdentifierValue()) { |
127 DCHECK_EQ(toCSSIdentifierValue(inValue).getValueID(), CSSValueNone); | 127 DCHECK_EQ(toCSSIdentifierValue(inValue).getValueID(), CSSValueNone); |
128 return operations; | 128 return operations; |
129 } | 129 } |
130 | 130 |
131 const CSSToLengthConversionData& conversionData = | 131 const CSSToLengthConversionData* conversionData; |
132 state.cssToLengthConversionData(); | 132 if (state) |
133 conversionData = &(state->cssToLengthConversionData()); | |
134 | |
133 for (auto& currValue : toCSSValueList(inValue)) { | 135 for (auto& currValue : toCSSValueList(inValue)) { |
134 if (currValue->isURIValue()) { | 136 if (currValue->isURIValue()) { |
135 countFilterUse(FilterOperation::REFERENCE, state.document()); | 137 if (!state) |
138 continue; | |
meade_UTC10
2016/10/26 06:57:34
This for loop is big and kind of hard to reason ab
fserb
2016/10/26 19:08:26
True. Although there's nothing to do if there's a
| |
139 countFilterUse(FilterOperation::REFERENCE, state->document()); | |
136 | 140 |
137 const CSSURIValue& urlValue = toCSSURIValue(*currValue); | 141 const CSSURIValue& urlValue = toCSSURIValue(*currValue); |
138 SVGURLReferenceResolver resolver(urlValue.value(), state.document()); | 142 SVGURLReferenceResolver resolver(urlValue.value(), state->document()); |
139 ReferenceFilterOperation* operation = ReferenceFilterOperation::create( | 143 ReferenceFilterOperation* operation = ReferenceFilterOperation::create( |
140 urlValue.value(), resolver.fragmentIdentifier()); | 144 urlValue.value(), resolver.fragmentIdentifier()); |
141 if (!resolver.isLocal()) { | 145 if (!resolver.isLocal()) { |
142 if (!urlValue.loadRequested()) | 146 if (!urlValue.loadRequested()) { |
143 state.elementStyleResources().addPendingSVGDocument(operation, | 147 state->elementStyleResources().addPendingSVGDocument(operation, |
144 &urlValue); | 148 &urlValue); |
145 else if (urlValue.cachedDocument()) | 149 } else if (urlValue.cachedDocument()) { |
146 ReferenceFilterBuilder::setDocumentResourceReference( | 150 ReferenceFilterBuilder::setDocumentResourceReference( |
147 operation, | 151 operation, |
148 new DocumentResourceReference(urlValue.cachedDocument())); | 152 new DocumentResourceReference(urlValue.cachedDocument())); |
153 } | |
149 } | 154 } |
150 operations.operations().append(operation); | 155 operations.operations().append(operation); |
151 continue; | 156 continue; |
152 } | 157 } |
153 | 158 |
154 const CSSFunctionValue* filterValue = toCSSFunctionValue(currValue.get()); | 159 const CSSFunctionValue* filterValue = toCSSFunctionValue(currValue.get()); |
155 FilterOperation::OperationType operationType = | 160 FilterOperation::OperationType operationType = |
156 filterOperationForType(filterValue->functionType()); | 161 filterOperationForType(filterValue->functionType()); |
157 countFilterUse(operationType, state.document()); | 162 if (state) |
163 countFilterUse(operationType, state->document()); | |
158 DCHECK_LE(filterValue->length(), 1u); | 164 DCHECK_LE(filterValue->length(), 1u); |
159 | 165 |
160 const CSSPrimitiveValue* firstValue = | 166 const CSSPrimitiveValue* firstValue = |
161 filterValue->length() && filterValue->item(0).isPrimitiveValue() | 167 filterValue->length() && filterValue->item(0).isPrimitiveValue() |
162 ? &toCSSPrimitiveValue(filterValue->item(0)) | 168 ? &toCSSPrimitiveValue(filterValue->item(0)) |
163 : nullptr; | 169 : nullptr; |
164 switch (filterValue->functionType()) { | 170 switch (filterValue->functionType()) { |
165 case CSSValueGrayscale: | 171 case CSSValueGrayscale: |
166 case CSSValueSepia: | 172 case CSSValueSepia: |
167 case CSSValueSaturate: { | 173 case CSSValueSaturate: { |
(...skipping 29 matching lines...) Expand all Loading... | |
197 amount /= 100; | 203 amount /= 100; |
198 } | 204 } |
199 | 205 |
200 operations.operations().append( | 206 operations.operations().append( |
201 BasicComponentTransferFilterOperation::create(amount, | 207 BasicComponentTransferFilterOperation::create(amount, |
202 operationType)); | 208 operationType)); |
203 break; | 209 break; |
204 } | 210 } |
205 case CSSValueBlur: { | 211 case CSSValueBlur: { |
206 Length stdDeviation = Length(0, Fixed); | 212 Length stdDeviation = Length(0, Fixed); |
207 if (filterValue->length() >= 1) | 213 if (filterValue->length() >= 1) { |
208 stdDeviation = firstValue->convertToLength(conversionData); | 214 if (state) |
215 stdDeviation = firstValue->convertToLength(*conversionData); | |
216 else | |
217 stdDeviation = Length(firstValue->getDoubleValue(), Fixed); | |
Justin Novosad
2016/10/24 18:51:22
This part is doubtful. We probably want some kind
fserb
2016/10/26 19:08:26
I did try to create a deafult ConversionData. I'm
| |
218 } | |
209 operations.operations().append( | 219 operations.operations().append( |
210 BlurFilterOperation::create(stdDeviation)); | 220 BlurFilterOperation::create(stdDeviation)); |
211 break; | 221 break; |
212 } | 222 } |
213 case CSSValueDropShadow: { | 223 case CSSValueDropShadow: { |
214 const CSSShadowValue& item = toCSSShadowValue(filterValue->item(0)); | 224 const CSSShadowValue& item = toCSSShadowValue(filterValue->item(0)); |
215 IntPoint location(item.x->computeLength<int>(conversionData), | 225 IntPoint location; |
216 item.y->computeLength<int>(conversionData)); | 226 int blur; |
217 int blur = | 227 |
218 item.blur ? item.blur->computeLength<int>(conversionData) : 0; | 228 if (state) { |
229 location = IntPoint(item.x->computeLength<int>(*conversionData), | |
230 item.y->computeLength<int>(*conversionData)); | |
231 blur = item.blur ? item.blur->computeLength<int>(*conversionData) : 0; | |
232 } else { | |
233 location = IntPoint(item.x->getIntValue(), item.y->getIntValue()); | |
234 blur = item.blur ? item.blur->getIntValue() : 0; | |
Justin Novosad
2016/10/24 18:51:22
More doubtful conversions.
fserb
2016/10/26 19:08:26
I'll try that.
| |
235 } | |
219 Color shadowColor = Color::black; | 236 Color shadowColor = Color::black; |
220 if (item.color) | 237 if (item.color && state) { |
221 shadowColor = state.document().textLinkColors().colorFromCSSValue( | 238 shadowColor = state->document().textLinkColors().colorFromCSSValue( |
222 *item.color, state.style()->color()); | 239 *item.color, state->style()->color()); |
240 } | |
223 | 241 |
224 operations.operations().append( | 242 operations.operations().append( |
225 DropShadowFilterOperation::create(location, blur, shadowColor)); | 243 DropShadowFilterOperation::create(location, blur, shadowColor)); |
226 break; | 244 break; |
227 } | 245 } |
228 default: | 246 default: |
229 ASSERT_NOT_REACHED(); | 247 ASSERT_NOT_REACHED(); |
230 break; | 248 break; |
231 } | 249 } |
232 } | 250 } |
233 | 251 |
234 return operations; | 252 return operations; |
235 } | 253 } |
236 | 254 |
237 } // namespace blink | 255 } // namespace blink |
OLD | NEW |