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

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

Issue 2537133005: New interface and function for form association (Closed)
Patch Set: Added to BUILD.gn Created 4 years 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/HTMLObjectElement.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 28 matching lines...) Expand all
39 #include "core/dom/ScriptLoader.h" 39 #include "core/dom/ScriptLoader.h"
40 #include "core/dom/TemplateContentDocumentFragment.h" 40 #include "core/dom/TemplateContentDocumentFragment.h"
41 #include "core/dom/Text.h" 41 #include "core/dom/Text.h"
42 #include "core/dom/ThrowOnDynamicMarkupInsertionCountIncrementer.h" 42 #include "core/dom/ThrowOnDynamicMarkupInsertionCountIncrementer.h"
43 #include "core/dom/custom/CEReactionsScope.h" 43 #include "core/dom/custom/CEReactionsScope.h"
44 #include "core/dom/custom/CustomElementDefinition.h" 44 #include "core/dom/custom/CustomElementDefinition.h"
45 #include "core/dom/custom/CustomElementDescriptor.h" 45 #include "core/dom/custom/CustomElementDescriptor.h"
46 #include "core/dom/custom/CustomElementRegistry.h" 46 #include "core/dom/custom/CustomElementRegistry.h"
47 #include "core/frame/LocalDOMWindow.h" 47 #include "core/frame/LocalDOMWindow.h"
48 #include "core/frame/LocalFrame.h" 48 #include "core/frame/LocalFrame.h"
49 #include "core/html/FormAssociated.h"
49 #include "core/html/HTMLFormElement.h" 50 #include "core/html/HTMLFormElement.h"
50 #include "core/html/HTMLHtmlElement.h" 51 #include "core/html/HTMLHtmlElement.h"
51 #include "core/html/HTMLPlugInElement.h" 52 #include "core/html/HTMLPlugInElement.h"
52 #include "core/html/HTMLScriptElement.h" 53 #include "core/html/HTMLScriptElement.h"
53 #include "core/html/HTMLTemplateElement.h" 54 #include "core/html/HTMLTemplateElement.h"
54 #include "core/html/parser/AtomicHTMLToken.h" 55 #include "core/html/parser/AtomicHTMLToken.h"
55 #include "core/html/parser/HTMLParserIdioms.h" 56 #include "core/html/parser/HTMLParserIdioms.h"
56 #include "core/html/parser/HTMLParserReentryPermit.h" 57 #include "core/html/parser/HTMLParserReentryPermit.h"
57 #include "core/html/parser/HTMLStackItem.h" 58 #include "core/html/parser/HTMLStackItem.h"
58 #include "core/html/parser/HTMLToken.h" 59 #include "core/html/parser/HTMLToken.h"
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 const AtomicString& localName = token->name(); 865 const AtomicString& localName = token->name();
865 const Attribute* isAttribute = token->getAttributeItem(HTMLNames::isAttr); 866 const Attribute* isAttribute = token->getAttributeItem(HTMLNames::isAttr);
866 const AtomicString& name = isAttribute ? isAttribute->value() : localName; 867 const AtomicString& name = isAttribute ? isAttribute->value() : localName;
867 CustomElementDescriptor descriptor(name, localName); 868 CustomElementDescriptor descriptor(name, localName);
868 869
869 // 4.-6. 870 // 4.-6.
870 return registry->definitionFor(descriptor); 871 return registry->definitionFor(descriptor);
871 } 872 }
872 873
873 // "create an element for a token" 874 // "create an element for a token"
874 // https://html.spec.whatwg.org/#create-an-element-for-the-token 875 // https://html.spec.whatwg.org/multipage/syntax.html#create-an-element-for-the- token
875 // TODO(dominicc): When form association is separate from creation, unify this 876 // TODO(dominicc): When form association is separate from creation, unify this
876 // with foreign element creation. Add a namespace parameter and check for HTML 877 // with foreign element creation. Add a namespace parameter and check for HTML
877 // namespace to lookupCustomElementDefinition. 878 // namespace to lookupCustomElementDefinition.
878 HTMLElement* HTMLConstructionSite::createHTMLElement(AtomicHTMLToken* token) { 879 HTMLElement* HTMLConstructionSite::createHTMLElement(AtomicHTMLToken* token) {
879 // "1. Let document be intended parent's node document." 880 // "1. Let document be intended parent's node document."
880 Document& document = ownerDocumentForCurrentNode(); 881 Document& document = ownerDocumentForCurrentNode();
881 882
882 // Only associate the element with the current form if we're creating the new 883 // Only associate the element with the current form if we're creating the new
883 // element in a document with a browsing context (rather than in <template> 884 // element in a document with a browsing context (rather than in <template>
884 // contents). 885 // contents).
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 931
931 // "9. If will execute script is true, then ..." etc. The CEReactionsScope 932 // "9. If will execute script is true, then ..." etc. The CEReactionsScope
932 // and ThrowOnDynamicMarkupInsertionCountIncrementer destructors implement 933 // and ThrowOnDynamicMarkupInsertionCountIncrementer destructors implement
933 // steps 9.1-3. 934 // steps 9.1-3.
934 } else { 935 } else {
935 // FIXME: This can't use HTMLConstructionSite::createElement because we have 936 // FIXME: This can't use HTMLConstructionSite::createElement because we have
936 // to pass the current form element. We should rework form association to 937 // to pass the current form element. We should rework form association to
937 // occur after construction to allow better code sharing here. 938 // occur after construction to allow better code sharing here.
938 element = HTMLElementFactory::createHTMLElement( 939 element = HTMLElementFactory::createHTMLElement(
939 token->name(), document, form, getCreateElementFlags()); 940 token->name(), document, form, getCreateElementFlags());
941 if (FormAssociated* formAssociatedElement =
942 element->toFormAssociatedOrNull()) {
943 formAssociatedElement->associateWith(form);
944 }
940 // Definition for the created element does not exist here and it cannot be 945 // Definition for the created element does not exist here and it cannot be
941 // custom or failed. 946 // custom or failed.
942 DCHECK_NE(element->getCustomElementState(), CustomElementState::Custom); 947 DCHECK_NE(element->getCustomElementState(), CustomElementState::Custom);
943 DCHECK_NE(element->getCustomElementState(), CustomElementState::Failed); 948 DCHECK_NE(element->getCustomElementState(), CustomElementState::Failed);
944 949
945 // "8. Append each attribute in the given token to element." 950 // "8. Append each attribute in the given token to element."
946 setAttributes(element, token, m_parserContentPolicy); 951 setAttributes(element, token, m_parserContentPolicy);
947 } 952 }
948 953
949 // TODO(dominicc): Implement steps 10-12 when customized built-in elements are 954 // TODO(dominicc): Implement steps 10-12 when customized built-in elements are
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 ASSERT(task.parent); 1072 ASSERT(task.parent);
1068 queueTask(task); 1073 queueTask(task);
1069 } 1074 }
1070 1075
1071 DEFINE_TRACE(HTMLConstructionSite::PendingText) { 1076 DEFINE_TRACE(HTMLConstructionSite::PendingText) {
1072 visitor->trace(parent); 1077 visitor->trace(parent);
1073 visitor->trace(nextChild); 1078 visitor->trace(nextChild);
1074 } 1079 }
1075 1080
1076 } // namespace blink 1081 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLObjectElement.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698