• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KHTML

  • sources
  • kde-4.12
  • kdelibs
  • khtml
  • svg
SVGLineElement.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3  2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
4 
5  This file is part of the KDE project
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Library General Public
9  License as published by the Free Software Foundation; either
10  version 2 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Library General Public License for more details.
16 
17  You should have received a copy of the GNU Library General Public License
18  along with this library; see the file COPYING.LIB. If not, write to
19  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  Boston, MA 02110-1301, USA.
21 */
22 
23 #include "config.h"
24 #include "wtf/Platform.h"
25 
26 #if ENABLE(SVG)
27 #include "SVGLineElement.h"
28 
29 #include "FloatPoint.h"
30 #include "RenderPath.h"
31 #include "SVGLength.h"
32 #include "SVGNames.h"
33 
34 namespace WebCore {
35 
36 SVGLineElement::SVGLineElement(const QualifiedName& tagName, Document* doc)
37  : SVGStyledTransformableElement(tagName, doc)
38  , SVGTests()
39  , SVGLangSpace()
40  , SVGExternalResourcesRequired()
41  , m_x1(this, LengthModeWidth)
42  , m_y1(this, LengthModeHeight)
43  , m_x2(this, LengthModeWidth)
44  , m_y2(this, LengthModeHeight)
45 {
46 }
47 
48 SVGLineElement::~SVGLineElement()
49 {
50 }
51 
52 ANIMATED_PROPERTY_DEFINITIONS(SVGLineElement, SVGLength, Length, length, X1, x1, SVGNames::x1Attr, m_x1)
53 ANIMATED_PROPERTY_DEFINITIONS(SVGLineElement, SVGLength, Length, length, Y1, y1, SVGNames::y1Attr, m_y1)
54 ANIMATED_PROPERTY_DEFINITIONS(SVGLineElement, SVGLength, Length, length, X2, x2, SVGNames::x2Attr, m_x2)
55 ANIMATED_PROPERTY_DEFINITIONS(SVGLineElement, SVGLength, Length, length, Y2, y2, SVGNames::y2Attr, m_y2)
56 
57 void SVGLineElement::parseMappedAttribute(MappedAttribute* attr)
58 {
59  if (attr->name() == SVGNames::x1Attr)
60  setX1BaseValue(SVGLength(this, LengthModeWidth, attr->value()));
61  else if (attr->name() == SVGNames::y1Attr)
62  setY1BaseValue(SVGLength(this, LengthModeHeight, attr->value()));
63  else if (attr->name() == SVGNames::x2Attr)
64  setX2BaseValue(SVGLength(this, LengthModeWidth, attr->value()));
65  else if (attr->name() == SVGNames::y2Attr)
66  setY2BaseValue(SVGLength(this, LengthModeHeight, attr->value()));
67  else
68  {
69  if (SVGTests::parseMappedAttribute(attr))
70  return;
71  if (SVGLangSpace::parseMappedAttribute(attr))
72  return;
73  if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
74  return;
75  SVGStyledTransformableElement::parseMappedAttribute(attr);
76  }
77 }
78 
79 void SVGLineElement::svgAttributeChanged(const QualifiedName& attrName)
80 {
81  SVGStyledTransformableElement::svgAttributeChanged(attrName);
82 
83  if (!renderer())
84  return;
85 
86  if (attrName == SVGNames::x1Attr || attrName == SVGNames::y1Attr ||
87  attrName == SVGNames::x2Attr || attrName == SVGNames::y2Attr ||
88  SVGTests::isKnownAttribute(attrName) ||
89  SVGLangSpace::isKnownAttribute(attrName) ||
90  SVGExternalResourcesRequired::isKnownAttribute(attrName) ||
91  SVGStyledTransformableElement::isKnownAttribute(attrName))
92  renderer()->setNeedsLayout(true);
93 }
94 
95 Path SVGLineElement::toPathData() const
96 {
97  return Path::createLine(FloatPoint(x1().value(), y1().value()),
98  FloatPoint(x2().value(), y2().value()));
99 }
100 
101 bool SVGLineElement::hasRelativeValues() const
102 {
103  return (x1().isRelative() || y1().isRelative() ||
104  x2().isRelative() || y2().isRelative());
105 }
106 
107 }
108 
109 #endif // ENABLE(SVG)
WebCore::SVGNames::x1Attr
DOM::QualifiedName x1Attr
Definition: SVGNames.cpp:340
WebCore::SVGNames::y1Attr
DOM::QualifiedName y1Attr
Definition: SVGNames.cpp:344
SVGLength.h
WebCore::Path
khtml::Path Path
Definition: PathTraversalState.h:37
WebCore::SVGNames::x2Attr
DOM::QualifiedName x2Attr
Definition: SVGNames.cpp:341
FloatPoint.h
SVGNames.h
WebCore::SVGNames::y2Attr
DOM::QualifiedName y2Attr
Definition: SVGNames.cpp:345
SVGLineElement.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:51:22 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KHTML

Skip menu "KHTML"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal