зеркало из https://github.com/mozilla/pjs.git
r=troy. Fix for bugs 8131, 13325.
- We no longer display alternate content for broken images inside image - We only display the image loading icon during the initial load of an image not if its src attribute is changed via the DOM. - In AttributeChanged(), se don't call ContentChanged() on the document to reflow the image frame but call the parent frame's ReflowDirtyChild() method instead.
This commit is contained in:
Родитель
9041082284
Коммит
28ad847496
|
@ -152,6 +152,7 @@ nsImageFrame::Init(nsIPresContext* aPresContext,
|
|||
mImageLoader.Init(this, UpdateImageFrame, nsnull, baseURL, src);
|
||||
NS_IF_RELEASE(baseURL);
|
||||
|
||||
mInitialLoadCompleted = PR_FALSE;
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -176,9 +177,11 @@ nsImageFrame::UpdateImage(nsIPresContext* aPresContext, PRUint32 aStatus)
|
|||
nsCOMPtr<nsIPresShell> presShell;
|
||||
aPresContext->GetShell(getter_AddRefs(presShell));
|
||||
|
||||
if (NS_IMAGE_LOAD_STATUS_ERROR & aStatus) {
|
||||
// We failed to load the image. Notify the pres shell
|
||||
if (presShell) {
|
||||
if (NS_IMAGE_LOAD_STATUS_ERROR & aStatus) {
|
||||
nsAutoString usemap;
|
||||
mContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::usemap, usemap);
|
||||
// We failed to load the image. Notify the pres shell if we aren't an image map
|
||||
if (presShell && usemap.Length() == 0) {
|
||||
presShell->CantRenderReplacedElement(aPresContext, this);
|
||||
}
|
||||
}
|
||||
|
@ -482,7 +485,8 @@ nsImageFrame::Paint(nsIPresContext* aPresContext,
|
|||
if (nsnull == image) {
|
||||
// No image yet, or image load failed. Draw the alt-text and an icon
|
||||
// indicating the status
|
||||
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) {
|
||||
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer &&
|
||||
!mInitialLoadCompleted) {
|
||||
DisplayAltFeedback(aPresContext, aRenderingContext,
|
||||
mImageLoader.GetLoadImageFailed()
|
||||
? NS_ICON_BROKEN_IMAGE
|
||||
|
@ -490,6 +494,7 @@ nsImageFrame::Paint(nsIPresContext* aPresContext,
|
|||
}
|
||||
}
|
||||
else {
|
||||
mInitialLoadCompleted = PR_TRUE;
|
||||
if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer) {
|
||||
// Now render the image into our content area (the area inside the
|
||||
// borders and padding)
|
||||
|
@ -860,14 +865,16 @@ nsImageFrame::AttributeChanged(nsIPresContext* aPresContext,
|
|||
}
|
||||
}
|
||||
else {
|
||||
// Force a reflow when the image size isn't already known
|
||||
if (nsnull != mContent) {
|
||||
nsIDocument* document = nsnull;
|
||||
mContent->GetDocument(document);
|
||||
if (nsnull != document) {
|
||||
document->ContentChanged(mContent, nsnull);
|
||||
NS_RELEASE(document);
|
||||
}
|
||||
// Dirty the image frame and ask its parent to reflow it
|
||||
// when the image size isn't already known
|
||||
if (mParent) {
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
aPresContext->GetShell(getter_AddRefs(presShell));
|
||||
mState |= NS_FRAME_IS_DIRTY;
|
||||
mParent->ReflowDirtyChild(presShell, (nsIFrame*) this);
|
||||
}
|
||||
else {
|
||||
NS_ASSERTION(0, "No parent to pass the reflow request up to.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -127,7 +127,8 @@ protected:
|
|||
|
||||
nsHTMLImageLoader mImageLoader;
|
||||
nsImageMap* mImageMap;
|
||||
PRBool mSizeFrozen;
|
||||
PRPackedBool mSizeFrozen;
|
||||
PRPackedBool mInitialLoadCompleted;
|
||||
nsMargin mBorderPadding;
|
||||
};
|
||||
|
||||
|
|
|
@ -152,6 +152,7 @@ nsImageFrame::Init(nsIPresContext* aPresContext,
|
|||
mImageLoader.Init(this, UpdateImageFrame, nsnull, baseURL, src);
|
||||
NS_IF_RELEASE(baseURL);
|
||||
|
||||
mInitialLoadCompleted = PR_FALSE;
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -176,9 +177,11 @@ nsImageFrame::UpdateImage(nsIPresContext* aPresContext, PRUint32 aStatus)
|
|||
nsCOMPtr<nsIPresShell> presShell;
|
||||
aPresContext->GetShell(getter_AddRefs(presShell));
|
||||
|
||||
if (NS_IMAGE_LOAD_STATUS_ERROR & aStatus) {
|
||||
// We failed to load the image. Notify the pres shell
|
||||
if (presShell) {
|
||||
if (NS_IMAGE_LOAD_STATUS_ERROR & aStatus) {
|
||||
nsAutoString usemap;
|
||||
mContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::usemap, usemap);
|
||||
// We failed to load the image. Notify the pres shell if we aren't an image map
|
||||
if (presShell && usemap.Length() == 0) {
|
||||
presShell->CantRenderReplacedElement(aPresContext, this);
|
||||
}
|
||||
}
|
||||
|
@ -482,7 +485,8 @@ nsImageFrame::Paint(nsIPresContext* aPresContext,
|
|||
if (nsnull == image) {
|
||||
// No image yet, or image load failed. Draw the alt-text and an icon
|
||||
// indicating the status
|
||||
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) {
|
||||
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer &&
|
||||
!mInitialLoadCompleted) {
|
||||
DisplayAltFeedback(aPresContext, aRenderingContext,
|
||||
mImageLoader.GetLoadImageFailed()
|
||||
? NS_ICON_BROKEN_IMAGE
|
||||
|
@ -490,6 +494,7 @@ nsImageFrame::Paint(nsIPresContext* aPresContext,
|
|||
}
|
||||
}
|
||||
else {
|
||||
mInitialLoadCompleted = PR_TRUE;
|
||||
if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer) {
|
||||
// Now render the image into our content area (the area inside the
|
||||
// borders and padding)
|
||||
|
@ -860,14 +865,16 @@ nsImageFrame::AttributeChanged(nsIPresContext* aPresContext,
|
|||
}
|
||||
}
|
||||
else {
|
||||
// Force a reflow when the image size isn't already known
|
||||
if (nsnull != mContent) {
|
||||
nsIDocument* document = nsnull;
|
||||
mContent->GetDocument(document);
|
||||
if (nsnull != document) {
|
||||
document->ContentChanged(mContent, nsnull);
|
||||
NS_RELEASE(document);
|
||||
}
|
||||
// Dirty the image frame and ask its parent to reflow it
|
||||
// when the image size isn't already known
|
||||
if (mParent) {
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
aPresContext->GetShell(getter_AddRefs(presShell));
|
||||
mState |= NS_FRAME_IS_DIRTY;
|
||||
mParent->ReflowDirtyChild(presShell, (nsIFrame*) this);
|
||||
}
|
||||
else {
|
||||
NS_ASSERTION(0, "No parent to pass the reflow request up to.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -127,7 +127,8 @@ protected:
|
|||
|
||||
nsHTMLImageLoader mImageLoader;
|
||||
nsImageMap* mImageMap;
|
||||
PRBool mSizeFrozen;
|
||||
PRPackedBool mSizeFrozen;
|
||||
PRPackedBool mInitialLoadCompleted;
|
||||
nsMargin mBorderPadding;
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче