<?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>62849</bug_id>
          
          <creation_ts>2011-06-17 01:42:58 -0700</creation_ts>
          <short_desc>Refactoring: Editor::selectionStartHasMarkerFor should be simplified</short_desc>
          <delta_ts>2011-11-22 00:59:04 -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>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>INVALID</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="Hajime Morrita">morrita</reporter>
          <assigned_to name="Hajime Morrita">morrita</assigned_to>
          <cc>rniwa</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>422487</commentid>
    <comment_count>0</comment_count>
    <who name="Hajime Morrita">morrita</who>
    <bug_when>2011-06-17 01:42:58 -0700</bug_when>
    <thetext>This testing API has a code duplication, which should be eliminated.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>422488</commentid>
    <comment_count>1</comment_count>
      <attachid>97560</attachid>
    <who name="Hajime Morrita">morrita</who>
    <bug_when>2011-06-17 01:45:59 -0700</bug_when>
    <thetext>Created attachment 97560
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>422499</commentid>
    <comment_count>2</comment_count>
      <attachid>97560</attachid>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2011-06-17 02:12:44 -0700</bug_when>
    <thetext>Comment on attachment 97560
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=97560&amp;action=review

&gt; Source/WebCore/editing/Editor.cpp:-3216
&gt; -        if (marker-&gt;startOffset() &lt;= startOffset &amp;&amp; endOffset &lt;= marker-&gt;endOffset() &amp;&amp; marker-&gt;type() == markerType)
&gt; -            return true;

It seems like we used to return true and we now return false if we have a zero-width marker at from=length but I guess we don&apos;t have to worry about that in practice?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>422504</commentid>
    <comment_count>3</comment_count>
    <who name="Hajime Morrita">morrita</who>
    <bug_when>2011-06-17 02:25:14 -0700</bug_when>
    <thetext>&gt; It seems like we used to return true and we now return false if we have a zero-width marker at from=length but I guess we don&apos;t have to worry about that in practice?
Yes. And in theory, we need should have a way to detect zero-length marker.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>422509</commentid>
    <comment_count>4</comment_count>
      <attachid>97560</attachid>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2011-06-17 02:42:36 -0700</bug_when>
    <thetext>Comment on attachment 97560
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=97560&amp;action=review

