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

Side by Side Diff: third_party/WebKit/Source/core/dom/Document.cpp

Issue 2505573002: CustomElements: createCustomElementSync accepts a definition (Closed)
Patch Set: createCustomElementSync accepts a definition Created 4 years, 1 month 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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All
7 * rights reserved. 7 * rights reserved.
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
9 * (http://www.torchmobile.com/) 9 * (http://www.torchmobile.com/)
10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 exceptionState.throwDOMException( 671 exceptionState.throwDOMException(
672 InvalidCharacterError, 672 InvalidCharacterError,
673 "The tag name provided ('" + name + "') is not a valid name."); 673 "The tag name provided ('" + name + "') is not a valid name.");
674 return nullptr; 674 return nullptr;
675 } 675 }
676 676
677 if (isXHTMLDocument() || isHTMLDocument()) { 677 if (isXHTMLDocument() || isHTMLDocument()) {
678 // 2. If the context object is an HTML document, let localName be 678 // 2. If the context object is an HTML document, let localName be
679 // converted to ASCII lowercase. 679 // converted to ASCII lowercase.
680 AtomicString localName = convertLocalName(name); 680 AtomicString localName = convertLocalName(name);
681 if (CustomElement::shouldCreateCustomElement(localName)) 681 if (CustomElement::shouldCreateCustomElement(localName)) {
682 return CustomElement::createCustomElementSync(*this, localName); 682 return CustomElement::createCustomElementSync(
683 *this,
684 QualifiedName(nullAtom, localName, HTMLNames::xhtmlNamespaceURI));
685 }
683 return HTMLElementFactory::createHTMLElement(localName, *this, 0, 686 return HTMLElementFactory::createHTMLElement(localName, *this, 0,
684 CreatedByCreateElement); 687 CreatedByCreateElement);
685 } 688 }
686
687 return Element::create(QualifiedName(nullAtom, name, nullAtom), this); 689 return Element::create(QualifiedName(nullAtom, name, nullAtom), this);
688 } 690 }
689 691
690 String getTypeExtension(Document* document, 692 String getTypeExtension(Document* document,
691 const StringOrDictionary& stringOrOptions, 693 const StringOrDictionary& stringOrOptions,
692 ExceptionState& exceptionState) { 694 ExceptionState& exceptionState) {
693 if (stringOrOptions.isNull()) 695 if (stringOrOptions.isNull())
694 return emptyString(); 696 return emptyString();
695 697
696 if (stringOrOptions.isString()) { 698 if (stringOrOptions.isString()) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 exceptionState.throwDOMException(NotFoundError, 750 exceptionState.throwDOMException(NotFoundError,
749 "Custom element definition not found."); 751 "Custom element definition not found.");
750 return nullptr; 752 return nullptr;
751 } 753 }
752 } 754 }
753 755
754 // 7. Let element be the result of creating an element 756 // 7. Let element be the result of creating an element
755 Element* element; 757 Element* element;
756 758
757 if (definition) { 759 if (definition) {
758 element = 760 element = CustomElement::createCustomElementSync(*this, convertedLocalName,
759 CustomElement::createCustomElementSync(*this, convertedLocalName, name); 761 definition);
760 } else if (V0CustomElement::isValidName(localName) && registrationContext()) { 762 } else if (V0CustomElement::isValidName(localName) && registrationContext()) {
761 element = registrationContext()->createCustomTagElement( 763 element = registrationContext()->createCustomTagElement(
762 *this, QualifiedName(nullAtom, convertedLocalName, xhtmlNamespaceURI)); 764 *this, QualifiedName(nullAtom, convertedLocalName, xhtmlNamespaceURI));
763 } else { 765 } else {
764 element = createElement(localName, exceptionState); 766 element = createElement(localName, exceptionState);
765 if (exceptionState.hadException()) 767 if (exceptionState.hadException())
766 return nullptr; 768 return nullptr;
767 } 769 }
768 770
769 // 8. If 'is' is non-null, set 'is' attribute 771 // 8. If 'is' is non-null, set 'is' attribute
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 } 857 }
856 } 858 }
857 859
858 // 5. Let element be the result of creating an element 860 // 5. Let element be the result of creating an element
859 Element* element; 861 Element* element;
860 862
861 bool shouldCreateBuiltin = 863 bool shouldCreateBuiltin =
862 isV1 && RuntimeEnabledFeatures::customElementsBuiltinEnabled(); 864 isV1 && RuntimeEnabledFeatures::customElementsBuiltinEnabled();
863 865
864 if (CustomElement::shouldCreateCustomElement(qName) || shouldCreateBuiltin) { 866 if (CustomElement::shouldCreateCustomElement(qName) || shouldCreateBuiltin) {
865 element = CustomElement::createCustomElementSync(*this, qName, is); 867 element = CustomElement::createCustomElementSync(*this, qName, definition);
866 } else if (V0CustomElement::isValidName(qName.localName()) && 868 } else if (V0CustomElement::isValidName(qName.localName()) &&
867 registrationContext()) { 869 registrationContext()) {
868 element = registrationContext()->createCustomTagElement(*this, qName); 870 element = registrationContext()->createCustomTagElement(*this, qName);
869 } else { 871 } else {
870 element = createElement(qName, CreatedByCreateElement); 872 element = createElement(qName, CreatedByCreateElement);
871 } 873 }
872 874
873 // 6. If 'is' is non-null, set 'is' attribute 875 // 6. If 'is' is non-null, set 'is' attribute
874 if (!is.isEmpty()) { 876 if (!is.isEmpty()) {
875 if (element->getCustomElementState() != CustomElementState::Custom) { 877 if (element->getCustomElementState() != CustomElementState::Custom) {
(...skipping 5637 matching lines...) Expand 10 before | Expand all | Expand 10 after
6513 } 6515 }
6514 6516
6515 void showLiveDocumentInstances() { 6517 void showLiveDocumentInstances() {
6516 WeakDocumentSet& set = liveDocumentSet(); 6518 WeakDocumentSet& set = liveDocumentSet();
6517 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 6519 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
6518 for (Document* document : set) 6520 for (Document* document : set)
6519 fprintf(stderr, "- Document %p URL: %s\n", document, 6521 fprintf(stderr, "- Document %p URL: %s\n", document,
6520 document->url().getString().utf8().data()); 6522 document->url().getString().utf8().data());
6521 } 6523 }
6522 #endif 6524 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698