• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) Research In Motion Limited 2010. All rights reserved.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public License
15  * along with this library; see the file COPYING.LIB.  If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19 
20 #ifndef SVGTransformListPropertyTearOff_h
21 #define SVGTransformListPropertyTearOff_h
22 
23 #if ENABLE(SVG)
24 #include "SVGListPropertyTearOff.h"
25 #include "SVGTransformList.h"
26 
27 namespace WebCore {
28 
29 // SVGTransformList contains two additional methods, that can be exposed to the bindings.
30 class SVGTransformListPropertyTearOff : public SVGListPropertyTearOff<SVGTransformList> {
31 public:
32     typedef SVGAnimatedListPropertyTearOff<SVGTransformList> AnimatedListPropertyTearOff;
33     typedef SVGAnimatedListPropertyTearOff<SVGTransformList>::ListWrapperCache ListWrapperCache;
34 
create(AnimatedListPropertyTearOff * animatedProperty,SVGPropertyRole role)35     static PassRefPtr<SVGListPropertyTearOff<SVGTransformList> > create(AnimatedListPropertyTearOff* animatedProperty, SVGPropertyRole role)
36     {
37         ASSERT(animatedProperty);
38         return adoptRef(new SVGTransformListPropertyTearOff(animatedProperty, role));
39     }
40 
createSVGTransformFromMatrix(SVGPropertyTearOff<SVGMatrix> * matrix,ExceptionCode & ec)41     PassRefPtr<SVGPropertyTearOff<SVGTransform> > createSVGTransformFromMatrix(SVGPropertyTearOff<SVGMatrix>* matrix, ExceptionCode& ec)
42     {
43         if (!matrix) {
44             ec = TYPE_MISMATCH_ERR;
45             return 0;
46         }
47         SVGTransformList& values = m_animatedProperty->values();
48         return SVGPropertyTearOff<SVGTransform>::create(values.createSVGTransformFromMatrix(matrix->propertyReference()));
49     }
50 
consolidate(ExceptionCode & ec)51     PassRefPtr<SVGPropertyTearOff<SVGTransform> > consolidate(ExceptionCode& ec)
52     {
53         if (!canAlterList(ec))
54             return 0;
55 
56         SVGTransformList& values = m_animatedProperty->values();
57         ListWrapperCache& wrappers = m_animatedProperty->wrappers();
58         ASSERT(values.size() == wrappers.size());
59 
60         // Spec: If the list was empty, then a value of null is returned.
61         if (values.isEmpty())
62             return 0;
63 
64         m_animatedProperty->detachListWrappers(0);
65         RefPtr<SVGPropertyTearOff<SVGTransform> > wrapper = SVGPropertyTearOff<SVGTransform>::create(values.consolidate());
66         wrappers.append(wrapper);
67 
68         ASSERT(values.size() == wrappers.size());
69         return wrapper.release();
70     }
71 
72 private:
SVGTransformListPropertyTearOff(AnimatedListPropertyTearOff * animatedProperty,SVGPropertyRole role)73     SVGTransformListPropertyTearOff(AnimatedListPropertyTearOff* animatedProperty, SVGPropertyRole role)
74         : SVGListPropertyTearOff<SVGTransformList>(animatedProperty, role)
75     {
76     }
77 
78 };
79 
80 }
81 
82 #endif // ENABLE(SVG)
83 #endif // SVGListPropertyTearOff_h
84