2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
4 * Copyright (C) 2014 Samsung Electronics. All rights reserved.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
23 #include "core/svg/SVGZoomAndPan.h"
25 #include "bindings/v8/ExceptionMessages.h"
26 #include "bindings/v8/ExceptionState.h"
27 #include "core/svg/SVGParserUtilities.h"
31 SVGZoomAndPan::SVGZoomAndPan()
32 : m_zoomAndPan(SVGZoomAndPanMagnify)
36 void SVGZoomAndPan::resetZoomAndPan()
38 m_zoomAndPan = SVGZoomAndPanMagnify;
41 bool SVGZoomAndPan::isKnownAttribute(const QualifiedName& attrName)
43 return attrName == SVGNames::zoomAndPanAttr;
46 void SVGZoomAndPan::addSupportedAttributes(HashSet<QualifiedName>& supportedAttributes)
48 supportedAttributes.add(SVGNames::zoomAndPanAttr);
51 static const LChar disable[] = {'d', 'i', 's', 'a', 'b', 'l', 'e'};
52 static const LChar magnify[] = {'m', 'a', 'g', 'n', 'i', 'f', 'y'};
54 template<typename CharType>
55 static bool parseZoomAndPanInternal(const CharType*& start, const CharType* end, SVGZoomAndPanType& zoomAndPan)
57 if (skipString(start, end, disable, WTF_ARRAY_LENGTH(disable))) {
58 zoomAndPan = SVGZoomAndPanDisable;
61 if (skipString(start, end, magnify, WTF_ARRAY_LENGTH(magnify))) {
62 zoomAndPan = SVGZoomAndPanMagnify;
68 bool SVGZoomAndPan::parseZoomAndPan(const LChar*& start, const LChar* end)
70 return parseZoomAndPanInternal(start, end, m_zoomAndPan);
73 bool SVGZoomAndPan::parseZoomAndPan(const UChar*& start, const UChar* end)
75 return parseZoomAndPanInternal(start, end, m_zoomAndPan);
78 void SVGZoomAndPan::setZoomAndPan(SVGViewSpec*, unsigned short, ExceptionState& exceptionState)
80 // SVGViewSpec and all of its content is read-only.
81 exceptionState.throwDOMException(NoModificationAllowedError, ExceptionMessages::readOnly());