<?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>4586</bug_id>
          
          <creation_ts>2005-08-22 08:59:19 -0700</creation_ts>
          <short_desc>rowIndex calculation doesn&apos;t consider head to come before body.</short_desc>
          <delta_ts>2006-01-13 09:52: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>DOM</component>
          <version>420+</version>
          <rep_platform>Other</rep_platform>
          <op_sys>Linux</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>1</everconfirmed>
          <reporter name="Maks Orlovich">maksim</reporter>
          <assigned_to name="Darin Adler">darin</assigned_to>
          <cc>oliver</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>17131</commentid>
    <comment_count>0</comment_count>
    <who name="Maks Orlovich">maksim</who>
    <bug_when>2005-08-22 08:59:19 -0700</bug_when>
    <thetext>From looking at the code (and testing on konq), the rowIndex routine only 
places the footer below the bodies, but fails to place the header before them, 
which is wrong. Will attach a testcase. For completeness, I&apos;ll also attach a 
second one with invalid multiple heads/foots, but IE and FFox don&apos;t agree on 
that, so it probably doesn&apos;t matter much</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>17132</commentid>
    <comment_count>1</comment_count>
      <attachid>3517</attachid>
    <who name="Maks Orlovich">maksim</who>
    <bug_when>2005-08-22 09:00:42 -0700</bug_when>
    <thetext>Created attachment 3517
normal testcase

This should output:
foot:2
body:1
head:0

but instead outputs:
foot:2
body:0
head:1</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>17133</commentid>
    <comment_count>2</comment_count>
      <attachid>3518</attachid>
    <who name="Maks Orlovich">maksim</who>
    <bug_when>2005-08-22 09:05:17 -0700</bug_when>
    <thetext>Created attachment 3518
Testcase of invalid table

This one has 2 footers and 2 headers (which IIRC is invalid), and doesn&apos;t show
any sort of consistent behavior between other browsers. WinIE just orders the
extra tfoot/thead in document order (which is what khtml currently matches if
one ignores the thead issue), Firefox gives them -1 for row order. Either
behavior would be trivial to implement. I&apos;ll probably fix this in konq in a
week or so and post a diff for adoption.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>17482</commentid>
    <comment_count>3</comment_count>
    <who name="Maks Orlovich">maksim</who>
    <bug_when>2005-08-25 18:22:19 -0700</bug_when>
    <thetext>I committed the following to KDE SVN to fix this: 
 
 
[maksim@treetop khtml]$ ~/kde3/kdesdk/scripts/svnlastchange 
html/html_tableimpl.cpp 
------------------------------------------------------------------------ 
r453378 | orlovich | 2005-08-25 20:58:28 -0400 (Thu, 25 Aug 2005) | 3 lines 
 
Fix rowIndex to make sure the head goes first. Noticed from reading the code. 
Testcase upcoming. 
 
------------------------------------------------------------------------ 
Index: html/html_tableimpl.cpp 
=================================================================== 
--- html/html_tableimpl.cpp     (revision 453377) 
+++ html/html_tableimpl.cpp     (revision 453378) 
@@ -707,10 +707,22 @@ long HTMLTableRowElementImpl::rowIndex() 
     if ( !table || table-&gt;id() != ID_TABLE ) 
        return -1; 
 
+    HTMLTableSectionElementImpl *head = static_cast&lt;HTMLTableElementImpl 
*&gt;(table)-&gt;tHead(); 
     HTMLTableSectionElementImpl *foot = static_cast&lt;HTMLTableElementImpl 
