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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 std::unique_ptr<SVGResources>& resources) { | 176 std::unique_ptr<SVGResources>& resources) { |
177 if (!resources) | 177 if (!resources) |
178 resources = WTF::wrapUnique(new SVGResources); | 178 resources = WTF::wrapUnique(new SVGResources); |
179 | 179 |
180 return *resources.get(); | 180 return *resources.get(); |
181 } | 181 } |
182 | 182 |
183 std::unique_ptr<SVGResources> SVGResources::buildResources( | 183 std::unique_ptr<SVGResources> SVGResources::buildResources( |
184 const LayoutObject* object, | 184 const LayoutObject* object, |
185 const ComputedStyle& computedStyle) { | 185 const ComputedStyle& computedStyle) { |
186 ASSERT(object); | 186 DCHECK(object); |
187 | 187 |
188 Node* node = object->node(); | 188 Node* node = object->node(); |
189 ASSERT(node); | 189 DCHECK(node); |
190 SECURITY_DCHECK(node->isSVGElement()); | 190 SECURITY_DCHECK(node->isSVGElement()); |
191 | 191 |
192 SVGElement& element = toSVGElement(*node); | 192 SVGElement& element = toSVGElement(*node); |
193 | 193 |
194 const AtomicString& tagName = element.localName(); | 194 const AtomicString& tagName = element.localName(); |
195 ASSERT(!tagName.isNull()); | 195 DCHECK(!tagName.isNull()); |
196 | 196 |
197 TreeScope& treeScope = element.treeScopeForIdResolution(); | 197 TreeScope& treeScope = element.treeScopeForIdResolution(); |
198 SVGTreeScopeResources& treeScopeResources = | 198 SVGTreeScopeResources& treeScopeResources = |
199 treeScope.ensureSVGTreeScopedResources(); | 199 treeScope.ensureSVGTreeScopedResources(); |
200 | 200 |
201 const SVGComputedStyle& style = computedStyle.svgStyle(); | 201 const SVGComputedStyle& style = computedStyle.svgStyle(); |
202 | 202 |
203 std::unique_ptr<SVGResources> resources; | 203 std::unique_ptr<SVGResources> resources; |
204 if (clipperFilterMaskerTags().contains(tagName)) { | 204 if (clipperFilterMaskerTags().contains(tagName)) { |
205 if (computedStyle.clipPath() && !object->isSVGRoot()) { | 205 if (computedStyle.clipPath() && !object->isSVGRoot()) { |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 if (LayoutSVGResourceMasker* masker = m_clipperFilterMaskerData->masker) | 321 if (LayoutSVGResourceMasker* masker = m_clipperFilterMaskerData->masker) |
322 masker->removeClientFromCache(object, markForInvalidation); | 322 masker->removeClientFromCache(object, markForInvalidation); |
323 } | 323 } |
324 | 324 |
325 void SVGResources::removeClientFromCache(LayoutObject* object, | 325 void SVGResources::removeClientFromCache(LayoutObject* object, |
326 bool markForInvalidation) const { | 326 bool markForInvalidation) const { |
327 if (!hasResourceData()) | 327 if (!hasResourceData()) |
328 return; | 328 return; |
329 | 329 |
330 if (m_linkedResource) { | 330 if (m_linkedResource) { |
331 ASSERT(!m_clipperFilterMaskerData); | 331 DCHECK(!m_clipperFilterMaskerData); |
332 ASSERT(!m_markerData); | 332 DCHECK(!m_markerData); |
333 ASSERT(!m_fillStrokeData); | 333 DCHECK(!m_fillStrokeData); |
334 m_linkedResource->removeClientFromCache(object, markForInvalidation); | 334 m_linkedResource->removeClientFromCache(object, markForInvalidation); |
335 return; | 335 return; |
336 } | 336 } |
337 | 337 |
338 removeClientFromCacheAffectingObjectBounds(object, markForInvalidation); | 338 removeClientFromCacheAffectingObjectBounds(object, markForInvalidation); |
339 | 339 |
340 if (m_markerData) { | 340 if (m_markerData) { |
341 if (m_markerData->markerStart) | 341 if (m_markerData->markerStart) |
342 m_markerData->markerStart->removeClientFromCache(object, | 342 m_markerData->markerStart->removeClientFromCache(object, |
343 markForInvalidation); | 343 markForInvalidation); |
344 if (m_markerData->markerMid) | 344 if (m_markerData->markerMid) |
345 m_markerData->markerMid->removeClientFromCache(object, | 345 m_markerData->markerMid->removeClientFromCache(object, |
346 markForInvalidation); | 346 markForInvalidation); |
347 if (m_markerData->markerEnd) | 347 if (m_markerData->markerEnd) |
348 m_markerData->markerEnd->removeClientFromCache(object, | 348 m_markerData->markerEnd->removeClientFromCache(object, |
349 markForInvalidation); | 349 markForInvalidation); |
350 } | 350 } |
351 | 351 |
352 if (m_fillStrokeData) { | 352 if (m_fillStrokeData) { |
353 if (m_fillStrokeData->fill) | 353 if (m_fillStrokeData->fill) |
354 m_fillStrokeData->fill->removeClientFromCache(object, | 354 m_fillStrokeData->fill->removeClientFromCache(object, |
355 markForInvalidation); | 355 markForInvalidation); |
356 if (m_fillStrokeData->stroke) | 356 if (m_fillStrokeData->stroke) |
357 m_fillStrokeData->stroke->removeClientFromCache(object, | 357 m_fillStrokeData->stroke->removeClientFromCache(object, |
358 markForInvalidation); | 358 markForInvalidation); |
359 } | 359 } |
360 } | 360 } |
361 | 361 |
362 void SVGResources::resourceDestroyed(LayoutSVGResourceContainer* resource) { | 362 void SVGResources::resourceDestroyed(LayoutSVGResourceContainer* resource) { |
363 ASSERT(resource); | 363 DCHECK(resource); |
364 if (!hasResourceData()) | 364 if (!hasResourceData()) |
365 return; | 365 return; |
366 | 366 |
367 if (m_linkedResource == resource) { | 367 if (m_linkedResource == resource) { |
368 ASSERT(!m_clipperFilterMaskerData); | 368 DCHECK(!m_clipperFilterMaskerData); |
369 ASSERT(!m_markerData); | 369 DCHECK(!m_markerData); |
370 ASSERT(!m_fillStrokeData); | 370 DCHECK(!m_fillStrokeData); |
371 m_linkedResource->removeAllClientsFromCache(); | 371 m_linkedResource->removeAllClientsFromCache(); |
372 m_linkedResource = nullptr; | 372 m_linkedResource = nullptr; |
373 return; | 373 return; |
374 } | 374 } |
375 | 375 |
376 switch (resource->resourceType()) { | 376 switch (resource->resourceType()) { |
377 case MaskerResourceType: | 377 case MaskerResourceType: |
378 if (!m_clipperFilterMaskerData) | 378 if (!m_clipperFilterMaskerData) |
379 break; | 379 break; |
380 if (m_clipperFilterMaskerData->masker == resource) | 380 if (m_clipperFilterMaskerData->masker == resource) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 NOTREACHED(); | 416 NOTREACHED(); |
417 } | 417 } |
418 } | 418 } |
419 | 419 |
420 void SVGResources::buildSetOfResources( | 420 void SVGResources::buildSetOfResources( |
421 HashSet<LayoutSVGResourceContainer*>& set) { | 421 HashSet<LayoutSVGResourceContainer*>& set) { |
422 if (!hasResourceData()) | 422 if (!hasResourceData()) |
423 return; | 423 return; |
424 | 424 |
425 if (m_linkedResource) { | 425 if (m_linkedResource) { |
426 ASSERT(!m_clipperFilterMaskerData); | 426 DCHECK(!m_clipperFilterMaskerData); |
427 ASSERT(!m_markerData); | 427 DCHECK(!m_markerData); |
428 ASSERT(!m_fillStrokeData); | 428 DCHECK(!m_fillStrokeData); |
429 set.insert(m_linkedResource); | 429 set.insert(m_linkedResource); |
430 return; | 430 return; |
431 } | 431 } |
432 | 432 |
433 if (m_clipperFilterMaskerData) { | 433 if (m_clipperFilterMaskerData) { |
434 if (m_clipperFilterMaskerData->clipper) | 434 if (m_clipperFilterMaskerData->clipper) |
435 set.insert(m_clipperFilterMaskerData->clipper); | 435 set.insert(m_clipperFilterMaskerData->clipper); |
436 if (m_clipperFilterMaskerData->filter) | 436 if (m_clipperFilterMaskerData->filter) |
437 set.insert(m_clipperFilterMaskerData->filter); | 437 set.insert(m_clipperFilterMaskerData->filter); |
438 if (m_clipperFilterMaskerData->masker) | 438 if (m_clipperFilterMaskerData->masker) |
(...skipping 14 matching lines...) Expand all Loading... |
453 set.insert(m_fillStrokeData->fill); | 453 set.insert(m_fillStrokeData->fill); |
454 if (m_fillStrokeData->stroke) | 454 if (m_fillStrokeData->stroke) |
455 set.insert(m_fillStrokeData->stroke); | 455 set.insert(m_fillStrokeData->stroke); |
456 } | 456 } |
457 } | 457 } |
458 | 458 |
459 void SVGResources::setClipper(LayoutSVGResourceClipper* clipper) { | 459 void SVGResources::setClipper(LayoutSVGResourceClipper* clipper) { |
460 if (!clipper) | 460 if (!clipper) |
461 return; | 461 return; |
462 | 462 |
463 ASSERT(clipper->resourceType() == ClipperResourceType); | 463 DCHECK_EQ(clipper->resourceType(), ClipperResourceType); |
464 | 464 |
465 if (!m_clipperFilterMaskerData) | 465 if (!m_clipperFilterMaskerData) |
466 m_clipperFilterMaskerData = ClipperFilterMaskerData::create(); | 466 m_clipperFilterMaskerData = ClipperFilterMaskerData::create(); |
467 | 467 |
468 m_clipperFilterMaskerData->clipper = clipper; | 468 m_clipperFilterMaskerData->clipper = clipper; |
469 } | 469 } |
470 | 470 |
471 void SVGResources::resetClipper() { | 471 void SVGResources::resetClipper() { |
472 ASSERT(m_clipperFilterMaskerData); | 472 DCHECK(m_clipperFilterMaskerData); |
473 ASSERT(m_clipperFilterMaskerData->clipper); | 473 DCHECK(m_clipperFilterMaskerData->clipper); |
474 m_clipperFilterMaskerData->clipper = nullptr; | 474 m_clipperFilterMaskerData->clipper = nullptr; |
475 } | 475 } |
476 | 476 |
477 void SVGResources::setFilter(LayoutSVGResourceFilter* filter) { | 477 void SVGResources::setFilter(LayoutSVGResourceFilter* filter) { |
478 if (!filter) | 478 if (!filter) |
479 return; | 479 return; |
480 | 480 |
481 ASSERT(filter->resourceType() == FilterResourceType); | 481 DCHECK_EQ(filter->resourceType(), FilterResourceType); |
482 | 482 |
483 if (!m_clipperFilterMaskerData) | 483 if (!m_clipperFilterMaskerData) |
484 m_clipperFilterMaskerData = ClipperFilterMaskerData::create(); | 484 m_clipperFilterMaskerData = ClipperFilterMaskerData::create(); |
485 | 485 |
486 m_clipperFilterMaskerData->filter = filter; | 486 m_clipperFilterMaskerData->filter = filter; |
487 } | 487 } |
488 | 488 |
489 void SVGResources::resetFilter() { | 489 void SVGResources::resetFilter() { |
490 ASSERT(m_clipperFilterMaskerData); | 490 DCHECK(m_clipperFilterMaskerData); |
491 ASSERT(m_clipperFilterMaskerData->filter); | 491 DCHECK(m_clipperFilterMaskerData->filter); |
492 m_clipperFilterMaskerData->filter = nullptr; | 492 m_clipperFilterMaskerData->filter = nullptr; |
493 } | 493 } |
494 | 494 |
495 void SVGResources::setMarkerStart(LayoutSVGResourceMarker* markerStart) { | 495 void SVGResources::setMarkerStart(LayoutSVGResourceMarker* markerStart) { |
496 if (!markerStart) | 496 if (!markerStart) |
497 return; | 497 return; |
498 | 498 |
499 ASSERT(markerStart->resourceType() == MarkerResourceType); | 499 DCHECK_EQ(markerStart->resourceType(), MarkerResourceType); |
500 | 500 |
501 if (!m_markerData) | 501 if (!m_markerData) |
502 m_markerData = MarkerData::create(); | 502 m_markerData = MarkerData::create(); |
503 | 503 |
504 m_markerData->markerStart = markerStart; | 504 m_markerData->markerStart = markerStart; |
505 } | 505 } |
506 | 506 |
507 void SVGResources::resetMarkerStart() { | 507 void SVGResources::resetMarkerStart() { |
508 ASSERT(m_markerData); | 508 DCHECK(m_markerData); |
509 ASSERT(m_markerData->markerStart); | 509 DCHECK(m_markerData->markerStart); |
510 m_markerData->markerStart = nullptr; | 510 m_markerData->markerStart = nullptr; |
511 } | 511 } |
512 | 512 |
513 void SVGResources::setMarkerMid(LayoutSVGResourceMarker* markerMid) { | 513 void SVGResources::setMarkerMid(LayoutSVGResourceMarker* markerMid) { |
514 if (!markerMid) | 514 if (!markerMid) |
515 return; | 515 return; |
516 | 516 |
517 ASSERT(markerMid->resourceType() == MarkerResourceType); | 517 DCHECK_EQ(markerMid->resourceType(), MarkerResourceType); |
518 | 518 |
519 if (!m_markerData) | 519 if (!m_markerData) |
520 m_markerData = MarkerData::create(); | 520 m_markerData = MarkerData::create(); |
521 | 521 |
522 m_markerData->markerMid = markerMid; | 522 m_markerData->markerMid = markerMid; |
523 } | 523 } |
524 | 524 |
525 void SVGResources::resetMarkerMid() { | 525 void SVGResources::resetMarkerMid() { |
526 ASSERT(m_markerData); | 526 DCHECK(m_markerData); |
527 ASSERT(m_markerData->markerMid); | 527 DCHECK(m_markerData->markerMid); |
528 m_markerData->markerMid = nullptr; | 528 m_markerData->markerMid = nullptr; |
529 } | 529 } |
530 | 530 |
531 void SVGResources::setMarkerEnd(LayoutSVGResourceMarker* markerEnd) { | 531 void SVGResources::setMarkerEnd(LayoutSVGResourceMarker* markerEnd) { |
532 if (!markerEnd) | 532 if (!markerEnd) |
533 return; | 533 return; |
534 | 534 |
535 ASSERT(markerEnd->resourceType() == MarkerResourceType); | 535 DCHECK_EQ(markerEnd->resourceType(), MarkerResourceType); |
536 | 536 |
537 if (!m_markerData) | 537 if (!m_markerData) |
538 m_markerData = MarkerData::create(); | 538 m_markerData = MarkerData::create(); |
539 | 539 |
540 m_markerData->markerEnd = markerEnd; | 540 m_markerData->markerEnd = markerEnd; |
541 } | 541 } |
542 | 542 |
543 void SVGResources::resetMarkerEnd() { | 543 void SVGResources::resetMarkerEnd() { |
544 ASSERT(m_markerData); | 544 DCHECK(m_markerData); |
545 ASSERT(m_markerData->markerEnd); | 545 DCHECK(m_markerData->markerEnd); |
546 m_markerData->markerEnd = nullptr; | 546 m_markerData->markerEnd = nullptr; |
547 } | 547 } |
548 | 548 |
549 void SVGResources::setMasker(LayoutSVGResourceMasker* masker) { | 549 void SVGResources::setMasker(LayoutSVGResourceMasker* masker) { |
550 if (!masker) | 550 if (!masker) |
551 return; | 551 return; |
552 | 552 |
553 ASSERT(masker->resourceType() == MaskerResourceType); | 553 DCHECK_EQ(masker->resourceType(), MaskerResourceType); |
554 | 554 |
555 if (!m_clipperFilterMaskerData) | 555 if (!m_clipperFilterMaskerData) |
556 m_clipperFilterMaskerData = ClipperFilterMaskerData::create(); | 556 m_clipperFilterMaskerData = ClipperFilterMaskerData::create(); |
557 | 557 |
558 m_clipperFilterMaskerData->masker = masker; | 558 m_clipperFilterMaskerData->masker = masker; |
559 } | 559 } |
560 | 560 |
561 void SVGResources::resetMasker() { | 561 void SVGResources::resetMasker() { |
562 ASSERT(m_clipperFilterMaskerData); | 562 DCHECK(m_clipperFilterMaskerData); |
563 ASSERT(m_clipperFilterMaskerData->masker); | 563 DCHECK(m_clipperFilterMaskerData->masker); |
564 m_clipperFilterMaskerData->masker = nullptr; | 564 m_clipperFilterMaskerData->masker = nullptr; |
565 } | 565 } |
566 | 566 |
567 void SVGResources::setFill(LayoutSVGResourcePaintServer* fill) { | 567 void SVGResources::setFill(LayoutSVGResourcePaintServer* fill) { |
568 if (!fill) | 568 if (!fill) |
569 return; | 569 return; |
570 | 570 |
571 if (!m_fillStrokeData) | 571 if (!m_fillStrokeData) |
572 m_fillStrokeData = FillStrokeData::create(); | 572 m_fillStrokeData = FillStrokeData::create(); |
573 | 573 |
574 m_fillStrokeData->fill = fill; | 574 m_fillStrokeData->fill = fill; |
575 } | 575 } |
576 | 576 |
577 void SVGResources::resetFill() { | 577 void SVGResources::resetFill() { |
578 ASSERT(m_fillStrokeData); | 578 DCHECK(m_fillStrokeData); |
579 ASSERT(m_fillStrokeData->fill); | 579 DCHECK(m_fillStrokeData->fill); |
580 m_fillStrokeData->fill = nullptr; | 580 m_fillStrokeData->fill = nullptr; |
581 } | 581 } |
582 | 582 |
583 void SVGResources::setStroke(LayoutSVGResourcePaintServer* stroke) { | 583 void SVGResources::setStroke(LayoutSVGResourcePaintServer* stroke) { |
584 if (!stroke) | 584 if (!stroke) |
585 return; | 585 return; |
586 | 586 |
587 if (!m_fillStrokeData) | 587 if (!m_fillStrokeData) |
588 m_fillStrokeData = FillStrokeData::create(); | 588 m_fillStrokeData = FillStrokeData::create(); |
589 | 589 |
590 m_fillStrokeData->stroke = stroke; | 590 m_fillStrokeData->stroke = stroke; |
591 } | 591 } |
592 | 592 |
593 void SVGResources::resetStroke() { | 593 void SVGResources::resetStroke() { |
594 ASSERT(m_fillStrokeData); | 594 DCHECK(m_fillStrokeData); |
595 ASSERT(m_fillStrokeData->stroke); | 595 DCHECK(m_fillStrokeData->stroke); |
596 m_fillStrokeData->stroke = nullptr; | 596 m_fillStrokeData->stroke = nullptr; |
597 } | 597 } |
598 | 598 |
599 void SVGResources::setLinkedResource( | 599 void SVGResources::setLinkedResource( |
600 LayoutSVGResourceContainer* linkedResource) { | 600 LayoutSVGResourceContainer* linkedResource) { |
601 if (!linkedResource) | 601 if (!linkedResource) |
602 return; | 602 return; |
603 | 603 |
604 m_linkedResource = linkedResource; | 604 m_linkedResource = linkedResource; |
605 } | 605 } |
606 | 606 |
607 void SVGResources::resetLinkedResource() { | 607 void SVGResources::resetLinkedResource() { |
608 ASSERT(m_linkedResource); | 608 DCHECK(m_linkedResource); |
609 m_linkedResource = nullptr; | 609 m_linkedResource = nullptr; |
610 } | 610 } |
611 | 611 |
612 #ifndef NDEBUG | 612 #ifndef NDEBUG |
613 void SVGResources::dump(const LayoutObject* object) { | 613 void SVGResources::dump(const LayoutObject* object) { |
614 ASSERT(object); | 614 DCHECK(object); |
615 ASSERT(object->node()); | 615 DCHECK(object->node()); |
616 | 616 |
617 fprintf(stderr, "-> this=%p, SVGResources(layoutObject=%p, node=%p)\n", this, | 617 fprintf(stderr, "-> this=%p, SVGResources(layoutObject=%p, node=%p)\n", this, |
618 object, object->node()); | 618 object, object->node()); |
619 fprintf(stderr, " | DOM Tree:\n"); | 619 fprintf(stderr, " | DOM Tree:\n"); |
620 fprintf(stderr, "%s", object->node()->toTreeStringForThis().utf8().data()); | 620 fprintf(stderr, "%s", object->node()->toTreeStringForThis().utf8().data()); |
621 | 621 |
622 fprintf(stderr, "\n | List of resources:\n"); | 622 fprintf(stderr, "\n | List of resources:\n"); |
623 if (m_clipperFilterMaskerData) { | 623 if (m_clipperFilterMaskerData) { |
624 if (LayoutSVGResourceClipper* clipper = m_clipperFilterMaskerData->clipper) | 624 if (LayoutSVGResourceClipper* clipper = m_clipperFilterMaskerData->clipper) |
625 fprintf(stderr, " |-> Clipper : %p (node=%p)\n", clipper, | 625 fprintf(stderr, " |-> Clipper : %p (node=%p)\n", clipper, |
(...skipping 27 matching lines...) Expand all Loading... |
653 stroke->element()); | 653 stroke->element()); |
654 } | 654 } |
655 | 655 |
656 if (m_linkedResource) | 656 if (m_linkedResource) |
657 fprintf(stderr, " |-> xlink:href : %p (node=%p)\n", m_linkedResource, | 657 fprintf(stderr, " |-> xlink:href : %p (node=%p)\n", m_linkedResource, |
658 m_linkedResource->element()); | 658 m_linkedResource->element()); |
659 } | 659 } |
660 #endif | 660 #endif |
661 | 661 |
662 } // namespace blink | 662 } // namespace blink |
OLD | NEW |