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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 inline SVGSVGElement::SVGSVGElement(Document& doc) | 72 inline SVGSVGElement::SVGSVGElement(Document& doc) |
73 : SVGGraphicsElement(SVGNames::svgTag, doc) | 73 : SVGGraphicsElement(SVGNames::svgTag, doc) |
74 , m_x(SVGAnimatedLength::create(this, SVGNames::xAttr, SVGLength::create(Len
gthModeWidth))) | 74 , m_x(SVGAnimatedLength::create(this, SVGNames::xAttr, SVGLength::create(Len
gthModeWidth))) |
75 , m_y(SVGAnimatedLength::create(this, SVGNames::yAttr, SVGLength::create(Len
gthModeHeight))) | 75 , m_y(SVGAnimatedLength::create(this, SVGNames::yAttr, SVGLength::create(Len
gthModeHeight))) |
76 , m_width(SVGAnimatedLength::create(this, SVGNames::widthAttr, SVGLength::cr
eate(LengthModeWidth))) | 76 , m_width(SVGAnimatedLength::create(this, SVGNames::widthAttr, SVGLength::cr
eate(LengthModeWidth))) |
77 , m_height(SVGAnimatedLength::create(this, SVGNames::heightAttr, SVGLength::
create(LengthModeHeight))) | 77 , m_height(SVGAnimatedLength::create(this, SVGNames::heightAttr, SVGLength::
create(LengthModeHeight))) |
78 , m_viewBox(SVGAnimatedRect::create(this, SVGNames::viewBoxAttr)) | 78 , m_viewBox(SVGAnimatedRect::create(this, SVGNames::viewBoxAttr)) |
79 , m_useCurrentView(false) | 79 , m_useCurrentView(false) |
80 , m_zoomAndPan(SVGZoomAndPanMagnify) | 80 , m_zoomAndPan(SVGZoomAndPanMagnify) |
81 , m_timeContainer(SMILTimeContainer::create(this)) | 81 , m_timeContainer(SMILTimeContainer::create(this)) |
| 82 , m_translation(SVGPoint::create()) |
82 { | 83 { |
83 ScriptWrappable::init(this); | 84 ScriptWrappable::init(this); |
84 | 85 |
85 m_width->setDefaultValueAsString("100%"); | 86 m_width->setDefaultValueAsString("100%"); |
86 m_height->setDefaultValueAsString("100%"); | 87 m_height->setDefaultValueAsString("100%"); |
87 | 88 |
88 addToPropertyMap(m_x); | 89 addToPropertyMap(m_x); |
89 addToPropertyMap(m_y); | 90 addToPropertyMap(m_y); |
90 addToPropertyMap(m_width); | 91 addToPropertyMap(m_width); |
91 addToPropertyMap(m_height); | 92 addToPropertyMap(m_height); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 | 201 |
201 // The behaviour of setCurrentScale() is undefined, when we're dealing with
non-standalone SVG documents. | 202 // The behaviour of setCurrentScale() is undefined, when we're dealing with
non-standalone SVG documents. |
202 // We choose the ignore this call, it's pretty useless to support calling se
tCurrentScale() from within | 203 // We choose the ignore this call, it's pretty useless to support calling se
tCurrentScale() from within |
203 // an embedded SVG document, for the same reasons as in currentScale() - nee
ds resolution by SVG WG. | 204 // an embedded SVG document, for the same reasons as in currentScale() - nee
ds resolution by SVG WG. |
204 if (frameTree.parent()) | 205 if (frameTree.parent()) |
205 return; | 206 return; |
206 | 207 |
207 frame->setPageZoomFactor(scale); | 208 frame->setPageZoomFactor(scale); |
208 } | 209 } |
209 | 210 |
210 void SVGSVGElement::setCurrentTranslate(const FloatPoint& translation) | 211 class SVGCurrentTranslateTearOff : public SVGPointTearOff { |
| 212 public: |
| 213 static PassRefPtr<SVGCurrentTranslateTearOff> create(SVGSVGElement* contextE
lement) |
| 214 { |
| 215 return adoptRef(new SVGCurrentTranslateTearOff(contextElement)); |
| 216 } |
| 217 |
| 218 virtual void commitChange() OVERRIDE |
| 219 { |
| 220 ASSERT(contextElement()); |
| 221 toSVGSVGElement(contextElement())->updateCurrentTranslate(); |
| 222 } |
| 223 |
| 224 private: |
| 225 SVGCurrentTranslateTearOff(SVGSVGElement* contextElement) |
| 226 : SVGPointTearOff(contextElement->m_translation, contextElement, Propert
yIsNotAnimVal) |
| 227 { |
| 228 } |
| 229 }; |
| 230 |
| 231 PassRefPtr<SVGPointTearOff> SVGSVGElement::currentTranslateFromJavascript() |
211 { | 232 { |
212 m_translation = translation; | 233 return SVGCurrentTranslateTearOff::create(this); |
| 234 } |
| 235 |
| 236 void SVGSVGElement::setCurrentTranslate(const FloatPoint& point) |
| 237 { |
| 238 m_translation->setValue(point); |
213 updateCurrentTranslate(); | 239 updateCurrentTranslate(); |
214 } | 240 } |
215 | 241 |
216 void SVGSVGElement::updateCurrentTranslate() | 242 void SVGSVGElement::updateCurrentTranslate() |
217 { | 243 { |
218 if (RenderObject* object = renderer()) | 244 if (RenderObject* object = renderer()) |
219 object->setNeedsLayout(); | 245 object->setNeedsLayout(); |
220 | 246 |
221 if (parentNode() == document() && document().renderer()) | 247 if (parentNode() == document() && document().renderer()) |
222 document().renderer()->repaint(); | 248 document().renderer()->repaint(); |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 PassRefPtr<SVGLengthTearOff> SVGSVGElement::createSVGLength() | 414 PassRefPtr<SVGLengthTearOff> SVGSVGElement::createSVGLength() |
389 { | 415 { |
390 return SVGLengthTearOff::create(SVGLength::create(), 0, PropertyIsNotAnimVal
); | 416 return SVGLengthTearOff::create(SVGLength::create(), 0, PropertyIsNotAnimVal
); |
391 } | 417 } |
392 | 418 |
393 SVGAngle SVGSVGElement::createSVGAngle() | 419 SVGAngle SVGSVGElement::createSVGAngle() |
394 { | 420 { |
395 return SVGAngle(); | 421 return SVGAngle(); |
396 } | 422 } |
397 | 423 |
398 SVGPoint SVGSVGElement::createSVGPoint() | 424 PassRefPtr<SVGPointTearOff> SVGSVGElement::createSVGPoint() |
399 { | 425 { |
400 return SVGPoint(); | 426 return SVGPointTearOff::create(SVGPoint::create(), 0, PropertyIsNotAnimVal); |
401 } | 427 } |
402 | 428 |
403 SVGMatrix SVGSVGElement::createSVGMatrix() | 429 SVGMatrix SVGSVGElement::createSVGMatrix() |
404 { | 430 { |
405 return SVGMatrix(); | 431 return SVGMatrix(); |
406 } | 432 } |
407 | 433 |
408 PassRefPtr<SVGRectTearOff> SVGSVGElement::createSVGRect() | 434 PassRefPtr<SVGRectTearOff> SVGSVGElement::createSVGRect() |
409 { | 435 { |
410 return SVGRectTearOff::create(SVGRect::create(), 0, PropertyIsNotAnimVal); | 436 return SVGRectTearOff::create(SVGRect::create(), 0, PropertyIsNotAnimVal); |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
773 continue; | 799 continue; |
774 | 800 |
775 Element* element = toElement(node); | 801 Element* element = toElement(node); |
776 if (element->getIdAttribute() == id) | 802 if (element->getIdAttribute() == id) |
777 return element; | 803 return element; |
778 } | 804 } |
779 return 0; | 805 return 0; |
780 } | 806 } |
781 | 807 |
782 } | 808 } |
OLD | NEW |