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

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

Issue 823263002: ScriptState used by EventListener::handleEvent() is wrong (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 11 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"
(...skipping 18 matching lines...) Expand all
29 } 29 }
30 30
31 using V8AbstractEventListener::ref; 31 using V8AbstractEventListener::ref;
32 using V8AbstractEventListener::deref; 32 using V8AbstractEventListener::deref;
33 33
34 virtual bool operator==(const EventListener&) 34 virtual bool operator==(const EventListener&)
35 { 35 {
36 return true; 36 return true;
37 } 37 }
38 38
39 virtual void handleEvent(ExecutionContext* context, Event* event) 39 virtual void handleEvent(ScriptState* scriptState, Event* event)
40 { 40 {
41 ASSERT(RuntimeEnabledFeatures::xsltEnabled()); 41 ASSERT(RuntimeEnabledFeatures::xsltEnabled());
42 ASSERT(event->type() == "DOMContentLoaded"); 42 ASSERT(event->type() == "DOMContentLoaded");
43 ScriptState::Scope scope(scriptState()); 43 ScriptState::Scope scope(scriptState);
44 44
45 Document& document = *toDocument(context); 45 Document& document = *toDocument(scriptState->executionContext());
46 ASSERT(!document.parsing()); 46 ASSERT(!document.parsing());
47 47
48 // Processing instruction (XML documents only). 48 // Processing instruction (XML documents only).
49 // We don't support linking to embedded CSS stylesheets, 49 // We don't support linking to embedded CSS stylesheets,
50 // see <https://bugs.webkit.org/show_bug.cgi?id=49281> for discussion. 50 // see <https://bugs.webkit.org/show_bug.cgi?id=49281> for discussion.
51 // Don't apply XSL transforms to already transformed documents. 51 // Don't apply XSL transforms to already transformed documents.
52 if (DocumentXSLT::hasTransformSourceDocument(document)) 52 if (DocumentXSLT::hasTransformSourceDocument(document))
53 return; 53 return;
54 54
55 ProcessingInstruction* pi = DocumentXSLT::findXSLStyleSheet(document); 55 ProcessingInstruction* pi = DocumentXSLT::findXSLStyleSheet(document);
56 if (!pi || pi != m_processingInstruction || pi->isLoading()) 56 if (!pi || pi != m_processingInstruction || pi->isLoading())
57 return; 57 return;
58 DocumentXSLT::applyXSLTransform(document, pi); 58 DocumentXSLT::applyXSLTransform(document, pi);
59 } 59 }
60 60
61 virtual void detach() override 61 virtual void detach() override
62 { 62 {
63 m_processingInstruction = nullptr; 63 m_processingInstruction = nullptr;
64 } 64 }
65 65
66 virtual EventListener* toEventListener() override 66 virtual EventListener* toEventListener() override
67 { 67 {
68 return this; 68 return this;
69 } 69 }
70 70
71 private: 71 private:
72 DOMContentLoadedListener(ScriptState* scriptState, ProcessingInstruction* pi ) 72 DOMContentLoadedListener(ScriptState* scriptState, ProcessingInstruction* pi )
73 : V8AbstractEventListener(false, scriptState) 73 : V8AbstractEventListener(false, scriptState->world(), scriptState->isol ate())
74 , m_processingInstruction(pi) 74 , m_processingInstruction(pi)
75 { 75 {
76 } 76 }
77 77
78 virtual void refDetachableEventListener() override { ref(); } 78 virtual void refDetachableEventListener() override { ref(); }
79 virtual void derefDetachableEventListener() override { deref(); } 79 virtual void derefDetachableEventListener() override { deref(); }
80 80
81 virtual v8::Local<v8::Value> callListenerFunction(v8::Handle<v8::Value> jsev ent, Event*) 81 virtual v8::Local<v8::Value> callListenerFunction(ScriptState*, v8::Handle<v 8::Value>, Event*)
82 { 82 {
83 ASSERT_NOT_REACHED(); 83 ASSERT_NOT_REACHED();
84 return v8::Local<v8::Value>(); 84 return v8::Local<v8::Value>();
85 } 85 }
86 86
87 // If this event listener is attached to a ProcessingInstruction, keep a 87 // If this event listener is attached to a ProcessingInstruction, keep a
88 // weak reference back to it. That ProcessingInstruction is responsible for 88 // weak reference back to it. That ProcessingInstruction is responsible for
89 // detaching itself and clear out the reference. 89 // detaching itself and clear out the reference.
90 // 90 //
91 // FIXME: Oilpan: when EventListener is on the heap, make this a WeakMember< >, 91 // FIXME: Oilpan: when EventListener is on the heap, make this a WeakMember< >,
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 return *supplement; 196 return *supplement;
197 } 197 }
198 198
199 void DocumentXSLT::trace(Visitor* visitor) 199 void DocumentXSLT::trace(Visitor* visitor)
200 { 200 {
201 visitor->trace(m_transformSourceDocument); 201 visitor->trace(m_transformSourceDocument);
202 DocumentSupplement::trace(visitor); 202 DocumentSupplement::trace(visitor);
203 } 203 }
204 204
205 } // namespace blink 205 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698