Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: Source/core/dom/Document.cpp

Issue 24469004: Amusingly deprecate the generic version of 'ExceptionState::throwDOMException'. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/DOMTokenList.cpp ('k') | Source/core/dom/Element.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 if (newDocumentElement == m_documentElement) 683 if (newDocumentElement == m_documentElement)
684 return; 684 return;
685 m_documentElement = newDocumentElement; 685 m_documentElement = newDocumentElement;
686 // The root style used for media query matching depends on the document elem ent. 686 // The root style used for media query matching depends on the document elem ent.
687 clearStyleResolver(); 687 clearStyleResolver();
688 } 688 }
689 689
690 PassRefPtr<Element> Document::createElement(const AtomicString& name, ExceptionS tate& es) 690 PassRefPtr<Element> Document::createElement(const AtomicString& name, ExceptionS tate& es)
691 { 691 {
692 if (!isValidName(name)) { 692 if (!isValidName(name)) {
693 es.throwDOMException(InvalidCharacterError); 693 es.throwUninformativeAndGenericDOMException(InvalidCharacterError);
694 return 0; 694 return 0;
695 } 695 }
696 696
697 if (isXHTMLDocument() || isHTMLDocument()) 697 if (isXHTMLDocument() || isHTMLDocument())
698 return HTMLElementFactory::createHTMLElement(QualifiedName(nullAtom, isH TMLDocument() ? name.lower() : name, xhtmlNamespaceURI), this, 0, false); 698 return HTMLElementFactory::createHTMLElement(QualifiedName(nullAtom, isH TMLDocument() ? name.lower() : name, xhtmlNamespaceURI), this, 0, false);
699 699
700 return createElement(QualifiedName(nullAtom, name, nullAtom), false); 700 return createElement(QualifiedName(nullAtom, name, nullAtom), false);
701 } 701 }
702 702
703 PassRefPtr<Element> Document::createElement(const AtomicString& localName, const AtomicString& typeExtension, ExceptionState& es) 703 PassRefPtr<Element> Document::createElement(const AtomicString& localName, const AtomicString& typeExtension, ExceptionState& es)
704 { 704 {
705 if (!isValidName(localName)) { 705 if (!isValidName(localName)) {
706 es.throwDOMException(InvalidCharacterError); 706 es.throwUninformativeAndGenericDOMException(InvalidCharacterError);
707 return 0; 707 return 0;
708 } 708 }
709 709
710 RefPtr<Element> element; 710 RefPtr<Element> element;
711 711
712 if (CustomElement::isValidName(localName) && registrationContext()) 712 if (CustomElement::isValidName(localName) && registrationContext())
713 element = registrationContext()->createCustomTagElement(*this, Qualified Name(nullAtom, localName, xhtmlNamespaceURI)); 713 element = registrationContext()->createCustomTagElement(*this, Qualified Name(nullAtom, localName, xhtmlNamespaceURI));
714 else 714 else
715 element = createElement(localName, es); 715 element = createElement(localName, es);
716 716
717 if (!typeExtension.isNull() && !typeExtension.isEmpty()) 717 if (!typeExtension.isNull() && !typeExtension.isEmpty())
718 CustomElementRegistrationContext::setIsAttributeAndTypeExtension(element .get(), typeExtension); 718 CustomElementRegistrationContext::setIsAttributeAndTypeExtension(element .get(), typeExtension);
719 719
720 return element; 720 return element;
721 } 721 }
722 722
723 PassRefPtr<Element> Document::createElementNS(const AtomicString& namespaceURI, const String& qualifiedName, const AtomicString& typeExtension, ExceptionState& es) 723 PassRefPtr<Element> Document::createElementNS(const AtomicString& namespaceURI, const String& qualifiedName, const AtomicString& typeExtension, ExceptionState& es)
724 { 724 {
725 String prefix, localName; 725 String prefix, localName;
726 if (!parseQualifiedName(qualifiedName, prefix, localName, es)) 726 if (!parseQualifiedName(qualifiedName, prefix, localName, es))
727 return 0; 727 return 0;
728 728
729 QualifiedName qName(prefix, localName, namespaceURI); 729 QualifiedName qName(prefix, localName, namespaceURI);
730 if (!hasValidNamespaceForElements(qName)) { 730 if (!hasValidNamespaceForElements(qName)) {
731 es.throwDOMException(NamespaceError); 731 es.throwUninformativeAndGenericDOMException(NamespaceError);
732 return 0; 732 return 0;
733 } 733 }
734 734
735 RefPtr<Element> element; 735 RefPtr<Element> element;
736 if (CustomElement::isValidName(qName.localName()) && registrationContext()) 736 if (CustomElement::isValidName(qName.localName()) && registrationContext())
737 element = registrationContext()->createCustomTagElement(*this, qName); 737 element = registrationContext()->createCustomTagElement(*this, qName);
738 else 738 else
739 element = createElementNS(namespaceURI, qualifiedName, es); 739 element = createElementNS(namespaceURI, qualifiedName, es);
740 740
741 if (!typeExtension.isNull() && !typeExtension.isEmpty()) 741 if (!typeExtension.isNull() && !typeExtension.isEmpty())
742 CustomElementRegistrationContext::setIsAttributeAndTypeExtension(element .get(), typeExtension); 742 CustomElementRegistrationContext::setIsAttributeAndTypeExtension(element .get(), typeExtension);
743 743
744 return element; 744 return element;
745 } 745 }
746 746
747 ScriptValue Document::registerElement(WebCore::ScriptState* state, const AtomicS tring& name, ExceptionState& es) 747 ScriptValue Document::registerElement(WebCore::ScriptState* state, const AtomicS tring& name, ExceptionState& es)
748 { 748 {
749 return registerElement(state, name, Dictionary(), es); 749 return registerElement(state, name, Dictionary(), es);
750 } 750 }
751 751
752 ScriptValue Document::registerElement(WebCore::ScriptState* state, const AtomicS tring& name, const Dictionary& options, ExceptionState& es, CustomElement::NameS et validNames) 752 ScriptValue Document::registerElement(WebCore::ScriptState* state, const AtomicS tring& name, const Dictionary& options, ExceptionState& es, CustomElement::NameS et validNames)
753 { 753 {
754 if (!registrationContext()) { 754 if (!registrationContext()) {
755 es.throwDOMException(NotSupportedError); 755 es.throwUninformativeAndGenericDOMException(NotSupportedError);
756 return ScriptValue(); 756 return ScriptValue();
757 } 757 }
758 758
759 CustomElementConstructorBuilder constructorBuilder(state, &options); 759 CustomElementConstructorBuilder constructorBuilder(state, &options);
760 registrationContext()->registerElement(this, &constructorBuilder, name, vali dNames, es); 760 registrationContext()->registerElement(this, &constructorBuilder, name, vali dNames, es);
761 return constructorBuilder.bindingsReturnValue(); 761 return constructorBuilder.bindingsReturnValue();
762 } 762 }
763 763
764 void Document::setImport(HTMLImport* import) 764 void Document::setImport(HTMLImport* import)
765 { 765 {
(...skipping 22 matching lines...) Expand all
788 } 788 }
789 789
790 PassRefPtr<Comment> Document::createComment(const String& data) 790 PassRefPtr<Comment> Document::createComment(const String& data)
791 { 791 {
792 return Comment::create(*this, data); 792 return Comment::create(*this, data);
793 } 793 }
794 794
795 PassRefPtr<CDATASection> Document::createCDATASection(const String& data, Except ionState& es) 795 PassRefPtr<CDATASection> Document::createCDATASection(const String& data, Except ionState& es)
796 { 796 {
797 if (isHTMLDocument()) { 797 if (isHTMLDocument()) {
798 es.throwDOMException(NotSupportedError); 798 es.throwUninformativeAndGenericDOMException(NotSupportedError);
799 return 0; 799 return 0;
800 } 800 }
801 if (data.find("]]>") != WTF::kNotFound) { 801 if (data.find("]]>") != WTF::kNotFound) {
802 es.throwDOMException(InvalidCharacterError, "String cannot contain ']]>' since that is the end delimiter of a CData section."); 802 es.throwDOMException(InvalidCharacterError, "String cannot contain ']]>' since that is the end delimiter of a CData section.");
803 return 0; 803 return 0;
804 } 804 }
805 return CDATASection::create(*this, data); 805 return CDATASection::create(*this, data);
806 } 806 }
807 807
808 PassRefPtr<ProcessingInstruction> Document::createProcessingInstruction(const St ring& target, const String& data, ExceptionState& es) 808 PassRefPtr<ProcessingInstruction> Document::createProcessingInstruction(const St ring& target, const String& data, ExceptionState& es)
809 { 809 {
810 if (!isValidName(target)) { 810 if (!isValidName(target)) {
811 es.throwDOMException(InvalidCharacterError); 811 es.throwUninformativeAndGenericDOMException(InvalidCharacterError);
812 return 0; 812 return 0;
813 } 813 }
814 if (isHTMLDocument()) { 814 if (isHTMLDocument()) {
815 es.throwDOMException(NotSupportedError); 815 es.throwUninformativeAndGenericDOMException(NotSupportedError);
816 return 0; 816 return 0;
817 } 817 }
818 return ProcessingInstruction::create(*this, target, data); 818 return ProcessingInstruction::create(*this, target, data);
819 } 819 }
820 820
821 PassRefPtr<Text> Document::createEditingTextNode(const String& text) 821 PassRefPtr<Text> Document::createEditingTextNode(const String& text)
822 { 822 {
823 return Text::createEditingText(*this, text); 823 return Text::createEditingText(*this, text);
824 } 824 }
825 825
826 PassRefPtr<CSSStyleDeclaration> Document::createCSSStyleDeclaration() 826 PassRefPtr<CSSStyleDeclaration> Document::createCSSStyleDeclaration()
827 { 827 {
828 return MutableStylePropertySet::create()->ensureCSSStyleDeclaration(); 828 return MutableStylePropertySet::create()->ensureCSSStyleDeclaration();
829 } 829 }
830 830
831 PassRefPtr<Node> Document::importNode(Node* importedNode, bool deep, ExceptionSt ate& es) 831 PassRefPtr<Node> Document::importNode(Node* importedNode, bool deep, ExceptionSt ate& es)
832 { 832 {
833 if (!importedNode) { 833 if (!importedNode) {
834 es.throwDOMException(NotSupportedError); 834 es.throwUninformativeAndGenericDOMException(NotSupportedError);
835 return 0; 835 return 0;
836 } 836 }
837 837
838 switch (importedNode->nodeType()) { 838 switch (importedNode->nodeType()) {
839 case TEXT_NODE: 839 case TEXT_NODE:
840 return createTextNode(importedNode->nodeValue()); 840 return createTextNode(importedNode->nodeValue());
841 case CDATA_SECTION_NODE: 841 case CDATA_SECTION_NODE:
842 return createCDATASection(importedNode->nodeValue(), es); 842 return createCDATASection(importedNode->nodeValue(), es);
843 case PROCESSING_INSTRUCTION_NODE: 843 case PROCESSING_INSTRUCTION_NODE:
844 return createProcessingInstruction(importedNode->nodeName(), importedNod e->nodeValue(), es); 844 return createProcessingInstruction(importedNode->nodeName(), importedNod e->nodeValue(), es);
845 case COMMENT_NODE: 845 case COMMENT_NODE:
846 return createComment(importedNode->nodeValue()); 846 return createComment(importedNode->nodeValue());
847 case ELEMENT_NODE: { 847 case ELEMENT_NODE: {
848 Element* oldElement = toElement(importedNode); 848 Element* oldElement = toElement(importedNode);
849 // FIXME: The following check might be unnecessary. Is it possible that 849 // FIXME: The following check might be unnecessary. Is it possible that
850 // oldElement has mismatched prefix/namespace? 850 // oldElement has mismatched prefix/namespace?
851 if (!hasValidNamespaceForElements(oldElement->tagQName())) { 851 if (!hasValidNamespaceForElements(oldElement->tagQName())) {
852 es.throwDOMException(NamespaceError); 852 es.throwUninformativeAndGenericDOMException(NamespaceError);
853 return 0; 853 return 0;
854 } 854 }
855 RefPtr<Element> newElement = createElement(oldElement->tagQName(), false ); 855 RefPtr<Element> newElement = createElement(oldElement->tagQName(), false );
856 856
857 newElement->cloneDataFromElement(*oldElement); 857 newElement->cloneDataFromElement(*oldElement);
858 858
859 if (deep) { 859 if (deep) {
860 for (Node* oldChild = oldElement->firstChild(); oldChild; oldChild = oldChild->nextSibling()) { 860 for (Node* oldChild = oldElement->firstChild(); oldChild; oldChild = oldChild->nextSibling()) {
861 RefPtr<Node> newChild = importNode(oldChild, true, es); 861 RefPtr<Node> newChild = importNode(oldChild, true, es);
862 if (es.hadException()) 862 if (es.hadException())
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 } 894 }
895 case ENTITY_NODE: 895 case ENTITY_NODE:
896 case NOTATION_NODE: 896 case NOTATION_NODE:
897 // 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. 897 // 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.
898 // Ability to add these imported nodes to a DocumentType will be conside red for addition to a future release of the DOM. 898 // Ability to add these imported nodes to a DocumentType will be conside red for addition to a future release of the DOM.
899 case DOCUMENT_NODE: 899 case DOCUMENT_NODE:
900 case DOCUMENT_TYPE_NODE: 900 case DOCUMENT_TYPE_NODE:
901 case XPATH_NAMESPACE_NODE: 901 case XPATH_NAMESPACE_NODE:
902 break; 902 break;
903 } 903 }
904 es.throwDOMException(NotSupportedError); 904 es.throwUninformativeAndGenericDOMException(NotSupportedError);
905 return 0; 905 return 0;
906 } 906 }
907 907
908 PassRefPtr<Node> Document::adoptNode(PassRefPtr<Node> source, ExceptionState& es ) 908 PassRefPtr<Node> Document::adoptNode(PassRefPtr<Node> source, ExceptionState& es )
909 { 909 {
910 if (!source) { 910 if (!source) {
911 es.throwDOMException(NotSupportedError); 911 es.throwUninformativeAndGenericDOMException(NotSupportedError);
912 return 0; 912 return 0;
913 } 913 }
914 914
915 EventQueueScope scope; 915 EventQueueScope scope;
916 916
917 switch (source->nodeType()) { 917 switch (source->nodeType()) {
918 case ENTITY_NODE: 918 case ENTITY_NODE:
919 case NOTATION_NODE: 919 case NOTATION_NODE:
920 case DOCUMENT_NODE: 920 case DOCUMENT_NODE:
921 case DOCUMENT_TYPE_NODE: 921 case DOCUMENT_TYPE_NODE:
922 case XPATH_NAMESPACE_NODE: 922 case XPATH_NAMESPACE_NODE:
923 es.throwDOMException(NotSupportedError); 923 es.throwUninformativeAndGenericDOMException(NotSupportedError);
924 return 0; 924 return 0;
925 case ATTRIBUTE_NODE: { 925 case ATTRIBUTE_NODE: {
926 Attr* attr = toAttr(source.get()); 926 Attr* attr = toAttr(source.get());
927 if (attr->ownerElement()) 927 if (attr->ownerElement())
928 attr->ownerElement()->removeAttributeNode(attr, es); 928 attr->ownerElement()->removeAttributeNode(attr, es);
929 attr->setSpecified(true); 929 attr->setSpecified(true);
930 break; 930 break;
931 } 931 }
932 default: 932 default:
933 if (source->isShadowRoot()) { 933 if (source->isShadowRoot()) {
934 // ShadowRoot cannot disconnect itself from the host node. 934 // ShadowRoot cannot disconnect itself from the host node.
935 es.throwDOMException(HierarchyRequestError); 935 es.throwUninformativeAndGenericDOMException(HierarchyRequestError);
936 return 0; 936 return 0;
937 } 937 }
938 938
939 if (source->isFrameOwnerElement()) { 939 if (source->isFrameOwnerElement()) {
940 HTMLFrameOwnerElement* frameOwnerElement = toHTMLFrameOwnerElement(s ource.get()); 940 HTMLFrameOwnerElement* frameOwnerElement = toHTMLFrameOwnerElement(s ource.get());
941 if (frame() && frame()->tree()->isDescendantOf(frameOwnerElement->co ntentFrame())) { 941 if (frame() && frame()->tree()->isDescendantOf(frameOwnerElement->co ntentFrame())) {
942 es.throwDOMException(HierarchyRequestError); 942 es.throwUninformativeAndGenericDOMException(HierarchyRequestErro r);
943 return 0; 943 return 0;
944 } 944 }
945 } 945 }
946 if (source->parentNode()) { 946 if (source->parentNode()) {
947 source->parentNode()->removeChild(source.get(), es); 947 source->parentNode()->removeChild(source.get(), es);
948 if (es.hadException()) 948 if (es.hadException())
949 return 0; 949 return 0;
950 } 950 }
951 } 951 }
952 952
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1040 } 1040 }
1041 1041
1042 PassRefPtr<Element> Document::createElementNS(const String& namespaceURI, const String& qualifiedName, ExceptionState& es) 1042 PassRefPtr<Element> Document::createElementNS(const String& namespaceURI, const String& qualifiedName, ExceptionState& es)
1043 { 1043 {
1044 String prefix, localName; 1044 String prefix, localName;
1045 if (!parseQualifiedName(qualifiedName, prefix, localName, es)) 1045 if (!parseQualifiedName(qualifiedName, prefix, localName, es))
1046 return 0; 1046 return 0;
1047 1047
1048 QualifiedName qName(prefix, localName, namespaceURI); 1048 QualifiedName qName(prefix, localName, namespaceURI);
1049 if (!hasValidNamespaceForElements(qName)) { 1049 if (!hasValidNamespaceForElements(qName)) {
1050 es.throwDOMException(NamespaceError); 1050 es.throwUninformativeAndGenericDOMException(NamespaceError);
1051 return 0; 1051 return 0;
1052 } 1052 }
1053 1053
1054 return createElement(qName, false); 1054 return createElement(qName, false);
1055 } 1055 }
1056 1056
1057 String Document::readyState() const 1057 String Document::readyState() const
1058 { 1058 {
1059 DEFINE_STATIC_LOCAL(const String, loading, ("loading")); 1059 DEFINE_STATIC_LOCAL(const String, loading, ("loading"));
1060 DEFINE_STATIC_LOCAL(const String, interactive, ("interactive")); 1060 DEFINE_STATIC_LOCAL(const String, interactive, ("interactive"));
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1129 return; 1129 return;
1130 m_contentLanguage = language; 1130 m_contentLanguage = language;
1131 1131
1132 // Document's style depends on the content language. 1132 // Document's style depends on the content language.
1133 setNeedsStyleRecalc(); 1133 setNeedsStyleRecalc();
1134 } 1134 }
1135 1135
1136 void Document::setXMLVersion(const String& version, ExceptionState& es) 1136 void Document::setXMLVersion(const String& version, ExceptionState& es)
1137 { 1137 {
1138 if (!implementation()->hasFeature("XML", String())) { 1138 if (!implementation()->hasFeature("XML", String())) {
1139 es.throwDOMException(NotSupportedError); 1139 es.throwUninformativeAndGenericDOMException(NotSupportedError);
1140 return; 1140 return;
1141 } 1141 }
1142 1142
1143 if (!XMLDocumentParser::supportsXMLVersion(version)) { 1143 if (!XMLDocumentParser::supportsXMLVersion(version)) {
1144 es.throwDOMException(NotSupportedError); 1144 es.throwUninformativeAndGenericDOMException(NotSupportedError);
1145 return; 1145 return;
1146 } 1146 }
1147 1147
1148 m_xmlVersion = version; 1148 m_xmlVersion = version;
1149 } 1149 }
1150 1150
1151 void Document::setXMLStandalone(bool standalone, ExceptionState& es) 1151 void Document::setXMLStandalone(bool standalone, ExceptionState& es)
1152 { 1152 {
1153 if (!implementation()->hasFeature("XML", String())) { 1153 if (!implementation()->hasFeature("XML", String())) {
1154 es.throwDOMException(NotSupportedError); 1154 es.throwUninformativeAndGenericDOMException(NotSupportedError);
1155 return; 1155 return;
1156 } 1156 }
1157 1157
1158 m_xmlStandalone = standalone ? Standalone : NotStandalone; 1158 m_xmlStandalone = standalone ? Standalone : NotStandalone;
1159 } 1159 }
1160 1160
1161 KURL Document::baseURI() const 1161 KURL Document::baseURI() const
1162 { 1162 {
1163 return m_baseURL; 1163 return m_baseURL;
1164 } 1164 }
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
1445 1445
1446 PassRefPtr<Range> Document::createRange() 1446 PassRefPtr<Range> Document::createRange()
1447 { 1447 {
1448 return Range::create(*this); 1448 return Range::create(*this);
1449 } 1449 }
1450 1450
1451 PassRefPtr<NodeIterator> Document::createNodeIterator(Node* root, ExceptionState & es) 1451 PassRefPtr<NodeIterator> Document::createNodeIterator(Node* root, ExceptionState & es)
1452 { 1452 {
1453 // FIXME: Probably this should be handled within the bindings layer and Type Error should be thrown. 1453 // FIXME: Probably this should be handled within the bindings layer and Type Error should be thrown.
1454 if (!root) { 1454 if (!root) {
1455 es.throwDOMException(NotSupportedError); 1455 es.throwUninformativeAndGenericDOMException(NotSupportedError);
1456 return 0; 1456 return 0;
1457 } 1457 }
1458 return NodeIterator::create(root, NodeFilter::SHOW_ALL, PassRefPtr<NodeFilte r>()); 1458 return NodeIterator::create(root, NodeFilter::SHOW_ALL, PassRefPtr<NodeFilte r>());
1459 } 1459 }
1460 1460
1461 PassRefPtr<NodeIterator> Document::createNodeIterator(Node* root, unsigned whatT oShow, ExceptionState& es) 1461 PassRefPtr<NodeIterator> Document::createNodeIterator(Node* root, unsigned whatT oShow, ExceptionState& es)
1462 { 1462 {
1463 if (!root) { 1463 if (!root) {
1464 es.throwDOMException(NotSupportedError); 1464 es.throwUninformativeAndGenericDOMException(NotSupportedError);
1465 return 0; 1465 return 0;
1466 } 1466 }
1467 // FIXME: It might be a good idea to emit a warning if |whatToShow| contains a bit that is not defined in 1467 // FIXME: It might be a good idea to emit a warning if |whatToShow| contains a bit that is not defined in
1468 // NodeFilter. 1468 // NodeFilter.
1469 return NodeIterator::create(root, whatToShow, PassRefPtr<NodeFilter>()); 1469 return NodeIterator::create(root, whatToShow, PassRefPtr<NodeFilter>());
1470 } 1470 }
1471 1471
1472 PassRefPtr<NodeIterator> Document::createNodeIterator(Node* root, unsigned whatT oShow, PassRefPtr<NodeFilter> filter, ExceptionState& es) 1472 PassRefPtr<NodeIterator> Document::createNodeIterator(Node* root, unsigned whatT oShow, PassRefPtr<NodeFilter> filter, ExceptionState& es)
1473 { 1473 {
1474 if (!root) { 1474 if (!root) {
1475 es.throwDOMException(NotSupportedError); 1475 es.throwUninformativeAndGenericDOMException(NotSupportedError);
1476 return 0; 1476 return 0;
1477 } 1477 }
1478 // FIXME: Ditto. 1478 // FIXME: Ditto.
1479 return NodeIterator::create(root, whatToShow, filter); 1479 return NodeIterator::create(root, whatToShow, filter);
1480 } 1480 }
1481 1481
1482 PassRefPtr<NodeIterator> Document::createNodeIterator(Node* root, unsigned whatT oShow, PassRefPtr<NodeFilter> filter, bool expandEntityReferences, ExceptionStat e& es) 1482 PassRefPtr<NodeIterator> Document::createNodeIterator(Node* root, unsigned whatT oShow, PassRefPtr<NodeFilter> filter, bool expandEntityReferences, ExceptionStat e& es)
1483 { 1483 {
1484 if (!root) { 1484 if (!root) {
1485 es.throwDOMException(NotSupportedError); 1485 es.throwUninformativeAndGenericDOMException(NotSupportedError);
1486 return 0; 1486 return 0;
1487 } 1487 }
1488 // FIXME: Warn if |expandEntityReferences| is specified. This optional argum ent is deprecated in DOM4. 1488 // FIXME: Warn if |expandEntityReferences| is specified. This optional argum ent is deprecated in DOM4.
1489 UNUSED_PARAM(expandEntityReferences); 1489 UNUSED_PARAM(expandEntityReferences);
1490 return NodeIterator::create(root, whatToShow, filter); 1490 return NodeIterator::create(root, whatToShow, filter);
1491 } 1491 }
1492 1492
1493 PassRefPtr<TreeWalker> Document::createTreeWalker(Node* root, ExceptionState& es ) 1493 PassRefPtr<TreeWalker> Document::createTreeWalker(Node* root, ExceptionState& es )
1494 { 1494 {
1495 if (!root) { 1495 if (!root) {
1496 es.throwDOMException(NotSupportedError); 1496 es.throwUninformativeAndGenericDOMException(NotSupportedError);
1497 return 0; 1497 return 0;
1498 } 1498 }
1499 return TreeWalker::create(root, NodeFilter::SHOW_ALL, PassRefPtr<NodeFilter> ()); 1499 return TreeWalker::create(root, NodeFilter::SHOW_ALL, PassRefPtr<NodeFilter> ());
1500 } 1500 }
1501 1501
1502 PassRefPtr<TreeWalker> Document::createTreeWalker(Node* root, unsigned whatToSho w, ExceptionState& es) 1502 PassRefPtr<TreeWalker> Document::createTreeWalker(Node* root, unsigned whatToSho w, ExceptionState& es)
1503 { 1503 {
1504 if (!root) { 1504 if (!root) {
1505 es.throwDOMException(NotSupportedError); 1505 es.throwUninformativeAndGenericDOMException(NotSupportedError);
1506 return 0; 1506 return 0;
1507 } 1507 }
1508 return TreeWalker::create(root, whatToShow, PassRefPtr<NodeFilter>()); 1508 return TreeWalker::create(root, whatToShow, PassRefPtr<NodeFilter>());
1509 } 1509 }
1510 1510
1511 PassRefPtr<TreeWalker> Document::createTreeWalker(Node* root, unsigned whatToSho w, PassRefPtr<NodeFilter> filter, ExceptionState& es) 1511 PassRefPtr<TreeWalker> Document::createTreeWalker(Node* root, unsigned whatToSho w, PassRefPtr<NodeFilter> filter, ExceptionState& es)
1512 { 1512 {
1513 if (!root) { 1513 if (!root) {
1514 es.throwDOMException(NotSupportedError); 1514 es.throwUninformativeAndGenericDOMException(NotSupportedError);
1515 return 0; 1515 return 0;
1516 } 1516 }
1517 return TreeWalker::create(root, whatToShow, filter); 1517 return TreeWalker::create(root, whatToShow, filter);
1518 } 1518 }
1519 1519
1520 PassRefPtr<TreeWalker> Document::createTreeWalker(Node* root, unsigned whatToSho w, PassRefPtr<NodeFilter> filter, bool expandEntityReferences, ExceptionState& e s) 1520 PassRefPtr<TreeWalker> Document::createTreeWalker(Node* root, unsigned whatToSho w, PassRefPtr<NodeFilter> filter, bool expandEntityReferences, ExceptionState& e s)
1521 { 1521 {
1522 UNUSED_PARAM(expandEntityReferences); 1522 UNUSED_PARAM(expandEntityReferences);
1523 if (!root) { 1523 if (!root) {
1524 es.throwDOMException(NotSupportedError); 1524 es.throwUninformativeAndGenericDOMException(NotSupportedError);
1525 return 0; 1525 return 0;
1526 } 1526 }
1527 return TreeWalker::create(root, whatToShow, filter); 1527 return TreeWalker::create(root, whatToShow, filter);
1528 } 1528 }
1529 1529
1530 void Document::scheduleStyleRecalc() 1530 void Document::scheduleStyleRecalc()
1531 { 1531 {
1532 if (shouldDisplaySeamlesslyWithParent()) { 1532 if (shouldDisplaySeamlesslyWithParent()) {
1533 // When we're seamless, our parent document manages our style recalcs. 1533 // When we're seamless, our parent document manages our style recalcs.
1534 ownerElement()->setNeedsStyleRecalc(); 1534 ownerElement()->setNeedsStyleRecalc();
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after
2253 } 2253 }
2254 2254
2255 return 0; 2255 return 0;
2256 } 2256 }
2257 2257
2258 void Document::setBody(PassRefPtr<HTMLElement> prpNewBody, ExceptionState& es) 2258 void Document::setBody(PassRefPtr<HTMLElement> prpNewBody, ExceptionState& es)
2259 { 2259 {
2260 RefPtr<HTMLElement> newBody = prpNewBody; 2260 RefPtr<HTMLElement> newBody = prpNewBody;
2261 2261
2262 if (!newBody || !documentElement()) { 2262 if (!newBody || !documentElement()) {
2263 es.throwDOMException(HierarchyRequestError); 2263 es.throwUninformativeAndGenericDOMException(HierarchyRequestError);
2264 return; 2264 return;
2265 } 2265 }
2266 2266
2267 if (!newBody->hasTagName(bodyTag) && !newBody->hasTagName(framesetTag)) { 2267 if (!newBody->hasTagName(bodyTag) && !newBody->hasTagName(framesetTag)) {
2268 es.throwDOMException(HierarchyRequestError); 2268 es.throwUninformativeAndGenericDOMException(HierarchyRequestError);
2269 return; 2269 return;
2270 } 2270 }
2271 2271
2272 HTMLElement* oldBody = body(); 2272 HTMLElement* oldBody = body();
2273 if (oldBody == newBody) 2273 if (oldBody == newBody)
2274 return; 2274 return;
2275 2275
2276 if (oldBody) 2276 if (oldBody)
2277 documentElement()->replaceChild(newBody.release(), oldBody, es); 2277 documentElement()->replaceChild(newBody.release(), oldBody, es);
2278 else 2278 else
(...skipping 1457 matching lines...) Expand 10 before | Expand all | Expand 10 after
3736 event->setTarget(this); 3736 event->setTarget(this);
3737 m_eventQueue->enqueueEvent(event); 3737 m_eventQueue->enqueueEvent(event);
3738 } 3738 }
3739 3739
3740 PassRefPtr<Event> Document::createEvent(const String& eventType, ExceptionState& es) 3740 PassRefPtr<Event> Document::createEvent(const String& eventType, ExceptionState& es)
3741 { 3741 {
3742 RefPtr<Event> event = EventFactory::create(eventType); 3742 RefPtr<Event> event = EventFactory::create(eventType);
3743 if (event) 3743 if (event)
3744 return event.release(); 3744 return event.release();
3745 3745
3746 es.throwDOMException(NotSupportedError); 3746 es.throwUninformativeAndGenericDOMException(NotSupportedError);
3747 return 0; 3747 return 0;
3748 } 3748 }
3749 3749
3750 void Document::dispatchWindowLoadEvent() 3750 void Document::dispatchWindowLoadEvent()
3751 { 3751 {
3752 ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden()); 3752 ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden());
3753 DOMWindow* domWindow = this->domWindow(); 3753 DOMWindow* domWindow = this->domWindow();
3754 if (!domWindow) 3754 if (!domWindow)
3755 return; 3755 return;
3756 domWindow->dispatchLoadEvent(); 3756 domWindow->dispatchLoadEvent();
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
4031 { 4031 {
4032 bool nameStart = true; 4032 bool nameStart = true;
4033 bool sawColon = false; 4033 bool sawColon = false;
4034 int colonPos = 0; 4034 int colonPos = 0;
4035 4035
4036 for (unsigned i = 0; i < length;) { 4036 for (unsigned i = 0; i < length;) {
4037 UChar32 c; 4037 UChar32 c;
4038 U16_NEXT(characters, i, length, c) 4038 U16_NEXT(characters, i, length, c)
4039 if (c == ':') { 4039 if (c == ':') {
4040 if (sawColon) { 4040 if (sawColon) {
4041 es.throwDOMException(NamespaceError); 4041 es.throwUninformativeAndGenericDOMException(NamespaceError);
4042 return false; // multiple colons: not allowed 4042 return false; // multiple colons: not allowed
4043 } 4043 }
4044 nameStart = true; 4044 nameStart = true;
4045 sawColon = true; 4045 sawColon = true;
4046 colonPos = i - 1; 4046 colonPos = i - 1;
4047 } else if (nameStart) { 4047 } else if (nameStart) {
4048 if (!isValidNameStart(c)) { 4048 if (!isValidNameStart(c)) {
4049 es.throwDOMException(InvalidCharacterError); 4049 es.throwUninformativeAndGenericDOMException(InvalidCharacterErro r);
4050 return false; 4050 return false;
4051 } 4051 }
4052 nameStart = false; 4052 nameStart = false;
4053 } else { 4053 } else {
4054 if (!isValidNamePart(c)) { 4054 if (!isValidNamePart(c)) {
4055 es.throwDOMException(InvalidCharacterError); 4055 es.throwUninformativeAndGenericDOMException(InvalidCharacterErro r);
4056 return false; 4056 return false;
4057 } 4057 }
4058 } 4058 }
4059 } 4059 }
4060 4060
4061 if (!sawColon) { 4061 if (!sawColon) {
4062 prefix = String(); 4062 prefix = String();
4063 localName = qualifiedName; 4063 localName = qualifiedName;
4064 } else { 4064 } else {
4065 prefix = qualifiedName.substring(0, colonPos); 4065 prefix = qualifiedName.substring(0, colonPos);
4066 if (prefix.isEmpty()) { 4066 if (prefix.isEmpty()) {
4067 es.throwDOMException(NamespaceError); 4067 es.throwUninformativeAndGenericDOMException(NamespaceError);
4068 return false; 4068 return false;
4069 } 4069 }
4070 localName = qualifiedName.substring(colonPos + 1); 4070 localName = qualifiedName.substring(colonPos + 1);
4071 } 4071 }
4072 4072
4073 if (localName.isEmpty()) { 4073 if (localName.isEmpty()) {
4074 es.throwDOMException(NamespaceError); 4074 es.throwUninformativeAndGenericDOMException(NamespaceError);
4075 return false; 4075 return false;
4076 } 4076 }
4077 4077
4078 return true; 4078 return true;
4079 } 4079 }
4080 4080
4081 bool Document::parseQualifiedName(const String& qualifiedName, String& prefix, S tring& localName, ExceptionState& es) 4081 bool Document::parseQualifiedName(const String& qualifiedName, String& prefix, S tring& localName, ExceptionState& es)
4082 { 4082 {
4083 unsigned length = qualifiedName.length(); 4083 unsigned length = qualifiedName.length();
4084 4084
4085 if (!length) { 4085 if (!length) {
4086 es.throwDOMException(InvalidCharacterError); 4086 es.throwUninformativeAndGenericDOMException(InvalidCharacterError);
4087 return false; 4087 return false;
4088 } 4088 }
4089 4089
4090 if (qualifiedName.is8Bit()) 4090 if (qualifiedName.is8Bit())
4091 return parseQualifiedNameInternal(qualifiedName, qualifiedName.character s8(), length, prefix, localName, es); 4091 return parseQualifiedNameInternal(qualifiedName, qualifiedName.character s8(), length, prefix, localName, es);
4092 return parseQualifiedNameInternal(qualifiedName, qualifiedName.characters16( ), length, prefix, localName, es); 4092 return parseQualifiedNameInternal(qualifiedName, qualifiedName.characters16( ), length, prefix, localName, es);
4093 } 4093 }
4094 4094
4095 void Document::setDecoder(PassRefPtr<TextResourceDecoder> decoder) 4095 void Document::setDecoder(PassRefPtr<TextResourceDecoder> decoder)
4096 { 4096 {
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
4311 4311
4312 PassRefPtr<Attr> Document::createAttributeNS(const String& namespaceURI, const S tring& qualifiedName, ExceptionState& es, bool shouldIgnoreNamespaceChecks) 4312 PassRefPtr<Attr> Document::createAttributeNS(const String& namespaceURI, const S tring& qualifiedName, ExceptionState& es, bool shouldIgnoreNamespaceChecks)
4313 { 4313 {
4314 String prefix, localName; 4314 String prefix, localName;
4315 if (!parseQualifiedName(qualifiedName, prefix, localName, es)) 4315 if (!parseQualifiedName(qualifiedName, prefix, localName, es))
4316 return 0; 4316 return 0;
4317 4317
4318 QualifiedName qName(prefix, localName, namespaceURI); 4318 QualifiedName qName(prefix, localName, namespaceURI);
4319 4319
4320 if (!shouldIgnoreNamespaceChecks && !hasValidNamespaceForAttributes(qName)) { 4320 if (!shouldIgnoreNamespaceChecks && !hasValidNamespaceForAttributes(qName)) {
4321 es.throwDOMException(NamespaceError); 4321 es.throwUninformativeAndGenericDOMException(NamespaceError);
4322 return 0; 4322 return 0;
4323 } 4323 }
4324 4324
4325 return Attr::create(*this, qName, emptyString()); 4325 return Attr::create(*this, qName, emptyString());
4326 } 4326 }
4327 4327
4328 const SVGDocumentExtensions* Document::svgExtensions() 4328 const SVGDocumentExtensions* Document::svgExtensions()
4329 { 4329 {
4330 return m_svgExtensions.get(); 4330 return m_svgExtensions.get();
4331 } 4331 }
(...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after
5386 { 5386 {
5387 return DocumentLifecycleNotifier::create(this); 5387 return DocumentLifecycleNotifier::create(this);
5388 } 5388 }
5389 5389
5390 DocumentLifecycleNotifier* Document::lifecycleNotifier() 5390 DocumentLifecycleNotifier* Document::lifecycleNotifier()
5391 { 5391 {
5392 return static_cast<DocumentLifecycleNotifier*>(ScriptExecutionContext::lifec ycleNotifier()); 5392 return static_cast<DocumentLifecycleNotifier*>(ScriptExecutionContext::lifec ycleNotifier());
5393 } 5393 }
5394 5394
5395 } // namespace WebCore 5395 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/DOMTokenList.cpp ('k') | Source/core/dom/Element.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698