OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008 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 17 matching lines...) Expand all Loading... |
28 | 28 |
29 #include "core/css/CSSImageGeneratorValue.h" | 29 #include "core/css/CSSImageGeneratorValue.h" |
30 #include "core/html/HTMLCanvasElement.h" | 30 #include "core/html/HTMLCanvasElement.h" |
31 | 31 |
32 namespace blink { | 32 namespace blink { |
33 | 33 |
34 class Document; | 34 class Document; |
35 | 35 |
36 class CSSCanvasValue : public CSSImageGeneratorValue { | 36 class CSSCanvasValue : public CSSImageGeneratorValue { |
37 public: | 37 public: |
38 static PassRefPtrWillBeRawPtr<CSSCanvasValue> create(const String& name) | 38 static PassRefPtr<CSSCanvasValue> create(const String& name) |
39 { | 39 { |
40 return adoptRefWillBeNoop(new CSSCanvasValue(name)); | 40 return adoptRef(new CSSCanvasValue(name)); |
41 } | 41 } |
42 ~CSSCanvasValue(); | 42 ~CSSCanvasValue(); |
43 | 43 |
44 String customCSSText() const; | 44 String customCSSText() const; |
45 | 45 |
46 PassRefPtr<Image> image(LayoutObject*, const IntSize&); | 46 PassRefPtr<Image> image(LayoutObject*, const IntSize&); |
47 bool isFixedSize() const { return true; } | 47 bool isFixedSize() const { return true; } |
48 IntSize fixedSize(const LayoutObject*); | 48 IntSize fixedSize(const LayoutObject*); |
49 | 49 |
50 bool isPending() const { return false; } | 50 bool isPending() const { return false; } |
51 void loadSubimages(Document*) { } | 51 void loadSubimages(Document*) { } |
52 | 52 |
53 bool equals(const CSSCanvasValue&) const; | 53 bool equals(const CSSCanvasValue&) const; |
54 | 54 |
55 DECLARE_TRACE_AFTER_DISPATCH(); | |
56 | |
57 private: | 55 private: |
58 explicit CSSCanvasValue(const String& name) | 56 explicit CSSCanvasValue(const String& name) |
59 : CSSImageGeneratorValue(CanvasClass) | 57 : CSSImageGeneratorValue(CanvasClass) |
60 , m_canvasObserver(adoptPtrWillBeNoop(new CanvasObserverProxy(this))) | 58 , m_canvasObserver(adoptPtrWillBeNoop(new CanvasObserverProxy(this))) |
61 , m_name(name) | 59 , m_name(name) |
62 , m_element(nullptr) | 60 , m_element(nullptr) |
63 { | 61 { |
64 } | 62 } |
65 | 63 |
66 // NOTE: We put the CanvasObserver in a member instead of inheriting from it | 64 // NOTE: We put the CanvasObserver in a member instead of inheriting from it |
(...skipping 12 matching lines...) Expand all Loading... |
79 m_ownerValue->canvasResized(canvas); | 77 m_ownerValue->canvasResized(canvas); |
80 } | 78 } |
81 #if !ENABLE(OILPAN) | 79 #if !ENABLE(OILPAN) |
82 void canvasDestroyed(HTMLCanvasElement* canvas) override | 80 void canvasDestroyed(HTMLCanvasElement* canvas) override |
83 { | 81 { |
84 m_ownerValue->canvasDestroyed(canvas); | 82 m_ownerValue->canvasDestroyed(canvas); |
85 } | 83 } |
86 #endif | 84 #endif |
87 DEFINE_INLINE_VIRTUAL_TRACE() | 85 DEFINE_INLINE_VIRTUAL_TRACE() |
88 { | 86 { |
89 visitor->trace(m_ownerValue); | |
90 CanvasObserver::trace(visitor); | 87 CanvasObserver::trace(visitor); |
91 } | 88 } |
92 | 89 |
93 private: | 90 private: |
94 RawPtrWillBeMember<CSSCanvasValue> m_ownerValue; | 91 RawPtr<CSSCanvasValue> m_ownerValue; |
95 }; | 92 }; |
96 | 93 |
97 void canvasChanged(HTMLCanvasElement*, const FloatRect& changedRect); | 94 void canvasChanged(HTMLCanvasElement*, const FloatRect& changedRect); |
98 void canvasResized(HTMLCanvasElement*); | 95 void canvasResized(HTMLCanvasElement*); |
99 | 96 |
100 #if !ENABLE(OILPAN) | 97 #if !ENABLE(OILPAN) |
101 void canvasDestroyed(HTMLCanvasElement*); | 98 void canvasDestroyed(HTMLCanvasElement*); |
102 #endif | 99 #endif |
103 | 100 |
104 HTMLCanvasElement* element(Document*); | 101 HTMLCanvasElement* element(Document*); |
105 | 102 |
106 OwnPtrWillBeMember<CanvasObserverProxy> m_canvasObserver; | 103 OwnPtrWillBePersistent<CanvasObserverProxy> m_canvasObserver; |
107 | 104 |
108 // The name of the canvas. | 105 // The name of the canvas. |
109 String m_name; | 106 String m_name; |
110 // The document supplies the element and owns it. | 107 // The document supplies the element and owns it. |
111 RawPtrWillBeWeakMember<HTMLCanvasElement> m_element; | 108 #if ENABLE(OILPAN) |
| 109 WeakPersistent<HTMLCanvasElement> m_element; |
| 110 #else |
| 111 RawPtr<HTMLCanvasElement> m_element; |
| 112 #endif |
112 }; | 113 }; |
113 | 114 |
114 DEFINE_CSS_VALUE_TYPE_CASTS(CSSCanvasValue, isCanvasValue()); | 115 DEFINE_CSS_VALUE_TYPE_CASTS(CSSCanvasValue, isCanvasValue()); |
115 | 116 |
116 } // namespace blink | 117 } // namespace blink |
117 | 118 |
118 #endif // CSSCanvasValue_h | 119 #endif // CSSCanvasValue_h |
OLD | NEW |