| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserv
ed. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserv
ed. |
| 6 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org> | 6 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org> |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 String type = typeAttributeValue(); | 154 String type = typeAttributeValue(); |
| 155 String language = languageAttributeValue(); | 155 String language = languageAttributeValue(); |
| 156 if (type.isEmpty() && language.isEmpty()) | 156 if (type.isEmpty() && language.isEmpty()) |
| 157 return true; // Assume text/javascript. | 157 return true; // Assume text/javascript. |
| 158 if (type.isEmpty()) { | 158 if (type.isEmpty()) { |
| 159 type = "text/" + language.lower(); | 159 type = "text/" + language.lower(); |
| 160 if (MIMETypeRegistry::isSupportedJavaScriptMIMEType(type) || isLegacySup
portedJavaScriptLanguage(language)) | 160 if (MIMETypeRegistry::isSupportedJavaScriptMIMEType(type) || isLegacySup
portedJavaScriptLanguage(language)) |
| 161 return true; | 161 return true; |
| 162 } else if (MIMETypeRegistry::isSupportedJavaScriptMIMEType(type.stripWhiteSp
ace().lower()) || (supportLegacyTypes == AllowLegacyTypeInTypeAttribute && isLeg
acySupportedJavaScriptLanguage(type))) | 162 } else if (MIMETypeRegistry::isSupportedJavaScriptMIMEType(type.stripWhiteSp
ace().lower()) || (supportLegacyTypes == AllowLegacyTypeInTypeAttribute && isLeg
acySupportedJavaScriptLanguage(type))) |
| 163 return true; | 163 return true; |
| 164 else { |
| 165 // FIXME: move JavaScript related logic to ScriptController::isScriptTyp
eSupported? |
| 166 Frame* frame = m_element->document()->frame(); |
| 167 if (frame && frame->script()->isScriptTypeSupported(type.stripWhiteSpace
().lower())) |
| 168 return true; |
| 169 } |
| 164 return false; | 170 return false; |
| 165 } | 171 } |
| 166 | 172 |
| 167 // http://dev.w3.org/html5/spec/Overview.html#prepare-a-script | 173 // http://dev.w3.org/html5/spec/Overview.html#prepare-a-script |
| 168 bool ScriptElement::prepareScript(const TextPosition& scriptStartPosition, Legac
yTypeSupport supportLegacyTypes) | 174 bool ScriptElement::prepareScript(const TextPosition& scriptStartPosition, Legac
yTypeSupport supportLegacyTypes) |
| 169 { | 175 { |
| 170 if (m_alreadyStarted) | 176 if (m_alreadyStarted) |
| 171 return false; | 177 return false; |
| 172 | 178 |
| 173 bool wasParserInserted; | 179 bool wasParserInserted; |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 return; | 297 return; |
| 292 | 298 |
| 293 RefPtr<Document> document = m_element->document(); | 299 RefPtr<Document> document = m_element->document(); |
| 294 ASSERT(document); | 300 ASSERT(document); |
| 295 if (Frame* frame = document->frame()) { | 301 if (Frame* frame = document->frame()) { |
| 296 { | 302 { |
| 297 IgnoreDestructiveWriteCountIncrementer ignoreDesctructiveWriteCountI
ncrementer(m_isExternalScript ? document.get() : 0); | 303 IgnoreDestructiveWriteCountIncrementer ignoreDesctructiveWriteCountI
ncrementer(m_isExternalScript ? document.get() : 0); |
| 298 // Create a script from the script element node, using the script | 304 // Create a script from the script element node, using the script |
| 299 // block's source and the script block's type. | 305 // block's source and the script block's type. |
| 300 // Note: This is where the script is compiled and actually executed. | 306 // Note: This is where the script is compiled and actually executed. |
| 301 frame->script()->evaluate(sourceCode); | 307 // FIXME: ScriptSourceCode mimeType should be set by the caller. |
| 308 ScriptSourceCode sourceCodeCopy(sourceCode); |
| 309 sourceCodeCopy.setMimeType(typeAttributeValue().stripWhiteSpace().lo
wer()); |
| 310 frame->script()->evaluate(sourceCodeCopy); |
| 302 } | 311 } |
| 303 | 312 |
| 304 Document::updateStyleForAllDocuments(); | 313 Document::updateStyleForAllDocuments(); |
| 305 } | 314 } |
| 306 } | 315 } |
| 307 | 316 |
| 308 void ScriptElement::stopLoadRequest() | 317 void ScriptElement::stopLoadRequest() |
| 309 { | 318 { |
| 310 if (m_cachedScript) { | 319 if (m_cachedScript) { |
| 311 if (!m_willBeParserExecuted) | 320 if (!m_willBeParserExecuted) |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 | 415 |
| 407 #if ENABLE(SVG) | 416 #if ENABLE(SVG) |
| 408 if (element->isSVGElement() && element->hasTagName(SVGNames::scriptTag)) | 417 if (element->isSVGElement() && element->hasTagName(SVGNames::scriptTag)) |
| 409 return static_cast<SVGScriptElement*>(element); | 418 return static_cast<SVGScriptElement*>(element); |
| 410 #endif | 419 #endif |
| 411 | 420 |
| 412 return 0; | 421 return 0; |
| 413 } | 422 } |
| 414 | 423 |
| 415 } | 424 } |
| OLD | NEW |