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

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

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
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 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 *errorMessage = origin->isPotentiallyTrustworthyErrorMessage(); 354 *errorMessage = origin->isPotentiallyTrustworthyErrorMessage();
355 return false; 355 return false;
356 } 356 }
357 357
358 uint64_t Document::s_globalTreeVersion = 0; 358 uint64_t Document::s_globalTreeVersion = 0;
359 359
360 static bool s_threadedParsingEnabledForTesting = true; 360 static bool s_threadedParsingEnabledForTesting = true;
361 361
362 Document::WeakDocumentSet& Document::liveDocumentSet() 362 Document::WeakDocumentSet& Document::liveDocumentSet()
363 { 363 {
364 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<WeakDocumentSet>, set, (adoptPtrW illBeNoop(new WeakDocumentSet()))); 364 DEFINE_STATIC_LOCAL(Persistent<WeakDocumentSet>, set, (new WeakDocumentSet() ));
365 return *set; 365 return *set;
366 } 366 }
367 367
368 // This class doesn't work with non-Document ExecutionContext. 368 // This class doesn't work with non-Document ExecutionContext.
369 class AutofocusTask final : public ExecutionContextTask { 369 class AutofocusTask final : public ExecutionContextTask {
370 public: 370 public:
371 static PassOwnPtr<AutofocusTask> create() 371 static PassOwnPtr<AutofocusTask> create()
372 { 372 {
373 return adoptPtr(new AutofocusTask()); 373 return adoptPtr(new AutofocusTask());
374 } 374 }
375 ~AutofocusTask() override { } 375 ~AutofocusTask() override { }
376 376
377 private: 377 private:
378 AutofocusTask() { } 378 AutofocusTask() { }
379 void performTask(ExecutionContext* context) override 379 void performTask(ExecutionContext* context) override
380 { 380 {
381 Document* document = toDocument(context); 381 Document* document = toDocument(context);
382 if (RefPtrWillBeRawPtr<Element> element = document->autofocusElement()) { 382 if (RawPtr<Element> element = document->autofocusElement()) {
383 document->setAutofocusElement(0); 383 document->setAutofocusElement(0);
384 element->focus(); 384 element->focus();
385 } 385 }
386 } 386 }
387 }; 387 };
388 388
389 Document::Document(const DocumentInit& initializer, DocumentClassFlags documentC lasses) 389 Document::Document(const DocumentInit& initializer, DocumentClassFlags documentC lasses)
390 : ContainerNode(0, CreateDocument) 390 : ContainerNode(0, CreateDocument)
391 , TreeScope(*this) 391 , TreeScope(*this)
392 , m_hasNodesWithPlaceholderStyle(false) 392 , m_hasNodesWithPlaceholderStyle(false)
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 return; 652 return;
653 m_compatibilityMode = mode; 653 m_compatibilityMode = mode;
654 selectorQueryCache().invalidate(); 654 selectorQueryCache().invalidate();
655 } 655 }
656 656
657 String Document::compatMode() const 657 String Document::compatMode() const
658 { 658 {
659 return inQuirksMode() ? "BackCompat" : "CSS1Compat"; 659 return inQuirksMode() ? "BackCompat" : "CSS1Compat";
660 } 660 }
661 661
662 void Document::setDoctype(PassRefPtrWillBeRawPtr<DocumentType> docType) 662 void Document::setDoctype(RawPtr<DocumentType> docType)
663 { 663 {
664 // This should never be called more than once. 664 // This should never be called more than once.
665 ASSERT(!m_docType || !docType); 665 ASSERT(!m_docType || !docType);
666 m_docType = docType; 666 m_docType = docType;
667 if (m_docType) { 667 if (m_docType) {
668 this->adoptIfNeeded(*m_docType); 668 this->adoptIfNeeded(*m_docType);
669 if (m_docType->publicId().startsWith("-//wapforum//dtd xhtml mobile 1.", TextCaseInsensitive)) 669 if (m_docType->publicId().startsWith("-//wapforum//dtd xhtml mobile 1.", TextCaseInsensitive))
670 m_isMobileDocument = true; 670 m_isMobileDocument = true;
671 } 671 }
672 // Doctype affects the interpretation of the stylesheets. 672 // Doctype affects the interpretation of the stylesheets.
(...skipping 24 matching lines...) Expand all
697 { 697 {
698 ContainerNode::childrenChanged(change); 698 ContainerNode::childrenChanged(change);
699 m_documentElement = ElementTraversal::firstWithin(*this); 699 m_documentElement = ElementTraversal::firstWithin(*this);
700 } 700 }
701 701
702 AtomicString Document::convertLocalName(const AtomicString& name) 702 AtomicString Document::convertLocalName(const AtomicString& name)
703 { 703 {
704 return isHTMLDocument() ? name.lower() : name; 704 return isHTMLDocument() ? name.lower() : name;
705 } 705 }
706 706
707 PassRefPtrWillBeRawPtr<Element> Document::createElement(const AtomicString& name , ExceptionState& exceptionState) 707 RawPtr<Element> Document::createElement(const AtomicString& name, ExceptionState & exceptionState)
708 { 708 {
709 if (!isValidName(name)) { 709 if (!isValidName(name)) {
710 exceptionState.throwDOMException(InvalidCharacterError, "The tag name pr ovided ('" + name + "') is not a valid name."); 710 exceptionState.throwDOMException(InvalidCharacterError, "The tag name pr ovided ('" + name + "') is not a valid name.");
711 return nullptr; 711 return nullptr;
712 } 712 }
713 713
714 if (isXHTMLDocument() || isHTMLDocument()) 714 if (isXHTMLDocument() || isHTMLDocument())
715 return HTMLElementFactory::createHTMLElement(convertLocalName(name), *th is, 0, false); 715 return HTMLElementFactory::createHTMLElement(convertLocalName(name), *th is, 0, false);
716 716
717 return Element::create(QualifiedName(nullAtom, name, nullAtom), this); 717 return Element::create(QualifiedName(nullAtom, name, nullAtom), this);
718 } 718 }
719 719
720 PassRefPtrWillBeRawPtr<Element> Document::createElement(const AtomicString& loca lName, const AtomicString& typeExtension, ExceptionState& exceptionState) 720 RawPtr<Element> Document::createElement(const AtomicString& localName, const Ato micString& typeExtension, ExceptionState& exceptionState)
721 { 721 {
722 if (!isValidName(localName)) { 722 if (!isValidName(localName)) {
723 exceptionState.throwDOMException(InvalidCharacterError, "The tag name pr ovided ('" + localName + "') is not a valid name."); 723 exceptionState.throwDOMException(InvalidCharacterError, "The tag name pr ovided ('" + localName + "') is not a valid name.");
724 return nullptr; 724 return nullptr;
725 } 725 }
726 726
727 RefPtrWillBeRawPtr<Element> element; 727 RawPtr<Element> element;
728 728
729 if (CustomElement::isValidName(localName) && registrationContext()) { 729 if (CustomElement::isValidName(localName) && registrationContext()) {
730 element = registrationContext()->createCustomTagElement(*this, Qualified Name(nullAtom, convertLocalName(localName), xhtmlNamespaceURI)); 730 element = registrationContext()->createCustomTagElement(*this, Qualified Name(nullAtom, convertLocalName(localName), xhtmlNamespaceURI));
731 } else { 731 } else {
732 element = createElement(localName, exceptionState); 732 element = createElement(localName, exceptionState);
733 if (exceptionState.hadException()) 733 if (exceptionState.hadException())
734 return nullptr; 734 return nullptr;
735 } 735 }
736 736
737 if (!typeExtension.isEmpty()) 737 if (!typeExtension.isEmpty())
(...skipping 10 matching lines...) Expand all
748 748
749 QualifiedName qName(prefix, localName, namespaceURI); 749 QualifiedName qName(prefix, localName, namespaceURI);
750 if (!Document::hasValidNamespaceForElements(qName)) { 750 if (!Document::hasValidNamespaceForElements(qName)) {
751 exceptionState.throwDOMException(NamespaceError, "The namespace URI prov ided ('" + namespaceURI + "') is not valid for the qualified name provided ('" + qualifiedName + "')."); 751 exceptionState.throwDOMException(NamespaceError, "The namespace URI prov ided ('" + namespaceURI + "') is not valid for the qualified name provided ('" + qualifiedName + "').");
752 return QualifiedName::null(); 752 return QualifiedName::null();
753 } 753 }
754 754
755 return qName; 755 return qName;
756 } 756 }
757 757
758 PassRefPtrWillBeRawPtr<Element> Document::createElementNS(const AtomicString& na mespaceURI, const AtomicString& qualifiedName, ExceptionState& exceptionState) 758 RawPtr<Element> Document::createElementNS(const AtomicString& namespaceURI, cons t AtomicString& qualifiedName, ExceptionState& exceptionState)
759 { 759 {
760 QualifiedName qName(createQualifiedName(namespaceURI, qualifiedName, excepti onState)); 760 QualifiedName qName(createQualifiedName(namespaceURI, qualifiedName, excepti onState));
761 if (qName == QualifiedName::null()) 761 if (qName == QualifiedName::null())
762 return nullptr; 762 return nullptr;
763 763
764 return createElement(qName, false); 764 return createElement(qName, false);
765 } 765 }
766 766
767 PassRefPtrWillBeRawPtr<Element> Document::createElementNS(const AtomicString& na mespaceURI, const AtomicString& qualifiedName, const AtomicString& typeExtension , ExceptionState& exceptionState) 767 RawPtr<Element> Document::createElementNS(const AtomicString& namespaceURI, cons t AtomicString& qualifiedName, const AtomicString& typeExtension, ExceptionState & exceptionState)
768 { 768 {
769 QualifiedName qName(createQualifiedName(namespaceURI, qualifiedName, excepti onState)); 769 QualifiedName qName(createQualifiedName(namespaceURI, qualifiedName, excepti onState));
770 if (qName == QualifiedName::null()) 770 if (qName == QualifiedName::null())
771 return nullptr; 771 return nullptr;
772 772
773 RefPtrWillBeRawPtr<Element> element; 773 RawPtr<Element> element;
774 if (CustomElement::isValidName(qName.localName()) && registrationContext()) 774 if (CustomElement::isValidName(qName.localName()) && registrationContext())
775 element = registrationContext()->createCustomTagElement(*this, qName); 775 element = registrationContext()->createCustomTagElement(*this, qName);
776 else 776 else
777 element = createElement(qName, false); 777 element = createElement(qName, false);
778 778
779 if (!typeExtension.isEmpty()) 779 if (!typeExtension.isEmpty())
780 CustomElementRegistrationContext::setIsAttributeAndTypeExtension(element .get(), typeExtension); 780 CustomElementRegistrationContext::setIsAttributeAndTypeExtension(element .get(), typeExtension);
781 781
782 return element.release(); 782 return element.release();
783 } 783 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 } 835 }
836 836
837 LocalFrame* Document::executingFrame() 837 LocalFrame* Document::executingFrame()
838 { 838 {
839 LocalDOMWindow* window = executingWindow(); 839 LocalDOMWindow* window = executingWindow();
840 if (!window) 840 if (!window)
841 return 0; 841 return 0;
842 return window->frame(); 842 return window->frame();
843 } 843 }
844 844
845 PassRefPtrWillBeRawPtr<DocumentFragment> Document::createDocumentFragment() 845 RawPtr<DocumentFragment> Document::createDocumentFragment()
846 { 846 {
847 return DocumentFragment::create(*this); 847 return DocumentFragment::create(*this);
848 } 848 }
849 849
850 PassRefPtrWillBeRawPtr<Text> Document::createTextNode(const String& data) 850 RawPtr<Text> Document::createTextNode(const String& data)
851 { 851 {
852 return Text::create(*this, data); 852 return Text::create(*this, data);
853 } 853 }
854 854
855 PassRefPtrWillBeRawPtr<Comment> Document::createComment(const String& data) 855 RawPtr<Comment> Document::createComment(const String& data)
856 { 856 {
857 return Comment::create(*this, data); 857 return Comment::create(*this, data);
858 } 858 }
859 859
860 PassRefPtrWillBeRawPtr<CDATASection> Document::createCDATASection(const String& data, ExceptionState& exceptionState) 860 RawPtr<CDATASection> Document::createCDATASection(const String& data, ExceptionS tate& exceptionState)
861 { 861 {
862 if (isHTMLDocument()) { 862 if (isHTMLDocument()) {
863 exceptionState.throwDOMException(NotSupportedError, "This operation is n ot supported for HTML documents."); 863 exceptionState.throwDOMException(NotSupportedError, "This operation is n ot supported for HTML documents.");
864 return nullptr; 864 return nullptr;
865 } 865 }
866 if (data.contains("]]>")) { 866 if (data.contains("]]>")) {
867 exceptionState.throwDOMException(InvalidCharacterError, "String cannot c ontain ']]>' since that is the end delimiter of a CData section."); 867 exceptionState.throwDOMException(InvalidCharacterError, "String cannot c ontain ']]>' since that is the end delimiter of a CData section.");
868 return nullptr; 868 return nullptr;
869 } 869 }
870 return CDATASection::create(*this, data); 870 return CDATASection::create(*this, data);
871 } 871 }
872 872
873 PassRefPtrWillBeRawPtr<ProcessingInstruction> Document::createProcessingInstruct ion(const String& target, const String& data, ExceptionState& exceptionState) 873 RawPtr<ProcessingInstruction> Document::createProcessingInstruction(const String & target, const String& data, ExceptionState& exceptionState)
874 { 874 {
875 if (!isValidName(target)) { 875 if (!isValidName(target)) {
876 exceptionState.throwDOMException(InvalidCharacterError, "The target prov ided ('" + target + "') is not a valid name."); 876 exceptionState.throwDOMException(InvalidCharacterError, "The target prov ided ('" + target + "') is not a valid name.");
877 return nullptr; 877 return nullptr;
878 } 878 }
879 if (data.contains("?>")) { 879 if (data.contains("?>")) {
880 exceptionState.throwDOMException(InvalidCharacterError, "The data provid ed ('" + data + "') contains '?>'."); 880 exceptionState.throwDOMException(InvalidCharacterError, "The data provid ed ('" + data + "') contains '?>'.");
881 return nullptr; 881 return nullptr;
882 } 882 }
883 return ProcessingInstruction::create(*this, target, data); 883 return ProcessingInstruction::create(*this, target, data);
884 } 884 }
885 885
886 PassRefPtrWillBeRawPtr<Text> Document::createEditingTextNode(const String& text) 886 RawPtr<Text> Document::createEditingTextNode(const String& text)
887 { 887 {
888 return Text::createEditingText(*this, text); 888 return Text::createEditingText(*this, text);
889 } 889 }
890 890
891 bool Document::importContainerNodeChildren(ContainerNode* oldContainerNode, Pass RefPtrWillBeRawPtr<ContainerNode> newContainerNode, ExceptionState& exceptionSta te) 891 bool Document::importContainerNodeChildren(ContainerNode* oldContainerNode, RawP tr<ContainerNode> newContainerNode, ExceptionState& exceptionState)
892 { 892 {
893 for (Node& oldChild : NodeTraversal::childrenOf(*oldContainerNode)) { 893 for (Node& oldChild : NodeTraversal::childrenOf(*oldContainerNode)) {
894 RefPtrWillBeRawPtr<Node> newChild = importNode(&oldChild, true, exceptio nState); 894 RawPtr<Node> newChild = importNode(&oldChild, true, exceptionState);
895 if (exceptionState.hadException()) 895 if (exceptionState.hadException())
896 return false; 896 return false;
897 newContainerNode->appendChild(newChild.release(), exceptionState); 897 newContainerNode->appendChild(newChild.release(), exceptionState);
898 if (exceptionState.hadException()) 898 if (exceptionState.hadException())
899 return false; 899 return false;
900 } 900 }
901 901
902 return true; 902 return true;
903 } 903 }
904 904
905 PassRefPtrWillBeRawPtr<Node> Document::importNode(Node* importedNode, bool deep, ExceptionState& exceptionState) 905 RawPtr<Node> Document::importNode(Node* importedNode, bool deep, ExceptionState& exceptionState)
906 { 906 {
907 switch (importedNode->getNodeType()) { 907 switch (importedNode->getNodeType()) {
908 case TEXT_NODE: 908 case TEXT_NODE:
909 return createTextNode(importedNode->nodeValue()); 909 return createTextNode(importedNode->nodeValue());
910 case CDATA_SECTION_NODE: 910 case CDATA_SECTION_NODE:
911 return CDATASection::create(*this, importedNode->nodeValue()); 911 return CDATASection::create(*this, importedNode->nodeValue());
912 case PROCESSING_INSTRUCTION_NODE: 912 case PROCESSING_INSTRUCTION_NODE:
913 return createProcessingInstruction(importedNode->nodeName(), importedNod e->nodeValue(), exceptionState); 913 return createProcessingInstruction(importedNode->nodeName(), importedNod e->nodeValue(), exceptionState);
914 case COMMENT_NODE: 914 case COMMENT_NODE:
915 return createComment(importedNode->nodeValue()); 915 return createComment(importedNode->nodeValue());
916 case DOCUMENT_TYPE_NODE: { 916 case DOCUMENT_TYPE_NODE: {
917 DocumentType* doctype = toDocumentType(importedNode); 917 DocumentType* doctype = toDocumentType(importedNode);
918 return DocumentType::create(this, doctype->name(), doctype->publicId(), doctype->systemId()); 918 return DocumentType::create(this, doctype->name(), doctype->publicId(), doctype->systemId());
919 } 919 }
920 case ELEMENT_NODE: { 920 case ELEMENT_NODE: {
921 Element* oldElement = toElement(importedNode); 921 Element* oldElement = toElement(importedNode);
922 // FIXME: The following check might be unnecessary. Is it possible that 922 // FIXME: The following check might be unnecessary. Is it possible that
923 // oldElement has mismatched prefix/namespace? 923 // oldElement has mismatched prefix/namespace?
924 if (!hasValidNamespaceForElements(oldElement->tagQName())) { 924 if (!hasValidNamespaceForElements(oldElement->tagQName())) {
925 exceptionState.throwDOMException(NamespaceError, "The imported node has an invalid namespace."); 925 exceptionState.throwDOMException(NamespaceError, "The imported node has an invalid namespace.");
926 return nullptr; 926 return nullptr;
927 } 927 }
928 RefPtrWillBeRawPtr<Element> newElement = createElement(oldElement->tagQN ame(), false); 928 RawPtr<Element> newElement = createElement(oldElement->tagQName(), false );
929 929
930 newElement->cloneDataFromElement(*oldElement); 930 newElement->cloneDataFromElement(*oldElement);
931 931
932 if (deep) { 932 if (deep) {
933 if (!importContainerNodeChildren(oldElement, newElement, exceptionSt ate)) 933 if (!importContainerNodeChildren(oldElement, newElement, exceptionSt ate))
934 return nullptr; 934 return nullptr;
935 if (isHTMLTemplateElement(*oldElement) 935 if (isHTMLTemplateElement(*oldElement)
936 && !ensureTemplateDocument().importContainerNodeChildren( 936 && !ensureTemplateDocument().importContainerNodeChildren(
937 toHTMLTemplateElement(oldElement)->content(), 937 toHTMLTemplateElement(oldElement)->content(),
938 toHTMLTemplateElement(newElement)->content(), exceptionState )) 938 toHTMLTemplateElement(newElement)->content(), exceptionState ))
939 return nullptr; 939 return nullptr;
940 } 940 }
941 941
942 return newElement.release(); 942 return newElement.release();
943 } 943 }
944 case ATTRIBUTE_NODE: 944 case ATTRIBUTE_NODE:
945 return Attr::create(*this, QualifiedName(nullAtom, AtomicString(toAttr(i mportedNode)->name()), nullAtom), toAttr(importedNode)->value()); 945 return Attr::create(*this, QualifiedName(nullAtom, AtomicString(toAttr(i mportedNode)->name()), nullAtom), toAttr(importedNode)->value());
946 case DOCUMENT_FRAGMENT_NODE: { 946 case DOCUMENT_FRAGMENT_NODE: {
947 if (importedNode->isShadowRoot()) { 947 if (importedNode->isShadowRoot()) {
948 // ShadowRoot nodes should not be explicitly importable. 948 // ShadowRoot nodes should not be explicitly importable.
949 // Either they are imported along with their host node, or created i mplicitly. 949 // Either they are imported along with their host node, or created i mplicitly.
950 exceptionState.throwDOMException(NotSupportedError, "The node provid ed is a shadow root, which may not be imported."); 950 exceptionState.throwDOMException(NotSupportedError, "The node provid ed is a shadow root, which may not be imported.");
951 return nullptr; 951 return nullptr;
952 } 952 }
953 DocumentFragment* oldFragment = toDocumentFragment(importedNode); 953 DocumentFragment* oldFragment = toDocumentFragment(importedNode);
954 RefPtrWillBeRawPtr<DocumentFragment> newFragment = createDocumentFragmen t(); 954 RawPtr<DocumentFragment> newFragment = createDocumentFragment();
955 if (deep && !importContainerNodeChildren(oldFragment, newFragment, excep tionState)) 955 if (deep && !importContainerNodeChildren(oldFragment, newFragment, excep tionState))
956 return nullptr; 956 return nullptr;
957 957
958 return newFragment.release(); 958 return newFragment.release();
959 } 959 }
960 case DOCUMENT_NODE: 960 case DOCUMENT_NODE:
961 exceptionState.throwDOMException(NotSupportedError, "The node provided i s a document, which may not be imported."); 961 exceptionState.throwDOMException(NotSupportedError, "The node provided i s a document, which may not be imported.");
962 return nullptr; 962 return nullptr;
963 } 963 }
964 964
965 ASSERT_NOT_REACHED(); 965 ASSERT_NOT_REACHED();
966 return nullptr; 966 return nullptr;
967 } 967 }
968 968
969 PassRefPtrWillBeRawPtr<Node> Document::adoptNode(PassRefPtrWillBeRawPtr<Node> so urce, ExceptionState& exceptionState) 969 RawPtr<Node> Document::adoptNode(RawPtr<Node> source, ExceptionState& exceptionS tate)
970 { 970 {
971 EventQueueScope scope; 971 EventQueueScope scope;
972 972
973 switch (source->getNodeType()) { 973 switch (source->getNodeType()) {
974 case DOCUMENT_NODE: 974 case DOCUMENT_NODE:
975 exceptionState.throwDOMException(NotSupportedError, "The node provided i s of type '" + source->nodeName() + "', which may not be adopted."); 975 exceptionState.throwDOMException(NotSupportedError, "The node provided i s of type '" + source->nodeName() + "', which may not be adopted.");
976 return nullptr; 976 return nullptr;
977 case ATTRIBUTE_NODE: { 977 case ATTRIBUTE_NODE: {
978 Attr* attr = toAttr(source.get()); 978 Attr* attr = toAttr(source.get());
979 if (RefPtrWillBeRawPtr<Element> ownerElement = attr->ownerElement()) 979 if (RawPtr<Element> ownerElement = attr->ownerElement())
980 ownerElement->removeAttributeNode(attr, exceptionState); 980 ownerElement->removeAttributeNode(attr, exceptionState);
981 break; 981 break;
982 } 982 }
983 default: 983 default:
984 if (source->isShadowRoot()) { 984 if (source->isShadowRoot()) {
985 // ShadowRoot cannot disconnect itself from the host node. 985 // ShadowRoot cannot disconnect itself from the host node.
986 exceptionState.throwDOMException(HierarchyRequestError, "The node pr ovided is a shadow root, which may not be adopted."); 986 exceptionState.throwDOMException(HierarchyRequestError, "The node pr ovided is a shadow root, which may not be adopted.");
987 return nullptr; 987 return nullptr;
988 } 988 }
989 989
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 return qName.namespaceURI() == XMLNSNames::xmlnsNamespaceURI; 1023 return qName.namespaceURI() == XMLNSNames::xmlnsNamespaceURI;
1024 return qName.namespaceURI() != XMLNSNames::xmlnsNamespaceURI; 1024 return qName.namespaceURI() != XMLNSNames::xmlnsNamespaceURI;
1025 } 1025 }
1026 1026
1027 bool Document::hasValidNamespaceForAttributes(const QualifiedName& qName) 1027 bool Document::hasValidNamespaceForAttributes(const QualifiedName& qName)
1028 { 1028 {
1029 return hasValidNamespaceForElements(qName); 1029 return hasValidNamespaceForElements(qName);
1030 } 1030 }
1031 1031
1032 // FIXME: This should really be in a possible ElementFactory class 1032 // FIXME: This should really be in a possible ElementFactory class
1033 PassRefPtrWillBeRawPtr<Element> Document::createElement(const QualifiedName& qNa me, bool createdByParser) 1033 RawPtr<Element> Document::createElement(const QualifiedName& qName, bool created ByParser)
1034 { 1034 {
1035 RefPtrWillBeRawPtr<Element> e = nullptr; 1035 RawPtr<Element> e = nullptr;
1036 1036
1037 // FIXME: Use registered namespaces and look up in a hash to find the right factory. 1037 // FIXME: Use registered namespaces and look up in a hash to find the right factory.
1038 if (qName.namespaceURI() == xhtmlNamespaceURI) 1038 if (qName.namespaceURI() == xhtmlNamespaceURI)
1039 e = HTMLElementFactory::createHTMLElement(qName.localName(), *this, 0, c reatedByParser); 1039 e = HTMLElementFactory::createHTMLElement(qName.localName(), *this, 0, c reatedByParser);
1040 else if (qName.namespaceURI() == SVGNames::svgNamespaceURI) 1040 else if (qName.namespaceURI() == SVGNames::svgNamespaceURI)
1041 e = SVGElementFactory::createSVGElement(qName.localName(), *this, create dByParser); 1041 e = SVGElementFactory::createSVGElement(qName.localName(), *this, create dByParser);
1042 1042
1043 if (e) 1043 if (e)
1044 m_sawElementsInKnownNamespaces = true; 1044 m_sawElementsInKnownNamespaces = true;
1045 else 1045 else
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1182 } 1182 }
1183 1183
1184 Element* Document::elementFromPoint(int x, int y) const 1184 Element* Document::elementFromPoint(int x, int y) const
1185 { 1185 {
1186 if (!layoutView()) 1186 if (!layoutView())
1187 return 0; 1187 return 0;
1188 1188
1189 return TreeScope::elementFromPoint(x, y); 1189 return TreeScope::elementFromPoint(x, y);
1190 } 1190 }
1191 1191
1192 WillBeHeapVector<RawPtrWillBeMember<Element>> Document::elementsFromPoint(int x, int y) const 1192 HeapVector<Member<Element>> Document::elementsFromPoint(int x, int y) const
1193 { 1193 {
1194 if (!layoutView()) 1194 if (!layoutView())
1195 return WillBeHeapVector<RawPtrWillBeMember<Element>>(); 1195 return HeapVector<Member<Element>>();
1196 return TreeScope::elementsFromPoint(x, y); 1196 return TreeScope::elementsFromPoint(x, y);
1197 } 1197 }
1198 1198
1199 PassRefPtrWillBeRawPtr<Range> Document::caretRangeFromPoint(int x, int y) 1199 RawPtr<Range> Document::caretRangeFromPoint(int x, int y)
1200 { 1200 {
1201 if (!layoutView()) 1201 if (!layoutView())
1202 return nullptr; 1202 return nullptr;
1203 1203
1204 HitTestResult result = hitTestInDocument(this, x, y); 1204 HitTestResult result = hitTestInDocument(this, x, y);
1205 PositionWithAffinity positionWithAffinity = result.position(); 1205 PositionWithAffinity positionWithAffinity = result.position();
1206 if (positionWithAffinity.position().isNull()) 1206 if (positionWithAffinity.position().isNull())
1207 return nullptr; 1207 return nullptr;
1208 1208
1209 Position rangeCompliantPosition = positionWithAffinity.position().parentAnch oredEquivalent(); 1209 Position rangeCompliantPosition = positionWithAffinity.position().parentAnch oredEquivalent();
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
1476 FrameHost* Document::frameHost() const 1476 FrameHost* Document::frameHost() const
1477 { 1477 {
1478 return m_frame ? m_frame->host() : 0; 1478 return m_frame ? m_frame->host() : 0;
1479 } 1479 }
1480 1480
1481 Settings* Document::settings() const 1481 Settings* Document::settings() const
1482 { 1482 {
1483 return m_frame ? m_frame->settings() : 0; 1483 return m_frame ? m_frame->settings() : 0;
1484 } 1484 }
1485 1485
1486 PassRefPtrWillBeRawPtr<Range> Document::createRange() 1486 RawPtr<Range> Document::createRange()
1487 { 1487 {
1488 return Range::create(*this); 1488 return Range::create(*this);
1489 } 1489 }
1490 1490
1491 PassRefPtrWillBeRawPtr<NodeIterator> Document::createNodeIterator(Node* root, un signed whatToShow, PassRefPtrWillBeRawPtr<NodeFilter> filter) 1491 RawPtr<NodeIterator> Document::createNodeIterator(Node* root, unsigned whatToSho w, RawPtr<NodeFilter> filter)
1492 { 1492 {
1493 ASSERT(root); 1493 ASSERT(root);
1494 return NodeIterator::create(root, whatToShow, filter); 1494 return NodeIterator::create(root, whatToShow, filter);
1495 } 1495 }
1496 1496
1497 PassRefPtrWillBeRawPtr<TreeWalker> Document::createTreeWalker(Node* root, unsign ed whatToShow, PassRefPtrWillBeRawPtr<NodeFilter> filter) 1497 RawPtr<TreeWalker> Document::createTreeWalker(Node* root, unsigned whatToShow, R awPtr<NodeFilter> filter)
1498 { 1498 {
1499 ASSERT(root); 1499 ASSERT(root);
1500 return TreeWalker::create(root, whatToShow, filter); 1500 return TreeWalker::create(root, whatToShow, filter);
1501 } 1501 }
1502 1502
1503 bool Document::needsLayoutTreeUpdate() const 1503 bool Document::needsLayoutTreeUpdate() const
1504 { 1504 {
1505 if (!isActive() || !view()) 1505 if (!isActive() || !view())
1506 return false; 1506 return false;
1507 if (needsFullLayoutTreeUpdate()) 1507 if (needsFullLayoutTreeUpdate())
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1578 return; 1578 return;
1579 if (!childNeedsStyleInvalidation()) 1579 if (!childNeedsStyleInvalidation())
1580 return; 1580 return;
1581 TRACE_EVENT0("blink", "Document::updateStyleInvalidationIfNeeded"); 1581 TRACE_EVENT0("blink", "Document::updateStyleInvalidationIfNeeded");
1582 styleEngine().styleInvalidator().invalidate(*this); 1582 styleEngine().styleInvalidator().invalidate(*this);
1583 } 1583 }
1584 1584
1585 void Document::setupFontBuilder(ComputedStyle& documentStyle) 1585 void Document::setupFontBuilder(ComputedStyle& documentStyle)
1586 { 1586 {
1587 FontBuilder fontBuilder(*this); 1587 FontBuilder fontBuilder(*this);
1588 RefPtrWillBeRawPtr<CSSFontSelector> selector = styleEngine().fontSelector(); 1588 RawPtr<CSSFontSelector> selector = styleEngine().fontSelector();
1589 fontBuilder.createFontForDocument(selector, documentStyle); 1589 fontBuilder.createFontForDocument(selector, documentStyle);
1590 } 1590 }
1591 1591
1592 void Document::inheritHtmlAndBodyElementStyles(StyleRecalcChange change) 1592 void Document::inheritHtmlAndBodyElementStyles(StyleRecalcChange change)
1593 { 1593 {
1594 ASSERT(inStyleRecalc()); 1594 ASSERT(inStyleRecalc());
1595 ASSERT(documentElement()); 1595 ASSERT(documentElement());
1596 1596
1597 bool didRecalcDocumentElement = false; 1597 bool didRecalcDocumentElement = false;
1598 RefPtr<ComputedStyle> documentElementStyle = documentElement()->mutableCompu tedStyle(); 1598 RefPtr<ComputedStyle> documentElementStyle = documentElement()->mutableCompu tedStyle();
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1777 // tear down the layout tree or (unfortunately) run script. Kill the whole l ayoutObject if 1777 // tear down the layout tree or (unfortunately) run script. Kill the whole l ayoutObject if
1778 // someone managed to get into here from inside layout or paint. 1778 // someone managed to get into here from inside layout or paint.
1779 RELEASE_ASSERT(!view()->isInPerformLayout()); 1779 RELEASE_ASSERT(!view()->isInPerformLayout());
1780 RELEASE_ASSERT(!view()->isPainting()); 1780 RELEASE_ASSERT(!view()->isPainting());
1781 1781
1782 // Script can run below in WidgetUpdates, so protect the LocalFrame. 1782 // Script can run below in WidgetUpdates, so protect the LocalFrame.
1783 // TODO(esprehn): This should actually crash because of the ScriptForbiddenS cope, 1783 // TODO(esprehn): This should actually crash because of the ScriptForbiddenS cope,
1784 // for an example stack see crbug.com/536194, it seems like we should just u se 1784 // for an example stack see crbug.com/536194, it seems like we should just u se
1785 // a PluginScriptForbiddenScope to block all script from running inside here 1785 // a PluginScriptForbiddenScope to block all script from running inside here
1786 // to avoid the crash. 1786 // to avoid the crash.
1787 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); 1787 RawPtr<LocalFrame> protect(m_frame.get());
1788 1788
1789 TRACE_EVENT_BEGIN1("blink,devtools.timeline", "UpdateLayoutTree", "beginData ", InspectorRecalculateStylesEvent::data(frame())); 1789 TRACE_EVENT_BEGIN1("blink,devtools.timeline", "UpdateLayoutTree", "beginData ", InspectorRecalculateStylesEvent::data(frame()));
1790 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "UpdateLayoutTree"); 1790 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "UpdateLayoutTree");
1791 1791
1792 unsigned startElementCount = styleEngine().styleForElementCount(); 1792 unsigned startElementCount = styleEngine().styleForElementCount();
1793 1793
1794 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willRecalc ulateStyle(this); 1794 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willRecalc ulateStyle(this);
1795 1795
1796 DocumentAnimations::updateAnimationTimingIfNeeded(*this); 1796 DocumentAnimations::updateAnimationTimingIfNeeded(*this);
1797 evaluateMediaQueryListIfNeeded(); 1797 evaluateMediaQueryListIfNeeded();
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1947 return; 1947 return;
1948 updateLayoutIgnorePendingStylesheets(); 1948 updateLayoutIgnorePendingStylesheets();
1949 } 1949 }
1950 1950
1951 void Document::updateLayout() 1951 void Document::updateLayout()
1952 { 1952 {
1953 ASSERT(isMainThread()); 1953 ASSERT(isMainThread());
1954 1954
1955 ScriptForbiddenScope forbidScript; 1955 ScriptForbiddenScope forbidScript;
1956 1956
1957 RefPtrWillBeRawPtr<FrameView> frameView = view(); 1957 RawPtr<FrameView> frameView = view();
1958 if (frameView && frameView->isInPerformLayout()) { 1958 if (frameView && frameView->isInPerformLayout()) {
1959 // View layout should not be re-entrant. 1959 // View layout should not be re-entrant.
1960 ASSERT_NOT_REACHED(); 1960 ASSERT_NOT_REACHED();
1961 return; 1961 return;
1962 } 1962 }
1963 1963
1964 if (HTMLFrameOwnerElement* owner = ownerElement()) 1964 if (HTMLFrameOwnerElement* owner = ownerElement())
1965 owner->document().updateLayout(); 1965 owner->document().updateLayout();
1966 1966
1967 updateLayoutTree(); 1967 updateLayoutTree();
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
2162 m_useElementsNeedingUpdate.remove(&element); 2162 m_useElementsNeedingUpdate.remove(&element);
2163 } 2163 }
2164 2164
2165 void Document::updateUseShadowTreesIfNeeded() 2165 void Document::updateUseShadowTreesIfNeeded()
2166 { 2166 {
2167 ScriptForbiddenScope forbidScript; 2167 ScriptForbiddenScope forbidScript;
2168 2168
2169 if (m_useElementsNeedingUpdate.isEmpty()) 2169 if (m_useElementsNeedingUpdate.isEmpty())
2170 return; 2170 return;
2171 2171
2172 WillBeHeapVector<RawPtrWillBeMember<SVGUseElement>> elements; 2172 HeapVector<Member<SVGUseElement>> elements;
2173 copyToVector(m_useElementsNeedingUpdate, elements); 2173 copyToVector(m_useElementsNeedingUpdate, elements);
2174 m_useElementsNeedingUpdate.clear(); 2174 m_useElementsNeedingUpdate.clear();
2175 2175
2176 for (SVGUseElement* element : elements) 2176 for (SVGUseElement* element : elements)
2177 element->buildPendingResource(); 2177 element->buildPendingResource();
2178 } 2178 }
2179 2179
2180 StyleResolver* Document::styleResolver() const 2180 StyleResolver* Document::styleResolver() const
2181 { 2181 {
2182 return m_styleEngine->resolver(); 2182 return m_styleEngine->resolver();
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
2263 m_layoutView->setIsInWindow(false); 2263 m_layoutView->setIsInWindow(false);
2264 2264
2265 if (registrationContext()) 2265 if (registrationContext())
2266 registrationContext()->documentWasDetached(); 2266 registrationContext()->documentWasDetached();
2267 2267
2268 m_hoverNode = nullptr; 2268 m_hoverNode = nullptr;
2269 m_activeHoverElement = nullptr; 2269 m_activeHoverElement = nullptr;
2270 m_autofocusElement = nullptr; 2270 m_autofocusElement = nullptr;
2271 2271
2272 if (m_focusedElement.get()) { 2272 if (m_focusedElement.get()) {
2273 RefPtrWillBeRawPtr<Element> oldFocusedElement = m_focusedElement; 2273 RawPtr<Element> oldFocusedElement = m_focusedElement;
2274 m_focusedElement = nullptr; 2274 m_focusedElement = nullptr;
2275 if (frameHost()) 2275 if (frameHost())
2276 frameHost()->chromeClient().focusedNodeChanged(oldFocusedElement.get (), nullptr); 2276 frameHost()->chromeClient().focusedNodeChanged(oldFocusedElement.get (), nullptr);
2277 } 2277 }
2278 m_sequentialFocusNavigationStartingPoint = nullptr; 2278 m_sequentialFocusNavigationStartingPoint = nullptr;
2279 2279
2280 if (this == &axObjectCacheOwner()) 2280 if (this == &axObjectCacheOwner())
2281 clearAXObjectCache(); 2281 clearAXObjectCache();
2282 2282
2283 m_layoutView = nullptr; 2283 m_layoutView = nullptr;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
2403 } 2403 }
2404 2404
2405 CanvasFontCache* Document::canvasFontCache() 2405 CanvasFontCache* Document::canvasFontCache()
2406 { 2406 {
2407 if (!m_canvasFontCache) 2407 if (!m_canvasFontCache)
2408 m_canvasFontCache = CanvasFontCache::create(*this); 2408 m_canvasFontCache = CanvasFontCache::create(*this);
2409 2409
2410 return m_canvasFontCache.get(); 2410 return m_canvasFontCache.get();
2411 } 2411 }
2412 2412
2413 PassRefPtrWillBeRawPtr<DocumentParser> Document::createParser() 2413 RawPtr<DocumentParser> Document::createParser()
2414 { 2414 {
2415 if (isHTMLDocument()) { 2415 if (isHTMLDocument()) {
2416 bool reportErrors = InspectorInstrumentation::collectingHTMLParseErrors( this); 2416 bool reportErrors = InspectorInstrumentation::collectingHTMLParseErrors( this);
2417 return HTMLDocumentParser::create(toHTMLDocument(*this), reportErrors, m _parserSyncPolicy); 2417 return HTMLDocumentParser::create(toHTMLDocument(*this), reportErrors, m _parserSyncPolicy);
2418 } 2418 }
2419 // FIXME: this should probably pass the frame instead 2419 // FIXME: this should probably pass the frame instead
2420 return XMLDocumentParser::create(*this, view()); 2420 return XMLDocumentParser::create(*this, view());
2421 } 2421 }
2422 2422
2423 bool Document::isFrameSet() const 2423 bool Document::isFrameSet() const
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
2496 m_parser.clear(); 2496 m_parser.clear();
2497 } 2497 }
2498 2498
2499 void Document::cancelParsing() 2499 void Document::cancelParsing()
2500 { 2500 {
2501 detachParser(); 2501 detachParser();
2502 setParsingState(FinishedParsing); 2502 setParsingState(FinishedParsing);
2503 setReadyState(Complete); 2503 setReadyState(Complete);
2504 } 2504 }
2505 2505
2506 PassRefPtrWillBeRawPtr<DocumentParser> Document::implicitOpen(ParserSynchronizat ionPolicy parserSyncPolicy) 2506 RawPtr<DocumentParser> Document::implicitOpen(ParserSynchronizationPolicy parser SyncPolicy)
2507 { 2507 {
2508 detachParser(); 2508 detachParser();
2509 2509
2510 removeChildren(); 2510 removeChildren();
2511 ASSERT(!m_focusedElement); 2511 ASSERT(!m_focusedElement);
2512 2512
2513 setCompatibilityMode(NoQuirksMode); 2513 setCompatibilityMode(NoQuirksMode);
2514 2514
2515 if (!threadedParsingEnabledForTesting()) 2515 if (!threadedParsingEnabledForTesting())
2516 parserSyncPolicy = ForceSynchronousParsing; 2516 parserSyncPolicy = ForceSynchronousParsing;
(...skipping 25 matching lines...) Expand all
2542 return 0; 2542 return 0;
2543 2543
2544 for (HTMLElement* child = Traversal<HTMLElement>::firstChild(*documentElemen t()); child; child = Traversal<HTMLElement>::nextSibling(*child)) { 2544 for (HTMLElement* child = Traversal<HTMLElement>::firstChild(*documentElemen t()); child; child = Traversal<HTMLElement>::nextSibling(*child)) {
2545 if (isHTMLBodyElement(*child)) 2545 if (isHTMLBodyElement(*child))
2546 return toHTMLBodyElement(child); 2546 return toHTMLBodyElement(child);
2547 } 2547 }
2548 2548
2549 return 0; 2549 return 0;
2550 } 2550 }
2551 2551
2552 void Document::setBody(PassRefPtrWillBeRawPtr<HTMLElement> prpNewBody, Exception State& exceptionState) 2552 void Document::setBody(RawPtr<HTMLElement> prpNewBody, ExceptionState& exception State)
2553 { 2553 {
2554 RefPtrWillBeRawPtr<HTMLElement> newBody = prpNewBody; 2554 RawPtr<HTMLElement> newBody = prpNewBody;
2555 2555
2556 if (!newBody) { 2556 if (!newBody) {
2557 exceptionState.throwDOMException(HierarchyRequestError, ExceptionMessage s::argumentNullOrIncorrectType(1, "HTMLElement")); 2557 exceptionState.throwDOMException(HierarchyRequestError, ExceptionMessage s::argumentNullOrIncorrectType(1, "HTMLElement"));
2558 return; 2558 return;
2559 } 2559 }
2560 if (!documentElement()) { 2560 if (!documentElement()) {
2561 exceptionState.throwDOMException(HierarchyRequestError, "No document ele ment exists."); 2561 exceptionState.throwDOMException(HierarchyRequestError, "No document ele ment exists.");
2562 return; 2562 return;
2563 } 2563 }
2564 2564
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
2624 } 2624 }
2625 2625
2626 close(); 2626 close();
2627 } 2627 }
2628 2628
2629 void Document::close() 2629 void Document::close()
2630 { 2630 {
2631 if (!scriptableDocumentParser() || !scriptableDocumentParser()->wasCreatedBy Script() || !scriptableDocumentParser()->isParsing()) 2631 if (!scriptableDocumentParser() || !scriptableDocumentParser()->wasCreatedBy Script() || !scriptableDocumentParser()->isParsing())
2632 return; 2632 return;
2633 2633
2634 if (RefPtrWillBeRawPtr<DocumentParser> parser = m_parser) 2634 if (RawPtr<DocumentParser> parser = m_parser)
2635 parser->finish(); 2635 parser->finish();
2636 2636
2637 if (!m_frame) { 2637 if (!m_frame) {
2638 // Because we have no frame, we don't know if all loading has completed, 2638 // Because we have no frame, we don't know if all loading has completed,
2639 // so we just call implicitClose() immediately. FIXME: This might fire 2639 // so we just call implicitClose() immediately. FIXME: This might fire
2640 // the load event prematurely <http://bugs.webkit.org/show_bug.cgi?id=14 568>. 2640 // the load event prematurely <http://bugs.webkit.org/show_bug.cgi?id=14 568>.
2641 implicitClose(); 2641 implicitClose();
2642 return; 2642 return;
2643 } 2643 }
2644 2644
2645 m_frame->loader().checkCompleted(); 2645 m_frame->loader().checkCompleted();
2646 } 2646 }
2647 2647
2648 void Document::implicitClose() 2648 void Document::implicitClose()
2649 { 2649 {
2650 ASSERT(!inStyleRecalc()); 2650 ASSERT(!inStyleRecalc());
2651 if (processingLoadEvent() || !m_parser) 2651 if (processingLoadEvent() || !m_parser)
2652 return; 2652 return;
2653 if (frame() && frame()->navigationScheduler().locationChangePending()) { 2653 if (frame() && frame()->navigationScheduler().locationChangePending()) {
2654 suppressLoadEvent(); 2654 suppressLoadEvent();
2655 return; 2655 return;
2656 } 2656 }
2657 2657
2658 // The call to dispatchWindowLoadEvent (from documentWasClosed()) can detach 2658 // The call to dispatchWindowLoadEvent (from documentWasClosed()) can detach
2659 // the LocalDOMWindow and cause it (and its attached Document) to be 2659 // the LocalDOMWindow and cause it (and its attached Document) to be
2660 // destroyed. 2660 // destroyed.
2661 RefPtrWillBeRawPtr<LocalDOMWindow> protectedWindow(this->domWindow()); 2661 RawPtr<LocalDOMWindow> protectedWindow(this->domWindow());
2662 2662
2663 m_loadEventProgress = LoadEventInProgress; 2663 m_loadEventProgress = LoadEventInProgress;
2664 2664
2665 ScriptableDocumentParser* parser = scriptableDocumentParser(); 2665 ScriptableDocumentParser* parser = scriptableDocumentParser();
2666 m_wellFormed = parser && parser->wellFormed(); 2666 m_wellFormed = parser && parser->wellFormed();
2667 2667
2668 // We have to clear the parser, in case someone document.write()s from the 2668 // We have to clear the parser, in case someone document.write()s from the
2669 // onLoad event handler, as in Radar 3206524. 2669 // onLoad event handler, as in Radar 3206524.
2670 detachParser(); 2670 detachParser();
2671 2671
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
2739 { 2739 {
2740 if (!m_domWindow) 2740 if (!m_domWindow)
2741 return true; 2741 return true;
2742 2742
2743 if (!body()) 2743 if (!body())
2744 return true; 2744 return true;
2745 2745
2746 if (processingBeforeUnload()) 2746 if (processingBeforeUnload())
2747 return false; 2747 return false;
2748 2748
2749 RefPtrWillBeRawPtr<Document> protect(this); 2749 RawPtr<Document> protect(this);
2750 2750
2751 RefPtrWillBeRawPtr<BeforeUnloadEvent> beforeUnloadEvent = BeforeUnloadEvent: :create(); 2751 RawPtr<BeforeUnloadEvent> beforeUnloadEvent = BeforeUnloadEvent::create();
2752 m_loadEventProgress = BeforeUnloadEventInProgress; 2752 m_loadEventProgress = BeforeUnloadEventInProgress;
2753 m_domWindow->dispatchEvent(beforeUnloadEvent.get(), this); 2753 m_domWindow->dispatchEvent(beforeUnloadEvent.get(), this);
2754 m_loadEventProgress = BeforeUnloadEventCompleted; 2754 m_loadEventProgress = BeforeUnloadEventCompleted;
2755 if (!beforeUnloadEvent->defaultPrevented()) 2755 if (!beforeUnloadEvent->defaultPrevented())
2756 defaultEventHandler(beforeUnloadEvent.get()); 2756 defaultEventHandler(beforeUnloadEvent.get());
2757 if (!frame() || beforeUnloadEvent->returnValue().isNull()) 2757 if (!frame() || beforeUnloadEvent->returnValue().isNull())
2758 return true; 2758 return true;
2759 2759
2760 if (didAllowNavigation) { 2760 if (didAllowNavigation) {
2761 addConsoleMessage(ConsoleMessage::create(JSMessageSource, ErrorMessageLe vel, "Blocked attempt to show multiple 'beforeunload' confirmation panels for a single navigation.")); 2761 addConsoleMessage(ConsoleMessage::create(JSMessageSource, ErrorMessageLe vel, "Blocked attempt to show multiple 'beforeunload' confirmation panels for a single navigation."));
2762 return true; 2762 return true;
2763 } 2763 }
2764 2764
2765 String text = beforeUnloadEvent->returnValue(); 2765 String text = beforeUnloadEvent->returnValue();
2766 if (chromeClient.openBeforeUnloadConfirmPanel(text, m_frame, isReload)) { 2766 if (chromeClient.openBeforeUnloadConfirmPanel(text, m_frame, isReload)) {
2767 didAllowNavigation = true; 2767 didAllowNavigation = true;
2768 return true; 2768 return true;
2769 } 2769 }
2770 return false; 2770 return false;
2771 } 2771 }
2772 2772
2773 void Document::dispatchUnloadEvents() 2773 void Document::dispatchUnloadEvents()
2774 { 2774 {
2775 PluginScriptForbiddenScope forbidPluginDestructorScripting; 2775 PluginScriptForbiddenScope forbidPluginDestructorScripting;
2776 RefPtrWillBeRawPtr<Document> protect(this); 2776 RawPtr<Document> protect(this);
2777 if (m_parser) 2777 if (m_parser)
2778 m_parser->stopParsing(); 2778 m_parser->stopParsing();
2779 2779
2780 if (m_loadEventProgress == LoadEventNotRun) 2780 if (m_loadEventProgress == LoadEventNotRun)
2781 return; 2781 return;
2782 2782
2783 if (m_loadEventProgress <= UnloadEventInProgress) { 2783 if (m_loadEventProgress <= UnloadEventInProgress) {
2784 Element* currentFocusedElement = focusedElement(); 2784 Element* currentFocusedElement = focusedElement();
2785 if (isHTMLInputElement(currentFocusedElement)) 2785 if (isHTMLInputElement(currentFocusedElement))
2786 toHTMLInputElement(*currentFocusedElement).endEditing(); 2786 toHTMLInputElement(*currentFocusedElement).endEditing();
(...skipping 11 matching lines...) Expand all
2798 // other notifications as we're about to be unloaded. 2798 // other notifications as we're about to be unloaded.
2799 dispatchEvent(Event::createBubble(EventTypeNames::visibilitychan ge)); 2799 dispatchEvent(Event::createBubble(EventTypeNames::visibilitychan ge));
2800 dispatchEvent(Event::createBubble(EventTypeNames::webkitvisibili tychange)); 2800 dispatchEvent(Event::createBubble(EventTypeNames::webkitvisibili tychange));
2801 } 2801 }
2802 if (!m_frame) 2802 if (!m_frame)
2803 return; 2803 return;
2804 2804
2805 // The DocumentLoader (and thus its DocumentLoadTiming) might get de stroyed 2805 // The DocumentLoader (and thus its DocumentLoadTiming) might get de stroyed
2806 // while dispatching the event, so protect it to prevent writing the end 2806 // while dispatching the event, so protect it to prevent writing the end
2807 // time into freed memory. 2807 // time into freed memory.
2808 RefPtrWillBeRawPtr<DocumentLoader> documentLoader = m_frame->loader( ).provisionalDocumentLoader(); 2808 RawPtr<DocumentLoader> documentLoader = m_frame->loader().provisiona lDocumentLoader();
2809 m_loadEventProgress = UnloadEventInProgress; 2809 m_loadEventProgress = UnloadEventInProgress;
2810 RefPtrWillBeRawPtr<Event> unloadEvent(Event::create(EventTypeNames:: unload)); 2810 RawPtr<Event> unloadEvent(Event::create(EventTypeNames::unload));
2811 if (documentLoader && !documentLoader->timing().unloadEventStart() & & !documentLoader->timing().unloadEventEnd()) { 2811 if (documentLoader && !documentLoader->timing().unloadEventStart() & & !documentLoader->timing().unloadEventEnd()) {
2812 DocumentLoadTiming& timing = documentLoader->timing(); 2812 DocumentLoadTiming& timing = documentLoader->timing();
2813 ASSERT(timing.navigationStart()); 2813 ASSERT(timing.navigationStart());
2814 timing.markUnloadEventStart(); 2814 timing.markUnloadEventStart();
2815 m_frame->localDOMWindow()->dispatchEvent(unloadEvent, this); 2815 m_frame->localDOMWindow()->dispatchEvent(unloadEvent, this);
2816 timing.markUnloadEventEnd(); 2816 timing.markUnloadEventEnd();
2817 } else { 2817 } else {
2818 m_frame->localDOMWindow()->dispatchEvent(unloadEvent, m_frame->d ocument()); 2818 m_frame->localDOMWindow()->dispatchEvent(unloadEvent, m_frame->d ocument());
2819 } 2819 }
2820 } 2820 }
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
2971 return &m_timers; 2971 return &m_timers;
2972 } 2972 }
2973 2973
2974 EventTarget* Document::errorEventTarget() 2974 EventTarget* Document::errorEventTarget()
2975 { 2975 {
2976 return domWindow(); 2976 return domWindow();
2977 } 2977 }
2978 2978
2979 void Document::logExceptionToConsole(const String& errorMessage, int scriptId, c onst String& sourceURL, int lineNumber, int columnNumber, PassRefPtr<ScriptCallS tack> callStack) 2979 void Document::logExceptionToConsole(const String& errorMessage, int scriptId, c onst String& sourceURL, int lineNumber, int columnNumber, PassRefPtr<ScriptCallS tack> callStack)
2980 { 2980 {
2981 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(J SMessageSource, ErrorMessageLevel, errorMessage, sourceURL, lineNumber, columnNu mber); 2981 RawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(JSMessageSour ce, ErrorMessageLevel, errorMessage, sourceURL, lineNumber, columnNumber);
2982 consoleMessage->setScriptId(scriptId); 2982 consoleMessage->setScriptId(scriptId);
2983 consoleMessage->setCallStack(callStack); 2983 consoleMessage->setCallStack(callStack);
2984 addConsoleMessage(consoleMessage.release()); 2984 addConsoleMessage(consoleMessage.release());
2985 } 2985 }
2986 2986
2987 void Document::setURL(const KURL& url) 2987 void Document::setURL(const KURL& url)
2988 { 2988 {
2989 const KURL& newURL = url.isEmpty() ? blankURL() : url; 2989 const KURL& newURL = url.isEmpty() ? blankURL() : url;
2990 if (newURL == m_url) 2990 if (newURL == m_url)
2991 return; 2991 return;
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
3364 if (numElements > 1 || numDoctypes > 1) { 3364 if (numElements > 1 || numDoctypes > 1) {
3365 exceptionState.throwDOMException(HierarchyRequestError, 3365 exceptionState.throwDOMException(HierarchyRequestError,
3366 String::format("Only one %s on document allowed.", 3366 String::format("Only one %s on document allowed.",
3367 numElements > 1 ? "element" : "doctype")); 3367 numElements > 1 ? "element" : "doctype"));
3368 return false; 3368 return false;
3369 } 3369 }
3370 3370
3371 return true; 3371 return true;
3372 } 3372 }
3373 3373
3374 PassRefPtrWillBeRawPtr<Node> Document::cloneNode(bool deep) 3374 RawPtr<Node> Document::cloneNode(bool deep)
3375 { 3375 {
3376 RefPtrWillBeRawPtr<Document> clone = cloneDocumentWithoutChildren(); 3376 RawPtr<Document> clone = cloneDocumentWithoutChildren();
3377 clone->cloneDataFromDocument(*this); 3377 clone->cloneDataFromDocument(*this);
3378 if (deep) 3378 if (deep)
3379 cloneChildNodes(clone.get()); 3379 cloneChildNodes(clone.get());
3380 return clone.release(); 3380 return clone.release();
3381 } 3381 }
3382 3382
3383 PassRefPtrWillBeRawPtr<Document> Document::cloneDocumentWithoutChildren() 3383 RawPtr<Document> Document::cloneDocumentWithoutChildren()
3384 { 3384 {
3385 DocumentInit init(url()); 3385 DocumentInit init(url());
3386 if (isXMLDocument()) { 3386 if (isXMLDocument()) {
3387 if (isXHTMLDocument()) 3387 if (isXHTMLDocument())
3388 return XMLDocument::createXHTML(init.withRegistrationContext(registr ationContext())); 3388 return XMLDocument::createXHTML(init.withRegistrationContext(registr ationContext()));
3389 return XMLDocument::create(init); 3389 return XMLDocument::create(init);
3390 } 3390 }
3391 return create(init); 3391 return create(init);
3392 } 3392 }
3393 3393
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
3503 // We need to manually repaint because we avoid doing all repaints in la yout or style 3503 // We need to manually repaint because we avoid doing all repaints in la yout or style
3504 // recalc while sheets are still loading to avoid FOUC. 3504 // recalc while sheets are still loading to avoid FOUC.
3505 m_pendingSheetLayout = IgnoreLayoutWithPendingSheets; 3505 m_pendingSheetLayout = IgnoreLayoutWithPendingSheets;
3506 3506
3507 ASSERT(layoutView() || importsController()); 3507 ASSERT(layoutView() || importsController());
3508 if (layoutView()) 3508 if (layoutView())
3509 layoutView()->invalidatePaintForViewAndCompositedLayers(); 3509 layoutView()->invalidatePaintForViewAndCompositedLayers();
3510 } 3510 }
3511 } 3511 }
3512 3512
3513 void Document::setHoverNode(PassRefPtrWillBeRawPtr<Node> newHoverNode) 3513 void Document::setHoverNode(RawPtr<Node> newHoverNode)
3514 { 3514 {
3515 m_hoverNode = newHoverNode; 3515 m_hoverNode = newHoverNode;
3516 } 3516 }
3517 3517
3518 void Document::setActiveHoverElement(PassRefPtrWillBeRawPtr<Element> newActiveEl ement) 3518 void Document::setActiveHoverElement(RawPtr<Element> newActiveElement)
3519 { 3519 {
3520 if (!newActiveElement) { 3520 if (!newActiveElement) {
3521 m_activeHoverElement.clear(); 3521 m_activeHoverElement.clear();
3522 return; 3522 return;
3523 } 3523 }
3524 3524
3525 m_activeHoverElement = newActiveElement; 3525 m_activeHoverElement = newActiveElement;
3526 } 3526 }
3527 3527
3528 void Document::removeFocusedElementOfSubtree(Node* node, bool amongChildrenOnly) 3528 void Document::removeFocusedElementOfSubtree(Node* node, bool amongChildrenOnly)
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
3580 { 3580 {
3581 return m_annotatedRegions; 3581 return m_annotatedRegions;
3582 } 3582 }
3583 3583
3584 void Document::setAnnotatedRegions(const Vector<AnnotatedRegionValue>& regions) 3584 void Document::setAnnotatedRegions(const Vector<AnnotatedRegionValue>& regions)
3585 { 3585 {
3586 m_annotatedRegions = regions; 3586 m_annotatedRegions = regions;
3587 setAnnotatedRegionsDirty(false); 3587 setAnnotatedRegionsDirty(false);
3588 } 3588 }
3589 3589
3590 bool Document::setFocusedElement(PassRefPtrWillBeRawPtr<Element> prpNewFocusedEl ement, const FocusParams& params) 3590 bool Document::setFocusedElement(RawPtr<Element> prpNewFocusedElement, const Foc usParams& params)
3591 { 3591 {
3592 ASSERT(!m_lifecycle.inDetach()); 3592 ASSERT(!m_lifecycle.inDetach());
3593 3593
3594 m_clearFocusedElementTimer.stop(); 3594 m_clearFocusedElementTimer.stop();
3595 3595
3596 RefPtrWillBeRawPtr<Element> newFocusedElement = prpNewFocusedElement; 3596 RawPtr<Element> newFocusedElement = prpNewFocusedElement;
3597 3597
3598 // Make sure newFocusedNode is actually in this document 3598 // Make sure newFocusedNode is actually in this document
3599 if (newFocusedElement && (newFocusedElement->document() != this)) 3599 if (newFocusedElement && (newFocusedElement->document() != this))
3600 return true; 3600 return true;
3601 3601
3602 if (NodeChildRemovalTracker::isBeingRemoved(newFocusedElement.get())) 3602 if (NodeChildRemovalTracker::isBeingRemoved(newFocusedElement.get()))
3603 return true; 3603 return true;
3604 3604
3605 if (m_focusedElement == newFocusedElement) 3605 if (m_focusedElement == newFocusedElement)
3606 return true; 3606 return true;
3607 3607
3608 bool focusChangeBlocked = false; 3608 bool focusChangeBlocked = false;
3609 RefPtrWillBeRawPtr<Element> oldFocusedElement = m_focusedElement; 3609 RawPtr<Element> oldFocusedElement = m_focusedElement;
3610 m_focusedElement = nullptr; 3610 m_focusedElement = nullptr;
3611 3611
3612 // Remove focus from the existing focus node (if any) 3612 // Remove focus from the existing focus node (if any)
3613 if (oldFocusedElement) { 3613 if (oldFocusedElement) {
3614 oldFocusedElement->setFocus(false); 3614 oldFocusedElement->setFocus(false);
3615 3615
3616 // Dispatch the blur event and let the node do any other blur related ac tivities (important for text fields) 3616 // Dispatch the blur event and let the node do any other blur related ac tivities (important for text fields)
3617 // If page lost focus, blur event will have already been dispatched 3617 // If page lost focus, blur event will have already been dispatched
3618 if (page() && (page()->focusController().isFocused())) { 3618 if (page() && (page()->focusController().isFocused())) {
3619 oldFocusedElement->dispatchBlurEvent(newFocusedElement.get(), params .type, params.sourceCapabilities); 3619 oldFocusedElement->dispatchBlurEvent(newFocusedElement.get(), params .type, params.sourceCapabilities);
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
3851 3851
3852 void Document::detachNodeIterator(NodeIterator* ni) 3852 void Document::detachNodeIterator(NodeIterator* ni)
3853 { 3853 {
3854 // The node iterator can be detached without having been attached if its roo t node didn't have a document 3854 // The node iterator can be detached without having been attached if its roo t node didn't have a document
3855 // when the iterator was created, but has it now. 3855 // when the iterator was created, but has it now.
3856 m_nodeIterators.remove(ni); 3856 m_nodeIterators.remove(ni);
3857 } 3857 }
3858 3858
3859 void Document::moveNodeIteratorsToNewDocument(Node& node, Document& newDocument) 3859 void Document::moveNodeIteratorsToNewDocument(Node& node, Document& newDocument)
3860 { 3860 {
3861 WillBeHeapHashSet<RawPtrWillBeWeakMember<NodeIterator>> nodeIteratorsList = m_nodeIterators; 3861 HeapHashSet<WeakMember<NodeIterator>> nodeIteratorsList = m_nodeIterators;
3862 for (NodeIterator* ni : nodeIteratorsList) { 3862 for (NodeIterator* ni : nodeIteratorsList) {
3863 if (ni->root() == node) { 3863 if (ni->root() == node) {
3864 detachNodeIterator(ni); 3864 detachNodeIterator(ni);
3865 newDocument.attachNodeIterator(ni); 3865 newDocument.attachNodeIterator(ni);
3866 } 3866 }
3867 } 3867 }
3868 } 3868 }
3869 3869
3870 void Document::updateRangesAfterChildrenChanged(ContainerNode* container) 3870 void Document::updateRangesAfterChildrenChanged(ContainerNode* container)
3871 { 3871 {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
3954 { 3954 {
3955 for (Range* range : m_ranges) 3955 for (Range* range : m_ranges)
3956 range->didSplitTextNode(oldNode); 3956 range->didSplitTextNode(oldNode);
3957 3957
3958 if (m_frame) 3958 if (m_frame)
3959 m_frame->selection().didSplitTextNode(oldNode); 3959 m_frame->selection().didSplitTextNode(oldNode);
3960 3960
3961 // FIXME: This should update markers for spelling and grammar checking. 3961 // FIXME: This should update markers for spelling and grammar checking.
3962 } 3962 }
3963 3963
3964 void Document::setWindowAttributeEventListener(const AtomicString& eventType, Pa ssRefPtrWillBeRawPtr<EventListener> listener) 3964 void Document::setWindowAttributeEventListener(const AtomicString& eventType, Ra wPtr<EventListener> listener)
3965 { 3965 {
3966 LocalDOMWindow* domWindow = this->domWindow(); 3966 LocalDOMWindow* domWindow = this->domWindow();
3967 if (!domWindow) 3967 if (!domWindow)
3968 return; 3968 return;
3969 domWindow->setAttributeEventListener(eventType, listener); 3969 domWindow->setAttributeEventListener(eventType, listener);
3970 } 3970 }
3971 3971
3972 EventListener* Document::getWindowAttributeEventListener(const AtomicString& eve ntType) 3972 EventListener* Document::getWindowAttributeEventListener(const AtomicString& eve ntType)
3973 { 3973 {
3974 LocalDOMWindow* domWindow = this->domWindow(); 3974 LocalDOMWindow* domWindow = this->domWindow();
3975 if (!domWindow) 3975 if (!domWindow)
3976 return 0; 3976 return 0;
3977 return domWindow->getAttributeEventListener(eventType); 3977 return domWindow->getAttributeEventListener(eventType);
3978 } 3978 }
3979 3979
3980 EventQueue* Document::getEventQueue() const 3980 EventQueue* Document::getEventQueue() const
3981 { 3981 {
3982 if (!m_domWindow) 3982 if (!m_domWindow)
3983 return 0; 3983 return 0;
3984 return m_domWindow->getEventQueue(); 3984 return m_domWindow->getEventQueue();
3985 } 3985 }
3986 3986
3987 void Document::enqueueAnimationFrameEvent(PassRefPtrWillBeRawPtr<Event> event) 3987 void Document::enqueueAnimationFrameEvent(RawPtr<Event> event)
3988 { 3988 {
3989 ensureScriptedAnimationController().enqueueEvent(event); 3989 ensureScriptedAnimationController().enqueueEvent(event);
3990 } 3990 }
3991 3991
3992 void Document::enqueueUniqueAnimationFrameEvent(PassRefPtrWillBeRawPtr<Event> ev ent) 3992 void Document::enqueueUniqueAnimationFrameEvent(RawPtr<Event> event)
3993 { 3993 {
3994 ensureScriptedAnimationController().enqueuePerFrameEvent(event); 3994 ensureScriptedAnimationController().enqueuePerFrameEvent(event);
3995 } 3995 }
3996 3996
3997 void Document::enqueueScrollEventForNode(Node* target) 3997 void Document::enqueueScrollEventForNode(Node* target)
3998 { 3998 {
3999 // Per the W3C CSSOM View Module only scroll events fired at the document sh ould bubble. 3999 // Per the W3C CSSOM View Module only scroll events fired at the document sh ould bubble.
4000 RefPtrWillBeRawPtr<Event> scrollEvent = target->isDocumentNode() ? Event::cr eateBubble(EventTypeNames::scroll) : Event::create(EventTypeNames::scroll); 4000 RawPtr<Event> scrollEvent = target->isDocumentNode() ? Event::createBubble(E ventTypeNames::scroll) : Event::create(EventTypeNames::scroll);
4001 scrollEvent->setTarget(target); 4001 scrollEvent->setTarget(target);
4002 ensureScriptedAnimationController().enqueuePerFrameEvent(scrollEvent.release ()); 4002 ensureScriptedAnimationController().enqueuePerFrameEvent(scrollEvent.release ());
4003 } 4003 }
4004 4004
4005 void Document::enqueueResizeEvent() 4005 void Document::enqueueResizeEvent()
4006 { 4006 {
4007 RefPtrWillBeRawPtr<Event> event = Event::create(EventTypeNames::resize); 4007 RawPtr<Event> event = Event::create(EventTypeNames::resize);
4008 event->setTarget(domWindow()); 4008 event->setTarget(domWindow());
4009 ensureScriptedAnimationController().enqueuePerFrameEvent(event.release()); 4009 ensureScriptedAnimationController().enqueuePerFrameEvent(event.release());
4010 } 4010 }
4011 4011
4012 void Document::enqueueMediaQueryChangeListeners(WillBeHeapVector<RefPtrWillBeMem ber<MediaQueryListListener>>& listeners) 4012 void Document::enqueueMediaQueryChangeListeners(HeapVector<Member<MediaQueryList Listener>>& listeners)
4013 { 4013 {
4014 ensureScriptedAnimationController().enqueueMediaQueryChangeListeners(listene rs); 4014 ensureScriptedAnimationController().enqueueMediaQueryChangeListeners(listene rs);
4015 } 4015 }
4016 4016
4017 void Document::dispatchEventsForPrinting() 4017 void Document::dispatchEventsForPrinting()
4018 { 4018 {
4019 if (!m_scriptedAnimationController) 4019 if (!m_scriptedAnimationController)
4020 return; 4020 return;
4021 m_scriptedAnimationController->dispatchEventsAndCallbacksForPrinting(); 4021 m_scriptedAnimationController->dispatchEventsAndCallbacksForPrinting();
4022 } 4022 }
(...skipping 11 matching lines...) Expand all
4034 } 4034 }
4035 return *m_accessEntryFromURL; 4035 return *m_accessEntryFromURL;
4036 } 4036 }
4037 4037
4038 void Document::registerEventFactory(PassOwnPtr<EventFactoryBase> eventFactory) 4038 void Document::registerEventFactory(PassOwnPtr<EventFactoryBase> eventFactory)
4039 { 4039 {
4040 ASSERT(!eventFactories().contains(eventFactory.get())); 4040 ASSERT(!eventFactories().contains(eventFactory.get()));
4041 eventFactories().add(eventFactory); 4041 eventFactories().add(eventFactory);
4042 } 4042 }
4043 4043
4044 PassRefPtrWillBeRawPtr<Event> Document::createEvent(ExecutionContext* executionC ontext, const String& eventType, ExceptionState& exceptionState) 4044 RawPtr<Event> Document::createEvent(ExecutionContext* executionContext, const St ring& eventType, ExceptionState& exceptionState)
4045 { 4045 {
4046 RefPtrWillBeRawPtr<Event> event = nullptr; 4046 RawPtr<Event> event = nullptr;
4047 for (const auto& factory : eventFactories()) { 4047 for (const auto& factory : eventFactories()) {
4048 event = factory->create(executionContext, eventType); 4048 event = factory->create(executionContext, eventType);
4049 if (event) 4049 if (event)
4050 return event.release(); 4050 return event.release();
4051 } 4051 }
4052 exceptionState.throwDOMException(NotSupportedError, "The provided event type ('" + eventType + "') is invalid."); 4052 exceptionState.throwDOMException(NotSupportedError, "The provided event type ('" + eventType + "') is invalid.");
4053 return nullptr; 4053 return nullptr;
4054 } 4054 }
4055 4055
4056 void Document::addMutationEventListenerTypeIfEnabled(ListenerType listenerType) 4056 void Document::addMutationEventListenerTypeIfEnabled(ListenerType listenerType)
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
4625 if (!equalIgnoringCase(linkElement->type(), openSearchMIMEType) || !equa lIgnoringCase(linkElement->rel(), openSearchRelation)) 4625 if (!equalIgnoringCase(linkElement->type(), openSearchMIMEType) || !equa lIgnoringCase(linkElement->rel(), openSearchRelation))
4626 continue; 4626 continue;
4627 if (linkElement->href().isEmpty()) 4627 if (linkElement->href().isEmpty())
4628 continue; 4628 continue;
4629 return linkElement->href(); 4629 return linkElement->href();
4630 } 4630 }
4631 4631
4632 return KURL(); 4632 return KURL();
4633 } 4633 }
4634 4634
4635 void Document::pushCurrentScript(PassRefPtrWillBeRawPtr<HTMLScriptElement> newCu rrentScript) 4635 void Document::pushCurrentScript(RawPtr<HTMLScriptElement> newCurrentScript)
4636 { 4636 {
4637 ASSERT(newCurrentScript); 4637 ASSERT(newCurrentScript);
4638 m_currentScriptStack.append(newCurrentScript); 4638 m_currentScriptStack.append(newCurrentScript);
4639 } 4639 }
4640 4640
4641 void Document::popCurrentScript() 4641 void Document::popCurrentScript()
4642 { 4642 {
4643 ASSERT(!m_currentScriptStack.isEmpty()); 4643 ASSERT(!m_currentScriptStack.isEmpty());
4644 m_currentScriptStack.removeLast(); 4644 m_currentScriptStack.removeLast();
4645 } 4645 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
4684 // FIXME: Not clear what topDocument() should do in the OOPI case--should it return the topmost 4684 // FIXME: Not clear what topDocument() should do in the OOPI case--should it return the topmost
4685 // available Document, or something else? 4685 // available Document, or something else?
4686 Document* doc = const_cast<Document*>(this); 4686 Document* doc = const_cast<Document*>(this);
4687 for (HTMLFrameOwnerElement* element = doc->ownerElement(); element; element = doc->ownerElement()) 4687 for (HTMLFrameOwnerElement* element = doc->ownerElement(); element; element = doc->ownerElement())
4688 doc = &element->document(); 4688 doc = &element->document();
4689 4689
4690 ASSERT(doc); 4690 ASSERT(doc);
4691 return *doc; 4691 return *doc;
4692 } 4692 }
4693 4693
4694 WeakPtrWillBeRawPtr<Document> Document::contextDocument() 4694 RawPtr<Document> Document::contextDocument()
4695 { 4695 {
4696 if (m_contextDocument) 4696 if (m_contextDocument)
4697 return m_contextDocument; 4697 return m_contextDocument;
4698 if (m_frame) { 4698 if (m_frame) {
4699 return createWeakPtr(); 4699 return createWeakPtr();
4700 } 4700 }
4701 return nullptr; 4701 return nullptr;
4702 } 4702 }
4703 4703
4704 PassRefPtrWillBeRawPtr<Attr> Document::createAttribute(const AtomicString& name, ExceptionState& exceptionState) 4704 RawPtr<Attr> Document::createAttribute(const AtomicString& name, ExceptionState& exceptionState)
4705 { 4705 {
4706 if (isHTMLDocument() && name != name.lower()) 4706 if (isHTMLDocument() && name != name.lower())
4707 UseCounter::count(*this, UseCounter::HTMLDocumentCreateAttributeNameNotL owercase); 4707 UseCounter::count(*this, UseCounter::HTMLDocumentCreateAttributeNameNotL owercase);
4708 return createAttributeNS(nullAtom, name, exceptionState, true); 4708 return createAttributeNS(nullAtom, name, exceptionState, true);
4709 } 4709 }
4710 4710
4711 PassRefPtrWillBeRawPtr<Attr> Document::createAttributeNS(const AtomicString& nam espaceURI, const AtomicString& qualifiedName, ExceptionState& exceptionState, bo ol shouldIgnoreNamespaceChecks) 4711 RawPtr<Attr> Document::createAttributeNS(const AtomicString& namespaceURI, const AtomicString& qualifiedName, ExceptionState& exceptionState, bool shouldIgnoreN amespaceChecks)
4712 { 4712 {
4713 AtomicString prefix, localName; 4713 AtomicString prefix, localName;
4714 if (!parseQualifiedName(qualifiedName, prefix, localName, exceptionState)) 4714 if (!parseQualifiedName(qualifiedName, prefix, localName, exceptionState))
4715 return nullptr; 4715 return nullptr;
4716 4716
4717 QualifiedName qName(prefix, localName, namespaceURI); 4717 QualifiedName qName(prefix, localName, namespaceURI);
4718 4718
4719 if (!shouldIgnoreNamespaceChecks && !hasValidNamespaceForAttributes(qName)) { 4719 if (!shouldIgnoreNamespaceChecks && !hasValidNamespaceForAttributes(qName)) {
4720 exceptionState.throwDOMException(NamespaceError, "The namespace URI prov ided ('" + namespaceURI + "') is not valid for the qualified name provided ('" + qualifiedName + "')."); 4720 exceptionState.throwDOMException(NamespaceError, "The namespace URI prov ided ('" + namespaceURI + "') is not valid for the qualified name provided ('" + qualifiedName + "').");
4721 return nullptr; 4721 return nullptr;
4722 } 4722 }
4723 4723
4724 return Attr::create(*this, qName, emptyAtom); 4724 return Attr::create(*this, qName, emptyAtom);
4725 } 4725 }
4726 4726
4727 const SVGDocumentExtensions* Document::svgExtensions() 4727 const SVGDocumentExtensions* Document::svgExtensions()
4728 { 4728 {
4729 return m_svgExtensions.get(); 4729 return m_svgExtensions.get();
4730 } 4730 }
4731 4731
4732 SVGDocumentExtensions& Document::accessSVGExtensions() 4732 SVGDocumentExtensions& Document::accessSVGExtensions()
4733 { 4733 {
4734 if (!m_svgExtensions) 4734 if (!m_svgExtensions)
4735 m_svgExtensions = adoptPtrWillBeNoop(new SVGDocumentExtensions(this)); 4735 m_svgExtensions = new SVGDocumentExtensions(this);
4736 return *m_svgExtensions; 4736 return *m_svgExtensions;
4737 } 4737 }
4738 4738
4739 bool Document::hasSVGRootNode() const 4739 bool Document::hasSVGRootNode() const
4740 { 4740 {
4741 return isSVGSVGElement(documentElement()); 4741 return isSVGSVGElement(documentElement());
4742 } 4742 }
4743 4743
4744 PassRefPtrWillBeRawPtr<HTMLCollection> Document::images() 4744 RawPtr<HTMLCollection> Document::images()
4745 { 4745 {
4746 return ensureCachedCollection<HTMLCollection>(DocImages); 4746 return ensureCachedCollection<HTMLCollection>(DocImages);
4747 } 4747 }
4748 4748
4749 PassRefPtrWillBeRawPtr<HTMLCollection> Document::applets() 4749 RawPtr<HTMLCollection> Document::applets()
4750 { 4750 {
4751 return ensureCachedCollection<HTMLCollection>(DocApplets); 4751 return ensureCachedCollection<HTMLCollection>(DocApplets);
4752 } 4752 }
4753 4753
4754 PassRefPtrWillBeRawPtr<HTMLCollection> Document::embeds() 4754 RawPtr<HTMLCollection> Document::embeds()
4755 { 4755 {
4756 return ensureCachedCollection<HTMLCollection>(DocEmbeds); 4756 return ensureCachedCollection<HTMLCollection>(DocEmbeds);
4757 } 4757 }
4758 4758
4759 PassRefPtrWillBeRawPtr<HTMLCollection> Document::scripts() 4759 RawPtr<HTMLCollection> Document::scripts()
4760 { 4760 {
4761 return ensureCachedCollection<HTMLCollection>(DocScripts); 4761 return ensureCachedCollection<HTMLCollection>(DocScripts);
4762 } 4762 }
4763 4763
4764 PassRefPtrWillBeRawPtr<HTMLCollection> Document::links() 4764 RawPtr<HTMLCollection> Document::links()
4765 { 4765 {
4766 return ensureCachedCollection<HTMLCollection>(DocLinks); 4766 return ensureCachedCollection<HTMLCollection>(DocLinks);
4767 } 4767 }
4768 4768
4769 PassRefPtrWillBeRawPtr<HTMLCollection> Document::forms() 4769 RawPtr<HTMLCollection> Document::forms()
4770 { 4770 {
4771 return ensureCachedCollection<HTMLCollection>(DocForms); 4771 return ensureCachedCollection<HTMLCollection>(DocForms);
4772 } 4772 }
4773 4773
4774 PassRefPtrWillBeRawPtr<HTMLCollection> Document::anchors() 4774 RawPtr<HTMLCollection> Document::anchors()
4775 { 4775 {
4776 return ensureCachedCollection<HTMLCollection>(DocAnchors); 4776 return ensureCachedCollection<HTMLCollection>(DocAnchors);
4777 } 4777 }
4778 4778
4779 PassRefPtrWillBeRawPtr<HTMLAllCollection> Document::allForBinding() 4779 RawPtr<HTMLAllCollection> Document::allForBinding()
4780 { 4780 {
4781 UseCounter::count(*this, UseCounter::DocumentAll); 4781 UseCounter::count(*this, UseCounter::DocumentAll);
4782 return all(); 4782 return all();
4783 } 4783 }
4784 4784
4785 PassRefPtrWillBeRawPtr<HTMLAllCollection> Document::all() 4785 RawPtr<HTMLAllCollection> Document::all()
4786 { 4786 {
4787 return ensureCachedCollection<HTMLAllCollection>(DocAll); 4787 return ensureCachedCollection<HTMLAllCollection>(DocAll);
4788 } 4788 }
4789 4789
4790 PassRefPtrWillBeRawPtr<HTMLCollection> Document::windowNamedItems(const AtomicSt ring& name) 4790 RawPtr<HTMLCollection> Document::windowNamedItems(const AtomicString& name)
4791 { 4791 {
4792 return ensureCachedCollection<WindowNameCollection>(WindowNamedItems, name); 4792 return ensureCachedCollection<WindowNameCollection>(WindowNamedItems, name);
4793 } 4793 }
4794 4794
4795 PassRefPtrWillBeRawPtr<DocumentNameCollection> Document::documentNamedItems(cons t AtomicString& name) 4795 RawPtr<DocumentNameCollection> Document::documentNamedItems(const AtomicString& name)
4796 { 4796 {
4797 return ensureCachedCollection<DocumentNameCollection>(DocumentNamedItems, na me); 4797 return ensureCachedCollection<DocumentNameCollection>(DocumentNamedItems, na me);
4798 } 4798 }
4799 4799
4800 void Document::finishedParsing() 4800 void Document::finishedParsing()
4801 { 4801 {
4802 ASSERT(!scriptableDocumentParser() || !m_parser->isParsing()); 4802 ASSERT(!scriptableDocumentParser() || !m_parser->isParsing());
4803 ASSERT(!scriptableDocumentParser() || m_readyState != Loading); 4803 ASSERT(!scriptableDocumentParser() || m_readyState != Loading);
4804 setParsingState(InDOMContentLoaded); 4804 setParsingState(InDOMContentLoaded);
4805 4805
4806 // FIXME: DOMContentLoaded is dispatched synchronously, but this should be d ispatched in a queued task, 4806 // FIXME: DOMContentLoaded is dispatched synchronously, but this should be d ispatched in a queued task,
4807 // See https://crbug.com/425790 4807 // See https://crbug.com/425790
4808 if (!m_documentTiming.domContentLoadedEventStart()) 4808 if (!m_documentTiming.domContentLoadedEventStart())
4809 m_documentTiming.markDomContentLoadedEventStart(); 4809 m_documentTiming.markDomContentLoadedEventStart();
4810 dispatchEvent(Event::createBubble(EventTypeNames::DOMContentLoaded)); 4810 dispatchEvent(Event::createBubble(EventTypeNames::DOMContentLoaded));
4811 if (!m_documentTiming.domContentLoadedEventEnd()) 4811 if (!m_documentTiming.domContentLoadedEventEnd())
4812 m_documentTiming.markDomContentLoadedEventEnd(); 4812 m_documentTiming.markDomContentLoadedEventEnd();
4813 setParsingState(FinishedParsing); 4813 setParsingState(FinishedParsing);
4814 4814
4815 // The microtask checkpoint or the loader's finishedParsing() method may inv oke script that causes this object to 4815 // The microtask checkpoint or the loader's finishedParsing() method may inv oke script that causes this object to
4816 // be dereferenced (when this document is in an iframe and the onload causes the iframe's src to change). 4816 // be dereferenced (when this document is in an iframe and the onload causes the iframe's src to change).
4817 // Keep it alive until we are done. 4817 // Keep it alive until we are done.
4818 RefPtrWillBeRawPtr<Document> protect(this); 4818 RawPtr<Document> protect(this);
4819 4819
4820 // Ensure Custom Element callbacks are drained before DOMContentLoaded. 4820 // Ensure Custom Element callbacks are drained before DOMContentLoaded.
4821 // FIXME: Remove this ad-hoc checkpoint when DOMContentLoaded is dispatched in a 4821 // FIXME: Remove this ad-hoc checkpoint when DOMContentLoaded is dispatched in a
4822 // queued task, which will do a checkpoint anyway. https://crbug.com/425790 4822 // queued task, which will do a checkpoint anyway. https://crbug.com/425790
4823 Microtask::performCheckpoint(V8PerIsolateData::mainThreadIsolate()); 4823 Microtask::performCheckpoint(V8PerIsolateData::mainThreadIsolate());
4824 4824
4825 if (RefPtrWillBeRawPtr<LocalFrame> frame = this->frame()) { 4825 if (RawPtr<LocalFrame> frame = this->frame()) {
4826 // Don't update the layout tree if we haven't requested the main resourc e yet to avoid 4826 // Don't update the layout tree if we haven't requested the main resourc e yet to avoid
4827 // adding extra latency. Note that the first layout tree update can be e xpensive since it 4827 // adding extra latency. Note that the first layout tree update can be e xpensive since it
4828 // triggers the parsing of the default stylesheets which are compiled-in . 4828 // triggers the parsing of the default stylesheets which are compiled-in .
4829 const bool mainResourceWasAlreadyRequested = frame->loader().stateMachin e()->committedFirstRealDocumentLoad(); 4829 const bool mainResourceWasAlreadyRequested = frame->loader().stateMachin e()->committedFirstRealDocumentLoad();
4830 4830
4831 // FrameLoader::finishedParsing() might end up calling Document::implici tClose() if all 4831 // FrameLoader::finishedParsing() might end up calling Document::implici tClose() if all
4832 // resource loads are complete. HTMLObjectElements can start loading the ir resources from 4832 // resource loads are complete. HTMLObjectElements can start loading the ir resources from
4833 // post attach callbacks triggered by recalcStyle(). This means if we p arse out an <object> 4833 // post attach callbacks triggered by recalcStyle(). This means if we p arse out an <object>
4834 // tag and then reach the end of the document without updating styles, w e might not have yet 4834 // tag and then reach the end of the document without updating styles, w e might not have yet
4835 // started the resource load and might fire the window load event too ea rly. To avoid this 4835 // started the resource load and might fire the window load event too ea rly. To avoid this
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
5037 setBaseURLOverride(initializer.parentBaseURL()); 5037 setBaseURLOverride(initializer.parentBaseURL());
5038 } 5038 }
5039 5039
5040 if (getSecurityOrigin()->isUnique() && SecurityOrigin::create(m_url)->isPote ntiallyTrustworthy()) 5040 if (getSecurityOrigin()->isUnique() && SecurityOrigin::create(m_url)->isPote ntiallyTrustworthy())
5041 getSecurityOrigin()->setUniqueOriginIsPotentiallyTrustworthy(true); 5041 getSecurityOrigin()->setUniqueOriginIsPotentiallyTrustworthy(true);
5042 5042
5043 if (getSecurityOrigin()->hasSuborigin()) 5043 if (getSecurityOrigin()->hasSuborigin())
5044 enforceSuborigin(*getSecurityOrigin()->suborigin()); 5044 enforceSuborigin(*getSecurityOrigin()->suborigin());
5045 } 5045 }
5046 5046
5047 void Document::initContentSecurityPolicy(PassRefPtrWillBeRawPtr<ContentSecurityP olicy> csp) 5047 void Document::initContentSecurityPolicy(RawPtr<ContentSecurityPolicy> csp)
5048 { 5048 {
5049 setContentSecurityPolicy(csp ? csp : ContentSecurityPolicy::create()); 5049 setContentSecurityPolicy(csp ? csp : ContentSecurityPolicy::create());
5050 if (m_frame && m_frame->tree().parent() && m_frame->tree().parent()->isLocal Frame()) { 5050 if (m_frame && m_frame->tree().parent() && m_frame->tree().parent()->isLocal Frame()) {
5051 ContentSecurityPolicy* parentCSP = toLocalFrame(m_frame->tree().parent() )->document()->contentSecurityPolicy(); 5051 ContentSecurityPolicy* parentCSP = toLocalFrame(m_frame->tree().parent() )->document()->contentSecurityPolicy();
5052 if (shouldInheritSecurityOriginFromOwner(m_url)) { 5052 if (shouldInheritSecurityOriginFromOwner(m_url)) {
5053 contentSecurityPolicy()->copyStateFrom(parentCSP); 5053 contentSecurityPolicy()->copyStateFrom(parentCSP);
5054 } else if (isPluginDocument()) { 5054 } else if (isPluginDocument()) {
5055 // Per CSP2, plugin-types for plugin documents in nested browsing 5055 // Per CSP2, plugin-types for plugin documents in nested browsing
5056 // contexts gets inherited from the parent. 5056 // contexts gets inherited from the parent.
5057 contentSecurityPolicy()->copyPluginTypesFrom(parentCSP); 5057 contentSecurityPolicy()->copyPluginTypesFrom(parentCSP);
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
5185 { 5185 {
5186 if (equalIgnoringCase(dnsPrefetchControl, "on") && !m_haveExplicitlyDisabled DNSPrefetch) { 5186 if (equalIgnoringCase(dnsPrefetchControl, "on") && !m_haveExplicitlyDisabled DNSPrefetch) {
5187 m_isDNSPrefetchEnabled = true; 5187 m_isDNSPrefetchEnabled = true;
5188 return; 5188 return;
5189 } 5189 }
5190 5190
5191 m_isDNSPrefetchEnabled = false; 5191 m_isDNSPrefetchEnabled = false;
5192 m_haveExplicitlyDisabledDNSPrefetch = true; 5192 m_haveExplicitlyDisabledDNSPrefetch = true;
5193 } 5193 }
5194 5194
5195 WeakPtrWillBeRawPtr<Document> Document::createWeakPtr() 5195 RawPtr<Document> Document::createWeakPtr()
5196 { 5196 {
5197 #if ENABLE(OILPAN) 5197 #if ENABLE(OILPAN)
5198 return this; 5198 return this;
5199 #else 5199 #else
5200 return m_weakFactory.createWeakPtr(); 5200 return m_weakFactory.createWeakPtr();
5201 #endif 5201 #endif
5202 } 5202 }
5203 5203
5204 IntersectionObserverController* Document::intersectionObserverController() 5204 IntersectionObserverController* Document::intersectionObserverController()
5205 { 5205 {
(...skipping 12 matching lines...) Expand all
5218 if (!m_intersectionObserverData) 5218 if (!m_intersectionObserverData)
5219 m_intersectionObserverData = new NodeIntersectionObserverData(); 5219 m_intersectionObserverData = new NodeIntersectionObserverData();
5220 return *m_intersectionObserverData; 5220 return *m_intersectionObserverData;
5221 } 5221 }
5222 5222
5223 void Document::reportBlockedScriptExecutionToInspector(const String& directiveTe xt) 5223 void Document::reportBlockedScriptExecutionToInspector(const String& directiveTe xt)
5224 { 5224 {
5225 InspectorInstrumentation::scriptExecutionBlockedByCSP(this, directiveText); 5225 InspectorInstrumentation::scriptExecutionBlockedByCSP(this, directiveText);
5226 } 5226 }
5227 5227
5228 void Document::addConsoleMessage(PassRefPtrWillBeRawPtr<ConsoleMessage> consoleM essage) 5228 void Document::addConsoleMessage(RawPtr<ConsoleMessage> consoleMessage)
5229 { 5229 {
5230 if (!isContextThread()) { 5230 if (!isContextThread()) {
5231 m_taskRunner->postTask(BLINK_FROM_HERE, AddConsoleMessageTask::create(co nsoleMessage->source(), consoleMessage->level(), consoleMessage->message())); 5231 m_taskRunner->postTask(BLINK_FROM_HERE, AddConsoleMessageTask::create(co nsoleMessage->source(), consoleMessage->level(), consoleMessage->message()));
5232 return; 5232 return;
5233 } 5233 }
5234 5234
5235 if (!m_frame) 5235 if (!m_frame)
5236 return; 5236 return;
5237 5237
5238 if (!consoleMessage->getScriptState() && consoleMessage->url().isNull() && ! consoleMessage->lineNumber()) { 5238 if (!consoleMessage->getScriptState() && consoleMessage->url().isNull() && ! consoleMessage->lineNumber()) {
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
5454 return ensureScriptedIdleTaskController().registerCallback(callback, options ); 5454 return ensureScriptedIdleTaskController().registerCallback(callback, options );
5455 } 5455 }
5456 5456
5457 void Document::cancelIdleCallback(int id) 5457 void Document::cancelIdleCallback(int id)
5458 { 5458 {
5459 if (!m_scriptedIdleTaskController) 5459 if (!m_scriptedIdleTaskController)
5460 return; 5460 return;
5461 m_scriptedIdleTaskController->cancelCallback(id); 5461 m_scriptedIdleTaskController->cancelCallback(id);
5462 } 5462 }
5463 5463
5464 PassRefPtrWillBeRawPtr<Touch> Document::createTouch(DOMWindow* window, EventTarg et* target, int identifier, double pageX, double pageY, double screenX, double s creenY, double radiusX, double radiusY, float rotationAngle, float force) const 5464 RawPtr<Touch> Document::createTouch(DOMWindow* window, EventTarget* target, int identifier, double pageX, double pageY, double screenX, double screenY, double r adiusX, double radiusY, float rotationAngle, float force) const
5465 { 5465 {
5466 // Match behavior from when these types were integers, and avoid surprises f rom someone explicitly 5466 // Match behavior from when these types were integers, and avoid surprises f rom someone explicitly
5467 // passing Infinity/NaN. 5467 // passing Infinity/NaN.
5468 if (!std::isfinite(pageX)) 5468 if (!std::isfinite(pageX))
5469 pageX = 0; 5469 pageX = 0;
5470 if (!std::isfinite(pageY)) 5470 if (!std::isfinite(pageY))
5471 pageY = 0; 5471 pageY = 0;
5472 if (!std::isfinite(screenX)) 5472 if (!std::isfinite(screenX))
5473 screenX = 0; 5473 screenX = 0;
5474 if (!std::isfinite(screenY)) 5474 if (!std::isfinite(screenY))
5475 screenY = 0; 5475 screenY = 0;
5476 if (!std::isfinite(radiusX)) 5476 if (!std::isfinite(radiusX))
5477 radiusX = 0; 5477 radiusX = 0;
5478 if (!std::isfinite(radiusY)) 5478 if (!std::isfinite(radiusY))
5479 radiusY = 0; 5479 radiusY = 0;
5480 if (!std::isfinite(rotationAngle)) 5480 if (!std::isfinite(rotationAngle))
5481 rotationAngle = 0; 5481 rotationAngle = 0;
5482 if (!std::isfinite(force)) 5482 if (!std::isfinite(force))
5483 force = 0; 5483 force = 0;
5484 5484
5485 // FIXME: It's not clear from the documentation at 5485 // FIXME: It's not clear from the documentation at
5486 // http://developer.apple.com/library/safari/#documentation/UserExperience/R eference/DocumentAdditionsReference/DocumentAdditions/DocumentAdditions.html 5486 // http://developer.apple.com/library/safari/#documentation/UserExperience/R eference/DocumentAdditionsReference/DocumentAdditions/DocumentAdditions.html
5487 // when this method should throw and nor is it by inspection of iOS behavior . It would be nice to verify any cases where it throws under iOS 5487 // when this method should throw and nor is it by inspection of iOS behavior . It would be nice to verify any cases where it throws under iOS
5488 // and implement them here. See https://bugs.webkit.org/show_bug.cgi?id=4781 9 5488 // and implement them here. See https://bugs.webkit.org/show_bug.cgi?id=4781 9
5489 LocalFrame* frame = window && window->isLocalDOMWindow() ? toLocalDOMWindow( window)->frame() : this->frame(); 5489 LocalFrame* frame = window && window->isLocalDOMWindow() ? toLocalDOMWindow( window)->frame() : this->frame();
5490 return Touch::create(frame, target, identifier, FloatPoint(screenX, screenY) , FloatPoint(pageX, pageY), FloatSize(radiusX, radiusY), rotationAngle, force, S tring()); 5490 return Touch::create(frame, target, identifier, FloatPoint(screenX, screenY) , FloatPoint(pageX, pageY), FloatSize(radiusX, radiusY), rotationAngle, force, S tring());
5491 } 5491 }
5492 5492
5493 PassRefPtrWillBeRawPtr<TouchList> Document::createTouchList(WillBeHeapVector<Ref PtrWillBeMember<Touch>>& touches) const 5493 RawPtr<TouchList> Document::createTouchList(HeapVector<Member<Touch>>& touches) const
5494 { 5494 {
5495 return TouchList::adopt(touches); 5495 return TouchList::adopt(touches);
5496 } 5496 }
5497 5497
5498 DocumentLoader* Document::loader() const 5498 DocumentLoader* Document::loader() const
5499 { 5499 {
5500 if (!m_frame) 5500 if (!m_frame)
5501 return 0; 5501 return 0;
5502 5502
5503 DocumentLoader* loader = m_frame->loader().documentLoader(); 5503 DocumentLoader* loader = m_frame->loader().documentLoader();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
5553 s_threadedParsingEnabledForTesting = enabled; 5553 s_threadedParsingEnabledForTesting = enabled;
5554 } 5554 }
5555 5555
5556 bool Document::threadedParsingEnabledForTesting() 5556 bool Document::threadedParsingEnabledForTesting()
5557 { 5557 {
5558 return s_threadedParsingEnabledForTesting; 5558 return s_threadedParsingEnabledForTesting;
5559 } 5559 }
5560 5560
5561 void Document::setContextFeatures(ContextFeatures& features) 5561 void Document::setContextFeatures(ContextFeatures& features)
5562 { 5562 {
5563 m_contextFeatures = PassRefPtrWillBeRawPtr<ContextFeatures>(features); 5563 m_contextFeatures = RawPtr<ContextFeatures>(features);
5564 } 5564 }
5565 5565
5566 static LayoutObject* nearestCommonHoverAncestor(LayoutObject* obj1, LayoutObject * obj2) 5566 static LayoutObject* nearestCommonHoverAncestor(LayoutObject* obj1, LayoutObject * obj2)
5567 { 5567 {
5568 if (!obj1 || !obj2) 5568 if (!obj1 || !obj2)
5569 return 0; 5569 return 0;
5570 5570
5571 for (LayoutObject* currObj1 = obj1; currObj1; currObj1 = currObj1->hoverAnce stor()) { 5571 for (LayoutObject* currObj1 = obj1; currObj1; currObj1 = currObj1->hoverAnce stor()) {
5572 for (LayoutObject* currObj2 = obj2; currObj2; currObj2 = currObj2->hover Ancestor()) { 5572 for (LayoutObject* currObj2 = obj2; currObj2; currObj2 = currObj2->hover Ancestor()) {
5573 if (currObj1 == currObj2) 5573 if (currObj1 == currObj2)
(...skipping 15 matching lines...) Expand all
5589 while (innerElementInDocument && innerElementInDocument->document() != this) { 5589 while (innerElementInDocument && innerElementInDocument->document() != this) {
5590 innerElementInDocument->document().updateHoverActiveState(request, inner ElementInDocument); 5590 innerElementInDocument->document().updateHoverActiveState(request, inner ElementInDocument);
5591 innerElementInDocument = innerElementInDocument->document().ownerElement (); 5591 innerElementInDocument = innerElementInDocument->document().ownerElement ();
5592 } 5592 }
5593 5593
5594 updateDistribution(); 5594 updateDistribution();
5595 Element* oldActiveElement = activeHoverElement(); 5595 Element* oldActiveElement = activeHoverElement();
5596 if (oldActiveElement && !request.active()) { 5596 if (oldActiveElement && !request.active()) {
5597 // The oldActiveElement layoutObject is null, dropped on :active by sett ing display: none, 5597 // The oldActiveElement layoutObject is null, dropped on :active by sett ing display: none,
5598 // for instance. We still need to clear the ActiveChain as the mouse is released. 5598 // for instance. We still need to clear the ActiveChain as the mouse is released.
5599 for (RefPtrWillBeRawPtr<Node> node = oldActiveElement; node; node = Flat TreeTraversal::parent(*node)) { 5599 for (RawPtr<Node> node = oldActiveElement; node; node = FlatTreeTraversa l::parent(*node)) {
5600 ASSERT(!node->isTextNode()); 5600 ASSERT(!node->isTextNode());
5601 node->setActive(false); 5601 node->setActive(false);
5602 m_userActionElements.setInActiveChain(node.get(), false); 5602 m_userActionElements.setInActiveChain(node.get(), false);
5603 } 5603 }
5604 setActiveHoverElement(nullptr); 5604 setActiveHoverElement(nullptr);
5605 } else { 5605 } else {
5606 Element* newActiveElement = innerElementInDocument; 5606 Element* newActiveElement = innerElementInDocument;
5607 if (!oldActiveElement && newActiveElement && !newActiveElement->isDisabl edFormControl() && request.active() && !request.touchMove()) { 5607 if (!oldActiveElement && newActiveElement && !newActiveElement->isDisabl edFormControl() && request.active() && !request.touchMove()) {
5608 // We are setting the :active chain and freezing it. If future moves happen, they 5608 // We are setting the :active chain and freezing it. If future moves happen, they
5609 // will need to reference this chain. 5609 // will need to reference this chain.
5610 for (Node* node = newActiveElement; node; node = FlatTreeTraversal:: parent(*node)) { 5610 for (Node* node = newActiveElement; node; node = FlatTreeTraversal:: parent(*node)) {
5611 ASSERT(!node->isTextNode()); 5611 ASSERT(!node->isTextNode());
5612 m_userActionElements.setInActiveChain(node, true); 5612 m_userActionElements.setInActiveChain(node, true);
5613 } 5613 }
5614 setActiveHoverElement(newActiveElement); 5614 setActiveHoverElement(newActiveElement);
5615 } 5615 }
5616 } 5616 }
5617 // If the mouse has just been pressed, set :active on the chain. Those (and only those) 5617 // If the mouse has just been pressed, set :active on the chain. Those (and only those)
5618 // nodes should remain :active until the mouse is released. 5618 // nodes should remain :active until the mouse is released.
5619 bool allowActiveChanges = !oldActiveElement && activeHoverElement(); 5619 bool allowActiveChanges = !oldActiveElement && activeHoverElement();
5620 5620
5621 // If the mouse is down and if this is a mouse move event, we want to restri ct changes in 5621 // If the mouse is down and if this is a mouse move event, we want to restri ct changes in
5622 // :hover/:active to only apply to elements that are in the :active chain th at we froze 5622 // :hover/:active to only apply to elements that are in the :active chain th at we froze
5623 // at the time the mouse went down. 5623 // at the time the mouse went down.
5624 bool mustBeInActiveChain = request.active() && request.move(); 5624 bool mustBeInActiveChain = request.active() && request.move();
5625 5625
5626 RefPtrWillBeRawPtr<Node> oldHoverNode = hoverNode(); 5626 RawPtr<Node> oldHoverNode = hoverNode();
5627 5627
5628 // Check to see if the hovered node has changed. 5628 // Check to see if the hovered node has changed.
5629 // If it hasn't, we do not need to do anything. 5629 // If it hasn't, we do not need to do anything.
5630 Node* newHoverNode = innerElementInDocument; 5630 Node* newHoverNode = innerElementInDocument;
5631 while (newHoverNode && !newHoverNode->layoutObject()) 5631 while (newHoverNode && !newHoverNode->layoutObject())
5632 newHoverNode = newHoverNode->parentOrShadowHostNode(); 5632 newHoverNode = newHoverNode->parentOrShadowHostNode();
5633 5633
5634 // Update our current hover node. 5634 // Update our current hover node.
5635 setHoverNode(newHoverNode); 5635 setHoverNode(newHoverNode);
5636 5636
5637 // We have two different objects. Fetch their layoutObjects. 5637 // We have two different objects. Fetch their layoutObjects.
5638 LayoutObject* oldHoverObj = oldHoverNode ? oldHoverNode->layoutObject() : 0; 5638 LayoutObject* oldHoverObj = oldHoverNode ? oldHoverNode->layoutObject() : 0;
5639 LayoutObject* newHoverObj = newHoverNode ? newHoverNode->layoutObject() : 0; 5639 LayoutObject* newHoverObj = newHoverNode ? newHoverNode->layoutObject() : 0;
5640 5640
5641 // Locate the common ancestor layout object for the two layoutObjects. 5641 // Locate the common ancestor layout object for the two layoutObjects.
5642 LayoutObject* ancestor = nearestCommonHoverAncestor(oldHoverObj, newHoverObj ); 5642 LayoutObject* ancestor = nearestCommonHoverAncestor(oldHoverObj, newHoverObj );
5643 RefPtrWillBeRawPtr<Node> ancestorNode(ancestor ? ancestor->node() : 0); 5643 RawPtr<Node> ancestorNode(ancestor ? ancestor->node() : 0);
5644 5644
5645 WillBeHeapVector<RefPtrWillBeMember<Node>, 32> nodesToRemoveFromChain; 5645 HeapVector<Member<Node>, 32> nodesToRemoveFromChain;
5646 WillBeHeapVector<RefPtrWillBeMember<Node>, 32> nodesToAddToChain; 5646 HeapVector<Member<Node>, 32> nodesToAddToChain;
5647 5647
5648 if (oldHoverObj != newHoverObj) { 5648 if (oldHoverObj != newHoverObj) {
5649 // If the old hovered node is not nil but it's layoutObject is, it was p robably detached as part of the :hover style 5649 // If the old hovered node is not nil but it's layoutObject is, it was p robably detached as part of the :hover style
5650 // (for instance by setting display:none in the :hover pseudo-class). In this case, the old hovered element (and its ancestors) 5650 // (for instance by setting display:none in the :hover pseudo-class). In this case, the old hovered element (and its ancestors)
5651 // must be updated, to ensure it's normal style is re-applied. 5651 // must be updated, to ensure it's normal style is re-applied.
5652 if (oldHoverNode && !oldHoverObj) { 5652 if (oldHoverNode && !oldHoverObj) {
5653 for (Node* node = oldHoverNode.get(); node; node = node->parentNode( )) { 5653 for (Node* node = oldHoverNode.get(); node; node = node->parentNode( )) {
5654 if (!mustBeInActiveChain || (node->isElementNode() && toElement( node)->inActiveChain())) 5654 if (!mustBeInActiveChain || (node->isElementNode() && toElement( node)->inActiveChain()))
5655 nodesToRemoveFromChain.append(node); 5655 nodesToRemoveFromChain.append(node);
5656 } 5656 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
5751 if (m_associatedFormControls.isEmpty()) 5751 if (m_associatedFormControls.isEmpty())
5752 m_didAssociateFormControlsTimer.stop(); 5752 m_didAssociateFormControlsTimer.stop();
5753 } 5753 }
5754 5754
5755 void Document::didAssociateFormControlsTimerFired(Timer<Document>* timer) 5755 void Document::didAssociateFormControlsTimerFired(Timer<Document>* timer)
5756 { 5756 {
5757 ASSERT_UNUSED(timer, timer == &m_didAssociateFormControlsTimer); 5757 ASSERT_UNUSED(timer, timer == &m_didAssociateFormControlsTimer);
5758 if (!frame() || !frame()->page()) 5758 if (!frame() || !frame()->page())
5759 return; 5759 return;
5760 5760
5761 WillBeHeapVector<RefPtrWillBeMember<Element>> associatedFormControls; 5761 HeapVector<Member<Element>> associatedFormControls;
5762 copyToVector(m_associatedFormControls, associatedFormControls); 5762 copyToVector(m_associatedFormControls, associatedFormControls);
5763 5763
5764 frame()->page()->chromeClient().didAssociateFormControls(associatedFormContr ols, frame()); 5764 frame()->page()->chromeClient().didAssociateFormControls(associatedFormContr ols, frame());
5765 m_associatedFormControls.clear(); 5765 m_associatedFormControls.clear();
5766 } 5766 }
5767 5767
5768 float Document::devicePixelRatio() const 5768 float Document::devicePixelRatio() const
5769 { 5769 {
5770 return m_frame ? m_frame->devicePixelRatio() : 1.0; 5770 return m_frame ? m_frame->devicePixelRatio() : 1.0;
5771 } 5771 }
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
5887 return; 5887 return;
5888 5888
5889 styleEngine().platformColorsChanged(); 5889 styleEngine().platformColorsChanged();
5890 } 5890 }
5891 5891
5892 v8::Local<v8::Object> Document::wrap(v8::Isolate* isolate, v8::Local<v8::Object> creationContext) 5892 v8::Local<v8::Object> Document::wrap(v8::Isolate* isolate, v8::Local<v8::Object> creationContext)
5893 { 5893 {
5894 // It's possible that no one except for the new wrapper owns this object at 5894 // It's possible that no one except for the new wrapper owns this object at
5895 // this moment, so we have to prevent GC to collect this object until the 5895 // this moment, so we have to prevent GC to collect this object until the
5896 // object gets associated with the wrapper. 5896 // object gets associated with the wrapper.
5897 RefPtrWillBeRawPtr<Document> protect(this); 5897 RawPtr<Document> protect(this);
5898 5898
5899 ASSERT(!DOMDataStore::containsWrapper(this, isolate)); 5899 ASSERT(!DOMDataStore::containsWrapper(this, isolate));
5900 5900
5901 const WrapperTypeInfo* wrapperType = wrapperTypeInfo(); 5901 const WrapperTypeInfo* wrapperType = wrapperTypeInfo();
5902 5902
5903 if (frame() && frame()->script().initializeMainWorld()) { 5903 if (frame() && frame()->script().initializeMainWorld()) {
5904 // initializeMainWorld may have created a wrapper for the object, retry from the start. 5904 // initializeMainWorld may have created a wrapper for the object, retry from the start.
5905 v8::Local<v8::Object> wrapper = DOMDataStore::getWrapper(this, isolate); 5905 v8::Local<v8::Object> wrapper = DOMDataStore::getWrapper(this, isolate);
5906 if (!wrapper.IsEmpty()) 5906 if (!wrapper.IsEmpty())
5907 return wrapper; 5907 return wrapper;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
5956 return Platform::current()->currentThread()->scheduler()->timerTaskRunner(); 5956 return Platform::current()->currentThread()->scheduler()->timerTaskRunner();
5957 } 5957 }
5958 5958
5959 void Document::enforceStrictMixedContentChecking() 5959 void Document::enforceStrictMixedContentChecking()
5960 { 5960 {
5961 securityContext().setShouldEnforceStrictMixedContentChecking(true); 5961 securityContext().setShouldEnforceStrictMixedContentChecking(true);
5962 if (frame()) 5962 if (frame())
5963 frame()->loader().client()->didEnforceStrictMixedContentChecking(); 5963 frame()->loader().client()->didEnforceStrictMixedContentChecking();
5964 } 5964 }
5965 5965
5966 PassOwnPtrWillBeRawPtr<OriginTrialContext> Document::createOriginTrialContext() 5966 RawPtr<OriginTrialContext> Document::createOriginTrialContext()
5967 { 5967 {
5968 return adoptPtrWillBeNoop(new DocumentOriginTrialContext(this)); 5968 return new DocumentOriginTrialContext(this);
5969 } 5969 }
5970 5970
5971 DEFINE_TRACE(Document) 5971 DEFINE_TRACE(Document)
5972 { 5972 {
5973 #if ENABLE(OILPAN) 5973 #if ENABLE(OILPAN)
5974 visitor->trace(m_importsController); 5974 visitor->trace(m_importsController);
5975 visitor->trace(m_docType); 5975 visitor->trace(m_docType);
5976 visitor->trace(m_implementation); 5976 visitor->trace(m_implementation);
5977 visitor->trace(m_autofocusElement); 5977 visitor->trace(m_autofocusElement);
5978 visitor->trace(m_focusedElement); 5978 visitor->trace(m_focusedElement);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
6019 visitor->trace(m_templateDocumentHost); 6019 visitor->trace(m_templateDocumentHost);
6020 visitor->trace(m_visibilityObservers); 6020 visitor->trace(m_visibilityObservers);
6021 visitor->trace(m_userActionElements); 6021 visitor->trace(m_userActionElements);
6022 visitor->trace(m_svgExtensions); 6022 visitor->trace(m_svgExtensions);
6023 visitor->trace(m_timeline); 6023 visitor->trace(m_timeline);
6024 visitor->trace(m_compositorPendingAnimations); 6024 visitor->trace(m_compositorPendingAnimations);
6025 visitor->trace(m_contextDocument); 6025 visitor->trace(m_contextDocument);
6026 visitor->trace(m_canvasFontCache); 6026 visitor->trace(m_canvasFontCache);
6027 visitor->trace(m_intersectionObserverController); 6027 visitor->trace(m_intersectionObserverController);
6028 visitor->trace(m_intersectionObserverData); 6028 visitor->trace(m_intersectionObserverData);
6029 WillBeHeapSupplementable<Document>::trace(visitor); 6029 HeapSupplementable<Document>::trace(visitor);
6030 #endif 6030 #endif
6031 TreeScope::trace(visitor); 6031 TreeScope::trace(visitor);
6032 ContainerNode::trace(visitor); 6032 ContainerNode::trace(visitor);
6033 ExecutionContext::trace(visitor); 6033 ExecutionContext::trace(visitor);
6034 DocumentLifecycleNotifier::trace(visitor); 6034 DocumentLifecycleNotifier::trace(visitor);
6035 SecurityContext::trace(visitor); 6035 SecurityContext::trace(visitor);
6036 } 6036 }
6037 6037
6038 template class CORE_TEMPLATE_EXPORT WillBeHeapSupplement<Document>; 6038 template class CORE_TEMPLATE_EXPORT HeapSupplement<Document>;
6039 6039
6040 } // namespace blink 6040 } // namespace blink
6041 6041
6042 #ifndef NDEBUG 6042 #ifndef NDEBUG
6043 using namespace blink; 6043 using namespace blink;
6044 void showLiveDocumentInstances() 6044 void showLiveDocumentInstances()
6045 { 6045 {
6046 Document::WeakDocumentSet& set = Document::liveDocumentSet(); 6046 Document::WeakDocumentSet& set = Document::liveDocumentSet();
6047 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 6047 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
6048 for (Document* document : set) 6048 for (Document* document : set)
6049 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data()); 6049 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data());
6050 } 6050 }
6051 #endif 6051 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.h ('k') | third_party/WebKit/Source/core/dom/DocumentFragment.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698