OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> |
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Rob Buis <buis@kde.org> |
4 * Copyright (C) 2007 Apple Inc. All rights reserved. | 4 * Copyright (C) 2007 Apple Inc. All rights reserved. |
5 * Copyright (C) 2014 Google, Inc. | 5 * Copyright (C) 2014 Google, Inc. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 // FIXME: XPointer references are ignored (https://bugs.webkit.org/show_
bug.cgi?id=17491) | 706 // FIXME: XPointer references are ignored (https://bugs.webkit.org/show_
bug.cgi?id=17491) |
707 if (renderer && hadUseCurrentView) | 707 if (renderer && hadUseCurrentView) |
708 markForLayoutAndParentResourceInvalidation(renderer); | 708 markForLayoutAndParentResourceInvalidation(renderer); |
709 return; | 709 return; |
710 } | 710 } |
711 | 711 |
712 if (fragmentIdentifier.startsWith("svgView(")) { | 712 if (fragmentIdentifier.startsWith("svgView(")) { |
713 if (!view) | 713 if (!view) |
714 view = currentView(); // Create the SVGViewSpec. | 714 view = currentView(); // Create the SVGViewSpec. |
715 | 715 |
| 716 view->inheritViewAttributesFromElement(this); |
| 717 |
716 if (view->parseViewSpec(fragmentIdentifier)) | 718 if (view->parseViewSpec(fragmentIdentifier)) |
717 m_useCurrentView = true; | 719 m_useCurrentView = true; |
718 else | 720 else |
719 view->reset(); | 721 view->reset(); |
720 | 722 |
721 if (renderer && (hadUseCurrentView || m_useCurrentView)) | 723 if (renderer && (hadUseCurrentView || m_useCurrentView)) |
722 markForLayoutAndParentResourceInvalidation(renderer); | 724 markForLayoutAndParentResourceInvalidation(renderer); |
723 return; | 725 return; |
724 } | 726 } |
725 | 727 |
726 // Spec: If the SVG fragment identifier addresses a 'view' element within an
SVG document (e.g., MyDrawing.svg#MyView | 728 // Spec: If the SVG fragment identifier addresses a 'view' element within an
SVG document (e.g., MyDrawing.svg#MyView |
727 // or MyDrawing.svg#xpointer(id('MyView'))) then the closest ancestor 'svg'
element is displayed in the viewport. | 729 // or MyDrawing.svg#xpointer(id('MyView'))) then the closest ancestor 'svg'
element is displayed in the viewport. |
728 // Any view specification attributes included on the given 'view' element ov
erride the corresponding view specification | 730 // Any view specification attributes included on the given 'view' element ov
erride the corresponding view specification |
729 // attributes on the closest ancestor 'svg' element. | 731 // attributes on the closest ancestor 'svg' element. |
| 732 // TODO(ed): The spec text above is a bit unclear. |
| 733 // Should the transform from outermost svg to nested svg be applied to "disp
lay" |
| 734 // the inner svg in the viewport, then let the view element override the inn
er |
| 735 // svg's view specification attributes. Should it fill/override the outer vi
ewport? |
730 if (isSVGViewElement(anchorNode)) { | 736 if (isSVGViewElement(anchorNode)) { |
731 SVGViewElement& viewElement = toSVGViewElement(*anchorNode); | 737 SVGViewElement& viewElement = toSVGViewElement(*anchorNode); |
732 | 738 |
733 if (SVGSVGElement* svg = viewElement.ownerSVGElement()) { | 739 if (SVGSVGElement* svg = viewElement.ownerSVGElement()) { |
734 svg->inheritViewAttributes(&viewElement); | 740 svg->inheritViewAttributes(&viewElement); |
735 | 741 |
736 if (LayoutObject* renderer = svg->layoutObject()) | 742 if (LayoutObject* renderer = svg->layoutObject()) |
737 markForLayoutAndParentResourceInvalidation(renderer); | 743 markForLayoutAndParentResourceInvalidation(renderer); |
738 | 744 |
739 return; | 745 return; |
740 } | 746 } |
741 } | 747 } |
742 | 748 |
743 // If we previously had a view and didn't get a new one, we need to | 749 // If we previously had a view and didn't get a new one, we need to |
744 // layout again. | 750 // layout again. |
745 if (renderer && hadUseCurrentView) | 751 if (renderer && hadUseCurrentView) |
746 markForLayoutAndParentResourceInvalidation(renderer); | 752 markForLayoutAndParentResourceInvalidation(renderer); |
747 | 753 |
748 // FIXME: We need to decide which <svg> to focus on, and zoom to it. | 754 // FIXME: We need to decide which <svg> to focus on, and zoom to it. |
749 // FIXME: We need to actually "highlight" the viewTarget(s). | 755 // FIXME: We need to actually "highlight" the viewTarget(s). |
750 } | 756 } |
751 | 757 |
752 void SVGSVGElement::inheritViewAttributes(SVGViewElement* viewElement) | 758 void SVGSVGElement::inheritViewAttributes(SVGViewElement* viewElement) |
753 { | 759 { |
754 SVGViewSpec* view = currentView(); | 760 SVGViewSpec* view = currentView(); |
755 m_useCurrentView = true; | 761 m_useCurrentView = true; |
756 | 762 view->inheritViewAttributesFromElement(this); |
757 if (viewElement->hasAttribute(SVGNames::viewBoxAttr)) | 763 view->inheritViewAttributesFromElement(viewElement); |
758 view->viewBox()->baseValue()->setValue(viewElement->viewBox()->currentVa
lue()->value()); | |
759 else | |
760 view->viewBox()->baseValue()->setValue(viewBox()->currentValue()->value(
)); | |
761 | |
762 if (viewElement->hasAttribute(SVGNames::preserveAspectRatioAttr)) { | |
763 view->preserveAspectRatio()->baseValue()->setAlign(viewElement->preserve
AspectRatio()->currentValue()->align()); | |
764 view->preserveAspectRatio()->baseValue()->setMeetOrSlice(viewElement->pr
eserveAspectRatio()->currentValue()->meetOrSlice()); | |
765 } else { | |
766 view->preserveAspectRatio()->baseValue()->setAlign(preserveAspectRatio()
->currentValue()->align()); | |
767 view->preserveAspectRatio()->baseValue()->setMeetOrSlice(preserveAspectR
atio()->currentValue()->meetOrSlice()); | |
768 } | |
769 | |
770 if (viewElement->hasAttribute(SVGNames::zoomAndPanAttr)) | |
771 view->setZoomAndPan(viewElement->zoomAndPan()); | |
772 else | |
773 view->setZoomAndPan(zoomAndPan()); | |
774 } | 764 } |
775 | 765 |
776 void SVGSVGElement::finishParsingChildren() | 766 void SVGSVGElement::finishParsingChildren() |
777 { | 767 { |
778 SVGGraphicsElement::finishParsingChildren(); | 768 SVGGraphicsElement::finishParsingChildren(); |
779 | 769 |
780 // The outermost SVGSVGElement SVGLoad event is fired through Document::disp
atchWindowLoadEvent. | 770 // The outermost SVGSVGElement SVGLoad event is fired through Document::disp
atchWindowLoadEvent. |
781 if (isOutermostSVGSVGElement()) | 771 if (isOutermostSVGSVGElement()) |
782 return; | 772 return; |
783 | 773 |
784 // finishParsingChildren() is called when the close tag is reached for an el
ement (e.g. </svg>) | 774 // finishParsingChildren() is called when the close tag is reached for an el
ement (e.g. </svg>) |
785 // we send SVGLoad events here if we can, otherwise they'll be sent when any
required loads finish | 775 // we send SVGLoad events here if we can, otherwise they'll be sent when any
required loads finish |
786 sendSVGLoadEventIfPossible(); | 776 sendSVGLoadEventIfPossible(); |
787 } | 777 } |
788 | 778 |
789 DEFINE_TRACE(SVGSVGElement) | 779 DEFINE_TRACE(SVGSVGElement) |
790 { | 780 { |
791 visitor->trace(m_x); | 781 visitor->trace(m_x); |
792 visitor->trace(m_y); | 782 visitor->trace(m_y); |
793 visitor->trace(m_width); | 783 visitor->trace(m_width); |
794 visitor->trace(m_height); | 784 visitor->trace(m_height); |
795 visitor->trace(m_translation); | 785 visitor->trace(m_translation); |
796 visitor->trace(m_timeContainer); | 786 visitor->trace(m_timeContainer); |
797 visitor->trace(m_viewSpec); | 787 visitor->trace(m_viewSpec); |
798 SVGGraphicsElement::trace(visitor); | 788 SVGGraphicsElement::trace(visitor); |
799 SVGFitToViewBox::trace(visitor); | 789 SVGFitToViewBox::trace(visitor); |
800 } | 790 } |
801 | 791 |
802 } // namespace blink | 792 } // namespace blink |
OLD | NEW |