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

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

Issue 2002903002: Hook createElement for Custom Elements V1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: dominicc review Created 4 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
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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 #include "core/dom/ScriptedIdleTaskController.h" 98 #include "core/dom/ScriptedIdleTaskController.h"
99 #include "core/dom/SelectorQuery.h" 99 #include "core/dom/SelectorQuery.h"
100 #include "core/dom/StaticNodeList.h" 100 #include "core/dom/StaticNodeList.h"
101 #include "core/dom/StyleChangeReason.h" 101 #include "core/dom/StyleChangeReason.h"
102 #include "core/dom/StyleEngine.h" 102 #include "core/dom/StyleEngine.h"
103 #include "core/dom/TouchList.h" 103 #include "core/dom/TouchList.h"
104 #include "core/dom/TransformSource.h" 104 #include "core/dom/TransformSource.h"
105 #include "core/dom/TreeWalker.h" 105 #include "core/dom/TreeWalker.h"
106 #include "core/dom/VisitedLinkState.h" 106 #include "core/dom/VisitedLinkState.h"
107 #include "core/dom/XMLDocument.h" 107 #include "core/dom/XMLDocument.h"
108 #include "core/dom/custom/CustomElement.h"
108 #include "core/dom/custom/V0CustomElementMicrotaskRunQueue.h" 109 #include "core/dom/custom/V0CustomElementMicrotaskRunQueue.h"
109 #include "core/dom/custom/V0CustomElementRegistrationContext.h" 110 #include "core/dom/custom/V0CustomElementRegistrationContext.h"
110 #include "core/dom/shadow/ElementShadow.h" 111 #include "core/dom/shadow/ElementShadow.h"
111 #include "core/dom/shadow/FlatTreeTraversal.h" 112 #include "core/dom/shadow/FlatTreeTraversal.h"
112 #include "core/dom/shadow/ShadowRoot.h" 113 #include "core/dom/shadow/ShadowRoot.h"
113 #include "core/editing/DragCaretController.h" 114 #include "core/editing/DragCaretController.h"
114 #include "core/editing/Editor.h" 115 #include "core/editing/Editor.h"
115 #include "core/editing/FrameSelection.h" 116 #include "core/editing/FrameSelection.h"
116 #include "core/editing/InputMethodController.h" 117 #include "core/editing/InputMethodController.h"
117 #include "core/editing/markers/DocumentMarkerController.h" 118 #include "core/editing/markers/DocumentMarkerController.h"
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 673
673 Element* Document::createElement(const AtomicString& localName, const AtomicStri ng& typeExtension, ExceptionState& exceptionState) 674 Element* Document::createElement(const AtomicString& localName, const AtomicStri ng& typeExtension, ExceptionState& exceptionState)
674 { 675 {
675 if (!isValidName(localName)) { 676 if (!isValidName(localName)) {
676 exceptionState.throwDOMException(InvalidCharacterError, "The tag name pr ovided ('" + localName + "') is not a valid name."); 677 exceptionState.throwDOMException(InvalidCharacterError, "The tag name pr ovided ('" + localName + "') is not a valid name.");
677 return nullptr; 678 return nullptr;
678 } 679 }
679 680
680 Element* element; 681 Element* element;
681 682
682 if (V0CustomElement::isValidName(localName) && registrationContext()) { 683 if (CustomElement::shouldCreateCustomElement(*this, localName)) {
684 element = CustomElement::createCustomElement(*this, localName);
685 } else if (V0CustomElement::isValidName(localName) && registrationContext()) {
683 element = registrationContext()->createCustomTagElement(*this, Qualified Name(nullAtom, convertLocalName(localName), xhtmlNamespaceURI)); 686 element = registrationContext()->createCustomTagElement(*this, Qualified Name(nullAtom, convertLocalName(localName), xhtmlNamespaceURI));
684 } else { 687 } else {
685 element = createElement(localName, exceptionState); 688 element = createElement(localName, exceptionState);
686 if (exceptionState.hadException()) 689 if (exceptionState.hadException())
687 return nullptr; 690 return nullptr;
688 } 691 }
689 692
690 if (!typeExtension.isEmpty()) 693 if (!typeExtension.isEmpty())
691 V0CustomElementRegistrationContext::setIsAttributeAndTypeExtension(eleme nt, typeExtension); 694 V0CustomElementRegistrationContext::setIsAttributeAndTypeExtension(eleme nt, typeExtension);
692 695
(...skipping 24 matching lines...) Expand all
717 return createElement(qName, false); 720 return createElement(qName, false);
718 } 721 }
719 722
720 Element* Document::createElementNS(const AtomicString& namespaceURI, const Atomi cString& qualifiedName, const AtomicString& typeExtension, ExceptionState& excep tionState) 723 Element* Document::createElementNS(const AtomicString& namespaceURI, const Atomi cString& qualifiedName, const AtomicString& typeExtension, ExceptionState& excep tionState)
721 { 724 {
722 QualifiedName qName(createQualifiedName(namespaceURI, qualifiedName, excepti onState)); 725 QualifiedName qName(createQualifiedName(namespaceURI, qualifiedName, excepti onState));
723 if (qName == QualifiedName::null()) 726 if (qName == QualifiedName::null())
724 return nullptr; 727 return nullptr;
725 728
726 Element* element; 729 Element* element;
727 if (V0CustomElement::isValidName(qName.localName()) && registrationContext() ) 730 if (CustomElement::shouldCreateCustomElement(*this, qName))
731 element = CustomElement::createCustomElement(*this, qName);
732 else if (V0CustomElement::isValidName(qName.localName()) && registrationCont ext())
728 element = registrationContext()->createCustomTagElement(*this, qName); 733 element = registrationContext()->createCustomTagElement(*this, qName);
729 else 734 else
730 element = createElement(qName, false); 735 element = createElement(qName, false);
731 736
732 if (!typeExtension.isEmpty()) 737 if (!typeExtension.isEmpty())
733 V0CustomElementRegistrationContext::setIsAttributeAndTypeExtension(eleme nt, typeExtension); 738 V0CustomElementRegistrationContext::setIsAttributeAndTypeExtension(eleme nt, typeExtension);
734 739
735 return element; 740 return element;
736 } 741 }
737 742
(...skipping 5276 matching lines...) Expand 10 before | Expand all | Expand 10 after
6014 #ifndef NDEBUG 6019 #ifndef NDEBUG
6015 using namespace blink; 6020 using namespace blink;
6016 void showLiveDocumentInstances() 6021 void showLiveDocumentInstances()
6017 { 6022 {
6018 Document::WeakDocumentSet& set = Document::liveDocumentSet(); 6023 Document::WeakDocumentSet& set = Document::liveDocumentSet();
6019 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 6024 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
6020 for (Document* document : set) 6025 for (Document* document : set)
6021 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data()); 6026 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data());
6022 } 6027 }
6023 #endif 6028 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698