| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. | 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. |
| 3 * Copyright (C) 2011 Apple Inc. All rights reserved. | 3 * Copyright (C) 2011 Apple Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 | 647 |
| 648 void HTMLConstructionSite::insertScriptElement(AtomicHTMLToken* token) | 648 void HTMLConstructionSite::insertScriptElement(AtomicHTMLToken* token) |
| 649 { | 649 { |
| 650 // http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.h
tml#already-started | 650 // http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.h
tml#already-started |
| 651 // http://html5.org/specs/dom-parsing.html#dom-range-createcontextualfragmen
t | 651 // http://html5.org/specs/dom-parsing.html#dom-range-createcontextualfragmen
t |
| 652 // For createContextualFragment, the specifications say to mark it parser-in
serted and already-started and later unmark them. | 652 // For createContextualFragment, the specifications say to mark it parser-in
serted and already-started and later unmark them. |
| 653 // However, we short circuit that logic to avoid the subtree traversal to fi
nd script elements since scripts can never see | 653 // However, we short circuit that logic to avoid the subtree traversal to fi
nd script elements since scripts can never see |
| 654 // those flags or effects thereof. | 654 // those flags or effects thereof. |
| 655 const bool parserInserted = m_parserContentPolicy != AllowScriptingContentAn
dDoNotMarkAlreadyStarted; | 655 const bool parserInserted = m_parserContentPolicy != AllowScriptingContentAn
dDoNotMarkAlreadyStarted; |
| 656 const bool alreadyStarted = m_isParsingFragment && parserInserted; | 656 const bool alreadyStarted = m_isParsingFragment && parserInserted; |
| 657 RawPtr<HTMLScriptElement> element = HTMLScriptElement::create(ownerDocumentF
orCurrentNode(), parserInserted, alreadyStarted); | 657 // TODO(csharrison): This logic only works if the tokenizer/parser was not |
| 658 // blocked waiting for scripts when the element was inserted. This usually |
| 659 // fails for instance, on second document.write if a script writes twice in |
| 660 // a row. To fix this, the parser might have to keep track of raw string |
| 661 // position. |
| 662 // TODO(csharrison): Refactor this so that the bools that are passed in are |
| 663 // packed in a bitfield from an enum class. |
| 664 const bool createdDuringDocumentWrite = ownerDocumentForCurrentNode().isInDo
cumentWrite(); |
| 665 RawPtr<HTMLScriptElement> element = HTMLScriptElement::create(ownerDocumentF
orCurrentNode(), parserInserted, alreadyStarted, createdDuringDocumentWrite); |
| 658 setAttributes(element.get(), token, m_parserContentPolicy); | 666 setAttributes(element.get(), token, m_parserContentPolicy); |
| 659 if (scriptingContentIsAllowed(m_parserContentPolicy)) | 667 if (scriptingContentIsAllowed(m_parserContentPolicy)) |
| 660 attachLater(currentNode(), element); | 668 attachLater(currentNode(), element); |
| 661 m_openElements.push(HTMLStackItem::create(element.release(), token)); | 669 m_openElements.push(HTMLStackItem::create(element.release(), token)); |
| 662 } | 670 } |
| 663 | 671 |
| 664 void HTMLConstructionSite::insertForeignElement(AtomicHTMLToken* token, const At
omicString& namespaceURI) | 672 void HTMLConstructionSite::insertForeignElement(AtomicHTMLToken* token, const At
omicString& namespaceURI) |
| 665 { | 673 { |
| 666 ASSERT(token->type() == HTMLToken::StartTag); | 674 ASSERT(token->type() == HTMLToken::StartTag); |
| 667 DVLOG(1) << "Not implemented."; // parseError when xmlns or xmlns:xlink are
wrong. | 675 DVLOG(1) << "Not implemented."; // parseError when xmlns or xmlns:xlink are
wrong. |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 873 queueTask(task); | 881 queueTask(task); |
| 874 } | 882 } |
| 875 | 883 |
| 876 DEFINE_TRACE(HTMLConstructionSite::PendingText) | 884 DEFINE_TRACE(HTMLConstructionSite::PendingText) |
| 877 { | 885 { |
| 878 visitor->trace(parent); | 886 visitor->trace(parent); |
| 879 visitor->trace(nextChild); | 887 visitor->trace(nextChild); |
| 880 } | 888 } |
| 881 | 889 |
| 882 } // namespace blink | 890 } // namespace blink |
| OLD | NEW |