Skip to content
Permalink
Browse files
[GTK] Implement back/forward touchpad gesture
https://bugs.webkit.org/show_bug.cgi?id=193919

Patch by Alexander Mikhaylenko <exalm7659@gmail.com> on 2019-02-08
Reviewed by Michael Catanzaro.

Source/WebKit:

Move ViewSnapshotStore and ViewGestureController from Cocoa/Mac directory
to UIProcess/, also move some parts of mac/ViewGestreControllerMac.mm to
ViewGestureController.cpp, split up Mac- and iOS-specific parts of
ViewSnapshotStore.cpp into mac/ViewSnapshotMac.mm, then implement 2-finger
touchpad swipe back-forward gesture for GTK based on that.

To avoid name conflict, rename existing ViewGestureController class inside
UIProcess/API/gtk/WebKitWebViewBase.cpp into TouchGestureController.

Since GTK gestures can only work with 3 or 4 fingers, treat horizontal
scrolling events as a swipe as long as there's nowhere to scroll in that
direction and web page doesn't handle the scrolling.

This is only allowed for touchpads, even though it can theoretically work
with touch mice and trackpoints.

The gesture requires every item in back-forward list to have a snapshot.
There's already an existing infrastructure for that, so the patch changes
a bunch of #if PLATFORM(COCOA) statements to also check for GTK platform.
The snapshots have to be taken in sync, so the implementation draws webview
widget into a Cairo image surface.

The gesture is disabled by default, and can be enabled by setting the newly
added 'enable-back-forward-navigation-gestures' property in WebKitSettings to
true.

Gesture drawing is implemented via Cairo. When the gesture is active, the
actual page is drawn into a Cairo group, which is then drawn together with
a given snapshot, as well as dimming and a drop shadow over the "lower" layer.

Also add a memory pressure handler that clears snapshot store when low on memory.

