1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
/*
* Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
* Copyright (C) 2004, 2005 Rob Buis <buis@kde.org>
* Copyright (C) 2005 Eric Seidel <eric@webkit.org>
* Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
* Copyright (C) Research In Motion Limited 2010. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef LayoutSVGResourceFilter_h
#define LayoutSVGResourceFilter_h
#include "core/layout/svg/LayoutSVGResourceContainer.h"
#include "core/svg/SVGFilterElement.h"
#include "core/svg/graphics/filters/SVGFilterBuilder.h"
#include "platform/graphics/filters/Filter.h"
namespace blink {
class FilterData final : public NoBaseWillBeGarbageCollectedFinalized<FilterData> {
USING_FAST_MALLOC_WILL_BE_REMOVED(FilterData);
public:
/*
* The state transitions should follow the following:
* Initial -> RecordingContent -> ReadyToPaint -> PaintingFilter -> ReadyToPaint
* | ^ | ^
* v | v |
* RecordingContentCycleDetected PaintingFilterCycle
*/
enum FilterDataState {
Initial,
RecordingContent,
RecordingContentCycleDetected,
ReadyToPaint,
PaintingFilter,
PaintingFilterCycleDetected
};
static PassOwnPtrWillBeRawPtr<FilterData> create()
{
return adoptPtrWillBeNoop(new FilterData());
}
void dispose();
DECLARE_TRACE();
RefPtrWillBeMember<Filter> filter;
RefPtrWillBeMember<SVGFilterGraphNodeMap> nodeMap;
FilterDataState m_state;
private:
FilterData() : m_state(Initial) { }
};
class LayoutSVGResourceFilter final : public LayoutSVGResourceContainer {
public:
explicit LayoutSVGResourceFilter(SVGFilterElement*);
~LayoutSVGResourceFilter() override;
bool isChildAllowed(LayoutObject*, const ComputedStyle&) const override;
const char* name() const override { return "LayoutSVGResourceFilter"; }
bool isOfType(LayoutObjectType type) const override { return type == LayoutObjectSVGResourceFilter || LayoutSVGResourceContainer::isOfType(type); }
void removeAllClientsFromCache(bool markForInvalidation = true) override;
void removeClientFromCache(LayoutObject*, bool markForInvalidation = true) override;
FloatRect resourceBoundingBox(const LayoutObject*);
SVGUnitTypes::SVGUnitType filterUnits() const { return toSVGFilterElement(element())->filterUnits()->currentValue()->enumValue(); }
SVGUnitTypes::SVGUnitType primitiveUnits() const { return toSVGFilterElement(element())->primitiveUnits()->currentValue()->enumValue(); }
void primitiveAttributeChanged(LayoutObject*, const QualifiedName&);
static const LayoutSVGResourceType s_resourceType = FilterResourceType;
LayoutSVGResourceType resourceType() const override { return s_resourceType; }
FilterData* getFilterDataForLayoutObject(const LayoutObject* object) { return m_filter.get(const_cast<LayoutObject*>(object)); }
void setFilterDataForLayoutObject(LayoutObject* object, PassOwnPtrWillBeRawPtr<FilterData> filterData) { m_filter.set(object, filterData); }
protected:
void willBeDestroyed() override;
private:
void disposeFilterMap();
using FilterMap = WillBePersistentHeapHashMap<LayoutObject*, OwnPtrWillBeMember<FilterData>>;
FilterMap m_filter;
};
DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutSVGResourceFilter, isSVGResourceFilter());
} // namespace blink
#endif
|