Bug 130376 - [WK2] Pass ranges over IPC in a cross-platform manner
Summary: [WK2] Pass ranges over IPC in a cross-platform manner
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Alexey Proskuryakov
Depends on:
Reported: 2014-03-17 18:00 PDT by Alexey Proskuryakov
Modified: 2014-03-18 11:14 PDT (History)
4 users (show)

See Also:

proposed patch (50.79 KB, patch)
2014-03-17 18:03 PDT, Alexey Proskuryakov
andersca: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexey Proskuryakov 2014-03-17 18:00:34 PDT
Ranges are passed as a pair of uint64_t numbers over IPC, and we pass NSNotFound as is. This is unfortunate in many ways:

1. Code that is otherwise cross-platform becomes Objective-C only because of NSNotFound.

2. We sometimes get NSNotFound confused with WTF::notFound, which has a different numeric value. All cross-platform code like TextIterator::getLocationAndLengthFromRange uses notFound, but we never convert it to NSNotFound when returning over API boundary.

3. Argument lists get longer than they need to be.
Comment 1 Alexey Proskuryakov 2014-03-17 18:03:45 PDT
Created attachment 226991 [details]
proposed patch
Comment 2 WebKit Commit Bot 2014-03-17 18:05:38 PDT
Attachment 226991 [details] did not pass style-queue:

ERROR: Source/WebKit2/Shared/EditingRange.h:64:  An else statement can be removed when the prior "if" concludes with a return, break, continue or goto statement.  [readability/control_flow] [4]
Total errors found: 1 in 14 files

If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Alexey Proskuryakov 2014-03-18 09:55:06 PDT
Comment on attachment 226991 [details]
proposed patch

View in context: https://bugs.webkit.org/attachment.cgi?id=226991&action=review

> Source/WebKit2/Shared/EditingRange.h:67
> +        if (location != NSNotFound)
> +            return NSMakeRange(location, length);
> +        else
> +            return NSMakeRange(NSNotFound, 0);

if (location == notFound)
            return NSMakeRange(NSNotFound, 0);
        return NSMakeRange(location, length);
Comment 4 Alexey Proskuryakov 2014-03-18 11:14:25 PDT
Committed <http://trac.webkit.org/r165823>.