Chromium Code Reviews| 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 <memory> | |
| 22 #include "core/SVGNames.h" | 23 #include "core/SVGNames.h" |
| 23 #include "core/layout/svg/LayoutSVGResourceClipper.h" | 24 #include "core/layout/svg/LayoutSVGResourceClipper.h" |
| 24 #include "core/layout/svg/LayoutSVGResourceFilter.h" | 25 #include "core/layout/svg/LayoutSVGResourceFilter.h" |
| 25 #include "core/layout/svg/LayoutSVGResourceMarker.h" | 26 #include "core/layout/svg/LayoutSVGResourceMarker.h" |
| 26 #include "core/layout/svg/LayoutSVGResourceMasker.h" | 27 #include "core/layout/svg/LayoutSVGResourceMasker.h" |
| 27 #include "core/layout/svg/LayoutSVGResourcePaintServer.h" | 28 #include "core/layout/svg/LayoutSVGResourcePaintServer.h" |
| 28 #include "core/style/ComputedStyle.h" | 29 #include "core/style/ComputedStyle.h" |
| 29 #include "core/svg/SVGGradientElement.h" | 30 #include "core/svg/SVGGradientElement.h" |
| 30 #include "core/svg/SVGPatternElement.h" | 31 #include "core/svg/SVGPatternElement.h" |
| 32 #include "core/svg/SVGTreeScopeResources.h" | |
| 31 #include "core/svg/SVGURIReference.h" | 33 #include "core/svg/SVGURIReference.h" |
| 32 #include "wtf/PtrUtil.h" | 34 #include "wtf/PtrUtil.h" |
| 33 #include <memory> | |
| 34 | 35 |
| 35 #ifndef NDEBUG | 36 #ifndef NDEBUG |
| 36 #include <stdio.h> | 37 #include <stdio.h> |
| 37 #endif | 38 #endif |
| 38 | 39 |
| 39 namespace blink { | 40 namespace blink { |
| 40 | 41 |
| 41 using namespace SVGNames; | 42 using namespace SVGNames; |
| 42 | 43 |
| 43 SVGResources::SVGResources() : m_linkedResource(nullptr) {} | 44 SVGResources::SVGResources() : m_linkedResource(nullptr) {} |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 126 case SVG_PAINTTYPE_URI_CURRENTCOLOR: | 127 case SVG_PAINTTYPE_URI_CURRENTCOLOR: |
| 127 case SVG_PAINTTYPE_URI_RGBCOLOR: | 128 case SVG_PAINTTYPE_URI_RGBCOLOR: |
| 128 case SVG_PAINTTYPE_URI: | 129 case SVG_PAINTTYPE_URI: |
| 129 return true; | 130 return true; |
| 130 default: | 131 default: |
| 131 break; | 132 break; |
| 132 } | 133 } |
| 133 return false; | 134 return false; |
| 134 } | 135 } |
| 135 | 136 |
| 136 static inline LayoutSVGResourcePaintServer* paintingResourceFromSVGPaint( | 137 namespace { |
| 137 TreeScope& treeScope, | 138 |
| 138 const String& paintUri, | 139 template <typename ContainerType> |
| 139 AtomicString& id) { | 140 bool isResourceOfType(LayoutSVGResourceContainer* container) { |
| 140 id = SVGURIReference::fragmentIdentifierFromIRIString(paintUri, treeScope); | 141 return container->resourceType() == ContainerType::s_resourceType; |
| 141 LayoutSVGResourceContainer* container = | 142 } |
| 142 treeScope.ensureSVGTreeScopedResources().resourceById(id); | 143 |
| 143 if (!container || !container->isSVGPaintServer()) | 144 template <> |
| 144 return nullptr; | 145 bool isResourceOfType<LayoutSVGResourcePaintServer>( |
|
pdr.
2017/03/24 16:46:34
The LayoutSVGResourcePaintServer and LayoutSVGReso
fs
2017/03/24 19:26:54
We should (be able to) get rid of the latter by re
| |
| 145 return toLayoutSVGResourcePaintServer(container); | 146 LayoutSVGResourceContainer* container) { |
| 147 return container->isSVGPaintServer(); | |
| 148 } | |
| 149 | |
| 150 template <> | |
| 151 bool isResourceOfType<LayoutSVGResourceContainer>( | |
| 152 LayoutSVGResourceContainer* container) { | |
| 153 return true; | |
| 154 } | |
| 155 | |
| 156 template <typename ContainerType> | |
| 157 ContainerType* attachToResource(SVGTreeScopeResources& treeScopeResources, | |
| 158 const AtomicString& id, | |
| 159 SVGElement& element) { | |
| 160 if (LayoutSVGResourceContainer* container = | |
| 161 treeScopeResources.resourceById(id)) { | |
| 162 if (isResourceOfType<ContainerType>(container)) | |
| 163 return static_cast<ContainerType*>(container); | |
| 164 } | |
| 165 treeScopeResources.addPendingResource(id, element); | |
| 166 return nullptr; | |
| 167 } | |
| 146 } | 168 } |
| 147 | 169 |
| 148 bool SVGResources::hasResourceData() const { | 170 bool SVGResources::hasResourceData() const { |
| 149 return m_clipperFilterMaskerData || m_markerData || m_fillStrokeData || | 171 return m_clipperFilterMaskerData || m_markerData || m_fillStrokeData || |
| 150 m_linkedResource; | 172 m_linkedResource; |
| 151 } | 173 } |
| 152 | 174 |
| 153 static inline SVGResources& ensureResources( | 175 static inline SVGResources& ensureResources( |
| 154 std::unique_ptr<SVGResources>& resources) { | 176 std::unique_ptr<SVGResources>& resources) { |
| 155 if (!resources) | 177 if (!resources) |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 180 | 202 |
| 181 std::unique_ptr<SVGResources> resources; | 203 std::unique_ptr<SVGResources> resources; |
| 182 if (clipperFilterMaskerTags().contains(tagName)) { | 204 if (clipperFilterMaskerTags().contains(tagName)) { |
| 183 if (computedStyle.clipPath() && !object->isSVGRoot()) { | 205 if (computedStyle.clipPath() && !object->isSVGRoot()) { |
| 184 ClipPathOperation* clipPathOperation = computedStyle.clipPath(); | 206 ClipPathOperation* clipPathOperation = computedStyle.clipPath(); |
| 185 if (clipPathOperation->type() == ClipPathOperation::REFERENCE) { | 207 if (clipPathOperation->type() == ClipPathOperation::REFERENCE) { |
| 186 const ReferenceClipPathOperation& clipPathReference = | 208 const ReferenceClipPathOperation& clipPathReference = |
| 187 toReferenceClipPathOperation(*clipPathOperation); | 209 toReferenceClipPathOperation(*clipPathOperation); |
| 188 AtomicString id = SVGURIReference::fragmentIdentifierFromIRIString( | 210 AtomicString id = SVGURIReference::fragmentIdentifierFromIRIString( |
| 189 clipPathReference.url(), treeScope); | 211 clipPathReference.url(), treeScope); |
| 190 if (!ensureResources(resources).setClipper( | 212 ensureResources(resources).setClipper( |
| 191 getLayoutSVGResourceById<LayoutSVGResourceClipper>( | 213 attachToResource<LayoutSVGResourceClipper>(treeScopeResources, id, |
| 192 treeScopeResources, id))) | 214 element)); |
| 193 treeScopeResources.addPendingResource(id, element); | |
| 194 } | 215 } |
| 195 } | 216 } |
| 196 | 217 |
| 197 if (computedStyle.hasFilter() && !object->isSVGRoot()) { | 218 if (computedStyle.hasFilter() && !object->isSVGRoot()) { |
| 198 const FilterOperations& filterOperations = computedStyle.filter(); | 219 const FilterOperations& filterOperations = computedStyle.filter(); |
| 199 if (filterOperations.size() == 1) { | 220 if (filterOperations.size() == 1) { |
| 200 const FilterOperation& filterOperation = *filterOperations.at(0); | 221 const FilterOperation& filterOperation = *filterOperations.at(0); |
| 201 if (filterOperation.type() == FilterOperation::REFERENCE) { | 222 if (filterOperation.type() == FilterOperation::REFERENCE) { |
| 202 const auto& referenceFilterOperation = | 223 const auto& referenceFilterOperation = |
| 203 toReferenceFilterOperation(filterOperation); | 224 toReferenceFilterOperation(filterOperation); |
| 204 AtomicString id = SVGURIReference::fragmentIdentifierFromIRIString( | 225 AtomicString id = SVGURIReference::fragmentIdentifierFromIRIString( |
| 205 referenceFilterOperation.url(), treeScope); | 226 referenceFilterOperation.url(), treeScope); |
| 206 if (!ensureResources(resources).setFilter( | 227 ensureResources(resources).setFilter( |
| 207 getLayoutSVGResourceById<LayoutSVGResourceFilter>( | 228 attachToResource<LayoutSVGResourceFilter>(treeScopeResources, id, |
| 208 treeScopeResources, id))) | 229 element)); |
| 209 treeScopeResources.addPendingResource(id, element); | |
| 210 } | 230 } |
| 211 } | 231 } |
| 212 } | 232 } |
| 213 | 233 |
| 214 if (style.hasMasker()) { | 234 if (style.hasMasker()) { |
| 215 AtomicString id = style.maskerResource(); | 235 ensureResources(resources).setMasker( |
| 216 if (!ensureResources(resources).setMasker( | 236 attachToResource<LayoutSVGResourceMasker>( |
| 217 getLayoutSVGResourceById<LayoutSVGResourceMasker>( | 237 treeScopeResources, style.maskerResource(), element)); |
| 218 treeScopeResources, id))) | |
| 219 treeScopeResources.addPendingResource(id, element); | |
| 220 } | 238 } |
| 221 } | 239 } |
| 222 | 240 |
| 223 if (style.hasMarkers() && supportsMarkers(element)) { | 241 if (style.hasMarkers() && supportsMarkers(element)) { |
| 224 const AtomicString& markerStartId = style.markerStartResource(); | 242 ensureResources(resources).setMarkerStart( |
| 225 if (!ensureResources(resources).setMarkerStart( | 243 attachToResource<LayoutSVGResourceMarker>( |
| 226 getLayoutSVGResourceById<LayoutSVGResourceMarker>( | 244 treeScopeResources, style.markerStartResource(), element)); |
| 227 treeScopeResources, markerStartId))) | 245 ensureResources(resources).setMarkerMid( |
| 228 treeScopeResources.addPendingResource(markerStartId, element); | 246 attachToResource<LayoutSVGResourceMarker>( |
| 229 | 247 treeScopeResources, style.markerMidResource(), element)); |
| 230 const AtomicString& markerMidId = style.markerMidResource(); | 248 ensureResources(resources).setMarkerEnd( |
| 231 if (!ensureResources(resources).setMarkerMid( | 249 attachToResource<LayoutSVGResourceMarker>( |
| 232 getLayoutSVGResourceById<LayoutSVGResourceMarker>( | 250 treeScopeResources, style.markerEndResource(), element)); |
| 233 treeScopeResources, markerMidId))) | |
| 234 treeScopeResources.addPendingResource(markerMidId, element); | |
| 235 | |
| 236 const AtomicString& markerEndId = style.markerEndResource(); | |
| 237 if (!ensureResources(resources).setMarkerEnd( | |
| 238 getLayoutSVGResourceById<LayoutSVGResourceMarker>( | |
| 239 treeScopeResources, markerEndId))) | |
| 240 treeScopeResources.addPendingResource(markerEndId, element); | |
| 241 } | 251 } |
| 242 | 252 |
| 243 if (fillAndStrokeTags().contains(tagName)) { | 253 if (fillAndStrokeTags().contains(tagName)) { |
| 244 if (style.hasFill() && svgPaintTypeHasURL(style.fillPaintType())) { | 254 if (style.hasFill() && svgPaintTypeHasURL(style.fillPaintType())) { |
| 245 AtomicString id; | 255 AtomicString id = SVGURIReference::fragmentIdentifierFromIRIString( |
| 246 LayoutSVGResourcePaintServer* resource = | 256 style.fillPaintUri(), treeScope); |
| 247 paintingResourceFromSVGPaint(treeScope, style.fillPaintUri(), id); | 257 ensureResources(resources).setFill( |
| 248 if (!ensureResources(resources).setFill(resource)) | 258 attachToResource<LayoutSVGResourcePaintServer>(treeScopeResources, id, |
| 249 treeScopeResources.addPendingResource(id, element); | 259 element)); |
| 250 } | 260 } |
| 251 | 261 |
| 252 if (style.hasStroke() && svgPaintTypeHasURL(style.strokePaintType())) { | 262 if (style.hasStroke() && svgPaintTypeHasURL(style.strokePaintType())) { |
| 253 AtomicString id; | 263 AtomicString id = SVGURIReference::fragmentIdentifierFromIRIString( |
| 254 LayoutSVGResourcePaintServer* resource = | 264 style.strokePaintUri(), treeScope); |
| 255 paintingResourceFromSVGPaint(treeScope, style.strokePaintUri(), id); | 265 ensureResources(resources).setStroke( |
| 256 if (!ensureResources(resources).setStroke(resource)) | 266 attachToResource<LayoutSVGResourcePaintServer>(treeScopeResources, id, |
| 257 treeScopeResources.addPendingResource(id, element); | 267 element)); |
| 258 } | 268 } |
| 259 } | 269 } |
| 260 | 270 |
| 261 if (chainableResourceTags().contains(tagName)) { | 271 if (chainableResourceTags().contains(tagName)) { |
| 262 AtomicString id = targetReferenceFromResource(element); | 272 AtomicString id = targetReferenceFromResource(element); |
| 263 if (!ensureResources(resources).setLinkedResource( | 273 ensureResources(resources).setLinkedResource( |
| 264 treeScopeResources.resourceById(id))) | 274 attachToResource<LayoutSVGResourceContainer>(treeScopeResources, id, |
| 265 treeScopeResources.addPendingResource(id, element); | 275 element)); |
| 266 } | 276 } |
| 267 | 277 |
| 268 return (!resources || !resources->hasResourceData()) ? nullptr | 278 return (!resources || !resources->hasResourceData()) ? nullptr |
| 269 : std::move(resources); | 279 : std::move(resources); |
| 270 } | 280 } |
| 271 | 281 |
| 272 void SVGResources::layoutIfNeeded() { | 282 void SVGResources::layoutIfNeeded() { |
| 273 if (m_clipperFilterMaskerData) { | 283 if (m_clipperFilterMaskerData) { |
| 274 if (LayoutSVGResourceClipper* clipper = m_clipperFilterMaskerData->clipper) | 284 if (LayoutSVGResourceClipper* clipper = m_clipperFilterMaskerData->clipper) |
| 275 clipper->layoutIfNeeded(); | 285 clipper->layoutIfNeeded(); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 439 } | 449 } |
| 440 | 450 |
| 441 if (m_fillStrokeData) { | 451 if (m_fillStrokeData) { |
| 442 if (m_fillStrokeData->fill) | 452 if (m_fillStrokeData->fill) |
| 443 set.insert(m_fillStrokeData->fill); | 453 set.insert(m_fillStrokeData->fill); |
| 444 if (m_fillStrokeData->stroke) | 454 if (m_fillStrokeData->stroke) |
| 445 set.insert(m_fillStrokeData->stroke); | 455 set.insert(m_fillStrokeData->stroke); |
| 446 } | 456 } |
| 447 } | 457 } |
| 448 | 458 |
| 449 bool SVGResources::setClipper(LayoutSVGResourceClipper* clipper) { | 459 void SVGResources::setClipper(LayoutSVGResourceClipper* clipper) { |
| 450 if (!clipper) | 460 if (!clipper) |
| 451 return false; | 461 return; |
| 452 | 462 |
| 453 ASSERT(clipper->resourceType() == ClipperResourceType); | 463 ASSERT(clipper->resourceType() == ClipperResourceType); |
| 454 | 464 |
| 455 if (!m_clipperFilterMaskerData) | 465 if (!m_clipperFilterMaskerData) |
| 456 m_clipperFilterMaskerData = ClipperFilterMaskerData::create(); | 466 m_clipperFilterMaskerData = ClipperFilterMaskerData::create(); |
| 457 | 467 |
| 458 m_clipperFilterMaskerData->clipper = clipper; | 468 m_clipperFilterMaskerData->clipper = clipper; |
| 459 return true; | |
| 460 } | 469 } |
| 461 | 470 |
| 462 void SVGResources::resetClipper() { | 471 void SVGResources::resetClipper() { |
| 463 ASSERT(m_clipperFilterMaskerData); | 472 ASSERT(m_clipperFilterMaskerData); |
| 464 ASSERT(m_clipperFilterMaskerData->clipper); | 473 ASSERT(m_clipperFilterMaskerData->clipper); |
| 465 m_clipperFilterMaskerData->clipper = nullptr; | 474 m_clipperFilterMaskerData->clipper = nullptr; |
| 466 } | 475 } |
| 467 | 476 |
| 468 bool SVGResources::setFilter(LayoutSVGResourceFilter* filter) { | 477 void SVGResources::setFilter(LayoutSVGResourceFilter* filter) { |
| 469 if (!filter) | 478 if (!filter) |
| 470 return false; | 479 return; |
| 471 | 480 |
| 472 ASSERT(filter->resourceType() == FilterResourceType); | 481 ASSERT(filter->resourceType() == FilterResourceType); |
| 473 | 482 |
| 474 if (!m_clipperFilterMaskerData) | 483 if (!m_clipperFilterMaskerData) |
| 475 m_clipperFilterMaskerData = ClipperFilterMaskerData::create(); | 484 m_clipperFilterMaskerData = ClipperFilterMaskerData::create(); |
| 476 | 485 |
| 477 m_clipperFilterMaskerData->filter = filter; | 486 m_clipperFilterMaskerData->filter = filter; |
| 478 return true; | |
| 479 } | 487 } |
| 480 | 488 |
| 481 void SVGResources::resetFilter() { | 489 void SVGResources::resetFilter() { |
| 482 ASSERT(m_clipperFilterMaskerData); | 490 ASSERT(m_clipperFilterMaskerData); |
| 483 ASSERT(m_clipperFilterMaskerData->filter); | 491 ASSERT(m_clipperFilterMaskerData->filter); |
| 484 m_clipperFilterMaskerData->filter = nullptr; | 492 m_clipperFilterMaskerData->filter = nullptr; |
| 485 } | 493 } |
| 486 | 494 |
| 487 bool SVGResources::setMarkerStart(LayoutSVGResourceMarker* markerStart) { | 495 void SVGResources::setMarkerStart(LayoutSVGResourceMarker* markerStart) { |
| 488 if (!markerStart) | 496 if (!markerStart) |
| 489 return false; | 497 return; |
| 490 | 498 |
| 491 ASSERT(markerStart->resourceType() == MarkerResourceType); | 499 ASSERT(markerStart->resourceType() == MarkerResourceType); |
| 492 | 500 |
| 493 if (!m_markerData) | 501 if (!m_markerData) |
| 494 m_markerData = MarkerData::create(); | 502 m_markerData = MarkerData::create(); |
| 495 | 503 |
| 496 m_markerData->markerStart = markerStart; | 504 m_markerData->markerStart = markerStart; |
| 497 return true; | |
| 498 } | 505 } |
| 499 | 506 |
| 500 void SVGResources::resetMarkerStart() { | 507 void SVGResources::resetMarkerStart() { |
| 501 ASSERT(m_markerData); | 508 ASSERT(m_markerData); |
| 502 ASSERT(m_markerData->markerStart); | 509 ASSERT(m_markerData->markerStart); |
| 503 m_markerData->markerStart = nullptr; | 510 m_markerData->markerStart = nullptr; |
| 504 } | 511 } |
| 505 | 512 |
| 506 bool SVGResources::setMarkerMid(LayoutSVGResourceMarker* markerMid) { | 513 void SVGResources::setMarkerMid(LayoutSVGResourceMarker* markerMid) { |
| 507 if (!markerMid) | 514 if (!markerMid) |
| 508 return false; | 515 return; |
| 509 | 516 |
| 510 ASSERT(markerMid->resourceType() == MarkerResourceType); | 517 ASSERT(markerMid->resourceType() == MarkerResourceType); |
| 511 | 518 |
| 512 if (!m_markerData) | 519 if (!m_markerData) |
| 513 m_markerData = MarkerData::create(); | 520 m_markerData = MarkerData::create(); |
| 514 | 521 |
| 515 m_markerData->markerMid = markerMid; | 522 m_markerData->markerMid = markerMid; |
| 516 return true; | |
| 517 } | 523 } |
| 518 | 524 |
| 519 void SVGResources::resetMarkerMid() { | 525 void SVGResources::resetMarkerMid() { |
| 520 ASSERT(m_markerData); | 526 ASSERT(m_markerData); |
| 521 ASSERT(m_markerData->markerMid); | 527 ASSERT(m_markerData->markerMid); |
| 522 m_markerData->markerMid = nullptr; | 528 m_markerData->markerMid = nullptr; |
| 523 } | 529 } |
| 524 | 530 |
| 525 bool SVGResources::setMarkerEnd(LayoutSVGResourceMarker* markerEnd) { | 531 void SVGResources::setMarkerEnd(LayoutSVGResourceMarker* markerEnd) { |
| 526 if (!markerEnd) | 532 if (!markerEnd) |
| 527 return false; | 533 return; |
| 528 | 534 |
| 529 ASSERT(markerEnd->resourceType() == MarkerResourceType); | 535 ASSERT(markerEnd->resourceType() == MarkerResourceType); |
| 530 | 536 |
| 531 if (!m_markerData) | 537 if (!m_markerData) |
| 532 m_markerData = MarkerData::create(); | 538 m_markerData = MarkerData::create(); |
| 533 | 539 |
| 534 m_markerData->markerEnd = markerEnd; | 540 m_markerData->markerEnd = markerEnd; |
| 535 return true; | |
| 536 } | 541 } |
| 537 | 542 |
| 538 void SVGResources::resetMarkerEnd() { | 543 void SVGResources::resetMarkerEnd() { |
| 539 ASSERT(m_markerData); | 544 ASSERT(m_markerData); |
| 540 ASSERT(m_markerData->markerEnd); | 545 ASSERT(m_markerData->markerEnd); |
| 541 m_markerData->markerEnd = nullptr; | 546 m_markerData->markerEnd = nullptr; |
| 542 } | 547 } |
| 543 | 548 |
| 544 bool SVGResources::setMasker(LayoutSVGResourceMasker* masker) { | 549 void SVGResources::setMasker(LayoutSVGResourceMasker* masker) { |
| 545 if (!masker) | 550 if (!masker) |
| 546 return false; | 551 return; |
| 547 | 552 |
| 548 ASSERT(masker->resourceType() == MaskerResourceType); | 553 ASSERT(masker->resourceType() == MaskerResourceType); |
| 549 | 554 |
| 550 if (!m_clipperFilterMaskerData) | 555 if (!m_clipperFilterMaskerData) |
| 551 m_clipperFilterMaskerData = ClipperFilterMaskerData::create(); | 556 m_clipperFilterMaskerData = ClipperFilterMaskerData::create(); |
| 552 | 557 |
| 553 m_clipperFilterMaskerData->masker = masker; | 558 m_clipperFilterMaskerData->masker = masker; |
| 554 return true; | |
| 555 } | 559 } |
| 556 | 560 |
| 557 void SVGResources::resetMasker() { | 561 void SVGResources::resetMasker() { |
| 558 ASSERT(m_clipperFilterMaskerData); | 562 ASSERT(m_clipperFilterMaskerData); |
| 559 ASSERT(m_clipperFilterMaskerData->masker); | 563 ASSERT(m_clipperFilterMaskerData->masker); |
| 560 m_clipperFilterMaskerData->masker = nullptr; | 564 m_clipperFilterMaskerData->masker = nullptr; |
| 561 } | 565 } |
| 562 | 566 |
| 563 bool SVGResources::setFill(LayoutSVGResourcePaintServer* fill) { | 567 void SVGResources::setFill(LayoutSVGResourcePaintServer* fill) { |
| 564 if (!fill) | 568 if (!fill) |
| 565 return false; | 569 return; |
| 566 | 570 |
| 567 if (!m_fillStrokeData) | 571 if (!m_fillStrokeData) |
| 568 m_fillStrokeData = FillStrokeData::create(); | 572 m_fillStrokeData = FillStrokeData::create(); |
| 569 | 573 |
| 570 m_fillStrokeData->fill = fill; | 574 m_fillStrokeData->fill = fill; |
| 571 return true; | |
| 572 } | 575 } |
| 573 | 576 |
| 574 void SVGResources::resetFill() { | 577 void SVGResources::resetFill() { |
| 575 ASSERT(m_fillStrokeData); | 578 ASSERT(m_fillStrokeData); |
| 576 ASSERT(m_fillStrokeData->fill); | 579 ASSERT(m_fillStrokeData->fill); |
| 577 m_fillStrokeData->fill = nullptr; | 580 m_fillStrokeData->fill = nullptr; |
| 578 } | 581 } |
| 579 | 582 |
| 580 bool SVGResources::setStroke(LayoutSVGResourcePaintServer* stroke) { | 583 void SVGResources::setStroke(LayoutSVGResourcePaintServer* stroke) { |
| 581 if (!stroke) | 584 if (!stroke) |
| 582 return false; | 585 return; |
| 583 | 586 |
| 584 if (!m_fillStrokeData) | 587 if (!m_fillStrokeData) |
| 585 m_fillStrokeData = FillStrokeData::create(); | 588 m_fillStrokeData = FillStrokeData::create(); |
| 586 | 589 |
| 587 m_fillStrokeData->stroke = stroke; | 590 m_fillStrokeData->stroke = stroke; |
| 588 return true; | |
| 589 } | 591 } |
| 590 | 592 |
| 591 void SVGResources::resetStroke() { | 593 void SVGResources::resetStroke() { |
| 592 ASSERT(m_fillStrokeData); | 594 ASSERT(m_fillStrokeData); |
| 593 ASSERT(m_fillStrokeData->stroke); | 595 ASSERT(m_fillStrokeData->stroke); |
| 594 m_fillStrokeData->stroke = nullptr; | 596 m_fillStrokeData->stroke = nullptr; |
| 595 } | 597 } |
| 596 | 598 |
| 597 bool SVGResources::setLinkedResource( | 599 void SVGResources::setLinkedResource( |
| 598 LayoutSVGResourceContainer* linkedResource) { | 600 LayoutSVGResourceContainer* linkedResource) { |
| 599 if (!linkedResource) | 601 if (!linkedResource) |
| 600 return false; | 602 return; |
| 601 | 603 |
| 602 m_linkedResource = linkedResource; | 604 m_linkedResource = linkedResource; |
| 603 return true; | |
| 604 } | 605 } |
| 605 | 606 |
| 606 void SVGResources::resetLinkedResource() { | 607 void SVGResources::resetLinkedResource() { |
| 607 ASSERT(m_linkedResource); | 608 ASSERT(m_linkedResource); |
| 608 m_linkedResource = nullptr; | 609 m_linkedResource = nullptr; |
| 609 } | 610 } |
| 610 | 611 |
| 611 #ifndef NDEBUG | 612 #ifndef NDEBUG |
| 612 void SVGResources::dump(const LayoutObject* object) { | 613 void SVGResources::dump(const LayoutObject* object) { |
| 613 ASSERT(object); | 614 ASSERT(object); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 652 stroke->element()); | 653 stroke->element()); |
| 653 } | 654 } |
| 654 | 655 |
| 655 if (m_linkedResource) | 656 if (m_linkedResource) |
| 656 fprintf(stderr, " |-> xlink:href : %p (node=%p)\n", m_linkedResource, | 657 fprintf(stderr, " |-> xlink:href : %p (node=%p)\n", m_linkedResource, |
| 657 m_linkedResource->element()); | 658 m_linkedResource->element()); |
| 658 } | 659 } |
| 659 #endif | 660 #endif |
| 660 | 661 |
| 661 } // namespace blink | 662 } // namespace blink |
| OLD | NEW |