Diff
Modified: trunk/Source/WTF/Scripts/Preferences/WebPreferencesInternal.yaml (279354 => 279355)
--- trunk/Source/WTF/Scripts/Preferences/WebPreferencesInternal.yaml 2021-06-29 00:24:54 UTC (rev 279354)
+++ trunk/Source/WTF/Scripts/Preferences/WebPreferencesInternal.yaml 2021-06-29 00:39:15 UTC (rev 279355)
@@ -220,6 +220,18 @@
WebCore:
default: false
+EventHandlerDrivenSmoothKeyboardScrollingEnabled:
+ type: bool
+ humanReadableName: "EventHandler driven smooth keyboard scrolling"
+ humanReadableDescription: "Enable EventHandler driven smooth keyboard scrolling"
+ defaultValue:
+ WebKitLegacy:
+ default: false
+ WebKit:
+ default: false
+ WebCore:
+ default: false
+
# FIXME: This is not relevent for WebKitLegacy, so should be excluded from WebKitLegacy entirely.
ExperimentalPlugInSandboxProfilesEnabled:
type: bool
Modified: trunk/Source/WebCore/ChangeLog (279354 => 279355)
--- trunk/Source/WebCore/ChangeLog 2021-06-29 00:24:54 UTC (rev 279354)
+++ trunk/Source/WebCore/ChangeLog 2021-06-29 00:39:15 UTC (rev 279355)
@@ -1,3 +1,34 @@
+2021-06-28 Dana Estra <[email protected]>
+
+ Refactor MacOS keyboard scrolling and use KeyboardScroll struct
+ https://bugs.webkit.org/show_bug.cgi?id=226986
+
+ Reviewed by Tim Horton.
+
+ No tests yet.
+
+ * page/EventHandler.cpp:
+ (WebCore::EventHandler::defaultSpaceEventHandler):
+
+ Added usage of switch EventDrivenSmoothKeyboardScrolling
+ that when enabled sends KeyboardEvent to
+ HandleKeyboardScrolling.
+
+ (WebCore::EventHandler::scrollDistance):
+ (WebCore::EventHandler::handleKeyboardScrolling):
+
+ Makes KeyboardScroll and calls scrollRecursively.
+
+ (WebCore::EventHandler::defaultArrowEventHandler):
+
+ Added usage of switch EventDrivenSmoothKeyboardScrolling
+ that when enabled sends KeyboardEvent to
+ HandleKeyboardScrolling.
+
+ * page/EventHandler.h:
+ * page/KeyboardScroll.cpp: Added.
+ * page/KeyboardScroll.h: Added.
+
2021-06-28 Wenson Hsieh <[email protected]>
Live Text selections inside images is misaligned when "object-fit" is not "fill"
Modified: trunk/Source/WebCore/Headers.cmake (279354 => 279355)
--- trunk/Source/WebCore/Headers.cmake 2021-06-29 00:24:54 UTC (rev 279354)
+++ trunk/Source/WebCore/Headers.cmake 2021-06-29 00:39:15 UTC (rev 279355)
@@ -898,6 +898,7 @@
page/FrameViewLayoutContext.h
page/GlobalFrameIdentifier.h
page/GlobalWindowIdentifier.h
+ page/KeyboardScroll.h
page/LayoutMilestone.h
page/MediaCanStartListener.h
page/MediaControlsContextMenuItem.h
Modified: trunk/Source/WebCore/Sources.txt (279354 => 279355)
--- trunk/Source/WebCore/Sources.txt 2021-06-29 00:24:54 UTC (rev 279354)
+++ trunk/Source/WebCore/Sources.txt 2021-06-29 00:39:15 UTC (rev 279355)
@@ -1711,6 +1711,7 @@
page/FrameViewLayoutContext.cpp
page/History.cpp
page/ImageOverlayController.cpp
+page/KeyboardScroll.cpp
page/IntersectionObserver.cpp
page/IntersectionObserverEntry.cpp
page/Location.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (279354 => 279355)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-06-29 00:24:54 UTC (rev 279354)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-06-29 00:39:15 UTC (rev 279355)
@@ -667,6 +667,7 @@
1DBC1B562347B3D200B901AF /* PictureInPictureObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 1DBC1B552347B3D200B901AF /* PictureInPictureObserver.h */; settings = {ATTRIBUTES = (Private, ); }; };
1DD3B4C6251DA0B80069B24A /* VideoLayerManagerObjC.mm in Sources */ = {isa = PBXBuildFile; fileRef = 52D5A18D1C54590300DE34A3 /* VideoLayerManagerObjC.mm */; };
1DF7E81F251A9E0600DB8F61 /* TextTrackRepresentation.h in Headers */ = {isa = PBXBuildFile; fileRef = CDD1E525167BA56400CE820B /* TextTrackRepresentation.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 1F020AEF26780FCE0000809A /* KeyboardScroll.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F020AED26780FCE0000809A /* KeyboardScroll.h */; settings = {ATTRIBUTES = (Private, ); }; };
1F36EA9C1E21BA1700621E25 /* WebBackgroundTaskController.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F36EA9A1E21BA1700621E25 /* WebBackgroundTaskController.h */; settings = {ATTRIBUTES = (Private, ); }; };
1F72BF0B187FD45C0009BCB3 /* TileControllerMemoryHandlerIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F72BF09187FD4270009BCB3 /* TileControllerMemoryHandlerIOS.h */; settings = {ATTRIBUTES = (Private, ); }; };
1F8756B21E22C3350042C40D /* WebSQLiteDatabaseTrackerClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F8756B11E22BEEF0042C40D /* WebSQLiteDatabaseTrackerClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -7061,8 +7062,10 @@
1DEF06DC233D2E1C00EE228D /* DocumentPictureInPicture.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentPictureInPicture.cpp; sourceTree = "<group>"; };
1DEF06DD233D2E1C00EE228D /* DocumentPictureInPicture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocumentPictureInPicture.h; sourceTree = "<group>"; };
1DEF06DE233D2E1C00EE228D /* Document+PictureInPicture.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "Document+PictureInPicture.idl"; sourceTree = "<group>"; };
+ 1F020AED26780FCE0000809A /* KeyboardScroll.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KeyboardScroll.h; sourceTree = "<group>"; };
1F36EA9A1E21BA1700621E25 /* WebBackgroundTaskController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebBackgroundTaskController.h; sourceTree = "<group>"; };
1F36EA9B1E21BA1700621E25 /* WebBackgroundTaskController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebBackgroundTaskController.mm; sourceTree = "<group>"; };
+ 1F53039A26854E6600236303 /* KeyboardScroll.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = KeyboardScroll.cpp; sourceTree = "<group>"; };
1F72BF08187FD4270009BCB3 /* TileControllerMemoryHandlerIOS.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TileControllerMemoryHandlerIOS.cpp; sourceTree = "<group>"; };
1F72BF09187FD4270009BCB3 /* TileControllerMemoryHandlerIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TileControllerMemoryHandlerIOS.h; sourceTree = "<group>"; };
1F8756B01E22BEEF0042C40D /* WebSQLiteDatabaseTrackerClient.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebSQLiteDatabaseTrackerClient.mm; sourceTree = "<group>"; };
@@ -22512,6 +22515,8 @@
0F4710D81DB6FE22002DCEC3 /* IntersectionObserverEntry.cpp */,
0F4710D91DB6FE22002DCEC3 /* IntersectionObserverEntry.h */,
0F4710DA1DB6FE22002DCEC3 /* IntersectionObserverEntry.idl */,
+ 1F53039A26854E6600236303 /* KeyboardScroll.cpp */,
+ 1F020AED26780FCE0000809A /* KeyboardScroll.h */,
931D72F515FE695300C4C07E /* LayoutMilestone.h */,
BCE1C41A0D982980003B02F2 /* Location.cpp */,
BCE1C4190D982980003B02F2 /* Location.h */,
@@ -34153,6 +34158,7 @@
BCEFE1EB0DCA5F6400739219 /* JSXSLTProcessor.h in Headers */,
83B74EF61F3E0BF200996BC7 /* KeepaliveRequestTracker.h in Headers */,
85031B440A44EFC700F992E0 /* KeyboardEvent.h in Headers */,
+ 1F020AEF26780FCE0000809A /* KeyboardScroll.h in Headers */,
1AE00D59182DAC8D00087DD7 /* KeyedCoding.h in Headers */,
517A63C51B74318F00E7DCDC /* KeyedDecoderCF.h in Headers */,
517A63C61B74319200E7DCDC /* KeyedEncoderCF.h in Headers */,
Modified: trunk/Source/WebCore/page/EventHandler.cpp (279354 => 279355)
--- trunk/Source/WebCore/page/EventHandler.cpp 2021-06-29 00:24:54 UTC (rev 279354)
+++ trunk/Source/WebCore/page/EventHandler.cpp 2021-06-29 00:39:15 UTC (rev 279355)
@@ -68,6 +68,7 @@
#include "ImageOverlayController.h"
#include "InspectorInstrumentation.h"
#include "KeyboardEvent.h"
+#include "KeyboardScroll.h"
#include "Logging.h"
#include "MouseEvent.h"
#include "MouseEventWithHitTestResults.h"
@@ -4200,7 +4201,8 @@
if (!view)
return;
- if (view->logicalScroll(direction, ScrollByPage))
+ bool defaultHandled = m_frame.settings().eventHandlerDrivenSmoothKeyboardScrollingEnabled() ? handleKeyboardScrolling(event) : view->logicalScroll(direction, ScrollByPage);
+ if (defaultHandled)
event.setDefaultHandled();
}
@@ -4232,11 +4234,91 @@
event.setDefaultHandled();
}
+float EventHandler::scrollDistance(ScrollDirection direction, ScrollGranularity granularity)
+{
+ auto scrollbar = [&] {
+ if (direction == ScrollDirection::ScrollUp || direction == ScrollDirection::ScrollDown)
+ return m_frame.view()->verticalScrollbar();
+ return m_frame.view()->horizontalScrollbar();
+ }();
+
+ switch (granularity) {
+ case ScrollGranularity::ScrollByLine:
+ return scrollbar->lineStep();
+ case ScrollGranularity::ScrollByPage:
+ return scrollbar->pageStep();
+ case ScrollGranularity::ScrollByDocument:
+ return scrollbar->totalSize();
+ case ScrollGranularity::ScrollByPixel:
+ return scrollbar->pixelStep();
+ }
+}
+bool EventHandler::handleKeyboardScrolling(KeyboardEvent& event)
+{
+ // FIXME (bug 227459): This logic does not account for writing-mode.
+
+ enum class Key : uint8_t { LeftArrow, RightArrow, UpArrow, DownArrow, Space };
+
+ Key key;
+ if (event.keyIdentifier() == "Left")
+ key = Key::LeftArrow;
+ else if (event.keyIdentifier() == "Right")
+ key = Key::RightArrow;
+ else if (event.keyIdentifier() == "Up")
+ key = Key::UpArrow;
+ else if (event.keyIdentifier() == "Down")
+ key = Key::DownArrow;
+ else if (event.charCode() == ' ')
+ key = Key::Space;
+ else
+ return false;
+
+ auto granularity = [&] {
+ switch (key) {
+ case Key::LeftArrow:
+ case Key::RightArrow:
+ return event.altKey() ? ScrollGranularity::ScrollByPage : ScrollGranularity::ScrollByLine;
+ case Key::UpArrow:
+ case Key::DownArrow:
+ if (event.metaKey())
+ return ScrollGranularity::ScrollByDocument;
+ if (event.altKey())
+ return ScrollGranularity::ScrollByPage;
+ return ScrollGranularity::ScrollByLine;
+ case Key::Space:
+ return ScrollGranularity::ScrollByPage;
+ };
+ }();
+
+ auto direction = [&] {
+ switch (key) {
+ case Key::LeftArrow:
+ return ScrollDirection::ScrollLeft;
+ case Key::RightArrow:
+ return ScrollDirection::ScrollRight;
+ case Key::UpArrow:
+ return ScrollDirection::ScrollUp;
+ case Key::DownArrow:
+ return ScrollDirection::ScrollDown;
+ case Key::Space:
+ return event.shiftKey() ? ScrollDirection::ScrollUp : ScrollDirection::ScrollDown;
+ }
+ }();
+
+ return EventHandler::scrollRecursively(direction, granularity, nullptr);
+}
+
void EventHandler::defaultArrowEventHandler(FocusDirection focusDirection, KeyboardEvent& event)
{
ASSERT(event.type() == eventNames().keydownEvent);
+ if (!isSpatialNavigationEnabled(&m_frame)) {
+ if (m_frame.settings().eventHandlerDrivenSmoothKeyboardScrollingEnabled())
+ handleKeyboardScrolling(event);
+ return;
+ }
+
if (event.ctrlKey() || event.metaKey() || event.altGraphKey() || event.shiftKey())
return;
@@ -4244,9 +4326,6 @@
if (!page)
return;
- if (!isSpatialNavigationEnabled(&m_frame))
- return;
-
// Arrows and other possible directional navigation keys can be used in design
// mode editing.
if (m_frame.document()->inDesignMode())
Modified: trunk/Source/WebCore/page/EventHandler.h (279354 => 279355)
--- trunk/Source/WebCore/page/EventHandler.h 2021-06-29 00:24:54 UTC (rev 279354)
+++ trunk/Source/WebCore/page/EventHandler.h 2021-06-29 00:39:15 UTC (rev 279355)
@@ -29,6 +29,7 @@
#include "DragActions.h"
#include "FocusDirection.h"
#include "HitTestRequest.h"
+#include "KeyboardScroll.h"
#include "LayoutPoint.h"
#include "PlatformMouseEvent.h"
#include "RenderObject.h"
@@ -375,6 +376,9 @@
bool handleMousePressEventDoubleClick(const MouseEventWithHitTestResults&);
bool handleMousePressEventTripleClick(const MouseEventWithHitTestResults&);
+ float scrollDistance(ScrollDirection, ScrollGranularity);
+ bool handleKeyboardScrolling(KeyboardEvent&);
+
#if ENABLE(DRAG_SUPPORT)
bool handleMouseDraggedEvent(const MouseEventWithHitTestResults&, CheckDragHysteresis = ShouldCheckDragHysteresis);
bool shouldAllowMouseDownToStartDrag() const;
Added: trunk/Source/WebCore/page/KeyboardScroll.cpp (0 => 279355)
--- trunk/Source/WebCore/page/KeyboardScroll.cpp (rev 0)
+++ trunk/Source/WebCore/page/KeyboardScroll.cpp 2021-06-29 00:39:15 UTC (rev 279355)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2021 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.
+ */
+
+#include "config.h"
+#include "KeyboardScroll.h"
+
+namespace WebCore {
+
+FloatSize unitVectorForScrollDirection(ScrollDirection direction)
+{
+ switch (direction) {
+ case ScrollDirection::ScrollUp:
+ return { 0, -1 };
+ case ScrollDirection::ScrollDown:
+ return { 0, 1 };
+ case ScrollDirection::ScrollLeft:
+ return { -1, 0 };
+ case ScrollDirection::ScrollRight:
+ return { 1, 0 };
+ }
+}
+
+}
Added: trunk/Source/WebCore/page/KeyboardScroll.h (0 => 279355)
--- trunk/Source/WebCore/page/KeyboardScroll.h (rev 0)
+++ trunk/Source/WebCore/page/KeyboardScroll.h 2021-06-29 00:39:15 UTC (rev 279355)
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2021 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 "ScrollTypes.h"
+
+namespace WebCore {
+
+WEBCORE_EXPORT FloatSize unitVectorForScrollDirection(ScrollDirection);
+
+struct KeyboardScroll {
+ FloatSize offset; // Points per increment.
+ FloatSize maximumVelocity; // Points per second.
+ FloatSize force;
+
+ ScrollGranularity granularity;
+ ScrollDirection direction;
+};
+
+struct KeyboardScrollParameters {
+ float springMass { 1 };
+ float springStiffness { 109 };
+ float springDamping { 20 };
+
+ float maximumVelocityMultiplier { 25 };
+ float timeToMaximumVelocity { 1 };
+
+ float rubberBandForce { 5000 };
+
+ static const KeyboardScrollParameters& parameters()
+ {
+ static const KeyboardScrollParameters parameters;
+ return parameters;
+ }
+};
+
+} // namespace WebCore
Modified: trunk/Source/WebCore/page/scrolling/ScrollLatchingController.cpp (279354 => 279355)
--- trunk/Source/WebCore/page/scrolling/ScrollLatchingController.cpp 2021-06-29 00:24:54 UTC (rev 279354)
+++ trunk/Source/WebCore/page/scrolling/ScrollLatchingController.cpp 2021-06-29 00:39:15 UTC (rev 279355)
@@ -29,6 +29,9 @@
#if ENABLE(WHEEL_EVENT_LATCHING)
#include "Element.h"
+#include "Frame.h"
+#include "FrameView.h"
+#include "Logging.h"
#include "PlatformWheelEvent.h"
#include "ScrollableArea.h"
#include <wtf/text/TextStream.h>
Modified: trunk/Source/WebKit/ChangeLog (279354 => 279355)
--- trunk/Source/WebKit/ChangeLog 2021-06-29 00:24:54 UTC (rev 279354)
+++ trunk/Source/WebKit/ChangeLog 2021-06-29 00:39:15 UTC (rev 279355)
@@ -1,3 +1,37 @@
+2021-06-28 Dana Estra <[email protected]>
+
+ Refactor MacOS keyboard scrolling and use KeyboardScroll struct
+ https://bugs.webkit.org/show_bug.cgi?id=226986
+
+ Reviewed by Tim Horton.
+
+ In addition to notes underneath, changed usage of WebKit::KeyboardScroll, WebKit::ScrollingIncrement, and WebKit::ScrollingDirection to
+ WebCore::KeyboardScroll, WebCore::ScrollGranularity, and WebCore::ScrollDirection, respectively.
+
+ * UIProcess/ios/WKKeyboardScrollingAnimator.h:
+ * UIProcess/ios/WKKeyboardScrollingAnimator.mm:
+ (-[WKKeyboardScrollingAnimator parameters]):
+
+ Deleted. Now lives in WebCore/KeyboardScroll.h.
+
+ (unitVector):
+
+ Deleted. Now lives in WebCore/KeyboardScroll.h.
+
+ (perpendicularAbsoluteUnitVector):
+ (boxSide):
+ (-[WKKeyboardScrollingAnimator keyboardScrollForEvent:]):
+ (-[WKKeyboardScrollingAnimator beginWithEvent:]):
+ (farthestPointInDirection):
+ (-[WKKeyboardScrollViewAnimator distanceForIncrement:inDirection:]):
+ * WebProcess/WebPage/mac/WebPageMac.mm:
+ (WebKit::WebPage::handleEditingKeyboardEvent):
+ (WebKit::WebPage::performNonEditingBehaviorForSelector):
+
+ Added switch that removes selectors that are now handled by
+ EventHandler when EventHandlerDrivenSmoothKeyboardScrolling
+ is enabled.
+
2021-06-28 Chris Dumez <[email protected]>
NetworkProcessProxy::networkProcessDidTerminate() should copy process pools before iterating over them
Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (279354 => 279355)
--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2021-06-29 00:24:54 UTC (rev 279354)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2021-06-29 00:39:15 UTC (rev 279355)
@@ -108,6 +108,7 @@
#import <WebCore/FontAttributeChanges.h>
#import <WebCore/InputMode.h>
#import <WebCore/KeyEventCodesIOS.h>
+#import <WebCore/KeyboardScroll.h>
#import <WebCore/LocalizedStrings.h>
#import <WebCore/MIMETypeRegistry.h>
#import <WebCore/NotImplemented.h>
@@ -116,6 +117,7 @@
#import <WebCore/PathUtilities.h>
#import <WebCore/PromisedAttachmentInfo.h>
#import <WebCore/RuntimeApplicationChecks.h>
+#import <WebCore/ScrollTypes.h>
#import <WebCore/Scrollbar.h>
#import <WebCore/ShareData.h>
#import <WebCore/TextAlternativeWithRange.h>
@@ -5950,21 +5952,23 @@
return YES;
}
-- (CGFloat)keyboardScrollViewAnimator:(WKKeyboardScrollViewAnimator *)animator distanceForIncrement:(WebKit::ScrollingIncrement)increment inDirection:(WebKit::ScrollingDirection)direction
+- (CGFloat)keyboardScrollViewAnimator:(WKKeyboardScrollViewAnimator *)animator distanceForIncrement:(WebCore::ScrollGranularity)increment inDirection:(WebCore::ScrollDirection)direction
{
- BOOL directionIsHorizontal = direction == WebKit::ScrollingDirection::Left || direction == WebKit::ScrollingDirection::Right;
+ BOOL directionIsHorizontal = direction == WebCore::ScrollDirection::ScrollLeft || direction == WebCore::ScrollDirection::ScrollRight;
switch (increment) {
- case WebKit::ScrollingIncrement::Document: {
+ case WebCore::ScrollGranularity::ScrollByDocument: {
CGSize documentSize = [self convertRect:self.bounds toView:self.webView].size;
return directionIsHorizontal ? documentSize.width : documentSize.height;
}
- case WebKit::ScrollingIncrement::Page: {
+ case WebCore::ScrollGranularity::ScrollByPage: {
CGSize pageSize = [self convertSize:CGSizeMake(0, WebCore::Scrollbar::pageStep(_page->unobscuredContentRect().height(), self.bounds.size.height)) toView:self.webView];
return directionIsHorizontal ? pageSize.width : pageSize.height;
}
- case WebKit::ScrollingIncrement::Line:
+ case WebCore::ScrollGranularity::ScrollByLine:
return [self convertSize:CGSizeMake(0, WebCore::Scrollbar::pixelsPerLineStep()) toView:self.webView].height;
+ case WebCore::ScrollGranularity::ScrollByPixel:
+ return 0;
}
ASSERT_NOT_REACHED();
return 0;
Modified: trunk/Source/WebKit/UIProcess/ios/WKKeyboardScrollingAnimator.h (279354 => 279355)
--- trunk/Source/WebKit/UIProcess/ios/WKKeyboardScrollingAnimator.h 2021-06-29 00:24:54 UTC (rev 279354)
+++ trunk/Source/WebKit/UIProcess/ios/WKKeyboardScrollingAnimator.h 2021-06-29 00:39:15 UTC (rev 279355)
@@ -23,6 +23,8 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
+#import <WebCore/ScrollTypes.h>
+
#if PLATFORM(IOS_FAMILY)
namespace WebCore {
@@ -29,23 +31,7 @@
class FloatPoint;
}
-namespace WebKit {
-enum class ScrollingIncrement : uint8_t {
- Document,
- Page,
- Line
-};
-
-enum class ScrollingDirection : uint8_t {
- Up,
- Down,
- Left,
- Right
-};
-
-}
-
@class UIScrollView;
@class WebEvent;
@protocol WKKeyboardScrollViewAnimatorDelegate;
@@ -71,7 +57,7 @@
@protocol WKKeyboardScrollViewAnimatorDelegate <NSObject>
@optional
- (BOOL)isScrollableForKeyboardScrollViewAnimator:(WKKeyboardScrollViewAnimator *)animator;
-- (CGFloat)keyboardScrollViewAnimator:(WKKeyboardScrollViewAnimator *)animator distanceForIncrement:(WebKit::ScrollingIncrement)increment inDirection:(WebKit::ScrollingDirection)direction;
+- (CGFloat)keyboardScrollViewAnimator:(WKKeyboardScrollViewAnimator *)animator distanceForIncrement:(WebCore::ScrollGranularity)increment inDirection:(WebCore::ScrollDirection)direction;
- (void)keyboardScrollViewAnimatorWillScroll:(WKKeyboardScrollViewAnimator *)animator;
- (void)keyboardScrollViewAnimatorDidFinishScrolling:(WKKeyboardScrollViewAnimator *)animator;
Modified: trunk/Source/WebKit/UIProcess/ios/WKKeyboardScrollingAnimator.mm (279354 => 279355)
--- trunk/Source/WebKit/UIProcess/ios/WKKeyboardScrollingAnimator.mm 2021-06-29 00:24:54 UTC (rev 279354)
+++ trunk/Source/WebKit/UIProcess/ios/WKKeyboardScrollingAnimator.mm 2021-06-29 00:39:15 UTC (rev 279355)
@@ -33,6 +33,7 @@
#import <QuartzCore/CADisplayLink.h>
#import <WebCore/FloatPoint.h>
#import <WebCore/KeyEventCodesIOS.h>
+#import <WebCore/KeyboardScroll.h>
#import <WebCore/RectEdges.h>
#import <WebCore/WebEvent.h>
#import <WebKit/UIKitSPI.h>
@@ -40,34 +41,11 @@
#import <wtf/RetainPtr.h>
#import <wtf/WeakObjCPtr.h>
-namespace WebKit {
-struct KeyboardScroll {
- WebCore::FloatSize offset; // Points per increment.
- WebCore::FloatSize maximumVelocity; // Points per second.
- WebCore::FloatSize force;
-
- WebKit::ScrollingIncrement increment;
- WebKit::ScrollingDirection direction;
-};
-
-struct KeyboardScrollParameters {
- CGFloat springMass { 1 };
- CGFloat springStiffness { 109 };
- CGFloat springDamping { 20 };
-
- CGFloat maximumVelocityMultiplier { 25 };
- CGFloat timeToMaximumVelocity { 1 };
-
- CGFloat rubberBandForce { 5000 };
-};
-
-}
-
@protocol WKKeyboardScrollableInternal <NSObject>
@required
- (BOOL)isKeyboardScrollable;
-- (CGFloat)distanceForIncrement:(WebKit::ScrollingIncrement)increment inDirection:(WebKit::ScrollingDirection)direction;
+- (CGFloat)distanceForIncrement:(WebCore::ScrollGranularity)increment inDirection:(WebCore::ScrollDirection)direction;
- (void)scrollToContentOffset:(WebCore::FloatPoint)offset animated:(BOOL)animated;
- (void)scrollWithScrollToExtentAnimationTo:(CGPoint)offset;
- (CGPoint)contentOffset;
@@ -97,7 +75,7 @@
id <WKKeyboardScrollableInternal> _scrollable;
RetainPtr<CADisplayLink> _displayLink;
- std::optional<WebKit::KeyboardScroll> _currentScroll;
+ std::optional<WebCore::KeyboardScroll> _currentScroll;
BOOL _scrollTriggeringKeyIsPressed;
@@ -124,9 +102,9 @@
return self;
}
-- (const WebKit::KeyboardScrollParameters &)parameters
+- (const WebCore::KeyboardScrollParameters &)parameters
{
- static const WebKit::KeyboardScrollParameters parameters;
+ static const WebCore::KeyboardScrollParameters parameters;
return parameters;
}
@@ -137,47 +115,33 @@
_scrollable = nil;
}
-static WebCore::FloatSize unitVector(WebKit::ScrollingDirection direction)
+static WebCore::FloatSize perpendicularAbsoluteUnitVector(WebCore::ScrollDirection direction)
{
switch (direction) {
- case WebKit::ScrollingDirection::Up:
- return { 0, -1 };
- case WebKit::ScrollingDirection::Down:
- return { 0, 1 };
- case WebKit::ScrollingDirection::Left:
- return { -1, 0 };
- case WebKit::ScrollingDirection::Right:
+ case WebCore::ScrollDirection::ScrollUp:
+ case WebCore::ScrollDirection::ScrollDown:
return { 1, 0 };
- }
-}
-
-static WebCore::FloatSize perpendicularAbsoluteUnitVector(WebKit::ScrollingDirection direction)
-{
- switch (direction) {
- case WebKit::ScrollingDirection::Up:
- case WebKit::ScrollingDirection::Down:
- return { 1, 0 };
- case WebKit::ScrollingDirection::Left:
- case WebKit::ScrollingDirection::Right:
+ case WebCore::ScrollDirection::ScrollLeft:
+ case WebCore::ScrollDirection::ScrollRight:
return { 0, 1 };
}
}
-static WebCore::BoxSide boxSide(WebKit::ScrollingDirection direction)
+static WebCore::BoxSide boxSide(WebCore::ScrollDirection direction)
{
switch (direction) {
- case WebKit::ScrollingDirection::Up:
+ case WebCore::ScrollDirection::ScrollUp:
return WebCore::BoxSide::Top;
- case WebKit::ScrollingDirection::Down:
+ case WebCore::ScrollDirection::ScrollDown:
return WebCore::BoxSide::Bottom;
- case WebKit::ScrollingDirection::Left:
+ case WebCore::ScrollDirection::ScrollLeft:
return WebCore::BoxSide::Left;
- case WebKit::ScrollingDirection::Right:
+ case WebCore::ScrollDirection::ScrollRight:
return WebCore::BoxSide::Right;
}
}
-- (std::optional<WebKit::KeyboardScroll>)keyboardScrollForEvent:(::WebEvent *)event
+- (std::optional<WebCore::KeyboardScroll>)keyboardScrollForEvent:(::WebEvent *)event
{
static const unsigned kWebSpaceKey = 0x20;
@@ -255,22 +219,22 @@
case Key::LeftArrow:
case Key::RightArrow:
if (altPressed)
- return WebKit::ScrollingIncrement::Page;
- return WebKit::ScrollingIncrement::Line;
+ return WebCore::ScrollGranularity::ScrollByPage;
+ return WebCore::ScrollGranularity::ScrollByLine;
case Key::UpArrow:
case Key::DownArrow:
if (altPressed)
- return WebKit::ScrollingIncrement::Page;
+ return WebCore::ScrollGranularity::ScrollByPage;
if (cmdPressed)
- return WebKit::ScrollingIncrement::Document;
- return WebKit::ScrollingIncrement::Line;
+ return WebCore::ScrollGranularity::ScrollByDocument;
+ return WebCore::ScrollGranularity::ScrollByLine;
case Key::PageUp:
case Key::PageDown:
case Key::Space:
- return WebKit::ScrollingIncrement::Page;
+ return WebCore::ScrollGranularity::ScrollByPage;
case Key::Other:
ASSERT_NOT_REACHED();
- return WebKit::ScrollingIncrement::Line;
+ return WebCore::ScrollGranularity::ScrollByLine;
};
}();
@@ -277,28 +241,30 @@
auto direction = ^() {
switch (key) {
case Key::LeftArrow:
- return WebKit::ScrollingDirection::Left;
+ return WebCore::ScrollDirection::ScrollLeft;
case Key::RightArrow:
- return WebKit::ScrollingDirection::Right;
+ return WebCore::ScrollDirection::ScrollRight;
case Key::UpArrow:
case Key::PageUp:
- return WebKit::ScrollingDirection::Up;
+ return WebCore::ScrollDirection::ScrollUp;
case Key::DownArrow:
case Key::PageDown:
- return WebKit::ScrollingDirection::Down;
+ return WebCore::ScrollDirection::ScrollDown;
case Key::Space:
- return shiftPressed ? WebKit::ScrollingDirection::Up : WebKit::ScrollingDirection::Down;
+ return shiftPressed ? WebCore::ScrollDirection::ScrollUp : WebCore::ScrollDirection::ScrollDown;
case Key::Other:
ASSERT_NOT_REACHED();
- return WebKit::ScrollingDirection::Down;
+ return WebCore::ScrollDirection::ScrollDown;
};
}();
+ // FIXME (227461): Replace with call to WebCore::KeyboardScroll constructor.
+
CGFloat scrollDistance = [_scrollable distanceForIncrement:increment inDirection:direction];
- WebKit::KeyboardScroll scroll;
- scroll.offset = unitVector(direction).scaled(scrollDistance);
- scroll.increment = increment;
+ WebCore::KeyboardScroll scroll;
+ scroll.offset = WebCore::unitVectorForScrollDirection(direction).scaled(scrollDistance);
+ scroll.granularity = increment;
scroll.direction = direction;
scroll.maximumVelocity = scroll.offset.scaled(self.parameters.maximumVelocityMultiplier);
@@ -327,7 +293,7 @@
_scrollTriggeringKeyIsPressed = YES;
_currentScroll = scroll;
- if (scroll->increment == WebKit::ScrollingIncrement::Document) {
+ if (scroll->granularity == WebCore::ScrollGranularity::ScrollByDocument) {
_velocity = { };
[self stopAnimatedScroll];
[self stopDisplayLink];
@@ -360,16 +326,16 @@
}
}
-static WebCore::FloatPoint farthestPointInDirection(WebCore::FloatPoint a, WebCore::FloatPoint b, WebKit::ScrollingDirection direction)
+static WebCore::FloatPoint farthestPointInDirection(WebCore::FloatPoint a, WebCore::FloatPoint b, WebCore::ScrollDirection direction)
{
switch (direction) {
- case WebKit::ScrollingDirection::Up:
+ case WebCore::ScrollDirection::ScrollUp:
return WebCore::FloatPoint(a.x(), std::min(a.y(), b.y()));
- case WebKit::ScrollingDirection::Down:
+ case WebCore::ScrollDirection::ScrollDown:
return WebCore::FloatPoint(a.x(), std::max(a.y(), b.y()));
- case WebKit::ScrollingDirection::Left:
+ case WebCore::ScrollDirection::ScrollLeft:
return WebCore::FloatPoint(std::min(a.x(), b.x()), a.y());
- case WebKit::ScrollingDirection::Right:
+ case WebCore::ScrollDirection::ScrollRight:
return WebCore::FloatPoint(std::max(a.x(), b.x()), a.y());
}
@@ -446,7 +412,7 @@
// The scroll view cannot scroll in this direction, and is rubber-banding.
// Apply a constant and significant force; otherwise, the force for a
// single-line increment is not strong enough to rubber-band perceptibly.
- force = unitVector(direction).scaled(self.parameters.rubberBandForce);
+ force = WebCore::unitVectorForScrollDirection(direction).scaled(self.parameters.rubberBandForce);
}
// If we've reached or exceeded the maximum velocity, stop applying any force.
@@ -566,7 +532,7 @@
return [_delegate isScrollableForKeyboardScrollViewAnimator:self];
}
-- (CGFloat)distanceForIncrement:(WebKit::ScrollingIncrement)increment inDirection:(WebKit::ScrollingDirection)direction
+- (CGFloat)distanceForIncrement:(WebCore::ScrollGranularity)increment inDirection:(WebCore::ScrollDirection)direction
{
auto scrollView = _scrollView.getAutoreleased();
if (!scrollView)
@@ -575,16 +541,18 @@
const CGFloat defaultPageScrollFraction = 0.8;
const CGFloat defaultLineScrollHeight = 40;
- BOOL directionIsHorizontal = direction == WebKit::ScrollingDirection::Left || direction == WebKit::ScrollingDirection::Right;
+ BOOL directionIsHorizontal = direction == WebCore::ScrollDirection::ScrollLeft || direction == WebCore::ScrollDirection::ScrollRight;
if (!_delegateRespondsToDistanceForIncrement) {
switch (increment) {
- case WebKit::ScrollingIncrement::Document:
+ case WebCore::ScrollGranularity::ScrollByDocument:
return directionIsHorizontal ? scrollView.contentSize.width : scrollView.contentSize.height;
- case WebKit::ScrollingIncrement::Page:
+ case WebCore::ScrollGranularity::ScrollByPage:
return (directionIsHorizontal ? scrollView.frame.size.width : scrollView.frame.size.height) * defaultPageScrollFraction;
- case WebKit::ScrollingIncrement::Line:
+ case WebCore::ScrollGranularity::ScrollByLine:
return defaultLineScrollHeight * scrollView.zoomScale;
+ case WebCore::ScrollGranularity::ScrollByPixel:
+ return 0;
}
ASSERT_NOT_REACHED();
return 0;
Modified: trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm (279354 => 279355)
--- trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm 2021-06-29 00:24:54 UTC (rev 279354)
+++ trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm 2021-06-29 00:39:15 UTC (rev 279355)
@@ -463,31 +463,34 @@
// Should such non-editing behaviors be implemented in Editor or EventHandler::defaultArrowEventHandler() perhaps?
bool didPerformAction = false;
+
+ if (!frame->settings().eventHandlerDrivenSmoothKeyboardScrollingEnabled()) {
+ if (selector == "moveUp:")
+ didPerformAction = scroll(m_page.get(), ScrollUp, ScrollByLine);
+ else if (selector == "moveToBeginningOfParagraph:")
+ didPerformAction = scroll(m_page.get(), ScrollUp, ScrollByPage);
+ else if (selector == "moveToBeginningOfDocument:") {
+ didPerformAction = scroll(m_page.get(), ScrollUp, ScrollByDocument);
+ didPerformAction |= scroll(m_page.get(), ScrollLeft, ScrollByDocument);
+ } else if (selector == "moveDown:")
+ didPerformAction = scroll(m_page.get(), ScrollDown, ScrollByLine);
+ else if (selector == "moveToEndOfParagraph:")
+ didPerformAction = scroll(m_page.get(), ScrollDown, ScrollByPage);
+ else if (selector == "moveToEndOfDocument:") {
+ didPerformAction = scroll(m_page.get(), ScrollDown, ScrollByDocument);
+ didPerformAction |= scroll(m_page.get(), ScrollLeft, ScrollByDocument);
+ } else if (selector == "moveLeft:")
+ didPerformAction = scroll(m_page.get(), ScrollLeft, ScrollByLine);
+ else if (selector == "moveWordLeft:")
+ didPerformAction = scroll(m_page.get(), ScrollLeft, ScrollByPage);
+ else if (selector == "moveRight:")
+ didPerformAction = scroll(m_page.get(), ScrollRight, ScrollByLine);
+ else if (selector == "moveWordRight:")
+ didPerformAction = scroll(m_page.get(), ScrollRight, ScrollByPage);
+ }
- if (selector == "moveUp:")
- didPerformAction = scroll(m_page.get(), ScrollUp, ScrollByLine);
- else if (selector == "moveToBeginningOfParagraph:")
- didPerformAction = scroll(m_page.get(), ScrollUp, ScrollByPage);
- else if (selector == "moveToBeginningOfDocument:") {
- didPerformAction = scroll(m_page.get(), ScrollUp, ScrollByDocument);
- didPerformAction |= scroll(m_page.get(), ScrollLeft, ScrollByDocument);
- } else if (selector == "moveDown:")
- didPerformAction = scroll(m_page.get(), ScrollDown, ScrollByLine);
- else if (selector == "moveToEndOfParagraph:")
- didPerformAction = scroll(m_page.get(), ScrollDown, ScrollByPage);
- else if (selector == "moveToEndOfDocument:") {
- didPerformAction = scroll(m_page.get(), ScrollDown, ScrollByDocument);
- didPerformAction |= scroll(m_page.get(), ScrollLeft, ScrollByDocument);
- } else if (selector == "moveLeft:")
- didPerformAction = scroll(m_page.get(), ScrollLeft, ScrollByLine);
- else if (selector == "moveWordLeft:")
- didPerformAction = scroll(m_page.get(), ScrollLeft, ScrollByPage);
- else if (selector == "moveToLeftEndOfLine:")
+ if (selector == "moveToLeftEndOfLine:")
didPerformAction = m_userInterfaceLayoutDirection == WebCore::UserInterfaceLayoutDirection::LTR ? m_page->backForward().goBack() : m_page->backForward().goForward();
- else if (selector == "moveRight:")
- didPerformAction = scroll(m_page.get(), ScrollRight, ScrollByLine);
- else if (selector == "moveWordRight:")
- didPerformAction = scroll(m_page.get(), ScrollRight, ScrollByPage);
else if (selector == "moveToRightEndOfLine:")
didPerformAction = m_userInterfaceLayoutDirection == WebCore::UserInterfaceLayoutDirection::LTR ? m_page->backForward().goForward() : m_page->backForward().goBack();