Merge Juggler changes, add dummy for Browser.setContrast #230

This commit is contained in:
daijro 2025-03-15 05:00:26 -05:00
parent 3bf91de311
commit 65a19393c5
5 changed files with 17 additions and 42 deletions

View file

@ -394,7 +394,6 @@ class PageTarget {
height: ChromeUtils.camouGetInt("window.innerHeight") || 720, height: ChromeUtils.camouGetInt("window.innerHeight") || 720,
}; };
} }
this._zoom = 1;
this._initialDPPX = this._linkedBrowser.browsingContext.overrideDPPX; this._initialDPPX = this._linkedBrowser.browsingContext.overrideDPPX;
this._url = 'about:blank'; this._url = 'about:blank';
this._openerId = opener ? opener.id() : undefined; this._openerId = opener ? opener.id() : undefined;
@ -507,7 +506,6 @@ class PageTarget {
this.updateUserAgent(browsingContext); this.updateUserAgent(browsingContext);
this.updatePlatform(browsingContext); this.updatePlatform(browsingContext);
this.updateDPPXOverride(browsingContext); this.updateDPPXOverride(browsingContext);
this.updateZoom(browsingContext);
this.updateEmulatedMedia(browsingContext); this.updateEmulatedMedia(browsingContext);
this.updateColorSchemeOverride(browsingContext); this.updateColorSchemeOverride(browsingContext);
this.updateReducedMotionOverride(browsingContext); this.updateReducedMotionOverride(browsingContext);
@ -546,16 +544,7 @@ class PageTarget {
} }
updateDPPXOverride(browsingContext = undefined) { updateDPPXOverride(browsingContext = undefined) {
browsingContext ||= this._linkedBrowser.browsingContext; (browsingContext || this._linkedBrowser.browsingContext).overrideDPPX = this._browserContext.deviceScaleFactor || this._initialDPPX;
const dppx = this._zoom * (this._browserContext.deviceScaleFactor || this._initialDPPX);
browsingContext.overrideDPPX = dppx;
}
async updateZoom(browsingContext = undefined) {
browsingContext ||= this._linkedBrowser.browsingContext;
// Update dpr first, and then UI zoom.
this.updateDPPXOverride(browsingContext);
browsingContext.fullZoom = this._zoom;
} }
_updateModalDialogs() { _updateModalDialogs() {
@ -617,7 +606,7 @@ class PageTarget {
const toolbarTop = stackRect.y; const toolbarTop = stackRect.y;
this._window.resizeBy(width - this._window.innerWidth, height + toolbarTop - this._window.innerHeight); this._window.resizeBy(width - this._window.innerWidth, height + toolbarTop - this._window.innerHeight);
await this._channel.connect('').send('awaitViewportDimensions', { width: width / this._zoom, height: height / this._zoom }); await this._channel.connect('').send('awaitViewportDimensions', { width, height });
} else { } else {
this._linkedBrowser.style.removeProperty('width'); this._linkedBrowser.style.removeProperty('width');
this._linkedBrowser.style.removeProperty('height'); this._linkedBrowser.style.removeProperty('height');
@ -629,8 +618,8 @@ class PageTarget {
const actualSize = this._linkedBrowser.getBoundingClientRect(); const actualSize = this._linkedBrowser.getBoundingClientRect();
await this._channel.connect('').send('awaitViewportDimensions', { await this._channel.connect('').send('awaitViewportDimensions', {
width: actualSize.width / this._zoom, width: actualSize.width,
height: actualSize.height / this._zoom, height: actualSize.height,
}); });
} }
} }
@ -683,14 +672,6 @@ class PageTarget {
await this.updateViewportSize(); await this.updateViewportSize();
} }
async setZoom(zoom) {
// This is default range from the ZoomManager.
if (zoom < 0.3 || zoom > 5)
throw new Error('Invalid zoom value, must be between 0.3 and 5');
this._zoom = zoom;
await this.updateZoom();
}
close(runBeforeUnload = false) { close(runBeforeUnload = false) {
this._gBrowser.removeTab(this._tab, { this._gBrowser.removeTab(this._tab, {
skipPermitUnload: !runBeforeUnload, skipPermitUnload: !runBeforeUnload,

View file

@ -219,6 +219,10 @@ class BrowserHandler {
await this._targetRegistry.browserContextForId(browserContextId).setForcedColors(nullToUndefined(forcedColors)); await this._targetRegistry.browserContextForId(browserContextId).setForcedColors(nullToUndefined(forcedColors));
} }
async ['Browser.setContrast']({browserContextId, contrast}) {
return; // TODO: Implement
}
async ['Browser.setVideoRecordingOptions']({browserContextId, options}) { async ['Browser.setVideoRecordingOptions']({browserContextId, options}) {
await this._targetRegistry.browserContextForId(browserContextId).setVideoRecordingOptions(options); await this._targetRegistry.browserContextForId(browserContextId).setVideoRecordingOptions(options);
} }

View file

@ -250,10 +250,6 @@ class PageHandler {
await this._pageTarget.setViewportSize(viewportSize === null ? undefined : viewportSize); await this._pageTarget.setViewportSize(viewportSize === null ? undefined : viewportSize);
} }
async ['Page.setZoom']({zoom}) {
await this._pageTarget.setZoom(zoom);
}
async ['Runtime.evaluate'](options) { async ['Runtime.evaluate'](options) {
return await this._contentPage.send('evaluate', options); return await this._contentPage.send('evaluate', options);
} }

View file

@ -463,6 +463,12 @@ const Browser = {
forcedColors: t.Nullable(t.Enum(['active', 'none'])), forcedColors: t.Nullable(t.Enum(['active', 'none'])),
}, },
}, },
'setContrast': {
params: {
browserContextId: t.Optional(t.String),
contrast: t.Nullable(t.Enum(['less', 'more', 'custom', 'no-preference'])),
},
},
'setVideoRecordingOptions': { 'setVideoRecordingOptions': {
params: { params: {
browserContextId: t.Optional(t.String), browserContextId: t.Optional(t.String),
@ -794,11 +800,6 @@ const Page = {
viewportSize: t.Nullable(pageTypes.Size), viewportSize: t.Nullable(pageTypes.Size),
}, },
}, },
'setZoom': {
params: {
zoom: t.Number,
},
},
'bringToFront': { 'bringToFront': {
params: { params: {
}, },

View file

@ -343,17 +343,10 @@ nsresult nsScreencastService::StartVideoRecording(nsIScreencastServiceClient* aC
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
gfx::IntMargin margin; gfx::IntMargin margin;
// Screen bounds is the widget location on screen. auto bounds = widget->GetScreenBounds().ToUnknownRect();
auto screenBounds = widget->GetScreenBounds().ToUnknownRect();
// Client bounds is the content location, in terms of parent widget.
// To use it, we need to translate it to screen coordinates first.
auto clientBounds = widget->GetClientBounds().ToUnknownRect(); auto clientBounds = widget->GetClientBounds().ToUnknownRect();
for (auto parent = widget->GetParent(); parent != nullptr; parent = parent->GetParent()) {
auto pb = parent->GetClientBounds().ToUnknownRect();
clientBounds.MoveBy(pb.X(), pb.Y());
}
// Crop the image to exclude frame (if any). // Crop the image to exclude frame (if any).
margin = screenBounds - clientBounds; margin = bounds - clientBounds;
// Crop the image to exclude controls. // Crop the image to exclude controls.
margin.top += offsetTop; margin.top += offsetTop;