Hang when going up the offsetParent-path

RESOLVED DUPLICATE of bug 13350

Status

()

Core
DOM: Core & HTML
--
critical
RESOLVED DUPLICATE of bug 13350
16 years ago
10 years ago

People

(Reporter: Arthur, Assigned: jst)

Tracking

Trunk
x86
Linux
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

(Reporter)

Description

16 years ago
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.8) Gecko/20020204
BuildID:    2002020415

Trying to write my first piece of JavaScript I've hung mozilla: I'm trying to
calculate the absolute position of an element and therefore I'm adding up all
the offsetLeft and offsetTop values belonging to all offsetParents of the
element (I've no idea whether this is the right way to do this). This seems to
hang mozilla with a high CPU load. I've stripped down the testcase a bit.

Reproducible: Always
Steps to Reproduce:
1.Go to the testcase.
2.Move the mouse over the given link


Actual Results:  Mozilla gets irresponsive

Expected Results:  Stay responsive, give me a chance to debug my code :)

Comment 1

16 years ago
it's in an infinite loop within findPosY
shouldn't it be:

64     obje = obje.obj.offsetParent

?

you can use the JavaScript debugger to debug this. just set breakpoints before
it hangs in your code, and then step (into) through it.

Comment 2

16 years ago
Browser, not engine ---> DOM Level 0
Assignee: rogerl → jst
Component: JavaScript Engine → DOM Level 0
QA Contact: pschwartau → desale

Comment 3

16 years ago
I agree with Andrew; this causes an infinite loop in findPosY:

 while (obje.obj.offsetParent)
 {
   curtop += obje.obj.offsetTop;
   obj = obje.obj.offsetParent;
 }

The test condition |obje.obj.offsetParent| is not being altered
in any way inside the loop, so the loop is never going to end...

Similarly for findPosX. Marking Invalid; sorry - 
Status: UNCONFIRMED → RESOLVED
Last Resolved: 16 years ago
Resolution: --- → INVALID

Comment 4

16 years ago
More detail on the above:

In looking through your code, note that the incoming parameter
|obje| has a property called "obj". That is, |obje.obj| is defined.

However, your assignment in the body of the loop says 

              obj = obje.obj.offsetParent;

What you are doing by this is defining a NEW variable |obj|, even
though the |var| keyword has not been used. Thus we now have TWO 
indpendent things: |obje.obj| and |obj|. That is why the assignment
above does nothing to affect the test condition |obje.obj.offsetParent|.

As Andrew suggested, you probably meant to do this instead:

              obje = obje.obj.offsetParent
(Reporter)

Comment 5

16 years ago
Thank's for your help. I duplicate the bug to bug 13350. A hang is after all a
bug. Staying responsive would be very nice in many circumstances.
(Reporter)

Comment 6

16 years ago
Reopening in order to duplicate.
Status: RESOLVED → UNCONFIRMED
Resolution: INVALID → ---
(Reporter)

Comment 7

16 years ago

*** This bug has been marked as a duplicate of 13350 ***
Status: UNCONFIRMED → RESOLVED
Last Resolved: 16 years ago16 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.