<?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>27154</bug_id>
          
          <creation_ts>2009-07-10 12:44:57 -0700</creation_ts>
          <short_desc>useless null-check statement in visible_units.cpp@logicalStartOfLine</short_desc>
          <delta_ts>2009-07-15 11:07:46 -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>RESOLVED</bug_status>
          <resolution>FIXED</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="Antonio Gomes">tonikitoo</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>bfulgham</cc>
    
    <cc>eric</cc>
    
    <cc>jparent</cc>
    
    <cc>justin.garcia</cc>
    
    <cc>ojan</cc>
    
    <cc>rniwa</cc>
    
    <cc>xji</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>130922</commentid>
    <comment_count>0</comment_count>
    <who name="Antonio Gomes">tonikitoo</who>
    <bug_when>2009-07-10 12:44:57 -0700</bug_when>
    <thetext>quoted code below and bug summary are self explanatory. 


(...)
VisiblePosition logicalStartOfLine(const VisiblePosition&amp; c)
{
   VisiblePosition visPos = logicalStartPositionForLine(c);

   if (visPos.isNull())
       return c.honorEditableBoundaryAtOrAfter(visPos);

   return c.honorEditableBoundaryAtOrAfter(visPos);
}
(...)


honorEditableBoundaryAtOrAfter is called regardless the null check and possibly (wrongly) twice</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>131463</commentid>
    <comment_count>1</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2009-07-13 18:44:33 -0700</bug_when>
    <thetext>It seems like the only difference between logicalStartOfLine and logicalStartPositionForLine is that we call honorEditableBoundaryAtOrAfter for logicalStartOfLine.  But because there is no mentioning of editable boundaries in the function, it&apos;s utterly confusing.  We should fix that.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>131464</commentid>
    <comment_count>2</comment_count>
    <who name="Justin Garcia">justin.garcia</who>
    <bug_when>2009-07-13 18:47:26 -0700</bug_when>
    <thetext>&gt;    if (visPos.isNull())
&gt;        return c.honorEditableBoundaryAtOrAfter(visPos);
&gt; 
&gt;    return c.honorEditableBoundaryAtOrAfter(visPos);

Hmm strange.  Does logicalEndOfLine have this problem as well?

Justin</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>131467</commentid>
    <comment_count>3</comment_count>
      <attachid>32693</attachid>
    <who name="Antonio Gomes">tonikitoo</who>
    <bug_when>2009-07-13 18:54:22 -0700</bug_when>
    <thetext>Created attachment 32693
