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

Side by Side Diff: third_party/WebKit/Source/core/svg/SVGPathSegList.h

Issue 1416273002: Remove SVGPathElement.pathSegList and related interfaces (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years, 1 month 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
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2014 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #ifndef SVGPathSegList_h
32 #define SVGPathSegList_h
33
34 #include "core/svg/SVGPathByteStream.h"
35 #include "core/svg/SVGPathSeg.h"
36 #include "core/svg/properties/SVGAnimatedProperty.h"
37 #include "core/svg/properties/SVGListPropertyHelper.h"
38
39 namespace blink {
40
41 class SVGPathElement;
42 class SVGPathSegListTearOff;
43
44 class SVGPathSegList : public SVGListPropertyHelper<SVGPathSegList, SVGPathSeg> {
45 public:
46 typedef void PrimitiveType;
47 typedef SVGPathSeg ItemPropertyType;
48 typedef SVGPathSegListTearOff TearOffType;
49 typedef SVGListPropertyHelper<SVGPathSegList, SVGPathSeg> Base;
50
51 static PassRefPtrWillBeRawPtr<SVGPathSegList> create(SVGPathElement* context Element)
52 {
53 return adoptRefWillBeNoop(new SVGPathSegList(contextElement));
54 }
55 static PassRefPtrWillBeRawPtr<SVGPathSegList> create()
56 {
57 ASSERT_NOT_REACHED();
58 return nullptr;
59 }
60
61 ~SVGPathSegList() override;
62
63 const SVGPathByteStream& byteStream() const;
64 SVGPathByteStream& mutableByteStream();
65 void clearByteStream() { m_byteStream.clear(); }
66
67 // SVGListPropertyHelper methods with |m_byteStream| sync:
68
69 ItemPropertyType* at(size_t index)
70 {
71 updateListFromByteStream();
72 return Base::at(index);
73 }
74
75 size_t length()
76 {
77 updateListFromByteStream();
78 return Base::length();
79 }
80
81 bool isEmpty() const
82 {
83 if (m_listSyncedToByteStream)
84 return Base::isEmpty();
85
86 return !m_byteStream || m_byteStream->isEmpty();
87 }
88
89 void clear()
90 {
91 clearByteStream();
92 Base::clear();
93 }
94
95 void append(PassRefPtrWillBeRawPtr<ItemPropertyType> passNewItem)
96 {
97 updateListFromByteStream();
98 clearByteStream();
99 Base::append(passNewItem);
100 }
101
102 PassRefPtrWillBeRawPtr<ItemPropertyType> initialize(PassRefPtrWillBeRawPtr<I temPropertyType> passItem)
103 {
104 clearByteStream();
105 return Base::initialize(passItem);
106 }
107
108 PassRefPtrWillBeRawPtr<ItemPropertyType> getItem(size_t index, ExceptionStat e& exceptionState)
109 {
110 updateListFromByteStream();
111 return Base::getItem(index, exceptionState);
112 }
113
114 PassRefPtrWillBeRawPtr<ItemPropertyType> insertItemBefore(PassRefPtrWillBeRa wPtr<ItemPropertyType> passItem, size_t index)
115 {
116 updateListFromByteStream();
117 clearByteStream();
118 return Base::insertItemBefore(passItem, index);
119 }
120
121 PassRefPtrWillBeRawPtr<ItemPropertyType> replaceItem(PassRefPtrWillBeRawPtr< ItemPropertyType> passItem, size_t index, ExceptionState& exceptionState)
122 {
123 updateListFromByteStream();
124 clearByteStream();
125 return Base::replaceItem(passItem, index, exceptionState);
126 }
127
128 PassRefPtrWillBeRawPtr<ItemPropertyType> removeItem(size_t index, ExceptionS tate& exceptionState)
129 {
130 updateListFromByteStream();
131 clearByteStream();
132 return Base::removeItem(index, exceptionState);
133 }
134
135 PassRefPtrWillBeRawPtr<ItemPropertyType> appendItem(PassRefPtrWillBeRawPtr<I temPropertyType> passItem);
136
137 // SVGPropertyBase:
138 PassRefPtrWillBeRawPtr<SVGPropertyBase> cloneForAnimation(const String&) con st override;
139 PassRefPtrWillBeRawPtr<SVGPathSegList> clone() override;
140 String valueAsString() const override;
141 void setValueAsString(const String&, ExceptionState&);
142
143 void add(PassRefPtrWillBeRawPtr<SVGPropertyBase>, SVGElement*) override;
144 void calculateAnimatedValue(SVGAnimationElement*, float percentage, unsigned repeatCount, PassRefPtrWillBeRawPtr<SVGPropertyBase> fromValue, PassRefPtrWillB eRawPtr<SVGPropertyBase> toValue, PassRefPtrWillBeRawPtr<SVGPropertyBase> toAtEn dOfDurationValue, SVGElement*) override;
145 float calculateDistance(PassRefPtrWillBeRawPtr<SVGPropertyBase> to, SVGEleme nt*) override;
146
147 static AnimatedPropertyType classType() { return AnimatedPath; }
148
149 DECLARE_VIRTUAL_TRACE();
150
151 void invalidateList();
152
153 private:
154 explicit SVGPathSegList(SVGPathElement*);
155 SVGPathSegList(SVGPathElement*, PassOwnPtr<SVGPathByteStream>);
156
157 friend class SVGPathSegListBuilder;
158 // This is only to be called from SVGPathSegListBuilder.
159 void appendWithoutByteStreamSync(PassRefPtrWillBeRawPtr<ItemPropertyType> pa ssNewItem)
160 {
161 Base::append(passNewItem);
162 }
163
164 void updateListFromByteStream();
165
166 // FIXME: This pointer should be removed after SVGPathSeg has a tear-off.
167 //
168 // SVGPathSegList is either owned by SVGAnimatedPath or SVGPathSegListTearOf f.
169 // Both keep |contextElement| alive, so this ptr is always valid.
170 GC_PLUGIN_IGNORE("528275")
171 SVGPathElement* m_contextElement;
172
173 mutable OwnPtr<SVGPathByteStream> m_byteStream;
174 bool m_listSyncedToByteStream;
175 };
176
177 inline PassRefPtrWillBeRawPtr<SVGPathSegList> toSVGPathSegList(PassRefPtrWillBeR awPtr<SVGPropertyBase> passBase)
178 {
179 RefPtrWillBeRawPtr<SVGPropertyBase> base = passBase;
180 ASSERT(base->type() == SVGPathSegList::classType());
181 return static_pointer_cast<SVGPathSegList>(base.release());
182 }
183
184 } // namespace blink
185
186 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698