| 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 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 10 * | 10 * |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 namespace WebCore { | 63 namespace WebCore { |
| 64 | 64 |
| 65 // Animated property definitions | 65 // Animated property definitions |
| 66 | 66 |
| 67 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGSVGElement) | 67 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGSVGElement) |
| 68 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) | 68 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGGraphicsElement) |
| 69 END_REGISTER_ANIMATED_PROPERTIES | 69 END_REGISTER_ANIMATED_PROPERTIES |
| 70 | 70 |
| 71 inline SVGSVGElement::SVGSVGElement(Document& doc) | 71 inline SVGSVGElement::SVGSVGElement(Document& doc) |
| 72 : SVGGraphicsElement(SVGNames::svgTag, doc) | 72 : SVGGraphicsElement(SVGNames::svgTag, doc) |
| 73 , SVGFitToViewBox(this) |
| 73 , m_x(SVGAnimatedLength::create(this, SVGNames::xAttr, SVGLength::create(Len
gthModeWidth))) | 74 , m_x(SVGAnimatedLength::create(this, SVGNames::xAttr, SVGLength::create(Len
gthModeWidth))) |
| 74 , m_y(SVGAnimatedLength::create(this, SVGNames::yAttr, SVGLength::create(Len
gthModeHeight))) | 75 , m_y(SVGAnimatedLength::create(this, SVGNames::yAttr, SVGLength::create(Len
gthModeHeight))) |
| 75 , m_width(SVGAnimatedLength::create(this, SVGNames::widthAttr, SVGLength::cr
eate(LengthModeWidth))) | 76 , m_width(SVGAnimatedLength::create(this, SVGNames::widthAttr, SVGLength::cr
eate(LengthModeWidth))) |
| 76 , m_height(SVGAnimatedLength::create(this, SVGNames::heightAttr, SVGLength::
create(LengthModeHeight))) | 77 , m_height(SVGAnimatedLength::create(this, SVGNames::heightAttr, SVGLength::
create(LengthModeHeight))) |
| 77 , m_viewBox(SVGAnimatedRect::create(this, SVGNames::viewBoxAttr)) | |
| 78 , m_preserveAspectRatio(SVGAnimatedPreserveAspectRatio::create(this, SVGName
s::preserveAspectRatioAttr, SVGPreserveAspectRatio::create())) | |
| 79 , m_useCurrentView(false) | 78 , m_useCurrentView(false) |
| 80 , m_timeContainer(SMILTimeContainer::create(this)) | 79 , m_timeContainer(SMILTimeContainer::create(this)) |
| 81 , m_translation(SVGPoint::create()) | 80 , m_translation(SVGPoint::create()) |
| 82 { | 81 { |
| 83 ScriptWrappable::init(this); | 82 ScriptWrappable::init(this); |
| 84 | 83 |
| 85 m_width->setDefaultValueAsString("100%"); | 84 m_width->setDefaultValueAsString("100%"); |
| 86 m_height->setDefaultValueAsString("100%"); | 85 m_height->setDefaultValueAsString("100%"); |
| 87 | 86 |
| 88 addToPropertyMap(m_x); | 87 addToPropertyMap(m_x); |
| 89 addToPropertyMap(m_y); | 88 addToPropertyMap(m_y); |
| 90 addToPropertyMap(m_width); | 89 addToPropertyMap(m_width); |
| 91 addToPropertyMap(m_height); | 90 addToPropertyMap(m_height); |
| 92 addToPropertyMap(m_viewBox); | |
| 93 addToPropertyMap(m_preserveAspectRatio); | |
| 94 registerAnimatedPropertiesForSVGSVGElement(); | 91 registerAnimatedPropertiesForSVGSVGElement(); |
| 95 | 92 |
| 96 UseCounter::count(doc, UseCounter::SVGSVGElement); | 93 UseCounter::count(doc, UseCounter::SVGSVGElement); |
| 97 } | 94 } |
| 98 | 95 |
| 99 PassRefPtr<SVGSVGElement> SVGSVGElement::create(Document& document) | 96 PassRefPtr<SVGSVGElement> SVGSVGElement::create(Document& document) |
| 100 { | 97 { |
| 101 return adoptRef(new SVGSVGElement(document)); | 98 return adoptRef(new SVGSVGElement(document)); |
| 102 } | 99 } |
| 103 | 100 |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 } else if (name == HTMLNames::onerrorAttr) { | 273 } else if (name == HTMLNames::onerrorAttr) { |
| 277 document().setWindowAttributeEventListener(EventTypeNames::error, create
AttributeEventListener(document().frame(), name, value)); | 274 document().setWindowAttributeEventListener(EventTypeNames::error, create
AttributeEventListener(document().frame(), name, value)); |
| 278 } else if (name == SVGNames::xAttr) { | 275 } else if (name == SVGNames::xAttr) { |
| 279 m_x->setBaseValueAsString(value, AllowNegativeLengths, parseError); | 276 m_x->setBaseValueAsString(value, AllowNegativeLengths, parseError); |
| 280 } else if (name == SVGNames::yAttr) { | 277 } else if (name == SVGNames::yAttr) { |
| 281 m_y->setBaseValueAsString(value, AllowNegativeLengths, parseError); | 278 m_y->setBaseValueAsString(value, AllowNegativeLengths, parseError); |
| 282 } else if (name == SVGNames::widthAttr) { | 279 } else if (name == SVGNames::widthAttr) { |
| 283 m_width->setBaseValueAsString(value, ForbidNegativeLengths, parseError); | 280 m_width->setBaseValueAsString(value, ForbidNegativeLengths, parseError); |
| 284 } else if (name == SVGNames::heightAttr) { | 281 } else if (name == SVGNames::heightAttr) { |
| 285 m_height->setBaseValueAsString(value, ForbidNegativeLengths, parseError)
; | 282 m_height->setBaseValueAsString(value, ForbidNegativeLengths, parseError)
; |
| 286 } else if (SVGFitToViewBox::parseAttribute(this, name, value) || SVGZoomAndP
an::parseAttribute(name, value)) { | 283 } else if (SVGFitToViewBox::parseAttribute(name, value, document(), parseErr
or)) { |
| 284 } else if (SVGZoomAndPan::parseAttribute(name, value)) { |
| 287 } else { | 285 } else { |
| 288 SVGGraphicsElement::parseAttribute(name, value); | 286 SVGGraphicsElement::parseAttribute(name, value); |
| 289 } | 287 } |
| 290 | 288 |
| 291 reportAttributeParsingError(parseError, name, value); | 289 reportAttributeParsingError(parseError, name, value); |
| 292 } | 290 } |
| 293 | 291 |
| 294 void SVGSVGElement::svgAttributeChanged(const QualifiedName& attrName) | 292 void SVGSVGElement::svgAttributeChanged(const QualifiedName& attrName) |
| 295 { | 293 { |
| 296 bool updateRelativeLengthsOrViewBox = false; | 294 bool updateRelativeLengthsOrViewBox = false; |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 || m_width->currentValue()->isRelative() | 549 || m_width->currentValue()->isRelative() |
| 552 || m_height->currentValue()->isRelative() | 550 || m_height->currentValue()->isRelative() |
| 553 || hasAttribute(SVGNames::viewBoxAttr); | 551 || hasAttribute(SVGNames::viewBoxAttr); |
| 554 } | 552 } |
| 555 | 553 |
| 556 FloatRect SVGSVGElement::currentViewBoxRect() const | 554 FloatRect SVGSVGElement::currentViewBoxRect() const |
| 557 { | 555 { |
| 558 if (m_useCurrentView) | 556 if (m_useCurrentView) |
| 559 return m_viewSpec ? m_viewSpec->viewBox()->currentValue()->value() : Flo
atRect(); | 557 return m_viewSpec ? m_viewSpec->viewBox()->currentValue()->value() : Flo
atRect(); |
| 560 | 558 |
| 561 FloatRect useViewBox = m_viewBox->currentValue()->value(); | 559 FloatRect useViewBox = viewBox()->currentValue()->value(); |
| 562 if (!useViewBox.isEmpty()) | 560 if (!useViewBox.isEmpty()) |
| 563 return useViewBox; | 561 return useViewBox; |
| 564 if (!renderer() || !renderer()->isSVGRoot()) | 562 if (!renderer() || !renderer()->isSVGRoot()) |
| 565 return FloatRect(); | 563 return FloatRect(); |
| 566 if (!toRenderSVGRoot(renderer())->isEmbeddedThroughSVGImage()) | 564 if (!toRenderSVGRoot(renderer())->isEmbeddedThroughSVGImage()) |
| 567 return FloatRect(); | 565 return FloatRect(); |
| 568 | 566 |
| 569 Length intrinsicWidth = this->intrinsicWidth(); | 567 Length intrinsicWidth = this->intrinsicWidth(); |
| 570 Length intrinsicHeight = this->intrinsicHeight(); | 568 Length intrinsicHeight = this->intrinsicHeight(); |
| 571 if (!intrinsicWidth.isFixed() || !intrinsicHeight.isFixed()) | 569 if (!intrinsicWidth.isFixed() || !intrinsicHeight.isFixed()) |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 return Length(m_height->currentValue()->value(lengthContext), Fixed); | 665 return Length(m_height->currentValue()->value(lengthContext), Fixed); |
| 668 } | 666 } |
| 669 | 667 |
| 670 ASSERT(renderer()); | 668 ASSERT(renderer()); |
| 671 return renderer()->style()->height(); | 669 return renderer()->style()->height(); |
| 672 } | 670 } |
| 673 | 671 |
| 674 AffineTransform SVGSVGElement::viewBoxToViewTransform(float viewWidth, float vie
wHeight) const | 672 AffineTransform SVGSVGElement::viewBoxToViewTransform(float viewWidth, float vie
wHeight) const |
| 675 { | 673 { |
| 676 if (!m_useCurrentView || !m_viewSpec) | 674 if (!m_useCurrentView || !m_viewSpec) |
| 677 return SVGFitToViewBox::viewBoxToViewTransform(currentViewBoxRect(), m_p
reserveAspectRatio->currentValue(), viewWidth, viewHeight); | 675 return SVGFitToViewBox::viewBoxToViewTransform(currentViewBoxRect(), pre
serveAspectRatio()->currentValue(), viewWidth, viewHeight); |
| 678 | 676 |
| 679 AffineTransform ctm = SVGFitToViewBox::viewBoxToViewTransform(currentViewBox
Rect(), m_viewSpec->preserveAspectRatio()->currentValue(), viewWidth, viewHeight
); | 677 AffineTransform ctm = SVGFitToViewBox::viewBoxToViewTransform(currentViewBox
Rect(), m_viewSpec->preserveAspectRatio()->currentValue(), viewWidth, viewHeight
); |
| 680 const SVGTransformList& transformList = m_viewSpec->transformBaseValue(); | 678 const SVGTransformList& transformList = m_viewSpec->transformBaseValue(); |
| 681 if (transformList.isEmpty()) | 679 if (transformList.isEmpty()) |
| 682 return ctm; | 680 return ctm; |
| 683 | 681 |
| 684 AffineTransform transform; | 682 AffineTransform transform; |
| 685 if (transformList.concatenate(transform)) | 683 if (transformList.concatenate(transform)) |
| 686 ctm *= transform; | 684 ctm *= transform; |
| 687 | 685 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 } | 739 } |
| 742 | 740 |
| 743 void SVGSVGElement::inheritViewAttributes(SVGViewElement* viewElement) | 741 void SVGSVGElement::inheritViewAttributes(SVGViewElement* viewElement) |
| 744 { | 742 { |
| 745 SVGViewSpec* view = currentView(); | 743 SVGViewSpec* view = currentView(); |
| 746 m_useCurrentView = true; | 744 m_useCurrentView = true; |
| 747 | 745 |
| 748 if (viewElement->hasAttribute(SVGNames::viewBoxAttr)) | 746 if (viewElement->hasAttribute(SVGNames::viewBoxAttr)) |
| 749 view->viewBox()->baseValue()->setValue(viewElement->viewBox()->currentVa
lue()->value()); | 747 view->viewBox()->baseValue()->setValue(viewElement->viewBox()->currentVa
lue()->value()); |
| 750 else | 748 else |
| 751 view->viewBox()->baseValue()->setValue(m_viewBox->currentValue()->value(
)); | 749 view->viewBox()->baseValue()->setValue(viewBox()->currentValue()->value(
)); |
| 752 | 750 |
| 753 if (viewElement->hasAttribute(SVGNames::preserveAspectRatioAttr)) { | 751 if (viewElement->hasAttribute(SVGNames::preserveAspectRatioAttr)) { |
| 754 view->preserveAspectRatio()->baseValue()->setAlign(viewElement->preserve
AspectRatio()->currentValue()->align()); | 752 view->preserveAspectRatio()->baseValue()->setAlign(viewElement->preserve
AspectRatio()->currentValue()->align()); |
| 755 view->preserveAspectRatio()->baseValue()->setMeetOrSlice(viewElement->pr
eserveAspectRatio()->currentValue()->meetOrSlice()); | 753 view->preserveAspectRatio()->baseValue()->setMeetOrSlice(viewElement->pr
eserveAspectRatio()->currentValue()->meetOrSlice()); |
| 756 } else { | 754 } else { |
| 757 view->preserveAspectRatio()->baseValue()->setAlign(m_preserveAspectRatio
->currentValue()->align()); | 755 view->preserveAspectRatio()->baseValue()->setAlign(preserveAspectRatio()
->currentValue()->align()); |
| 758 view->preserveAspectRatio()->baseValue()->setMeetOrSlice(m_preserveAspec
tRatio->currentValue()->meetOrSlice()); | 756 view->preserveAspectRatio()->baseValue()->setMeetOrSlice(preserveAspectR
atio()->currentValue()->meetOrSlice()); |
| 759 } | 757 } |
| 760 | 758 |
| 761 if (viewElement->hasAttribute(SVGNames::zoomAndPanAttr)) | 759 if (viewElement->hasAttribute(SVGNames::zoomAndPanAttr)) |
| 762 view->setZoomAndPan(viewElement->zoomAndPan()); | 760 view->setZoomAndPan(viewElement->zoomAndPan()); |
| 763 else | 761 else |
| 764 view->setZoomAndPan(zoomAndPan()); | 762 view->setZoomAndPan(zoomAndPan()); |
| 765 } | 763 } |
| 766 | 764 |
| 767 // getElementById on SVGSVGElement is restricted to only the child subtree defin
ed by the <svg> element. | 765 // getElementById on SVGSVGElement is restricted to only the child subtree defin
ed by the <svg> element. |
| 768 // See http://www.w3.org/TR/SVG11/struct.html#InterfaceSVGSVGElement | 766 // See http://www.w3.org/TR/SVG11/struct.html#InterfaceSVGSVGElement |
| (...skipping 10 matching lines...) Expand all Loading... |
| 779 continue; | 777 continue; |
| 780 | 778 |
| 781 Element* element = toElement(node); | 779 Element* element = toElement(node); |
| 782 if (element->getIdAttribute() == id) | 780 if (element->getIdAttribute() == id) |
| 783 return element; | 781 return element; |
| 784 } | 782 } |
| 785 return 0; | 783 return 0; |
| 786 } | 784 } |
| 787 | 785 |
| 788 } | 786 } |
| OLD | NEW |