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

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

Issue 442343002: Creating custom element should not be case sensitive (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Addressing comments Created 6 years, 4 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
« no previous file with comments | « Source/core/dom/Document.h ('k') | Source/core/dom/custom/CustomElementRegistrationContext.cpp » ('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 r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 751
752 return &domWindow()->location(); 752 return &domWindow()->location();
753 } 753 }
754 754
755 void Document::childrenChanged(const ChildrenChange& change) 755 void Document::childrenChanged(const ChildrenChange& change)
756 { 756 {
757 ContainerNode::childrenChanged(change); 757 ContainerNode::childrenChanged(change);
758 m_documentElement = ElementTraversal::firstWithin(*this); 758 m_documentElement = ElementTraversal::firstWithin(*this);
759 } 759 }
760 760
761 AtomicString Document::convertLocalName(const AtomicString& name)
762 {
763 return isHTMLDocument() ? name.lower() : name;
764 }
765
761 PassRefPtrWillBeRawPtr<Element> Document::createElement(const AtomicString& name , ExceptionState& exceptionState) 766 PassRefPtrWillBeRawPtr<Element> Document::createElement(const AtomicString& name , ExceptionState& exceptionState)
762 { 767 {
763 if (!isValidName(name)) { 768 if (!isValidName(name)) {
764 exceptionState.throwDOMException(InvalidCharacterError, "The tag name pr ovided ('" + name + "') is not a valid name."); 769 exceptionState.throwDOMException(InvalidCharacterError, "The tag name pr ovided ('" + name + "') is not a valid name.");
765 return nullptr; 770 return nullptr;
766 } 771 }
767 772
768 if (isXHTMLDocument() || isHTMLDocument()) 773 if (isXHTMLDocument() || isHTMLDocument())
769 return HTMLElementFactory::createHTMLElement(isHTMLDocument() ? name.low er() : name, *this, 0, false); 774 return HTMLElementFactory::createHTMLElement(convertLocalName(name), *th is, 0, false);
770 775
771 return Element::create(QualifiedName(nullAtom, name, nullAtom), this); 776 return Element::create(QualifiedName(nullAtom, name, nullAtom), this);
772 } 777 }
773 778
774 PassRefPtrWillBeRawPtr<Element> Document::createElement(const AtomicString& loca lName, const AtomicString& typeExtension, ExceptionState& exceptionState) 779 PassRefPtrWillBeRawPtr<Element> Document::createElement(const AtomicString& loca lName, const AtomicString& typeExtension, ExceptionState& exceptionState)
775 { 780 {
776 if (!isValidName(localName)) { 781 if (!isValidName(localName)) {
777 exceptionState.throwDOMException(InvalidCharacterError, "The tag name pr ovided ('" + localName + "') is not a valid name."); 782 exceptionState.throwDOMException(InvalidCharacterError, "The tag name pr ovided ('" + localName + "') is not a valid name.");
778 return nullptr; 783 return nullptr;
779 } 784 }
780 785
781 RefPtrWillBeRawPtr<Element> element; 786 RefPtrWillBeRawPtr<Element> element;
782 787
783 if (CustomElement::isValidName(localName) && registrationContext()) { 788 if (CustomElement::isValidName(localName) && registrationContext()) {
784 element = registrationContext()->createCustomTagElement(*this, Qualified Name(nullAtom, localName, xhtmlNamespaceURI)); 789 element = registrationContext()->createCustomTagElement(*this, Qualified Name(nullAtom, convertLocalName(localName), xhtmlNamespaceURI));
785 } else { 790 } else {
786 element = createElement(localName, exceptionState); 791 element = createElement(localName, exceptionState);
787 if (exceptionState.hadException()) 792 if (exceptionState.hadException())
788 return nullptr; 793 return nullptr;
789 } 794 }
790 795
791 if (!typeExtension.isEmpty()) 796 if (!typeExtension.isEmpty())
792 CustomElementRegistrationContext::setIsAttributeAndTypeExtension(element .get(), typeExtension); 797 CustomElementRegistrationContext::setIsAttributeAndTypeExtension(element .get(), typeExtension);
793 798
794 return element.release(); 799 return element.release();
(...skipping 5088 matching lines...) Expand 10 before | Expand all | Expand 10 after
5883 using namespace blink; 5888 using namespace blink;
5884 void showLiveDocumentInstances() 5889 void showLiveDocumentInstances()
5885 { 5890 {
5886 WeakDocumentSet& set = liveDocumentSet(); 5891 WeakDocumentSet& set = liveDocumentSet();
5887 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 5892 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
5888 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it ) { 5893 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it ) {
5889 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut f8().data()); 5894 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut f8().data());
5890 } 5895 }
5891 } 5896 }
5892 #endif 5897 #endif
OLDNEW
« no previous file with comments | « Source/core/dom/Document.h ('k') | Source/core/dom/custom/CustomElementRegistrationContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698