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

Side by Side Diff: third_party/WebKit/Source/core/style/FilterOperation.h

Issue 2490163002: Reland of "Tracking reference filter mutation via SVGElementProxy" (Closed)
Patch Set: Fix double observer unregistration; simplify scope selection; add tests Created 4 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
1 /* 1 /*
2 * Copyright (C) 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2011 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 20 matching lines...) Expand all
31 #include "platform/geometry/FloatRect.h" 31 #include "platform/geometry/FloatRect.h"
32 #include "platform/graphics/BoxReflection.h" 32 #include "platform/graphics/BoxReflection.h"
33 #include "platform/graphics/Color.h" 33 #include "platform/graphics/Color.h"
34 #include "platform/heap/Handle.h" 34 #include "platform/heap/Handle.h"
35 #include "wtf/Noncopyable.h" 35 #include "wtf/Noncopyable.h"
36 #include "wtf/text/WTFString.h" 36 #include "wtf/text/WTFString.h"
37 37
38 namespace blink { 38 namespace blink {
39 39
40 class Filter; 40 class Filter;
41 class SVGResourceClient;
42 class SVGElementProxy;
41 43
42 // CSS Filters 44 // CSS Filters
43 45
44 class CORE_EXPORT FilterOperation 46 class CORE_EXPORT FilterOperation
45 : public GarbageCollectedFinalized<FilterOperation> { 47 : public GarbageCollectedFinalized<FilterOperation> {
46 WTF_MAKE_NONCOPYABLE(FilterOperation); 48 WTF_MAKE_NONCOPYABLE(FilterOperation);
47 49
48 public: 50 public:
49 enum OperationType { 51 enum OperationType {
50 REFERENCE, // url(#somefilter) 52 REFERENCE, // url(#somefilter)
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 }; 123 };
122 124
123 #define DEFINE_FILTER_OPERATION_TYPE_CASTS(thisType, operationType) \ 125 #define DEFINE_FILTER_OPERATION_TYPE_CASTS(thisType, operationType) \
124 DEFINE_TYPE_CASTS(thisType, FilterOperation, op, \ 126 DEFINE_TYPE_CASTS(thisType, FilterOperation, op, \
125 op->type() == FilterOperation::operationType, \ 127 op->type() == FilterOperation::operationType, \
126 op.type() == FilterOperation::operationType); 128 op.type() == FilterOperation::operationType);
127 129
128 class CORE_EXPORT ReferenceFilterOperation : public FilterOperation { 130 class CORE_EXPORT ReferenceFilterOperation : public FilterOperation {
129 public: 131 public:
130 static ReferenceFilterOperation* create(const String& url, 132 static ReferenceFilterOperation* create(const String& url,
131 const AtomicString& fragment) { 133 SVGElementProxy& elementProxy) {
132 return new ReferenceFilterOperation(url, fragment); 134 return new ReferenceFilterOperation(url, elementProxy);
133 } 135 }
134 136
135 bool affectsOpacity() const override { return true; } 137 bool affectsOpacity() const override { return true; }
136 bool movesPixels() const override { return true; } 138 bool movesPixels() const override { return true; }
137 FloatRect mapRect(const FloatRect&) const override; 139 FloatRect mapRect(const FloatRect&) const override;
138 140
139 const String& url() const { return m_url; } 141 const String& url() const { return m_url; }
140 const AtomicString& fragment() const { return m_fragment; }
141 142
142 Filter* getFilter() const { return m_filter.get(); } 143 Filter* getFilter() const { return m_filter.get(); }
143 void setFilter(Filter* filter) { m_filter = filter; } 144 void setFilter(Filter* filter) { m_filter = filter; }
144 145
146 SVGElementProxy& elementProxy() const { return *m_elementProxy; }
147
148 void addClient(SVGResourceClient*);
149 void removeClient(SVGResourceClient*);
150
145 DECLARE_VIRTUAL_TRACE(); 151 DECLARE_VIRTUAL_TRACE();
146 152
147 private: 153 private:
154 ReferenceFilterOperation(const String& url, SVGElementProxy&);
155
148 FilterOperation* blend(const FilterOperation* from, 156 FilterOperation* blend(const FilterOperation* from,
149 double progress) const override { 157 double progress) const override {
150 NOTREACHED(); 158 NOTREACHED();
151 return nullptr; 159 return nullptr;
152 } 160 }
153 161
154 bool operator==(const FilterOperation& o) const override { 162 bool operator==(const FilterOperation&) const override;
155 if (!isSameType(o))
156 return false;
157 const ReferenceFilterOperation* other =
158 static_cast<const ReferenceFilterOperation*>(&o);
159 return m_url == other->m_url;
160 }
161
162 ReferenceFilterOperation(const String& url, const AtomicString& fragment)
163 : FilterOperation(REFERENCE), m_url(url), m_fragment(fragment) {}
164 163
165 String m_url; 164 String m_url;
166 AtomicString m_fragment; 165 Member<SVGElementProxy> m_elementProxy;
167 Member<Filter> m_filter; 166 Member<Filter> m_filter;
168 }; 167 };
169 168
170 DEFINE_FILTER_OPERATION_TYPE_CASTS(ReferenceFilterOperation, REFERENCE); 169 DEFINE_FILTER_OPERATION_TYPE_CASTS(ReferenceFilterOperation, REFERENCE);
171 170
172 // GRAYSCALE, SEPIA, SATURATE and HUE_ROTATE are variations on a basic color 171 // GRAYSCALE, SEPIA, SATURATE and HUE_ROTATE are variations on a basic color
173 // matrix effect. For HUE_ROTATE, the angle of rotation is stored in m_amount. 172 // matrix effect. For HUE_ROTATE, the angle of rotation is stored in m_amount.
174 class CORE_EXPORT BasicColorMatrixFilterOperation : public FilterOperation { 173 class CORE_EXPORT BasicColorMatrixFilterOperation : public FilterOperation {
175 public: 174 public:
176 static BasicColorMatrixFilterOperation* create(double amount, 175 static BasicColorMatrixFilterOperation* create(double amount,
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 BoxReflectFilterOperation(const BoxReflection& reflection) 351 BoxReflectFilterOperation(const BoxReflection& reflection)
353 : FilterOperation(BOX_REFLECT), m_reflection(reflection) {} 352 : FilterOperation(BOX_REFLECT), m_reflection(reflection) {}
354 353
355 BoxReflection m_reflection; 354 BoxReflection m_reflection;
356 }; 355 };
357 DEFINE_FILTER_OPERATION_TYPE_CASTS(BoxReflectFilterOperation, BOX_REFLECT); 356 DEFINE_FILTER_OPERATION_TYPE_CASTS(BoxReflectFilterOperation, BOX_REFLECT);
358 357
359 } // namespace blink 358 } // namespace blink
360 359
361 #endif // FilterOperation_h 360 #endif // FilterOperation_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698