Bug 192613

Summary: Make HTMLConverter take two Positions in preparation to make it work with shadow DOM
Product: WebKit Reporter: Ryosuke Niwa <rniwa>
Component: HTML EditingAssignee: Ryosuke Niwa <rniwa>
Status: RESOLVED FIXED    
Severity: Normal CC: darin, megan_gardner, sam, thorton, webkit-bug-importer, wenson_hsieh
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 192640    
Attachments:
Description Flags
Cleanup darin: review+

Ryosuke Niwa
Reported 2018-12-11 21:36:18 PST
In order to make HTMLConverter compatible with shadow DOM, we need to make it take two Positions instead of a Range so that it can represent a selection which spans across shadow boundaries.
Attachments
Cleanup (9.06 KB, patch)
2018-12-11 21:42 PST, Ryosuke Niwa
darin: review+
Ryosuke Niwa
Comment 1 2018-12-11 21:42:50 PST
Darin Adler
Comment 2 2018-12-12 09:19:23 PST
Comment on attachment 357099 [details] Cleanup View in context: https://bugs.webkit.org/attachment.cgi?id=357099&action=review Wish we had a structure with two Positions instead of two separate ones. If we take two positions, do we need to take precautions against traversing the entire document if end is not after start? Range takes care of that, but two positions don’t. > Source/WebCore/editing/cocoa/HTMLConverter.mm:2459 > + HTMLConverter converter(range.startPosition(), range.endPosition()); I would have used { } syntax. And maybe not named the local variable. > Source/WebCore/editing/cocoa/HTMLConverter.mm:2467 > + HTMLConverter converter(range->startPosition(), range->endPosition()); Ditto.
Ryosuke Niwa
Comment 3 2018-12-12 13:11:04 PST
(In reply to Darin Adler from comment #2) > Comment on attachment 357099 [details] > Cleanup > > View in context: > https://bugs.webkit.org/attachment.cgi?id=357099&action=review > > Wish we had a structure with two Positions instead of two separate ones. > > If we take two positions, do we need to take precautions against traversing > the entire document if end is not after start? Range takes care of that, but > two positions don’t. That is a good point. We have an early return for that in serializePreservingVisualAppearanceInternal too: if (!comparePositions(start, end)) return emptyString(); We should probably update it to: if (comparePositions(start, end) >= 0) return emptyString(); I'm gonna add the following early return to HTMLConverter::convert(): if (comparePositions(m_start, m_end) > 0) return nil; > > > Source/WebCore/editing/cocoa/HTMLConverter.mm:2459 > > + HTMLConverter converter(range.startPosition(), range.endPosition()); > > I would have used { } syntax. And maybe not named the local variable. > > > Source/WebCore/editing/cocoa/HTMLConverter.mm:2467 > > + HTMLConverter converter(range->startPosition(), range->endPosition()); > > Ditto. Fixed.
Ryosuke Niwa
Comment 4 2018-12-12 13:20:12 PST
Radar WebKit Bug Importer
Comment 5 2018-12-12 13:21:28 PST
Note You need to log in before you can comment on or make changes to this bug.