Skip to content

workbench: don't nest rounded clips around the editor - #350107

Merged
Alexandru Dima (alexdima) merged 2 commits into
mainfrom
alexd/modern-ui-one-editor-clip
Nov 24, 2026
Merged

Alexandru Dima (alexdima) merged 2 commits into
mainfrom
alexd/modern-ui-one-editor-clip

Conversation

@alexdima

@alexdima Alexandru Dima (alexdima) commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

In short: the editor card already clips the editor to its rounded corners, and .content inside it clipped a second time to the very same curve. Chromium applies only one rounded clip per drawn tile, so for that nested pair it drew the editor offscreen first, on every scroll frame and keystroke. This change drops the inner rounded clip. The pixels stay the same (a few corner pixels change by 1/255). In the default layout, scroll frames and keystrokes then draw no render passes, and the GPU process spends about 0.4 ms less per scroll frame and 0.9 ms less per keystroke.

With Modern UI (the default), two rounded clips nest around the editor. The editor card in editorBorder.css rounds and clips the editor part, and floatingPanels.css also rounds the part's .content inside it. Since #349847 that inner curve is concentric: the card's radius less its stroke. That is the curve the card's own clip already follows, because overflow clips to the padding edge. So the second clip adds nothing visible, but it is costly. Chromium applies one rounded clip per draw quad, so for nested rounded clips Blink gives the outer clips render surfaces (property_tree_manager.cc: "Nested rounded corner clips need to force render surfaces for clips other than the leaf ones"). Each frame carried five offscreen render passes for the nested clips (the whole editor, its text area, the minimap, a one-line strip and the caret). On every frame that changes the editor (scrolling, typing), viz redrew about three of them, instead of handing the editor's layers to Core Animation.

This change leaves .content a square clip inside the card. On macOS with the status bar hidden, floatingPanels.css also rounded the content's window-facing bottom corners, with selectors more specific than the card rule. The same macOS rules give the card itself the window corner's radius, and the card clips its content to the curve inside its stroke, so this change drops those two content selectors and keeps the webview overlays'. The card rule then wins by specificity, without !important, which the CSS guidance doesn't allow (.github/skills/ux-css-layout/SKILL.md). Only the main editor part gets the floating-editor-outer-* classes, and only with Modern UI on, so the card always clips it.

The tests that #349847 added checked .content's own radius. They now check what the user sees:

  • the card clips its content (overflow: hidden);
  • the card's radius less its border width is the concentric radius;
  • .content rounds nothing of its own.

Their editor cards also get the stroke they have in the product. Without a border color, the card's border shorthand was invalid at computed-value time, so the test card had no border.

