Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 10 matching lines...) Expand all Loading... | |
| 21 * | 21 * |
| 22 * You should have received a copy of the GNU Library General Public License | 22 * You should have received a copy of the GNU Library General Public License |
| 23 * along with this library; see the file COPYING.LIB. If not, write to | 23 * along with this library; see the file COPYING.LIB. If not, write to |
| 24 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 24 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 25 * Boston, MA 02110-1301, USA. | 25 * Boston, MA 02110-1301, USA. |
| 26 */ | 26 */ |
| 27 | 27 |
| 28 #include "core/dom/Document.h" | 28 #include "core/dom/Document.h" |
| 29 | 29 |
| 30 #include "bindings/core/v8/DOMDataStore.h" | 30 #include "bindings/core/v8/DOMDataStore.h" |
| 31 #include "bindings/core/v8/ElementCreationOptionsOrString.h" | |
| 31 #include "bindings/core/v8/ExceptionMessages.h" | 32 #include "bindings/core/v8/ExceptionMessages.h" |
| 32 #include "bindings/core/v8/ExceptionState.h" | 33 #include "bindings/core/v8/ExceptionState.h" |
| 33 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 34 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
| 34 #include "bindings/core/v8/HTMLScriptElementOrSVGScriptElement.h" | 35 #include "bindings/core/v8/HTMLScriptElementOrSVGScriptElement.h" |
| 35 #include "bindings/core/v8/Microtask.h" | 36 #include "bindings/core/v8/Microtask.h" |
| 36 #include "bindings/core/v8/ScriptController.h" | 37 #include "bindings/core/v8/ScriptController.h" |
| 37 #include "bindings/core/v8/SourceLocation.h" | 38 #include "bindings/core/v8/SourceLocation.h" |
| 38 #include "bindings/core/v8/V0CustomElementConstructorBuilder.h" | 39 #include "bindings/core/v8/V0CustomElementConstructorBuilder.h" |
| 39 #include "bindings/core/v8/V8DOMWrapper.h" | 40 #include "bindings/core/v8/V8DOMWrapper.h" |
| 40 #include "bindings/core/v8/V8PerIsolateData.h" | 41 #include "bindings/core/v8/V8PerIsolateData.h" |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 66 #include "core/dom/Attr.h" | 67 #include "core/dom/Attr.h" |
| 67 #include "core/dom/CDATASection.h" | 68 #include "core/dom/CDATASection.h" |
| 68 #include "core/dom/ClientRect.h" | 69 #include "core/dom/ClientRect.h" |
| 69 #include "core/dom/Comment.h" | 70 #include "core/dom/Comment.h" |
| 70 #include "core/dom/ContextFeatures.h" | 71 #include "core/dom/ContextFeatures.h" |
| 71 #include "core/dom/DOMImplementation.h" | 72 #include "core/dom/DOMImplementation.h" |
| 72 #include "core/dom/DocumentFragment.h" | 73 #include "core/dom/DocumentFragment.h" |
| 73 #include "core/dom/DocumentParserTiming.h" | 74 #include "core/dom/DocumentParserTiming.h" |
| 74 #include "core/dom/DocumentType.h" | 75 #include "core/dom/DocumentType.h" |
| 75 #include "core/dom/Element.h" | 76 #include "core/dom/Element.h" |
| 77 #include "core/dom/ElementCreationOptions.h" | |
| 76 #include "core/dom/ElementDataCache.h" | 78 #include "core/dom/ElementDataCache.h" |
| 77 #include "core/dom/ElementRegistrationOptions.h" | 79 #include "core/dom/ElementRegistrationOptions.h" |
| 78 #include "core/dom/ElementTraversal.h" | 80 #include "core/dom/ElementTraversal.h" |
| 79 #include "core/dom/ExceptionCode.h" | 81 #include "core/dom/ExceptionCode.h" |
| 80 #include "core/dom/ExecutionContextTask.h" | 82 #include "core/dom/ExecutionContextTask.h" |
| 81 #include "core/dom/FrameRequestCallback.h" | 83 #include "core/dom/FrameRequestCallback.h" |
| 82 #include "core/dom/IntersectionObserverController.h" | 84 #include "core/dom/IntersectionObserverController.h" |
| 83 #include "core/dom/LayoutTreeBuilderTraversal.h" | 85 #include "core/dom/LayoutTreeBuilderTraversal.h" |
| 84 #include "core/dom/MainThreadTaskRunner.h" | 86 #include "core/dom/MainThreadTaskRunner.h" |
| 85 #include "core/dom/MutationObserver.h" | 87 #include "core/dom/MutationObserver.h" |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 653 | 655 |
| 654 if (isXHTMLDocument() || isHTMLDocument()) { | 656 if (isXHTMLDocument() || isHTMLDocument()) { |
| 655 if (CustomElement::shouldCreateCustomElement(name)) | 657 if (CustomElement::shouldCreateCustomElement(name)) |
| 656 return CustomElement::createCustomElementSync(*this, name, exception State); | 658 return CustomElement::createCustomElementSync(*this, name, exception State); |
| 657 return HTMLElementFactory::createHTMLElement(convertLocalName(name), *th is, 0, CreatedByCreateElement); | 659 return HTMLElementFactory::createHTMLElement(convertLocalName(name), *th is, 0, CreatedByCreateElement); |
| 658 } | 660 } |
| 659 | 661 |
| 660 return Element::create(QualifiedName(nullAtom, name, nullAtom), this); | 662 return Element::create(QualifiedName(nullAtom, name, nullAtom), this); |
| 661 } | 663 } |
| 662 | 664 |
| 663 Element* Document::createElement(const AtomicString& localName, const AtomicStri ng& typeExtension, ExceptionState& exceptionState) | 665 Element* Document::createElement(const AtomicString& localName, const ElementCre ationOptionsOrString& optionsOrString, ExceptionState& exceptionState) |
| 664 { | 666 { |
| 665 if (!isValidName(localName)) { | 667 if (!isValidName(localName)) { |
| 666 exceptionState.throwDOMException(InvalidCharacterError, "The tag name pr ovided ('" + localName + "') is not a valid name."); | 668 exceptionState.throwDOMException(InvalidCharacterError, "The tag name pr ovided ('" + localName + "') is not a valid name."); |
| 667 return nullptr; | 669 return nullptr; |
| 668 } | 670 } |
| 669 | 671 |
| 670 Element* element; | 672 Element* element; |
| 671 | 673 |
| 672 if (CustomElement::shouldCreateCustomElement(localName)) { | 674 if (CustomElement::shouldCreateCustomElement(localName)) { |
| 673 element = CustomElement::createCustomElementSync(*this, localName, excep tionState); | 675 element = CustomElement::createCustomElementSync(*this, localName, excep tionState); |
| 674 } else if (V0CustomElement::isValidName(localName) && registrationContext()) { | 676 } else if (V0CustomElement::isValidName(localName) && registrationContext()) { |
| 675 element = registrationContext()->createCustomTagElement(*this, Qualified Name(nullAtom, convertLocalName(localName), xhtmlNamespaceURI)); | 677 element = registrationContext()->createCustomTagElement(*this, Qualified Name(nullAtom, convertLocalName(localName), xhtmlNamespaceURI)); |
| 676 } else { | 678 } else { |
| 677 element = createElement(localName, exceptionState); | 679 element = createElement(localName, exceptionState); |
| 678 if (exceptionState.hadException()) | 680 if (exceptionState.hadException()) |
| 679 return nullptr; | 681 return nullptr; |
| 680 } | 682 } |
| 681 | 683 |
| 682 if (!typeExtension.isEmpty()) | 684 if (optionsOrString.isString() && !optionsOrString.getAsString().isEmpty()) { |
|
dominicc (has gone to gerrit)
2016/09/15 01:19:24
I wonder if the existing code does toString on non
Anton Obzhirov
2016/09/15 09:25:20
Will check, good point, will need to figure out ho
| |
| 683 V0CustomElementRegistrationContext::setIsAttributeAndTypeExtension(eleme nt, typeExtension); | 685 V0CustomElementRegistrationContext::setIsAttributeAndTypeExtension(eleme nt, AtomicString(optionsOrString.getAsString())); |
| 686 Deprecation::countDeprecation(this, UseCounter::DocumentCreateElement2nd Arg); | |
| 687 } else if (optionsOrString.isElementCreationOptions() && !optionsOrString.ge tAsElementCreationOptions().is().isEmpty()) { | |
| 688 V0CustomElementRegistrationContext::setIsAttributeAndTypeExtension(eleme nt, AtomicString(optionsOrString.getAsElementCreationOptions().is())); | |
| 689 } | |
| 684 | 690 |
| 685 return element; | 691 return element; |
| 686 } | 692 } |
| 687 | 693 |
| 688 static inline QualifiedName createQualifiedName(const AtomicString& namespaceURI , const AtomicString& qualifiedName, ExceptionState& exceptionState) | 694 static inline QualifiedName createQualifiedName(const AtomicString& namespaceURI , const AtomicString& qualifiedName, ExceptionState& exceptionState) |
| 689 { | 695 { |
| 690 AtomicString prefix, localName; | 696 AtomicString prefix, localName; |
| 691 if (!Document::parseQualifiedName(qualifiedName, prefix, localName, exceptio nState)) | 697 if (!Document::parseQualifiedName(qualifiedName, prefix, localName, exceptio nState)) |
| 692 return QualifiedName::null(); | 698 return QualifiedName::null(); |
| 693 | 699 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 704 { | 710 { |
| 705 QualifiedName qName(createQualifiedName(namespaceURI, qualifiedName, excepti onState)); | 711 QualifiedName qName(createQualifiedName(namespaceURI, qualifiedName, excepti onState)); |
| 706 if (qName == QualifiedName::null()) | 712 if (qName == QualifiedName::null()) |
| 707 return nullptr; | 713 return nullptr; |
| 708 | 714 |
| 709 if (CustomElement::shouldCreateCustomElement(qName)) | 715 if (CustomElement::shouldCreateCustomElement(qName)) |
| 710 return CustomElement::createCustomElementSync(*this, qName, exceptionSta te); | 716 return CustomElement::createCustomElementSync(*this, qName, exceptionSta te); |
| 711 return createElement(qName, CreatedByCreateElement); | 717 return createElement(qName, CreatedByCreateElement); |
| 712 } | 718 } |
| 713 | 719 |
| 714 Element* Document::createElementNS(const AtomicString& namespaceURI, const Atomi cString& qualifiedName, const AtomicString& typeExtension, ExceptionState& excep tionState) | 720 Element* Document::createElementNS(const AtomicString& namespaceURI, const Atomi cString& qualifiedName, const ElementCreationOptionsOrString& optionsOrString, E xceptionState& exceptionState) |
| 715 { | 721 { |
| 716 QualifiedName qName(createQualifiedName(namespaceURI, qualifiedName, excepti onState)); | 722 QualifiedName qName(createQualifiedName(namespaceURI, qualifiedName, excepti onState)); |
| 717 if (qName == QualifiedName::null()) | 723 if (qName == QualifiedName::null()) |
| 718 return nullptr; | 724 return nullptr; |
| 719 | 725 |
| 720 Element* element; | 726 Element* element; |
| 721 if (CustomElement::shouldCreateCustomElement(qName)) | 727 if (CustomElement::shouldCreateCustomElement(qName)) |
| 722 element = CustomElement::createCustomElementSync(*this, qName, exception State); | 728 element = CustomElement::createCustomElementSync(*this, qName, exception State); |
| 723 else if (V0CustomElement::isValidName(qName.localName()) && registrationCont ext()) | 729 else if (V0CustomElement::isValidName(qName.localName()) && registrationCont ext()) |
| 724 element = registrationContext()->createCustomTagElement(*this, qName); | 730 element = registrationContext()->createCustomTagElement(*this, qName); |
| 725 else | 731 else |
| 726 element = createElement(qName, CreatedByCreateElement); | 732 element = createElement(qName, CreatedByCreateElement); |
| 727 | 733 |
| 728 if (!typeExtension.isEmpty()) | 734 if (optionsOrString.isString() && !optionsOrString.getAsString().isEmpty()) { |
| 729 V0CustomElementRegistrationContext::setIsAttributeAndTypeExtension(eleme nt, typeExtension); | 735 V0CustomElementRegistrationContext::setIsAttributeAndTypeExtension(eleme nt, AtomicString(optionsOrString.getAsString())); |
| 736 Deprecation::countDeprecation(this, UseCounter::DocumentCreateElement2nd Arg); | |
| 737 } else if (optionsOrString.isElementCreationOptions() && !optionsOrString.ge tAsElementCreationOptions().is().isEmpty()) { | |
| 738 V0CustomElementRegistrationContext::setIsAttributeAndTypeExtension(eleme nt, AtomicString(optionsOrString.getAsElementCreationOptions().is())); | |
| 739 } | |
| 730 | 740 |
| 731 return element; | 741 return element; |
| 732 } | 742 } |
| 733 | 743 |
| 734 ScriptValue Document::registerElement(ScriptState* scriptState, const AtomicStri ng& name, const ElementRegistrationOptions& options, ExceptionState& exceptionSt ate, V0CustomElement::NameSet validNames) | 744 ScriptValue Document::registerElement(ScriptState* scriptState, const AtomicStri ng& name, const ElementRegistrationOptions& options, ExceptionState& exceptionSt ate, V0CustomElement::NameSet validNames) |
| 735 { | 745 { |
| 736 HostsUsingFeatures::countMainWorldOnly(scriptState, *this, HostsUsingFeature s::Feature::DocumentRegisterElement); | 746 HostsUsingFeatures::countMainWorldOnly(scriptState, *this, HostsUsingFeature s::Feature::DocumentRegisterElement); |
| 737 | 747 |
| 738 if (!registrationContext()) { | 748 if (!registrationContext()) { |
| 739 exceptionState.throwDOMException(NotSupportedError, "No element registra tion context is available."); | 749 exceptionState.throwDOMException(NotSupportedError, "No element registra tion context is available."); |
| (...skipping 5349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6089 } | 6099 } |
| 6090 | 6100 |
| 6091 void showLiveDocumentInstances() | 6101 void showLiveDocumentInstances() |
| 6092 { | 6102 { |
| 6093 WeakDocumentSet& set = liveDocumentSet(); | 6103 WeakDocumentSet& set = liveDocumentSet(); |
| 6094 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 6104 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
| 6095 for (Document* document : set) | 6105 for (Document* document : set) |
| 6096 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data()); | 6106 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data()); |
| 6097 } | 6107 } |
| 6098 #endif | 6108 #endif |
| OLD | NEW |