report: add full-page-screenshot to experimental config#10716
Conversation
| Util.reportJson = report; | ||
|
|
||
| const detailsRenderer = new DetailsRenderer(this._dom); | ||
| const fullPageScreenshot = /** @type {LH.Artifacts.FullPageScreenshot | undefined} */ ( |
There was a problem hiding this comment.
same thing with the audit details type and possibly avoiding the cast
There was a problem hiding this comment.
how to avoid the cast?
There was a problem hiding this comment.
how to avoid the cast?
caveating that I could be wrong because I haven't tried it :) I assume details will already either be LH.Audit.Details or undefined, so testing that it exists and has type full-page-screenshot should be enough to convince tsc.
There was a problem hiding this comment.
alright how's that
There was a problem hiding this comment.
for report-ui-features.js could also do something like
const fullPageScreenshot = report.audits['full-page-screenshot'] && report.audits['full-page-screenshot'].details;
if (!fullPageScreenshot || fullPageScreenshot.type !== 'full-page-screenshot') return;or some kind of code golfing, but it's also good enough if you're happy :)
paulirish
left a comment
There was a problem hiding this comment.
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.
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'; |
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.
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.
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.
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_SCmaxRenderSizeInDisplayCoords=>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.
this plus the fileoverview explaining the two coordinate spaces (and what the abbreviation means) SGTM 👍
There was a problem hiding this comment.
Just no underscores, please :)
There was a problem hiding this comment.
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
…er.js Co-authored-by: Paul Irish <paulirish@google.com>
Co-authored-by: Paul Irish <paulirish@google.com>


demo
Summary
New gatherer:
full-page-screenshotchanges 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 theafterPassof 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
nodedetail type, an optionalboundingRectrepresents the location of the node on the screen.New audit:
full-page-screenshot, simply exposes theFullPageScreenshotartifact.New renderer:
element-screenshot-renderer, fornodedetails 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.jsand intodriver.js, meaning the overrides only go toDriver.beginEmulation. I think moving presets out ofemulation.jsmakes 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-sizesso 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 <matt@mostlystatic.com>to commit body.