Changeset 239039 in webkit


Ignore:
Timestamp:
Dec 10, 2018 12:27:59 PM (5 years ago)
Author:
Wenson Hsieh
Message:

[iOS] Caret is obscured by finger when dragging over an editable element
https://bugs.webkit.org/show_bug.cgi?id=192499
<rdar://problem/46570101>

Reviewed by Tim Horton.

Source/WebCore:

  • page/DragActions.h:

Move DragHandlingMethod to DragActions.h, and drive-by fix some minor issues (i.e. make a couple of enum classes
use 8 bits, fix the indentation levels, and update the copyright year). Also add EnumTraits for
DragHandlingMethod so that it may be encoded over IPC.

  • page/DragController.cpp:

(WebCore::dragIsHandledByDocument):

Simplify this helper function.

(WebCore::DragController::tryDocumentDrag):

  • page/DragController.h:

Expose the current DragHandlingMethod via a const getter method.

(WebCore::DragController::dragHandlingMethod const):

Source/WebKit:

Add support for setting the precise property of UIDropProposal to YES when dragging over an editable area.
When enabled, this property shifts the drop location up by a small amount, allowing the user to see the drop
caret (currently, this is not the case, and it's difficult to drop text at a precise location on iOS). Changes
are covered by adding to existing API tests.

  • Scripts/webkit/messages.py:
  • UIProcess/API/Cocoa/WKUIDelegatePrivate.h:

Add a new version of -_webView:willUpdateDataInteractionOperationToOperation:forSession: that receives and
returns a UIDropProposal, so that Mail can more easily port over existing logic in its legacy-WebKit-based
compose implementation. iOS Safari is currently the only client of this private delegate, so the old version can
be easily removed once Safari adopts this new version.

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::didPerformDragControllerAction):

Add plumbing to send the latest drag handling method from WebPage to WebPageProxy.

(WebKit::WebPageProxy::resetCurrentDragInformation):

  • UIProcess/WebPageProxy.h:

(WebKit::WebPageProxy::currentDragHandlingMethod const):

  • UIProcess/WebPageProxy.messages.in:
  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView dropInteraction:sessionDidUpdate:]):

Call the new UI delegate hook when determining the drop proposal to return to UIKit. Additionally set the
precise bit on the drop proposal in the case where the drop handling method is either "editing rich text" or
"editing plain text".

  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::performDragControllerAction):

  • WebProcess/WebPage/WebPage.h:

Tools:

Augment some existing API tests to check that the precise flag is either on or off on UIDropProposal.

  • TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm:
  • TestWebKitAPI/cocoa/DragAndDropSimulator.h:
  • TestWebKitAPI/ios/DragAndDropSimulatorIOS.mm:

(-[DragAndDropSimulator _resetSimulatedState]):
(-[DragAndDropSimulator lastKnownDropProposal]):

Rename currentDropProposal to lastKnownDropProposal, and expose it as a readonly property.

(-[DragAndDropSimulator _concludeDropAndPerformOperationIfNecessary]):
(-[DragAndDropSimulator _advanceProgress]):
(-[DragAndDropSimulator setShowCustomActionSheetBlock:]):
(-[DragAndDropSimulator showCustomActionSheetBlock]):
(-[DragAndDropSimulator setConvertItemProvidersBlock:]):
(-[DragAndDropSimulator convertItemProvidersBlock]):
(-[DragAndDropSimulator setOverridePerformDropBlock:]):
(-[DragAndDropSimulator overridePerformDropBlock]):
(-[DragAndDropSimulator setOverrideDragUpdateBlock:]):
(-[DragAndDropSimulator overrideDragUpdateBlock]):
(-[DragAndDropSimulator setDropCompletionBlock:]):
(-[DragAndDropSimulator dropCompletionBlock]):

Refactor these properties to return and take normal Objective-C blocks, rather than BlockPtrs. However, use
BlockPtr instance variables to manage the lifetimes of these blocks.

(-[DragAndDropSimulator _webView:willUpdateDropProposalToProposal:forSession:]):
(-[DragAndDropSimulator _webView:willUpdateDataInteractionOperationToOperation:forSession:]): Deleted.

Update this to use the new WebKit delegate hook for overriding the drop proposal.

