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

Side by Side Diff: Source/core/xml/DocumentXSLT.cpp

Issue 1238083002: Oilpan: Move the EventListener hierarchy to Oilpan's heap (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 5 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/xml/DocumentXSLT.h" 6 #include "core/xml/DocumentXSLT.h"
7 7
8 #include "bindings/core/v8/DOMWrapperWorld.h" 8 #include "bindings/core/v8/DOMWrapperWorld.h"
9 #include "bindings/core/v8/ScriptState.h" 9 #include "bindings/core/v8/ScriptState.h"
10 #include "bindings/core/v8/V8AbstractEventListener.h" 10 #include "bindings/core/v8/V8AbstractEventListener.h"
11 #include "bindings/core/v8/V8Binding.h" 11 #include "bindings/core/v8/V8Binding.h"
12 #include "core/dom/Document.h" 12 #include "core/dom/Document.h"
13 #include "core/dom/Node.h" 13 #include "core/dom/Node.h"
14 #include "core/dom/ProcessingInstruction.h" 14 #include "core/dom/ProcessingInstruction.h"
15 #include "core/events/Event.h" 15 #include "core/events/Event.h"
16 #include "core/events/EventListener.h" 16 #include "core/events/EventListener.h"
17 #include "core/frame/UseCounter.h" 17 #include "core/frame/UseCounter.h"
18 #include "core/inspector/InspectorInstrumentation.h" 18 #include "core/inspector/InspectorInstrumentation.h"
19 #include "core/xml/XSLStyleSheet.h" 19 #include "core/xml/XSLStyleSheet.h"
20 #include "core/xml/XSLTProcessor.h" 20 #include "core/xml/XSLTProcessor.h"
21 21
22 namespace blink { 22 namespace blink {
23 23
24 class DOMContentLoadedListener final : public ProcessingInstruction::DetachableE ventListener, public V8AbstractEventListener { 24 class DOMContentLoadedListener final : public V8AbstractEventListener, public Pr ocessingInstruction::DetachableEventListener {
25 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(DOMContentLoadedListener);
25 public: 26 public:
26 static PassRefPtr<DOMContentLoadedListener> create(ScriptState* scriptState, ProcessingInstruction* pi) 27 static PassRefPtrWillBeRawPtr<DOMContentLoadedListener> create(ScriptState* scriptState, ProcessingInstruction* pi)
27 { 28 {
28 return adoptRef(new DOMContentLoadedListener(scriptState, pi)); 29 return adoptRefWillBeNoop(new DOMContentLoadedListener(scriptState, pi)) ;
29 } 30 }
30 31
32 #if !ENABLE(OILPAN)
31 using V8AbstractEventListener::ref; 33 using V8AbstractEventListener::ref;
32 using V8AbstractEventListener::deref; 34 using V8AbstractEventListener::deref;
35 #endif
33 36
34 virtual bool operator==(const EventListener&) 37 virtual bool operator==(const EventListener&)
35 { 38 {
36 return true; 39 return true;
37 } 40 }
38 41
39 virtual void handleEvent(ScriptState* scriptState, Event* event) 42 virtual void handleEvent(ScriptState* scriptState, Event* event)
40 { 43 {
41 ASSERT(RuntimeEnabledFeatures::xsltEnabled()); 44 ASSERT(RuntimeEnabledFeatures::xsltEnabled());
42 ASSERT(event->type() == "DOMContentLoaded"); 45 ASSERT(event->type() == "DOMContentLoaded");
(...skipping 18 matching lines...) Expand all
61 void detach() override 64 void detach() override
62 { 65 {
63 m_processingInstruction = nullptr; 66 m_processingInstruction = nullptr;
64 } 67 }
65 68
66 EventListener* toEventListener() override 69 EventListener* toEventListener() override
67 { 70 {
68 return this; 71 return this;
69 } 72 }
70 73
74 DEFINE_INLINE_VIRTUAL_TRACE()
75 {
76 visitor->trace(m_processingInstruction);
77 V8AbstractEventListener::trace(visitor);
78 ProcessingInstruction::DetachableEventListener::trace(visitor);
79 }
80
71 private: 81 private:
72 DOMContentLoadedListener(ScriptState* scriptState, ProcessingInstruction* pi ) 82 DOMContentLoadedListener(ScriptState* scriptState, ProcessingInstruction* pi )
73 : V8AbstractEventListener(false, scriptState->world(), scriptState->isol ate()) 83 : V8AbstractEventListener(false, scriptState->world(), scriptState->isol ate())
74 , m_processingInstruction(pi) 84 , m_processingInstruction(pi)
75 { 85 {
76 } 86 }
77 87
88 #if !ENABLE(OILPAN)
78 void refDetachableEventListener() override { ref(); } 89 void refDetachableEventListener() override { ref(); }
79 void derefDetachableEventListener() override { deref(); } 90 void derefDetachableEventListener() override { deref(); }
91 #endif
80 92
81 virtual v8::Local<v8::Value> callListenerFunction(ScriptState*, v8::Local<v8 ::Value>, Event*) 93 virtual v8::Local<v8::Value> callListenerFunction(ScriptState*, v8::Local<v8 ::Value>, Event*)
82 { 94 {
83 ASSERT_NOT_REACHED(); 95 ASSERT_NOT_REACHED();
84 return v8::Local<v8::Value>(); 96 return v8::Local<v8::Value>();
85 } 97 }
86 98
87 // If this event listener is attached to a ProcessingInstruction, keep a 99 // If this event listener is attached to a ProcessingInstruction, keep a
88 // weak reference back to it. That ProcessingInstruction is responsible for 100 // weak reference back to it. That ProcessingInstruction is responsible for
89 // detaching itself and clear out the reference. 101 // detaching itself and clear out the reference.
90 // 102 RawPtrWillBeMember<ProcessingInstruction> m_processingInstruction;
91 // FIXME: Oilpan: when EventListener is on the heap, make this a WeakMember< >,
92 // which will remove the need for explicit detachment.
93 ProcessingInstruction* m_processingInstruction;
94 }; 103 };
95 104
96 DocumentXSLT::DocumentXSLT() 105 DocumentXSLT::DocumentXSLT()
97 : m_transformSourceDocument(nullptr) 106 : m_transformSourceDocument(nullptr)
98 { 107 {
99 } 108 }
100 109
101 void DocumentXSLT::applyXSLTransform(Document& document, ProcessingInstruction* pi) 110 void DocumentXSLT::applyXSLTransform(Document& document, ProcessingInstruction* pi)
102 { 111 {
103 ASSERT(!pi->isLoading()); 112 ASSERT(!pi->isLoading());
(...skipping 30 matching lines...) Expand all
134 143
135 bool DocumentXSLT::processingInstructionInsertedIntoDocument(Document& document, ProcessingInstruction* pi) 144 bool DocumentXSLT::processingInstructionInsertedIntoDocument(Document& document, ProcessingInstruction* pi)
136 { 145 {
137 if (!pi->isXSL()) 146 if (!pi->isXSL())
138 return false; 147 return false;
139 148
140 if (!RuntimeEnabledFeatures::xsltEnabled() || !document.frame()) 149 if (!RuntimeEnabledFeatures::xsltEnabled() || !document.frame())
141 return true; 150 return true;
142 151
143 ScriptState* scriptState = ScriptState::forMainWorld(document.frame()); 152 ScriptState* scriptState = ScriptState::forMainWorld(document.frame());
144 RefPtr<DOMContentLoadedListener> listener = DOMContentLoadedListener::create (scriptState, pi); 153 RefPtrWillBeRawPtr<DOMContentLoadedListener> listener = DOMContentLoadedList ener::create(scriptState, pi);
145 document.addEventListener(EventTypeNames::DOMContentLoaded, listener, false) ; 154 document.addEventListener(EventTypeNames::DOMContentLoaded, listener, false) ;
146 ASSERT(!pi->eventListenerForXSLT()); 155 ASSERT(!pi->eventListenerForXSLT());
147 pi->setEventListenerForXSLT(listener.release()); 156 pi->setEventListenerForXSLT(listener.release());
148 return true; 157 return true;
149 } 158 }
150 159
151 bool DocumentXSLT::processingInstructionRemovedFromDocument(Document& document, ProcessingInstruction* pi) 160 bool DocumentXSLT::processingInstructionRemovedFromDocument(Document& document, ProcessingInstruction* pi)
152 { 161 {
153 if (!pi->isXSL()) 162 if (!pi->isXSL())
154 return false; 163 return false;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 return *supplement; 205 return *supplement;
197 } 206 }
198 207
199 DEFINE_TRACE(DocumentXSLT) 208 DEFINE_TRACE(DocumentXSLT)
200 { 209 {
201 visitor->trace(m_transformSourceDocument); 210 visitor->trace(m_transformSourceDocument);
202 WillBeHeapSupplement<Document>::trace(visitor); 211 WillBeHeapSupplement<Document>::trace(visitor);
203 } 212 }
204 213
205 } // namespace blink 214 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698