*&gt;(table)-&gt;tFoot(); 
+ 
+    if ( head ) { 
+        const NodeImpl *row = head-&gt;firstChild(); 
+        while ( row ) { 
+            if ( row == this ) 
+                return rIndex; 
+            rIndex++; 
+            row = row-&gt;nextSibling(); 
+        } 
+    } 
+ 
     NodeImpl *node = table-&gt;firstChild(); 
     while ( node ) { 
-        if ( node != foot &amp;&amp; (node-&gt;id() == ID_THEAD || node-&gt;id() == 
ID_TFOOT || node-&gt;id() == ID_TBODY) ) { 
+        if ( node != foot &amp;&amp; node != head &amp;&amp; (node-&gt;id() == ID_THEAD || 
node-&gt;id() == ID_TFOOT || node-&gt;id() == ID_TBODY) ) { 
            HTMLTableSectionElementImpl* section = 
static_cast&lt;HTMLTableSectionElementImpl *&gt;(node); 
            const NodeImpl *row = section-&gt;firstChild(); 
            while ( row ) { 
 </thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>18990</commentid>
    <comment_count>4</comment_count>
    <who name="Oliver Hunt">oliver</who>
    <bug_when>2005-09-07 04:30:44 -0700</bug_when>
    <thetext>nice testcase</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>26843</commentid>
    <comment_count>5</comment_count>
      <attachid>5314</attachid>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2005-12-27 15:15:17 -0800</bug_when>
    <thetext>Created attachment 5314
Completely blind application of Maksim&apos;s fix (untested)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>26887</commentid>
    <comment_count>6</comment_count>
    <who name="Maks Orlovich">maksim</who>
    <bug_when>2005-12-27 16:25:09 -0800</bug_when>
    <thetext>Thanks,  but:  
+        if (node != foot &amp;&amp; node != foot &amp;&amp; (node-&gt;hasTagName(theadTag) ||  
node-&gt;hasTagName(tfootTag) || node-&gt;hasTagName(tbodyTag))) {  
  
should probably have node != head &amp;&amp; node != foot... Will reattach tweaked. 
 
  </thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>26890</commentid>
    <comment_count>7</comment_count>
      <attachid>5318</attachid>
    <who name="Maks Orlovich">maksim</who>
    <bug_when>2005-12-27 16:29:08 -0800</bug_when>
    <thetext>Created attachment 5318
An obvious fix to MacDome&apos;s adoptation of my patch (even more untested)

Coincidentally, the current testcase in our SVN is nicer:
http://websvn.kde.org/trunk/tests/khtmltests/regression/tests/dom/rowindex.html?rev=453382&amp;view=markup</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>27277</commentid>
    <comment_count>8</comment_count>
      <attachid>5318</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2005-12-30 16:18:48 -0800</bug_when>
    <thetext>Comment on attachment 5318
An obvious fix to MacDome&apos;s adoptation of my patch (even more untested)

Patch looks fine. I&apos;d like to see it landed and have the test landed at the
same time.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>27530</commentid>
    <comment_count>9</comment_count>
      <attachid>5318</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2006-01-02 18:30:31 -0800</bug_when>
    <thetext>Comment on attachment 5318
An obvious fix to MacDome&apos;s adoptation of my patch (even more untested)

Will this patch fix bug 4571 too?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>27735</commentid>
    <comment_count>10</comment_count>
    <who name="Maks Orlovich">maksim</who>
    <bug_when>2006-01-04 11:54:28 -0800</bug_when>
    <thetext> (In reply to comment #9) 
&gt; (From update of attachment 5318 [edit]) 
&gt; Will this patch fix bug 4571 too? 
 
No.  
 
 
 </thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>28296</commentid>
    <comment_count>11</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2006-01-12 07:52:51 -0800</bug_when>
    <thetext>I would land this now, but there&apos;s no Change Log or layout test at this point, so it&apos;s a bit of work.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>28369</commentid>
    <comment_count>12</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2006-01-13 09:49:33 -0800</bug_when>
    <thetext>I made a layout test, wrote a change log, and updated the fix to match Firefox&apos;s behavior. Working on 
landing it now.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>3517</attachid>
            <date>2005-08-22 09:00:42 -0700</date>
            <delta_ts>2005-08-22 09:00:42 -0700</delta_ts>
            <desc>normal testcase</desc>
            <filename>rowindex.html</filename>
            <type>text/html</type>
            <size>391</size>
            <attacher name="Maks Orlovich">maksim</attacher>
            
              <data encoding="base64">PHRhYmxlPgogICAgPHRmb290Pjx0ciBpZD0iZm9vdCI+PC90Zm9vdD4KICAgIDx0Ym9keT48dHIg
aWQ9ImJvZHkiPjwvdGJvZHk+CiAgICA8dGhlYWQ+PHRyIGlkPSJoZWFkIj48L3RoZWFkPgo8L3Rh
YmxlPgoKPGRpdiBpZD0ibG9nIj4KPC9kaXY+Cgo8c2NyaXB0PgoKZnVuY3Rpb24gZG9JdCgpCnsK
ICAgIHJvd3MgPSBkb2N1bWVudC5nZXRFbGVtZW50c0J5VGFnTmFtZSgidHIiKTsKICAgIGZvciAo
aSA9IDA7IGkgPCByb3dzLmxlbmd0aDsgKytpKQogICAgICAgIGRvY3VtZW50LmdldEVsZW1lbnRC
eUlkKCJsb2ciKS5pbm5lckhUTUwgKz0gcm93c1tpXS5pZCArICI6IiArIHJvd3NbaV0ucm93SW5k
ZXggKyAiPGJyPiIKfQoKPC9zY3JpcHQ+Cgo8Ym9keSBvbmxvYWQ9ImRvSXQoKSI+Cg==
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>3518</attachid>
            <date>2005-08-22 09:05:17 -0700</date>
            <delta_ts>2005-08-22 09:05:17 -0700</delta_ts>
            <desc>Testcase of invalid table</desc>
            <filename>rowindex2.html</filename>
            <type>text/html</type>
            <size>496</size>
            <attacher name="Maks Orlovich">maksim</attacher>
            
              <data encoding="base64">PHRhYmxlPgogICAgPHRmb290Pjx0ciBpZD0iZm9vdCI+PC90Zm9vdD4KICAgIDx0Zm9vdD48dHIg
aWQ9ImZvb3QyIj48L3Rmb290PgogICAgPHRib2R5Pjx0ciBpZD0iYm9keSI+PC90Ym9keT4KICAg
IDx0Ym9keT48dHIgaWQ9ImJvZHkyIj48L3Rib2R5PgogICAgPHRoZWFkPjx0ciBpZD0iaGVhZCI+
PC90aGVhZD4KICAgIDx0aGVhZD48dHIgaWQ9ImhlYWQyIj48L3RoZWFkPgo8L3RhYmxlPgoKPGRp
diBpZD0ibG9nIj4KPC9kaXY+Cgo8c2NyaXB0PgoKZnVuY3Rpb24gZG9JdCgpCnsKICAgIHJvd3Mg
PSBkb2N1bWVudC5nZXRFbGVtZW50c0J5VGFnTmFtZSgidHIiKTsKICAgIGZvciAoaSA9IDA7IGkg
PCByb3dzLmxlbmd0aDsgKytpKQogICAgICAgIGRvY3VtZW50LmdldEVsZW1lbnRCeUlkKCJsb2ci
KS5pbm5lckhUTUwgKz0gcm93c1tpXS5pZCArICI6IiArIHJvd3NbaV0ucm93SW5kZXggKyAiPGJy
PiIKfQoKPC9zY3JpcHQ+Cgo8Ym9keSBvbmxvYWQ9ImRvSXQoKSI+Cg==
</data>

          </attachment>
          <attachment
              isobsolete="1"
              ispatch="1"
              isprivate="0"
          >
            <attachid>5314</attachid>
            <date>2005-12-27 15:15:17 -0800</date>
            <delta_ts>2005-12-27 16:29:42 -0800</delta_ts>
            <desc>Completely blind application of Maksim&apos;s fix (untested)</desc>
            <filename>sad.patch</filename>
            <type>text/plain</type>
            <size>1407</size>
            <attacher name="Eric Seidel (no email)">eric</attacher>
            
              <data encoding="base64">SW5kZXg6IGh0bWxfdGFibGVpbXBsLmNwcAo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09ClJDUyBmaWxlOiAvY3ZzL3Jvb3Qv
V2ViQ29yZS9raHRtbC9odG1sL2h0bWxfdGFibGVpbXBsLmNwcCx2CnJldHJpZXZpbmcgcmV2aXNp
b24gMS43MgpkaWZmIC11IC1yMS43MiBodG1sX3RhYmxlaW1wbC5jcHAKLS0tIGh0bWxfdGFibGVp
bXBsLmNwcAkyMyBEZWMgMjAwNSAxODo0NDoxNyAtMDAwMAkxLjcyCisrKyBodG1sX3RhYmx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keVRhZykpKSB7CisgICAgICAgIGlmIChub2RlICE9IGZvb3QgJiYgbm9kZSAhPSBm
b290ICYmIChub2RlLT5oYXNUYWdOYW1lKHRoZWFkVGFnKSB8fCBub2RlLT5oYXNUYWdOYW1lKHRm
b290VGFnKSB8fCBub2RlLT5oYXNUYWdOYW1lKHRib2R5VGFnKSkpIHsKIAkgICAgSFRNTFRhYmxl
U2VjdGlvbkVsZW1lbnRJbXBsKiBzZWN0aW9uID0gc3RhdGljX2Nhc3Q8SFRNTFRhYmxlU2VjdGlv
bkVsZW1lbnRJbXBsICo+KG5vZGUpOwogCSAgICBjb25zdCBOb2RlSW1wbCAqcm93ID0gc2VjdGlv
bi0+Zmlyc3RDaGlsZCgpOwogCSAgICB3aGlsZSAoIHJvdyApIHsK
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>5318</attachid>
            <date>2005-12-27 16:29:08 -0800</date>
            <delta_ts>2005-12-30 16:18:48 -0800</delta_ts>
            <desc>An obvious fix to MacDome&apos;s adoptation of my patch (even more untested)</desc>
            <filename>mc.patch</filename>
            <type>text/plain</type>
            <size>1407</size>
            <attacher name="Maks Orlovich">maksim</attacher>
            
              <data encoding="base64">SW5kZXg6IGh0bWxfdGFibGVpbXBsLmNwcAo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09ClJDUyBmaWxlOiAvY3ZzL3Jvb3Qv
V2ViQ29yZS9raHRtbC9odG1sL2h0bWxfdGFibGVpbXBsLmNwcCx2CnJldHJpZXZpbmcgcmV2aXNp
b24gMS43MgpkaWZmIC11IC1yMS43MiBodG1sX3RhYmxlaW1wbC5jcHAKLS0tIGh0bWxfdGFibGVp
bXBsLmNwcAkyMyBEZWMgMjAwNSAxODo0NDoxNyAtMDAwMAkxLjcyCisrKyBodG1sX3RhYmxlaW1w
bC5jcHAJMjcgRGVjIDIwMDUgMjM6MTU6NTUgLT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gbm9kZSAhPSBo
ZWFkICYmIChub2RlLT5oYXNUYWdOYW1lKHRoZWFkVGFnKSB8fCBub2RlLT5oYXNUYWdOYW1lKHRm
b290VGFnKSB8fCBub2RlLT5oYXNUYWdOYW1lKHRib2R5VGFnKSkpIHsKIAkgICAgSFRNTFRhYmxl
U2VjdGlvbkVsZW1lbnRJbXBsKiBzZWN0aW9uID0gc3RhdGljX2Nhc3Q8SFRNTFRhYmxlU2VjdGlv
bkVsZW1lbnRJbXBsICo+KG5vZGUpOwogCSAgICBjb25zdCBOb2RlSW1wbCAqcm93ID0gc2VjdGlv
bi0+Zmlyc3RDaGlsZCgpOwogCSAgICB3aGlsZSAoIHJvdyApIHsK
</data>
<flag name="review"
          id="1120"
          type_id="1"
          status="+"
          setter="darin"
    />
          </attachment>
      

    </bug>

</bugzilla>