Location:
trunk
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r239038 r239039  
     12018-12-10  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [iOS] Caret is obscured by finger when dragging over an editable element
     4        https://bugs.webkit.org/show_bug.cgi?id=192499
     5        <rdar://problem/46570101>
     6
     7        Reviewed by Tim Horton.
     8
     9        * page/DragActions.h:
     10
     11        Move DragHandlingMethod to DragActions.h, and drive-by fix some minor issues (i.e. make a couple of enum classes
     12        use 8 bits, fix the indentation levels, and update the copyright year). Also add `EnumTraits` for
     13        DragHandlingMethod so that it may be encoded over IPC.
     14
     15        * page/DragController.cpp:
     16        (WebCore::dragIsHandledByDocument):
     17
     18        Simplify this helper function.
     19
     20        (WebCore::DragController::tryDocumentDrag):
     21        * page/DragController.h:
     22
     23        Expose the current DragHandlingMethod via a const getter method.
     24
     25        (WebCore::DragController::dragHandlingMethod const):
     26
    1272018-12-10  Youenn Fablet  <youenn@apple.com>
    228
  • trunk/Source/WebCore/page/DragActions.h

    r234930 r239039  
    11/*
    2  * Copyright (C) 2007, 2012 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2007-2018 Apple Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2727
    2828#include <limits.h>
     29#include <wtf/Forward.h>
    2930
    3031namespace WebCore {
    3132
    32     // WebCoreDragDestinationAction should be kept in sync with WebDragDestinationAction
    33     typedef enum {
    34         DragDestinationActionNone    = 0,
    35         DragDestinationActionDHTML   = 1,
    36         DragDestinationActionEdit    = 2,
    37         DragDestinationActionLoad    = 4,
    38         DragDestinationActionAny     = UINT_MAX
    39     } DragDestinationAction;
    40    
    41     // WebCoreDragSourceAction should be kept in sync with WebDragSourceAction
    42     typedef enum {
    43         DragSourceActionNone         = 0,
    44         DragSourceActionDHTML        = 1,
    45         DragSourceActionImage        = 2,
    46         DragSourceActionLink         = 4,
    47         DragSourceActionSelection    = 8,
     33// WebCoreDragDestinationAction should be kept in sync with WebDragDestinationAction.
     34typedef enum {
     35    DragDestinationActionNone    = 0,
     36    DragDestinationActionDHTML   = 1,
     37    DragDestinationActionEdit    = 2,
     38    DragDestinationActionLoad    = 4,
     39    DragDestinationActionAny     = UINT_MAX
     40} DragDestinationAction;
     41
     42// WebCoreDragSourceAction should be kept in sync with WebDragSourceAction.
     43typedef enum {
     44    DragSourceActionNone         = 0,
     45    DragSourceActionDHTML        = 1,
     46    DragSourceActionImage        = 2,
     47    DragSourceActionLink         = 4,
     48    DragSourceActionSelection    = 8,
    4849#if ENABLE(ATTACHMENT_ELEMENT)
    49         DragSourceActionAttachment   = 16,
     50    DragSourceActionAttachment   = 16,
    5051#endif
    5152#if ENABLE(INPUT_TYPE_COLOR)
    52         DragSourceActionColor        = 32,
     53    DragSourceActionColor        = 32,
    5354#endif
    54         DragSourceActionAny          = UINT_MAX
    55     } DragSourceAction;
    56    
    57     //matches NSDragOperation
    58     typedef enum {
    59         DragOperationNone    = 0,
    60         DragOperationCopy    = 1,
    61         DragOperationLink    = 2,
    62         DragOperationGeneric = 4,
    63         DragOperationPrivate = 8,
    64         DragOperationMove    = 16,
    65         DragOperationDelete  = 32,
    66         DragOperationEvery   = UINT_MAX
    67     } DragOperation;
     55    DragSourceActionAny          = UINT_MAX
     56} DragSourceAction;
    6857
    69     enum class MayExtendDragSession { No, Yes };
    70     enum class HasNonDefaultPasteboardData { No, Yes };
    71    
     58// Matches NSDragOperation.
     59typedef enum {
     60    DragOperationNone    = 0,
     61    DragOperationCopy    = 1,
     62    DragOperationLink    = 2,
     63    DragOperationGeneric = 4,
     64    DragOperationPrivate = 8,
     65    DragOperationMove    = 16,
     66    DragOperationDelete  = 32,
     67    DragOperationEvery   = UINT_MAX
     68} DragOperation;
     69
     70enum class MayExtendDragSession : bool { No, Yes };
     71enum class HasNonDefaultPasteboardData : bool { No, Yes };
     72enum class DragHandlingMethod : uint8_t { None, EditPlainText, EditRichText, UploadFile, PageLoad, SetColor, NonDefault };
     73
    7274} // namespace WebCore
     75
     76namespace WTF {
     77
     78template<> struct EnumTraits<WebCore::DragHandlingMethod> {
     79    using values = EnumValues<
     80        WebCore::DragHandlingMethod,
     81        WebCore::DragHandlingMethod::None,
     82        WebCore::DragHandlingMethod::EditPlainText,
     83        WebCore::DragHandlingMethod::EditRichText,
     84        WebCore::DragHandlingMethod::UploadFile,
     85        WebCore::DragHandlingMethod::PageLoad,
     86        WebCore::DragHandlingMethod::SetColor,
     87        WebCore::DragHandlingMethod::NonDefault
     88    >;
     89};
     90
     91} // namespace WTF
  • trunk/Source/WebCore/page/DragController.cpp

    r238771 r239039  
    238238}
    239239
    240 inline static bool dragIsHandledByDocument(DragController::DragHandlingMethod dragHandlingMethod)
    241 {
    242     if (dragHandlingMethod == DragController::DragHandlingMethod::None)
    243         return false;
    244 
    245     if (dragHandlingMethod == DragController::DragHandlingMethod::PageLoad)
    246         return false;
    247 
    248     return true;
     240inline static bool dragIsHandledByDocument(DragHandlingMethod dragHandlingMethod)
     241{
     242    return dragHandlingMethod != DragHandlingMethod::None && dragHandlingMethod != DragHandlingMethod::PageLoad;
    249243}
    250244
     
    386380#endif
    387381
    388 DragController::DragHandlingMethod DragController::tryDocumentDrag(const DragData& dragData, DragDestinationAction actionMask, DragOperation& dragOperation)
     382DragHandlingMethod DragController::tryDocumentDrag(const DragData& dragData, DragDestinationAction actionMask, DragOperation& dragOperation)
    389383{
    390384    if (!m_documentUnderMouse)
  • trunk/Source/WebCore/page/DragController.h

    r238771 r239039  
    7979        const IntPoint& dragOffset() const { return m_dragOffset; }
    8080        DragSourceAction dragSourceAction() const { return m_dragSourceAction; }
     81        DragHandlingMethod dragHandlingMethod() const { return m_dragHandlingMethod; }
    8182
    82         enum class DragHandlingMethod { None, EditPlainText, EditRichText, UploadFile, PageLoad, SetColor, NonDefault };
    8383        Document* documentUnderMouse() const { return m_documentUnderMouse.get(); }
    8484        DragDestinationAction dragDestinationAction() const { return m_dragDestinationAction; }
     
    144144        RefPtr<HTMLInputElement> m_fileInputElementUnderMouse;
    145145        unsigned m_numberOfItemsToBeAccepted;
    146         DragHandlingMethod m_dragHandlingMethod;
     146        DragHandlingMethod m_dragHandlingMethod { DragHandlingMethod::None };
    147147
    148148        DragDestinationAction m_dragDestinationAction;
  • trunk/Source/WebKit/ChangeLog

    r239038 r239039  
     12018-12-10  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [iOS] Caret is obscured by finger when dragging over an editable element
     4        https://bugs.webkit.org/show_bug.cgi?id=192499
     5        <rdar://problem/46570101>
     6
     7        Reviewed by Tim Horton.
     8
     9        Add support for setting the `precise` property of `UIDropProposal` to YES when dragging over an editable area.
     10        When enabled, this property shifts the drop location up by a small amount, allowing the user to see the drop
     11        caret (currently, this is not the case, and it's difficult to drop text at a precise location on iOS). Changes
     12        are covered by adding to existing API tests.
     13
     14        * Scripts/webkit/messages.py:
     15        * UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
     16
     17        Add a new version of `-_webView:willUpdateDataInteractionOperationToOperation:forSession:` that receives and
     18        returns a UIDropProposal, so that Mail can more easily port over existing logic in its legacy-WebKit-based
     19        compose implementation. iOS Safari is currently the only client of this private delegate, so the old version can
     20        be easily removed once Safari adopts this new version.
     21
     22        * UIProcess/WebPageProxy.cpp:
     23        (WebKit::WebPageProxy::didPerformDragControllerAction):
     24
     25        Add plumbing to send the latest drag handling method from WebPage to WebPageProxy.
     26
     27        (WebKit::WebPageProxy::resetCurrentDragInformation):
     28        * UIProcess/WebPageProxy.h:
     29        (WebKit::WebPageProxy::currentDragHandlingMethod const):
     30        * UIProcess/WebPageProxy.messages.in:
     31        * UIProcess/ios/WKContentViewInteraction.mm:
     32        (-[WKContentView dropInteraction:sessionDidUpdate:]):
     33
     34        Call the new UI delegate hook when determining the drop proposal to return to UIKit. Additionally set the
     35        `precise` bit on the drop proposal in the case where the drop handling method is either "editing rich text" or
     36        "editing plain text".
     37
     38        * WebProcess/WebPage/WebPage.cpp:
     39        (WebKit::WebPage::performDragControllerAction):
     40        * WebProcess/WebPage/WebPage.h:
     41
    1422018-12-10  Youenn Fablet  <youenn@apple.com>
    243
  • trunk/Source/WebKit/Scripts/webkit/messages.py

    r239006 r239039  
    398398        'PAL::SessionID': ['<pal/SessionID.h>'],
    399399        'WebCore::AutoplayEventFlags': ['<WebCore/AutoplayEvent.h>'],
     400        'WebCore::DragHandlingMethod': ['<WebCore/DragActions.h>'],
    400401        'WebCore::ExceptionDetails': ['<WebCore/JSDOMExceptionHandling.h>'],
    401402        'WebCore::FileChooserSettings': ['<WebCore/FileChooser.h>'],
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h

    r238726 r239039  
    158158- (void)_webView:(WKWebView *)webView dataInteractionOperationWasHandled:(BOOL)handled forSession:(id)session itemProviders:(NSArray *)itemProviders WK_API_AVAILABLE(ios(11.0));
    159159- (NSUInteger)_webView:(WKWebView *)webView willUpdateDataInteractionOperationToOperation:(NSUInteger)operation forSession:(id)session WK_API_AVAILABLE(ios(11.0));
     160- (UIDropProposal *)_webView:(WKWebView *)webView willUpdateDropProposalToProposal:(UIDropProposal *)proposal forSession:(id <UIDropSession>)session WK_API_AVAILABLE(ios(WK_IOS_TBA));
    160161#if TARGET_OS_IOS
    161162- (UITargetedDragPreview *)_webView:(WKWebView *)webView previewForLiftingItem:(UIDragItem *)item session:(id <UIDragSession>)session WK_API_AVAILABLE(ios(11.0));
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r238939 r239039  
    20472047}
    20482048
    2049 void WebPageProxy::didPerformDragControllerAction(uint64_t dragOperation, bool mouseIsOverFileInput, unsigned numberOfItemsToBeAccepted, const IntRect& insertionRect)
     2049void WebPageProxy::didPerformDragControllerAction(uint64_t dragOperation, WebCore::DragHandlingMethod dragHandlingMethod, bool mouseIsOverFileInput, unsigned numberOfItemsToBeAccepted, const IntRect& insertionRect)
    20502050{
    20512051    MESSAGE_CHECK(dragOperation <= DragOperationDelete);
    20522052
    20532053    m_currentDragOperation = static_cast<DragOperation>(dragOperation);
     2054    m_currentDragHandlingMethod = dragHandlingMethod;
    20542055    m_currentDragIsOverFileInput = mouseIsOverFileInput;
    20552056    m_currentDragNumberOfFilesToBeAccepted = numberOfItemsToBeAccepted;
     
    21002101{
    21012102    m_currentDragOperation = WebCore::DragOperationNone;
     2103    m_currentDragHandlingMethod = DragHandlingMethod::None;
    21022104    m_currentDragIsOverFileInput = false;
    21032105    m_currentDragNumberOfFilesToBeAccepted = 0;
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r238939 r239039  
    974974    void didPerformDragOperation(bool handled);
    975975
    976     void didPerformDragControllerAction(uint64_t dragOperation, bool mouseIsOverFileInput, unsigned numberOfItemsToBeAccepted, const WebCore::IntRect& insertionRect);
     976    void didPerformDragControllerAction(uint64_t dragOperation, WebCore::DragHandlingMethod, bool mouseIsOverFileInput, unsigned numberOfItemsToBeAccepted, const WebCore::IntRect& insertionRect);
    977977    void dragEnded(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition, uint64_t operation);
    978978    void didStartDrag();
     
    10301030#if ENABLE(DRAG_SUPPORT)
    10311031    WebCore::DragOperation currentDragOperation() const { return m_currentDragOperation; }
     1032    WebCore::DragHandlingMethod currentDragHandlingMethod() const { return m_currentDragHandlingMethod; }
    10321033    bool currentDragIsOverFileInput() const { return m_currentDragIsOverFileInput; }
    10331034    unsigned currentDragNumberOfFilesToBeAccepted() const { return m_currentDragNumberOfFilesToBeAccepted; }
     
    21522153    // so we preserve them to be used when the next dragging delegate call is made.
    21532154    WebCore::DragOperation m_currentDragOperation { WebCore::DragOperationNone };
     2155    WebCore::DragHandlingMethod m_currentDragHandlingMethod { WebCore::DragHandlingMethod::None };
    21542156    bool m_currentDragIsOverFileInput { false };
    21552157    unsigned m_currentDragNumberOfFilesToBeAccepted { 0 };
  • trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in

    r238771 r239039  
    312312    # Drag and drop messages
    313313#if ENABLE(DRAG_SUPPORT)
    314     DidPerformDragControllerAction(uint64_t dragOperation, bool mouseIsOverFileInput, unsigned numberOfItemsToBeAccepted, WebCore::IntRect insertionRect)
     314    DidPerformDragControllerAction(uint64_t dragOperation, enum:uint8_t WebCore::DragHandlingMethod dragHandlingMethod, bool mouseIsOverFileInput, unsigned numberOfItemsToBeAccepted, WebCore::IntRect insertionRect)
    315315    DidEndDragging();
    316316#endif
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r239029 r239039  
    58885888    _dragDropInteractionState.dropSessionDidEnterOrUpdate(session, dragData);
    58895889
    5890     NSUInteger operation = dropOperationForWebCoreDragOperation(_page->currentDragOperation());
    5891     if ([self.webViewUIDelegate respondsToSelector:@selector(_webView:willUpdateDataInteractionOperationToOperation:forSession:)])
    5892         operation = [self.webViewUIDelegate _webView:_webView willUpdateDataInteractionOperationToOperation:operation forSession:session];
    5893 
    5894     return [[[UIDropProposal alloc] initWithDropOperation:static_cast<UIDropOperation>(operation)] autorelease];
     5890    auto delegate = self.webViewUIDelegate;
     5891    auto operation = dropOperationForWebCoreDragOperation(_page->currentDragOperation());
     5892    if ([delegate respondsToSelector:@selector(_webView:willUpdateDataInteractionOperationToOperation:forSession:)])
     5893        operation = static_cast<UIDropOperation>([delegate _webView:_webView willUpdateDataInteractionOperationToOperation:operation forSession:session]);
     5894
     5895    auto proposal = adoptNS([[UIDropProposal alloc] initWithDropOperation:static_cast<UIDropOperation>(operation)]);
     5896    auto dragHandlingMethod = _page->currentDragHandlingMethod();
     5897    [proposal setPrecise:dragHandlingMethod == DragHandlingMethod::EditPlainText || dragHandlingMethod == DragHandlingMethod::EditRichText];
     5898    if ([delegate respondsToSelector:@selector(_webView:willUpdateDropProposalToProposal:forSession:)])
     5899        proposal = [delegate _webView:_webView willUpdateDropProposalToProposal:proposal.get() forSession:session];
     5900
     5901    return proposal.autorelease();
    58955902}
    58965903
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp

    r239006 r239039  
    36213621{
    36223622    if (!m_page) {
    3623         send(Messages::WebPageProxy::DidPerformDragControllerAction(DragOperationNone, false, 0, { }));
     3623        send(Messages::WebPageProxy::DidPerformDragControllerAction(DragOperationNone, DragHandlingMethod::None, false, 0, { }));
    36243624        return;
    36253625    }
     
    36293629    case DragControllerAction::Entered: {
    36303630        DragOperation resolvedDragOperation = m_page->dragController().dragEntered(dragData);
    3631         send(Messages::WebPageProxy::DidPerformDragControllerAction(resolvedDragOperation, m_page->dragController().mouseIsOverFileInput(), m_page->dragController().numberOfItemsToBeAccepted(), { }));
     3631        send(Messages::WebPageProxy::DidPerformDragControllerAction(resolvedDragOperation, m_page->dragController().dragHandlingMethod(), m_page->dragController().mouseIsOverFileInput(), m_page->dragController().numberOfItemsToBeAccepted(), { }));
    36323632        return;
    36333633    }
    36343634    case DragControllerAction::Updated: {
    36353635        DragOperation resolvedDragOperation = m_page->dragController().dragEntered(dragData);
    3636         send(Messages::WebPageProxy::DidPerformDragControllerAction(resolvedDragOperation, m_page->dragController().mouseIsOverFileInput(), m_page->dragController().numberOfItemsToBeAccepted(), { }));
     3636        send(Messages::WebPageProxy::DidPerformDragControllerAction(resolvedDragOperation, m_page->dragController().dragHandlingMethod(), m_page->dragController().mouseIsOverFileInput(), m_page->dragController().numberOfItemsToBeAccepted(), { }));
    36373637        return;
    36383638    }
     
    36523652{
    36533653    if (!m_page) {
    3654         send(Messages::WebPageProxy::DidPerformDragControllerAction(DragOperationNone, false, 0, { }));
     3654        send(Messages::WebPageProxy::DidPerformDragControllerAction(DragOperationNone, DragHandlingMethod::None, false, 0, { }));
    36553655        return;
    36563656    }
     
    36593659    case DragControllerAction::Entered: {
    36603660        DragOperation resolvedDragOperation = m_page->dragController().dragEntered(dragData);
    3661         send(Messages::WebPageProxy::DidPerformDragControllerAction(resolvedDragOperation, m_page->dragController().mouseIsOverFileInput(), m_page->dragController().numberOfItemsToBeAccepted(), m_page->dragCaretController().caretRectInRootViewCoordinates()));
     3661        send(Messages::WebPageProxy::DidPerformDragControllerAction(resolvedDragOperation, m_page->dragController().dragHandlingMethod(), m_page->dragController().mouseIsOverFileInput(), m_page->dragController().numberOfItemsToBeAccepted(), m_page->dragCaretController().caretRectInRootViewCoordinates()));
    36623662        return;
    36633663    }
    36643664    case DragControllerAction::Updated: {
    36653665        DragOperation resolvedDragOperation = m_page->dragController().dragUpdated(dragData);
    3666         send(Messages::WebPageProxy::DidPerformDragControllerAction(resolvedDragOperation, m_page->dragController().mouseIsOverFileInput(), m_page->dragController().numberOfItemsToBeAccepted(), m_page->dragCaretController().caretRectInRootViewCoordinates()));
     3666        send(Messages::WebPageProxy::DidPerformDragControllerAction(resolvedDragOperation, m_page->dragController().dragHandlingMethod(), m_page->dragController().mouseIsOverFileInput(), m_page->dragController().numberOfItemsToBeAccepted(), m_page->dragCaretController().caretRectInRootViewCoordinates()));
    36673667        return;
    36683668    }
    36693669    case DragControllerAction::Exited:
    36703670        m_page->dragController().dragExited(dragData);
    3671         send(Messages::WebPageProxy::DidPerformDragControllerAction(DragOperationNone, false, 0, { }));
     3671        send(Messages::WebPageProxy::DidPerformDragControllerAction(DragOperationNone, DragHandlingMethod::None, false, 0, { }));
    36723672        return;
    36733673       
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.h

    r239006 r239039  
    168168
    169169enum SyntheticClickType : int8_t;
     170enum class DragHandlingMethod : uint8_t;
    170171enum class ShouldTreatAsContinuingLoad : bool;
    171172enum class TextIndicatorPresentationTransition : uint8_t;
  • trunk/Tools/ChangeLog

    r239028 r239039  
     12018-12-10  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [iOS] Caret is obscured by finger when dragging over an editable element
     4        https://bugs.webkit.org/show_bug.cgi?id=192499
     5        <rdar://problem/46570101>
     6
     7        Reviewed by Tim Horton.
     8
     9        Augment some existing API tests to check that the `precise` flag is either on or off on `UIDropProposal`.
     10
     11        * TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm:
     12        * TestWebKitAPI/cocoa/DragAndDropSimulator.h:
     13        * TestWebKitAPI/ios/DragAndDropSimulatorIOS.mm:
     14        (-[DragAndDropSimulator _resetSimulatedState]):
     15        (-[DragAndDropSimulator lastKnownDropProposal]):
     16
     17        Rename `currentDropProposal` to `lastKnownDropProposal`, and expose it as a readonly property.
     18
     19        (-[DragAndDropSimulator _concludeDropAndPerformOperationIfNecessary]):
     20        (-[DragAndDropSimulator _advanceProgress]):
     21        (-[DragAndDropSimulator setShowCustomActionSheetBlock:]):
     22        (-[DragAndDropSimulator showCustomActionSheetBlock]):
     23        (-[DragAndDropSimulator setConvertItemProvidersBlock:]):
     24        (-[DragAndDropSimulator convertItemProvidersBlock]):
     25        (-[DragAndDropSimulator setOverridePerformDropBlock:]):
     26        (-[DragAndDropSimulator overridePerformDropBlock]):
     27        (-[DragAndDropSimulator setOverrideDragUpdateBlock:]):
     28        (-[DragAndDropSimulator overrideDragUpdateBlock]):
     29        (-[DragAndDropSimulator setDropCompletionBlock:]):
     30        (-[DragAndDropSimulator dropCompletionBlock]):
     31
     32        Refactor these properties to return and take normal Objective-C blocks, rather than `BlockPtr`s. However, use
     33        `BlockPtr` instance variables to manage the lifetimes of these blocks.
     34
     35        (-[DragAndDropSimulator _webView:willUpdateDropProposalToProposal:forSession:]):
     36        (-[DragAndDropSimulator _webView:willUpdateDataInteractionOperationToOperation:forSession:]): Deleted.
     37
     38        Update this to use the new WebKit delegate hook for overriding the drop proposal.
     39
    1402018-12-10  Michael Catanzaro  <mcatanzaro@igalia.com>
    241
  • trunk/Tools/TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm

    r238795 r239039  
    273273    checkFirstTypeIsPresentAndSecondTypeIsMissing(simulator.get(), kUTTypePNG, kUTTypeFileURL);
    274274    checkEstimatedSize(simulator.get(), { 215, 174 });
     275    EXPECT_TRUE([simulator lastKnownDropProposal].precise);
    275276}
    276277
     
    317318    checkSuggestedNameAndEstimatedSize(simulator.get(), @"icon.png", { 215, 174 });
    318319    checkTypeIdentifierIsRegisteredAtIndex(simulator.get(), (__bridge NSString *)kUTTypePNG, 0);
     320    EXPECT_TRUE([simulator lastKnownDropProposal].precise);
    319321}
    320322
     
    364366    checkSelectionRectsWithLogging(@[ makeCGRectValue(1, 201, 961, 227) ], [simulator finalSelectionRects]);
    365367    checkRichTextTypePrecedesPlainTextType(simulator.get());
     368    EXPECT_TRUE([simulator lastKnownDropProposal].precise);
    366369}
    367370
     
    384387    checkSelectionRectsWithLogging(@[ makeCGRectValue(6, 203, 990, 232) ], [simulator finalSelectionRects]);
    385388    checkRichTextTypePrecedesPlainTextType(simulator.get());
     389    EXPECT_TRUE([simulator lastKnownDropProposal].precise);
    386390}
    387391
     
    414418    EXPECT_GT(firstParagraphOffset, secondParagraphOffset);
    415419    checkSelectionRectsWithLogging(@[ makeCGRectValue(190, 100, 130, 20), makeCGRectValue(0, 120, 320, 100), makeCGRectValue(0, 220, 252, 20) ], [simulator finalSelectionRects]);
     420    EXPECT_TRUE([simulator lastKnownDropProposal].precise);
    416421}
    417422
     
    630635
    631636    EXPECT_WK_STREQ("", [webView stringByEvaluatingJavaScript:@"output.value"]);
     637    EXPECT_FALSE([simulator lastKnownDropProposal].precise);
    632638}
    633639
     
    646652
    647653    EXPECT_WK_STREQ("application/json", [webView stringByEvaluatingJavaScript:@"output.value"]);
     654    EXPECT_FALSE([simulator lastKnownDropProposal].precise);
    648655}
    649656
     
    663670    NSString *outputValue = [webView stringByEvaluatingJavaScript:@"output.value"];
    664671    EXPECT_WK_STREQ("image/jpeg", outputValue.UTF8String);
     672    EXPECT_FALSE([simulator lastKnownDropProposal].precise);
    665673}
    666674
     
    682690    NSString *outputValue = [webView stringByEvaluatingJavaScript:@"output.value"];
    683691    EXPECT_WK_STREQ("text/html", outputValue.UTF8String);
     692    EXPECT_FALSE([simulator lastKnownDropProposal].precise);
    684693}
    685694
     
    719728    NSString *outputValue = [webView stringByEvaluatingJavaScript:@"output.value"];
    720729    EXPECT_WK_STREQ("application/zip", outputValue.UTF8String);
     730    EXPECT_FALSE([simulator lastKnownDropProposal].precise);
    721731}
    722732
     
    735745    NSString *outputValue = [webView stringByEvaluatingJavaScript:@"output.value"];
    736746    EXPECT_WK_STREQ("application/zip", outputValue.UTF8String);
     747    EXPECT_FALSE([simulator lastKnownDropProposal].precise);
    737748}
    738749
     
    756767    NSString *outputValue = [webView stringByEvaluatingJavaScript:@"output.value"];
    757768    EXPECT_WK_STREQ("", outputValue.UTF8String);
     769    EXPECT_FALSE([simulator lastKnownDropProposal].precise);
    758770}
    759771
     
    778790    NSString *outputValue = [webView stringByEvaluatingJavaScript:@"output.value"];
    779791    EXPECT_WK_STREQ("image/jpeg, text/html", outputValue.UTF8String);
     792    EXPECT_FALSE([simulator lastKnownDropProposal].precise);
    780793}
    781794
     
    804817    NSString *outputValue = [webView stringByEvaluatingJavaScript:@"output.value"];
    805818    EXPECT_WK_STREQ("image/jpeg, text/html, text/html", outputValue.UTF8String);
     819    EXPECT_FALSE([simulator lastKnownDropProposal].precise);
    806820}
    807821
     
    10301044    NSString *outputValue = [webView stringByEvaluatingJavaScript:@"output.value"];
    10311045    EXPECT_WK_STREQ("text/html", outputValue.UTF8String);
     1046    EXPECT_FALSE([simulator lastKnownDropProposal].precise);
    10321047}
    10331048
     
    11551170    auto simulator = adoptNS([[DragAndDropSimulator alloc] initWithWebView:webView.get()]);
    11561171    [simulator setExternalItemProviders:@[ simulatedItemProvider.get() ]];
    1157     [simulator setOverrideDragUpdateBlock:^NSUInteger(NSUInteger operation, id session)
    1158     {
    1159         EXPECT_EQ(0U, operation);
     1172    [simulator setOverrideDragUpdateBlock:[] (UIDropOperation operation, id <UIDropSession> session) {
     1173        EXPECT_EQ(UIDropOperationCancel, operation);
    11601174        return UIDropOperationCopy;
    11611175    }];
  • trunk/Tools/TestWebKitAPI/cocoa/DragAndDropSimulator.h

    r238728 r239039  
    9696@property (nonatomic) BOOL shouldEnsureUIApplication;
    9797@property (nonatomic) BOOL shouldAllowMoveOperation;
    98 @property (nonatomic) BlockPtr<BOOL(_WKActivatedElementInfo *)> showCustomActionSheetBlock;
    99 @property (nonatomic) BlockPtr<NSArray *(NSItemProvider *, NSArray *, NSDictionary *)> convertItemProvidersBlock;
    100 @property (nonatomic) BlockPtr<NSArray *(id <UIDropSession>)> overridePerformDropBlock;
    10198@property (nonatomic, strong) NSArray *externalItemProviders;
    102 @property (nonatomic) BlockPtr<NSUInteger(NSUInteger, id)> overrideDragUpdateBlock;
    103 @property (nonatomic) BlockPtr<void(BOOL, NSArray *)> dropCompletionBlock;
     99@property (nonatomic, readonly) UIDropProposal *lastKnownDropProposal;
     100
     101@property (nonatomic, copy) BOOL(^showCustomActionSheetBlock)(_WKActivatedElementInfo *);
     102@property (nonatomic, copy) NSArray *(^convertItemProvidersBlock)(NSItemProvider *, NSArray *, NSDictionary *);
     103@property (nonatomic, copy) NSArray *(^overridePerformDropBlock)(id <UIDropSession>);
     104@property (nonatomic, copy) void(^dropCompletionBlock)(BOOL, NSArray *);
     105@property (nonatomic, copy) UIDropOperation(^overrideDragUpdateBlock)(UIDropOperation, id <UIDropSession>);
    104106
    105107@property (nonatomic, readonly) NSArray *sourceItemProviders;
  • trunk/Tools/TestWebKitAPI/ios/DragAndDropSimulatorIOS.mm

    r238728 r239039  
    317317
    318318    BOOL _suppressedSelectionCommandsDuringDrop;
    319     RetainPtr<UIDropProposal> _currentDropProposal;
     319    RetainPtr<UIDropProposal> _lastKnownDropProposal;
     320
     321    BlockPtr<BOOL(_WKActivatedElementInfo *)> _showCustomActionSheetBlock;
     322    BlockPtr<NSArray *(NSItemProvider *, NSArray *, NSDictionary *)> _convertItemProvidersBlock;
     323    BlockPtr<NSArray *(id <UIDropSession>)> _overridePerformDropBlock;
     324    BlockPtr<UIDropOperation(UIDropOperation, id)> _overrideDragUpdateBlock;
     325    BlockPtr<void(BOOL, NSArray *)> _dropCompletionBlock;
    320326}
    321327
     
    368374    _dragSession = nil;
    369375    _dropSession = nil;
    370     _currentDropProposal = nil;
     376    _lastKnownDropProposal = nil;
    371377    _lastKnownDragCaretRect = CGRectZero;
    372378    _remainingAdditionalItemRequestLocationsByProgress = nil;
     
    379385{
    380386    return _observedEventNames.get();
     387}
     388
     389- (UIDropProposal *)lastKnownDropProposal
     390{
     391    return _lastKnownDropProposal.get();
    381392}
    382393
     
    449460{
    450461    _lastKnownDragCaretRect = [_webView _dragCaretRect];
    451     auto operation = [_currentDropProposal operation];
     462    auto operation = [_lastKnownDropProposal operation];
    452463    if (operation != UIDropOperationCancel && operation != UIDropOperationForbidden) {
    453464        [[_webView dropInteractionDelegate] dropInteraction:[_webView dropInteraction] performDrop:_dropSession.get()];
     
    570581        break;
    571582    case DragAndDropPhaseEntered: {
    572         _currentDropProposal = [[_webView dropInteractionDelegate] dropInteraction:[_webView dropInteraction] sessionDidUpdate:_dropSession.get()];
    573         if (![self shouldAllowMoveOperation] && [_currentDropProposal operation] == UIDropOperationMove)
    574             _currentDropProposal = adoptNS([[UIDropProposal alloc] initWithDropOperation:UIDropOperationCancel]);
     583        _lastKnownDropProposal = [[_webView dropInteractionDelegate] dropInteraction:[_webView dropInteraction] sessionDidUpdate:_dropSession.get()];
     584        if (![self shouldAllowMoveOperation] && [_lastKnownDropProposal operation] == UIDropOperationMove)
     585            _lastKnownDropProposal = adoptNS([[UIDropProposal alloc] initWithDropOperation:UIDropOperationCancel]);
    575586        break;
    576587    }
     
    655666}
    656667
     668- (void)setShowCustomActionSheetBlock:(BOOL(^)(_WKActivatedElementInfo *))showCustomActionSheetBlock
     669{
     670    _showCustomActionSheetBlock = showCustomActionSheetBlock;
     671}
     672
     673- (BOOL(^)(_WKActivatedElementInfo *))showCustomActionSheetBlock
     674{
     675    return _showCustomActionSheetBlock.get();
     676}
     677
     678- (void)setConvertItemProvidersBlock:(NSArray *(^)(NSItemProvider *, NSArray *, NSDictionary *))convertItemProvidersBlock
     679{
     680    _convertItemProvidersBlock = convertItemProvidersBlock;
     681}
     682
     683- (NSArray *(^)(NSItemProvider *, NSArray *, NSDictionary *))convertItemProvidersBlock
     684{
     685    return _convertItemProvidersBlock.get();
     686}
     687
     688- (void)setOverridePerformDropBlock:(NSArray *(^)(id <UIDropSession>))overridePerformDropBlock
     689{
     690    _overridePerformDropBlock = overridePerformDropBlock;
     691}
     692
     693- (NSArray *(^)(id <UIDropSession>))overridePerformDropBlock
     694{
     695    return _overridePerformDropBlock.get();
     696}
     697
     698- (void)setOverrideDragUpdateBlock:(UIDropOperation(^)(UIDropOperation, id <UIDropSession>))overrideDragUpdateBlock
     699{
     700    _overrideDragUpdateBlock = overrideDragUpdateBlock;
     701}
     702
     703- (UIDropOperation(^)(UIDropOperation, id <UIDropSession>))overrideDragUpdateBlock
     704{
     705    return _overrideDragUpdateBlock.get();
     706}
     707
     708- (void)setDropCompletionBlock:(void(^)(BOOL, NSArray *))dropCompletionBlock
     709{
     710    _dropCompletionBlock = dropCompletionBlock;
     711}
     712
     713- (void(^)(BOOL, NSArray *))dropCompletionBlock
     714{
     715    return _dropCompletionBlock.get();
     716}
     717
    657718#pragma mark - WKUIDelegatePrivate
    658719
     
    666727}
    667728
    668 - (NSUInteger)_webView:(WKWebView *)webView willUpdateDataInteractionOperationToOperation:(NSUInteger)operation forSession:(id)session
    669 {
    670     return self.overrideDragUpdateBlock ? self.overrideDragUpdateBlock(operation, session) : operation;
     729- (UIDropProposal *)_webView:(WKWebView *)webView willUpdateDropProposalToProposal:(UIDropProposal *)proposal forSession:(id <UIDropSession>)session
     730{
     731    if (!self.overrideDragUpdateBlock)
     732        return proposal;
     733
     734    return [[[UIDropProposal alloc] initWithDropOperation:self.overrideDragUpdateBlock(proposal.operation, session)] autorelease];
    671735}
    672736
Note: See TracChangeset for help on using the changeset viewer.