Bug 14321

Summary: getComputedStyle(...).zIndex returns string "normal"
Product: WebKit Reporter: Adam Winer <awiner>
Component: DOMAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Major CC: mitz, sam
Priority: P2 Keywords: HasReduction, InRadar
Version: 523.x (Safari 3)   
Hardware: All   
OS: All   
Attachments:
Description Flags
Test case
none
patch
mitz: review-
updated patch mitz: review+

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.