RESOLVED FIXED 198230
[css-overflow] Implement clip value for overflow
https://bugs.webkit.org/show_bug.cgi?id=198230
Summary [css-overflow] Implement clip value for overflow
jonjohnjohnson
Reported 2019-05-24 13:46:45 PDT
See spec: https://www.w3.org/TR/css-overflow-3/#valdef-overflow-clip See geckos ticket for implementing and renaming "-moz-hidden-unscrollable" value: https://bugzilla.mozilla.org/show_bug.cgi?id=1531609 See contentious posSticky/overflow csswg ticket that would be be cleared up: https://github.com/w3c/csswg-drafts/issues/865 I'm surprised this wasn't already filed, but guessing @smfr (simon fraser) already has a bunch of thoughts on how troublesome this could be in webkit.
Attachments
Patch (16.31 KB, patch)
2021-07-09 07:08 PDT, Rob Buis
no flags
Patch (22.17 KB, patch)
2021-07-11 06:19 PDT, Rob Buis
no flags
Patch (30.04 KB, patch)
2021-07-12 05:40 PDT, Rob Buis
no flags
Patch (31.21 KB, patch)
2021-07-12 06:57 PDT, Rob Buis
ews-feeder: commit-queue-
Patch (29.37 KB, patch)
2021-07-12 09:03 PDT, Rob Buis
no flags
Patch (31.01 KB, patch)
2021-07-14 02:30 PDT, Rob Buis
no flags
Patch (31.35 KB, patch)
2021-07-15 02:09 PDT, Rob Buis
no flags
Patch (33.49 KB, patch)
2021-07-15 09:28 PDT, Rob Buis
no flags
Patch (31.73 KB, patch)
2021-07-15 09:41 PDT, Rob Buis
no flags
Patch (31.40 KB, patch)
2021-07-15 12:03 PDT, Rob Buis
no flags
Patch (31.93 KB, patch)
2021-07-29 10:46 PDT, Rob Buis
no flags
Patch (31.94 KB, patch)
2021-07-29 20:23 PDT, Rob Buis
no flags
Patch (35.28 KB, patch)
2021-07-30 01:45 PDT, Rob Buis
no flags
Patch (35.51 KB, patch)
2021-07-30 22:02 PDT, Rob Buis
no flags
Radar WebKit Bug Importer
Comment 1 2019-08-16 15:46:15 PDT
Kai
Comment 2 2021-03-15 10:35:43 PDT
The clip value is coming with Chrome 90, Safari is the last one missing: - https://caniuse.com/mdn-css_properties_overflow_clip - https://developer.mozilla.org/en-US/docs/Web/CSS/overflow#browser_compatibility - https://www.chromestatus.com/feature/5638444178997248 - https://caniuse.com/css-overflow (PR to update is pending) Maybe since it's in blink now a port could be easier than matching gecko?
Simon Fraser (smfr)
Comment 3 2021-03-15 11:10:44 PDT
Code has diverged enough that porting changes like this is hard (and we don't always agree which how things are implemented in Blink).
Rob Buis
Comment 4 2021-07-09 07:08:46 PDT
Rob Buis
Comment 5 2021-07-11 06:19:37 PDT
Rob Buis
Comment 6 2021-07-12 05:40:29 PDT
Rob Buis
Comment 7 2021-07-12 06:57:32 PDT
Rob Buis
Comment 8 2021-07-12 09:03:43 PDT
Simon Fraser (smfr)
Comment 9 2021-07-12 10:38:23 PDT
Comment on attachment 433324 [details] Patch Please do the isScrollContainer() rename in a separate patch.
Rob Buis
Comment 10 2021-07-13 07:53:25 PDT
(In reply to Simon Fraser (smfr) from comment #9) > Comment on attachment 433324 [details] > Patch > > Please do the isScrollContainer() rename in a separate patch. Sure, I created https://bugs.webkit.org/show_bug.cgi?id=227899 for this.
Rob Buis
Comment 11 2021-07-14 02:30:13 PDT
Rob Buis
Comment 12 2021-07-15 02:09:00 PDT
Rob Buis
Comment 13 2021-07-15 09:28:01 PDT
EWS Watchlist
Comment 14 2021-07-15 09:28:51 PDT
This patch modifies the imported WPT tests. Please ensure that any changes on the tests (not coming from a WPT import) are exported to WPT. Please see https://trac.webkit.org/wiki/WPTExportProcess
Rob Buis
Comment 15 2021-07-15 09:41:27 PDT
Simon Fraser (smfr)
Comment 16 2021-07-15 09:54:39 PDT
Comment on attachment 433592 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=433592&action=review Do we need any requiresLayer()/RenderLayerScrollableArea changes for this? > Source/WebCore/css/CSSProperties.json:3635 > + "clip" Move "clip" to after "hidden" > Source/WebCore/css/CSSProperties.json:3650 > + "clip" Move "clip" to after "hidden" > Source/WebCore/page/FrameView.cpp:652 > + case Overflow::Clip: Do we allow programmatic scrolling for an "overflow:clip" viewport? Should we? > Source/WebCore/rendering/style/RenderStyleConstants.h:282 > + Clip Move "Clip" to after "Hidden" > Source/WebCore/style/StyleAdjuster.cpp:430 > + if (style.overflowY() != Overflow::Visible && style.overflowY() != Overflow::Clip) { > + if (style.overflowX() == Overflow::Visible) { > + // FIXME: Once we implement pagination controls, overflow-x should default to hidden > + // if overflow-y is set to -webkit-paged-x or -webkit-page-y. For now, we'll let it > + // default to auto so we can at least scroll through the pages. > + style.setOverflowX(Overflow::Auto); > + } else if (style.overflowX() == Overflow::Clip) > + style.setOverflowX(Overflow::Hidden); > + } else if (style.overflowX() != Overflow::Visible && style.overflowX() != Overflow::Clip) { > + if (style.overflowY() == Overflow::Visible) > + style.setOverflowY(Overflow::Auto); > + else if (style.overflowY() == Overflow::Clip) > + style.setOverflowY(Overflow::Hidden); > + } I feel like this could be simplified using a lambda that you call for each axis.
Rob Buis
Comment 17 2021-07-15 12:03:04 PDT
Rob Buis
Comment 18 2021-07-15 12:07:18 PDT
Comment on attachment 433592 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=433592&action=review >> Source/WebCore/css/CSSProperties.json:3635 >> + "clip" > > Move "clip" to after "hidden" Done. >> Source/WebCore/css/CSSProperties.json:3650 >> + "clip" > > Move "clip" to after "hidden" Done. >> Source/WebCore/page/FrameView.cpp:652 >> + case Overflow::Clip: > > Do we allow programmatic scrolling for an "overflow:clip" viewport? Should we? No the specification says we should not (https://drafts.csswg.org/css-overflow/#valdef-overflow-clip): " In addition, unlike overflow: hidden which still allows programmatic scrolling, overflow: clip forbids scrolling entirely" >> Source/WebCore/rendering/style/RenderStyleConstants.h:282 >> + Clip > > Move "Clip" to after "Hidden" Done. >> Source/WebCore/style/StyleAdjuster.cpp:430 >> + } > > I feel like this could be simplified using a lambda that you call for each axis. Done. Much nicer indeed!
Rob Buis
Comment 19 2021-07-15 12:08:15 PDT
(In reply to Simon Fraser (smfr) from comment #16) > Comment on attachment 433592 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=433592&action=review > > Do we need any requiresLayer()/RenderLayerScrollableArea changes for this? I do not think so.
Simon Fraser (smfr)
Comment 20 2021-07-15 12:19:57 PDT
(In reply to Rob Buis from comment #18) > Comment on attachment 433592 [details] > No the specification says we should not > (https://drafts.csswg.org/css-overflow/#valdef-overflow-clip): > " In addition, unlike overflow: hidden which still allows programmatic > scrolling, overflow: clip forbids scrolling entirely" Is that done in this patch? Does it work for macOS and iOS? Any tests for it?
Rob Buis
Comment 21 2021-07-15 13:04:34 PDT
(In reply to Simon Fraser (smfr) from comment #20) > (In reply to Rob Buis from comment #18) > > Comment on attachment 433592 [details] > > > No the specification says we should not > > (https://drafts.csswg.org/css-overflow/#valdef-overflow-clip): > > " In addition, unlike overflow: hidden which still allows programmatic > > scrolling, overflow: clip forbids scrolling entirely" > > Is that done in this patch? Does it work for macOS and iOS? Any tests for it? Yes, it is tested by overflow-clip-cant-scroll.html.
Rob Buis
Comment 22 2021-07-16 12:57:59 PDT
BTW does this need a runtime setting?
Darin Adler
Comment 23 2021-07-28 12:52:21 PDT
Comment on attachment 433607 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=433607&action=review > Source/WebCore/rendering/RenderObject.h:440 > + bool hasPotentiallyScrollableOverflow() const { return hasNonVisibleOverflow() && style().overflowX() != Overflow::Clip && style().overflowX() != Overflow::Visible; } Nothing in this name says "vertical scrolling"; it’s not obvious why it’s correct for this to check only overflowX.
Rob Buis
Comment 24 2021-07-29 07:21:08 PDT
(In reply to Darin Adler from comment #23) > Comment on attachment 433607 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=433607&action=review > > > Source/WebCore/rendering/RenderObject.h:440 > > + bool hasPotentiallyScrollableOverflow() const { return hasNonVisibleOverflow() && style().overflowX() != Overflow::Clip && style().overflowX() != Overflow::Visible; } > > Nothing in this name says "vertical scrolling"; it’s not obvious why it’s > correct for this to check only overflowX. Right that may not be obvious right away. The thing is, internally 'visible' for one overflow dimension always has a 'visible' or 'clip' value in the other dimension, similarly 'clip' for one overflow dimension always has a 'visible' or 'clip' value in the other dimension, StyleAdjuster makes sure of this. Given that, it is enough to test either overflow dimension that neither of these two values are present, i.e. it covers all possible visible/clip combinations.
Darin Adler
Comment 25 2021-07-29 10:34:26 PDT
(In reply to Rob Buis from comment #24) > (In reply to Darin Adler from comment #23) > > Nothing in this name says "vertical scrolling"; it’s not obvious why it’s > > correct for this to check only overflowX. > > Right that may not be obvious right away. The thing is, internally 'visible' > for one overflow dimension always has a 'visible' or 'clip' value in the > other dimension, similarly 'clip' for one overflow dimension always has a > 'visible' or 'clip' value in the other dimension, StyleAdjuster makes sure > of this. Given that, it is enough to test either overflow dimension that > neither of these two values are present, i.e. it covers all possible > visible/clip combinations. This is the kind of thing that we want to make clear with comments or function names. And don’t want it in this kind of super-terse single-line function. Helps make the code maintainable in the future. I like the idea of moving this function out of the class definition to the bottom of the file, and adding a quite terse and economical comment about why overflowX gives the answer for both directions. Or abstracting it away into another function if there is more than one place that uses the same technique. But if hasPotentiallyScrollableOverflow is the only place that is taking advantage of this, then that’s not important.
Rob Buis
Comment 26 2021-07-29 10:46:17 PDT
Rob Buis
Comment 27 2021-07-29 11:04:09 PDT
(In reply to Darin Adler from comment #25) > This is the kind of thing that we want to make clear with comments or > function names. And don’t want it in this kind of super-terse single-line > function. Helps make the code maintainable in the future. > > I like the idea of moving this function out of the class definition to the > bottom of the file, and adding a quite terse and economical comment about > why overflowX gives the answer for both directions. That makes sense. I did that in my new patch, hard to make the comment terse, but I tried :) > Or abstracting it away into another function if there is more than one place > that uses the same technique. But if hasPotentiallyScrollableOverflow is the > only place that is taking advantage of this, then that’s not important. Pretty sure it is the only place (so far).
Darin Adler
Comment 28 2021-07-29 12:59:00 PDT
Comment on attachment 434534 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=434534&action=review Looks good to me, but I am not a layout expert. We are doing this without a feature flag? > Source/WebCore/rendering/RenderObject.h:1193 > +// We only need to test one overflow dimension since 'visible' and 'clip' always get accompanied > +// with 'clip' or 'visible' in the other dimension (see Style::Adjuster::adjust). Small subtle point, but I’d put this comment inside the function, since it’s about how the function works, not how you use it.
Rob Buis
Comment 29 2021-07-29 20:23:42 PDT
Rob Buis
Comment 30 2021-07-30 01:45:09 PDT
Rob Buis
Comment 31 2021-07-30 07:32:00 PDT
(In reply to Darin Adler from comment #28) > Comment on attachment 434534 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=434534&action=review > > Looks good to me, but I am not a layout expert. > > We are doing this without a feature flag? Makes sense, I added a preference in the latest patch. > > Source/WebCore/rendering/RenderObject.h:1193 > > +// We only need to test one overflow dimension since 'visible' and 'clip' always get accompanied > > +// with 'clip' or 'visible' in the other dimension (see Style::Adjuster::adjust). > > Small subtle point, but I’d put this comment inside the function, since it’s > about how the function works, not how you use it. Sure, done.
Simon Fraser (smfr)
Comment 32 2021-07-30 10:51:18 PDT
Comment on attachment 434612 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=434612&action=review So where do we actually reap the performance rewards from overflow:clip? > Source/WebCore/style/StyleAdjuster.cpp:425 > + if (style.overflowY() != Overflow::Visible && style.overflowY() != Overflow::Clip) { I think the lambda could also include this test
Rob Buis
Comment 33 2021-07-30 22:02:21 PDT
EWS
Comment 34 2021-07-30 23:07:17 PDT
Committed r280509 (240141@main): <https://commits.webkit.org/240141@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 434689 [details].
Rob Buis
Comment 35 2021-08-02 13:27:55 PDT
(In reply to Simon Fraser (smfr) from comment #32) > Comment on attachment 434612 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=434612&action=review > > So where do we actually reap the performance rewards from overflow:clip? We should through contain: paint, which will rely on overflow: clip. I started on some performance tests for that (https://bugs.webkit.org/show_bug.cgi?id=228696), expect to get some numbers soon.
Arcady Goldmints-Orlov
Comment 36 2021-08-04 14:15:38 PDT
It appears that the imported/w3c/web-platform-tests/css/css-overflow/clip-006.html and imported/w3c/web-platform-tests/css/css-overflow/clip-007.html tests are failing on GTK and WPE since they were enabled by this change. For an example failure see: https://build.webkit.org/results/GTK-Linux-64-bit-Release-Tests/r280645%20(3061)/results.html All the other css-overflow tests that were unskipped by this change appear to be fine.
Rob Buis
Comment 37 2021-11-24 08:20:50 PST
I think this is a feature that can be enabled, what do people think? Note that contain: paint support is not relying on overflow: clip to function.
Rob Buis
Comment 38 2021-12-07 06:15:51 PST
ping?
Simon Fraser (smfr)
Comment 39 2022-02-01 15:13:46 PST
Yes, we should enable it by default. Please do so via a new bug.
Rob Buis
Comment 40 2022-02-02 04:02:20 PST
(In reply to Simon Fraser (smfr) from comment #39) > Yes, we should enable it by default. Please do so via a new bug. Great! I made a new bug with patch here: https://bugs.webkit.org/show_bug.cgi?id=236008
Note You need to log in before you can comment on or make changes to this bug.