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

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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/custom/CustomElement.h » ('j') | 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) 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 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 exceptionState.throwDOMException( 670 exceptionState.throwDOMException(
671 InvalidCharacterError, 671 InvalidCharacterError,
672 "The tag name provided ('" + name + "') is not a valid name."); 672 "The tag name provided ('" + name + "') is not a valid name.");
673 return nullptr; 673 return nullptr;
674 } 674 }
675 675
676 if (isXHTMLDocument() || isHTMLDocument()) { 676 if (isXHTMLDocument() || isHTMLDocument()) {
677 // 2. If the context object is an HTML document, let localName be 677 // 2. If the context object is an HTML document, let localName be
678 // converted to ASCII lowercase. 678 // converted to ASCII lowercase.
679 AtomicString localName = convertLocalName(name); 679 AtomicString localName = convertLocalName(name);
680 if (CustomElement::shouldCreateCustomElement(localName)) 680 if (CustomElement::shouldCreateCustomElement(localName)) {
681 return CustomElement::createCustomElementSync(*this, localName); 681 return CustomElement::createCustomElementSync(
682 *this,
683 QualifiedName(nullAtom, localName, HTMLNames::xhtmlNamespaceURI));
684 }
682 return HTMLElementFactory::createHTMLElement(localName, *this, 0, 685 return HTMLElementFactory::createHTMLElement(localName, *this, 0,
683 CreatedByCreateElement); 686 CreatedByCreateElement);
684 } 687 }
685
686 return Element::create(QualifiedName(nullAtom, name, nullAtom), this); 688 return Element::create(QualifiedName(nullAtom, name, nullAtom), this);
687 } 689 }
688 690
689 String getTypeExtension(Document* document, 691 String getTypeExtension(Document* document,
690 const StringOrDictionary& stringOrOptions, 692 const StringOrDictionary& stringOrOptions,
691 ExceptionState& exceptionState) { 693 ExceptionState& exceptionState) {
692 if (stringOrOptions.isNull()) 694 if (stringOrOptions.isNull())
693 return emptyString(); 695 return emptyString();
694 696
695 if (stringOrOptions.isString()) { 697 if (stringOrOptions.isString()) {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 exceptionState.throwDOMException(NotFoundError, 755 exceptionState.throwDOMException(NotFoundError,
754 "Custom element definition not found."); 756 "Custom element definition not found.");
755 return nullptr; 757 return nullptr;
756 } 758 }
757 } 759 }
758 760
759 // 7. Let element be the result of creating an element 761 // 7. Let element be the result of creating an element
760 Element* element; 762 Element* element;
761 763
762 if (definition) { 764 if (definition) {
763 element = 765 element = CustomElement::createCustomElementSync(*this, convertedLocalName,
764 CustomElement::createCustomElementSync(*this, convertedLocalName, name); 766 definition);
765 } else if (V0CustomElement::isValidName(localName) && registrationContext()) { 767 } else if (V0CustomElement::isValidName(localName) && registrationContext()) {
766 element = registrationContext()->createCustomTagElement( 768 element = registrationContext()->createCustomTagElement(
767 *this, QualifiedName(nullAtom, convertedLocalName, xhtmlNamespaceURI)); 769 *this, QualifiedName(nullAtom, convertedLocalName, xhtmlNamespaceURI));
768 } else { 770 } else {
769 element = createElement(localName, exceptionState); 771 element = createElement(localName, exceptionState);
770 if (exceptionState.hadException()) 772 if (exceptionState.hadException())
771 return nullptr; 773 return nullptr;
772 } 774 }
773 775
774 // 8. If 'is' is non-null, set 'is' attribute 776 // 8. If 'is' is non-null, set 'is' attribute
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 exceptionState.throwDOMException(NotFoundError, 863 exceptionState.throwDOMException(NotFoundError,
862 "Custom element definition not found."); 864 "Custom element definition not found.");
863 return nullptr; 865 return nullptr;
864 } 866 }
865 } 867 }
866 868
867 // 5. Let element be the result of creating an element 869 // 5. Let element be the result of creating an element
868 Element* element; 870 Element* element;
869 871
870 if (CustomElement::shouldCreateCustomElement(qName) || createV1Builtin) { 872 if (CustomElement::shouldCreateCustomElement(qName) || createV1Builtin) {
871 element = CustomElement::createCustomElementSync(*this, qName, is); 873 element = CustomElement::createCustomElementSync(*this, qName, definition);
872 } else if (V0CustomElement::isValidName(qName.localName()) && 874 } else if (V0CustomElement::isValidName(qName.localName()) &&
873 registrationContext()) { 875 registrationContext()) {
874 element = registrationContext()->createCustomTagElement(*this, qName); 876 element = registrationContext()->createCustomTagElement(*this, qName);
875 } else { 877 } else {
876 element = createElement(qName, CreatedByCreateElement); 878 element = createElement(qName, CreatedByCreateElement);
877 } 879 }
878 880
879 // 6. If 'is' is non-null, set 'is' attribute 881 // 6. If 'is' is non-null, set 'is' attribute
880 if (!is.isEmpty()) { 882 if (!is.isEmpty()) {
881 if (element->getCustomElementState() != CustomElementState::Custom) { 883 if (element->getCustomElementState() != CustomElementState::Custom) {
(...skipping 5642 matching lines...) Expand 10 before | Expand all | Expand 10 after
6524 } 6526 }
6525 6527
6526 void showLiveDocumentInstances() { 6528 void showLiveDocumentInstances() {
6527 WeakDocumentSet& set = liveDocumentSet(); 6529 WeakDocumentSet& set = liveDocumentSet();
6528 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 6530 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
6529 for (Document* document : set) 6531 for (Document* document : set)
6530 fprintf(stderr, "- Document %p URL: %s\n", document, 6532 fprintf(stderr, "- Document %p URL: %s\n", document,
6531 document->url().getString().utf8().data()); 6533 document->url().getString().utf8().data());
6532 } 6534 }
6533 #endif 6535 #endif
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/custom/CustomElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698