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

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, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 return origin->isPotentiallyTrustworthy(*errorMessage); 343 return origin->isPotentiallyTrustworthy(*errorMessage);
344 return origin->isPotentiallyTrustworthy(); 344 return origin->isPotentiallyTrustworthy();
345 } 345 }
346 346
347 uint64_t Document::s_globalTreeVersion = 0; 347 uint64_t Document::s_globalTreeVersion = 0;
348 348
349 static bool s_threadedParsingEnabledForTesting = true; 349 static bool s_threadedParsingEnabledForTesting = true;
350 350
351 Document::WeakDocumentSet& Document::liveDocumentSet() 351 Document::WeakDocumentSet& Document::liveDocumentSet()
352 { 352 {
353 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<WeakDocumentSet>, set, (adoptPtrW illBeNoop(new WeakDocumentSet()))); 353 DEFINE_STATIC_LOCAL(Persistent<WeakDocumentSet>, set, ((new WeakDocumentSet( ))));
354 return *set; 354 return *set;
355 } 355 }
356 356
357 // This class doesn't work with non-Document ExecutionContext. 357 // This class doesn't work with non-Document ExecutionContext.
358 class AutofocusTask final : public ExecutionContextTask { 358 class AutofocusTask final : public ExecutionContextTask {
359 public: 359 public:
360 static PassOwnPtr<AutofocusTask> create() 360 static PassOwnPtr<AutofocusTask> create()
361 { 361 {
362 return adoptPtr(new AutofocusTask()); 362 return adoptPtr(new AutofocusTask());
363 } 363 }
364 ~AutofocusTask() override { } 364 ~AutofocusTask() override { }
365 365
366 private: 366 private:
367 AutofocusTask() { } 367 AutofocusTask() { }
368 void performTask(ExecutionContext* context) override 368 void performTask(ExecutionContext* context) override
369 { 369 {
370 Document* document = toDocument(context); 370 Document* document = toDocument(context);
371 if (RefPtrWillBeRawPtr<Element> element = document->autofocusElement()) { 371 if (RawPtr<Element> element = document->autofocusElement()) {
372 document->setAutofocusElement(0); 372 document->setAutofocusElement(0);
373 element->focus(); 373 element->focus();
374 } 374 }
375 } 375 }
376 }; 376 };
377 377
378 Document::Document(const DocumentInit& initializer, DocumentClassFlags documentC lasses) 378 Document::Document(const DocumentInit& initializer, DocumentClassFlags documentC lasses)
379 : ContainerNode(0, CreateDocument) 379 : ContainerNode(0, CreateDocument)
380 , TreeScope(*this) 380 , TreeScope(*this)
381 , m_hasNodesWithPlaceholderStyle(false) 381 , m_hasNodesWithPlaceholderStyle(false)
(...skipping 19 matching lines...) Expand all
401 , m_mutationObserverTypes(0) 401 , m_mutationObserverTypes(0)
402 , m_visitedLinkState(VisitedLinkState::create(*this)) 402 , m_visitedLinkState(VisitedLinkState::create(*this))
403 , m_visuallyOrdered(false) 403 , m_visuallyOrdered(false)
404 , m_readyState(Complete) 404 , m_readyState(Complete)
405 , m_parsingState(FinishedParsing) 405 , m_parsingState(FinishedParsing)
406 , m_gotoAnchorNeededAfterStylesheetsLoad(false) 406 , m_gotoAnchorNeededAfterStylesheetsLoad(false)
407 , m_containsValidityStyleRules(false) 407 , m_containsValidityStyleRules(false)
408 , m_containsPlugins(false) 408 , m_containsPlugins(false)
409 , m_updateFocusAppearanceSelectionBahavior(SelectionBehaviorOnFocus::Reset) 409 , m_updateFocusAppearanceSelectionBahavior(SelectionBehaviorOnFocus::Reset)
410 , m_ignoreDestructiveWriteCount(0) 410 , m_ignoreDestructiveWriteCount(0)
411 , m_markers(adoptPtrWillBeNoop(new DocumentMarkerController)) 411 , m_markers((new DocumentMarkerController))
412 , m_updateFocusAppearanceTimer(this, &Document::updateFocusAppearanceTimerFi red) 412 , m_updateFocusAppearanceTimer(this, &Document::updateFocusAppearanceTimerFi red)
413 , m_cssTarget(nullptr) 413 , m_cssTarget(nullptr)
414 , m_loadEventProgress(LoadEventNotRun) 414 , m_loadEventProgress(LoadEventNotRun)
415 , m_startTime(currentTime()) 415 , m_startTime(currentTime())
416 , m_scriptRunner(ScriptRunner::create(this)) 416 , m_scriptRunner(ScriptRunner::create(this))
417 , m_xmlVersion("1.0") 417 , m_xmlVersion("1.0")
418 , m_xmlStandalone(StandaloneUnspecified) 418 , m_xmlStandalone(StandaloneUnspecified)
419 , m_hasXMLDeclaration(0) 419 , m_hasXMLDeclaration(0)
420 , m_designMode(false) 420 , m_designMode(false)
421 , m_isRunningExecCommand(false) 421 , m_isRunningExecCommand(false)
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 return; 642 return;
643 m_compatibilityMode = mode; 643 m_compatibilityMode = mode;
644 selectorQueryCache().invalidate(); 644 selectorQueryCache().invalidate();
645 } 645 }
646 646
647 String Document::compatMode() const 647 String Document::compatMode() const
648 { 648 {
649 return inQuirksMode() ? "BackCompat" : "CSS1Compat"; 649 return inQuirksMode() ? "BackCompat" : "CSS1Compat";
650 } 650 }
651 651
652 void Document::setDoctype(PassRefPtrWillBeRawPtr<DocumentType> docType) 652 void Document::setDoctype(RawPtr<DocumentType> docType)
653 { 653 {
654 // This should never be called more than once. 654 // This should never be called more than once.
655 ASSERT(!m_docType || !docType); 655 ASSERT(!m_docType || !docType);
656 m_docType = docType; 656 m_docType = docType;
657 if (m_docType) { 657 if (m_docType) {
658 this->adoptIfNeeded(*m_docType); 658 this->adoptIfNeeded(*m_docType);
659 if (m_docType->publicId().startsWith("-//wapforum//dtd xhtml mobile 1.", TextCaseInsensitive)) 659 if (m_docType->publicId().startsWith("-//wapforum//dtd xhtml mobile 1.", TextCaseInsensitive))
660 m_isMobileDocument = true; 660 m_isMobileDocument = true;
661 } 661 }
662 // Doctype affects the interpretation of the stylesheets. 662 // Doctype affects the interpretation of the stylesheets.
(...skipping 24 matching lines...) Expand all
687 { 687 {
688 ContainerNode::childrenChanged(change); 688 ContainerNode::childrenChanged(change);
689 m_documentElement = ElementTraversal::firstWithin(*this); 689 m_documentElement = ElementTraversal::firstWithin(*this);
690 } 690 }
691 691
692 AtomicString Document::convertLocalName(const AtomicString& name) 692 AtomicString Document::convertLocalName(const AtomicString& name)
693 { 693 {
694 return isHTMLDocument() ? name.lower() : name; 694 return isHTMLDocument() ? name.lower() : name;
695 } 695 }
696 696
697 PassRefPtrWillBeRawPtr<Element> Document::createElement(const AtomicString& name , ExceptionState& exceptionState) 697 RawPtr<Element> Document::createElement(const AtomicString& name, ExceptionState & exceptionState)
698 { 698 {
699 if (!isValidName(name)) { 699 if (!isValidName(name)) {
700 exceptionState.throwDOMException(InvalidCharacterError, "The tag name pr ovided ('" + name + "') is not a valid name."); 700 exceptionState.throwDOMException(InvalidCharacterError, "The tag name pr ovided ('" + name + "') is not a valid name.");
701 return nullptr; 701 return nullptr;
702 } 702 }
703 703
704 if (isXHTMLDocument() || isHTMLDocument()) 704 if (isXHTMLDocument() || isHTMLDocument())
705 return HTMLElementFactory::createHTMLElement(convertLocalName(name), *th is, 0, false); 705 return HTMLElementFactory::createHTMLElement(convertLocalName(name), *th is, 0, false);
706 706
707 return Element::create(QualifiedName(nullAtom, name, nullAtom), this); 707 return Element::create(QualifiedName(nullAtom, name, nullAtom), this);
708 } 708 }
709 709
710 PassRefPtrWillBeRawPtr<Element> Document::createElement(const AtomicString& loca lName, const AtomicString& typeExtension, ExceptionState& exceptionState) 710 RawPtr<Element> Document::createElement(const AtomicString& localName, const Ato micString& typeExtension, ExceptionState& exceptionState)
711 { 711 {
712 if (!isValidName(localName)) { 712 if (!isValidName(localName)) {
713 exceptionState.throwDOMException(InvalidCharacterError, "The tag name pr ovided ('" + localName + "') is not a valid name."); 713 exceptionState.throwDOMException(InvalidCharacterError, "The tag name pr ovided ('" + localName + "') is not a valid name.");
714 return nullptr; 714 return nullptr;
715 } 715 }
716 716
717 RefPtrWillBeRawPtr<Element> element; 717 RawPtr<Element> element;
718 718
719 if (CustomElement::isValidName(localName) && registrationContext()) { 719 if (CustomElement::isValidName(localName) && registrationContext()) {
720 element = registrationContext()->createCustomTagElement(*this, Qualified Name(nullAtom, convertLocalName(localName), xhtmlNamespaceURI)); 720 element = registrationContext()->createCustomTagElement(*this, Qualified Name(nullAtom, convertLocalName(localName), xhtmlNamespaceURI));
721 } else { 721 } else {
722 element = createElement(localName, exceptionState); 722 element = createElement(localName, exceptionState);
723 if (exceptionState.hadException()) 723 if (exceptionState.hadException())
724 return nullptr; 724 return nullptr;
725 } 725 }
726 726
727 if (!typeExtension.isEmpty()) 727 if (!typeExtension.isEmpty())
(...skipping 10 matching lines...) Expand all
738 738
739 QualifiedName qName(prefix, localName, namespaceURI); 739 QualifiedName qName(prefix, localName, namespaceURI);
740 if (!Document::hasValidNamespaceForElements(qName)) { 740 if (!Document::hasValidNamespaceForElements(qName)) {
741 exceptionState.throwDOMException(NamespaceError, "The namespace URI prov ided ('" + namespaceURI + "') is not valid for the qualified name provided ('" + qualifiedName + "')."); 741 exceptionState.throwDOMException(NamespaceError, "The namespace URI prov ided ('" + namespaceURI + "') is not valid for the qualified name provided ('" + qualifiedName + "').");
742 return QualifiedName::null(); 742 return QualifiedName::null();
743 } 743 }
744 744
745 return qName; 745 return qName;
746 } 746 }
747 747
748 PassRefPtrWillBeRawPtr<Element> Document::createElementNS(const AtomicString& na mespaceURI, const AtomicString& qualifiedName, ExceptionState& exceptionState) 748 RawPtr<Element> Document::createElementNS(const AtomicString& namespaceURI, cons t AtomicString& qualifiedName, ExceptionState& exceptionState)
749 { 749 {
750 QualifiedName qName(createQualifiedName(namespaceURI, qualifiedName, excepti onState)); 750 QualifiedName qName(createQualifiedName(namespaceURI, qualifiedName, excepti onState));
751 if (qName == QualifiedName::null()) 751 if (qName == QualifiedName::null())
752 return nullptr; 752 return nullptr;
753 753
754 return createElement(qName, false); 754 return createElement(qName, false);
755 } 755 }
756 756
757 PassRefPtrWillBeRawPtr<Element> Document::createElementNS(const AtomicString& na mespaceURI, const AtomicString& qualifiedName, const AtomicString& typeExtension , ExceptionState& exceptionState) 757 RawPtr<Element> Document::createElementNS(const AtomicString& namespaceURI, cons t AtomicString& qualifiedName, const AtomicString& typeExtension, ExceptionState & exceptionState)
758 { 758 {
759 QualifiedName qName(createQualifiedName(namespaceURI, qualifiedName, excepti onState)); 759 QualifiedName qName(createQualifiedName(namespaceURI, qualifiedName, excepti onState));
760 if (qName == QualifiedName::null()) 760 if (qName == QualifiedName::null())
761 return nullptr; 761 return nullptr;
762 762
763 RefPtrWillBeRawPtr<Element> element; 763 RawPtr<Element> element;
764 if (CustomElement::isValidName(qName.localName()) && registrationContext()) 764 if (CustomElement::isValidName(qName.localName()) && registrationContext())
765 element = registrationContext()->createCustomTagElement(*this, qName); 765 element = registrationContext()->createCustomTagElement(*this, qName);
766 else 766 else
767 element = createElement(qName, false); 767 element = createElement(qName, false);
768 768
769 if (!typeExtension.isEmpty()) 769 if (!typeExtension.isEmpty())
770 CustomElementRegistrationContext::setIsAttributeAndTypeExtension(element .get(), typeExtension); 770 CustomElementRegistrationContext::setIsAttributeAndTypeExtension(element .get(), typeExtension);
771 771
772 return element.release(); 772 return element.release();
773 } 773 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 } 825 }
826 826
827 LocalFrame* Document::executingFrame() 827 LocalFrame* Document::executingFrame()
828 { 828 {
829 LocalDOMWindow* window = executingWindow(); 829 LocalDOMWindow* window = executingWindow();
830 if (!window) 830 if (!window)
831 return 0; 831 return 0;
832 return window->frame(); 832 return window->frame();
833 } 833 }
834 834
835 PassRefPtrWillBeRawPtr<DocumentFragment> Document::createDocumentFragment() 835 RawPtr<DocumentFragment> Document::createDocumentFragment()
836 { 836 {
837 return DocumentFragment::create(*this); 837 return DocumentFragment::create(*this);
838 } 838 }
839 839
840 PassRefPtrWillBeRawPtr<Text> Document::createTextNode(const String& data) 840 RawPtr<Text> Document::createTextNode(const String& data)
841 { 841 {
842 return Text::create(*this, data); 842 return Text::create(*this, data);
843 } 843 }
844 844
845 PassRefPtrWillBeRawPtr<Comment> Document::createComment(const String& data) 845 RawPtr<Comment> Document::createComment(const String& data)
846 { 846 {
847 return Comment::create(*this, data); 847 return Comment::create(*this, data);
848 } 848 }
849 849
850 PassRefPtrWillBeRawPtr<CDATASection> Document::createCDATASection(const String& data, ExceptionState& exceptionState) 850 RawPtr<CDATASection> Document::createCDATASection(const String& data, ExceptionS tate& exceptionState)
851 { 851 {
852 if (isHTMLDocument()) { 852 if (isHTMLDocument()) {
853 exceptionState.throwDOMException(NotSupportedError, "This operation is n ot supported for HTML documents."); 853 exceptionState.throwDOMException(NotSupportedError, "This operation is n ot supported for HTML documents.");
854 return nullptr; 854 return nullptr;
855 } 855 }
856 if (data.contains("]]>")) { 856 if (data.contains("]]>")) {
857 exceptionState.throwDOMException(InvalidCharacterError, "String cannot c ontain ']]>' since that is the end delimiter of a CData section."); 857 exceptionState.throwDOMException(InvalidCharacterError, "String cannot c ontain ']]>' since that is the end delimiter of a CData section.");
858 return nullptr; 858 return nullptr;
859 } 859 }
860 return CDATASection::create(*this, data); 860 return CDATASection::create(*this, data);
861 } 861 }
862 862
863 PassRefPtrWillBeRawPtr<ProcessingInstruction> Document::createProcessingInstruct ion(const String& target, const String& data, ExceptionState& exceptionState) 863 RawPtr<ProcessingInstruction> Document::createProcessingInstruction(const String & target, const String& data, ExceptionState& exceptionState)
864 { 864 {
865 if (!isValidName(target)) { 865 if (!isValidName(target)) {
866 exceptionState.throwDOMException(InvalidCharacterError, "The target prov ided ('" + target + "') is not a valid name."); 866 exceptionState.throwDOMException(InvalidCharacterError, "The target prov ided ('" + target + "') is not a valid name.");
867 return nullptr; 867 return nullptr;
868 } 868 }
869 if (data.contains("?>")) { 869 if (data.contains("?>")) {
870 exceptionState.throwDOMException(InvalidCharacterError, "The data provid ed ('" + data + "') contains '?>'."); 870 exceptionState.throwDOMException(InvalidCharacterError, "The data provid ed ('" + data + "') contains '?>'.");
871 return nullptr; 871 return nullptr;
872 } 872 }
873 return ProcessingInstruction::create(*this, target, data); 873 return ProcessingInstruction::create(*this, target, data);
874 } 874 }
875 875
876 PassRefPtrWillBeRawPtr<Text> Document::createEditingTextNode(const String& text) 876 RawPtr<Text> Document::createEditingTextNode(const String& text)
877 { 877 {
878 return Text::createEditingText(*this, text); 878 return Text::createEditingText(*this, text);
879 } 879 }
880 880
881 bool Document::importContainerNodeChildren(ContainerNode* oldContainerNode, Pass RefPtrWillBeRawPtr<ContainerNode> newContainerNode, ExceptionState& exceptionSta te) 881 bool Document::importContainerNodeChildren(ContainerNode* oldContainerNode, RawP tr<ContainerNode> newContainerNode, ExceptionState& exceptionState)
882 { 882 {
883 for (Node& oldChild : NodeTraversal::childrenOf(*oldContainerNode)) { 883 for (Node& oldChild : NodeTraversal::childrenOf(*oldContainerNode)) {
884 RefPtrWillBeRawPtr<Node> newChild = importNode(&oldChild, true, exceptio nState); 884 RawPtr<Node> newChild = importNode(&oldChild, true, exceptionState);
885 if (exceptionState.hadException()) 885 if (exceptionState.hadException())
886 return false; 886 return false;
887 newContainerNode->appendChild(newChild.release(), exceptionState); 887 newContainerNode->appendChild(newChild.release(), exceptionState);
888 if (exceptionState.hadException()) 888 if (exceptionState.hadException())
889 return false; 889 return false;
890 } 890 }
891 891
892 return true; 892 return true;
893 } 893 }
894 894
895 PassRefPtrWillBeRawPtr<Node> Document::importNode(Node* importedNode, bool deep, ExceptionState& exceptionState) 895 RawPtr<Node> Document::importNode(Node* importedNode, bool deep, ExceptionState& exceptionState)
896 { 896 {
897 switch (importedNode->nodeType()) { 897 switch (importedNode->nodeType()) {
898 case TEXT_NODE: 898 case TEXT_NODE:
899 return createTextNode(importedNode->nodeValue()); 899 return createTextNode(importedNode->nodeValue());
900 case CDATA_SECTION_NODE: 900 case CDATA_SECTION_NODE:
901 return CDATASection::create(*this, importedNode->nodeValue()); 901 return CDATASection::create(*this, importedNode->nodeValue());
902 case PROCESSING_INSTRUCTION_NODE: 902 case PROCESSING_INSTRUCTION_NODE:
903 return createProcessingInstruction(importedNode->nodeName(), importedNod e->nodeValue(), exceptionState); 903 return createProcessingInstruction(importedNode->nodeName(), importedNod e->nodeValue(), exceptionState);
904 case COMMENT_NODE: 904 case COMMENT_NODE:
905 return createComment(importedNode->nodeValue()); 905 return createComment(importedNode->nodeValue());
906 case DOCUMENT_TYPE_NODE: { 906 case DOCUMENT_TYPE_NODE: {
907 DocumentType* doctype = toDocumentType(importedNode); 907 DocumentType* doctype = toDocumentType(importedNode);
908 return DocumentType::create(this, doctype->name(), doctype->publicId(), doctype->systemId()); 908 return DocumentType::create(this, doctype->name(), doctype->publicId(), doctype->systemId());
909 } 909 }
910 case ELEMENT_NODE: { 910 case ELEMENT_NODE: {
911 Element* oldElement = toElement(importedNode); 911 Element* oldElement = toElement(importedNode);
912 // FIXME: The following check might be unnecessary. Is it possible that 912 // FIXME: The following check might be unnecessary. Is it possible that
913 // oldElement has mismatched prefix/namespace? 913 // oldElement has mismatched prefix/namespace?
914 if (!hasValidNamespaceForElements(oldElement->tagQName())) { 914 if (!hasValidNamespaceForElements(oldElement->tagQName())) {
915 exceptionState.throwDOMException(NamespaceError, "The imported node has an invalid namespace."); 915 exceptionState.throwDOMException(NamespaceError, "The imported node has an invalid namespace.");
916 return nullptr; 916 return nullptr;
917 } 917 }
918 RefPtrWillBeRawPtr<Element> newElement = createElement(oldElement->tagQN ame(), false); 918 RawPtr<Element> newElement = createElement(oldElement->tagQName(), false );
919 919
920 newElement->cloneDataFromElement(*oldElement); 920 newElement->cloneDataFromElement(*oldElement);
921 921
922 if (deep) { 922 if (deep) {
923 if (!importContainerNodeChildren(oldElement, newElement, exceptionSt ate)) 923 if (!importContainerNodeChildren(oldElement, newElement, exceptionSt ate))
924 return nullptr; 924 return nullptr;
925 if (isHTMLTemplateElement(*oldElement) 925 if (isHTMLTemplateElement(*oldElement)
926 && !ensureTemplateDocument().importContainerNodeChildren( 926 && !ensureTemplateDocument().importContainerNodeChildren(
927 toHTMLTemplateElement(oldElement)->content(), 927 toHTMLTemplateElement(oldElement)->content(),
928 toHTMLTemplateElement(newElement)->content(), exceptionState )) 928 toHTMLTemplateElement(newElement)->content(), exceptionState ))
929 return nullptr; 929 return nullptr;
930 } 930 }
931 931
932 return newElement.release(); 932 return newElement.release();
933 } 933 }
934 case ATTRIBUTE_NODE: 934 case ATTRIBUTE_NODE:
935 return Attr::create(*this, QualifiedName(nullAtom, AtomicString(toAttr(i mportedNode)->name()), nullAtom), toAttr(importedNode)->value()); 935 return Attr::create(*this, QualifiedName(nullAtom, AtomicString(toAttr(i mportedNode)->name()), nullAtom), toAttr(importedNode)->value());
936 case DOCUMENT_FRAGMENT_NODE: { 936 case DOCUMENT_FRAGMENT_NODE: {
937 if (importedNode->isShadowRoot()) { 937 if (importedNode->isShadowRoot()) {
938 // ShadowRoot nodes should not be explicitly importable. 938 // ShadowRoot nodes should not be explicitly importable.
939 // Either they are imported along with their host node, or created i mplicitly. 939 // Either they are imported along with their host node, or created i mplicitly.
940 exceptionState.throwDOMException(NotSupportedError, "The node provid ed is a shadow root, which may not be imported."); 940 exceptionState.throwDOMException(NotSupportedError, "The node provid ed is a shadow root, which may not be imported.");
941 return nullptr; 941 return nullptr;
942 } 942 }
943 DocumentFragment* oldFragment = toDocumentFragment(importedNode); 943 DocumentFragment* oldFragment = toDocumentFragment(importedNode);
944 RefPtrWillBeRawPtr<DocumentFragment> newFragment = createDocumentFragmen t(); 944 RawPtr<DocumentFragment> newFragment = createDocumentFragment();
945 if (deep && !importContainerNodeChildren(oldFragment, newFragment, excep tionState)) 945 if (deep && !importContainerNodeChildren(oldFragment, newFragment, excep tionState))
946 return nullptr; 946 return nullptr;
947 947
948 return newFragment.release(); 948 return newFragment.release();
949 } 949 }
950 case DOCUMENT_NODE: 950 case DOCUMENT_NODE:
951 exceptionState.throwDOMException(NotSupportedError, "The node provided i s a document, which may not be imported."); 951 exceptionState.throwDOMException(NotSupportedError, "The node provided i s a document, which may not be imported.");
952 return nullptr; 952 return nullptr;
953 } 953 }
954 954
955 ASSERT_NOT_REACHED(); 955 ASSERT_NOT_REACHED();
956 return nullptr; 956 return nullptr;
957 } 957 }
958 958
959 PassRefPtrWillBeRawPtr<Node> Document::adoptNode(PassRefPtrWillBeRawPtr<Node> so urce, ExceptionState& exceptionState) 959 RawPtr<Node> Document::adoptNode(RawPtr<Node> source, ExceptionState& exceptionS tate)
960 { 960 {
961 EventQueueScope scope; 961 EventQueueScope scope;
962 962
963 switch (source->nodeType()) { 963 switch (source->nodeType()) {
964 case DOCUMENT_NODE: 964 case DOCUMENT_NODE:
965 exceptionState.throwDOMException(NotSupportedError, "The node provided i s of type '" + source->nodeName() + "', which may not be adopted."); 965 exceptionState.throwDOMException(NotSupportedError, "The node provided i s of type '" + source->nodeName() + "', which may not be adopted.");
966 return nullptr; 966 return nullptr;
967 case ATTRIBUTE_NODE: { 967 case ATTRIBUTE_NODE: {
968 Attr* attr = toAttr(source.get()); 968 Attr* attr = toAttr(source.get());
969 if (RefPtrWillBeRawPtr<Element> ownerElement = attr->ownerElement()) 969 if (RawPtr<Element> ownerElement = attr->ownerElement())
970 ownerElement->removeAttributeNode(attr, exceptionState); 970 ownerElement->removeAttributeNode(attr, exceptionState);
971 break; 971 break;
972 } 972 }
973 default: 973 default:
974 if (source->isShadowRoot()) { 974 if (source->isShadowRoot()) {
975 // ShadowRoot cannot disconnect itself from the host node. 975 // ShadowRoot cannot disconnect itself from the host node.
976 exceptionState.throwDOMException(HierarchyRequestError, "The node pr ovided is a shadow root, which may not be adopted."); 976 exceptionState.throwDOMException(HierarchyRequestError, "The node pr ovided is a shadow root, which may not be adopted.");
977 return nullptr; 977 return nullptr;
978 } 978 }
979 979
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1013 return qName.namespaceURI() == XMLNSNames::xmlnsNamespaceURI; 1013 return qName.namespaceURI() == XMLNSNames::xmlnsNamespaceURI;
1014 return qName.namespaceURI() != XMLNSNames::xmlnsNamespaceURI; 1014 return qName.namespaceURI() != XMLNSNames::xmlnsNamespaceURI;
1015 } 1015 }
1016 1016
1017 bool Document::hasValidNamespaceForAttributes(const QualifiedName& qName) 1017 bool Document::hasValidNamespaceForAttributes(const QualifiedName& qName)
1018 { 1018 {
1019 return hasValidNamespaceForElements(qName); 1019 return hasValidNamespaceForElements(qName);
1020 } 1020 }
1021 1021
1022 // FIXME: This should really be in a possible ElementFactory class 1022 // FIXME: This should really be in a possible ElementFactory class
1023 PassRefPtrWillBeRawPtr<Element> Document::createElement(const QualifiedName& qNa me, bool createdByParser) 1023 RawPtr<Element> Document::createElement(const QualifiedName& qName, bool created ByParser)
1024 { 1024 {
1025 RefPtrWillBeRawPtr<Element> e = nullptr; 1025 RawPtr<Element> e = nullptr;
1026 1026
1027 // FIXME: Use registered namespaces and look up in a hash to find the right factory. 1027 // FIXME: Use registered namespaces and look up in a hash to find the right factory.
1028 if (qName.namespaceURI() == xhtmlNamespaceURI) 1028 if (qName.namespaceURI() == xhtmlNamespaceURI)
1029 e = HTMLElementFactory::createHTMLElement(qName.localName(), *this, 0, c reatedByParser); 1029 e = HTMLElementFactory::createHTMLElement(qName.localName(), *this, 0, c reatedByParser);
1030 else if (qName.namespaceURI() == SVGNames::svgNamespaceURI) 1030 else if (qName.namespaceURI() == SVGNames::svgNamespaceURI)
1031 e = SVGElementFactory::createSVGElement(qName.localName(), *this, create dByParser); 1031 e = SVGElementFactory::createSVGElement(qName.localName(), *this, create dByParser);
1032 1032
1033 if (e) 1033 if (e)
1034 m_sawElementsInKnownNamespaces = true; 1034 m_sawElementsInKnownNamespaces = true;
1035 else 1035 else
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1179 } 1179 }
1180 1180
1181 Element* Document::elementFromPoint(int x, int y) const 1181 Element* Document::elementFromPoint(int x, int y) const
1182 { 1182 {
1183 if (!layoutView()) 1183 if (!layoutView())
1184 return 0; 1184 return 0;
1185 1185
1186 return TreeScope::elementFromPoint(x, y); 1186 return TreeScope::elementFromPoint(x, y);
1187 } 1187 }
1188 1188
1189 WillBeHeapVector<RawPtrWillBeMember<Element>> Document::elementsFromPoint(int x, int y) const 1189 HeapVector<Member<Element>> Document::elementsFromPoint(int x, int y) const
1190 { 1190 {
1191 if (!layoutView()) 1191 if (!layoutView())
1192 return WillBeHeapVector<RawPtrWillBeMember<Element>>(); 1192 return HeapVector<Member<Element>>();
1193 return TreeScope::elementsFromPoint(x, y); 1193 return TreeScope::elementsFromPoint(x, y);
1194 } 1194 }
1195 1195
1196 PassRefPtrWillBeRawPtr<Range> Document::caretRangeFromPoint(int x, int y) 1196 RawPtr<Range> Document::caretRangeFromPoint(int x, int y)
1197 { 1197 {
1198 if (!layoutView()) 1198 if (!layoutView())
1199 return nullptr; 1199 return nullptr;
1200 1200
1201 HitTestResult result = hitTestInDocument(this, x, y); 1201 HitTestResult result = hitTestInDocument(this, x, y);
1202 PositionWithAffinity positionWithAffinity = result.position(); 1202 PositionWithAffinity positionWithAffinity = result.position();
1203 if (positionWithAffinity.position().isNull()) 1203 if (positionWithAffinity.position().isNull())
1204 return nullptr; 1204 return nullptr;
1205 1205
1206 Position rangeCompliantPosition = positionWithAffinity.position().parentAnch oredEquivalent(); 1206 Position rangeCompliantPosition = positionWithAffinity.position().parentAnch oredEquivalent();
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
1450 FrameHost* Document::frameHost() const 1450 FrameHost* Document::frameHost() const
1451 { 1451 {
1452 return m_frame ? m_frame->host() : 0; 1452 return m_frame ? m_frame->host() : 0;
1453 } 1453 }
1454 1454
1455 Settings* Document::settings() const 1455 Settings* Document::settings() const
1456 { 1456 {
1457 return m_frame ? m_frame->settings() : 0; 1457 return m_frame ? m_frame->settings() : 0;
1458 } 1458 }
1459 1459
1460 PassRefPtrWillBeRawPtr<Range> Document::createRange() 1460 RawPtr<Range> Document::createRange()
1461 { 1461 {
1462 return Range::create(*this); 1462 return Range::create(*this);
1463 } 1463 }
1464 1464
1465 PassRefPtrWillBeRawPtr<NodeIterator> Document::createNodeIterator(Node* root, un signed whatToShow, PassRefPtrWillBeRawPtr<NodeFilter> filter) 1465 RawPtr<NodeIterator> Document::createNodeIterator(Node* root, unsigned whatToSho w, RawPtr<NodeFilter> filter)
1466 { 1466 {
1467 ASSERT(root); 1467 ASSERT(root);
1468 return NodeIterator::create(root, whatToShow, filter); 1468 return NodeIterator::create(root, whatToShow, filter);
1469 } 1469 }
1470 1470
1471 PassRefPtrWillBeRawPtr<TreeWalker> Document::createTreeWalker(Node* root, unsign ed whatToShow, PassRefPtrWillBeRawPtr<NodeFilter> filter) 1471 RawPtr<TreeWalker> Document::createTreeWalker(Node* root, unsigned whatToShow, R awPtr<NodeFilter> filter)
1472 { 1472 {
1473 ASSERT(root); 1473 ASSERT(root);
1474 return TreeWalker::create(root, whatToShow, filter); 1474 return TreeWalker::create(root, whatToShow, filter);
1475 } 1475 }
1476 1476
1477 bool Document::needsLayoutTreeUpdate() const 1477 bool Document::needsLayoutTreeUpdate() const
1478 { 1478 {
1479 if (!isActive() || !view()) 1479 if (!isActive() || !view())
1480 return false; 1480 return false;
1481 if (needsFullLayoutTreeUpdate()) 1481 if (needsFullLayoutTreeUpdate())
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1552 return; 1552 return;
1553 if (!childNeedsStyleInvalidation()) 1553 if (!childNeedsStyleInvalidation())
1554 return; 1554 return;
1555 TRACE_EVENT0("blink", "Document::updateStyleInvalidationIfNeeded"); 1555 TRACE_EVENT0("blink", "Document::updateStyleInvalidationIfNeeded");
1556 styleEngine().styleInvalidator().invalidate(*this); 1556 styleEngine().styleInvalidator().invalidate(*this);
1557 } 1557 }
1558 1558
1559 void Document::setupFontBuilder(ComputedStyle& documentStyle) 1559 void Document::setupFontBuilder(ComputedStyle& documentStyle)
1560 { 1560 {
1561 FontBuilder fontBuilder(*this); 1561 FontBuilder fontBuilder(*this);
1562 RefPtrWillBeRawPtr<CSSFontSelector> selector = styleEngine().fontSelector(); 1562 RawPtr<CSSFontSelector> selector = styleEngine().fontSelector();
1563 fontBuilder.createFontForDocument(selector, documentStyle); 1563 fontBuilder.createFontForDocument(selector, documentStyle);
1564 } 1564 }
1565 1565
1566 void Document::inheritHtmlAndBodyElementStyles(StyleRecalcChange change) 1566 void Document::inheritHtmlAndBodyElementStyles(StyleRecalcChange change)
1567 { 1567 {
1568 ASSERT(inStyleRecalc()); 1568 ASSERT(inStyleRecalc());
1569 ASSERT(documentElement()); 1569 ASSERT(documentElement());
1570 1570
1571 bool didRecalcDocumentElement = false; 1571 bool didRecalcDocumentElement = false;
1572 RefPtr<ComputedStyle> documentElementStyle = documentElement()->mutableCompu tedStyle(); 1572 RefPtr<ComputedStyle> documentElementStyle = documentElement()->mutableCompu tedStyle();
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
1747 // tear down the layout tree or (unfortunately) run script. Kill the whole l ayoutObject if 1747 // tear down the layout tree or (unfortunately) run script. Kill the whole l ayoutObject if
1748 // someone managed to get into here from inside layout or paint. 1748 // someone managed to get into here from inside layout or paint.
1749 RELEASE_ASSERT(!view()->isInPerformLayout()); 1749 RELEASE_ASSERT(!view()->isInPerformLayout());
1750 RELEASE_ASSERT(!view()->isPainting()); 1750 RELEASE_ASSERT(!view()->isPainting());
1751 1751
1752 // Script can run below in WidgetUpdates, so protect the LocalFrame. 1752 // Script can run below in WidgetUpdates, so protect the LocalFrame.
1753 // TODO(esprehn): This should actually crash because of the ScriptForbiddenS cope, 1753 // TODO(esprehn): This should actually crash because of the ScriptForbiddenS cope,
1754 // for an example stack see crbug.com/536194, it seems like we should just u se 1754 // for an example stack see crbug.com/536194, it seems like we should just u se
1755 // a PluginScriptForbiddenScope to block all script from running inside here 1755 // a PluginScriptForbiddenScope to block all script from running inside here
1756 // to avoid the crash. 1756 // to avoid the crash.
1757 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); 1757 RawPtr<LocalFrame> protect(m_frame.get());
1758 1758
1759 TRACE_EVENT_BEGIN1("blink,devtools.timeline", "UpdateLayoutTree", "beginData ", InspectorRecalculateStylesEvent::data(frame())); 1759 TRACE_EVENT_BEGIN1("blink,devtools.timeline", "UpdateLayoutTree", "beginData ", InspectorRecalculateStylesEvent::data(frame()));
1760 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "UpdateLayoutTree"); 1760 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "UpdateLayoutTree");
1761 1761
1762 unsigned startElementCount = styleEngine().styleForElementCount(); 1762 unsigned startElementCount = styleEngine().styleForElementCount();
1763 1763
1764 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willRecalc ulateStyle(this); 1764 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willRecalc ulateStyle(this);
1765 1765
1766 DocumentAnimations::updateAnimationTimingIfNeeded(*this); 1766 DocumentAnimations::updateAnimationTimingIfNeeded(*this);
1767 evaluateMediaQueryListIfNeeded(); 1767 evaluateMediaQueryListIfNeeded();
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1908 if (needsRecalc) 1908 if (needsRecalc)
1909 updateLayoutTreeIfNeeded(); 1909 updateLayoutTreeIfNeeded();
1910 } 1910 }
1911 1911
1912 void Document::updateLayout() 1912 void Document::updateLayout()
1913 { 1913 {
1914 ASSERT(isMainThread()); 1914 ASSERT(isMainThread());
1915 1915
1916 ScriptForbiddenScope forbidScript; 1916 ScriptForbiddenScope forbidScript;
1917 1917
1918 RefPtrWillBeRawPtr<FrameView> frameView = view(); 1918 RawPtr<FrameView> frameView = view();
1919 if (frameView && frameView->isInPerformLayout()) { 1919 if (frameView && frameView->isInPerformLayout()) {
1920 // View layout should not be re-entrant. 1920 // View layout should not be re-entrant.
1921 ASSERT_NOT_REACHED(); 1921 ASSERT_NOT_REACHED();
1922 return; 1922 return;
1923 } 1923 }
1924 1924
1925 if (HTMLFrameOwnerElement* owner = ownerElement()) 1925 if (HTMLFrameOwnerElement* owner = ownerElement())
1926 owner->document().updateLayout(); 1926 owner->document().updateLayout();
1927 1927
1928 updateLayoutTreeIfNeeded(); 1928 updateLayoutTreeIfNeeded();
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
2125 m_useElementsNeedingUpdate.remove(&element); 2125 m_useElementsNeedingUpdate.remove(&element);
2126 } 2126 }
2127 2127
2128 void Document::updateUseShadowTreesIfNeeded() 2128 void Document::updateUseShadowTreesIfNeeded()
2129 { 2129 {
2130 ScriptForbiddenScope forbidScript; 2130 ScriptForbiddenScope forbidScript;
2131 2131
2132 if (m_useElementsNeedingUpdate.isEmpty()) 2132 if (m_useElementsNeedingUpdate.isEmpty())
2133 return; 2133 return;
2134 2134
2135 WillBeHeapVector<RawPtrWillBeMember<SVGUseElement>> elements; 2135 HeapVector<Member<SVGUseElement>> elements;
2136 copyToVector(m_useElementsNeedingUpdate, elements); 2136 copyToVector(m_useElementsNeedingUpdate, elements);
2137 m_useElementsNeedingUpdate.clear(); 2137 m_useElementsNeedingUpdate.clear();
2138 2138
2139 for (SVGUseElement* element : elements) 2139 for (SVGUseElement* element : elements)
2140 element->buildPendingResource(); 2140 element->buildPendingResource();
2141 } 2141 }
2142 2142
2143 StyleResolver* Document::styleResolver() const 2143 StyleResolver* Document::styleResolver() const
2144 { 2144 {
2145 return m_styleEngine->resolver(); 2145 return m_styleEngine->resolver();
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
2226 m_layoutView->setIsInWindow(false); 2226 m_layoutView->setIsInWindow(false);
2227 2227
2228 if (registrationContext()) 2228 if (registrationContext())
2229 registrationContext()->documentWasDetached(); 2229 registrationContext()->documentWasDetached();
2230 2230
2231 m_hoverNode = nullptr; 2231 m_hoverNode = nullptr;
2232 m_activeHoverElement = nullptr; 2232 m_activeHoverElement = nullptr;
2233 m_autofocusElement = nullptr; 2233 m_autofocusElement = nullptr;
2234 2234
2235 if (m_focusedElement.get()) { 2235 if (m_focusedElement.get()) {
2236 RefPtrWillBeRawPtr<Element> oldFocusedElement = m_focusedElement; 2236 RawPtr<Element> oldFocusedElement = m_focusedElement;
2237 m_focusedElement = nullptr; 2237 m_focusedElement = nullptr;
2238 if (frameHost()) 2238 if (frameHost())
2239 frameHost()->chromeClient().focusedNodeChanged(oldFocusedElement.get (), nullptr); 2239 frameHost()->chromeClient().focusedNodeChanged(oldFocusedElement.get (), nullptr);
2240 } 2240 }
2241 2241
2242 if (this == &axObjectCacheOwner()) 2242 if (this == &axObjectCacheOwner())
2243 clearAXObjectCache(); 2243 clearAXObjectCache();
2244 2244
2245 m_layoutView = nullptr; 2245 m_layoutView = nullptr;
2246 ContainerNode::detach(context); 2246 ContainerNode::detach(context);
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
2382 } 2382 }
2383 2383
2384 CanvasFontCache* Document::canvasFontCache() 2384 CanvasFontCache* Document::canvasFontCache()
2385 { 2385 {
2386 if (!m_canvasFontCache) 2386 if (!m_canvasFontCache)
2387 m_canvasFontCache = CanvasFontCache::create(*this); 2387 m_canvasFontCache = CanvasFontCache::create(*this);
2388 2388
2389 return m_canvasFontCache.get(); 2389 return m_canvasFontCache.get();
2390 } 2390 }
2391 2391
2392 PassRefPtrWillBeRawPtr<DocumentParser> Document::createParser() 2392 RawPtr<DocumentParser> Document::createParser()
2393 { 2393 {
2394 if (isHTMLDocument()) { 2394 if (isHTMLDocument()) {
2395 bool reportErrors = InspectorInstrumentation::collectingHTMLParseErrors( this); 2395 bool reportErrors = InspectorInstrumentation::collectingHTMLParseErrors( this);
2396 return HTMLDocumentParser::create(toHTMLDocument(*this), reportErrors, m _parserSyncPolicy); 2396 return HTMLDocumentParser::create(toHTMLDocument(*this), reportErrors, m _parserSyncPolicy);
2397 } 2397 }
2398 // FIXME: this should probably pass the frame instead 2398 // FIXME: this should probably pass the frame instead
2399 return XMLDocumentParser::create(*this, view()); 2399 return XMLDocumentParser::create(*this, view());
2400 } 2400 }
2401 2401
2402 bool Document::isFrameSet() const 2402 bool Document::isFrameSet() const
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
2475 m_parser.clear(); 2475 m_parser.clear();
2476 } 2476 }
2477 2477
2478 void Document::cancelParsing() 2478 void Document::cancelParsing()
2479 { 2479 {
2480 detachParser(); 2480 detachParser();
2481 setParsingState(FinishedParsing); 2481 setParsingState(FinishedParsing);
2482 setReadyState(Complete); 2482 setReadyState(Complete);
2483 } 2483 }
2484 2484
2485 PassRefPtrWillBeRawPtr<DocumentParser> Document::implicitOpen(ParserSynchronizat ionPolicy parserSyncPolicy) 2485 RawPtr<DocumentParser> Document::implicitOpen(ParserSynchronizationPolicy parser SyncPolicy)
2486 { 2486 {
2487 detachParser(); 2487 detachParser();
2488 2488
2489 removeChildren(); 2489 removeChildren();
2490 ASSERT(!m_focusedElement); 2490 ASSERT(!m_focusedElement);
2491 2491
2492 setCompatibilityMode(NoQuirksMode); 2492 setCompatibilityMode(NoQuirksMode);
2493 2493
2494 if (!threadedParsingEnabledForTesting()) 2494 if (!threadedParsingEnabledForTesting())
2495 parserSyncPolicy = ForceSynchronousParsing; 2495 parserSyncPolicy = ForceSynchronousParsing;
(...skipping 25 matching lines...) Expand all
2521 return 0; 2521 return 0;
2522 2522
2523 for (HTMLElement* child = Traversal<HTMLElement>::firstChild(*documentElemen t()); child; child = Traversal<HTMLElement>::nextSibling(*child)) { 2523 for (HTMLElement* child = Traversal<HTMLElement>::firstChild(*documentElemen t()); child; child = Traversal<HTMLElement>::nextSibling(*child)) {
2524 if (isHTMLBodyElement(*child)) 2524 if (isHTMLBodyElement(*child))
2525 return toHTMLBodyElement(child); 2525 return toHTMLBodyElement(child);
2526 } 2526 }
2527 2527
2528 return 0; 2528 return 0;
2529 } 2529 }
2530 2530
2531 void Document::setBody(PassRefPtrWillBeRawPtr<HTMLElement> prpNewBody, Exception State& exceptionState) 2531 void Document::setBody(RawPtr<HTMLElement> prpNewBody, ExceptionState& exception State)
2532 { 2532 {
2533 RefPtrWillBeRawPtr<HTMLElement> newBody = prpNewBody; 2533 RawPtr<HTMLElement> newBody = prpNewBody;
2534 2534
2535 if (!newBody) { 2535 if (!newBody) {
2536 exceptionState.throwDOMException(HierarchyRequestError, ExceptionMessage s::argumentNullOrIncorrectType(1, "HTMLElement")); 2536 exceptionState.throwDOMException(HierarchyRequestError, ExceptionMessage s::argumentNullOrIncorrectType(1, "HTMLElement"));
2537 return; 2537 return;
2538 } 2538 }
2539 if (!documentElement()) { 2539 if (!documentElement()) {
2540 exceptionState.throwDOMException(HierarchyRequestError, "No document ele ment exists."); 2540 exceptionState.throwDOMException(HierarchyRequestError, "No document ele ment exists.");
2541 return; 2541 return;
2542 } 2542 }
2543 2543
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
2603 } 2603 }
2604 2604
2605 close(); 2605 close();
2606 } 2606 }
2607 2607
2608 void Document::close() 2608 void Document::close()
2609 { 2609 {
2610 if (!scriptableDocumentParser() || !scriptableDocumentParser()->wasCreatedBy Script() || !scriptableDocumentParser()->isParsing()) 2610 if (!scriptableDocumentParser() || !scriptableDocumentParser()->wasCreatedBy Script() || !scriptableDocumentParser()->isParsing())
2611 return; 2611 return;
2612 2612
2613 if (RefPtrWillBeRawPtr<DocumentParser> parser = m_parser) 2613 if (RawPtr<DocumentParser> parser = m_parser)
2614 parser->finish(); 2614 parser->finish();
2615 2615
2616 if (!m_frame) { 2616 if (!m_frame) {
2617 // Because we have no frame, we don't know if all loading has completed, 2617 // Because we have no frame, we don't know if all loading has completed,
2618 // so we just call implicitClose() immediately. FIXME: This might fire 2618 // so we just call implicitClose() immediately. FIXME: This might fire
2619 // the load event prematurely <http://bugs.webkit.org/show_bug.cgi?id=14 568>. 2619 // the load event prematurely <http://bugs.webkit.org/show_bug.cgi?id=14 568>.
2620 implicitClose(); 2620 implicitClose();
2621 return; 2621 return;
2622 } 2622 }
2623 2623
2624 m_frame->loader().checkCompleted(); 2624 m_frame->loader().checkCompleted();
2625 } 2625 }
2626 2626
2627 void Document::implicitClose() 2627 void Document::implicitClose()
2628 { 2628 {
2629 ASSERT(!inStyleRecalc()); 2629 ASSERT(!inStyleRecalc());
2630 if (processingLoadEvent() || !m_parser) 2630 if (processingLoadEvent() || !m_parser)
2631 return; 2631 return;
2632 if (frame() && frame()->navigationScheduler().locationChangePending()) { 2632 if (frame() && frame()->navigationScheduler().locationChangePending()) {
2633 suppressLoadEvent(); 2633 suppressLoadEvent();
2634 return; 2634 return;
2635 } 2635 }
2636 2636
2637 // The call to dispatchWindowLoadEvent (from documentWasClosed()) can detach 2637 // The call to dispatchWindowLoadEvent (from documentWasClosed()) can detach
2638 // the LocalDOMWindow and cause it (and its attached Document) to be 2638 // the LocalDOMWindow and cause it (and its attached Document) to be
2639 // destroyed. 2639 // destroyed.
2640 RefPtrWillBeRawPtr<LocalDOMWindow> protectedWindow(this->domWindow()); 2640 RawPtr<LocalDOMWindow> protectedWindow(this->domWindow());
2641 2641
2642 m_loadEventProgress = LoadEventInProgress; 2642 m_loadEventProgress = LoadEventInProgress;
2643 2643
2644 ScriptableDocumentParser* parser = scriptableDocumentParser(); 2644 ScriptableDocumentParser* parser = scriptableDocumentParser();
2645 m_wellFormed = parser && parser->wellFormed(); 2645 m_wellFormed = parser && parser->wellFormed();
2646 2646
2647 // We have to clear the parser, in case someone document.write()s from the 2647 // We have to clear the parser, in case someone document.write()s from the
2648 // onLoad event handler, as in Radar 3206524. 2648 // onLoad event handler, as in Radar 3206524.
2649 detachParser(); 2649 detachParser();
2650 2650
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
2718 { 2718 {
2719 if (!m_domWindow) 2719 if (!m_domWindow)
2720 return true; 2720 return true;
2721 2721
2722 if (!body()) 2722 if (!body())
2723 return true; 2723 return true;
2724 2724
2725 if (processingBeforeUnload()) 2725 if (processingBeforeUnload())
2726 return false; 2726 return false;
2727 2727
2728 RefPtrWillBeRawPtr<Document> protect(this); 2728 RawPtr<Document> protect(this);
2729 2729
2730 RefPtrWillBeRawPtr<BeforeUnloadEvent> beforeUnloadEvent = BeforeUnloadEvent: :create(); 2730 RawPtr<BeforeUnloadEvent> beforeUnloadEvent = BeforeUnloadEvent::create();
2731 m_loadEventProgress = BeforeUnloadEventInProgress; 2731 m_loadEventProgress = BeforeUnloadEventInProgress;
2732 m_domWindow->dispatchEvent(beforeUnloadEvent.get(), this); 2732 m_domWindow->dispatchEvent(beforeUnloadEvent.get(), this);
2733 m_loadEventProgress = BeforeUnloadEventCompleted; 2733 m_loadEventProgress = BeforeUnloadEventCompleted;
2734 if (!beforeUnloadEvent->defaultPrevented()) 2734 if (!beforeUnloadEvent->defaultPrevented())
2735 defaultEventHandler(beforeUnloadEvent.get()); 2735 defaultEventHandler(beforeUnloadEvent.get());
2736 if (!frame() || beforeUnloadEvent->returnValue().isNull()) 2736 if (!frame() || beforeUnloadEvent->returnValue().isNull())
2737 return true; 2737 return true;
2738 2738
2739 if (didAllowNavigation) { 2739 if (didAllowNavigation) {
2740 addConsoleMessage(ConsoleMessage::create(JSMessageSource, ErrorMessageLe vel, "Blocked attempt to show multiple 'beforeunload' confirmation panels for a single navigation.")); 2740 addConsoleMessage(ConsoleMessage::create(JSMessageSource, ErrorMessageLe vel, "Blocked attempt to show multiple 'beforeunload' confirmation panels for a single navigation."));
2741 return true; 2741 return true;
2742 } 2742 }
2743 2743
2744 String text = beforeUnloadEvent->returnValue(); 2744 String text = beforeUnloadEvent->returnValue();
2745 if (chromeClient.openBeforeUnloadConfirmPanel(text, m_frame, isReload)) { 2745 if (chromeClient.openBeforeUnloadConfirmPanel(text, m_frame, isReload)) {
2746 didAllowNavigation = true; 2746 didAllowNavigation = true;
2747 return true; 2747 return true;
2748 } 2748 }
2749 return false; 2749 return false;
2750 } 2750 }
2751 2751
2752 void Document::dispatchUnloadEvents() 2752 void Document::dispatchUnloadEvents()
2753 { 2753 {
2754 PluginScriptForbiddenScope forbidPluginDestructorScripting; 2754 PluginScriptForbiddenScope forbidPluginDestructorScripting;
2755 RefPtrWillBeRawPtr<Document> protect(this); 2755 RawPtr<Document> protect(this);
2756 if (m_parser) 2756 if (m_parser)
2757 m_parser->stopParsing(); 2757 m_parser->stopParsing();
2758 2758
2759 if (m_loadEventProgress == LoadEventNotRun) 2759 if (m_loadEventProgress == LoadEventNotRun)
2760 return; 2760 return;
2761 2761
2762 if (m_loadEventProgress <= UnloadEventInProgress) { 2762 if (m_loadEventProgress <= UnloadEventInProgress) {
2763 Element* currentFocusedElement = focusedElement(); 2763 Element* currentFocusedElement = focusedElement();
2764 if (isHTMLInputElement(currentFocusedElement)) 2764 if (isHTMLInputElement(currentFocusedElement))
2765 toHTMLInputElement(*currentFocusedElement).endEditing(); 2765 toHTMLInputElement(*currentFocusedElement).endEditing();
2766 if (m_loadEventProgress < PageHideInProgress) { 2766 if (m_loadEventProgress < PageHideInProgress) {
2767 m_loadEventProgress = PageHideInProgress; 2767 m_loadEventProgress = PageHideInProgress;
2768 if (LocalDOMWindow* window = domWindow()) 2768 if (LocalDOMWindow* window = domWindow())
2769 window->dispatchEvent(PageTransitionEvent::create(EventTypeNames ::pagehide, false), this); 2769 window->dispatchEvent(PageTransitionEvent::create(EventTypeNames ::pagehide, false), this);
2770 if (!m_frame) 2770 if (!m_frame)
2771 return; 2771 return;
2772 2772
2773 // The DocumentLoader (and thus its DocumentLoadTiming) might get de stroyed 2773 // The DocumentLoader (and thus its DocumentLoadTiming) might get de stroyed
2774 // while dispatching the event, so protect it to prevent writing the end 2774 // while dispatching the event, so protect it to prevent writing the end
2775 // time into freed memory. 2775 // time into freed memory.
2776 RefPtrWillBeRawPtr<DocumentLoader> documentLoader = m_frame->loader( ).provisionalDocumentLoader(); 2776 RawPtr<DocumentLoader> documentLoader = m_frame->loader().provisiona lDocumentLoader();
2777 m_loadEventProgress = UnloadEventInProgress; 2777 m_loadEventProgress = UnloadEventInProgress;
2778 RefPtrWillBeRawPtr<Event> unloadEvent(Event::create(EventTypeNames:: unload)); 2778 RawPtr<Event> unloadEvent(Event::create(EventTypeNames::unload));
2779 if (documentLoader && !documentLoader->timing().unloadEventStart() & & !documentLoader->timing().unloadEventEnd()) { 2779 if (documentLoader && !documentLoader->timing().unloadEventStart() & & !documentLoader->timing().unloadEventEnd()) {
2780 DocumentLoadTiming& timing = documentLoader->timing(); 2780 DocumentLoadTiming& timing = documentLoader->timing();
2781 ASSERT(timing.navigationStart()); 2781 ASSERT(timing.navigationStart());
2782 timing.markUnloadEventStart(); 2782 timing.markUnloadEventStart();
2783 m_frame->localDOMWindow()->dispatchEvent(unloadEvent, this); 2783 m_frame->localDOMWindow()->dispatchEvent(unloadEvent, this);
2784 timing.markUnloadEventEnd(); 2784 timing.markUnloadEventEnd();
2785 } else { 2785 } else {
2786 m_frame->localDOMWindow()->dispatchEvent(unloadEvent, m_frame->d ocument()); 2786 m_frame->localDOMWindow()->dispatchEvent(unloadEvent, m_frame->d ocument());
2787 } 2787 }
2788 } 2788 }
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
2927 return &m_timers; 2927 return &m_timers;
2928 } 2928 }
2929 2929
2930 EventTarget* Document::errorEventTarget() 2930 EventTarget* Document::errorEventTarget()
2931 { 2931 {
2932 return domWindow(); 2932 return domWindow();
2933 } 2933 }
2934 2934
2935 void Document::logExceptionToConsole(const String& errorMessage, int scriptId, c onst String& sourceURL, int lineNumber, int columnNumber, PassRefPtr<ScriptCallS tack> callStack) 2935 void Document::logExceptionToConsole(const String& errorMessage, int scriptId, c onst String& sourceURL, int lineNumber, int columnNumber, PassRefPtr<ScriptCallS tack> callStack)
2936 { 2936 {
2937 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(J SMessageSource, ErrorMessageLevel, errorMessage, sourceURL, lineNumber, columnNu mber); 2937 RawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(JSMessageSour ce, ErrorMessageLevel, errorMessage, sourceURL, lineNumber, columnNumber);
2938 consoleMessage->setScriptId(scriptId); 2938 consoleMessage->setScriptId(scriptId);
2939 consoleMessage->setCallStack(callStack); 2939 consoleMessage->setCallStack(callStack);
2940 addConsoleMessage(consoleMessage.release()); 2940 addConsoleMessage(consoleMessage.release());
2941 } 2941 }
2942 2942
2943 void Document::setURL(const KURL& url) 2943 void Document::setURL(const KURL& url)
2944 { 2944 {
2945 const KURL& newURL = url.isEmpty() ? blankURL() : url; 2945 const KURL& newURL = url.isEmpty() ? blankURL() : url;
2946 if (newURL == m_url) 2946 if (newURL == m_url)
2947 return; 2947 return;
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
3316 if (numElements > 1 || numDoctypes > 1) { 3316 if (numElements > 1 || numDoctypes > 1) {
3317 exceptionState.throwDOMException(HierarchyRequestError, 3317 exceptionState.throwDOMException(HierarchyRequestError,
3318 String::format("Only one %s on document allowed.", 3318 String::format("Only one %s on document allowed.",
3319 numElements > 1 ? "element" : "doctype")); 3319 numElements > 1 ? "element" : "doctype"));
3320 return false; 3320 return false;
3321 } 3321 }
3322 3322
3323 return true; 3323 return true;
3324 } 3324 }
3325 3325
3326 PassRefPtrWillBeRawPtr<Node> Document::cloneNode(bool deep) 3326 RawPtr<Node> Document::cloneNode(bool deep)
3327 { 3327 {
3328 RefPtrWillBeRawPtr<Document> clone = cloneDocumentWithoutChildren(); 3328 RawPtr<Document> clone = cloneDocumentWithoutChildren();
3329 clone->cloneDataFromDocument(*this); 3329 clone->cloneDataFromDocument(*this);
3330 if (deep) 3330 if (deep)
3331 cloneChildNodes(clone.get()); 3331 cloneChildNodes(clone.get());
3332 return clone.release(); 3332 return clone.release();
3333 } 3333 }
3334 3334
3335 PassRefPtrWillBeRawPtr<Document> Document::cloneDocumentWithoutChildren() 3335 RawPtr<Document> Document::cloneDocumentWithoutChildren()
3336 { 3336 {
3337 DocumentInit init(url()); 3337 DocumentInit init(url());
3338 if (isXMLDocument()) { 3338 if (isXMLDocument()) {
3339 if (isXHTMLDocument()) 3339 if (isXHTMLDocument())
3340 return XMLDocument::createXHTML(init.withRegistrationContext(registr ationContext())); 3340 return XMLDocument::createXHTML(init.withRegistrationContext(registr ationContext()));
3341 return XMLDocument::create(init); 3341 return XMLDocument::create(init);
3342 } 3342 }
3343 return create(init); 3343 return create(init);
3344 } 3344 }
3345 3345
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
3476 if (layoutView()) 3476 if (layoutView())
3477 layoutView()->invalidatePaintForViewAndCompositedLayers(); 3477 layoutView()->invalidatePaintForViewAndCompositedLayers();
3478 } 3478 }
3479 } 3479 }
3480 3480
3481 void Document::styleResolverMayHaveChanged() 3481 void Document::styleResolverMayHaveChanged()
3482 { 3482 {
3483 styleResolverChanged(hasNodesWithPlaceholderStyle() ? FullStyleUpdate : Anal yzedStyleUpdate); 3483 styleResolverChanged(hasNodesWithPlaceholderStyle() ? FullStyleUpdate : Anal yzedStyleUpdate);
3484 } 3484 }
3485 3485
3486 void Document::setHoverNode(PassRefPtrWillBeRawPtr<Node> newHoverNode) 3486 void Document::setHoverNode(RawPtr<Node> newHoverNode)
3487 { 3487 {
3488 m_hoverNode = newHoverNode; 3488 m_hoverNode = newHoverNode;
3489 } 3489 }
3490 3490
3491 void Document::setActiveHoverElement(PassRefPtrWillBeRawPtr<Element> newActiveEl ement) 3491 void Document::setActiveHoverElement(RawPtr<Element> newActiveElement)
3492 { 3492 {
3493 if (!newActiveElement) { 3493 if (!newActiveElement) {
3494 m_activeHoverElement.clear(); 3494 m_activeHoverElement.clear();
3495 return; 3495 return;
3496 } 3496 }
3497 3497
3498 m_activeHoverElement = newActiveElement; 3498 m_activeHoverElement = newActiveElement;
3499 } 3499 }
3500 3500
3501 void Document::removeFocusedElementOfSubtree(Node* node, bool amongChildrenOnly) 3501 void Document::removeFocusedElementOfSubtree(Node* node, bool amongChildrenOnly)
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
3553 { 3553 {
3554 return m_annotatedRegions; 3554 return m_annotatedRegions;
3555 } 3555 }
3556 3556
3557 void Document::setAnnotatedRegions(const Vector<AnnotatedRegionValue>& regions) 3557 void Document::setAnnotatedRegions(const Vector<AnnotatedRegionValue>& regions)
3558 { 3558 {
3559 m_annotatedRegions = regions; 3559 m_annotatedRegions = regions;
3560 setAnnotatedRegionsDirty(false); 3560 setAnnotatedRegionsDirty(false);
3561 } 3561 }
3562 3562
3563 bool Document::setFocusedElement(PassRefPtrWillBeRawPtr<Element> prpNewFocusedEl ement, const FocusParams& params) 3563 bool Document::setFocusedElement(RawPtr<Element> prpNewFocusedElement, const Foc usParams& params)
3564 { 3564 {
3565 ASSERT(!m_lifecycle.inDetach()); 3565 ASSERT(!m_lifecycle.inDetach());
3566 3566
3567 m_clearFocusedElementTimer.stop(); 3567 m_clearFocusedElementTimer.stop();
3568 3568
3569 RefPtrWillBeRawPtr<Element> newFocusedElement = prpNewFocusedElement; 3569 RawPtr<Element> newFocusedElement = prpNewFocusedElement;
3570 3570
3571 // Make sure newFocusedNode is actually in this document 3571 // Make sure newFocusedNode is actually in this document
3572 if (newFocusedElement && (newFocusedElement->document() != this)) 3572 if (newFocusedElement && (newFocusedElement->document() != this))
3573 return true; 3573 return true;
3574 3574
3575 if (NodeChildRemovalTracker::isBeingRemoved(newFocusedElement.get())) 3575 if (NodeChildRemovalTracker::isBeingRemoved(newFocusedElement.get()))
3576 return true; 3576 return true;
3577 3577
3578 if (m_focusedElement == newFocusedElement) 3578 if (m_focusedElement == newFocusedElement)
3579 return true; 3579 return true;
3580 3580
3581 bool focusChangeBlocked = false; 3581 bool focusChangeBlocked = false;
3582 RefPtrWillBeRawPtr<Element> oldFocusedElement = m_focusedElement; 3582 RawPtr<Element> oldFocusedElement = m_focusedElement;
3583 m_focusedElement = nullptr; 3583 m_focusedElement = nullptr;
3584 3584
3585 // Remove focus from the existing focus node (if any) 3585 // Remove focus from the existing focus node (if any)
3586 if (oldFocusedElement) { 3586 if (oldFocusedElement) {
3587 if (oldFocusedElement->active()) 3587 if (oldFocusedElement->active())
3588 oldFocusedElement->setActive(false); 3588 oldFocusedElement->setActive(false);
3589 3589
3590 oldFocusedElement->setFocus(false); 3590 oldFocusedElement->setFocus(false);
3591 3591
3592 // Dispatch the blur event and let the node do any other blur related ac tivities (important for text fields) 3592 // Dispatch the blur event and let the node do any other blur related ac tivities (important for text fields)
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
3775 3775
3776 void Document::detachNodeIterator(NodeIterator* ni) 3776 void Document::detachNodeIterator(NodeIterator* ni)
3777 { 3777 {
3778 // The node iterator can be detached without having been attached if its roo t node didn't have a document 3778 // The node iterator can be detached without having been attached if its roo t node didn't have a document
3779 // when the iterator was created, but has it now. 3779 // when the iterator was created, but has it now.
3780 m_nodeIterators.remove(ni); 3780 m_nodeIterators.remove(ni);
3781 } 3781 }
3782 3782
3783 void Document::moveNodeIteratorsToNewDocument(Node& node, Document& newDocument) 3783 void Document::moveNodeIteratorsToNewDocument(Node& node, Document& newDocument)
3784 { 3784 {
3785 WillBeHeapHashSet<RawPtrWillBeWeakMember<NodeIterator>> nodeIteratorsList = m_nodeIterators; 3785 HeapHashSet<WeakMember<NodeIterator>> nodeIteratorsList = m_nodeIterators;
3786 for (NodeIterator* ni : nodeIteratorsList) { 3786 for (NodeIterator* ni : nodeIteratorsList) {
3787 if (ni->root() == node) { 3787 if (ni->root() == node) {
3788 detachNodeIterator(ni); 3788 detachNodeIterator(ni);
3789 newDocument.attachNodeIterator(ni); 3789 newDocument.attachNodeIterator(ni);
3790 } 3790 }
3791 } 3791 }
3792 } 3792 }
3793 3793
3794 void Document::updateRangesAfterChildrenChanged(ContainerNode* container) 3794 void Document::updateRangesAfterChildrenChanged(ContainerNode* container)
3795 { 3795 {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
3878 { 3878 {
3879 for (Range* range : m_ranges) 3879 for (Range* range : m_ranges)
3880 range->didSplitTextNode(oldNode); 3880 range->didSplitTextNode(oldNode);
3881 3881
3882 if (m_frame) 3882 if (m_frame)
3883 m_frame->selection().didSplitTextNode(oldNode); 3883 m_frame->selection().didSplitTextNode(oldNode);
3884 3884
3885 // FIXME: This should update markers for spelling and grammar checking. 3885 // FIXME: This should update markers for spelling and grammar checking.
3886 } 3886 }
3887 3887
3888 void Document::setWindowAttributeEventListener(const AtomicString& eventType, Pa ssRefPtrWillBeRawPtr<EventListener> listener) 3888 void Document::setWindowAttributeEventListener(const AtomicString& eventType, Ra wPtr<EventListener> listener)
3889 { 3889 {
3890 LocalDOMWindow* domWindow = this->domWindow(); 3890 LocalDOMWindow* domWindow = this->domWindow();
3891 if (!domWindow) 3891 if (!domWindow)
3892 return; 3892 return;
3893 domWindow->setAttributeEventListener(eventType, listener); 3893 domWindow->setAttributeEventListener(eventType, listener);
3894 } 3894 }
3895 3895
3896 EventListener* Document::getWindowAttributeEventListener(const AtomicString& eve ntType) 3896 EventListener* Document::getWindowAttributeEventListener(const AtomicString& eve ntType)
3897 { 3897 {
3898 LocalDOMWindow* domWindow = this->domWindow(); 3898 LocalDOMWindow* domWindow = this->domWindow();
3899 if (!domWindow) 3899 if (!domWindow)
3900 return 0; 3900 return 0;
3901 return domWindow->getAttributeEventListener(eventType); 3901 return domWindow->getAttributeEventListener(eventType);
3902 } 3902 }
3903 3903
3904 EventQueue* Document::eventQueue() const 3904 EventQueue* Document::eventQueue() const
3905 { 3905 {
3906 if (!m_domWindow) 3906 if (!m_domWindow)
3907 return 0; 3907 return 0;
3908 return m_domWindow->eventQueue(); 3908 return m_domWindow->eventQueue();
3909 } 3909 }
3910 3910
3911 void Document::enqueueAnimationFrameEvent(PassRefPtrWillBeRawPtr<Event> event) 3911 void Document::enqueueAnimationFrameEvent(RawPtr<Event> event)
3912 { 3912 {
3913 ensureScriptedAnimationController().enqueueEvent(event); 3913 ensureScriptedAnimationController().enqueueEvent(event);
3914 } 3914 }
3915 3915
3916 void Document::enqueueUniqueAnimationFrameEvent(PassRefPtrWillBeRawPtr<Event> ev ent) 3916 void Document::enqueueUniqueAnimationFrameEvent(RawPtr<Event> event)
3917 { 3917 {
3918 ensureScriptedAnimationController().enqueuePerFrameEvent(event); 3918 ensureScriptedAnimationController().enqueuePerFrameEvent(event);
3919 } 3919 }
3920 3920
3921 void Document::enqueueScrollEventForNode(Node* target) 3921 void Document::enqueueScrollEventForNode(Node* target)
3922 { 3922 {
3923 // Per the W3C CSSOM View Module only scroll events fired at the document sh ould bubble. 3923 // Per the W3C CSSOM View Module only scroll events fired at the document sh ould bubble.
3924 RefPtrWillBeRawPtr<Event> scrollEvent = target->isDocumentNode() ? Event::cr eateBubble(EventTypeNames::scroll) : Event::create(EventTypeNames::scroll); 3924 RawPtr<Event> scrollEvent = target->isDocumentNode() ? Event::createBubble(E ventTypeNames::scroll) : Event::create(EventTypeNames::scroll);
3925 scrollEvent->setTarget(target); 3925 scrollEvent->setTarget(target);
3926 ensureScriptedAnimationController().enqueuePerFrameEvent(scrollEvent.release ()); 3926 ensureScriptedAnimationController().enqueuePerFrameEvent(scrollEvent.release ());
3927 } 3927 }
3928 3928
3929 void Document::enqueueResizeEvent() 3929 void Document::enqueueResizeEvent()
3930 { 3930 {
3931 RefPtrWillBeRawPtr<Event> event = Event::create(EventTypeNames::resize); 3931 RawPtr<Event> event = Event::create(EventTypeNames::resize);
3932 event->setTarget(domWindow()); 3932 event->setTarget(domWindow());
3933 ensureScriptedAnimationController().enqueuePerFrameEvent(event.release()); 3933 ensureScriptedAnimationController().enqueuePerFrameEvent(event.release());
3934 } 3934 }
3935 3935
3936 void Document::enqueueMediaQueryChangeListeners(WillBeHeapVector<RefPtrWillBeMem ber<MediaQueryListListener>>& listeners) 3936 void Document::enqueueMediaQueryChangeListeners(HeapVector<Member<MediaQueryList Listener>>& listeners)
3937 { 3937 {
3938 ensureScriptedAnimationController().enqueueMediaQueryChangeListeners(listene rs); 3938 ensureScriptedAnimationController().enqueueMediaQueryChangeListeners(listene rs);
3939 } 3939 }
3940 3940
3941 void Document::dispatchEventsForPrinting() 3941 void Document::dispatchEventsForPrinting()
3942 { 3942 {
3943 if (!m_scriptedAnimationController) 3943 if (!m_scriptedAnimationController)
3944 return; 3944 return;
3945 m_scriptedAnimationController->dispatchEventsAndCallbacksForPrinting(); 3945 m_scriptedAnimationController->dispatchEventsAndCallbacksForPrinting();
3946 } 3946 }
(...skipping 11 matching lines...) Expand all
3958 } 3958 }
3959 return *m_accessEntryFromURL; 3959 return *m_accessEntryFromURL;
3960 } 3960 }
3961 3961
3962 void Document::registerEventFactory(PassOwnPtr<EventFactoryBase> eventFactory) 3962 void Document::registerEventFactory(PassOwnPtr<EventFactoryBase> eventFactory)
3963 { 3963 {
3964 ASSERT(!eventFactories().contains(eventFactory.get())); 3964 ASSERT(!eventFactories().contains(eventFactory.get()));
3965 eventFactories().add(eventFactory); 3965 eventFactories().add(eventFactory);
3966 } 3966 }
3967 3967
3968 PassRefPtrWillBeRawPtr<Event> Document::createEvent(const String& eventType, Exc eptionState& exceptionState) 3968 RawPtr<Event> Document::createEvent(const String& eventType, ExceptionState& exc eptionState)
3969 { 3969 {
3970 RefPtrWillBeRawPtr<Event> event = nullptr; 3970 RawPtr<Event> event = nullptr;
3971 for (const auto& factory : eventFactories()) { 3971 for (const auto& factory : eventFactories()) {
3972 event = factory->create(eventType); 3972 event = factory->create(eventType);
3973 if (event) 3973 if (event)
3974 return event.release(); 3974 return event.release();
3975 } 3975 }
3976 exceptionState.throwDOMException(NotSupportedError, "The provided event type ('" + eventType + "') is invalid."); 3976 exceptionState.throwDOMException(NotSupportedError, "The provided event type ('" + eventType + "') is invalid.");
3977 return nullptr; 3977 return nullptr;
3978 } 3978 }
3979 3979
3980 void Document::addMutationEventListenerTypeIfEnabled(ListenerType listenerType) 3980 void Document::addMutationEventListenerTypeIfEnabled(ListenerType listenerType)
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
4542 if (!equalIgnoringCase(linkElement->type(), openSearchMIMEType) || !equa lIgnoringCase(linkElement->rel(), openSearchRelation)) 4542 if (!equalIgnoringCase(linkElement->type(), openSearchMIMEType) || !equa lIgnoringCase(linkElement->rel(), openSearchRelation))
4543 continue; 4543 continue;
4544 if (linkElement->href().isEmpty()) 4544 if (linkElement->href().isEmpty())
4545 continue; 4545 continue;
4546 return linkElement->href(); 4546 return linkElement->href();
4547 } 4547 }
4548 4548
4549 return KURL(); 4549 return KURL();
4550 } 4550 }
4551 4551
4552 void Document::pushCurrentScript(PassRefPtrWillBeRawPtr<HTMLScriptElement> newCu rrentScript) 4552 void Document::pushCurrentScript(RawPtr<HTMLScriptElement> newCurrentScript)
4553 { 4553 {
4554 ASSERT(newCurrentScript); 4554 ASSERT(newCurrentScript);
4555 m_currentScriptStack.append(newCurrentScript); 4555 m_currentScriptStack.append(newCurrentScript);
4556 } 4556 }
4557 4557
4558 void Document::popCurrentScript() 4558 void Document::popCurrentScript()
4559 { 4559 {
4560 ASSERT(!m_currentScriptStack.isEmpty()); 4560 ASSERT(!m_currentScriptStack.isEmpty());
4561 m_currentScriptStack.removeLast(); 4561 m_currentScriptStack.removeLast();
4562 } 4562 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
4601 // FIXME: Not clear what topDocument() should do in the OOPI case--should it return the topmost 4601 // FIXME: Not clear what topDocument() should do in the OOPI case--should it return the topmost
4602 // available Document, or something else? 4602 // available Document, or something else?
4603 Document* doc = const_cast<Document*>(this); 4603 Document* doc = const_cast<Document*>(this);
4604 for (HTMLFrameOwnerElement* element = doc->ownerElement(); element; element = doc->ownerElement()) 4604 for (HTMLFrameOwnerElement* element = doc->ownerElement(); element; element = doc->ownerElement())
4605 doc = &element->document(); 4605 doc = &element->document();
4606 4606
4607 ASSERT(doc); 4607 ASSERT(doc);
4608 return *doc; 4608 return *doc;
4609 } 4609 }
4610 4610
4611 WeakPtrWillBeRawPtr<Document> Document::contextDocument() 4611 RawPtr<Document> Document::contextDocument()
4612 { 4612 {
4613 if (m_contextDocument) 4613 if (m_contextDocument)
4614 return m_contextDocument; 4614 return m_contextDocument;
4615 if (m_frame) { 4615 if (m_frame) {
4616 return createWeakPtr(); 4616 return createWeakPtr();
4617 } 4617 }
4618 return nullptr; 4618 return nullptr;
4619 } 4619 }
4620 4620
4621 PassRefPtrWillBeRawPtr<Attr> Document::createAttribute(const AtomicString& name, ExceptionState& exceptionState) 4621 RawPtr<Attr> Document::createAttribute(const AtomicString& name, ExceptionState& exceptionState)
4622 { 4622 {
4623 if (isHTMLDocument() && name != name.lower()) 4623 if (isHTMLDocument() && name != name.lower())
4624 UseCounter::count(*this, UseCounter::HTMLDocumentCreateAttributeNameNotL owercase); 4624 UseCounter::count(*this, UseCounter::HTMLDocumentCreateAttributeNameNotL owercase);
4625 return createAttributeNS(nullAtom, name, exceptionState, true); 4625 return createAttributeNS(nullAtom, name, exceptionState, true);
4626 } 4626 }
4627 4627
4628 PassRefPtrWillBeRawPtr<Attr> Document::createAttributeNS(const AtomicString& nam espaceURI, const AtomicString& qualifiedName, ExceptionState& exceptionState, bo ol shouldIgnoreNamespaceChecks) 4628 RawPtr<Attr> Document::createAttributeNS(const AtomicString& namespaceURI, const AtomicString& qualifiedName, ExceptionState& exceptionState, bool shouldIgnoreN amespaceChecks)
4629 { 4629 {
4630 AtomicString prefix, localName; 4630 AtomicString prefix, localName;
4631 if (!parseQualifiedName(qualifiedName, prefix, localName, exceptionState)) 4631 if (!parseQualifiedName(qualifiedName, prefix, localName, exceptionState))
4632 return nullptr; 4632 return nullptr;
4633 4633
4634 QualifiedName qName(prefix, localName, namespaceURI); 4634 QualifiedName qName(prefix, localName, namespaceURI);
4635 4635
4636 if (!shouldIgnoreNamespaceChecks && !hasValidNamespaceForAttributes(qName)) { 4636 if (!shouldIgnoreNamespaceChecks && !hasValidNamespaceForAttributes(qName)) {
4637 exceptionState.throwDOMException(NamespaceError, "The namespace URI prov ided ('" + namespaceURI + "') is not valid for the qualified name provided ('" + qualifiedName + "')."); 4637 exceptionState.throwDOMException(NamespaceError, "The namespace URI prov ided ('" + namespaceURI + "') is not valid for the qualified name provided ('" + qualifiedName + "').");
4638 return nullptr; 4638 return nullptr;
4639 } 4639 }
4640 4640
4641 return Attr::create(*this, qName, emptyAtom); 4641 return Attr::create(*this, qName, emptyAtom);
4642 } 4642 }
4643 4643
4644 const SVGDocumentExtensions* Document::svgExtensions() 4644 const SVGDocumentExtensions* Document::svgExtensions()
4645 { 4645 {
4646 return m_svgExtensions.get(); 4646 return m_svgExtensions.get();
4647 } 4647 }
4648 4648
4649 SVGDocumentExtensions& Document::accessSVGExtensions() 4649 SVGDocumentExtensions& Document::accessSVGExtensions()
4650 { 4650 {
4651 if (!m_svgExtensions) 4651 if (!m_svgExtensions)
4652 m_svgExtensions = adoptPtrWillBeNoop(new SVGDocumentExtensions(this)); 4652 m_svgExtensions = (new SVGDocumentExtensions(this));
4653 return *m_svgExtensions; 4653 return *m_svgExtensions;
4654 } 4654 }
4655 4655
4656 bool Document::hasSVGRootNode() const 4656 bool Document::hasSVGRootNode() const
4657 { 4657 {
4658 return isSVGSVGElement(documentElement()); 4658 return isSVGSVGElement(documentElement());
4659 } 4659 }
4660 4660
4661 PassRefPtrWillBeRawPtr<HTMLCollection> Document::images() 4661 RawPtr<HTMLCollection> Document::images()
4662 { 4662 {
4663 return ensureCachedCollection<HTMLCollection>(DocImages); 4663 return ensureCachedCollection<HTMLCollection>(DocImages);
4664 } 4664 }
4665 4665
4666 PassRefPtrWillBeRawPtr<HTMLCollection> Document::applets() 4666 RawPtr<HTMLCollection> Document::applets()
4667 { 4667 {
4668 return ensureCachedCollection<HTMLCollection>(DocApplets); 4668 return ensureCachedCollection<HTMLCollection>(DocApplets);
4669 } 4669 }
4670 4670
4671 PassRefPtrWillBeRawPtr<HTMLCollection> Document::embeds() 4671 RawPtr<HTMLCollection> Document::embeds()
4672 { 4672 {
4673 return ensureCachedCollection<HTMLCollection>(DocEmbeds); 4673 return ensureCachedCollection<HTMLCollection>(DocEmbeds);
4674 } 4674 }
4675 4675
4676 PassRefPtrWillBeRawPtr<HTMLCollection> Document::scripts() 4676 RawPtr<HTMLCollection> Document::scripts()
4677 { 4677 {
4678 return ensureCachedCollection<HTMLCollection>(DocScripts); 4678 return ensureCachedCollection<HTMLCollection>(DocScripts);
4679 } 4679 }
4680 4680
4681 PassRefPtrWillBeRawPtr<HTMLCollection> Document::links() 4681 RawPtr<HTMLCollection> Document::links()
4682 { 4682 {
4683 return ensureCachedCollection<HTMLCollection>(DocLinks); 4683 return ensureCachedCollection<HTMLCollection>(DocLinks);
4684 } 4684 }
4685 4685
4686 PassRefPtrWillBeRawPtr<HTMLCollection> Document::forms() 4686 RawPtr<HTMLCollection> Document::forms()
4687 { 4687 {
4688 return ensureCachedCollection<HTMLCollection>(DocForms); 4688 return ensureCachedCollection<HTMLCollection>(DocForms);
4689 } 4689 }
4690 4690
4691 PassRefPtrWillBeRawPtr<HTMLCollection> Document::anchors() 4691 RawPtr<HTMLCollection> Document::anchors()
4692 { 4692 {
4693 return ensureCachedCollection<HTMLCollection>(DocAnchors); 4693 return ensureCachedCollection<HTMLCollection>(DocAnchors);
4694 } 4694 }
4695 4695
4696 PassRefPtrWillBeRawPtr<HTMLAllCollection> Document::allForBinding() 4696 RawPtr<HTMLAllCollection> Document::allForBinding()
4697 { 4697 {
4698 UseCounter::count(*this, UseCounter::DocumentAll); 4698 UseCounter::count(*this, UseCounter::DocumentAll);
4699 return all(); 4699 return all();
4700 } 4700 }
4701 4701
4702 PassRefPtrWillBeRawPtr<HTMLAllCollection> Document::all() 4702 RawPtr<HTMLAllCollection> Document::all()
4703 { 4703 {
4704 return ensureCachedCollection<HTMLAllCollection>(DocAll); 4704 return ensureCachedCollection<HTMLAllCollection>(DocAll);
4705 } 4705 }
4706 4706
4707 PassRefPtrWillBeRawPtr<HTMLCollection> Document::windowNamedItems(const AtomicSt ring& name) 4707 RawPtr<HTMLCollection> Document::windowNamedItems(const AtomicString& name)
4708 { 4708 {
4709 return ensureCachedCollection<WindowNameCollection>(WindowNamedItems, name); 4709 return ensureCachedCollection<WindowNameCollection>(WindowNamedItems, name);
4710 } 4710 }
4711 4711
4712 PassRefPtrWillBeRawPtr<DocumentNameCollection> Document::documentNamedItems(cons t AtomicString& name) 4712 RawPtr<DocumentNameCollection> Document::documentNamedItems(const AtomicString& name)
4713 { 4713 {
4714 return ensureCachedCollection<DocumentNameCollection>(DocumentNamedItems, na me); 4714 return ensureCachedCollection<DocumentNameCollection>(DocumentNamedItems, na me);
4715 } 4715 }
4716 4716
4717 void Document::finishedParsing() 4717 void Document::finishedParsing()
4718 { 4718 {
4719 ASSERT(!scriptableDocumentParser() || !m_parser->isParsing()); 4719 ASSERT(!scriptableDocumentParser() || !m_parser->isParsing());
4720 ASSERT(!scriptableDocumentParser() || m_readyState != Loading); 4720 ASSERT(!scriptableDocumentParser() || m_readyState != Loading);
4721 setParsingState(InDOMContentLoaded); 4721 setParsingState(InDOMContentLoaded);
4722 4722
4723 // FIXME: DOMContentLoaded is dispatched synchronously, but this should be d ispatched in a queued task, 4723 // FIXME: DOMContentLoaded is dispatched synchronously, but this should be d ispatched in a queued task,
4724 // See https://crbug.com/425790 4724 // See https://crbug.com/425790
4725 if (!m_documentTiming.domContentLoadedEventStart()) 4725 if (!m_documentTiming.domContentLoadedEventStart())
4726 m_documentTiming.markDomContentLoadedEventStart(); 4726 m_documentTiming.markDomContentLoadedEventStart();
4727 dispatchEvent(Event::createBubble(EventTypeNames::DOMContentLoaded)); 4727 dispatchEvent(Event::createBubble(EventTypeNames::DOMContentLoaded));
4728 if (!m_documentTiming.domContentLoadedEventEnd()) 4728 if (!m_documentTiming.domContentLoadedEventEnd())
4729 m_documentTiming.markDomContentLoadedEventEnd(); 4729 m_documentTiming.markDomContentLoadedEventEnd();
4730 setParsingState(FinishedParsing); 4730 setParsingState(FinishedParsing);
4731 4731
4732 // The microtask checkpoint or the loader's finishedParsing() method may inv oke script that causes this object to 4732 // The microtask checkpoint or the loader's finishedParsing() method may inv oke script that causes this object to
4733 // be dereferenced (when this document is in an iframe and the onload causes the iframe's src to change). 4733 // be dereferenced (when this document is in an iframe and the onload causes the iframe's src to change).
4734 // Keep it alive until we are done. 4734 // Keep it alive until we are done.
4735 RefPtrWillBeRawPtr<Document> protect(this); 4735 RawPtr<Document> protect(this);
4736 4736
4737 // Ensure Custom Element callbacks are drained before DOMContentLoaded. 4737 // Ensure Custom Element callbacks are drained before DOMContentLoaded.
4738 // FIXME: Remove this ad-hoc checkpoint when DOMContentLoaded is dispatched in a 4738 // FIXME: Remove this ad-hoc checkpoint when DOMContentLoaded is dispatched in a
4739 // queued task, which will do a checkpoint anyway. https://crbug.com/425790 4739 // queued task, which will do a checkpoint anyway. https://crbug.com/425790
4740 Microtask::performCheckpoint(V8PerIsolateData::mainThreadIsolate()); 4740 Microtask::performCheckpoint(V8PerIsolateData::mainThreadIsolate());
4741 4741
4742 if (RefPtrWillBeRawPtr<LocalFrame> frame = this->frame()) { 4742 if (RawPtr<LocalFrame> frame = this->frame()) {
4743 // Don't update the layout tree if we haven't requested the main resourc e yet to avoid 4743 // Don't update the layout tree if we haven't requested the main resourc e yet to avoid
4744 // adding extra latency. Note that the first layout tree update can be e xpensive since it 4744 // adding extra latency. Note that the first layout tree update can be e xpensive since it
4745 // triggers the parsing of the default stylesheets which are compiled-in . 4745 // triggers the parsing of the default stylesheets which are compiled-in .
4746 const bool mainResourceWasAlreadyRequested = frame->loader().stateMachin e()->committedFirstRealDocumentLoad(); 4746 const bool mainResourceWasAlreadyRequested = frame->loader().stateMachin e()->committedFirstRealDocumentLoad();
4747 4747
4748 // FrameLoader::finishedParsing() might end up calling Document::implici tClose() if all 4748 // FrameLoader::finishedParsing() might end up calling Document::implici tClose() if all
4749 // resource loads are complete. HTMLObjectElements can start loading the ir resources from 4749 // resource loads are complete. HTMLObjectElements can start loading the ir resources from
4750 // post attach callbacks triggered by recalcStyle(). This means if we p arse out an <object> 4750 // post attach callbacks triggered by recalcStyle(). This means if we p arse out an <object>
4751 // tag and then reach the end of the document without updating styles, w e might not have yet 4751 // tag and then reach the end of the document without updating styles, w e might not have yet
4752 // started the resource load and might fire the window load event too ea rly. To avoid this 4752 // started the resource load and might fire the window load event too ea rly. To avoid this
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
4951 securityOrigin()->grantLoadLocalResources(); 4951 securityOrigin()->grantLoadLocalResources();
4952 return; 4952 return;
4953 } 4953 }
4954 4954
4955 m_cookieURL = initializer.owner()->cookieURL(); 4955 m_cookieURL = initializer.owner()->cookieURL();
4956 // We alias the SecurityOrigins to match Firefox, see Bug 15313 4956 // We alias the SecurityOrigins to match Firefox, see Bug 15313
4957 // https://bugs.webkit.org/show_bug.cgi?id=15313 4957 // https://bugs.webkit.org/show_bug.cgi?id=15313
4958 setSecurityOrigin(initializer.owner()->securityOrigin()); 4958 setSecurityOrigin(initializer.owner()->securityOrigin());
4959 } 4959 }
4960 4960
4961 void Document::initContentSecurityPolicy(PassRefPtrWillBeRawPtr<ContentSecurityP olicy> csp) 4961 void Document::initContentSecurityPolicy(RawPtr<ContentSecurityPolicy> csp)
4962 { 4962 {
4963 setContentSecurityPolicy(csp ? csp : ContentSecurityPolicy::create()); 4963 setContentSecurityPolicy(csp ? csp : ContentSecurityPolicy::create());
4964 if (m_frame && m_frame->tree().parent() && m_frame->tree().parent()->isLocal Frame()) { 4964 if (m_frame && m_frame->tree().parent() && m_frame->tree().parent()->isLocal Frame()) {
4965 ContentSecurityPolicy* parentCSP = toLocalFrame(m_frame->tree().parent() )->document()->contentSecurityPolicy(); 4965 ContentSecurityPolicy* parentCSP = toLocalFrame(m_frame->tree().parent() )->document()->contentSecurityPolicy();
4966 if (shouldInheritContentSecurityPolicyFromOwner(m_url)) { 4966 if (shouldInheritContentSecurityPolicyFromOwner(m_url)) {
4967 contentSecurityPolicy()->copyStateFrom(parentCSP); 4967 contentSecurityPolicy()->copyStateFrom(parentCSP);
4968 } else if (isPluginDocument()) { 4968 } else if (isPluginDocument()) {
4969 // Per CSP2, plugin-types for plugin documents in nested browsing 4969 // Per CSP2, plugin-types for plugin documents in nested browsing
4970 // contexts gets inherited from the parent. 4970 // contexts gets inherited from the parent.
4971 contentSecurityPolicy()->copyPluginTypesFrom(parentCSP); 4971 contentSecurityPolicy()->copyPluginTypesFrom(parentCSP);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
5080 { 5080 {
5081 if (equalIgnoringCase(dnsPrefetchControl, "on") && !m_haveExplicitlyDisabled DNSPrefetch) { 5081 if (equalIgnoringCase(dnsPrefetchControl, "on") && !m_haveExplicitlyDisabled DNSPrefetch) {
5082 m_isDNSPrefetchEnabled = true; 5082 m_isDNSPrefetchEnabled = true;
5083 return; 5083 return;
5084 } 5084 }
5085 5085
5086 m_isDNSPrefetchEnabled = false; 5086 m_isDNSPrefetchEnabled = false;
5087 m_haveExplicitlyDisabledDNSPrefetch = true; 5087 m_haveExplicitlyDisabledDNSPrefetch = true;
5088 } 5088 }
5089 5089
5090 WeakPtrWillBeRawPtr<Document> Document::createWeakPtr() 5090 RawPtr<Document> Document::createWeakPtr()
5091 { 5091 {
5092 #if ENABLE(OILPAN) 5092 #if ENABLE(OILPAN)
5093 return this; 5093 return this;
5094 #else 5094 #else
5095 return m_weakFactory.createWeakPtr(); 5095 return m_weakFactory.createWeakPtr();
5096 #endif 5096 #endif
5097 } 5097 }
5098 5098
5099 IntersectionObserverController* Document::intersectionObserverController() 5099 IntersectionObserverController* Document::intersectionObserverController()
5100 { 5100 {
(...skipping 12 matching lines...) Expand all
5113 if (!m_intersectionObserverData) 5113 if (!m_intersectionObserverData)
5114 m_intersectionObserverData = new NodeIntersectionObserverData(); 5114 m_intersectionObserverData = new NodeIntersectionObserverData();
5115 return *m_intersectionObserverData; 5115 return *m_intersectionObserverData;
5116 } 5116 }
5117 5117
5118 void Document::reportBlockedScriptExecutionToInspector(const String& directiveTe xt) 5118 void Document::reportBlockedScriptExecutionToInspector(const String& directiveTe xt)
5119 { 5119 {
5120 InspectorInstrumentation::scriptExecutionBlockedByCSP(this, directiveText); 5120 InspectorInstrumentation::scriptExecutionBlockedByCSP(this, directiveText);
5121 } 5121 }
5122 5122
5123 void Document::addConsoleMessage(PassRefPtrWillBeRawPtr<ConsoleMessage> consoleM essage) 5123 void Document::addConsoleMessage(RawPtr<ConsoleMessage> consoleMessage)
5124 { 5124 {
5125 if (!isContextThread()) { 5125 if (!isContextThread()) {
5126 m_taskRunner->postTask(BLINK_FROM_HERE, AddConsoleMessageTask::create(co nsoleMessage->source(), consoleMessage->level(), consoleMessage->message())); 5126 m_taskRunner->postTask(BLINK_FROM_HERE, AddConsoleMessageTask::create(co nsoleMessage->source(), consoleMessage->level(), consoleMessage->message()));
5127 return; 5127 return;
5128 } 5128 }
5129 5129
5130 if (!m_frame) 5130 if (!m_frame)
5131 return; 5131 return;
5132 5132
5133 if (!consoleMessage->scriptState() && consoleMessage->url().isNull() && !con soleMessage->lineNumber()) { 5133 if (!consoleMessage->scriptState() && consoleMessage->url().isNull() && !con soleMessage->lineNumber()) {
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
5349 return ensureScriptedIdleTaskController().registerCallback(callback, options ); 5349 return ensureScriptedIdleTaskController().registerCallback(callback, options );
5350 } 5350 }
5351 5351
5352 void Document::cancelIdleCallback(int id) 5352 void Document::cancelIdleCallback(int id)
5353 { 5353 {
5354 if (!m_scriptedIdleTaskController) 5354 if (!m_scriptedIdleTaskController)
5355 return; 5355 return;
5356 m_scriptedIdleTaskController->cancelCallback(id); 5356 m_scriptedIdleTaskController->cancelCallback(id);
5357 } 5357 }
5358 5358
5359 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 5359 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
5360 { 5360 {
5361 // Match behavior from when these types were integers, and avoid surprises f rom someone explicitly 5361 // Match behavior from when these types were integers, and avoid surprises f rom someone explicitly
5362 // passing Infinity/NaN. 5362 // passing Infinity/NaN.
5363 if (!std::isfinite(pageX)) 5363 if (!std::isfinite(pageX))
5364 pageX = 0; 5364 pageX = 0;
5365 if (!std::isfinite(pageY)) 5365 if (!std::isfinite(pageY))
5366 pageY = 0; 5366 pageY = 0;
5367 if (!std::isfinite(screenX)) 5367 if (!std::isfinite(screenX))
5368 screenX = 0; 5368 screenX = 0;
5369 if (!std::isfinite(screenY)) 5369 if (!std::isfinite(screenY))
5370 screenY = 0; 5370 screenY = 0;
5371 if (!std::isfinite(radiusX)) 5371 if (!std::isfinite(radiusX))
5372 radiusX = 0; 5372 radiusX = 0;
5373 if (!std::isfinite(radiusY)) 5373 if (!std::isfinite(radiusY))
5374 radiusY = 0; 5374 radiusY = 0;
5375 if (!std::isfinite(rotationAngle)) 5375 if (!std::isfinite(rotationAngle))
5376 rotationAngle = 0; 5376 rotationAngle = 0;
5377 if (!std::isfinite(force)) 5377 if (!std::isfinite(force))
5378 force = 0; 5378 force = 0;
5379 5379
5380 // FIXME: It's not clear from the documentation at 5380 // FIXME: It's not clear from the documentation at
5381 // http://developer.apple.com/library/safari/#documentation/UserExperience/R eference/DocumentAdditionsReference/DocumentAdditions/DocumentAdditions.html 5381 // http://developer.apple.com/library/safari/#documentation/UserExperience/R eference/DocumentAdditionsReference/DocumentAdditions/DocumentAdditions.html
5382 // 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 5382 // 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
5383 // and implement them here. See https://bugs.webkit.org/show_bug.cgi?id=4781 9 5383 // and implement them here. See https://bugs.webkit.org/show_bug.cgi?id=4781 9
5384 LocalFrame* frame = window && window->isLocalDOMWindow() ? toLocalDOMWindow( window)->frame() : this->frame(); 5384 LocalFrame* frame = window && window->isLocalDOMWindow() ? toLocalDOMWindow( window)->frame() : this->frame();
5385 return Touch::create(frame, target, identifier, FloatPoint(screenX, screenY) , FloatPoint(pageX, pageY), FloatSize(radiusX, radiusY), rotationAngle, force); 5385 return Touch::create(frame, target, identifier, FloatPoint(screenX, screenY) , FloatPoint(pageX, pageY), FloatSize(radiusX, radiusY), rotationAngle, force);
5386 } 5386 }
5387 5387
5388 PassRefPtrWillBeRawPtr<TouchList> Document::createTouchList(WillBeHeapVector<Ref PtrWillBeMember<Touch>>& touches) const 5388 RawPtr<TouchList> Document::createTouchList(HeapVector<Member<Touch>>& touches) const
5389 { 5389 {
5390 return TouchList::adopt(touches); 5390 return TouchList::adopt(touches);
5391 } 5391 }
5392 5392
5393 DocumentLoader* Document::loader() const 5393 DocumentLoader* Document::loader() const
5394 { 5394 {
5395 if (!m_frame) 5395 if (!m_frame)
5396 return 0; 5396 return 0;
5397 5397
5398 DocumentLoader* loader = m_frame->loader().documentLoader(); 5398 DocumentLoader* loader = m_frame->loader().documentLoader();
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
5453 return s_threadedParsingEnabledForTesting; 5453 return s_threadedParsingEnabledForTesting;
5454 } 5454 }
5455 5455
5456 bool Document::hasActiveParser() 5456 bool Document::hasActiveParser()
5457 { 5457 {
5458 return m_activeParserCount || (m_parser && m_parser->processingData()); 5458 return m_activeParserCount || (m_parser && m_parser->processingData());
5459 } 5459 }
5460 5460
5461 void Document::setContextFeatures(ContextFeatures& features) 5461 void Document::setContextFeatures(ContextFeatures& features)
5462 { 5462 {
5463 m_contextFeatures = PassRefPtrWillBeRawPtr<ContextFeatures>(features); 5463 m_contextFeatures = RawPtr<ContextFeatures>(features);
5464 } 5464 }
5465 5465
5466 static LayoutObject* nearestCommonHoverAncestor(LayoutObject* obj1, LayoutObject * obj2) 5466 static LayoutObject* nearestCommonHoverAncestor(LayoutObject* obj1, LayoutObject * obj2)
5467 { 5467 {
5468 if (!obj1 || !obj2) 5468 if (!obj1 || !obj2)
5469 return 0; 5469 return 0;
5470 5470
5471 for (LayoutObject* currObj1 = obj1; currObj1; currObj1 = currObj1->hoverAnce stor()) { 5471 for (LayoutObject* currObj1 = obj1; currObj1; currObj1 = currObj1->hoverAnce stor()) {
5472 for (LayoutObject* currObj2 = obj2; currObj2; currObj2 = currObj2->hover Ancestor()) { 5472 for (LayoutObject* currObj2 = obj2; currObj2; currObj2 = currObj2->hover Ancestor()) {
5473 if (currObj1 == currObj2) 5473 if (currObj1 == currObj2)
(...skipping 15 matching lines...) Expand all
5489 while (innerElementInDocument && innerElementInDocument->document() != this) { 5489 while (innerElementInDocument && innerElementInDocument->document() != this) {
5490 innerElementInDocument->document().updateHoverActiveState(request, inner ElementInDocument); 5490 innerElementInDocument->document().updateHoverActiveState(request, inner ElementInDocument);
5491 innerElementInDocument = innerElementInDocument->document().ownerElement (); 5491 innerElementInDocument = innerElementInDocument->document().ownerElement ();
5492 } 5492 }
5493 5493
5494 updateDistribution(); 5494 updateDistribution();
5495 Element* oldActiveElement = activeHoverElement(); 5495 Element* oldActiveElement = activeHoverElement();
5496 if (oldActiveElement && !request.active()) { 5496 if (oldActiveElement && !request.active()) {
5497 // The oldActiveElement layoutObject is null, dropped on :active by sett ing display: none, 5497 // The oldActiveElement layoutObject is null, dropped on :active by sett ing display: none,
5498 // for instance. We still need to clear the ActiveChain as the mouse is released. 5498 // for instance. We still need to clear the ActiveChain as the mouse is released.
5499 for (RefPtrWillBeRawPtr<Node> node = oldActiveElement; node; node = Flat TreeTraversal::parent(*node)) { 5499 for (RawPtr<Node> node = oldActiveElement; node; node = FlatTreeTraversa l::parent(*node)) {
5500 ASSERT(!node->isTextNode()); 5500 ASSERT(!node->isTextNode());
5501 node->setActive(false); 5501 node->setActive(false);
5502 m_userActionElements.setInActiveChain(node.get(), false); 5502 m_userActionElements.setInActiveChain(node.get(), false);
5503 } 5503 }
5504 setActiveHoverElement(nullptr); 5504 setActiveHoverElement(nullptr);
5505 } else { 5505 } else {
5506 Element* newActiveElement = innerElementInDocument; 5506 Element* newActiveElement = innerElementInDocument;
5507 if (!oldActiveElement && newActiveElement && !newActiveElement->isDisabl edFormControl() && request.active() && !request.touchMove()) { 5507 if (!oldActiveElement && newActiveElement && !newActiveElement->isDisabl edFormControl() && request.active() && !request.touchMove()) {
5508 // We are setting the :active chain and freezing it. If future moves happen, they 5508 // We are setting the :active chain and freezing it. If future moves happen, they
5509 // will need to reference this chain. 5509 // will need to reference this chain.
5510 for (Node* node = newActiveElement; node; node = FlatTreeTraversal:: parent(*node)) { 5510 for (Node* node = newActiveElement; node; node = FlatTreeTraversal:: parent(*node)) {
5511 ASSERT(!node->isTextNode()); 5511 ASSERT(!node->isTextNode());
5512 m_userActionElements.setInActiveChain(node, true); 5512 m_userActionElements.setInActiveChain(node, true);
5513 } 5513 }
5514 setActiveHoverElement(newActiveElement); 5514 setActiveHoverElement(newActiveElement);
5515 } 5515 }
5516 } 5516 }
5517 // If the mouse has just been pressed, set :active on the chain. Those (and only those) 5517 // If the mouse has just been pressed, set :active on the chain. Those (and only those)
5518 // nodes should remain :active until the mouse is released. 5518 // nodes should remain :active until the mouse is released.
5519 bool allowActiveChanges = !oldActiveElement && activeHoverElement(); 5519 bool allowActiveChanges = !oldActiveElement && activeHoverElement();
5520 5520
5521 // If the mouse is down and if this is a mouse move event, we want to restri ct changes in 5521 // If the mouse is down and if this is a mouse move event, we want to restri ct changes in
5522 // :hover/:active to only apply to elements that are in the :active chain th at we froze 5522 // :hover/:active to only apply to elements that are in the :active chain th at we froze
5523 // at the time the mouse went down. 5523 // at the time the mouse went down.
5524 bool mustBeInActiveChain = request.active() && request.move(); 5524 bool mustBeInActiveChain = request.active() && request.move();
5525 5525
5526 RefPtrWillBeRawPtr<Node> oldHoverNode = hoverNode(); 5526 RawPtr<Node> oldHoverNode = hoverNode();
5527 5527
5528 // Check to see if the hovered node has changed. 5528 // Check to see if the hovered node has changed.
5529 // If it hasn't, we do not need to do anything. 5529 // If it hasn't, we do not need to do anything.
5530 Node* newHoverNode = innerElementInDocument; 5530 Node* newHoverNode = innerElementInDocument;
5531 while (newHoverNode && !newHoverNode->layoutObject()) 5531 while (newHoverNode && !newHoverNode->layoutObject())
5532 newHoverNode = newHoverNode->parentOrShadowHostNode(); 5532 newHoverNode = newHoverNode->parentOrShadowHostNode();
5533 5533
5534 // Update our current hover node. 5534 // Update our current hover node.
5535 setHoverNode(newHoverNode); 5535 setHoverNode(newHoverNode);
5536 5536
5537 // We have two different objects. Fetch their layoutObjects. 5537 // We have two different objects. Fetch their layoutObjects.
5538 LayoutObject* oldHoverObj = oldHoverNode ? oldHoverNode->layoutObject() : 0; 5538 LayoutObject* oldHoverObj = oldHoverNode ? oldHoverNode->layoutObject() : 0;
5539 LayoutObject* newHoverObj = newHoverNode ? newHoverNode->layoutObject() : 0; 5539 LayoutObject* newHoverObj = newHoverNode ? newHoverNode->layoutObject() : 0;
5540 5540
5541 // Locate the common ancestor layout object for the two layoutObjects. 5541 // Locate the common ancestor layout object for the two layoutObjects.
5542 LayoutObject* ancestor = nearestCommonHoverAncestor(oldHoverObj, newHoverObj ); 5542 LayoutObject* ancestor = nearestCommonHoverAncestor(oldHoverObj, newHoverObj );
5543 RefPtrWillBeRawPtr<Node> ancestorNode(ancestor ? ancestor->node() : 0); 5543 RawPtr<Node> ancestorNode(ancestor ? ancestor->node() : 0);
5544 5544
5545 WillBeHeapVector<RefPtrWillBeMember<Node>, 32> nodesToRemoveFromChain; 5545 HeapVector<Member<Node>, 32> nodesToRemoveFromChain;
5546 WillBeHeapVector<RefPtrWillBeMember<Node>, 32> nodesToAddToChain; 5546 HeapVector<Member<Node>, 32> nodesToAddToChain;
5547 5547
5548 if (oldHoverObj != newHoverObj) { 5548 if (oldHoverObj != newHoverObj) {
5549 // If the old hovered node is not nil but it's layoutObject is, it was p robably detached as part of the :hover style 5549 // If the old hovered node is not nil but it's layoutObject is, it was p robably detached as part of the :hover style
5550 // (for instance by setting display:none in the :hover pseudo-class). In this case, the old hovered element (and its ancestors) 5550 // (for instance by setting display:none in the :hover pseudo-class). In this case, the old hovered element (and its ancestors)
5551 // must be updated, to ensure it's normal style is re-applied. 5551 // must be updated, to ensure it's normal style is re-applied.
5552 if (oldHoverNode && !oldHoverObj) { 5552 if (oldHoverNode && !oldHoverObj) {
5553 for (Node* node = oldHoverNode.get(); node; node = node->parentNode( )) { 5553 for (Node* node = oldHoverNode.get(); node; node = node->parentNode( )) {
5554 if (!mustBeInActiveChain || (node->isElementNode() && toElement( node)->inActiveChain())) 5554 if (!mustBeInActiveChain || (node->isElementNode() && toElement( node)->inActiveChain()))
5555 nodesToRemoveFromChain.append(node); 5555 nodesToRemoveFromChain.append(node);
5556 } 5556 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
5651 if (m_associatedFormControls.isEmpty()) 5651 if (m_associatedFormControls.isEmpty())
5652 m_didAssociateFormControlsTimer.stop(); 5652 m_didAssociateFormControlsTimer.stop();
5653 } 5653 }
5654 5654
5655 void Document::didAssociateFormControlsTimerFired(Timer<Document>* timer) 5655 void Document::didAssociateFormControlsTimerFired(Timer<Document>* timer)
5656 { 5656 {
5657 ASSERT_UNUSED(timer, timer == &m_didAssociateFormControlsTimer); 5657 ASSERT_UNUSED(timer, timer == &m_didAssociateFormControlsTimer);
5658 if (!frame() || !frame()->page()) 5658 if (!frame() || !frame()->page())
5659 return; 5659 return;
5660 5660
5661 WillBeHeapVector<RefPtrWillBeMember<Element>> associatedFormControls; 5661 HeapVector<Member<Element>> associatedFormControls;
5662 copyToVector(m_associatedFormControls, associatedFormControls); 5662 copyToVector(m_associatedFormControls, associatedFormControls);
5663 5663
5664 frame()->page()->chromeClient().didAssociateFormControls(associatedFormContr ols, frame()); 5664 frame()->page()->chromeClient().didAssociateFormControls(associatedFormContr ols, frame());
5665 m_associatedFormControls.clear(); 5665 m_associatedFormControls.clear();
5666 } 5666 }
5667 5667
5668 float Document::devicePixelRatio() const 5668 float Document::devicePixelRatio() const
5669 { 5669 {
5670 return m_frame ? m_frame->devicePixelRatio() : 1.0; 5670 return m_frame ? m_frame->devicePixelRatio() : 1.0;
5671 } 5671 }
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
5787 return; 5787 return;
5788 5788
5789 styleEngine().platformColorsChanged(); 5789 styleEngine().platformColorsChanged();
5790 } 5790 }
5791 5791
5792 v8::Local<v8::Object> Document::wrap(v8::Isolate* isolate, v8::Local<v8::Object> creationContext) 5792 v8::Local<v8::Object> Document::wrap(v8::Isolate* isolate, v8::Local<v8::Object> creationContext)
5793 { 5793 {
5794 // It's possible that no one except for the new wrapper owns this object at 5794 // It's possible that no one except for the new wrapper owns this object at
5795 // this moment, so we have to prevent GC to collect this object until the 5795 // this moment, so we have to prevent GC to collect this object until the
5796 // object gets associated with the wrapper. 5796 // object gets associated with the wrapper.
5797 RefPtrWillBeRawPtr<Document> protect(this); 5797 RawPtr<Document> protect(this);
5798 5798
5799 ASSERT(!DOMDataStore::containsWrapper(this, isolate)); 5799 ASSERT(!DOMDataStore::containsWrapper(this, isolate));
5800 5800
5801 const WrapperTypeInfo* wrapperType = wrapperTypeInfo(); 5801 const WrapperTypeInfo* wrapperType = wrapperTypeInfo();
5802 5802
5803 if (frame() && frame()->script().initializeMainWorld()) { 5803 if (frame() && frame()->script().initializeMainWorld()) {
5804 // initializeMainWorld may have created a wrapper for the object, retry from the start. 5804 // initializeMainWorld may have created a wrapper for the object, retry from the start.
5805 v8::Local<v8::Object> wrapper = DOMDataStore::getWrapper(this, isolate); 5805 v8::Local<v8::Object> wrapper = DOMDataStore::getWrapper(this, isolate);
5806 if (!wrapper.IsEmpty()) 5806 if (!wrapper.IsEmpty())
5807 return wrapper; 5807 return wrapper;
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
5913 visitor->trace(m_templateDocumentHost); 5913 visitor->trace(m_templateDocumentHost);
5914 visitor->trace(m_visibilityObservers); 5914 visitor->trace(m_visibilityObservers);
5915 visitor->trace(m_userActionElements); 5915 visitor->trace(m_userActionElements);
5916 visitor->trace(m_svgExtensions); 5916 visitor->trace(m_svgExtensions);
5917 visitor->trace(m_timeline); 5917 visitor->trace(m_timeline);
5918 visitor->trace(m_compositorPendingAnimations); 5918 visitor->trace(m_compositorPendingAnimations);
5919 visitor->trace(m_contextDocument); 5919 visitor->trace(m_contextDocument);
5920 visitor->trace(m_canvasFontCache); 5920 visitor->trace(m_canvasFontCache);
5921 visitor->trace(m_intersectionObserverController); 5921 visitor->trace(m_intersectionObserverController);
5922 visitor->trace(m_intersectionObserverData); 5922 visitor->trace(m_intersectionObserverData);
5923 WillBeHeapSupplementable<Document>::trace(visitor); 5923 HeapSupplementable<Document>::trace(visitor);
5924 #endif 5924 #endif
5925 TreeScope::trace(visitor); 5925 TreeScope::trace(visitor);
5926 ContainerNode::trace(visitor); 5926 ContainerNode::trace(visitor);
5927 ExecutionContext::trace(visitor); 5927 ExecutionContext::trace(visitor);
5928 DocumentLifecycleNotifier::trace(visitor); 5928 DocumentLifecycleNotifier::trace(visitor);
5929 SecurityContext::trace(visitor); 5929 SecurityContext::trace(visitor);
5930 } 5930 }
5931 5931
5932 template class CORE_TEMPLATE_EXPORT WillBeHeapSupplement<Document>; 5932 template class CORE_TEMPLATE_EXPORT HeapSupplement<Document>;
5933 5933
5934 } // namespace blink 5934 } // namespace blink
5935 5935
5936 #ifndef NDEBUG 5936 #ifndef NDEBUG
5937 using namespace blink; 5937 using namespace blink;
5938 void showLiveDocumentInstances() 5938 void showLiveDocumentInstances()
5939 { 5939 {
5940 Document::WeakDocumentSet& set = Document::liveDocumentSet(); 5940 Document::WeakDocumentSet& set = Document::liveDocumentSet();
5941 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 5941 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
5942 for (Document* document : set) 5942 for (Document* document : set)
5943 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data()); 5943 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data());
5944 } 5944 }
5945 #endif 5945 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698