simple fix: statement removed</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>131475</commentid>
    <comment_count>4</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2009-07-13 19:31:45 -0700</bug_when>
    <thetext>logicalStartPositionForLine is only used in logicalStartOfLine.  I don&apos;t understand what was the reason for making two functions, one of which is only used in the other function.  It seems like this function is added in https://trac.webkit.org/changeset/43032.  Maybe that the person intended to remove logicalStartOfLine later?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>131476</commentid>
    <comment_count>5</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2009-07-13 19:35:25 -0700</bug_when>
    <thetext>(In reply to comment #2)
&gt; Hmm strange.  Does logicalEndOfLine have this problem as well?
&gt; 
&gt; Justin

logicalEndOfLine is slightly better:

    VisiblePosition visPos = logicalEndPositionForLine(c);
   
    // Make sure the end of line is at the same line as the given input position. For a wrapping line, the logical end
    // position for the not-last-2-lines might incorrectly hand back the logical beginning of the next line. 
    // For example, &lt;div contenteditable dir=&quot;rtl&quot; style=&quot;line-break:before-white-space&quot;&gt;abcdefg abcdefg abcdefg
    // a abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg abcdefg &lt;/div&gt;
    // In this case, use the previous position of the computed logical end position.
    if (!inSameLogicalLine(c, visPos))
        visPos = visPos.previous();
    
    return c.honorEditableBoundaryAtOrBefore(visPos);

But logicalEndPositionForLine isn&apos;t used anywhere else either.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>131477</commentid>
    <comment_count>6</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2009-07-13 19:42:05 -0700</bug_when>
    <thetext>(In reply to comment #3)
&gt; Created an attachment (id=32693) [details]
&gt; simple fix: statement removed

Thank you for posting a patch, but I&apos;d like to investigate more about these functions.  It seems like we don&apos;t even need logicalStartPositionForLine (we can put everything inside logicalStartOfLine).  I have added the author of the changeset 43032.  Hopefully he can give us some feedback on this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>131604</commentid>
    <comment_count>7</comment_count>
    <who name="Xiaomei Ji">xji</who>
    <bug_when>2009-07-14 10:26:03 -0700</bug_when>
    <thetext>Thanks for identifying and working on this bug!

logicalStartPositionForLine/logicalStartOfLine and 
logicalEndPositionForLine/logicalEndOfLine are introduced when fixing issue 24168
(RTL: Home/End key does not behave correctly in mixed bidi text in RTL document ).

Since Home/End key are logical keys, those logical operations are introduced, while the original startPositionForLine/startOfLine/endPositionForLine/endOfLine are preserved for visual operations.

I think it is my bug having the following code in logicalStartOfLine (although honorEditableBoundaryAtOrAfter wont be called twice).
if (visPos.isNull())
       return c.honorEditableBoundaryAtOrAfter(visPos);
return c.honorEditableBoundaryAtOrAfter(visPos);

Antonio Gomes&apos;s patch should fix it.

The structure of logicalStartOfLine was similar to that of startOfLine() which have &quot;if (visPos.isNotNull())&quot;. But during the testing, I did not find any cases where the above condition is true, so, I removed it (see the last 4th review feedback in comments #20 of issue 24168). I guess the above mistake was introduced when I removed it (should remove the if block completely).

The structure of logicalEndOfLine is slightly different because I did find cases where the returning position from logicalEndPositionForLine() need to be adjusted (see comments in the code).

I am leaving the logicalStartPositionForLine and logicalStartOfLine (same for end of line) as separate functions to follow the pattern of startPositionForLine and startOfLine. I prefer to leave it as is (although logicalStartOfLine() is pretty simple right now), but I do not have strong opinion about it. Maybe mitz has better suggestions.

I did not replace any of the startPositionForLine/startOfLine/endPositionForLine/endofLine simply because they are visual operations and are used in several other places. I do not have enough knowledge of whether those functionalities are correct or not and whether their usages are correct or not.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>131958</commentid>
    <comment_count>8</comment_count>
    <who name="Brent Fulgham">bfulgham</who>
    <bug_when>2009-07-15 11:07:46 -0700</bug_when>
    <thetext>Landed in http://trac.webkit.org/changeset/45926.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>32693</attachid>
            <date>2009-07-13 18:54:22 -0700</date>
            <delta_ts>2009-07-14 11:53:28 -0700</delta_ts>
            <desc>simple fix: statement removed</desc>
            <filename>BUG_27154_v1.diff</filename>
            <type>text/plain</type>
            <size>1714</size>
            <attacher name="Antonio Gomes">tonikitoo</attacher>
            
              <data encoding="base64">Y29tbWl0IDdkZTE1YjEyMzZhODBhNDEwMTdjZWFmODM4M2VmYWUwMDliODc2NzAKQXV0aG9yOiBB
bnRvbmlvIEdvbWVzICh0b25pa2l0b28pIDxhbnRvbmlvLmdvbWVzQG9wZW5ib3NzYS5vcmc+CkRh
dGU6ICAgTW9uIEp1bCAxMyAyMTo1MToyNCAyMDA5IC0wNDAwCgogICAgMjAwOS0wNy0xMyAgQW50
b25pbyBHb21lcyAgIDxhbnR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W5nL3Zpc2libGVfdW5pdHMuY3BwOgorICAgICAg
ICAoV2ViQ29yZTo6bG9naWNhbFN0YXJ0T2ZMaW5lKTogRG91YmxlZCBob25vckVkaXRhYmxlQm91
bmRhcnlBdE9yQWZ0ZXIoKSBjYWxsIHJlbW92ZWQuCisKIDIwMDktMDctMTMgIEVyaWsgQXJ2aWRz
c29uICA8YXJ2QGNocm9taXVtLm9yZz4KIAogICAgICAgICBSZXZpZXdlZCBieSBEYXJpbiBBZGxl
ciBhbmQgTWFjaWVqIFN0YWNob3dpYWsuCmRpZmYgLS1naXQgYS9XZWJDb3JlL2VkaXRpbmcvdmlz
aWJsZV91bml0cy5jcHAgYi9XZWJDb3JlL2VkaXRpbmcvdmlzaWJsZV91bml0cy5jcHAKaW5kZXgg
MDJlOWZiOC4uODY5Yzg5MyAxMDA2NDQKLS0tIGEvV2ViQ29yZS9lZGl0aW5nL3Zpc2libGVfdW5p
dHMuY3BwCisrKyBiL1dlYkNvcmUvZWRpdGluZy92aXNpYmxlX3VuaXRzLmNwcApAQCAtMTE3OCw5
ICsxMTc4LDYgQEAgVmlzaWJsZVBvc2l0aW9uIGxvZ2ljYWxTdGFydE9mTGluZShjb25zdCBWaXNp
YmxlUG9zaXRpb24mIGMpCiB7CiAgICAgVmlzaWJsZVBvc2l0aW9uIHZpc1BvcyA9IGxvZ2ljYWxT
dGFydFBvc2l0aW9uRm9yTGluZShjKTsKICAgICAKLSAgICBpZiAodmlzUG9zLmlzTnVsbCgpKQot
ICAgICAgICByZXR1cm4gYy5ob25vckVkaXRhYmxlQm91bmRhcnlBdE9yQWZ0ZXIodmlzUG9zKTsK
LQogICAgIHJldHVybiBjLmhvbm9yRWRpdGFibGVCb3VuZGFyeUF0T3JBZnRlcih2aXNQb3MpOwog
fQogCg==
</data>
<flag name="review"
          id="17075"
          type_id="1"
          status="+"
          setter="darin"
    />
          </attachment>
      

    </bug>

</bugzilla>