| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 #include "platform/weborigin/SecurityOrigin.h" | 52 #include "platform/weborigin/SecurityOrigin.h" |
| 53 #include "public/platform/WebFrameScheduler.h" | 53 #include "public/platform/WebFrameScheduler.h" |
| 54 #include "wtf/StdLibExtras.h" | 54 #include "wtf/StdLibExtras.h" |
| 55 #include "wtf/text/StringBuilder.h" | 55 #include "wtf/text/StringBuilder.h" |
| 56 #include "wtf/text/StringHash.h" | 56 #include "wtf/text/StringHash.h" |
| 57 | 57 |
| 58 namespace blink { | 58 namespace blink { |
| 59 | 59 |
| 60 ScriptLoader::ScriptLoader(Element* element, bool parserInserted, bool alreadySt
arted) | 60 ScriptLoader::ScriptLoader(Element* element, bool parserInserted, bool alreadySt
arted) |
| 61 : m_element(element) | 61 : m_element(element) |
| 62 , m_resource(0) | |
| 63 , m_startLineNumber(WTF::OrdinalNumber::beforeFirst()) | 62 , m_startLineNumber(WTF::OrdinalNumber::beforeFirst()) |
| 64 , m_parserInserted(parserInserted) | 63 , m_parserInserted(parserInserted) |
| 65 , m_isExternalScript(false) | 64 , m_isExternalScript(false) |
| 66 , m_alreadyStarted(alreadyStarted) | 65 , m_alreadyStarted(alreadyStarted) |
| 67 , m_haveFiredLoad(false) | 66 , m_haveFiredLoad(false) |
| 68 , m_willBeParserExecuted(false) | 67 , m_willBeParserExecuted(false) |
| 69 , m_readyToBeParserExecuted(false) | 68 , m_readyToBeParserExecuted(false) |
| 70 , m_willExecuteInOrder(false) | 69 , m_willExecuteInOrder(false) |
| 71 , m_willExecuteWhenDocumentFinishedParsing(false) | 70 , m_willExecuteWhenDocumentFinishedParsing(false) |
| 72 , m_forceAsync(!parserInserted) | 71 , m_forceAsync(!parserInserted) |
| 73 { | 72 { |
| 74 ASSERT(m_element); | 73 ASSERT(m_element); |
| 75 if (parserInserted && element->document().scriptableDocumentParser() && !ele
ment->document().isInDocumentWrite()) | 74 if (parserInserted && element->document().scriptableDocumentParser() && !ele
ment->document().isInDocumentWrite()) |
| 76 m_startLineNumber = element->document().scriptableDocumentParser()->line
Number(); | 75 m_startLineNumber = element->document().scriptableDocumentParser()->line
Number(); |
| 77 #if ENABLE(OILPAN) | |
| 78 ThreadState::current()->registerPreFinalizer(this); | |
| 79 #endif | |
| 80 } | 76 } |
| 81 | 77 |
| 82 ScriptLoader::~ScriptLoader() | 78 ScriptLoader::~ScriptLoader() |
| 83 { | 79 { |
| 84 #if !ENABLE(OILPAN) | |
| 85 detach(); | |
| 86 #endif | |
| 87 } | 80 } |
| 88 | 81 |
| 89 DEFINE_TRACE(ScriptLoader) | 82 DEFINE_TRACE(ScriptLoader) |
| 90 { | 83 { |
| 91 visitor->trace(m_element); | 84 visitor->trace(m_element); |
| 85 visitor->trace(m_resource); |
| 92 visitor->trace(m_pendingScript); | 86 visitor->trace(m_pendingScript); |
| 93 } | 87 } |
| 94 | 88 |
| 95 void ScriptLoader::didNotifySubtreeInsertionsToDocument() | 89 void ScriptLoader::didNotifySubtreeInsertionsToDocument() |
| 96 { | 90 { |
| 97 if (!m_parserInserted) | 91 if (!m_parserInserted) |
| 98 prepareScript(); // FIXME: Provide a real starting line number here. | 92 prepareScript(); // FIXME: Provide a real starting line number here. |
| 99 } | 93 } |
| 100 | 94 |
| 101 void ScriptLoader::childrenChanged() | 95 void ScriptLoader::childrenChanged() |
| (...skipping 12 matching lines...) Expand all Loading... |
| 114 | 108 |
| 115 void ScriptLoader::handleAsyncAttribute() | 109 void ScriptLoader::handleAsyncAttribute() |
| 116 { | 110 { |
| 117 m_forceAsync = false; | 111 m_forceAsync = false; |
| 118 } | 112 } |
| 119 | 113 |
| 120 void ScriptLoader::detach() | 114 void ScriptLoader::detach() |
| 121 { | 115 { |
| 122 if (!m_pendingScript) | 116 if (!m_pendingScript) |
| 123 return; | 117 return; |
| 124 m_pendingScript->stopWatchingForLoad(this); | 118 m_pendingScript->dispose(); |
| 125 m_pendingScript->releaseElementAndClear(); | |
| 126 m_pendingScript = nullptr; | 119 m_pendingScript = nullptr; |
| 127 } | 120 } |
| 128 | 121 |
| 129 // Helper function | 122 // Helper function |
| 130 static bool isLegacySupportedJavaScriptLanguage(const String& language) | 123 static bool isLegacySupportedJavaScriptLanguage(const String& language) |
| 131 { | 124 { |
| 132 // Mozilla 1.8 accepts javascript1.0 - javascript1.7, but WinIE 7 accepts on
ly javascript1.1 - javascript1.3. | 125 // Mozilla 1.8 accepts javascript1.0 - javascript1.7, but WinIE 7 accepts on
ly javascript1.1 - javascript1.3. |
| 133 // Mozilla 1.8 and WinIE 7 both accept javascript and livescript. | 126 // Mozilla 1.8 and WinIE 7 both accept javascript and livescript. |
| 134 // WinIE 7 accepts ecmascript and jscript, but Mozilla 1.8 doesn't. | 127 // WinIE 7 accepts ecmascript and jscript, but Mozilla 1.8 doesn't. |
| 135 // Neither Mozilla 1.8 nor WinIE 7 accept leading or trailing whitespace. | 128 // Neither Mozilla 1.8 nor WinIE 7 accept leading or trailing whitespace. |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 RefPtrWillBeRawPtr<Element> element = m_pendingScript->releaseElementAndClea
r(); | 440 RefPtrWillBeRawPtr<Element> element = m_pendingScript->releaseElementAndClea
r(); |
| 448 ALLOW_UNUSED_LOCAL(element); | 441 ALLOW_UNUSED_LOCAL(element); |
| 449 if (errorOccurred) { | 442 if (errorOccurred) { |
| 450 dispatchErrorEvent(); | 443 dispatchErrorEvent(); |
| 451 } else if (!m_resource->wasCanceled()) { | 444 } else if (!m_resource->wasCanceled()) { |
| 452 if (executeScript(source)) | 445 if (executeScript(source)) |
| 453 dispatchLoadEvent(); | 446 dispatchLoadEvent(); |
| 454 else | 447 else |
| 455 dispatchErrorEvent(); | 448 dispatchErrorEvent(); |
| 456 } | 449 } |
| 457 m_resource = 0; | 450 m_resource = nullptr; |
| 458 } | 451 } |
| 459 | 452 |
| 460 void ScriptLoader::notifyFinished(Resource* resource) | 453 void ScriptLoader::notifyFinished(Resource* resource) |
| 461 { | 454 { |
| 462 ASSERT(!m_willBeParserExecuted); | 455 ASSERT(!m_willBeParserExecuted); |
| 463 | 456 |
| 464 RefPtrWillBeRawPtr<Document> elementDocument(m_element->document()); | 457 RefPtrWillBeRawPtr<Document> elementDocument(m_element->document()); |
| 465 RefPtrWillBeRawPtr<Document> contextDocument = elementDocument->contextDocum
ent().get(); | 458 RefPtrWillBeRawPtr<Document> contextDocument = elementDocument->contextDocum
ent().get(); |
| 466 if (!contextDocument) | 459 if (!contextDocument) |
| 467 return; | 460 return; |
| 468 | 461 |
| 469 ASSERT_UNUSED(resource, resource == m_resource); | 462 ASSERT_UNUSED(resource, resource == m_resource); |
| 470 | 463 |
| 471 ScriptRunner::ExecutionType runOrder = m_willExecuteInOrder ? ScriptRunner::
IN_ORDER_EXECUTION : ScriptRunner::ASYNC_EXECUTION; | 464 ScriptRunner::ExecutionType runOrder = m_willExecuteInOrder ? ScriptRunner::
IN_ORDER_EXECUTION : ScriptRunner::ASYNC_EXECUTION; |
| 472 if (m_resource->errorOccurred()) { | 465 if (m_resource->errorOccurred()) { |
| 473 dispatchErrorEvent(); | 466 dispatchErrorEvent(); |
| 474 // The error handler can move the HTMLScriptElement to a new document. | 467 // The error handler can move the HTMLScriptElement to a new document. |
| 475 // In that case, we must notify the ScriptRunner of the new document, | 468 // In that case, we must notify the ScriptRunner of the new document, |
| 476 // not the ScriptRunner of the old docuemnt. | 469 // not the ScriptRunner of the old docuemnt. |
| 477 contextDocument = m_element->document().contextDocument().get(); | 470 contextDocument = m_element->document().contextDocument().get(); |
| 478 if (!contextDocument) | 471 if (!contextDocument) |
| 479 return; | 472 return; |
| 480 contextDocument->scriptRunner()->notifyScriptLoadError(this, runOrder); | 473 contextDocument->scriptRunner()->notifyScriptLoadError(this, runOrder); |
| 481 return; | 474 return; |
| 482 } | 475 } |
| 483 contextDocument->scriptRunner()->notifyScriptReady(this, runOrder); | 476 contextDocument->scriptRunner()->notifyScriptReady(this, runOrder); |
| 484 m_pendingScript->stopWatchingForLoad(this); | 477 m_pendingScript->stopWatchingForLoad(); |
| 485 } | 478 } |
| 486 | 479 |
| 487 bool ScriptLoader::ignoresLoadRequest() const | 480 bool ScriptLoader::ignoresLoadRequest() const |
| 488 { | 481 { |
| 489 return m_alreadyStarted || m_isExternalScript || m_parserInserted || !elemen
t() || !element()->inDocument(); | 482 return m_alreadyStarted || m_isExternalScript || m_parserInserted || !elemen
t() || !element()->inDocument(); |
| 490 } | 483 } |
| 491 | 484 |
| 492 bool ScriptLoader::isScriptForEventSupported() const | 485 bool ScriptLoader::isScriptForEventSupported() const |
| 493 { | 486 { |
| 494 String eventAttribute = client()->eventAttributeValue(); | 487 String eventAttribute = client()->eventAttributeValue(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 525 if (isHTMLScriptLoader(element)) | 518 if (isHTMLScriptLoader(element)) |
| 526 return toHTMLScriptElement(element)->loader(); | 519 return toHTMLScriptElement(element)->loader(); |
| 527 | 520 |
| 528 if (isSVGScriptLoader(element)) | 521 if (isSVGScriptLoader(element)) |
| 529 return toSVGScriptElement(element)->loader(); | 522 return toSVGScriptElement(element)->loader(); |
| 530 | 523 |
| 531 return 0; | 524 return 0; |
| 532 } | 525 } |
| 533 | 526 |
| 534 } // namespace blink | 527 } // namespace blink |
| OLD | NEW |