<?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>36741</bug_id>
          
          <creation_ts>2010-03-29 00:07:08 -0700</creation_ts>
          <short_desc>Duplicate, slightly divergent implementation of Position[Iterator]::isCandidate()</short_desc>
          <delta_ts>2017-07-18 08:29:38 -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>528+ (Nightly build)</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>REOPENED</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>1</everconfirmed>
          <reporter name="Roland Steiner">rolandsteiner</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>adele</cc>
    
    <cc>commit-queue</cc>
    
    <cc>enrica</cc>
    
    <cc>eric</cc>
    
    <cc>leviw</cc>
    
    <cc>mitz</cc>
    
    <cc>rniwa</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>205308</commentid>
    <comment_count>0</comment_count>
    <who name="Roland Steiner">rolandsteiner</who>
    <bug_when>2010-03-29 00:07:08 -0700</bug_when>
    <thetext>The member function isCandidate is implemented twice, once on the Position class, and once on the PositionIterator class. The latter also does not contain the latest modifications to that function.

There should be only one implementation.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>205311</commentid>
    <comment_count>1</comment_count>
      <attachid>51879</attachid>
    <who name="Roland Steiner">rolandsteiner</who>
    <bug_when>2010-03-29 00:23:14 -0700</bug_when>
    <thetext>Created attachment 51879
patch - consolidate implementations into PositionIterator::isCandidate()

As stated in the ChangeLog, the rationale for using PositionIterator::isCandidate() over Position::isCandidate() is that a PositionIterator is cheaper to construct from a Position than vice versa (no call to nodeIndex()). Also, PositionIterator::isCandidate is called in a tight loop within next/previousCandidate (editing/htmlediting.cpp).

The code as is doesn&apos;t look very nice though, and I believe that PositionIterator and Position should be merged at some point. But that is another story, for another 1001 commits...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>207510</commentid>
    <comment_count>2</comment_count>
      <attachid>51879</attachid>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2010-04-01 17:04:32 -0700</bug_when>
    <thetext>Comment on attachment 51879
patch - consolidate implementations into PositionIterator::isCandidate()

I like the idea.  Concerned about possible performace troubles, but OK.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>207807</commentid>
    <comment_count>3</comment_count>
      <attachid>51879</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2010-04-02 01:31:23 -0700</bug_when>
    <thetext>Comment on attachment 51879
patch - consolidate implementations into PositionIterator::isCandidate()

Clearing flags on attachment: 51879

