mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
Don't use Emulation.resetPageScaleFactor (#147)
Instead of using Emulation.resetPageScaleFactor, this patch starts using clip's scale for fullPage screenshots.
This commit is contained in:
parent
5068185d03
commit
585f815548
10
lib/Page.js
10
lib/Page.js
@ -400,11 +400,16 @@ class Page extends EventEmitter {
|
||||
*/
|
||||
async _screenshotTask(format, options) {
|
||||
await this._client.send('Target.activateTarget', {targetId: this._client.targetId()});
|
||||
let clip = options.clip ? Object.assign({}, options['clip']) : undefined;
|
||||
if (clip)
|
||||
clip.scale = 1;
|
||||
|
||||
if (options.fullPage) {
|
||||
const metrics = await this._client.send('Page.getLayoutMetrics');
|
||||
const width = Math.ceil(metrics.contentSize.width);
|
||||
const height = Math.ceil(metrics.contentSize.height);
|
||||
await this._client.send('Emulation.resetPageScaleFactor');
|
||||
// Overwrite clip for full page at all times.
|
||||
clip = { x: 0, y: 0, width, height, scale: 1 };
|
||||
const mobile = this._viewport.isMobile || false;
|
||||
const deviceScaleFactor = this._viewport.deviceScaleFactor || 1;
|
||||
const landscape = this._viewport.isLandscape || false;
|
||||
@ -412,9 +417,6 @@ class Page extends EventEmitter {
|
||||
await this._client.send('Emulation.setDeviceMetricsOverride', { mobile, width, height, deviceScaleFactor, screenOrientation });
|
||||
}
|
||||
|
||||
let clip = options.clip ? Object.assign({}, options['clip']) : undefined;
|
||||
if (clip)
|
||||
clip.scale = 1;
|
||||
let result = await this._client.send('Page.captureScreenshot', { format, quality: options.quality, clip });
|
||||
|
||||
if (options.fullPage)
|
||||
|
Loading…
Reference in New Issue
Block a user