Closed Bug 35276 Opened 25 years ago Closed 25 years ago

offsetWidth/Height not in sync with style.width/height

Categories

(Core :: DOM: CSS Object Model, defect, P3)

x86
Windows 98
defect

Tracking

()

VERIFIED FIXED

People

(Reporter: joe, Assigned: jst)

Details

(Whiteboard: [HAVE FIX])

Attachments

(1 file)

Apparently the offsetWidth and offsetHeight properties are not updated synchronously whenever .style.width and .style.height are modified. This is a real problem because it essentially makes these properties meaningless. As a practical example, in a DHTML animation, if an element's size is constantly changing, and the script wants to rely on .offsetWidth and .offsetHeight to determine the current size, the obviously cannot do so. However, relying on the style properties is also not a good idea because you don't know if the element's size was set inline (and we don't have getComputedStyle() yet either, to find out the cascaded size).
Attached file see the bug in action
Status: UNCONFIRMED → NEW
Ever confirmed: true
Joe, could you test if adding user_pref("layout.reflow.async.afterDocLoad", false); to your prefs.js fixes this?
Adding that line to prefs.js does in fact fix the bug. Will this be a permanent addition to the code?
No, it will not, and it's not even possible to do that any more (or adding that line doesn't change anything any more). But it does confirm my theory tho so thanks for testing. The problem is that modifying the dom tells gecko to reflow the changed content but this is done asynchronously so if you ask for style.width immediately after you change something you probably won't see the changes. Now I just haveto figure out how to get arround this, we probably need to add code that flushes all pending reflows before returning style properties through the dom, I'll look into this...
Status: NEW → ASSIGNED
I've got a fix for this, I'll land it as soon as I can (tomorrow probably)...
Whiteboard: [HAVE FIX]
Target Milestone: --- → M16
The fix is checked in, marking FIXED.
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
Component: DOM Level 2 → DOM Style
Taking QA Contact on all open or unverified DOM Style bugs...
QA Contact: vidur → ian