<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>10883</bug_id>
          
          <creation_ts>2006-09-16 02:17:01 -0700</creation_ts>
          <short_desc>WebView - (void)setSelectedDOMRange fails in many circumstances</short_desc>
          <delta_ts>2014-10-14 12:45:31 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>HTML Editing</component>
          <version>419.x</version>
          <rep_platform>Mac</rep_platform>
          <op_sys>OS X 10.4</op_sys>
          <bug_status>UNCONFIRMED</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Robert Burns">robburns1</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>dgatwood</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>55643</commentid>
    <comment_count>0</comment_count>
    <who name="Robert Burns">robburns1</who>
    <bug_when>2006-09-16 02:17:01 -0700</bug_when>
    <thetext>When trying to insert a new element at the selectedDOMRange and that selectedDOMRange is collapsed the WebView will not accept a setSelectedDOMRange under several circumstances.

I&apos;ve loaded content as both text/html and application/xml+xhtml.
I&apos;ve tried inserting an empty textnode; a textnode with a single zero-width-space; a textnode with a single space (see bug 10881); and a textnode with several zero-width-spaces.

I&apos;ve tried [webView replaceSelectionWithNode:],  [selectedDOMRange insertNode:], and a few others. I&apos;ve tried normalizing (which seemed to have no effect at all). I&apos;v tried selecting the inserted element with offset (0,0) and offset (0,1).

I&apos;ve tried inline and block elements.
When working with application/xhtml+xml I&apos;ve tried (DOMDocument createElement:] and(DOMDocument createElementNS:] .

All of these attempts have had the same results. The log shows a successful change of the ivar selectedRange, but when invoking setSelectedDOMRange on the webview it doesn&apos;t take.

Setting the selected DOMRange on Exiting elements work fine, but on the elements I create it fails. Without altering the selectedDOMRange to be inside newElement there&apos;s no way for the user to navigate with the keyboard into the element (bug report forthcoming).

Below is a code fragment that should help reproduce the bug and provide an illustration of the problem.


		if ([selectedRange collapsed]) {
			
//			textPlaceholder = [theDOMDocument createTextNode:@&quot;&quot;];
			textPlaceholder = [theDOMDocument createTextNode:
				[NSString stringWithFormat:@&quot;%c%c%c&quot;,
					8203, 8203, 8203]];
									
			[newElement appendChild:textPlaceholder];
			[selectedRange insertNode:newElement];

			NSLog(@&quot;selectedRange is: %@&quot;, selectedRange);
			NSLog(@&quot;the prior selected range is: %@&quot;, [webView selectedDOMRange]);
			NSLog(@&quot;newElement is %@&quot;, newElement);
			
			[selectedRange setStart:textPlaceholder :1];
			[selectedRange setEnd:textPlaceholder :2];

//			[selectedRange setStart:newElement :0];
//			[selectedRange setEnd:newElement :1];

//			[selectedRange collapse:YES];

			[webView setSelectedDOMRange:selectedRange affinity:NSSelectionAffinityDownstream];

			NSLog(@&quot;new selected range is: %@&quot;, selectedRange);

				NSLog(@&quot;the selected range is: %@&quot;, [webView selectedDOMRange]);
			[webView display];

		} else {
			
			aFragment = [selectedRange cloneContents];
			NSLog(@&quot;aFragment is %@&quot;, [aFragment textContent]);
			[newElement appendChild:aFragment];
			// [selectedRange surroundContents:newElement];
			[webView replaceSelectionWithNode:newElement];
		}</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1041657</commentid>
    <comment_count>1</comment_count>
    <who name="David Gatwood">dgatwood</who>
    <bug_when>2014-10-14 12:45:31 -0700</bug_when>
    <thetext>This is probably a dup of bug 15256 (or vice-versa, technically).  See patches attached to that bug.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>