Diff
Modified: branches/safari-601.1.46-branch/Source/WebKit2/ChangeLog (188042 => 188043)
--- branches/safari-601.1.46-branch/Source/WebKit2/ChangeLog 2015-08-06 16:52:15 UTC (rev 188042)
+++ branches/safari-601.1.46-branch/Source/WebKit2/ChangeLog 2015-08-06 17:30:44 UTC (rev 188043)
@@ -1,3 +1,35 @@
+2015-08-06 Babak Shafiei <bshaf...@apple.com>
+
+ Merge r186849.
+
+ 2015-07-14 Enrica Casucci <enr...@apple.com>
+
+ [iOS] Add support for updateSelectionWithExtentPoint:withBoundary.
+ https://bugs.webkit.org/show_bug.cgi?id=146951
+ rdar://problem/20864286
+
+ Reviewed by Tim Horton.
+
+ Add implementation for new method used by text selection
+ engine on iOS. The new function modifies the selection near the given point
+ and snaps it at the boundary of the specified granularity.
+
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView updateSelectionWithExtentPoint:completionHandler:]):
+ (-[WKContentView updateSelectionWithExtentPoint:withBoundary:completionHandler:]):
+ (-[WKContentView _characterBeforeCaretSelection]):
+ * UIProcess/ios/WebPageProxyIOS.mm:
+ (WebKit::WebPageProxy::updateSelectionWithExtentPoint):
+ (WebKit::WebPageProxy::updateSelectionWithExtentPointAndBoundary):
+ (WebKit::WebPageProxy::requestDictationContext):
+ * WebProcess/WebPage/WebPage.h:
+ * WebProcess/WebPage/WebPage.messages.in:
+ * WebProcess/WebPage/ios/WebPageIOS.mm:
+ (WebKit::WebPage::rangeForGranularityAtPoint):
+ (WebKit::WebPage::selectTextWithGranularityAtPoint):
+ (WebKit::WebPage::updateSelectionWithExtentPointAndBoundary):
+
2015-08-05 Matthew Hanson <matthew_han...@apple.com>
Merge r187962. rdar://problem/21827815
Modified: branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/WebPageProxy.h (188042 => 188043)
--- branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/WebPageProxy.h 2015-08-06 16:52:15 UTC (rev 188042)
+++ branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/WebPageProxy.h 2015-08-06 17:30:44 UTC (rev 188043)
@@ -491,6 +491,7 @@
void moveSelectionAtBoundaryWithDirection(WebCore::TextGranularity, WebCore::SelectionDirection, std::function<void(CallbackBase::Error)>);
void beginSelectionInDirection(WebCore::SelectionDirection, std::function<void (uint64_t, CallbackBase::Error)>);
void updateSelectionWithExtentPoint(const WebCore::IntPoint, std::function<void (uint64_t, CallbackBase::Error)>);
+ void updateSelectionWithExtentPointAndBoundary(const WebCore::IntPoint, WebCore::TextGranularity, std::function<void(uint64_t, CallbackBase::Error)>);
void requestAutocorrectionData(const String& textForAutocorrection, std::function<void (const Vector<WebCore::FloatRect>&, const String&, double, uint64_t, CallbackBase::Error)>);
void applyAutocorrection(const String& correction, const String& originalText, std::function<void (const String&, CallbackBase::Error)>);
bool applyAutocorrection(const String& correction, const String& originalText);
Modified: branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (188042 => 188043)
--- branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm 2015-08-06 16:52:15 UTC (rev 188042)
+++ branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm 2015-08-06 17:30:44 UTC (rev 188043)
@@ -2051,6 +2051,16 @@
});
}
+- (void)updateSelectionWithExtentPoint:(CGPoint)point withBoundary:(UITextGranularity)granularity completionHandler:(void (^)(BOOL selectionEndIsMoving))completionHandler
+{
+ UIWKSelectionWithDirectionCompletionHandler selectionHandler = [completionHandler copy];
+
+ _page->updateSelectionWithExtentPointAndBoundary(WebCore::IntPoint(point), toWKTextGranularity(granularity), [selectionHandler](bool endIsMoving, WebKit::CallbackBase::Error error) {
+ selectionHandler(endIsMoving);
+ [selectionHandler release];
+ });
+}
+
- (UTF32Char)_characterBeforeCaretSelection
{
return _page->editorState().postLayoutData().characterBeforeSelection;
Modified: branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm (188042 => 188043)
--- branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm 2015-08-06 16:52:15 UTC (rev 188042)
+++ branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm 2015-08-06 17:30:44 UTC (rev 188043)
@@ -497,6 +497,18 @@
}
+void WebPageProxy::updateSelectionWithExtentPointAndBoundary(const WebCore::IntPoint point, WebCore::TextGranularity granularity, std::function<void(uint64_t, CallbackBase::Error)> callbackFunction)
+{
+ if (!isValid()) {
+ callbackFunction(0, CallbackBase::Error::Unknown);
+ return;
+ }
+
+ uint64_t callbackID = m_callbacks.put(WTF::move(callbackFunction), m_process->throttler().backgroundActivityToken());
+ m_process->send(Messages::WebPage::UpdateSelectionWithExtentPointAndBoundary(point, granularity, callbackID), m_pageID);
+
+}
+
void WebPageProxy::requestDictationContext(std::function<void (const String&, const String&, const String&, CallbackBase::Error)> callbackFunction)
{
if (!isValid()) {
Modified: branches/safari-601.1.46-branch/Source/WebKit2/WebProcess/WebPage/WebPage.h (188042 => 188043)
--- branches/safari-601.1.46-branch/Source/WebKit2/WebProcess/WebPage/WebPage.h 2015-08-06 16:52:15 UTC (rev 188042)
+++ branches/safari-601.1.46-branch/Source/WebKit2/WebProcess/WebPage/WebPage.h 2015-08-06 17:30:44 UTC (rev 188043)
@@ -511,6 +511,7 @@
void selectPositionAtPoint(const WebCore::IntPoint&, uint64_t callbackID);
void beginSelectionInDirection(uint32_t direction, uint64_t callbackID);
void updateSelectionWithExtentPoint(const WebCore::IntPoint&, uint64_t callbackID);
+ void updateSelectionWithExtentPointAndBoundary(const WebCore::IntPoint&, uint32_t granularity, uint64_t callbackID);
void elementDidFocus(WebCore::Node*);
void elementDidBlur(WebCore::Node*);
@@ -934,6 +935,7 @@
void sendTapHighlightForNodeIfNecessary(uint64_t requestID, WebCore::Node*);
void resetTextAutosizingBeforeLayoutIfNeeded(const WebCore::FloatSize& oldSize, const WebCore::FloatSize& newSize);
WebCore::VisiblePosition visiblePositionInFocusedNodeForPoint(const WebCore::Frame&, const WebCore::IntPoint&);
+ PassRefPtr<WebCore::Range> rangeForGranularityAtPoint(const WebCore::Frame&, const WebCore::IntPoint&, uint32_t granularity);
void volatilityTimerFired();
#endif
#if !PLATFORM(COCOA)
@@ -1352,6 +1354,7 @@
WebCore::FloatSize m_screenSize;
WebCore::FloatSize m_availableScreenSize;
RefPtr<WebCore::Range> m_currentBlockSelection;
+ RefPtr<WebCore::Range> m_initialSelection;
WebCore::IntSize m_blockSelectionDesiredSize;
WebCore::FloatSize m_maximumUnobscuredSize;
int32_t m_deviceOrientation;
Modified: branches/safari-601.1.46-branch/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (188042 => 188043)
--- branches/safari-601.1.46-branch/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in 2015-08-06 16:52:15 UTC (rev 188042)
+++ branches/safari-601.1.46-branch/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in 2015-08-06 17:30:44 UTC (rev 188043)
@@ -70,6 +70,7 @@
SelectPositionAtPoint(WebCore::IntPoint point, uint64_t callbackID)
BeginSelectionInDirection(uint32_t direction, uint64_t callbackID)
UpdateSelectionWithExtentPoint(WebCore::IntPoint point, uint64_t callbackID)
+ UpdateSelectionWithExtentPointAndBoundary(WebCore::IntPoint point, uint32_t granularity, uint64_t callbackID)
RequestDictationContext(uint64_t callbackID)
ReplaceDictatedText(String oldText, String newText)
ReplaceSelectedText(String oldText, String newText)
Modified: branches/safari-601.1.46-branch/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm (188042 => 188043)
--- branches/safari-601.1.46-branch/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm 2015-08-06 16:52:15 UTC (rev 188042)
+++ branches/safari-601.1.46-branch/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm 2015-08-06 17:30:44 UTC (rev 188043)
@@ -1736,9 +1736,8 @@
send(Messages::WebPageProxy::VoidCallback(callbackID));
}
-void WebPage::selectTextWithGranularityAtPoint(const WebCore::IntPoint& point, uint32_t granularity, uint64_t callbackID)
+PassRefPtr<Range> WebPage::rangeForGranularityAtPoint(const Frame& frame, const WebCore::IntPoint& point, uint32_t granularity)
{
- const Frame& frame = m_page->focusController().focusedOrMainFrame();
VisiblePosition position = visiblePositionInFocusedNodeForPoint(frame, point);
RefPtr<Range> range;
@@ -1758,8 +1757,17 @@
default:
break;
}
+ return range;
+}
+
+void WebPage::selectTextWithGranularityAtPoint(const WebCore::IntPoint& point, uint32_t granularity, uint64_t callbackID)
+{
+ const Frame& frame = m_page->focusController().focusedOrMainFrame();
+ RefPtr<Range> range = rangeForGranularityAtPoint(frame, point, granularity);
+
if (range)
frame.selection().setSelectedRange(range.get(), UPSTREAM, true);
+ m_initialSelection = range;
send(Messages::WebPageProxy::VoidCallback(callbackID));
}
@@ -1768,7 +1776,36 @@
m_selectionAnchor = (static_cast<SelectionDirection>(direction) == DirectionLeft) ? Start : End;
send(Messages::WebPageProxy::UnsignedCallback(m_selectionAnchor == Start, callbackID));
}
+
+void WebPage::updateSelectionWithExtentPointAndBoundary(const WebCore::IntPoint& point, uint32_t granularity, uint64_t callbackID)
+{
+ const Frame& frame = m_page->focusController().focusedOrMainFrame();
+ VisiblePosition position = visiblePositionInFocusedNodeForPoint(frame, point);
+ RefPtr<Range> newRange = rangeForGranularityAtPoint(frame, point, granularity);
+ if (position.isNull() || !m_initialSelection || !newRange) {
+ send(Messages::WebPageProxy::UnsignedCallback(false, callbackID));
+ return;
+ }
+
+ RefPtr<Range> range;
+ VisiblePosition selectionStart = m_initialSelection->startPosition();
+ VisiblePosition selectionEnd = m_initialSelection->endPosition();
+
+ if (position > m_initialSelection->endPosition())
+ selectionEnd = newRange->endPosition();
+ else if (position < m_initialSelection->startPosition())
+ selectionStart = newRange->startPosition();
+
+ if (selectionStart.isNotNull() && selectionEnd.isNotNull())
+ range = Range::create(*frame.document(), selectionStart, selectionEnd);
+
+ if (range)
+ frame.selection().setSelectedRange(range.get(), UPSTREAM, true);
+
+ send(Messages::WebPageProxy::UnsignedCallback(selectionStart == m_initialSelection->startPosition(), callbackID));
+}
+
void WebPage::updateSelectionWithExtentPoint(const WebCore::IntPoint& point, uint64_t callbackID)
{
const Frame& frame = m_page->focusController().focusedOrMainFrame();