Bug 14321 - getComputedStyle(...).zIndex returns string "normal"
Summary: getComputedStyle(...).zIndex returns string "normal"
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 523.x (Safari 3)
Hardware: All All
: P2 Major
Assignee: Nobody
URL:
Keywords: HasReduction, InRadar
Depends on:
Blocks:
 
Reported: 2007-06-22 16:39 PDT by Adam Winer
Modified: 2007-06-24 13:54 PDT (History)
2 users (show)

See Also:


Attachments
Test case (378 bytes, text/html)
2007-06-23 11:10 PDT, David Kilzer (:ddkilzer)
no flags Details
patch (4.86 KB, patch)
2007-06-23 23:41 PDT, Sam Weinig
mitz: review-
Details | Formatted Diff | Diff
updated patch (4.72 KB, patch)
2007-06-23 23:54 PDT, Sam Weinig
mitz: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Winer 2007-06-22 16:39:23 PDT
In the following page, clicking on "Hi" shows
  Computed: normal element: 20
This is true both on 419.3/MacOS and 522.13.1/Windows.

On Firefox 2.0, it displays:
  Computed: 20 element: 20

Can't see where the string "normal" comes from, as legal values seem to be
"inherit", "auto", and integers.  "normal" shows whether or not the z-index
property is set.

<html>
<head>
<script>
function testHtml()
{
  var elem = document.getElementById('someId');
  var compStyle = elem.ownerDocument.defaultView.getComputedStyle(elem, null);
  alert("Computed:" + compStyle.zIndex + ", off element: " + elem.style.zIndex);

}
</script>
</head>
<body>
<div style="z-index:20" id ='someId' onclick="testHtml()">Hi</div>
</body>
</html>
Comment 1 David Kilzer (:ddkilzer) 2007-06-23 11:08:43 PDT
Confirmed with a local debug build of WebKit r23737 with Safari 3.0 (522.12) on Mac OS X 10.4.10 (8R218).

Note that this also occurs with Safari 2.0.4 (419.3) on Mac OS X 10.4.10 (8R218), so it is not a regression.

Both Opera 9.21 and Firefox 2.0.0.4 work as expected.

Comment 2 David Kilzer (:ddkilzer) 2007-06-23 11:10:43 PDT
Created attachment 15200 [details]
Test case

Please attach test cases to a bug in the future--makes them easier to test! :)
Comment 3 David Kilzer (:ddkilzer) 2007-06-23 11:11:35 PDT
<rdar://problem/5290095>
Comment 4 mitz 2007-06-23 12:27:45 PDT
Since the div is not positioned nor transparent, it actually renders as 'auto', so I don't think it should return '20'. That it returns 'normal' instead of auto looks like a simple typo in CSSComputedStyleDeclaration:

            if (style->hasAutoZIndex())
                return new CSSPrimitiveValue(CSS_VAL_NORMAL);

should be CSS_VAL_AUTO.
Comment 5 Sam Weinig 2007-06-23 23:41:03 PDT
Created attachment 15204 [details]
patch
Comment 6 mitz 2007-06-23 23:51:10 PDT
Comment on attachment 15204 [details]
patch

Code change looks fine, but please improve the logging function in the test as discussed on IRC.
Comment 7 Sam Weinig 2007-06-23 23:54:05 PDT
Created attachment 15205 [details]
updated patch
Comment 8 mitz 2007-06-23 23:58:18 PDT
Comment on attachment 15205 [details]
updated patch

r=me
Comment 9 Sam Weinig 2007-06-24 13:54:02 PDT
Landed in r23754.