| 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 ScriptElementBase::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 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1023 handleElementAttributes(prefixedAttributes, libxmlAttributes, nbAttributes, | 1024 handleElementAttributes(prefixedAttributes, libxmlAttributes, nbAttributes, |
| 1024 m_prefixToNamespaceMap, exceptionState); | 1025 m_prefixToNamespaceMap, exceptionState); |
| 1025 setAttributes(newElement, prefixedAttributes, getParserContentPolicy()); | 1026 setAttributes(newElement, prefixedAttributes, getParserContentPolicy()); |
| 1026 if (exceptionState.hadException()) { | 1027 if (exceptionState.hadException()) { |
| 1027 stopParsing(); | 1028 stopParsing(); |
| 1028 return; | 1029 return; |
| 1029 } | 1030 } |
| 1030 | 1031 |
| 1031 newElement->beginParsingChildren(); | 1032 newElement->beginParsingChildren(); |
| 1032 | 1033 |
| 1033 ScriptLoader* scriptLoader = toScriptLoaderIfPossible(newElement); | 1034 if (newElement->isScriptElement()) |
| 1034 if (scriptLoader) | |
| 1035 m_scriptStartPosition = textPosition(); | 1035 m_scriptStartPosition = textPosition(); |
| 1036 | 1036 |
| 1037 m_currentNode->parserAppendChild(newElement); | 1037 m_currentNode->parserAppendChild(newElement); |
| 1038 | 1038 |
| 1039 // Event handlers may synchronously trigger removal of the | 1039 // Event handlers may synchronously trigger removal of the |
| 1040 // document and cancellation of this parser. | 1040 // document and cancellation of this parser. |
| 1041 if (isStopped()) { | 1041 if (isStopped()) { |
| 1042 stopParsing(); | 1042 stopParsing(); |
| 1043 return; | 1043 return; |
| 1044 } | 1044 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1069 return; | 1069 return; |
| 1070 } | 1070 } |
| 1071 | 1071 |
| 1072 if (!updateLeafTextNode()) | 1072 if (!updateLeafTextNode()) |
| 1073 return; | 1073 return; |
| 1074 | 1074 |
| 1075 ContainerNode* n = m_currentNode; | 1075 ContainerNode* n = m_currentNode; |
| 1076 if (m_currentNode->isElementNode()) | 1076 if (m_currentNode->isElementNode()) |
| 1077 toElement(n)->finishParsingChildren(); | 1077 toElement(n)->finishParsingChildren(); |
| 1078 | 1078 |
| 1079 ScriptElementBase* scriptElementBase = |
| 1080 n->isElementNode() |
| 1081 ? ScriptElementBase::fromElementIfPossible(toElement(n)) |
| 1082 : nullptr; |
| 1079 if (!scriptingContentIsAllowed(getParserContentPolicy()) && | 1083 if (!scriptingContentIsAllowed(getParserContentPolicy()) && |
| 1080 n->isElementNode() && toScriptLoaderIfPossible(toElement(n))) { | 1084 scriptElementBase) { |
| 1081 popCurrentNode(); | 1085 popCurrentNode(); |
| 1082 n->remove(IGNORE_EXCEPTION_FOR_TESTING); | 1086 n->remove(IGNORE_EXCEPTION_FOR_TESTING); |
| 1083 return; | 1087 return; |
| 1084 } | 1088 } |
| 1085 | 1089 |
| 1086 if (!n->isElementNode() || !m_hasView) { | 1090 if (!n->isElementNode() || !m_hasView) { |
| 1087 popCurrentNode(); | 1091 popCurrentNode(); |
| 1088 return; | 1092 return; |
| 1089 } | 1093 } |
| 1090 | 1094 |
| 1091 Element* element = toElement(n); | 1095 Element* element = toElement(n); |
| 1092 | 1096 |
| 1093 // The element's parent may have already been removed from document. | 1097 // The element's parent may have already been removed from document. |
| 1094 // Parsing continues in this case, but scripts aren't executed. | 1098 // Parsing continues in this case, but scripts aren't executed. |
| 1095 if (!element->isConnected()) { | 1099 if (!element->isConnected()) { |
| 1096 popCurrentNode(); | 1100 popCurrentNode(); |
| 1097 return; | 1101 return; |
| 1098 } | 1102 } |
| 1099 | 1103 |
| 1100 ScriptLoader* scriptLoader = toScriptLoaderIfPossible(element); | 1104 ScriptLoader* scriptLoader = |
| 1105 scriptElementBase ? scriptElementBase->loader() : nullptr; |
| 1101 if (!scriptLoader) { | 1106 if (!scriptLoader) { |
| 1102 popCurrentNode(); | 1107 popCurrentNode(); |
| 1103 return; | 1108 return; |
| 1104 } | 1109 } |
| 1105 | 1110 |
| 1106 // Don't load external scripts for standalone documents (for now). | 1111 // Don't load external scripts for standalone documents (for now). |
| 1107 DCHECK(!m_pendingScript); | 1112 DCHECK(!m_pendingScript); |
| 1108 m_requestingScript = true; | 1113 m_requestingScript = true; |
| 1109 | 1114 |
| 1110 if (scriptLoader->prepareScript( | 1115 if (scriptLoader->prepareScript( |
| (...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1711 RefPtr<XMLParserContext> parser = | 1716 RefPtr<XMLParserContext> parser = |
| 1712 XMLParserContext::createStringParser(&sax, &state); | 1717 XMLParserContext::createStringParser(&sax, &state); |
| 1713 String parseString = "<?xml version=\"1.0\"?><attrs " + string + " />"; | 1718 String parseString = "<?xml version=\"1.0\"?><attrs " + string + " />"; |
| 1714 parseChunk(parser->context(), parseString); | 1719 parseChunk(parser->context(), parseString); |
| 1715 finishParsing(parser->context()); | 1720 finishParsing(parser->context()); |
| 1716 attrsOK = state.gotAttributes; | 1721 attrsOK = state.gotAttributes; |
| 1717 return state.attributes; | 1722 return state.attributes; |
| 1718 } | 1723 } |
| 1719 | 1724 |
| 1720 } // namespace blink | 1725 } // namespace blink |
| OLD | NEW |