Bug 226697 - Factor selection clamping into a type
Summary: Factor selection clamping into a type
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-06-06 08:12 PDT by Antti Koivisto
Modified: 2021-06-06 23:20 PDT (History)
20 users (show)

See Also:


Attachments
patch (22.07 KB, patch)
2021-06-06 09:19 PDT, Antti Koivisto
no flags Details | Formatted Diff | Diff
patch (25.69 KB, patch)
2021-06-06 11:27 PDT, Antti Koivisto
no flags Details | Formatted Diff | Diff
patch (26.37 KB, patch)
2021-06-06 11:35 PDT, Antti Koivisto
sam: review+
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
patch (26.36 KB, patch)
2021-06-06 21:34 PDT, Antti Koivisto
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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>