Title: [258920] trunk/Source/WebKit
Revision
258920
Author
[email protected]
Date
2020-03-24 11:00:14 -0700 (Tue, 24 Mar 2020)

Log Message

Simplify characterRectsForRange() in WebPage::requestDocumentEditingContext()
https://bugs.webkit.org/show_bug.cgi?id=209462

Reviewed by Wenson Hsieh.

No need to allow by-reference capture by default. Update code to take a const
Range& and unsigned instead of non-const and uint64_t params. The former is
const correct for this code, which doesn't modify anything. The latter is
actually the max width data type callers pass. Simplify the inside of the loop
by using StringView::isEmpty(). Lastly add a constant for the stride length
to make the 1s less mysterious despite the name of the function alluding to
this stride.

* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::requestDocumentEditingContext):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (258919 => 258920)


--- trunk/Source/WebKit/ChangeLog	2020-03-24 17:57:41 UTC (rev 258919)
+++ trunk/Source/WebKit/ChangeLog	2020-03-24 18:00:14 UTC (rev 258920)
@@ -1,5 +1,23 @@
 2020-03-24  Daniel Bates  <[email protected]>
 
+        Simplify characterRectsForRange() in WebPage::requestDocumentEditingContext()
+        https://bugs.webkit.org/show_bug.cgi?id=209462
+
+        Reviewed by Wenson Hsieh.
+
+        No need to allow by-reference capture by default. Update code to take a const
+        Range& and unsigned instead of non-const and uint64_t params. The former is
+        const correct for this code, which doesn't modify anything. The latter is
+        actually the max width data type callers pass. Simplify the inside of the loop
+        by using StringView::isEmpty(). Lastly add a constant for the stride length
+        to make the 1s less mysterious despite the name of the function alluding to
+        this stride.
+
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::requestDocumentEditingContext):
+
+2020-03-24  Daniel Bates  <[email protected]>
+
         [iOS][WK2] Set text trait isSingleLineDocument
         https://bugs.webkit.org/show_bug.cgi?id=209391
         <rdar://problem/60705870>

Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (258919 => 258920)


--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2020-03-24 17:57:41 UTC (rev 258919)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2020-03-24 18:00:14 UTC (rev 258920)
@@ -4236,20 +4236,15 @@
         context.selectedRangeInMarkedText.length = [context.selectedText.string length];
     }
 
-    auto characterRectsForRange = [&] (Range& range, uint64_t locationOffset) {
+    auto characterRectsForRange = [](const Range& range, unsigned startOffset) {
         Vector<DocumentEditingContext::TextRectAndRange> rects;
-        CharacterIterator contextIterator(range);
-        unsigned currentLocation = locationOffset;
-        while (!contextIterator.atEnd()) {
-            unsigned length = contextIterator.text().length();
-            if (!length) {
-                contextIterator.advance(1);
-                continue;
-            }
-
-            rects.append({ createLiveRange(contextIterator.range())->absoluteBoundingBox(Range::BoundingRectBehavior::IgnoreEmptyTextSelections), { currentLocation, 1 } });
-            currentLocation++;
-            contextIterator.advance(1);
+        CharacterIterator iterator { range };
+        unsigned offsetSoFar = startOffset;
+        const int stride = 1;
+        while (!iterator.atEnd()) {
+            if (!iterator.text().isEmpty())
+                rects.append({ createLiveRange(iterator.range())->absoluteBoundingBox(Range::BoundingRectBehavior::IgnoreEmptyTextSelections), { offsetSoFar++, stride } });
+            iterator.advance(stride);
         }
         return rects;
     };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to