UNCONFIRMED Bug 99438
[WK2][WTR] Text input controller needs selectedRange implementation
https://bugs.webkit.org/show_bug.cgi?id=99438
Summary [WK2][WTR] Text input controller needs selectedRange implementation
Mariusz Grzegorczyk
Reported 2012-10-16 02:03:03 PDT
Because of missing selectedRange() implementation following test doesn't pass: editing/selection/mixed-editability-10.html
Attachments
patch (10.40 KB, patch)
2012-10-25 01:41 PDT, Mariusz Grzegorczyk
no flags
use getSelectedRange from WebPage's Mac port (12.79 KB, patch)
2012-10-26 06:36 PDT, Mariusz Grzegorczyk
buildbot: commit-queue-
Applied Kenneth's comments (13.51 KB, patch)
2012-10-29 02:59 PDT, Mariusz Grzegorczyk
no flags
Rebase and extend function to UIProcess (17.26 KB, patch)
2012-11-28 09:49 PST, Mariusz Grzegorczyk
no flags
Rebased, added comment about moving mac implementation to common part (17.32 KB, patch)
2012-12-12 01:09 PST, Mariusz Grzegorczyk
sam: review-
Rebased, make asynchronous (18.12 KB, patch)
2013-03-06 10:07 PST, Mariusz Grzegorczyk
no flags
Mariusz Grzegorczyk
Comment 1 2012-10-22 09:58:05 PDT
Tests which uses textInputController.selectedRange: editing/selection/5825350-1.html editing/selection/5825350-2.html editing/selection/extend-by-sentence-002.html editing/selection/mixed-editability-10.html editing/selection/move-left-right.html platform/mac/editing/input/text-input-controller.html
Mariusz Grzegorczyk
Comment 2 2012-10-25 01:41:24 PDT
Chris Dumez
Comment 3 2012-10-25 03:13:00 PDT
Comment on attachment 170588 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=170588&action=review > Source/WebKit2/WebProcess/WebPage/WebPage.cpp:3334 > + WebCore::ExceptionCode ec; Shouldn't we handle error case?
Jussi Kukkonen (jku)
Comment 4 2012-10-25 06:24:22 PDT
Comment on attachment 170588 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=170588&action=review > Source/WebKit2/WebProcess/WebPage/WebPage.cpp:3314 > +bool WebPage::selectedRangeForTesting(int* start, int* length) Is there a reason for not just moving WebPage::getSelectedRange() from WebPageMac.mm to here?
Mariusz Grzegorczyk
Comment 5 2012-10-26 03:24:09 PDT
(In reply to comment #4) > (From update of attachment 170588 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=170588&action=review > > > Source/WebKit2/WebProcess/WebPage/WebPage.cpp:3314 > > +bool WebPage::selectedRangeForTesting(int* start, int* length) > > Is there a reason for not just moving WebPage::getSelectedRange() from WebPageMac.mm to here? I'm afraid of NSRange usage in Mac port. There failure is marked as location = NSNotFound
Jussi Kukkonen (jku)
Comment 6 2012-10-26 03:44:25 PDT
(In reply to comment #5) > > > Source/WebKit2/WebProcess/WebPage/WebPage.cpp:3314 > > > +bool WebPage::selectedRangeForTesting(int* start, int* length) > > > > Is there a reason for not just moving WebPage::getSelectedRange() from WebPageMac.mm to here? > > I'm afraid of NSRange usage in Mac port. There failure is marked as location = NSNotFound There's only one user for this function: WKView selectedRange so assuming you modified getSelectedRange to return a boolean like your new function and not set NSNotFound, wouldn't something like this work? diff --git a/Source/WebKit2/UIProcess/API/mac/WKView.mm b/Source/WebKit2/UIProcess/API/mac/WKView.mm index 0f221c6..d0fda59 100644 --- a/Source/WebKit2/UIProcess/API/mac/WKView.mm +++ b/Source/WebKit2/UIProcess/API/mac/WKView.mm @@ -1427 +1427,2 @@ static const short kIOHIDEventTypeScroll = 6; - _data->_page->getSelectedRange(selectionStart, selectionLength); + if (!_data->_page->getSelectedRange(selectionStart, selectionLength)) + selectionStart = NSNotFound;
Mariusz Grzegorczyk
Comment 7 2012-10-26 05:02:37 PDT
(In reply to comment #6) > (In reply to comment #5) > > > > Source/WebKit2/WebProcess/WebPage/WebPage.cpp:3314 > > > > +bool WebPage::selectedRangeForTesting(int* start, int* length) > > > > > > Is there a reason for not just moving WebPage::getSelectedRange() from WebPageMac.mm to here? > > > > I'm afraid of NSRange usage in Mac port. There failure is marked as location = NSNotFound > > There's only one user for this function: > WKView selectedRange > so assuming you modified getSelectedRange to return a boolean like your new function and not set NSNotFound, wouldn't something like this work? > > diff --git a/Source/WebKit2/UIProcess/API/mac/WKView.mm b/Source/WebKit2/UIProcess/API/mac/WKView.mm > index 0f221c6..d0fda59 100644 > --- a/Source/WebKit2/UIProcess/API/mac/WKView.mm > +++ b/Source/WebKit2/UIProcess/API/mac/WKView.mm > @@ -1427 +1427,2 @@ static const short kIOHIDEventTypeScroll = 6; > - _data->_page->getSelectedRange(selectionStart, selectionLength); > + if (!_data->_page->getSelectedRange(selectionStart, selectionLength)) > + selectionStart = NSNotFound; Ok, I'll try this. Will see what Mac developers say.
Mariusz Grzegorczyk
Comment 8 2012-10-26 06:36:12 PDT
Created attachment 170910 [details] use getSelectedRange from WebPage's Mac port
Build Bot
Comment 9 2012-10-26 06:51:52 PDT
Comment on attachment 170910 [details] use getSelectedRange from WebPage's Mac port Attachment 170910 [details] did not pass mac-ews (mac): Output: http://queues.webkit.org/results/14551020
Jussi Kukkonen (jku)
Comment 10 2012-10-26 06:52:48 PDT
Comment on attachment 170910 [details] use getSelectedRange from WebPage's Mac port View in context: https://bugs.webkit.org/attachment.cgi?id=170910&action=review > Source/WebKit2/WebProcess/WebPage/WebPage.cpp:3346 > + if (range && TextIterator::getLocationAndLengthFromRange(frame->selection()->rootEditableElementOrDocumentElement(), range.get(), locationSize, lengthSize)) { > + location = static_cast<uint64_t>(locationSize); > + length = static_cast<uint64_t>(lengthSize); > + } Need to return false if the test here is not true, to reproduce the original mac version behaviour.
Kenneth Rohde Christiansen
Comment 11 2012-10-26 07:38:18 PDT
Comment on attachment 170910 [details] use getSelectedRange from WebPage's Mac port View in context: https://bugs.webkit.org/attachment.cgi?id=170910&action=review > Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h:70 > +WK_EXPORT bool WKBundlePageSelectedRange(WKBundlePageRef pageRef, uint64_t& location, uint64_t& length); I'm not sure other C-WK-API methods return a bool for getters. Maybe making location = -1 makes more sense? > Source/WebKit2/WebProcess/WebPage/WebPage.cpp:3334 > +{ location = WTF::notFound ?
Mariusz Grzegorczyk
Comment 12 2012-10-29 02:59:42 PDT
Created attachment 171187 [details] Applied Kenneth's comments
Jussi Kukkonen (jku)
Comment 13 2012-10-30 01:16:50 PDT
(In reply to comment #12) > Created an attachment (id=171187) [details] > Applied Kenneth's comments Looks good to me at least.
Mariusz Grzegorczyk
Comment 14 2012-11-12 06:15:16 PST
(In reply to comment #13) > (In reply to comment #12) > > Created an attachment (id=171187) [details] [details] > > Applied Kenneth's comments > > Looks good to me at least. I'm wondering if all these functions should be exported to API. If mac is testing such api in the future maybe all ports will do same. See https://bugs.webkit.org/show_bug.cgi?id=100219 comments.
Mariusz Grzegorczyk
Comment 15 2012-11-28 09:49:11 PST
Created attachment 176500 [details] Rebase and extend function to UIProcess
Mariusz Grzegorczyk
Comment 16 2012-11-29 01:56:41 PST
Adding chromium and qt reviewers since this change affects all ports.
Gyuyoung Kim
Comment 17 2012-11-29 02:13:42 PST
Comment on attachment 176500 [details] Rebase and extend function to UIProcess View in context: https://bugs.webkit.org/attachment.cgi?id=176500&action=review > Source/WebKit2/ChangeLog:8 > + Implementation of getting selected range from webpage. IMO, it would be good if you say this patch moves the implementation of mac port to common place for all ports.
Tony Chang
Comment 18 2012-11-29 10:39:24 PST
(In reply to comment #16) > Adding chromium and qt reviewers since this change affects all ports. This doesn't affect Chromium since Chromium doesn't use WebKit2 or WTR.
Mariusz Grzegorczyk
Comment 19 2012-12-12 01:09:59 PST
Created attachment 178994 [details] Rebased, added comment about moving mac implementation to common part
Ryosuke Niwa
Comment 20 2012-12-12 01:50:55 PST
Comment on attachment 178994 [details] Rebased, added comment about moving mac implementation to common part View in context: https://bugs.webkit.org/attachment.cgi?id=178994&action=review > Source/WebKit2/UIProcess/API/mac/WKView.mm:1431 > NSRange result = NSMakeRange(selectionStart, selectionLength); > - if (result.location == NSNotFound) > - LOG(TextInput, "selectedRange -> (NSNotFound, %u)", result.length); > + if (result.location == WTF::notFound) > + LOG(TextInput, "selectedRange -> (notFound, %u)", result.length); Don't we need to pass in NSNotFound to NSMakeRange?
Mariusz Grzegorczyk
Comment 21 2012-12-12 03:05:41 PST
(In reply to comment #20) > (From update of attachment 178994 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=178994&action=review > > > Source/WebKit2/UIProcess/API/mac/WKView.mm:1431 > > NSRange result = NSMakeRange(selectionStart, selectionLength); > > - if (result.location == NSNotFound) > > - LOG(TextInput, "selectedRange -> (NSNotFound, %u)", result.length); > > + if (result.location == WTF::notFound) > > + LOG(TextInput, "selectedRange -> (notFound, %u)", result.length); > > Don't we need to pass in NSNotFound to NSMakeRange? In my opinion: no. NSMakeRange just fills structure with passed arguments. Because of common implementation getSelectedRange returns WTF::notFound instead of NSNotFound. I suppose you are asking about following change: ...getSelectedRange(selectionStart, selectionLength); +if (selectionStart == WTF::notFound) + selectionStart = NSNotFound; if (result.location == NSNotFound) LOG(TextInput, "selectedRange -> (NSNotFound, %u)", result.length);
Gyuyoung Kim
Comment 22 2012-12-18 00:04:42 PST
Comment on attachment 178994 [details] Rebased, added comment about moving mac implementation to common part Looks good to me in terms of sharing port implementation. But, I think mac port reviewer or WK2 reviewer needs to have a final review.
Gyuyoung Kim
Comment 23 2012-12-27 23:00:15 PST
(In reply to comment #22) > (From update of attachment 178994 [details]) > Looks good to me in terms of sharing port implementation. But, I think mac port reviewer or WK2 reviewer needs to have a final review. If there is no comment or objection by next week, I'd like to land this patch. And, happy new year !!
Gyuyoung Kim
Comment 24 2013-01-06 18:21:15 PST
Comment on attachment 178994 [details] Rebased, added comment about moving mac implementation to common part LGTM. But, someone might wanna have a final look.
Sam Weinig
Comment 25 2013-01-06 18:32:36 PST
Comment on attachment 178994 [details] Rebased, added comment about moving mac implementation to common part This codifies a sync message to the WebProcess, something we need to eliminate and which is a huge no-no, in API. r-. Please find another way to do
Mariusz Grzegorczyk
Comment 26 2013-01-07 02:13:39 PST
(In reply to comment #25) > (From update of attachment 178994 [details]) > This codifies a sync message to the WebProcess, something we need to eliminate and which is a huge no-no, in API. r-. Please find another way to do Code is only shared between all ports and was moved from existing mac's implementation.
Gyuyoung Kim
Comment 27 2013-01-07 04:56:01 PST
(In reply to comment #25) > > (From update of attachment 178994 [details] [details]) > > This codifies a sync message to the WebProcess, something we need to eliminate and which is a huge no-no, in API. r-. Please find another way to do Sam, thank you for your review. But, we don't understand what is your point well. I also thought this patch is just share mac implementation with other ports. Could you let us know what something we missed in more detail ?
Sam Weinig
Comment 28 2013-01-07 10:54:43 PST
The Mac port does a bad thing here, it does a synchronous call to the WebProcess. This is something that should be fixed, not extended to all the other ports. By moving it into shared code and adding API, it makes it much harder to fix.
Mariusz Grzegorczyk
Comment 29 2013-01-08 02:07:13 PST
(In reply to comment #28) > The Mac port does a bad thing here, it does a synchronous call to the WebProcess. This is something that should be fixed, not extended to all the other ports. By moving it into shared code and adding API, it makes it much harder to fix. Are you proposing to make it using callbacks? What about changing API in mac? Who is using selectedRange there?
Mariusz Grzegorczyk
Comment 30 2013-03-06 10:07:52 PST
Created attachment 191781 [details] Rebased, make asynchronous
Kenneth Rohde Christiansen
Comment 31 2013-03-07 03:05:33 PST
Comment on attachment 191781 [details] Rebased, make asynchronous View in context: https://bugs.webkit.org/attachment.cgi?id=191781&action=review > Source/WebKit2/UIProcess/WebPageProxy.cpp:1014 > +void WebPageProxy::getSelectedRange(PassRefPtr<DataCallback> prpCallback) what is a prp callback? pass ref ptr... no, please don't name like this!
Kenneth Rohde Christiansen
Comment 32 2013-03-07 03:06:05 PST
Benjamin, can you look at this?
Mariusz Grzegorczyk
Comment 33 2013-03-07 05:30:44 PST
Comment on attachment 191781 [details] Rebased, make asynchronous View in context: https://bugs.webkit.org/attachment.cgi?id=191781&action=review >> Source/WebKit2/UIProcess/WebPageProxy.cpp:1014 >> +void WebPageProxy::getSelectedRange(PassRefPtr<DataCallback> prpCallback) > > what is a prp callback? pass ref ptr... no, please don't name like this! All callbacks are named in this file in this manner.
Andreas Kling
Comment 34 2014-02-05 11:19:23 PST
Comment on attachment 191781 [details] Rebased, make asynchronous Clearing review flag on patches from before 2014. If this patch is still relevant, please reset the r? flag.
Note You need to log in before you can comment on or make changes to this bug.