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 | 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 26 matching lines...) Expand all Loading... | |
| 37 #include "bindings/core/v8/Microtask.h" | 37 #include "bindings/core/v8/Microtask.h" |
| 38 #include "bindings/core/v8/ScriptController.h" | 38 #include "bindings/core/v8/ScriptController.h" |
| 39 #include "bindings/core/v8/SourceLocation.h" | 39 #include "bindings/core/v8/SourceLocation.h" |
| 40 #include "bindings/core/v8/StringOrDictionary.h" | 40 #include "bindings/core/v8/StringOrDictionary.h" |
| 41 #include "bindings/core/v8/V0CustomElementConstructorBuilder.h" | 41 #include "bindings/core/v8/V0CustomElementConstructorBuilder.h" |
| 42 #include "bindings/core/v8/V8DOMWrapper.h" | 42 #include "bindings/core/v8/V8DOMWrapper.h" |
| 43 #include "bindings/core/v8/V8ElementCreationOptions.h" | 43 #include "bindings/core/v8/V8ElementCreationOptions.h" |
| 44 #include "bindings/core/v8/V8PerIsolateData.h" | 44 #include "bindings/core/v8/V8PerIsolateData.h" |
| 45 #include "bindings/core/v8/WindowProxy.h" | 45 #include "bindings/core/v8/WindowProxy.h" |
| 46 #include "core/HTMLElementFactory.h" | 46 #include "core/HTMLElementFactory.h" |
| 47 #include "core/HTMLElementTypeHelpers.h" | |
| 47 #include "core/HTMLNames.h" | 48 #include "core/HTMLNames.h" |
| 48 #include "core/SVGElementFactory.h" | 49 #include "core/SVGElementFactory.h" |
| 49 #include "core/SVGNames.h" | 50 #include "core/SVGNames.h" |
| 50 #include "core/XMLNSNames.h" | 51 #include "core/XMLNSNames.h" |
| 51 #include "core/XMLNames.h" | 52 #include "core/XMLNames.h" |
| 52 #include "core/animation/CompositorPendingAnimations.h" | 53 #include "core/animation/CompositorPendingAnimations.h" |
| 53 #include "core/animation/DocumentAnimations.h" | 54 #include "core/animation/DocumentAnimations.h" |
| 54 #include "core/animation/DocumentTimeline.h" | 55 #include "core/animation/DocumentTimeline.h" |
| 55 #include "core/css/CSSFontSelector.h" | 56 #include "core/css/CSSFontSelector.h" |
| 56 #include "core/css/CSSStyleDeclaration.h" | 57 #include "core/css/CSSStyleDeclaration.h" |
| (...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 706 | 707 |
| 707 return toCoreString(dict.v8Value()->ToString()); | 708 return toCoreString(dict.v8Value()->ToString()); |
| 708 } | 709 } |
| 709 | 710 |
| 710 return emptyString(); | 711 return emptyString(); |
| 711 } | 712 } |
| 712 | 713 |
| 713 Element* Document::createElement(const AtomicString& localName, | 714 Element* Document::createElement(const AtomicString& localName, |
| 714 const StringOrDictionary& stringOrOptions, | 715 const StringOrDictionary& stringOrOptions, |
| 715 ExceptionState& exceptionState) { | 716 ExceptionState& exceptionState) { |
| 717 const AtomicString& is = | |
| 718 AtomicString(getTypeExtension(this, stringOrOptions, exceptionState)); | |
| 719 | |
| 716 if (!isValidName(localName)) { | 720 if (!isValidName(localName)) { |
| 717 exceptionState.throwDOMException( | 721 exceptionState.throwDOMException( |
| 718 InvalidCharacterError, | 722 InvalidCharacterError, |
| 719 "The tag name provided ('" + localName + "') is not a valid name."); | 723 "The tag name provided ('" + localName + "') is not a valid name."); |
| 720 return nullptr; | 724 return nullptr; |
| 721 } | 725 } |
| 722 | 726 |
| 723 Element* element; | 727 Element* element; |
| 724 | 728 |
| 725 if (CustomElement::shouldCreateCustomElement(convertLocalName(localName))) { | 729 bool shouldCreateBuiltin = |
| 730 stringOrOptions.isDictionary() && | |
| 731 RuntimeEnabledFeatures::customElementsBuiltinEnabled(); | |
| 732 | |
| 733 if (CustomElement::shouldCreateCustomElement(convertLocalName(localName)) || | |
| 734 shouldCreateBuiltin) { | |
| 726 element = CustomElement::createCustomElementSync( | 735 element = CustomElement::createCustomElementSync( |
| 727 *this, convertLocalName(localName)); | 736 *this, convertLocalName(localName), is); |
| 728 } else if (V0CustomElement::isValidName(localName) && registrationContext()) { | 737 } else if (V0CustomElement::isValidName(localName) && registrationContext()) { |
| 729 element = registrationContext()->createCustomTagElement( | 738 element = registrationContext()->createCustomTagElement( |
| 730 *this, QualifiedName(nullAtom, convertLocalName(localName), | 739 *this, QualifiedName(nullAtom, convertLocalName(localName), |
| 731 xhtmlNamespaceURI)); | 740 xhtmlNamespaceURI)); |
| 732 } else { | 741 } else { |
| 733 element = createElement(localName, exceptionState); | 742 element = createElement(localName, exceptionState); |
| 734 if (exceptionState.hadException()) | 743 if (exceptionState.hadException()) |
| 735 return nullptr; | 744 return nullptr; |
| 736 } | 745 } |
| 737 | 746 |
| 738 String typeExtention = | 747 if (!is.isEmpty()) { |
| 739 getTypeExtension(this, stringOrOptions, exceptionState); | 748 if (element->getCustomElementState() != CustomElementState::Custom) { |
| 740 if (!typeExtention.isEmpty()) { | 749 V0CustomElementRegistrationContext::setIsAttributeAndTypeExtension( |
| 741 V0CustomElementRegistrationContext::setIsAttributeAndTypeExtension( | 750 element, is); |
| 742 element, AtomicString(typeExtention)); | 751 } else if (stringOrOptions.isDictionary()) { |
| 752 element->setAttribute(HTMLNames::isAttr, is); | |
| 753 } | |
| 743 } | 754 } |
| 744 | 755 |
| 745 return element; | 756 return element; |
| 746 } | 757 } |
| 747 | 758 |
| 748 static inline QualifiedName createQualifiedName( | 759 static inline QualifiedName createQualifiedName( |
| 749 const AtomicString& namespaceURI, | 760 const AtomicString& namespaceURI, |
| 750 const AtomicString& qualifiedName, | 761 const AtomicString& qualifiedName, |
| 751 ExceptionState& exceptionState) { | 762 ExceptionState& exceptionState) { |
| 752 AtomicString prefix, localName; | 763 AtomicString prefix, localName; |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 777 | 788 |
| 778 if (CustomElement::shouldCreateCustomElement(qName)) | 789 if (CustomElement::shouldCreateCustomElement(qName)) |
| 779 return CustomElement::createCustomElementSync(*this, qName); | 790 return CustomElement::createCustomElementSync(*this, qName); |
| 780 return createElement(qName, CreatedByCreateElement); | 791 return createElement(qName, CreatedByCreateElement); |
| 781 } | 792 } |
| 782 | 793 |
| 783 Element* Document::createElementNS(const AtomicString& namespaceURI, | 794 Element* Document::createElementNS(const AtomicString& namespaceURI, |
| 784 const AtomicString& qualifiedName, | 795 const AtomicString& qualifiedName, |
| 785 const StringOrDictionary& stringOrOptions, | 796 const StringOrDictionary& stringOrOptions, |
| 786 ExceptionState& exceptionState) { | 797 ExceptionState& exceptionState) { |
| 798 const AtomicString& is = | |
| 799 AtomicString(getTypeExtension(this, stringOrOptions, exceptionState)); | |
| 800 | |
| 801 if (!isValidName(qualifiedName)) { | |
| 802 exceptionState.throwDOMException( | |
| 803 InvalidCharacterError, | |
| 804 "The tag name provided ('" + qualifiedName + "') is not a valid name."); | |
| 805 return nullptr; | |
| 806 } | |
| 807 | |
| 787 QualifiedName qName( | 808 QualifiedName qName( |
| 788 createQualifiedName(namespaceURI, qualifiedName, exceptionState)); | 809 createQualifiedName(namespaceURI, qualifiedName, exceptionState)); |
| 789 if (qName == QualifiedName::null()) | 810 if (qName == QualifiedName::null()) |
| 790 return nullptr; | 811 return nullptr; |
| 791 | 812 |
| 792 Element* element; | 813 Element* element; |
| 793 if (CustomElement::shouldCreateCustomElement(qName)) | 814 |
| 794 element = CustomElement::createCustomElementSync(*this, qName); | 815 bool shouldCreateBuiltin = |
|
dominicc (has gone to gerrit)
2016/11/10 03:43:09
Maybe *may* create builtin is better? If the optio
| |
| 795 else if (V0CustomElement::isValidName(qName.localName()) && | 816 stringOrOptions.isDictionary() && |
| 796 registrationContext()) | 817 RuntimeEnabledFeatures::customElementsBuiltinEnabled(); |
| 818 | |
| 819 if (CustomElement::shouldCreateCustomElement(qName) || shouldCreateBuiltin) { | |
| 820 element = CustomElement::createCustomElementSync(*this, qName, is); | |
| 821 } else if (V0CustomElement::isValidName(qName.localName()) && | |
| 822 registrationContext()) { | |
| 797 element = registrationContext()->createCustomTagElement(*this, qName); | 823 element = registrationContext()->createCustomTagElement(*this, qName); |
| 798 else | 824 } else { |
| 799 element = createElement(qName, CreatedByCreateElement); | 825 element = createElement(qName, CreatedByCreateElement); |
| 826 } | |
| 800 | 827 |
| 801 String typeExtention = | 828 if (!is.isEmpty()) { |
| 802 getTypeExtension(this, stringOrOptions, exceptionState); | 829 if (element->getCustomElementState() != CustomElementState::Custom) { |
|
dominicc (has gone to gerrit)
2016/11/10 03:43:09
I'm not sure about this part. Doesn't v0-ish stuff
| |
| 803 if (!typeExtention.isEmpty()) { | 830 V0CustomElementRegistrationContext::setIsAttributeAndTypeExtension( |
| 804 V0CustomElementRegistrationContext::setIsAttributeAndTypeExtension( | 831 element, is); |
| 805 element, AtomicString(typeExtention)); | 832 } else if (stringOrOptions.isDictionary()) { |
| 833 element->setAttribute(HTMLNames::isAttr, is); | |
| 834 } | |
| 806 } | 835 } |
| 807 | 836 |
| 808 return element; | 837 return element; |
| 809 } | 838 } |
| 810 | 839 |
| 811 ScriptValue Document::registerElement(ScriptState* scriptState, | 840 ScriptValue Document::registerElement(ScriptState* scriptState, |
| 812 const AtomicString& name, | 841 const AtomicString& name, |
| 813 const ElementRegistrationOptions& options, | 842 const ElementRegistrationOptions& options, |
| 814 ExceptionState& exceptionState, | 843 ExceptionState& exceptionState, |
| 815 V0CustomElement::NameSet validNames) { | 844 V0CustomElement::NameSet validNames) { |
| (...skipping 5652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6468 } | 6497 } |
| 6469 | 6498 |
| 6470 void showLiveDocumentInstances() { | 6499 void showLiveDocumentInstances() { |
| 6471 WeakDocumentSet& set = liveDocumentSet(); | 6500 WeakDocumentSet& set = liveDocumentSet(); |
| 6472 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 6501 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
| 6473 for (Document* document : set) | 6502 for (Document* document : set) |
| 6474 fprintf(stderr, "- Document %p URL: %s\n", document, | 6503 fprintf(stderr, "- Document %p URL: %s\n", document, |
| 6475 document->url().getString().utf8().data()); | 6504 document->url().getString().utf8().data()); |
| 6476 } | 6505 } |
| 6477 #endif | 6506 #endif |
| OLD | NEW |