| OLD | NEW |
| 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 "core/xml/DocumentXSLT.h" | 5 #include "core/xml/DocumentXSLT.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/DOMWrapperWorld.h" | 7 #include "bindings/core/v8/DOMWrapperWorld.h" |
| 8 #include "bindings/core/v8/ScriptState.h" | 8 #include "bindings/core/v8/ScriptState.h" |
| 9 #include "bindings/core/v8/V8AbstractEventListener.h" | 9 #include "bindings/core/v8/V8AbstractEventListener.h" |
| 10 #include "bindings/core/v8/V8Binding.h" | 10 #include "bindings/core/v8/V8Binding.h" |
| 11 #include "core/dom/Document.h" | 11 #include "core/dom/Document.h" |
| 12 #include "core/dom/Node.h" | 12 #include "core/dom/Node.h" |
| 13 #include "core/dom/ProcessingInstruction.h" | 13 #include "core/dom/ProcessingInstruction.h" |
| 14 #include "core/events/Event.h" | 14 #include "core/events/Event.h" |
| 15 #include "core/events/EventListener.h" | 15 #include "core/events/EventListener.h" |
| 16 #include "core/frame/UseCounter.h" | 16 #include "core/frame/UseCounter.h" |
| 17 #include "core/inspector/InspectorInstrumentation.h" | 17 #include "core/inspector/InspectorInstrumentation.h" |
| 18 #include "core/xml/XSLStyleSheet.h" | 18 #include "core/xml/XSLStyleSheet.h" |
| 19 #include "core/xml/XSLTProcessor.h" | 19 #include "core/xml/XSLTProcessor.h" |
| 20 | 20 |
| 21 namespace blink { | 21 namespace blink { |
| 22 | 22 |
| 23 class DOMContentLoadedListener final : public V8AbstractEventListener, public Pr
ocessingInstruction::DetachableEventListener { | 23 class DOMContentLoadedListener final : public V8AbstractEventListener, public Pr
ocessingInstruction::DetachableEventListener { |
| 24 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(DOMContentLoadedListener); | 24 USING_GARBAGE_COLLECTED_MIXIN(DOMContentLoadedListener); |
| 25 public: | 25 public: |
| 26 static PassRefPtrWillBeRawPtr<DOMContentLoadedListener> create(ScriptState*
scriptState, ProcessingInstruction* pi) | 26 static RawPtr<DOMContentLoadedListener> create(ScriptState* scriptState, Pro
cessingInstruction* pi) |
| 27 { | 27 { |
| 28 return adoptRefWillBeNoop(new DOMContentLoadedListener(scriptState, pi))
; | 28 return new DOMContentLoadedListener(scriptState, pi); |
| 29 } | 29 } |
| 30 | 30 |
| 31 #if !ENABLE(OILPAN) | 31 #if !ENABLE(OILPAN) |
| 32 using V8AbstractEventListener::ref; | 32 using V8AbstractEventListener::ref; |
| 33 using V8AbstractEventListener::deref; | 33 using V8AbstractEventListener::deref; |
| 34 #endif | 34 #endif |
| 35 | 35 |
| 36 bool operator==(const EventListener&) const override | 36 bool operator==(const EventListener&) const override |
| 37 { | 37 { |
| 38 return true; | 38 return true; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 91 |
| 92 virtual v8::Local<v8::Value> callListenerFunction(ScriptState*, v8::Local<v8
::Value>, Event*) | 92 virtual v8::Local<v8::Value> callListenerFunction(ScriptState*, v8::Local<v8
::Value>, Event*) |
| 93 { | 93 { |
| 94 ASSERT_NOT_REACHED(); | 94 ASSERT_NOT_REACHED(); |
| 95 return v8::Local<v8::Value>(); | 95 return v8::Local<v8::Value>(); |
| 96 } | 96 } |
| 97 | 97 |
| 98 // If this event listener is attached to a ProcessingInstruction, keep a | 98 // If this event listener is attached to a ProcessingInstruction, keep a |
| 99 // weak reference back to it. That ProcessingInstruction is responsible for | 99 // weak reference back to it. That ProcessingInstruction is responsible for |
| 100 // detaching itself and clear out the reference. | 100 // detaching itself and clear out the reference. |
| 101 RawPtrWillBeMember<ProcessingInstruction> m_processingInstruction; | 101 Member<ProcessingInstruction> m_processingInstruction; |
| 102 }; | 102 }; |
| 103 | 103 |
| 104 DocumentXSLT::DocumentXSLT() | 104 DocumentXSLT::DocumentXSLT() |
| 105 : m_transformSourceDocument(nullptr) | 105 : m_transformSourceDocument(nullptr) |
| 106 { | 106 { |
| 107 } | 107 } |
| 108 | 108 |
| 109 void DocumentXSLT::applyXSLTransform(Document& document, ProcessingInstruction*
pi) | 109 void DocumentXSLT::applyXSLTransform(Document& document, ProcessingInstruction*
pi) |
| 110 { | 110 { |
| 111 ASSERT(!pi->isLoading()); | 111 ASSERT(!pi->isLoading()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 { | 144 { |
| 145 if (!pi->isXSL()) | 145 if (!pi->isXSL()) |
| 146 return false; | 146 return false; |
| 147 | 147 |
| 148 if (!RuntimeEnabledFeatures::xsltEnabled() || !document.frame()) | 148 if (!RuntimeEnabledFeatures::xsltEnabled() || !document.frame()) |
| 149 return true; | 149 return true; |
| 150 | 150 |
| 151 ScriptState* scriptState = ScriptState::forMainWorld(document.frame()); | 151 ScriptState* scriptState = ScriptState::forMainWorld(document.frame()); |
| 152 if (!scriptState) | 152 if (!scriptState) |
| 153 return false; | 153 return false; |
| 154 RefPtrWillBeRawPtr<DOMContentLoadedListener> listener = DOMContentLoadedList
ener::create(scriptState, pi); | 154 RawPtr<DOMContentLoadedListener> listener = DOMContentLoadedListener::create
(scriptState, pi); |
| 155 document.addEventListener(EventTypeNames::DOMContentLoaded, listener, false)
; | 155 document.addEventListener(EventTypeNames::DOMContentLoaded, listener, false)
; |
| 156 ASSERT(!pi->eventListenerForXSLT()); | 156 ASSERT(!pi->eventListenerForXSLT()); |
| 157 pi->setEventListenerForXSLT(listener.release()); | 157 pi->setEventListenerForXSLT(listener.release()); |
| 158 return true; | 158 return true; |
| 159 } | 159 } |
| 160 | 160 |
| 161 bool DocumentXSLT::processingInstructionRemovedFromDocument(Document& document,
ProcessingInstruction* pi) | 161 bool DocumentXSLT::processingInstructionRemovedFromDocument(Document& document,
ProcessingInstruction* pi) |
| 162 { | 162 { |
| 163 if (!pi->isXSL()) | 163 if (!pi->isXSL()) |
| 164 return false; | 164 return false; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 185 return true; | 185 return true; |
| 186 } | 186 } |
| 187 | 187 |
| 188 const char* DocumentXSLT::supplementName() | 188 const char* DocumentXSLT::supplementName() |
| 189 { | 189 { |
| 190 return "DocumentXSLT"; | 190 return "DocumentXSLT"; |
| 191 } | 191 } |
| 192 | 192 |
| 193 bool DocumentXSLT::hasTransformSourceDocument(Document& document) | 193 bool DocumentXSLT::hasTransformSourceDocument(Document& document) |
| 194 { | 194 { |
| 195 return static_cast<DocumentXSLT*>(WillBeHeapSupplement<Document>::from(docum
ent, supplementName())); | 195 return static_cast<DocumentXSLT*>(HeapSupplement<Document>::from(document, s
upplementName())); |
| 196 } | 196 } |
| 197 | 197 |
| 198 | 198 |
| 199 DocumentXSLT& DocumentXSLT::from(WillBeHeapSupplementable<Document>& document) | 199 DocumentXSLT& DocumentXSLT::from(HeapSupplementable<Document>& document) |
| 200 { | 200 { |
| 201 DocumentXSLT* supplement = static_cast<DocumentXSLT*>(WillBeHeapSupplement<D
ocument>::from(document, supplementName())); | 201 DocumentXSLT* supplement = static_cast<DocumentXSLT*>(HeapSupplement<Documen
t>::from(document, supplementName())); |
| 202 if (!supplement) { | 202 if (!supplement) { |
| 203 supplement = new DocumentXSLT(); | 203 supplement = new DocumentXSLT(); |
| 204 WillBeHeapSupplement<Document>::provideTo(document, supplementName(), ad
optPtrWillBeNoop(supplement)); | 204 HeapSupplement<Document>::provideTo(document, supplementName(), adoptPtr
WillBeNoop(supplement)); |
| 205 } | 205 } |
| 206 return *supplement; | 206 return *supplement; |
| 207 } | 207 } |
| 208 | 208 |
| 209 DEFINE_TRACE(DocumentXSLT) | 209 DEFINE_TRACE(DocumentXSLT) |
| 210 { | 210 { |
| 211 visitor->trace(m_transformSourceDocument); | 211 visitor->trace(m_transformSourceDocument); |
| 212 WillBeHeapSupplement<Document>::trace(visitor); | 212 HeapSupplement<Document>::trace(visitor); |
| 213 } | 213 } |
| 214 | 214 |
| 215 } // namespace blink | 215 } // namespace blink |
| OLD | NEW |