OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2000 Peter Kelly (pmk@post.com) | 2 * Copyright (C) 2000 Peter Kelly (pmk@post.com) |
3 * Copyright (C) 2005, 2006, 2008, 2014 Apple Inc. All rights reserved. | 3 * Copyright (C) 2005, 2006, 2008, 2014 Apple Inc. All rights reserved. |
4 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 4 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
5 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org) | 5 * Copyright (C) 2007 Samuel Weinig (sam@webkit.org) |
6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
7 * Copyright (C) 2008 Holger Hans Peter Freyther | 7 * Copyright (C) 2008 Holger Hans Peter Freyther |
8 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. | 8 * Copyright (C) 2008 Torch Mobile Inc. All rights reserved. |
9 * (http://www.torchmobile.com/) | 9 * (http://www.torchmobile.com/) |
10 * | 10 * |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
441 bool wasCanceled = m_pendingScript->wasCanceled(); | 441 bool wasCanceled = m_pendingScript->wasCanceled(); |
442 double scriptParserBlockingTime = m_parserBlockingPendingScriptLoadStartTime; | 442 double scriptParserBlockingTime = m_parserBlockingPendingScriptLoadStartTime; |
443 m_parserBlockingPendingScriptLoadStartTime = 0.0; | 443 m_parserBlockingPendingScriptLoadStartTime = 0.0; |
444 | 444 |
445 m_pendingScript->removeClient(this); | 445 m_pendingScript->removeClient(this); |
446 m_pendingScript = nullptr; | 446 m_pendingScript = nullptr; |
447 | 447 |
448 Element* e = m_scriptElement; | 448 Element* e = m_scriptElement; |
449 m_scriptElement = nullptr; | 449 m_scriptElement = nullptr; |
450 | 450 |
451 ScriptLoader* scriptLoader = toScriptLoaderIfPossible(e); | 451 ScriptLoader* scriptLoader = |
452 ScriptLoaderClient::fromElementIfPossible(e)->loader(); | |
452 DCHECK(scriptLoader); | 453 DCHECK(scriptLoader); |
453 | 454 |
454 if (errorOccurred) { | 455 if (errorOccurred) { |
455 scriptLoader->dispatchErrorEvent(); | 456 scriptLoader->dispatchErrorEvent(); |
456 } else if (!wasCanceled) { | 457 } else if (!wasCanceled) { |
457 if (scriptParserBlockingTime > 0.0) { | 458 if (scriptParserBlockingTime > 0.0) { |
458 DocumentParserTiming::from(*document()) | 459 DocumentParserTiming::from(*document()) |
459 .recordParserBlockedOnScriptLoadDuration( | 460 .recordParserBlockedOnScriptLoadDuration( |
460 monotonicallyIncreasingTime() - scriptParserBlockingTime, | 461 monotonicallyIncreasingTime() - scriptParserBlockingTime, |
461 scriptLoader->wasCreatedDuringDocumentWrite()); | 462 scriptLoader->wasCreatedDuringDocumentWrite()); |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1022 handleElementAttributes(prefixedAttributes, libxmlAttributes, nbAttributes, | 1023 handleElementAttributes(prefixedAttributes, libxmlAttributes, nbAttributes, |
1023 m_prefixToNamespaceMap, exceptionState); | 1024 m_prefixToNamespaceMap, exceptionState); |
1024 setAttributes(newElement, prefixedAttributes, getParserContentPolicy()); | 1025 setAttributes(newElement, prefixedAttributes, getParserContentPolicy()); |
1025 if (exceptionState.hadException()) { | 1026 if (exceptionState.hadException()) { |
1026 stopParsing(); | 1027 stopParsing(); |
1027 return; | 1028 return; |
1028 } | 1029 } |
1029 | 1030 |
1030 newElement->beginParsingChildren(); | 1031 newElement->beginParsingChildren(); |
1031 | 1032 |
1032 ScriptLoader* scriptLoader = toScriptLoaderIfPossible(newElement); | 1033 if (ScriptLoaderClient::fromElementIfPossible(newElement)) |
hiroshige
2017/03/01 00:58:15
Same as HTMLOptionElement.cpp.
Nate Chapin
2017/03/01 21:35:00
Done.
| |
1033 if (scriptLoader) | |
1034 m_scriptStartPosition = textPosition(); | 1034 m_scriptStartPosition = textPosition(); |
1035 | 1035 |
1036 m_currentNode->parserAppendChild(newElement); | 1036 m_currentNode->parserAppendChild(newElement); |
1037 | 1037 |
1038 // Event handlers may synchronously trigger removal of the | 1038 // Event handlers may synchronously trigger removal of the |
1039 // document and cancellation of this parser. | 1039 // document and cancellation of this parser. |
1040 if (isStopped()) { | 1040 if (isStopped()) { |
1041 stopParsing(); | 1041 stopParsing(); |
1042 return; | 1042 return; |
1043 } | 1043 } |
(...skipping 24 matching lines...) Expand all Loading... | |
1068 return; | 1068 return; |
1069 } | 1069 } |
1070 | 1070 |
1071 if (!updateLeafTextNode()) | 1071 if (!updateLeafTextNode()) |
1072 return; | 1072 return; |
1073 | 1073 |
1074 ContainerNode* n = m_currentNode; | 1074 ContainerNode* n = m_currentNode; |
1075 if (m_currentNode->isElementNode()) | 1075 if (m_currentNode->isElementNode()) |
1076 toElement(n)->finishParsingChildren(); | 1076 toElement(n)->finishParsingChildren(); |
1077 | 1077 |
1078 ScriptLoaderClient* scriptLoaderClient = | |
1079 n->isElementNode() | |
1080 ? ScriptLoaderClient::fromElementIfPossible(toElement(n)) | |
1081 : nullptr; | |
1078 if (!scriptingContentIsAllowed(getParserContentPolicy()) && | 1082 if (!scriptingContentIsAllowed(getParserContentPolicy()) && |
1079 n->isElementNode() && toScriptLoaderIfPossible(toElement(n))) { | 1083 scriptLoaderClient) { |
1080 popCurrentNode(); | 1084 popCurrentNode(); |
1081 n->remove(IGNORE_EXCEPTION_FOR_TESTING); | 1085 n->remove(IGNORE_EXCEPTION_FOR_TESTING); |
1082 return; | 1086 return; |
1083 } | 1087 } |
1084 | 1088 |
1085 if (!n->isElementNode() || !m_hasView) { | 1089 if (!n->isElementNode() || !m_hasView) { |
1086 popCurrentNode(); | 1090 popCurrentNode(); |
1087 return; | 1091 return; |
1088 } | 1092 } |
1089 | 1093 |
1090 Element* element = toElement(n); | 1094 Element* element = toElement(n); |
1091 | 1095 |
1092 // The element's parent may have already been removed from document. | 1096 // The element's parent may have already been removed from document. |
1093 // Parsing continues in this case, but scripts aren't executed. | 1097 // Parsing continues in this case, but scripts aren't executed. |
1094 if (!element->isConnected()) { | 1098 if (!element->isConnected()) { |
1095 popCurrentNode(); | 1099 popCurrentNode(); |
1096 return; | 1100 return; |
1097 } | 1101 } |
1098 | 1102 |
1099 ScriptLoader* scriptLoader = toScriptLoaderIfPossible(element); | 1103 ScriptLoader* scriptLoader = |
1104 scriptLoaderClient ? scriptLoaderClient->loader() : nullptr; | |
1100 if (!scriptLoader) { | 1105 if (!scriptLoader) { |
1101 popCurrentNode(); | 1106 popCurrentNode(); |
1102 return; | 1107 return; |
1103 } | 1108 } |
1104 | 1109 |
1105 // Don't load external scripts for standalone documents (for now). | 1110 // Don't load external scripts for standalone documents (for now). |
1106 DCHECK(!m_pendingScript); | 1111 DCHECK(!m_pendingScript); |
1107 m_requestingScript = true; | 1112 m_requestingScript = true; |
1108 | 1113 |
1109 if (scriptLoader->prepareScript( | 1114 if (scriptLoader->prepareScript( |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1709 RefPtr<XMLParserContext> parser = | 1714 RefPtr<XMLParserContext> parser = |
1710 XMLParserContext::createStringParser(&sax, &state); | 1715 XMLParserContext::createStringParser(&sax, &state); |
1711 String parseString = "<?xml version=\"1.0\"?><attrs " + string + " />"; | 1716 String parseString = "<?xml version=\"1.0\"?><attrs " + string + " />"; |
1712 parseChunk(parser->context(), parseString); | 1717 parseChunk(parser->context(), parseString); |
1713 finishParsing(parser->context()); | 1718 finishParsing(parser->context()); |
1714 attrsOK = state.gotAttributes; | 1719 attrsOK = state.gotAttributes; |
1715 return state.attributes; | 1720 return state.attributes; |
1716 } | 1721 } |
1717 | 1722 |
1718 } // namespace blink | 1723 } // namespace blink |
OLD | NEW |