Diff
Modified: trunk/Source/WebKit/ChangeLog (221501 => 221502)
--- trunk/Source/WebKit/ChangeLog 2017-09-01 22:16:01 UTC (rev 221501)
+++ trunk/Source/WebKit/ChangeLog 2017-09-01 22:19:26 UTC (rev 221502)
@@ -1,5 +1,33 @@
2017-09-01 Alex Christensen <achristen...@webkit.org>
+ Make PageClientImplCocoa a proper superclass of PageClientImpls for Mac and iOS
+ https://bugs.webkit.org/show_bug.cgi?id=176239
+
+ Reviewed by Tim Horton.
+
+ * UIProcess/Cocoa/PageClientImplCocoa.h: Added.
+ (WebKit::PageClientImplCocoa::PageClientImplCocoa):
+ * UIProcess/Cocoa/PageClientImplCocoa.mm:
+ (WebKit::PageClientImplCocoa::isPlayingAudioWillChange):
+ (WebKit::PageClientImplCocoa::isPlayingAudioDidChange):
+ (WebKit::PageClientImpl::isPlayingAudioWillChange): Deleted.
+ (WebKit::PageClientImpl::isPlayingAudioDidChange): Deleted.
+ * UIProcess/Cocoa/WebViewImpl.mm:
+ * UIProcess/ios/PageClientImplIOS.h:
+ * UIProcess/ios/PageClientImplIOS.mm:
+ (WebKit::PageClientImpl::PageClientImpl):
+ * UIProcess/mac/PageClientImpl.h: Removed.
+ * UIProcess/mac/PageClientImpl.mm: Removed.
+ * UIProcess/mac/PageClientImplMac.h: Copied from Source/WebKit/UIProcess/mac/PageClientImpl.h.
+ * UIProcess/mac/PageClientImplMac.mm: Copied from Source/WebKit/UIProcess/mac/PageClientImpl.mm.
+ (WebKit::PageClientImpl::PageClientImpl):
+ * UIProcess/mac/WebContextMenuProxyMac.mm:
+ * UIProcess/mac/WebPageProxyMac.mm:
+ * UIProcess/mac/WebPopupMenuProxyMac.mm:
+ * WebKit.xcodeproj/project.pbxproj:
+
+2017-09-01 Alex Christensen <achristen...@webkit.org>
+
Replace WKUIDelegatePrivate's isPlayingMediaDidChange with KVO _isPlayingAudio on WKWebView
https://bugs.webkit.org/show_bug.cgi?id=176212
Added: trunk/Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.h (0 => 221502)
--- trunk/Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.h (rev 0)
+++ trunk/Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.h 2017-09-01 22:19:26 UTC (rev 221502)
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "PageClient.h"
+
+@class WKWebView;
+
+namespace WebKit {
+
+class PageClientImplCocoa : public PageClient {
+public:
+ PageClientImplCocoa(WKWebView *webView)
+ : m_webView(webView) { }
+ void isPlayingAudioWillChange() final;
+ void isPlayingAudioDidChange() final;
+protected:
+ WKWebView *m_webView;
+};
+
+}
Modified: trunk/Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.mm (221501 => 221502)
--- trunk/Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.mm 2017-09-01 22:16:01 UTC (rev 221501)
+++ trunk/Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.mm 2017-09-01 22:19:26 UTC (rev 221502)
@@ -24,14 +24,13 @@
*/
#import "config.h"
-#import "PageClientImpl.h"
+#import "PageClientImplCocoa.h"
-#import "PageClientImplIOS.h"
#import "WKWebViewPrivate.h"
namespace WebKit {
-void PageClientImpl::isPlayingAudioWillChange()
+void PageClientImplCocoa::isPlayingAudioWillChange()
{
#if WK_API_ENABLED
[m_webView willChangeValueForKey:NSStringFromSelector(@selector(_isPlayingAudio))];
@@ -38,7 +37,7 @@
#endif
}
-void PageClientImpl::isPlayingAudioDidChange()
+void PageClientImplCocoa::isPlayingAudioDidChange()
{
#if WK_API_ENABLED
[m_webView didChangeValueForKey:NSStringFromSelector(@selector(_isPlayingAudio))];
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (221501 => 221502)
--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm 2017-09-01 22:16:01 UTC (rev 221501)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm 2017-09-01 22:19:26 UTC (rev 221502)
@@ -39,7 +39,7 @@
#import "NativeWebMouseEvent.h"
#import "NativeWebWheelEvent.h"
#import "PageClient.h"
-#import "PageClientImpl.h"
+#import "PageClientImplMac.h"
#import "PasteboardTypes.h"
#import "PlaybackSessionManagerProxy.h"
#import "RemoteLayerTreeDrawingAreaProxy.h"
Modified: trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h (221501 => 221502)
--- trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h 2017-09-01 22:16:01 UTC (rev 221501)
+++ trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h 2017-09-01 22:19:26 UTC (rev 221502)
@@ -27,17 +27,16 @@
#if PLATFORM(IOS)
-#import "PageClient.h"
+#import "PageClientImplCocoa.h"
#import "WebFullScreenManagerProxy.h"
#import <wtf/RetainPtr.h>
OBJC_CLASS WKContentView;
-OBJC_CLASS WKWebView;
OBJC_CLASS WKEditorUndoTargetObjC;
namespace WebKit {
-class PageClientImpl : public PageClient
+class PageClientImpl : public PageClientImplCocoa
#if ENABLE(FULLSCREEN_API)
, public WebFullScreenManagerProxyClient
#endif
@@ -194,8 +193,6 @@
void derefView() override;
void didRestoreScrollPosition() override;
- void isPlayingAudioWillChange() final;
- void isPlayingAudioDidChange() final;
WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection() override;
@@ -214,7 +211,6 @@
#endif
WKContentView *m_contentView;
- WKWebView *m_webView;
RetainPtr<WKEditorUndoTargetObjC> m_undoTarget;
};
} // namespace WebKit
Modified: trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm (221501 => 221502)
--- trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm 2017-09-01 22:16:01 UTC (rev 221501)
+++ trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm 2017-09-01 22:19:26 UTC (rev 221502)
@@ -113,8 +113,8 @@
namespace WebKit {
PageClientImpl::PageClientImpl(WKContentView *contentView, WKWebView *webView)
- : m_contentView(contentView)
- , m_webView(webView)
+ : PageClientImplCocoa(webView)
+ , m_contentView(contentView)
, m_undoTarget(adoptNS([[WKEditorUndoTargetObjC alloc] init]))
{
}
Deleted: trunk/Source/WebKit/UIProcess/mac/PageClientImpl.h (221501 => 221502)
--- trunk/Source/WebKit/UIProcess/mac/PageClientImpl.h 2017-09-01 22:16:01 UTC (rev 221501)
+++ trunk/Source/WebKit/UIProcess/mac/PageClientImpl.h 2017-09-01 22:19:26 UTC (rev 221502)
@@ -1,261 +0,0 @@
-/*
- * Copyright (C) 2010, 2011, 2016 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#if PLATFORM(MAC)
-
-#include "CorrectionPanel.h"
-#include "PageClient.h"
-#include "WebFullScreenManagerProxy.h"
-#include <wtf/RetainPtr.h>
-
-@class WKEditorUndoTargetObjC;
-@class WKView;
-@class WKWebView;
-
-namespace WebCore {
-class AlternativeTextUIController;
-}
-
-namespace WebKit {
-
-class WebViewImpl;
-
-class PageClientImpl final : public PageClient
-#if ENABLE(FULLSCREEN_API)
- , public WebFullScreenManagerProxyClient
-#endif
- {
-public:
- PageClientImpl(NSView *, WKWebView *);
- virtual ~PageClientImpl();
-
- // FIXME: Eventually WebViewImpl should become the PageClient.
- void setImpl(WebViewImpl& impl) { m_impl = &impl; }
-
- void viewWillMoveToAnotherWindow();
-
-private:
- // PageClient
- std::unique_ptr<DrawingAreaProxy> createDrawingAreaProxy() override;
- void setViewNeedsDisplay(const WebCore::Region&) override;
- void requestScroll(const WebCore::FloatPoint& scrollPosition, const WebCore::IntPoint& scrollOrigin, bool isProgrammaticScroll) override;
- WebCore::FloatPoint viewScrollPosition() override;
-
- WebCore::IntSize viewSize() override;
- bool isViewWindowActive() override;
- bool isViewFocused() override;
- bool isViewVisible() override;
- bool isViewVisibleOrOccluded() override;
- bool isViewInWindow() override;
- bool isVisuallyIdle() override;
- LayerHostingMode viewLayerHostingMode() override;
- ColorSpaceData colorSpace() override;
- void setAcceleratedCompositingRootLayer(LayerOrView *) override;
- LayerOrView *acceleratedCompositingRootLayer() const override;
-
- void processDidExit() override;
- void pageClosed() override;
- void didRelaunchProcess() override;
- void preferencesDidChange() override;
- void toolTipChanged(const String& oldToolTip, const String& newToolTip) override;
- void didCommitLoadForMainFrame(const String& mimeType, bool useCustomContentProvider) override;
- void didFinishLoadingDataForCustomContentProvider(const String& suggestedFilename, const IPC::DataReference&) override;
- void handleDownloadRequest(DownloadProxy*) override;
- void didChangeContentSize(const WebCore::IntSize&) override;
- void setCursor(const WebCore::Cursor&) override;
- void setCursorHiddenUntilMouseMoves(bool) override;
- void didChangeViewportProperties(const WebCore::ViewportAttributes&) override;
- void isPlayingAudioWillChange() final;
- void isPlayingAudioDidChange() final;
-
- void registerEditCommand(Ref<WebEditCommandProxy>&&, WebPageProxy::UndoOrRedo) override;
- void clearAllEditCommands() override;
- bool canUndoRedo(WebPageProxy::UndoOrRedo) override;
- void executeUndoRedo(WebPageProxy::UndoOrRedo) override;
- bool executeSavedCommandBySelector(const String& selector) override;
- void setDragImage(const WebCore::IntPoint& clientPosition, Ref<ShareableBitmap>&& dragImage, WebCore::DragSourceAction) override;
- void setPromisedDataForImage(const String& pasteboardName, Ref<WebCore::SharedBuffer>&& imageBuffer, const String& filename, const String& extension, const String& title,
- const String& url, const String& visibleUrl, RefPtr<WebCore::SharedBuffer>&& archiveBuffer) override;
-#if ENABLE(ATTACHMENT_ELEMENT)
- void setPromisedDataForAttachment(const String& pasteboardName, const String& filename, const String& extension, const String& title, const String& url, const String& visibleUrl) override;
-#endif
- void updateSecureInputState() override;
- void resetSecureInputState() override;
- void notifyInputContextAboutDiscardedComposition() override;
- void selectionDidChange() override;
-
- WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&) override;
- WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&) override;
- WebCore::IntPoint screenToRootView(const WebCore::IntPoint&) override;
- WebCore::IntRect rootViewToScreen(const WebCore::IntRect&) override;
-#if PLATFORM(MAC)
- WebCore::IntRect rootViewToWindow(const WebCore::IntRect&) override;
-#endif
-#if PLATFORM(IOS)
- virtual WebCore::IntPoint accessibilityScreenToRootView(const WebCore::IntPoint&) = 0;
- virtual WebCore::IntRect rootViewToAccessibilityScreen(const WebCore::IntRect&) = 0;
-#endif
-
- CGRect boundsOfLayerInLayerBackedWindowCoordinates(CALayer *layer) const override;
-
- void doneWithKeyEvent(const NativeWebKeyboardEvent&, bool wasEventHandled) override;
-
- RefPtr<WebPopupMenuProxy> createPopupMenuProxy(WebPageProxy&) override;
-#if ENABLE(CONTEXT_MENUS)
- RefPtr<WebContextMenuProxy> createContextMenuProxy(WebPageProxy&, const ContextMenuContextData&, const UserData&) override;
-#endif
-
-#if ENABLE(INPUT_TYPE_COLOR)
- RefPtr<WebColorPicker> createColorPicker(WebPageProxy*, const WebCore::Color& initialColor, const WebCore::IntRect&) override;
-#endif
-
- Ref<WebCore::ValidationBubble> createValidationBubble(const String& message, const WebCore::ValidationBubble::Settings&) final;
-
- void setTextIndicator(Ref<WebCore::TextIndicator>, WebCore::TextIndicatorWindowLifetime) override;
- void clearTextIndicator(WebCore::TextIndicatorWindowDismissalAnimation) override;
- void setTextIndicatorAnimationProgress(float) override;
-
- void enterAcceleratedCompositingMode(const LayerTreeContext&) override;
- void exitAcceleratedCompositingMode() override;
- void updateAcceleratedCompositingMode(const LayerTreeContext&) override;
-
- RefPtr<ViewSnapshot> takeViewSnapshot() override;
- void wheelEventWasNotHandledByWebCore(const NativeWebWheelEvent&) override;
-#if ENABLE(MAC_GESTURE_EVENTS)
- void gestureEventWasNotHandledByWebCore(const NativeWebGestureEvent&) override;
-#endif
-
- void accessibilityWebProcessTokenReceived(const IPC::DataReference&) override;
-
- void pluginFocusOrWindowFocusChanged(uint64_t pluginComplexTextInputIdentifier, bool pluginHasFocusAndWindowHasFocus) override;
- void setPluginComplexTextInputState(uint64_t pluginComplexTextInputIdentifier, PluginComplexTextInputState) override;
-
- void makeFirstResponder() override;
- void setShouldSuppressFirstResponderChanges(bool shouldSuppress) override { m_shouldSuppressFirstResponderChanges = shouldSuppress; }
-
- void didPerformDictionaryLookup(const WebCore::DictionaryPopupInfo&) override;
-
- void showCorrectionPanel(WebCore::AlternativeTextType, const WebCore::FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings) override;
- void dismissCorrectionPanel(WebCore::ReasonForDismissingAlternativeText) override;
- String dismissCorrectionPanelSoon(WebCore::ReasonForDismissingAlternativeText) override;
- void recordAutocorrectionResponse(WebCore::AutocorrectionResponse, const String& replacedString, const String& replacementString) override;
-
- void recommendedScrollbarStyleDidChange(WebCore::ScrollbarStyle) override;
-
- void intrinsicContentSizeDidChange(const WebCore::IntSize& intrinsicContentSize) override;
-
-#if USE(DICTATION_ALTERNATIVES)
- uint64_t addDictationAlternatives(const RetainPtr<NSTextAlternatives>&) override;
- void removeDictationAlternatives(uint64_t dictationContext) override;
- void showDictationAlternativeUI(const WebCore::FloatRect& boundingBoxOfDictatedText, uint64_t dictationContext) override;
- Vector<String> dictationAlternatives(uint64_t dictationContext) override;
-#endif
- void setEditableElementIsFocused(bool) override;
-
-#if USE(INSERTION_UNDO_GROUPING)
- void registerInsertionUndoGrouping() override;
-#endif
-
- // Auxiliary Client Creation
-#if ENABLE(FULLSCREEN_API)
- WebFullScreenManagerProxyClient& fullScreenManagerProxyClient() override;
-#endif
-
-#if ENABLE(FULLSCREEN_API)
- // WebFullScreenManagerProxyClient
- void closeFullScreenManager() override;
- bool isFullScreen() override;
- void enterFullScreen() override;
- void exitFullScreen() override;
- void beganEnterFullScreen(const WebCore::IntRect& initialFrame, const WebCore::IntRect& finalFrame) override;
- void beganExitFullScreen(const WebCore::IntRect& initialFrame, const WebCore::IntRect& finalFrame) override;
-#endif
-
- void navigationGestureDidBegin() override;
- void navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem&) override;
- void navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem&) override;
- void navigationGestureDidEnd() override;
- void willRecordNavigationSnapshot(WebBackForwardListItem&) override;
- void didRemoveNavigationGestureSnapshot() override;
-
- NSView *activeView() const;
- NSWindow *activeWindow() const;
-
- void didFirstVisuallyNonEmptyLayoutForMainFrame() override;
- void didFinishLoadForMainFrame() override;
- void didFailLoadForMainFrame() override;
- void didSameDocumentNavigationForMainFrame(SameDocumentNavigationType) override;
- void handleControlledElementIDResponse(const String&) override;
- void handleActiveNowPlayingSessionInfoResponse(bool hasActiveSession, const String& title, double duration, double elapsedTime) override;
-
- void didPerformImmediateActionHitTest(const WebHitTestResultData&, bool contentPreventsDefault, API::Object*) override;
- void* immediateActionAnimationControllerForHitTestResult(RefPtr<API::HitTestResult>, uint64_t, RefPtr<API::Object>) override;
-
- void didHandleAcceptedCandidate() override;
-
- void videoControlsManagerDidChange() override;
-
- void showPlatformContextMenu(NSMenu *, WebCore::IntPoint) override;
-
- void didChangeBackgroundColor() override;
-
- void startWindowDrag() override;
- NSWindow *platformWindow() override;
-
- WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection() override;
-
-#if WK_API_ENABLED
- NSView *inspectorAttachmentView() override;
- _WKRemoteObjectRegistry *remoteObjectRegistry() override;
-#endif
-
- NSView *m_view;
- WKWebView *m_webView;
- WebViewImpl* m_impl { nullptr };
-#if USE(AUTOCORRECTION_PANEL)
- CorrectionPanel m_correctionPanel;
-#endif
-#if USE(DICTATION_ALTERNATIVES)
- std::unique_ptr<WebCore::AlternativeTextUIController> m_alternativeTextUIController;
-#endif
-
- bool m_shouldSuppressFirstResponderChanges { false };
-
-#if ENABLE(WIRELESS_PLAYBACK_TARGET)
- WebCore::WebMediaSessionManager& mediaSessionManager() override;
-#endif
-
- void refView() override;
- void derefView() override;
-
- void didRestoreScrollPosition() override;
- bool windowIsFrontWindowUnderMouse(const NativeWebMouseEvent&) override;
-};
-
-} // namespace WebKit
-
-#endif // PLATFORM(MAC)
Deleted: trunk/Source/WebKit/UIProcess/mac/PageClientImpl.mm (221501 => 221502)
--- trunk/Source/WebKit/UIProcess/mac/PageClientImpl.mm 2017-09-01 22:16:01 UTC (rev 221501)
+++ trunk/Source/WebKit/UIProcess/mac/PageClientImpl.mm 2017-09-01 22:19:26 UTC (rev 221502)
@@ -1,886 +0,0 @@
-/*
- * Copyright (C) 2010, 2011, 2016 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "PageClientImpl.h"
-
-#if PLATFORM(MAC)
-
-#import "APIHitTestResult.h"
-#import "ColorSpaceData.h"
-#import "DataReference.h"
-#import "DownloadProxy.h"
-#import "DrawingAreaProxy.h"
-#import "NativeWebGestureEvent.h"
-#import "NativeWebKeyboardEvent.h"
-#import "NativeWebMouseEvent.h"
-#import "NativeWebWheelEvent.h"
-#import "NavigationState.h"
-#import "StringUtilities.h"
-#import "ViewGestureController.h"
-#import "ViewSnapshotStore.h"
-#import "WKAPICast.h"
-#import "WKFullScreenWindowController.h"
-#import "WKStringCF.h"
-#import "WKViewInternal.h"
-#import "WKWebViewInternal.h"
-#import "WebColorPickerMac.h"
-#import "WebContextMenuProxyMac.h"
-#import "WebEditCommandProxy.h"
-#import "WebPopupMenuProxyMac.h"
-#import "WebViewImpl.h"
-#import "WindowServerConnection.h"
-#import "_WKDownloadInternal.h"
-#import "_WKHitTestResultInternal.h"
-#import "_WKThumbnailView.h"
-#import <WebCore/AlternativeTextUIController.h>
-#import <WebCore/BitmapImage.h>
-#import <WebCore/Cursor.h>
-#import <WebCore/DictionaryLookup.h>
-#import <WebCore/FloatRect.h>
-#import <WebCore/GraphicsContext.h>
-#import <WebCore/Image.h>
-#import <WebCore/KeyboardEvent.h>
-#import <WebCore/NotImplemented.h>
-#import <WebCore/SharedBuffer.h>
-#import <WebCore/TextIndicator.h>
-#import <WebCore/TextIndicatorWindow.h>
-#import <WebCore/TextUndoInsertionMarkupMac.h>
-#import <WebCore/ValidationBubble.h>
-#import <WebKitSystemInterface.h>
-#import <wtf/text/CString.h>
-#import <wtf/text/WTFString.h>
-
-#if USE(DICTATION_ALTERNATIVES)
-#import <AppKit/NSTextAlternatives.h>
-#endif
-
-#if ENABLE(WIRELESS_PLAYBACK_TARGET)
-#include <WebCore/WebMediaSessionManager.h>
-#endif
-
-@interface NSApplication (WebNSApplicationDetails)
-- (NSCursor *)_cursorRectCursor;
-@end
-
-#if HAVE(OUT_OF_PROCESS_LAYER_HOSTING)
-@interface NSWindow (WebNSWindowDetails)
-- (BOOL)_hostsLayersInWindowServer;
-@end
-#endif
-
-using namespace WebCore;
-using namespace WebKit;
-
-namespace WebKit {
-
-PageClientImpl::PageClientImpl(NSView* view, WKWebView *webView)
- : m_view(view)
- , m_webView(webView)
-#if USE(DICTATION_ALTERNATIVES)
- , m_alternativeTextUIController(std::make_unique<AlternativeTextUIController>())
-#endif
-{
-#if !WK_API_ENABLED
- ASSERT_UNUSED(m_webView, !m_webView);
-#endif
-}
-
-PageClientImpl::~PageClientImpl()
-{
-}
-
-std::unique_ptr<DrawingAreaProxy> PageClientImpl::createDrawingAreaProxy()
-{
- return m_impl->createDrawingAreaProxy();
-}
-
-void PageClientImpl::setViewNeedsDisplay(const WebCore::Region&)
-{
- ASSERT_NOT_REACHED();
-}
-
-void PageClientImpl::requestScroll(const FloatPoint& scrollPosition, const IntPoint& scrollOrigin, bool isProgrammaticScroll)
-{
-}
-
-WebCore::FloatPoint PageClientImpl::viewScrollPosition()
-{
- return { };
-}
-
-IntSize PageClientImpl::viewSize()
-{
- return IntSize([m_view bounds].size);
-}
-
-NSView *PageClientImpl::activeView() const
-{
-#if WK_API_ENABLED
- return (m_impl && m_impl->thumbnailView()) ? (NSView *)m_impl->thumbnailView() : m_view;
-#else
- return m_view;
-#endif
-}
-
-NSWindow *PageClientImpl::activeWindow() const
-{
-#if WK_API_ENABLED
- if (m_impl && m_impl->thumbnailView())
- return m_impl->thumbnailView().window;
-#endif
- if (m_impl && m_impl->targetWindowForMovePreparation())
- return m_impl->targetWindowForMovePreparation();
- return m_view.window;
-}
-
-bool PageClientImpl::isViewWindowActive()
-{
- NSWindow *activeViewWindow = activeWindow();
- return activeViewWindow.isKeyWindow || [NSApp keyWindow] == activeViewWindow;
-}
-
-bool PageClientImpl::isViewFocused()
-{
- // FIXME: This is called from the WebPageProxy constructor before we have a WebViewImpl.
- // Once WebViewImpl and PageClient merge, this won't be a problem.
- if (!m_impl)
- return NO;
-
- return m_impl->isFocused();
-}
-
-void PageClientImpl::makeFirstResponder()
-{
- if (m_shouldSuppressFirstResponderChanges)
- return;
-
- [[m_view window] makeFirstResponder:m_view];
-}
-
-bool PageClientImpl::isViewVisible()
-{
- NSView *activeView = this->activeView();
- NSWindow *activeViewWindow = activeWindow();
-
- if (!activeViewWindow)
- return false;
-
- if (!activeViewWindow.isVisible)
- return false;
-
- if (activeView.isHiddenOrHasHiddenAncestor)
- return false;
-
- if (m_impl->windowOcclusionDetectionEnabled() && (activeViewWindow.occlusionState & NSWindowOcclusionStateVisible) != NSWindowOcclusionStateVisible)
- return false;
-
- return true;
-}
-
-bool PageClientImpl::isViewVisibleOrOccluded()
-{
- return activeWindow().isVisible;
-}
-
-bool PageClientImpl::isViewInWindow()
-{
- return activeWindow();
-}
-
-bool PageClientImpl::isVisuallyIdle()
-{
- return WindowServerConnection::singleton().applicationWindowModificationsHaveStopped() || !isViewVisible();
-}
-
-LayerHostingMode PageClientImpl::viewLayerHostingMode()
-{
-#if HAVE(OUT_OF_PROCESS_LAYER_HOSTING)
- if ([activeWindow() _hostsLayersInWindowServer])
- return LayerHostingMode::OutOfProcess;
-#endif
- return LayerHostingMode::InProcess;
-}
-
-void PageClientImpl::viewWillMoveToAnotherWindow()
-{
- clearAllEditCommands();
-}
-
-ColorSpaceData PageClientImpl::colorSpace()
-{
- return m_impl->colorSpace();
-}
-
-void PageClientImpl::processDidExit()
-{
- m_impl->processDidExit();
-}
-
-void PageClientImpl::pageClosed()
-{
- m_impl->pageClosed();
-#if USE(DICTATION_ALTERNATIVES)
- m_alternativeTextUIController->clear();
-#endif
-}
-
-void PageClientImpl::didRelaunchProcess()
-{
- m_impl->didRelaunchProcess();
-}
-
-void PageClientImpl::preferencesDidChange()
-{
- m_impl->preferencesDidChange();
-}
-
-void PageClientImpl::toolTipChanged(const String& oldToolTip, const String& newToolTip)
-{
- m_impl->toolTipChanged(oldToolTip, newToolTip);
-}
-
-void PageClientImpl::didCommitLoadForMainFrame(const String& mimeType, bool useCustomContentProvider)
-{
- m_impl->updateSupportsArbitraryLayoutModes();
- m_impl->dismissContentRelativeChildWindowsWithAnimation(true);
-}
-
-void PageClientImpl::didFinishLoadingDataForCustomContentProvider(const String& suggestedFilename, const IPC::DataReference& dataReference)
-{
-}
-
-void PageClientImpl::handleDownloadRequest(DownloadProxy* download)
-{
- ASSERT_ARG(download, download);
-#if WK_API_ENABLED
- ASSERT([download->wrapper() isKindOfClass:[_WKDownload class]]);
- [static_cast<_WKDownload *>(download->wrapper()) setOriginatingWebView:m_webView];
-#endif
-}
-
-void PageClientImpl::didChangeContentSize(const WebCore::IntSize& newSize)
-{
- m_impl->didChangeContentSize(newSize);
-}
-
-void PageClientImpl::setCursor(const WebCore::Cursor& cursor)
-{
- // FIXME: Would be nice to share this code with WebKit1's WebChromeClient.
-
- // The Web process may have asked to change the cursor when the view was in an active window, but
- // if it is no longer in a window or the window is not active, then the cursor should not change.
- if (!isViewWindowActive())
- return;
-
- if ([NSApp _cursorRectCursor])
- return;
-
- if (!m_view)
- return;
-
- NSWindow *window = [m_view window];
- if (!window)
- return;
-
- if ([window windowNumber] != [NSWindow windowNumberAtPoint:[NSEvent mouseLocation] belowWindowWithWindowNumber:0])
- return;
-
- NSCursor *platformCursor = cursor.platformCursor();
- if ([NSCursor currentCursor] == platformCursor)
- return;
-
- [platformCursor set];
-}
-
-void PageClientImpl::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
-{
- [NSCursor setHiddenUntilMouseMoves:hiddenUntilMouseMoves];
-}
-
-void PageClientImpl::didChangeViewportProperties(const WebCore::ViewportAttributes&)
-{
-}
-
-void PageClientImpl::registerEditCommand(Ref<WebEditCommandProxy>&& command, WebPageProxy::UndoOrRedo undoOrRedo)
-{
- m_impl->registerEditCommand(WTFMove(command), undoOrRedo);
-}
-
-#if USE(INSERTION_UNDO_GROUPING)
-void PageClientImpl::registerInsertionUndoGrouping()
-{
- registerInsertionUndoGroupingWithUndoManager([m_view undoManager]);
-}
-#endif
-
-void PageClientImpl::clearAllEditCommands()
-{
- m_impl->clearAllEditCommands();
-}
-
-bool PageClientImpl::canUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
-{
- return (undoOrRedo == WebPageProxy::Undo) ? [[m_view undoManager] canUndo] : [[m_view undoManager] canRedo];
-}
-
-void PageClientImpl::executeUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
-{
- return (undoOrRedo == WebPageProxy::Undo) ? [[m_view undoManager] undo] : [[m_view undoManager] redo];
-}
-
-void PageClientImpl::setDragImage(const IntPoint& clientPosition, Ref<ShareableBitmap>&& dragImage, DragSourceAction action)
-{
- RetainPtr<CGImageRef> dragCGImage = dragImage->makeCGImage();
- RetainPtr<NSImage> dragNSImage = adoptNS([[NSImage alloc] initWithCGImage:dragCGImage.get() size:dragImage->size()]);
- IntSize size([dragNSImage size]);
- size.scale(1.0 / m_impl->page().deviceScaleFactor());
- [dragNSImage setSize:size];
-
- m_impl->dragImageForView(m_view, dragNSImage.get(), clientPosition, action == DragSourceActionLink);
-}
-
-void PageClientImpl::setPromisedDataForImage(const String& pasteboardName, Ref<SharedBuffer>&& imageBuffer, const String& filename, const String& extension, const String& title, const String& url, const String& visibleURL, RefPtr<SharedBuffer>&& archiveBuffer)
-{
- RefPtr<Image> image = BitmapImage::create();
- image->setData(WTFMove(imageBuffer), true);
- m_impl->setPromisedDataForImage(image.get(), filename, extension, title, url, visibleURL, archiveBuffer.get(), pasteboardName);
-}
-
-#if ENABLE(ATTACHMENT_ELEMENT)
-void PageClientImpl::setPromisedDataForAttachment(const String& pasteboardName, const String& filename, const String& extension, const String& title, const String& url, const String& visibleURL)
-{
- m_impl->setPromisedDataForAttachment(filename, extension, title, url, visibleURL, pasteboardName);
-}
-#endif
-
-void PageClientImpl::updateSecureInputState()
-{
- m_impl->updateSecureInputState();
-}
-
-void PageClientImpl::resetSecureInputState()
-{
- m_impl->resetSecureInputState();
-}
-
-void PageClientImpl::notifyInputContextAboutDiscardedComposition()
-{
- m_impl->notifyInputContextAboutDiscardedComposition();
-}
-
-FloatRect PageClientImpl::convertToDeviceSpace(const FloatRect& rect)
-{
- return toDeviceSpace(rect, [m_view window]);
-}
-
-FloatRect PageClientImpl::convertToUserSpace(const FloatRect& rect)
-{
- return toUserSpace(rect, [m_view window]);
-}
-
-IntPoint PageClientImpl::screenToRootView(const IntPoint& point)
-{
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- NSPoint windowCoord = [[m_view window] convertScreenToBase:point];
-#pragma clang diagnostic pop
- return IntPoint([m_view convertPoint:windowCoord fromView:nil]);
-}
-
-IntRect PageClientImpl::rootViewToScreen(const IntRect& rect)
-{
- NSRect tempRect = rect;
- tempRect = [m_view convertRect:tempRect toView:nil];
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- tempRect.origin = [[m_view window] convertBaseToScreen:tempRect.origin];
-#pragma clang diagnostic pop
- return enclosingIntRect(tempRect);
-}
-
-IntRect PageClientImpl::rootViewToWindow(const WebCore::IntRect& rect)
-{
- NSRect tempRect = rect;
- tempRect = [m_view convertRect:tempRect toView:nil];
- return enclosingIntRect(tempRect);
-}
-
-void PageClientImpl::doneWithKeyEvent(const NativeWebKeyboardEvent& event, bool eventWasHandled)
-{
- m_impl->doneWithKeyEvent(event.nativeEvent(), eventWasHandled);
-}
-
-RefPtr<WebPopupMenuProxy> PageClientImpl::createPopupMenuProxy(WebPageProxy& page)
-{
- return WebPopupMenuProxyMac::create(m_view, page);
-}
-
-#if ENABLE(CONTEXT_MENUS)
-RefPtr<WebContextMenuProxy> PageClientImpl::createContextMenuProxy(WebPageProxy& page, const ContextMenuContextData& context, const UserData& userData)
-{
- return WebContextMenuProxyMac::create(m_view, page, context, userData);
-}
-#endif
-
-#if ENABLE(INPUT_TYPE_COLOR)
-RefPtr<WebColorPicker> PageClientImpl::createColorPicker(WebPageProxy* page, const WebCore::Color& initialColor, const WebCore::IntRect& rect)
-{
- return WebColorPickerMac::create(page, initialColor, rect, m_view);
-}
-#endif
-
-Ref<ValidationBubble> PageClientImpl::createValidationBubble(const String& message, const ValidationBubble::Settings& settings)
-{
- return ValidationBubble::create(m_view, message, settings);
-}
-
-void PageClientImpl::setTextIndicator(Ref<TextIndicator> textIndicator, WebCore::TextIndicatorWindowLifetime lifetime)
-{
- m_impl->setTextIndicator(textIndicator.get(), lifetime);
-}
-
-void PageClientImpl::clearTextIndicator(WebCore::TextIndicatorWindowDismissalAnimation dismissalAnimation)
-{
- m_impl->clearTextIndicatorWithAnimation(dismissalAnimation);
-}
-
-void PageClientImpl::setTextIndicatorAnimationProgress(float progress)
-{
- m_impl->setTextIndicatorAnimationProgress(progress);
-}
-
-void PageClientImpl::accessibilityWebProcessTokenReceived(const IPC::DataReference& data)
-{
- m_impl->setAccessibilityWebProcessToken([NSData dataWithBytes:data.data() length:data.size()]);
-}
-
-void PageClientImpl::enterAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext)
-{
- ASSERT(!layerTreeContext.isEmpty());
-
- CALayer *renderLayer = WKMakeRenderLayer(layerTreeContext.contextID);
- m_impl->setAcceleratedCompositingRootLayer(renderLayer);
-}
-
-void PageClientImpl::exitAcceleratedCompositingMode()
-{
- m_impl->setAcceleratedCompositingRootLayer(nil);
-}
-
-void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext)
-{
- ASSERT(!layerTreeContext.isEmpty());
-
- CALayer *renderLayer = WKMakeRenderLayer(layerTreeContext.contextID);
- m_impl->setAcceleratedCompositingRootLayer(renderLayer);
-}
-
-void PageClientImpl::setAcceleratedCompositingRootLayer(CALayer *rootLayer)
-{
- m_impl->setAcceleratedCompositingRootLayer(rootLayer);
-}
-
-CALayer *PageClientImpl::acceleratedCompositingRootLayer() const
-{
- return m_impl->acceleratedCompositingRootLayer();
-}
-
-RefPtr<ViewSnapshot> PageClientImpl::takeViewSnapshot()
-{
- return m_impl->takeViewSnapshot();
-}
-
-void PageClientImpl::selectionDidChange()
-{
- m_impl->selectionDidChange();
-}
-
-void PageClientImpl::wheelEventWasNotHandledByWebCore(const NativeWebWheelEvent& event)
-{
- if (auto gestureController = m_impl->gestureController())
- gestureController->wheelEventWasNotHandledByWebCore(event.nativeEvent());
-}
-
-#if ENABLE(MAC_GESTURE_EVENTS)
-void PageClientImpl::gestureEventWasNotHandledByWebCore(const NativeWebGestureEvent& event)
-{
- m_impl->gestureEventWasNotHandledByWebCore(event.nativeEvent());
-}
-#endif
-
-void PageClientImpl::pluginFocusOrWindowFocusChanged(uint64_t pluginComplexTextInputIdentifier, bool pluginHasFocusAndWindowHasFocus)
-{
- m_impl->pluginFocusOrWindowFocusChanged(pluginHasFocusAndWindowHasFocus, pluginComplexTextInputIdentifier);
-}
-
-void PageClientImpl::setPluginComplexTextInputState(uint64_t pluginComplexTextInputIdentifier, PluginComplexTextInputState pluginComplexTextInputState)
-{
- m_impl->setPluginComplexTextInputStateAndIdentifier(pluginComplexTextInputState, pluginComplexTextInputIdentifier);
-}
-
-void PageClientImpl::didPerformDictionaryLookup(const DictionaryPopupInfo& dictionaryPopupInfo)
-{
- m_impl->prepareForDictionaryLookup();
-
- DictionaryLookup::showPopup(dictionaryPopupInfo, m_view, [this](TextIndicator& textIndicator) {
- m_impl->setTextIndicator(textIndicator, TextIndicatorWindowLifetime::Permanent);
- });
-}
-
-void PageClientImpl::showCorrectionPanel(AlternativeTextType type, const FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings)
-{
-#if USE(AUTOCORRECTION_PANEL)
- if (!isViewVisible() || !isViewInWindow())
- return;
- m_correctionPanel.show(m_view, *m_impl, type, boundingBoxOfReplacedString, replacedString, replacementString, alternativeReplacementStrings);
-#endif
-}
-
-void PageClientImpl::dismissCorrectionPanel(ReasonForDismissingAlternativeText reason)
-{
-#if USE(AUTOCORRECTION_PANEL)
- m_correctionPanel.dismiss(reason);
-#endif
-}
-
-String PageClientImpl::dismissCorrectionPanelSoon(WebCore::ReasonForDismissingAlternativeText reason)
-{
-#if USE(AUTOCORRECTION_PANEL)
- return m_correctionPanel.dismiss(reason);
-#else
- return String();
-#endif
-}
-
-static inline NSCorrectionResponse toCorrectionResponse(AutocorrectionResponse response)
-{
- switch (response) {
- case WebCore::AutocorrectionResponse::Reverted:
- return NSCorrectionResponseReverted;
- case WebCore::AutocorrectionResponse::Edited:
- return NSCorrectionResponseEdited;
- case WebCore::AutocorrectionResponse::Accepted:
- return NSCorrectionResponseAccepted;
- }
-
- ASSERT_NOT_REACHED();
- return NSCorrectionResponseAccepted;
-}
-
-void PageClientImpl::recordAutocorrectionResponse(AutocorrectionResponse response, const String& replacedString, const String& replacementString)
-{
- CorrectionPanel::recordAutocorrectionResponse(m_impl->spellCheckerDocumentTag(), toCorrectionResponse(response), replacedString, replacementString);
-}
-
-void PageClientImpl::recommendedScrollbarStyleDidChange(ScrollbarStyle newStyle)
-{
- // Now re-create a tracking area with the appropriate options given the new scrollbar style
- NSTrackingAreaOptions options = NSTrackingMouseMoved | NSTrackingMouseEnteredAndExited | NSTrackingInVisibleRect | NSTrackingCursorUpdate;
- if (newStyle == ScrollbarStyle::AlwaysVisible)
- options |= NSTrackingActiveAlways;
- else
- options |= NSTrackingActiveInKeyWindow;
-
- RetainPtr<NSTrackingArea> trackingArea = adoptNS([[NSTrackingArea alloc] initWithRect:[m_view frame] options:options owner:m_view userInfo:nil]);
- m_impl->setPrimaryTrackingArea(trackingArea.get());
-}
-
-void PageClientImpl::intrinsicContentSizeDidChange(const IntSize& intrinsicContentSize)
-{
- m_impl->setIntrinsicContentSize(intrinsicContentSize);
-}
-
-bool PageClientImpl::executeSavedCommandBySelector(const String& selectorString)
-{
- return m_impl->executeSavedCommandBySelector(NSSelectorFromString(selectorString));
-}
-
-#if USE(DICTATION_ALTERNATIVES)
-uint64_t PageClientImpl::addDictationAlternatives(const RetainPtr<NSTextAlternatives>& alternatives)
-{
- return m_alternativeTextUIController->addAlternatives(alternatives);
-}
-
-void PageClientImpl::removeDictationAlternatives(uint64_t dictationContext)
-{
- m_alternativeTextUIController->removeAlternatives(dictationContext);
-}
-
-void PageClientImpl::showDictationAlternativeUI(const WebCore::FloatRect& boundingBoxOfDictatedText, uint64_t dictationContext)
-{
- if (!isViewVisible() || !isViewInWindow())
- return;
- m_alternativeTextUIController->showAlternatives(m_view, boundingBoxOfDictatedText, dictationContext, ^(NSString *acceptedAlternative) {
- m_impl->handleAcceptedAlternativeText(acceptedAlternative);
- });
-}
-
-Vector<String> PageClientImpl::dictationAlternatives(uint64_t dictationContext)
-{
- return m_alternativeTextUIController->alternativesForContext(dictationContext);
-}
-#endif
-
-void PageClientImpl::setEditableElementIsFocused(bool editableElementIsFocused)
-{
- m_impl->setEditableElementIsFocused(editableElementIsFocused);
-}
-
-#if ENABLE(FULLSCREEN_API)
-
-WebFullScreenManagerProxyClient& PageClientImpl::fullScreenManagerProxyClient()
-{
- return *this;
-}
-
-// WebFullScreenManagerProxyClient
-
-void PageClientImpl::closeFullScreenManager()
-{
- m_impl->closeFullScreenWindowController();
-}
-
-bool PageClientImpl::isFullScreen()
-{
- if (!m_impl->hasFullScreenWindowController())
- return false;
-
- return m_impl->fullScreenWindowController().isFullScreen;
-}
-
-void PageClientImpl::enterFullScreen()
-{
- [m_impl->fullScreenWindowController() enterFullScreen:nil];
-}
-
-void PageClientImpl::exitFullScreen()
-{
- [m_impl->fullScreenWindowController() exitFullScreen];
-}
-
-void PageClientImpl::beganEnterFullScreen(const IntRect& initialFrame, const IntRect& finalFrame)
-{
- [m_impl->fullScreenWindowController() beganEnterFullScreenWithInitialFrame:initialFrame finalFrame:finalFrame];
- m_impl->updateSupportsArbitraryLayoutModes();
-}
-
-void PageClientImpl::beganExitFullScreen(const IntRect& initialFrame, const IntRect& finalFrame)
-{
- [m_impl->fullScreenWindowController() beganExitFullScreenWithInitialFrame:initialFrame finalFrame:finalFrame];
- m_impl->updateSupportsArbitraryLayoutModes();
-}
-
-#endif // ENABLE(FULLSCREEN_API)
-
-void PageClientImpl::navigationGestureDidBegin()
-{
- m_impl->dismissContentRelativeChildWindowsWithAnimation(true);
-
-#if WK_API_ENABLED
- if (m_webView)
- NavigationState::fromWebPage(*m_webView->_page).navigationGestureDidBegin();
-#endif
-}
-
-void PageClientImpl::navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem& item)
-{
-#if WK_API_ENABLED
- if (m_webView)
- NavigationState::fromWebPage(*m_webView->_page).navigationGestureWillEnd(willNavigate, item);
-#else
- UNUSED_PARAM(willNavigate);
- UNUSED_PARAM(item);
-#endif
-}
-
-void PageClientImpl::navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem& item)
-{
-#if WK_API_ENABLED
- if (m_webView)
- NavigationState::fromWebPage(*m_webView->_page).navigationGestureDidEnd(willNavigate, item);
-#else
- UNUSED_PARAM(willNavigate);
- UNUSED_PARAM(item);
-#endif
-}
-
-void PageClientImpl::navigationGestureDidEnd()
-{
-}
-
-void PageClientImpl::willRecordNavigationSnapshot(WebBackForwardListItem& item)
-{
-#if WK_API_ENABLED
- if (m_webView)
- NavigationState::fromWebPage(*m_webView->_page).willRecordNavigationSnapshot(item);
-#else
- UNUSED_PARAM(item);
-#endif
-}
-
-void PageClientImpl::didRemoveNavigationGestureSnapshot()
-{
-#if WK_API_ENABLED
- if (m_webView)
- NavigationState::fromWebPage(*m_webView->_page).navigationGestureSnapshotWasRemoved();
-#endif
-}
-
-void PageClientImpl::didFirstVisuallyNonEmptyLayoutForMainFrame()
-{
- if (auto gestureController = m_impl->gestureController())
- gestureController->didFirstVisuallyNonEmptyLayoutForMainFrame();
-}
-
-void PageClientImpl::didFinishLoadForMainFrame()
-{
- if (auto gestureController = m_impl->gestureController())
- gestureController->didFinishLoadForMainFrame();
-}
-
-void PageClientImpl::didFailLoadForMainFrame()
-{
- if (auto gestureController = m_impl->gestureController())
- gestureController->didFailLoadForMainFrame();
-}
-
-void PageClientImpl::didSameDocumentNavigationForMainFrame(SameDocumentNavigationType type)
-{
- if (auto gestureController = m_impl->gestureController())
- gestureController->didSameDocumentNavigationForMainFrame(type);
-}
-
-void PageClientImpl::handleControlledElementIDResponse(const String& identifier)
-{
-#if WK_API_ENABLED
- [m_webView _handleControlledElementIDResponse:nsStringFromWebCoreString(identifier)];
-#endif
-}
-
-void PageClientImpl::handleActiveNowPlayingSessionInfoResponse(bool hasActiveSession, const String& title, double duration, double elapsedTime)
-{
-#if WK_API_ENABLED
- [m_webView _handleActiveNowPlayingSessionInfoResponse:hasActiveSession title:nsStringFromWebCoreString(title) duration:duration elapsedTime:elapsedTime];
-#endif
-}
-
-void PageClientImpl::didChangeBackgroundColor()
-{
- notImplemented();
-}
-
-CGRect PageClientImpl::boundsOfLayerInLayerBackedWindowCoordinates(CALayer *layer) const
-{
- CALayer *windowContentLayer = static_cast<NSView *>(m_view.window.contentView).layer;
- ASSERT(windowContentLayer);
-
- return [windowContentLayer convertRect:layer.bounds fromLayer:layer];
-}
-
-void PageClientImpl::didPerformImmediateActionHitTest(const WebHitTestResultData& result, bool contentPreventsDefault, API::Object* userData)
-{
- m_impl->didPerformImmediateActionHitTest(result, contentPreventsDefault, userData);
-}
-
-void* PageClientImpl::immediateActionAnimationControllerForHitTestResult(RefPtr<API::HitTestResult> hitTestResult, uint64_t type, RefPtr<API::Object> userData)
-{
- return m_impl->immediateActionAnimationControllerForHitTestResult(hitTestResult.get(), type, userData.get());
-}
-
-void PageClientImpl::didHandleAcceptedCandidate()
-{
- m_impl->didHandleAcceptedCandidate();
-}
-
-void PageClientImpl::videoControlsManagerDidChange()
-{
- m_impl->videoControlsManagerDidChange();
-}
-
-void PageClientImpl::showPlatformContextMenu(NSMenu *menu, IntPoint location)
-{
- [menu popUpMenuPositioningItem:nil atLocation:location inView:m_view];
-}
-
-#if ENABLE(WIRELESS_PLAYBACK_TARGET)
-WebCore::WebMediaSessionManager& PageClientImpl::mediaSessionManager()
-{
- return WebMediaSessionManager::shared();
-}
-#endif
-
-void PageClientImpl::refView()
-{
- CFRetain(m_view);
-}
-
-void PageClientImpl::derefView()
-{
- CFRelease(m_view);
-}
-
-void PageClientImpl::startWindowDrag()
-{
- m_impl->startWindowDrag();
-}
-
-NSWindow *PageClientImpl::platformWindow()
-{
- return m_impl->window();
-}
-
-#if WK_API_ENABLED
-NSView *PageClientImpl::inspectorAttachmentView()
-{
- return m_impl->inspectorAttachmentView();
-}
-
-_WKRemoteObjectRegistry *PageClientImpl::remoteObjectRegistry()
-{
- return m_impl->remoteObjectRegistry();
-}
-#endif
-
-void PageClientImpl::didRestoreScrollPosition()
-{
- m_impl->didRestoreScrollPosition();
-}
-
-bool PageClientImpl::windowIsFrontWindowUnderMouse(const NativeWebMouseEvent& event)
-{
- return m_impl->windowIsFrontWindowUnderMouse(event.nativeEvent());
-}
-
-WebCore::UserInterfaceLayoutDirection PageClientImpl::userInterfaceLayoutDirection()
-{
- if (!m_view)
- return WebCore::UserInterfaceLayoutDirection::LTR;
- return (m_view.userInterfaceLayoutDirection == NSUserInterfaceLayoutDirectionLeftToRight) ? WebCore::UserInterfaceLayoutDirection::LTR : WebCore::UserInterfaceLayoutDirection::RTL;
-}
-
-} // namespace WebKit
-
-#endif // PLATFORM(MAC)
Copied: trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h (from rev 221489, trunk/Source/WebKit/UIProcess/mac/PageClientImpl.h) (0 => 221502)
--- trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h (rev 0)
+++ trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h 2017-09-01 22:19:26 UTC (rev 221502)
@@ -0,0 +1,257 @@
+/*
+ * Copyright (C) 2010, 2011, 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if PLATFORM(MAC)
+
+#include "CorrectionPanel.h"
+#include "PageClientImplCocoa.h"
+#include "WebFullScreenManagerProxy.h"
+#include <wtf/RetainPtr.h>
+
+@class WKEditorUndoTargetObjC;
+@class WKView;
+
+namespace WebCore {
+class AlternativeTextUIController;
+}
+
+namespace WebKit {
+
+class WebViewImpl;
+
+class PageClientImpl final : public PageClientImplCocoa
+#if ENABLE(FULLSCREEN_API)
+ , public WebFullScreenManagerProxyClient
+#endif
+ {
+public:
+ PageClientImpl(NSView *, WKWebView *);
+ virtual ~PageClientImpl();
+
+ // FIXME: Eventually WebViewImpl should become the PageClient.
+ void setImpl(WebViewImpl& impl) { m_impl = &impl; }
+
+ void viewWillMoveToAnotherWindow();
+
+private:
+ // PageClient
+ std::unique_ptr<DrawingAreaProxy> createDrawingAreaProxy() override;
+ void setViewNeedsDisplay(const WebCore::Region&) override;
+ void requestScroll(const WebCore::FloatPoint& scrollPosition, const WebCore::IntPoint& scrollOrigin, bool isProgrammaticScroll) override;
+ WebCore::FloatPoint viewScrollPosition() override;
+
+ WebCore::IntSize viewSize() override;
+ bool isViewWindowActive() override;
+ bool isViewFocused() override;
+ bool isViewVisible() override;
+ bool isViewVisibleOrOccluded() override;
+ bool isViewInWindow() override;
+ bool isVisuallyIdle() override;
+ LayerHostingMode viewLayerHostingMode() override;
+ ColorSpaceData colorSpace() override;
+ void setAcceleratedCompositingRootLayer(LayerOrView *) override;
+ LayerOrView *acceleratedCompositingRootLayer() const override;
+
+ void processDidExit() override;
+ void pageClosed() override;
+ void didRelaunchProcess() override;
+ void preferencesDidChange() override;
+ void toolTipChanged(const String& oldToolTip, const String& newToolTip) override;
+ void didCommitLoadForMainFrame(const String& mimeType, bool useCustomContentProvider) override;
+ void didFinishLoadingDataForCustomContentProvider(const String& suggestedFilename, const IPC::DataReference&) override;
+ void handleDownloadRequest(DownloadProxy*) override;
+ void didChangeContentSize(const WebCore::IntSize&) override;
+ void setCursor(const WebCore::Cursor&) override;
+ void setCursorHiddenUntilMouseMoves(bool) override;
+ void didChangeViewportProperties(const WebCore::ViewportAttributes&) override;
+
+ void registerEditCommand(Ref<WebEditCommandProxy>&&, WebPageProxy::UndoOrRedo) override;
+ void clearAllEditCommands() override;
+ bool canUndoRedo(WebPageProxy::UndoOrRedo) override;
+ void executeUndoRedo(WebPageProxy::UndoOrRedo) override;
+ bool executeSavedCommandBySelector(const String& selector) override;
+ void setDragImage(const WebCore::IntPoint& clientPosition, Ref<ShareableBitmap>&& dragImage, WebCore::DragSourceAction) override;
+ void setPromisedDataForImage(const String& pasteboardName, Ref<WebCore::SharedBuffer>&& imageBuffer, const String& filename, const String& extension, const String& title,
+ const String& url, const String& visibleUrl, RefPtr<WebCore::SharedBuffer>&& archiveBuffer) override;
+#if ENABLE(ATTACHMENT_ELEMENT)
+ void setPromisedDataForAttachment(const String& pasteboardName, const String& filename, const String& extension, const String& title, const String& url, const String& visibleUrl) override;
+#endif
+ void updateSecureInputState() override;
+ void resetSecureInputState() override;
+ void notifyInputContextAboutDiscardedComposition() override;
+ void selectionDidChange() override;
+
+ WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&) override;
+ WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&) override;
+ WebCore::IntPoint screenToRootView(const WebCore::IntPoint&) override;
+ WebCore::IntRect rootViewToScreen(const WebCore::IntRect&) override;
+#if PLATFORM(MAC)
+ WebCore::IntRect rootViewToWindow(const WebCore::IntRect&) override;
+#endif
+#if PLATFORM(IOS)
+ virtual WebCore::IntPoint accessibilityScreenToRootView(const WebCore::IntPoint&) = 0;
+ virtual WebCore::IntRect rootViewToAccessibilityScreen(const WebCore::IntRect&) = 0;
+#endif
+
+ CGRect boundsOfLayerInLayerBackedWindowCoordinates(CALayer *) const override;
+
+ void doneWithKeyEvent(const NativeWebKeyboardEvent&, bool wasEventHandled) override;
+
+ RefPtr<WebPopupMenuProxy> createPopupMenuProxy(WebPageProxy&) override;
+#if ENABLE(CONTEXT_MENUS)
+ RefPtr<WebContextMenuProxy> createContextMenuProxy(WebPageProxy&, const ContextMenuContextData&, const UserData&) override;
+#endif
+
+#if ENABLE(INPUT_TYPE_COLOR)
+ RefPtr<WebColorPicker> createColorPicker(WebPageProxy*, const WebCore::Color& initialColor, const WebCore::IntRect&) override;
+#endif
+
+ Ref<WebCore::ValidationBubble> createValidationBubble(const String& message, const WebCore::ValidationBubble::Settings&) final;
+
+ void setTextIndicator(Ref<WebCore::TextIndicator>, WebCore::TextIndicatorWindowLifetime) override;
+ void clearTextIndicator(WebCore::TextIndicatorWindowDismissalAnimation) override;
+ void setTextIndicatorAnimationProgress(float) override;
+
+ void enterAcceleratedCompositingMode(const LayerTreeContext&) override;
+ void exitAcceleratedCompositingMode() override;
+ void updateAcceleratedCompositingMode(const LayerTreeContext&) override;
+
+ RefPtr<ViewSnapshot> takeViewSnapshot() override;
+ void wheelEventWasNotHandledByWebCore(const NativeWebWheelEvent&) override;
+#if ENABLE(MAC_GESTURE_EVENTS)
+ void gestureEventWasNotHandledByWebCore(const NativeWebGestureEvent&) override;
+#endif
+
+ void accessibilityWebProcessTokenReceived(const IPC::DataReference&) override;
+
+ void pluginFocusOrWindowFocusChanged(uint64_t pluginComplexTextInputIdentifier, bool pluginHasFocusAndWindowHasFocus) override;
+ void setPluginComplexTextInputState(uint64_t pluginComplexTextInputIdentifier, PluginComplexTextInputState) override;
+
+ void makeFirstResponder() override;
+ void setShouldSuppressFirstResponderChanges(bool shouldSuppress) override { m_shouldSuppressFirstResponderChanges = shouldSuppress; }
+
+ void didPerformDictionaryLookup(const WebCore::DictionaryPopupInfo&) override;
+
+ void showCorrectionPanel(WebCore::AlternativeTextType, const WebCore::FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings) override;
+ void dismissCorrectionPanel(WebCore::ReasonForDismissingAlternativeText) override;
+ String dismissCorrectionPanelSoon(WebCore::ReasonForDismissingAlternativeText) override;
+ void recordAutocorrectionResponse(WebCore::AutocorrectionResponse, const String& replacedString, const String& replacementString) override;
+
+ void recommendedScrollbarStyleDidChange(WebCore::ScrollbarStyle) override;
+
+ void intrinsicContentSizeDidChange(const WebCore::IntSize& intrinsicContentSize) override;
+
+#if USE(DICTATION_ALTERNATIVES)
+ uint64_t addDictationAlternatives(const RetainPtr<NSTextAlternatives>&) override;
+ void removeDictationAlternatives(uint64_t dictationContext) override;
+ void showDictationAlternativeUI(const WebCore::FloatRect& boundingBoxOfDictatedText, uint64_t dictationContext) override;
+ Vector<String> dictationAlternatives(uint64_t dictationContext) override;
+#endif
+ void setEditableElementIsFocused(bool) override;
+
+#if USE(INSERTION_UNDO_GROUPING)
+ void registerInsertionUndoGrouping() override;
+#endif
+
+ // Auxiliary Client Creation
+#if ENABLE(FULLSCREEN_API)
+ WebFullScreenManagerProxyClient& fullScreenManagerProxyClient() override;
+#endif
+
+#if ENABLE(FULLSCREEN_API)
+ // WebFullScreenManagerProxyClient
+ void closeFullScreenManager() override;
+ bool isFullScreen() override;
+ void enterFullScreen() override;
+ void exitFullScreen() override;
+ void beganEnterFullScreen(const WebCore::IntRect& initialFrame, const WebCore::IntRect& finalFrame) override;
+ void beganExitFullScreen(const WebCore::IntRect& initialFrame, const WebCore::IntRect& finalFrame) override;
+#endif
+
+ void navigationGestureDidBegin() override;
+ void navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem&) override;
+ void navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem&) override;
+ void navigationGestureDidEnd() override;
+ void willRecordNavigationSnapshot(WebBackForwardListItem&) override;
+ void didRemoveNavigationGestureSnapshot() override;
+
+ NSView *activeView() const;
+ NSWindow *activeWindow() const;
+
+ void didFirstVisuallyNonEmptyLayoutForMainFrame() override;
+ void didFinishLoadForMainFrame() override;
+ void didFailLoadForMainFrame() override;
+ void didSameDocumentNavigationForMainFrame(SameDocumentNavigationType) override;
+ void handleControlledElementIDResponse(const String&) override;
+ void handleActiveNowPlayingSessionInfoResponse(bool hasActiveSession, const String& title, double duration, double elapsedTime) override;
+
+ void didPerformImmediateActionHitTest(const WebHitTestResultData&, bool contentPreventsDefault, API::Object*) override;
+ void* immediateActionAnimationControllerForHitTestResult(RefPtr<API::HitTestResult>, uint64_t, RefPtr<API::Object>) override;
+
+ void didHandleAcceptedCandidate() override;
+
+ void videoControlsManagerDidChange() override;
+
+ void showPlatformContextMenu(NSMenu *, WebCore::IntPoint) override;
+
+ void didChangeBackgroundColor() override;
+
+ void startWindowDrag() override;
+ NSWindow *platformWindow() override;
+
+ WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection() override;
+
+#if WK_API_ENABLED
+ NSView *inspectorAttachmentView() override;
+ _WKRemoteObjectRegistry *remoteObjectRegistry() override;
+#endif
+
+ NSView *m_view;
+ WebViewImpl* m_impl { nullptr };
+#if USE(AUTOCORRECTION_PANEL)
+ CorrectionPanel m_correctionPanel;
+#endif
+#if USE(DICTATION_ALTERNATIVES)
+ std::unique_ptr<WebCore::AlternativeTextUIController> m_alternativeTextUIController;
+#endif
+
+ bool m_shouldSuppressFirstResponderChanges { false };
+
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+ WebCore::WebMediaSessionManager& mediaSessionManager() override;
+#endif
+
+ void refView() override;
+ void derefView() override;
+
+ void didRestoreScrollPosition() override;
+ bool windowIsFrontWindowUnderMouse(const NativeWebMouseEvent&) override;
+};
+
+} // namespace WebKit
+
+#endif // PLATFORM(MAC)
Copied: trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm (from rev 221467, trunk/Source/WebKit/UIProcess/mac/PageClientImpl.mm) (0 => 221502)
--- trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm (rev 0)
+++ trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm 2017-09-01 22:19:26 UTC (rev 221502)
@@ -0,0 +1,886 @@
+/*
+ * Copyright (C) 2010, 2011, 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "PageClientImplMac.h"
+
+#if PLATFORM(MAC)
+
+#import "APIHitTestResult.h"
+#import "ColorSpaceData.h"
+#import "DataReference.h"
+#import "DownloadProxy.h"
+#import "DrawingAreaProxy.h"
+#import "NativeWebGestureEvent.h"
+#import "NativeWebKeyboardEvent.h"
+#import "NativeWebMouseEvent.h"
+#import "NativeWebWheelEvent.h"
+#import "NavigationState.h"
+#import "StringUtilities.h"
+#import "ViewGestureController.h"
+#import "ViewSnapshotStore.h"
+#import "WKAPICast.h"
+#import "WKFullScreenWindowController.h"
+#import "WKStringCF.h"
+#import "WKViewInternal.h"
+#import "WKWebViewInternal.h"
+#import "WebColorPickerMac.h"
+#import "WebContextMenuProxyMac.h"
+#import "WebEditCommandProxy.h"
+#import "WebPopupMenuProxyMac.h"
+#import "WebViewImpl.h"
+#import "WindowServerConnection.h"
+#import "_WKDownloadInternal.h"
+#import "_WKHitTestResultInternal.h"
+#import "_WKThumbnailView.h"
+#import <WebCore/AlternativeTextUIController.h>
+#import <WebCore/BitmapImage.h>
+#import <WebCore/Cursor.h>
+#import <WebCore/DictionaryLookup.h>
+#import <WebCore/FloatRect.h>
+#import <WebCore/GraphicsContext.h>
+#import <WebCore/Image.h>
+#import <WebCore/KeyboardEvent.h>
+#import <WebCore/NotImplemented.h>
+#import <WebCore/SharedBuffer.h>
+#import <WebCore/TextIndicator.h>
+#import <WebCore/TextIndicatorWindow.h>
+#import <WebCore/TextUndoInsertionMarkupMac.h>
+#import <WebCore/ValidationBubble.h>
+#import <WebKitSystemInterface.h>
+#import <wtf/text/CString.h>
+#import <wtf/text/WTFString.h>
+
+#if USE(DICTATION_ALTERNATIVES)
+#import <AppKit/NSTextAlternatives.h>
+#endif
+
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+#include <WebCore/WebMediaSessionManager.h>
+#endif
+
+@interface NSApplication (WebNSApplicationDetails)
+- (NSCursor *)_cursorRectCursor;
+@end
+
+#if HAVE(OUT_OF_PROCESS_LAYER_HOSTING)
+@interface NSWindow (WebNSWindowDetails)
+- (BOOL)_hostsLayersInWindowServer;
+@end
+#endif
+
+using namespace WebCore;
+using namespace WebKit;
+
+namespace WebKit {
+
+PageClientImpl::PageClientImpl(NSView* view, WKWebView *webView)
+ : PageClientImplCocoa(webView)
+ , m_view(view)
+#if USE(DICTATION_ALTERNATIVES)
+ , m_alternativeTextUIController(std::make_unique<AlternativeTextUIController>())
+#endif
+{
+#if !WK_API_ENABLED
+ ASSERT_UNUSED(m_webView, !m_webView);
+#endif
+}
+
+PageClientImpl::~PageClientImpl()
+{
+}
+
+std::unique_ptr<DrawingAreaProxy> PageClientImpl::createDrawingAreaProxy()
+{
+ return m_impl->createDrawingAreaProxy();
+}
+
+void PageClientImpl::setViewNeedsDisplay(const WebCore::Region&)
+{
+ ASSERT_NOT_REACHED();
+}
+
+void PageClientImpl::requestScroll(const FloatPoint& scrollPosition, const IntPoint& scrollOrigin, bool isProgrammaticScroll)
+{
+}
+
+WebCore::FloatPoint PageClientImpl::viewScrollPosition()
+{
+ return { };
+}
+
+IntSize PageClientImpl::viewSize()
+{
+ return IntSize([m_view bounds].size);
+}
+
+NSView *PageClientImpl::activeView() const
+{
+#if WK_API_ENABLED
+ return (m_impl && m_impl->thumbnailView()) ? (NSView *)m_impl->thumbnailView() : m_view;
+#else
+ return m_view;
+#endif
+}
+
+NSWindow *PageClientImpl::activeWindow() const
+{
+#if WK_API_ENABLED
+ if (m_impl && m_impl->thumbnailView())
+ return m_impl->thumbnailView().window;
+#endif
+ if (m_impl && m_impl->targetWindowForMovePreparation())
+ return m_impl->targetWindowForMovePreparation();
+ return m_view.window;
+}
+
+bool PageClientImpl::isViewWindowActive()
+{
+ NSWindow *activeViewWindow = activeWindow();
+ return activeViewWindow.isKeyWindow || [NSApp keyWindow] == activeViewWindow;
+}
+
+bool PageClientImpl::isViewFocused()
+{
+ // FIXME: This is called from the WebPageProxy constructor before we have a WebViewImpl.
+ // Once WebViewImpl and PageClient merge, this won't be a problem.
+ if (!m_impl)
+ return NO;
+
+ return m_impl->isFocused();
+}
+
+void PageClientImpl::makeFirstResponder()
+{
+ if (m_shouldSuppressFirstResponderChanges)
+ return;
+
+ [[m_view window] makeFirstResponder:m_view];
+}
+
+bool PageClientImpl::isViewVisible()
+{
+ NSView *activeView = this->activeView();
+ NSWindow *activeViewWindow = activeWindow();
+
+ if (!activeViewWindow)
+ return false;
+
+ if (!activeViewWindow.isVisible)
+ return false;
+
+ if (activeView.isHiddenOrHasHiddenAncestor)
+ return false;
+
+ if (m_impl->windowOcclusionDetectionEnabled() && (activeViewWindow.occlusionState & NSWindowOcclusionStateVisible) != NSWindowOcclusionStateVisible)
+ return false;
+
+ return true;
+}
+
+bool PageClientImpl::isViewVisibleOrOccluded()
+{
+ return activeWindow().isVisible;
+}
+
+bool PageClientImpl::isViewInWindow()
+{
+ return activeWindow();
+}
+
+bool PageClientImpl::isVisuallyIdle()
+{
+ return WindowServerConnection::singleton().applicationWindowModificationsHaveStopped() || !isViewVisible();
+}
+
+LayerHostingMode PageClientImpl::viewLayerHostingMode()
+{
+#if HAVE(OUT_OF_PROCESS_LAYER_HOSTING)
+ if ([activeWindow() _hostsLayersInWindowServer])
+ return LayerHostingMode::OutOfProcess;
+#endif
+ return LayerHostingMode::InProcess;
+}
+
+void PageClientImpl::viewWillMoveToAnotherWindow()
+{
+ clearAllEditCommands();
+}
+
+ColorSpaceData PageClientImpl::colorSpace()
+{
+ return m_impl->colorSpace();
+}
+
+void PageClientImpl::processDidExit()
+{
+ m_impl->processDidExit();
+}
+
+void PageClientImpl::pageClosed()
+{
+ m_impl->pageClosed();
+#if USE(DICTATION_ALTERNATIVES)
+ m_alternativeTextUIController->clear();
+#endif
+}
+
+void PageClientImpl::didRelaunchProcess()
+{
+ m_impl->didRelaunchProcess();
+}
+
+void PageClientImpl::preferencesDidChange()
+{
+ m_impl->preferencesDidChange();
+}
+
+void PageClientImpl::toolTipChanged(const String& oldToolTip, const String& newToolTip)
+{
+ m_impl->toolTipChanged(oldToolTip, newToolTip);
+}
+
+void PageClientImpl::didCommitLoadForMainFrame(const String& mimeType, bool useCustomContentProvider)
+{
+ m_impl->updateSupportsArbitraryLayoutModes();
+ m_impl->dismissContentRelativeChildWindowsWithAnimation(true);
+}
+
+void PageClientImpl::didFinishLoadingDataForCustomContentProvider(const String& suggestedFilename, const IPC::DataReference& dataReference)
+{
+}
+
+void PageClientImpl::handleDownloadRequest(DownloadProxy* download)
+{
+ ASSERT_ARG(download, download);
+#if WK_API_ENABLED
+ ASSERT([download->wrapper() isKindOfClass:[_WKDownload class]]);
+ [static_cast<_WKDownload *>(download->wrapper()) setOriginatingWebView:m_webView];
+#endif
+}
+
+void PageClientImpl::didChangeContentSize(const WebCore::IntSize& newSize)
+{
+ m_impl->didChangeContentSize(newSize);
+}
+
+void PageClientImpl::setCursor(const WebCore::Cursor& cursor)
+{
+ // FIXME: Would be nice to share this code with WebKit1's WebChromeClient.
+
+ // The Web process may have asked to change the cursor when the view was in an active window, but
+ // if it is no longer in a window or the window is not active, then the cursor should not change.
+ if (!isViewWindowActive())
+ return;
+
+ if ([NSApp _cursorRectCursor])
+ return;
+
+ if (!m_view)
+ return;
+
+ NSWindow *window = [m_view window];
+ if (!window)
+ return;
+
+ if ([window windowNumber] != [NSWindow windowNumberAtPoint:[NSEvent mouseLocation] belowWindowWithWindowNumber:0])
+ return;
+
+ NSCursor *platformCursor = cursor.platformCursor();
+ if ([NSCursor currentCursor] == platformCursor)
+ return;
+
+ [platformCursor set];
+}
+
+void PageClientImpl::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
+{
+ [NSCursor setHiddenUntilMouseMoves:hiddenUntilMouseMoves];
+}
+
+void PageClientImpl::didChangeViewportProperties(const WebCore::ViewportAttributes&)
+{
+}
+
+void PageClientImpl::registerEditCommand(Ref<WebEditCommandProxy>&& command, WebPageProxy::UndoOrRedo undoOrRedo)
+{
+ m_impl->registerEditCommand(WTFMove(command), undoOrRedo);
+}
+
+#if USE(INSERTION_UNDO_GROUPING)
+void PageClientImpl::registerInsertionUndoGrouping()
+{
+ registerInsertionUndoGroupingWithUndoManager([m_view undoManager]);
+}
+#endif
+
+void PageClientImpl::clearAllEditCommands()
+{
+ m_impl->clearAllEditCommands();
+}
+
+bool PageClientImpl::canUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
+{
+ return (undoOrRedo == WebPageProxy::Undo) ? [[m_view undoManager] canUndo] : [[m_view undoManager] canRedo];
+}
+
+void PageClientImpl::executeUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
+{
+ return (undoOrRedo == WebPageProxy::Undo) ? [[m_view undoManager] undo] : [[m_view undoManager] redo];
+}
+
+void PageClientImpl::setDragImage(const IntPoint& clientPosition, Ref<ShareableBitmap>&& dragImage, DragSourceAction action)
+{
+ RetainPtr<CGImageRef> dragCGImage = dragImage->makeCGImage();
+ RetainPtr<NSImage> dragNSImage = adoptNS([[NSImage alloc] initWithCGImage:dragCGImage.get() size:dragImage->size()]);
+ IntSize size([dragNSImage size]);
+ size.scale(1.0 / m_impl->page().deviceScaleFactor());
+ [dragNSImage setSize:size];
+
+ m_impl->dragImageForView(m_view, dragNSImage.get(), clientPosition, action == DragSourceActionLink);
+}
+
+void PageClientImpl::setPromisedDataForImage(const String& pasteboardName, Ref<SharedBuffer>&& imageBuffer, const String& filename, const String& extension, const String& title, const String& url, const String& visibleURL, RefPtr<SharedBuffer>&& archiveBuffer)
+{
+ RefPtr<Image> image = BitmapImage::create();
+ image->setData(WTFMove(imageBuffer), true);
+ m_impl->setPromisedDataForImage(image.get(), filename, extension, title, url, visibleURL, archiveBuffer.get(), pasteboardName);
+}
+
+#if ENABLE(ATTACHMENT_ELEMENT)
+void PageClientImpl::setPromisedDataForAttachment(const String& pasteboardName, const String& filename, const String& extension, const String& title, const String& url, const String& visibleURL)
+{
+ m_impl->setPromisedDataForAttachment(filename, extension, title, url, visibleURL, pasteboardName);
+}
+#endif
+
+void PageClientImpl::updateSecureInputState()
+{
+ m_impl->updateSecureInputState();
+}
+
+void PageClientImpl::resetSecureInputState()
+{
+ m_impl->resetSecureInputState();
+}
+
+void PageClientImpl::notifyInputContextAboutDiscardedComposition()
+{
+ m_impl->notifyInputContextAboutDiscardedComposition();
+}
+
+FloatRect PageClientImpl::convertToDeviceSpace(const FloatRect& rect)
+{
+ return toDeviceSpace(rect, [m_view window]);
+}
+
+FloatRect PageClientImpl::convertToUserSpace(const FloatRect& rect)
+{
+ return toUserSpace(rect, [m_view window]);
+}
+
+IntPoint PageClientImpl::screenToRootView(const IntPoint& point)
+{
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+ NSPoint windowCoord = [[m_view window] convertScreenToBase:point];
+#pragma clang diagnostic pop
+ return IntPoint([m_view convertPoint:windowCoord fromView:nil]);
+}
+
+IntRect PageClientImpl::rootViewToScreen(const IntRect& rect)
+{
+ NSRect tempRect = rect;
+ tempRect = [m_view convertRect:tempRect toView:nil];
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+ tempRect.origin = [[m_view window] convertBaseToScreen:tempRect.origin];
+#pragma clang diagnostic pop
+ return enclosingIntRect(tempRect);
+}
+
+IntRect PageClientImpl::rootViewToWindow(const WebCore::IntRect& rect)
+{
+ NSRect tempRect = rect;
+ tempRect = [m_view convertRect:tempRect toView:nil];
+ return enclosingIntRect(tempRect);
+}
+
+void PageClientImpl::doneWithKeyEvent(const NativeWebKeyboardEvent& event, bool eventWasHandled)
+{
+ m_impl->doneWithKeyEvent(event.nativeEvent(), eventWasHandled);
+}
+
+RefPtr<WebPopupMenuProxy> PageClientImpl::createPopupMenuProxy(WebPageProxy& page)
+{
+ return WebPopupMenuProxyMac::create(m_view, page);
+}
+
+#if ENABLE(CONTEXT_MENUS)
+RefPtr<WebContextMenuProxy> PageClientImpl::createContextMenuProxy(WebPageProxy& page, const ContextMenuContextData& context, const UserData& userData)
+{
+ return WebContextMenuProxyMac::create(m_view, page, context, userData);
+}
+#endif
+
+#if ENABLE(INPUT_TYPE_COLOR)
+RefPtr<WebColorPicker> PageClientImpl::createColorPicker(WebPageProxy* page, const WebCore::Color& initialColor, const WebCore::IntRect& rect)
+{
+ return WebColorPickerMac::create(page, initialColor, rect, m_view);
+}
+#endif
+
+Ref<ValidationBubble> PageClientImpl::createValidationBubble(const String& message, const ValidationBubble::Settings& settings)
+{
+ return ValidationBubble::create(m_view, message, settings);
+}
+
+void PageClientImpl::setTextIndicator(Ref<TextIndicator> textIndicator, WebCore::TextIndicatorWindowLifetime lifetime)
+{
+ m_impl->setTextIndicator(textIndicator.get(), lifetime);
+}
+
+void PageClientImpl::clearTextIndicator(WebCore::TextIndicatorWindowDismissalAnimation dismissalAnimation)
+{
+ m_impl->clearTextIndicatorWithAnimation(dismissalAnimation);
+}
+
+void PageClientImpl::setTextIndicatorAnimationProgress(float progress)
+{
+ m_impl->setTextIndicatorAnimationProgress(progress);
+}
+
+void PageClientImpl::accessibilityWebProcessTokenReceived(const IPC::DataReference& data)
+{
+ m_impl->setAccessibilityWebProcessToken([NSData dataWithBytes:data.data() length:data.size()]);
+}
+
+void PageClientImpl::enterAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext)
+{
+ ASSERT(!layerTreeContext.isEmpty());
+
+ CALayer *renderLayer = WKMakeRenderLayer(layerTreeContext.contextID);
+ m_impl->setAcceleratedCompositingRootLayer(renderLayer);
+}
+
+void PageClientImpl::exitAcceleratedCompositingMode()
+{
+ m_impl->setAcceleratedCompositingRootLayer(nil);
+}
+
+void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext)
+{
+ ASSERT(!layerTreeContext.isEmpty());
+
+ CALayer *renderLayer = WKMakeRenderLayer(layerTreeContext.contextID);
+ m_impl->setAcceleratedCompositingRootLayer(renderLayer);
+}
+
+void PageClientImpl::setAcceleratedCompositingRootLayer(CALayer *rootLayer)
+{
+ m_impl->setAcceleratedCompositingRootLayer(rootLayer);
+}
+
+CALayer *PageClientImpl::acceleratedCompositingRootLayer() const
+{
+ return m_impl->acceleratedCompositingRootLayer();
+}
+
+RefPtr<ViewSnapshot> PageClientImpl::takeViewSnapshot()
+{
+ return m_impl->takeViewSnapshot();
+}
+
+void PageClientImpl::selectionDidChange()
+{
+ m_impl->selectionDidChange();
+}
+
+void PageClientImpl::wheelEventWasNotHandledByWebCore(const NativeWebWheelEvent& event)
+{
+ if (auto gestureController = m_impl->gestureController())
+ gestureController->wheelEventWasNotHandledByWebCore(event.nativeEvent());
+}
+
+#if ENABLE(MAC_GESTURE_EVENTS)
+void PageClientImpl::gestureEventWasNotHandledByWebCore(const NativeWebGestureEvent& event)
+{
+ m_impl->gestureEventWasNotHandledByWebCore(event.nativeEvent());
+}
+#endif
+
+void PageClientImpl::pluginFocusOrWindowFocusChanged(uint64_t pluginComplexTextInputIdentifier, bool pluginHasFocusAndWindowHasFocus)
+{
+ m_impl->pluginFocusOrWindowFocusChanged(pluginHasFocusAndWindowHasFocus, pluginComplexTextInputIdentifier);
+}
+
+void PageClientImpl::setPluginComplexTextInputState(uint64_t pluginComplexTextInputIdentifier, PluginComplexTextInputState pluginComplexTextInputState)
+{
+ m_impl->setPluginComplexTextInputStateAndIdentifier(pluginComplexTextInputState, pluginComplexTextInputIdentifier);
+}
+
+void PageClientImpl::didPerformDictionaryLookup(const DictionaryPopupInfo& dictionaryPopupInfo)
+{
+ m_impl->prepareForDictionaryLookup();
+
+ DictionaryLookup::showPopup(dictionaryPopupInfo, m_view, [this](TextIndicator& textIndicator) {
+ m_impl->setTextIndicator(textIndicator, TextIndicatorWindowLifetime::Permanent);
+ });
+}
+
+void PageClientImpl::showCorrectionPanel(AlternativeTextType type, const FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings)
+{
+#if USE(AUTOCORRECTION_PANEL)
+ if (!isViewVisible() || !isViewInWindow())
+ return;
+ m_correctionPanel.show(m_view, *m_impl, type, boundingBoxOfReplacedString, replacedString, replacementString, alternativeReplacementStrings);
+#endif
+}
+
+void PageClientImpl::dismissCorrectionPanel(ReasonForDismissingAlternativeText reason)
+{
+#if USE(AUTOCORRECTION_PANEL)
+ m_correctionPanel.dismiss(reason);
+#endif
+}
+
+String PageClientImpl::dismissCorrectionPanelSoon(WebCore::ReasonForDismissingAlternativeText reason)
+{
+#if USE(AUTOCORRECTION_PANEL)
+ return m_correctionPanel.dismiss(reason);
+#else
+ return String();
+#endif
+}
+
+static inline NSCorrectionResponse toCorrectionResponse(AutocorrectionResponse response)
+{
+ switch (response) {
+ case WebCore::AutocorrectionResponse::Reverted:
+ return NSCorrectionResponseReverted;
+ case WebCore::AutocorrectionResponse::Edited:
+ return NSCorrectionResponseEdited;
+ case WebCore::AutocorrectionResponse::Accepted:
+ return NSCorrectionResponseAccepted;
+ }
+
+ ASSERT_NOT_REACHED();
+ return NSCorrectionResponseAccepted;
+}
+
+void PageClientImpl::recordAutocorrectionResponse(AutocorrectionResponse response, const String& replacedString, const String& replacementString)
+{
+ CorrectionPanel::recordAutocorrectionResponse(m_impl->spellCheckerDocumentTag(), toCorrectionResponse(response), replacedString, replacementString);
+}
+
+void PageClientImpl::recommendedScrollbarStyleDidChange(ScrollbarStyle newStyle)
+{
+ // Now re-create a tracking area with the appropriate options given the new scrollbar style
+ NSTrackingAreaOptions options = NSTrackingMouseMoved | NSTrackingMouseEnteredAndExited | NSTrackingInVisibleRect | NSTrackingCursorUpdate;
+ if (newStyle == ScrollbarStyle::AlwaysVisible)
+ options |= NSTrackingActiveAlways;
+ else
+ options |= NSTrackingActiveInKeyWindow;
+
+ RetainPtr<NSTrackingArea> trackingArea = adoptNS([[NSTrackingArea alloc] initWithRect:[m_view frame] options:options owner:m_view userInfo:nil]);
+ m_impl->setPrimaryTrackingArea(trackingArea.get());
+}
+
+void PageClientImpl::intrinsicContentSizeDidChange(const IntSize& intrinsicContentSize)
+{
+ m_impl->setIntrinsicContentSize(intrinsicContentSize);
+}
+
+bool PageClientImpl::executeSavedCommandBySelector(const String& selectorString)
+{
+ return m_impl->executeSavedCommandBySelector(NSSelectorFromString(selectorString));
+}
+
+#if USE(DICTATION_ALTERNATIVES)
+uint64_t PageClientImpl::addDictationAlternatives(const RetainPtr<NSTextAlternatives>& alternatives)
+{
+ return m_alternativeTextUIController->addAlternatives(alternatives);
+}
+
+void PageClientImpl::removeDictationAlternatives(uint64_t dictationContext)
+{
+ m_alternativeTextUIController->removeAlternatives(dictationContext);
+}
+
+void PageClientImpl::showDictationAlternativeUI(const WebCore::FloatRect& boundingBoxOfDictatedText, uint64_t dictationContext)
+{
+ if (!isViewVisible() || !isViewInWindow())
+ return;
+ m_alternativeTextUIController->showAlternatives(m_view, boundingBoxOfDictatedText, dictationContext, ^(NSString *acceptedAlternative) {
+ m_impl->handleAcceptedAlternativeText(acceptedAlternative);
+ });
+}
+
+Vector<String> PageClientImpl::dictationAlternatives(uint64_t dictationContext)
+{
+ return m_alternativeTextUIController->alternativesForContext(dictationContext);
+}
+#endif
+
+void PageClientImpl::setEditableElementIsFocused(bool editableElementIsFocused)
+{
+ m_impl->setEditableElementIsFocused(editableElementIsFocused);
+}
+
+#if ENABLE(FULLSCREEN_API)
+
+WebFullScreenManagerProxyClient& PageClientImpl::fullScreenManagerProxyClient()
+{
+ return *this;
+}
+
+// WebFullScreenManagerProxyClient
+
+void PageClientImpl::closeFullScreenManager()
+{
+ m_impl->closeFullScreenWindowController();
+}
+
+bool PageClientImpl::isFullScreen()
+{
+ if (!m_impl->hasFullScreenWindowController())
+ return false;
+
+ return m_impl->fullScreenWindowController().isFullScreen;
+}
+
+void PageClientImpl::enterFullScreen()
+{
+ [m_impl->fullScreenWindowController() enterFullScreen:nil];
+}
+
+void PageClientImpl::exitFullScreen()
+{
+ [m_impl->fullScreenWindowController() exitFullScreen];
+}
+
+void PageClientImpl::beganEnterFullScreen(const IntRect& initialFrame, const IntRect& finalFrame)
+{
+ [m_impl->fullScreenWindowController() beganEnterFullScreenWithInitialFrame:initialFrame finalFrame:finalFrame];
+ m_impl->updateSupportsArbitraryLayoutModes();
+}
+
+void PageClientImpl::beganExitFullScreen(const IntRect& initialFrame, const IntRect& finalFrame)
+{
+ [m_impl->fullScreenWindowController() beganExitFullScreenWithInitialFrame:initialFrame finalFrame:finalFrame];
+ m_impl->updateSupportsArbitraryLayoutModes();
+}
+
+#endif // ENABLE(FULLSCREEN_API)
+
+void PageClientImpl::navigationGestureDidBegin()
+{
+ m_impl->dismissContentRelativeChildWindowsWithAnimation(true);
+
+#if WK_API_ENABLED
+ if (m_webView)
+ NavigationState::fromWebPage(*m_webView->_page).navigationGestureDidBegin();
+#endif
+}
+
+void PageClientImpl::navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem& item)
+{
+#if WK_API_ENABLED
+ if (m_webView)
+ NavigationState::fromWebPage(*m_webView->_page).navigationGestureWillEnd(willNavigate, item);
+#else
+ UNUSED_PARAM(willNavigate);
+ UNUSED_PARAM(item);
+#endif
+}
+
+void PageClientImpl::navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem& item)
+{
+#if WK_API_ENABLED
+ if (m_webView)
+ NavigationState::fromWebPage(*m_webView->_page).navigationGestureDidEnd(willNavigate, item);
+#else
+ UNUSED_PARAM(willNavigate);
+ UNUSED_PARAM(item);
+#endif
+}
+
+void PageClientImpl::navigationGestureDidEnd()
+{
+}
+
+void PageClientImpl::willRecordNavigationSnapshot(WebBackForwardListItem& item)
+{
+#if WK_API_ENABLED
+ if (m_webView)
+ NavigationState::fromWebPage(*m_webView->_page).willRecordNavigationSnapshot(item);
+#else
+ UNUSED_PARAM(item);
+#endif
+}
+
+void PageClientImpl::didRemoveNavigationGestureSnapshot()
+{
+#if WK_API_ENABLED
+ if (m_webView)
+ NavigationState::fromWebPage(*m_webView->_page).navigationGestureSnapshotWasRemoved();
+#endif
+}
+
+void PageClientImpl::didFirstVisuallyNonEmptyLayoutForMainFrame()
+{
+ if (auto gestureController = m_impl->gestureController())
+ gestureController->didFirstVisuallyNonEmptyLayoutForMainFrame();
+}
+
+void PageClientImpl::didFinishLoadForMainFrame()
+{
+ if (auto gestureController = m_impl->gestureController())
+ gestureController->didFinishLoadForMainFrame();
+}
+
+void PageClientImpl::didFailLoadForMainFrame()
+{
+ if (auto gestureController = m_impl->gestureController())
+ gestureController->didFailLoadForMainFrame();
+}
+
+void PageClientImpl::didSameDocumentNavigationForMainFrame(SameDocumentNavigationType type)
+{
+ if (auto gestureController = m_impl->gestureController())
+ gestureController->didSameDocumentNavigationForMainFrame(type);
+}
+
+void PageClientImpl::handleControlledElementIDResponse(const String& identifier)
+{
+#if WK_API_ENABLED
+ [m_webView _handleControlledElementIDResponse:nsStringFromWebCoreString(identifier)];
+#endif
+}
+
+void PageClientImpl::handleActiveNowPlayingSessionInfoResponse(bool hasActiveSession, const String& title, double duration, double elapsedTime)
+{
+#if WK_API_ENABLED
+ [m_webView _handleActiveNowPlayingSessionInfoResponse:hasActiveSession title:nsStringFromWebCoreString(title) duration:duration elapsedTime:elapsedTime];
+#endif
+}
+
+void PageClientImpl::didChangeBackgroundColor()
+{
+ notImplemented();
+}
+
+CGRect PageClientImpl::boundsOfLayerInLayerBackedWindowCoordinates(CALayer *layer) const
+{
+ CALayer *windowContentLayer = static_cast<NSView *>(m_view.window.contentView).layer;
+ ASSERT(windowContentLayer);
+
+ return [windowContentLayer convertRect:layer.bounds fromLayer:layer];
+}
+
+void PageClientImpl::didPerformImmediateActionHitTest(const WebHitTestResultData& result, bool contentPreventsDefault, API::Object* userData)
+{
+ m_impl->didPerformImmediateActionHitTest(result, contentPreventsDefault, userData);
+}
+
+void* PageClientImpl::immediateActionAnimationControllerForHitTestResult(RefPtr<API::HitTestResult> hitTestResult, uint64_t type, RefPtr<API::Object> userData)
+{
+ return m_impl->immediateActionAnimationControllerForHitTestResult(hitTestResult.get(), type, userData.get());
+}
+
+void PageClientImpl::didHandleAcceptedCandidate()
+{
+ m_impl->didHandleAcceptedCandidate();
+}
+
+void PageClientImpl::videoControlsManagerDidChange()
+{
+ m_impl->videoControlsManagerDidChange();
+}
+
+void PageClientImpl::showPlatformContextMenu(NSMenu *menu, IntPoint location)
+{
+ [menu popUpMenuPositioningItem:nil atLocation:location inView:m_view];
+}
+
+#if ENABLE(WIRELESS_PLAYBACK_TARGET)
+WebCore::WebMediaSessionManager& PageClientImpl::mediaSessionManager()
+{
+ return WebMediaSessionManager::shared();
+}
+#endif
+
+void PageClientImpl::refView()
+{
+ CFRetain(m_view);
+}
+
+void PageClientImpl::derefView()
+{
+ CFRelease(m_view);
+}
+
+void PageClientImpl::startWindowDrag()
+{
+ m_impl->startWindowDrag();
+}
+
+NSWindow *PageClientImpl::platformWindow()
+{
+ return m_impl->window();
+}
+
+#if WK_API_ENABLED
+NSView *PageClientImpl::inspectorAttachmentView()
+{
+ return m_impl->inspectorAttachmentView();
+}
+
+_WKRemoteObjectRegistry *PageClientImpl::remoteObjectRegistry()
+{
+ return m_impl->remoteObjectRegistry();
+}
+#endif
+
+void PageClientImpl::didRestoreScrollPosition()
+{
+ m_impl->didRestoreScrollPosition();
+}
+
+bool PageClientImpl::windowIsFrontWindowUnderMouse(const NativeWebMouseEvent& event)
+{
+ return m_impl->windowIsFrontWindowUnderMouse(event.nativeEvent());
+}
+
+WebCore::UserInterfaceLayoutDirection PageClientImpl::userInterfaceLayoutDirection()
+{
+ if (!m_view)
+ return WebCore::UserInterfaceLayoutDirection::LTR;
+ return (m_view.userInterfaceLayoutDirection == NSUserInterfaceLayoutDirectionLeftToRight) ? WebCore::UserInterfaceLayoutDirection::LTR : WebCore::UserInterfaceLayoutDirection::RTL;
+}
+
+} // namespace WebKit
+
+#endif // PLATFORM(MAC)
Modified: trunk/Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm (221501 => 221502)
--- trunk/Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm 2017-09-01 22:16:01 UTC (rev 221501)
+++ trunk/Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm 2017-09-01 22:19:26 UTC (rev 221502)
@@ -31,7 +31,7 @@
#import "APIContextMenuClient.h"
#import "DataReference.h"
#import "MenuUtilities.h"
-#import "PageClientImpl.h"
+#import "PageClientImplMac.h"
#import "ServicesController.h"
#import "ShareableBitmap.h"
#import "StringUtilities.h"
Modified: trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm (221501 => 221502)
--- trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm 2017-09-01 22:16:01 UTC (rev 221501)
+++ trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm 2017-09-01 22:19:26 UTC (rev 221502)
@@ -37,7 +37,7 @@
#import "MenuUtilities.h"
#import "NativeWebKeyboardEvent.h"
#import "PageClient.h"
-#import "PageClientImpl.h"
+#import "PageClientImplMac.h"
#import "PluginComplexTextInputState.h"
#import "StringUtilities.h"
#import "TextChecker.h"
Modified: trunk/Source/WebKit/UIProcess/mac/WebPopupMenuProxyMac.mm (221501 => 221502)
--- trunk/Source/WebKit/UIProcess/mac/WebPopupMenuProxyMac.mm 2017-09-01 22:16:01 UTC (rev 221501)
+++ trunk/Source/WebKit/UIProcess/mac/WebPopupMenuProxyMac.mm 2017-09-01 22:19:26 UTC (rev 221502)
@@ -29,7 +29,7 @@
#if USE(APPKIT)
#import "NativeWebMouseEvent.h"
-#import "PageClientImpl.h"
+#import "PageClientImplMac.h"
#import "PlatformPopupMenuData.h"
#import "StringUtilities.h"
#import "WebPopupItem.h"
Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (221501 => 221502)
--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2017-09-01 22:16:01 UTC (rev 221501)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2017-09-01 22:19:26 UTC (rev 221502)
@@ -104,8 +104,8 @@
0FCB4E5118BBE044000FCFC9 /* WKGeolocationProviderIOSObjCSecurityOrigin.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0FCB4E4118BBE044000FCFC9 /* WKGeolocationProviderIOSObjCSecurityOrigin.mm */; };
0FCB4E5418BBE044000FCFC9 /* WKScrollView.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FCB4E4418BBE044000FCFC9 /* WKScrollView.h */; };
0FCB4E5518BBE044000FCFC9 /* WKScrollView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0FCB4E4518BBE044000FCFC9 /* WKScrollView.mm */; };
- 0FCB4E6218BBE3D9000FCFC9 /* PageClientImpl.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FCB4E5818BBE3D9000FCFC9 /* PageClientImpl.h */; };
- 0FCB4E6318BBE3D9000FCFC9 /* PageClientImpl.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0FCB4E5918BBE3D9000FCFC9 /* PageClientImpl.mm */; };
+ 0FCB4E6218BBE3D9000FCFC9 /* PageClientImplMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FCB4E5818BBE3D9000FCFC9 /* PageClientImplMac.h */; };
+ 0FCB4E6318BBE3D9000FCFC9 /* PageClientImplMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0FCB4E5918BBE3D9000FCFC9 /* PageClientImplMac.mm */; };
0FCB4E6618BBE3D9000FCFC9 /* WKPrintingView.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FCB4E5C18BBE3D9000FCFC9 /* WKPrintingView.h */; };
0FCB4E6718BBE3D9000FCFC9 /* WKPrintingView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0FCB4E5D18BBE3D9000FCFC9 /* WKPrintingView.mm */; };
0FCB4E6818BBE3D9000FCFC9 /* WKTextInputWindowController.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FCB4E5E18BBE3D9000FCFC9 /* WKTextInputWindowController.h */; };
@@ -2314,8 +2314,8 @@
0FCB4E4118BBE044000FCFC9 /* WKGeolocationProviderIOSObjCSecurityOrigin.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKGeolocationProviderIOSObjCSecurityOrigin.mm; path = ios/WKGeolocationProviderIOSObjCSecurityOrigin.mm; sourceTree = "<group>"; };
0FCB4E4418BBE044000FCFC9 /* WKScrollView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKScrollView.h; path = ios/WKScrollView.h; sourceTree = "<group>"; };
0FCB4E4518BBE044000FCFC9 /* WKScrollView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKScrollView.mm; path = ios/WKScrollView.mm; sourceTree = "<group>"; };
- 0FCB4E5818BBE3D9000FCFC9 /* PageClientImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PageClientImpl.h; sourceTree = "<group>"; };
- 0FCB4E5918BBE3D9000FCFC9 /* PageClientImpl.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PageClientImpl.mm; sourceTree = "<group>"; };
+ 0FCB4E5818BBE3D9000FCFC9 /* PageClientImplMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PageClientImplMac.h; sourceTree = "<group>"; };
+ 0FCB4E5918BBE3D9000FCFC9 /* PageClientImplMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PageClientImplMac.mm; sourceTree = "<group>"; };
0FCB4E5C18BBE3D9000FCFC9 /* WKPrintingView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKPrintingView.h; sourceTree = "<group>"; };
0FCB4E5D18BBE3D9000FCFC9 /* WKPrintingView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKPrintingView.mm; sourceTree = "<group>"; };
0FCB4E5E18BBE3D9000FCFC9 /* WKTextInputWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKTextInputWindowController.h; sourceTree = "<group>"; };
@@ -3511,6 +3511,7 @@
5C298D9E1C3DEF2900470AFE /* PendingDownload.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PendingDownload.h; path = NetworkProcess/Downloads/PendingDownload.h; sourceTree = "<group>"; };
5C62FDF81EFC263C00CE072E /* WKURLSchemeTaskPrivate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WKURLSchemeTaskPrivate.h; sourceTree = "<group>"; };
5C6CE6D01F59BC460007C6CB /* PageClientImplCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PageClientImplCocoa.mm; sourceTree = "<group>"; };
+ 5C6CE6D31F59EA350007C6CB /* PageClientImplCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PageClientImplCocoa.h; sourceTree = "<group>"; };
5C7706731D111D8B0012700F /* WebSocketProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebSocketProvider.cpp; path = Network/WebSocketProvider.cpp; sourceTree = "<group>"; };
5C7C88DC1D0F41A0009D2F6D /* WebSocketProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebSocketProvider.h; path = Network/WebSocketProvider.h; sourceTree = "<group>"; };
5C85C7861C3F23C50061A4FA /* PendingDownload.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PendingDownload.cpp; path = NetworkProcess/Downloads/PendingDownload.cpp; sourceTree = "<group>"; };
@@ -5275,6 +5276,7 @@
7A821F4D1E2F679E00604577 /* LegacyCustomProtocolManagerClient.mm */,
1ABC3DF41899E437004F0626 /* NavigationState.h */,
1ABC3DF31899E437004F0626 /* NavigationState.mm */,
+ 5C6CE6D31F59EA350007C6CB /* PageClientImplCocoa.h */,
5C6CE6D01F59BC460007C6CB /* PageClientImplCocoa.mm */,
CDA29A1E1CBEB5FB00901CCF /* PlaybackSessionManagerProxy.h */,
CDA29A221CBEB61A00901CCF /* PlaybackSessionManagerProxy.messages.in */,
@@ -7696,8 +7698,8 @@
B878B613133428DC006888E9 /* CorrectionPanel.h */,
B878B614133428DC006888E9 /* CorrectionPanel.mm */,
1AFDE65B1954E8D500C48FFA /* LegacySessionStateCoding.cpp */,
- 0FCB4E5818BBE3D9000FCFC9 /* PageClientImpl.h */,
- 0FCB4E5918BBE3D9000FCFC9 /* PageClientImpl.mm */,
+ 0FCB4E5818BBE3D9000FCFC9 /* PageClientImplMac.h */,
+ 0FCB4E5918BBE3D9000FCFC9 /* PageClientImplMac.mm */,
1AB16AE01648656D00290D62 /* RemoteLayerTreeDrawingAreaProxy.h */,
0FF24A2F1879E4FE003ABF0C /* RemoteLayerTreeDrawingAreaProxy.messages.in */,
1AB16ADF1648656D00290D62 /* RemoteLayerTreeDrawingAreaProxy.mm */,
@@ -8632,8 +8634,8 @@
37B47E2D1D64DB76005F4EFF /* objcSPI.h in Headers */,
7CF47FFB17275C57008ACB91 /* PageBanner.h in Headers */,
BC6EDAA6111271C600E7678B /* PageClient.h in Headers */,
- 0FCB4E6218BBE3D9000FCFC9 /* PageClientImpl.h in Headers */,
0FCB4E4618BBE044000FCFC9 /* PageClientImplIOS.h in Headers */,
+ 0FCB4E6218BBE3D9000FCFC9 /* PageClientImplMac.h in Headers */,
1AC7537C183A9FDB0072CB15 /* PageLoadState.h in Headers */,
1A8B66B01BC43C860082DF77 /* PageLoadStateObserver.h in Headers */,
C574A58112E66681002DFE98 /* PasteboardTypes.h in Headers */,
@@ -10202,9 +10204,9 @@
BC8ACA1416670D89004C1941 /* ObjCObjectGraph.mm in Sources */,
7C387434172F5615001BD88A /* PageBanner.cpp in Sources */,
7C6D37FC172F555F009D2847 /* PageBannerMac.mm in Sources */,
- 0FCB4E6318BBE3D9000FCFC9 /* PageClientImpl.mm in Sources */,
5C6CE6D11F59BC7A0007C6CB /* PageClientImplCocoa.mm in Sources */,
0FCB4E4718BBE044000FCFC9 /* PageClientImplIOS.mm in Sources */,
+ 0FCB4E6318BBE3D9000FCFC9 /* PageClientImplMac.mm in Sources */,
1AC7537B183A9FDB0072CB15 /* PageLoadState.cpp in Sources */,
C574A58212E66681002DFE98 /* PasteboardTypes.mm in Sources */,
E19582D6153CC05400B60875 /* PDFKitImports.mm in Sources */,