<?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>67686</bug_id>
          
          <creation_ts>2011-09-06 17:38:50 -0700</creation_ts>
          <short_desc>Optimize Node::isInShadowTree to execute in constant-time</short_desc>
          <delta_ts>2011-10-24 23:41:29 -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>New Bugs</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</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>
          
          <blocked>70649</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Adam Klein">adamk</reporter>
          <assigned_to name="Adam Klein">adamk</assigned_to>
          <cc>dglazkov</cc>
    
    <cc>dominicc</cc>
    
    <cc>rafaelw</cc>
    
    <cc>rolandsteiner</cc>
    
    <cc>webkit.review.bot</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>463017</commentid>
    <comment_count>0</comment_count>
    <who name="Adam Klein">adamk</who>
    <bug_when>2011-09-06 17:38:50 -0700</bug_when>
    <thetext>Optimize Node::isInShadowTree to execute in constant-time</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>463018</commentid>
    <comment_count>1</comment_count>
      <attachid>106525</attachid>
    <who name="Adam Klein">adamk</who>
    <bug_when>2011-09-06 17:39:52 -0700</bug_when>
    <thetext>Created attachment 106525
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>463024</commentid>
    <comment_count>2</comment_count>
      <attachid>106525</attachid>
    <who name="Dominic Cooney">dominicc</who>
    <bug_when>2011-09-06 17:52:58 -0700</bug_when>
    <thetext>Comment on attachment 106525
Patch

