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

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

Issue 170603003: Use nullptr_t for RefPtr, PassRefPtr and RawPtr. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Final rebase Created 6 years, 10 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/DOMImplementation.cpp ('k') | Source/core/dom/DocumentInit.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 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 setClient(0); 578 setClient(0);
579 579
580 InspectorCounters::decrementCounter(InspectorCounters::DocumentCounter); 580 InspectorCounters::decrementCounter(InspectorCounters::DocumentCounter);
581 } 581 }
582 582
583 void Document::dispose() 583 void Document::dispose()
584 { 584 {
585 ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun); 585 ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun);
586 // We must make sure not to be retaining any of our children through 586 // We must make sure not to be retaining any of our children through
587 // these extra pointers or we will create a reference cycle. 587 // these extra pointers or we will create a reference cycle.
588 m_docType = 0; 588 m_docType = nullptr;
589 m_focusedElement = 0; 589 m_focusedElement = nullptr;
590 m_hoverNode = 0; 590 m_hoverNode = nullptr;
591 m_activeHoverElement = 0; 591 m_activeHoverElement = nullptr;
592 m_titleElement = 0; 592 m_titleElement = nullptr;
593 m_documentElement = 0; 593 m_documentElement = nullptr;
594 m_contextFeatures = ContextFeatures::defaultSwitch(); 594 m_contextFeatures = ContextFeatures::defaultSwitch();
595 m_userActionElements.documentDidRemoveLastRef(); 595 m_userActionElements.documentDidRemoveLastRef();
596 m_associatedFormControls.clear(); 596 m_associatedFormControls.clear();
597 597
598 detachParser(); 598 detachParser();
599 599
600 m_registrationContext.clear(); 600 m_registrationContext.clear();
601 601
602 if (m_import) { 602 if (m_import) {
603 m_import->wasDetachedFromDocument(); 603 m_import->wasDetachedFromDocument();
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 return; 707 return;
708 m_documentElement = newDocumentElement; 708 m_documentElement = newDocumentElement;
709 // The root style used for media query matching depends on the document elem ent. 709 // The root style used for media query matching depends on the document elem ent.
710 clearStyleResolver(); 710 clearStyleResolver();
711 } 711 }
712 712
713 PassRefPtr<Element> Document::createElement(const AtomicString& name, ExceptionS tate& exceptionState) 713 PassRefPtr<Element> Document::createElement(const AtomicString& name, ExceptionS tate& exceptionState)
714 { 714 {
715 if (!isValidName(name)) { 715 if (!isValidName(name)) {
716 exceptionState.throwDOMException(InvalidCharacterError, "The tag name pr ovided ('" + name + "') is not a valid name."); 716 exceptionState.throwDOMException(InvalidCharacterError, "The tag name pr ovided ('" + name + "') is not a valid name.");
717 return 0; 717 return nullptr;
718 } 718 }
719 719
720 if (isXHTMLDocument() || isHTMLDocument()) 720 if (isXHTMLDocument() || isHTMLDocument())
721 return HTMLElementFactory::createHTMLElement(isHTMLDocument() ? name.low er() : name, *this, 0, false); 721 return HTMLElementFactory::createHTMLElement(isHTMLDocument() ? name.low er() : name, *this, 0, false);
722 722
723 return Element::create(QualifiedName(nullAtom, name, nullAtom), this); 723 return Element::create(QualifiedName(nullAtom, name, nullAtom), this);
724 } 724 }
725 725
726 PassRefPtr<Element> Document::createElement(const AtomicString& localName, const AtomicString& typeExtension, ExceptionState& exceptionState) 726 PassRefPtr<Element> Document::createElement(const AtomicString& localName, const AtomicString& typeExtension, ExceptionState& exceptionState)
727 { 727 {
728 if (!isValidName(localName)) { 728 if (!isValidName(localName)) {
729 exceptionState.throwDOMException(InvalidCharacterError, "The tag name pr ovided ('" + localName + "') is not a valid name."); 729 exceptionState.throwDOMException(InvalidCharacterError, "The tag name pr ovided ('" + localName + "') is not a valid name.");
730 return 0; 730 return nullptr;
731 } 731 }
732 732
733 RefPtr<Element> element; 733 RefPtr<Element> element;
734 734
735 if (CustomElement::isValidName(localName) && registrationContext()) { 735 if (CustomElement::isValidName(localName) && registrationContext()) {
736 element = registrationContext()->createCustomTagElement(*this, Qualified Name(nullAtom, localName, xhtmlNamespaceURI)); 736 element = registrationContext()->createCustomTagElement(*this, Qualified Name(nullAtom, localName, xhtmlNamespaceURI));
737 } else { 737 } else {
738 element = createElement(localName, exceptionState); 738 element = createElement(localName, exceptionState);
739 if (exceptionState.hadException()) 739 if (exceptionState.hadException())
740 return 0; 740 return nullptr;
741 } 741 }
742 742
743 if (!typeExtension.isEmpty()) 743 if (!typeExtension.isEmpty())
744 CustomElementRegistrationContext::setIsAttributeAndTypeExtension(element .get(), typeExtension); 744 CustomElementRegistrationContext::setIsAttributeAndTypeExtension(element .get(), typeExtension);
745 745
746 return element; 746 return element;
747 } 747 }
748 748
749 static inline QualifiedName createQualifiedName(const AtomicString& namespaceURI , const AtomicString& qualifiedName, ExceptionState& exceptionState) 749 static inline QualifiedName createQualifiedName(const AtomicString& namespaceURI , const AtomicString& qualifiedName, ExceptionState& exceptionState)
750 { 750 {
751 AtomicString prefix, localName; 751 AtomicString prefix, localName;
752 if (!Document::parseQualifiedName(qualifiedName, prefix, localName, exceptio nState)) 752 if (!Document::parseQualifiedName(qualifiedName, prefix, localName, exceptio nState))
753 return nullQName(); 753 return nullQName();
754 754
755 QualifiedName qName(prefix, localName, namespaceURI); 755 QualifiedName qName(prefix, localName, namespaceURI);
756 if (!Document::hasValidNamespaceForElements(qName)) { 756 if (!Document::hasValidNamespaceForElements(qName)) {
757 exceptionState.throwDOMException(NamespaceError, "The namespace URI prov ided ('" + namespaceURI + "') is not valid for the qualified name provided ('" + qualifiedName + "')."); 757 exceptionState.throwDOMException(NamespaceError, "The namespace URI prov ided ('" + namespaceURI + "') is not valid for the qualified name provided ('" + qualifiedName + "').");
758 return nullQName(); 758 return nullQName();
759 } 759 }
760 760
761 return qName; 761 return qName;
762 } 762 }
763 763
764 PassRefPtr<Element> Document::createElementNS(const AtomicString& namespaceURI, const AtomicString& qualifiedName, ExceptionState& exceptionState) 764 PassRefPtr<Element> Document::createElementNS(const AtomicString& namespaceURI, const AtomicString& qualifiedName, ExceptionState& exceptionState)
765 { 765 {
766 QualifiedName qName(createQualifiedName(namespaceURI, qualifiedName, excepti onState)); 766 QualifiedName qName(createQualifiedName(namespaceURI, qualifiedName, excepti onState));
767 if (qName == nullQName()) 767 if (qName == nullQName())
768 return 0; 768 return nullptr;
769 769
770 return createElement(qName, false); 770 return createElement(qName, false);
771 } 771 }
772 772
773 PassRefPtr<Element> Document::createElementNS(const AtomicString& namespaceURI, const AtomicString& qualifiedName, const AtomicString& typeExtension, ExceptionS tate& exceptionState) 773 PassRefPtr<Element> Document::createElementNS(const AtomicString& namespaceURI, const AtomicString& qualifiedName, const AtomicString& typeExtension, ExceptionS tate& exceptionState)
774 { 774 {
775 QualifiedName qName(createQualifiedName(namespaceURI, qualifiedName, excepti onState)); 775 QualifiedName qName(createQualifiedName(namespaceURI, qualifiedName, excepti onState));
776 if (qName == nullQName()) 776 if (qName == nullQName())
777 return 0; 777 return nullptr;
778 778
779 RefPtr<Element> element; 779 RefPtr<Element> element;
780 if (CustomElement::isValidName(qName.localName()) && registrationContext()) 780 if (CustomElement::isValidName(qName.localName()) && registrationContext())
781 element = registrationContext()->createCustomTagElement(*this, qName); 781 element = registrationContext()->createCustomTagElement(*this, qName);
782 else 782 else
783 element = createElement(qName, false); 783 element = createElement(qName, false);
784 784
785 if (!typeExtension.isEmpty()) 785 if (!typeExtension.isEmpty())
786 CustomElementRegistrationContext::setIsAttributeAndTypeExtension(element .get(), typeExtension); 786 CustomElementRegistrationContext::setIsAttributeAndTypeExtension(element .get(), typeExtension);
787 787
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 850
851 PassRefPtr<Comment> Document::createComment(const String& data) 851 PassRefPtr<Comment> Document::createComment(const String& data)
852 { 852 {
853 return Comment::create(*this, data); 853 return Comment::create(*this, data);
854 } 854 }
855 855
856 PassRefPtr<CDATASection> Document::createCDATASection(const String& data, Except ionState& exceptionState) 856 PassRefPtr<CDATASection> Document::createCDATASection(const String& data, Except ionState& exceptionState)
857 { 857 {
858 if (isHTMLDocument()) { 858 if (isHTMLDocument()) {
859 exceptionState.throwDOMException(NotSupportedError, "This operation is n ot supported for HTML documents."); 859 exceptionState.throwDOMException(NotSupportedError, "This operation is n ot supported for HTML documents.");
860 return 0; 860 return nullptr;
861 } 861 }
862 if (data.contains("]]>")) { 862 if (data.contains("]]>")) {
863 exceptionState.throwDOMException(InvalidCharacterError, "String cannot c ontain ']]>' since that is the end delimiter of a CData section."); 863 exceptionState.throwDOMException(InvalidCharacterError, "String cannot c ontain ']]>' since that is the end delimiter of a CData section.");
864 return 0; 864 return nullptr;
865 } 865 }
866 return CDATASection::create(*this, data); 866 return CDATASection::create(*this, data);
867 } 867 }
868 868
869 PassRefPtr<ProcessingInstruction> Document::createProcessingInstruction(const St ring& target, const String& data, ExceptionState& exceptionState) 869 PassRefPtr<ProcessingInstruction> Document::createProcessingInstruction(const St ring& target, const String& data, ExceptionState& exceptionState)
870 { 870 {
871 if (!isValidName(target)) { 871 if (!isValidName(target)) {
872 exceptionState.throwDOMException(InvalidCharacterError, "The target prov ided ('" + target + "') is not a valid name."); 872 exceptionState.throwDOMException(InvalidCharacterError, "The target prov ided ('" + target + "') is not a valid name.");
873 return 0; 873 return nullptr;
874 } 874 }
875 if (data.contains("?>")) { 875 if (data.contains("?>")) {
876 exceptionState.throwDOMException(InvalidCharacterError, "The data provid ed ('" + data + "') contains '?>'."); 876 exceptionState.throwDOMException(InvalidCharacterError, "The data provid ed ('" + data + "') contains '?>'.");
877 return 0; 877 return nullptr;
878 } 878 }
879 return ProcessingInstruction::create(*this, target, data); 879 return ProcessingInstruction::create(*this, target, data);
880 } 880 }
881 881
882 PassRefPtr<Text> Document::createEditingTextNode(const String& text) 882 PassRefPtr<Text> Document::createEditingTextNode(const String& text)
883 { 883 {
884 return Text::createEditingText(*this, text); 884 return Text::createEditingText(*this, text);
885 } 885 }
886 886
887 PassRefPtr<Node> Document::importNode(Node* importedNode, bool deep, ExceptionSt ate& exceptionState) 887 PassRefPtr<Node> Document::importNode(Node* importedNode, bool deep, ExceptionSt ate& exceptionState)
888 { 888 {
889 if (!importedNode) { 889 if (!importedNode) {
890 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Node")); 890 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Node"));
891 return 0; 891 return nullptr;
892 } 892 }
893 893
894 switch (importedNode->nodeType()) { 894 switch (importedNode->nodeType()) {
895 case TEXT_NODE: 895 case TEXT_NODE:
896 return createTextNode(importedNode->nodeValue()); 896 return createTextNode(importedNode->nodeValue());
897 case CDATA_SECTION_NODE: 897 case CDATA_SECTION_NODE:
898 return createCDATASection(importedNode->nodeValue(), exceptionState); 898 return createCDATASection(importedNode->nodeValue(), exceptionState);
899 case PROCESSING_INSTRUCTION_NODE: 899 case PROCESSING_INSTRUCTION_NODE:
900 return createProcessingInstruction(importedNode->nodeName(), importedNod e->nodeValue(), exceptionState); 900 return createProcessingInstruction(importedNode->nodeName(), importedNod e->nodeValue(), exceptionState);
901 case COMMENT_NODE: 901 case COMMENT_NODE:
902 return createComment(importedNode->nodeValue()); 902 return createComment(importedNode->nodeValue());
903 case DOCUMENT_TYPE_NODE: { 903 case DOCUMENT_TYPE_NODE: {
904 DocumentType* doctype = toDocumentType(importedNode); 904 DocumentType* doctype = toDocumentType(importedNode);
905 return DocumentType::create(this, doctype->name(), doctype->publicId(), doctype->systemId()); 905 return DocumentType::create(this, doctype->name(), doctype->publicId(), doctype->systemId());
906 } 906 }
907 case ELEMENT_NODE: { 907 case ELEMENT_NODE: {
908 Element* oldElement = toElement(importedNode); 908 Element* oldElement = toElement(importedNode);
909 // FIXME: The following check might be unnecessary. Is it possible that 909 // FIXME: The following check might be unnecessary. Is it possible that
910 // oldElement has mismatched prefix/namespace? 910 // oldElement has mismatched prefix/namespace?
911 if (!hasValidNamespaceForElements(oldElement->tagQName())) { 911 if (!hasValidNamespaceForElements(oldElement->tagQName())) {
912 exceptionState.throwDOMException(NamespaceError, "The imported node has an invalid namespace."); 912 exceptionState.throwDOMException(NamespaceError, "The imported node has an invalid namespace.");
913 return 0; 913 return nullptr;
914 } 914 }
915 RefPtr<Element> newElement = createElement(oldElement->tagQName(), false ); 915 RefPtr<Element> newElement = createElement(oldElement->tagQName(), false );
916 916
917 newElement->cloneDataFromElement(*oldElement); 917 newElement->cloneDataFromElement(*oldElement);
918 918
919 if (deep) { 919 if (deep) {
920 for (Node* oldChild = oldElement->firstChild(); oldChild; oldChild = oldChild->nextSibling()) { 920 for (Node* oldChild = oldElement->firstChild(); oldChild; oldChild = oldChild->nextSibling()) {
921 RefPtr<Node> newChild = importNode(oldChild, true, exceptionStat e); 921 RefPtr<Node> newChild = importNode(oldChild, true, exceptionStat e);
922 if (exceptionState.hadException()) 922 if (exceptionState.hadException())
923 return 0; 923 return nullptr;
924 newElement->appendChild(newChild.release(), exceptionState); 924 newElement->appendChild(newChild.release(), exceptionState);
925 if (exceptionState.hadException()) 925 if (exceptionState.hadException())
926 return 0; 926 return nullptr;
927 } 927 }
928 } 928 }
929 929
930 return newElement.release(); 930 return newElement.release();
931 } 931 }
932 case ATTRIBUTE_NODE: 932 case ATTRIBUTE_NODE:
933 return Attr::create(*this, QualifiedName(nullAtom, AtomicString(toAttr(i mportedNode)->name()), nullAtom), toAttr(importedNode)->value()); 933 return Attr::create(*this, QualifiedName(nullAtom, AtomicString(toAttr(i mportedNode)->name()), nullAtom), toAttr(importedNode)->value());
934 case DOCUMENT_FRAGMENT_NODE: { 934 case DOCUMENT_FRAGMENT_NODE: {
935 if (importedNode->isShadowRoot()) { 935 if (importedNode->isShadowRoot()) {
936 // ShadowRoot nodes should not be explicitly importable. 936 // ShadowRoot nodes should not be explicitly importable.
937 // Either they are imported along with their host node, or created i mplicitly. 937 // Either they are imported along with their host node, or created i mplicitly.
938 exceptionState.throwDOMException(NotSupportedError, "The node provid ed is a shadow root, which may not be imported."); 938 exceptionState.throwDOMException(NotSupportedError, "The node provid ed is a shadow root, which may not be imported.");
939 return 0; 939 return nullptr;
940 } 940 }
941 DocumentFragment* oldFragment = toDocumentFragment(importedNode); 941 DocumentFragment* oldFragment = toDocumentFragment(importedNode);
942 RefPtr<DocumentFragment> newFragment = createDocumentFragment(); 942 RefPtr<DocumentFragment> newFragment = createDocumentFragment();
943 if (deep) { 943 if (deep) {
944 for (Node* oldChild = oldFragment->firstChild(); oldChild; oldChild = oldChild->nextSibling()) { 944 for (Node* oldChild = oldFragment->firstChild(); oldChild; oldChild = oldChild->nextSibling()) {
945 RefPtr<Node> newChild = importNode(oldChild, true, exceptionStat e); 945 RefPtr<Node> newChild = importNode(oldChild, true, exceptionStat e);
946 if (exceptionState.hadException()) 946 if (exceptionState.hadException())
947 return 0; 947 return nullptr;
948 newFragment->appendChild(newChild.release(), exceptionState); 948 newFragment->appendChild(newChild.release(), exceptionState);
949 if (exceptionState.hadException()) 949 if (exceptionState.hadException())
950 return 0; 950 return nullptr;
951 } 951 }
952 } 952 }
953 953
954 return newFragment.release(); 954 return newFragment.release();
955 } 955 }
956 case DOCUMENT_NODE: 956 case DOCUMENT_NODE:
957 exceptionState.throwDOMException(NotSupportedError, "The node provided i s a document, which may not be imported."); 957 exceptionState.throwDOMException(NotSupportedError, "The node provided i s a document, which may not be imported.");
958 return 0; 958 return nullptr;
959 } 959 }
960 960
961 ASSERT_NOT_REACHED(); 961 ASSERT_NOT_REACHED();
962 return 0; 962 return nullptr;
963 } 963 }
964 964
965 PassRefPtr<Node> Document::adoptNode(PassRefPtr<Node> source, ExceptionState& ex ceptionState) 965 PassRefPtr<Node> Document::adoptNode(PassRefPtr<Node> source, ExceptionState& ex ceptionState)
966 { 966 {
967 if (!source) { 967 if (!source) {
968 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Node")); 968 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Node"));
969 return 0; 969 return nullptr;
970 } 970 }
971 971
972 EventQueueScope scope; 972 EventQueueScope scope;
973 973
974 switch (source->nodeType()) { 974 switch (source->nodeType()) {
975 case DOCUMENT_NODE: 975 case DOCUMENT_NODE:
976 case DOCUMENT_TYPE_NODE: 976 case DOCUMENT_TYPE_NODE:
977 exceptionState.throwDOMException(NotSupportedError, "The node provided i s of type '" + source->nodeName() + "', which may not be adopted."); 977 exceptionState.throwDOMException(NotSupportedError, "The node provided i s of type '" + source->nodeName() + "', which may not be adopted.");
978 return 0; 978 return nullptr;
979 case ATTRIBUTE_NODE: { 979 case ATTRIBUTE_NODE: {
980 Attr* attr = toAttr(source.get()); 980 Attr* attr = toAttr(source.get());
981 if (attr->ownerElement()) 981 if (attr->ownerElement())
982 attr->ownerElement()->removeAttributeNode(attr, exceptionState); 982 attr->ownerElement()->removeAttributeNode(attr, exceptionState);
983 break; 983 break;
984 } 984 }
985 default: 985 default:
986 if (source->isShadowRoot()) { 986 if (source->isShadowRoot()) {
987 // ShadowRoot cannot disconnect itself from the host node. 987 // ShadowRoot cannot disconnect itself from the host node.
988 exceptionState.throwDOMException(HierarchyRequestError, "The node pr ovided is a shadow root, which may not be adopted."); 988 exceptionState.throwDOMException(HierarchyRequestError, "The node pr ovided is a shadow root, which may not be adopted.");
989 return 0; 989 return nullptr;
990 } 990 }
991 991
992 if (source->isFrameOwnerElement()) { 992 if (source->isFrameOwnerElement()) {
993 HTMLFrameOwnerElement* frameOwnerElement = toHTMLFrameOwnerElement(s ource.get()); 993 HTMLFrameOwnerElement* frameOwnerElement = toHTMLFrameOwnerElement(s ource.get());
994 if (frame() && frame()->tree().isDescendantOf(frameOwnerElement->con tentFrame())) { 994 if (frame() && frame()->tree().isDescendantOf(frameOwnerElement->con tentFrame())) {
995 exceptionState.throwDOMException(HierarchyRequestError, "The nod e provided is a frame which contains this document."); 995 exceptionState.throwDOMException(HierarchyRequestError, "The nod e provided is a frame which contains this document.");
996 return 0; 996 return nullptr;
997 } 997 }
998 } 998 }
999 if (source->parentNode()) { 999 if (source->parentNode()) {
1000 source->parentNode()->removeChild(source.get(), exceptionState); 1000 source->parentNode()->removeChild(source.get(), exceptionState);
1001 if (exceptionState.hadException()) 1001 if (exceptionState.hadException())
1002 return 0; 1002 return nullptr;
1003 } 1003 }
1004 } 1004 }
1005 1005
1006 this->adoptIfNeeded(*source); 1006 this->adoptIfNeeded(*source);
1007 1007
1008 return source; 1008 return source;
1009 } 1009 }
1010 1010
1011 bool Document::hasValidNamespaceForElements(const QualifiedName& qName) 1011 bool Document::hasValidNamespaceForElements(const QualifiedName& qName)
1012 { 1012 {
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
1212 { 1212 {
1213 if (!renderView()) 1213 if (!renderView())
1214 return 0; 1214 return 0;
1215 1215
1216 return TreeScope::elementFromPoint(x, y); 1216 return TreeScope::elementFromPoint(x, y);
1217 } 1217 }
1218 1218
1219 PassRefPtr<Range> Document::caretRangeFromPoint(int x, int y) 1219 PassRefPtr<Range> Document::caretRangeFromPoint(int x, int y)
1220 { 1220 {
1221 if (!renderView()) 1221 if (!renderView())
1222 return 0; 1222 return nullptr;
1223 HitTestResult result = hitTestInDocument(this, x, y); 1223 HitTestResult result = hitTestInDocument(this, x, y);
1224 RenderObject* renderer = result.renderer(); 1224 RenderObject* renderer = result.renderer();
1225 if (!renderer) 1225 if (!renderer)
1226 return 0; 1226 return nullptr;
1227 1227
1228 Node* node = renderer->node(); 1228 Node* node = renderer->node();
1229 Node* shadowAncestorNode = ancestorInThisScope(node); 1229 Node* shadowAncestorNode = ancestorInThisScope(node);
1230 if (shadowAncestorNode != node) { 1230 if (shadowAncestorNode != node) {
1231 unsigned offset = shadowAncestorNode->nodeIndex(); 1231 unsigned offset = shadowAncestorNode->nodeIndex();
1232 ContainerNode* container = shadowAncestorNode->parentNode(); 1232 ContainerNode* container = shadowAncestorNode->parentNode();
1233 return Range::create(*this, container, offset, container, offset); 1233 return Range::create(*this, container, offset, container, offset);
1234 } 1234 }
1235 1235
1236 PositionWithAffinity positionWithAffinity = renderer->positionForPoint(resul t.localPoint()); 1236 PositionWithAffinity positionWithAffinity = renderer->positionForPoint(resul t.localPoint());
1237 if (positionWithAffinity.position().isNull()) 1237 if (positionWithAffinity.position().isNull())
1238 return 0; 1238 return nullptr;
1239 1239
1240 Position rangeCompliantPosition = positionWithAffinity.position().parentAnch oredEquivalent(); 1240 Position rangeCompliantPosition = positionWithAffinity.position().parentAnch oredEquivalent();
1241 return Range::create(*this, rangeCompliantPosition, rangeCompliantPosition); 1241 return Range::create(*this, rangeCompliantPosition, rangeCompliantPosition);
1242 } 1242 }
1243 1243
1244 /* 1244 /*
1245 * Performs three operations: 1245 * Performs three operations:
1246 * 1. Convert control characters to spaces 1246 * 1. Convert control characters to spaces
1247 * 2. Trim leading and trailing spaces 1247 * 2. Trim leading and trailing spaces
1248 * 3. Collapse internal whitespace. 1248 * 3. Collapse internal whitespace.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1315 if (!m_frame || oldTitle == m_title) 1315 if (!m_frame || oldTitle == m_title)
1316 return; 1316 return;
1317 m_frame->loader().client()->dispatchDidReceiveTitle(m_title); 1317 m_frame->loader().client()->dispatchDidReceiveTitle(m_title);
1318 } 1318 }
1319 1319
1320 void Document::setTitle(const String& title) 1320 void Document::setTitle(const String& title)
1321 { 1321 {
1322 // Title set by JavaScript -- overrides any title elements. 1322 // Title set by JavaScript -- overrides any title elements.
1323 m_titleSetExplicitly = true; 1323 m_titleSetExplicitly = true;
1324 if (!isHTMLDocument() && !isXHTMLDocument()) 1324 if (!isHTMLDocument() && !isXHTMLDocument())
1325 m_titleElement = 0; 1325 m_titleElement = nullptr;
1326 else if (!m_titleElement) { 1326 else if (!m_titleElement) {
1327 if (HTMLElement* headElement = head()) { 1327 if (HTMLElement* headElement = head()) {
1328 m_titleElement = HTMLTitleElement::create(*this); 1328 m_titleElement = HTMLTitleElement::create(*this);
1329 headElement->appendChild(m_titleElement); 1329 headElement->appendChild(m_titleElement);
1330 } 1330 }
1331 } 1331 }
1332 1332
1333 if (m_titleElement && m_titleElement->hasTagName(titleTag)) 1333 if (m_titleElement && m_titleElement->hasTagName(titleTag))
1334 toHTMLTitleElement(m_titleElement)->setText(title); 1334 toHTMLTitleElement(m_titleElement)->setText(title);
1335 else 1335 else
(...skipping 10 matching lines...) Expand all
1346 } 1346 }
1347 1347
1348 updateTitle(title); 1348 updateTitle(title);
1349 } 1349 }
1350 1350
1351 void Document::removeTitle(Element* titleElement) 1351 void Document::removeTitle(Element* titleElement)
1352 { 1352 {
1353 if (m_titleElement != titleElement) 1353 if (m_titleElement != titleElement)
1354 return; 1354 return;
1355 1355
1356 m_titleElement = 0; 1356 m_titleElement = nullptr;
1357 m_titleSetExplicitly = false; 1357 m_titleSetExplicitly = false;
1358 1358
1359 // FIXME: This is broken for SVG. 1359 // FIXME: This is broken for SVG.
1360 // Update title based on first title element in the head, if one exists. 1360 // Update title based on first title element in the head, if one exists.
1361 if (HTMLElement* headElement = head()) { 1361 if (HTMLElement* headElement = head()) {
1362 for (Element* element = ElementTraversal::firstWithin(*headElement); ele ment; element = ElementTraversal::nextSibling(*element)) { 1362 for (Element* element = ElementTraversal::firstWithin(*headElement); ele ment; element = ElementTraversal::nextSibling(*element)) {
1363 if (!element->hasTagName(titleTag)) 1363 if (!element->hasTagName(titleTag))
1364 continue; 1364 continue;
1365 HTMLTitleElement* title = toHTMLTitleElement(element); 1365 HTMLTitleElement* title = toHTMLTitleElement(element);
1366 setTitleElement(title->text(), title); 1366 setTitleElement(title->text(), title);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1471 PassRefPtr<Range> Document::createRange() 1471 PassRefPtr<Range> Document::createRange()
1472 { 1472 {
1473 return Range::create(*this); 1473 return Range::create(*this);
1474 } 1474 }
1475 1475
1476 PassRefPtr<NodeIterator> Document::createNodeIterator(Node* root, ExceptionState & exceptionState) 1476 PassRefPtr<NodeIterator> Document::createNodeIterator(Node* root, ExceptionState & exceptionState)
1477 { 1477 {
1478 // FIXME: Probably this should be handled within the bindings layer and Type Error should be thrown. 1478 // FIXME: Probably this should be handled within the bindings layer and Type Error should be thrown.
1479 if (!root) { 1479 if (!root) {
1480 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Node")); 1480 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Node"));
1481 return 0; 1481 return nullptr;
1482 } 1482 }
1483 return NodeIterator::create(root, NodeFilter::SHOW_ALL, PassRefPtr<NodeFilte r>()); 1483 return NodeIterator::create(root, NodeFilter::SHOW_ALL, PassRefPtr<NodeFilte r>());
1484 } 1484 }
1485 1485
1486 PassRefPtr<NodeIterator> Document::createNodeIterator(Node* root, unsigned whatT oShow, ExceptionState& exceptionState) 1486 PassRefPtr<NodeIterator> Document::createNodeIterator(Node* root, unsigned whatT oShow, ExceptionState& exceptionState)
1487 { 1487 {
1488 if (!root) { 1488 if (!root) {
1489 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Node")); 1489 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Node"));
1490 return 0; 1490 return nullptr;
1491 } 1491 }
1492 // FIXME: It might be a good idea to emit a warning if |whatToShow| contains a bit that is not defined in 1492 // FIXME: It might be a good idea to emit a warning if |whatToShow| contains a bit that is not defined in
1493 // NodeFilter. 1493 // NodeFilter.
1494 return NodeIterator::create(root, whatToShow, PassRefPtr<NodeFilter>()); 1494 return NodeIterator::create(root, whatToShow, PassRefPtr<NodeFilter>());
1495 } 1495 }
1496 1496
1497 PassRefPtr<NodeIterator> Document::createNodeIterator(Node* root, unsigned whatT oShow, PassRefPtr<NodeFilter> filter, ExceptionState& exceptionState) 1497 PassRefPtr<NodeIterator> Document::createNodeIterator(Node* root, unsigned whatT oShow, PassRefPtr<NodeFilter> filter, ExceptionState& exceptionState)
1498 { 1498 {
1499 if (!root) { 1499 if (!root) {
1500 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Node")); 1500 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Node"));
1501 return 0; 1501 return nullptr;
1502 } 1502 }
1503 // FIXME: Ditto. 1503 // FIXME: Ditto.
1504 return NodeIterator::create(root, whatToShow, filter); 1504 return NodeIterator::create(root, whatToShow, filter);
1505 } 1505 }
1506 1506
1507 PassRefPtr<TreeWalker> Document::createTreeWalker(Node* root, ExceptionState& ex ceptionState) 1507 PassRefPtr<TreeWalker> Document::createTreeWalker(Node* root, ExceptionState& ex ceptionState)
1508 { 1508 {
1509 if (!root) { 1509 if (!root) {
1510 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Node")); 1510 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Node"));
1511 return 0; 1511 return nullptr;
1512 } 1512 }
1513 return TreeWalker::create(root, NodeFilter::SHOW_ALL, PassRefPtr<NodeFilter> ()); 1513 return TreeWalker::create(root, NodeFilter::SHOW_ALL, PassRefPtr<NodeFilter> ());
1514 } 1514 }
1515 1515
1516 PassRefPtr<TreeWalker> Document::createTreeWalker(Node* root, unsigned whatToSho w, ExceptionState& exceptionState) 1516 PassRefPtr<TreeWalker> Document::createTreeWalker(Node* root, unsigned whatToSho w, ExceptionState& exceptionState)
1517 { 1517 {
1518 if (!root) { 1518 if (!root) {
1519 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Node")); 1519 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Node"));
1520 return 0; 1520 return nullptr;
1521 } 1521 }
1522 return TreeWalker::create(root, whatToShow, PassRefPtr<NodeFilter>()); 1522 return TreeWalker::create(root, whatToShow, PassRefPtr<NodeFilter>());
1523 } 1523 }
1524 1524
1525 PassRefPtr<TreeWalker> Document::createTreeWalker(Node* root, unsigned whatToSho w, PassRefPtr<NodeFilter> filter, ExceptionState& exceptionState) 1525 PassRefPtr<TreeWalker> Document::createTreeWalker(Node* root, unsigned whatToSho w, PassRefPtr<NodeFilter> filter, ExceptionState& exceptionState)
1526 { 1526 {
1527 if (!root) { 1527 if (!root) {
1528 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Node")); 1528 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "Node"));
1529 return 0; 1529 return nullptr;
1530 } 1530 }
1531 return TreeWalker::create(root, whatToShow, filter); 1531 return TreeWalker::create(root, whatToShow, filter);
1532 } 1532 }
1533 1533
1534 bool Document::shouldCallRecalcStyleForDocument() 1534 bool Document::shouldCallRecalcStyleForDocument()
1535 { 1535 {
1536 if (!isActive() || !view()) 1536 if (!isActive() || !view())
1537 return false; 1537 return false;
1538 return needsStyleRecalc() || childNeedsStyleRecalc() || childNeedsDistributi onRecalc() || !m_useElementsNeedingUpdate.isEmpty() || childNeedsStyleInvalidati on(); 1538 return needsStyleRecalc() || childNeedsStyleRecalc() || childNeedsDistributi onRecalc() || !m_useElementsNeedingUpdate.isEmpty() || childNeedsStyleInvalidati on();
1539 } 1539 }
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
1875 if (!m_clearFocusedElementTimer.isActive()) 1875 if (!m_clearFocusedElementTimer.isActive())
1876 m_clearFocusedElementTimer.startOneShot(0); 1876 m_clearFocusedElementTimer.startOneShot(0);
1877 } 1877 }
1878 1878
1879 void Document::clearFocusedElementTimerFired(Timer<Document>*) 1879 void Document::clearFocusedElementTimerFired(Timer<Document>*)
1880 { 1880 {
1881 updateStyleIfNeeded(); 1881 updateStyleIfNeeded();
1882 m_clearFocusedElementTimer.stop(); 1882 m_clearFocusedElementTimer.stop();
1883 1883
1884 if (m_focusedElement && !m_focusedElement->isFocusable()) 1884 if (m_focusedElement && !m_focusedElement->isFocusable())
1885 setFocusedElement(0); 1885 setFocusedElement(nullptr);
1886 } 1886 }
1887 1887
1888 void Document::recalcStyleForLayoutIgnoringPendingStylesheets() 1888 void Document::recalcStyleForLayoutIgnoringPendingStylesheets()
1889 { 1889 {
1890 ASSERT(m_styleEngine->ignoringPendingStylesheets()); 1890 ASSERT(m_styleEngine->ignoringPendingStylesheets());
1891 1891
1892 if (!m_styleEngine->hasPendingSheets()) 1892 if (!m_styleEngine->hasPendingSheets())
1893 return; 1893 return;
1894 1894
1895 // FIXME: We are willing to attempt to suppress painting with outdated style info only once. 1895 // FIXME: We are willing to attempt to suppress painting with outdated style info only once.
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
2117 FrameView* view = m_frame->view(); 2117 FrameView* view = m_frame->view();
2118 if (view) 2118 if (view)
2119 view->detachCustomScrollbars(); 2119 view->detachCustomScrollbars();
2120 } 2120 }
2121 2121
2122 // Indicate destruction mode by setting the renderer to null. 2122 // Indicate destruction mode by setting the renderer to null.
2123 // FIXME: Don't do this and use m_lifecycle.state() == Stopping instead. 2123 // FIXME: Don't do this and use m_lifecycle.state() == Stopping instead.
2124 setRenderer(0); 2124 setRenderer(0);
2125 m_renderView = 0; 2125 m_renderView = 0;
2126 2126
2127 m_hoverNode = 0; 2127 m_hoverNode = nullptr;
2128 m_focusedElement = 0; 2128 m_focusedElement = nullptr;
2129 m_activeHoverElement = 0; 2129 m_activeHoverElement = nullptr;
2130 m_autofocusElement = 0; 2130 m_autofocusElement = nullptr;
2131 2131
2132 ContainerNode::detach(context); 2132 ContainerNode::detach(context);
2133 2133
2134 m_styleEngine->didDetach(); 2134 m_styleEngine->didDetach();
2135 2135
2136 if (renderView) 2136 if (renderView)
2137 renderView->destroy(); 2137 renderView->destroy();
2138 2138
2139 if (Document* parentDoc = parentDocument()) 2139 if (Document* parentDoc = parentDocument())
2140 parentDoc->didClearTouchEventHandlers(this); 2140 parentDoc->didClearTouchEventHandlers(this);
(...skipping 1195 matching lines...) Expand 10 before | Expand all | Expand 10 after
3336 void Document::removeFocusedElementOfSubtree(Node* node, bool amongChildrenOnly) 3336 void Document::removeFocusedElementOfSubtree(Node* node, bool amongChildrenOnly)
3337 { 3337 {
3338 if (!m_focusedElement) 3338 if (!m_focusedElement)
3339 return; 3339 return;
3340 3340
3341 // We can't be focused if we're not in the document. 3341 // We can't be focused if we're not in the document.
3342 if (!node->inDocument()) 3342 if (!node->inDocument())
3343 return; 3343 return;
3344 bool contains = node->containsIncludingShadowDOM(m_focusedElement.get()); 3344 bool contains = node->containsIncludingShadowDOM(m_focusedElement.get());
3345 if (contains && (m_focusedElement != node || !amongChildrenOnly)) 3345 if (contains && (m_focusedElement != node || !amongChildrenOnly))
3346 setFocusedElement(0); 3346 setFocusedElement(nullptr);
3347 } 3347 }
3348 3348
3349 void Document::hoveredNodeDetached(Node* node) 3349 void Document::hoveredNodeDetached(Node* node)
3350 { 3350 {
3351 if (!m_hoverNode) 3351 if (!m_hoverNode)
3352 return; 3352 return;
3353 3353
3354 if (node != m_hoverNode && (!m_hoverNode->isTextNode() || node != NodeRender ingTraversal::parent(m_hoverNode.get()))) 3354 if (node != m_hoverNode && (!m_hoverNode->isTextNode() || node != NodeRender ingTraversal::parent(m_hoverNode.get())))
3355 return; 3355 return;
3356 3356
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
3405 return true; 3405 return true;
3406 3406
3407 if (NodeChildRemovalTracker::isBeingRemoved(newFocusedElement.get())) 3407 if (NodeChildRemovalTracker::isBeingRemoved(newFocusedElement.get()))
3408 return true; 3408 return true;
3409 3409
3410 if (m_focusedElement == newFocusedElement) 3410 if (m_focusedElement == newFocusedElement)
3411 return true; 3411 return true;
3412 3412
3413 bool focusChangeBlocked = false; 3413 bool focusChangeBlocked = false;
3414 RefPtr<Element> oldFocusedElement = m_focusedElement; 3414 RefPtr<Element> oldFocusedElement = m_focusedElement;
3415 m_focusedElement = 0; 3415 m_focusedElement = nullptr;
3416 3416
3417 // Remove focus from the existing focus node (if any) 3417 // Remove focus from the existing focus node (if any)
3418 if (oldFocusedElement) { 3418 if (oldFocusedElement) {
3419 ASSERT(!oldFocusedElement->inDetach()); 3419 ASSERT(!oldFocusedElement->inDetach());
3420 3420
3421 if (oldFocusedElement->active()) 3421 if (oldFocusedElement->active())
3422 oldFocusedElement->setActive(false); 3422 oldFocusedElement->setActive(false);
3423 3423
3424 oldFocusedElement->setFocus(false); 3424 oldFocusedElement->setFocus(false);
3425 3425
3426 // Dispatch the blur event and let the node do any other blur related ac tivities (important for text fields) 3426 // Dispatch the blur event and let the node do any other blur related ac tivities (important for text fields)
3427 // If page lost focus, blur event will have already been dispatched 3427 // If page lost focus, blur event will have already been dispatched
3428 if (page() && (page()->focusController().isFocused())) { 3428 if (page() && (page()->focusController().isFocused())) {
3429 oldFocusedElement->dispatchBlurEvent(newFocusedElement.get()); 3429 oldFocusedElement->dispatchBlurEvent(newFocusedElement.get());
3430 3430
3431 if (m_focusedElement) { 3431 if (m_focusedElement) {
3432 // handler shifted focus 3432 // handler shifted focus
3433 focusChangeBlocked = true; 3433 focusChangeBlocked = true;
3434 newFocusedElement = 0; 3434 newFocusedElement = nullptr;
3435 } 3435 }
3436 3436
3437 oldFocusedElement->dispatchFocusOutEvent(EventTypeNames::focusout, n ewFocusedElement.get()); // DOM level 3 name for the bubbling blur event. 3437 oldFocusedElement->dispatchFocusOutEvent(EventTypeNames::focusout, n ewFocusedElement.get()); // DOM level 3 name for the bubbling blur event.
3438 // FIXME: We should remove firing DOMFocusOutEvent event when we are sure no content depends 3438 // FIXME: We should remove firing DOMFocusOutEvent event when we are sure no content depends
3439 // on it, probably when <rdar://problem/8503958> is resolved. 3439 // on it, probably when <rdar://problem/8503958> is resolved.
3440 oldFocusedElement->dispatchFocusOutEvent(EventTypeNames::DOMFocusOut , newFocusedElement.get()); // DOM level 2 name for compatibility. 3440 oldFocusedElement->dispatchFocusOutEvent(EventTypeNames::DOMFocusOut , newFocusedElement.get()); // DOM level 2 name for compatibility.
3441 3441
3442 if (m_focusedElement) { 3442 if (m_focusedElement) {
3443 // handler shifted focus 3443 // handler shifted focus
3444 focusChangeBlocked = true; 3444 focusChangeBlocked = true;
3445 newFocusedElement = 0; 3445 newFocusedElement = nullptr;
3446 } 3446 }
3447 } 3447 }
3448 3448
3449 if (view()) { 3449 if (view()) {
3450 Widget* oldWidget = widgetForElement(*oldFocusedElement); 3450 Widget* oldWidget = widgetForElement(*oldFocusedElement);
3451 if (oldWidget) 3451 if (oldWidget)
3452 oldWidget->setFocus(false); 3452 oldWidget->setFocus(false);
3453 else 3453 else
3454 view()->setFocus(false); 3454 view()->setFocus(false);
3455 } 3455 }
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
3733 ensureScriptedAnimationController().enqueuePerFrameEvent(event.release()); 3733 ensureScriptedAnimationController().enqueuePerFrameEvent(event.release());
3734 } 3734 }
3735 3735
3736 PassRefPtr<Event> Document::createEvent(const String& eventType, ExceptionState& exceptionState) 3736 PassRefPtr<Event> Document::createEvent(const String& eventType, ExceptionState& exceptionState)
3737 { 3737 {
3738 RefPtr<Event> event = EventFactory::create(eventType); 3738 RefPtr<Event> event = EventFactory::create(eventType);
3739 if (event) 3739 if (event)
3740 return event.release(); 3740 return event.release();
3741 3741
3742 exceptionState.throwDOMException(NotSupportedError, "The provided event type ('" + eventType + "') is invalid."); 3742 exceptionState.throwDOMException(NotSupportedError, "The provided event type ('" + eventType + "') is invalid.");
3743 return 0; 3743 return nullptr;
3744 } 3744 }
3745 3745
3746 PassRefPtr<Event> Document::createEvent(ExceptionState& exceptionState) 3746 PassRefPtr<Event> Document::createEvent(ExceptionState& exceptionState)
3747 { 3747 {
3748 if (!isSVGDocument()) { 3748 if (!isSVGDocument()) {
3749 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, 0 )); 3749 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, 0 ));
3750 return 0; 3750 return nullptr;
3751 } 3751 }
3752 3752
3753 UseCounter::count(this, UseCounter::DocumentCreateEventOptionalArgument); 3753 UseCounter::count(this, UseCounter::DocumentCreateEventOptionalArgument);
3754 // Legacy SVGDocument behavior. 3754 // Legacy SVGDocument behavior.
3755 return createEvent("undefined", exceptionState); 3755 return createEvent("undefined", exceptionState);
3756 } 3756 }
3757 3757
3758 void Document::addMutationEventListenerTypeIfEnabled(ListenerType listenerType) 3758 void Document::addMutationEventListenerTypeIfEnabled(ListenerType listenerType)
3759 { 3759 {
3760 if (ContextFeatures::mutationEventsEnabled(this)) 3760 if (ContextFeatures::mutationEventsEnabled(this))
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
4318 4318
4319 return doc; 4319 return doc;
4320 } 4320 }
4321 4321
4322 WeakPtr<Document> Document::contextDocument() 4322 WeakPtr<Document> Document::contextDocument()
4323 { 4323 {
4324 if (m_contextDocument) 4324 if (m_contextDocument)
4325 return m_contextDocument; 4325 return m_contextDocument;
4326 if (m_frame) 4326 if (m_frame)
4327 return m_weakFactory.createWeakPtr(); 4327 return m_weakFactory.createWeakPtr();
4328 return WeakPtr<Document>(0); 4328 return WeakPtr<Document>(nullptr);
4329 } 4329 }
4330 4330
4331 PassRefPtr<Attr> Document::createAttribute(const AtomicString& name, ExceptionSt ate& exceptionState) 4331 PassRefPtr<Attr> Document::createAttribute(const AtomicString& name, ExceptionSt ate& exceptionState)
4332 { 4332 {
4333 AtomicString prefix, localName; 4333 AtomicString prefix, localName;
4334 if (!parseQualifiedName(name, prefix, localName, exceptionState)) 4334 if (!parseQualifiedName(name, prefix, localName, exceptionState))
4335 return 0; 4335 return nullptr;
4336 4336
4337 QualifiedName qName(prefix, localName, nullAtom); 4337 QualifiedName qName(prefix, localName, nullAtom);
4338 4338
4339 return Attr::create(*this, qName, emptyAtom); 4339 return Attr::create(*this, qName, emptyAtom);
4340 } 4340 }
4341 4341
4342 const SVGDocumentExtensions* Document::svgExtensions() 4342 const SVGDocumentExtensions* Document::svgExtensions()
4343 { 4343 {
4344 return m_svgExtensions.get(); 4344 return m_svgExtensions.get();
4345 } 4345 }
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
4467 } 4467 }
4468 4468
4469 Vector<IconURL> Document::iconURLs(int iconTypesMask) 4469 Vector<IconURL> Document::iconURLs(int iconTypesMask)
4470 { 4470 {
4471 IconURL firstFavicon; 4471 IconURL firstFavicon;
4472 IconURL firstTouchIcon; 4472 IconURL firstTouchIcon;
4473 IconURL firstTouchPrecomposedIcon; 4473 IconURL firstTouchPrecomposedIcon;
4474 Vector<IconURL> secondaryIcons; 4474 Vector<IconURL> secondaryIcons;
4475 4475
4476 // Start from the last child node so that icons seen later take precedence a s required by the spec. 4476 // Start from the last child node so that icons seen later take precedence a s required by the spec.
4477 RefPtr<HTMLCollection> children = head() ? head()->children() : 0; 4477 RefPtr<HTMLCollection> children = head() ? head()->children() : nullptr;
4478 unsigned length = children ? children->length() : 0; 4478 unsigned length = children ? children->length() : 0;
4479 for (unsigned i = 0; i < length; i++) { 4479 for (unsigned i = 0; i < length; i++) {
4480 Element* child = children->item(i); 4480 Element* child = children->item(i);
4481 if (!child->hasTagName(linkTag)) 4481 if (!child->hasTagName(linkTag))
4482 continue; 4482 continue;
4483 HTMLLinkElement* linkElement = toHTMLLinkElement(child); 4483 HTMLLinkElement* linkElement = toHTMLLinkElement(child);
4484 if (!(linkElement->iconType() & iconTypesMask)) 4484 if (!(linkElement->iconType() & iconTypesMask))
4485 continue; 4485 continue;
4486 if (linkElement->href().isEmpty()) 4486 if (linkElement->href().isEmpty())
4487 continue; 4487 continue;
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
4712 { 4712 {
4713 HTMLCanvasElement* element = getCSSCanvasElement(name); 4713 HTMLCanvasElement* element = getCSSCanvasElement(name);
4714 if (!element) 4714 if (!element)
4715 return 0; 4715 return 0;
4716 element->setSize(IntSize(width, height)); 4716 element->setSize(IntSize(width, height));
4717 return element->getContext(type); 4717 return element->getContext(type);
4718 } 4718 }
4719 4719
4720 HTMLCanvasElement* Document::getCSSCanvasElement(const String& name) 4720 HTMLCanvasElement* Document::getCSSCanvasElement(const String& name)
4721 { 4721 {
4722 RefPtr<HTMLCanvasElement>& element = m_cssCanvasElements.add(name, 0).stored Value->value; 4722 RefPtr<HTMLCanvasElement>& element = m_cssCanvasElements.add(name, nullptr). storedValue->value;
4723 if (!element) { 4723 if (!element) {
4724 element = HTMLCanvasElement::create(*this); 4724 element = HTMLCanvasElement::create(*this);
4725 element->setAccelerationDisabled(true); 4725 element->setAccelerationDisabled(true);
4726 } 4726 }
4727 return element.get(); 4727 return element.get();
4728 } 4728 }
4729 4729
4730 void Document::initDNSPrefetch() 4730 void Document::initDNSPrefetch()
4731 { 4731 {
4732 Settings* settings = this->settings(); 4732 Settings* settings = this->settings();
(...skipping 19 matching lines...) Expand all
4752 m_haveExplicitlyDisabledDNSPrefetch = true; 4752 m_haveExplicitlyDisabledDNSPrefetch = true;
4753 } 4753 }
4754 4754
4755 void Document::reportBlockedScriptExecutionToInspector(const String& directiveTe xt) 4755 void Document::reportBlockedScriptExecutionToInspector(const String& directiveTe xt)
4756 { 4756 {
4757 InspectorInstrumentation::scriptExecutionBlockedByCSP(this, directiveText); 4757 InspectorInstrumentation::scriptExecutionBlockedByCSP(this, directiveText);
4758 } 4758 }
4759 4759
4760 void Document::addMessage(MessageSource source, MessageLevel level, const String & message, const String& sourceURL, unsigned lineNumber, ScriptState* state) 4760 void Document::addMessage(MessageSource source, MessageLevel level, const String & message, const String& sourceURL, unsigned lineNumber, ScriptState* state)
4761 { 4761 {
4762 internalAddMessage(source, level, message, sourceURL, lineNumber, 0, state); 4762 internalAddMessage(source, level, message, sourceURL, lineNumber, nullptr, s tate);
4763 } 4763 }
4764 4764
4765 void Document::internalAddMessage(MessageSource source, MessageLevel level, cons t String& message, const String& sourceURL, unsigned lineNumber, PassRefPtr<Scri ptCallStack> callStack, ScriptState* state) 4765 void Document::internalAddMessage(MessageSource source, MessageLevel level, cons t String& message, const String& sourceURL, unsigned lineNumber, PassRefPtr<Scri ptCallStack> callStack, ScriptState* state)
4766 { 4766 {
4767 if (!isContextThread()) { 4767 if (!isContextThread()) {
4768 m_taskRunner->postTask(AddConsoleMessageTask::create(source, level, mess age)); 4768 m_taskRunner->postTask(AddConsoleMessageTask::create(source, level, mess age));
4769 return; 4769 return;
4770 } 4770 }
4771 FrameHost* host = frameHost(); 4771 FrameHost* host = frameHost();
4772 if (!host) 4772 if (!host)
(...skipping 12 matching lines...) Expand all
4785 } 4785 }
4786 4786
4787 void Document::addConsoleMessageWithRequestIdentifier(MessageSource source, Mess ageLevel level, const String& message, unsigned long requestIdentifier) 4787 void Document::addConsoleMessageWithRequestIdentifier(MessageSource source, Mess ageLevel level, const String& message, unsigned long requestIdentifier)
4788 { 4788 {
4789 if (!isContextThread()) { 4789 if (!isContextThread()) {
4790 m_taskRunner->postTask(AddConsoleMessageTask::create(source, level, mess age)); 4790 m_taskRunner->postTask(AddConsoleMessageTask::create(source, level, mess age));
4791 return; 4791 return;
4792 } 4792 }
4793 4793
4794 if (FrameHost* host = frameHost()) 4794 if (FrameHost* host = frameHost())
4795 host->console().addMessage(source, level, message, String(), 0, 0, 0, 0, requestIdentifier); 4795 host->console().addMessage(source, level, message, String(), 0, 0, nullp tr, 0, requestIdentifier);
4796 } 4796 }
4797 4797
4798 // FIXME(crbug.com/305497): This should be removed after ExecutionContext-DOMWin dow migration. 4798 // FIXME(crbug.com/305497): This should be removed after ExecutionContext-DOMWin dow migration.
4799 void Document::postTask(PassOwnPtr<ExecutionContextTask> task) 4799 void Document::postTask(PassOwnPtr<ExecutionContextTask> task)
4800 { 4800 {
4801 m_taskRunner->postTask(task); 4801 m_taskRunner->postTask(task);
4802 } 4802 }
4803 4803
4804 void Document::tasksWereSuspended() 4804 void Document::tasksWereSuspended()
4805 { 4805 {
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
5162 Element* oldActiveElement = activeHoverElement(); 5162 Element* oldActiveElement = activeHoverElement();
5163 if (oldActiveElement && !request.active()) { 5163 if (oldActiveElement && !request.active()) {
5164 // We are clearing the :active chain because the mouse has been released . 5164 // We are clearing the :active chain because the mouse has been released .
5165 for (RenderObject* curr = oldActiveElement->renderer(); curr; curr = cur r->parent()) { 5165 for (RenderObject* curr = oldActiveElement->renderer(); curr; curr = cur r->parent()) {
5166 if (curr->node()) { 5166 if (curr->node()) {
5167 ASSERT(!curr->node()->isTextNode()); 5167 ASSERT(!curr->node()->isTextNode());
5168 curr->node()->setActive(false); 5168 curr->node()->setActive(false);
5169 m_userActionElements.setInActiveChain(curr->node(), false); 5169 m_userActionElements.setInActiveChain(curr->node(), false);
5170 } 5170 }
5171 } 5171 }
5172 setActiveHoverElement(0); 5172 setActiveHoverElement(nullptr);
5173 } else { 5173 } else {
5174 Element* newActiveElement = innerElementInDocument; 5174 Element* newActiveElement = innerElementInDocument;
5175 if (!oldActiveElement && newActiveElement && request.active() && !reques t.touchMove()) { 5175 if (!oldActiveElement && newActiveElement && request.active() && !reques t.touchMove()) {
5176 // We are setting the :active chain and freezing it. If future moves happen, they 5176 // We are setting the :active chain and freezing it. If future moves happen, they
5177 // will need to reference this chain. 5177 // will need to reference this chain.
5178 for (RenderObject* curr = newActiveElement->renderer(); curr; curr = curr->parent()) { 5178 for (RenderObject* curr = newActiveElement->renderer(); curr; curr = curr->parent()) {
5179 if (curr->node() && !curr->isText()) 5179 if (curr->node() && !curr->isText())
5180 m_userActionElements.setInActiveChain(curr->node(), true); 5180 m_userActionElements.setInActiveChain(curr->node(), true);
5181 } 5181 }
5182 5182
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
5393 FastTextAutosizer* Document::fastTextAutosizer() 5393 FastTextAutosizer* Document::fastTextAutosizer()
5394 { 5394 {
5395 if (!m_fastTextAutosizer && RuntimeEnabledFeatures::fastTextAutosizingEnable d()) 5395 if (!m_fastTextAutosizer && RuntimeEnabledFeatures::fastTextAutosizingEnable d())
5396 m_fastTextAutosizer = FastTextAutosizer::create(this); 5396 m_fastTextAutosizer = FastTextAutosizer::create(this);
5397 return m_fastTextAutosizer.get(); 5397 return m_fastTextAutosizer.get();
5398 } 5398 }
5399 5399
5400 void Document::setAutofocusElement(Element* element) 5400 void Document::setAutofocusElement(Element* element)
5401 { 5401 {
5402 if (!element) { 5402 if (!element) {
5403 m_autofocusElement = 0; 5403 m_autofocusElement = nullptr;
5404 return; 5404 return;
5405 } 5405 }
5406 if (m_hasAutofocused) 5406 if (m_hasAutofocused)
5407 return; 5407 return;
5408 m_hasAutofocused = true; 5408 m_hasAutofocused = true;
5409 ASSERT(!m_autofocusElement); 5409 ASSERT(!m_autofocusElement);
5410 m_autofocusElement = element; 5410 m_autofocusElement = element;
5411 m_taskRunner->postTask(AutofocusTask::create()); 5411 m_taskRunner->postTask(AutofocusTask::create());
5412 } 5412 }
5413 5413
(...skipping 23 matching lines...) Expand all
5437 void Document::defaultEventHandler(Event* event) 5437 void Document::defaultEventHandler(Event* event)
5438 { 5438 {
5439 if (frame() && frame()->remotePlatformLayer()) { 5439 if (frame() && frame()->remotePlatformLayer()) {
5440 frame()->chromeClient().forwardInputEvent(this, event); 5440 frame()->chromeClient().forwardInputEvent(this, event);
5441 return; 5441 return;
5442 } 5442 }
5443 Node::defaultEventHandler(event); 5443 Node::defaultEventHandler(event);
5444 } 5444 }
5445 5445
5446 } // namespace WebCore 5446 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/DOMImplementation.cpp ('k') | Source/core/dom/DocumentInit.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698