Bug 130376

Summary: [WK2] Pass ranges over IPC in a cross-platform manner
Product: WebKit Reporter: Alexey Proskuryakov <ap>
Component: WebKit2Assignee: Alexey Proskuryakov <ap>
Status: RESOLVED FIXED    
Severity: Normal CC: andersca, commit-queue, darin, enrica
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
proposed patch andersca: review+

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>.