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

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

Issue 2274573004: Replace ASSERT*() with DCHECK*() in core/xml/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 17 matching lines...) Expand all
28 return new DOMContentLoadedListener(scriptState, pi); 28 return new DOMContentLoadedListener(scriptState, pi);
29 } 29 }
30 30
31 bool operator==(const EventListener&) const override 31 bool operator==(const EventListener&) const override
32 { 32 {
33 return true; 33 return true;
34 } 34 }
35 35
36 virtual void handleEvent(ScriptState* scriptState, Event* event) 36 virtual void handleEvent(ScriptState* scriptState, Event* event)
37 { 37 {
38 ASSERT(RuntimeEnabledFeatures::xsltEnabled()); 38 DCHECK(RuntimeEnabledFeatures::xsltEnabled());
39 ASSERT(event->type() == "DOMContentLoaded"); 39 DCHECK_EQ(event->type(), "DOMContentLoaded");
40 ScriptState::Scope scope(scriptState); 40 ScriptState::Scope scope(scriptState);
41 41
42 Document& document = *toDocument(scriptState->getExecutionContext()); 42 Document& document = *toDocument(scriptState->getExecutionContext());
43 ASSERT(!document.parsing()); 43 DCHECK(!document.parsing());
44 44
45 // Processing instruction (XML documents only). 45 // Processing instruction (XML documents only).
46 // We don't support linking to embedded CSS stylesheets, 46 // We don't support linking to embedded CSS stylesheets,
47 // see <https://bugs.webkit.org/show_bug.cgi?id=49281> for discussion. 47 // see <https://bugs.webkit.org/show_bug.cgi?id=49281> for discussion.
48 // Don't apply XSL transforms to already transformed documents. 48 // Don't apply XSL transforms to already transformed documents.
49 if (DocumentXSLT::hasTransformSourceDocument(document)) 49 if (DocumentXSLT::hasTransformSourceDocument(document))
50 return; 50 return;
51 51
52 ProcessingInstruction* pi = DocumentXSLT::findXSLStyleSheet(document); 52 ProcessingInstruction* pi = DocumentXSLT::findXSLStyleSheet(document);
53 if (!pi || pi != m_processingInstruction || pi->isLoading()) 53 if (!pi || pi != m_processingInstruction || pi->isLoading())
(...skipping 20 matching lines...) Expand all
74 74
75 private: 75 private:
76 DOMContentLoadedListener(ScriptState* scriptState, ProcessingInstruction* pi ) 76 DOMContentLoadedListener(ScriptState* scriptState, ProcessingInstruction* pi )
77 : V8AbstractEventListener(false, scriptState->world(), scriptState->isol ate()) 77 : V8AbstractEventListener(false, scriptState->world(), scriptState->isol ate())
78 , m_processingInstruction(pi) 78 , m_processingInstruction(pi)
79 { 79 {
80 } 80 }
81 81
82 virtual v8::Local<v8::Value> callListenerFunction(ScriptState*, v8::Local<v8 ::Value>, Event*) 82 virtual v8::Local<v8::Value> callListenerFunction(ScriptState*, v8::Local<v8 ::Value>, Event*)
83 { 83 {
84 ASSERT_NOT_REACHED(); 84 NOTREACHED();
85 return v8::Local<v8::Value>(); 85 return v8::Local<v8::Value>();
86 } 86 }
87 87
88 // If this event listener is attached to a ProcessingInstruction, keep a 88 // If this event listener is attached to a ProcessingInstruction, keep a
89 // weak reference back to it. That ProcessingInstruction is responsible for 89 // weak reference back to it. That ProcessingInstruction is responsible for
90 // detaching itself and clear out the reference. 90 // detaching itself and clear out the reference.
91 Member<ProcessingInstruction> m_processingInstruction; 91 Member<ProcessingInstruction> m_processingInstruction;
92 }; 92 };
93 93
94 DocumentXSLT::DocumentXSLT() 94 DocumentXSLT::DocumentXSLT()
95 : m_transformSourceDocument(nullptr) 95 : m_transformSourceDocument(nullptr)
96 { 96 {
97 } 97 }
98 98
99 void DocumentXSLT::applyXSLTransform(Document& document, ProcessingInstruction* pi) 99 void DocumentXSLT::applyXSLTransform(Document& document, ProcessingInstruction* pi)
100 { 100 {
101 ASSERT(!pi->isLoading()); 101 DCHECK(!pi->isLoading());
102 UseCounter::count(document, UseCounter::XSLProcessingInstruction); 102 UseCounter::count(document, UseCounter::XSLProcessingInstruction);
103 XSLTProcessor* processor = XSLTProcessor::create(document); 103 XSLTProcessor* processor = XSLTProcessor::create(document);
104 processor->setXSLStyleSheet(toXSLStyleSheet(pi->sheet())); 104 processor->setXSLStyleSheet(toXSLStyleSheet(pi->sheet()));
105 String resultMIMEType; 105 String resultMIMEType;
106 String newSource; 106 String newSource;
107 String resultEncoding; 107 String resultEncoding;
108 document.setParsingState(Document::Parsing); 108 document.setParsingState(Document::Parsing);
109 if (!processor->transformToString(&document, resultMIMEType, newSource, resu ltEncoding)) { 109 if (!processor->transformToString(&document, resultMIMEType, newSource, resu ltEncoding)) {
110 document.setParsingState(Document::FinishedParsing); 110 document.setParsingState(Document::FinishedParsing);
111 return; 111 return;
(...skipping 24 matching lines...) Expand all
136 return false; 136 return false;
137 137
138 if (!RuntimeEnabledFeatures::xsltEnabled() || !document.frame()) 138 if (!RuntimeEnabledFeatures::xsltEnabled() || !document.frame())
139 return true; 139 return true;
140 140
141 ScriptState* scriptState = ScriptState::forMainWorld(document.frame()); 141 ScriptState* scriptState = ScriptState::forMainWorld(document.frame());
142 if (!scriptState) 142 if (!scriptState)
143 return false; 143 return false;
144 DOMContentLoadedListener* listener = DOMContentLoadedListener::create(script State, pi); 144 DOMContentLoadedListener* listener = DOMContentLoadedListener::create(script State, pi);
145 document.addEventListener(EventTypeNames::DOMContentLoaded, listener, false) ; 145 document.addEventListener(EventTypeNames::DOMContentLoaded, listener, false) ;
146 ASSERT(!pi->eventListenerForXSLT()); 146 DCHECK(!pi->eventListenerForXSLT());
147 pi->setEventListenerForXSLT(listener); 147 pi->setEventListenerForXSLT(listener);
148 return true; 148 return true;
149 } 149 }
150 150
151 bool DocumentXSLT::processingInstructionRemovedFromDocument(Document& document, ProcessingInstruction* pi) 151 bool DocumentXSLT::processingInstructionRemovedFromDocument(Document& document, ProcessingInstruction* pi)
152 { 152 {
153 if (!pi->isXSL()) 153 if (!pi->isXSL())
154 return false; 154 return false;
155 155
156 if (!pi->eventListenerForXSLT()) 156 if (!pi->eventListenerForXSLT())
157 return true; 157 return true;
158 158
159 ASSERT(RuntimeEnabledFeatures::xsltEnabled()); 159 DCHECK(RuntimeEnabledFeatures::xsltEnabled());
160 document.removeEventListener(EventTypeNames::DOMContentLoaded, pi->eventList enerForXSLT(), false); 160 document.removeEventListener(EventTypeNames::DOMContentLoaded, pi->eventList enerForXSLT(), false);
161 pi->clearEventListenerForXSLT(); 161 pi->clearEventListenerForXSLT();
162 return true; 162 return true;
163 } 163 }
164 164
165 bool DocumentXSLT::sheetLoaded(Document& document, ProcessingInstruction* pi) 165 bool DocumentXSLT::sheetLoaded(Document& document, ProcessingInstruction* pi)
166 { 166 {
167 if (!pi->isXSL()) 167 if (!pi->isXSL())
168 return false; 168 return false;
169 169
(...skipping 26 matching lines...) Expand all
196 return *supplement; 196 return *supplement;
197 } 197 }
198 198
199 DEFINE_TRACE(DocumentXSLT) 199 DEFINE_TRACE(DocumentXSLT)
200 { 200 {
201 visitor->trace(m_transformSourceDocument); 201 visitor->trace(m_transformSourceDocument);
202 Supplement<Document>::trace(visitor); 202 Supplement<Document>::trace(visitor);
203 } 203 }
204 204
205 } // namespace blink 205 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/xml/DocumentXSLT.h ('k') | third_party/WebKit/Source/core/xml/XMLSerializer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698