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

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

Issue 2617103002: Use a new Supplement constructor for Supplement<Document> (Part 1) (Closed)
Patch Set: temp Created 3 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
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 "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"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 NOTREACHED(); 77 NOTREACHED();
78 return v8::Local<v8::Value>(); 78 return v8::Local<v8::Value>();
79 } 79 }
80 80
81 // If this event listener is attached to a ProcessingInstruction, keep a 81 // If this event listener is attached to a ProcessingInstruction, keep a
82 // weak reference back to it. That ProcessingInstruction is responsible for 82 // weak reference back to it. That ProcessingInstruction is responsible for
83 // detaching itself and clear out the reference. 83 // detaching itself and clear out the reference.
84 Member<ProcessingInstruction> m_processingInstruction; 84 Member<ProcessingInstruction> m_processingInstruction;
85 }; 85 };
86 86
87 DocumentXSLT::DocumentXSLT() : m_transformSourceDocument(nullptr) {} 87 DocumentXSLT::DocumentXSLT(Document& document)
88 : Supplement<Document>(document), m_transformSourceDocument(nullptr) {}
88 89
89 void DocumentXSLT::applyXSLTransform(Document& document, 90 void DocumentXSLT::applyXSLTransform(Document& document,
90 ProcessingInstruction* pi) { 91 ProcessingInstruction* pi) {
91 DCHECK(!pi->isLoading()); 92 DCHECK(!pi->isLoading());
92 UseCounter::count(document, UseCounter::XSLProcessingInstruction); 93 UseCounter::count(document, UseCounter::XSLProcessingInstruction);
93 XSLTProcessor* processor = XSLTProcessor::create(document); 94 XSLTProcessor* processor = XSLTProcessor::create(document);
94 processor->setXSLStyleSheet(toXSLStyleSheet(pi->sheet())); 95 processor->setXSLStyleSheet(toXSLStyleSheet(pi->sheet()));
95 String resultMIMEType; 96 String resultMIMEType;
96 String newSource; 97 String newSource;
97 String resultEncoding; 98 String resultEncoding;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 173
173 const char* DocumentXSLT::supplementName() { 174 const char* DocumentXSLT::supplementName() {
174 return "DocumentXSLT"; 175 return "DocumentXSLT";
175 } 176 }
176 177
177 bool DocumentXSLT::hasTransformSourceDocument(Document& document) { 178 bool DocumentXSLT::hasTransformSourceDocument(Document& document) {
178 return static_cast<DocumentXSLT*>( 179 return static_cast<DocumentXSLT*>(
179 Supplement<Document>::from(document, supplementName())); 180 Supplement<Document>::from(document, supplementName()));
180 } 181 }
181 182
182 DocumentXSLT& DocumentXSLT::from(Supplementable<Document>& document) { 183 DocumentXSLT& DocumentXSLT::from(Document& document) {
183 DocumentXSLT* supplement = static_cast<DocumentXSLT*>( 184 DocumentXSLT* supplement = static_cast<DocumentXSLT*>(
184 Supplement<Document>::from(document, supplementName())); 185 Supplement<Document>::from(document, supplementName()));
185 if (!supplement) { 186 if (!supplement) {
186 supplement = new DocumentXSLT; 187 supplement = new DocumentXSLT(document);
187 Supplement<Document>::provideTo(document, supplementName(), supplement); 188 Supplement<Document>::provideTo(document, supplementName(), supplement);
188 } 189 }
189 return *supplement; 190 return *supplement;
190 } 191 }
191 192
192 DEFINE_TRACE(DocumentXSLT) { 193 DEFINE_TRACE(DocumentXSLT) {
193 visitor->trace(m_transformSourceDocument); 194 visitor->trace(m_transformSourceDocument);
194 Supplement<Document>::trace(visitor); 195 Supplement<Document>::trace(visitor);
195 } 196 }
196 197
197 } // namespace blink 198 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698