Closed Bug 94855 Opened 23 years ago Closed 23 years ago

getComputedStyle; absolute and relative positioned elements

Categories

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

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla0.9.7

People

(Reporter: andorxor, Assigned: bzbarsky)

References

(Depends on 1 open bug)

Details

Attachments

(1 file)

I think the behaviour of Mozilla's implementation of DOM2's getComputedStyle is 
inconsistent.

Look at bug #93437 to read about the intended behaviour of getComputedStyle.

Presuming the following pseudo document:

<div id="layer1" style="position: absolute;">
  layer 1
  <div id="layer2" style="position: see below;">layer 2</div>
</div>

getComputedStyle will return the following values for layer2's "top"
property:
 - position set to "absolute":
        "top" relative to the containing block, ie. "top" relative to layer1

 - position set to "relative"
   or position set to "static":
         "top" relative to the viewport

If the position is set to "relative" shouldn't getComputedStyle return
zero?
If the position is set to "relative" shouldn't getComputedStyle return
"top" relative to where it would be if statically positioned?

Does the specified behaviour allow to findout the relative position of a 
statically positioned element with respect to its containing block
not using proprietary offsetLeft/Top properties)? [Missing feature?]
Attached file Testcase
Depends on: 84599
The computed value of 'top' for 'layer2' in the example quoted inline above
should be the distance from the top of 'layer2' when 'position' is 'absolute',
'0' when 'position' is 'relative', and 'auto' if 'position' is 'static' (since
if 'position' is 'static' then there is no computation to complete for 'top').
Status: UNCONFIRMED → NEW
Ever confirmed: true
Blocks: 42417
I'll take this; working on this stuff right now.
Assignee: jst → bzbarsky
OK. I've got some thoughts on a partial fix.  It will not be completely correct.
 To be precise, we will return incorrect values when auto margins/padding are
involved.  Fixing that would require hooks into layout which is bug 106154.

Other than that we should be able to get decent computed values. ETA a few
weeks, I would say.
Status: NEW → ASSIGNED
Depends on: 106154
Target Milestone: --- → mozilla0.9.7
Hooks into layout?  I want to move nsComputedDOMStyle back into layout one of
these days...
That would be awesome.  That's by far the most logical place for it to live
given the sort of things it needs access to.

As it is, I'll just be doing my own calculations for percentages, I guess.  And
fixing logic errors like bug 84599, of course.
Fixed with checkin for bug 84599.  Follow-up bug 109253 filed on coming up with
a spec and implementation of positioning properties for statically positioned
elements.
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: