Bug 218544 - Remove more functions that implicitly use composed tree
Summary: Remove more functions that implicitly use composed tree
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Darin Adler
URL:
Keywords: InRadar
: 217313 (view as bug list)
Depends on: 218424
Blocks:
  Show dependency treegraph
 
Reported: 2020-11-03 16:21 PST by Darin Adler
Modified: 2021-04-07 19:27 PDT (History)
14 users (show)

See Also:


Attachments
Patch (31.81 KB, patch)
2020-11-03 16:41 PST, Darin Adler
no flags Details | Formatted Diff | Diff
Patch (31.87 KB, patch)
2020-11-03 16:45 PST, Darin Adler
rniwa: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Darin Adler 2020-11-03 16:21:39 PST
Remove more functions that implicitly use composed tree
Comment 1 Darin Adler 2020-11-03 16:41:02 PST
Created attachment 413121 [details]
Patch
Comment 2 Darin Adler 2020-11-03 16:45:26 PST
Created attachment 413124 [details]
Patch
Comment 3 Darin Adler 2020-11-03 17:26:58 PST
Comment on attachment 413124 [details]
Patch

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

> Source/WebCore/editing/VisiblePosition.cpp:828
> +    auto midpoint = checkedSum<uint64_t>(characterRange.location, characterRange.length / 2);
> +    if (midpoint.hasOverflowed())
> +        return { };

Since these are actual computed sizes of a document already in memory, I don’t see any way we’d actually need checked arithmetic, so this should probably be changed to normal arithmetic.
Comment 4 Darin Adler 2020-11-04 11:37:32 PST
(In reply to Darin Adler from comment #3)
> Since these are actual computed sizes of a document already in memory, I
> don’t see any way we’d actually need checked arithmetic, so this should
> probably be changed to normal arithmetic.

Or I can write a separate midpoint function that takes a CharacterRange, and clamps end to the maximum value of uint64_t rather than treating it as an error. Should be safe/practical for our uses.
Comment 5 Darin Adler 2020-11-05 09:36:37 PST
Committed r269442: <https://trac.webkit.org/changeset/269442>
Comment 6 Radar WebKit Bug Importer 2020-11-05 09:37:38 PST
<rdar://problem/71081440>
Comment 7 Ryosuke Niwa 2021-04-07 19:27:28 PDT
*** Bug 217313 has been marked as a duplicate of this bug. ***