OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU Library General Public License | 14 * You should have received a copy of the GNU Library General Public License |
15 * along with this library; see the file COPYING.LIB. If not, write to | 15 * along with this library; see the file COPYING.LIB. If not, write to |
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
18 */ | 18 */ |
19 | 19 |
20 #include "core/layout/svg/SVGResources.h" | 20 #include "core/layout/svg/SVGResources.h" |
21 | 21 |
22 #include "core/SVGNames.h" | 22 #include "core/SVGNames.h" |
23 #include "core/layout/svg/LayoutSVGResourceClipper.h" | 23 #include "core/layout/svg/LayoutSVGResourceClipper.h" |
24 #include "core/layout/svg/LayoutSVGResourceFilter.h" | 24 #include "core/layout/svg/LayoutSVGResourceFilter.h" |
25 #include "core/layout/svg/LayoutSVGResourceMarker.h" | 25 #include "core/layout/svg/LayoutSVGResourceMarker.h" |
26 #include "core/layout/svg/LayoutSVGResourceMasker.h" | 26 #include "core/layout/svg/LayoutSVGResourceMasker.h" |
27 #include "core/layout/svg/LayoutSVGResourcePaintServer.h" | 27 #include "core/layout/svg/LayoutSVGResourcePaintServer.h" |
28 #include "core/style/SVGComputedStyle.h" | 28 #include "core/style/ComputedStyle.h" |
29 #include "core/svg/SVGFilterElement.h" | 29 #include "core/svg/SVGFilterElement.h" |
30 #include "core/svg/SVGGradientElement.h" | 30 #include "core/svg/SVGGradientElement.h" |
31 #include "core/svg/SVGPatternElement.h" | 31 #include "core/svg/SVGPatternElement.h" |
32 #include "core/svg/SVGURIReference.h" | 32 #include "core/svg/SVGURIReference.h" |
33 #include "wtf/PtrUtil.h" | 33 #include "wtf/PtrUtil.h" |
34 #include <memory> | 34 #include <memory> |
35 | 35 |
36 #ifndef NDEBUG | 36 #ifndef NDEBUG |
37 #include <stdio.h> | 37 #include <stdio.h> |
38 #endif | 38 #endif |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 } | 198 } |
199 | 199 |
200 static inline SVGResources& ensureResources(std::unique_ptr<SVGResources>& resou
rces) | 200 static inline SVGResources& ensureResources(std::unique_ptr<SVGResources>& resou
rces) |
201 { | 201 { |
202 if (!resources) | 202 if (!resources) |
203 resources = wrapUnique(new SVGResources); | 203 resources = wrapUnique(new SVGResources); |
204 | 204 |
205 return *resources.get(); | 205 return *resources.get(); |
206 } | 206 } |
207 | 207 |
208 std::unique_ptr<SVGResources> SVGResources::buildResources(const LayoutObject* o
bject, const SVGComputedStyle& style) | 208 std::unique_ptr<SVGResources> SVGResources::buildResources(const LayoutObject* o
bject, const ComputedStyle& computedStyle) |
209 { | 209 { |
210 ASSERT(object); | 210 ASSERT(object); |
211 | 211 |
212 Node* node = object->node(); | 212 Node* node = object->node(); |
213 ASSERT(node); | 213 ASSERT(node); |
214 ASSERT_WITH_SECURITY_IMPLICATION(node->isSVGElement()); | 214 ASSERT_WITH_SECURITY_IMPLICATION(node->isSVGElement()); |
215 | 215 |
216 SVGElement* element = toSVGElement(node); | 216 SVGElement* element = toSVGElement(node); |
217 ASSERT(element); | 217 ASSERT(element); |
218 | 218 |
219 const AtomicString& tagName = element->localName(); | 219 const AtomicString& tagName = element->localName(); |
220 ASSERT(!tagName.isNull()); | 220 ASSERT(!tagName.isNull()); |
221 | 221 |
222 TreeScope& treeScope = element->treeScope(); | 222 TreeScope& treeScope = element->treeScope(); |
223 SVGDocumentExtensions& extensions = element->document().accessSVGExtensions(
); | 223 SVGDocumentExtensions& extensions = element->document().accessSVGExtensions(
); |
224 | 224 |
| 225 const SVGComputedStyle& style = computedStyle.svgStyle(); |
| 226 |
225 std::unique_ptr<SVGResources> resources; | 227 std::unique_ptr<SVGResources> resources; |
226 if (clipperFilterMaskerTags().contains(tagName)) { | 228 if (clipperFilterMaskerTags().contains(tagName)) { |
227 if (style.hasClipper()) { | 229 if (style.hasClipper()) { |
228 AtomicString id = style.clipperResource(); | 230 AtomicString id = style.clipperResource(); |
229 if (!ensureResources(resources).setClipper(getLayoutSVGResourceById<
LayoutSVGResourceClipper>(treeScope, id))) | 231 if (!ensureResources(resources).setClipper(getLayoutSVGResourceById<
LayoutSVGResourceClipper>(treeScope, id))) |
230 registerPendingResource(extensions, id, element); | 232 registerPendingResource(extensions, id, element); |
231 } | 233 } |
232 | 234 |
233 if (style.hasFilter()) { | 235 if (computedStyle.hasFilter() && !object->isSVGRoot()) { |
234 AtomicString id = style.filterResource(); | 236 const FilterOperations& filterOperations = computedStyle.filter(); |
235 if (!ensureResources(resources).setFilter(getLayoutSVGResourceById<L
ayoutSVGResourceFilter>(treeScope, id))) | 237 if (filterOperations.size() == 1) { |
236 registerPendingResource(extensions, id, element); | 238 const FilterOperation& filterOperation = *filterOperations.at(0)
; |
| 239 if (filterOperation.type() == FilterOperation::REFERENCE) { |
| 240 const auto& referenceFilterOperation = toReferenceFilterOper
ation(filterOperation); |
| 241 AtomicString id = SVGURIReference::fragmentIdentifierFromIRI
String(referenceFilterOperation.url(), treeScope); |
| 242 if (!ensureResources(resources).setFilter(getLayoutSVGResour
ceById<LayoutSVGResourceFilter>(treeScope, id))) |
| 243 registerPendingResource(extensions, id, element); |
| 244 } |
| 245 } |
237 } | 246 } |
238 | 247 |
239 if (style.hasMasker()) { | 248 if (style.hasMasker()) { |
240 AtomicString id = style.maskerResource(); | 249 AtomicString id = style.maskerResource(); |
241 if (!ensureResources(resources).setMasker(getLayoutSVGResourceById<L
ayoutSVGResourceMasker>(treeScope, id))) | 250 if (!ensureResources(resources).setMasker(getLayoutSVGResourceById<L
ayoutSVGResourceMasker>(treeScope, id))) |
242 registerPendingResource(extensions, id, element); | 251 registerPendingResource(extensions, id, element); |
243 } | 252 } |
244 } | 253 } |
245 | 254 |
246 if (style.hasMarkers() && supportsMarkers(*element)) { | 255 if (style.hasMarkers() && supportsMarkers(*element)) { |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 if (LayoutSVGResourcePaintServer* stroke = m_fillStrokeData->stroke) | 675 if (LayoutSVGResourcePaintServer* stroke = m_fillStrokeData->stroke) |
667 fprintf(stderr, " |-> Stroke : %p (node=%p)\n", stroke, stroke->
element()); | 676 fprintf(stderr, " |-> Stroke : %p (node=%p)\n", stroke, stroke->
element()); |
668 } | 677 } |
669 | 678 |
670 if (m_linkedResource) | 679 if (m_linkedResource) |
671 fprintf(stderr, " |-> xlink:href : %p (node=%p)\n", m_linkedResource, m_
linkedResource->element()); | 680 fprintf(stderr, " |-> xlink:href : %p (node=%p)\n", m_linkedResource, m_
linkedResource->element()); |
672 } | 681 } |
673 #endif | 682 #endif |
674 | 683 |
675 } // namespace blink | 684 } // namespace blink |
OLD | NEW |