<?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>32580</bug_id>
          
          <creation_ts>2009-12-15 14:26:30 -0800</creation_ts>
          <short_desc>JS Event listeners should not call Document::updateStyleForAllDocuments()</short_desc>
          <delta_ts>2010-03-04 21:18:19 -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 JavaScript</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>
          <dependson>32641</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="James Robinson">jamesr</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ap</cc>
    
    <cc>commit-queue</cc>
    
    <cc>darin</cc>
    
    <cc>dglazkov</cc>
    
    <cc>eric</cc>
    
    <cc>fishd</cc>
    
    <cc>hyatt</cc>
    
    <cc>webkit.review.bot</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>172038</commentid>
    <comment_count>0</comment_count>
    <who name="James Robinson">jamesr</who>
    <bug_when>2009-12-15 14:26:30 -0800</bug_when>
    <thetext>Currently whenever a JS event handler for a DOM event is fired at a document context a call to Document::updateStyleForAllDocuments() is made.  This used to be necessary since many parts of the codebase would assume styles were up to date and there was no useful way to defer the style updates, but I believe this is no longer the case as all layout codepaths should be ensuring that styles are up to date.

This is really bad for pages that register DOM mutation event listeners since styles are updated on every DOM mutation.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>172044</commentid>
    <comment_count>1</comment_count>
      <attachid>44911</attachid>
    <who name="James Robinson">jamesr</who>
    <bug_when>2009-12-15 14:32:56 -0800</bug_when>
    <thetext>Created attachment 44911
Removes the calls to Document::updateStyleForAllDocuments() in event dispatch code

This patch just deletes the calls for both the JSC and V8 bindings.  This does not regress any layout tests (including pixel tests) so I believe it is correct.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>172046</commentid>
    <comment_count>2</comment_count>
    <who name="WebKit Review Bot">webkit.review.bot</who>
    <bug_when>2009-12-15 14:34:00 -0800</bug_when>
    <thetext>style-queue ran check-webkit-style on attachment 44911 without any errors.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>172047</commentid>
    <comment_count>3</comment_count>
      <attachid>44911</attachid>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2009-12-15 14:35:24 -0800</bug_when>
    <thetext>Comment on attachment 44911
Removes the calls to Document::updateStyleForAllDocuments() in event dispatch code

I would agree, this seems like a bug.  We should get the original author of these lines to confirm as such though. :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>172048</commentid>
    <comment_count>4</comment_count>
      <attachid>44911</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2009-12-15 14:35:54 -0800</bug_when>
    <thetext>Comment on attachment 44911
Removes the calls to Document::updateStyleForAllDocuments() in event dispatch code

I see how this is bad for performance. But I suspect that removing this call is wrong for correctness. It&apos;s entirely possible that a script changes something that triggers a style change and there is no other mechanism to guarantee the style change happens.

We need to replace this mechanism with a better one, but just ripping this code out is probably wrong. We&apos;ll need to construct a test case to demonstrate this.

I hope I&apos;m wrong. I&apos;m not saying review- because I&apos;m not sure. Hyatt might know better.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>172054</commentid>
    <comment_count>5</comment_count>
    <who name="James Robinson">jamesr</who>
    <bug_when>2009-12-15 14:53:27 -0800</bug_when>
    <thetext>Thanks for the feedback Darin.  This is basically a continuation of http://trac.webkit.org/changeset/42384 (which sadly doesn&apos;t seem to have an associated bugzilla bug).  I think any code that queries properties derived from styles without making sure styles are up to date is wrong and should be fixed.  I&apos;m not sure if there is any code that does that currently - if there is then the layout tests do not seem to be hitting it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>172512</commentid>
    <comment_count>6</comment_count>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2009-12-16 13:26:43 -0800</bug_when>
    <thetext>The important quote there being &quot;For now in order to reduce the risk of regressions, I have left in all the synchronous machinery for updating style following DOM events and JavaScript timeouts. Eventually these calls will be removed.&quot; - Dave Hyatt.

I&apos;m ready to r+ this based on the comments above and hyatt&apos;s comments in http://trac.webkit.org/changeset/42384, but I agree, it would be nice to see Hyatt&apos;s stamp on this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>172585</commentid>
    <comment_count>7</comment_count>
    <who name="James Robinson">jamesr</who>
    <bug_when>2009-12-16 16:49:53 -0800</bug_when>
    <thetext>https://bugs.webkit.org/show_bug.cgi?id=32641 is one case where this patch could cause a regression.  This patch only removes the call from the individual dispatches - i.e. between multiple event handlers on the same event, so it doesn&apos;t cause a layout test regression currently.  However, the logical next thing to do is to remove the call from Node::dispatchGenericEvent which would break fast/forms/HTMLOptionElement-selected.html.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>173900</commentid>
    <comment_count>8</comment_count>
      <attachid>44911</attachid>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2009-12-21 00:20:43 -0800</bug_when>
    <thetext>Comment on attachment 44911
