Changeset 226067 in webkit


Ignore:
Timestamp:
Dec 18, 2017 12:13:56 PM (6 years ago)
Author:
Megan Gardner
Message:

Support Autoscrolling in contenteditable for WK2
https://bugs.webkit.org/show_bug.cgi?id=180789

Source/WebCore:

Reviewed by Simon Frasier and Wenson Hsieh..

Activate the autoscrollController to scroll to the position provided to us by the
UIProcess. Allows for scrolling in contentEditable for WebKit2

Test: fast/events/touch/ios/drag-to-autoscroll-in-single-line-editable.html

  • page/AutoscrollController.cpp:

(WebCore::AutoscrollController::autoscrollTimerFired):

  • page/EventHandler.cpp:

(WebCore::EventHandler::clearOrScheduleClearingLatchedStateIfNeeded):
(WebCore::EventHandler::targetPositionForSelectionAutoscroll const):
(WebCore::EventHandler::shouldUpdateAutoscroll):
(WebCore::EventHandler::effectiveMousePositionForSelectionAutoscroll const): Deleted.

  • page/EventHandler.h:
  • page/ios/EventHandlerIOS.mm:

(WebCore::EventHandler::startTextAutoscroll):
(WebCore::EventHandler::cancelTextAutoscroll):
(WebCore::EventHandler::targetPositionForSelectionAutoscroll const):
(WebCore::EventHandler::shouldUpdateAutoscroll):

  • page/mac/EventHandlerMac.mm:

(WebCore::EventHandler::targetPositionForSelectionAutoscroll const):
(WebCore::EventHandler::effectiveMousePositionForSelectionAutoscroll const): Deleted.

Source/WebKit:

Reviewed by Simon Frasier and Wenson Hsieh.

Implements the UIKit protocol for autoscrolling and alerts the Web Process to start
(or stop) an autoscroll to the specified position. Allows for scrolling in contenteditable
in WebKit2.

  • Platform/spi/ios/UIKitSPI.h:
  • UIProcess/WebPageProxy.h:
  • UIProcess/ios/WKContentViewInteraction.h:
  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView startAutoscroll:]):
(-[WKContentView cancelAutoscroll]):
(-[WKContentView scrollSelectionToVisible:]):

  • UIProcess/ios/WebPageProxyIOS.mm:

(WebKit::WebPageProxy::startAutoscrollAtPosition):
(WebKit::WebPageProxy::cancelAutoscroll):

  • WebProcess/WebPage/WebPage.h:
  • WebProcess/WebPage/WebPage.messages.in:
  • WebProcess/WebPage/ios/WebPageIOS.mm:

(WebKit::WebPage::startAutoscrollAtPosition):
(WebKit::WebPage::cancelAutoscroll):