The rule first went into the GPU editor work (#336479), where it broke the tests that #349847 added; it moves here, with the tests updated.

Before / after

What changed: the card still rounds and clips the corners. .content inside it no longer clips to the same curve a second time.

0-what-changed

What it costs on main: each offscreen render pass in one scroll frame, outlined over the window. This change removes all of them in the default layout. With the status bar hidden on macOS, the card's own clip keeps five, because its corners differ (a separate change).

1-render-passes

What you see: the whole window in four layouts, old CSS against new. Magenta marks the pixels that differ: 8 by default, 18 with the status bar hidden, and none at a 4 px corner radius or at 120% zoom.

2-overview

The card's four corners zoomed 5×, the only places where pixels change, by at most 1/255 per channel:

3-corners-zoomed

Measurements

These are on main with the DOM editor, on an Apple M5 Pro at device pixel ratio 2 (Electron 43, load average about 11). One VS Code instance alternated the old and the new rule in rotating order. Times are the CPU time (tdur) of the GPU process's traced threads.

Nested clips (main) One clip (this PR) Paired difference Pairs agreeing
GPU process per scroll frame 1.44 ms 1.08 ms −0.39 ms 10/10
Render passes per scroll frame 2.95 0 10/10
GPU process per keystroke 2.66 ms 1.71 ms −0.85 ms 8/8
Render passes per keystroke 3.6 0 8/8
GPU process per scroll frame, macOS 26, status bar hidden 1.83 ms 1.65 ms −0.15 ms 8/8
Render passes per scroll frame, macOS 26, status bar hidden 7.5 3.8 8/8

With the status bar hidden on macOS, the remaining passes come from the card's own clip. Its window-facing corner is 12 px and the others are 8 px, and on macOS Blink masks a clip whose corners differ through a render surface, because Core Animation can't apply such corners (ShaderBasedRRect in the same file). That needs a separate change. In that layout, keeping floatingPanels.css's window-facing content radii leaves the passes at main's 7.5. The renderer's CPU time showed no consistent difference. The timings were measured on the first commit, which squared the content with !important. The second commit computes the same styles without it, and the render-pass dumps and screenshots above were taken on it: 5 offscreen passes become none by default, and 10 become 5 with the status bar hidden.

Screenshots of the whole window with the old and the new CSS, in one instance, differ in 8 of 5,017,600 device pixels, all on the card's bottom corner arcs, by at most 1/255 per channel. With the status bar hidden on macOS, 18 differ. At "editorArea.cornerRadius": 4 and at 120% zoom (device pixel ratio 2.4, a 0.83 px border), none differ. Repeated screenshots with the same CSS don't differ at all.

How to verify

  • Scroll an editor while tracing the viz and cc categories. With this change, frames that scroll draw no DirectRenderer::DrawRenderPass, and RenderSurfaceReasonCount reports no rounded corner surfaces. With the old rule, each frame has about three passes and five such surfaces.
  • To compare both rules in one window, add the old rule back in a style element: body .monaco-workbench.modern-ui .monaco-grid-view .part.editor:not(.modal-editor-part) > .content { border-radius: max(0px, calc(var(--vscode-editorArea-cornerRadius, var(--vscode-cornerRadius-large, 8px)) - var(--modern-ui-floating-card-stroke-width))) !important; }
  • Check that the editor card's corners look unchanged, including at a non-default editorArea.cornerRadius, at window zoom levels, and with the status bar hidden on macOS.

Tests

  • ./scripts/test.sh with --run for each of the seven test files that load floatingPanels.css (src/vs/workbench/services/layout/test/browser/layoutService.test.ts, src/vs/workbench/contrib/webview/test/browser/overlayWebview.test.ts, src/vs/workbench/services/themes/test/browser/workbenchSizeService.test.ts, src/vs/workbench/test/browser/parts/chat/chatHostPart.test.ts, src/vs/workbench/test/browser/parts/compositeBar.test.ts, src/vs/workbench/contrib/welcomeGettingStarted/test/browser/gettingStarted.test.ts, src/vs/workbench/contrib/modernUI/test/browser/modernUI.contribution.test.ts): 194 passing, 32 pending (the Getting Started focus tests skip in hidden Electron windows).
  • node test/unit/browser/index.js with the same seven --run files and --browser chromium: 225 passing, the focus outlines at macOS window corners included. On the first commit, the two edited test files also passed in --browser webkit (163 passing).
  • Without the card rule, 9 of these tests fail: the 7 WorkbenchSizeService size cases from 2 px up, and both ModernUIContribution editor tests.
  • npm run typecheck-client, node --experimental-strip-types build/hygiene.ts on the changed files, and node build/stylelint.ts on the CSS files: all pass.

tl;dr

Inside the editor card, which already clips to the curve, give .content a square clip instead of a second rounded one on the same curve. In the default layout, scroll frames and keystrokes on main then draw no render passes instead of about three, and the GPU process spends 0.39 ms less per scroll frame and 0.85 ms less per keystroke. The corners look the same.

🤖 Authored with GitHub Copilot on behalf of Alexandru Dima (@alexdima).

With Modern UI (the default), the editor card in editorBorder.css rounds and clips the editor
part, and floatingPanels.css also rounds the part's `.content` inside it. Since #349847 that
inner curve is concentric, the card's radius less its stroke, which is the curve the card's own
clip already follows: `overflow` clips to the padding edge. So the second clip adds nothing
visible, but it costs: Chromium applies one rounded clip per draw quad, so for nested rounded
clips Blink gives the outer clips render surfaces ("Nested rounded corner clips need to force
render surfaces for clips other than the leaf ones", property_tree_manager.cc). Every frame that
changes the editor drew about three render passes, two of them offscreen copies of the editor,
instead of handing the editor's layers to Core Animation.

Now only the card clips; `.content` keeps a square clip. `!important` also overrides the radii
that floatingPanels.css gives the content's window-facing corners on macOS when the status bar
is hidden, whose selectors are more specific; without it, the clips stay nested there.

The tests now check what the user sees: the card clips its content, its radius less its border
width is the concentric radius, and `.content` rounds nothing of its own. Their editor cards also
get the stroke they have in the product: without a border color, the card's `border` shorthand
was invalid and the card had no border.

Measured on main with the DOM editor, in one instance alternating the old and the new rule (CPU
time of the GPU process's traced threads, every pair agreeing):
- scrolling: 1.44 -> 1.08 ms per frame (paired difference -0.39 ms, 10 pairs); render passes
  drawn 2.95 -> 0 per frame
- typing: 2.66 -> 1.71 ms per keystroke (-0.85 ms, 8 pairs); render passes 3.6 -> 0
- scrolling on macOS 26 with the status bar hidden: 1.83 -> 1.65 ms per frame (-0.15 ms, 8
  pairs); render passes 7.5 -> 3.8. The rest come from the card itself: its window-facing corner
  is 12 px and the others 8 px, and on macOS Blink masks a clip whose corners differ through a
  render surface, because Core Animation can't apply them.
The renderer's CPU time showed no consistent difference.

How to verify:
- Scroll an editor under a trace of the `viz` and `cc` categories: with this change, frames that
  scroll draw no `DirectRenderer::DrawRenderPass`, and `RenderSurfaceReasonCount` reports no
  "rounded corner" surfaces; with the old rule, about three passes and five such surfaces a frame.
- Screenshots of the editor part with the old and the new rule differ in 8 of 4.45 M device
  pixels at DPR 2, on the corner arcs, by at most 1/255 per channel (18 of 4.6 M with the status
  bar hidden).
- `./scripts/test.sh --run src/vs/workbench/services/themes/test/browser/workbenchSizeService.test.ts --run src/vs/workbench/contrib/modernUI/test/browser/modernUI.contribution.test.ts`

🤖 Authored with GitHub Copilot on behalf of @alexdima.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 24, 2026 10:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new !important radius declarations violate CSS layout guidance and override normal state-specific rules rather than resolving the competing selectors.

1 open issue
What changed in this PR

Removes redundant rounded clipping inside Modern UI’s editor card to reduce offscreen rendering while preserving the card’s visible corners. This separates the workbench optimization from the optional GPU editor work.

Changes:

  • Makes editor content square-clipped, leaving rounded clipping to the outer card, including on macOS.
  • Updates regression tests to check the card’s clipping geometry and adds missing border colors to test fixtures.
  • Documents why nested rounded clips are avoided.
File Description
src/​vs/​workbench/​services/​themes/​test/​browser/​workbenchSizeService.test.ts Checks outer-card clipping and square content across radius and density settings.
src/​vs/​workbench/​contrib/​modernUI/​test/​browser/​modernUI.contribution.test.ts Updates clipping checks for zoom, compact layout, and macOS corners.
src/​vs/​workbench/​contrib/​modernUI/​README.md Explains clipping ownership and its rendering benefit.
src/​vs/​workbench/​contrib/​modernUI/​browser/​media/​editorBorder.css Removes the content’s redundant rounded clip.

Review effort: Balanced

The previous commit made the editor's `.content` square with `!important`, to outrank the
macOS rules in floatingPanels.css that round its window-facing bottom corners when the status
bar is hidden. The repository's CSS guidance doesn't allow new `!important` declarations
(`.github/skills/ux-css-layout/SKILL.md`, "Never Add New `!important`"), and a review flagged it.

Those two selectors are redundant inside the Modern UI editor card: the same macOS rules give
the card itself the window corner's radius, and the card clips its content to its padding edge,
the curve inside its stroke. Only the main editor part gets the `floating-editor-outer-*`
classes, and only with Modern UI on, so the card always clips it. Dropping them leaves the
webview overlays' window-facing corners as they were, and the card rule now wins over the other
`.content` radius rules by specificity alone.

The computed styles are the same as with the previous commit: `.content` is square everywhere,
and the card's clip has 11 px bottom corners at macOS window corners. So the measurements in
the previous commit still apply.

How to verify:
- `./scripts/test.sh` and `node test/unit/browser/index.js --browser chromium` with `--run` for
  each of the seven test files that load floatingPanels.css: `layoutService`, `overlayWebview`,
  `workbenchSizeService`, `chatHostPart`, `compositeBar`, `gettingStarted` and
  `modernUI.contribution`. 194 pass in Electron (32 pending: the Getting Started focus tests
  skip in hidden windows) and 225 in Chromium, the focus outlines at macOS window corners included.
- Without the card rule, 9 of them fail: the 7 `WorkbenchSizeService` size cases from 2 px up and
  both `ModernUIContribution` editor tests.

🤖 Authored with GitHub Copilot on behalf of @alexdima.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Wing K.Y (wingwkyuen) pushed a commit to tcgoidc/vscode that referenced this pull request Nov 24, 2026
…350119)

Modern UI rounds and clips both the editor suggest widget and its list.
Chromium applies one rounded clip per draw quad, so nesting them forces
offscreen render surfaces while the selection or suggestions change.

Keep the widget's clip and square its list's clip, including with a status
bar. The widget's four radii remain equal, so macOS can use Core Animation
rather than mask unequal rounded corners through a render surface. This
preserves the footer, loading/message state and row boundary radii. The
separate details overlay is unchanged. Workbench suggestions keep their
list clip so their resize sashes remain reachable. Both Modern UI and the
Agents window share the editor fix; classic UI is unchanged.

Measured in one inactive instance per run, alternating old and new CSS:
- On main's editor card: GPU-process CPU time per arrow key 2.78 -> 1.91 ms,
  render passes 4.95 -> 3.08; all eight pairs improve.
- With microsoft#350107 applied equally to both arms: 2.68 -> 1.85 ms, render passes
  2.73 -> 0; all eight pairs improve. The paired CPU difference is -0.88 ms.
- With that same editor-card fix and a status bar: 2.86 -> 1.86 ms, render
  passes 2.58 -> 0; all four pairs improve.

How to verify:
- Open editor suggestions and move the selection, with and without
  editor.suggest.showStatusBar. Check first/last row highlights and the
  footer seam, partial scrolling, resize sashes and the details overlay.
- Trace viz and cc: with microsoft#350107, there are no DirectRenderer::DrawRenderPass
  events or rounded-corner render surfaces for the selection workload.
- At DPR 2, first/last selection screenshots differ only on corner arcs:
  54/376704 pixels without a footer (max channel difference 15/255),
  46/407808 with a footer and first selected, zero with last selected.
  Repeated screenshots with unchanged CSS are identical.
- ./scripts/test.sh --run src/vs/workbench/contrib/modernUI/test/browser/roundedCorners.test.ts
  passes (35 tests); the Chromium runner passes (34 tests).
- npm run typecheck-client, targeted hygiene and stylelint pass.

🤖 Authored with GitHub Copilot on behalf of @alexdima.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Alexandru Dima (alexdima) added a commit that referenced this pull request Nov 24, 2026
The previous commit also restructured the comet ring that spins while a
response streams: layout containment instead of its rounded overflow: clip,
and a new square-clipped child for the rotating gradient. The ring's mask is
square, so its rounded clip is what rounds the comet's arc at the corners;
the square clip changed those corners by up to 22/255. Rounding the new
child's clip instead brings back every render pass the restructuring saved.
So the ring can't drop its nested rounded clip without changing how the
comet looks, and this commit puts it back exactly as in main.

What remains is the input box's square clip-path: inset(0) instead of its
rounded overflow: hidden. That is the clip that costs render passes on every
keystroke, while nothing streams. The ring's clip only costs them while the
ring is shown. The comments say why neither clip may become (or stay)
rounded without a reason.

How to verify:
- Trace the viz and cc categories while typing in the chat input. Compared
  with main, RenderSurfaceReasonCount drops from 5 to 2 "rounded corner"
  surfaces and DirectRenderer::DrawRenderPass from about 2.8 to 1.1 per
  keystroke. The remaining 2 surfaces come from the editor card (#350107);
  with both changes, typing draws no render passes.
- Add .working to the input container and trace again: passes per frame
  stay at about 5, as in main.
- Compare screenshots of the input box's corners and of the comet with
  main: they differ by at most 1/255.

🤖 Authored with GitHub Copilot on behalf of @alexdima.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Christopher Montevirgen (toperux) pushed a commit to toperux/vscode that referenced this pull request Nov 24, 2026
…50120)

The modal editor's shadow wrapper, bordered part and (with Modern UI) content
each rounded and clipped the same surface. Chromium supports one rounded clip
per draw quad, so nested clips force offscreen render surfaces while scrolling.
The content's 8px curve also sat inside the part's 7px padding-edge curve.

Let only the part clip the modal surface. Keep the shadow's rounded paint but
remove its overflow clip, and exclude modal content from floating-panel rounding.
The part still clips the header, optional sidebar and content inside its border,
with equal radii on all four corners for Core Animation. Resize handles remain
outside the clip. This also removes the redundant shadow clip without Modern UI.

With the underlying main editor's microsoft#350107 clip fix applied equally to both arms,
eight alternating pairs per workload give:
- Settings: GPU-process CPU time 1.49 -> 1.20 ms per scroll frame; paired median
  difference -0.21 ms, 8/8 pairs lower; render passes 1.45 -> 0.
- Modal text: 1.75 -> 1.21 ms; paired median difference -0.57 ms, 8/8 pairs lower;
  render passes 3.83 -> 0.
Rounded-corner render surfaces fall from 4 and 8 respectively to none.

How to verify:
- Open Settings, or set workbench.editor.useModal to all and open a text file.
  Scroll under a trace of viz and cc and compare with the old shadow overflow
  and content radius restored. Keep the main editor behind the modal identical.
- Check all four corners with Modern UI enabled and disabled, the optional
  sidebar, navigation controls and resize handles. The part retains its 8px
  outer radius and 7px inside curve; content adds no second rounded clip.
- npm run typecheck-client: passed.
- ./scripts/test.sh --run src/vs/workbench/contrib/modernUI/test/browser/modernUI.contribution.test.ts:
  124 passing.
- node test/unit/browser/index.js --run src/vs/workbench/contrib/modernUI/test/browser/modernUI.contribution.test.ts --browser chromium:
  123 passing. Both new regressions fail with the original CSS.
- Targeted hygiene and stylelint: passed.
- DPR 2 screenshots are stable on repeat. Modern Settings/text differ only on
  corner arcs (87/83 of 3,082,240 pixels, at most 6/255 per channel); classic
  differs in 5/6 pixels by at most 1/255.

🤖 Authored with GitHub Copilot on behalf of @alexdima.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@alexdima
Alexandru Dima (alexdima) marked this pull request as ready for review November 24, 2026 17:19
@alexdima
Alexandru Dima (alexdima) added this pull request to the merge queue Nov 24, 2026
Merged via the queue into main with commit bcb7291 Nov 24, 2026
36 checks passed
@alexdima
Alexandru Dima (alexdima) deleted the alexd/modern-ui-one-editor-clip branch November 24, 2026 17:50
Alexandru Dima (alexdima) added a commit that referenced this pull request Nov 24, 2026
Replaces the square `clip-path` on the chat input box (the previous
commits on this branch) with a change that keeps main's CSS. The square
clip-path changed what the input looks like on Windows and Linux, which
the component-fixture screenshots in CI caught:
- With no attachment, the input editor reaches the box's inner top-right
  corner. `overflow: hidden` rounded it there; the square clip doesn't,
  so the corner turned square.
- In the Agents window's phone layout, the editor is a few pixels wider
  than the inside of the box. `overflow: hidden` clipped it inside the
  border; clip-path clips at the border's outer edge, so the editor
  covered the border.
- The clip-path changed how Chromium splits the page into composited
  layers: the text in the box and the toolbar below it moved into layers
  without an opaque background, so cc refused LCD text there
  (`contents-not-opaque`, `background-color-not-opaque`) and drew it
  grayscale. macOS never uses LCD text, so it didn't show there.

chat.css and its test are back to main's. Instead, the input editor
sets `disableLayerHinting`. Monaco otherwise promotes the editor's text
(`.lines-content`, and its margin) to a composited layer with
`translate3d(0, 0, 0)`. That layer sits under two rounded clips, the
input box's and the side bar card's, and Chromium applies one rounded
clip per draw quad, so Blink gave the outer clips render surfaces around
it on every keystroke. Without the hint, the text is drawn into the
layer below, which on main already holds the rest of the input and is
opaque, so LCD text is kept everywhere.

Measured on macOS (M5 Pro, DPR 2), one VS Code window alternating this
build and main's layer hint restored with CSS, 4 pairs, per keystroke:
- typing: GPU process 1.36 -> 1.15 ms (4 of 4 pairs), `rounded corner`
  render surfaces 4 -> 3, render passes drawn unchanged;
- with the "workbench: don't nest rounded clips around the editor"
  change (#350107) in both: 1.31 -> 1.14 ms (4 of 4), surfaces 2 -> 1;
- with the signed-out sign-in prompt docked above the input: 1.38 ->
  1.17 ms and 2.96 -> 1.57 render passes (4 of 4 each);
- while a response streams, per comet frame: no GPU difference, 5.92 ->
  5.59 render passes (4 of 4).
The surface left is Blink's caret layer for the hidden edit context.

Pixels on macOS: at most 1/255 anywhere, with and without an attachment
and with the comet paused at three times; the five chat-input component
fixtures render identically. Scrolling a long input now repaints the
input's viewport instead of moving a layer; it's a few lines high.

How to verify:
- `git diff 679e1ca -- src/vs/workbench/contrib/chat` shows only the
  new option and its comment in chatInputPart.ts.
- In a Code OSS build, open the chat view, type in the input and check
  in DevTools' Layers panel that the input's `.lines-content` has no
  layer of its own.
- Trace `viz` and `cc` while typing: `RenderSurfaceReasonCount` reports
  one `rounded corner` surface fewer than on main.
- The "Screenshots & Tests" check passes with the committed blocks-ci
  hashes.

🤖 Authored with GitHub Copilot on behalf of @alexdima.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Alexandru Dima (alexdima) added a commit that referenced this pull request Nov 24, 2026
Brings in the update from main that was merged into this branch on
GitHub (dd01b74), which includes "workbench: don't nest rounded
clips around the editor" (#350107), so that the change that turns off
Monaco's layer hint on the chat input (57b491e) can be pushed on
top of it.

How to verify:
- `git diff origin/main...HEAD -- src/vs/workbench/contrib/chat` shows
  only the `disableLayerHinting` option and its comment in
  chatInputPart.ts.

🤖 Authored with GitHub Copilot on behalf of @alexdima.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants