Chromium Code Reviews| 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. |
| 730 if (isSVGViewElement(anchorNode)) { | 732 if (isSVGViewElement(anchorNode)) { |
| 731 SVGViewElement& viewElement = toSVGViewElement(*anchorNode); | 733 SVGViewElement& viewElement = toSVGViewElement(*anchorNode); |
| 732 | 734 |
| 733 if (SVGSVGElement* svg = viewElement.ownerSVGElement()) { | 735 if (SVGSVGElement* svg = viewElement.ownerSVGElement()) { |
| 734 svg->inheritViewAttributes(&viewElement); | 736 if (!view) |
| 737 view = currentView(); | |
| 738 m_useCurrentView = true; | |
|
fs
2015/03/19 10:16:30
Maybe we should tread more carefully here, since v
| |
| 739 | |
| 740 view->inheritViewAttributesFromElement(svg); | |
| 741 view->inheritViewAttributesFromElement(&viewElement); | |
| 735 | 742 |
| 736 if (LayoutObject* renderer = svg->layoutObject()) | 743 if (LayoutObject* renderer = svg->layoutObject()) |
| 737 markForLayoutAndParentResourceInvalidation(renderer); | 744 markForLayoutAndParentResourceInvalidation(renderer); |
| 738 | 745 |
| 739 return; | 746 return; |
| 740 } | 747 } |
| 741 } | 748 } |
| 742 | 749 |
| 743 // If we previously had a view and didn't get a new one, we need to | 750 // If we previously had a view and didn't get a new one, we need to |
| 744 // layout again. | 751 // layout again. |
| 745 if (renderer && hadUseCurrentView) | 752 if (renderer && hadUseCurrentView) |
| 746 markForLayoutAndParentResourceInvalidation(renderer); | 753 markForLayoutAndParentResourceInvalidation(renderer); |
| 747 | 754 |
| 748 // FIXME: We need to decide which <svg> to focus on, and zoom to it. | 755 // FIXME: We need to decide which <svg> to focus on, and zoom to it. |
| 749 // FIXME: We need to actually "highlight" the viewTarget(s). | 756 // FIXME: We need to actually "highlight" the viewTarget(s). |
| 750 } | 757 } |
| 751 | 758 |
| 752 void SVGSVGElement::inheritViewAttributes(SVGViewElement* viewElement) | |
| 753 { | |
| 754 SVGViewSpec* view = currentView(); | |
| 755 m_useCurrentView = true; | |
| 756 | |
| 757 if (viewElement->hasAttribute(SVGNames::viewBoxAttr)) | |
| 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 } | |
| 775 | |
| 776 void SVGSVGElement::finishParsingChildren() | 759 void SVGSVGElement::finishParsingChildren() |
| 777 { | 760 { |
| 778 SVGGraphicsElement::finishParsingChildren(); | 761 SVGGraphicsElement::finishParsingChildren(); |
| 779 | 762 |
| 780 // The outermost SVGSVGElement SVGLoad event is fired through Document::disp atchWindowLoadEvent. | 763 // The outermost SVGSVGElement SVGLoad event is fired through Document::disp atchWindowLoadEvent. |
| 781 if (isOutermostSVGSVGElement()) | 764 if (isOutermostSVGSVGElement()) |
| 782 return; | 765 return; |
| 783 | 766 |
| 784 // finishParsingChildren() is called when the close tag is reached for an el ement (e.g. </svg>) | 767 // 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 | 768 // we send SVGLoad events here if we can, otherwise they'll be sent when any required loads finish |
| 786 sendSVGLoadEventIfPossible(); | 769 sendSVGLoadEventIfPossible(); |
| 787 } | 770 } |
| 788 | 771 |
| 789 DEFINE_TRACE(SVGSVGElement) | 772 DEFINE_TRACE(SVGSVGElement) |
| 790 { | 773 { |
| 791 visitor->trace(m_x); | 774 visitor->trace(m_x); |
| 792 visitor->trace(m_y); | 775 visitor->trace(m_y); |
| 793 visitor->trace(m_width); | 776 visitor->trace(m_width); |
| 794 visitor->trace(m_height); | 777 visitor->trace(m_height); |
| 795 visitor->trace(m_translation); | 778 visitor->trace(m_translation); |
| 796 visitor->trace(m_timeContainer); | 779 visitor->trace(m_timeContainer); |
| 797 visitor->trace(m_viewSpec); | 780 visitor->trace(m_viewSpec); |
| 798 SVGGraphicsElement::trace(visitor); | 781 SVGGraphicsElement::trace(visitor); |
| 799 SVGFitToViewBox::trace(visitor); | 782 SVGFitToViewBox::trace(visitor); |
| 800 } | 783 } |
| 801 | 784 |
| 802 } // namespace blink | 785 } // namespace blink |
| OLD | NEW |