Diff
Modified: trunk/Source/WebCore/ChangeLog (243711 => 243712)
--- trunk/Source/WebCore/ChangeLog 2019-04-01 20:52:36 UTC (rev 243711)
+++ trunk/Source/WebCore/ChangeLog 2019-04-01 21:08:31 UTC (rev 243712)
@@ -1,3 +1,21 @@
+2019-04-01 Tim Horton <[email protected]>
+
+ Make UIWKDocumentContext rects per-character instead of per-word
+ https://bugs.webkit.org/show_bug.cgi?id=196459
+
+ Reviewed by Wenson Hsieh.
+
+ No new tests; adjusted expected results of WebKit.DocumentEditingContext.
+
+ * editing/TextIterator.cpp:
+ (WebCore::CharacterIterator::CharacterIterator):
+ * editing/TextIterator.h:
+ (WebCore::CharacterIterator::atEnd const):
+ (WebCore::CharacterIterator::text const):
+ Add WEBCORE_EXPORT to some things.
+ Introduce a CharacterIterator constructor that takes Positions, like one that TextIterator has.
+ Move initializers to the header.
+
2019-04-01 Antti Koivisto <[email protected]>
Update event region when toggling pointer-events:none
Modified: trunk/Source/WebCore/editing/TextIterator.cpp (243711 => 243712)
--- trunk/Source/WebCore/editing/TextIterator.cpp 2019-04-01 20:52:36 UTC (rev 243711)
+++ trunk/Source/WebCore/editing/TextIterator.cpp 2019-04-01 21:08:31 UTC (rev 243712)
@@ -1528,14 +1528,18 @@
CharacterIterator::CharacterIterator(const Range& range, TextIteratorBehavior behavior)
: m_underlyingIterator(&range, behavior)
- , m_offset(0)
- , m_runOffset(0)
- , m_atBreak(true)
{
while (!atEnd() && !m_underlyingIterator.text().length())
m_underlyingIterator.advance();
}
+CharacterIterator::CharacterIterator(Position start, Position end, TextIteratorBehavior behavior)
+ : m_underlyingIterator(start, end, behavior)
+{
+ while (!atEnd() && !m_underlyingIterator.text().length())
+ m_underlyingIterator.advance();
+}
+
Ref<Range> CharacterIterator::range() const
{
Ref<Range> range = m_underlyingIterator.range();
Modified: trunk/Source/WebCore/editing/TextIterator.h (243711 => 243712)
--- trunk/Source/WebCore/editing/TextIterator.h 2019-04-01 20:52:36 UTC (rev 243711)
+++ trunk/Source/WebCore/editing/TextIterator.h 2019-04-01 21:08:31 UTC (rev 243712)
@@ -255,12 +255,13 @@
class CharacterIterator {
public:
explicit CharacterIterator(const Range&, TextIteratorBehavior = TextIteratorDefaultBehavior);
+ WEBCORE_EXPORT explicit CharacterIterator(Position start, Position end, TextIteratorBehavior = TextIteratorDefaultBehavior);
bool atEnd() const { return m_underlyingIterator.atEnd(); }
- void advance(int numCharacters);
+ WEBCORE_EXPORT void advance(int numCharacters);
StringView text() const { return m_underlyingIterator.text().substring(m_runOffset); }
- Ref<Range> range() const;
+ WEBCORE_EXPORT Ref<Range> range() const;
bool atBreak() const { return m_atBreak; }
int characterOffset() const { return m_offset; }
@@ -268,9 +269,9 @@
private:
TextIterator m_underlyingIterator;
- int m_offset;
- int m_runOffset;
- bool m_atBreak;
+ int m_offset { 0 };
+ int m_runOffset { 0 };
+ bool m_atBreak { true };
};
class BackwardsCharacterIterator {
Modified: trunk/Source/WebKit/ChangeLog (243711 => 243712)
--- trunk/Source/WebKit/ChangeLog 2019-04-01 20:52:36 UTC (rev 243711)
+++ trunk/Source/WebKit/ChangeLog 2019-04-01 21:08:31 UTC (rev 243712)
@@ -1,3 +1,15 @@
+2019-04-01 Tim Horton <[email protected]>
+
+ Make UIWKDocumentContext rects per-character instead of per-word
+ https://bugs.webkit.org/show_bug.cgi?id=196459
+
+ Reviewed by Wenson Hsieh.
+
+ * WebProcess/WebPage/ios/WebPageIOS.mm:
+ (WebKit::WebPage::requestDocumentEditingContext):
+ Switch to CharacterIterator instead of TextIterator directly, to get
+ per-character rects as the API requests.
+
2019-04-01 Chris Dumez <[email protected]>
UIProcess crash when a prewarmed process is terminated
Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (243711 => 243712)
--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm 2019-04-01 20:52:36 UTC (rev 243711)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm 2019-04-01 21:08:31 UTC (rev 243712)
@@ -3518,22 +3518,22 @@
}
if (wantsRects) {
- TextIterator contextIterator(contextBeforeStart.deepEquivalent(), contextAfterEnd.deepEquivalent());
+ CharacterIterator contextIterator(contextBeforeStart.deepEquivalent(), contextAfterEnd.deepEquivalent());
unsigned currentLocation = 0;
while (!contextIterator.atEnd()) {
unsigned length = contextIterator.text().length();
if (!length) {
- contextIterator.advance();
+ contextIterator.advance(1);
continue;
}
DocumentEditingContext::TextRectAndRange rect;
rect.rect = contextIterator.range()->absoluteBoundingBox();
- rect.range = { currentLocation, length };
+ rect.range = { currentLocation, 1 };
context.textRects.append(rect);
- currentLocation += length;
- contextIterator.advance();
+ currentLocation++;
+ contextIterator.advance(1);
}
}
Modified: trunk/Tools/ChangeLog (243711 => 243712)
--- trunk/Tools/ChangeLog 2019-04-01 20:52:36 UTC (rev 243711)
+++ trunk/Tools/ChangeLog 2019-04-01 21:08:31 UTC (rev 243712)
@@ -1,3 +1,14 @@
+2019-04-01 Tim Horton <[email protected]>
+
+ Make UIWKDocumentContext rects per-character instead of per-word
+ https://bugs.webkit.org/show_bug.cgi?id=196459
+
+ Reviewed by Wenson Hsieh.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/DocumentEditingContext.mm:
+ (TEST):
+ Adjust test results due to switching to per-character rects.
+
2019-04-01 Chris Dumez <[email protected]>
UIProcess crash when a prewarmed process is terminated
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/DocumentEditingContext.mm (243711 => 243712)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/DocumentEditingContext.mm 2019-04-01 20:52:36 UTC (rev 243711)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/DocumentEditingContext.mm 2019-04-01 21:08:31 UTC (rev 243712)
@@ -206,9 +206,14 @@
EXPECT_NSSTRING_EQ("MMMM", context.selectedText);
EXPECT_NULL(context.contextAfter);
- NSArray<NSValue *> *rects = [context characterRectsForCharacterRange:NSMakeRange(0, 1)];
- EXPECT_EQ(1UL, rects.count);
- EXPECT_RECT_EQ(0, 0, 92, 24, rects.firstObject.CGRectValue);
+ NSArray<NSValue *> *rects = [[context characterRectsForCharacterRange:NSMakeRange(0, 4)] sortedArrayUsingComparator:^(NSValue *a, NSValue *b) {
+ return [@(a.CGRectValue.origin.x) compare:@(b.CGRectValue.origin.x)];
+ }];
+ EXPECT_EQ(4UL, rects.count);
+ EXPECT_RECT_EQ(0, 0, 23, 24, rects[0].CGRectValue);
+ EXPECT_RECT_EQ(23, 0, 23, 24, rects[1].CGRectValue);
+ EXPECT_RECT_EQ(46, 0, 23, 24, rects[2].CGRectValue);
+ EXPECT_RECT_EQ(69, 0, 23, 24, rects[3].CGRectValue);
rects = [context characterRectsForCharacterRange:NSMakeRange(5, 1)];
EXPECT_EQ(0UL, rects.count);
@@ -216,10 +221,10 @@
EXPECT_NSSTRING_EQ(" MMM", context.contextAfter);
rects = [context characterRectsForCharacterRange:NSMakeRange(0, 1)];
EXPECT_EQ(1UL, rects.count);
- EXPECT_RECT_EQ(0, 0, 92, 24, rects.firstObject.CGRectValue);
+ EXPECT_RECT_EQ(0, 0, 23, 24, rects.firstObject.CGRectValue);
rects = [context characterRectsForCharacterRange:NSMakeRange(6, 1)];
EXPECT_EQ(1UL, rects.count);
- EXPECT_RECT_EQ(92, 0, 92, 24, rects.firstObject.CGRectValue);
+ EXPECT_RECT_EQ(138, 0, 23, 24, rects.firstObject.CGRectValue);
// Text Input Context
[webView synchronouslyLoadHTMLString:applyStyle(@"<input type='text' style='width: 50px; height: 50px;' value='hello, world'>")];