Bug 10881 - Selecting the entire range of an inline element causes the element to be deleted
Summary: Selecting the entire range of an inline element causes the element to be deleted
Status: UNCONFIRMED
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML Editing (show other bugs)
Version: 419.x
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-09-16 00:53 PDT by Robert Burns
Modified: 2012-05-01 20:42 PDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Burns 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];
		}
Comment 1 Ryosuke Niwa 2012-05-01 20:42:38 PDT
Could you give us an example? e.g. markup + editing operations to reproduce the bug?