UNCONFIRMED Bug 10881
Selecting the entire range of an inline element causes the element to be deleted
https://bugs.webkit.org/show_bug.cgi?id=10881
Summary Selecting the entire range of an inline element causes the element to be deleted
Robert Burns
Reported 2006-09-16 00:53:33 PDT
Selecting the entire range of an inline element causes the element to be deleted and replaced by a <span> element with class="apple-style-span". The following code reproduces the problem. This is an attempt at a workaround for another bug (to be reported). WebView generally has problems with selectedDOMRange navigation (keyboard and programmatically) editing problems when working near the bondary of an element. if ([selectedRange collapsed]) { textPlaceholder = [theDOMDocument createTextNode: [NSString stringWithFormat:@"%c%c%c", 8203, 8203, 8203]]; textPlaceholder2 = [theDOMDocument createTextNode: [NSString stringWithFormat:@"%c", 8203]]; textPlaceholder3 = [theDOMDocument createTextNode: [NSString stringWithFormat:@"%c", 8203]]; [newElement appendChild:textPlaceholder]; [selectedRange insertNode:newElement]; if (debugState == YES) NSLog(@"the selected range is: %@", selectedRange); // if these are set to 0 and 3 (selecting the entire range of newElement the newElement // will be replaced by an apple style span wrapping the entire paragraph set to // "font-style:normal" and another set to "font-style:bold" [selectedRange setStart:textPlaceholder :1]; [selectedRange setEnd:textPlaceholder :2]; elementInsertionRange = selectedRange; if (debugState == YES) NSLog(@"the selected range is: %@", selectedRange); [webView display]; } else { aFragment = [selectedRange cloneContents]; NSLog(@"aFragment is %@", [aFragment textContent]); [newElement appendChild:aFragment]; // [selectedRange surroundContents:newElement]; [webView replaceSelectionWithNode:newElement]; }
Attachments
Ryosuke Niwa
Comment 1 2012-05-01 20:42:38 PDT
Could you give us an example? e.g. markup + editing operations to reproduce the bug?
Note You need to log in before you can comment on or make changes to this bug.