Skip to content

[css-ui] Outline rects of an inline #6981

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
emilio opened this issue Jan 24, 2022 · 4 comments
Open

[css-ui] Outline rects of an inline #6981

emilio opened this issue Jan 24, 2022 · 4 comments
Labels
css-ui-4 Current Work

Comments

@emilio
Copy link
Collaborator

emilio commented Jan 24, 2022

Context:

So given that browsers are agreeing now to draw the outline around the border area, not including descendants, except for this Blink special-case, can we spec outline rects finally?

I think I'd prefer agreeing on the Gecko + WebKit behavior, since it's consistent with borders and outlines on all other boxes.

@css-meeting-bot
Copy link
Member

The CSS Working Group just discussed [css-ui] Outline rects of an inline.

The full IRC log of that discussion <emeyer> Topic: [css-ui] Outline rects of an inline
<emeyer> Github: https://github.com//issues/6981
<emeyer> emilio: When you have an outline around inlines, the spec was ambiguous about what an outline should draw around. We’ve changed Gecko to match WebKit, but missed a case where Blink does something different.
<emeyer> …There is a special code path for outlines of inlines. Can we resolve on what outline actually does and fully spec it?
<smfr> i’d love to see some pictuers in the issue
<emeyer> iank_: Does this cover auto outlines?
<emeyer> …I think engines have different code paths.
<emeyer> emilio: How do they differ?
<emeyer> smfr: What I remember is we only respect border radius for auto outlines.
<Rossen_> q
<Rossen_> ack emilio
<emeyer> iank_: I believe things differ for auto versus non-auto. If you have an inline block, we do something different to capture more of the visual overflow.
<emeyer> …The special case we had for non-auto outlines, I agree our behavior looks broken for one of the cases on the issue.
<emeyer> smfr: I’d love to see these and web platform tests.
<emeyer> iank_: I’ll try to create test cases where everyone does different things. I’ll be reluctant to change the auto outline case because of accessibility, but the non-auto outline case is difficult because people often force the outlines to be different.
<emeyer> emilio: I find the auto versus non-auto distinction quite weird. It should be about whether the element is focused. If we want to have focus outlines versus non-focus outlines, that’s another topic. But documenting the differences would be great, so we can agree on behavior.
<emeyer> Rossen: let’s take this back to the issue and create as many test cases as we can. I’ll +1 smfr’s suggestion to make the test cases WPT test cases.

@astearns astearns removed the Agenda+ label Feb 22, 2022
@stylpe
Copy link

stylpe commented Mar 4, 2022

Came across this while experimenting with nice styling for multi-selectable cells in a sudoku grid. I made a demo here: https://observablehq.com/@supermikal/css-outline-rects-demo

The styles are a bit messy due to several iterations of trial and error, so it might not be a minimal repro but it's_something.jpg

Screenshot from Chrome for Android 98.0.4758.101:

Screenshot_20220304-212519

Firefox for Android 97.2.0 (Build #2015863827), fc8bbf84c+ :

Screenshot_20220304-213336

@MicahZoltu
Copy link

MicahZoltu commented Jan 29, 2023

As a web developer, the behavior of Blink is surprising to me here. When I draw outside of the border box for some reason, I expect outline to draw around the border box and not around the stuff I drew outside of that box. My (potentially incorrect) understanding of outline is that it is similar to a border, but it doesn't consume space (thus making it a good tool for hover/focus as it won't trigger reflow like adding a border will).

The situation that caused me to spend a couple hours debugging was something like this:

<style>
my-element {
  	outline: auto;
	outline-color: red;
	border: 1px solid blue;
	display: inline-flex;
	flex-direction: column;
}
my-element::after {
  	height: 0;
	content: 'words';
	visibility: hidden;
}
</style>
<my-element>More Text</my-element>

image

In this example note that the ::after is invisible to both the user and the layout engine, yet the outline encapsulates it on Chromium browsers.

A potential middle ground that would address this specific issue would be to treat visibility: hidden the same as overflow: hidden, which causes the outline to ignore the overflow. Even with this change, I still feel like this behavior would be surprising to developers, but not quite as surprising as having outlines of empty boxes.

@pols12
Copy link

pols12 commented Aug 11, 2024

You may find some screenshots for this issue in MediaWiki.

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

6 participants