<?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>16843</bug_id>
          
          <creation_ts>2008-01-11 11:04:24 -0800</creation_ts>
          <short_desc>RenderText::addLineBoxRects erroneously includes last char for boundingBox</short_desc>
          <delta_ts>2008-01-11 11:34:36 -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>WebCore Misc.</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows XP</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>16844</dup_id>
          
          <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="Finnur Thorarinsson">finnur.webkit</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>eric</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>66930</commentid>
    <comment_count>0</comment_count>
    <who name="Finnur Thorarinsson">finnur.webkit</who>
    <bug_when>2008-01-11 11:04:24 -0800</bug_when>
    <thetext>Version: local build, downloaded from tarball on Jan 10th, 2008.
Platform and OS: Reproduced with Safari (which I hooked up to use my local build of WebKit) on Windows XP (didn&apos;t try Mac)

To reproduce, start with this super simple web page:

&lt;html&gt; 
&lt;body&gt; 
Ctrl-T&lt;br&gt;
asdf&lt;br&gt;
&lt;/body&gt; 
&lt;/html&gt;

Then add the following code line to Frame::findString at the bottom:

+    IntRect bounds = resultRange-&gt;boundingBox();
     return true;

... and set a breakpoint on the return statement.

Now, in Safari, when you incrementally search for &apos;asdf&apos;, you will see the following boundingBox as the breakpoint hits:

search (x, y)   (w,  h)
--------------------------
a      (8, 26)  (14, 42)
as     (8, 26)  (20, 42)
asd    (8, 26)  (33, 42)  &lt;- clearly wrong, this is showing the boundingBox for &apos;asdf&apos; instead of &apos;asd&apos;
asdf   (8, 26)  (33, 42)

The reason for this error is that box-&gt;end() is assumed to point beyond the last character, when in fact it points *to* the last character (as specified in a comment in this function). WebKit uses box-&gt;end() in two locations in this function but only adds +1 to it in one location. The fix is therefore to add the missing +1. 

With the fix we get:

search (x, y)   (w,  h)
--------------------------
a      (8, 26)  (14, 42)
as     (8, 26)  (20, 42)
asd    (8, 26)  (28, 42)  &lt;- correct
asdf   (8, 26)  (33, 42)

I&apos;ve been in touch with Eric Seidel and will work with him on what else I need to supply for this bug (if anything).

In the meantime, here is the fix:

===================================================================
--- RenderText.cpp      (revision 29378)
+++ RenderText.cpp      (working copy)
@@ -211,7 +211,7 @@
     absolutePositionForContent(x, y);

     for (InlineTextBox* box = firstTextBox(); box; box = box-&gt;nextTextBox()) {
-        if (start &lt;= box-&gt;start() &amp;&amp; box-&gt;end() &lt;= end) {
+        if (start &lt;= box-&gt;start() &amp;&amp; box-&gt;end() + 1 &lt;= end) {
             IntRect r = IntRect(x + box-&gt;xPos(), y + box-&gt;yPos(), box-&gt;width(),
 box-&gt;height());
             if (useSelectionHeight) {
                 IntRect selectionRect = box-&gt;selectionRect(x, y, start, end);</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>66935</commentid>
    <comment_count>1</comment_count>
    <who name="Mark Rowe (bdash)">mrowe</who>
    <bug_when>2008-01-11 11:30:52 -0800</bug_when>
    <thetext>*** Bug 16844 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>66938</commentid>
    <comment_count>2</comment_count>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2008-01-11 11:34:36 -0800</bug_when>
    <thetext>

*** This bug has been marked as a duplicate of 16844 ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>