| 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 TreeScope& treeScope, | 140 TreeScope& treeScope, |
| 141 const SVGPaintType& paintType, | 141 const SVGPaintType& paintType, |
| 142 const String& paintUri, | 142 const String& paintUri, |
| 143 AtomicString& id, | 143 AtomicString& id, |
| 144 bool& hasPendingResource) { | 144 bool& hasPendingResource) { |
| 145 if (!svgPaintTypeHasURL(paintType)) | 145 if (!svgPaintTypeHasURL(paintType)) |
| 146 return nullptr; | 146 return nullptr; |
| 147 | 147 |
| 148 id = SVGURIReference::fragmentIdentifierFromIRIString(paintUri, treeScope); | 148 id = SVGURIReference::fragmentIdentifierFromIRIString(paintUri, treeScope); |
| 149 LayoutSVGResourceContainer* container = | 149 LayoutSVGResourceContainer* container = |
| 150 getLayoutSVGResourceContainerById(treeScope, id); | 150 treeScope.ensureSVGTreeScopedResources().resourceById(id); |
| 151 if (!container) { | 151 if (!container) { |
| 152 hasPendingResource = true; | 152 hasPendingResource = true; |
| 153 return nullptr; | 153 return nullptr; |
| 154 } | 154 } |
| 155 | 155 |
| 156 if (!container->isSVGPaintServer()) | 156 if (!container->isSVGPaintServer()) |
| 157 return nullptr; | 157 return nullptr; |
| 158 | 158 |
| 159 return toLayoutSVGResourcePaintServer(container); | 159 return toLayoutSVGResourcePaintServer(container); |
| 160 } | 160 } |
| 161 | 161 |
| 162 static inline void registerPendingResource( | |
| 163 SVGTreeScopeResources& treeScopeResources, | |
| 164 const AtomicString& id, | |
| 165 SVGElement* element) { | |
| 166 DCHECK(element); | |
| 167 treeScopeResources.addPendingResource(id, element); | |
| 168 } | |
| 169 | |
| 170 bool SVGResources::hasResourceData() const { | 162 bool SVGResources::hasResourceData() const { |
| 171 return m_clipperFilterMaskerData || m_markerData || m_fillStrokeData || | 163 return m_clipperFilterMaskerData || m_markerData || m_fillStrokeData || |
| 172 m_linkedResource; | 164 m_linkedResource; |
| 173 } | 165 } |
| 174 | 166 |
| 175 static inline SVGResources& ensureResources( | 167 static inline SVGResources& ensureResources( |
| 176 std::unique_ptr<SVGResources>& resources) { | 168 std::unique_ptr<SVGResources>& resources) { |
| 177 if (!resources) | 169 if (!resources) |
| 178 resources = WTF::wrapUnique(new SVGResources); | 170 resources = WTF::wrapUnique(new SVGResources); |
| 179 | 171 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 204 std::unique_ptr<SVGResources> resources; | 196 std::unique_ptr<SVGResources> resources; |
| 205 if (clipperFilterMaskerTags().contains(tagName)) { | 197 if (clipperFilterMaskerTags().contains(tagName)) { |
| 206 if (computedStyle.clipPath() && !object->isSVGRoot()) { | 198 if (computedStyle.clipPath() && !object->isSVGRoot()) { |
| 207 ClipPathOperation* clipPathOperation = computedStyle.clipPath(); | 199 ClipPathOperation* clipPathOperation = computedStyle.clipPath(); |
| 208 if (clipPathOperation->type() == ClipPathOperation::REFERENCE) { | 200 if (clipPathOperation->type() == ClipPathOperation::REFERENCE) { |
| 209 const ReferenceClipPathOperation& clipPathReference = | 201 const ReferenceClipPathOperation& clipPathReference = |
| 210 toReferenceClipPathOperation(*clipPathOperation); | 202 toReferenceClipPathOperation(*clipPathOperation); |
| 211 AtomicString id = SVGURIReference::fragmentIdentifierFromIRIString( | 203 AtomicString id = SVGURIReference::fragmentIdentifierFromIRIString( |
| 212 clipPathReference.url(), treeScope); | 204 clipPathReference.url(), treeScope); |
| 213 if (!ensureResources(resources).setClipper( | 205 if (!ensureResources(resources).setClipper( |
| 214 getLayoutSVGResourceById<LayoutSVGResourceClipper>(treeScope, | 206 getLayoutSVGResourceById<LayoutSVGResourceClipper>( |
| 215 id))) | 207 treeScopeResources, id))) |
| 216 registerPendingResource(treeScopeResources, id, element); | 208 treeScopeResources.addPendingResource(id, element); |
| 217 } | 209 } |
| 218 } | 210 } |
| 219 | 211 |
| 220 if (computedStyle.hasFilter() && !object->isSVGRoot()) { | 212 if (computedStyle.hasFilter() && !object->isSVGRoot()) { |
| 221 const FilterOperations& filterOperations = computedStyle.filter(); | 213 const FilterOperations& filterOperations = computedStyle.filter(); |
| 222 if (filterOperations.size() == 1) { | 214 if (filterOperations.size() == 1) { |
| 223 const FilterOperation& filterOperation = *filterOperations.at(0); | 215 const FilterOperation& filterOperation = *filterOperations.at(0); |
| 224 if (filterOperation.type() == FilterOperation::REFERENCE) { | 216 if (filterOperation.type() == FilterOperation::REFERENCE) { |
| 225 const auto& referenceFilterOperation = | 217 const auto& referenceFilterOperation = |
| 226 toReferenceFilterOperation(filterOperation); | 218 toReferenceFilterOperation(filterOperation); |
| 227 AtomicString id = SVGURIReference::fragmentIdentifierFromIRIString( | 219 AtomicString id = SVGURIReference::fragmentIdentifierFromIRIString( |
| 228 referenceFilterOperation.url(), treeScope); | 220 referenceFilterOperation.url(), treeScope); |
| 229 if (!ensureResources(resources).setFilter( | 221 if (!ensureResources(resources).setFilter( |
| 230 getLayoutSVGResourceById<LayoutSVGResourceFilter>(treeScope, | 222 getLayoutSVGResourceById<LayoutSVGResourceFilter>( |
| 231 id))) | 223 treeScopeResources, id))) |
| 232 registerPendingResource(treeScopeResources, id, element); | 224 treeScopeResources.addPendingResource(id, element); |
| 233 } | 225 } |
| 234 } | 226 } |
| 235 } | 227 } |
| 236 | 228 |
| 237 if (style.hasMasker()) { | 229 if (style.hasMasker()) { |
| 238 AtomicString id = style.maskerResource(); | 230 AtomicString id = style.maskerResource(); |
| 239 if (!ensureResources(resources).setMasker( | 231 if (!ensureResources(resources).setMasker( |
| 240 getLayoutSVGResourceById<LayoutSVGResourceMasker>(treeScope, id))) | 232 getLayoutSVGResourceById<LayoutSVGResourceMasker>( |
| 241 registerPendingResource(treeScopeResources, id, element); | 233 treeScopeResources, id))) |
| 234 treeScopeResources.addPendingResource(id, element); |
| 242 } | 235 } |
| 243 } | 236 } |
| 244 | 237 |
| 245 if (style.hasMarkers() && supportsMarkers(*element)) { | 238 if (style.hasMarkers() && supportsMarkers(*element)) { |
| 246 const AtomicString& markerStartId = style.markerStartResource(); | 239 const AtomicString& markerStartId = style.markerStartResource(); |
| 247 if (!ensureResources(resources).setMarkerStart( | 240 if (!ensureResources(resources).setMarkerStart( |
| 248 getLayoutSVGResourceById<LayoutSVGResourceMarker>(treeScope, | 241 getLayoutSVGResourceById<LayoutSVGResourceMarker>( |
| 249 markerStartId))) | 242 treeScopeResources, markerStartId))) |
| 250 registerPendingResource(treeScopeResources, markerStartId, element); | 243 treeScopeResources.addPendingResource(markerStartId, element); |
| 251 | 244 |
| 252 const AtomicString& markerMidId = style.markerMidResource(); | 245 const AtomicString& markerMidId = style.markerMidResource(); |
| 253 if (!ensureResources(resources).setMarkerMid( | 246 if (!ensureResources(resources).setMarkerMid( |
| 254 getLayoutSVGResourceById<LayoutSVGResourceMarker>(treeScope, | 247 getLayoutSVGResourceById<LayoutSVGResourceMarker>( |
| 255 markerMidId))) | 248 treeScopeResources, markerMidId))) |
| 256 registerPendingResource(treeScopeResources, markerMidId, element); | 249 treeScopeResources.addPendingResource(markerMidId, element); |
| 257 | 250 |
| 258 const AtomicString& markerEndId = style.markerEndResource(); | 251 const AtomicString& markerEndId = style.markerEndResource(); |
| 259 if (!ensureResources(resources).setMarkerEnd( | 252 if (!ensureResources(resources).setMarkerEnd( |
| 260 getLayoutSVGResourceById<LayoutSVGResourceMarker>( | 253 getLayoutSVGResourceById<LayoutSVGResourceMarker>( |
| 261 treeScope, style.markerEndResource()))) | 254 treeScopeResources, markerEndId))) |
| 262 registerPendingResource(treeScopeResources, markerEndId, element); | 255 treeScopeResources.addPendingResource(markerEndId, element); |
| 263 } | 256 } |
| 264 | 257 |
| 265 if (fillAndStrokeTags().contains(tagName)) { | 258 if (fillAndStrokeTags().contains(tagName)) { |
| 266 if (style.hasFill()) { | 259 if (style.hasFill()) { |
| 267 bool hasPendingResource = false; | 260 bool hasPendingResource = false; |
| 268 AtomicString id; | 261 AtomicString id; |
| 269 LayoutSVGResourcePaintServer* resource = paintingResourceFromSVGPaint( | 262 LayoutSVGResourcePaintServer* resource = paintingResourceFromSVGPaint( |
| 270 treeScope, style.fillPaintType(), style.fillPaintUri(), id, | 263 treeScope, style.fillPaintType(), style.fillPaintUri(), id, |
| 271 hasPendingResource); | 264 hasPendingResource); |
| 272 if (!ensureResources(resources).setFill(resource) && hasPendingResource) | 265 if (!ensureResources(resources).setFill(resource) && hasPendingResource) |
| 273 registerPendingResource(treeScopeResources, id, element); | 266 treeScopeResources.addPendingResource(id, element); |
| 274 } | 267 } |
| 275 | 268 |
| 276 if (style.hasStroke()) { | 269 if (style.hasStroke()) { |
| 277 bool hasPendingResource = false; | 270 bool hasPendingResource = false; |
| 278 AtomicString id; | 271 AtomicString id; |
| 279 LayoutSVGResourcePaintServer* resource = paintingResourceFromSVGPaint( | 272 LayoutSVGResourcePaintServer* resource = paintingResourceFromSVGPaint( |
| 280 treeScope, style.strokePaintType(), style.strokePaintUri(), id, | 273 treeScope, style.strokePaintType(), style.strokePaintUri(), id, |
| 281 hasPendingResource); | 274 hasPendingResource); |
| 282 if (!ensureResources(resources).setStroke(resource) && hasPendingResource) | 275 if (!ensureResources(resources).setStroke(resource) && hasPendingResource) |
| 283 registerPendingResource(treeScopeResources, id, element); | 276 treeScopeResources.addPendingResource(id, element); |
| 284 } | 277 } |
| 285 } | 278 } |
| 286 | 279 |
| 287 if (chainableResourceTags().contains(tagName)) { | 280 if (chainableResourceTags().contains(tagName)) { |
| 288 AtomicString id = targetReferenceFromResource(*element); | 281 AtomicString id = targetReferenceFromResource(*element); |
| 289 if (!ensureResources(resources).setLinkedResource( | 282 if (!ensureResources(resources).setLinkedResource( |
| 290 getLayoutSVGResourceContainerById(treeScope, id))) | 283 treeScopeResources.resourceById(id))) |
| 291 registerPendingResource(treeScopeResources, id, element); | 284 treeScopeResources.addPendingResource(id, element); |
| 292 } | 285 } |
| 293 | 286 |
| 294 return (!resources || !resources->hasResourceData()) ? nullptr | 287 return (!resources || !resources->hasResourceData()) ? nullptr |
| 295 : std::move(resources); | 288 : std::move(resources); |
| 296 } | 289 } |
| 297 | 290 |
| 298 void SVGResources::layoutIfNeeded() { | 291 void SVGResources::layoutIfNeeded() { |
| 299 if (m_clipperFilterMaskerData) { | 292 if (m_clipperFilterMaskerData) { |
| 300 if (LayoutSVGResourceClipper* clipper = m_clipperFilterMaskerData->clipper) | 293 if (LayoutSVGResourceClipper* clipper = m_clipperFilterMaskerData->clipper) |
| 301 clipper->layoutIfNeeded(); | 294 clipper->layoutIfNeeded(); |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 678 stroke->element()); | 671 stroke->element()); |
| 679 } | 672 } |
| 680 | 673 |
| 681 if (m_linkedResource) | 674 if (m_linkedResource) |
| 682 fprintf(stderr, " |-> xlink:href : %p (node=%p)\n", m_linkedResource, | 675 fprintf(stderr, " |-> xlink:href : %p (node=%p)\n", m_linkedResource, |
| 683 m_linkedResource->element()); | 676 m_linkedResource->element()); |
| 684 } | 677 } |
| 685 #endif | 678 #endif |
| 686 | 679 |
| 687 } // namespace blink | 680 } // namespace blink |
| OLD | NEW |