зеркало из 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);
|
mImageLoader.Init(this, UpdateImageFrame, nsnull, baseURL, src);
|
||||||
NS_IF_RELEASE(baseURL);
|
NS_IF_RELEASE(baseURL);
|
||||||
|
|
||||||
|
mInitialLoadCompleted = PR_FALSE;
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,9 +177,11 @@ nsImageFrame::UpdateImage(nsIPresContext* aPresContext, PRUint32 aStatus)
|
||||||
nsCOMPtr<nsIPresShell> presShell;
|
nsCOMPtr<nsIPresShell> presShell;
|
||||||
aPresContext->GetShell(getter_AddRefs(presShell));
|
aPresContext->GetShell(getter_AddRefs(presShell));
|
||||||
|
|
||||||
if (NS_IMAGE_LOAD_STATUS_ERROR & aStatus) {
|
if (NS_IMAGE_LOAD_STATUS_ERROR & aStatus) {
|
||||||
// We failed to load the image. Notify the pres shell
|
nsAutoString usemap;
|
||||||
if (presShell) {
|
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);
|
presShell->CantRenderReplacedElement(aPresContext, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -482,7 +485,8 @@ nsImageFrame::Paint(nsIPresContext* aPresContext,
|
||||||
if (nsnull == image) {
|
if (nsnull == image) {
|
||||||
// No image yet, or image load failed. Draw the alt-text and an icon
|
// No image yet, or image load failed. Draw the alt-text and an icon
|
||||||
// indicating the status
|
// indicating the status
|
||||||
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) {
|
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer &&
|
||||||
|
!mInitialLoadCompleted) {
|
||||||
DisplayAltFeedback(aPresContext, aRenderingContext,
|
DisplayAltFeedback(aPresContext, aRenderingContext,
|
||||||
mImageLoader.GetLoadImageFailed()
|
mImageLoader.GetLoadImageFailed()
|
||||||
? NS_ICON_BROKEN_IMAGE
|
? NS_ICON_BROKEN_IMAGE
|
||||||
|
@ -490,6 +494,7 @@ nsImageFrame::Paint(nsIPresContext* aPresContext,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
mInitialLoadCompleted = PR_TRUE;
|
||||||
if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer) {
|
if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer) {
|
||||||
// Now render the image into our content area (the area inside the
|
// Now render the image into our content area (the area inside the
|
||||||
// borders and padding)
|
// borders and padding)
|
||||||
|
@ -860,14 +865,16 @@ nsImageFrame::AttributeChanged(nsIPresContext* aPresContext,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Force a reflow when the image size isn't already known
|
// Dirty the image frame and ask its parent to reflow it
|
||||||
if (nsnull != mContent) {
|
// when the image size isn't already known
|
||||||
nsIDocument* document = nsnull;
|
if (mParent) {
|
||||||
mContent->GetDocument(document);
|
nsCOMPtr<nsIPresShell> presShell;
|
||||||
if (nsnull != document) {
|
aPresContext->GetShell(getter_AddRefs(presShell));
|
||||||
document->ContentChanged(mContent, nsnull);
|
mState |= NS_FRAME_IS_DIRTY;
|
||||||
NS_RELEASE(document);
|
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;
|
nsHTMLImageLoader mImageLoader;
|
||||||
nsImageMap* mImageMap;
|
nsImageMap* mImageMap;
|
||||||
PRBool mSizeFrozen;
|
PRPackedBool mSizeFrozen;
|
||||||
|
PRPackedBool mInitialLoadCompleted;
|
||||||
nsMargin mBorderPadding;
|
nsMargin mBorderPadding;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -152,6 +152,7 @@ nsImageFrame::Init(nsIPresContext* aPresContext,
|
||||||
mImageLoader.Init(this, UpdateImageFrame, nsnull, baseURL, src);
|
mImageLoader.Init(this, UpdateImageFrame, nsnull, baseURL, src);
|
||||||
NS_IF_RELEASE(baseURL);
|
NS_IF_RELEASE(baseURL);
|
||||||
|
|
||||||
|
mInitialLoadCompleted = PR_FALSE;
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,9 +177,11 @@ nsImageFrame::UpdateImage(nsIPresContext* aPresContext, PRUint32 aStatus)
|
||||||
nsCOMPtr<nsIPresShell> presShell;
|
nsCOMPtr<nsIPresShell> presShell;
|
||||||
aPresContext->GetShell(getter_AddRefs(presShell));
|
aPresContext->GetShell(getter_AddRefs(presShell));
|
||||||
|
|
||||||
if (NS_IMAGE_LOAD_STATUS_ERROR & aStatus) {
|
if (NS_IMAGE_LOAD_STATUS_ERROR & aStatus) {
|
||||||
// We failed to load the image. Notify the pres shell
|
nsAutoString usemap;
|
||||||
if (presShell) {
|
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);
|
presShell->CantRenderReplacedElement(aPresContext, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -482,7 +485,8 @@ nsImageFrame::Paint(nsIPresContext* aPresContext,
|
||||||
if (nsnull == image) {
|
if (nsnull == image) {
|
||||||
// No image yet, or image load failed. Draw the alt-text and an icon
|
// No image yet, or image load failed. Draw the alt-text and an icon
|
||||||
// indicating the status
|
// indicating the status
|
||||||
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) {
|
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer &&
|
||||||
|
!mInitialLoadCompleted) {
|
||||||
DisplayAltFeedback(aPresContext, aRenderingContext,
|
DisplayAltFeedback(aPresContext, aRenderingContext,
|
||||||
mImageLoader.GetLoadImageFailed()
|
mImageLoader.GetLoadImageFailed()
|
||||||
? NS_ICON_BROKEN_IMAGE
|
? NS_ICON_BROKEN_IMAGE
|
||||||
|
@ -490,6 +494,7 @@ nsImageFrame::Paint(nsIPresContext* aPresContext,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
mInitialLoadCompleted = PR_TRUE;
|
||||||
if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer) {
|
if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer) {
|
||||||
// Now render the image into our content area (the area inside the
|
// Now render the image into our content area (the area inside the
|
||||||
// borders and padding)
|
// borders and padding)
|
||||||
|
@ -860,14 +865,16 @@ nsImageFrame::AttributeChanged(nsIPresContext* aPresContext,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Force a reflow when the image size isn't already known
|
// Dirty the image frame and ask its parent to reflow it
|
||||||
if (nsnull != mContent) {
|
// when the image size isn't already known
|
||||||
nsIDocument* document = nsnull;
|
if (mParent) {
|
||||||
mContent->GetDocument(document);
|
nsCOMPtr<nsIPresShell> presShell;
|
||||||
if (nsnull != document) {
|
aPresContext->GetShell(getter_AddRefs(presShell));
|
||||||
document->ContentChanged(mContent, nsnull);
|
mState |= NS_FRAME_IS_DIRTY;
|
||||||
NS_RELEASE(document);
|
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;
|
nsHTMLImageLoader mImageLoader;
|
||||||
nsImageMap* mImageMap;
|
nsImageMap* mImageMap;
|
||||||
PRBool mSizeFrozen;
|
PRPackedBool mSizeFrozen;
|
||||||
|
PRPackedBool mInitialLoadCompleted;
|
||||||
nsMargin mBorderPadding;
|
nsMargin mBorderPadding;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче