Diff
Modified: trunk/Source/WebKit/mac/ChangeLog (196451 => 196452)
--- trunk/Source/WebKit/mac/ChangeLog 2016-02-11 23:17:19 UTC (rev 196451)
+++ trunk/Source/WebKit/mac/ChangeLog 2016-02-11 23:39:15 UTC (rev 196452)
@@ -1,3 +1,36 @@
+2016-02-11 Beth Dakin <[email protected]>
+
+ Soft spaces are often tracked in the wrong spot
+ https://bugs.webkit.org/show_bug.cgi?id=154127
+ -and corresponding-
+ rdar://problem/24493140
+
+ Reviewed by Sam Weinig.
+
+ Soft spaces are in the wrong space now for two reasons. First of all, the
+ NSRange we get from the accepted candidate is relative to the paragraph
+ start, so without this patch, soft spaces are only ever right for the first
+ paragraph. Secondly, if focus changes for any reason other than text
+ insertion, soft spaces are also wrong because they need to be re-set.
+
+ New version of _convertToDOMRange takes a NSRangeIsRelativeTo so that it can
+ handle ranges relative to both the document and the paragraph.
+ * WebView/WebFrame.mm:
+ (-[WebFrame _convertToDOMRange:rangeIsRelativeTo:]):
+ (-[WebFrame _convertNSRangeToDOMRange:]):
+
+ New enum NSRangeIsRelativeTo.
+ * WebView/WebFrameInternal.h:
+
+ Re-set the softSpaceRange on selection changes so long as the WebCore::Editor
+ is not currently handling an accepted candidate.
+ * WebView/WebHTMLView.mm:
+ (-[WebHTMLView _selectionChanged]):
+
+ If needToRemoveSoftSpace is true, then the replacementRange is
+ relative to the paragraph.
+ (-[WebHTMLView insertText:]):
+
2016-02-10 Mark Lam <[email protected]>
WebFrame _stringByEvaluatingJavaScriptFromString:forceUserGesture: should assert that it is being called from the "main" thread.
Modified: trunk/Source/WebKit/mac/WebView/WebFrame.mm (196451 => 196452)
--- trunk/Source/WebKit/mac/WebView/WebFrame.mm 2016-02-11 23:17:19 UTC (rev 196451)
+++ trunk/Source/WebKit/mac/WebView/WebFrame.mm 2016-02-11 23:39:15 UTC (rev 196452)
@@ -793,21 +793,43 @@
- (PassRefPtr<Range>)_convertToDOMRange:(NSRange)nsrange
{
+ return [self _convertToDOMRange:nsrange rangeIsRelativeTo:NSRangeIsRelativeTo::Document];
+}
+
+- (PassRefPtr<Range>)_convertToDOMRange:(NSRange)nsrange rangeIsRelativeTo:(NSRangeIsRelativeTo)rangeIsRelativeTo
+{
if (nsrange.location > INT_MAX)
return 0;
if (nsrange.length > INT_MAX || nsrange.location + nsrange.length > INT_MAX)
nsrange.length = INT_MAX - nsrange.location;
- // our critical assumption is that we are only called by input methods that
- // concentrate on a given area containing the selection
- // We have to do this because of text fields and textareas. The DOM for those is not
- // directly in the document DOM, so serialization is problematic. Our solution is
- // to use the root editable element of the selection start as the positional base.
- // That fits with AppKit's idea of an input context.
- Element* element = _private->coreFrame->selection().rootEditableElementOrDocumentElement();
- if (!element)
- return nil;
- return TextIterator::rangeFromLocationAndLength(element, nsrange.location, nsrange.length);
+ if (rangeIsRelativeTo == NSRangeIsRelativeTo::Document) {
+ // Our critical assumption is that this code path is only called by input methods that
+ // concentrate on a given area containing the selection
+ // We have to do this because of text fields and textareas. The DOM for those is not
+ // directly in the document DOM, so serialization is problematic. Our solution is
+ // to use the root editable element of the selection start as the positional base.
+ // That fits with AppKit's idea of an input context.
+ Element* element = _private->coreFrame->selection().rootEditableElementOrDocumentElement();
+ if (!element)
+ return nil;
+ return TextIterator::rangeFromLocationAndLength(element, nsrange.location, nsrange.length);
+ }
+
+ ASSERT(rangeIsRelativeTo == NSRangeIsRelativeTo::Paragraph);
+
+ const VisibleSelection& selection = _private->coreFrame->selection().selection();
+ RefPtr<Range> selectedRange = selection.toNormalizedRange();
+ if (!selectedRange)
+ return 0;
+
+ RefPtr<Range> paragraphRange = makeRange(startOfParagraph(selection.visibleStart()), selection.visibleEnd());
+ if (!paragraphRange)
+ return 0;
+
+ ContainerNode& rootNode = paragraphRange.get()->startContainer().treeScope().rootNode();
+ int paragraphStartIndex = TextIterator::rangeLength(Range::create(rootNode.document(), &rootNode, 0, ¶graphRange->startContainer(), paragraphRange->startOffset()).ptr());
+ return TextIterator::rangeFromLocationAndLength(&rootNode, paragraphStartIndex + static_cast<int>(nsrange.location), nsrange.length);
}
- (DOMRange *)_convertNSRangeToDOMRange:(NSRange)nsrange
Modified: trunk/Source/WebKit/mac/WebView/WebFrameInternal.h (196451 => 196452)
--- trunk/Source/WebKit/mac/WebView/WebFrameInternal.h 2016-02-11 23:17:19 UTC (rev 196451)
+++ trunk/Source/WebKit/mac/WebView/WebFrameInternal.h 2016-02-11 23:39:15 UTC (rev 196452)
@@ -63,6 +63,11 @@
typedef WebCore::HistoryItem WebCoreHistoryItem;
+enum class NSRangeIsRelativeTo : uint8_t {
+ Document,
+ Paragraph,
+};
+
WebCore::Frame* core(WebFrame *);
WebFrame *kit(WebCore::Frame *);
@@ -160,6 +165,7 @@
#endif
- (NSRange)_convertToNSRange:(WebCore::Range*)range;
- (PassRefPtr<WebCore::Range>)_convertToDOMRange:(NSRange)nsrange;
+- (PassRefPtr<WebCore::Range>)_convertToDOMRange:(NSRange)nsrange rangeIsRelativeTo:(NSRangeIsRelativeTo)rangeIsRelativeTo;
- (DOMDocumentFragment *)_documentFragmentWithMarkupString:(NSString *)markupString baseURLString:(NSString *)baseURLString;
- (DOMDocumentFragment *)_documentFragmentWithNodesAsParagraphs:(NSArray *)nodes;
Modified: trunk/Source/WebKit/mac/WebView/WebHTMLView.mm (196451 => 196452)
--- trunk/Source/WebKit/mac/WebView/WebHTMLView.mm 2016-02-11 23:17:19 UTC (rev 196451)
+++ trunk/Source/WebKit/mac/WebView/WebHTMLView.mm 2016-02-11 23:39:15 UTC (rev 196452)
@@ -6097,6 +6097,10 @@
[self _updateSelectionForInputManager];
#if !PLATFORM(IOS)
[self _updateFontPanel];
+ if (Frame* coreFrame = core([self _frame])) {
+ if (!coreFrame->editor().isHandlingAcceptedCandidate())
+ _private->softSpaceRange = NSMakeRange(NSNotFound, 0);
+ }
#endif
}
@@ -7098,16 +7102,23 @@
if (!coreFrame || !coreFrame->editor().canEdit())
return;
+ BOOL needToRemoveSoftSpace = NO;
#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
- if (_private->softSpaceRange.location != NSNotFound && (replacementRange.location == NSMaxRange(_private->softSpaceRange) || replacementRange.location == NSNotFound) && replacementRange.length == 0 && [[NSSpellChecker sharedSpellChecker] deletesAutospaceBeforeString:text language:nil])
+ if (_private->softSpaceRange.location != NSNotFound && (replacementRange.location == NSMaxRange(_private->softSpaceRange) || replacementRange.location == NSNotFound) && !replacementRange.length && [[NSSpellChecker sharedSpellChecker] deletesAutospaceBeforeString:text language:nil]) {
replacementRange = _private->softSpaceRange;
+ needToRemoveSoftSpace = YES;
+ }
#endif
#if !PLATFORM(IOS)
_private->softSpaceRange = NSMakeRange(NSNotFound, 0);
#endif
- if (replacementRange.location != NSNotFound)
- [[self _frame] _selectNSRange:replacementRange];
+ if (replacementRange.location != NSNotFound) {
+ NSRangeIsRelativeTo rangeIsRelativeTo = needToRemoveSoftSpace ? NSRangeIsRelativeTo::Paragraph : NSRangeIsRelativeTo::Document;
+ RefPtr<Range> domRange = [[self _frame] _convertToDOMRange:replacementRange rangeIsRelativeTo:rangeIsRelativeTo];
+ if (domRange)
+ coreFrame->selection().setSelection(VisibleSelection(*domRange, SEL_DEFAULT_AFFINITY));
+ }
bool eventHandled = false;
String eventText = text;
Modified: trunk/Source/WebKit2/ChangeLog (196451 => 196452)
--- trunk/Source/WebKit2/ChangeLog 2016-02-11 23:17:19 UTC (rev 196451)
+++ trunk/Source/WebKit2/ChangeLog 2016-02-11 23:39:15 UTC (rev 196452)
@@ -1,3 +1,81 @@
+2016-02-11 Beth Dakin <[email protected]>
+
+ Soft spaces are often tracked in the wrong spot
+ https://bugs.webkit.org/show_bug.cgi?id=154127
+ -and corresponding-
+ rdar://problem/24493140
+
+ Reviewed by Sam Weinig.
+
+ Soft spaces are in the wrong space now for two reasons. First of all, the
+ NSRange we get from the accepted candidate is relative to the paragraph
+ start, so without this patch, soft spaces are only ever right for the first
+ paragraph. Secondly, if focus changes for any reason other than text
+ insertion, soft spaces are also wrong because they need to be re-set.
+
+ New enum can be used to indicate what an EditingRange is relative to.
+ * Shared/EditingRange.h:
+ (WebKit::EditingRange::EditingRange):
+
+ didHandleAcceptedCandidate is a new message that gets sent from the
+ WebProcess. This lets us track a bool m_isHandlingAcceptedCandidate.
+ * UIProcess/Cocoa/WebViewImpl.h:
+ (WebKit::WebViewImpl::didHandleAcceptedCandidate):
+
+ Re-set the m_softSpaceRange on selection changes so long as
+ m_isHandlingAcceptedCandidate is false.
+ * UIProcess/Cocoa/WebViewImpl.mm:
+ (WebKit::WebViewImpl::selectionDidChange):
+
+ Set m_isHandlingAcceptedCandidate to true.
+ (WebKit::WebViewImpl::handleAcceptedCandidate):
+
+ Set m_isHandlingAcceptedCandidate to false.
+ (WebKit::WebViewImpl::didHandleAcceptedCandidate):
+
+ insertTextAsync takes a new parameter indicating what the replacementRange is
+ relative to. If needToRemoveSoftSpace is true, then the replacementRange is
+ relative to the paragraph.
+ (WebKit::WebViewImpl::insertText):
+
+ Pipe didHandleAcceptedCandidate through to WebViewImpl.
+ * UIProcess/PageClient.h:
+
+ insertTextAsync takes an EditingRangeIsRelativeTo.
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::insertTextAsync):
+
+ Pipe didHandleAcceptedCandidate through to WebViewImpl.
+ (WebKit::WebPageProxy::didHandleAcceptedCandidate):
+ * UIProcess/WebPageProxy.h:
+
+ New message lets the WebProcess tell the UIProcess when the candidate has
+ been accepted.
+ * UIProcess/WebPageProxy.messages.in:
+
+ Pipe didHandleAcceptedCandidate through to WebViewImpl.
+ * UIProcess/mac/PageClientImpl.h:
+ * UIProcess/mac/PageClientImpl.mm:
+ (WebKit::PageClientImpl::didHandleAcceptedCandidate):
+
+ insertTextAsync takes an EditingRangeIsRelativeTo. Pass that through to
+ rangeFromEditingRange to get the correct range.
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::insertTextAsync):
+
+ Use the EditingRangeIsRelativeTo to find the right WebCore::Range.
+ (WebKit::WebPage::rangeFromEditingRange):
+
+ Take EditingRangeIsRelativeTo in a few places.
+ * WebProcess/WebPage/WebPage.h:
+
+ InsertTextAsync takes a EditingRangeIsRelativeTo.
+ * WebProcess/WebPage/WebPage.messages.in:
+
+ Send didHandleAccpetedCandidate to the UIProcess
+ * WebProcess/WebPage/mac/WebPageMac.mm:
+ (WebKit::WebPage::handleAcceptedCandidate):
+
2016-02-11 Alex Christensen <[email protected]>
Use BlobResourceHandle when loading blob urls, even when using NetworkSession
Modified: trunk/Source/WebKit2/Shared/EditingRange.h (196451 => 196452)
--- trunk/Source/WebKit2/Shared/EditingRange.h 2016-02-11 23:17:19 UTC (rev 196451)
+++ trunk/Source/WebKit2/Shared/EditingRange.h 2016-02-11 23:39:15 UTC (rev 196452)
@@ -31,6 +31,11 @@
namespace WebKit {
+enum class EditingRangeIsRelativeTo : uint8_t {
+ Document,
+ Paragraph,
+};
+
struct EditingRange {
EditingRange()
: location(notFound)
Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h (196451 => 196452)
--- trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h 2016-02-11 23:17:19 UTC (rev 196451)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h 2016-02-11 23:39:15 UTC (rev 196452)
@@ -323,6 +323,7 @@
void cancelImmediateActionAnimation();
void completeImmediateActionAnimation();
void didChangeContentSize(CGSize);
+ void didHandleAcceptedCandidate();
void setIgnoresNonWheelEvents(bool);
bool ignoresNonWheelEvents() const { return m_ignoresNonWheelEvents; }
@@ -638,6 +639,7 @@
String m_lastStringForCandidateRequest;
#endif
NSRange m_softSpaceRange { NSNotFound, 0 };
+ bool m_isHandlingAcceptedCandidate { false };
};
} // namespace WebKit
Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm (196451 => 196452)
--- trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm 2016-02-11 23:17:19 UTC (rev 196451)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm 2016-02-11 23:39:15 UTC (rev 196452)
@@ -1747,6 +1747,8 @@
void WebViewImpl::selectionDidChange()
{
updateFontPanelIfNeeded();
+ if (!m_isHandlingAcceptedCandidate)
+ m_softSpaceRange = NSMakeRange(NSNotFound, 0);
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
updateWebViewImplAdditions();
if (!m_page->editorState().isMissingPostLayoutData)
@@ -2210,6 +2212,7 @@
if (m_lastStringForCandidateRequest != postLayoutData.stringForCandidateRequest)
return;
+ m_isHandlingAcceptedCandidate = true;
NSRange range = [acceptedCandidate range];
if (acceptedCandidate.replacementString && [acceptedCandidate.replacementString length] > 0) {
NSRange replacedRange = NSMakeRange(range.location, [acceptedCandidate.replacementString length]);
@@ -2363,6 +2366,11 @@
[m_view _web_didChangeContentSize:NSSizeFromCGSize(newSize)];
}
+void WebViewImpl::didHandleAcceptedCandidate()
+{
+ m_isHandlingAcceptedCandidate = false;
+}
+
void WebViewImpl::setIgnoresNonWheelEvents(bool ignoresNonWheelEvents)
{
if (m_ignoresNonWheelEvents == ignoresNonWheelEvents)
@@ -3548,7 +3556,7 @@
if (!dictationAlternatives.isEmpty())
m_page->insertDictatedTextAsync(eventText, replacementRange, dictationAlternatives, registerUndoGroup);
else
- m_page->insertTextAsync(eventText, replacementRange, registerUndoGroup);
+ m_page->insertTextAsync(eventText, replacementRange, registerUndoGroup, needToRemoveSoftSpace ? EditingRangeIsRelativeTo::Paragraph : EditingRangeIsRelativeTo::Document);
}
void WebViewImpl::selectedRangeWithCompletionHandler(void(^completionHandlerPtr)(NSRange selectedRange))
Modified: trunk/Source/WebKit2/UIProcess/PageClient.h (196451 => 196452)
--- trunk/Source/WebKit2/UIProcess/PageClient.h 2016-02-11 23:17:19 UTC (rev 196451)
+++ trunk/Source/WebKit2/UIProcess/PageClient.h 2016-02-11 23:39:15 UTC (rev 196452)
@@ -345,6 +345,8 @@
virtual void didPerformImmediateActionHitTest(const WebHitTestResultData&, bool contentPreventsDefault, API::Object*) = 0;
virtual void* immediateActionAnimationControllerForHitTestResult(RefPtr<API::HitTestResult>, uint64_t, RefPtr<API::Object>) = 0;
+
+ virtual void didHandleAcceptedCandidate() = 0;
#endif
#if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS)
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (196451 => 196452)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2016-02-11 23:17:19 UTC (rev 196451)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2016-02-11 23:39:15 UTC (rev 196452)
@@ -5811,12 +5811,12 @@
#if PLATFORM(COCOA)
-void WebPageProxy::insertTextAsync(const String& text, const EditingRange& replacementRange, bool registerUndoGroup)
+void WebPageProxy::insertTextAsync(const String& text, const EditingRange& replacementRange, bool registerUndoGroup, EditingRangeIsRelativeTo editingRangeIsRelativeTo)
{
if (!isValid())
return;
- process().send(Messages::WebPage::InsertTextAsync(text, replacementRange, registerUndoGroup), m_pageID);
+ process().send(Messages::WebPage::InsertTextAsync(text, replacementRange, registerUndoGroup, static_cast<uint32_t>(editingRangeIsRelativeTo)), m_pageID);
}
void WebPageProxy::getMarkedRangeAsync(std::function<void (EditingRange, CallbackBase::Error)> callbackFunction)
@@ -6064,6 +6064,11 @@
{
m_process->send(Messages::WebPage::HandleAcceptedCandidate(acceptedCandidate), m_pageID);
}
+
+void WebPageProxy::didHandleAcceptedCandidate()
+{
+ m_pageClient.didHandleAcceptedCandidate();
+}
#endif
void WebPageProxy::imageOrMediaDocumentSizeChanged(const WebCore::IntSize& newSize)
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (196451 => 196452)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2016-02-11 23:17:19 UTC (rev 196451)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2016-02-11 23:39:15 UTC (rev 196452)
@@ -561,7 +561,7 @@
void setAcceleratedCompositingRootLayer(LayerOrView*);
LayerOrView* acceleratedCompositingRootLayer() const;
- void insertTextAsync(const String& text, const EditingRange& replacementRange, bool registerUndoGroup = false);
+ void insertTextAsync(const String& text, const EditingRange& replacementRange, bool registerUndoGroup = false, EditingRangeIsRelativeTo = EditingRangeIsRelativeTo::Document);
void getMarkedRangeAsync(std::function<void (EditingRange, CallbackBase::Error)>);
void getSelectedRangeAsync(std::function<void (EditingRange, CallbackBase::Error)>);
void characterIndexForPointAsync(const WebCore::IntPoint&, std::function<void (uint64_t, CallbackBase::Error)>);
@@ -1042,6 +1042,7 @@
void installViewStateChangeCompletionHandler(void(^completionHandler)());
void handleAcceptedCandidate(WebCore::TextCheckingResult);
+ void didHandleAcceptedCandidate();
#endif
#if PLATFORM(EFL) && HAVE(ACCESSIBILITY) && defined(HAVE_ECORE_X)
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in (196451 => 196452)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in 2016-02-11 23:17:19 UTC (rev 196451)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in 2016-02-11 23:39:15 UTC (rev 196452)
@@ -451,4 +451,8 @@
#endif
DidRestoreScrollPosition()
+
+#if PLATFORM(MAC)
+ DidHandleAcceptedCandidate()
+#endif
}
Modified: trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h (196451 => 196452)
--- trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h 2016-02-11 23:17:19 UTC (rev 196451)
+++ trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h 2016-02-11 23:39:15 UTC (rev 196452)
@@ -209,6 +209,8 @@
virtual void didPerformImmediateActionHitTest(const WebHitTestResultData&, bool contentPreventsDefault, API::Object*) override;
virtual void* immediateActionAnimationControllerForHitTestResult(RefPtr<API::HitTestResult>, uint64_t, RefPtr<API::Object>) override;
+ virtual void didHandleAcceptedCandidate() override;
+
virtual void showPlatformContextMenu(NSMenu *, WebCore::IntPoint) override;
virtual void didChangeBackgroundColor() override;
Modified: trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm (196451 => 196452)
--- trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm 2016-02-11 23:17:19 UTC (rev 196451)
+++ trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm 2016-02-11 23:39:15 UTC (rev 196452)
@@ -780,6 +780,11 @@
return m_impl->immediateActionAnimationControllerForHitTestResult(hitTestResult.get(), type, userData.get());
}
+void PageClientImpl::didHandleAcceptedCandidate()
+{
+ m_impl->didHandleAcceptedCandidate();
+}
+
void PageClientImpl::showPlatformContextMenu(NSMenu *menu, IntPoint location)
{
[menu popUpMenuPositioningItem:nil atLocation:location inView:m_view];
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (196451 => 196452)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2016-02-11 23:17:19 UTC (rev 196451)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2016-02-11 23:39:15 UTC (rev 196452)
@@ -35,7 +35,6 @@
#include "DragControllerAction.h"
#include "DrawingArea.h"
#include "DrawingAreaMessages.h"
-#include "EditingRange.h"
#include "EditorState.h"
#include "EventDispatcher.h"
#include "InjectedBundle.h"
@@ -4327,12 +4326,12 @@
#if PLATFORM(COCOA)
-void WebPage::insertTextAsync(const String& text, const EditingRange& replacementEditingRange, bool registerUndoGroup)
+void WebPage::insertTextAsync(const String& text, const EditingRange& replacementEditingRange, bool registerUndoGroup, uint32_t editingRangeIsRelativeTo)
{
Frame& frame = m_page->focusController().focusedOrMainFrame();
if (replacementEditingRange.location != notFound) {
- RefPtr<Range> replacementRange = rangeFromEditingRange(frame, replacementEditingRange);
+ RefPtr<Range> replacementRange = rangeFromEditingRange(frame, replacementEditingRange, static_cast<EditingRangeIsRelativeTo>(editingRangeIsRelativeTo));
if (replacementRange)
frame.selection().setSelection(VisibleSelection(*replacementRange, SEL_DEFAULT_AFFINITY));
}
@@ -5026,7 +5025,7 @@
send(Messages::WebPageProxy::StringCallback(result, callbackID));
}
-PassRefPtr<WebCore::Range> WebPage::rangeFromEditingRange(WebCore::Frame& frame, const EditingRange& range)
+PassRefPtr<WebCore::Range> WebPage::rangeFromEditingRange(WebCore::Frame& frame, const EditingRange& range, EditingRangeIsRelativeTo editingRangeIsRelativeTo)
{
ASSERT(range.location != notFound);
@@ -5039,13 +5038,30 @@
else
length = INT_MAX - range.location;
- // Our critical assumption is that we are only called by input methods that
- // concentrate on a given area containing the selection.
- // We have to do this because of text fields and textareas. The DOM for those is not
- // directly in the document DOM, so serialization is problematic. Our solution is
- // to use the root editable element of the selection start as the positional base.
- // That fits with AppKit's idea of an input context.
- return TextIterator::rangeFromLocationAndLength(frame.selection().rootEditableElementOrDocumentElement(), static_cast<int>(range.location), length);
+ if (editingRangeIsRelativeTo == EditingRangeIsRelativeTo::Document) {
+ // Our critical assumption is that this code path is called by input methods that
+ // concentrate on a given area containing the selection.
+ // We have to do this because of text fields and textareas. The DOM for those is not
+ // directly in the document DOM, so serialization is problematic. Our solution is
+ // to use the root editable element of the selection start as the positional base.
+ // That fits with AppKit's idea of an input context.
+ return TextIterator::rangeFromLocationAndLength(frame.selection().rootEditableElementOrDocumentElement(), static_cast<int>(range.location), length);
+ }
+
+ ASSERT(editingRangeIsRelativeTo == EditingRangeIsRelativeTo::Paragraph);
+
+ const VisibleSelection& selection = frame.selection().selection();
+ RefPtr<Range> selectedRange = selection.toNormalizedRange();
+ if (!selectedRange)
+ return 0;
+
+ RefPtr<Range> paragraphRange = makeRange(startOfParagraph(selection.visibleStart()), selection.visibleEnd());
+ if (!paragraphRange)
+ return 0;
+
+ ContainerNode& rootNode = paragraphRange.get()->startContainer().treeScope().rootNode();
+ int paragraphStartIndex = TextIterator::rangeLength(Range::create(rootNode.document(), &rootNode, 0, ¶graphRange->startContainer(), paragraphRange->startOffset()).ptr());
+ return TextIterator::rangeFromLocationAndLength(&rootNode, paragraphStartIndex + static_cast<int>(range.location), length);
}
void WebPage::didChangeScrollOffsetForFrame(Frame* frame)
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (196451 => 196452)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h 2016-02-11 23:17:19 UTC (rev 196451)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h 2016-02-11 23:39:15 UTC (rev 196452)
@@ -31,6 +31,7 @@
#include "APIInjectedBundlePageUIClient.h"
#include "APIObject.h"
#include "Download.h"
+#include "EditingRange.h"
#include "FindController.h"
#include "GeolocationPermissionRequestManager.h"
#include "ImageOptions.h"
@@ -646,7 +647,7 @@
void sendComplexTextInputToPlugin(uint64_t pluginComplexTextInputIdentifier, const String& textInput);
- void insertTextAsync(const String& text, const EditingRange& replacementRange, bool registerUndoGroup = false);
+ void insertTextAsync(const String& text, const EditingRange& replacementRange, bool registerUndoGroup = false, uint32_t editingRangeIsRelativeTo = (uint32_t)EditingRangeIsRelativeTo::Document);
void getMarkedRangeAsync(uint64_t callbackID);
void getSelectedRangeAsync(uint64_t callbackID);
void characterIndexForPointAsync(const WebCore::IntPoint&, uint64_t callbackID);
@@ -1135,7 +1136,7 @@
static PluginView* focusedPluginViewForFrame(WebCore::Frame&);
static PluginView* pluginViewForFrame(WebCore::Frame*);
- static PassRefPtr<WebCore::Range> rangeFromEditingRange(WebCore::Frame&, const EditingRange&);
+ static PassRefPtr<WebCore::Range> rangeFromEditingRange(WebCore::Frame&, const EditingRange&, EditingRangeIsRelativeTo = EditingRangeIsRelativeTo::Document);
void reportUsedFeatures();
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (196451 => 196452)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in 2016-02-11 23:17:19 UTC (rev 196451)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in 2016-02-11 23:39:15 UTC (rev 196452)
@@ -357,7 +357,7 @@
ShouldDelayWindowOrderingEvent(WebKit::WebMouseEvent event) -> (bool result)
AcceptsFirstMouse(int eventNumber, WebKit::WebMouseEvent event) -> (bool result)
- InsertTextAsync(String text, struct WebKit::EditingRange replacementRange, bool registerUndoGroup)
+ InsertTextAsync(String text, struct WebKit::EditingRange replacementRange, bool registerUndoGroup, uint32_t editingRangeIsRelativeTo)
GetMarkedRangeAsync(uint64_t callbackID)
GetSelectedRangeAsync(uint64_t callbackID)
CharacterIndexForPointAsync(WebCore::IntPoint point, uint64_t callbackID);
Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm (196451 => 196452)
--- trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm 2016-02-11 23:17:19 UTC (rev 196451)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm 2016-02-11 23:39:15 UTC (rev 196452)
@@ -155,6 +155,7 @@
return;
frame->editor().handleAcceptedCandidate(acceptedCandidate);
+ send(Messages::WebPageProxy::DidHandleAcceptedCandidate());
}
NSObject *WebPage::accessibilityObjectForMainFramePlugin()