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 "core/svg/SVGParserUtilities.h" 26 27namespace blink { 28 29SVGZoomAndPan::SVGZoomAndPan() 30 : m_zoomAndPan(SVGZoomAndPanMagnify) 31{ 32} 33 34void SVGZoomAndPan::resetZoomAndPan() 35{ 36 m_zoomAndPan = SVGZoomAndPanMagnify; 37} 38 39bool SVGZoomAndPan::isKnownAttribute(const QualifiedName& attrName) 40{ 41 return attrName == SVGNames::zoomAndPanAttr; 42} 43 44void SVGZoomAndPan::addSupportedAttributes(HashSet<QualifiedName>& supportedAttributes) 45{ 46 supportedAttributes.add(SVGNames::zoomAndPanAttr); 47} 48 49static const LChar disable[] = {'d', 'i', 's', 'a', 'b', 'l', 'e'}; 50static const LChar magnify[] = {'m', 'a', 'g', 'n', 'i', 'f', 'y'}; 51 52template<typename CharType> 53static bool parseZoomAndPanInternal(const CharType*& start, const CharType* end, SVGZoomAndPanType& zoomAndPan) 54{ 55 if (skipString(start, end, disable, WTF_ARRAY_LENGTH(disable))) { 56 zoomAndPan = SVGZoomAndPanDisable; 57 return true; 58 } 59 if (skipString(start, end, magnify, WTF_ARRAY_LENGTH(magnify))) { 60 zoomAndPan = SVGZoomAndPanMagnify; 61 return true; 62 } 63 return false; 64} 65 66bool SVGZoomAndPan::parseZoomAndPan(const LChar*& start, const LChar* end) 67{ 68 return parseZoomAndPanInternal(start, end, m_zoomAndPan); 69} 70 71bool SVGZoomAndPan::parseZoomAndPan(const UChar*& start, const UChar* end) 72{ 73 return parseZoomAndPanInternal(start, end, m_zoomAndPan); 74} 75 76} 77