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 | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights |
6 * reserved. | 6 * reserved. |
7 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org> | 7 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org> |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 } | 135 } |
136 | 136 |
137 void ScriptLoader::handleAsyncAttribute() { | 137 void ScriptLoader::handleAsyncAttribute() { |
138 // https://html.spec.whatwg.org/#non-blocking | 138 // https://html.spec.whatwg.org/#non-blocking |
139 // "In addition, whenever a script element whose "non-blocking" flag is set | 139 // "In addition, whenever a script element whose "non-blocking" flag is set |
140 // has an async content attribute added, the element's "non-blocking" flag | 140 // has an async content attribute added, the element's "non-blocking" flag |
141 // must be unset." | 141 // must be unset." |
142 m_nonBlocking = false; | 142 m_nonBlocking = false; |
143 } | 143 } |
144 | 144 |
145 void ScriptLoader::detach() { | 145 void ScriptLoader::detachPendingScript() { |
146 if (!m_pendingScript) | 146 if (!m_pendingScript) |
147 return; | 147 return; |
148 m_pendingScript->dispose(); | 148 m_pendingScript->dispose(); |
149 m_pendingScript = nullptr; | 149 m_pendingScript = nullptr; |
150 } | 150 } |
151 | 151 |
152 static bool isLegacySupportedJavaScriptLanguage(const String& language) { | 152 static bool isLegacySupportedJavaScriptLanguage(const String& language) { |
153 // Mozilla 1.8 accepts javascript1.0 - javascript1.7, but WinIE 7 accepts only | 153 // Mozilla 1.8 accepts javascript1.0 - javascript1.7, but WinIE 7 accepts only |
154 // javascript1.1 - javascript1.3. | 154 // javascript1.1 - javascript1.3. |
155 // Mozilla 1.8 and WinIE 7 both accept javascript and livescript. | 155 // Mozilla 1.8 and WinIE 7 both accept javascript and livescript. |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
810 // if it was incremented in the earlier step." | 810 // if it was incremented in the earlier step." |
811 // Implemented as the scope out of IgnoreDestructiveWriteCountIncrementer. | 811 // Implemented as the scope out of IgnoreDestructiveWriteCountIncrementer. |
812 } | 812 } |
813 | 813 |
814 void ScriptLoader::execute() { | 814 void ScriptLoader::execute() { |
815 DCHECK(!m_willBeParserExecuted); | 815 DCHECK(!m_willBeParserExecuted); |
816 DCHECK(m_asyncExecType != ScriptRunner::None); | 816 DCHECK(m_asyncExecType != ScriptRunner::None); |
817 DCHECK(m_pendingScript->resource()); | 817 DCHECK(m_pendingScript->resource()); |
818 bool errorOccurred = false; | 818 bool errorOccurred = false; |
819 ScriptSourceCode source = m_pendingScript->getSource(KURL(), errorOccurred); | 819 ScriptSourceCode source = m_pendingScript->getSource(KURL(), errorOccurred); |
820 m_pendingScript->dispose(); | 820 detachPendingScript(); |
821 if (errorOccurred) { | 821 if (errorOccurred) { |
822 dispatchErrorEvent(); | 822 dispatchErrorEvent(); |
823 } else if (!m_resource->wasCanceled()) { | 823 } else if (!m_resource->wasCanceled()) { |
824 if (executeScript(source)) | 824 if (executeScript(source)) |
825 dispatchLoadEvent(); | 825 dispatchLoadEvent(); |
826 else | 826 else |
827 dispatchErrorEvent(); | 827 dispatchErrorEvent(); |
828 } | 828 } |
829 m_resource = nullptr; | 829 m_resource = nullptr; |
830 } | 830 } |
(...skipping 10 matching lines...) Expand all Loading... |
841 DocumentWriteIntervention::FetchDocWrittenScriptDeferIdle) { | 841 DocumentWriteIntervention::FetchDocWrittenScriptDeferIdle) { |
842 memoryCache()->remove(m_pendingScript->resource()); | 842 memoryCache()->remove(m_pendingScript->resource()); |
843 m_pendingScript->stopWatchingForLoad(); | 843 m_pendingScript->stopWatchingForLoad(); |
844 return; | 844 return; |
845 } | 845 } |
846 | 846 |
847 DCHECK(m_asyncExecType != ScriptRunner::None); | 847 DCHECK(m_asyncExecType != ScriptRunner::None); |
848 | 848 |
849 Document* contextDocument = m_element->document().contextDocument(); | 849 Document* contextDocument = m_element->document().contextDocument(); |
850 if (!contextDocument) { | 850 if (!contextDocument) { |
851 detach(); | 851 detachPendingScript(); |
852 return; | 852 return; |
853 } | 853 } |
854 | 854 |
855 DCHECK_EQ(pendingScript->resource(), m_resource); | 855 DCHECK_EQ(pendingScript->resource(), m_resource); |
856 | 856 |
857 if (m_resource->errorOccurred()) { | 857 if (m_resource->errorOccurred()) { |
858 contextDocument->scriptRunner()->notifyScriptLoadError(this, | 858 contextDocument->scriptRunner()->notifyScriptLoadError(this, |
859 m_asyncExecType); | 859 m_asyncExecType); |
860 detach(); | 860 detachPendingScript(); |
861 dispatchErrorEvent(); | 861 dispatchErrorEvent(); |
862 return; | 862 return; |
863 } | 863 } |
864 contextDocument->scriptRunner()->notifyScriptReady(this, m_asyncExecType); | 864 contextDocument->scriptRunner()->notifyScriptReady(this, m_asyncExecType); |
865 m_pendingScript->stopWatchingForLoad(); | 865 m_pendingScript->stopWatchingForLoad(); |
866 } | 866 } |
867 | 867 |
868 bool ScriptLoader::ignoresLoadRequest() const { | 868 bool ScriptLoader::ignoresLoadRequest() const { |
869 return m_alreadyStarted || m_isExternalScript || m_parserInserted || | 869 return m_alreadyStarted || m_isExternalScript || m_parserInserted || |
870 !element() || !element()->isConnected(); | 870 !element() || !element()->isConnected(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
917 if (isHTMLScriptLoader(element)) | 917 if (isHTMLScriptLoader(element)) |
918 return toHTMLScriptElement(element)->loader(); | 918 return toHTMLScriptElement(element)->loader(); |
919 | 919 |
920 if (isSVGScriptLoader(element)) | 920 if (isSVGScriptLoader(element)) |
921 return toSVGScriptElement(element)->loader(); | 921 return toSVGScriptElement(element)->loader(); |
922 | 922 |
923 return 0; | 923 return 0; |
924 } | 924 } |
925 | 925 |
926 } // namespace blink | 926 } // namespace blink |
OLD | NEW |