<?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>42010</bug_id>
          
          <creation_ts>2010-07-09 17:33:40 -0700</creation_ts>
          <short_desc>TreeWalker::previousNode does not handle FILTER_REJECT when processing lastChild</short_desc>
          <delta_ts>2019-02-06 09:04:14 -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>528+ (Nightly build)</version>
          <rep_platform>All</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>1</everconfirmed>
          <reporter name="Craig Topper">craig.topper</reporter>
          <assigned_to name="Darin Adler">darin</assigned_to>
          <cc>cdumez</cc>
    
    <cc>darin</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>249380</commentid>
    <comment_count>0</comment_count>
    <who name="Craig Topper">craig.topper</who>
    <bug_when>2010-07-09 17:33:40 -0700</bug_when>
    <thetext>A FILTER_REJECT response after calling acceptNode for a last child should not follow that node&apos;s last child pointer.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>250070</commentid>
    <comment_count>1</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2010-07-12 14:49:00 -0700</bug_when>
    <thetext>Could you provide a test case?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>250075</commentid>
    <comment_count>2</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2010-07-12 14:55:50 -0700</bug_when>
    <thetext>From code inspection, I’m not sure I see the problem. The logic looks right to me. I’ll need to see the test case to understand what is actually wrong.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>250113</commentid>
    <comment_count>3</comment_count>
    <who name="Craig Topper">craig.topper</who>
    <bug_when>2010-07-12 15:57:09 -0700</bug_when>
    <thetext>I have a test case, but I&apos;m at work right now and don&apos;t have access to it. But I can attempt to better explain the problem

In the following code, a FILTER_REJECT response should terminate the loop instead of going back around. If you go back around you&apos;re asking for the lastChild of a node that was just rejected.

222	            while (Node* lastChild = node-&gt;lastChild()) {
223	                node = lastChild;
224	                acceptNodeResult = acceptNode(state, node.get());
225	                if (state &amp;&amp; state-&gt;hadException())
226	                    return 0;
227	                if (acceptNodeResult == NodeFilter::FILTER_ACCEPT)
228	                    continue;
229	            }

Also the &quot;if (acceptNodeResult == NodeFilter::FILTER_ACCEPT)&quot; part of the loop is pointless as it just does a continue which is exactly what would happen if it weren&apos;t there at all.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>250117</commentid>
    <comment_count>4</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2010-07-12 16:07:19 -0700</bug_when>
    <thetext>I see. The code should probably just say:

    if (acceptNodeResult != NodeFilter::FILTER_ACCEPT)
        break;

I think that’s right.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>250118</commentid>
    <comment_count>5</comment_count>
    <who name="Craig Topper">craig.topper</who>
    <bug_when>2010-07-12 16:08:35 -0700</bug_when>
    <thetext>You don&apos;t want to do that because FILTER_SKIP would still allow you to see the children. So it should be 

    if (acceptNodeResult == NodeFilter::FILTER_REJECT)
        break;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>250289</commentid>
    <comment_count>6</comment_count>
      <attachid>61323</attachid>
    <who name="Craig Topper">craig.topper</who>
    <bug_when>2010-07-12 21:57:28 -0700</bug_when>
    <thetext>Created attachment 61323
Test case</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>251482</commentid>
    <comment_count>7</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2010-07-14 15:51:08 -0700</bug_when>
    <thetext>Committed r63365: &lt;http://trac.webkit.org/changeset/63365&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1503130</commentid>
    <comment_count>8</comment_count>
    <who name="Lucas Forschler">lforschler</who>
    <bug_when>2019-02-06 09:04:14 -0800</bug_when>
    <thetext>Mass moving XML DOM bugs to the &quot;DOM&quot; Component.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>61323</attachid>
            <date>2010-07-12 21:57:28 -0700</date>
            <delta_ts>2010-07-12 21:57:28 -0700</delta_ts>
            <desc>Test case</desc>
            <filename>treewalker_prevnode.html</filename>
            <type>text/html</type>
            <size>1368</size>
            <attacher name="Craig Topper">craig.topper</attacher>
            
              <data encoding="base64">PGh0bWw+CiAgPGhlYWQ+CiAgICA8dGl0bGU+VGVzdCBmb3IgV2ViS2l0IGJ1Z3MgaW4gVHJlZVdh
bGtlcjwvdGl0bGU+CiAgPC9oZWFkPgogIDxib2R5IG9ubG9hZD0idGVzdFRyZWVXYWxrZXIoKSI+
CiAgICA8ZGl2IGlkPSJub2RlcyI+PGRpdiBpZD0iQTEiPjxkaXYgaWQ9IkIxIj48ZGl2IGlkPSJD
MSI+PC9kaXY+PGRpdiBpZD0iQzIiPjxkaXYgaWQ9IkQxIj48L2Rpdj48ZGl2IGlkPSJEMiI+PC9k
aXY+PC9kaXY+PC9kaXY+PGRpdiBpZD0iQjIiPjxkaXYgaWQ9IkMzIj48L2Rpdj48ZGl2IGlkPSJD
NCI+PC9kaXY+PC9kaXY+PC9kaXY+PC9kaXY+CiAgICA8c2NyaXB0IHR5cGU9ImFwcGxpY2F0aW9u
L2phdmFzY3JpcHQiPgpmdW5jdGlvbiBmaWx0ZXIxKG5vZGUpIHsKICBpZiAobm9kZS5pZCA9PSAi
QjEi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gLy8gQzEKICBpZiAod2Fsa2VyLmN1cnJlbnRO
b2RlLmlkICE9ICJDMSIpCiAgICBhbGVydCgiRXJyb3IgMTIgZXhwZWN0ZWQgQzEgZ290ICIgKyB3
YWxrZXIuY3VycmVudE5vZGUuaWQpOwp9CiAgICA8L3NjcmlwdD4KICA8L2JvZHk+CjwvaHRtbD4K
</data>

          </attachment>
      

    </bug>

</bugzilla>