| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 , m_x(SVGAnimatedLength::create(this, SVGNames::xAttr, SVGLength::create(Len
gthModeWidth))) | 73 , m_x(SVGAnimatedLength::create(this, SVGNames::xAttr, SVGLength::create(Len
gthModeWidth))) |
| 74 , m_y(SVGAnimatedLength::create(this, SVGNames::yAttr, SVGLength::create(Len
gthModeHeight))) | 74 , m_y(SVGAnimatedLength::create(this, SVGNames::yAttr, SVGLength::create(Len
gthModeHeight))) |
| 75 , m_width(SVGAnimatedLength::create(this, SVGNames::widthAttr, SVGLength::cr
eate(LengthModeWidth))) | 75 , m_width(SVGAnimatedLength::create(this, SVGNames::widthAttr, SVGLength::cr
eate(LengthModeWidth))) |
| 76 , m_height(SVGAnimatedLength::create(this, SVGNames::heightAttr, SVGLength::
create(LengthModeHeight))) | 76 , m_height(SVGAnimatedLength::create(this, SVGNames::heightAttr, SVGLength::
create(LengthModeHeight))) |
| 77 , m_viewBox(SVGAnimatedRect::create(this, SVGNames::viewBoxAttr)) | 77 , m_viewBox(SVGAnimatedRect::create(this, SVGNames::viewBoxAttr)) |
| 78 , m_preserveAspectRatio(SVGAnimatedPreserveAspectRatio::create(this, SVGName
s::preserveAspectRatioAttr, SVGPreserveAspectRatio::create())) | 78 , m_preserveAspectRatio(SVGAnimatedPreserveAspectRatio::create(this, SVGName
s::preserveAspectRatioAttr, SVGPreserveAspectRatio::create())) |
| 79 , m_useCurrentView(false) | 79 , m_useCurrentView(false) |
| 80 , m_zoomAndPan(SVGZoomAndPanMagnify) | |
| 81 , m_timeContainer(SMILTimeContainer::create(this)) | 80 , m_timeContainer(SMILTimeContainer::create(this)) |
| 82 , m_translation(SVGPoint::create()) | 81 , m_translation(SVGPoint::create()) |
| 83 { | 82 { |
| 84 ScriptWrappable::init(this); | 83 ScriptWrappable::init(this); |
| 85 | 84 |
| 86 m_width->setDefaultValueAsString("100%"); | 85 m_width->setDefaultValueAsString("100%"); |
| 87 m_height->setDefaultValueAsString("100%"); | 86 m_height->setDefaultValueAsString("100%"); |
| 88 | 87 |
| 89 addToPropertyMap(m_x); | 88 addToPropertyMap(m_x); |
| 90 addToPropertyMap(m_y); | 89 addToPropertyMap(m_y); |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 document().setWindowAttributeEventListener(EventTypeNames::scroll, c
reateAttributeEventListener(document().frame(), name, value)); | 264 document().setWindowAttributeEventListener(EventTypeNames::scroll, c
reateAttributeEventListener(document().frame(), name, value)); |
| 266 else if (name == SVGNames::onzoomAttr) | 265 else if (name == SVGNames::onzoomAttr) |
| 267 document().setWindowAttributeEventListener(EventTypeNames::zoom, cre
ateAttributeEventListener(document().frame(), name, value)); | 266 document().setWindowAttributeEventListener(EventTypeNames::zoom, cre
ateAttributeEventListener(document().frame(), name, value)); |
| 268 else | 267 else |
| 269 setListener = false; | 268 setListener = false; |
| 270 | 269 |
| 271 if (setListener) | 270 if (setListener) |
| 272 return; | 271 return; |
| 273 } | 272 } |
| 274 | 273 |
| 275 if (name == HTMLNames::onabortAttr) | 274 if (name == HTMLNames::onabortAttr) { |
| 276 document().setWindowAttributeEventListener(EventTypeNames::abort, create
AttributeEventListener(document().frame(), name, value)); | 275 document().setWindowAttributeEventListener(EventTypeNames::abort, create
AttributeEventListener(document().frame(), name, value)); |
| 277 else if (name == HTMLNames::onerrorAttr) | 276 } else if (name == HTMLNames::onerrorAttr) { |
| 278 document().setWindowAttributeEventListener(EventTypeNames::error, create
AttributeEventListener(document().frame(), name, value)); | 277 document().setWindowAttributeEventListener(EventTypeNames::error, create
AttributeEventListener(document().frame(), name, value)); |
| 279 else if (name == SVGNames::xAttr) | 278 } else if (name == SVGNames::xAttr) { |
| 280 m_x->setBaseValueAsString(value, AllowNegativeLengths, parseError); | 279 m_x->setBaseValueAsString(value, AllowNegativeLengths, parseError); |
| 281 else if (name == SVGNames::yAttr) | 280 } else if (name == SVGNames::yAttr) { |
| 282 m_y->setBaseValueAsString(value, AllowNegativeLengths, parseError); | 281 m_y->setBaseValueAsString(value, AllowNegativeLengths, parseError); |
| 283 else if (name == SVGNames::widthAttr) | 282 } else if (name == SVGNames::widthAttr) { |
| 284 m_width->setBaseValueAsString(value, ForbidNegativeLengths, parseError); | 283 m_width->setBaseValueAsString(value, ForbidNegativeLengths, parseError); |
| 285 else if (name == SVGNames::heightAttr) | 284 } else if (name == SVGNames::heightAttr) { |
| 286 m_height->setBaseValueAsString(value, ForbidNegativeLengths, parseError)
; | 285 m_height->setBaseValueAsString(value, ForbidNegativeLengths, parseError)
; |
| 287 else if (SVGFitToViewBox::parseAttribute(this, name, value) | 286 } else if (SVGFitToViewBox::parseAttribute(this, name, value) || SVGZoomAndP
an::parseAttribute(name, value)) { |
| 288 || SVGZoomAndPan::parseAttribute(this, name, value)) { | 287 } else { |
| 289 } else | |
| 290 SVGGraphicsElement::parseAttribute(name, value); | 288 SVGGraphicsElement::parseAttribute(name, value); |
| 289 } |
| 291 | 290 |
| 292 reportAttributeParsingError(parseError, name, value); | 291 reportAttributeParsingError(parseError, name, value); |
| 293 } | 292 } |
| 294 | 293 |
| 295 void SVGSVGElement::svgAttributeChanged(const QualifiedName& attrName) | 294 void SVGSVGElement::svgAttributeChanged(const QualifiedName& attrName) |
| 296 { | 295 { |
| 297 bool updateRelativeLengthsOrViewBox = false; | 296 bool updateRelativeLengthsOrViewBox = false; |
| 298 bool widthChanged = attrName == SVGNames::widthAttr; | 297 bool widthChanged = attrName == SVGNames::widthAttr; |
| 299 if (widthChanged | 298 if (widthChanged |
| 300 || attrName == SVGNames::heightAttr | 299 || attrName == SVGNames::heightAttr |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 753 | 752 |
| 754 if (viewElement->hasAttribute(SVGNames::preserveAspectRatioAttr)) { | 753 if (viewElement->hasAttribute(SVGNames::preserveAspectRatioAttr)) { |
| 755 view->preserveAspectRatio()->baseValue()->setAlign(viewElement->preserve
AspectRatio()->currentValue()->align()); | 754 view->preserveAspectRatio()->baseValue()->setAlign(viewElement->preserve
AspectRatio()->currentValue()->align()); |
| 756 view->preserveAspectRatio()->baseValue()->setMeetOrSlice(viewElement->pr
eserveAspectRatio()->currentValue()->meetOrSlice()); | 755 view->preserveAspectRatio()->baseValue()->setMeetOrSlice(viewElement->pr
eserveAspectRatio()->currentValue()->meetOrSlice()); |
| 757 } else { | 756 } else { |
| 758 view->preserveAspectRatio()->baseValue()->setAlign(m_preserveAspectRatio
->currentValue()->align()); | 757 view->preserveAspectRatio()->baseValue()->setAlign(m_preserveAspectRatio
->currentValue()->align()); |
| 759 view->preserveAspectRatio()->baseValue()->setMeetOrSlice(m_preserveAspec
tRatio->currentValue()->meetOrSlice()); | 758 view->preserveAspectRatio()->baseValue()->setMeetOrSlice(m_preserveAspec
tRatio->currentValue()->meetOrSlice()); |
| 760 } | 759 } |
| 761 | 760 |
| 762 if (viewElement->hasAttribute(SVGNames::zoomAndPanAttr)) | 761 if (viewElement->hasAttribute(SVGNames::zoomAndPanAttr)) |
| 763 view->setZoomAndPanBaseValue(viewElement->zoomAndPan()); | 762 view->setZoomAndPan(viewElement->zoomAndPan()); |
| 764 else | 763 else |
| 765 view->setZoomAndPanBaseValue(zoomAndPan()); | 764 view->setZoomAndPan(zoomAndPan()); |
| 766 } | 765 } |
| 767 | 766 |
| 768 // getElementById on SVGSVGElement is restricted to only the child subtree defin
ed by the <svg> element. | 767 // getElementById on SVGSVGElement is restricted to only the child subtree defin
ed by the <svg> element. |
| 769 // See http://www.w3.org/TR/SVG11/struct.html#InterfaceSVGSVGElement | 768 // See http://www.w3.org/TR/SVG11/struct.html#InterfaceSVGSVGElement |
| 770 Element* SVGSVGElement::getElementById(const AtomicString& id) const | 769 Element* SVGSVGElement::getElementById(const AtomicString& id) const |
| 771 { | 770 { |
| 772 Element* element = treeScope().getElementById(id); | 771 Element* element = treeScope().getElementById(id); |
| 773 if (element && element->isDescendantOf(this)) | 772 if (element && element->isDescendantOf(this)) |
| 774 return element; | 773 return element; |
| 775 | 774 |
| 776 // Fall back to traversing our subtree. Duplicate ids are allowed, the first
found will | 775 // Fall back to traversing our subtree. Duplicate ids are allowed, the first
found will |
| 777 // be returned. | 776 // be returned. |
| 778 for (Node* node = firstChild(); node; node = NodeTraversal::next(*node, this
)) { | 777 for (Node* node = firstChild(); node; node = NodeTraversal::next(*node, this
)) { |
| 779 if (!node->isElementNode()) | 778 if (!node->isElementNode()) |
| 780 continue; | 779 continue; |
| 781 | 780 |
| 782 Element* element = toElement(node); | 781 Element* element = toElement(node); |
| 783 if (element->getIdAttribute() == id) | 782 if (element->getIdAttribute() == id) |
| 784 return element; | 783 return element; |
| 785 } | 784 } |
| 786 return 0; | 785 return 0; |
| 787 } | 786 } |
| 788 | 787 |
| 789 } | 788 } |
| OLD | NEW |