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,
};
}
this._zoom = 1;
this._initialDPPX = this._linkedBrowser.browsingContext.overrideDPPX;
this._url = 'about:blank';
this._openerId = opener ? opener.id() : undefined;
@ -507,7 +506,6 @@ class PageTarget {
this.updateUserAgent(browsingContext);
this.updatePlatform(browsingContext);
this.updateDPPXOverride(browsingContext);
this.updateZoom(browsingContext);
this.updateEmulatedMedia(browsingContext);
this.updateColorSchemeOverride(browsingContext);
this.updateReducedMotionOverride(browsingContext);
@ -546,16 +544,7 @@ class PageTarget {
}
updateDPPXOverride(browsingContext = undefined) {
browsingContext ||= this._linkedBrowser.browsingContext;
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;
(browsingContext || this._linkedBrowser.browsingContext).overrideDPPX = this._browserContext.deviceScaleFactor || this._initialDPPX;
}
_updateModalDialogs() {
@ -617,7 +606,7 @@ class PageTarget {
const toolbarTop = stackRect.y;
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 {
this._linkedBrowser.style.removeProperty('width');
this._linkedBrowser.style.removeProperty('height');
@ -629,8 +618,8 @@ class PageTarget {
const actualSize = this._linkedBrowser.getBoundingClientRect();
await this._channel.connect('').send('awaitViewportDimensions', {
width: actualSize.width / this._zoom,
height: actualSize.height / this._zoom,
width: actualSize.width,
height: actualSize.height,
});
}
}
@ -682,14 +671,6 @@ class PageTarget {
this._viewportSize = viewportSize;
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) {
this._gBrowser.removeTab(this._tab, {

View file

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

View file

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

View file

@ -463,6 +463,12 @@ const Browser = {
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': {
params: {
browserContextId: t.Optional(t.String),
@ -794,11 +800,6 @@ const Page = {
viewportSize: t.Nullable(pageTypes.Size),
},
},
'setZoom': {
params: {
zoom: t.Number,
},
},
'bringToFront': {
params: {
},

View file

@ -343,17 +343,10 @@ nsresult nsScreencastService::StartVideoRecording(nsIScreencastServiceClient* aC
return NS_ERROR_FAILURE;
gfx::IntMargin margin;
// Screen bounds is the widget location on screen.
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 bounds = widget->GetScreenBounds().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).
margin = screenBounds - clientBounds;
margin = bounds - clientBounds;
// Crop the image to exclude controls.
margin.top += offsetTop;
@ -398,4 +391,4 @@ nsresult nsScreencastService::ScreencastFrameAck(const nsAString& aSessionId) {
return NS_OK;
}
} // namespace mozilla
} // namespace mozilla