Bug 226697

Summary: Factor selection clamping into a type
Product: WebKit Reporter: Antti Koivisto <koivisto>
Component: Layout and RenderingAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: annulen, bfulgham, changseok, dino, esprehn+autocc, ews-watchlist, fmalita, glenn, gyuyoung.kim, kondapallykalyan, mmaxfield, pdr, ryuan.choi, sabouhallawa, sam, schenney, sergio, simon.fraser, webkit-bug-importer, zalan
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
patch
none
patch
none
patch
sam: review+, ews-feeder: commit-queue-
patch none

Description Antti Koivisto 2021-06-06 08:12:38 PDT
It will be helpful for moving selection code out of legacy inline boxes.
Comment 1 Antti Koivisto 2021-06-06 09:19:50 PDT
Created attachment 430684 [details]
patch
Comment 2 Antti Koivisto 2021-06-06 11:27:52 PDT
Created attachment 430689 [details]
patch
Comment 3 Antti Koivisto 2021-06-06 11:35:50 PDT
Created attachment 430690 [details]
patch
Comment 4 Sam Weinig 2021-06-06 12:32:41 PDT
Comment on attachment 430690 [details]
patch

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

> Source/WebCore/rendering/TextBoxSelectableRange.h:39
> +        auto clampedOffset = std::max(std::min(offset, start + length), start) - start;

I think you can write this as:

auto clampedOffset = std::clamp(offset, start, start + length) - start;

(though  `- start` is kind of confusing, I do realize this is existing code you ar moving.).
Comment 5 Antti Koivisto 2021-06-06 13:26:41 PDT
> (though  `- start` is kind of confusing, I do realize this is existing code
> you ar moving.).

Yeah, in addition to clamping it also moves the offset to be relative to the current run start. I didn't know how to express that so didn't change the naming.
Comment 6 Antti Koivisto 2021-06-06 21:34:42 PDT
Created attachment 430710 [details]
patch
Comment 7 EWS 2021-06-06 23:19:11 PDT
Committed r278545 (238543@main): <https://commits.webkit.org/238543@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 430710 [details].
Comment 8 Radar WebKit Bug Importer 2021-06-06 23:20:17 PDT
<rdar://problem/78935528>