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

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>13164</bug_id>
          
          <creation_ts>2011-07-06 20:30:14 +0000</creation_ts>
          <short_desc>Centralize changes to CharacterData so other specs can hook in easily</short_desc>
          <delta_ts>2011-07-24 18:04:13 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>DOM</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>enhancement</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>13248</blocked>
    
    <blocked>13250</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Aryeh Gregor">ayg</reporter>
          <assigned_to name="Anne">annevk</assigned_to>
          <cc>jonas</cc>
    
    <cc>mike</cc>
    
    <cc>Ms2ger</cc>
    
    <cc>www-dom</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>50748</commentid>
    <comment_count>0</comment_count>
    <who name="Aryeh Gregor">ayg</who>
    <bug_when>2011-07-06 20:30:14 +0000</bug_when>
    <thetext>Bug 13153 is related.  If this is fixed, that becomes invalid.

There are at least two things that currently care about when CharacterData changes: range mutations and mutation events.  Currently CharacterData is changed directly by lots of different parts of the spec.  This leads to ugly stuff like

&quot;&quot;&quot;
This includes (but is not limited to) if a script or specification sets a data or nodeValue or textContent attribute, or if a script or specification calls the replaceWholeText() method, or if a specification says to set the node&apos;s data without specifically referring to its data attribute.
&quot;&quot;&quot;
http://html5.org/specs/dom-range.html#range-behavior-under-document-mutation

This could be simplified a bunch if all CharacterData changes were funneled through one algorithm.  It could be replaceData().  Thus you&apos;d change deleteData(offset, count) to work the same as replaceData(offset, count, 0), and insertData(offset, data) to work the same as replaceData(offset, 0, data), and text.data = s to work the same as replaceData(0, -1, s), and so on.  This is probably how implementations work anyway (I&apos;ve been told it&apos;s how Gecko works).  You might then add an explicit hook for other specs to use, as the last step of the algorithm, like &quot;Run &lt;span&gt;CharacterData change steps&lt;/span&gt;&quot; or something, with &quot;CharacterData change steps&quot; defined as &quot;whatever other specs say&quot;.

If you do this, one thing to keep in mind is what to do about no-ops.  If the new data winds up being the same as the old data, how is it treated?  WebKit doesn&apos;t mutate ranges in this case, and that&apos;s the behavior I specced.  Presumably if we do that, we don&apos;t want to fire mutation events (or their replacements) either.  So you could add a step to the effect of &quot;if this isn&apos;t going to actually change anything, abort&quot; somewhere before the hook that other specs use.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50754</commentid>
    <comment_count>1</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2011-07-06 21:12:04 +0000</bug_when>
    <thetext>Define common algorithm to define the methods in is one way to have less text in that section. Addressing this bug would involve having a single callback for other specifications, but that needs to wait for a solution to mutation events.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>50759</commentid>
    <comment_count>2</comment_count>
    <who name="Aryeh Gregor">ayg</who>
    <bug_when>2011-07-06 21:41:18 +0000</bug_when>
    <thetext>Even before mutation events are solved, it would be useful to have a single callback so that the description of range mutation can be simplified.  DOM Range is currently pretty ugly on this subject, as you can see in the part of the spec I linked to in comment 0.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51004</commentid>
    <comment_count>3</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2011-07-14 11:43:45 +0000</bug_when>
    <thetext>They now use a single algorithm.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51020</commentid>
    <comment_count>4</comment_count>
    <who name="Aryeh Gregor">ayg</who>
    <bug_when>2011-07-14 14:45:00 +0000</bug_when>
    <thetext>Looks good to me, thanks!</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>