(In reply to comment #3)
&gt; &gt; It seems like we used to return true and we now return false if we have a zero-width marker at from=length but I guess we don&apos;t have to worry about that in practice?
&gt; Yes. And in theory, we need should have a way to detect zero-length marker.

Document markets aren&apos;t exposed to the Web, are they?  We may want to assert somewhere that we&apos;re not adding a zero-length marker.

&gt; Source/WebCore/editing/Editor.cpp:-3194
&gt; -        if (node-&gt;renderer()-&gt;isTextControl())
&gt; -            node = toRenderTextControl(node-&gt;renderer())-&gt;visiblePositionForIndex(1).deepEquivalent().deprecatedNode();

We&apos;re no longer looking for the text node, is that really fine?  Do we have a test coverage for this?

&gt; Source/WebCore/editing/Editor.cpp:-3198
&gt; -        else if (node-&gt;firstChild())
&gt; -            node = node-&gt;firstChild();
&gt; -        else
&gt; -            node = node-&gt;nextSibling();

We don&apos;t do this either.  Maybe you want to canonicalize the selection start using VisiblePosition and get the deepEquivalent?  It seems like that&apos;s what this code is trying to do.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>422512</commentid>
    <comment_count>5</comment_count>
      <attachid>97560</attachid>
    <who name="Hajime Morrita">morrita</who>
    <bug_when>2011-06-17 02:52:45 -0700</bug_when>
    <thetext>Comment on attachment 97560
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=97560&amp;action=review

&gt;&gt; Source/WebCore/editing/Editor.cpp:-3194
&gt;&gt; -            node = toRenderTextControl(node-&gt;renderer())-&gt;visiblePositionForIndex(1).deepEquivalent().deprecatedNode();
&gt; 
&gt; We&apos;re no longer looking for the text node, is that really fine?  Do we have a test coverage for this?

Traversing to text node is done by DocumentMarkerController. 
Our test case cannot handle this because our
selection anchors always go to leaf if it has any text in the subtree.

&gt;&gt; Source/WebCore/editing/Editor.cpp:-3198
&gt;&gt; -            node = node-&gt;nextSibling();
&gt; 
&gt; We don&apos;t do this either.  Maybe you want to canonicalize the selection start using VisiblePosition and get the deepEquivalent?  It seems like that&apos;s what this code is trying to do.

Yeah, that&apos;s another reason to remove this function. It&apos;s done by DocumentMarker anyway.


Anyway, thank you much for taking a look at this on such a midnight!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>422513</commentid>
    <comment_count>6</comment_count>
      <attachid>97560</attachid>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2011-06-17 02:56:00 -0700</bug_when>
    <thetext>Comment on attachment 97560
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=97560&amp;action=review

&gt;&gt;&gt; Source/WebCore/editing/Editor.cpp:-3194
&gt;&gt;&gt; -            node = toRenderTextControl(node-&gt;renderer())-&gt;visiblePositionForIndex(1).deepEquivalent().deprecatedNode();
&gt;&gt; 
&gt;&gt; We&apos;re no longer looking for the text node, is that really fine?  Do we have a test coverage for this?
&gt; 
&gt; Traversing to text node is done by DocumentMarkerController. 
&gt; Our test case cannot handle this because our
&gt; selection anchors always go to leaf if it has any text in the subtree.

I&apos;m confused.  DocumentMarkerController::hasMarkers doesn&apos;t contain any code that looks for text node.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>422521</commentid>
    <comment_count>7</comment_count>
    <who name="Hajime Morrita">morrita</who>
    <bug_when>2011-06-17 03:11:17 -0700</bug_when>
    <thetext>&gt; I&apos;m confused.  DocumentMarkerController::hasMarkers doesn&apos;t contain any code that looks for text node.
The marker is associated only for Text node. 
And hasMarker() uses traverseNextNode() for traversing, which walks up to leaf nodes.
Text nodes appear only as leaf nodes. So we never misses marked text node. 
Sorry for unclear explanation.

I think DocumentMarkerController should hold node refrences as Text*, instead of Node*.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>422524</commentid>
    <comment_count>8</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2011-06-17 03:18:11 -0700</bug_when>
    <thetext>(In reply to comment #7)
&gt; &gt; I&apos;m confused.  DocumentMarkerController::hasMarkers doesn&apos;t contain any code that looks for text node.
&gt; The marker is associated only for Text node. 
&gt; And hasMarker() uses traverseNextNode() for traversing, which walks up to leaf nodes.
&gt; Text nodes appear only as leaf nodes. So we never misses marked text node. 
&gt; Sorry for unclear explanation.
&gt; 
&gt; I think DocumentMarkerController should hold node refrences as Text*, instead of Node*.

But selectionStartHasMarkerFor&apos;s from and to are now with respect to selection start&apos;s node instead of whatever text node we used to use, right?  So it seems like we&apos;ll be including more markers.

E.g. consider a case where we have |&lt;b&gt;hello&lt;/b&gt; where | is the selection start.  If we passed (from,to)=(0,1), we used to catch markekers on &quot;h&quot; but now we catch markers on &quot;hello&quot;.  Am I missing something?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>422528</commentid>
    <comment_count>9</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2011-06-17 03:22:11 -0700</bug_when>
    <thetext>To clarify, the selection start&apos;s deprecated node is b in this case.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>422535</commentid>
    <comment_count>10</comment_count>
    <who name="Hajime Morrita">morrita</who>
    <bug_when>2011-06-17 03:34:54 -0700</bug_when>
    <thetext>&gt; E.g. consider a case where we have |&lt;b&gt;hello&lt;/b&gt; where | is the selection start.  If we passed (from,to)=(0,1), we used to catch markekers on &quot;h&quot; but now we catch markers on &quot;hello&quot;.  Am I missing something?
Wow, you are right. I need to fix it using TextIterator or something....</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>422536</commentid>
    <comment_count>11</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2011-06-17 03:37:47 -0700</bug_when>
    <thetext>(In reply to comment #10)
&gt; &gt; E.g. consider a case where we have |&lt;b&gt;hello&lt;/b&gt; where | is the selection start.  If we passed (from,to)=(0,1), we used to catch markekers on &quot;h&quot; but now we catch markers on &quot;hello&quot;.  Am I missing something?
&gt; Wow, you are right. I need to fix it using TextIterator or something....

I&apos;m glad I pointed this out before giving r+ :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>422538</commentid>
    <comment_count>12</comment_count>
    <who name="Hajime Morrita">morrita</who>
    <bug_when>2011-06-17 03:42:48 -0700</bug_when>
    <thetext>&gt; 
&gt; I&apos;m glad I pointed this out before giving r+ :)
Yeah, thanks for doing this ;-)
Actually I&apos;m confused the assumption about Positions which FrameSelection returns.
I thought it&apos;s always Text. But it looks no longer (or hasn&apos;t been) true.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>422542</commentid>
    <comment_count>13</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2011-06-17 03:46:24 -0700</bug_when>
    <thetext>(In reply to comment #12)
&gt; Yeah, thanks for doing this ;-)
&gt; Actually I&apos;m confused the assumption about Positions which FrameSelection returns.
&gt; I thought it&apos;s always Text. But it looks no longer (or hasn&apos;t been) true.

It&apos;s not.  FrameSelection&apos;s start and end are usually canonicalized but there are cases in which they&apos;re not validated.  Take a look at VisibleSelection::setWithoutValidation.  We&apos;ll really need to clean up the whole FrameSelection class at some point :(</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>507451</commentid>
    <comment_count>14</comment_count>
    <who name="Hajime Morrita">morrita</who>
    <bug_when>2011-11-22 00:59:04 -0800</bug_when>
    <thetext>Original assumption for this refactoring was wrong. Closing.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="1"
              ispatch="1"
              isprivate="0"
          >
            <attachid>97560</attachid>
            <date>2011-06-17 01:45:59 -0700</date>
            <delta_ts>2011-06-17 03:40:33 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-62849-20110617174557.patch</filename>
            <type>text/plain</type>
            <size>2835</size>
            <attacher name="Hajime Morrita">morrita</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogODkxMjcKZGlmZiAtLWdpdCBhL1NvdXJjZS9XZWJDb3JlL0No
YW5nZUxvZyBiL1NvdXJjZS9XZWJDb3JlL0NoYW5nZUxvZwppbmRleCAxMGYzNGRhZTk1Yzg3YWUx
NzM4ODg0OTIxZTgxM2M2MzhlNmE5MTliLi5kN2IyODk3MzBjOGFjNTk0NjQ0ZjkzYjlhNGJjMmRm
ZjZkNjc5OGFjIDEwMDY0NAotLS0gYS9Tb3VyY2UvV2ViQ29yZS9DaGFuZ2VMb2cKKysrIGIvU291
cmNlL1dlYkNvcmUvQ2hhbmdlTG9nCkBAIC0xLDMgKzEsMTUgQEAKKzIwMTEtMDYtMTcgIE1PUklU
QSBIYWppbWUgIDxtb3JyaXRhQGdvb2dsZS5jb20+CisKKyAgICAgICAgUmV2aWV3ZWQgYnkgTk9C
T0RZIChPT1BTISkuCisKKyAgICAgICAgUmVmYWN0b3Jpbmc6IEVkaXRvcjo6c2VsZWN0aW9uU3Rh
cnRIYXNNYXJrZXJGb3Igc2hvdWxkIGJlIHNpbXBsaWZpZWQuCisgICAgICAgIGh0dHBzOi8vYnVn
cy53ZWJraXQub3JnL3Nob3dfY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