@@ -12,6 +12,7 @@ import {
1212 sanitizeDesktopPreviewBounds ,
1313 validateDesktopPreviewUrl ,
1414} from "./preview" ;
15+ import { projectPreviewBoundsToContent } from "./previewBounds" ;
1516
1617const PREVIEW_WEB_PREFERENCES = {
1718 contextIsolation : true ,
@@ -36,6 +37,8 @@ export class DesktopPreviewController {
3637 width : 0 ,
3738 height : 0 ,
3839 visible : false ,
40+ viewportWidth : 0 ,
41+ viewportHeight : 0 ,
3942 } ;
4043 private unsubscribers : Array < ( ) => void > = [ ] ;
4144 private disposingView = false ;
@@ -150,6 +153,7 @@ export class DesktopPreviewController {
150153 const view = new WebContentsView ( {
151154 webPreferences : PREVIEW_WEB_PREFERENCES ,
152155 } ) ;
156+ view . setBorderRadius ( 8 ) ;
153157 this . view = view ;
154158 this . window . contentView . addChildView ( view ) ;
155159 this . bindView ( view ) ;
@@ -280,30 +284,9 @@ export class DesktopPreviewController {
280284 return false ;
281285 }
282286
283- const contentBounds = this . window . getContentBounds ( ) ;
284- const rawWidth = Math . round ( this . bounds . width ) ;
285- const rawHeight = Math . round ( this . bounds . height ) ;
286-
287- if (
288- ! this . bounds . visible ||
289- rawWidth <= 0 ||
290- rawHeight <= 0 ||
291- contentBounds . width <= 0 ||
292- contentBounds . height <= 0
293- ) {
294- this . view . setBounds ( { x : 0 , y : 0 , width : 0 , height : 0 } ) ;
295- return false ;
296- }
297-
298- const width = Math . min ( rawWidth , contentBounds . width ) ;
299- const height = Math . min ( rawHeight , contentBounds . height ) ;
300- const maxX = Math . max ( 0 , contentBounds . width - width ) ;
301- const maxY = Math . max ( 0 , contentBounds . height - height ) ;
302- const x = Math . max ( 0 , Math . min ( Math . round ( this . bounds . x ) , maxX ) ) ;
303- const y = Math . max ( 0 , Math . min ( Math . round ( this . bounds . y ) , maxY ) ) ;
304-
305- this . view . setBounds ( { x, y, width, height } ) ;
306- return width > 0 && height > 0 ;
287+ const nextBounds = projectPreviewBoundsToContent ( this . bounds , this . window . getContentBounds ( ) ) ;
288+ this . view . setBounds ( nextBounds ) ;
289+ return nextBounds . width > 0 && nextBounds . height > 0 ;
307290 }
308291
309292 private disposeView ( ) : void {
0 commit comments