Skip to content

[css-ui][css-background] should clarify outline drawing behavior for boxes with negative sizes #2892

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
dbaron opened this issue Jul 6, 2018 · 6 comments
Labels
css-ui-4 Current Work

Comments

@dbaron
Copy link
Member

dbaron commented Jul 6, 2018

https://twitter.com/Martijn_Cuppens/status/1015169981368225793 points out lack of interoperability with the following style:

div {
  margin: auto;
  width: 100px;
  height: 100px;
  outline: inset 100px green;
  outline-offset: -125px;
}

This is creating a 100px×100px box, and then offsetting its outline by -125px, which creates an outline whose inner edge is a box that's a -150px×-150px rectangle and whose outer edge is a 50px×50px rectangle.

Quoting the tweet's image:
Screenshots

The behavior of this case (outlines drawn over a rectangle that has negative sizes) should probably be better defined so that browsers can become more interoperable here.

@dbaron dbaron added css-backgrounds-3 Current Work css-ui-4 Current Work labels Jul 6, 2018
@frivoal
Copy link
Collaborator

frivoal commented Jul 7, 2018

Right. At the moment, large negative offsets on outline are mostly a form of interpretive art, with the browser, not the author, doing the interpretation. As the picture from the tweet illustrates, it can be very pretty and highly creative, but interoperable it isn't.

The CSS-UI has some minimal "SHOULD" constraints to try and keep it vaguely sane (roughly, to prevent disappearing outlines with extremely large negative offsets), but even that isn't reliably followed yet. We have a test in the test suite that's almost as creative in rendering as that tweet:

http://test.csswg.org/suites/css-ui-3_dev/nightly-unstable/html/outline-016.htm

It should be a green square, but
screenshot 2018-07-07 12 42 49

(This test case needs the Ahem font to be installed)

@frivoal
Copy link
Collaborator

frivoal commented Jul 7, 2018

(note: this question of interop on outlines relates to #2846: even though we're considering different aspects of the outline, both raise the question of how much we should define)

@tomhodgins
Copy link

(these are unexpectedly beautiful)

@frivoal
Copy link
Collaborator

frivoal commented Jul 7, 2018

Just one more, because it's fun to let browsers go wild with lack of interop:
https://codepen.io/frivoal/pen/vroNqm

screenshot 2018-07-07 18 48 30

@tabatkins
Copy link
Member

I'll note also that the paragraph applying the SHOULD here doesn't seem to read coherently to me:

Both the height and the width of outside of the shape drawn by the outline should not become smaller than twice the computed value of the outline-width property,

I can't quite parse this.

@tabatkins
Copy link
Member

Can we just upgrade that to:

If the value is negative, its actual value must be clamped so that the absolute value of the offset is no more than half the width or height of the border box, as appropriate. The clamping should apply in both axises independently.

That way there's no self-intersecting outlines; at worst, the outline starts from the center of the element and grows outward from there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css-ui-4 Current Work
Projects
None yet
Development

No branches or pull requests

5 participants