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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 if (!clipper_filter_masker_data_) | 411 if (!clipper_filter_masker_data_) |
412 break; | 412 break; |
413 if (clipper_filter_masker_data_->clipper == resource) | 413 if (clipper_filter_masker_data_->clipper == resource) |
414 clipper_filter_masker_data_->clipper = nullptr; | 414 clipper_filter_masker_data_->clipper = nullptr; |
415 break; | 415 break; |
416 default: | 416 default: |
417 NOTREACHED(); | 417 NOTREACHED(); |
418 } | 418 } |
419 } | 419 } |
420 | 420 |
| 421 void SVGResources::ClearReferencesTo(LayoutSVGResourceContainer* resource) { |
| 422 DCHECK(resource); |
| 423 if (linked_resource_ == resource) { |
| 424 DCHECK(!clipper_filter_masker_data_); |
| 425 DCHECK(!marker_data_); |
| 426 DCHECK(!fill_stroke_data_); |
| 427 linked_resource_ = nullptr; |
| 428 return; |
| 429 } |
| 430 |
| 431 switch (resource->ResourceType()) { |
| 432 case kMaskerResourceType: |
| 433 DCHECK(clipper_filter_masker_data_); |
| 434 DCHECK_EQ(clipper_filter_masker_data_->masker, resource); |
| 435 clipper_filter_masker_data_->masker = nullptr; |
| 436 break; |
| 437 case kMarkerResourceType: |
| 438 DCHECK(marker_data_); |
| 439 DCHECK(resource == MarkerStart() || resource == MarkerMid() || |
| 440 resource == MarkerEnd()); |
| 441 if (marker_data_->marker_start == resource) |
| 442 marker_data_->marker_start = nullptr; |
| 443 if (marker_data_->marker_mid == resource) |
| 444 marker_data_->marker_mid = nullptr; |
| 445 if (marker_data_->marker_end == resource) |
| 446 marker_data_->marker_end = nullptr; |
| 447 break; |
| 448 case kPatternResourceType: |
| 449 case kLinearGradientResourceType: |
| 450 case kRadialGradientResourceType: |
| 451 DCHECK(fill_stroke_data_); |
| 452 DCHECK(resource == Fill() || resource == Stroke()); |
| 453 if (fill_stroke_data_->fill == resource) |
| 454 fill_stroke_data_->fill = nullptr; |
| 455 if (fill_stroke_data_->stroke == resource) |
| 456 fill_stroke_data_->stroke = nullptr; |
| 457 break; |
| 458 case kFilterResourceType: |
| 459 DCHECK(clipper_filter_masker_data_); |
| 460 DCHECK_EQ(clipper_filter_masker_data_->filter, resource); |
| 461 clipper_filter_masker_data_->filter = nullptr; |
| 462 break; |
| 463 case kClipperResourceType: |
| 464 DCHECK(clipper_filter_masker_data_); |
| 465 DCHECK_EQ(clipper_filter_masker_data_->clipper, resource); |
| 466 clipper_filter_masker_data_->clipper = nullptr; |
| 467 break; |
| 468 default: |
| 469 NOTREACHED(); |
| 470 } |
| 471 } |
| 472 |
421 void SVGResources::BuildSetOfResources( | 473 void SVGResources::BuildSetOfResources( |
422 HashSet<LayoutSVGResourceContainer*>& set) { | 474 HashSet<LayoutSVGResourceContainer*>& set) { |
423 if (!HasResourceData()) | 475 if (!HasResourceData()) |
424 return; | 476 return; |
425 | 477 |
426 if (linked_resource_) { | 478 if (linked_resource_) { |
427 DCHECK(!clipper_filter_masker_data_); | 479 DCHECK(!clipper_filter_masker_data_); |
428 DCHECK(!marker_data_); | 480 DCHECK(!marker_data_); |
429 DCHECK(!fill_stroke_data_); | 481 DCHECK(!fill_stroke_data_); |
430 set.insert(linked_resource_); | 482 set.insert(linked_resource_); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 return; | 514 return; |
463 | 515 |
464 DCHECK_EQ(clipper->ResourceType(), kClipperResourceType); | 516 DCHECK_EQ(clipper->ResourceType(), kClipperResourceType); |
465 | 517 |
466 if (!clipper_filter_masker_data_) | 518 if (!clipper_filter_masker_data_) |
467 clipper_filter_masker_data_ = ClipperFilterMaskerData::Create(); | 519 clipper_filter_masker_data_ = ClipperFilterMaskerData::Create(); |
468 | 520 |
469 clipper_filter_masker_data_->clipper = clipper; | 521 clipper_filter_masker_data_->clipper = clipper; |
470 } | 522 } |
471 | 523 |
472 void SVGResources::ResetClipper() { | |
473 DCHECK(clipper_filter_masker_data_); | |
474 DCHECK(clipper_filter_masker_data_->clipper); | |
475 clipper_filter_masker_data_->clipper = nullptr; | |
476 } | |
477 | |
478 void SVGResources::SetFilter(LayoutSVGResourceFilter* filter) { | 524 void SVGResources::SetFilter(LayoutSVGResourceFilter* filter) { |
479 if (!filter) | 525 if (!filter) |
480 return; | 526 return; |
481 | 527 |
482 DCHECK_EQ(filter->ResourceType(), kFilterResourceType); | 528 DCHECK_EQ(filter->ResourceType(), kFilterResourceType); |
483 | 529 |
484 if (!clipper_filter_masker_data_) | 530 if (!clipper_filter_masker_data_) |
485 clipper_filter_masker_data_ = ClipperFilterMaskerData::Create(); | 531 clipper_filter_masker_data_ = ClipperFilterMaskerData::Create(); |
486 | 532 |
487 clipper_filter_masker_data_->filter = filter; | 533 clipper_filter_masker_data_->filter = filter; |
488 } | 534 } |
489 | 535 |
490 void SVGResources::ResetFilter() { | |
491 DCHECK(clipper_filter_masker_data_); | |
492 DCHECK(clipper_filter_masker_data_->filter); | |
493 clipper_filter_masker_data_->filter = nullptr; | |
494 } | |
495 | |
496 void SVGResources::SetMarkerStart(LayoutSVGResourceMarker* marker_start) { | 536 void SVGResources::SetMarkerStart(LayoutSVGResourceMarker* marker_start) { |
497 if (!marker_start) | 537 if (!marker_start) |
498 return; | 538 return; |
499 | 539 |
500 DCHECK_EQ(marker_start->ResourceType(), kMarkerResourceType); | 540 DCHECK_EQ(marker_start->ResourceType(), kMarkerResourceType); |
501 | 541 |
502 if (!marker_data_) | 542 if (!marker_data_) |
503 marker_data_ = MarkerData::Create(); | 543 marker_data_ = MarkerData::Create(); |
504 | 544 |
505 marker_data_->marker_start = marker_start; | 545 marker_data_->marker_start = marker_start; |
506 } | 546 } |
507 | 547 |
508 void SVGResources::ResetMarkerStart() { | |
509 DCHECK(marker_data_); | |
510 DCHECK(marker_data_->marker_start); | |
511 marker_data_->marker_start = nullptr; | |
512 } | |
513 | |
514 void SVGResources::SetMarkerMid(LayoutSVGResourceMarker* marker_mid) { | 548 void SVGResources::SetMarkerMid(LayoutSVGResourceMarker* marker_mid) { |
515 if (!marker_mid) | 549 if (!marker_mid) |
516 return; | 550 return; |
517 | 551 |
518 DCHECK_EQ(marker_mid->ResourceType(), kMarkerResourceType); | 552 DCHECK_EQ(marker_mid->ResourceType(), kMarkerResourceType); |
519 | 553 |
520 if (!marker_data_) | 554 if (!marker_data_) |
521 marker_data_ = MarkerData::Create(); | 555 marker_data_ = MarkerData::Create(); |
522 | 556 |
523 marker_data_->marker_mid = marker_mid; | 557 marker_data_->marker_mid = marker_mid; |
524 } | 558 } |
525 | 559 |
526 void SVGResources::ResetMarkerMid() { | |
527 DCHECK(marker_data_); | |
528 DCHECK(marker_data_->marker_mid); | |
529 marker_data_->marker_mid = nullptr; | |
530 } | |
531 | |
532 void SVGResources::SetMarkerEnd(LayoutSVGResourceMarker* marker_end) { | 560 void SVGResources::SetMarkerEnd(LayoutSVGResourceMarker* marker_end) { |
533 if (!marker_end) | 561 if (!marker_end) |
534 return; | 562 return; |
535 | 563 |
536 DCHECK_EQ(marker_end->ResourceType(), kMarkerResourceType); | 564 DCHECK_EQ(marker_end->ResourceType(), kMarkerResourceType); |
537 | 565 |
538 if (!marker_data_) | 566 if (!marker_data_) |
539 marker_data_ = MarkerData::Create(); | 567 marker_data_ = MarkerData::Create(); |
540 | 568 |
541 marker_data_->marker_end = marker_end; | 569 marker_data_->marker_end = marker_end; |
542 } | 570 } |
543 | 571 |
544 void SVGResources::ResetMarkerEnd() { | |
545 DCHECK(marker_data_); | |
546 DCHECK(marker_data_->marker_end); | |
547 marker_data_->marker_end = nullptr; | |
548 } | |
549 | |
550 void SVGResources::SetMasker(LayoutSVGResourceMasker* masker) { | 572 void SVGResources::SetMasker(LayoutSVGResourceMasker* masker) { |
551 if (!masker) | 573 if (!masker) |
552 return; | 574 return; |
553 | 575 |
554 DCHECK_EQ(masker->ResourceType(), kMaskerResourceType); | 576 DCHECK_EQ(masker->ResourceType(), kMaskerResourceType); |
555 | 577 |
556 if (!clipper_filter_masker_data_) | 578 if (!clipper_filter_masker_data_) |
557 clipper_filter_masker_data_ = ClipperFilterMaskerData::Create(); | 579 clipper_filter_masker_data_ = ClipperFilterMaskerData::Create(); |
558 | 580 |
559 clipper_filter_masker_data_->masker = masker; | 581 clipper_filter_masker_data_->masker = masker; |
560 } | 582 } |
561 | 583 |
562 void SVGResources::ResetMasker() { | |
563 DCHECK(clipper_filter_masker_data_); | |
564 DCHECK(clipper_filter_masker_data_->masker); | |
565 clipper_filter_masker_data_->masker = nullptr; | |
566 } | |
567 | |
568 void SVGResources::SetFill(LayoutSVGResourcePaintServer* fill) { | 584 void SVGResources::SetFill(LayoutSVGResourcePaintServer* fill) { |
569 if (!fill) | 585 if (!fill) |
570 return; | 586 return; |
571 | 587 |
572 if (!fill_stroke_data_) | 588 if (!fill_stroke_data_) |
573 fill_stroke_data_ = FillStrokeData::Create(); | 589 fill_stroke_data_ = FillStrokeData::Create(); |
574 | 590 |
575 fill_stroke_data_->fill = fill; | 591 fill_stroke_data_->fill = fill; |
576 } | 592 } |
577 | 593 |
578 void SVGResources::ResetFill() { | |
579 DCHECK(fill_stroke_data_); | |
580 DCHECK(fill_stroke_data_->fill); | |
581 fill_stroke_data_->fill = nullptr; | |
582 } | |
583 | |
584 void SVGResources::SetStroke(LayoutSVGResourcePaintServer* stroke) { | 594 void SVGResources::SetStroke(LayoutSVGResourcePaintServer* stroke) { |
585 if (!stroke) | 595 if (!stroke) |
586 return; | 596 return; |
587 | 597 |
588 if (!fill_stroke_data_) | 598 if (!fill_stroke_data_) |
589 fill_stroke_data_ = FillStrokeData::Create(); | 599 fill_stroke_data_ = FillStrokeData::Create(); |
590 | 600 |
591 fill_stroke_data_->stroke = stroke; | 601 fill_stroke_data_->stroke = stroke; |
592 } | 602 } |
593 | 603 |
594 void SVGResources::ResetStroke() { | |
595 DCHECK(fill_stroke_data_); | |
596 DCHECK(fill_stroke_data_->stroke); | |
597 fill_stroke_data_->stroke = nullptr; | |
598 } | |
599 | |
600 void SVGResources::SetLinkedResource( | 604 void SVGResources::SetLinkedResource( |
601 LayoutSVGResourceContainer* linked_resource) { | 605 LayoutSVGResourceContainer* linked_resource) { |
602 if (!linked_resource) | 606 if (!linked_resource) |
603 return; | 607 return; |
604 | 608 |
605 linked_resource_ = linked_resource; | 609 linked_resource_ = linked_resource; |
606 } | 610 } |
607 | 611 |
608 void SVGResources::ResetLinkedResource() { | |
609 DCHECK(linked_resource_); | |
610 linked_resource_ = nullptr; | |
611 } | |
612 | |
613 #ifndef NDEBUG | 612 #ifndef NDEBUG |
614 void SVGResources::Dump(const LayoutObject* object) { | 613 void SVGResources::Dump(const LayoutObject* object) { |
615 DCHECK(object); | 614 DCHECK(object); |
616 DCHECK(object->GetNode()); | 615 DCHECK(object->GetNode()); |
617 | 616 |
618 fprintf(stderr, "-> this=%p, SVGResources(layoutObject=%p, node=%p)\n", this, | 617 fprintf(stderr, "-> this=%p, SVGResources(layoutObject=%p, node=%p)\n", this, |
619 object, object->GetNode()); | 618 object, object->GetNode()); |
620 fprintf(stderr, " | DOM Tree:\n"); | 619 fprintf(stderr, " | DOM Tree:\n"); |
621 fprintf(stderr, "%s", object->GetNode()->ToTreeStringForThis().Utf8().Data()); | 620 fprintf(stderr, "%s", object->GetNode()->ToTreeStringForThis().Utf8().Data()); |
622 | 621 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 stroke->GetElement()); | 654 stroke->GetElement()); |
656 } | 655 } |
657 | 656 |
658 if (linked_resource_) | 657 if (linked_resource_) |
659 fprintf(stderr, " |-> xlink:href : %p (node=%p)\n", linked_resource_, | 658 fprintf(stderr, " |-> xlink:href : %p (node=%p)\n", linked_resource_, |
660 linked_resource_->GetElement()); | 659 linked_resource_->GetElement()); |
661 } | 660 } |
662 #endif | 661 #endif |
663 | 662 |
664 } // namespace blink | 663 } // namespace blink |
OLD | NEW |