servo: Border Rendering fails on simple scaling

Describe the bug: Some border edges not displayed when zoomed out under some percentage (Threshold varies depending on screen resolution. For me it is 100%).
Same behaviour in Firefox and Servo. But Chrome/Edge does this correctly.

To Reproduce: Open following page in Firefox/Servo. May need zoom out.

<!DOCTYPE html>

<head>
    <title>Border Radius Test</title>
    <style>
        .hi {
            height: 1.6875rem;
            line-height: 1.6875rem;
            text-align: center;

            color: #333;
            padding: 0 .625rem;
            display: inline-block;

            background: #fff;
            position: relative;
        }

        .hi::after {
            content: "";
            width: 200%;
            height: 200%;
            position: absolute;
            top: 0;
            left: 0;
            -webkit-transform: scale(.5);
            transform: scale(.5);
            -webkit-transform-origin: 0 0;
            transform-origin: 0 0;
            box-sizing: border-box;

            border: 1px solid #999;

        }
    </style>
</head>

<body>
    <span class="hi">Hi All!</span>
</body>

</html>

Platform: Any

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 16 (15 by maintainers)

Most upvoted comments

But it still doesn’t have this problem after transform: scale(.01).

I see no border at all with that. I see a grey border with transform: scale(.1).

Anyways, this seems to be a webrender thing, so changing the behavior should be done upstream in Firefox.

I think it is indeed a bug, after further investigation.

<!DOCTYPE html>
<div style="transform: scale(.5); border: 1px solid; height: 100px; width: 100px"></div>

I tested on Firefox, the computed value of each border width is always >0.54px with whatever zoom. (And scale actually does not change computed border width). But the left/upper edge still disappears below 120% Zoom.

This is further confirmed by following debug print of Fragment Tree. The border rectangle of <div> is 101.333px * 101.333px, no matter whether you scale or not. This is not enough, as we need 102px * 102px.

┌ Fragment Tree
│  ├─ Box
│  │         base=BaseFragment { tag: Some(Tag { node: OpaqueNode(51970346156368), pseudo: None }), flags: FragmentFlags(0x0) }
│  │         content=Rect(1024pxx117.33333333333333px at (0px, 0px))
│  │         padding rect=Rect(1024pxx117.33333333333333px at (0px, 0px))
│  │         border rect=Rect(1024pxx117.33333333333333px at (0px, 0px))
│  │         margin=(0px,0px,0px,0px)
│  │         clearance=None
│  │         scrollable_overflow=Rect(1024pxx117.33333333333333px at (0px, 0px))
│  │         baselines=Baselines { first: None, last: None }
│  │         overflow=AxesOverflow { x: Visible, y: Visible }
│  │  ├─ Box
│  │  │         base=BaseFragment { tag: Some(Tag { node: OpaqueNode(51970346156448), pseudo: None }), flags: FragmentFlags(IS_BODY_ELEMENT_OF_HTML_ELEMENT_ROOT) }
│  │  │         content=Rect(1008pxx101.33333333333333px at (8px, 8px))
│  │  │         padding rect=Rect(1008pxx101.33333333333333px at (8px, 8px))
│  │  │         border rect=Rect(1008pxx101.33333333333333px at (8px, 8px))
│  │  │         margin=(8px,8px,8px,8px)
│  │  │         clearance=None
│  │  │         scrollable_overflow=Rect(1008pxx101.33333333333333px at (8px, 8px))
│  │  │         baselines=Baselines { first: None, last: None }
│  │  │         overflow=AxesOverflow { x: Visible, y: Visible }
│  │  │  ├─ Box
│  │  │  │         base=BaseFragment { tag: Some(Tag { node: OpaqueNode(51970346156488), pseudo: None }), flags: FragmentFlags(0x0) }
│  │  │  │         content=Rect(100pxx100px at (0.6666666666666666px, 0.6666666666666666px))
│  │  │  │         padding rect=Rect(100pxx100px at (0.6666666666666666px, 0.6666666666666666px))
│  │  │  │         border rect=Rect(101.33333333333333pxx101.33333333333333px at (0px, 0px))
│  │  │  │         margin=(0px,0px,0px,0px)
│  │  │  │         clearance=None
│  │  │  │         scrollable_overflow=Rect(100pxx100px at (0.6666666666666666px, 0.6666666666666666px))
│  │  │  │         baselines=Baselines { first: None, last: None }
│  │  │  │         overflow=AxesOverflow { x: Visible, y: Visible }