Fix a regression in dynamically setting the src of an image (bug 176926). r=hyatt, sr=bzbarsky, a=brendan.
git-svn-id: svn://10.0.0.236/trunk@132686 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
e510231894
commit
47dc988ac2
@ -547,16 +547,6 @@ nsHTMLImageElement::GetMappedAttributeImpact(const nsIAtom* aAttribute,
|
||||
(aAttribute == nsHTMLAtoms::align)) {
|
||||
aHint = NS_STYLE_HINT_FRAMECHANGE;
|
||||
}
|
||||
else if (aAttribute == nsHTMLAtoms::src) {
|
||||
// If 'src' changed and we don't have a real image frame,
|
||||
// we need to cause a reframe.
|
||||
nsIImageFrame* imageFrame;
|
||||
// cast away |const| because the underlying interfaces don't use it.
|
||||
nsHTMLImageElement* mutable_this = NS_CONST_CAST(nsHTMLImageElement*,
|
||||
this);
|
||||
mutable_this->GetImageFrame(&imageFrame);
|
||||
aHint = imageFrame ? NS_STYLE_HINT_CONTENT : NS_STYLE_HINT_FRAMECHANGE;
|
||||
}
|
||||
else if (!GetCommonMappedAttributesImpact(aAttribute, aHint)) {
|
||||
if (!GetImageMappedAttributesImpact(aAttribute, aHint)) {
|
||||
if (!GetImageBorderAttributeImpact(aAttribute, aHint)) {
|
||||
@ -760,8 +750,9 @@ nsHTMLImageElement::SetSrcInner(nsIURI* aBaseURL,
|
||||
{
|
||||
nsresult result = SetAttr(kNameSpaceID_None, nsHTMLAtoms::src, aSrc,
|
||||
PR_TRUE);
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
if (NS_SUCCEEDED(result) && !mDocument) {
|
||||
if (!mDocument) {
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
mNodeInfo->GetDocument(*getter_AddRefs(doc));
|
||||
|
||||
@ -837,6 +828,18 @@ nsHTMLImageElement::SetSrcInner(nsIURI* aBaseURL,
|
||||
nsnull, nsnull, getter_AddRefs(mRequest));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
nsIImageFrame* imageFrame;
|
||||
GetImageFrame(&imageFrame);
|
||||
if (!imageFrame) {
|
||||
// If we don't have an image frame, reconstruct the frame
|
||||
// so that the new image can load.
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
mDocument->GetShellAt(0, getter_AddRefs(shell));
|
||||
if (shell) {
|
||||
shell->RecreateFramesFor(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user