Changeset 212149 in webkit
- Timestamp:
- Feb 10, 2017, 2:16:19 PM (9 years ago)
- Location:
- trunk/Source
- Files:
-
- 7 edited
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/editing/FrameSelection.cpp (modified) (2 diffs)
-
WebCore/editing/FrameSelection.h (modified) (1 diff)
-
WebKit2/ChangeLog (modified) (1 diff)
-
WebKit2/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInEditingDelegate.h (modified) (2 diffs)
-
WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm (modified) (3 diffs)
-
WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r212148 r212149 1 2017-02-10 Dan Bernstein <mitz@apple.com> 2 3 [Cocoa] Add shouldChangeSelectedRange to WKWebProcessPlugInEditingDelegate 4 https://bugs.webkit.org/show_bug.cgi?id=168097 5 6 Reviewed by Tim Horton. 7 8 Added a userTriggered argument to FrameSelection::setSelectedRange so that WebKit2 can 9 indicate that changes should be agreed to by the delegate. 10 11 * editing/FrameSelection.cpp: 12 (WebCore::FrameSelection::setSelectedRange): If the change is user-triggered, check with 13 shouldChangeSelection. 14 * editing/FrameSelection.h: 15 1 16 2017-02-10 Jonathan Bedard <jbedard@apple.com> 2 17 -
trunk/Source/WebCore/editing/FrameSelection.cpp
r211591 r212149 1944 1944 } 1945 1945 1946 bool FrameSelection::setSelectedRange(Range* range, EAffinity affinity, bool closeTyping )1946 bool FrameSelection::setSelectedRange(Range* range, EAffinity affinity, bool closeTyping, EUserTriggered userTriggered) 1947 1947 { 1948 1948 if (!range) … … 1957 1957 return false; 1958 1958 #endif 1959 1960 if (userTriggered == UserTriggered) { 1961 FrameSelection trialFrameSelection; 1962 trialFrameSelection.setSelection(newSelection, ClearTypingStyle | (closeTyping ? CloseTyping : 0)); 1963 1964 if (!shouldChangeSelection(trialFrameSelection.selection())) 1965 return false; 1966 } 1959 1967 1960 1968 setSelection(newSelection, ClearTypingStyle | (closeTyping ? CloseTyping : 0)); -
trunk/Source/WebCore/editing/FrameSelection.h
r209411 r212149 146 146 const VisibleSelection& selection() const { return m_selection; } 147 147 WEBCORE_EXPORT void setSelection(const VisibleSelection&, SetSelectionOptions = defaultSetSelectionOptions(), AXTextStateChangeIntent = AXTextStateChangeIntent(), CursorAlignOnScroll = AlignCursorOnScrollIfNeeded, TextGranularity = CharacterGranularity); 148 WEBCORE_EXPORT bool setSelectedRange(Range*, EAffinity, bool closeTyping );148 WEBCORE_EXPORT bool setSelectedRange(Range*, EAffinity, bool closeTyping, EUserTriggered = NotUserTriggered); 149 149 WEBCORE_EXPORT void selectAll(); 150 150 WEBCORE_EXPORT void clear(); -
trunk/Source/WebKit2/ChangeLog
r212134 r212149 1 2017-02-10 Dan Bernstein <mitz@apple.com> 2 3 [Cocoa] Add shouldChangeSelectedRange to WKWebProcessPlugInEditingDelegate 4 https://bugs.webkit.org/show_bug.cgi?id=168097 5 6 Reviewed by Tim Horton. 7 8 * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInEditingDelegate.h: 9 Declared new delegate method. 10 * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm: 11 (-[WKWebProcessPlugInBrowserContextController _setEditingDelegate:]): Dispatch new delegate 12 method. 13 14 * WebProcess/WebPage/ios/WebPageIOS.mm: 15 (WebKit::WebPage::selectWithGesture): Pass UserTriggered whan calling 16 WebCore::Frame::Selection::setSelectedRange, so that the delegate is consulted. 17 (WebKit::WebPage::changeBlockSelection): Ditto. 18 (WebKit::WebPage::updateSelectionWithTouches): Ditto. 19 (WebKit::WebPage::selectWithTwoTouches): Ditto. 20 (WebKit::WebPage::extendSelection): Ditto. 21 (WebKit::WebPage::selectWordBackward): Ditto, 22 (WebKit::WebPage::moveSelectionByOffset): Ditto. 23 (WebKit::WebPage::selectPositionAtPoint): Ditto. 24 (WebKit::WebPage::selectPositionAtBoundaryWithDirection): Ditto. 25 (WebKit::WebPage::moveSelectionAtBoundaryWithDirection): Ditto. 26 (WebKit::WebPage::selectTextWithGranularityAtPoint): Ditto. 27 (WebKit::WebPage::updateSelectionWithExtentPointAndBoundary): Ditto. 28 (WebKit::WebPage::updateSelectionWithExtentPoint): Ditto. 29 1 30 2017-02-10 Brady Eidson <beidson@apple.com> 2 31 -
trunk/Source/WebKit2/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInEditingDelegate.h
r209775 r212149 31 31 #import <WebKit/WKWebProcessPlugInRangeHandle.h> 32 32 33 #if TARGET_OS_IPHONE 34 #import <UIKit/UIKit.h> 35 #else 36 #import <AppKit/AppKit.h> 37 #endif 38 33 39 NS_ASSUME_NONNULL_BEGIN 34 40 … … 45 51 46 52 - (BOOL)_webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController *)controller shouldInsertText:(NSString *)text replacingRange:(WKWebProcessPlugInRangeHandle *)range givenAction:(WKEditorInsertAction)action; 53 #if TARGET_OS_IPHONE 54 - (BOOL)_webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController *)controller shouldChangeSelectedRange:(WKDOMRange *)currentRange toRange:(WKDOMRange *)proposedRange affinity:(UITextStorageDirection)selectionAffinity stillSelecting:(BOOL)stillSelecting; 55 #else 56 - (BOOL)_webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController *)controller shouldChangeSelectedRange:(WKDOMRange *)currentRange toRange:(WKDOMRange *)proposedRange affinity:(NSSelectionAffinity)selectionAffinity stillSelecting:(BOOL)stillSelecting; 57 #endif 47 58 - (void)_webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController *)controller willWriteRangeToPasteboard:(WKWebProcessPlugInRangeHandle *)range; 48 59 - (NSDictionary<NSString *, NSData *> *)_webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController *)controller pasteboardDataForRange:(WKWebProcessPlugInRangeHandle *)range; -
trunk/Source/WebKit2/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm
r210109 r212149 607 607 } 608 608 609 bool shouldChangeSelectedRange(WebPage&, Range* fromRange, Range* toRange, EAffinity affinity, bool stillSelecting) final 610 { 611 if (!m_delegateMethods.shouldChangeSelectedRange) 612 return true; 613 614 auto apiFromRange = fromRange ? adoptNS([[WKDOMRange alloc] _initWithImpl:fromRange]) : nil; 615 auto apiToRange = toRange ? adoptNS([[WKDOMRange alloc] _initWithImpl:toRange]) : nil; 616 #if PLATFORM(IOS) 617 UITextStorageDirection apiAffinity = affinity == UPSTREAM ? UITextStorageDirectionBackward : UITextStorageDirectionForward; 618 #else 619 NSSelectionAffinity apiAffinity = affinity == UPSTREAM ? NSSelectionAffinityUpstream : NSSelectionAffinityDownstream; 620 #endif 621 622 return [m_controller->_editingDelegate.get() _webProcessPlugInBrowserContextController:m_controller shouldChangeSelectedRange:apiFromRange.get() toRange:apiToRange.get() affinity:apiAffinity stillSelecting:stillSelecting]; 623 } 624 609 625 void willWriteToPasteboard(WebKit::WebPage&, WebCore::Range* range) final 610 626 { … … 639 655 DelegateMethods(RetainPtr<id <WKWebProcessPlugInEditingDelegate>> delegate) 640 656 : shouldInsertText([delegate respondsToSelector:@selector(_webProcessPlugInBrowserContextController:shouldInsertText:replacingRange:givenAction:)]) 657 , shouldChangeSelectedRange([delegate respondsToSelector:@selector(_webProcessPlugInBrowserContextController:shouldChangeSelectedRange:toRange:affinity:stillSelecting:)]) 641 658 , willWriteToPasteboard([delegate respondsToSelector:@selector(_webProcessPlugInBrowserContextController:willWriteRangeToPasteboard:)]) 642 659 , getPasteboardDataForRange([delegate respondsToSelector:@selector(_webProcessPlugInBrowserContextController:pasteboardDataForRange:)]) … … 646 663 647 664 bool shouldInsertText; 665 bool shouldChangeSelectedRange; 648 666 bool willWriteToPasteboard; 649 667 bool getPasteboardDataForRange; -
trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm
r211679 r212149 1161 1161 } 1162 1162 if (range) 1163 frame.selection().setSelectedRange(range.get(), position.affinity(), true );1163 frame.selection().setSelectedRange(range.get(), position.affinity(), true, UserTriggered); 1164 1164 1165 1165 send(Messages::WebPageProxy::GestureCallback(point, gestureType, gestureState, static_cast<uint32_t>(flags), callbackID)); … … 1614 1614 if (newRange) { 1615 1615 m_currentBlockSelection = newRange; 1616 frame.selection().setSelectedRange(newRange.get(), VP_DEFAULT_AFFINITY, true );1616 frame.selection().setSelectedRange(newRange.get(), VP_DEFAULT_AFFINITY, true, UserTriggered); 1617 1617 } 1618 1618 … … 1738 1738 } 1739 1739 if (range && flags != IsBlockSelection) 1740 frame.selection().setSelectedRange(range.get(), position.affinity(), true );1740 frame.selection().setSelectedRange(range.get(), position.affinity(), true, UserTriggered); 1741 1741 1742 1742 send(Messages::WebPageProxy::TouchesCallback(point, touches, flags, callbackID)); … … 1744 1744 // We just switched to block selection therefore we need to compute the thresholds. 1745 1745 m_currentBlockSelection = range; 1746 frame.selection().setSelectedRange(range.get(), position.affinity(), true );1746 frame.selection().setSelectedRange(range.get(), position.affinity(), true, UserTriggered); 1747 1747 1748 1748 float growThreshold = 0; … … 1764 1764 else 1765 1765 range = Range::create(*frame.document(), toPosition, fromPosition); 1766 frame.selection().setSelectedRange(range.get(), fromPosition.affinity(), true );1766 frame.selection().setSelectedRange(range.get(), fromPosition.affinity(), true, UserTriggered); 1767 1767 } 1768 1768 … … 1779 1779 1780 1780 VisiblePosition position = frame.selection().selection().start(); 1781 frame.selection().setSelectedRange(wordRangeFromPosition(position).get(), position.affinity(), true );1781 frame.selection().setSelectedRange(wordRangeFromPosition(position).get(), position.affinity(), true, UserTriggered); 1782 1782 } 1783 1783 … … 1791 1791 VisiblePosition startPosition = positionOfNextBoundaryOfGranularity(position, WordGranularity, DirectionBackward); 1792 1792 if (startPosition.isNotNull() && startPosition != position) 1793 frame.selection().setSelectedRange(Range::create(*frame.document(), startPosition, position).ptr(), position.affinity(), true );1793 frame.selection().setSelectedRange(Range::create(*frame.document(), startPosition, position).ptr(), position.affinity(), true, UserTriggered); 1794 1794 } 1795 1795 … … 1809 1809 } 1810 1810 if (position.isNotNull() && startPosition != position) 1811 frame.selection().setSelectedRange(Range::create(*frame.document(), position, position).ptr(), position.affinity(), true );1811 frame.selection().setSelectedRange(Range::create(*frame.document(), position, position).ptr(), position.affinity(), true, UserTriggered); 1812 1812 send(Messages::WebPageProxy::VoidCallback(callbackID)); 1813 1813 } … … 1904 1904 1905 1905 if (position.isNotNull()) 1906 frame.selection().setSelectedRange(Range::create(*frame.document(), position, position).ptr(), position.affinity(), true );1906 frame.selection().setSelectedRange(Range::create(*frame.document(), position, position).ptr(), position.affinity(), true, UserTriggered); 1907 1907 send(Messages::WebPageProxy::VoidCallback(callbackID)); 1908 1908 } … … 1916 1916 position = positionOfNextBoundaryOfGranularity(position, static_cast<WebCore::TextGranularity>(granularity), static_cast<SelectionDirection>(direction)); 1917 1917 if (position.isNotNull()) 1918 frame.selection().setSelectedRange(Range::create(*frame.document(), position, position).ptr(), UPSTREAM, true );1918 frame.selection().setSelectedRange(Range::create(*frame.document(), position, position).ptr(), UPSTREAM, true, UserTriggered); 1919 1919 } 1920 1920 send(Messages::WebPageProxy::VoidCallback(callbackID)); … … 1930 1930 position = positionOfNextBoundaryOfGranularity(position, static_cast<WebCore::TextGranularity>(granularity), static_cast<SelectionDirection>(direction)); 1931 1931 if (position.isNotNull()) 1932 frame.selection().setSelectedRange(Range::create(*frame.document(), position, position).ptr(), isForward? UPSTREAM : DOWNSTREAM, true );1932 frame.selection().setSelectedRange(Range::create(*frame.document(), position, position).ptr(), isForward? UPSTREAM : DOWNSTREAM, true, UserTriggered); 1933 1933 } 1934 1934 send(Messages::WebPageProxy::VoidCallback(callbackID)); … … 1987 1987 1988 1988 if (range) 1989 frame.selection().setSelectedRange(range.get(), UPSTREAM, true );1989 frame.selection().setSelectedRange(range.get(), UPSTREAM, true, UserTriggered); 1990 1990 m_initialSelection = range; 1991 1991 send(Messages::WebPageProxy::VoidCallback(callbackID)); … … 2022 2022 2023 2023 if (range) 2024 frame.selection().setSelectedRange(range.get(), UPSTREAM, true );2024 frame.selection().setSelectedRange(range.get(), UPSTREAM, true, UserTriggered); 2025 2025 2026 2026 send(Messages::WebPageProxy::UnsignedCallback(selectionStart == m_initialSelection->startPosition(), callbackID)); … … 2065 2065 2066 2066 if (range) 2067 frame.selection().setSelectedRange(range.get(), UPSTREAM, true );2067 frame.selection().setSelectedRange(range.get(), UPSTREAM, true, UserTriggered); 2068 2068 2069 2069 send(Messages::WebPageProxy::UnsignedCallback(m_selectionAnchor == Start, callbackID));
Note:
See TracChangeset
for help on using the changeset viewer.