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