* DerivedSources-input.xcfilelist:
* PlatformGTK.cmake:
* PlatformMac.cmake:
* Shared/SessionState.h: Add snapshot to back-forward items for GTK.
* Shared/WebBackForwardListItem.h: Add snapshot to back-forward items for GTK.
* SourcesCocoa.txt:
* SourcesGTK.txt:
* UIProcess/API/glib/WebKitSettings.cpp:
Added 'enable-back-forward-navigation-gestures' property for enabling the gesture.
(webKitSettingsSetProperty):
(webKitSettingsGetProperty):
(webkit_settings_class_init):
(webkit_settings_get_enable_back_forward_navigation_gestures): Added, GTK only.
(webkit_settings_set_enable_back_forward_navigation_gestures): Added, GTK only.
* UIProcess/API/glib/WebKitWebView.cpp:
(enableBackForwardNavigationGesturesChanged): Added, GTK only.
(webkitWebViewUpdateSettings):
(webkitWebViewDisconnectSettingsSignalHandlers):
* UIProcess/API/gtk/PageClientImpl.cpp:
(WebKit::PageClientImpl::setViewNeedsDisplay): Redraw the whole screen instead of a region during the gesture.
(WebKit::PageClientImpl::takeViewSnapshot): Added.
(WebKit::PageClientImpl::wheelEventWasNotHandledByWebCore): Pass unhandled events to the gesture controller.
(WebKit::PageClientImpl::didRemoveNavigationGestureSnapshot): Redraw the widget immediately after removing snapshot.
(WebKit::PageClientImpl::didStartProvisionalLoadForMainFrame): Added, send a notification to the gesture controller.
(WebKit::PageClientImpl::didFirstVisuallyNonEmptyLayoutForMainFrame):  Send a notification to the gesture controller.
(WebKit::PageClientImpl::didFinishLoadForMainFrame):  Send a notification to the gesture controller.
(WebKit::PageClientImpl::didFailLoadForMainFrame):  Added, send a notification to the gesture controller.
(WebKit::PageClientImpl::didSameDocumentNavigationForMainFrame):  Send a notification to the gesture controller.
(WebKit::PageClientImpl::didRestoreScrollPosition):  Added, send a notification to the gesture controller.
* UIProcess/API/gtk/PageClientImpl.h:
* UIProcess/API/gtk/WebKitSettings.h:
Add webkit_settings_get_enable_back_forward_navigation_gestures() and webkit_settings_get_enable_back_forward_navigation_gestures()
to public API.
* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(webkitWebViewBaseDraw): Pass drawing to ViewGestureController during the gesture.
(webkitWebViewBaseScrollEvent): Pass scroll events to ViewGestureController during the gesture.
(webkitWebViewBaseGestureController): Renamed ViewGestureController to TouchGestureController.
(webkitWebViewBaseViewGestureController): Added.
(webkitWebViewBaseCreateWebPage): Create an instance of ViewGestureController.
(webkitWebViewBaseTakeViewSnapshot): Added.
(webkitWebViewBaseDidStartProvisionalLoadForMainFrame): Added.
(webkitWebViewBaseDidFirstVisuallyNonEmptyLayoutForMainFrame): Added.
(webkitWebViewBaseDidFinishLoadForMainFrame): Added.
(webkitWebViewBaseDidFailLoadForMainFrame): Added.
(webkitWebViewBaseDidSameDocumentNavigationForMainFrame): Added.
(webkitWebViewBaseDidRestoreScrollPosition): Added.
* UIProcess/API/gtk/WebKitWebViewBasePrivate.h:
* UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt: Mentioned the added functions in docs.
* UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::platformInitialize): Move the check from WebMemoryPressureHandlerCocoa.mm here.
* UIProcess/PageClient.h: Add takeViewSnapshot() for GTK.
* UIProcess/ViewGestureController.cpp: Renamed from Source/WebKit/UIProcess/Cocoa/ViewGestureController.cpp.
(WebKit::ViewGestureController::ViewGestureController):
(WebKit::ViewGestureController::~ViewGestureController):
(WebKit::ViewGestureController::disconnectFromProcess):
(WebKit::ViewGestureController::connectToProcess):
(WebKit::ViewGestureController::controllerForGesture):
(WebKit::ViewGestureController::takeNextGestureID):
(WebKit::ViewGestureController::willBeginGesture):
(WebKit::ViewGestureController::didEndGesture):
(WebKit::ViewGestureController::setAlternateBackForwardListSourcePage):
(WebKit::ViewGestureController::canSwipeInDirection const):
(WebKit::ViewGestureController::didStartProvisionalOrSameDocumentLoadForMainFrame):
(WebKit::ViewGestureController::didStartProvisionalLoadForMainFrame):
(WebKit::ViewGestureController::didFirstVisuallyNonEmptyLayoutForMainFrame):
(WebKit::ViewGestureController::didRepaintAfterNavigation):
(WebKit::ViewGestureController::didHitRenderTreeSizeThreshold):
(WebKit::ViewGestureController::didRestoreScrollPosition):
(WebKit::ViewGestureController::didReachMainFrameLoadTerminalState):
(WebKit::ViewGestureController::didSameDocumentNavigationForMainFrame):
(WebKit::ViewGestureController::checkForActiveLoads):
(WebKit::ViewGestureController::SnapshotRemovalTracker::SnapshotRemovalTracker):
(WebKit::ViewGestureController::SnapshotRemovalTracker::eventsDescription):
(WebKit::ViewGestureController::SnapshotRemovalTracker::log const):
(WebKit::ViewGestureController::SnapshotRemovalTracker::resume):
(WebKit::ViewGestureController::SnapshotRemovalTracker::start):
(WebKit::ViewGestureController::SnapshotRemovalTracker::reset):
(WebKit::ViewGestureController::SnapshotRemovalTracker::stopWaitingForEvent):
(WebKit::ViewGestureController::SnapshotRemovalTracker::eventOccurred):
(WebKit::ViewGestureController::SnapshotRemovalTracker::cancelOutstandingEvent):
(WebKit::ViewGestureController::SnapshotRemovalTracker::hasOutstandingEvent):
(WebKit::ViewGestureController::SnapshotRemovalTracker::fireRemovalCallbackIfPossible):
(WebKit::ViewGestureController::SnapshotRemovalTracker::fireRemovalCallbackImmediately):
(WebKit::ViewGestureController::SnapshotRemovalTracker::watchdogTimerFired):
(WebKit::ViewGestureController::SnapshotRemovalTracker::startWatchdog):
(WebKit::deltaShouldCancelSwipe):
(WebKit::ViewGestureController::PendingSwipeTracker::PendingSwipeTracker):
(WebKit::ViewGestureController::PendingSwipeTracker::scrollEventCanBecomeSwipe):
(WebKit::ViewGestureController::PendingSwipeTracker::handleEvent):
(WebKit::ViewGestureController::PendingSwipeTracker::eventWasNotHandledByWebCore):
(WebKit::ViewGestureController::PendingSwipeTracker::tryToStartSwipe):
(WebKit::ViewGestureController::PendingSwipeTracker::reset):
(WebKit::ViewGestureController::startSwipeGesture):
(WebKit::ViewGestureController::isPhysicallySwipingLeft const):
(WebKit::ViewGestureController::shouldUseSnapshotForSize):
(WebKit::ViewGestureController::forceRepaintIfNeeded):
(WebKit::ViewGestureController::willEndSwipeGesture):
(WebKit::ViewGestureController::endSwipeGesture):
(WebKit::ViewGestureController::requestRenderTreeSizeNotificationIfNeeded):
* UIProcess/ViewGestureController.h: Renamed from Source/WebKit/UIProcess/Cocoa/ViewGestureController.h.
(WebKit::ViewGestureController::wheelEventWasNotHandledByWebCore):
(WebKit::ViewGestureController::shouldIgnorePinnedState):
(WebKit::ViewGestureController::setShouldIgnorePinnedState):
(WebKit::ViewGestureController::hasActiveMagnificationGesture const):
(WebKit::ViewGestureController::setCustomSwipeViews):
(WebKit::ViewGestureController::setCustomSwipeViewsTopContentInset):
(WebKit::ViewGestureController::setDidMoveSwipeSnapshotCallback):
(WebKit::ViewGestureController::backgroundColorForCurrentSnapshot const):
(WebKit::ViewGestureController::didFinishLoadForMainFrame):
(WebKit::ViewGestureController::didFailLoadForMainFrame):
(WebKit::ViewGestureController::setSwipeGestureEnabled):
(WebKit::ViewGestureController::isSwipeGestureEnabled):
(WebKit::ViewGestureController::SnapshotRemovalTracker::pause):
(WebKit::ViewGestureController::SnapshotRemovalTracker::isPaused const):
(WebKit::ViewGestureController::SnapshotRemovalTracker::hasRemovalCallback const):
(WebKit::ViewGestureController::SnapshotRemovalTracker::renderTreeSizeThreshold const):
(WebKit::ViewGestureController::SnapshotRemovalTracker::setRenderTreeSizeThreshold):
(WebKit::ViewGestureController::PendingSwipeTracker::shouldIgnorePinnedState):
(WebKit::ViewGestureController::PendingSwipeTracker::setShouldIgnorePinnedState):
(WebKit::ViewGestureController::SwipeProgressTracker::progress const):
(WebKit::ViewGestureController::SwipeProgressTracker::direction const):
* UIProcess/ViewGestureController.messages.in: Renamed from Source/WebKit/UIProcess/Cocoa/ViewGestureController.messages.in.
* UIProcess/ViewSnapshotStore.cpp: Copied from Source/WebKit/UIProcess/mac/ViewSnapshotStore.mm.
(WebKit::ViewSnapshotStore::ViewSnapshotStore):
(WebKit::ViewSnapshotStore::~ViewSnapshotStore):
(WebKit::ViewSnapshotStore::singleton):
(WebKit::ViewSnapshotStore::didAddImageToSnapshot):
(WebKit::ViewSnapshotStore::willRemoveImageFromSnapshot):
(WebKit::ViewSnapshotStore::pruneSnapshots):
(WebKit::ViewSnapshotStore::recordSnapshot):
(WebKit::ViewSnapshotStore::discardSnapshotImages):
(WebKit::ViewSnapshot::~ViewSnapshot):
* UIProcess/ViewSnapshotStore.h: Renamed from Source/WebKit/UIProcess/mac/ViewSnapshotStore.h.
(WebKit::ViewSnapshot::setRenderTreeSize):
(WebKit::ViewSnapshot::renderTreeSize const):
(WebKit::ViewSnapshot::setBackgroundColor):
(WebKit::ViewSnapshot::backgroundColor const):
(WebKit::ViewSnapshot::setViewScrollPosition):
(WebKit::ViewSnapshot::viewScrollPosition const):
(WebKit::ViewSnapshot::setDeviceScaleFactor):
(WebKit::ViewSnapshot::deviceScaleFactor const):
(WebKit::ViewSnapshot::surface const):
(WebKit::ViewSnapshot::imageSizeInBytes const):
(WebKit::ViewSnapshot::size const):
(WebKit::ViewSnapshotStore::setDisableSnapshotVolatilityForTesting):
(WebKit::ViewSnapshotStore::disableSnapshotVolatilityForTesting const):
* UIProcess/WebBackForwardList.cpp:
(WebKit::WebBackForwardList::didRemoveItem): Unset snapshot for GTK.
* UIProcess/WebMemoryPressureHandler.cpp: Copied from Source/WebKit/UIProcess/Cocoa/WebMemoryPressureHandlerCocoa.mm.
(WebKit::installMemoryPressureHandler):
* UIProcess/WebMemoryPressureHandler.h: Renamed from Source/WebKit/UIProcess/Cocoa/WebMemoryPressureHandlerCocoa.h.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::recordNavigationSnapshot): Take snapshots for GTK.
* UIProcess/WebPageProxy.h:
* UIProcess/gtk/ViewGestureControllerGtk.cpp: Added. This is a port of
UIProcess/mac/ViewGestureControllerMac.mm. SwipeProgressTracker class is a
re-implementation of trackSwipeEventWithOptions.
(WebKit::isEventStop):
(WebKit::ViewGestureController::platformTeardown):
(WebKit::ViewGestureController::PendingSwipeTracker::scrollEventCanStartSwipe):
(WebKit::ViewGestureController::PendingSwipeTracker::scrollEventCanEndSwipe):
(WebKit::ViewGestureController::PendingSwipeTracker::scrollEventCanInfluenceSwipe):
(WebKit::ViewGestureController::PendingSwipeTracker::scrollEventGetScrollingDeltas):
(WebKit::ViewGestureController::handleScrollWheelEvent):
(WebKit::ViewGestureController::trackSwipeGesture):
(WebKit::ViewGestureController::SwipeProgressTracker::SwipeProgressTracker):
(WebKit::ViewGestureController::SwipeProgressTracker::startTracking):
(WebKit::ViewGestureController::SwipeProgressTracker::reset):
(WebKit::ViewGestureController::SwipeProgressTracker::handleEvent):
(WebKit::ViewGestureController::SwipeProgressTracker::startAnimation):
(WebKit::easeOutCubic):
(WebKit::ViewGestureController::SwipeProgressTracker::onAnimationTick):
(WebKit::ViewGestureController::SwipeProgressTracker::endAnimation):
(WebKit::ViewGestureController::beginSwipeGesture):
(WebKit::ViewGestureController::handleSwipeGesture):
(WebKit::ViewGestureController::draw):
(WebKit::ViewGestureController::removeSwipeSnapshot):
(WebKit::ViewGestureController::beginSimulatedSwipeInDirectionForTesting):
(WebKit::ViewGestureController::completeSimulatedSwipeInDirectionForTesting):
* UIProcess/gtk/ViewSnapshotStoreGtk.cpp: Renamed from Source/WebKit/UIProcess/Cocoa/WebMemoryPressureHandlerCocoa.mm.
(WebKit::ViewSnapshot::create):
(WebKit::ViewSnapshot::ViewSnapshot):
(WebKit::ViewSnapshot::hasImage const):
(WebKit::ViewSnapshot::clearImage):
(WebKit::ViewSnapshot::imageSizeInBytes const):
(WebKit::ViewSnapshot::size const):
* UIProcess/gtk/WebProcessPoolGtk.cpp:
(WebKit::memoryPressureMonitorDisabled): Added.
(WebKit::WebProcessPool::platformInitialize): Install memory pressure handler.
(WebKit::WebProcessPool::platformInitializeWebProcess): Use memoryPressureMonitorDisabled().
* UIProcess/mac/ViewGestureControllerMac.mm:
Moved many functions into UIProcess/ViewGestureController.cpp
(WebKit::ViewGestureController::PendingSwipeTracker::scrollEventCanStartSwipe):
(WebKit::ViewGestureController::PendingSwipeTracker::scrollEventCanEndSwipe):
(WebKit::ViewGestureController::PendingSwipeTracker::scrollEventCanInfluenceSwipe):
(WebKit::ViewGestureController::PendingSwipeTracker::scrollEventGetScrollingDeltas):
(WebKit::ViewGestureController::trackSwipeGesture):
(WebKit::scrollEventCanInfluenceSwipe): Deleted.
(WebKit::deltaShouldCancelSwipe): Deleted.
(WebKit::ViewGestureController::PendingSwipeTracker::PendingSwipeTracker): Deleted.
(WebKit::ViewGestureController::PendingSwipeTracker::scrollEventCanBecomeSwipe): Deleted.
(WebKit::ViewGestureController::PendingSwipeTracker::handleEvent): Deleted.
(WebKit::ViewGestureController::PendingSwipeTracker::eventWasNotHandledByWebCore): Deleted.
(WebKit::ViewGestureController::PendingSwipeTracker::tryToStartSwipe): Deleted.
(WebKit::ViewGestureController::PendingSwipeTracker::reset): Deleted.
(WebKit::ViewGestureController::willEndSwipeGesture): Deleted.
(WebKit::ViewGestureController::shouldUseSnapshotForSize): Deleted.
(WebKit::ViewGestureController::isPhysicallySwipingLeft const): Deleted.
(WebKit::ViewGestureController::endSwipeGesture): Deleted.
(WebKit::ViewGestureController::forceRepaintIfNeeded): Deleted.
(WebKit::ViewGestureController::requestRenderTreeSizeNotificationIfNeeded): Deleted.
* UIProcess/mac/ViewSnapshotStoreMac.mm: Renamed from Source/WebKit/UIProcess/mac/ViewSnapshotStore.mm.
(WebKit::ViewSnapshotStore::snapshottingContext):
(WebKit::ViewSnapshot::create):
(WebKit::ViewSnapshot::ViewSnapshot):
(WebKit::ViewSnapshot::setSurface):
(WebKit::ViewSnapshot::hasImage const):
(WebKit::ViewSnapshot::clearImage):
(WebKit::ViewSnapshot::setVolatile):
(WebKit::ViewSnapshot::asLayerContents):
(WebKit::ViewSnapshot::asImageForTesting):
* WebKit.xcodeproj/project.pbxproj:
* WebProcess/WebPage/ViewGestureGeometryCollector.cpp:
Make SetRenderTreeSizeNotificationThreshold() cross-platform.
(WebKit::ViewGestureGeometryCollector::ViewGestureGeometryCollector):
(WebKit::ViewGestureGeometryCollector::computeMinimumAndMaximumViewportScales const):
(WebKit::ViewGestureGeometryCollector::mainFrameDidLayout):
* WebProcess/WebPage/ViewGestureGeometryCollector.h:
* WebProcess/WebPage/ViewGestureGeometryCollector.messages.in:
* WebProcess/WebPage/WebPage.cpp:
Start using ViewGestureGeometryCollector for GTK.
(WebKit::WebPage::mainFrameDidLayout):
* WebProcess/WebPage/WebPage.h:

