[Webkit-unassigned] [Bug 226697] Factor selection clamping into a type

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sun Jun 6 12:32:41 PDT 2021


https://bugs.webkit.org/show_bug.cgi?id=226697

Sam Weinig <sam at webkit.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 Attachment #430690|review?                     |review+
              Flags|                            |

--- Comment #4 from Sam Weinig <sam at webkit.org> ---
Comment on attachment 430690
  --> https://bugs.webkit.org/attachment.cgi?id=430690
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.).

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20210606/1aae4ca6/attachment.htm>


More information about the webkit-unassigned mailing list