diff options
Diffstat (limited to 'Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp')
-rw-r--r-- | Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp | 190 |
1 files changed, 129 insertions, 61 deletions
diff --git a/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp b/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp index 872a274c9..815855091 100644 --- a/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp @@ -31,16 +31,22 @@ #include "DrawingAreaProxyImpl.h" #include "NativeWebKeyboardEvent.h" #include "NativeWebMouseEvent.h" +#include "NativeWebWheelEvent.h" #include "NotImplemented.h" -#include "WebContext.h" +#include "WebColorPickerGtk.h" #include "WebContextMenuProxyGtk.h" #include "WebEventFactory.h" +#include "WebKitColorChooser.h" #include "WebKitWebViewBasePrivate.h" +#include "WebKitWebViewPrivate.h" #include "WebPageProxy.h" #include "WebPopupMenuProxyGtk.h" +#include "WebProcessPool.h" +#include <WebCore/CairoUtilities.h> #include <WebCore/Cursor.h> #include <WebCore/EventNames.h> #include <WebCore/GtkUtilities.h> +#include <WebCore/RefPtrCairo.h> #include <wtf/text/CString.h> #include <wtf/text/WTFString.h> @@ -53,47 +59,26 @@ PageClientImpl::PageClientImpl(GtkWidget* viewWidget) { } -PageClientImpl::~PageClientImpl() -{ -} - -void PageClientImpl::getEditorCommandsForKeyEvent(const NativeWebKeyboardEvent& event, const AtomicString& eventType, Vector<WTF::String>& commandList) -{ - ASSERT(eventType == eventNames().keydownEvent || eventType == eventNames().keypressEvent); - - KeyBindingTranslator::EventType type = eventType == eventNames().keydownEvent ? - KeyBindingTranslator::KeyDown : KeyBindingTranslator::KeyPress; - m_keyBindingTranslator.getEditorCommandsForKeyEvent(const_cast<GdkEventKey*>(&event.nativeEvent()->key), type, commandList); -} - // PageClient's pure virtual functions std::unique_ptr<DrawingAreaProxy> PageClientImpl::createDrawingAreaProxy() { - return std::make_unique<DrawingAreaProxyImpl>(webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(m_viewWidget))); + return std::make_unique<DrawingAreaProxyImpl>(*webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(m_viewWidget))); } -void PageClientImpl::setViewNeedsDisplay(const WebCore::IntRect& rect) +void PageClientImpl::setViewNeedsDisplay(const WebCore::Region& region) { - gtk_widget_queue_draw_area(m_viewWidget, rect.x(), rect.y(), rect.width(), rect.height()); + gtk_widget_queue_draw_region(m_viewWidget, toCairoRegion(region).get()); } -void PageClientImpl::displayView() +void PageClientImpl::requestScroll(const WebCore::FloatPoint&, const WebCore::IntPoint&, bool) { notImplemented(); } -void PageClientImpl::scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset) -{ - setViewNeedsDisplay(scrollRect); -} - WebCore::IntSize PageClientImpl::viewSize() { - if (!gtk_widget_get_realized(m_viewWidget)) - return IntSize(); - GtkAllocation allocation; - gtk_widget_get_allocation(m_viewWidget, &allocation); - return IntSize(allocation.width, allocation.height); + auto* drawingArea = static_cast<DrawingAreaProxyImpl*>(webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(m_viewWidget))->drawingArea()); + return drawingArea ? drawingArea->size() : IntSize(); } bool PageClientImpl::isViewWindowActive() @@ -116,14 +101,14 @@ bool PageClientImpl::isViewInWindow() return webkitWebViewBaseIsInWindow(WEBKIT_WEB_VIEW_BASE(m_viewWidget)); } -void PageClientImpl::PageClientImpl::processDidCrash() +void PageClientImpl::PageClientImpl::processDidExit() { notImplemented(); } void PageClientImpl::didRelaunchProcess() { - notImplemented(); + webkitWebViewBaseDidRelaunchWebProcess(WEBKIT_WEB_VIEW_BASE(m_viewWidget)); } void PageClientImpl::toolTipChanged(const String&, const String& newToolTip) @@ -131,7 +116,7 @@ void PageClientImpl::toolTipChanged(const String&, const String& newToolTip) webkitWebViewBaseSetTooltipText(WEBKIT_WEB_VIEW_BASE(m_viewWidget), newToolTip.utf8().data()); } -void PageClientImpl::setCursor(const Cursor& cursor) +void PageClientImpl::setCursor(const WebCore::Cursor& cursor) { if (!gtk_widget_get_realized(m_viewWidget)) return; @@ -147,7 +132,7 @@ void PageClientImpl::setCursor(const Cursor& cursor) gdk_window_set_cursor(window, newCursor); } -void PageClientImpl::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves) +void PageClientImpl::setCursorHiddenUntilMouseMoves(bool /* hiddenUntilMouseMoves */) { notImplemented(); } @@ -189,7 +174,7 @@ FloatRect PageClientImpl::convertToUserSpace(const FloatRect& viewRect) return viewRect; } -IntPoint PageClientImpl::screenToWindow(const IntPoint& point) +IntPoint PageClientImpl::screenToRootView(const IntPoint& point) { IntPoint widgetPositionOnScreen = convertWidgetPointToScreenPoint(m_viewWidget, IntPoint()); IntPoint result(point); @@ -197,7 +182,7 @@ IntPoint PageClientImpl::screenToWindow(const IntPoint& point) return result; } -IntRect PageClientImpl::windowToScreen(const IntRect& rect) +IntRect PageClientImpl::rootViewToScreen(const IntRect& rect) { return IntRect(convertWidgetPointToScreenPoint(m_viewWidget, rect.location()), rect.size()); } @@ -214,49 +199,41 @@ void PageClientImpl::doneWithKeyEvent(const NativeWebKeyboardEvent& event, bool gtk_main_do_event(event.nativeEvent()); } -PassRefPtr<WebPopupMenuProxy> PageClientImpl::createPopupMenuProxy(WebPageProxy* page) +RefPtr<WebPopupMenuProxy> PageClientImpl::createPopupMenuProxy(WebPageProxy& page) { return WebPopupMenuProxyGtk::create(m_viewWidget, page); } -PassRefPtr<WebContextMenuProxy> PageClientImpl::createContextMenuProxy(WebPageProxy* page) -{ - return WebContextMenuProxyGtk::create(m_viewWidget, page); -} - -#if ENABLE(INPUT_TYPE_COLOR) -PassRefPtr<WebColorPicker> PageClientImpl::createColorPicker(WebPageProxy*, const WebCore::Color&, const WebCore::IntRect&) +std::unique_ptr<WebContextMenuProxy> PageClientImpl::createContextMenuProxy(WebPageProxy& page, const ContextMenuContextData& context, const UserData& userData) { - notImplemented(); - return 0; + return std::make_unique<WebContextMenuProxyGtk>(m_viewWidget, page, context, userData); } -#endif -void PageClientImpl::setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut, bool animate) +RefPtr<WebColorPicker> PageClientImpl::createColorPicker(WebPageProxy* page, const WebCore::Color& color, const WebCore::IntRect& rect) { - notImplemented(); + if (WEBKIT_IS_WEB_VIEW(m_viewWidget)) + return WebKitColorChooser::create(*page, color, rect); + return WebColorPickerGtk::create(*page, color, rect); } -#if USE(ACCELERATED_COMPOSITING) -void PageClientImpl::enterAcceleratedCompositingMode(const LayerTreeContext&) +void PageClientImpl::enterAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext) { - notImplemented(); + webkitWebViewBaseEnterAcceleratedCompositingMode(WEBKIT_WEB_VIEW_BASE(m_viewWidget), layerTreeContext); } void PageClientImpl::exitAcceleratedCompositingMode() { - notImplemented(); + webkitWebViewBaseExitAcceleratedCompositingMode(WEBKIT_WEB_VIEW_BASE(m_viewWidget)); } -void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext&) +void PageClientImpl::updateAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext) { - notImplemented(); + webkitWebViewBaseUpdateAcceleratedCompositingMode(WEBKIT_WEB_VIEW_BASE(m_viewWidget), layerTreeContext); } -#endif // USE(ACCELERATED_COMPOSITING) void PageClientImpl::pageClosed() { - notImplemented(); + webkitWebViewBasePageClosed(WEBKIT_WEB_VIEW_BASE(m_viewWidget)); } void PageClientImpl::preferencesDidChange() @@ -264,15 +241,27 @@ void PageClientImpl::preferencesDidChange() notImplemented(); } -void PageClientImpl::updateTextInputState() +void PageClientImpl::selectionDidChange() { webkitWebViewBaseUpdateTextInputState(WEBKIT_WEB_VIEW_BASE(m_viewWidget)); + if (WEBKIT_IS_WEB_VIEW(m_viewWidget)) + webkitWebViewSelectionDidChange(WEBKIT_WEB_VIEW(m_viewWidget)); +} + +void PageClientImpl::didChangeContentSize(const IntSize& size) +{ + webkitWebViewBaseSetContentsSize(WEBKIT_WEB_VIEW_BASE(m_viewWidget), size); } #if ENABLE(DRAG_SUPPORT) -void PageClientImpl::startDrag(const WebCore::DragData& dragData, PassRefPtr<ShareableBitmap> dragImage) +void PageClientImpl::startDrag(Ref<SelectionData>&& selection, DragOperation dragOperation, RefPtr<ShareableBitmap>&& dragImage) { - webkitWebViewBaseStartDrag(WEBKIT_WEB_VIEW_BASE(m_viewWidget), dragData, dragImage); + WebKitWebViewBase* webView = WEBKIT_WEB_VIEW_BASE(m_viewWidget); + webkitWebViewBaseDragAndDropHandler(webView).startDrag(WTFMove(selection), dragOperation, WTFMove(dragImage)); + + // A drag starting should prevent a double-click from happening. This might + // happen if a drag is followed very quickly by another click (like in the WTR). + webkitWebViewBaseResetClickCounter(webView); } #endif @@ -281,7 +270,7 @@ void PageClientImpl::handleDownloadRequest(DownloadProxy* download) webkitWebViewBaseHandleDownloadRequest(WEBKIT_WEB_VIEW_BASE(m_viewWidget), download); } -void PageClientImpl::didCommitLoadForMainFrame() +void PageClientImpl::didCommitLoadForMainFrame(const String& /* mimeType */, bool /* useCustomContentProvider */ ) { webkitWebViewBaseResetClickCounter(WEBKIT_WEB_VIEW_BASE(m_viewWidget)); } @@ -319,23 +308,30 @@ void PageClientImpl::exitFullScreen() webkitWebViewBaseExitFullScreen(WEBKIT_WEB_VIEW_BASE(m_viewWidget)); } -void PageClientImpl::beganEnterFullScreen(const IntRect& initialFrame, const IntRect& finalFrame) +void PageClientImpl::beganEnterFullScreen(const IntRect& /* initialFrame */, const IntRect& /* finalFrame */) { notImplemented(); } -void PageClientImpl::beganExitFullScreen(const IntRect& initialFrame, const IntRect& finalFrame) +void PageClientImpl::beganExitFullScreen(const IntRect& /* initialFrame */, const IntRect& /* finalFrame */) { notImplemented(); } #endif // ENABLE(FULLSCREEN_API) +#if ENABLE(TOUCH_EVENTS) void PageClientImpl::doneWithTouchEvent(const NativeWebTouchEvent& event, bool wasEventHandled) { if (wasEventHandled) return; +#if HAVE(GTK_GESTURES) + GestureController& gestureController = webkitWebViewBaseGestureController(WEBKIT_WEB_VIEW_BASE(m_viewWidget)); + if (gestureController.handleEvent(event.nativeEvent())) + return; +#endif + // Emulate pointer events if unhandled. const GdkEvent* touchEvent = event.nativeEvent(); @@ -380,5 +376,77 @@ void PageClientImpl::doneWithTouchEvent(const NativeWebTouchEvent& event, bool w gtk_widget_event(m_viewWidget, pointerEvent.get()); } +#endif // ENABLE(TOUCH_EVENTS) + +void PageClientImpl::wheelEventWasNotHandledByWebCore(const NativeWebWheelEvent& event) +{ + webkitWebViewBaseForwardNextWheelEvent(WEBKIT_WEB_VIEW_BASE(m_viewWidget)); + gtk_main_do_event(event.nativeEvent()); +} + +void PageClientImpl::didFinishLoadingDataForCustomContentProvider(const String&, const IPC::DataReference&) +{ +} + +void PageClientImpl::navigationGestureDidBegin() +{ +} + +void PageClientImpl::navigationGestureWillEnd(bool, WebBackForwardListItem&) +{ +} + +void PageClientImpl::navigationGestureDidEnd(bool, WebBackForwardListItem&) +{ +} + +void PageClientImpl::navigationGestureDidEnd() +{ +} + +void PageClientImpl::willRecordNavigationSnapshot(WebBackForwardListItem&) +{ +} + +void PageClientImpl::didRemoveNavigationGestureSnapshot() +{ +} + +void PageClientImpl::didFirstVisuallyNonEmptyLayoutForMainFrame() +{ +} + +void PageClientImpl::didFinishLoadForMainFrame() +{ +} + +void PageClientImpl::didSameDocumentNavigationForMainFrame(SameDocumentNavigationType) +{ +} + +void PageClientImpl::didChangeBackgroundColor() +{ +} + +void PageClientImpl::refView() +{ + g_object_ref(m_viewWidget); +} + +void PageClientImpl::derefView() +{ + g_object_unref(m_viewWidget); +} + +#if ENABLE(VIDEO) && USE(GSTREAMER) +bool PageClientImpl::decidePolicyForInstallMissingMediaPluginsPermissionRequest(InstallMissingMediaPluginsPermissionRequest& request) +{ + if (!WEBKIT_IS_WEB_VIEW(m_viewWidget)) + return false; + + webkitWebViewRequestInstallMissingMediaPlugins(WEBKIT_WEB_VIEW(m_viewWidget), request); + return true; +} +#endif } // namespace WebKit |