Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: third_party/WebKit/Source/core/html/parser/HTMLConstructionSite.cpp

Issue 1814853003: Track whether an element was inserted via document.write (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: back to ps2 with some changes Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLScriptElement.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLScriptElement.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698