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.
All rights reserved. | 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc.
All rights reserved. |
6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> | 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> |
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. | 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. |
10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
(...skipping 13 matching lines...) Expand all Loading... |
24 * along with this library; see the file COPYING.LIB. If not, write to | 24 * along with this library; see the file COPYING.LIB. If not, write to |
25 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 25 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
26 * Boston, MA 02110-1301, USA. | 26 * Boston, MA 02110-1301, USA. |
27 */ | 27 */ |
28 | 28 |
29 #include "core/css/resolver/FilterOperationResolver.h" | 29 #include "core/css/resolver/FilterOperationResolver.h" |
30 | 30 |
31 #include "core/css/CSSFunctionValue.h" | 31 #include "core/css/CSSFunctionValue.h" |
32 #include "core/css/CSSPrimitiveValueMappings.h" | 32 #include "core/css/CSSPrimitiveValueMappings.h" |
33 #include "core/css/CSSShadowValue.h" | 33 #include "core/css/CSSShadowValue.h" |
| 34 #include "core/css/CSSURIValue.h" |
34 #include "core/css/resolver/StyleResolverState.h" | 35 #include "core/css/resolver/StyleResolverState.h" |
35 #include "core/frame/UseCounter.h" | 36 #include "core/frame/UseCounter.h" |
36 #include "core/layout/svg/ReferenceFilterBuilder.h" | 37 #include "core/layout/svg/ReferenceFilterBuilder.h" |
37 | 38 |
38 namespace blink { | 39 namespace blink { |
39 | 40 |
40 FilterOperation::OperationType FilterOperationResolver::filterOperationForType(C
SSValueID type) | 41 FilterOperation::OperationType FilterOperationResolver::filterOperationForType(C
SSValueID type) |
41 { | 42 { |
42 switch (type) { | 43 switch (type) { |
43 case CSSValueUrl: | |
44 return FilterOperation::REFERENCE; | |
45 case CSSValueGrayscale: | 44 case CSSValueGrayscale: |
46 return FilterOperation::GRAYSCALE; | 45 return FilterOperation::GRAYSCALE; |
47 case CSSValueSepia: | 46 case CSSValueSepia: |
48 return FilterOperation::SEPIA; | 47 return FilterOperation::SEPIA; |
49 case CSSValueSaturate: | 48 case CSSValueSaturate: |
50 return FilterOperation::SATURATE; | 49 return FilterOperation::SATURATE; |
51 case CSSValueHueRotate: | 50 case CSSValueHueRotate: |
52 return FilterOperation::HUE_ROTATE; | 51 return FilterOperation::HUE_ROTATE; |
53 case CSSValueInvert: | 52 case CSSValueInvert: |
54 return FilterOperation::INVERT; | 53 return FilterOperation::INVERT; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 { | 119 { |
121 FilterOperations operations; | 120 FilterOperations operations; |
122 | 121 |
123 if (inValue.isPrimitiveValue()) { | 122 if (inValue.isPrimitiveValue()) { |
124 ASSERT(toCSSPrimitiveValue(inValue).getValueID() == CSSValueNone); | 123 ASSERT(toCSSPrimitiveValue(inValue).getValueID() == CSSValueNone); |
125 return operations; | 124 return operations; |
126 } | 125 } |
127 | 126 |
128 const CSSToLengthConversionData& conversionData = state.cssToLengthConversio
nData(); | 127 const CSSToLengthConversionData& conversionData = state.cssToLengthConversio
nData(); |
129 for (auto& currValue : toCSSValueList(inValue)) { | 128 for (auto& currValue : toCSSValueList(inValue)) { |
130 const CSSFunctionValue* filterValue = toCSSFunctionValue(currValue.get()
); | 129 if (currValue->isURIValue()) { |
131 FilterOperation::OperationType operationType = filterOperationForType(fi
lterValue->functionType()); | 130 countFilterUse(FilterOperation::REFERENCE, state.document()); |
132 countFilterUse(operationType, state.document()); | |
133 ASSERT(filterValue->length() <= 1); | |
134 | 131 |
135 if (operationType == FilterOperation::REFERENCE) { | 132 const CSSURIValue& urlValue = toCSSURIValue(*currValue); |
136 const CSSSVGDocumentValue& svgDocumentValue = toCSSSVGDocumentValue(
filterValue->item(0)); | 133 KURL url = state.document().completeURL(urlValue.url()); |
137 KURL url = state.document().completeURL(svgDocumentValue.url()); | |
138 | 134 |
139 ReferenceFilterOperation* operation = ReferenceFilterOperation::crea
te(svgDocumentValue.url(), AtomicString(url.fragmentIdentifier())); | 135 ReferenceFilterOperation* operation = ReferenceFilterOperation::crea
te(urlValue.url(), AtomicString(url.fragmentIdentifier())); |
140 if (!equalIgnoringFragmentIdentifier(url, state.document().url())) { | 136 if (!equalIgnoringFragmentIdentifier(url, state.document().url())) { |
141 if (!svgDocumentValue.loadRequested()) | 137 if (!urlValue.loadRequested()) |
142 state.elementStyleResources().addPendingSVGDocument(operatio
n, &svgDocumentValue); | 138 state.elementStyleResources().addPendingSVGDocument(operatio
n, &urlValue); |
143 else if (svgDocumentValue.cachedSVGDocument()) | 139 else if (urlValue.cachedDocument()) |
144 ReferenceFilterBuilder::setDocumentResourceReference(operati
on, new DocumentResourceReference(svgDocumentValue.cachedSVGDocument())); | 140 ReferenceFilterBuilder::setDocumentResourceReference(operati
on, new DocumentResourceReference(urlValue.cachedDocument())); |
145 } | 141 } |
146 operations.operations().append(operation); | 142 operations.operations().append(operation); |
147 continue; | 143 continue; |
148 } | 144 } |
149 | 145 |
| 146 const CSSFunctionValue* filterValue = toCSSFunctionValue(currValue.get()
); |
| 147 FilterOperation::OperationType operationType = filterOperationForType(fi
lterValue->functionType()); |
| 148 countFilterUse(operationType, state.document()); |
| 149 DCHECK_LE(filterValue->length(), 1u); |
| 150 |
150 const CSSPrimitiveValue* firstValue = filterValue->length() && filterVal
ue->item(0).isPrimitiveValue() ? &toCSSPrimitiveValue(filterValue->item(0)) : nu
llptr; | 151 const CSSPrimitiveValue* firstValue = filterValue->length() && filterVal
ue->item(0).isPrimitiveValue() ? &toCSSPrimitiveValue(filterValue->item(0)) : nu
llptr; |
151 switch (filterValue->functionType()) { | 152 switch (filterValue->functionType()) { |
152 case CSSValueGrayscale: | 153 case CSSValueGrayscale: |
153 case CSSValueSepia: | 154 case CSSValueSepia: |
154 case CSSValueSaturate: { | 155 case CSSValueSaturate: { |
155 double amount = 1; | 156 double amount = 1; |
156 if (filterValue->length() == 1) { | 157 if (filterValue->length() == 1) { |
157 amount = firstValue->getDoubleValue(); | 158 amount = firstValue->getDoubleValue(); |
158 if (firstValue->isPercentage()) | 159 if (firstValue->isPercentage()) |
159 amount /= 100; | 160 amount /= 100; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 default: | 206 default: |
206 ASSERT_NOT_REACHED(); | 207 ASSERT_NOT_REACHED(); |
207 break; | 208 break; |
208 } | 209 } |
209 } | 210 } |
210 | 211 |
211 return operations; | 212 return operations; |
212 } | 213 } |
213 | 214 |
214 } // namespace blink | 215 } // namespace blink |
OLD | NEW |