Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(367)

Side by Side Diff: Source/core/svg/properties/SVGStaticPropertyWithParentTearOff.h

Issue 23537049: Merge 157801 "Fix lifetime handling of SVGPropertyTearOffs." (Closed) Base URL: svn://svn.chromium.org/blink/branches/chromium/1599/
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/svg/properties/SVGPropertyTearOff.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 SVGStaticPropertyWithParentTearOff_h
21 #define SVGStaticPropertyWithParentTearOff_h
22
23 #include "core/svg/properties/SVGPropertyTearOff.h"
24
25 namespace WebCore {
26
27 #if COMPILER(MSVC)
28 // UpdateMethod is 12 bytes. We have to pack to a size greater than or equal to that to avoid an
29 // alignment warning (C4121). 16 is the next-largest size allowed for packing, s o we use that.
30 #pragma pack(push, 16)
31 #endif
32 template<typename ParentType, typename PropertyType>
33 class SVGStaticPropertyWithParentTearOff : public SVGPropertyTearOff<PropertyTyp e> {
34 public:
35 typedef SVGStaticPropertyWithParentTearOff<ParentType, PropertyType> Self;
36 typedef void (ParentType::*UpdateMethod)();
37
38 // Used for non-animated POD types that are not associated with a SVGAnimate dProperty object, nor with a XML DOM attribute
39 // and that contain a parent type that's exposed to the bindings via a SVGSt aticPropertyTearOff object
40 // (for example: SVGTransform::matrix).
41 static PassRefPtr<Self> create(SVGProperty* parent, PropertyType& value, Upd ateMethod update)
42 {
43 ASSERT(parent);
44 return adoptRef(new Self(parent, value, update));
45 }
46
47 virtual void commitChange()
48 {
49 (static_cast<SVGPropertyTearOff<ParentType>*>(m_parent.get())->propertyR eference().*m_update)();
50 m_parent->commitChange();
51 }
52
53 private:
54 SVGStaticPropertyWithParentTearOff(SVGProperty* parent, PropertyType& value, UpdateMethod update)
55 : SVGPropertyTearOff<PropertyType>(0, UndefinedRole, value)
56 , m_update(update)
57 , m_parent(parent)
58 {
59 }
60
61 UpdateMethod m_update;
62 RefPtr<SVGProperty> m_parent;
63 };
64 #if COMPILER(MSVC)
65 #pragma pack(pop)
66 #endif
67
68 }
69
70 #endif // SVGStaticPropertyWithParentTearOff_h
OLDNEW
« no previous file with comments | « Source/core/svg/properties/SVGPropertyTearOff.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698