| 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 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 ContainerNode::childrenChanged(changedByParser, beforeChange, afterChange, c
hildCountDelta); | 667 ContainerNode::childrenChanged(changedByParser, beforeChange, afterChange, c
hildCountDelta); |
| 668 | 668 |
| 669 Element* newDocumentElement = ElementTraversal::firstWithin(*this); | 669 Element* newDocumentElement = ElementTraversal::firstWithin(*this); |
| 670 if (newDocumentElement == m_documentElement) | 670 if (newDocumentElement == m_documentElement) |
| 671 return; | 671 return; |
| 672 m_documentElement = newDocumentElement; | 672 m_documentElement = newDocumentElement; |
| 673 // The root style used for media query matching depends on the document elem
ent. | 673 // The root style used for media query matching depends on the document elem
ent. |
| 674 clearStyleResolver(); | 674 clearStyleResolver(); |
| 675 } | 675 } |
| 676 | 676 |
| 677 PassRefPtr<Element> Document::createElement(const AtomicString& name, ExceptionS
tate& es) | 677 PassRefPtr<Element> Document::createElement(const AtomicString& name, ExceptionS
tate& exceptionState) |
| 678 { | 678 { |
| 679 if (!isValidName(name)) { | 679 if (!isValidName(name)) { |
| 680 es.throwUninformativeAndGenericDOMException(InvalidCharacterError); | 680 exceptionState.throwUninformativeAndGenericDOMException(InvalidCharacter
Error); |
| 681 return 0; | 681 return 0; |
| 682 } | 682 } |
| 683 | 683 |
| 684 if (isXHTMLDocument() || isHTMLDocument()) | 684 if (isXHTMLDocument() || isHTMLDocument()) |
| 685 return HTMLElementFactory::createHTMLElement(isHTMLDocument() ? name.low
er() : name, document(), 0, false); | 685 return HTMLElementFactory::createHTMLElement(isHTMLDocument() ? name.low
er() : name, document(), 0, false); |
| 686 | 686 |
| 687 return createElement(QualifiedName(nullAtom, name, nullAtom), false); | 687 return createElement(QualifiedName(nullAtom, name, nullAtom), false); |
| 688 } | 688 } |
| 689 | 689 |
| 690 PassRefPtr<Element> Document::createElement(const AtomicString& localName, const
AtomicString& typeExtension, ExceptionState& es) | 690 PassRefPtr<Element> Document::createElement(const AtomicString& localName, const
AtomicString& typeExtension, ExceptionState& exceptionState) |
| 691 { | 691 { |
| 692 if (!isValidName(localName)) { | 692 if (!isValidName(localName)) { |
| 693 es.throwUninformativeAndGenericDOMException(InvalidCharacterError); | 693 exceptionState.throwUninformativeAndGenericDOMException(InvalidCharacter
Error); |
| 694 return 0; | 694 return 0; |
| 695 } | 695 } |
| 696 | 696 |
| 697 RefPtr<Element> element; | 697 RefPtr<Element> element; |
| 698 | 698 |
| 699 if (RuntimeEnabledFeatures::customElementsEnabled() && CustomElement::isVali
dName(localName) && registrationContext()) | 699 if (RuntimeEnabledFeatures::customElementsEnabled() && CustomElement::isVali
dName(localName) && registrationContext()) |
| 700 element = registrationContext()->createCustomTagElement(*this, Qualified
Name(nullAtom, localName, xhtmlNamespaceURI)); | 700 element = registrationContext()->createCustomTagElement(*this, Qualified
Name(nullAtom, localName, xhtmlNamespaceURI)); |
| 701 else | 701 else |
| 702 element = createElement(localName, es); | 702 element = createElement(localName, exceptionState); |
| 703 | 703 |
| 704 if (RuntimeEnabledFeatures::customElementsEnabled() && !typeExtension.isNull
() && !typeExtension.isEmpty()) | 704 if (RuntimeEnabledFeatures::customElementsEnabled() && !typeExtension.isNull
() && !typeExtension.isEmpty()) |
| 705 CustomElementRegistrationContext::setIsAttributeAndTypeExtension(element
.get(), typeExtension); | 705 CustomElementRegistrationContext::setIsAttributeAndTypeExtension(element
.get(), typeExtension); |
| 706 | 706 |
| 707 return element; | 707 return element; |
| 708 } | 708 } |
| 709 | 709 |
| 710 PassRefPtr<Element> Document::createElementNS(const AtomicString& namespaceURI,
const String& qualifiedName, const AtomicString& typeExtension, ExceptionState&
es) | 710 PassRefPtr<Element> Document::createElementNS(const AtomicString& namespaceURI,
const String& qualifiedName, const AtomicString& typeExtension, ExceptionState&
exceptionState) |
| 711 { | 711 { |
| 712 String prefix, localName; | 712 String prefix, localName; |
| 713 if (!parseQualifiedName(qualifiedName, prefix, localName, es)) | 713 if (!parseQualifiedName(qualifiedName, prefix, localName, exceptionState)) |
| 714 return 0; | 714 return 0; |
| 715 | 715 |
| 716 QualifiedName qName(prefix, localName, namespaceURI); | 716 QualifiedName qName(prefix, localName, namespaceURI); |
| 717 if (!hasValidNamespaceForElements(qName)) { | 717 if (!hasValidNamespaceForElements(qName)) { |
| 718 es.throwUninformativeAndGenericDOMException(NamespaceError); | 718 exceptionState.throwUninformativeAndGenericDOMException(NamespaceError); |
| 719 return 0; | 719 return 0; |
| 720 } | 720 } |
| 721 | 721 |
| 722 RefPtr<Element> element; | 722 RefPtr<Element> element; |
| 723 if (CustomElement::isValidName(qName.localName()) && registrationContext()) | 723 if (CustomElement::isValidName(qName.localName()) && registrationContext()) |
| 724 element = registrationContext()->createCustomTagElement(*this, qName); | 724 element = registrationContext()->createCustomTagElement(*this, qName); |
| 725 else | 725 else |
| 726 element = createElementNS(namespaceURI, qualifiedName, es); | 726 element = createElementNS(namespaceURI, qualifiedName, exceptionState); |
| 727 | 727 |
| 728 if (!typeExtension.isNull() && !typeExtension.isEmpty()) | 728 if (!typeExtension.isNull() && !typeExtension.isEmpty()) |
| 729 CustomElementRegistrationContext::setIsAttributeAndTypeExtension(element
.get(), typeExtension); | 729 CustomElementRegistrationContext::setIsAttributeAndTypeExtension(element
.get(), typeExtension); |
| 730 | 730 |
| 731 return element; | 731 return element; |
| 732 } | 732 } |
| 733 | 733 |
| 734 ScriptValue Document::registerElement(WebCore::ScriptState* state, const AtomicS
tring& name, ExceptionState& es) | 734 ScriptValue Document::registerElement(WebCore::ScriptState* state, const AtomicS
tring& name, ExceptionState& exceptionState) |
| 735 { | 735 { |
| 736 return registerElement(state, name, Dictionary(), es); | 736 return registerElement(state, name, Dictionary(), exceptionState); |
| 737 } | 737 } |
| 738 | 738 |
| 739 ScriptValue Document::registerElement(WebCore::ScriptState* state, const AtomicS
tring& name, const Dictionary& options, ExceptionState& es, CustomElement::NameS
et validNames) | 739 ScriptValue Document::registerElement(WebCore::ScriptState* state, const AtomicS
tring& name, const Dictionary& options, ExceptionState& exceptionState, CustomEl
ement::NameSet validNames) |
| 740 { | 740 { |
| 741 if (!registrationContext()) { | 741 if (!registrationContext()) { |
| 742 es.throwUninformativeAndGenericDOMException(NotSupportedError); | 742 exceptionState.throwUninformativeAndGenericDOMException(NotSupportedErro
r); |
| 743 return ScriptValue(); | 743 return ScriptValue(); |
| 744 } | 744 } |
| 745 | 745 |
| 746 CustomElementConstructorBuilder constructorBuilder(state, &options); | 746 CustomElementConstructorBuilder constructorBuilder(state, &options); |
| 747 registrationContext()->registerElement(this, &constructorBuilder, name, vali
dNames, es); | 747 registrationContext()->registerElement(this, &constructorBuilder, name, vali
dNames, exceptionState); |
| 748 return constructorBuilder.bindingsReturnValue(); | 748 return constructorBuilder.bindingsReturnValue(); |
| 749 } | 749 } |
| 750 | 750 |
| 751 void Document::setImport(HTMLImport* import) | 751 void Document::setImport(HTMLImport* import) |
| 752 { | 752 { |
| 753 ASSERT(!m_import || !import); | 753 ASSERT(!m_import || !import); |
| 754 m_import = import; | 754 m_import = import; |
| 755 } | 755 } |
| 756 | 756 |
| 757 void Document::didLoadAllImports() | 757 void Document::didLoadAllImports() |
| (...skipping 14 matching lines...) Expand all Loading... |
| 772 PassRefPtr<Text> Document::createTextNode(const String& data) | 772 PassRefPtr<Text> Document::createTextNode(const String& data) |
| 773 { | 773 { |
| 774 return Text::create(*this, data); | 774 return Text::create(*this, data); |
| 775 } | 775 } |
| 776 | 776 |
| 777 PassRefPtr<Comment> Document::createComment(const String& data) | 777 PassRefPtr<Comment> Document::createComment(const String& data) |
| 778 { | 778 { |
| 779 return Comment::create(*this, data); | 779 return Comment::create(*this, data); |
| 780 } | 780 } |
| 781 | 781 |
| 782 PassRefPtr<CDATASection> Document::createCDATASection(const String& data, Except
ionState& es) | 782 PassRefPtr<CDATASection> Document::createCDATASection(const String& data, Except
ionState& exceptionState) |
| 783 { | 783 { |
| 784 if (isHTMLDocument()) { | 784 if (isHTMLDocument()) { |
| 785 es.throwUninformativeAndGenericDOMException(NotSupportedError); | 785 exceptionState.throwUninformativeAndGenericDOMException(NotSupportedErro
r); |
| 786 return 0; | 786 return 0; |
| 787 } | 787 } |
| 788 if (data.find("]]>") != WTF::kNotFound) { | 788 if (data.find("]]>") != WTF::kNotFound) { |
| 789 es.throwDOMException(InvalidCharacterError, "String cannot contain ']]>'
since that is the end delimiter of a CData section."); | 789 exceptionState.throwDOMException(InvalidCharacterError, "String cannot c
ontain ']]>' since that is the end delimiter of a CData section."); |
| 790 return 0; | 790 return 0; |
| 791 } | 791 } |
| 792 return CDATASection::create(*this, data); | 792 return CDATASection::create(*this, data); |
| 793 } | 793 } |
| 794 | 794 |
| 795 PassRefPtr<ProcessingInstruction> Document::createProcessingInstruction(const St
ring& target, const String& data, ExceptionState& es) | 795 PassRefPtr<ProcessingInstruction> Document::createProcessingInstruction(const St
ring& target, const String& data, ExceptionState& exceptionState) |
| 796 { | 796 { |
| 797 if (!isValidName(target)) { | 797 if (!isValidName(target)) { |
| 798 es.throwUninformativeAndGenericDOMException(InvalidCharacterError); | 798 exceptionState.throwUninformativeAndGenericDOMException(InvalidCharacter
Error); |
| 799 return 0; | 799 return 0; |
| 800 } | 800 } |
| 801 if (isHTMLDocument()) { | 801 if (isHTMLDocument()) { |
| 802 es.throwUninformativeAndGenericDOMException(NotSupportedError); | 802 exceptionState.throwUninformativeAndGenericDOMException(NotSupportedErro
r); |
| 803 return 0; | 803 return 0; |
| 804 } | 804 } |
| 805 return ProcessingInstruction::create(*this, target, data); | 805 return ProcessingInstruction::create(*this, target, data); |
| 806 } | 806 } |
| 807 | 807 |
| 808 PassRefPtr<Text> Document::createEditingTextNode(const String& text) | 808 PassRefPtr<Text> Document::createEditingTextNode(const String& text) |
| 809 { | 809 { |
| 810 return Text::createEditingText(*this, text); | 810 return Text::createEditingText(*this, text); |
| 811 } | 811 } |
| 812 | 812 |
| 813 PassRefPtr<CSSStyleDeclaration> Document::createCSSStyleDeclaration() | 813 PassRefPtr<CSSStyleDeclaration> Document::createCSSStyleDeclaration() |
| 814 { | 814 { |
| 815 return MutableStylePropertySet::create()->ensureCSSStyleDeclaration(); | 815 return MutableStylePropertySet::create()->ensureCSSStyleDeclaration(); |
| 816 } | 816 } |
| 817 | 817 |
| 818 PassRefPtr<Node> Document::importNode(Node* importedNode, bool deep, ExceptionSt
ate& es) | 818 PassRefPtr<Node> Document::importNode(Node* importedNode, bool deep, ExceptionSt
ate& exceptionState) |
| 819 { | 819 { |
| 820 if (!importedNode) { | 820 if (!importedNode) { |
| 821 es.throwUninformativeAndGenericDOMException(NotSupportedError); | 821 exceptionState.throwUninformativeAndGenericDOMException(NotSupportedErro
r); |
| 822 return 0; | 822 return 0; |
| 823 } | 823 } |
| 824 | 824 |
| 825 switch (importedNode->nodeType()) { | 825 switch (importedNode->nodeType()) { |
| 826 case TEXT_NODE: | 826 case TEXT_NODE: |
| 827 return createTextNode(importedNode->nodeValue()); | 827 return createTextNode(importedNode->nodeValue()); |
| 828 case CDATA_SECTION_NODE: | 828 case CDATA_SECTION_NODE: |
| 829 return createCDATASection(importedNode->nodeValue(), es); | 829 return createCDATASection(importedNode->nodeValue(), exceptionState); |
| 830 case PROCESSING_INSTRUCTION_NODE: | 830 case PROCESSING_INSTRUCTION_NODE: |
| 831 return createProcessingInstruction(importedNode->nodeName(), importedNod
e->nodeValue(), es); | 831 return createProcessingInstruction(importedNode->nodeName(), importedNod
e->nodeValue(), exceptionState); |
| 832 case COMMENT_NODE: | 832 case COMMENT_NODE: |
| 833 return createComment(importedNode->nodeValue()); | 833 return createComment(importedNode->nodeValue()); |
| 834 case ELEMENT_NODE: { | 834 case ELEMENT_NODE: { |
| 835 Element* oldElement = toElement(importedNode); | 835 Element* oldElement = toElement(importedNode); |
| 836 // FIXME: The following check might be unnecessary. Is it possible that | 836 // FIXME: The following check might be unnecessary. Is it possible that |
| 837 // oldElement has mismatched prefix/namespace? | 837 // oldElement has mismatched prefix/namespace? |
| 838 if (!hasValidNamespaceForElements(oldElement->tagQName())) { | 838 if (!hasValidNamespaceForElements(oldElement->tagQName())) { |
| 839 es.throwUninformativeAndGenericDOMException(NamespaceError); | 839 exceptionState.throwUninformativeAndGenericDOMException(NamespaceErr
or); |
| 840 return 0; | 840 return 0; |
| 841 } | 841 } |
| 842 RefPtr<Element> newElement = createElement(oldElement->tagQName(), false
); | 842 RefPtr<Element> newElement = createElement(oldElement->tagQName(), false
); |
| 843 | 843 |
| 844 newElement->cloneDataFromElement(*oldElement); | 844 newElement->cloneDataFromElement(*oldElement); |
| 845 | 845 |
| 846 if (deep) { | 846 if (deep) { |
| 847 for (Node* oldChild = oldElement->firstChild(); oldChild; oldChild =
oldChild->nextSibling()) { | 847 for (Node* oldChild = oldElement->firstChild(); oldChild; oldChild =
oldChild->nextSibling()) { |
| 848 RefPtr<Node> newChild = importNode(oldChild, true, es); | 848 RefPtr<Node> newChild = importNode(oldChild, true, exceptionStat
e); |
| 849 if (es.hadException()) | 849 if (exceptionState.hadException()) |
| 850 return 0; | 850 return 0; |
| 851 newElement->appendChild(newChild.release(), es); | 851 newElement->appendChild(newChild.release(), exceptionState); |
| 852 if (es.hadException()) | 852 if (exceptionState.hadException()) |
| 853 return 0; | 853 return 0; |
| 854 } | 854 } |
| 855 } | 855 } |
| 856 | 856 |
| 857 return newElement.release(); | 857 return newElement.release(); |
| 858 } | 858 } |
| 859 case ATTRIBUTE_NODE: | 859 case ATTRIBUTE_NODE: |
| 860 return Attr::create(*this, QualifiedName(nullAtom, toAttr(importedNode)-
>name(), nullAtom), toAttr(importedNode)->value()); | 860 return Attr::create(*this, QualifiedName(nullAtom, toAttr(importedNode)-
>name(), nullAtom), toAttr(importedNode)->value()); |
| 861 case DOCUMENT_FRAGMENT_NODE: { | 861 case DOCUMENT_FRAGMENT_NODE: { |
| 862 if (importedNode->isShadowRoot()) { | 862 if (importedNode->isShadowRoot()) { |
| 863 // ShadowRoot nodes should not be explicitly importable. | 863 // ShadowRoot nodes should not be explicitly importable. |
| 864 // Either they are imported along with their host node, or created i
mplicitly. | 864 // Either they are imported along with their host node, or created i
mplicitly. |
| 865 break; | 865 break; |
| 866 } | 866 } |
| 867 DocumentFragment* oldFragment = toDocumentFragment(importedNode); | 867 DocumentFragment* oldFragment = toDocumentFragment(importedNode); |
| 868 RefPtr<DocumentFragment> newFragment = createDocumentFragment(); | 868 RefPtr<DocumentFragment> newFragment = createDocumentFragment(); |
| 869 if (deep) { | 869 if (deep) { |
| 870 for (Node* oldChild = oldFragment->firstChild(); oldChild; oldChild
= oldChild->nextSibling()) { | 870 for (Node* oldChild = oldFragment->firstChild(); oldChild; oldChild
= oldChild->nextSibling()) { |
| 871 RefPtr<Node> newChild = importNode(oldChild, true, es); | 871 RefPtr<Node> newChild = importNode(oldChild, true, exceptionStat
e); |
| 872 if (es.hadException()) | 872 if (exceptionState.hadException()) |
| 873 return 0; | 873 return 0; |
| 874 newFragment->appendChild(newChild.release(), es); | 874 newFragment->appendChild(newChild.release(), exceptionState); |
| 875 if (es.hadException()) | 875 if (exceptionState.hadException()) |
| 876 return 0; | 876 return 0; |
| 877 } | 877 } |
| 878 } | 878 } |
| 879 | 879 |
| 880 return newFragment.release(); | 880 return newFragment.release(); |
| 881 } | 881 } |
| 882 case ENTITY_NODE: | 882 case ENTITY_NODE: |
| 883 case NOTATION_NODE: | 883 case NOTATION_NODE: |
| 884 // FIXME: It should be possible to import these node types, however in D
OM3 the DocumentType is readonly, so there isn't much sense in doing that. | 884 // FIXME: It should be possible to import these node types, however in D
OM3 the DocumentType is readonly, so there isn't much sense in doing that. |
| 885 // Ability to add these imported nodes to a DocumentType will be conside
red for addition to a future release of the DOM. | 885 // Ability to add these imported nodes to a DocumentType will be conside
red for addition to a future release of the DOM. |
| 886 case DOCUMENT_NODE: | 886 case DOCUMENT_NODE: |
| 887 case DOCUMENT_TYPE_NODE: | 887 case DOCUMENT_TYPE_NODE: |
| 888 case XPATH_NAMESPACE_NODE: | 888 case XPATH_NAMESPACE_NODE: |
| 889 break; | 889 break; |
| 890 } | 890 } |
| 891 es.throwUninformativeAndGenericDOMException(NotSupportedError); | 891 exceptionState.throwUninformativeAndGenericDOMException(NotSupportedError); |
| 892 return 0; | 892 return 0; |
| 893 } | 893 } |
| 894 | 894 |
| 895 PassRefPtr<Node> Document::adoptNode(PassRefPtr<Node> source, ExceptionState& es
) | 895 PassRefPtr<Node> Document::adoptNode(PassRefPtr<Node> source, ExceptionState& ex
ceptionState) |
| 896 { | 896 { |
| 897 if (!source) { | 897 if (!source) { |
| 898 es.throwUninformativeAndGenericDOMException(NotSupportedError); | 898 exceptionState.throwUninformativeAndGenericDOMException(NotSupportedErro
r); |
| 899 return 0; | 899 return 0; |
| 900 } | 900 } |
| 901 | 901 |
| 902 EventQueueScope scope; | 902 EventQueueScope scope; |
| 903 | 903 |
| 904 switch (source->nodeType()) { | 904 switch (source->nodeType()) { |
| 905 case ENTITY_NODE: | 905 case ENTITY_NODE: |
| 906 case NOTATION_NODE: | 906 case NOTATION_NODE: |
| 907 case DOCUMENT_NODE: | 907 case DOCUMENT_NODE: |
| 908 case DOCUMENT_TYPE_NODE: | 908 case DOCUMENT_TYPE_NODE: |
| 909 case XPATH_NAMESPACE_NODE: | 909 case XPATH_NAMESPACE_NODE: |
| 910 es.throwUninformativeAndGenericDOMException(NotSupportedError); | 910 exceptionState.throwUninformativeAndGenericDOMException(NotSupportedErro
r); |
| 911 return 0; | 911 return 0; |
| 912 case ATTRIBUTE_NODE: { | 912 case ATTRIBUTE_NODE: { |
| 913 Attr* attr = toAttr(source.get()); | 913 Attr* attr = toAttr(source.get()); |
| 914 if (attr->ownerElement()) | 914 if (attr->ownerElement()) |
| 915 attr->ownerElement()->removeAttributeNode(attr, es); | 915 attr->ownerElement()->removeAttributeNode(attr, exceptionState); |
| 916 break; | 916 break; |
| 917 } | 917 } |
| 918 default: | 918 default: |
| 919 if (source->isShadowRoot()) { | 919 if (source->isShadowRoot()) { |
| 920 // ShadowRoot cannot disconnect itself from the host node. | 920 // ShadowRoot cannot disconnect itself from the host node. |
| 921 es.throwUninformativeAndGenericDOMException(HierarchyRequestError); | 921 exceptionState.throwUninformativeAndGenericDOMException(HierarchyReq
uestError); |
| 922 return 0; | 922 return 0; |
| 923 } | 923 } |
| 924 | 924 |
| 925 if (source->isFrameOwnerElement()) { | 925 if (source->isFrameOwnerElement()) { |
| 926 HTMLFrameOwnerElement* frameOwnerElement = toHTMLFrameOwnerElement(s
ource.get()); | 926 HTMLFrameOwnerElement* frameOwnerElement = toHTMLFrameOwnerElement(s
ource.get()); |
| 927 if (frame() && frame()->tree().isDescendantOf(frameOwnerElement->con
tentFrame())) { | 927 if (frame() && frame()->tree().isDescendantOf(frameOwnerElement->con
tentFrame())) { |
| 928 es.throwUninformativeAndGenericDOMException(HierarchyRequestErro
r); | 928 exceptionState.throwUninformativeAndGenericDOMException(Hierarch
yRequestError); |
| 929 return 0; | 929 return 0; |
| 930 } | 930 } |
| 931 } | 931 } |
| 932 if (source->parentNode()) { | 932 if (source->parentNode()) { |
| 933 source->parentNode()->removeChild(source.get(), es); | 933 source->parentNode()->removeChild(source.get(), exceptionState); |
| 934 if (es.hadException()) | 934 if (exceptionState.hadException()) |
| 935 return 0; | 935 return 0; |
| 936 } | 936 } |
| 937 } | 937 } |
| 938 | 938 |
| 939 this->adoptIfNeeded(*source); | 939 this->adoptIfNeeded(*source); |
| 940 | 940 |
| 941 return source; | 941 return source; |
| 942 } | 942 } |
| 943 | 943 |
| 944 bool Document::hasValidNamespaceForElements(const QualifiedName& qName) | 944 bool Document::hasValidNamespaceForElements(const QualifiedName& qName) |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1010 } | 1010 } |
| 1011 | 1011 |
| 1012 NamedFlowCollection* Document::namedFlows() | 1012 NamedFlowCollection* Document::namedFlows() |
| 1013 { | 1013 { |
| 1014 if (!m_namedFlows) | 1014 if (!m_namedFlows) |
| 1015 m_namedFlows = NamedFlowCollection::create(this); | 1015 m_namedFlows = NamedFlowCollection::create(this); |
| 1016 | 1016 |
| 1017 return m_namedFlows.get(); | 1017 return m_namedFlows.get(); |
| 1018 } | 1018 } |
| 1019 | 1019 |
| 1020 PassRefPtr<Element> Document::createElementNS(const String& namespaceURI, const
String& qualifiedName, ExceptionState& es) | 1020 PassRefPtr<Element> Document::createElementNS(const String& namespaceURI, const
String& qualifiedName, ExceptionState& exceptionState) |
| 1021 { | 1021 { |
| 1022 String prefix, localName; | 1022 String prefix, localName; |
| 1023 if (!parseQualifiedName(qualifiedName, prefix, localName, es)) | 1023 if (!parseQualifiedName(qualifiedName, prefix, localName, exceptionState)) |
| 1024 return 0; | 1024 return 0; |
| 1025 | 1025 |
| 1026 QualifiedName qName(prefix, localName, namespaceURI); | 1026 QualifiedName qName(prefix, localName, namespaceURI); |
| 1027 if (!hasValidNamespaceForElements(qName)) { | 1027 if (!hasValidNamespaceForElements(qName)) { |
| 1028 es.throwUninformativeAndGenericDOMException(NamespaceError); | 1028 exceptionState.throwUninformativeAndGenericDOMException(NamespaceError); |
| 1029 return 0; | 1029 return 0; |
| 1030 } | 1030 } |
| 1031 | 1031 |
| 1032 return createElement(qName, false); | 1032 return createElement(qName, false); |
| 1033 } | 1033 } |
| 1034 | 1034 |
| 1035 String Document::readyState() const | 1035 String Document::readyState() const |
| 1036 { | 1036 { |
| 1037 DEFINE_STATIC_LOCAL(const String, loading, ("loading")); | 1037 DEFINE_STATIC_LOCAL(const String, loading, ("loading")); |
| 1038 DEFINE_STATIC_LOCAL(const String, interactive, ("interactive")); | 1038 DEFINE_STATIC_LOCAL(const String, interactive, ("interactive")); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1114 void Document::setContentLanguage(const String& language) | 1114 void Document::setContentLanguage(const String& language) |
| 1115 { | 1115 { |
| 1116 if (m_contentLanguage == language) | 1116 if (m_contentLanguage == language) |
| 1117 return; | 1117 return; |
| 1118 m_contentLanguage = language; | 1118 m_contentLanguage = language; |
| 1119 | 1119 |
| 1120 // Document's style depends on the content language. | 1120 // Document's style depends on the content language. |
| 1121 setNeedsStyleRecalc(); | 1121 setNeedsStyleRecalc(); |
| 1122 } | 1122 } |
| 1123 | 1123 |
| 1124 void Document::setXMLVersion(const String& version, ExceptionState& es) | 1124 void Document::setXMLVersion(const String& version, ExceptionState& exceptionSta
te) |
| 1125 { | 1125 { |
| 1126 if (!implementation()->hasFeature("XML", String())) { | 1126 if (!implementation()->hasFeature("XML", String())) { |
| 1127 es.throwUninformativeAndGenericDOMException(NotSupportedError); | 1127 exceptionState.throwUninformativeAndGenericDOMException(NotSupportedErro
r); |
| 1128 return; | 1128 return; |
| 1129 } | 1129 } |
| 1130 | 1130 |
| 1131 if (!XMLDocumentParser::supportsXMLVersion(version)) { | 1131 if (!XMLDocumentParser::supportsXMLVersion(version)) { |
| 1132 es.throwUninformativeAndGenericDOMException(NotSupportedError); | 1132 exceptionState.throwUninformativeAndGenericDOMException(NotSupportedErro
r); |
| 1133 return; | 1133 return; |
| 1134 } | 1134 } |
| 1135 | 1135 |
| 1136 m_xmlVersion = version; | 1136 m_xmlVersion = version; |
| 1137 } | 1137 } |
| 1138 | 1138 |
| 1139 void Document::setXMLStandalone(bool standalone, ExceptionState& es) | 1139 void Document::setXMLStandalone(bool standalone, ExceptionState& exceptionState) |
| 1140 { | 1140 { |
| 1141 if (!implementation()->hasFeature("XML", String())) { | 1141 if (!implementation()->hasFeature("XML", String())) { |
| 1142 es.throwUninformativeAndGenericDOMException(NotSupportedError); | 1142 exceptionState.throwUninformativeAndGenericDOMException(NotSupportedErro
r); |
| 1143 return; | 1143 return; |
| 1144 } | 1144 } |
| 1145 | 1145 |
| 1146 m_xmlStandalone = standalone ? Standalone : NotStandalone; | 1146 m_xmlStandalone = standalone ? Standalone : NotStandalone; |
| 1147 } | 1147 } |
| 1148 | 1148 |
| 1149 KURL Document::baseURI() const | 1149 KURL Document::baseURI() const |
| 1150 { | 1150 { |
| 1151 return m_baseURL; | 1151 return m_baseURL; |
| 1152 } | 1152 } |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1422 Settings* Document::settings() const | 1422 Settings* Document::settings() const |
| 1423 { | 1423 { |
| 1424 return m_frame ? m_frame->settings() : 0; | 1424 return m_frame ? m_frame->settings() : 0; |
| 1425 } | 1425 } |
| 1426 | 1426 |
| 1427 PassRefPtr<Range> Document::createRange() | 1427 PassRefPtr<Range> Document::createRange() |
| 1428 { | 1428 { |
| 1429 return Range::create(*this); | 1429 return Range::create(*this); |
| 1430 } | 1430 } |
| 1431 | 1431 |
| 1432 PassRefPtr<NodeIterator> Document::createNodeIterator(Node* root, ExceptionState
& es) | 1432 PassRefPtr<NodeIterator> Document::createNodeIterator(Node* root, ExceptionState
& exceptionState) |
| 1433 { | 1433 { |
| 1434 // FIXME: Probably this should be handled within the bindings layer and Type
Error should be thrown. | 1434 // FIXME: Probably this should be handled within the bindings layer and Type
Error should be thrown. |
| 1435 if (!root) { | 1435 if (!root) { |
| 1436 es.throwUninformativeAndGenericDOMException(NotSupportedError); | 1436 exceptionState.throwUninformativeAndGenericDOMException(NotSupportedErro
r); |
| 1437 return 0; | 1437 return 0; |
| 1438 } | 1438 } |
| 1439 return NodeIterator::create(root, NodeFilter::SHOW_ALL, PassRefPtr<NodeFilte
r>()); | 1439 return NodeIterator::create(root, NodeFilter::SHOW_ALL, PassRefPtr<NodeFilte
r>()); |
| 1440 } | 1440 } |
| 1441 | 1441 |
| 1442 PassRefPtr<NodeIterator> Document::createNodeIterator(Node* root, unsigned whatT
oShow, ExceptionState& es) | 1442 PassRefPtr<NodeIterator> Document::createNodeIterator(Node* root, unsigned whatT
oShow, ExceptionState& exceptionState) |
| 1443 { | 1443 { |
| 1444 if (!root) { | 1444 if (!root) { |
| 1445 es.throwUninformativeAndGenericDOMException(NotSupportedError); | 1445 exceptionState.throwUninformativeAndGenericDOMException(NotSupportedErro
r); |
| 1446 return 0; | 1446 return 0; |
| 1447 } | 1447 } |
| 1448 // FIXME: It might be a good idea to emit a warning if |whatToShow| contains
a bit that is not defined in | 1448 // FIXME: It might be a good idea to emit a warning if |whatToShow| contains
a bit that is not defined in |
| 1449 // NodeFilter. | 1449 // NodeFilter. |
| 1450 return NodeIterator::create(root, whatToShow, PassRefPtr<NodeFilter>()); | 1450 return NodeIterator::create(root, whatToShow, PassRefPtr<NodeFilter>()); |
| 1451 } | 1451 } |
| 1452 | 1452 |
| 1453 PassRefPtr<NodeIterator> Document::createNodeIterator(Node* root, unsigned whatT
oShow, PassRefPtr<NodeFilter> filter, ExceptionState& es) | 1453 PassRefPtr<NodeIterator> Document::createNodeIterator(Node* root, unsigned whatT
oShow, PassRefPtr<NodeFilter> filter, ExceptionState& exceptionState) |
| 1454 { | 1454 { |
| 1455 if (!root) { | 1455 if (!root) { |
| 1456 es.throwUninformativeAndGenericDOMException(NotSupportedError); | 1456 exceptionState.throwUninformativeAndGenericDOMException(NotSupportedErro
r); |
| 1457 return 0; | 1457 return 0; |
| 1458 } | 1458 } |
| 1459 // FIXME: Ditto. | 1459 // FIXME: Ditto. |
| 1460 return NodeIterator::create(root, whatToShow, filter); | 1460 return NodeIterator::create(root, whatToShow, filter); |
| 1461 } | 1461 } |
| 1462 | 1462 |
| 1463 PassRefPtr<NodeIterator> Document::createNodeIterator(Node* root, unsigned whatT
oShow, PassRefPtr<NodeFilter> filter, bool expandEntityReferences, ExceptionStat
e& es) | 1463 PassRefPtr<NodeIterator> Document::createNodeIterator(Node* root, unsigned whatT
oShow, PassRefPtr<NodeFilter> filter, bool expandEntityReferences, ExceptionStat
e& exceptionState) |
| 1464 { | 1464 { |
| 1465 if (!root) { | 1465 if (!root) { |
| 1466 es.throwUninformativeAndGenericDOMException(NotSupportedError); | 1466 exceptionState.throwUninformativeAndGenericDOMException(NotSupportedErro
r); |
| 1467 return 0; | 1467 return 0; |
| 1468 } | 1468 } |
| 1469 // FIXME: Warn if |expandEntityReferences| is specified. This optional argum
ent is deprecated in DOM4. | 1469 // FIXME: Warn if |expandEntityReferences| is specified. This optional argum
ent is deprecated in DOM4. |
| 1470 UNUSED_PARAM(expandEntityReferences); | 1470 UNUSED_PARAM(expandEntityReferences); |
| 1471 return NodeIterator::create(root, whatToShow, filter); | 1471 return NodeIterator::create(root, whatToShow, filter); |
| 1472 } | 1472 } |
| 1473 | 1473 |
| 1474 PassRefPtr<TreeWalker> Document::createTreeWalker(Node* root, ExceptionState& es
) | 1474 PassRefPtr<TreeWalker> Document::createTreeWalker(Node* root, ExceptionState& ex
ceptionState) |
| 1475 { | 1475 { |
| 1476 if (!root) { | 1476 if (!root) { |
| 1477 es.throwUninformativeAndGenericDOMException(NotSupportedError); | 1477 exceptionState.throwUninformativeAndGenericDOMException(NotSupportedErro
r); |
| 1478 return 0; | 1478 return 0; |
| 1479 } | 1479 } |
| 1480 return TreeWalker::create(root, NodeFilter::SHOW_ALL, PassRefPtr<NodeFilter>
()); | 1480 return TreeWalker::create(root, NodeFilter::SHOW_ALL, PassRefPtr<NodeFilter>
()); |
| 1481 } | 1481 } |
| 1482 | 1482 |
| 1483 PassRefPtr<TreeWalker> Document::createTreeWalker(Node* root, unsigned whatToSho
w, ExceptionState& es) | 1483 PassRefPtr<TreeWalker> Document::createTreeWalker(Node* root, unsigned whatToSho
w, ExceptionState& exceptionState) |
| 1484 { | 1484 { |
| 1485 if (!root) { | 1485 if (!root) { |
| 1486 es.throwUninformativeAndGenericDOMException(NotSupportedError); | 1486 exceptionState.throwUninformativeAndGenericDOMException(NotSupportedErro
r); |
| 1487 return 0; | 1487 return 0; |
| 1488 } | 1488 } |
| 1489 return TreeWalker::create(root, whatToShow, PassRefPtr<NodeFilter>()); | 1489 return TreeWalker::create(root, whatToShow, PassRefPtr<NodeFilter>()); |
| 1490 } | 1490 } |
| 1491 | 1491 |
| 1492 PassRefPtr<TreeWalker> Document::createTreeWalker(Node* root, unsigned whatToSho
w, PassRefPtr<NodeFilter> filter, ExceptionState& es) | 1492 PassRefPtr<TreeWalker> Document::createTreeWalker(Node* root, unsigned whatToSho
w, PassRefPtr<NodeFilter> filter, ExceptionState& exceptionState) |
| 1493 { | 1493 { |
| 1494 if (!root) { | 1494 if (!root) { |
| 1495 es.throwUninformativeAndGenericDOMException(NotSupportedError); | 1495 exceptionState.throwUninformativeAndGenericDOMException(NotSupportedErro
r); |
| 1496 return 0; | 1496 return 0; |
| 1497 } | 1497 } |
| 1498 return TreeWalker::create(root, whatToShow, filter); | 1498 return TreeWalker::create(root, whatToShow, filter); |
| 1499 } | 1499 } |
| 1500 | 1500 |
| 1501 PassRefPtr<TreeWalker> Document::createTreeWalker(Node* root, unsigned whatToSho
w, PassRefPtr<NodeFilter> filter, bool expandEntityReferences, ExceptionState& e
s) | 1501 PassRefPtr<TreeWalker> Document::createTreeWalker(Node* root, unsigned whatToSho
w, PassRefPtr<NodeFilter> filter, bool expandEntityReferences, ExceptionState& e
xceptionState) |
| 1502 { | 1502 { |
| 1503 UNUSED_PARAM(expandEntityReferences); | 1503 UNUSED_PARAM(expandEntityReferences); |
| 1504 if (!root) { | 1504 if (!root) { |
| 1505 es.throwUninformativeAndGenericDOMException(NotSupportedError); | 1505 exceptionState.throwUninformativeAndGenericDOMException(NotSupportedErro
r); |
| 1506 return 0; | 1506 return 0; |
| 1507 } | 1507 } |
| 1508 return TreeWalker::create(root, whatToShow, filter); | 1508 return TreeWalker::create(root, whatToShow, filter); |
| 1509 } | 1509 } |
| 1510 | 1510 |
| 1511 void Document::serviceAnimations(double monotonicAnimationStartTime) | 1511 void Document::serviceAnimations(double monotonicAnimationStartTime) |
| 1512 { | 1512 { |
| 1513 if (!RuntimeEnabledFeatures::webAnimationsEnabled()) | 1513 if (!RuntimeEnabledFeatures::webAnimationsEnabled()) |
| 1514 return; | 1514 return; |
| 1515 | 1515 |
| (...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2245 return 0; | 2245 return 0; |
| 2246 | 2246 |
| 2247 for (Node* child = documentElement()->firstChild(); child; child = child->ne
xtSibling()) { | 2247 for (Node* child = documentElement()->firstChild(); child; child = child->ne
xtSibling()) { |
| 2248 if (child->hasTagName(framesetTag) || child->hasTagName(bodyTag)) | 2248 if (child->hasTagName(framesetTag) || child->hasTagName(bodyTag)) |
| 2249 return toHTMLElement(child); | 2249 return toHTMLElement(child); |
| 2250 } | 2250 } |
| 2251 | 2251 |
| 2252 return 0; | 2252 return 0; |
| 2253 } | 2253 } |
| 2254 | 2254 |
| 2255 void Document::setBody(PassRefPtr<HTMLElement> prpNewBody, ExceptionState& es) | 2255 void Document::setBody(PassRefPtr<HTMLElement> prpNewBody, ExceptionState& excep
tionState) |
| 2256 { | 2256 { |
| 2257 RefPtr<HTMLElement> newBody = prpNewBody; | 2257 RefPtr<HTMLElement> newBody = prpNewBody; |
| 2258 | 2258 |
| 2259 if (!newBody || !documentElement()) { | 2259 if (!newBody || !documentElement()) { |
| 2260 es.throwUninformativeAndGenericDOMException(HierarchyRequestError); | 2260 exceptionState.throwUninformativeAndGenericDOMException(HierarchyRequest
Error); |
| 2261 return; | 2261 return; |
| 2262 } | 2262 } |
| 2263 | 2263 |
| 2264 if (!newBody->hasTagName(bodyTag) && !newBody->hasTagName(framesetTag)) { | 2264 if (!newBody->hasTagName(bodyTag) && !newBody->hasTagName(framesetTag)) { |
| 2265 es.throwUninformativeAndGenericDOMException(HierarchyRequestError); | 2265 exceptionState.throwUninformativeAndGenericDOMException(HierarchyRequest
Error); |
| 2266 return; | 2266 return; |
| 2267 } | 2267 } |
| 2268 | 2268 |
| 2269 HTMLElement* oldBody = body(); | 2269 HTMLElement* oldBody = body(); |
| 2270 if (oldBody == newBody) | 2270 if (oldBody == newBody) |
| 2271 return; | 2271 return; |
| 2272 | 2272 |
| 2273 if (oldBody) | 2273 if (oldBody) |
| 2274 documentElement()->replaceChild(newBody.release(), oldBody, es); | 2274 documentElement()->replaceChild(newBody.release(), oldBody, exceptionSta
te); |
| 2275 else | 2275 else |
| 2276 documentElement()->appendChild(newBody.release(), es); | 2276 documentElement()->appendChild(newBody.release(), exceptionState); |
| 2277 } | 2277 } |
| 2278 | 2278 |
| 2279 HTMLHeadElement* Document::head() | 2279 HTMLHeadElement* Document::head() |
| 2280 { | 2280 { |
| 2281 Node* de = documentElement(); | 2281 Node* de = documentElement(); |
| 2282 if (!de) | 2282 if (!de) |
| 2283 return 0; | 2283 return 0; |
| 2284 | 2284 |
| 2285 for (Node* node = de->firstChild(); node; node = node->nextSibling()) { | 2285 for (Node* node = de->firstChild(); node; node = node->nextSibling()) { |
| 2286 if (node->hasTagName(headTag)) | 2286 if (node->hasTagName(headTag)) |
| (...skipping 1348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3635 } | 3635 } |
| 3636 | 3636 |
| 3637 void Document::enqueueScrollEventForNode(Node* target) | 3637 void Document::enqueueScrollEventForNode(Node* target) |
| 3638 { | 3638 { |
| 3639 // Per the W3C CSSOM View Module only scroll events fired at the document sh
ould bubble. | 3639 // Per the W3C CSSOM View Module only scroll events fired at the document sh
ould bubble. |
| 3640 RefPtr<Event> scrollEvent = target->isDocumentNode() ? Event::createBubble(E
ventTypeNames::scroll) : Event::create(EventTypeNames::scroll); | 3640 RefPtr<Event> scrollEvent = target->isDocumentNode() ? Event::createBubble(E
ventTypeNames::scroll) : Event::create(EventTypeNames::scroll); |
| 3641 scrollEvent->setTarget(target); | 3641 scrollEvent->setTarget(target); |
| 3642 scheduleAnimationFrameEvent(scrollEvent.release()); | 3642 scheduleAnimationFrameEvent(scrollEvent.release()); |
| 3643 } | 3643 } |
| 3644 | 3644 |
| 3645 PassRefPtr<Event> Document::createEvent(const String& eventType, ExceptionState&
es) | 3645 PassRefPtr<Event> Document::createEvent(const String& eventType, ExceptionState&
exceptionState) |
| 3646 { | 3646 { |
| 3647 RefPtr<Event> event = EventFactory::create(eventType); | 3647 RefPtr<Event> event = EventFactory::create(eventType); |
| 3648 if (event) | 3648 if (event) |
| 3649 return event.release(); | 3649 return event.release(); |
| 3650 | 3650 |
| 3651 es.throwUninformativeAndGenericDOMException(NotSupportedError); | 3651 exceptionState.throwUninformativeAndGenericDOMException(NotSupportedError); |
| 3652 return 0; | 3652 return 0; |
| 3653 } | 3653 } |
| 3654 | 3654 |
| 3655 void Document::addMutationEventListenerTypeIfEnabled(ListenerType listenerType) | 3655 void Document::addMutationEventListenerTypeIfEnabled(ListenerType listenerType) |
| 3656 { | 3656 { |
| 3657 if (ContextFeatures::mutationEventsEnabled(this)) | 3657 if (ContextFeatures::mutationEventsEnabled(this)) |
| 3658 addListenerType(listenerType); | 3658 addListenerType(listenerType); |
| 3659 } | 3659 } |
| 3660 | 3660 |
| 3661 void Document::addListenerTypeIfNeeded(const AtomicString& eventType) | 3661 void Document::addListenerTypeIfNeeded(const AtomicString& eventType) |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3705 return 0; | 3705 return 0; |
| 3706 } | 3706 } |
| 3707 | 3707 |
| 3708 HTMLFrameOwnerElement* Document::ownerElement() const | 3708 HTMLFrameOwnerElement* Document::ownerElement() const |
| 3709 { | 3709 { |
| 3710 if (!frame()) | 3710 if (!frame()) |
| 3711 return 0; | 3711 return 0; |
| 3712 return frame()->ownerElement(); | 3712 return frame()->ownerElement(); |
| 3713 } | 3713 } |
| 3714 | 3714 |
| 3715 String Document::cookie(ExceptionState& es) const | 3715 String Document::cookie(ExceptionState& exceptionState) const |
| 3716 { | 3716 { |
| 3717 if (settings() && !settings()->cookieEnabled()) | 3717 if (settings() && !settings()->cookieEnabled()) |
| 3718 return String(); | 3718 return String(); |
| 3719 | 3719 |
| 3720 // FIXME: The HTML5 DOM spec states that this attribute can raise an | 3720 // FIXME: The HTML5 DOM spec states that this attribute can raise an |
| 3721 // InvalidStateError exception on getting if the Document has no | 3721 // InvalidStateError exception on getting if the Document has no |
| 3722 // browsing context. | 3722 // browsing context. |
| 3723 | 3723 |
| 3724 if (!securityOrigin()->canAccessCookies()) { | 3724 if (!securityOrigin()->canAccessCookies()) { |
| 3725 String accessDeniedMessage = "Access to 'cookie' is denied for this docu
ment."; | 3725 String accessDeniedMessage = "Access to 'cookie' is denied for this docu
ment."; |
| 3726 if (isSandboxed(SandboxOrigin)) | 3726 if (isSandboxed(SandboxOrigin)) |
| 3727 es.throwSecurityError(accessDeniedMessage + " The document is sandbo
xed and lacks the 'allow-same-origin' flag."); | 3727 exceptionState.throwSecurityError(accessDeniedMessage + " The docume
nt is sandboxed and lacks the 'allow-same-origin' flag."); |
| 3728 else if (url().protocolIs("data")) | 3728 else if (url().protocolIs("data")) |
| 3729 es.throwSecurityError(accessDeniedMessage + " Cookies are disabled i
nside 'data:' URLs."); | 3729 exceptionState.throwSecurityError(accessDeniedMessage + " Cookies ar
e disabled inside 'data:' URLs."); |
| 3730 else | 3730 else |
| 3731 es.throwSecurityError(accessDeniedMessage); | 3731 exceptionState.throwSecurityError(accessDeniedMessage); |
| 3732 return String(); | 3732 return String(); |
| 3733 } | 3733 } |
| 3734 | 3734 |
| 3735 KURL cookieURL = this->cookieURL(); | 3735 KURL cookieURL = this->cookieURL(); |
| 3736 if (cookieURL.isEmpty()) | 3736 if (cookieURL.isEmpty()) |
| 3737 return String(); | 3737 return String(); |
| 3738 | 3738 |
| 3739 return cookies(this, cookieURL); | 3739 return cookies(this, cookieURL); |
| 3740 } | 3740 } |
| 3741 | 3741 |
| 3742 void Document::setCookie(const String& value, ExceptionState& es) | 3742 void Document::setCookie(const String& value, ExceptionState& exceptionState) |
| 3743 { | 3743 { |
| 3744 if (settings() && !settings()->cookieEnabled()) | 3744 if (settings() && !settings()->cookieEnabled()) |
| 3745 return; | 3745 return; |
| 3746 | 3746 |
| 3747 // FIXME: The HTML5 DOM spec states that this attribute can raise an | 3747 // FIXME: The HTML5 DOM spec states that this attribute can raise an |
| 3748 // InvalidStateError exception on setting if the Document has no | 3748 // InvalidStateError exception on setting if the Document has no |
| 3749 // browsing context. | 3749 // browsing context. |
| 3750 | 3750 |
| 3751 if (!securityOrigin()->canAccessCookies()) { | 3751 if (!securityOrigin()->canAccessCookies()) { |
| 3752 String accessDeniedMessage = "Access to 'cookie' is denied for this docu
ment."; | 3752 String accessDeniedMessage = "Access to 'cookie' is denied for this docu
ment."; |
| 3753 if (isSandboxed(SandboxOrigin)) | 3753 if (isSandboxed(SandboxOrigin)) |
| 3754 es.throwSecurityError(accessDeniedMessage + " The document is sandbo
xed and lacks the 'allow-same-origin' flag."); | 3754 exceptionState.throwSecurityError(accessDeniedMessage + " The docume
nt is sandboxed and lacks the 'allow-same-origin' flag."); |
| 3755 else if (url().protocolIs("data")) | 3755 else if (url().protocolIs("data")) |
| 3756 es.throwSecurityError(accessDeniedMessage + " Cookies are disabled i
nside 'data:' URLs."); | 3756 exceptionState.throwSecurityError(accessDeniedMessage + " Cookies ar
e disabled inside 'data:' URLs."); |
| 3757 else | 3757 else |
| 3758 es.throwSecurityError(accessDeniedMessage); | 3758 exceptionState.throwSecurityError(accessDeniedMessage); |
| 3759 return; | 3759 return; |
| 3760 } | 3760 } |
| 3761 | 3761 |
| 3762 KURL cookieURL = this->cookieURL(); | 3762 KURL cookieURL = this->cookieURL(); |
| 3763 if (cookieURL.isEmpty()) | 3763 if (cookieURL.isEmpty()) |
| 3764 return; | 3764 return; |
| 3765 | 3765 |
| 3766 setCookies(this, cookieURL, value); | 3766 setCookies(this, cookieURL, value); |
| 3767 } | 3767 } |
| 3768 | 3768 |
| 3769 String Document::referrer() const | 3769 String Document::referrer() const |
| 3770 { | 3770 { |
| 3771 if (loader()) | 3771 if (loader()) |
| 3772 return loader()->request().httpReferrer(); | 3772 return loader()->request().httpReferrer(); |
| 3773 return String(); | 3773 return String(); |
| 3774 } | 3774 } |
| 3775 | 3775 |
| 3776 String Document::domain() const | 3776 String Document::domain() const |
| 3777 { | 3777 { |
| 3778 return securityOrigin()->domain(); | 3778 return securityOrigin()->domain(); |
| 3779 } | 3779 } |
| 3780 | 3780 |
| 3781 void Document::setDomain(const String& newDomain, ExceptionState& es) | 3781 void Document::setDomain(const String& newDomain, ExceptionState& exceptionState
) |
| 3782 { | 3782 { |
| 3783 if (SchemeRegistry::isDomainRelaxationForbiddenForURLScheme(securityOrigin()
->protocol())) { | 3783 if (SchemeRegistry::isDomainRelaxationForbiddenForURLScheme(securityOrigin()
->protocol())) { |
| 3784 es.throwSecurityError(ExceptionMessages::failedToSet("domain", "Document
", "assignment is forbidden for the '" + securityOrigin()->protocol() + "' schem
e.")); | 3784 exceptionState.throwSecurityError(ExceptionMessages::failedToSet("domain
", "Document", "assignment is forbidden for the '" + securityOrigin()->protocol(
) + "' scheme.")); |
| 3785 return; | 3785 return; |
| 3786 } | 3786 } |
| 3787 | 3787 |
| 3788 String exceptionMessage = ExceptionMessages::failedToSet("domain", "Document
", "'" + newDomain + "' is not a suffix of '" + domain() + "'."); | 3788 String exceptionMessage = ExceptionMessages::failedToSet("domain", "Document
", "'" + newDomain + "' is not a suffix of '" + domain() + "'."); |
| 3789 if (newDomain.isEmpty()) { | 3789 if (newDomain.isEmpty()) { |
| 3790 es.throwSecurityError(exceptionMessage); | 3790 exceptionState.throwSecurityError(exceptionMessage); |
| 3791 return; | 3791 return; |
| 3792 } | 3792 } |
| 3793 | 3793 |
| 3794 OriginAccessEntry::IPAddressSetting ipAddressSetting = settings() && setting
s()->treatIPAddressAsDomain() ? OriginAccessEntry::TreatIPAddressAsDomain : Orig
inAccessEntry::TreatIPAddressAsIPAddress; | 3794 OriginAccessEntry::IPAddressSetting ipAddressSetting = settings() && setting
s()->treatIPAddressAsDomain() ? OriginAccessEntry::TreatIPAddressAsDomain : Orig
inAccessEntry::TreatIPAddressAsIPAddress; |
| 3795 OriginAccessEntry accessEntry(securityOrigin()->protocol(), newDomain, Origi
nAccessEntry::AllowSubdomains, ipAddressSetting); | 3795 OriginAccessEntry accessEntry(securityOrigin()->protocol(), newDomain, Origi
nAccessEntry::AllowSubdomains, ipAddressSetting); |
| 3796 if (!accessEntry.matchesOrigin(*securityOrigin())) { | 3796 if (!accessEntry.matchesOrigin(*securityOrigin())) { |
| 3797 es.throwSecurityError(exceptionMessage); | 3797 exceptionState.throwSecurityError(exceptionMessage); |
| 3798 return; | 3798 return; |
| 3799 } | 3799 } |
| 3800 | 3800 |
| 3801 securityOrigin()->setDomainFromDOM(newDomain); | 3801 securityOrigin()->setDomainFromDOM(newDomain); |
| 3802 if (m_frame) | 3802 if (m_frame) |
| 3803 m_frame->script().updateSecurityOrigin(); | 3803 m_frame->script().updateSecurityOrigin(); |
| 3804 } | 3804 } |
| 3805 | 3805 |
| 3806 // http://www.whatwg.org/specs/web-apps/current-work/#dom-document-lastmodified | 3806 // http://www.whatwg.org/specs/web-apps/current-work/#dom-document-lastmodified |
| 3807 String Document::lastModified() const | 3807 String Document::lastModified() const |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3894 | 3894 |
| 3895 const UChar* characters = name.characters16(); | 3895 const UChar* characters = name.characters16(); |
| 3896 | 3896 |
| 3897 if (isValidNameASCII(characters, length)) | 3897 if (isValidNameASCII(characters, length)) |
| 3898 return true; | 3898 return true; |
| 3899 | 3899 |
| 3900 return isValidNameNonASCII(characters, length); | 3900 return isValidNameNonASCII(characters, length); |
| 3901 } | 3901 } |
| 3902 | 3902 |
| 3903 template<typename CharType> | 3903 template<typename CharType> |
| 3904 static bool parseQualifiedNameInternal(const String& qualifiedName, const CharTy
pe* characters, unsigned length, String& prefix, String& localName, ExceptionSta
te& es) | 3904 static bool parseQualifiedNameInternal(const String& qualifiedName, const CharTy
pe* characters, unsigned length, String& prefix, String& localName, ExceptionSta
te& exceptionState) |
| 3905 { | 3905 { |
| 3906 bool nameStart = true; | 3906 bool nameStart = true; |
| 3907 bool sawColon = false; | 3907 bool sawColon = false; |
| 3908 int colonPos = 0; | 3908 int colonPos = 0; |
| 3909 | 3909 |
| 3910 for (unsigned i = 0; i < length;) { | 3910 for (unsigned i = 0; i < length;) { |
| 3911 UChar32 c; | 3911 UChar32 c; |
| 3912 U16_NEXT(characters, i, length, c) | 3912 U16_NEXT(characters, i, length, c) |
| 3913 if (c == ':') { | 3913 if (c == ':') { |
| 3914 if (sawColon) { | 3914 if (sawColon) { |
| 3915 es.throwUninformativeAndGenericDOMException(NamespaceError); | 3915 exceptionState.throwUninformativeAndGenericDOMException(Namespac
eError); |
| 3916 return false; // multiple colons: not allowed | 3916 return false; // multiple colons: not allowed |
| 3917 } | 3917 } |
| 3918 nameStart = true; | 3918 nameStart = true; |
| 3919 sawColon = true; | 3919 sawColon = true; |
| 3920 colonPos = i - 1; | 3920 colonPos = i - 1; |
| 3921 } else if (nameStart) { | 3921 } else if (nameStart) { |
| 3922 if (!isValidNameStart(c)) { | 3922 if (!isValidNameStart(c)) { |
| 3923 es.throwUninformativeAndGenericDOMException(InvalidCharacterErro
r); | 3923 exceptionState.throwUninformativeAndGenericDOMException(InvalidC
haracterError); |
| 3924 return false; | 3924 return false; |
| 3925 } | 3925 } |
| 3926 nameStart = false; | 3926 nameStart = false; |
| 3927 } else { | 3927 } else { |
| 3928 if (!isValidNamePart(c)) { | 3928 if (!isValidNamePart(c)) { |
| 3929 es.throwUninformativeAndGenericDOMException(InvalidCharacterErro
r); | 3929 exceptionState.throwUninformativeAndGenericDOMException(InvalidC
haracterError); |
| 3930 return false; | 3930 return false; |
| 3931 } | 3931 } |
| 3932 } | 3932 } |
| 3933 } | 3933 } |
| 3934 | 3934 |
| 3935 if (!sawColon) { | 3935 if (!sawColon) { |
| 3936 prefix = String(); | 3936 prefix = String(); |
| 3937 localName = qualifiedName; | 3937 localName = qualifiedName; |
| 3938 } else { | 3938 } else { |
| 3939 prefix = qualifiedName.substring(0, colonPos); | 3939 prefix = qualifiedName.substring(0, colonPos); |
| 3940 if (prefix.isEmpty()) { | 3940 if (prefix.isEmpty()) { |
| 3941 es.throwUninformativeAndGenericDOMException(NamespaceError); | 3941 exceptionState.throwUninformativeAndGenericDOMException(NamespaceErr
or); |
| 3942 return false; | 3942 return false; |
| 3943 } | 3943 } |
| 3944 localName = qualifiedName.substring(colonPos + 1); | 3944 localName = qualifiedName.substring(colonPos + 1); |
| 3945 } | 3945 } |
| 3946 | 3946 |
| 3947 if (localName.isEmpty()) { | 3947 if (localName.isEmpty()) { |
| 3948 es.throwUninformativeAndGenericDOMException(NamespaceError); | 3948 exceptionState.throwUninformativeAndGenericDOMException(NamespaceError); |
| 3949 return false; | 3949 return false; |
| 3950 } | 3950 } |
| 3951 | 3951 |
| 3952 return true; | 3952 return true; |
| 3953 } | 3953 } |
| 3954 | 3954 |
| 3955 bool Document::parseQualifiedName(const String& qualifiedName, String& prefix, S
tring& localName, ExceptionState& es) | 3955 bool Document::parseQualifiedName(const String& qualifiedName, String& prefix, S
tring& localName, ExceptionState& exceptionState) |
| 3956 { | 3956 { |
| 3957 unsigned length = qualifiedName.length(); | 3957 unsigned length = qualifiedName.length(); |
| 3958 | 3958 |
| 3959 if (!length) { | 3959 if (!length) { |
| 3960 es.throwUninformativeAndGenericDOMException(InvalidCharacterError); | 3960 exceptionState.throwUninformativeAndGenericDOMException(InvalidCharacter
Error); |
| 3961 return false; | 3961 return false; |
| 3962 } | 3962 } |
| 3963 | 3963 |
| 3964 if (qualifiedName.is8Bit()) | 3964 if (qualifiedName.is8Bit()) |
| 3965 return parseQualifiedNameInternal(qualifiedName, qualifiedName.character
s8(), length, prefix, localName, es); | 3965 return parseQualifiedNameInternal(qualifiedName, qualifiedName.character
s8(), length, prefix, localName, exceptionState); |
| 3966 return parseQualifiedNameInternal(qualifiedName, qualifiedName.characters16(
), length, prefix, localName, es); | 3966 return parseQualifiedNameInternal(qualifiedName, qualifiedName.characters16(
), length, prefix, localName, exceptionState); |
| 3967 } | 3967 } |
| 3968 | 3968 |
| 3969 void Document::setEncodingData(const DocumentEncodingData& newData) | 3969 void Document::setEncodingData(const DocumentEncodingData& newData) |
| 3970 { | 3970 { |
| 3971 // It's possible for the encoding of the document to change while we're deco
ding | 3971 // It's possible for the encoding of the document to change while we're deco
ding |
| 3972 // data. That can only occur while we're processing the <head> portion of th
e | 3972 // data. That can only occur while we're processing the <head> portion of th
e |
| 3973 // document. There isn't much user-visible content in the <head>, but there
is | 3973 // document. There isn't much user-visible content in the <head>, but there
is |
| 3974 // the <title> element. This function detects that situation and re-decodes
the | 3974 // the <title> element. This function detects that situation and re-decodes
the |
| 3975 // document's title so that the user doesn't see an incorrectly decoded titl
e | 3975 // document's title so that the user doesn't see an incorrectly decoded titl
e |
| 3976 // in the title bar. | 3976 // in the title bar. |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4157 | 4157 |
| 4158 WeakPtr<Document> Document::contextDocument() | 4158 WeakPtr<Document> Document::contextDocument() |
| 4159 { | 4159 { |
| 4160 if (m_contextDocument) | 4160 if (m_contextDocument) |
| 4161 return m_contextDocument; | 4161 return m_contextDocument; |
| 4162 if (m_frame) | 4162 if (m_frame) |
| 4163 return m_weakFactory.createWeakPtr(); | 4163 return m_weakFactory.createWeakPtr(); |
| 4164 return WeakPtr<Document>(0); | 4164 return WeakPtr<Document>(0); |
| 4165 } | 4165 } |
| 4166 | 4166 |
| 4167 PassRefPtr<Attr> Document::createAttribute(const String& name, ExceptionState& e
s) | 4167 PassRefPtr<Attr> Document::createAttribute(const String& name, ExceptionState& e
xceptionState) |
| 4168 { | 4168 { |
| 4169 return createAttributeNS(String(), name, es, true); | 4169 return createAttributeNS(String(), name, exceptionState, true); |
| 4170 } | 4170 } |
| 4171 | 4171 |
| 4172 PassRefPtr<Attr> Document::createAttributeNS(const String& namespaceURI, const S
tring& qualifiedName, ExceptionState& es, bool shouldIgnoreNamespaceChecks) | 4172 PassRefPtr<Attr> Document::createAttributeNS(const String& namespaceURI, const S
tring& qualifiedName, ExceptionState& exceptionState, bool shouldIgnoreNamespace
Checks) |
| 4173 { | 4173 { |
| 4174 String prefix, localName; | 4174 String prefix, localName; |
| 4175 if (!parseQualifiedName(qualifiedName, prefix, localName, es)) | 4175 if (!parseQualifiedName(qualifiedName, prefix, localName, exceptionState)) |
| 4176 return 0; | 4176 return 0; |
| 4177 | 4177 |
| 4178 QualifiedName qName(prefix, localName, namespaceURI); | 4178 QualifiedName qName(prefix, localName, namespaceURI); |
| 4179 | 4179 |
| 4180 if (!shouldIgnoreNamespaceChecks && !hasValidNamespaceForAttributes(qName))
{ | 4180 if (!shouldIgnoreNamespaceChecks && !hasValidNamespaceForAttributes(qName))
{ |
| 4181 es.throwUninformativeAndGenericDOMException(NamespaceError); | 4181 exceptionState.throwUninformativeAndGenericDOMException(NamespaceError); |
| 4182 return 0; | 4182 return 0; |
| 4183 } | 4183 } |
| 4184 | 4184 |
| 4185 return Attr::create(*this, qName, emptyString()); | 4185 return Attr::create(*this, qName, emptyString()); |
| 4186 } | 4186 } |
| 4187 | 4187 |
| 4188 const SVGDocumentExtensions* Document::svgExtensions() | 4188 const SVGDocumentExtensions* Document::svgExtensions() |
| 4189 { | 4189 { |
| 4190 return m_svgExtensions.get(); | 4190 return m_svgExtensions.get(); |
| 4191 } | 4191 } |
| (...skipping 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5209 void Document::modifiedStyleSheet(StyleSheet* sheet, RecalcStyleTime when, Style
ResolverUpdateMode updateMode) | 5209 void Document::modifiedStyleSheet(StyleSheet* sheet, RecalcStyleTime when, Style
ResolverUpdateMode updateMode) |
| 5210 { | 5210 { |
| 5211 if (!isActive()) | 5211 if (!isActive()) |
| 5212 return; | 5212 return; |
| 5213 | 5213 |
| 5214 styleEngine()->modifiedStyleSheet(sheet); | 5214 styleEngine()->modifiedStyleSheet(sheet); |
| 5215 styleResolverChanged(when, updateMode); | 5215 styleResolverChanged(when, updateMode); |
| 5216 } | 5216 } |
| 5217 | 5217 |
| 5218 } // namespace WebCore | 5218 } // namespace WebCore |
| OLD | NEW |