Bug 1193349 - Part 1: Force a reload only when a source/img is really inserted into a picture; r=jdm

MozReview-Commit-ID: 4FfTwg1nRFO
This commit is contained in:
Edgar Chen
2016-05-04 10:21:45 +08:00
parent e4a9eb4573
commit db0868d04c
4 changed files with 38 additions and 12 deletions

View File

@@ -62,6 +62,35 @@ HTMLPictureElement::RemoveChildAt(uint32_t aIndex, bool aNotify)
}
}
nsresult
HTMLPictureElement::InsertChildAt(nsIContent* aKid, uint32_t aIndex, bool aNotify)
{
nsresult rv = nsGenericHTMLElement::InsertChildAt(aKid, aIndex, aNotify);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(aKid, rv);
if (aKid->IsHTMLElement(nsGkAtoms::img)) {
HTMLImageElement* img = HTMLImageElement::FromContent(aKid);
if (img) {
img->PictureSourceAdded(aKid->AsContent());
}
} else if (aKid->IsHTMLElement(nsGkAtoms::source)) {
// Find all img siblings after this <source> to notify them of its insertion
nsCOMPtr<nsIContent> nextSibling = aKid->GetNextSibling();
if (nextSibling && nextSibling->GetParentNode() == this) {
do {
HTMLImageElement* img = HTMLImageElement::FromContent(nextSibling);
if (img) {
img->PictureSourceAdded(aKid->AsContent());
}
} while ( (nextSibling = nextSibling->GetNextSibling()) );
}
}
return rv;
}
bool
HTMLPictureElement::IsPictureEnabled()
{