<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[176364] tags/Safari-601.1.10/Source/WebKit2</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/176364">176364</a></dd>
<dt>Author</dt> <dd>bshafiei@apple.com</dd>
<dt>Date</dt> <dd>2014-11-19 16:14:13 -0800 (Wed, 19 Nov 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Merged <a href="http://trac.webkit.org/projects/webkit/changeset/176337">r176337</a>. rdar://problem/18964359</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#tagsSafari601110SourceWebKit2ChangeLog">tags/Safari-601.1.10/Source/WebKit2/ChangeLog</a></li>
<li><a href="#tagsSafari601110SourceWebKit2UIProcessWebPageProxyh">tags/Safari-601.1.10/Source/WebKit2/UIProcess/WebPageProxy.h</a></li>
<li><a href="#tagsSafari601110SourceWebKit2UIProcessiosWKContentViewInteractionh">tags/Safari-601.1.10/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h</a></li>
<li><a href="#tagsSafari601110SourceWebKit2UIProcessiosWKContentViewInteractionmm">tags/Safari-601.1.10/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm</a></li>
<li><a href="#tagsSafari601110SourceWebKit2UIProcessiosWebPageProxyIOSmm">tags/Safari-601.1.10/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm</a></li>
<li><a href="#tagsSafari601110SourceWebKit2WebProcessWebPageWebPagecpp">tags/Safari-601.1.10/Source/WebKit2/WebProcess/WebPage/WebPage.cpp</a></li>
<li><a href="#tagsSafari601110SourceWebKit2WebProcessWebPageWebPageh">tags/Safari-601.1.10/Source/WebKit2/WebProcess/WebPage/WebPage.h</a></li>
<li><a href="#tagsSafari601110SourceWebKit2WebProcessWebPageWebPagemessagesin">tags/Safari-601.1.10/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in</a></li>
<li><a href="#tagsSafari601110SourceWebKit2WebProcessWebPageiosWebPageIOSmm">tags/Safari-601.1.10/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="tagsSafari601110SourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: tags/Safari-601.1.10/Source/WebKit2/ChangeLog (176363 => 176364)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-601.1.10/Source/WebKit2/ChangeLog        2014-11-20 00:10:57 UTC (rev 176363)
+++ tags/Safari-601.1.10/Source/WebKit2/ChangeLog        2014-11-20 00:14:13 UTC (rev 176364)
</span><span class="lines">@@ -1,3 +1,49 @@
</span><ins>+2014-11-19 Babak Shafiei <bshafiei@apple.com>
+
+ Merge r176337.
+
+ 2014-11-19 Enrica Casucci <enrica@apple.com>
+
+ Refactor iOS selection gestures.
+ https://bugs.webkit.org/show_bug.cgi?id=138720
+ rdar://problem/18964359
+
+ Reviewed by Benjamin Poulain.
+
+ This is a first step towards refactoring the selection gestures code.
+ It introduces more general selection movement functions that can be used to build
+ the gestures.
+
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/ios/WKContentViewInteraction.h:
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (toWKTextGranularity):
+ (toWKSelectionDirection):
+ (-[WKContentView selectPositionAtPoint:completionHandler:]):
+ (-[WKContentView selectPositionAtBoundary:inDirection:fromPoint:completionHandler:]):
+ (-[WKContentView selectTextWithGranularity:atPoint:completionHandler:]):
+ (-[WKContentView beginSelectionInDirection:completionHandler:]):
+ (-[WKContentView updateSelectionWithExtentPoint:completionHandler:]):
+ (-[WKContentView _startAssistingNode:userIsInteracting:blurPreviousNode:userObject:]):
+ * UIProcess/ios/WebPageProxyIOS.mm:
+ (WebKit::WebPageProxy::selectTextWithGranularityAtPoint):
+ (WebKit::WebPageProxy::selectPositionAtBoundaryWithDirection):
+ (WebKit::WebPageProxy::selectPositionAtPoint):
+ (WebKit::WebPageProxy::beginSelectionInDirection):
+ (WebKit::WebPageProxy::updateSelectionWithExtentPoint):
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::WebPage):
+ * WebProcess/WebPage/WebPage.h:
+ * WebProcess/WebPage/WebPage.messages.in:
+ * WebProcess/WebPage/ios/WebPageIOS.mm:
+ (WebKit::WebPage::selectWithGesture):
+ (WebKit::WebPage::visiblePositionInFocusedNodeForPoint):
+ (WebKit::WebPage::selectPositionAtPoint):
+ (WebKit::WebPage::selectPositionAtBoundaryWithDirection):
+ (WebKit::WebPage::selectTextWithGranularityAtPoint):
+ (WebKit::WebPage::beginSelectionInDirection):
+ (WebKit::WebPage::updateSelectionWithExtentPoint):
+
</ins><span class="cx"> 2014-11-19 Michael Catanzaro <mcatanzaro@igalia.com>
</span><span class="cx">
</span><span class="cx"> [GTK] Error in documentation of webkit_print_operation_get_page_setup()
</span></span></pre></div>
<a id="tagsSafari601110SourceWebKit2UIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: tags/Safari-601.1.10/Source/WebKit2/UIProcess/WebPageProxy.h (176363 => 176364)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-601.1.10/Source/WebKit2/UIProcess/WebPageProxy.h        2014-11-20 00:10:57 UTC (rev 176363)
+++ tags/Safari-601.1.10/Source/WebKit2/UIProcess/WebPageProxy.h        2014-11-20 00:14:13 UTC (rev 176364)
</span><span class="lines">@@ -69,6 +69,7 @@
</span><span class="cx"> #include <WebCore/TextChecking.h>
</span><span class="cx"> #include <WebCore/TextGranularity.h>
</span><span class="cx"> #include <WebCore/ViewState.h>
</span><ins>+#include <WebCore/VisibleSelection.h>
</ins><span class="cx"> #include <memory>
</span><span class="cx"> #include <wtf/HashMap.h>
</span><span class="cx"> #include <wtf/HashSet.h>
</span><span class="lines">@@ -423,6 +424,11 @@
</span><span class="cx"> void extendSelection(WebCore::TextGranularity);
</span><span class="cx"> void selectWordBackward();
</span><span class="cx"> void moveSelectionByOffset(int32_t offset, std::function<void (CallbackBase::Error)>);
</span><ins>+ void selectTextWithGranularityAtPoint(const WebCore::IntPoint, WebCore::TextGranularity, std::function<void (CallbackBase::Error)>);
+ void selectPositionAtPoint(const WebCore::IntPoint, std::function<void (CallbackBase::Error)>);
+ void selectPositionAtBoundaryWithDirection(const WebCore::IntPoint, 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)>);
</ins><span class="cx"> void requestAutocorrectionData(const String& textForAutocorrection, std::function<void (const Vector<WebCore::FloatRect>&, const String&, double, uint64_t, CallbackBase::Error)>);
</span><span class="cx"> void applyAutocorrection(const String& correction, const String& originalText, std::function<void (const String&, CallbackBase::Error)>);
</span><span class="cx"> bool applyAutocorrection(const String& correction, const String& originalText);
</span></span></pre></div>
<a id="tagsSafari601110SourceWebKit2UIProcessiosWKContentViewInteractionh"></a>
<div class="modfile"><h4>Modified: tags/Safari-601.1.10/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h (176363 => 176364)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-601.1.10/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h        2014-11-20 00:10:57 UTC (rev 176363)
+++ tags/Safari-601.1.10/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h        2014-11-20 00:14:13 UTC (rev 176364)
</span><span class="lines">@@ -71,6 +71,8 @@
</span><span class="cx"> typedef void (^UIWKAutocorrectionCompletionHandler)(UIWKAutocorrectionRects *rectsForInput);
</span><span class="cx"> typedef void (^UIWKAutocorrectionContextHandler)(UIWKAutocorrectionContext *autocorrectionContext);
</span><span class="cx"> typedef void (^UIWKDictationContextHandler)(NSString *selectedText, NSString *beforeText, NSString *afterText);
</span><ins>+typedef void (^UIWKSelectionCompletionHandler)(void);
+typedef void (^UIWKSelectionWithDirectionCompletionHandler)(BOOL selectionEndIsMoving);
</ins><span class="cx">
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> struct WKAutoCorrectionData {
</span></span></pre></div>
<a id="tagsSafari601110SourceWebKit2UIProcessiosWKContentViewInteractionmm"></a>
<div class="modfile"><h4>Modified: tags/Safari-601.1.10/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (176363 => 176364)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-601.1.10/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm        2014-11-20 00:10:57 UTC (rev 176363)
+++ tags/Safari-601.1.10/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm        2014-11-20 00:14:13 UTC (rev 176364)
</span><span class="lines">@@ -1637,6 +1637,40 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static inline WebCore::TextGranularity toWKTextGranularity(UITextGranularity granularity)
+{
+ switch (granularity) {
+ case UITextGranularityCharacter:
+ return CharacterGranularity;
+ case UITextGranularityWord:
+ return WordGranularity;
+ case UITextGranularitySentence:
+ return SentenceGranularity;
+ case UITextGranularityParagraph:
+ return ParagraphGranularity;
+ case UITextGranularityLine:
+ return LineGranularity;
+ case UITextGranularityDocument:
+ return DocumentGranularity;
+ }
+}
+
+static inline WebCore::SelectionDirection toWKSelectionDirection(UITextDirection direction)
+{
+ switch (direction) {
+ case UITextLayoutDirectionDown:
+ case UITextLayoutDirectionRight:
+ return DirectionRight;
+ case UITextLayoutDirectionUp:
+ case UITextLayoutDirectionLeft:
+ return DirectionLeft;
+ default:
+ // UITextDirection is not an enum, but we only want to accept values from UITextLayoutDirection.
+ ASSERT_NOT_REACHED();
+ return DirectionRight;
+ }
+}
+
</ins><span class="cx"> static void selectionChangedWithGesture(WKContentView *view, const WebCore::IntPoint& point, uint32_t gestureType, uint32_t gestureState, uint32_t flags, CallbackBase::Error error)
</span><span class="cx"> {
</span><span class="cx"> if (error != CallbackBase::Error::None) {
</span><span class="lines">@@ -1749,6 +1783,56 @@
</span><span class="cx"> });
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+- (void)selectPositionAtPoint:(CGPoint)point completionHandler:(void (^)(void))completionHandler
+{
+ UIWKSelectionCompletionHandler selectionHandler = [completionHandler copy];
+
+ _page->selectPositionAtPoint(WebCore::IntPoint(point), [selectionHandler](CallbackBase::Error error) {
+ selectionHandler();
+ [selectionHandler release];
+ });
+}
+
+- (void)selectPositionAtBoundary:(UITextGranularity)granularity inDirection:(UITextDirection)direction fromPoint:(CGPoint)point completionHandler:(void (^)(void))completionHandler
+{
+ UIWKSelectionCompletionHandler selectionHandler = [completionHandler copy];
+
+ _page->selectPositionAtBoundaryWithDirection(WebCore::IntPoint(point), toWKTextGranularity(granularity), toWKSelectionDirection(direction), [selectionHandler](CallbackBase::Error error) {
+ selectionHandler();
+ [selectionHandler release];
+ });
+}
+
+- (void)selectTextWithGranularity:(UITextGranularity)granularity atPoint:(CGPoint)point completionHandler:(void (^)(void))completionHandler
+{
+ UIWKSelectionCompletionHandler selectionHandler = [completionHandler copy];
+
+ _page->selectTextWithGranularityAtPoint(WebCore::IntPoint(point), toWKTextGranularity(granularity), [selectionHandler](CallbackBase::Error error) {
+ selectionHandler();
+ [selectionHandler release];
+ });
+}
+
+- (void)beginSelectionInDirection:(UITextDirection)direction completionHandler:(void (^)(BOOL endIsMoving))completionHandler
+{
+ UIWKSelectionWithDirectionCompletionHandler selectionHandler = [completionHandler copy];
+
+ _page->beginSelectionInDirection(toWKSelectionDirection(direction), [selectionHandler](bool endIsMoving, CallbackBase::Error error) {
+ selectionHandler(endIsMoving);
+ [selectionHandler release];
+ });
+}
+
+- (void)updateSelectionWithExtentPoint:(CGPoint)point completionHandler:(void (^)(BOOL endIsMoving))completionHandler
+{
+ UIWKSelectionWithDirectionCompletionHandler selectionHandler = [completionHandler copy];
+
+ _page->updateSelectionWithExtentPoint(WebCore::IntPoint(point), [selectionHandler](bool endIsMoving, CallbackBase::Error error) {
+ selectionHandler(endIsMoving);
+ [selectionHandler release];
+ });
+}
+
</ins><span class="cx"> - (UTF32Char)_characterBeforeCaretSelection
</span><span class="cx"> {
</span><span class="cx"> return _page->editorState().characterBeforeSelection;
</span><span class="lines">@@ -2575,6 +2659,8 @@
</span><span class="cx"> if (![self isFirstResponder])
</span><span class="cx"> [self becomeFirstResponder];
</span><span class="cx">
</span><ins>+ [self reloadInputViews];
+
</ins><span class="cx"> switch (information.elementType) {
</span><span class="cx"> case InputType::Select:
</span><span class="cx"> case InputType::DateTimeLocal:
</span><span class="lines">@@ -2589,8 +2675,7 @@
</span><span class="cx">
</span><span class="cx"> if (information.insideFixedPosition)
</span><span class="cx"> [_webView _updateVisibleContentRects];
</span><del>-
- [self reloadInputViews];
</del><ins>+
</ins><span class="cx"> [self _displayFormNodeInputView];
</span><span class="cx">
</span><span class="cx"> // _inputPeripheral has been initialized in inputView called by reloadInputViews.
</span></span></pre></div>
<a id="tagsSafari601110SourceWebKit2UIProcessiosWebPageProxyIOSmm"></a>
<div class="modfile"><h4>Modified: tags/Safari-601.1.10/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm (176363 => 176364)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-601.1.10/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm        2014-11-20 00:10:57 UTC (rev 176363)
+++ tags/Safari-601.1.10/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm        2014-11-20 00:14:13 UTC (rev 176364)
</span><span class="lines">@@ -430,6 +430,62 @@
</span><span class="cx"> return autocorrectionApplied;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void WebPageProxy::selectTextWithGranularityAtPoint(const WebCore::IntPoint point, WebCore::TextGranularity granularity, std::function<void (CallbackBase::Error)> callbackFunction)
+{
+ if (!isValid()) {
+ callbackFunction(CallbackBase::Error::Unknown);
+ return;
+ }
+
+ uint64_t callbackID = m_callbacks.put(WTF::move(callbackFunction), std::make_unique<ProcessThrottler::BackgroundActivityToken>(m_process->throttler()));
+ m_process->send(Messages::WebPage::SelectTextWithGranularityAtPoint(point, static_cast<uint32_t>(granularity), callbackID), m_pageID);
+}
+
+void WebPageProxy::selectPositionAtBoundaryWithDirection(const WebCore::IntPoint point, WebCore::TextGranularity granularity, WebCore::SelectionDirection direction, std::function<void (CallbackBase::Error)> callbackFunction)
+{
+ if (!isValid()) {
+ callbackFunction(CallbackBase::Error::Unknown);
+ return;
+ }
+
+ uint64_t callbackID = m_callbacks.put(WTF::move(callbackFunction), std::make_unique<ProcessThrottler::BackgroundActivityToken>(m_process->throttler()));
+ m_process->send(Messages::WebPage::SelectPositionAtBoundaryWithDirection(point, static_cast<uint32_t>(granularity), static_cast<uint32_t>(direction), callbackID), m_pageID);
+}
+
+void WebPageProxy::selectPositionAtPoint(const WebCore::IntPoint point, std::function<void (CallbackBase::Error)> callbackFunction)
+{
+ if (!isValid()) {
+ callbackFunction(CallbackBase::Error::Unknown);
+ return;
+ }
+
+ uint64_t callbackID = m_callbacks.put(WTF::move(callbackFunction), std::make_unique<ProcessThrottler::BackgroundActivityToken>(m_process->throttler()));
+ m_process->send(Messages::WebPage::SelectPositionAtPoint(point, callbackID), m_pageID);
+}
+
+void WebPageProxy::beginSelectionInDirection(WebCore::SelectionDirection direction, 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), std::make_unique<ProcessThrottler::BackgroundActivityToken>(m_process->throttler()));
+ m_process->send(Messages::WebPage::BeginSelectionInDirection(direction, callbackID), m_pageID);
+}
+
+void WebPageProxy::updateSelectionWithExtentPoint(const WebCore::IntPoint point, 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), std::make_unique<ProcessThrottler::BackgroundActivityToken>(m_process->throttler()));
+ m_process->send(Messages::WebPage::UpdateSelectionWithExtentPoint(point, callbackID), m_pageID);
+
+}
+
</ins><span class="cx"> void WebPageProxy::requestDictationContext(std::function<void (const String&, const String&, const String&, CallbackBase::Error)> callbackFunction)
</span><span class="cx"> {
</span><span class="cx"> if (!isValid()) {
</span></span></pre></div>
<a id="tagsSafari601110SourceWebKit2WebProcessWebPageWebPagecpp"></a>
<div class="modfile"><h4>Modified: tags/Safari-601.1.10/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (176363 => 176364)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-601.1.10/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2014-11-20 00:10:57 UTC (rev 176363)
+++ tags/Safari-601.1.10/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2014-11-20 00:14:13 UTC (rev 176364)
</span><span class="lines">@@ -300,6 +300,7 @@
</span><span class="cx"> , m_isShowingContextMenu(false)
</span><span class="cx"> #endif
</span><span class="cx"> #if PLATFORM(IOS)
</span><ins>+ , m_selectionAnchor(Start)
</ins><span class="cx"> , m_firstLayerTreeTransactionIDAfterDidCommitLoad(0)
</span><span class="cx"> , m_hasReceivedVisibleContentRectsAfterDidCommitLoad(false)
</span><span class="cx"> , m_scaleWasSetByUIProcess(false)
</span></span></pre></div>
<a id="tagsSafari601110SourceWebKit2WebProcessWebPageWebPageh"></a>
<div class="modfile"><h4>Modified: tags/Safari-601.1.10/Source/WebKit2/WebProcess/WebPage/WebPage.h (176363 => 176364)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-601.1.10/Source/WebKit2/WebProcess/WebPage/WebPage.h        2014-11-20 00:10:57 UTC (rev 176363)
+++ tags/Safari-601.1.10/Source/WebKit2/WebProcess/WebPage/WebPage.h        2014-11-20 00:14:13 UTC (rev 176364)
</span><span class="lines">@@ -490,6 +490,12 @@
</span><span class="cx"> void extendSelection(uint32_t granularity);
</span><span class="cx"> void selectWordBackward();
</span><span class="cx"> void moveSelectionByOffset(int32_t offset, uint64_t callbackID);
</span><ins>+ void selectTextWithGranularityAtPoint(const WebCore::IntPoint&, uint32_t granularity, uint64_t callbackID);
+ void selectPositionAtBoundaryWithDirection(const WebCore::IntPoint&, uint32_t granularity, uint32_t direction, uint64_t callbackID);
+ void selectPositionAtPoint(const WebCore::IntPoint&, uint64_t callbackID);
+ void beginSelectionInDirection(uint32_t direction, uint64_t callbackID);
+ void updateSelectionWithExtentPoint(const WebCore::IntPoint&, uint64_t callbackID);
+
</ins><span class="cx"> void elementDidFocus(WebCore::Node*);
</span><span class="cx"> void elementDidBlur(WebCore::Node*);
</span><span class="cx"> void requestDictationContext(uint64_t callbackID);
</span><span class="lines">@@ -876,6 +882,7 @@
</span><span class="cx"> void completeSyntheticClick(WebCore::Node* nodeRespondingToClick, const WebCore::FloatPoint& location);
</span><span class="cx"> void sendTapHighlightForNodeIfNecessary(uint64_t requestID, WebCore::Node*);
</span><span class="cx"> void resetTextAutosizingBeforeLayoutIfNeeded(const WebCore::FloatSize& oldSize, const WebCore::FloatSize& newSize);
</span><ins>+ WebCore::VisiblePosition visiblePositionInFocusedNodeForPoint(WebCore::Frame&, const WebCore::IntPoint&);
</ins><span class="cx"> #endif
</span><span class="cx"> #if !PLATFORM(COCOA)
</span><span class="cx"> static const char* interpretKeyEvent(const WebCore::KeyboardEvent*);
</span><span class="lines">@@ -1242,6 +1249,12 @@
</span><span class="cx"> RefPtr<WebCore::Range> m_currentWordRange;
</span><span class="cx"> RefPtr<WebCore::Node> m_interactionNode;
</span><span class="cx"> WebCore::IntPoint m_lastInteractionLocation;
</span><ins>+
+ enum SelectionAnchor {
+ Start,
+ End
+ };
+ SelectionAnchor m_selectionAnchor;
</ins><span class="cx">
</span><span class="cx"> RefPtr<WebCore::Node> m_potentialTapNode;
</span><span class="cx"> WebCore::FloatPoint m_potentialTapLocation;
</span></span></pre></div>
<a id="tagsSafari601110SourceWebKit2WebProcessWebPageWebPagemessagesin"></a>
<div class="modfile"><h4>Modified: tags/Safari-601.1.10/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (176363 => 176364)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-601.1.10/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in        2014-11-20 00:10:57 UTC (rev 176363)
+++ tags/Safari-601.1.10/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in        2014-11-20 00:14:13 UTC (rev 176364)
</span><span class="lines">@@ -64,6 +64,11 @@
</span><span class="cx"> ExtendSelection(uint32_t granularity)
</span><span class="cx"> SelectWordBackward()
</span><span class="cx"> MoveSelectionByOffset(int32_t offset, uint64_t callbackID)
</span><ins>+ SelectTextWithGranularityAtPoint(WebCore::IntPoint point, uint32_t granularity, uint64_t callbackID)
+ SelectPositionAtBoundaryWithDirection(WebCore::IntPoint point, uint32_t granularity, uint32_t direction, uint64_t callbackID)
+ SelectPositionAtPoint(WebCore::IntPoint point, uint64_t callbackID)
+ BeginSelectionInDirection(uint32_t direction, uint64_t callbackID)
+ UpdateSelectionWithExtentPoint(WebCore::IntPoint point, uint64_t callbackID)
</ins><span class="cx"> RequestDictationContext(uint64_t callbackID)
</span><span class="cx"> ReplaceDictatedText(String oldText, String newText)
</span><span class="cx"> ReplaceSelectedText(String oldText, String newText)
</span></span></pre></div>
<a id="tagsSafari601110SourceWebKit2WebProcessWebPageiosWebPageIOSmm"></a>
<div class="modfile"><h4>Modified: tags/Safari-601.1.10/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm (176363 => 176364)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-601.1.10/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm        2014-11-20 00:10:57 UTC (rev 176363)
+++ tags/Safari-601.1.10/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm        2014-11-20 00:14:13 UTC (rev 176364)
</span><span class="lines">@@ -816,10 +816,8 @@
</span><span class="cx"> void WebPage::selectWithGesture(const IntPoint& point, uint32_t granularity, uint32_t gestureType, uint32_t gestureState, uint64_t callbackID)
</span><span class="cx"> {
</span><span class="cx"> Frame& frame = m_page->focusController().focusedOrMainFrame();
</span><del>- IntPoint adjustedPoint(frame.view()->rootViewToContents(point));
</del><ins>+ VisiblePosition position = visiblePositionInFocusedNodeForPoint(frame, point);
</ins><span class="cx">
</span><del>- IntPoint constrainedPoint = m_assistedNode ? constrainPoint(adjustedPoint, &frame, m_assistedNode.get()) : adjustedPoint;
- VisiblePosition position = frame.visiblePositionForPoint(constrainedPoint);
</del><span class="cx"> if (position.isNull()) {
</span><span class="cx"> send(Messages::WebPageProxy::GestureCallback(point, gestureType, gestureState, 0, callbackID));
</span><span class="cx"> return;
</span><span class="lines">@@ -853,12 +851,11 @@
</span><span class="cx"> // Don't cross line boundaries.
</span><span class="cx"> result = position;
</span><span class="cx"> } else if (withinTextUnitOfGranularity(position, WordGranularity, DirectionForward)) {
</span><del>- // The position lies within a word.
- RefPtr<Range> wordRange = enclosingTextUnitOfGranularity(position, WordGranularity, DirectionForward);
-
- result = wordRange->startPosition();
- if (distanceBetweenPositions(position, result) > 1)
- result = wordRange->endPosition();
</del><ins>+ // The position lies within a word, we want to select the word.
+ if (frame.selection().isCaret())
+ range = enclosingTextUnitOfGranularity(position, WordGranularity, DirectionForward);
+ else if (frame.selection().isRange() && (position < frame.selection().selection().start() || position > frame.selection().selection().end()))
+ result = position;
</ins><span class="cx"> } else if (atBoundaryOfGranularity(position, WordGranularity, DirectionBackward)) {
</span><span class="cx"> // The position is at the end of a word.
</span><span class="cx"> result = position;
</span><span class="lines">@@ -1553,6 +1550,112 @@
</span><span class="cx"> send(Messages::WebPageProxy::VoidCallback(callbackID));
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+VisiblePosition WebPage::visiblePositionInFocusedNodeForPoint(Frame& frame, const IntPoint& point)
+{
+ IntPoint adjustedPoint(frame.view()->rootViewToContents(point));
+ IntPoint constrainedPoint = m_assistedNode ? constrainPoint(adjustedPoint, &frame, m_assistedNode.get()) : adjustedPoint;
+ return frame.visiblePositionForPoint(constrainedPoint);
+}
+
+void WebPage::selectPositionAtPoint(const WebCore::IntPoint& point, uint64_t callbackID)
+{
+ Frame& frame = m_page->focusController().focusedOrMainFrame();
+ VisiblePosition position = visiblePositionInFocusedNodeForPoint(frame, point);
+
+ if (position.isNotNull())
+ frame.selection().setSelectedRange(Range::create(*frame.document(), position, position).get(), position.affinity(), true);
+ send(Messages::WebPageProxy::VoidCallback(callbackID));
+}
+
+void WebPage::selectPositionAtBoundaryWithDirection(const WebCore::IntPoint& point, uint32_t granularity, uint32_t direction, uint64_t callbackID)
+{
+ Frame& frame = m_page->focusController().focusedOrMainFrame();
+ VisiblePosition position = visiblePositionInFocusedNodeForPoint(frame, point);
+
+ if (position.isNotNull()) {
+ position = positionOfNextBoundaryOfGranularity(position, static_cast<WebCore::TextGranularity>(granularity), static_cast<SelectionDirection>(direction));
+ if (position.isNotNull())
+ frame.selection().setSelectedRange(Range::create(*frame.document(), position, position).get(), UPSTREAM, true);
+ }
+ send(Messages::WebPageProxy::VoidCallback(callbackID));
+}
+
+void WebPage::selectTextWithGranularityAtPoint(const WebCore::IntPoint& point, uint32_t granularity, uint64_t callbackID)
+{
+ Frame& frame = m_page->focusController().focusedOrMainFrame();
+ VisiblePosition position = visiblePositionInFocusedNodeForPoint(frame, point);
+
+ RefPtr<Range> range;
+ switch (static_cast<WebCore::TextGranularity>(granularity)) {
+ case WordGranularity:
+ range = wordRangeFromPosition(position);
+ break;
+ case SentenceGranularity:
+ range = enclosingTextUnitOfGranularity(position, SentenceGranularity, DirectionForward);
+ break;
+ case ParagraphGranularity:
+ range = enclosingTextUnitOfGranularity(position, ParagraphGranularity, DirectionForward);
+ break;
+ case DocumentGranularity:
+ frame.selection().selectAll();
+ break;
+ default:
+ break;
+ }
+ if (range)
+ frame.selection().setSelectedRange(range.get(), UPSTREAM, true);
+ send(Messages::WebPageProxy::VoidCallback(callbackID));
+}
+
+void WebPage::beginSelectionInDirection(uint32_t direction, uint64_t callbackID)
+{
+ m_selectionAnchor = (static_cast<SelectionDirection>(direction) == DirectionLeft) ? Start : End;
+ send(Messages::WebPageProxy::UnsignedCallback(m_selectionAnchor == Start, callbackID));
+}
+
+void WebPage::updateSelectionWithExtentPoint(const WebCore::IntPoint& point, uint64_t callbackID)
+{
+ Frame& frame = m_page->focusController().focusedOrMainFrame();
+ VisiblePosition position = visiblePositionInFocusedNodeForPoint(frame, point);
+
+ if (position.isNull()) {
+ send(Messages::WebPageProxy::UnsignedCallback(false, callbackID));
+ return;
+ }
+
+ RefPtr<Range> range;
+ VisiblePosition selectionStart;
+ VisiblePosition selectionEnd;
+
+ if (m_selectionAnchor == Start) {
+ selectionStart = frame.selection().selection().visibleStart();
+ selectionEnd = position;
+
+ if (position <= selectionStart) {
+ selectionStart = selectionStart.previous();
+ selectionEnd = frame.selection().selection().visibleEnd();
+ m_selectionAnchor = End;
+ }
+ } else {
+ selectionStart = position;
+ selectionEnd = frame.selection().selection().visibleEnd();
+
+ if (position >= selectionEnd) {
+ selectionStart = frame.selection().selection().visibleStart();
+ selectionEnd = selectionEnd.next();
+ m_selectionAnchor = Start;
+ }
+ }
+
+ 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(m_selectionAnchor == Start, callbackID));
+}
+
</ins><span class="cx"> void WebPage::convertSelectionRectsToRootView(FrameView* view, Vector<SelectionRect>& selectionRects)
</span><span class="cx"> {
</span><span class="cx"> for (size_t i = 0; i < selectionRects.size(); ++i) {
</span></span></pre>
</div>
</div>
</body>
</html>