Changeset 238475 in webkit


Ignore:
Timestamp:
Nov 25, 2018 4:11:16 AM (6 years ago)
Author:
timothy_horton@apple.com
Message:

Make it possible to insert editable images with a gesture
https://bugs.webkit.org/show_bug.cgi?id=191937

Reviewed by Wenson Hsieh.

Source/WebCore:

Tests:

editing/images/redo-insert-editable-image-maintains-strokes.html,
editing/images/undo-insert-editable-image.html,
editing/images/basic-editable-image-from-execCommand.html

  • Sources.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • Source/WebCore/editing/EditorCommand.cpp:
  • Source/WebCore/en.lproj/Localizable.strings:
  • editing/EditAction.h:
  • editing/Editor.cpp:

(WebCore::Editor::insertEditableImage):

  • editing/Editor.h:
  • editing/InsertEditableImageCommand.cpp: Added.

(WebCore::InsertEditableImageCommand::InsertEditableImageCommand):
(WebCore::InsertEditableImageCommand::doApply):

  • editing/InsertEditableImageCommand.h: Added.

(WebCore::InsertEditableImageCommand::create):

  • editing/VisibleSelection.cpp:

Add an editor command that inserts an editable image.
It will likely get a bit more complicated, but for now it just inserts
a 100% by 300px editable image.

Source/WebKit:

  • UIProcess/API/Cocoa/WKWebView.mm:

(-[WKWebView _stylusTapGestureShouldCreateEditableImage]):

  • UIProcess/API/Cocoa/WKWebViewInternal.h:

Add a internal getter for a WKWebViewConfiguration property.

  • UIProcess/WebEditCommandProxy.cpp:

(WebKit::WebEditCommandProxy::nameForEditAction):
Add a undo name.

  • UIProcess/WebPageProxy.h:
  • UIProcess/ios/WKContentViewInteraction.h:
  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView setupInteraction]):
(-[WKContentView cleanupInteraction]):
(-[WKContentView _removeDefaultGestureRecognizers]):
(-[WKContentView _addDefaultGestureRecognizers]):
Add a single-stylus-tap gesture recognizer.

(-[WKContentView _stylusSingleTapRecognized:]):
If allowed, request to insert an editable image when a stylus tap occurs.

  • UIProcess/ios/WebPageProxyIOS.mm:

(WebKit::WebPageProxy::handleStylusSingleTapAtPoint):

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

(WebKit::WebPage::handleStylusSingleTapAtPoint):
Do a hit test, select the hit position, insert an editable image, and
then de-assist any assisted node (to make the keyboard go away).
For now, we'll only insert if we hit non-replaced elements,
though this heuristic will need to be enhanced significantly once we
decide on a design.

Source/WebKitLegacy/mac:

  • WebCoreSupport/WebEditorClient.mm:

(undoNameForEditAction):
Add a undo name.

Tools:

  • WebKitTestRunner/ios/UIScriptControllerIOS.mm:

(WTR::UIScriptController::drawSquareInEditableImage):
If the canvas already has a drawing, draw a new stroke on top of it
instead of removing the existing stroke.

LayoutTests:

  • editing/images/basic-editable-image-from-execCommand-expected.txt: Added.
  • editing/images/basic-editable-image-from-execCommand.html: Added.

Add a test that ensures that editable images also work when
inserted via the editor command.

  • editing/images/redo-insert-editable-image-maintains-strokes-expected.txt: Added.
  • editing/images/redo-insert-editable-image-maintains-strokes.html: Added.

Add a test that ensures that strokes are maintained when re-doing an
un-done editable image insertion.

  • editing/images/undo-insert-editable-image-expected.txt: Added.
  • editing/images/undo-insert-editable-image.html: Added.

Add a test that ensures that the selection stays in a sensible place
when undoing and redoing editable image insertion.

