Bug 10881
Summary: | Selecting the entire range of an inline element causes the element to be deleted | ||
---|---|---|---|
Product: | WebKit | Reporter: | Robert Burns <robburns1> |
Component: | HTML Editing | Assignee: | Nobody <webkit-unassigned> |
Status: | UNCONFIRMED | ||
Severity: | Normal | CC: | rniwa |
Priority: | P2 | ||
Version: | 419.x | ||
Hardware: | Mac | ||
OS: | OS X 10.4 |
Robert Burns
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 | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Ryosuke Niwa
Could you give us an example? e.g. markup + editing operations to reproduce the bug?