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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 m_element->dispatchEvent(Event::create(EventTypeNames::error)); | 155 m_element->dispatchEvent(Event::create(EventTypeNames::error)); |
156 } | 156 } |
157 | 157 |
158 void ScriptLoader::dispatchLoadEvent() | 158 void ScriptLoader::dispatchLoadEvent() |
159 { | 159 { |
160 if (ScriptLoaderClient* client = this->client()) | 160 if (ScriptLoaderClient* client = this->client()) |
161 client->dispatchLoadEvent(); | 161 client->dispatchLoadEvent(); |
162 setHaveFiredLoadEvent(true); | 162 setHaveFiredLoadEvent(true); |
163 } | 163 } |
164 | 164 |
165 ScriptLoader::ScriptType ScriptLoader::isScriptTypeSupported(LegacyTypeSupport s
upportLegacyTypes) const | 165 bool ScriptLoader::isScriptTypeSupported(LegacyTypeSupport supportLegacyTypes) c
onst |
166 { | 166 { |
167 // FIXME: isLegacySupportedJavaScriptLanguage() is not valid HTML5. It is us
ed here to maintain backwards compatibility with existing layout tests. The spec
ific violations are: | 167 // FIXME: isLegacySupportedJavaScriptLanguage() is not valid HTML5. It is us
ed here to maintain backwards compatibility with existing layout tests. The spec
ific violations are: |
168 // - Allowing type=javascript. type= should only support MIME types, such as
text/javascript. | 168 // - Allowing type=javascript. type= should only support MIME types, such as
text/javascript. |
| 169 // - Allowing a different set of languages for language= and type=. language
= supports Javascript 1.1 and 1.4-1.6, but type= does not. |
| 170 |
| 171 String type = client()->typeAttributeValue(); |
| 172 String language = client()->languageAttributeValue(); |
| 173 if (type.isEmpty() && language.isEmpty()) |
| 174 return ScriptJavaScript; // Assume text/javascript. |
| 175 if (type.isEmpty()) { |
| 176 type = "text/" + language.lower(); |
| 177 if (MIMETypeRegistry::isSupportedJavaScriptMIMEType(type) || isLegacySup
portedJavaScriptLanguage(language)) |
| 178 return true; |
| 179 } else if (MIMETypeRegistry::isSupportedJavaScriptMIMEType(type.stripWhiteSp
ace()) || (supportLegacyTypes == AllowLegacyTypeInTypeAttribute && isLegacySuppo
rtedJavaScriptLanguage(type))) { |
| 180 return true; |
| 181 } else if (MIMETypeRegistry::isSupportedDartMIMEType(type.stripWhiteSpace())
) { |
| 182 // FIXMEDART: Added check for Dart MIME type |
| 183 return true; |
| 184 } |
| 185 |
| 186 return false; |
| 187 } |
| 188 |
| 189 |
| 190 // FIXMEDART: Added to return ScriptType and to support Dart MIME type similar t
o isScriptTypeSupported |
| 191 // but returns a enum for the script type. |
| 192 ScriptLoader::ScriptType ScriptLoader::getScriptTypeSupported(LegacyTypeSupport
supportLegacyTypes) const |
| 193 { |
| 194 // FIXME: isLegacySupportedJavaScriptLanguage() is not valid HTML5. It is us
ed here to maintain backwards compatibility with existing layout tests. The spec
ific violations are: |
| 195 // - Allowing type=javascript. type= should only support MIME types, such as
text/javascript. |
169 // - Allowing a different set of languages for language= and type=. language
= supports Javascript 1.1 and 1.4-1.6, but type= does not. | 196 // - Allowing a different set of languages for language= and type=. language
= supports Javascript 1.1 and 1.4-1.6, but type= does not. |
170 | 197 |
171 String type = client()->typeAttributeValue(); | 198 String type = client()->typeAttributeValue(); |
172 String language = client()->languageAttributeValue(); | 199 String language = client()->languageAttributeValue(); |
173 if (type.isEmpty() && language.isEmpty()) | 200 if (type.isEmpty() && language.isEmpty()) |
174 return ScriptJavaScript; // Assume text/javascript. | 201 return ScriptJavaScript; // Assume text/javascript. |
175 if (type.isEmpty()) { | 202 if (type.isEmpty()) { |
176 type = "text/" + language.lower(); | 203 type = "text/" + language.lower(); |
177 if (MIMETypeRegistry::isSupportedJavaScriptMIMEType(type) || isLegacySup
portedJavaScriptLanguage(language)) | 204 if (MIMETypeRegistry::isSupportedJavaScriptMIMEType(type) || isLegacySup
portedJavaScriptLanguage(language)) |
178 return ScriptJavaScript; | 205 return ScriptJavaScript; |
179 } else if (MIMETypeRegistry::isSupportedJavaScriptMIMEType(type.stripWhiteSp
ace()) || (supportLegacyTypes == AllowLegacyTypeInTypeAttribute && isLegacySuppo
rtedJavaScriptLanguage(type))) { | 206 } else if (MIMETypeRegistry::isSupportedJavaScriptMIMEType(type.stripWhiteSp
ace()) || (supportLegacyTypes == AllowLegacyTypeInTypeAttribute && isLegacySuppo
rtedJavaScriptLanguage(type))) { |
180 return ScriptJavaScript; | 207 return ScriptJavaScript; |
181 } else if (MIMETypeRegistry::isSupportedDartMIMEType(type.stripWhiteSpace())
) { | 208 } else if (MIMETypeRegistry::isSupportedDartMIMEType(type.stripWhiteSpace())
) { |
| 209 // FIXMEDART: Added checked for Dart MIME type |
182 return ScriptDart; | 210 return ScriptDart; |
183 } | 211 } |
184 | 212 |
185 return ScriptNone; | 213 return ScriptNone; |
186 } | 214 } |
187 | 215 |
188 // http://dev.w3.org/html5/spec/Overview.html#prepare-a-script | 216 // http://dev.w3.org/html5/spec/Overview.html#prepare-a-script |
189 bool ScriptLoader::prepareScript(const TextPosition& scriptStartPosition, Legacy
TypeSupport supportLegacyTypes) | 217 bool ScriptLoader::prepareScript(const TextPosition& scriptStartPosition, Legacy
TypeSupport supportLegacyTypes) |
190 { | 218 { |
191 if (m_alreadyStarted) | 219 if (m_alreadyStarted) |
(...skipping 15 matching lines...) Expand all Loading... |
207 // FIXME: HTML5 spec says we should check that all children are either comme
nts or empty text nodes. | 235 // FIXME: HTML5 spec says we should check that all children are either comme
nts or empty text nodes. |
208 if (!client->hasSourceAttribute() && !m_element->hasChildren()) | 236 if (!client->hasSourceAttribute() && !m_element->hasChildren()) |
209 return false; | 237 return false; |
210 | 238 |
211 if (!m_element->inDocument()) | 239 if (!m_element->inDocument()) |
212 return false; | 240 return false; |
213 | 241 |
214 if (!isScriptTypeSupported(supportLegacyTypes)) | 242 if (!isScriptTypeSupported(supportLegacyTypes)) |
215 return false; | 243 return false; |
216 | 244 |
| 245 // FIXMEDAT: Changed to compute the script type. |
| 246 m_scriptType = getScriptTypeSupported(supportLegacyTypes); |
| 247 RELEASE_ASSERT(m_scriptType != ScriptNone); |
| 248 |
217 if (wasParserInserted) { | 249 if (wasParserInserted) { |
218 m_parserInserted = true; | 250 m_parserInserted = true; |
219 m_forceAsync = false; | 251 m_forceAsync = false; |
220 } | 252 } |
221 | 253 |
222 m_alreadyStarted = true; | 254 m_alreadyStarted = true; |
223 | 255 |
224 // FIXME: If script is parser inserted, verify it's still in the original do
cument. | 256 // FIXME: If script is parser inserted, verify it's still in the original do
cument. |
225 Document& elementDocument = m_element->document(); | 257 Document& elementDocument = m_element->document(); |
226 Document* contextDocument = elementDocument.contextDocument().get(); | 258 Document* contextDocument = elementDocument.contextDocument().get(); |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 if (isHTMLScriptLoader(element)) | 541 if (isHTMLScriptLoader(element)) |
510 return toHTMLScriptElement(element)->loader(); | 542 return toHTMLScriptElement(element)->loader(); |
511 | 543 |
512 if (isSVGScriptLoader(element)) | 544 if (isSVGScriptLoader(element)) |
513 return toSVGScriptElement(element)->loader(); | 545 return toSVGScriptElement(element)->loader(); |
514 | 546 |
515 return 0; | 547 return 0; |
516 } | 548 } |
517 | 549 |
518 } // namespace blink | 550 } // namespace blink |
OLD | NEW |