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 |
(...skipping 12 matching lines...) Expand all Loading... |
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/SVGComputedStyle.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" | |
34 #include <memory> | |
35 | 33 |
36 #ifndef NDEBUG | 34 #ifndef NDEBUG |
37 #include <stdio.h> | 35 #include <stdio.h> |
38 #endif | 36 #endif |
39 | 37 |
40 namespace blink { | 38 namespace blink { |
41 | 39 |
42 using namespace SVGNames; | 40 using namespace SVGNames; |
43 | 41 |
44 SVGResources::SVGResources() | 42 SVGResources::SVGResources() |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 } | 188 } |
191 | 189 |
192 bool SVGResources::hasResourceData() const | 190 bool SVGResources::hasResourceData() const |
193 { | 191 { |
194 return m_clipperFilterMaskerData | 192 return m_clipperFilterMaskerData |
195 || m_markerData | 193 || m_markerData |
196 || m_fillStrokeData | 194 || m_fillStrokeData |
197 || m_linkedResource; | 195 || m_linkedResource; |
198 } | 196 } |
199 | 197 |
200 static inline SVGResources& ensureResources(std::unique_ptr<SVGResources>& resou
rces) | 198 static inline SVGResources& ensureResources(OwnPtr<SVGResources>& resources) |
201 { | 199 { |
202 if (!resources) | 200 if (!resources) |
203 resources = wrapUnique(new SVGResources); | 201 resources = adoptPtr(new SVGResources); |
204 | 202 |
205 return *resources.get(); | 203 return *resources.get(); |
206 } | 204 } |
207 | 205 |
208 std::unique_ptr<SVGResources> SVGResources::buildResources(const LayoutObject* o
bject, const SVGComputedStyle& style) | 206 PassOwnPtr<SVGResources> SVGResources::buildResources(const LayoutObject* object
, const SVGComputedStyle& style) |
209 { | 207 { |
210 ASSERT(object); | 208 ASSERT(object); |
211 | 209 |
212 Node* node = object->node(); | 210 Node* node = object->node(); |
213 ASSERT(node); | 211 ASSERT(node); |
214 ASSERT_WITH_SECURITY_IMPLICATION(node->isSVGElement()); | 212 ASSERT_WITH_SECURITY_IMPLICATION(node->isSVGElement()); |
215 | 213 |
216 SVGElement* element = toSVGElement(node); | 214 SVGElement* element = toSVGElement(node); |
217 ASSERT(element); | 215 ASSERT(element); |
218 | 216 |
219 const AtomicString& tagName = element->localName(); | 217 const AtomicString& tagName = element->localName(); |
220 ASSERT(!tagName.isNull()); | 218 ASSERT(!tagName.isNull()); |
221 | 219 |
222 TreeScope& treeScope = element->treeScope(); | 220 TreeScope& treeScope = element->treeScope(); |
223 SVGDocumentExtensions& extensions = element->document().accessSVGExtensions(
); | 221 SVGDocumentExtensions& extensions = element->document().accessSVGExtensions(
); |
224 | 222 |
225 std::unique_ptr<SVGResources> resources; | 223 OwnPtr<SVGResources> resources; |
226 if (clipperFilterMaskerTags().contains(tagName)) { | 224 if (clipperFilterMaskerTags().contains(tagName)) { |
227 if (style.hasClipper()) { | 225 if (style.hasClipper()) { |
228 AtomicString id = style.clipperResource(); | 226 AtomicString id = style.clipperResource(); |
229 if (!ensureResources(resources).setClipper(getLayoutSVGResourceById<
LayoutSVGResourceClipper>(treeScope, id))) | 227 if (!ensureResources(resources).setClipper(getLayoutSVGResourceById<
LayoutSVGResourceClipper>(treeScope, id))) |
230 registerPendingResource(extensions, id, element); | 228 registerPendingResource(extensions, id, element); |
231 } | 229 } |
232 | 230 |
233 if (style.hasFilter()) { | 231 if (style.hasFilter()) { |
234 AtomicString id = style.filterResource(); | 232 AtomicString id = style.filterResource(); |
235 if (!ensureResources(resources).setFilter(getLayoutSVGResourceById<L
ayoutSVGResourceFilter>(treeScope, id))) | 233 if (!ensureResources(resources).setFilter(getLayoutSVGResourceById<L
ayoutSVGResourceFilter>(treeScope, id))) |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 if (LayoutSVGResourcePaintServer* stroke = m_fillStrokeData->stroke) | 664 if (LayoutSVGResourcePaintServer* stroke = m_fillStrokeData->stroke) |
667 fprintf(stderr, " |-> Stroke : %p (node=%p)\n", stroke, stroke->
element()); | 665 fprintf(stderr, " |-> Stroke : %p (node=%p)\n", stroke, stroke->
element()); |
668 } | 666 } |
669 | 667 |
670 if (m_linkedResource) | 668 if (m_linkedResource) |
671 fprintf(stderr, " |-> xlink:href : %p (node=%p)\n", m_linkedResource, m_
linkedResource->element()); | 669 fprintf(stderr, " |-> xlink:href : %p (node=%p)\n", m_linkedResource, m_
linkedResource->element()); |
672 } | 670 } |
673 #endif | 671 #endif |
674 | 672 |
675 } // namespace blink | 673 } // namespace blink |
OLD | NEW |