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

KHTML

  • khtml
  • svg
SVGFilterPrimitiveStandardAttributes.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
3 2004, 2005, 2006 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
25#if ENABLE(SVG) && ENABLE(SVG_FILTERS)
26#include "SVGFilterPrimitiveStandardAttributes.h"
27
28#include "SVGFilterElement.h"
29#include "SVGFilterEffect.h"
30#include "SVGLength.h"
31#include "SVGNames.h"
32#include "SVGStyledElement.h"
33#include "SVGUnitTypes.h"
34
35namespace WebCore {
36
37SVGFilterPrimitiveStandardAttributes::SVGFilterPrimitiveStandardAttributes(const QualifiedName& tagName, Document* doc)
38 : SVGStyledElement(tagName, doc)
39 , m_x(this, LengthModeWidth)
40 , m_y(this, LengthModeHeight)
41 , m_width(this, LengthModeWidth)
42 , m_height(this, LengthModeHeight)
43{
44 // Spec: If the attribute is not specified, the effect is as if a value of "0%" were specified.
45 setXBaseValue(SVGLength(this, LengthModeWidth, "0%"));
46 setYBaseValue(SVGLength(this, LengthModeHeight, "0%"));
47
48 // Spec: If the attribute is not specified, the effect is as if a value of "100%" were specified.
49 setWidthBaseValue(SVGLength(this, LengthModeWidth, "100%"));
50 setHeightBaseValue(SVGLength(this, LengthModeHeight, "100%"));
51}
52
53SVGFilterPrimitiveStandardAttributes::~SVGFilterPrimitiveStandardAttributes()
54{
55}
56
57ANIMATED_PROPERTY_DEFINITIONS(SVGFilterPrimitiveStandardAttributes, SVGLength, Length, length, X, x, SVGNames::xAttr, m_x)
58ANIMATED_PROPERTY_DEFINITIONS(SVGFilterPrimitiveStandardAttributes, SVGLength, Length, length, Y, y, SVGNames::yAttr, m_y)
59ANIMATED_PROPERTY_DEFINITIONS(SVGFilterPrimitiveStandardAttributes, SVGLength, Length, length, Width, width, SVGNames::widthAttr, m_width)
60ANIMATED_PROPERTY_DEFINITIONS(SVGFilterPrimitiveStandardAttributes, SVGLength, Length, length, Height, height, SVGNames::heightAttr, m_height)
61ANIMATED_PROPERTY_DEFINITIONS(SVGFilterPrimitiveStandardAttributes, String, String, string, Result, result, SVGNames::resultAttr, m_result)
62
63void SVGFilterPrimitiveStandardAttributes::parseMappedAttribute(MappedAttribute* attr)
64{
65 const AtomicString& value = attr->value();
66 if (attr->name() == SVGNames::xAttr)
67 setXBaseValue(SVGLength(this, LengthModeWidth, value));
68 else if (attr->name() == SVGNames::yAttr)
69 setYBaseValue(SVGLength(this, LengthModeHeight, value));
70 else if (attr->name() == SVGNames::widthAttr)
71 setWidthBaseValue(SVGLength(this, LengthModeWidth, value));
72 else if (attr->name() == SVGNames::heightAttr)
73 setHeightBaseValue(SVGLength(this, LengthModeHeight, value));
74 else if (attr->name() == SVGNames::resultAttr)
75 setResultBaseValue(value);
76 else
77 return SVGStyledElement::parseMappedAttribute(attr);
78}
79
80void SVGFilterPrimitiveStandardAttributes::setStandardAttributes(SVGFilterEffect* filterEffect) const
81{
82 ASSERT(filterEffect);
83 if (!filterEffect)
84 return;
85
86 ASSERT(filterEffect->filter());
87
88 float _x, _y, _width, _height;
89
90 if (filterEffect->filter()->effectBoundingBoxMode()) {
91 _x = x().valueAsPercentage();
92 _y = y().valueAsPercentage();
93 _width = width().valueAsPercentage();
94 _height = height().valueAsPercentage();
95 } else {
96 // We need to resolve any percentages in filter rect space.
97 if (x().unitType() == LengthTypePercentage) {
98 filterEffect->setXBoundingBoxMode(true);
99 _x = x().valueAsPercentage();
100 } else {
101 filterEffect->setXBoundingBoxMode(false);
102 _x = x().value();
103 }
104
105 if (y().unitType() == LengthTypePercentage) {
106 filterEffect->setYBoundingBoxMode(true);
107 _y = y().valueAsPercentage();
108 } else {
109 filterEffect->setYBoundingBoxMode(false);
110 _y = y().value();
111 }
112
113 if (width().unitType() == LengthTypePercentage) {
114 filterEffect->setWidthBoundingBoxMode(true);
115 _width = width().valueAsPercentage();
116 } else {
117 filterEffect->setWidthBoundingBoxMode(false);
118 _width = width().value();
119 }
120
121 if (height().unitType() == LengthTypePercentage) {
122 filterEffect->setHeightBoundingBoxMode(true);
123 _height = height().valueAsPercentage();
124 } else {
125 filterEffect->setHeightBoundingBoxMode(false);
126 _height = height().value();
127 }
128 }
129
130 filterEffect->setSubRegion(FloatRect(_x, _y, _width, _height));
131 filterEffect->setResult(result());
132}
133
134}
135
136#endif // ENABLE(SVG)
137
138// vim:ts=4:noet
SVGFilterEffect.h
SVGFilterElement.h
SVGFilterPrimitiveStandardAttributes.h
SVGLength.h
SVGNames.h
SVGStyledElement.h
SVGUnitTypes.h
WebCore
Definition: CSSHelper.h:7
X
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 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-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 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
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
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