Bug 1441136: Cleanup a bit the responsive image content setup. r?smaug
Also, clear it in DestroyElementMaps, as the rest of the code.
MozReview-Commit-ID: A8D3pgQ8MxX
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -8639,16 +8639,17 @@ nsIDocument::MutationEventDispatched(nsI
void
nsIDocument::DestroyElementMaps()
{
#ifdef DEBUG
mStyledLinksCleared = true;
#endif
mStyledLinks.Clear();
mIdentifierMap.Clear();
+ mResponsiveContent.Clear();
IncrementExpandoGeneration(*this);
}
void
nsIDocument::RefreshLinkHrefs()
{
// Get a list of all links we know about. We will reset them, which will
// remove them from the document, so we need a copy of what is in the
--- a/dom/html/HTMLImageElement.cpp
+++ b/dom/html/HTMLImageElement.cpp
@@ -627,22 +627,18 @@ HTMLImageElement::UnbindFromTree(bool aD
if (aNullParent || !FindAncestorForm(mForm)) {
ClearForm(true);
} else {
UnsetFlags(MAYBE_ORPHAN_FORM_ELEMENT);
}
}
if (mInDocResponsiveContent) {
- nsIDocument* doc = GetOurOwnerDoc();
- MOZ_ASSERT(doc);
- if (doc) {
- doc->RemoveResponsiveContent(this);
- mInDocResponsiveContent = false;
- }
+ OwnerDoc()->RemoveResponsiveContent(this);
+ mInDocResponsiveContent = false;
}
nsImageLoadingContent::UnbindFromTree(aDeep, aNullParent);
nsGenericHTMLElement::UnbindFromTree(aDeep, aNullParent);
}
void
HTMLImageElement::UpdateFormOwner()
@@ -1045,21 +1041,18 @@ HTMLImageElement::PictureSourceSrcsetCha
principal = mSrcsetTriggeringPrincipal;
} else if (auto* source = HTMLSourceElement::FromNode(aSourceNode)) {
principal = source->GetSrcsetTriggeringPrincipal();
}
mResponsiveSelector->SetCandidatesFromSourceSet(aNewValue, principal);
}
if (!mInDocResponsiveContent && IsInComposedDoc()) {
- nsIDocument* doc = GetOurOwnerDoc();
- if (doc) {
- doc->AddResponsiveContent(this);
- mInDocResponsiveContent = true;
- }
+ OwnerDoc()->AddResponsiveContent(this);
+ mInDocResponsiveContent = true;
}
// This always triggers the image update steps per the spec, even if
// we are not using this source.
QueueImageLoadTask(true);
}
void