<?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>23793</bug_id>
          
          <creation_ts>2009-02-06 11:39:32 -0800</creation_ts>
          <short_desc>WebKit needs separate VisibleSelection and Selection data storage</short_desc>
          <delta_ts>2023-02-25 07:38:21 -0800</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>528+ (Nightly build)</version>
          <rep_platform>Mac</rep_platform>
          <op_sys>OS X 10.5</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>CONFIGURATION CHANGED</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>
          <dependson>23852</dependson>
          <blocked>6350</blocked>
    
    <blocked>17697</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Eric Seidel (no email)">eric</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>ayg</cc>
    
    <cc>emacemac7</cc>
    
    <cc>hyatt</cc>
    
    <cc>jparent</cc>
    
    <cc>justin.garcia</cc>
    
    <cc>kai</cc>
    
    <cc>ojan</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>108669</commentid>
    <comment_count>0</comment_count>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2009-02-06 11:39:32 -0800</bug_when>
    <thetext>WebKit changes the Selection on setting with addRange, FF does not

This is sorta a dupe of bug 6350 and bug 17697, certainly fixing this more general bug would fix both of those.

Basically Selection::validate() is flawed, at least from the DOM&apos;s perspective.  JS should be able to set the selection to anything and get it back w/o having it be mutated in the process.  The Editing code wants to be able to get at the &quot;validated&quot; selection.  We may just want to store things double, not sure yet.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108670</commentid>
    <comment_count>1</comment_count>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2009-02-06 11:40:26 -0800</bug_when>
    <thetext>This bug was prompted by http://code.google.com/p/chromium/issues/detail?id=2874, I&apos;m about to attach a modified test case from chromium&apos;s 2874</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108671</commentid>
    <comment_count>2</comment_count>
      <attachid>27404</attachid>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2009-02-06 11:41:21 -0800</bug_when>
    <thetext>Created attachment 27404
modified test case from chromium bug</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108674</commentid>
    <comment_count>3</comment_count>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2009-02-06 12:01:24 -0800</bug_when>
    <thetext>I think the &quot;validation&quot; invariant which Selection currently tries to hold, is a wrong one.  In at least I don&apos;t think Selection should assume that both of it&apos;s endpoints are valid visible positions.  Maybe we need a separate VisibleSelection class which holds that invariant, similar to how we have VisiblePosition and Position split classes.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108675</commentid>
    <comment_count>4</comment_count>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2009-02-06 12:07:00 -0800</bug_when>
    <thetext>In the above proposal, Selection would just be an array of ranges.  VisibleSelection would probably still support only one Range (like it does today), slowly editing commands could be transitioned off of VisibleSelection and onto Selection?  Maybe adding multiple-range selection support in the process?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108677</commentid>
    <comment_count>5</comment_count>
    <who name="Justin Garcia">justin.garcia</who>
    <bug_when>2009-02-06 12:24:29 -0800</bug_when>
    <thetext>(In reply to comment #3)
&gt; Maybe we need a separate VisibleSelection class which holds that invariant, 
&gt; similar to how we have VisiblePosition and Position split classes.

Yea, that seems like the way to go.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>108701</commentid>
    <comment_count>6</comment_count>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2009-02-06 13:27:36 -0800</bug_when>
    <thetext>Ok, so SelectionController will need a VisibleSelection member (the current m_selection), and a new Selection member.

What the user sees and interacts with is the VisibleSelection.  What JavaScript and (eventually) the editing commands interact with will be Selection (a Vector of Range objects).

VisibleSelection and Selection will both be copyable, datastorage types.  Editing, and any other section of the code which wants to keep around multiple copies can do so.  SelectionController maintain the official copy. :)

In order to handle keeping the stored Selection and VisibleSelection in sync, SelectionController will need to change to return a copy of a VisibleSelection via visibleSelection() instead of a reference like it does now.  There will be a new setVisibleSelection method which can take a VisibleSelection and knows to set m_selection from VisibleSelection::toSelection() or similar.

Likewise there will need to be a setSelection which takes a Selection object and knows to create a VisibleSelection from the Selection and store it in m_visibleSelection.

Initially all of our code will use VisibleSelection.  Over time, we will move more and more code to use Selection instead.

To add multi-range selection (which we&apos;ll eventually need for table editing), Selection will just store a Vector of Range objects.  VisibleSelection can hold whatever data it needs to represent the selection, but it will probably be a Vector of VisiblePosition pairs (or maybe VisibleRanges?).

Thoughts on this proposal are most welcome!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1936752</commentid>
    <comment_count>7</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2023-02-25 07:38:21 -0800</bug_when>
    <thetext>Attached test case also passes in Safari Technology Preview 164 after Live Range Selection API also matching Chrome Canary 112 and Firefox Nightly 112.

Marking this as &quot;RESOLVED CONFIGURATION CHANGED&quot;. Thanks!</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>27404</attachid>
            <date>2009-02-06 11:41:21 -0800</date>
            <delta_ts>2009-02-06 11:41:21 -0800</delta_ts>
            <desc>modified test case from chromium bug</desc>
            <filename>caret-set-get.html</filename>
            <type>text/html</type>
            <size>3682</size>
            <attacher name="Eric Seidel (no email)">eric</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWwgUFVCTElDICItLy9XM0MvL0RURCBYSFRNTCAxLjAgU3RyaWN0Ly9FTiIg
Imh0dHA6Ly93d3cudzMub3JnL1RSL3hodG1sMS9EVEQveGh0bWwxLXN0cmljdC5kdGQiPgo8aHRt
bD4KICA8aGVhZD4KICAgIDx0aXRsZT5TZWxlY3Rpb24gdGVzdDwvdGl0bGU+CiAgICA8c3R5bGU+
CiAgICAgIGRpdiNlZGl0IHsKICAgICAgICBib3JkZXI6MXB4IHNvbGlkIGJsdWU7CiAgICAgICAg
cGFkZGluZzo1cHg7CiAgICAgIH0KICAgICAgZGl2I2xvZyB7CiAgICAgICAgbWFyZ2luLXRvcDox
MHB4OwogICAgICB9CiAgICAgIC5lcnJvciB7CiAgICAgICAgY29sb3I6cmVkOwogICAgICB9CiAg
ICAgIC5zdWNjZXNzIHsKICAgICAgICBjb2xvcjpncmVlbjsKICAgICAgfQogICAgPC9zdHlsZT4K
ICAgIDxzY3JpcHQgbGFuZ3VhZ2U9J2phdmFzY3JpcHQnPgoKICAgIHZhciBzdWNjZXNzID0gdHJ1
ZTsKICAgIAogICAgZnVuY3Rpb24gcnVuVGVzdChub2RlKSB7CiAgICAgIGxvZ1RleHQobm9kZS5v
dXRlckhUTUwpOwogICAgICB0ZXN0Tm9kZShub2RlKTsKICAgICAgaWYgKHN1Y2Nlc3MpIHsKICAg
ICAgICBsb2dTdWNjZXNzKCJQYXNzISIpOwogICAgICB9CiAgICB9CiAgICAgICAgCiAgICBmdW5j
dGlvbiBpc1RleHQobm9kZSkgewogICAgICByZXR1cm4gbm9kZS5ub2RlVHlwZSA9PSAzOwogICAg
fQogICAgCiAgICBmdW5jdGlvbiB0ZXN0Tm9kZShub2RlKSB7CiAgICAgIGlmIChpc1RleHQobm9k
ZSkpIHsKICAgICAgICB0ZXN0VGV4dE5vZGUobm9kZSk7CiAgICAgI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