Committed r56989: &lt;http://trac.webkit.org/changeset/56989&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>207808</commentid>
    <comment_count>4</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2010-04-02 01:31:28 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>207879</commentid>
    <comment_count>5</comment_count>
    <who name="">mitz</who>
    <bug_when>2010-04-02 09:04:40 -0700</bug_when>
    <thetext>(In reply to comment #1)
&gt; a
&gt; PositionIterator is cheaper to construct from a Position than vice versa (no
&gt; call to nodeIndex()).

But there is a call to childNode(). Isn&apos;t is just as expensive? I am concerned about the performance impact of this patch. How did you measure it?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>208708</commentid>
    <comment_count>6</comment_count>
    <who name="Mark Rowe (bdash)">mrowe</who>
    <bug_when>2010-04-05 14:33:45 -0700</bug_when>
    <thetext>This introduced bug 37115.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>208761</commentid>
    <comment_count>7</comment_count>
    <who name="Adele Peterson">adele</who>
    <bug_when>2010-04-05 15:57:30 -0700</bug_when>
    <thetext>I&apos;m considering rolling this out based on the introduced bug, and the performance concerns.  I guess it was after the commit, but why were&apos;s the performance concerns addressed?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>208775</commentid>
    <comment_count>8</comment_count>
    <who name="Adele Peterson">adele</who>
    <bug_when>2010-04-05 16:18:25 -0700</bug_when>
    <thetext>wow.  I meant to say - why weren&apos;t the performance concerns addressed?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>208781</commentid>
    <comment_count>9</comment_count>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2010-04-05 16:26:01 -0700</bug_when>
    <thetext>You should of course feel free to roll it out.

I&apos;m not sure there is any performance data for or against this change.  It creates and extra object on the stack (in a relatively hot code path).  But that doesn&apos;t necessarily mean it&apos;s noticeably slower.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>208845</commentid>
    <comment_count>10</comment_count>
    <who name="Mark Rowe (bdash)">mrowe</who>
    <bug_when>2010-04-05 18:46:40 -0700</bug_when>
    <thetext>I rolled this out in r57110 to address bug 37115.  I added a test case that covers that crash in r57111.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>208849</commentid>
    <comment_count>11</comment_count>
    <who name="Roland Steiner">rolandsteiner</who>
    <bug_when>2010-04-05 19:12:12 -0700</bug_when>
    <thetext>[sorry for the belated response]

Regarding the performance concerns: Note that even
PositionIterator::isCandidate() contains conversions back to Position, so the
implementation is sub-optimal in this regard anyway.

As mentioned in my initial comment, and also on webkit-dev@ I believe that
those classes should be refactored anyway, even more so now that consolidating
the divergent implementations apparently even leads to crashes.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>208899</commentid>
    <comment_count>12</comment_count>
    <who name="Mark Rowe (bdash)">mrowe</who>
    <bug_when>2010-04-05 22:43:26 -0700</bug_when>
    <thetext>(In reply to comment #11)
&gt; As mentioned in my initial comment, and also on webkit-dev@ I believe that
&gt; those classes should be refactored anyway, even more so now that consolidating
&gt; the divergent implementations apparently even leads to crashes.

What it says to me is that refactoring needs to be approached carefully as it is easy to unintentionally break something.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>209066</commentid>
    <comment_count>13</comment_count>
    <who name="Enrica Casucci">enrica</who>
    <bug_when>2010-04-06 08:51:10 -0700</bug_when>
    <thetext>(In reply to comment #11)
&gt; [sorry for the belated response]
&gt; 
&gt; Regarding the performance concerns: Note that even
&gt; PositionIterator::isCandidate() contains conversions back to Position, so the
&gt; implementation is sub-optimal in this regard anyway.
&gt; 
&gt; As mentioned in my initial comment, and also on webkit-dev@ I believe that
&gt; those classes should be refactored anyway, even more so now that consolidating
&gt; the divergent implementations apparently even leads to crashes.

I&apos;ve read you e-mail to webkit dev very carefully and, even though I like the idea of refactoring Position, PositionIterator and Visible position, I think it is a major undertaking.
There are too many places in the editing code where heavy assumptions are made on what VisiblePosition or Position will provide, that will force you to revisit many of the editing commands.
I considered something similar for Selection and VisibleSelection at some point, encouraged by the comment in the VisibleSelection class but I decided not to move forward because the chances of breaking many places were too high.
As far as this specific change is concerned, my advice is to run performance tests before making this change. As you know, the purpose of Position iterator is to allow you to move among positions fast and we want to make sure we are not slowing it down.
I like the idea of having VisiblePosition work on renderers.
isCandidate can be very expensive at times, especially since we introduced the ability to have a selection in an editable container that contains only non editable elements and in empty editable spans within non editable content.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>51879</attachid>
            <date>2010-03-29 00:23:14 -0700</date>
            <delta_ts>2010-06-11 10:43:51 -0700</delta_ts>
            <desc>patch - consolidate implementations into PositionIterator::isCandidate()</desc>
            <filename>isc.patch</filename>
            <type>text/plain</type>
            <size>3438</size>
            <attacher name="Roland Steiner">rolandsteiner</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL1dlYkNvcmUvQ2hhbmdlTG9nIGIvV2ViQ29yZS9DaGFuZ2VMb2cKaW5kZXgg
Y2FiZmYxZC4uZDEwMDIyMiAxMDA2NDQKLS0tIGEvV2ViQ29yZS9DaGFuZ2VMb2cKKysrIGIvV2Vi
Q29yZS9DaGFuZ2VMb2cKQEAgLTEsMyArMSwyNCBAQAorMjAxMC0wMy0yOSAgUm9sYW5kIFN0ZWlu
ZXIgIDxyb2xhbmRzdGVpbmVyQGNocm9taXVtLm9yZz4KKworICAgICAgICBSZXZpZXdlZCBieSBO
T0JPRFkgKE9PUFMhKS4KKworICAgICAgICBCdWcgMzY3NDEgLSAgRHVwbGljYXRlLCBzbGlnaHRs
eSBkaXZlcmdlbnQgaW1wbGVtZW50YXRpb24gb2YgUG9zaXRpb25bSXRlcmF0b3JdOjppc0NhbmRp
ZGF0ZSgpCisgICAgICAgIGh0dHBzOi8vYnVncy53ZWJraXQub3JnL3Nob3dfYnVnLmNnaT9pZD0z
Njc0MQorICAgICAgICAKKyAgICAgICAgUGF0Y2g6IGNoYW5nZSBQb3NpdGlvbjo6aXNDYW5kaWRp
ZGF0ZSgpIHRvIGNhbGwgdGhlIFBvc2l0aW9uSXRlcmF0b3I6OmlzQ2FuZGlkYXRlKCkgdmVyc2lv
bi4KKyAgICAgICAgVXBkYXRlIFBvc2l0aW9uSXRlcmF0b3I6OmlzQ2FuZGlkYXRlKCkgdG8gbWly
cm9yIFBvc2l0aW9uOjppc0NhbmRpZGF0ZSgpLgorCisgICAgICAgIFJhdGlvbmFsZTogUG9zaXRp
b25JdGVyYXRvcjo6aXNDYW5kaWRhdGUoKSBpcyBjYWxsZWQgaW4gYSB0aWdodCBsb29wIHdpdGhp
bgorICAgICAgICBuZXh0L3ByZXZpb3VzQ2FuZ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