OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2007, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2005, 2007, 2009 Apple Inc. All rights reserved. |
3 * (C) 2005 Rob Buis <buis@kde.org> | 3 * (C) 2005 Rob Buis <buis@kde.org> |
4 * (C) 2006 Alexander Kellett <lypanov@kde.org> | 4 * (C) 2006 Alexander Kellett <lypanov@kde.org> |
5 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 5 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
6 * | 6 * |
7 * Redistribution and use in source and binary forms, with or without | 7 * Redistribution and use in source and binary forms, with or without |
8 * modification, are permitted provided that the following conditions | 8 * modification, are permitted provided that the following conditions |
9 * are met: | 9 * are met: |
10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
(...skipping 27 matching lines...) Expand all Loading... |
38 #include "core/layout/svg/LayoutSVGResourceFilter.h" | 38 #include "core/layout/svg/LayoutSVGResourceFilter.h" |
39 #include "core/layout/svg/LayoutSVGResourceLinearGradient.h" | 39 #include "core/layout/svg/LayoutSVGResourceLinearGradient.h" |
40 #include "core/layout/svg/LayoutSVGResourceMarker.h" | 40 #include "core/layout/svg/LayoutSVGResourceMarker.h" |
41 #include "core/layout/svg/LayoutSVGResourceMasker.h" | 41 #include "core/layout/svg/LayoutSVGResourceMasker.h" |
42 #include "core/layout/svg/LayoutSVGResourcePattern.h" | 42 #include "core/layout/svg/LayoutSVGResourcePattern.h" |
43 #include "core/layout/svg/LayoutSVGResourceRadialGradient.h" | 43 #include "core/layout/svg/LayoutSVGResourceRadialGradient.h" |
44 #include "core/layout/svg/LayoutSVGRoot.h" | 44 #include "core/layout/svg/LayoutSVGRoot.h" |
45 #include "core/layout/svg/LayoutSVGShape.h" | 45 #include "core/layout/svg/LayoutSVGShape.h" |
46 #include "core/layout/svg/LayoutSVGText.h" | 46 #include "core/layout/svg/LayoutSVGText.h" |
47 #include "core/layout/svg/SVGLayoutSupport.h" | 47 #include "core/layout/svg/SVGLayoutSupport.h" |
| 48 #include "core/layout/svg/SVGResources.h" |
| 49 #include "core/layout/svg/SVGResourcesCache.h" |
48 #include "core/layout/svg/line/SVGInlineTextBox.h" | 50 #include "core/layout/svg/line/SVGInlineTextBox.h" |
49 #include "core/layout/svg/line/SVGRootInlineBox.h" | 51 #include "core/layout/svg/line/SVGRootInlineBox.h" |
50 #include "core/paint/PaintLayer.h" | 52 #include "core/paint/PaintLayer.h" |
51 #include "core/svg/LinearGradientAttributes.h" | 53 #include "core/svg/LinearGradientAttributes.h" |
52 #include "core/svg/PatternAttributes.h" | 54 #include "core/svg/PatternAttributes.h" |
53 #include "core/svg/RadialGradientAttributes.h" | 55 #include "core/svg/RadialGradientAttributes.h" |
54 #include "core/svg/SVGCircleElement.h" | 56 #include "core/svg/SVGCircleElement.h" |
55 #include "core/svg/SVGEllipseElement.h" | 57 #include "core/svg/SVGEllipseElement.h" |
56 #include "core/svg/SVGFilterElement.h" | 58 #include "core/svg/SVGFilterElement.h" |
57 #include "core/svg/SVGLineElement.h" | 59 #include "core/svg/SVGLineElement.h" |
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
699 | 701 |
700 SVGStopElement* stopElement = toSVGStopElement(stop.node()); | 702 SVGStopElement* stopElement = toSVGStopElement(stop.node()); |
701 ASSERT(stopElement); | 703 ASSERT(stopElement); |
702 ASSERT(stop.style()); | 704 ASSERT(stop.style()); |
703 | 705 |
704 ts << " [offset=" << stopElement->offset()->currentValue()->value() | 706 ts << " [offset=" << stopElement->offset()->currentValue()->value() |
705 << "] [color=" << stopElement->stopColorIncludingOpacity() << "]\n"; | 707 << "] [color=" << stopElement->stopColorIncludingOpacity() << "]\n"; |
706 } | 708 } |
707 | 709 |
708 void writeResources(TextStream& ts, const LayoutObject& object, int indent) { | 710 void writeResources(TextStream& ts, const LayoutObject& object, int indent) { |
| 711 SVGResources* resources = |
| 712 SVGResourcesCache::cachedResourcesForLayoutObject(&object); |
| 713 if (!resources) |
| 714 return; |
709 const ComputedStyle& style = object.styleRef(); | 715 const ComputedStyle& style = object.styleRef(); |
710 const SVGComputedStyle& svgStyle = style.svgStyle(); | |
711 TreeScope& treeScope = object.document(); | 716 TreeScope& treeScope = object.document(); |
712 SVGTreeScopeResources& treeScopeResources = | 717 if (LayoutSVGResourceMasker* masker = resources->masker()) { |
713 treeScope.ensureSVGTreeScopedResources(); | 718 writeIndent(ts, indent); |
714 | 719 ts << " "; |
715 // FIXME: We want to use SVGResourcesCache to determine which resources are | 720 writeNameAndQuotedValue(ts, "masker", style.svgStyle().maskerResource()); |
716 // present, instead of quering the resource <-> id cache. | 721 ts << " "; |
717 // For now leave the DRT output as is, but later on we should change this so | 722 writeStandardPrefix(ts, *masker, 0); |
718 // cycles are properly ignored in the DRT output. | 723 ts << " " << masker->resourceBoundingBox(&object) << "\n"; |
719 if (!svgStyle.maskerResource().isEmpty()) { | |
720 if (LayoutSVGResourceMasker* masker = | |
721 getLayoutSVGResourceById<LayoutSVGResourceMasker>( | |
722 treeScopeResources, svgStyle.maskerResource())) { | |
723 writeIndent(ts, indent); | |
724 ts << " "; | |
725 writeNameAndQuotedValue(ts, "masker", svgStyle.maskerResource()); | |
726 ts << " "; | |
727 writeStandardPrefix(ts, *masker, 0); | |
728 ts << " " << masker->resourceBoundingBox(&object) << "\n"; | |
729 } | |
730 } | 724 } |
731 if (ClipPathOperation* clipPathOperation = style.clipPath()) { | 725 if (LayoutSVGResourceClipper* clipper = resources->clipper()) { |
732 if (clipPathOperation->type() == ClipPathOperation::REFERENCE) { | 726 DCHECK(style.clipPath()); |
733 const ReferenceClipPathOperation& clipPathReference = | 727 DCHECK_EQ(style.clipPath()->type(), ClipPathOperation::REFERENCE); |
734 toReferenceClipPathOperation(*clipPathOperation); | 728 const ReferenceClipPathOperation& clipPathReference = |
735 AtomicString id = SVGURIReference::fragmentIdentifierFromIRIString( | 729 toReferenceClipPathOperation(*style.clipPath()); |
736 clipPathReference.url(), treeScope); | 730 AtomicString id = SVGURIReference::fragmentIdentifierFromIRIString( |
737 if (LayoutSVGResourceClipper* clipper = | 731 clipPathReference.url(), treeScope); |
738 getLayoutSVGResourceById<LayoutSVGResourceClipper>( | 732 writeIndent(ts, indent); |
739 treeScopeResources, id)) { | 733 ts << " "; |
740 writeIndent(ts, indent); | 734 writeNameAndQuotedValue(ts, "clipPath", id); |
741 ts << " "; | 735 ts << " "; |
742 writeNameAndQuotedValue(ts, "clipPath", id); | 736 writeStandardPrefix(ts, *clipper, 0); |
743 ts << " "; | 737 ts << " " << clipper->resourceBoundingBox(object.objectBoundingBox()) |
744 writeStandardPrefix(ts, *clipper, 0); | 738 << "\n"; |
745 ts << " " << clipper->resourceBoundingBox(object.objectBoundingBox()) | |
746 << "\n"; | |
747 } | |
748 } | |
749 } | 739 } |
750 if (style.hasFilter()) { | 740 if (LayoutSVGResourceFilter* filter = resources->filter()) { |
751 const FilterOperations& filterOperations = style.filter(); | 741 DCHECK(style.hasFilter()); |
752 if (filterOperations.size() == 1) { | 742 DCHECK_EQ(style.filter().size(), 1u); |
753 const FilterOperation& filterOperation = *filterOperations.at(0); | 743 const FilterOperation& filterOperation = *style.filter().at(0); |
754 if (filterOperation.type() == FilterOperation::REFERENCE) { | 744 DCHECK_EQ(filterOperation.type(), FilterOperation::REFERENCE); |
755 const auto& referenceFilterOperation = | 745 const auto& referenceFilterOperation = |
756 toReferenceFilterOperation(filterOperation); | 746 toReferenceFilterOperation(filterOperation); |
757 AtomicString id = SVGURIReference::fragmentIdentifierFromIRIString( | 747 AtomicString id = SVGURIReference::fragmentIdentifierFromIRIString( |
758 referenceFilterOperation.url(), treeScope); | 748 referenceFilterOperation.url(), treeScope); |
759 if (LayoutSVGResourceFilter* filter = | 749 writeIndent(ts, indent); |
760 getLayoutSVGResourceById<LayoutSVGResourceFilter>( | 750 ts << " "; |
761 treeScopeResources, id)) { | 751 writeNameAndQuotedValue(ts, "filter", id); |
762 writeIndent(ts, indent); | 752 ts << " "; |
763 ts << " "; | 753 writeStandardPrefix(ts, *filter, 0); |
764 writeNameAndQuotedValue(ts, "filter", id); | 754 ts << " " << filter->resourceBoundingBox(&object) << "\n"; |
765 ts << " "; | |
766 writeStandardPrefix(ts, *filter, 0); | |
767 ts << " " << filter->resourceBoundingBox(&object) << "\n"; | |
768 } | |
769 } | |
770 } | |
771 } | 755 } |
772 } | 756 } |
773 | 757 |
774 } // namespace blink | 758 } // namespace blink |
OLD | NEW |