-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
report: add full-page-screenshot to experimental config #10716
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spent some time in the renderer. in general it's dealing with the complexity quite well. :)
the var names make reading it a little tough so i have a few suggestions below that should help (and shouldn't be too contentious)
i'm also gonna do a followup PR with a slightly more contentious naming tweak
* @param {LH.Artifacts.Rect} elementRectInScreenshotCoords | ||
* @param {Size} elementPreviewSizeInScreenshotCoords | ||
*/ | ||
static renderClipPath(dom, maskEl, positionClip, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we can simplify this, but I'll attempt it in a followup.
markerEl.style.top = positions.clip.top * zoomFactor + 'px'; | ||
|
||
const maskEl = dom.find('.lh-element-screenshot__mask', containerEl); | ||
maskEl.style.width = elementPreviewSizeInDisplayCoords.width + 'px'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
* @param {Size} elementPreviewSizeInScreenshotCoords | ||
* @param {Size} screenshotSize | ||
*/ | ||
static getScreenshotPositions(elementRectInScreenshotCoords, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this method is clearly working in screenshot coordinate scale, can we drop InScreenshotCoords
from all the var names within?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to push back a little on the idea that anything anywhere here is clearly working in any particular scale :)
it's definitely clearer what's happening within this function but in absence of comments getScreenshotPositions
could easily be a name for a function that returns somethingScreenshotCords
based on somethingDisplayCoords
.
in my experience variable names are less easily ignored when reading a function to figure out what it's doing than function overview. I'm ok with removing the suffix, just didn't want it to die without a fight :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aiight well if you're already feelin this, lemme pitch you on what I was going to put in a separate PR. basically abbreviating all the suffixes:
elementRectInScreenshotCoords
=>elementRect_SC
maxRenderSizeInDisplayCoords
=>maxRenderSize_DC
On my first pass looking at this renderer code i was really confused because the var names suffix was "Coords" but their types were Rect/Size. But then realized the different coords spaces and i'm pleased the names indicate this signal. But still, it just takes up so much visual space that I think it current hampers readability.
So yeah. suffix abbreviation. Connor's on board. so if you're into it, we could just do this.
edit: (Oh last bit... I already wrote a lil description for the top.. and we'd add in the abbv's in thar:
/**
* @overview These functions define {Rect}s and {Size}s using two different coordinate spaces:
* 1. Screenshot coords (SC): where 0,0 is the top left of the screenshot image
* 2. Display coords (DC): that match the CSS pixel coordinate space of the LH report's page.
*/
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this plus the fileoverview explaining the two coordinate spaces (and what the abbreviation means) SGTM 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just no underscores, please :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So yeah. suffix abbreviation. Connor's on board. so if you're into it, we could just do this.
plz do this in followup pr
lighthouse-core/report/html/renderer/element-screenshot-renderer.js
Outdated
Show resolved
Hide resolved
lighthouse-core/report/html/renderer/element-screenshot-renderer.js
Outdated
Show resolved
Hide resolved
lighthouse-core/report/html/renderer/element-screenshot-renderer.js
Outdated
Show resolved
Hide resolved
lighthouse-core/report/html/renderer/element-screenshot-renderer.js
Outdated
Show resolved
Hide resolved
lighthouse-core/report/html/renderer/element-screenshot-renderer.js
Outdated
Show resolved
Hide resolved
…er.js Co-authored-by: Paul Irish <[email protected]>
Co-authored-by: Paul Irish <[email protected]>
addressed review by moving to experimental config
demo
Summary
New gatherer:
full-page-screenshot
changes the screen emulation to be as large as the content height and snaps a JPEG, backing off as necessary to meet size thresholds. After: if Lighthouse is in control of the emulation, we easily set it back to the emulated state. Otherwise, if emulation is outside of our control, we do our best to put it back. In practice this probably doesn't matter, since this is theafterPass
of the very last gatherer, and we'd expect any programatic usage of Lighthouse to not reuse the page after the LH run.New details: for the
node
detail type, an optionalboundingRect
represents the location of the node on the screen.New audit:
full-page-screenshot
, simply exposes theFullPageScreenshot
artifact.New renderer:
element-screenshot-renderer
, fornode
details with aboundingRect
, display a clipped image of the full page screenshot. On click, use the same renderer to paint the clipped image in a larger viewport in an overlay. The overlay is enabled inreport-ui-features
.old
(before many refactors)
emulation
The previous PR wired emulation overrides through the driver + emulation files. Instead, I moved the presets out of
emulation.js
and intodriver.js
, meaning the overrides only go toDriver.beginEmulation
. I think moving presets out ofemulation.js
makes the file better encapsulated.on click
currently if you click on a node image you'll get a shadowbox overlay over the entire report. I see there is some code for instead showing the image in the corner of the page. I suppose we could also do a tooltip hover thing. We should sort out exactly what we want to do.
size
I added a script
json-sizes
so we can get a feel for how much larger this will make the LHR.theverge.com:
example.com:
Cont: #8797
Note: do not use "land when green". Add
Co-authored-by: Matt Zeunert <[email protected]>
to commit body.