<?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>17969</bug_id>
          
          <creation_ts>2008-03-20 11:35:04 -0700</creation_ts>
          <short_desc>Element onresize does not work</short_desc>
          <delta_ts>2022-07-21 17:01:57 -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>DOM</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>PC</rep_platform>
          <op_sys>OS X 10.5</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WONTFIX</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>HasReduction</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Erik Arvidsson">erik.arvidsson</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>ap</cc>
    
    <cc>arv</cc>
    
    <cc>bedney</cc>
    
    <cc>bfulgham</cc>
    
    <cc>lea</cc>
    
    <cc>rniwa</cc>
    
    <cc>webkit</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>74537</commentid>
    <comment_count>0</comment_count>
    <who name="Erik Arvidsson">erik.arvidsson</who>
    <bug_when>2008-03-20 11:35:04 -0700</bug_when>
    <thetext>When an element is resize (for whatever reason) it should fire a resize event.  This event is very important for creating reusable UI components that need to do js layout logic.

IE has had this event since version 4.

Test case coming up</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>74538</commentid>
    <comment_count>1</comment_count>
      <attachid>19900</attachid>
    <who name="Erik Arvidsson">erik.arvidsson</who>
    <bug_when>2008-03-20 11:36:19 -0700</bug_when>
    <thetext>Created attachment 19900
Resize the window to trigger the resize event</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>74545</commentid>
    <comment_count>2</comment_count>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2008-03-20 12:04:37 -0700</bug_when>
    <thetext>FF3 fails the attached test case.  Which means unless someone is going through the painful process of trying to right a &quot;next gen&quot; web application in IE7, I don&apos;t think they&apos;ll be using this event. :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115905</commentid>
    <comment_count>3</comment_count>
    <who name="William J. Edney">bedney</who>
    <bug_when>2009-03-30 15:06:47 -0700</bug_when>
    <thetext>Yes and Erik, to his credit, filed this bug there too... back in 2003...

https://bugzilla.mozilla.org/show_bug.cgi?id=227495

My mom taught me that two wrongs don&apos;t make a right :-).

Seriously, this capability (the ability to observe size changes at an element level - i.e. as various CSS rules come into and go out of effect), is crucial to doing web-based UI components without resorting to &apos;JS monitors&apos;.

At minimum, this bug shouldn&apos;t be left as &apos;unconfirmed&apos; when it clearly has been confirmed.

Cheers,

- Bill</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115907</commentid>
    <comment_count>4</comment_count>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2009-03-30 15:12:50 -0700</bug_when>
    <thetext>We don&apos;t follow bugzilla&apos;s arbitrary conventions very closely here in WebKit land. :)

In order to fix this, we need to know *what* onresize is supposed to do?  When should it fire?  Synchronously with the resize?  After all resizes have happened?  Does it bubble?  I assume that addEventListener(&quot;resize&quot;) is supposed to work too.

Someone effectively needs to write a little mini spec, and associated test cases, if we&apos;re going to be able to fix this.  Until we know what exact behavior we&apos;re supposed to add, it&apos;s hard to write the code. :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115913</commentid>
    <comment_count>5</comment_count>
    <who name="William J. Edney">bedney</who>
    <bug_when>2009-03-30 15:27:06 -0700</bug_when>
    <thetext>Eric -

Thanks for the quick reply!

A comment from the Mozilla bug report states that the &apos;resize&apos; event is documented in the DOM Level 3 events spec. And so it is:

http://www.w3.org/TR/DOM-Level-3-Events/events.html#event-resize

Looks like its not cancelable, it bubbles and can be targeted at a Document or Element.

Since its a DOM event, I would assume that the &apos;addEventListener(&quot;resize&quot;, ..., ...)&apos; syntax should work.

In so far as how it actually gets fired, that&apos;s not specified. As a JS programmer who&apos;s not a C/Webkit guy ;-), I guess it would depend on how the Webkit engine is structured. I know that sitting on my side of the fence, my expectation would be that all &apos;resize&apos; events get queued until the reflow is complete. But then my handlers would be invoked before painting/blitting such that I can resize other elements thereby recursing back into the engine . That is a totally WAG (wide a**ed guess and others with *much* more experience than I may want to chime in here... hint hint :-) ).

Of course, the potential exists here for folks in my world (JS) to write handlers that then try to resize the target element that just got resized, thereby setting up an infinite loop... but then again, that&apos;s their problem.