Removes the calls to Document::updateStyleForAllDocuments() in event dispatch code

I don&apos;t see how this patch can be up for review with the other bug depending on this one.  I&apos;m ready to r+ this (I think part of the only way to figure this out is to land it and wathc for regressions), but an r+ is not possible until bug 32641 is fixed.

Clearing review flag.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>188540</commentid>
    <comment_count>9</comment_count>
      <attachid>44911</attachid>
    <who name="Adam Barth">abarth</who>
    <bug_when>2010-02-07 18:48:14 -0800</bug_when>
    <thetext>Comment on attachment 44911
Removes the calls to Document::updateStyleForAllDocuments() in event dispatch code

Re-nominating fore review.  It looks like the blocking bug has been fixed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>188544</commentid>
    <comment_count>10</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2010-02-07 20:07:29 -0800</bug_when>
    <thetext>Hyatt, can we do this now or not?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>188545</commentid>
    <comment_count>11</comment_count>
    <who name="James Robinson">jamesr</who>
    <bug_when>2010-02-07 20:12:13 -0800</bug_when>
    <thetext>The forms code still depends on style recalcs to update internal state, so we can&apos;t remove _all_ of the Document::updateStyleForAllDocuments() calls.  I think this one is safe to remove, since the call at the end of Node::dispatchGenericEvents() will still ensure that everything is up to date before anything outside of the event dispatching code runs.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>188548</commentid>
    <comment_count>12</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2010-02-07 20:58:48 -0800</bug_when>
    <thetext>(In reply to comment #11)
&gt; The forms code still depends on style recalcs to update internal state, so we
&gt; can&apos;t remove _all_ of the Document::updateStyleForAllDocuments() calls.

Really? Doesn&apos;t the style recalc timer take care of that case?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>190367</commentid>
    <comment_count>13</comment_count>
    <who name="James Robinson">jamesr</who>
    <bug_when>2010-02-14 20:00:13 -0800</bug_when>
    <thetext>No, because recalcStyle() has side effects other than updating styles.  For instance. HTMLFormControl::recalcStyle() enqueues a call to the virtual RenderObject::updateFromElement() function.  Several overrides of this (RenderMenuList::updateFromElement, RenderListBox::updateFromElement) cause updates within the DOM like updating selected state, etc.

What happens in most tests currently is:

1.) The parser creates some DOM structure
2.) DOMContentLoaded fires, which calls Document::updateStyleForAllDocuments(), which forces pending updates to occur.
3.) The test code runs in the body&apos;s onload handler.
4.) The style time fires.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>191244</commentid>
    <comment_count>14</comment_count>
      <attachid>44911</attachid>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2010-02-17 15:07:36 -0800</bug_when>
    <thetext>Comment on attachment 44911
Removes the calls to Document::updateStyleForAllDocuments() in event dispatch code

Looks OK to me.  Would be nice to see a comment from Hyatt, but we can always back this out if it breaks things.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>196308</commentid>
    <comment_count>15</comment_count>
      <attachid>44911</attachid>
    <who name="Adam Barth">abarth</who>
    <bug_when>2010-03-04 19:10:35 -0800</bug_when>
    <thetext>Comment on attachment 44911
Removes the calls to Document::updateStyleForAllDocuments() in event dispatch code

Ready to land?  This has been sitting here for a while.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>196342</commentid>
    <comment_count>16</comment_count>
      <attachid>44911</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2010-03-04 21:18:13 -0800</bug_when>
    <thetext>Comment on attachment 44911
Removes the calls to Document::updateStyleForAllDocuments() in event dispatch code

Clearing flags on attachment: 44911

Committed r55568: &lt;http://trac.webkit.org/changeset/55568&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>196343</commentid>
    <comment_count>17</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2010-03-04 21:18:19 -0800</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>44911</attachid>
            <date>2009-12-15 14:32:56 -0800</date>
            <delta_ts>2010-03-04 21:18:13 -0800</delta_ts>
            <desc>Removes the calls to Document::updateStyleForAllDocuments() in event dispatch code</desc>
            <filename>update-styles.diff</filename>
            <type>text/plain</type>
            <size>1745</size>
            <attacher name="James Robinson">jamesr</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL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