Skip to content

Commit

Permalink
Bug 1863491 - Use weak pointers for LargestContentfulPaint to avoid k…
Browse files Browse the repository at this point in the history
…eeping the element alive for unnecessary period r=emilio,mccr8

Differential Revision: https://phabricator.services.mozilla.com/D193135

UltraBlame original commit: abf27349f36e96612106b51dd196526df2efd501
  • Loading branch information
marco-c committed Nov 16, 2023
1 parent 77ad05a commit 241e036
Show file tree
Hide file tree
Showing 4 changed files with 268 additions and 99 deletions.
69 changes: 59 additions & 10 deletions dom/performance/LargestContentfulPaint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,10 +475,6 @@ mURI
(
aURI
)
mElement
(
aElement
)
mLCPImageEntryKey
(
aLCPImageEntryKey
Expand All @@ -491,7 +487,7 @@ mPerformance
;
MOZ_ASSERT
(
mElement
aElement
)
;
/
Expand All @@ -506,7 +502,7 @@ pseudo
element
if
(
mElement
aElement
-
>
ChromeOnlyAccess
Expand All @@ -516,6 +512,8 @@ ChromeOnlyAccess
{
mElement
=
do_GetWeakReference
(
Element
:
:
Expand All @@ -528,6 +526,17 @@ FindFirstNonChromeOnlyAccessContent
(
)
)
)
;
}
else
{
mElement
=
do_GetWeakReference
(
aElement
)
;
}
if
Expand Down Expand Up @@ -596,16 +605,27 @@ GetElement
)
const
{
return
nsCOMPtr
<
Element
>
element
=
do_QueryReferent
(
mElement
)
;
return
element
?
nsContentUtils
:
:
GetAnElementForTiming
(
mElement
mElement
element
element
-
>
GetComposedDoc
Expand All @@ -625,6 +645,15 @@ BufferEntryIfNeeded
(
)
{
MOZ_ASSERT
(
mLCPImageEntryKey
.
isNothing
(
)
)
;
mPerformance
-
>
Expand Down Expand Up @@ -3249,12 +3278,32 @@ ReportLCPToNavigationTimings
(
)
{
nsCOMPtr
<
Element
>
element
=
do_QueryReferent
(
mElement
)
;
if
(
!
element
)
{
return
;
}
const
Document
*
document
=
mElement
element
-
>
OwnerDoc
Expand Down
Loading

0 comments on commit 241e036

Please sign in to comment.