Bug 1722322 - Implement LargestContentfulPaint r=emilio

Spec: https://w3c.github.io/largest-contentful-paint

Differential Revision: https://phabricator.services.mozilla.com/D151079
This commit is contained in:
Sean Feng
2023-11-02 20:53:36 +00:00
parent 8af9f7d663
commit 2d6e584e05
30 changed files with 1080 additions and 52 deletions

View File

@@ -27,6 +27,7 @@
#include "mozilla/dom/HTMLImageElement.h"
#include "mozilla/dom/ReferrerInfo.h"
#include "mozilla/dom/ResponsiveImageSelector.h"
#include "mozilla/dom/LargestContentfulPaint.h"
#include "mozilla/image/WebRenderImageProvider.h"
#include "mozilla/layers/RenderRootStateManager.h"
#include "mozilla/layers/WebRenderLayerManager.h"
@@ -1115,6 +1116,8 @@ void nsImageFrame::Notify(imgIRequest* aRequest, int32_t aType,
}
if (aType == imgINotificationObserver::LOAD_COMPLETE) {
LargestContentfulPaint::MaybeProcessImageForElementTiming(
static_cast<imgRequestProxy*>(aRequest), GetContent()->AsElement());
uint32_t imgStatus;
aRequest->GetImageStatus(&imgStatus);
nsresult status =
@@ -2365,6 +2368,13 @@ bool nsDisplayImage::CreateWebRenderCommands(
mImage->GetImageProvider(aManager->LayerManager(), decodeSize, svgContext,
region, flags, getter_AddRefs(provider));
if (nsCOMPtr<imgIRequest> currentRequest = frame->GetCurrentRequest()) {
LCPHelpers::FinalizeLCPEntryForImage(
frame->GetContent()->AsElement(),
static_cast<imgRequestProxy*>(currentRequest.get()),
GetDestRect() - ToReferenceFrame());
}
// While we got a container, it may not contain a fully decoded surface. If
// that is the case, and we have an image we were previously displaying which
// has a fully decoded surface, then we should prefer the previous image.