Tools:

* TestWebKitAPI/Tests/WebKitGLib/TestWebKitSettings.cpp:
(testWebKitSettings): Add a test for 'enable-back-forward-navigation-gestures' property.

Canonical link: https://commits.webkit.org/208883@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241224 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Exalm authored and webkit-commit-queue committed Feb 9, 2019
1 parent 55485ea commit 714e2beecfe09dec09956845825c6952020b0f29
Show file tree
Hide file tree
Showing 41 changed files with 1,602 additions and 437 deletions.

Large diffs are not rendered by default.

@@ -63,7 +63,6 @@ $(PROJECT_DIR)/UIProcess/Automation/WebAutomationSession.messages.in
$(PROJECT_DIR)/UIProcess/Cocoa/PlaybackSessionManagerProxy.messages.in
$(PROJECT_DIR)/UIProcess/Cocoa/UserMediaCaptureManagerProxy.messages.in
$(PROJECT_DIR)/UIProcess/Cocoa/VideoFullscreenManagerProxy.messages.in
$(PROJECT_DIR)/UIProcess/Cocoa/ViewGestureController.messages.in
$(PROJECT_DIR)/UIProcess/Downloads/DownloadProxy.messages.in
$(PROJECT_DIR)/UIProcess/DrawingAreaProxy.messages.in
$(PROJECT_DIR)/UIProcess/Network/CustomProtocols/LegacyCustomProtocolManagerProxy.messages.in
@@ -72,6 +71,7 @@ $(PROJECT_DIR)/UIProcess/Plugins/PluginProcessProxy.messages.in
$(PROJECT_DIR)/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.messages.in
$(PROJECT_DIR)/UIProcess/RemoteWebInspectorProxy.messages.in
$(PROJECT_DIR)/UIProcess/UserContent/WebUserContentControllerProxy.messages.in
$(PROJECT_DIR)/UIProcess/ViewGestureController.messages.in
$(PROJECT_DIR)/UIProcess/VisitedLinkStore.messages.in
$(PROJECT_DIR)/UIProcess/WebAuthentication/WebAuthenticatorCoordinatorProxy.messages.in
$(PROJECT_DIR)/UIProcess/WebCookieManagerProxy.messages.in
@@ -35,7 +35,11 @@ list(APPEND WebKit_UNIFIED_SOURCE_LIST_FILES
list(APPEND WebKit_MESSAGES_IN_FILES
NetworkProcess/CustomProtocols/LegacyCustomProtocolManager.messages.in

UIProcess/ViewGestureController.messages.in

UIProcess/Network/CustomProtocols/LegacyCustomProtocolManagerProxy.messages.in

WebProcess/WebPage/ViewGestureGeometryCollector.messages.in
)

list(APPEND WebKit_DERIVED_SOURCES
@@ -161,6 +161,8 @@ list(APPEND WebKit_SOURCES

UIProcess/HighPerformanceGraphicsUsageSampler.cpp
UIProcess/PerActivityStateCPUUsageSampler.cpp
UIProcess/ViewGestureController.cpp
UIProcess/ViewSnapshotStore.cpp

UIProcess/Automation/WebAutomationSession.cpp

@@ -253,7 +255,6 @@ list(APPEND WebKit_SOURCES
UIProcess/Cocoa/SessionStateCoding.mm
UIProcess/Cocoa/UIDelegate.mm
UIProcess/Cocoa/VersionChecks.mm
UIProcess/Cocoa/ViewGestureController.cpp
UIProcess/Cocoa/WKFullKeyboardAccessWatcher.mm
UIProcess/Cocoa/WKReloadFrameErrorRecoveryAttempter.mm
UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm
@@ -291,7 +292,7 @@ list(APPEND WebKit_SOURCES
UIProcess/mac/TextCheckerMac.mm
UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm
UIProcess/mac/ViewGestureControllerMac.mm
UIProcess/mac/ViewSnapshotStore.mm
UIProcess/mac/ViewSnapshotStoreMac.mm
UIProcess/mac/WKFullScreenWindowController.mm
UIProcess/mac/WKImmediateActionController.mm
UIProcess/mac/WKInspectorViewController.mm
@@ -466,8 +467,9 @@ list(APPEND WebKit_MESSAGES_IN_FILES

Shared/API/Cocoa/RemoteObjectRegistry.messages.in

UIProcess/ViewGestureController.messages.in

UIProcess/Cocoa/VideoFullscreenManagerProxy.messages.in
UIProcess/Cocoa/ViewGestureController.messages.in

UIProcess/Network/CustomProtocols/LegacyCustomProtocolManagerProxy.messages.in

@@ -25,10 +25,7 @@

#pragma once

#if PLATFORM(COCOA)
#include "ViewSnapshotStore.h"
#endif

#include <WebCore/BackForwardItemIdentifier.h>
#include <WebCore/FloatRect.h>
#include <WebCore/FrameLoaderTypes.h>
@@ -133,7 +130,7 @@ struct BackForwardListItemState {
WebCore::BackForwardItemIdentifier identifier;

PageState pageState;
#if PLATFORM(COCOA)
#if PLATFORM(COCOA) || PLATFORM(GTK)
RefPtr<ViewSnapshot> snapshot;
#endif
};
@@ -66,7 +66,7 @@ class WebBackForwardListItem : public API::ObjectImpl<API::Object::Type::BackFor
bool itemIsInSameDocument(const WebBackForwardListItem&) const;
bool itemIsClone(const WebBackForwardListItem&);

#if PLATFORM(COCOA)
#if PLATFORM(COCOA) || PLATFORM(GTK)
ViewSnapshot* snapshot() const { return m_itemState.snapshot.get(); }
void setSnapshot(RefPtr<ViewSnapshot>&& snapshot) { m_itemState.snapshot = WTFMove(snapshot); }
#endif
@@ -205,9 +205,12 @@ UIProcess/_WKWebViewPrintFormatter.mm
UIProcess/ApplicationStateTracker.mm
UIProcess/HighPerformanceGraphicsUsageSampler.cpp
UIProcess/PerActivityStateCPUUsageSampler.cpp
UIProcess/ViewGestureController.cpp
UIProcess/ViewSnapshotStore.cpp
UIProcess/WebDataListSuggestionsDropdown.cpp
UIProcess/WebMediaSessionFocusManager.cpp
UIProcess/WebMediaSessionFocusManagerClient.cpp
UIProcess/WebMemoryPressureHandler.cpp
UIProcess/WKImagePreviewViewController.mm
UIProcess/WKInspectorHighlightView.mm

@@ -338,8 +341,6 @@ UIProcess/Cocoa/UIDelegate.mm
UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp
UIProcess/Cocoa/VersionChecks.mm
UIProcess/Cocoa/VideoFullscreenManagerProxy.mm
UIProcess/Cocoa/ViewGestureController.cpp
UIProcess/Cocoa/WebMemoryPressureHandlerCocoa.mm
UIProcess/Cocoa/WebPageProxyCocoa.mm
UIProcess/Cocoa/WebPasteboardProxyCocoa.mm
UIProcess/Cocoa/WebProcessPoolCocoa.mm
@@ -426,7 +427,7 @@ UIProcess/mac/ServicesController.mm
UIProcess/mac/TextCheckerMac.mm
UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm
UIProcess/mac/ViewGestureControllerMac.mm
UIProcess/mac/ViewSnapshotStore.mm
UIProcess/mac/ViewSnapshotStoreMac.mm
UIProcess/mac/WebColorPickerMac.mm
UIProcess/mac/WebContextMenuProxyMac.mm
UIProcess/mac/WebCookieManagerProxyMac.mm
@@ -112,7 +112,10 @@ UIProcess/BackingStore.cpp
UIProcess/DefaultUndoController.cpp
UIProcess/DrawingAreaProxyImpl.cpp
UIProcess/LegacySessionStateCodingNone.cpp
UIProcess/ViewGestureController.cpp
UIProcess/ViewSnapshotStore.cpp @no-unify
UIProcess/WebGrammarDetail.cpp
UIProcess/WebMemoryPressureHandler.cpp @no-unify
UIProcess/WebTextChecker.cpp
UIProcess/WebTextCheckerClient.cpp
UIProcess/WebViewportAttributes.cpp
@@ -240,6 +243,8 @@ UIProcess/gtk/InputMethodFilter.cpp @no-unify
UIProcess/gtk/KeyBindingTranslator.cpp
UIProcess/gtk/RemoteWebInspectorProxyGtk.cpp @no-unify
UIProcess/gtk/TextCheckerGtk.cpp @no-unify
UIProcess/gtk/ViewGestureControllerGtk.cpp @no-unify
UIProcess/gtk/ViewSnapshotStoreGtk.cpp @no-unify
UIProcess/gtk/WaylandCompositor.cpp @no-unify
UIProcess/gtk/WebColorPickerGtk.cpp @no-unify
UIProcess/gtk/WebContextMenuProxyGtk.cpp
@@ -397,6 +402,7 @@ WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.cpp
WebProcess/WebPage/AcceleratedDrawingArea.cpp
WebProcess/WebPage/AcceleratedSurface.cpp
WebProcess/WebPage/LayerTreeHost.cpp
WebProcess/WebPage/ViewGestureGeometryCollector.cpp

WebProcess/WebPage/CoordinatedGraphics/CompositingCoordinator.cpp
WebProcess/WebPage/CoordinatedGraphics/CoordinatedLayerTreeHost.cpp
@@ -80,6 +80,9 @@ struct _WebKitSettingsPrivate {
bool allowModalDialogs { false };
bool zoomTextOnly { false };
double screenDpi { 96 };
#if PLATFORM(GTK)
bool enableBackForwardNavigationGestures { false };
#endif
};

/**
@@ -161,6 +164,7 @@ enum {
PROP_ALLOW_UNIVERSAL_ACCESS_FROM_FILE_URLS,
#if PLATFORM(GTK)
PROP_HARDWARE_ACCELERATION_POLICY,
PROP_ENABLE_BACK_FORWARD_NAVIGATION_GESTURES,
#endif
};

@@ -381,6 +385,9 @@ static void webKitSettingsSetProperty(GObject* object, guint propId, const GValu
case PROP_HARDWARE_ACCELERATION_POLICY:
webkit_settings_set_hardware_acceleration_policy(settings, static_cast<WebKitHardwareAccelerationPolicy>(g_value_get_enum(value)));
break;
case PROP_ENABLE_BACK_FORWARD_NAVIGATION_GESTURES:
webkit_settings_set_enable_back_forward_navigation_gestures(settings, g_value_get_boolean(value));
break;
#endif
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);
@@ -560,6 +567,9 @@ static void webKitSettingsGetProperty(GObject* object, guint propId, GValue* val
case PROP_HARDWARE_ACCELERATION_POLICY:
g_value_set_enum(value, webkit_settings_get_hardware_acceleration_policy(settings));
break;
case PROP_ENABLE_BACK_FORWARD_NAVIGATION_GESTURES:
g_value_set_boolean(value, webkit_settings_get_enable_back_forward_navigation_gestures(settings));
break;
#endif
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);
@@ -1443,6 +1453,21 @@ static void webkit_settings_class_init(WebKitSettingsClass* klass)
WEBKIT_TYPE_HARDWARE_ACCELERATION_POLICY,
WEBKIT_HARDWARE_ACCELERATION_POLICY_ON_DEMAND,
readWriteConstructParamFlags));

/**
* WebKitSettings:enable-back-forward-navigation-gestures:
*
* Enable or disable horizontal swipe gesture for back-forward navigation.
*
* Since: 2.24
*/
g_object_class_install_property(gObjectClass,
PROP_ENABLE_BACK_FORWARD_NAVIGATION_GESTURES,
g_param_spec_boolean("enable-back-forward-navigation-gestures",
_("Enable back-forward navigation gestures"),
_("Whether horizontal swipe gesture will trigger back-forward navigation"),
FALSE,
readWriteConstructParamFlags));
#endif // PLATFOTM(GTK)
}

@@ -3512,6 +3537,44 @@ void webkit_settings_set_hardware_acceleration_policy(WebKitSettings* settings,
g_object_notify(G_OBJECT(settings), "hardware-acceleration-policy");
}

/**
* webkit_settings_get_enable_back_forward_navigation_gestures:
* @settings: a #WebKitSettings
*
* Get the #WebKitSettings:enable-back-forward-navigation-gestures property.
*
* Returns: %TRUE if horizontal swipe gesture will trigger back-forward navigaiton or %FALSE otherwise.
*
* Since: 2.24
*/
gboolean webkit_settings_get_enable_back_forward_navigation_gestures(WebKitSettings* settings)
{
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);

return settings->priv->enableBackForwardNavigationGestures;
}

/**
* webkit_settings_set_enable_back_forward_navigation_gestures:
* @settings: a #WebKitSettings
* @enableed: value to be set
*
* Set the #WebKitSettings:enable-back-forward-navigation-gestures property.
*
* Since: 2.24
*/
void webkit_settings_set_enable_back_forward_navigation_gestures(WebKitSettings* settings, gboolean enableed)
{
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));

WebKitSettingsPrivate* priv = settings->priv;
if (priv->enableBackForwardNavigationGestures == enableed)
return;

priv->enableBackForwardNavigationGestures = enableed;
g_object_notify(G_OBJECT(settings), "enable-back-forward-navigation-gestures");
}

/**
* webkit_settings_font_size_to_points:
* @pixels: the font size in pixels to convert to points
@@ -501,6 +501,16 @@ static void userAgentChanged(WebKitSettings* settings, GParamSpec*, WebKitWebVie
}

#if PLATFORM(GTK)
static void enableBackForwardNavigationGesturesChanged(WebKitSettings* settings, GParamSpec*, WebKitWebView* webView)
{
gboolean enable = webkit_settings_get_enable_back_forward_navigation_gestures(settings);

ViewGestureController& controller = webkitWebViewBaseViewGestureController(WEBKIT_WEB_VIEW_BASE(webView));
controller.setSwipeGestureEnabled(enable);

getPage(webView).setShouldRecordNavigationSnapshots(enable);
}

static void webkitWebViewUpdateFavicon(WebKitWebView* webView, cairo_surface_t* favicon)
{
WebKitWebViewPrivate* priv = webView->priv;
@@ -581,10 +591,16 @@ static void webkitWebViewUpdateSettings(WebKitWebView* webView)
page.setPreferences(*webkitSettingsGetPreferences(settings));
page.setCanRunModal(webkit_settings_get_allow_modal_dialogs(settings));
page.setCustomUserAgent(String::fromUTF8(webkit_settings_get_user_agent(settings)));
#if PLATFORM(GTK)
enableBackForwardNavigationGesturesChanged(settings, nullptr, webView);
#endif

g_signal_connect(settings, "notify::allow-modal-dialogs", G_CALLBACK(allowModalDialogsChanged), webView);
g_signal_connect(settings, "notify::zoom-text-only", G_CALLBACK(zoomTextOnlyChanged), webView);
g_signal_connect(settings, "notify::user-agent", G_CALLBACK(userAgentChanged), webView);
#if PLATFORM(GTK)
g_signal_connect(settings, "notify::enable-back-forward-navigation-gestures", G_CALLBACK(enableBackForwardNavigationGesturesChanged), webView);
#endif
}

static void webkitWebViewDisconnectSettingsSignalHandlers(WebKitWebView* webView)
@@ -596,6 +612,9 @@ static void webkitWebViewDisconnectSettingsSignalHandlers(WebKitWebView* webView
g_signal_handlers_disconnect_by_func(settings, reinterpret_cast<gpointer>(allowModalDialogsChanged), webView);
g_signal_handlers_disconnect_by_func(settings, reinterpret_cast<gpointer>(zoomTextOnlyChanged), webView);
g_signal_handlers_disconnect_by_func(settings, reinterpret_cast<gpointer>(userAgentChanged), webView);
#if PLATFORM(GTK)
g_signal_handlers_disconnect_by_func(settings, reinterpret_cast<gpointer>(enableBackForwardNavigationGesturesChanged), webView);
#endif
}

#if PLATFORM(GTK)
@@ -32,6 +32,7 @@
#include "NativeWebKeyboardEvent.h"
#include "NativeWebMouseEvent.h"
#include "NativeWebWheelEvent.h"
#include "ViewSnapshotStore.h"
#include "WebColorPickerGtk.h"
#include "WebContextMenuProxyGtk.h"
#include "WebEventFactory.h"
@@ -67,6 +68,16 @@ std::unique_ptr<DrawingAreaProxy> PageClientImpl::createDrawingAreaProxy(WebProc

void PageClientImpl::setViewNeedsDisplay(const WebCore::Region& region)
{
WebPageProxy* pageProxy = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(m_viewWidget));
ASSERT(pageProxy);

// During the gesture, the page may be displayed with an offset.
// To avoid visual glitches, redraw the whole page.
if (pageProxy->isShowingNavigationGestureSnapshot()) {
gtk_widget_queue_draw(m_viewWidget);
return;
}

gtk_widget_queue_draw_region(m_viewWidget, toCairoRegion(region).get());
}

@@ -255,6 +266,11 @@ void PageClientImpl::selectionDidChange()
webkitWebViewSelectionDidChange(WEBKIT_WEB_VIEW(m_viewWidget));
}

RefPtr<ViewSnapshot> PageClientImpl::takeViewSnapshot()
{
return webkitWebViewBaseTakeViewSnapshot(WEBKIT_WEB_VIEW_BASE(m_viewWidget));
}

void PageClientImpl::didChangeContentSize(const IntSize& size)
{
webkitWebViewBaseSetContentsSize(WEBKIT_WEB_VIEW_BASE(m_viewWidget), size);
@@ -404,6 +420,12 @@ void PageClientImpl::doneWithTouchEvent(const NativeWebTouchEvent& event, bool w

void PageClientImpl::wheelEventWasNotHandledByWebCore(const NativeWebWheelEvent& event)
{
ViewGestureController& controller = webkitWebViewBaseViewGestureController(WEBKIT_WEB_VIEW_BASE(m_viewWidget));
if (controller.isSwipeGestureEnabled()) {
controller.wheelEventWasNotHandledByWebCore(&event.nativeEvent()->scroll);
return;
}

webkitWebViewBaseForwardNextWheelEvent(WEBKIT_WEB_VIEW_BASE(m_viewWidget));
gtk_main_do_event(event.nativeEvent());
}
@@ -434,18 +456,37 @@ void PageClientImpl::willRecordNavigationSnapshot(WebBackForwardListItem&)

void PageClientImpl::didRemoveNavigationGestureSnapshot()
{
gtk_widget_queue_draw(m_viewWidget);
}

void PageClientImpl::didStartProvisionalLoadForMainFrame()
{
webkitWebViewBaseDidStartProvisionalLoadForMainFrame(WEBKIT_WEB_VIEW_BASE(m_viewWidget));
}

void PageClientImpl::didFirstVisuallyNonEmptyLayoutForMainFrame()
{
webkitWebViewBaseDidFirstVisuallyNonEmptyLayoutForMainFrame(WEBKIT_WEB_VIEW_BASE(m_viewWidget));
}

void PageClientImpl::didFinishLoadForMainFrame()
{
webkitWebViewBaseDidFinishLoadForMainFrame(WEBKIT_WEB_VIEW_BASE(m_viewWidget));
}

void PageClientImpl::didFailLoadForMainFrame()
{
webkitWebViewBaseDidFailLoadForMainFrame(WEBKIT_WEB_VIEW_BASE(m_viewWidget));
}

void PageClientImpl::didSameDocumentNavigationForMainFrame(SameDocumentNavigationType type)
{
webkitWebViewBaseDidSameDocumentNavigationForMainFrame(WEBKIT_WEB_VIEW_BASE(m_viewWidget), type);
}

void PageClientImpl::didSameDocumentNavigationForMainFrame(SameDocumentNavigationType)
void PageClientImpl::didRestoreScrollPosition()
{
webkitWebViewBaseDidRestoreScrollPosition(WEBKIT_WEB_VIEW_BASE(m_viewWidget));
}

void PageClientImpl::didChangeBackgroundColor()

0 comments on commit 714e2be

Please sign in to comment.