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

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

Issue 17033002: HTML parser should not associate elements inside templates with forms (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Patch for landing Created 7 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 | Annotate | Revision Log
« no previous file with comments | « LayoutTests/fast/dom/HTMLTemplateElement/no-form-association-expected.txt ('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 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 inline Document* HTMLConstructionSite::ownerDocumentForCurrentNode() 638 inline Document* HTMLConstructionSite::ownerDocumentForCurrentNode()
639 { 639 {
640 if (currentNode()->hasTagName(templateTag)) 640 if (currentNode()->hasTagName(templateTag))
641 return toHTMLTemplateElement(currentElement())->content()->document(); 641 return toHTMLTemplateElement(currentElement())->content()->document();
642 return currentNode()->document(); 642 return currentNode()->document();
643 } 643 }
644 644
645 PassRefPtr<Element> HTMLConstructionSite::createHTMLElement(AtomicHTMLToken* tok en) 645 PassRefPtr<Element> HTMLConstructionSite::createHTMLElement(AtomicHTMLToken* tok en)
646 { 646 {
647 QualifiedName tagName(nullAtom, token->name(), xhtmlNamespaceURI); 647 QualifiedName tagName(nullAtom, token->name(), xhtmlNamespaceURI);
648 Document* document = ownerDocumentForCurrentNode();
649 // Only associate the element with the current form if we're creating the ne w element
650 // in a document with a browsing context (rather than in <template> contents ).
651 HTMLFormElement* form = document->frame() ? m_form.get() : 0;
648 // FIXME: This can't use HTMLConstructionSite::createElement because we 652 // FIXME: This can't use HTMLConstructionSite::createElement because we
649 // have to pass the current form element. We should rework form association 653 // have to pass the current form element. We should rework form association
650 // to occur after construction to allow better code sharing here. 654 // to occur after construction to allow better code sharing here.
651 RefPtr<Element> element = HTMLElementFactory::createHTMLElement(tagName, own erDocumentForCurrentNode(), form(), true); 655 RefPtr<Element> element = HTMLElementFactory::createHTMLElement(tagName, doc ument, form, true);
652 setAttributes(element.get(), token, m_parserContentPolicy); 656 setAttributes(element.get(), token, m_parserContentPolicy);
653 ASSERT(element->isHTMLElement()); 657 ASSERT(element->isHTMLElement());
654 return element.release(); 658 return element.release();
655 } 659 }
656 660
657 PassRefPtr<HTMLStackItem> HTMLConstructionSite::createElementFromSavedToken(HTML StackItem* item) 661 PassRefPtr<HTMLStackItem> HTMLConstructionSite::createElementFromSavedToken(HTML StackItem* item)
658 { 662 {
659 RefPtr<Element> element; 663 RefPtr<Element> element;
660 // NOTE: Moving from item -> token -> item copies the Attribute vector twice ! 664 // NOTE: Moving from item -> token -> item copies the Attribute vector twice !
661 AtomicHTMLToken fakeToken(HTMLToken::StartTag, item->localName(), item->attr ibutes()); 665 AtomicHTMLToken fakeToken(HTMLToken::StartTag, item->localName(), item->attr ibutes());
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 { 764 {
761 HTMLConstructionSiteTask task(HTMLConstructionSiteTask::Insert); 765 HTMLConstructionSiteTask task(HTMLConstructionSiteTask::Insert);
762 findFosterSite(task); 766 findFosterSite(task);
763 task.child = node; 767 task.child = node;
764 ASSERT(task.parent); 768 ASSERT(task.parent);
765 769
766 m_taskQueue.append(task); 770 m_taskQueue.append(task);
767 } 771 }
768 772
769 } 773 }
OLDNEW
« no previous file with comments | « LayoutTests/fast/dom/HTMLTemplateElement/no-form-association-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698