Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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; |
| 167 unsigned m_elementProxyGeneration; | |
|
esprehn
2016/10/25 01:18:42
Why do we need a generation instead of a single di
fs
2016/10/25 15:00:53
(see similar comment in SVGElementProxy.h)
| |
| 168 }; | 168 }; |
| 169 | 169 |
| 170 DEFINE_FILTER_OPERATION_TYPE_CASTS(ReferenceFilterOperation, REFERENCE); | 170 DEFINE_FILTER_OPERATION_TYPE_CASTS(ReferenceFilterOperation, REFERENCE); |
| 171 | 171 |
| 172 // GRAYSCALE, SEPIA, SATURATE and HUE_ROTATE are variations on a basic color | 172 // 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. | 173 // matrix effect. For HUE_ROTATE, the angle of rotation is stored in m_amount. |
| 174 class CORE_EXPORT BasicColorMatrixFilterOperation : public FilterOperation { | 174 class CORE_EXPORT BasicColorMatrixFilterOperation : public FilterOperation { |
| 175 public: | 175 public: |
| 176 static BasicColorMatrixFilterOperation* create(double amount, | 176 static BasicColorMatrixFilterOperation* create(double amount, |
| 177 OperationType type) { | 177 OperationType type) { |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 352 BoxReflectFilterOperation(const BoxReflection& reflection) | 352 BoxReflectFilterOperation(const BoxReflection& reflection) |
| 353 : FilterOperation(BOX_REFLECT), m_reflection(reflection) {} | 353 : FilterOperation(BOX_REFLECT), m_reflection(reflection) {} |
| 354 | 354 |
| 355 BoxReflection m_reflection; | 355 BoxReflection m_reflection; |
| 356 }; | 356 }; |
| 357 DEFINE_FILTER_OPERATION_TYPE_CASTS(BoxReflectFilterOperation, BOX_REFLECT); | 357 DEFINE_FILTER_OPERATION_TYPE_CASTS(BoxReflectFilterOperation, BOX_REFLECT); |
| 358 | 358 |
| 359 } // namespace blink | 359 } // namespace blink |
| 360 | 360 |
| 361 #endif // FilterOperation_h | 361 #endif // FilterOperation_h |
| OLD | NEW |