Location:
trunk
Files:
7 added
25 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r238465 r238475  
     12018-11-25  Tim Horton  <timothy_horton@apple.com>
     2
     3        Make it possible to insert editable images with a gesture
     4        https://bugs.webkit.org/show_bug.cgi?id=191937
     5
     6        Reviewed by Wenson Hsieh.
     7
     8        * editing/images/basic-editable-image-from-execCommand-expected.txt: Added.
     9        * editing/images/basic-editable-image-from-execCommand.html: Added.
     10        Add a test that ensures that editable images also work when
     11        inserted via the editor command.
     12
     13        * editing/images/redo-insert-editable-image-maintains-strokes-expected.txt: Added.
     14        * editing/images/redo-insert-editable-image-maintains-strokes.html: Added.
     15        Add a test that ensures that strokes are maintained when re-doing an
     16        un-done editable image insertion.
     17
     18        * editing/images/undo-insert-editable-image-expected.txt: Added.
     19        * editing/images/undo-insert-editable-image.html: Added.
     20        Add a test that ensures that the selection stays in a sensible place
     21        when undoing and redoing editable image insertion.
     22
    1232018-11-23  Ryosuke Niwa  <rniwa@webkit.org>
    224
  • trunk/Source/WebCore/ChangeLog

    r238473 r238475  
     12018-11-25  Tim Horton  <timothy_horton@apple.com>
     2
     3        Make it possible to insert editable images with a gesture
     4        https://bugs.webkit.org/show_bug.cgi?id=191937
     5
     6        Reviewed by Wenson Hsieh.
     7
     8        Tests:
     9            editing/images/redo-insert-editable-image-maintains-strokes.html,
     10            editing/images/undo-insert-editable-image.html,
     11            editing/images/basic-editable-image-from-execCommand.html
     12
     13        * Sources.txt:
     14        * WebCore.xcodeproj/project.pbxproj:
     15        * Source/WebCore/editing/EditorCommand.cpp:
     16        * Source/WebCore/en.lproj/Localizable.strings:
     17        * editing/EditAction.h:
     18        * editing/Editor.cpp:
     19        (WebCore::Editor::insertEditableImage):
     20        * editing/Editor.h:
     21        * editing/InsertEditableImageCommand.cpp: Added.
     22        (WebCore::InsertEditableImageCommand::InsertEditableImageCommand):
     23        (WebCore::InsertEditableImageCommand::doApply):
     24        * editing/InsertEditableImageCommand.h: Added.
     25        (WebCore::InsertEditableImageCommand::create):
     26        * editing/VisibleSelection.cpp:
     27        Add an editor command that inserts an editable image.
     28        It will likely get a bit more complicated, but for now it just inserts
     29        a 100% by 300px editable image.
     30
    1312018-11-24  Wenson Hsieh  <wenson_hsieh@apple.com>
    232
  • trunk/Source/WebCore/Sources.txt

    r238457 r238475  
    915915editing/InsertNestedListCommand.cpp
    916916editing/IndentOutdentCommand.cpp
     917editing/InsertEditableImageCommand.cpp
    917918editing/InsertIntoTextNodeCommand.cpp
    918919editing/InsertLineBreakCommand.cpp
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r238451 r238475  
    755755                2D76BB821945632400CFD29A /* RunLoopObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D76BB801945632400CFD29A /* RunLoopObserver.h */; settings = {ATTRIBUTES = (Private, ); }; };
    756756                2D7ED0AB1BAE99170043B3E5 /* TimerEventBasedMock.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D7ED0A91BAE99170043B3E5 /* TimerEventBasedMock.h */; };
     757                2D81E1CF21A78CC200A32CF4 /* InsertEditableImageCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D81E1CD21A78CC200A32CF4 /* InsertEditableImageCommand.h */; };
    757758                2D8287F716E4A0380086BD00 /* HitTestLocation.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D8287F516E4A0380086BD00 /* HitTestLocation.h */; settings = {ATTRIBUTES = (Private, ); }; };
    758759                2D8B92CE203D13E1009C868F /* UnifiedSource481.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE5F84AD1FA1A48B006DB63B /* UnifiedSource481.cpp */; };
     
    66506651                2D76BB8319456F8100CFD29A /* RunLoopObserver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RunLoopObserver.cpp; sourceTree = "<group>"; };
    66516652                2D7ED0A91BAE99170043B3E5 /* TimerEventBasedMock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TimerEventBasedMock.h; sourceTree = "<group>"; };
     6653                2D81E1CB21A78CC100A32CF4 /* InsertEditableImageCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InsertEditableImageCommand.cpp; sourceTree = "<group>"; };
     6654                2D81E1CD21A78CC200A32CF4 /* InsertEditableImageCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InsertEditableImageCommand.h; sourceTree = "<group>"; };
    66526655                2D8287F416E4A0380086BD00 /* HitTestLocation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HitTestLocation.cpp; sourceTree = "<group>"; };
    66536656                2D8287F516E4A0380086BD00 /* HitTestLocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HitTestLocation.h; sourceTree = "<group>"; };
     
    2085420857                                DB23C2C90A508D29002489EB /* IndentOutdentCommand.cpp */,
    2085520858                                DB23C2CA0A508D29002489EB /* IndentOutdentCommand.h */,
     20859                                2D81E1CB21A78CC100A32CF4 /* InsertEditableImageCommand.cpp */,
     20860                                2D81E1CD21A78CC200A32CF4 /* InsertEditableImageCommand.h */,
    2085620861                                93309D9A099E64910056E581 /* InsertIntoTextNodeCommand.cpp */,
    2085720862                                93309D9B099E64910056E581 /* InsertIntoTextNodeCommand.h */,
     
    2920629211                                37E3524D12450C6600BAF5D9 /* InputType.h in Headers */,
    2920729212                                C348612415FDE21E007A1CC9 /* InputTypeNames.h in Headers */,
     29213                                2D81E1CF21A78CC200A32CF4 /* InsertEditableImageCommand.h in Headers */,
    2920829214                                93309DEA099E64920056E581 /* InsertIntoTextNodeCommand.h in Headers */,
    2920929215                                93309DEC099E64920056E581 /* InsertLineBreakCommand.h in Headers */,
  • trunk/Source/WebCore/editing/EditAction.h

    r238080 r238475  
    8888    ConvertToUnorderedList,
    8989    Indent,
    90     Outdent
     90    Outdent,
     91    InsertEditableImage
    9192};
    9293
  • trunk/Source/WebCore/editing/Editor.cpp

    r238454 r238475  
    6969#include "IndentOutdentCommand.h"
    7070#include "InputEvent.h"
     71#include "InsertEditableImageCommand.h"
    7172#include "InsertListCommand.h"
    7273#include "InsertTextCommand.h"
     
    42514252}
    42524253
     4254void Editor::insertEditableImage()
     4255{
     4256    InsertEditableImageCommand::create(document())->apply();
     4257}
     4258
    42534259} // namespace WebCore
  • trunk/Source/WebCore/editing/Editor.h

    r238454 r238475  
    533533#endif
    534534
     535    WEBCORE_EXPORT void insertEditableImage();
     536
    535537private:
    536538    Document& document() const;
  • trunk/Source/WebCore/editing/EditorCommand.cpp

    r238454 r238475  
    4747#include "HTMLNames.h"
    4848#include "IndentOutdentCommand.h"
     49#include "InsertEditableImageCommand.h"
    4950#include "InsertListCommand.h"
    5051#include "InsertNestedListCommand.h"
     
    479480}
    480481
     482static bool executeInsertEditableImage(Frame& frame, Event*, EditorCommandSource, const String&)
     483{
     484    ASSERT(frame.document());
     485    InsertEditableImageCommand::create(*frame.document())->apply();
     486    return true;
     487}
     488
    481489static bool executeInsertLineBreak(Frame& frame, Event* event, EditorCommandSource source, const String&)
    482490{
     
    13701378{
    13711379    return frame.editor().canUndo();
     1380}
     1381
     1382static bool enabledInRichlyEditableTextWithEditableImagesEnabled(Frame& frame, Event* event, EditorCommandSource source)
     1383{
     1384    if (!frame.settings().editableImagesEnabled())
     1385        return false;
     1386    return enabledInRichlyEditableText(frame, event, source);
    13721387}
    13731388
     
    15911606        { "Indent", { executeIndent, supported, enabledInRichlyEditableText, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
    15921607        { "InsertBacktab", { executeInsertBacktab, supportedFromMenuOrKeyBinding, enabledInEditableText, stateNone, valueNull, isTextInsertion, doNotAllowExecutionWhenDisabled } },
     1608        { "InsertEditableImage", { executeInsertEditableImage, supported, enabledInRichlyEditableTextWithEditableImagesEnabled, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
    15931609        { "InsertHTML", { executeInsertHTML, supported, enabledInEditableText, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
    15941610        { "InsertHorizontalRule", { executeInsertHorizontalRule, supported, enabledInRichlyEditableText, stateNone, valueNull, notTextInsertion, doNotAllowExecutionWhenDisabled } },
  • trunk/Source/WebCore/editing/InsertEditableImageCommand.h

    r238474 r238475  
    11/*
    2  * Copyright (C) 2004-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2626#pragma once
    2727
     28#include "CompositeEditCommand.h"
     29
    2830namespace WebCore {
    2931
    30 enum class EditAction : uint8_t {
    31     Unspecified,
    32     Insert,
    33     InsertReplacement,
    34     InsertFromDrop,
    35     SetColor,
    36     SetBackgroundColor,
    37     TurnOffKerning,
    38     TightenKerning,
    39     LoosenKerning,
    40     UseStandardKerning,
    41     TurnOffLigatures,
    42     UseStandardLigatures,
    43     UseAllLigatures,
    44     RaiseBaseline,
    45     LowerBaseline,
    46     SetTraditionalCharacterShape,
    47     SetFont,
    48     ChangeAttributes,
    49     AlignLeft,
    50     AlignRight,
    51     Center,
    52     Justify,
    53     SetWritingDirection,
    54     Subscript,
    55     Superscript,
    56     Underline,
    57     Outline,
    58     Unscript,
    59     DeleteByDrag,
    60     Cut,
    61     Bold,
    62     Italics,
    63     Delete,
    64     Dictation,
    65     Paste,
    66     PasteFont,
    67     PasteRuler,
    68     TypingDeleteSelection,
    69     TypingDeleteBackward,
    70     TypingDeleteForward,
    71     TypingDeleteWordBackward,
    72     TypingDeleteWordForward,
    73     TypingDeleteLineBackward,
    74     TypingDeleteLineForward,
    75     TypingDeletePendingComposition,
    76     TypingDeleteFinalComposition,
    77     TypingInsertText,
    78     TypingInsertLineBreak,
    79     TypingInsertParagraph,
    80     TypingInsertPendingComposition,
    81     TypingInsertFinalComposition,
    82     CreateLink,
    83     Unlink,
    84     FormatBlock,
    85     InsertOrderedList,
    86     InsertUnorderedList,
    87     ConvertToOrderedList,
    88     ConvertToUnorderedList,
    89     Indent,
    90     Outdent
     32class InsertEditableImageCommand : public CompositeEditCommand {
     33public:
     34    static Ref<InsertEditableImageCommand> create(Document& document)
     35    {
     36        return adoptRef(*new InsertEditableImageCommand(document));
     37    }
     38
     39private:
     40    InsertEditableImageCommand(Document&);
     41
     42    void doApply() override;
     43    EditAction editingAction() const final { return EditAction::InsertEditableImage; }
    9144};
    9245
  • trunk/Source/WebCore/editing/VisibleSelection.cpp

    r236522 r238475  
    3232#include "HTMLInputElement.h"
    3333#include "Settings.h"
     34#include "ShadowRoot.h"
    3435#include "TextIterator.h"
    3536#include "VisibleUnits.h"
  • trunk/Source/WebCore/en.lproj/Localizable.strings

    r238473 r238475  
    357357
    358358/* Undo action name */
     359"Insert Drawing (Undo action name)" = "Insert Drawing";
     360
     361/* Undo action name */
    359362"Insert List (Undo action name)" = "Insert List";
    360363
  • trunk/Source/WebKit/ChangeLog

    r238474 r238475  
     12018-11-25  Tim Horton  <timothy_horton@apple.com>
     2
     3        Make it possible to insert editable images with a gesture
     4        https://bugs.webkit.org/show_bug.cgi?id=191937
     5
     6        Reviewed by Wenson Hsieh.
     7
     8        * UIProcess/API/Cocoa/WKWebView.mm:
     9        (-[WKWebView _stylusTapGestureShouldCreateEditableImage]):
     10        * UIProcess/API/Cocoa/WKWebViewInternal.h:
     11        Add a internal getter for a WKWebViewConfiguration property.
     12
     13        * UIProcess/WebEditCommandProxy.cpp:
     14        (WebKit::WebEditCommandProxy::nameForEditAction):
     15        Add a undo name.
     16
     17        * UIProcess/WebPageProxy.h:
     18        * UIProcess/ios/WKContentViewInteraction.h:
     19        * UIProcess/ios/WKContentViewInteraction.mm:
     20        (-[WKContentView setupInteraction]):
     21        (-[WKContentView cleanupInteraction]):
     22        (-[WKContentView _removeDefaultGestureRecognizers]):
     23        (-[WKContentView _addDefaultGestureRecognizers]):
     24        Add a single-stylus-tap gesture recognizer.
     25
     26        (-[WKContentView _stylusSingleTapRecognized:]):
     27        If allowed, request to insert an editable image when a stylus tap occurs.
     28
     29        * UIProcess/ios/WebPageProxyIOS.mm:
     30        (WebKit::WebPageProxy::handleStylusSingleTapAtPoint):
     31        * WebProcess/WebPage/WebPage.h:
     32        * WebProcess/WebPage/WebPage.messages.in:
     33        * WebProcess/WebPage/ios/WebPageIOS.mm:
     34        (WebKit::WebPage::handleStylusSingleTapAtPoint):
     35        Do a hit test, select the hit position, insert an editable image, and
     36        then de-assist any assisted node (to make the keyboard go away).
     37        For now, we'll only insert if we hit non-replaced elements,
     38        though this heuristic will need to be enhanced significantly once we
     39        decide on a design.
     40
    1412018-11-25  Tim Horton  <timothy_horton@apple.com>
    242
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm

    r238474 r238475  
    24392439    // initial scale, this simply becomes a test of the current scale against 1.
    24402440    return !areEssentiallyEqualAsFloat(contentZoomScale(self), 1);
     2441}
     2442
     2443- (BOOL)_stylusTapGestureShouldCreateEditableImage
     2444{
     2445    return [_configuration _editableImagesEnabled];
    24412446}
    24422447
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h

    r238235 r238475  
    168168
    169169@property (nonatomic, readonly) BOOL _allowsDoubleTapGestures;
     170@property (nonatomic, readonly) BOOL _stylusTapGestureShouldCreateEditableImage;
    170171@property (nonatomic, readonly) BOOL _haveSetObscuredInsets;
    171172@property (nonatomic, readonly) UIEdgeInsets _computedObscuredInset;
  • trunk/Source/WebKit/UIProcess/WebEditCommandProxy.cpp

    r238473 r238475  
    178178    case EditAction::ConvertToUnorderedList:
    179179        return WEB_UI_STRING_KEY("Convert to Unordered List", "Convert to Unordered List (Undo action name)", "Undo action name");
     180    case EditAction::InsertEditableImage:
     181        return WEB_UI_STRING_KEY("Insert Drawing", "Insert Drawing (Undo action name)", "Undo action name");
    180182    }
    181183    return String();
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r238471 r238475  
    653653    void getSelectionContext(WTF::Function<void(const String&, const String&, const String&, CallbackBase::Error)>&&);
    654654    void handleTwoFingerTapAtPoint(const WebCore::IntPoint&, uint64_t requestID);
     655    void handleStylusSingleTapAtPoint(const WebCore::IntPoint&, uint64_t requestID);
    655656    void setForceAlwaysUserScalable(bool);
    656657    bool forceAlwaysUserScalable() const { return m_forceAlwaysUserScalable; }
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h

    r238235 r238475  
    211211    RetainPtr<UITapGestureRecognizer> _twoFingerDoubleTapGestureRecognizer;
    212212    RetainPtr<UITapGestureRecognizer> _twoFingerSingleTapGestureRecognizer;
     213    RetainPtr<UITapGestureRecognizer> _stylusSingleTapGestureRecognizer;
    213214    RetainPtr<WKInspectorNodeSearchGestureRecognizer> _inspectorNodeSearchGestureRecognizer;
    214215
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r238360 r238475  
    692692    [self addGestureRecognizer:_twoFingerSingleTapGestureRecognizer.get()];
    693693
     694    _stylusSingleTapGestureRecognizer = adoptNS([[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(_stylusSingleTapRecognized:)]);
     695    [_stylusSingleTapGestureRecognizer setNumberOfTapsRequired:1];
     696    [_stylusSingleTapGestureRecognizer setDelegate:self];
     697    [_stylusSingleTapGestureRecognizer setAllowedTouchTypes:@[ @(UITouchTypePencil) ]];
     698    [self addGestureRecognizer:_stylusSingleTapGestureRecognizer.get()];
     699
    694700#if HAVE(LINK_PREVIEW)
    695701    [self _registerPreview];
     
    779785    [self removeGestureRecognizer:_twoFingerSingleTapGestureRecognizer.get()];
    780786
     787    [_stylusSingleTapGestureRecognizer setDelegate:nil];
     788    [self removeGestureRecognizer:_stylusSingleTapGestureRecognizer.get()];
     789
    781790    _layerTreeTransactionIdAtLastTouchStart = 0;
    782791
     
    835844    [self removeGestureRecognizer:_twoFingerDoubleTapGestureRecognizer.get()];
    836845    [self removeGestureRecognizer:_twoFingerSingleTapGestureRecognizer.get()];
     846    [self removeGestureRecognizer:_stylusSingleTapGestureRecognizer.get()];
    837847#if PLATFORM(IOSMAC)
    838848    [self removeGestureRecognizer:_hoverGestureRecognizer.get()];
     
    849859    [self addGestureRecognizer:_twoFingerDoubleTapGestureRecognizer.get()];
    850860    [self addGestureRecognizer:_twoFingerSingleTapGestureRecognizer.get()];
     861    [self addGestureRecognizer:_stylusSingleTapGestureRecognizer.get()];
    851862#if PLATFORM(IOSMAC)
    852863    [self addGestureRecognizer:_hoverGestureRecognizer.get()];
     
    18951906    _isExpectingFastSingleTapCommit = YES;
    18961907    _page->handleTwoFingerTapAtPoint(roundedIntPoint(gestureRecognizer.centroid), ++_latestTapID);
     1908}
     1909
     1910- (void)_stylusSingleTapRecognized:(UITapGestureRecognizer *)gestureRecognizer
     1911{
     1912    if (!_webView._stylusTapGestureShouldCreateEditableImage)
     1913        return;
     1914
     1915    ASSERT(gestureRecognizer == _stylusSingleTapGestureRecognizer);
     1916    _page->handleStylusSingleTapAtPoint(roundedIntPoint(gestureRecognizer.location), ++_latestTapID);
    18971917}
    18981918
  • trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm

    r238468 r238475  
    598598}
    599599
     600void WebPageProxy::handleStylusSingleTapAtPoint(const WebCore::IntPoint& point, uint64_t requestID)
     601{
     602    process().send(Messages::WebPage::HandleStylusSingleTapAtPoint(point, requestID), m_pageID);
     603}
     604
    600605void WebPageProxy::selectWithTwoTouches(const WebCore::IntPoint from, const WebCore::IntPoint to, uint32_t gestureType, uint32_t gestureState, WTF::Function<void (const WebCore::IntPoint&, uint32_t, uint32_t, uint32_t, CallbackBase::Error)>&& callbackFunction)
    601606{
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.h

    r238471 r238475  
    654654    void getSelectionContext(CallbackID);
    655655    void handleTwoFingerTapAtPoint(const WebCore::IntPoint&, uint64_t requestID);
     656    void handleStylusSingleTapAtPoint(const WebCore::IntPoint&, uint64_t requestID);
    656657    void getRectsForGranularityWithSelectionOffset(uint32_t, int32_t, CallbackID);
    657658    void getRectsAtSelectionOffsetWithText(int32_t, const String&, CallbackID);
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in

    r238471 r238475  
    100100    SetAllowsMediaDocumentInlinePlayback(bool allows)
    101101    HandleTwoFingerTapAtPoint(WebCore::IntPoint point, uint64_t requestID)
     102    HandleStylusSingleTapAtPoint(WebCore::IntPoint point, uint64_t requestID)
    102103    SetForceAlwaysUserScalable(bool userScalable)
    103104    GetRectsForGranularityWithSelectionOffset(uint32_t granularity, int32_t offset, WebKit::CallbackID callbackID)
  • trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r238461 r238475  
    759759}
    760760
     761void WebPage::handleStylusSingleTapAtPoint(const WebCore::IntPoint& point, uint64_t requestID)
     762{
     763    auto& frame = m_page->focusController().focusedOrMainFrame();
     764
     765    auto pointInDocument = frame.view()->rootViewToContents(point);
     766    HitTestResult hitTest = frame.eventHandler().hitTestResultAtPoint(pointInDocument, HitTestRequest::ReadOnly | HitTestRequest::Active);
     767
     768    Node* node = hitTest.innerNonSharedNode();
     769    if (!node)
     770        return;
     771    auto renderer = node->renderer();
     772    if (!renderer)
     773        return;
     774
     775    if (renderer->isReplaced())
     776        return;
     777
     778    VisiblePosition position = renderer->positionForPoint(hitTest.localPoint(), nullptr);
     779    if (position.isNull())
     780        position = firstPositionInOrBeforeNode(node);
     781
     782    if (position.isNull())
     783        return;
     784
     785    auto range = Range::create(*frame.document(), position, position);
     786    frame.selection().setSelectedRange(range.ptr(), position.affinity(), WebCore::FrameSelection::ShouldCloseTyping::Yes, UserTriggered);
     787    frame.editor().insertEditableImage();
     788    resetAssistedNodeForFrame(m_mainFrame.get());
     789}
     790
    761791void WebPage::potentialTapAtPosition(uint64_t requestID, const WebCore::FloatPoint& position)
    762792{
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r238473 r238475  
     12018-11-25  Tim Horton  <timothy_horton@apple.com>
     2
     3        Make it possible to insert editable images with a gesture
     4        https://bugs.webkit.org/show_bug.cgi?id=191937
     5
     6        Reviewed by Wenson Hsieh.
     7
     8        * WebCoreSupport/WebEditorClient.mm:
     9        (undoNameForEditAction):
     10        Add a undo name.
     11
    1122018-11-24  Wenson Hsieh  <wenson_hsieh@apple.com>
    213
  • trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebEditorClient.mm

    r238473 r238475  
    656656    case EditAction::ConvertToOrderedList: return UI_STRING_KEY_INTERNAL("Convert to Ordered List", "Convert to Ordered List (Undo action name)", "Undo action name");
    657657    case EditAction::ConvertToUnorderedList: return UI_STRING_KEY_INTERNAL("Convert to Unordered List", "Convert to Unordered List (Undo action name)", "Undo action name");
     658    case EditAction::InsertEditableImage: return UI_STRING_KEY_INTERNAL("Insert Drawing", "Insert Drawing (Undo action name)", "Undo action name");
    658659    }
    659660    return nil;
  • trunk/Tools/ChangeLog

    r238471 r238475  
     12018-11-25  Tim Horton  <timothy_horton@apple.com>
     2
     3        Make it possible to insert editable images with a gesture
     4        https://bugs.webkit.org/show_bug.cgi?id=191937
     5
     6        Reviewed by Wenson Hsieh.
     7
     8        * WebKitTestRunner/ios/UIScriptControllerIOS.mm:
     9        (WTR::UIScriptController::drawSquareInEditableImage):
     10        If the canvas already has a drawing, draw a new stroke on top of it
     11        instead of removing the existing stroke.
     12
    1132018-11-24  Wenson Hsieh  <wenson_hsieh@apple.com>
    214
  • trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm

    r238235 r238475  
    891891
    892892    PKCanvasView *canvasView = findEditableImageCanvas();
    893     RetainPtr<PKDrawing> drawing = adoptNS([[pkDrawingClass alloc] init]);
     893    RetainPtr<PKDrawing> drawing = canvasView.drawing ?: adoptNS([[pkDrawingClass alloc] init]);
    894894    RetainPtr<CGPathRef> path = adoptCF(CGPathCreateWithRect(CGRectMake(0, 0, 50, 50), NULL));
    895895    RetainPtr<PKInk> ink = [pkInkClass inkWithType:0 color:UIColor.greenColor weight:100.0];
Note: See TracChangeset for help on using the changeset viewer.