Location:
trunk
Files:
2 added
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/fast/events/touch/ios/resources/basic-gestures.js

    r222813 r226067  
     1function didShowKeyboard()
     2{
     3        return `
     4        (function() {
     5        uiController.didShowKeyboardCallback = function() {
     6            uiController.uiScriptComplete();
     7                }
     8    })();`
     9}
     10
     11
    112function longPressAtPoint(x, y)
    213{
     
    920}
    1021
    11 function longPressAndHoldAtPoint(X, Y)
     22function liftUpAtPoint(x, y)
     23{
     24    return `
     25    (function() {
     26        uiController.liftUpAtPoint(${x}, ${y}, 1, function() {
     27            uiController.uiScriptComplete();
     28        });
     29    })();`
     30}
     31
     32function longPressAndHoldAtPoint(x, y)
    1233{
    1334    return `
     
    2748                        phase : "began",
    2849                        id : 1,
    29                         x : ${X},
    30                         y : ${Y},
     50                        x : ${x},
     51                        y : ${y},
    3152                        pressure : 0
    3253                    }
     
    4162                        phase : "moved",
    4263                        id : 1,
    43                         x : ${X},
    44                         y : ${Y},
     64                        x : ${x},
     65                        y : ${y},
    4566                        pressure : 0
    4667                    }
     
    98119                        x : ${endX},
    99120                        y : ${endY},
     121                        pressure : 0
     122                    }
     123                ]
     124            }
     125    }]};
     126   
     127    uiController.sendEventStream(JSON.stringify(eventStream), function() {});
     128        uiController.uiScriptComplete();
     129    })();`
     130}
     131
     132function holdAtPoint(x, y)
     133{
     134    return `
     135    (function() {
     136    var eventStream = {
     137    events : [
     138        {
     139            interpolate : "linear",
     140            timestep: 0.1,
     141            coordinateSpace : "content",
     142            startEvent : {
     143                inputType : "hand",
     144                timeOffset : 0,
     145                touches : [
     146                    {
     147                        inputType : "finger",
     148                        phase : "moved",
     149                        id : 1,
     150                        x : ${x},
     151                        y : ${y},
     152                        pressure : 0
     153                    }
     154                ]
     155            },
     156            endEvent : {
     157                inputType : "hand",
     158                timeOffset : 5.0,
     159                touches : [
     160                    {
     161                        inputType : "finger",
     162                        phase : "moved",
     163                        id : 1,
     164                        x : ${x},
     165                        y : ${y},
    100166                        pressure : 0
    101167                    }
  • trunk/Source/WebCore/ChangeLog

    r226066 r226067  
     12017-12-18  Megan Gardner  <megan_gardner@apple.com>
     2
     3        Support Autoscrolling in contenteditable for WK2
     4        https://bugs.webkit.org/show_bug.cgi?id=180789
     5
     6        Reviewed by Simon Frasier and Wenson Hsieh..
     7
     8        Activate the autoscrollController to scroll to the position provided to us by the
     9        UIProcess. Allows for scrolling in contentEditable for WebKit2
     10
     11        Test: fast/events/touch/ios/drag-to-autoscroll-in-single-line-editable.html
     12
     13        * page/AutoscrollController.cpp:
     14        (WebCore::AutoscrollController::autoscrollTimerFired):
     15        * page/EventHandler.cpp:
     16        (WebCore::EventHandler::clearOrScheduleClearingLatchedStateIfNeeded):
     17        (WebCore::EventHandler::targetPositionForSelectionAutoscroll const):
     18        (WebCore::EventHandler::shouldUpdateAutoscroll):
     19        (WebCore::EventHandler::effectiveMousePositionForSelectionAutoscroll const): Deleted.
     20        * page/EventHandler.h:
     21        * page/ios/EventHandlerIOS.mm:
     22        (WebCore::EventHandler::startTextAutoscroll):
     23        (WebCore::EventHandler::cancelTextAutoscroll):
     24        (WebCore::EventHandler::targetPositionForSelectionAutoscroll const):
     25        (WebCore::EventHandler::shouldUpdateAutoscroll):
     26        * page/mac/EventHandlerMac.mm:
     27        (WebCore::EventHandler::targetPositionForSelectionAutoscroll const):
     28        (WebCore::EventHandler::effectiveMousePositionForSelectionAutoscroll const): Deleted.
     29
    1302017-12-18  Youenn Fablet  <youenn@apple.com>
    231
  • trunk/Source/WebCore/page/AutoscrollController.cpp

    r222392 r226067  
    244244        break;
    245245    case AutoscrollForSelection: {
    246         if (!frame.eventHandler().mousePressed()) {
     246        if (!frame.eventHandler().shouldUpdateAutoscroll()) {
    247247            stopAutoscrollTimer();
    248248            return;
     
    251251        frame.eventHandler().updateSelectionForMouseDrag();
    252252#endif
    253         m_autoscrollRenderer->autoscroll(frame.eventHandler().effectiveMousePositionForSelectionAutoscroll());
     253        m_autoscrollRenderer->autoscroll(frame.eventHandler().targetPositionInWindowForSelectionAutoscroll());
    254254        break;
    255255    }
  • trunk/Source/WebCore/page/EventHandler.cpp

    r225494 r226067  
    26822682}
    26832683
    2684 IntPoint EventHandler::effectiveMousePositionForSelectionAutoscroll() const
     2684void EventHandler::clearOrScheduleClearingLatchedStateIfNeeded(const PlatformWheelEvent&)
     2685{
     2686    clearLatchedState();
     2687}
     2688   
     2689#if !PLATFORM(IOS)
     2690   
     2691IntPoint EventHandler::targetPositionInWindowForSelectionAutoscroll() const
    26852692{
    26862693    return m_lastKnownMousePosition;
    26872694}
    2688 
    2689 void EventHandler::clearOrScheduleClearingLatchedStateIfNeeded(const PlatformWheelEvent&)
    2690 {
    2691     clearLatchedState();
    2692 }
    2693 #endif
     2695   
     2696#endif // !PLATFORM(IOS)
     2697   
     2698#endif // !PLATFORM(MAC)
     2699   
     2700#if !PLATFORM(IOS)
     2701   
     2702bool EventHandler::shouldUpdateAutoscroll()
     2703{
     2704    return mousePressed();
     2705}
     2706   
     2707#endif // !PLATFORM(IOS)
    26942708
    26952709Widget* EventHandler::widgetForEventTarget(Element* eventTarget)
  • trunk/Source/WebCore/page/EventHandler.h

    r224459 r226067  
    3232#include "LayoutPoint.h"
    3333#include "PlatformMouseEvent.h"
     34#include "RenderObject.h"
    3435#include "ScrollTypes.h"
    3536#include "TextEventInputType.h"
     
    189190    Cursor currentMouseCursor() const { return m_currentMouseCursor; }
    190191
    191     IntPoint effectiveMousePositionForSelectionAutoscroll() const;
     192    IntPoint targetPositionInWindowForSelectionAutoscroll() const;
     193    bool shouldUpdateAutoscroll();
    192194
    193195    static Frame* subframeForTargetNode(Node*);
     
    333335    WEBCORE_EXPORT bool tryToBeginDataInteractionAtPoint(const IntPoint& clientPosition, const IntPoint& globalPosition);
    334336#endif
     337   
     338#if PLATFORM(IOS)
     339    WEBCORE_EXPORT void startTextAutoscroll(RenderObject* renderer, const FloatPoint& positionInWindow);
     340    WEBCORE_EXPORT void cancelTextAutoscroll();
     341    IntPoint m_targetAutoscrollPositionInWindow;
     342    bool m_isAutoscrolling { false };
     343#endif
    335344
    336345private:
  • trunk/Source/WebCore/page/ios/EventHandlerIOS.mm

    r222595 r226067  
    2828
    2929#import "AXObjectCache.h"
     30#import "AutoscrollController.h"
    3031#import "Chrome.h"
    3132#import "ChromeClient.h"
     
    559560    return PlatformEventFactory::createPlatformMouseEvent(currentEvent());
    560561}
     562   
     563void EventHandler::startTextAutoscroll(RenderObject* renderer, const FloatPoint& positionInWindow)
     564{
     565    m_targetAutoscrollPositionInWindow = roundedIntPoint(positionInWindow);
     566    m_isAutoscrolling = true;
     567    m_autoscrollController->startAutoscrollForSelection(renderer);
     568}
     569
     570void EventHandler::cancelTextAutoscroll()
     571{
     572    m_isAutoscrolling = false;
     573    m_autoscrollController->stopAutoscrollTimer();
     574}
     575   
     576IntPoint EventHandler::targetPositionInWindowForSelectionAutoscroll() const
     577{
     578    return m_targetAutoscrollPositionInWindow;
     579}
     580   
     581bool EventHandler::shouldUpdateAutoscroll()
     582{
     583    return m_isAutoscrolling;
     584}
    561585
    562586#if ENABLE(DRAG_SUPPORT)
  • trunk/Source/WebCore/page/mac/EventHandlerMac.mm

    r225142 r226067  
    11421142}
    11431143
    1144 IntPoint EventHandler::effectiveMousePositionForSelectionAutoscroll() const
     1144IntPoint EventHandler::targetPositionInWindowForSelectionAutoscroll() const
    11451145{
    11461146    Page* page = m_frame.page();
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r225983 r226067  
    27532753}
    27542754
    2755 void RenderLayer::autoscroll(const IntPoint& position)
    2756 {
    2757     IntPoint currentDocumentPosition = renderer().view().frameView().windowToContents(position);
     2755void RenderLayer::autoscroll(const IntPoint& positionInWindow)
     2756{
     2757    IntPoint currentDocumentPosition = renderer().view().frameView().windowToContents(positionInWindow);
    27582758    scrollRectToVisible(SelectionRevealMode::Reveal, LayoutRect(currentDocumentPosition, LayoutSize(1, 1)), false, ScrollAlignment::alignToEdgeIfNeeded, ScrollAlignment::alignToEdgeIfNeeded);
    27592759}
  • trunk/Source/WebKit/ChangeLog

    r226066 r226067  
     12017-12-18  Megan Gardner  <megan_gardner@apple.com>
     2
     3        Support Autoscrolling in contenteditable for WK2
     4        https://bugs.webkit.org/show_bug.cgi?id=180789
     5
     6        Reviewed by Simon Frasier and Wenson Hsieh.
     7
     8        Implements the UIKit protocol for autoscrolling and alerts the Web Process to start
     9        (or stop) an autoscroll to the specified position. Allows for scrolling in contenteditable
     10        in WebKit2.
     11
     12        * Platform/spi/ios/UIKitSPI.h:
     13        * UIProcess/WebPageProxy.h:
     14        * UIProcess/ios/WKContentViewInteraction.h:
     15        * UIProcess/ios/WKContentViewInteraction.mm:
     16        (-[WKContentView startAutoscroll:]):
     17        (-[WKContentView cancelAutoscroll]):
     18        (-[WKContentView scrollSelectionToVisible:]):
     19        * UIProcess/ios/WebPageProxyIOS.mm:
     20        (WebKit::WebPageProxy::startAutoscrollAtPosition):
     21        (WebKit::WebPageProxy::cancelAutoscroll):
     22        * WebProcess/WebPage/WebPage.h:
     23        * WebProcess/WebPage/WebPage.messages.in:
     24        * WebProcess/WebPage/ios/WebPageIOS.mm:
     25        (WebKit::WebPage::startAutoscrollAtPosition):
     26        (WebKit::WebPage::cancelAutoscroll):
     27
    1282017-12-18  Youenn Fablet  <youenn@apple.com>
    229
  • trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h

    r225958 r226067  
    626626@end
    627627
     628@protocol UITextAutoscrolling
     629- (void)startAutoscroll:(CGPoint)point;
     630- (void)cancelAutoscroll;
     631- (void)scrollSelectionToVisible:(BOOL)animated;
     632@end
     633
     634
    628635@protocol UIWebFormAccessoryDelegate;
    629636
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r226016 r226067  
    583583    void autofillLoginCredentials(const String& username, const String& password);
    584584    void storeSelectionForAccessibility(bool);
     585    void startAutoscrollAtPosition(const WebCore::FloatPoint& positionInWindow);
     586    void cancelAutoscroll();
    585587#if ENABLE(DATA_INTERACTION)
    586588    void didPerformDataInteractionControllerOperation(bool handled);
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h

    r224029 r226067  
    242242@end
    243243
    244 @interface WKContentView (WKInteraction) <UIGestureRecognizerDelegate, UIWebTouchEventsGestureRecognizerDelegate, UITextInputPrivate, UIWebFormAccessoryDelegate, UIWKInteractionViewProtocol, WKFileUploadPanelDelegate, WKActionSheetAssistantDelegate
     244@interface WKContentView (WKInteraction) <UIGestureRecognizerDelegate, UIWebTouchEventsGestureRecognizerDelegate, UITextInputPrivate, UIWebFormAccessoryDelegate, UIWKInteractionViewProtocol, WKFileUploadPanelDelegate, WKActionSheetAssistantDelegate, UITextAutoscrolling
    245245#if ENABLE(DATA_INTERACTION)
    246246    , UIDragInteractionDelegate, UIDropInteractionDelegate
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r226048 r226067  
    691691    return _page->unobscuredContentRect();
    692692}
     693
     694
     695#pragma mark - UITextAutoscrolling
     696- (void)startAutoscroll:(CGPoint)point
     697{
     698    _page->startAutoscrollAtPosition(point);
     699}
     700
     701- (void)cancelAutoscroll
     702{
     703    _page->cancelAutoscroll();
     704}
     705
     706- (void)scrollSelectionToVisible:(BOOL)animated
     707{
     708    // Used to scroll selection on keyboard up; we already scroll to visible.
     709}
     710
    693711
    694712- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
  • trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm

    r225562 r226067  
    714714}
    715715
     716void WebPageProxy::startAutoscrollAtPosition(const WebCore::FloatPoint& position)
     717{
     718    m_process->send(Messages::WebPage::StartAutoscrollAtPosition(position), m_pageID);
     719}
     720   
     721void WebPageProxy::cancelAutoscroll()
     722{
     723    m_process->send(Messages::WebPage::CancelAutoscroll(), m_pageID);
     724}
     725
    716726void WebPageProxy::moveSelectionByOffset(int32_t offset, WTF::Function<void (CallbackBase::Error)>&& callbackFunction)
    717727{
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.h

    r226016 r226067  
    606606    void getRectsAtSelectionOffsetWithText(int32_t, const String&, CallbackID);
    607607    void storeSelectionForAccessibility(bool);
     608    void startAutoscrollAtPosition(const WebCore::FloatPoint&);
     609    void cancelAutoscroll();
    608610
    609611    void contentSizeCategoryDidChange(const String&);
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in

    r226008 r226067  
    100100    GetRectsAtSelectionOffsetWithText(int32_t offset, String text, WebKit::CallbackID callbackID)
    101101    StoreSelectionForAccessibility(bool shouldStore)
     102    StartAutoscrollAtPosition(WebCore::FloatPoint positionInWindow)
     103    CancelAutoscroll()
    102104#endif
    103105
  • trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r225715 r226067  
    13821382    send(Messages::WebPageProxy::VoidCallback(callbackID));
    13831383}
     1384   
     1385void WebPage::startAutoscrollAtPosition(const WebCore::FloatPoint& positionInWindow)
     1386{
     1387    if (m_assistedNode && m_assistedNode->renderer())
     1388        m_page->mainFrame().eventHandler().startTextAutoscroll(m_assistedNode->renderer(), positionInWindow);
     1389}
     1390   
     1391void WebPage::cancelAutoscroll()
     1392{
     1393    m_page->mainFrame().eventHandler().cancelTextAutoscroll();
     1394}
    13841395
    13851396void WebPage::getRectsForGranularityWithSelectionOffset(uint32_t granularity, int32_t offset, CallbackID callbackID)
  • trunk/Source/bmalloc/bmalloc.xcodeproj/project.pbxproj

    r225320 r226067  
    186186                0F74B93C1F89713E00B935D3 /* CryptoRandom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CryptoRandom.h; path = bmalloc/CryptoRandom.h; sourceTree = "<group>"; };
    187187                0F74B93D1F89713E00B935D3 /* CryptoRandom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CryptoRandom.cpp; path = bmalloc/CryptoRandom.cpp; sourceTree = "<group>"; };
    188                 0F7EB7EF1F95285300F1ABCB /* libtestbmalloc */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = libtestbmalloc; path = testbmalloc; sourceTree = BUILT_PRODUCTS_DIR; };
     188                0F7EB7EF1F95285300F1ABCB /* testbmalloc */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testbmalloc; sourceTree = BUILT_PRODUCTS_DIR; };
    189189                0F7EB7F11F95285300F1ABCB /* testbmalloc.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = testbmalloc.cpp; sourceTree = "<group>"; };
    190190                0F7EB7FC1F9541AD00F1ABCB /* EligibilityResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = EligibilityResult.h; path = bmalloc/EligibilityResult.h; sourceTree = SOURCE_ROOT; };
     
    417417                                14F271BE18EA3963008C152F /* libbmalloc.a */,
    418418                                14CC394418EA8743004AFE34 /* libmbmalloc.dylib */,
    419                                 0F7EB7EF1F95285300F1ABCB /* libtestbmalloc */,
     419                                0F7EB7EF1F95285300F1ABCB /* testbmalloc */,
    420420                        );
    421421                        name = Products;
     
    660660                        name = testbmalloc;
    661661                        productName = testbmalloc;
    662                         productReference = 0F7EB7EF1F95285300F1ABCB /* libtestbmalloc */;
     662                        productReference = 0F7EB7EF1F95285300F1ABCB /* testbmalloc */;
    663663                        productType = "com.apple.product-type.tool";
    664664                };
Note: See TracChangeset for help on using the changeset viewer.