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

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

Issue 2002063003: Change "bool createdByParser" of createElement() to enum (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cestate
Patch Set: Add ImportNode Created 4 years, 6 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
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 720 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 } 731 }
732 732
733 void HTMLConstructionSite::takeAllChildren(HTMLStackItem* newParent, HTMLElement Stack::ElementRecord* oldParent) 733 void HTMLConstructionSite::takeAllChildren(HTMLStackItem* newParent, HTMLElement Stack::ElementRecord* oldParent)
734 { 734 {
735 HTMLConstructionSiteTask task(HTMLConstructionSiteTask::TakeAllChildren); 735 HTMLConstructionSiteTask task(HTMLConstructionSiteTask::TakeAllChildren);
736 task.parent = newParent->node(); 736 task.parent = newParent->node();
737 task.child = oldParent->node(); 737 task.child = oldParent->node();
738 queueTask(task); 738 queueTask(task);
739 } 739 }
740 740
741 CreateElementFlags HTMLConstructionSite::getCreateElementFlags() const
742 {
743 return m_isParsingFragment ? CreatedByFragmentParser : CreatedByParser;
744 }
745
741 Element* HTMLConstructionSite::createElement(AtomicHTMLToken* token, const Atomi cString& namespaceURI) 746 Element* HTMLConstructionSite::createElement(AtomicHTMLToken* token, const Atomi cString& namespaceURI)
742 { 747 {
743 QualifiedName tagName(nullAtom, token->name(), namespaceURI); 748 QualifiedName tagName(nullAtom, token->name(), namespaceURI);
744 Element* element = ownerDocumentForCurrentNode().createElement(tagName, true ); 749 Element* element = ownerDocumentForCurrentNode().createElement(tagName, getC reateElementFlags());
745 setAttributes(element, token, m_parserContentPolicy); 750 setAttributes(element, token, m_parserContentPolicy);
746 return element; 751 return element;
747 } 752 }
748 753
749 inline Document& HTMLConstructionSite::ownerDocumentForCurrentNode() 754 inline Document& HTMLConstructionSite::ownerDocumentForCurrentNode()
750 { 755 {
751 if (isHTMLTemplateElement(*currentNode())) 756 if (isHTMLTemplateElement(*currentNode()))
752 return toHTMLTemplateElement(currentElement())->content()->document(); 757 return toHTMLTemplateElement(currentElement())->content()->document();
753 return currentNode()->document(); 758 return currentNode()->document();
754 } 759 }
755 760
756 HTMLElement* HTMLConstructionSite::createHTMLElement(AtomicHTMLToken* token) 761 HTMLElement* HTMLConstructionSite::createHTMLElement(AtomicHTMLToken* token)
757 { 762 {
758 Document& document = ownerDocumentForCurrentNode(); 763 Document& document = ownerDocumentForCurrentNode();
759 // Only associate the element with the current form if we're creating the ne w element 764 // Only associate the element with the current form if we're creating the ne w element
760 // in a document with a browsing context (rather than in <template> contents ). 765 // in a document with a browsing context (rather than in <template> contents ).
761 HTMLFormElement* form = document.frame() ? m_form.get() : 0; 766 HTMLFormElement* form = document.frame() ? m_form.get() : 0;
762 // FIXME: This can't use HTMLConstructionSite::createElement because we 767 // FIXME: This can't use HTMLConstructionSite::createElement because we
763 // have to pass the current form element. We should rework form association 768 // have to pass the current form element. We should rework form association
764 // to occur after construction to allow better code sharing here. 769 // to occur after construction to allow better code sharing here.
765 HTMLElement* element = HTMLElementFactory::createHTMLElement(token->name(), document, form, true); 770 HTMLElement* element = HTMLElementFactory::createHTMLElement(token->name(), document, form, getCreateElementFlags());
766 setAttributes(element, token, m_parserContentPolicy); 771 setAttributes(element, token, m_parserContentPolicy);
767 return element; 772 return element;
768 } 773 }
769 774
770 HTMLStackItem* HTMLConstructionSite::createElementFromSavedToken(HTMLStackItem* item) 775 HTMLStackItem* HTMLConstructionSite::createElementFromSavedToken(HTMLStackItem* item)
771 { 776 {
772 Element* element; 777 Element* element;
773 // NOTE: Moving from item -> token -> item copies the Attribute vector twice ! 778 // NOTE: Moving from item -> token -> item copies the Attribute vector twice !
774 AtomicHTMLToken fakeToken(HTMLToken::StartTag, item->localName(), item->attr ibutes()); 779 AtomicHTMLToken fakeToken(HTMLToken::StartTag, item->localName(), item->attr ibutes());
775 if (item->namespaceURI() == HTMLNames::xhtmlNamespaceURI) 780 if (item->namespaceURI() == HTMLNames::xhtmlNamespaceURI)
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 queueTask(task); 886 queueTask(task);
882 } 887 }
883 888
884 DEFINE_TRACE(HTMLConstructionSite::PendingText) 889 DEFINE_TRACE(HTMLConstructionSite::PendingText)
885 { 890 {
886 visitor->trace(parent); 891 visitor->trace(parent);
887 visitor->trace(nextChild); 892 visitor->trace(nextChild);
888 } 893 }
889 894
890 } // namespace blink 895 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698