Skip to content
This repository was archived by the owner on Jun 24, 2022. It is now read-only.

Commit eb3e057

Browse files
[iOS] Clean up visible position comparisons in WebPage::requestDocumentEditingContext()
https://bugs.webkit.org/show_bug.cgi?id=213701 Reviewed by Geoffrey Garen. Use std::min and std::max when the result needs to be copied instead of doing the comparison by hand to make the code a tiny bit more clear. Also, don't copy a VisiblePosition when doing the min/max in-place. Both of these things are unlikely to effect code generation. If they do, the latter makes things a tiny bit more efficient. * WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::requestDocumentEditingContext): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@263634 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 1c3243a commit eb3e057

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

Source/WebKit/ChangeLog

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
2020-06-28 Daniel Bates <[email protected]>
2+
3+
[iOS] Clean up visible position comparisons in WebPage::requestDocumentEditingContext()
4+
https://bugs.webkit.org/show_bug.cgi?id=213701
5+
6+
Reviewed by Geoffrey Garen.
7+
8+
Use std::min and std::max when the result needs to be copied instead of doing the comparison
9+
by hand to make the code a tiny bit more clear. Also, don't copy a VisiblePosition when doing
10+
the min/max in-place. Both of these things are unlikely to effect code generation. If they do,
11+
the latter makes things a tiny bit more efficient.
12+
13+
* WebProcess/WebPage/ios/WebPageIOS.mm:
14+
(WebKit::WebPage::requestDocumentEditingContext):
15+
116
2020-06-28 Youenn Fablet <[email protected]>
217

318
MediaRecorder stopRecorder() returns empty Blob after first use

Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4179,8 +4179,8 @@ static VisiblePosition visiblePositionForPointInRootViewCoordinates(Frame& frame
41794179
auto selectionRange = selection.toNormalizedRange();
41804180
auto rangeOfInterest = makeRange(rangeOfInterestStart, rangeOfInterestEnd);
41814181
if (selectionRange && rangesOverlap(rangeOfInterest.get(), createLiveRange(*selectionRange).ptr())) {
4182-
startOfRangeOfInterestInSelection = rangeOfInterestStart > selectionStart ? rangeOfInterestStart : selectionStart;
4183-
endOfRangeOfInterestInSelection = rangeOfInterestEnd < selectionEnd ? rangeOfInterestEnd : selectionEnd;
4182+
startOfRangeOfInterestInSelection = std::max(rangeOfInterestStart, selectionStart);
4183+
endOfRangeOfInterestInSelection = std::min(rangeOfInterestEnd, selectionEnd);
41844184
} else {
41854185
auto rootNode = makeRefPtr(rangeOfInterest->commonAncestorContainer());
41864186
if (!rootNode) {
@@ -4221,12 +4221,14 @@ static VisiblePosition visiblePositionForPointInRootViewCoordinates(Frame& frame
42214221
contextBeforeStart = rangeOfInterestStart;
42224222
contextAfterEnd = rangeOfInterestEnd;
42234223
if (wantsMarkedTextRects && compositionRange) {
4224-
// In the case where the client has requested marked text rects, additionally make sure that the
4225-
// context range encompasses the entire marked text range.
4224+
// In the case where the client has requested marked text rects make sure that the context
4225+
// range encompasses the entire marked text range so that we don't return a truncated result.
42264226
auto compositionStart = compositionRange->startPosition();
42274227
auto compositionEnd = compositionRange->endPosition();
4228-
contextBeforeStart = contextBeforeStart > compositionStart ? compositionStart : contextBeforeStart;
4229-
contextAfterEnd = contextAfterEnd < compositionEnd ? compositionEnd : contextAfterEnd;
4228+
if (contextBeforeStart > compositionStart)
4229+
contextBeforeStart = compositionStart;
4230+
if (contextAfterEnd < compositionEnd)
4231+
contextAfterEnd = compositionEnd;
42304232
}
42314233
}
42324234

0 commit comments

Comments
 (0)