Re: [csswg-drafts] [CSS2][CSSOM] Used value of margin properties (#2328)

This bit me while trying to implement an optimization in Firefox. Firefox returns what I think is the correct value in these test-cases:

<details>

```html
<!doctype html>
<style>
  .parent {
    width: 200px;
    height: 200px;
    background: purple;
  }
  .child {
    width: 10px;
    height: 10px;
    background: yellow;
  }
  .fixed-margins-b {
    margin-left: 10px;
    margin-right: 60px;
  }
  .fixed-margins-a {
    margin-right: 10px;
    margin-left: 60px;
  }
  .percent-margins-a {
    margin-right: 10px;
    margin-left: 30%;
  }
  .percent-margins-b {
    margin-left: 10px;
    margin-right: 30%;
  }
  .percent-margins-c {
    margin-right: 5%;
    margin-left: 30%;
  }
  .percent-margins-d {
    margin-left: 5%;
    margin-right: 30%;
  }
</style>
<div class="parent">
  <div class="child fixed-margins-a"></div>
</div>
<div class="parent">
  <div class="child fixed-margins-b"></div>
</div>
<div class="parent">
  <div class="child percent-margins-a"></div>
</div>
<div class="parent">
  <div class="child percent-margins-b"></div>
</div>
<div class="parent">
  <div class="child percent-margins-c"></div>
</div>
<div class="parent">
  <div class="child percent-margins-d"></div>
</div>
<pre>
<script>
  for (let element of document.querySelectorAll(".child")) {
    let cs = getComputedStyle(element);
    document.writeln(element.className + ": " + cs.marginLeft + " | " + cs.marginRight);
  }
</script>
</pre>
```

</details>

One WPT relies on us _not_ doing this, and returning the pixel value as-is. My patch "fixed" the WPT, but given this issue I think I'm going to keep our behavior untouched for now, and reference this issue from the code. Also maybe fix the WPT, which is a rather naive one that isn't testing this in particular (

-- 
GitHub Notification of comment by emilio
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/2328#issuecomment-517437931 using your GitHub account

Received on Thursday, 1 August 2019 20:06:29 UTC