Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: element screenshot issue in headful mode #8018

Merged
merged 1 commit into from Feb 15, 2022
Merged

Conversation

OrKoN
Copy link
Collaborator

@OrKoN OrKoN commented Feb 14, 2022

Fixes: #7999

// Fallback to `layoutViewport` in case of using Firefox.
const { pageX, pageY } =
layoutMetrics.cssLayoutViewport || layoutMetrics.layoutViewport;
const { pageX, pageY } = layoutMetrics.layoutViewport;
Copy link
Collaborator

Choose a reason for hiding this comment

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

As a temp workaround we can get the cssPixel / deprecatedPixel ratio and normalize the layoutViewport.pageX, layoutViewport.pageY by that ratio.

Copy link
Collaborator

Choose a reason for hiding this comment

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

smth like

const pixelRatio = layoutMetrics.cssLayoutViewport.clientWidth / layoutMetrics.layoutViewport.clientWidth;

Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually, according to the implementation, it looks like we have to use cssVisualViewport instead. DevTools uses it and screenshots in Canary DevTools works well.

My experiment showed the cssLayoutViewport.Page[X/Y] shows the window's position on the screen.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
const { pageX, pageY } = layoutMetrics.layoutViewport;
const { pageX, pageY } = layoutMetrics.cssVisualViewport;

@OrKoN OrKoN changed the title fix: revert changes related to layout metrics fix: element screenshot issue in headful mode Feb 15, 2022
@OrKoN OrKoN enabled auto-merge (squash) February 15, 2022 09:19
@OrKoN OrKoN disabled auto-merge February 15, 2022 09:24
@OrKoN OrKoN enabled auto-merge (squash) February 15, 2022 09:44
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.

[Bug]: element screenshot not vertically aligned with element
2 participants