714d0439f337a8ba53c705b153a7f2d5ff3d58c5
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / svg / SVGZoomAndPan.cpp
1 /*
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.
5  *
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.
10  *
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.
15  *
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.
20  */
21
22 #include "config.h"
23 #include "core/svg/SVGZoomAndPan.h"
24
25 #include "bindings/v8/ExceptionMessages.h"
26 #include "bindings/v8/ExceptionState.h"
27 #include "core/svg/SVGParserUtilities.h"
28
29 namespace WebCore {
30
31 SVGZoomAndPan::SVGZoomAndPan()
32     : m_zoomAndPan(SVGZoomAndPanMagnify)
33 {
34 }
35
36 void SVGZoomAndPan::resetZoomAndPan()
37 {
38     m_zoomAndPan = SVGZoomAndPanMagnify;
39 }
40
41 bool SVGZoomAndPan::isKnownAttribute(const QualifiedName& attrName)
42 {
43     return attrName == SVGNames::zoomAndPanAttr;
44 }
45
46 void SVGZoomAndPan::addSupportedAttributes(HashSet<QualifiedName>& supportedAttributes)
47 {
48     supportedAttributes.add(SVGNames::zoomAndPanAttr);
49 }
50
51 static const LChar disable[] =  {'d', 'i', 's', 'a', 'b', 'l', 'e'};
52 static const LChar magnify[] =  {'m', 'a', 'g', 'n', 'i', 'f', 'y'};
53
54 template<typename CharType>
55 static bool parseZoomAndPanInternal(const CharType*& start, const CharType* end, SVGZoomAndPanType& zoomAndPan)
56 {
57     if (skipString(start, end, disable, WTF_ARRAY_LENGTH(disable))) {
58         zoomAndPan = SVGZoomAndPanDisable;
59         return true;
60     }
61     if (skipString(start, end, magnify, WTF_ARRAY_LENGTH(magnify))) {
62         zoomAndPan = SVGZoomAndPanMagnify;
63         return true;
64     }
65     return false;
66 }
67
68 bool SVGZoomAndPan::parseZoomAndPan(const LChar*& start, const LChar* end)
69 {
70     return parseZoomAndPanInternal(start, end, m_zoomAndPan);
71 }
72
73 bool SVGZoomAndPan::parseZoomAndPan(const UChar*& start, const UChar* end)
74 {
75     return parseZoomAndPanInternal(start, end, m_zoomAndPan);
76 }
77
78 void SVGZoomAndPan::setZoomAndPan(SVGViewSpec*, unsigned short, ExceptionState& exceptionState)
79 {
80     // SVGViewSpec and all of its content is read-only.
81     exceptionState.throwDOMException(NoModificationAllowedError, ExceptionMessages::readOnly());
82 }
83
84 }