| 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 19 matching lines...) Expand all Loading... |
| 30 #include "core/dom/Document.h" | 30 #include "core/dom/Document.h" |
| 31 | 31 |
| 32 #include "bindings/core/v8/DOMDataStore.h" | 32 #include "bindings/core/v8/DOMDataStore.h" |
| 33 #include "bindings/core/v8/ExceptionMessages.h" | 33 #include "bindings/core/v8/ExceptionMessages.h" |
| 34 #include "bindings/core/v8/ExceptionState.h" | 34 #include "bindings/core/v8/ExceptionState.h" |
| 35 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 35 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
| 36 #include "bindings/core/v8/HTMLScriptElementOrSVGScriptElement.h" | 36 #include "bindings/core/v8/HTMLScriptElementOrSVGScriptElement.h" |
| 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/V0CustomElementConstructorBuilder.h" | 41 #include "bindings/core/v8/V0CustomElementConstructorBuilder.h" |
| 41 #include "bindings/core/v8/V8DOMWrapper.h" | 42 #include "bindings/core/v8/V8DOMWrapper.h" |
| 43 #include "bindings/core/v8/V8ElementCreationOptions.h" |
| 42 #include "bindings/core/v8/V8PerIsolateData.h" | 44 #include "bindings/core/v8/V8PerIsolateData.h" |
| 43 #include "bindings/core/v8/WindowProxy.h" | 45 #include "bindings/core/v8/WindowProxy.h" |
| 44 #include "core/HTMLElementFactory.h" | 46 #include "core/HTMLElementFactory.h" |
| 45 #include "core/HTMLNames.h" | 47 #include "core/HTMLNames.h" |
| 46 #include "core/SVGElementFactory.h" | 48 #include "core/SVGElementFactory.h" |
| 47 #include "core/SVGNames.h" | 49 #include "core/SVGNames.h" |
| 48 #include "core/XMLNSNames.h" | 50 #include "core/XMLNSNames.h" |
| 49 #include "core/XMLNames.h" | 51 #include "core/XMLNames.h" |
| 50 #include "core/animation/CompositorPendingAnimations.h" | 52 #include "core/animation/CompositorPendingAnimations.h" |
| 51 #include "core/animation/DocumentAnimations.h" | 53 #include "core/animation/DocumentAnimations.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 68 #include "core/dom/Attr.h" | 70 #include "core/dom/Attr.h" |
| 69 #include "core/dom/CDATASection.h" | 71 #include "core/dom/CDATASection.h" |
| 70 #include "core/dom/ClientRect.h" | 72 #include "core/dom/ClientRect.h" |
| 71 #include "core/dom/Comment.h" | 73 #include "core/dom/Comment.h" |
| 72 #include "core/dom/ContextFeatures.h" | 74 #include "core/dom/ContextFeatures.h" |
| 73 #include "core/dom/DOMImplementation.h" | 75 #include "core/dom/DOMImplementation.h" |
| 74 #include "core/dom/DocumentFragment.h" | 76 #include "core/dom/DocumentFragment.h" |
| 75 #include "core/dom/DocumentParserTiming.h" | 77 #include "core/dom/DocumentParserTiming.h" |
| 76 #include "core/dom/DocumentType.h" | 78 #include "core/dom/DocumentType.h" |
| 77 #include "core/dom/Element.h" | 79 #include "core/dom/Element.h" |
| 80 #include "core/dom/ElementCreationOptions.h" |
| 78 #include "core/dom/ElementDataCache.h" | 81 #include "core/dom/ElementDataCache.h" |
| 79 #include "core/dom/ElementRegistrationOptions.h" | 82 #include "core/dom/ElementRegistrationOptions.h" |
| 80 #include "core/dom/ElementTraversal.h" | 83 #include "core/dom/ElementTraversal.h" |
| 81 #include "core/dom/ExceptionCode.h" | 84 #include "core/dom/ExceptionCode.h" |
| 82 #include "core/dom/ExecutionContextTask.h" | 85 #include "core/dom/ExecutionContextTask.h" |
| 83 #include "core/dom/FrameRequestCallback.h" | 86 #include "core/dom/FrameRequestCallback.h" |
| 84 #include "core/dom/IntersectionObserverController.h" | 87 #include "core/dom/IntersectionObserverController.h" |
| 85 #include "core/dom/LayoutTreeBuilderTraversal.h" | 88 #include "core/dom/LayoutTreeBuilderTraversal.h" |
| 86 #include "core/dom/MainThreadTaskRunner.h" | 89 #include "core/dom/MainThreadTaskRunner.h" |
| 87 #include "core/dom/MutationObserver.h" | 90 #include "core/dom/MutationObserver.h" |
| (...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 AtomicString localName = convertLocalName(name); | 675 AtomicString localName = convertLocalName(name); |
| 673 if (CustomElement::shouldCreateCustomElement(localName)) | 676 if (CustomElement::shouldCreateCustomElement(localName)) |
| 674 return CustomElement::createCustomElementSync(*this, localName); | 677 return CustomElement::createCustomElementSync(*this, localName); |
| 675 return HTMLElementFactory::createHTMLElement(localName, *this, 0, | 678 return HTMLElementFactory::createHTMLElement(localName, *this, 0, |
| 676 CreatedByCreateElement); | 679 CreatedByCreateElement); |
| 677 } | 680 } |
| 678 | 681 |
| 679 return Element::create(QualifiedName(nullAtom, name, nullAtom), this); | 682 return Element::create(QualifiedName(nullAtom, name, nullAtom), this); |
| 680 } | 683 } |
| 681 | 684 |
| 685 String getTypeExtension(Document* document, |
| 686 const StringOrDictionary& stringOrOptions, |
| 687 ExceptionState& exceptionState) { |
| 688 if (stringOrOptions.isNull()) |
| 689 return emptyString(); |
| 690 |
| 691 if (stringOrOptions.isString()) { |
| 692 UseCounter::count(document, |
| 693 UseCounter::DocumentCreateElement2ndArgStringHandling); |
| 694 return stringOrOptions.getAsString(); |
| 695 } |
| 696 |
| 697 if (stringOrOptions.isDictionary()) { |
| 698 Dictionary dict = stringOrOptions.getAsDictionary(); |
| 699 ElementCreationOptions impl; |
| 700 V8ElementCreationOptions::toImpl(dict.isolate(), dict.v8Value(), impl, |
| 701 exceptionState); |
| 702 if (impl.hasIs()) |
| 703 return impl.is(); |
| 704 |
| 705 return toCoreString(dict.v8Value()->ToString()); |
| 706 } |
| 707 |
| 708 return emptyString(); |
| 709 } |
| 710 |
| 682 Element* Document::createElement(const AtomicString& localName, | 711 Element* Document::createElement(const AtomicString& localName, |
| 683 const AtomicString& typeExtension, | 712 const StringOrDictionary& stringOrOptions, |
| 684 ExceptionState& exceptionState) { | 713 ExceptionState& exceptionState) { |
| 685 if (!isValidName(localName)) { | 714 if (!isValidName(localName)) { |
| 686 exceptionState.throwDOMException( | 715 exceptionState.throwDOMException( |
| 687 InvalidCharacterError, | 716 InvalidCharacterError, |
| 688 "The tag name provided ('" + localName + "') is not a valid name."); | 717 "The tag name provided ('" + localName + "') is not a valid name."); |
| 689 return nullptr; | 718 return nullptr; |
| 690 } | 719 } |
| 691 | 720 |
| 692 Element* element; | 721 Element* element; |
| 693 | 722 |
| 694 if (CustomElement::shouldCreateCustomElement(convertLocalName(localName))) { | 723 if (CustomElement::shouldCreateCustomElement(convertLocalName(localName))) { |
| 695 element = CustomElement::createCustomElementSync( | 724 element = CustomElement::createCustomElementSync( |
| 696 *this, convertLocalName(localName)); | 725 *this, convertLocalName(localName)); |
| 697 } else if (V0CustomElement::isValidName(localName) && registrationContext()) { | 726 } else if (V0CustomElement::isValidName(localName) && registrationContext()) { |
| 698 element = registrationContext()->createCustomTagElement( | 727 element = registrationContext()->createCustomTagElement( |
| 699 *this, QualifiedName(nullAtom, convertLocalName(localName), | 728 *this, QualifiedName(nullAtom, convertLocalName(localName), |
| 700 xhtmlNamespaceURI)); | 729 xhtmlNamespaceURI)); |
| 701 } else { | 730 } else { |
| 702 element = createElement(localName, exceptionState); | 731 element = createElement(localName, exceptionState); |
| 703 if (exceptionState.hadException()) | 732 if (exceptionState.hadException()) |
| 704 return nullptr; | 733 return nullptr; |
| 705 } | 734 } |
| 706 | 735 |
| 707 if (!typeExtension.isEmpty()) | 736 String typeExtention = |
| 737 getTypeExtension(this, stringOrOptions, exceptionState); |
| 738 if (!typeExtention.isEmpty()) { |
| 708 V0CustomElementRegistrationContext::setIsAttributeAndTypeExtension( | 739 V0CustomElementRegistrationContext::setIsAttributeAndTypeExtension( |
| 709 element, typeExtension); | 740 element, AtomicString(typeExtention)); |
| 741 } |
| 710 | 742 |
| 711 return element; | 743 return element; |
| 712 } | 744 } |
| 713 | 745 |
| 714 static inline QualifiedName createQualifiedName( | 746 static inline QualifiedName createQualifiedName( |
| 715 const AtomicString& namespaceURI, | 747 const AtomicString& namespaceURI, |
| 716 const AtomicString& qualifiedName, | 748 const AtomicString& qualifiedName, |
| 717 ExceptionState& exceptionState) { | 749 ExceptionState& exceptionState) { |
| 718 AtomicString prefix, localName; | 750 AtomicString prefix, localName; |
| 719 if (!Document::parseQualifiedName(qualifiedName, prefix, localName, | 751 if (!Document::parseQualifiedName(qualifiedName, prefix, localName, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 741 if (qName == QualifiedName::null()) | 773 if (qName == QualifiedName::null()) |
| 742 return nullptr; | 774 return nullptr; |
| 743 | 775 |
| 744 if (CustomElement::shouldCreateCustomElement(qName)) | 776 if (CustomElement::shouldCreateCustomElement(qName)) |
| 745 return CustomElement::createCustomElementSync(*this, qName); | 777 return CustomElement::createCustomElementSync(*this, qName); |
| 746 return createElement(qName, CreatedByCreateElement); | 778 return createElement(qName, CreatedByCreateElement); |
| 747 } | 779 } |
| 748 | 780 |
| 749 Element* Document::createElementNS(const AtomicString& namespaceURI, | 781 Element* Document::createElementNS(const AtomicString& namespaceURI, |
| 750 const AtomicString& qualifiedName, | 782 const AtomicString& qualifiedName, |
| 751 const AtomicString& typeExtension, | 783 const StringOrDictionary& stringOrOptions, |
| 752 ExceptionState& exceptionState) { | 784 ExceptionState& exceptionState) { |
| 753 QualifiedName qName( | 785 QualifiedName qName( |
| 754 createQualifiedName(namespaceURI, qualifiedName, exceptionState)); | 786 createQualifiedName(namespaceURI, qualifiedName, exceptionState)); |
| 755 if (qName == QualifiedName::null()) | 787 if (qName == QualifiedName::null()) |
| 756 return nullptr; | 788 return nullptr; |
| 757 | 789 |
| 758 Element* element; | 790 Element* element; |
| 759 if (CustomElement::shouldCreateCustomElement(qName)) | 791 if (CustomElement::shouldCreateCustomElement(qName)) |
| 760 element = CustomElement::createCustomElementSync(*this, qName); | 792 element = CustomElement::createCustomElementSync(*this, qName); |
| 761 else if (V0CustomElement::isValidName(qName.localName()) && | 793 else if (V0CustomElement::isValidName(qName.localName()) && |
| 762 registrationContext()) | 794 registrationContext()) |
| 763 element = registrationContext()->createCustomTagElement(*this, qName); | 795 element = registrationContext()->createCustomTagElement(*this, qName); |
| 764 else | 796 else |
| 765 element = createElement(qName, CreatedByCreateElement); | 797 element = createElement(qName, CreatedByCreateElement); |
| 766 | 798 |
| 767 if (!typeExtension.isEmpty()) | 799 String typeExtention = |
| 800 getTypeExtension(this, stringOrOptions, exceptionState); |
| 801 if (!typeExtention.isEmpty()) { |
| 768 V0CustomElementRegistrationContext::setIsAttributeAndTypeExtension( | 802 V0CustomElementRegistrationContext::setIsAttributeAndTypeExtension( |
| 769 element, typeExtension); | 803 element, AtomicString(typeExtention)); |
| 804 } |
| 770 | 805 |
| 771 return element; | 806 return element; |
| 772 } | 807 } |
| 773 | 808 |
| 774 ScriptValue Document::registerElement(ScriptState* scriptState, | 809 ScriptValue Document::registerElement(ScriptState* scriptState, |
| 775 const AtomicString& name, | 810 const AtomicString& name, |
| 776 const ElementRegistrationOptions& options, | 811 const ElementRegistrationOptions& options, |
| 777 ExceptionState& exceptionState, | 812 ExceptionState& exceptionState, |
| 778 V0CustomElement::NameSet validNames) { | 813 V0CustomElement::NameSet validNames) { |
| 779 HostsUsingFeatures::countMainWorldOnly( | 814 HostsUsingFeatures::countMainWorldOnly( |
| (...skipping 5636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6416 } | 6451 } |
| 6417 | 6452 |
| 6418 void showLiveDocumentInstances() { | 6453 void showLiveDocumentInstances() { |
| 6419 WeakDocumentSet& set = liveDocumentSet(); | 6454 WeakDocumentSet& set = liveDocumentSet(); |
| 6420 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 6455 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
| 6421 for (Document* document : set) | 6456 for (Document* document : set) |
| 6422 fprintf(stderr, "- Document %p URL: %s\n", document, | 6457 fprintf(stderr, "- Document %p URL: %s\n", document, |
| 6423 document->url().getString().utf8().data()); | 6458 document->url().getString().utf8().data()); |
| 6424 } | 6459 } |
| 6425 #endif | 6460 #endif |
| OLD | NEW |