If you feel like you need more detail, I&apos;d be willing to write some tests here to &apos;document&apos; IE&apos;s current behavior and let that drive a mini-spec of some sort. Maybe Arv has some more to add here.

Cheers,

- Bill</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>115917</commentid>
    <comment_count>6</comment_count>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2009-03-30 15:37:21 -0700</bug_when>
    <thetext>Interesting, I did not realize there was any spec-work around a resize event.  The spec sure doesn&apos;t have much to say about it. :)  But it does look like something that we could consider supporting.

Every RenderObject::layout() implementation would have to notify the document that a resize of the corresponding node had occurred.  A list would be kept by the Document, and then from that list, events would be dispatched after the layout() had occurred.

One question would be what the behavior of the list should be if a resize is triggered during a resize js handler (set some size property and then trigger a layout).  I assume it should be a FIFO queue and that the remaining resize events from the previous resize should be fired before the new ones are.  But maybe the queue should just be cleared on any new layout?

Either way, it looks like even though there is some minor specwork, there is no testing, or exploration of the various edge conditions. ;)  Something any implementor would have to explore.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>116134</commentid>
    <comment_count>7</comment_count>
    <who name="Erik Arvidsson">erik.arvidsson</who>
    <bug_when>2009-03-31 20:45:50 -0700</bug_when>
    <thetext>I&apos;m pretty sure that resize events do not bubble in IE.

I&apos;m willing to write a mini design doc for this that covers how IE works.

I think it is important to make sure that we can minimize the work needed to do this. For example, it might make more sense to fire the event when we know that the element will change size but before we complete the reflow so that we do not do unnecessary reflows if the size changes due to the event handler.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>524435</commentid>
    <comment_count>8</comment_count>
    <who name="Lea Verou">lea</who>
    <bug_when>2011-12-19 21:55:12 -0800</bug_when>
    <thetext>What&apos;s the progress of this bug?

If I&apos;m interpreting the DOM3 Events spec correctly, it should also fire on every element, when resized by the user due to the CSS resize property. It doesn&apos;t.

Testcase: http://dabblet.com/result/gist/1498895</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1885861</commentid>
    <comment_count>9</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2022-07-21 16:02:33 -0700</bug_when>
    <thetext>I think it was only present in the IE and all other browser now moved to - Resize Observer API - https://github.com/WICG/resize-observer &amp; https://www.w3.org/TR/resize-observer/

Attached test case and test case from Comment 08 does not work in Safari 15.6, Chrome Canary 105 and Firefox Nightly 104. I think this can be closed, if I am not mistaken. Please ignore my comment, if I am wrong. Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1885874</commentid>
    <comment_count>10</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2022-07-21 17:01:57 -0700</bug_when>
    <thetext>Yeah, this is won&apos;t fix. Use ResizeObserver instead.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>19900</attachid>
            <date>2008-03-20 11:36:19 -0700</date>
            <delta_ts>2008-03-20 11:36:19 -0700</delta_ts>
            <desc>Resize the window to trigger the resize event</desc>
            <filename>onresize.html</filename>
            <type>text/html</type>
            <size>428</size>
            <attacher name="Erik Arvidsson">erik.arvidsson</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+CjxodG1sPgo8aGVhZD4KPHRpdGxlPk9ucmVzaXplIHRlc3Q8L3RpdGxl
Pgo8c3R5bGU+CgojdGVzdCB7CiAgcG9zaXRpb246IGFic29sdXRlOwogIHdpZHRoOiA1MCU7CiAg
aGVpZ2h0OiA1MCU7CiAgYmFja2dyb3VuZC1jb2xvcjogI2RkZDsKfQoKPC9zdHlsZT4KPHNjcmlw
dD4KCndpbmRvdy5vbmxvYWQgPSBmdW5jdGlvbigpIHsKICB2YXIgZWwgPSBkb2N1bWVudC5nZXRF
bGVtZW50QnlJZCgndGVzdCcpOwogIGVsLm9ucmVzaXplID0gZnVuY3Rpb24oKSB7CiAgICBlbC5p
bm5lckhUTUwgPSBlbC5vZmZzZXRXaWR0aCArICd4JyArIGVsLm9mZnNldEhlaWdodDsKICB9Owp9
Cgo8L3NjcmlwdD4KPC9oZWFkPgo8Ym9keT4KCjxkaXYgaWQ9dGVzdD5ObyByZXNpemUgZXZlbnRz
IHlldC48L2Rpdj4KCjwvYm9keT4KPC9odG1sPgo=
</data>

          </attachment>
      

    </bug>

</bugzilla>