Changeset 269435 in webkit
- Timestamp:
- Nov 5, 2020 8:54:48 AM (3 years ago)
- Location:
- trunk/Source
- Files:
-
- 30 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r269434 r269435 1 2020-11-05 Alex Christensen <achristensen@webkit.org> 2 3 Store WeakPtr<Frame> instead of Frame* 4 https://bugs.webkit.org/show_bug.cgi?id=218599 5 6 Reviewed by Youenn Fablet. 7 8 No change in behavior, but this probably fixes some bugs. 9 10 * bindings/js/WindowProxy.cpp: 11 (WebCore::WindowProxy::WindowProxy): 12 (WebCore::WindowProxy::frame const): 13 * bindings/js/WindowProxy.h: 14 (WebCore::WindowProxy::frame const): Deleted. 15 * dom/Document.cpp: 16 (WebCore::Document::willBeRemovedFromFrame): 17 (WebCore::Document::canNavigateInternal): 18 (WebCore::Document::setDesignMode): 19 (WebCore::Document::getDesignMode const): Deleted. 20 * dom/Document.h: 21 * html/HTMLFrameOwnerElement.cpp: 22 (WebCore::HTMLFrameOwnerElement::setContentFrame): 23 (WebCore::HTMLFrameOwnerElement::disconnectContentFrame): 24 * html/HTMLFrameOwnerElement.h: 25 (WebCore::HTMLFrameOwnerElement::contentFrame const): 26 * inspector/agents/InspectorPageAgent.cpp: 27 (WebCore::InspectorPageAgent::frameForId): 28 (WebCore::InspectorPageAgent::frameId): 29 * inspector/agents/InspectorPageAgent.h: 30 * loader/DocumentLoader.cpp: 31 (WebCore::DocumentLoader::stopLoading): 32 (WebCore::DocumentLoader::willSendRequest): 33 (WebCore::DocumentLoader::commitLoad): 34 (WebCore::DocumentLoader::detachFromFrame): 35 (WebCore::DocumentLoader::removeSubresourceLoader): 36 (WebCore::DocumentLoader::subresourceLoaderFinishedLoadingOnePart): 37 * loader/DocumentWriter.cpp: 38 (WebCore::DocumentWriter::createDocument): 39 (WebCore::DocumentWriter::decoder): 40 (WebCore::DocumentWriter::setFrame): 41 * loader/DocumentWriter.h: 42 (WebCore::DocumentWriter::setFrame): Deleted. 43 * loader/FrameLoader.cpp: 44 (WebCore::FrameLoader::detachFromAllOpenedFrames): 45 (WebCore::FrameLoader::opener): 46 (WebCore::FrameLoader::setOpener): 47 (WebCore::FrameLoader::hasOpenedFrames const): 48 (WebCore::FrameLoader::addExtraFieldsToRequest): 49 * loader/FrameLoader.h: 50 * loader/FrameNetworkingContext.h: 51 (WebCore::FrameNetworkingContext::FrameNetworkingContext): 52 (WebCore::FrameNetworkingContext::frame const): 53 * loader/appcache/ApplicationCacheGroup.cpp: 54 (WebCore::ApplicationCacheGroup::update): 55 (WebCore::ApplicationCacheGroup::didFinishLoadingEntry): 56 (WebCore::ApplicationCacheGroup::didFailLoadingEntry): 57 (WebCore::ApplicationCacheGroup::didFailLoadingManifest): 58 (WebCore::ApplicationCacheGroup::startLoadingEntry): 59 * loader/appcache/ApplicationCacheGroup.h: 60 * page/AbstractFrame.h: 61 * page/Frame.cpp: 62 (WebCore::Frame::Frame): 63 (WebCore::Frame::addDestructionObserver): 64 (WebCore::Frame::removeDestructionObserver): 65 * page/Frame.h: 66 * page/FrameDestructionObserver.cpp: 67 (WebCore::FrameDestructionObserver::frame const): 68 (WebCore::FrameDestructionObserver::observeFrame): 69 * page/FrameDestructionObserver.h: 70 (WebCore::FrameDestructionObserver::frame const): Deleted. 71 * page/FrameTree.cpp: 72 (WebCore::FrameTree::FrameTree): 73 (WebCore::FrameTree::parent const): 74 (WebCore::FrameTree::appendChild): 75 (WebCore::FrameTree::removeChild): 76 (WebCore::FrameTree::traverseNextInPostOrder const): 77 * page/FrameTree.h: 78 (WebCore::FrameTree::previousSibling const): 79 (WebCore::FrameTree::lastChild const): 80 (WebCore::FrameTree::FrameTree): Deleted. 81 * rendering/RenderScrollbar.cpp: 82 (WebCore::RenderScrollbar::RenderScrollbar): 83 * rendering/RenderScrollbar.h: 84 1 85 2020-11-05 Alex Christensen <achristensen@webkit.org> 2 86 -
trunk/Source/WebCore/bindings/js/WindowProxy.cpp
r262751 r269435 54 54 55 55 WindowProxy::WindowProxy(AbstractFrame& frame) 56 : m_frame( &frame)56 : m_frame(makeWeakPtr(frame)) 57 57 , m_jsWindowProxies(makeUniqueRef<ProxyMap>()) 58 58 { … … 63 63 ASSERT(!m_frame); 64 64 ASSERT(m_jsWindowProxies->isEmpty()); 65 } 66 67 AbstractFrame* WindowProxy::frame() const 68 { 69 return m_frame.get(); 65 70 } 66 71 -
trunk/Source/WebCore/bindings/js/WindowProxy.h
r251361 r269435 25 25 #include <wtf/RefCounted.h> 26 26 #include <wtf/UniqueRef.h> 27 #include <wtf/WeakPtr.h> 27 28 28 29 namespace JSC { … … 50 51 WEBCORE_EXPORT ~WindowProxy(); 51 52 52 AbstractFrame* frame() const { return m_frame; }53 WEBCORE_EXPORT AbstractFrame* frame() const; 53 54 void detachFromFrame(); 54 55 … … 95 96 WEBCORE_EXPORT JSWindowProxy& createJSWindowProxyWithInitializedScript(DOMWrapperWorld&); 96 97 97 AbstractFrame*m_frame;98 WeakPtr<AbstractFrame> m_frame; 98 99 UniqueRef<ProxyMap> m_jsWindowProxies; 99 100 }; -
trunk/Source/WebCore/dom/Document.cpp
r269295 r269435 2559 2559 2560 2560 { 2561 NavigationDisabler navigationDisabler(m_frame );2561 NavigationDisabler navigationDisabler(m_frame.get()); 2562 2562 disconnectDescendantFrames(); 2563 2563 } … … 3467 3467 3468 3468 // iii. A sandboxed frame can always navigate its descendants. 3469 if (isSandboxed(SandboxNavigation) && targetFrame.tree().isDescendantOf(m_frame ))3469 if (isSandboxed(SandboxNavigation) && targetFrame.tree().isDescendantOf(m_frame.get())) 3470 3470 return true; 3471 3471 … … 3473 3473 // 1. If A is not the same browsing context as B, and A is not one of the ancestor browsing contexts of B, and B is not a top-level browsing context, and A's active document's active sandboxing 3474 3474 // flag set has its sandboxed navigation browsing context flag set, then abort these steps negatively. 3475 if (m_frame != &targetFrame && isSandboxed(SandboxNavigation) && targetFrame.tree().parent() && !targetFrame.tree().isDescendantOf(m_frame )) {3475 if (m_frame != &targetFrame && isSandboxed(SandboxNavigation) && targetFrame.tree().parent() && !targetFrame.tree().isDescendantOf(m_frame.get())) { 3476 3476 printNavigationErrorMessage(targetFrame, url(), "The frame attempting navigation is sandboxed, and is therefore disallowed from navigating its ancestors."_s); 3477 3477 return false; … … 5701 5701 { 5702 5702 m_designMode = value; 5703 for ( Frame* frame = m_frame; frame && frame->document(); frame = frame->tree().traverseNext(m_frame))5703 for (auto* frame = m_frame.get(); frame && frame->document(); frame = frame->tree().traverseNext(m_frame.get())) 5704 5704 frame->document()->scheduleFullStyleRebuild(); 5705 5705 } … … 5720 5720 mode = inherit; 5721 5721 setDesignMode(mode); 5722 }5723 5724 auto Document::getDesignMode() const -> InheritedBool5725 {5726 return m_designMode;5727 5722 } 5728 5723 -
trunk/Source/WebCore/dom/Document.h
r269295 r269435 1008 1008 enum InheritedBool { off = false, on = true, inherit }; 1009 1009 void setDesignMode(InheritedBool value); 1010 InheritedBool getDesignMode() const;1011 1010 bool inDesignMode() const; 1012 1011 WEBCORE_EXPORT String designMode() const; -
trunk/Source/WebCore/html/HTMLFrameOwnerElement.cpp
r247924 r269435 51 51 } 52 52 53 void HTMLFrameOwnerElement::setContentFrame(Frame *frame)53 void HTMLFrameOwnerElement::setContentFrame(Frame& frame) 54 54 { 55 55 // Make sure we will not end up with two frames referencing the same owner element. 56 56 ASSERT(!m_contentFrame || m_contentFrame->ownerElement() != this); 57 ASSERT(frame);58 57 // Disconnected frames should not be allowed to load. 59 58 ASSERT(isConnected()); 60 m_contentFrame = frame;59 m_contentFrame = makeWeakPtr(frame); 61 60 62 61 for (RefPtr<ContainerNode> node = this; node; node = node->parentOrShadowHostNode()) … … 77 76 void HTMLFrameOwnerElement::disconnectContentFrame() 78 77 { 79 if (RefPtr<Frame> frame = m_contentFrame ) {78 if (RefPtr<Frame> frame = m_contentFrame.get()) { 80 79 frame->loader().frameDetached(); 81 80 frame->disconnectOwnerElement(); -
trunk/Source/WebCore/html/HTMLFrameOwnerElement.h
r267449 r269435 36 36 virtual ~HTMLFrameOwnerElement(); 37 37 38 Frame* contentFrame() const { return m_contentFrame ; }38 Frame* contentFrame() const { return m_contentFrame.get(); } 39 39 WEBCORE_EXPORT WindowProxy* contentWindow() const; 40 40 WEBCORE_EXPORT Document* contentDocument() const; 41 41 42 void setContentFrame(Frame *);42 void setContentFrame(Frame&); 43 43 void clearContentFrame(); 44 44 … … 74 74 bool isFrameOwnerElement() const final { return true; } 75 75 76 Frame* m_contentFrame { nullptr };76 WeakPtr<Frame> m_contentFrame; 77 77 SandboxFlags m_sandboxFlags { SandboxNone }; 78 78 }; -
trunk/Source/WebCore/inspector/agents/InspectorPageAgent.cpp
r269323 r269435 829 829 Frame* InspectorPageAgent::frameForId(const Protocol::Network::FrameId& frameId) 830 830 { 831 return frameId.isEmpty() ? nullptr : m_identifierToFrame.get(frameId) ;831 return frameId.isEmpty() ? nullptr : m_identifierToFrame.get(frameId).get(); 832 832 } 833 833 … … 838 838 return m_frameToIdentifier.ensure(frame, [this, frame] { 839 839 auto identifier = IdentifiersFactory::createIdentifier(); 840 m_identifierToFrame.set(identifier, frame);840 m_identifierToFrame.set(identifier, makeWeakPtr(frame)); 841 841 return identifier; 842 842 }).iterator->value; -
trunk/Source/WebCore/inspector/agents/InspectorPageAgent.h
r268716 r269435 166 166 InspectorOverlay* m_overlay { nullptr }; 167 167 168 // FIXME: Make a WeakHashMap and use it for m_frameToIdentifier and m_loaderToIdentifier. 168 169 HashMap<Frame*, String> m_frameToIdentifier; 169 HashMap<String, Frame*> m_identifierToFrame;170 HashMap<String, WeakPtr<Frame>> m_identifierToFrame; 170 171 HashMap<DocumentLoader*, String> m_loaderToIdentifier; 171 172 String m_userAgentOverride; -
trunk/Source/WebCore/loader/DocumentLoader.cpp
r266148 r269435 284 284 void DocumentLoader::stopLoading() 285 285 { 286 RefPtr<Frame> protectedFrame(m_frame );286 RefPtr<Frame> protectedFrame(m_frame.get()); 287 287 Ref<DocumentLoader> protectedThis(*this); 288 288 … … 600 600 if (!redirectingOrigin.get().canDisplay(newRequest.url())) { 601 601 RELEASE_LOG_IF_ALLOWED("willSendRequest: canceling - redirecting URL not allowed to display content from target"); 602 FrameLoader::reportLocalLoadFailed(m_frame , newRequest.url().string());602 FrameLoader::reportLocalLoadFailed(m_frame.get(), newRequest.url().string()); 603 603 cancelMainResourceLoad(frameLoader()->cancelledError(newRequest)); 604 604 return completionHandler(WTFMove(newRequest)); … … 1049 1049 // Both unloading the old page and parsing the new page may execute JavaScript which destroys the datasource 1050 1050 // by starting a new load, so retain temporarily. 1051 RefPtr<Frame> protectedFrame(m_frame );1051 RefPtr<Frame> protectedFrame(m_frame.get()); 1052 1052 Ref<DocumentLoader> protectedThis(*this); 1053 1053 … … 1303 1303 ASSERT_WITH_MESSAGE(m_frame, "detachFromFrame() is being called on a DocumentLoader that has never attached to any Frame"); 1304 1304 #endif 1305 RefPtr<Frame> protectedFrame(m_frame );1305 RefPtr<Frame> protectedFrame(m_frame.get()); 1306 1306 Ref<DocumentLoader> protectedThis(*this); 1307 1307 … … 1788 1788 return; 1789 1789 checkLoadComplete(); 1790 if ( Frame* frame =m_frame)1791 frame->loader().subresourceLoadDone(type);1790 if (m_frame) 1791 m_frame->loader().subresourceLoadDone(type); 1792 1792 } 1793 1793 … … 2074 2074 2075 2075 checkLoadComplete(); 2076 if ( Frame* frame =m_frame)2077 frame->loader().checkLoadComplete();2076 if (m_frame) 2077 m_frame->loader().checkLoadComplete(); 2078 2078 } 2079 2079 -
trunk/Source/WebCore/loader/DocumentWriter.cpp
r268114 r269435 118 118 if (!m_frame->loader().client().hasHTMLView()) 119 119 return Document::createNonRenderedPlaceholder(*m_frame, url); 120 return DOMImplementation::createDocument(m_mimeType, m_frame , m_frame->settings(), url);120 return DOMImplementation::createDocument(m_mimeType, m_frame.get(), m_frame->settings(), url); 121 121 } 122 122 … … 223 223 // FIXME: This might be too cautious for non-7bit-encodings and 224 224 // we may consider relaxing this later after testing. 225 if (canReferToParentFrameEncoding(m_frame , parentFrame))225 if (canReferToParentFrameEncoding(m_frame.get(), parentFrame)) 226 226 m_decoder->setHintEncoding(parentFrame->document()->decoder()); 227 227 if (m_encoding.isEmpty()) { 228 if (canReferToParentFrameEncoding(m_frame , parentFrame))228 if (canReferToParentFrameEncoding(m_frame.get(), parentFrame)) 229 229 m_decoder->setEncoding(parentFrame->document()->textEncoding(), TextResourceDecoder::EncodingFromParentFrame); 230 230 } else { … … 298 298 } 299 299 300 void DocumentWriter::setFrame(Frame& frame) 301 { 302 m_frame = makeWeakPtr(frame); 303 } 304 300 305 void DocumentWriter::setDocumentWasLoadedAsPartOfNavigation() 301 306 { -
trunk/Source/WebCore/loader/DocumentWriter.h
r247017 r269435 51 51 WEBCORE_EXPORT void end(); 52 52 53 void setFrame(Frame& frame) { m_frame = &frame; }53 void setFrame(Frame&); 54 54 55 55 WEBCORE_EXPORT void setEncoding(const String& encoding, bool userChosen); … … 68 68 void clear(); 69 69 70 Frame* m_frame { nullptr };70 WeakPtr<Frame> m_frame; 71 71 72 72 bool m_hasReceivedSomeData { false }; -
trunk/Source/WebCore/loader/FrameLoader.cpp
r269434 r269435 331 331 { 332 332 for (auto& frame : m_openedFrames) 333 frame ->loader().m_opener = nullptr;333 frame.loader().m_opener = nullptr; 334 334 m_openedFrames.clear(); 335 335 } … … 383 383 { 384 384 return client().frameID(); 385 } 386 387 Frame* FrameLoader::opener() 388 { 389 return m_opener; 390 } 391 392 const Frame* FrameLoader::opener() const 393 { 394 return m_opener; 385 395 } 386 396 … … 1051 1061 // When setOpener is called in ~FrameLoader, opener's m_frameLoader is already cleared. 1052 1062 auto& openerFrameLoader = m_opener == &m_frame ? *this : m_opener->loader(); 1053 openerFrameLoader.m_openedFrames.remove( &m_frame);1063 openerFrameLoader.m_openedFrames.remove(m_frame); 1054 1064 } 1055 1065 if (opener) { … … 1058 1068 page->setOpenedByDOMWithOpener(); 1059 1069 } 1060 m_opener = opener;1070 m_opener = makeWeakPtr(opener); 1061 1071 1062 1072 if (m_frame.document()) … … 1640 1650 } 1641 1651 1652 bool FrameLoader::hasOpenedFrames() const 1653 { 1654 return !m_openedFrames.computesEmpty(); 1655 } 1656 1642 1657 void FrameLoader::reportLocalLoadFailed(Frame* frame, const String& url) 1643 1658 { … … 2892 2907 auto* ownerFrame = m_frame.tree().parent(); 2893 2908 if (!ownerFrame && m_stateMachine.isDisplayingInitialEmptyDocument()) 2894 ownerFrame = m_opener ;2909 ownerFrame = m_opener.get(); 2895 2910 if (ownerFrame) 2896 2911 initiator = ownerFrame->document(); -
trunk/Source/WebCore/loader/FrameLoader.h
r269434 r269435 54 54 #include <wtf/UniqueRef.h> 55 55 #include <wtf/WallTime.h> 56 #include <wtf/WeakHashSet.h> 56 57 57 58 namespace WebCore { … … 249 250 bool checkIfFormActionAllowedByCSP(const URL&, bool didReceiveRedirectResponse) const; 250 251 251 Frame* opener() { return m_opener; }252 const Frame* opener() const { return m_opener; }252 WEBCORE_EXPORT Frame* opener(); 253 WEBCORE_EXPORT const Frame* opener() const; 253 254 WEBCORE_EXPORT void setOpener(Frame*); 254 255 WEBCORE_EXPORT void detachFromAllOpenedFrames(); … … 427 428 // PolicyChecker specific. 428 429 void clearProvisionalLoadForPolicyCheck(); 429 bool hasOpenedFrames() const { return !m_openedFrames.isEmpty(); }430 bool hasOpenedFrames() const; 430 431 431 432 bool preventsParentFromBeingComplete(const Frame&) const; … … 483 484 bool m_shouldCallCheckLoadComplete; 484 485 485 Frame*m_opener;486 HashSet<Frame*> m_openedFrames;486 WeakPtr<Frame> m_opener; 487 WeakHashSet<Frame> m_openedFrames; 487 488 488 489 bool m_loadingFromCachedPage; -
trunk/Source/WebCore/loader/FrameNetworkingContext.h
r220208 r269435 45 45 protected: 46 46 explicit FrameNetworkingContext(Frame* frame) 47 : m_frame( frame)47 : m_frame(makeWeakPtr(frame)) 48 48 { 49 49 } 50 50 51 Frame* frame() const { return m_frame ; }51 Frame* frame() const { return m_frame.get(); } 52 52 53 53 private: 54 bool isValid() const override { return m_frame; }54 bool isValid() const override { return !!m_frame; } 55 55 56 Frame*m_frame;56 WeakPtr<Frame> m_frame; 57 57 }; 58 58 -
trunk/Source/WebCore/loader/appcache/ApplicationCacheGroup.cpp
r263775 r269435 417 417 418 418 ASSERT(!m_frame); 419 m_frame = &frame;419 m_frame = makeWeakPtr(frame); 420 420 421 421 setUpdateStatus(Checking); … … 438 438 439 439 m_currentResourceIdentifier = m_frame->page()->progress().createUniqueIdentifier(); 440 InspectorInstrumentation::willSendRequest(m_frame , m_currentResourceIdentifier, m_frame->loader().documentLoader(), request, ResourceResponse { });440 InspectorInstrumentation::willSendRequest(m_frame.get(), m_currentResourceIdentifier, m_frame->loader().documentLoader(), request, ResourceResponse { }); 441 441 442 442 m_manifestLoader = ApplicationCacheResourceLoader::create(ApplicationCacheResource::Type::Manifest, documentLoader.cachedResourceLoader(), WTFMove(request), [this] (auto&& resourceOrError) { … … 448 448 if (error == ApplicationCacheResourceLoader::Error::CannotCreateResource) { 449 449 // FIXME: We should get back the error from ApplicationCacheResourceLoader level. 450 InspectorInstrumentation::didFailLoading(m_frame , m_frame->loader().documentLoader(), m_currentResourceIdentifier, ResourceError { ResourceError::Type::AccessControl });450 InspectorInstrumentation::didFailLoading(m_frame.get(), m_frame->loader().documentLoader(), m_currentResourceIdentifier, ResourceError { ResourceError::Type::AccessControl }); 451 451 this->cacheUpdateFailed(); 452 452 return; … … 495 495 // FIXME: We should have NetworkLoadMetrics for ApplicationCache loads. 496 496 NetworkLoadMetrics emptyMetrics; 497 InspectorInstrumentation::didFinishLoading(m_frame , m_frame->loader().documentLoader(), m_currentResourceIdentifier, emptyMetrics, nullptr);497 InspectorInstrumentation::didFinishLoading(m_frame.get(), m_frame->loader().documentLoader(), m_currentResourceIdentifier, emptyMetrics, nullptr); 498 498 499 499 ASSERT(m_pendingEntries.contains(entryURL.string())); … … 544 544 ResourceError resourceError { error == ApplicationCacheResourceLoader::Error::CannotCreateResource ? ResourceError::Type::AccessControl : ResourceError::Type::General }; 545 545 546 InspectorInstrumentation::didFailLoading(m_frame , m_frame->loader().documentLoader(), m_currentResourceIdentifier, resourceError);546 InspectorInstrumentation::didFailLoading(m_frame.get(), m_frame->loader().documentLoader(), m_currentResourceIdentifier, resourceError); 547 547 548 548 URL url(entryURL); … … 664 664 break; 665 665 case ApplicationCacheResourceLoader::Error::NotFound: 666 InspectorInstrumentation::didFailLoading(m_frame , m_frame->loader().documentLoader(), m_currentResourceIdentifier, m_frame->loader().cancelledError(m_manifestLoader->resource()->resourceRequest()));666 InspectorInstrumentation::didFailLoading(m_frame.get(), m_frame->loader().documentLoader(), m_currentResourceIdentifier, m_frame->loader().cancelledError(m_manifestLoader->resource()->resourceRequest())); 667 667 m_frame->document()->addConsoleMessage(MessageSource::AppCache, MessageLevel::Error, makeString("Application Cache manifest could not be fetched, because the manifest had a ", m_manifestLoader->resource()->response().httpStatusCode(), " response.")); 668 668 manifestNotFound(); 669 669 break; 670 670 case ApplicationCacheResourceLoader::Error::NotOK: 671 InspectorInstrumentation::didFailLoading(m_frame , m_frame->loader().documentLoader(), m_currentResourceIdentifier, m_frame->loader().cancelledError(m_manifestLoader->resource()->resourceRequest()));671 InspectorInstrumentation::didFailLoading(m_frame.get(), m_frame->loader().documentLoader(), m_currentResourceIdentifier, m_frame->loader().cancelledError(m_manifestLoader->resource()->resourceRequest())); 672 672 m_frame->document()->addConsoleMessage(MessageSource::AppCache, MessageLevel::Error, makeString("Application Cache manifest could not be fetched, because the manifest had a ", m_manifestLoader->resource()->response().httpStatusCode(), " response.")); 673 673 cacheUpdateFailed(); 674 674 break; 675 675 case ApplicationCacheResourceLoader::Error::RedirectForbidden: 676 InspectorInstrumentation::didFailLoading(m_frame , m_frame->loader().documentLoader(), m_currentResourceIdentifier, m_frame->loader().cancelledError(m_manifestLoader->resource()->resourceRequest()));676 InspectorInstrumentation::didFailLoading(m_frame.get(), m_frame->loader().documentLoader(), m_currentResourceIdentifier, m_frame->loader().cancelledError(m_manifestLoader->resource()->resourceRequest())); 677 677 m_frame->document()->addConsoleMessage(MessageSource::AppCache, MessageLevel::Error, "Application Cache manifest could not be fetched, because a redirection was attempted."_s); 678 678 cacheUpdateFailed(); … … 900 900 901 901 m_currentResourceIdentifier = m_frame->page()->progress().createUniqueIdentifier(); 902 InspectorInstrumentation::willSendRequest(m_frame , m_currentResourceIdentifier, m_frame->loader().documentLoader(), request, ResourceResponse { });902 InspectorInstrumentation::willSendRequest(m_frame.get(), m_currentResourceIdentifier, m_frame->loader().documentLoader(), request, ResourceResponse { }); 903 903 904 904 auto& documentLoader = *m_frame->loader().documentLoader(); -
trunk/Source/WebCore/loader/appcache/ApplicationCacheGroup.h
r250283 r269435 160 160 // Frame used for fetching resources when updating. 161 161 // FIXME: An update started by a particular frame should not stop if it is destroyed, but there are other frames associated with the same cache group. 162 Frame* m_frame { nullptr };162 WeakPtr<Frame> m_frame; 163 163 164 164 // An obsolete cache group is never stored, but the opposite is not true - storing may fail for multiple reasons, such as exceeding disk quota. -
trunk/Source/WebCore/page/AbstractFrame.h
r231963 r269435 28 28 #include <wtf/Ref.h> 29 29 #include <wtf/ThreadSafeRefCounted.h> 30 #include <wtf/WeakPtr.h> 30 31 31 32 namespace WebCore { … … 35 36 36 37 // FIXME: Rename Frame to LocalFrame and AbstractFrame to Frame. 37 class AbstractFrame : public ThreadSafeRefCounted<AbstractFrame> {38 class AbstractFrame : public ThreadSafeRefCounted<AbstractFrame>, public CanMakeWeakPtr<AbstractFrame> { 38 39 public: 39 40 virtual ~AbstractFrame(); -
trunk/Source/WebCore/page/Frame.cpp
r269434 r269435 164 164 if (ownerElement) { 165 165 m_mainFrame.selfOnlyRef(); 166 ownerElement->setContentFrame( this);166 ownerElement->setContentFrame(*this); 167 167 } 168 168 … … 218 218 } 219 219 220 void Frame::addDestructionObserver(FrameDestructionObserver *observer)221 { 222 m_destructionObservers.add( observer);223 } 224 225 void Frame::removeDestructionObserver(FrameDestructionObserver *observer)226 { 227 m_destructionObservers.remove( observer);220 void Frame::addDestructionObserver(FrameDestructionObserver& observer) 221 { 222 m_destructionObservers.add(&observer); 223 } 224 225 void Frame::removeDestructionObserver(FrameDestructionObserver& observer) 226 { 227 m_destructionObservers.remove(&observer); 228 228 } 229 229 -
trunk/Source/WebCore/page/Frame.h
r269434 r269435 149 149 WEBCORE_EXPORT DOMWindow* window() const; 150 150 151 void addDestructionObserver(FrameDestructionObserver *);152 void removeDestructionObserver(FrameDestructionObserver *);151 void addDestructionObserver(FrameDestructionObserver&); 152 void removeDestructionObserver(FrameDestructionObserver&); 153 153 154 154 WEBCORE_EXPORT void willDetachPage(); -
trunk/Source/WebCore/page/FrameDestructionObserver.cpp
r185231 r269435 43 43 } 44 44 45 Frame* FrameDestructionObserver::frame() const 46 { 47 return m_frame.get(); 48 } 49 45 50 void FrameDestructionObserver::observeFrame(Frame* frame) 46 51 { 47 52 if (m_frame) 48 m_frame->removeDestructionObserver( this);53 m_frame->removeDestructionObserver(*this); 49 54 50 m_frame = frame;55 m_frame = makeWeakPtr(frame); 51 56 52 57 if (m_frame) 53 m_frame->addDestructionObserver( this);58 m_frame->addDestructionObserver(*this); 54 59 } 55 60 -
trunk/Source/WebCore/page/FrameDestructionObserver.h
r228483 r269435 26 26 #pragma once 27 27 28 #include <wtf/WeakPtr.h> 29 28 30 namespace WebCore { 29 31 … … 37 39 WEBCORE_EXPORT virtual void willDetachPage(); 38 40 39 Frame* frame() const { return m_frame; }41 WEBCORE_EXPORT Frame* frame() const; 40 42 41 43 protected: … … 43 45 WEBCORE_EXPORT void observeFrame(Frame*); 44 46 45 Frame*m_frame;47 WeakPtr<Frame> m_frame; 46 48 }; 47 49 -
trunk/Source/WebCore/page/FrameTree.cpp
r264372 r269435 37 37 namespace WebCore { 38 38 39 FrameTree::FrameTree(Frame& thisFrame, Frame* parentFrame) 40 : m_thisFrame(thisFrame) 41 , m_parent(makeWeakPtr(parentFrame)) 42 { 43 } 44 39 45 FrameTree::~FrameTree() 40 46 { … … 62 68 Frame* FrameTree::parent() const 63 69 { 64 return m_parent ;70 return m_parent.get(); 65 71 } 66 72 … … 68 74 { 69 75 ASSERT(child.page() == m_thisFrame.page()); 70 child.tree().m_parent = &m_thisFrame;71 Frame*oldLast = m_lastChild;72 m_lastChild = &child;76 child.tree().m_parent = makeWeakPtr(m_thisFrame); 77 WeakPtr<Frame> oldLast = m_lastChild; 78 m_lastChild = makeWeakPtr(child); 73 79 74 80 if (oldLast) { … … 85 91 void FrameTree::removeChild(Frame& child) 86 92 { 87 Frame*& newLocationForPrevious = m_lastChild == &child ? m_lastChild : child.tree().m_nextSibling->tree().m_previousSibling;93 WeakPtr<Frame>& newLocationForPrevious = m_lastChild == &child ? m_lastChild : child.tree().m_nextSibling->tree().m_previousSibling; 88 94 RefPtr<Frame>& newLocationForNext = m_firstChild == &child ? m_firstChild : child.tree().m_previousSibling->tree().m_nextSibling; 89 95 … … 424 430 return m_nextSibling->tree().deepFirstChild(); 425 431 if (m_parent) 426 return m_parent ;432 return m_parent.get(); 427 433 if (canWrap == CanWrap::Yes) 428 434 return deepFirstChild(); -
trunk/Source/WebCore/page/FrameTree.h
r264372 r269435 35 35 static constexpr unsigned invalidCount = static_cast<unsigned>(-1); 36 36 37 FrameTree(Frame& thisFrame, Frame* parentFrame) 38 : m_thisFrame(thisFrame) 39 , m_parent(parentFrame) 40 , m_previousSibling(nullptr) 41 , m_lastChild(nullptr) 42 , m_scopedChildCount(invalidCount) 43 { 44 } 37 FrameTree(Frame& thisFrame, Frame* parentFrame); 45 38 46 39 ~FrameTree(); … … 53 46 54 47 Frame* nextSibling() const { return m_nextSibling.get(); } 55 Frame* previousSibling() const { return m_previousSibling ; }48 Frame* previousSibling() const { return m_previousSibling.get(); } 56 49 Frame* firstChild() const { return m_firstChild.get(); } 57 Frame* lastChild() const { return m_lastChild ; }50 Frame* lastChild() const { return m_lastChild.get(); } 58 51 59 52 Frame* firstRenderedChild() const; … … 101 94 Frame& m_thisFrame; 102 95 103 Frame*m_parent;96 WeakPtr<Frame> m_parent; 104 97 AtomString m_name; // The actual frame name (may be empty). 105 98 AtomString m_uniqueName; 106 99 107 100 RefPtr<Frame> m_nextSibling; 108 Frame*m_previousSibling;101 WeakPtr<Frame> m_previousSibling; 109 102 RefPtr<Frame> m_firstChild; 110 Frame*m_lastChild;111 mutable unsigned m_scopedChildCount ;103 WeakPtr<Frame> m_lastChild; 104 mutable unsigned m_scopedChildCount { invalidCount }; 112 105 mutable uint64_t m_frameIDGenerator { 0 }; 113 106 }; -
trunk/Source/WebCore/rendering/RenderScrollbar.cpp
r264525 r269435 45 45 : Scrollbar(scrollableArea, orientation, ScrollbarControlSize::Regular, RenderScrollbarTheme::renderScrollbarTheme(), true) 46 46 , m_ownerElement(ownerElement) 47 , m_owningFrame( owningFrame)47 , m_owningFrame(makeWeakPtr(owningFrame)) 48 48 { 49 49 ASSERT(ownerElement || owningFrame); -
trunk/Source/WebCore/rendering/RenderScrollbar.h
r264525 r269435 86 86 RefPtr<Element> m_ownerElement; 87 87 88 Frame*m_owningFrame;88 WeakPtr<Frame> m_owningFrame; 89 89 HashMap<unsigned, RenderPtr<RenderScrollbarPart>> m_parts; 90 90 }; -
trunk/Source/WebKit/ChangeLog
r269434 r269435 1 2020-11-05 Alex Christensen <achristensen@webkit.org> 2 3 Store WeakPtr<Frame> instead of Frame* 4 https://bugs.webkit.org/show_bug.cgi?id=218599 5 6 Reviewed by Youenn Fablet. 7 8 * WebProcess/WebPage/WebFrame.cpp: 9 (WebKit::WebFrame::initWithCoreMainFrame): 10 (WebKit::WebFrame::createSubframe): 11 (WebKit::WebFrame::coreFrame const): 12 (WebKit::WebFrame::info const): 13 (WebKit::WebFrame::handlesPageScaleGesture const): 14 (WebKit::WebFrame::requiresUnifiedScaleFactor const): 15 * WebProcess/WebPage/WebFrame.h: 16 (WebKit::WebFrame::coreFrame const): Deleted. 17 1 18 2020-11-05 Alex Christensen <achristensen@webkit.org> 2 19 -
trunk/Source/WebKit/WebProcess/InjectedBundle/API/glib/DOM/DOMObjectCache.cpp
r248846 r269435 171 171 { 172 172 clear(); 173 WebCore::Frame* frame = m_frame ;173 WebCore::Frame* frame = m_frame.get(); 174 174 FrameDestructionObserver::frameDestroyed(); 175 175 domObjectCacheFrameObservers().remove(frame); -
trunk/Source/WebKit/WebProcess/WebPage/WebFrame.cpp
r269323 r269435 107 107 page.send(Messages::WebPageProxy::DidCreateMainFrame(frameID())); 108 108 109 m_coreFrame = &coreFrame;109 m_coreFrame = makeWeakPtr(coreFrame); 110 110 m_coreFrame->tree().setName(String()); 111 111 m_coreFrame->init(); … … 118 118 119 119 auto coreFrame = Frame::create(page->corePage(), ownerElement, makeUniqueRef<WebFrameLoaderClient>(frame.get())); 120 frame->m_coreFrame = coreFrame.ptr();120 frame->m_coreFrame = makeWeakPtr(coreFrame.get()); 121 121 122 122 coreFrame->tree().setName(frameName); … … 178 178 } 179 179 180 WebCore::Frame* WebFrame::coreFrame() const 181 { 182 return m_coreFrame.get(); 183 } 184 180 185 FrameInfoData WebFrame::info() const 181 186 { … … 186 191 // FIXME: This should use the full request. 187 192 ResourceRequest(url()), 188 SecurityOriginData::fromFrame(m_coreFrame ),193 SecurityOriginData::fromFrame(m_coreFrame.get()), 189 194 m_frameID, 190 195 parent ? Optional<WebCore::FrameIdentifier> { parent->frameID() } : WTF::nullopt, … … 534 539 bool WebFrame::handlesPageScaleGesture() const 535 540 { 536 auto* pluginView = WebPage::pluginViewForFrame(m_coreFrame );541 auto* pluginView = WebPage::pluginViewForFrame(m_coreFrame.get()); 537 542 return pluginView && pluginView->handlesPageScaleFactor(); 538 543 } … … 540 545 bool WebFrame::requiresUnifiedScaleFactor() const 541 546 { 542 auto* pluginView = WebPage::pluginViewForFrame(m_coreFrame );547 auto* pluginView = WebPage::pluginViewForFrame(m_coreFrame.get()); 543 548 return pluginView && pluginView->requiresUnifiedScaleFactor(); 544 549 } -
trunk/Source/WebKit/WebProcess/WebPage/WebFrame.h
r268989 r269435 79 79 80 80 static WebFrame* fromCoreFrame(const WebCore::Frame&); 81 WebCore::Frame* coreFrame() const { return m_coreFrame; }81 WebCore::Frame* coreFrame() const; 82 82 83 83 FrameInfoData info() const; … … 185 185 WebFrame(); 186 186 187 We bCore::Frame* m_coreFrame { nullptr };187 WeakPtr<WebCore::Frame> m_coreFrame; 188 188 189 189 uint64_t m_policyListenerID { 0 };
Note: See TracChangeset
for help on using the changeset viewer.