Changeset 243712 in webkit
- Timestamp:
- Apr 1, 2019, 2:08:31 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/editing/TextIterator.cpp (modified) (1 diff)
-
Source/WebCore/editing/TextIterator.h (modified) (2 diffs)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (modified) (2 diffs)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKitCocoa/DocumentEditingContext.mm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r243709 r243712 1 2019-04-01 Tim Horton <timothy_horton@apple.com> 2 3 Make UIWKDocumentContext rects per-character instead of per-word 4 https://bugs.webkit.org/show_bug.cgi?id=196459 5 6 Reviewed by Wenson Hsieh. 7 8 No new tests; adjusted expected results of WebKit.DocumentEditingContext. 9 10 * editing/TextIterator.cpp: 11 (WebCore::CharacterIterator::CharacterIterator): 12 * editing/TextIterator.h: 13 (WebCore::CharacterIterator::atEnd const): 14 (WebCore::CharacterIterator::text const): 15 Add WEBCORE_EXPORT to some things. 16 Introduce a CharacterIterator constructor that takes Positions, like one that TextIterator has. 17 Move initializers to the header. 18 1 19 2019-04-01 Antti Koivisto <antti@apple.com> 2 20 -
trunk/Source/WebCore/editing/TextIterator.cpp
r243354 r243712 1529 1529 CharacterIterator::CharacterIterator(const Range& range, TextIteratorBehavior behavior) 1530 1530 : m_underlyingIterator(&range, behavior) 1531 , m_offset(0) 1532 , m_runOffset(0) 1533 , m_atBreak(true) 1531 { 1532 while (!atEnd() && !m_underlyingIterator.text().length()) 1533 m_underlyingIterator.advance(); 1534 } 1535 1536 CharacterIterator::CharacterIterator(Position start, Position end, TextIteratorBehavior behavior) 1537 : m_underlyingIterator(start, end, behavior) 1534 1538 { 1535 1539 while (!atEnd() && !m_underlyingIterator.text().length()) -
trunk/Source/WebCore/editing/TextIterator.h
r243354 r243712 256 256 public: 257 257 explicit CharacterIterator(const Range&, TextIteratorBehavior = TextIteratorDefaultBehavior); 258 258 WEBCORE_EXPORT explicit CharacterIterator(Position start, Position end, TextIteratorBehavior = TextIteratorDefaultBehavior); 259 260 bool atEnd() const { return m_underlyingIterator.atEnd(); } 261 WEBCORE_EXPORT void advance(int numCharacters); 262 263 StringView text() const { return m_underlyingIterator.text().substring(m_runOffset); } 264 WEBCORE_EXPORT Ref<Range> range() const; 265 266 bool atBreak() const { return m_atBreak; } 267 int characterOffset() const { return m_offset; } 268 269 private: 270 TextIterator m_underlyingIterator; 271 272 int m_offset { 0 }; 273 int m_runOffset { 0 }; 274 bool m_atBreak { true }; 275 }; 276 277 class BackwardsCharacterIterator { 278 public: 279 explicit BackwardsCharacterIterator(const Range&); 280 259 281 bool atEnd() const { return m_underlyingIterator.atEnd(); } 260 282 void advance(int numCharacters); 261 262 StringView text() const { return m_underlyingIterator.text().substring(m_runOffset); } 283 263 284 Ref<Range> range() const; 264 285 265 bool atBreak() const { return m_atBreak; } 266 int characterOffset() const { return m_offset; } 267 268 private: 269 TextIterator m_underlyingIterator; 286 private: 287 SimplifiedBackwardsTextIterator m_underlyingIterator; 270 288 271 289 int m_offset; … … 273 291 bool m_atBreak; 274 292 }; 275 276 class BackwardsCharacterIterator {277 public:278 explicit BackwardsCharacterIterator(const Range&);279 280 bool atEnd() const { return m_underlyingIterator.atEnd(); }281 void advance(int numCharacters);282 283 Ref<Range> range() const;284 285 private:286 SimplifiedBackwardsTextIterator m_underlyingIterator;287 288 int m_offset;289 int m_runOffset;290 bool m_atBreak;291 };292 293 293 294 // Similar to the TextIterator, except that the chunks of text returned are "well behaved", meaning -
trunk/Source/WebKit/ChangeLog
r243711 r243712 1 2019-04-01 Tim Horton <timothy_horton@apple.com> 2 3 Make UIWKDocumentContext rects per-character instead of per-word 4 https://bugs.webkit.org/show_bug.cgi?id=196459 5 6 Reviewed by Wenson Hsieh. 7 8 * WebProcess/WebPage/ios/WebPageIOS.mm: 9 (WebKit::WebPage::requestDocumentEditingContext): 10 Switch to CharacterIterator instead of TextIterator directly, to get 11 per-character rects as the API requests. 12 1 13 2019-04-01 Chris Dumez <cdumez@apple.com> 2 14 -
trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
r243677 r243712 3519 3519 3520 3520 if (wantsRects) { 3521 TextIterator contextIterator(contextBeforeStart.deepEquivalent(), contextAfterEnd.deepEquivalent());3521 CharacterIterator contextIterator(contextBeforeStart.deepEquivalent(), contextAfterEnd.deepEquivalent()); 3522 3522 unsigned currentLocation = 0; 3523 3523 while (!contextIterator.atEnd()) { 3524 3524 unsigned length = contextIterator.text().length(); 3525 3525 if (!length) { 3526 contextIterator.advance( );3526 contextIterator.advance(1); 3527 3527 continue; 3528 3528 } … … 3530 3530 DocumentEditingContext::TextRectAndRange rect; 3531 3531 rect.rect = contextIterator.range()->absoluteBoundingBox(); 3532 rect.range = { currentLocation, length};3532 rect.range = { currentLocation, 1 }; 3533 3533 context.textRects.append(rect); 3534 3534 3535 currentLocation += length;3536 contextIterator.advance( );3535 currentLocation++; 3536 contextIterator.advance(1); 3537 3537 } 3538 3538 } -
trunk/Tools/ChangeLog
r243711 r243712 1 2019-04-01 Tim Horton <timothy_horton@apple.com> 2 3 Make UIWKDocumentContext rects per-character instead of per-word 4 https://bugs.webkit.org/show_bug.cgi?id=196459 5 6 Reviewed by Wenson Hsieh. 7 8 * TestWebKitAPI/Tests/WebKitCocoa/DocumentEditingContext.mm: 9 (TEST): 10 Adjust test results due to switching to per-character rects. 11 1 12 2019-04-01 Chris Dumez <cdumez@apple.com> 2 13 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/DocumentEditingContext.mm
r243484 r243712 207 207 EXPECT_NULL(context.contextAfter); 208 208 209 NSArray<NSValue *> *rects = [context characterRectsForCharacterRange:NSMakeRange(0, 1)]; 210 EXPECT_EQ(1UL, rects.count); 211 EXPECT_RECT_EQ(0, 0, 92, 24, rects.firstObject.CGRectValue); 209 NSArray<NSValue *> *rects = [[context characterRectsForCharacterRange:NSMakeRange(0, 4)] sortedArrayUsingComparator:^(NSValue *a, NSValue *b) { 210 return [@(a.CGRectValue.origin.x) compare:@(b.CGRectValue.origin.x)]; 211 }]; 212 EXPECT_EQ(4UL, rects.count); 213 EXPECT_RECT_EQ(0, 0, 23, 24, rects[0].CGRectValue); 214 EXPECT_RECT_EQ(23, 0, 23, 24, rects[1].CGRectValue); 215 EXPECT_RECT_EQ(46, 0, 23, 24, rects[2].CGRectValue); 216 EXPECT_RECT_EQ(69, 0, 23, 24, rects[3].CGRectValue); 212 217 rects = [context characterRectsForCharacterRange:NSMakeRange(5, 1)]; 213 218 EXPECT_EQ(0UL, rects.count); … … 217 222 rects = [context characterRectsForCharacterRange:NSMakeRange(0, 1)]; 218 223 EXPECT_EQ(1UL, rects.count); 219 EXPECT_RECT_EQ(0, 0, 92, 24, rects.firstObject.CGRectValue);224 EXPECT_RECT_EQ(0, 0, 23, 24, rects.firstObject.CGRectValue); 220 225 rects = [context characterRectsForCharacterRange:NSMakeRange(6, 1)]; 221 226 EXPECT_EQ(1UL, rects.count); 222 EXPECT_RECT_EQ( 92, 0, 92, 24, rects.firstObject.CGRectValue);227 EXPECT_RECT_EQ(138, 0, 23, 24, rects.firstObject.CGRectValue); 223 228 224 229 // Text Input Context
Note:
See TracChangeset
for help on using the changeset viewer.