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 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 769 | 769 |
| 770 PassRefPtr<Element> Document::createElement(const AtomicString& localName, const AtomicString& typeExtension, ExceptionCode& ec) | 770 PassRefPtr<Element> Document::createElement(const AtomicString& localName, const AtomicString& typeExtension, ExceptionCode& ec) |
| 771 { | 771 { |
| 772 if (!isValidName(localName)) { | 772 if (!isValidName(localName)) { |
| 773 ec = INVALID_CHARACTER_ERR; | 773 ec = INVALID_CHARACTER_ERR; |
| 774 return 0; | 774 return 0; |
| 775 } | 775 } |
| 776 | 776 |
| 777 RefPtr<Element> element; | 777 RefPtr<Element> element; |
| 778 | 778 |
| 779 if (m_registry) | 779 if (CustomElementRegistry::isCustomTagName(localName)) |
| 780 element = m_registry->tryToCreateCustomTagElement(QualifiedName(nullAtom , localName, xhtmlNamespaceURI)); | 780 element = ensureCustomElementRegistry()->createCustomTagElement(Qualifie dName(nullAtom, localName, xhtmlNamespaceURI)); |
| 781 | 781 else |
| 782 if (!element) | |
| 783 element = createElement(localName, ec); | 782 element = createElement(localName, ec); |
| 784 | 783 |
| 785 if (!typeExtension.isNull()) { | 784 if (!typeExtension.isNull()) { |
| 786 setTypeExtension(element.get(), typeExtension); | 785 setTypeExtension(element.get(), typeExtension); |
| 787 if (m_registry) | 786 ensureCustomElementRegistry()->didGiveTypeExtension(element.get()); |
| 788 m_registry->didGiveTypeExtension(element.get()); | |
| 789 } | 787 } |
| 790 | 788 |
| 791 return element; | 789 return element; |
| 792 } | 790 } |
| 793 | 791 |
| 794 PassRefPtr<Element> Document::createElementNS(const AtomicString& namespaceURI, const String& qualifiedName, const AtomicString& typeExtension, ExceptionCode& e c) | 792 PassRefPtr<Element> Document::createElementNS(const AtomicString& namespaceURI, const String& qualifiedName, const AtomicString& typeExtension, ExceptionCode& e c) |
| 795 { | 793 { |
| 796 String prefix, localName; | 794 String prefix, localName; |
| 797 if (!parseQualifiedName(qualifiedName, prefix, localName, ec)) | 795 if (!parseQualifiedName(qualifiedName, prefix, localName, ec)) |
| 798 return 0; | 796 return 0; |
| 799 | 797 |
| 800 QualifiedName qName(prefix, localName, namespaceURI); | 798 QualifiedName qName(prefix, localName, namespaceURI); |
| 801 if (!hasValidNamespaceForElements(qName)) { | 799 if (!hasValidNamespaceForElements(qName)) { |
| 802 ec = NAMESPACE_ERR; | 800 ec = NAMESPACE_ERR; |
| 803 return 0; | 801 return 0; |
| 804 } | 802 } |
| 805 | 803 |
| 806 RefPtr<Element> element; | 804 RefPtr<Element> element; |
| 807 | 805 if (CustomElementRegistry::isCustomTagName(qName.localName())) |
| 808 if (m_registry) | 806 element = ensureCustomElementRegistry()->createCustomTagElement(qName); |
| 809 element = m_registry->tryToCreateCustomTagElement(qName); | 807 else |
| 810 | |
| 811 if (!element) | |
| 812 element = createElementNS(namespaceURI, qualifiedName, ec); | 808 element = createElementNS(namespaceURI, qualifiedName, ec); |
| 813 | 809 |
| 814 if (!typeExtension.isNull()) { | 810 if (!typeExtension.isNull()) { |
| 815 setTypeExtension(element.get(), typeExtension); | 811 setTypeExtension(element.get(), typeExtension); |
| 816 if (m_registry) | 812 ensureCustomElementRegistry()->didGiveTypeExtension(element.get()); |
| 817 m_registry->didGiveTypeExtension(element.get()); | |
| 818 } | 813 } |
| 819 | 814 |
| 820 return element; | 815 return element; |
| 821 } | 816 } |
| 822 | 817 |
| 823 PassRefPtr<CustomElementConstructor> Document::registerElement(WebCore::ScriptSt ate* state, const AtomicString& name, ExceptionCode& ec) | 818 PassRefPtr<CustomElementConstructor> Document::registerElement(WebCore::ScriptSt ate* state, const AtomicString& name, ExceptionCode& ec) |
| 824 { | 819 { |
| 825 return registerElement(state, name, Dictionary(), ec); | 820 return registerElement(state, name, Dictionary(), ec); |
| 826 } | 821 } |
| 827 | 822 |
| 828 PassRefPtr<CustomElementConstructor> Document::registerElement(WebCore::ScriptSt ate* state, const AtomicString& name, const Dictionary& options, ExceptionCode& ec) | 823 PassRefPtr<CustomElementConstructor> Document::registerElement(WebCore::ScriptSt ate* state, const AtomicString& name, const Dictionary& options, ExceptionCode& ec) |
| 829 { | 824 { |
| 830 if (!isHTMLDocument() && !isXHTMLDocument()) { | 825 if (!isHTMLDocument() && !isXHTMLDocument()) { |
| 831 ec = NOT_SUPPORTED_ERR; | 826 ec = NOT_SUPPORTED_ERR; |
| 832 return 0; | 827 return 0; |
| 833 } | 828 } |
| 834 | 829 |
| 835 if (!m_registry) | 830 return ensureCustomElementRegistry()->registerElement(state, name, options, ec); |
| 831 } | |
| 832 | |
| 833 CustomElementRegistry* Document::ensureCustomElementRegistry() | |
|
dglazkov
2013/05/01 16:51:22
Making registry RAII could've been its own patch,
| |
| 834 { | |
| 835 if (!m_registry) { | |
| 836 ASSERT(isHTMLDocument() || isXHTMLDocument()); | |
| 836 m_registry = adoptRef(new CustomElementRegistry(this)); | 837 m_registry = adoptRef(new CustomElementRegistry(this)); |
| 837 return m_registry->registerElement(state, name, options, ec); | 838 } |
| 839 return m_registry.get(); | |
| 838 } | 840 } |
| 839 | 841 |
| 840 PassRefPtr<DocumentFragment> Document::createDocumentFragment() | 842 PassRefPtr<DocumentFragment> Document::createDocumentFragment() |
| 841 { | 843 { |
| 842 return DocumentFragment::create(document()); | 844 return DocumentFragment::create(document()); |
| 843 } | 845 } |
| 844 | 846 |
| 845 PassRefPtr<Text> Document::createTextNode(const String& data) | 847 PassRefPtr<Text> Document::createTextNode(const String& data) |
| 846 { | 848 { |
| 847 return Text::create(this, data); | 849 return Text::create(this, data); |
| (...skipping 4837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5685 return; | 5687 return; |
| 5686 | 5688 |
| 5687 Vector<RefPtr<Element> > associatedFormControls; | 5689 Vector<RefPtr<Element> > associatedFormControls; |
| 5688 copyToVector(m_associatedFormControls, associatedFormControls); | 5690 copyToVector(m_associatedFormControls, associatedFormControls); |
| 5689 | 5691 |
| 5690 frame()->page()->chrome()->client()->didAssociateFormControls(associatedForm Controls); | 5692 frame()->page()->chrome()->client()->didAssociateFormControls(associatedForm Controls); |
| 5691 m_associatedFormControls.clear(); | 5693 m_associatedFormControls.clear(); |
| 5692 } | 5694 } |
| 5693 | 5695 |
| 5694 } // namespace WebCore | 5696 } // namespace WebCore |
| OLD | NEW |