@@ -604,7 +604,7 @@ - (void)_setEditingDelegate:(id <WKWebProcessPlugInEditingDelegate>)editingDeleg
604604 public:
605605 explicit Client (WKWebProcessPlugInBrowserContextController *controller)
606606 : m_controller { controller }
607- , m_delegateMethods { m_controller ->_editingDelegate .get () }
607+ , m_delegateMethods { controller ->_editingDelegate .get () }
608608 {
609609 }
610610
@@ -614,7 +614,8 @@ bool shouldInsertText(WebKit::WebPage&, const WTF::String& text, const std::opti
614614 if (!m_delegateMethods.shouldInsertText )
615615 return true ;
616616
617- return [m_controller->_editingDelegate.get () _webProcessPlugInBrowserContextController: m_controller shouldInsertText: text replacingRange: wrapper (*WebKit: :createHandle (rangeToReplace)) givenAction: toWK (action)];
617+ RetainPtr controller = m_controller.get ();
618+ return [controller->_editingDelegate.get () _webProcessPlugInBrowserContextController: controller.get () shouldInsertText: text replacingRange: wrapper (*WebKit: :createHandle (rangeToReplace)) givenAction: toWK (action)];
618619 }
619620
620621 bool shouldChangeSelectedRange (WebKit::WebPage&, const std::optional<WebCore::SimpleRange>& fromRange, const std::optional<WebCore::SimpleRange>& toRange, WebCore::Affinity affinity, bool stillSelecting) final
@@ -636,31 +637,35 @@ bool shouldChangeSelectedRange(WebKit::WebPage&, const std::optional<WebCore::Si
636637 NSSelectionAffinity apiAffinity = affinity == WebCore::Affinity::Upstream ? NSSelectionAffinityUpstream : NSSelectionAffinityDownstream;
637638#endif
638639
639- return [m_controller->_editingDelegate.get () _webProcessPlugInBrowserContextController: m_controller shouldChangeSelectedRange: apiFromRange.get () toRange: apiToRange.get () affinity: apiAffinity stillSelecting: stillSelecting];
640+ RetainPtr controller = m_controller.get ();
641+ return [controller->_editingDelegate.get () _webProcessPlugInBrowserContextController: controller.get () shouldChangeSelectedRange: apiFromRange.get () toRange: apiToRange.get () affinity: apiAffinity stillSelecting: stillSelecting];
640642 }
641643
642644 void didChange (WebKit::WebPage&, const String&) final
643645 {
644646 if (!m_delegateMethods.didChange )
645647 return ;
646648
647- [m_controller->_editingDelegate.get () _webProcessPlugInBrowserContextControllerDidChangeByEditing: m_controller];
649+ RetainPtr controller = m_controller.get ();
650+ [controller->_editingDelegate.get () _webProcessPlugInBrowserContextControllerDidChangeByEditing: controller.get ()];
648651 }
649652
650653 void willWriteToPasteboard (WebKit::WebPage&, const std::optional<WebCore::SimpleRange>& range) final
651654 {
652655 if (!m_delegateMethods.willWriteToPasteboard )
653656 return ;
654657
655- [m_controller->_editingDelegate.get () _webProcessPlugInBrowserContextController: m_controller willWriteRangeToPasteboard: wrapper (WebKit: :createHandle (range).get ())];
658+ RetainPtr controller = m_controller.get ();
659+ [controller->_editingDelegate.get () _webProcessPlugInBrowserContextController: controller.get () willWriteRangeToPasteboard: wrapper (WebKit: :createHandle (range).get ())];
656660 }
657661
658662 void getPasteboardDataForRange (WebKit::WebPage&, const std::optional<WebCore::SimpleRange>& range, Vector<String>& pasteboardTypes, Vector<RefPtr<WebCore::SharedBuffer>>& pasteboardData) final
659663 {
660664 if (!m_delegateMethods.getPasteboardDataForRange )
661665 return ;
662666
663- auto dataByType = [m_controller->_editingDelegate.get () _webProcessPlugInBrowserContextController: m_controller pasteboardDataForRange: wrapper (WebKit: :createHandle (range).get ())];
667+ RetainPtr controller = m_controller.get ();
668+ auto dataByType = [controller->_editingDelegate.get () _webProcessPlugInBrowserContextController: controller.get () pasteboardDataForRange: wrapper (WebKit: :createHandle (range).get ())];
664669 for (NSString *type in dataByType) {
665670 pasteboardTypes.append (type);
666671 pasteboardData.append (WebCore::SharedBuffer::create (dataByType[type]));
@@ -672,7 +677,8 @@ void didWriteToPasteboard(WebKit::WebPage&) final
672677 if (!m_delegateMethods.didWriteToPasteboard )
673678 return ;
674679
675- [m_controller->_editingDelegate.get () _webProcessPlugInBrowserContextControllerDidWriteToPasteboard: m_controller];
680+ RetainPtr controller = m_controller.get ();
681+ [controller->_editingDelegate.get () _webProcessPlugInBrowserContextControllerDidWriteToPasteboard: controller.get ()];
676682 }
677683
678684 bool performTwoStepDrop (WebKit::WebPage&, WebCore::DocumentFragment& fragment, const WebCore::SimpleRange& range, bool isMove) final
@@ -682,10 +688,11 @@ bool performTwoStepDrop(WebKit::WebPage&, WebCore::DocumentFragment& fragment, c
682688
683689 auto rangeHandle = WebKit::createHandle (range);
684690 auto nodeHandle = WebKit::InjectedBundleNodeHandle::getOrCreate (&fragment);
685- return [m_controller->_editingDelegate.get () _webProcessPlugInBrowserContextController: m_controller performTwoStepDrop: wrapper (*nodeHandle) atDestination: wrapper (*rangeHandle) isMove: isMove];
691+ RetainPtr controller = m_controller.get ();
692+ return [controller->_editingDelegate.get () _webProcessPlugInBrowserContextController: controller.get () performTwoStepDrop: wrapper (*nodeHandle) atDestination: wrapper (*rangeHandle) isMove: isMove];
686693 }
687694
688- WKWebProcessPlugInBrowserContextController * m_controller;
695+ WeakObjCPtr< WKWebProcessPlugInBrowserContextController> m_controller;
689696 const struct DelegateMethods {
690697 DelegateMethods (RetainPtr<id <WKWebProcessPlugInEditingDelegate>> delegate)
691698 : shouldInsertText([delegate respondsToSelector: @selector (_webProcessPlugInBrowserContextController:shouldInsertText:replacingRange:givenAction: )])
0 commit comments