[Webkit-unassigned] [Bug 17433] getComputedStyle() -> clip returns empty string

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Jul 16 10:42:36 PDT 2008


https://bugs.webkit.org/show_bug.cgi?id=17433


dhtmlkitchen at gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |




------- Comment #6 from dhtmlkitchen at gmail.com  2008-07-16 10:42 PDT -------
(In reply to comment #2)
> Created an attachment (id=21195)
 --> (https://bugs.webkit.org/attachment.cgi?id=21195&action=view) [edit]
> First attempt
> 
> So now we give a better CSSPrimitiveValue for the computed value of 'clip'.
> What is not completely clear to me is how to treat 'auto'. 

"rect(0, " + el.offsetWidth +", " + el.offsetHeight +", " + "0)"

> Right now it returns
> rect(0px, 0px, 0px, 0px), 

That's worse than returning an empty string. Before the "fix", if
computedStyle.clip was the empty string, it was logical to assume that the
value couldn't be read. Now it's impossible to tell what the actual computed
value is where as b. Is the element really clipped, or is this the result of a
bug 17433's "fix"?

> I would have expected something with at least a width
> and height, also no clipping can be seen. 

Of course.

> However if I specify rect(0px, 0px,
> 0px, 0px) explicitly, there is clipping. 

That seems to violate transivity.

> I don't see how a distinction is made
> between these two cases, and whether it is relevant for the computed value.
> Opera also returns what we return for auto, FF3 just returns 'auto'.

returning 'auto' is wrong. That is not the CSS 2.1 computed value for clip.

The computed value for clip is defined by css 2.1:
http://www.w3.org/TR/CSS21/visufx.html#clipping

| Computed value:       For rectangle values, a rectangle 
| consisting of four computed lengths; otherwise, as specified 

Returning all zeros, or "rect(0px, 0px, 0px, 0px)", is obviously inaccurate and
intransitive, as you noticed.

If the computedStyle.clip is all zeros, and is used to set el.style.clip, it
will result in the element being clipped. Obviously, the error is in the
computedStyle.clip incorrectly returning all zeros. This can be demonstrated by
an example:-

<!DOCTYPE HTML>
<html lang="en">
<head>
        <title>Clip Test</title>
</head>
<body>

<div style="position: absolute" id="el"
>will be clipped?</div>
<script>
var el = document.getElementById('el'),

  // Since readStyle.clip returns empty string in current Webkit, 
  // use a "mock" object.
        readStyle = {clip: "rect(0px, 0px, 0px, 0px)"}; 
        //readStyle = getComputedStyle(el,''),
    style = el.style;

alert(style.clip = readStyle.clip);
alert("getPropertyCSSValue('clip'): "
+getComputedStyle(el,'').getPropertyCSSValue('clip'));

</script>

</body>
</html>


To solve the problem, return a correct length. This is as simple as:-

"rect(0, " + el.offsetWidth +", " + el.offsetHeight +", " + "0)"


We can also see that 'getPropertyCSSValue' does not return a Rect for clip but
returns null instead. (Method  getPropertyCSSValue should also return the
correct computed lengths (not all zeros).)


There is a need for a determination between "absolute" value and "computed"
value in the DOM Style specs.

> 
> Rob.
> 


-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the webkit-unassigned mailing list