1d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)/*
2d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) * Copyright (C) 2014 Google Inc. All rights reserved.
3d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) *
4d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) * Redistribution and use in source and binary forms, with or without
5d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) * modification, are permitted provided that the following conditions are
6d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) * met:
7d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) *
8d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) *     * Redistributions of source code must retain the above copyright
9d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) * notice, this list of conditions and the following disclaimer.
10d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) *     * Redistributions in binary form must reproduce the above
11d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) * copyright notice, this list of conditions and the following disclaimer
12d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) * in the documentation and/or other materials provided with the
13d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) * distribution.
14d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) *     * Neither the name of Google Inc. nor the names of its
15d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) * contributors may be used to endorse or promote products derived from
16d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) * this software without specific prior written permission.
17d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) *
18d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) */
30d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)
31d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)#ifndef SVGPathSegListTearOff_h
32d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)#define SVGPathSegListTearOff_h
33d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)
345d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)#include "core/SVGNames.h"
35d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)#include "core/svg/SVGPathSegList.h"
3607a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch#include "core/svg/properties/SVGListPropertyTearOffHelper.h"
37d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)
38c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)namespace blink {
39d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)
40d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)template<>
41d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)class ListItemPropertyTraits<SVGPathSeg> {
42d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)public:
43d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)    typedef SVGPathSeg ItemPropertyType;
44d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)    // FIXME: Currently SVGPathSegitself is a tear-off.
45d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)    typedef SVGPathSeg ItemTearOffType;
46d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)
475d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)    static PassRefPtr<ItemPropertyType> getValueForInsertionFromTearOff(PassRefPtr<ItemTearOffType> passNewItem, SVGElement* contextElement, const QualifiedName& attributeName)
48d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)    {
495d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)        ASSERT(attributeName == SVGNames::dAttr);
505d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)        RefPtr<ItemTearOffType> newItem = passNewItem;
515d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)        newItem->setContextElement(contextElement);
525d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)        return newItem.release();
53d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)    }
54d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)
55d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)    static PassRefPtr<ItemTearOffType> createTearOff(PassRefPtr<ItemPropertyType> passValue, SVGElement* contextElement, PropertyIsAnimValType, const QualifiedName&)
56d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)    {
57d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)        RefPtr<SVGPathSeg> value = passValue;
58d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)        value->setContextElement(contextElement);
59d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)        return value.release();
60d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)    }
61d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)};
62d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)
63c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)class SVGPathSegListTearOff FINAL
64c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)    : public SVGListPropertyTearOffHelper<SVGPathSegListTearOff, SVGPathSegList>
65c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)    , public ScriptWrappable {
667242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci    DEFINE_WRAPPERTYPEINFO();
67d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)public:
685d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)    static PassRefPtr<SVGPathSegListTearOff> create(PassRefPtr<SVGPathSegList> target, SVGElement* contextElement, PropertyIsAnimValType propertyIsAnimVal, const QualifiedName& attributeName = QualifiedName::null())
69d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)    {
70d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)        return adoptRef(new SVGPathSegListTearOff(target, contextElement, propertyIsAnimVal, attributeName));
71d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)    }
72d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)
73d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)private:
745d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)    SVGPathSegListTearOff(PassRefPtr<SVGPathSegList> target, SVGElement* contextElement, PropertyIsAnimValType propertyIsAnimVal, const QualifiedName& attributeName = QualifiedName::null())
757242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci        : SVGListPropertyTearOffHelper<SVGPathSegListTearOff, SVGPathSegList>(target, contextElement, propertyIsAnimVal, attributeName) { }
76d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)};
77d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)
78c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)} // namespace blink
79d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles)
807242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci#endif // SVGPathSegListTearOff_h
81