Awesome.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>463026</commentid>
    <comment_count>3</comment_count>
    <who name="Adam Klein">adamk</who>
    <bug_when>2011-09-06 17:59:03 -0700</bug_when>
    <thetext>I should ask: do y&apos;all know of a particular test that might exercise isInShadowTree()?  There are only a few callers...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>463093</commentid>
    <comment_count>4</comment_count>
    <who name="Dimitri Glazkov (Google)">dglazkov</who>
    <bug_when>2011-09-06 19:45:02 -0700</bug_when>
    <thetext>(In reply to comment #3)
&gt; I should ask: do y&apos;all know of a particular test that might exercise isInShadowTree()?  There are only a few callers...

Let&apos;s just write one.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>463439</commentid>
    <comment_count>5</comment_count>
    <who name="Adam Klein">adamk</who>
    <bug_when>2011-09-07 10:44:35 -0700</bug_when>
    <thetext>(In reply to comment #4)
&gt; (In reply to comment #3)
&gt; &gt; I should ask: do y&apos;all know of a particular test that might exercise isInShadowTree()?  There are only a few callers...
&gt; 
&gt; Let&apos;s just write one.

That&apos;ll require finding an entry point I understand :).

The clearest usage is in HTMLLinkElement; it looks like that call was added for http://trac.webkit.org/changeset/77834, and I&apos;ve run the test that patch was meant to fix (svg/dom/use-transform.svg).  It passes without crashing.

The other two usages are in editing/range code and in SVGTrefElement, neither of which I&apos;m familiar enough with to exercise.  Let me know if you&apos;ve got something in mind...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>463457</commentid>
    <comment_count>6</comment_count>
    <who name="Roland Steiner">rolandsteiner</who>
    <bug_when>2011-09-07 11:01:52 -0700</bug_when>
    <thetext>Unless someone changed SVG while I wasn&apos;t looking, this won&apos;t work for SVG, because SVG doesn&apos;t use TreeScope yet. Indeed, SVG is the only reason why we still have various functions climbing the tree to look for, e.g., the host element (Node::shadowTreeRootNode et al) rather than doing O(1) access.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>463612</commentid>
    <comment_count>7</comment_count>
    <who name="Dominic Cooney">dominicc</who>
    <bug_when>2011-09-07 13:33:26 -0700</bug_when>
    <thetext>You could still fast-path the in new-style shadow case as a prefix. Maybe if you’re willing to assume SVG elements don’t display non-SVG children (pretty sure I have seen that elsewhere in SVG shadow walking code) you could test !isSVGElement and predicate the fast path on that.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>463613</commentid>
    <comment_count>8</comment_count>
    <who name="Dimitri Glazkov (Google)">dglazkov</who>
    <bug_when>2011-09-07 13:35:17 -0700</bug_when>
    <thetext>This could be a bug in existing code, but it already ignores SVG shadow roots. So I think this change doesn&apos;t make things worse. Right?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>463617</commentid>
    <comment_count>9</comment_count>
    <who name="Roland Steiner">rolandsteiner</who>
    <bug_when>2011-09-07 13:39:54 -0700</bug_when>
    <thetext>(In reply to comment #8)

IIRC isShadowRoot() works for both new-style shadows and SVG shadows.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>488654</commentid>
    <comment_count>10</comment_count>
    <who name="Rafael Weinstein">rafaelw</who>
    <bug_when>2011-10-21 14:17:57 -0700</bug_when>
    <thetext>This blocks an important optimization for mutation observers</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>488987</commentid>
    <comment_count>11</comment_count>
    <who name="Dominic Cooney">dominicc</who>
    <bug_when>2011-10-22 20:08:34 -0700</bug_when>
    <thetext>(In reply to comment #9)
&gt; IIRC isShadowRoot() works for both new-style shadows and SVG shadows.

No it doesn&apos;t; look at the definition of isShadowRoot.

Adam: Any reason not to R? this patch. It looks good to me.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>489483</commentid>
    <comment_count>12</comment_count>
    <who name="Adam Klein">adamk</who>
    <bug_when>2011-10-24 11:39:41 -0700</bug_when>
    <thetext>(In reply to comment #11)
&gt; (In reply to comment #9)
&gt; &gt; IIRC isShadowRoot() works for both new-style shadows and SVG shadows.
&gt; 
&gt; No it doesn&apos;t; look at the definition of isShadowRoot.
&gt; 
&gt; Adam: Any reason not to R? this patch. It looks good to me.

Only Roland&apos;s comments, pushed back to R?.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>489580</commentid>
    <comment_count>13</comment_count>
      <attachid>106525</attachid>
    <who name="WebKit Review Bot">webkit.review.bot</who>
    <bug_when>2011-10-24 13:40:42 -0700</bug_when>
    <thetext>Comment on attachment 106525
Patch

Clearing flags on attachment: 106525

Committed r98275: &lt;http://trac.webkit.org/changeset/98275&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>489581</commentid>
    <comment_count>14</comment_count>
    <who name="WebKit Review Bot">webkit.review.bot</who>
    <bug_when>2011-10-24 13:40:47 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>489828</commentid>
    <comment_count>15</comment_count>
    <who name="Roland Steiner">rolandsteiner</who>
    <bug_when>2011-10-24 18:41:26 -0700</bug_when>
    <thetext>(In reply to comment #11)
&gt; (In reply to comment #9)
&gt; &gt; IIRC isShadowRoot() works for both new-style shadows and SVG shadows.
&gt; 
&gt; No it doesn&apos;t; look at the definition of isShadowRoot.

That definition has changed since I made the comment! And I wonder if we haven&apos;t introduced a bug here:

If I reconstruct this correctly, isInShadowTree is used in SVG at least by SVGTRefElement. This used to climb the tree looking for isShadowRoot, which used to be set for both SVG and new-style shadow roots. With the changes that isShadowRoot no longer applies for SVG and the shortcut introduced here, this is probably broken (?).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>489887</commentid>
    <comment_count>16</comment_count>
    <who name="Dominic Cooney">dominicc</who>
    <bug_when>2011-10-24 23:41:29 -0700</bug_when>
    <thetext>(In reply to comment #15)
&gt; (In reply to comment #11)
&gt; &gt; (In reply to comment #9)
&gt; &gt; &gt; IIRC isShadowRoot() works for both new-style shadows and SVG shadows.
&gt; &gt; 
&gt; &gt; No it doesn&apos;t; look at the definition of isShadowRoot.
&gt; 
&gt; That definition has changed since I made the comment! 

Can you point to when it changed? I don&apos;t think it has.

&gt; And I wonder if we haven&apos;t introduced a bug here:

If there a bug, it was probably introduced in this revision: &lt;http://trac.webkit.org/changeset/84225&gt; so maybe we should re-review that.

&gt; If I reconstruct this correctly, isInShadowTree is used in SVG at least by SVGTRefElement. This used to climb the tree looking for isShadowRoot, which used to be set for both SVG and new-style shadow roots. With the changes that isShadowRoot no longer applies for SVG and the shortcut introduced here, this is probably broken (?).

Yes, it looks broken to me. (Looks like I broke it.)</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>106525</attachid>
            <date>2011-09-06 17:39:52 -0700</date>
            <delta_ts>2011-10-24 13:40:41 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-67686-20110906173951.patch</filename>
            <type>text/plain</type>
            <size>1301</size>
            <attacher name="Adam Klein">adamk</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogOTQ2MTMKZGlmZiAtLWdpdCBhL1NvdXJjZS9XZWJDb3JlL0No
YW5nZUxvZyBiL1NvdXJjZS9XZWJDb3JlL0NoYW5nZUxvZwppbmRleCA4MmFlNWFiZjQ5YTU0MTE2
MTE5NWRlMWE3NDEwOWJmNmIzZGVmMTdmLi5lMDQ0Y2RmYTdjYjg2YzMyOTNiNWIxYTdjYzA3MmFl
ZTg2MjE3MzFlIDEwMDY0NAotLS0gYS9Tb3VyY2UvV2ViQ29yZS9DaGFuZ2VMb2cKKysrIGIvU291
cmNlL1dlYkNvcmUvQ2hhbmdlTG9nCkBAIC0xLDMgKzEsMTUgQEAKKzIwMTEtMDktMDYgIEFkYW0g
S2xlaW4gIDxhZGFta0BjaHJvbWl1bS5vcmc+CisKKyAg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