Bug 1193349 - Part 2: Force a reload only when a source/img is really removed from a picture; r=jdm

MozReview-Commit-ID: 96ui8rQf4uz
This commit is contained in:
Edgar Chen
2016-04-22 22:36:54 +08:00
parent db0868d04c
commit aeed512b76
2 changed files with 21 additions and 23 deletions

View File

@@ -43,23 +43,27 @@ NS_IMPL_ELEMENT_CLONE(HTMLPictureElement)
void
HTMLPictureElement::RemoveChildAt(uint32_t aIndex, bool aNotify)
{
// Find all img siblings after this <source> to notify them of its demise
nsCOMPtr<nsIContent> child = GetChildAt(aIndex);
nsCOMPtr<nsIContent> nextSibling;
if (child && child->IsHTMLElement(nsGkAtoms::source)) {
nextSibling = child->GetNextSibling();
if (child && child->IsHTMLElement(nsGkAtoms::img)) {
HTMLImageElement* img = HTMLImageElement::FromContent(child);
if (img) {
img->PictureSourceRemoved(child->AsContent());
}
} else if (child && child->IsHTMLElement(nsGkAtoms::source)) {
// Find all img siblings after this <source> to notify them of its demise
nsCOMPtr<nsIContent> nextSibling = child->GetNextSibling();
if (nextSibling && nextSibling->GetParentNode() == this) {
do {
HTMLImageElement* img = HTMLImageElement::FromContent(nextSibling);
if (img) {
img->PictureSourceRemoved(child->AsContent());
}
} while ( (nextSibling = nextSibling->GetNextSibling()) );
}
}
nsGenericHTMLElement::RemoveChildAt(aIndex, aNotify);
if (nextSibling && nextSibling->GetParentNode() == this) {
do {
HTMLImageElement* img = HTMLImageElement::FromContent(nextSibling);
if (img) {
img->PictureSourceRemoved(child->AsContent());
}
} while ( (nextSibling = nextSibling->GetNextSibling()) );
}
}
nsresult