From bb6e9bfbd900817933c130bcfe4147d78bb94f31 Mon Sep 17 00:00:00 2001 From: "troy%netscape.com" Date: Sun, 20 Sep 1998 00:08:24 +0000 Subject: [PATCH] Work in progress for displaying icon while laoding image... git-svn-id: svn://10.0.0.236/trunk@10522 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/generic/nsImageFrame.cpp | 52 ++++++++++++++----- mozilla/layout/html/base/src/nsImageFrame.cpp | 52 ++++++++++++++----- 2 files changed, 76 insertions(+), 28 deletions(-) diff --git a/mozilla/layout/generic/nsImageFrame.cpp b/mozilla/layout/generic/nsImageFrame.cpp index 78b9932b80a..95c54761676 100644 --- a/mozilla/layout/generic/nsImageFrame.cpp +++ b/mozilla/layout/generic/nsImageFrame.cpp @@ -45,6 +45,7 @@ #include "nsIFontMetrics.h" #include "nsCSSRendering.h" #include "nsIDOMHTMLImageElement.h" +#include "nsIDeviceContext.h" #define BROKEN_IMAGE_URL "resource:/res/html/broken-image.gif" @@ -617,26 +618,49 @@ ImageFrame::Paint(nsIPresContext& aPresContext, if (nsnull == image) { // No image yet. Draw the icon that indicates we're loading, and display // the alt-text - nsAutoString altText; - if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute("ALT", altText)) { - // Display a recessed one-pixel border in the inner area - nsRect inner; - GetInnerArea(&aPresContext, inner); + // Display a recessed one-pixel border in the inner area + nsRect inner; + GetInnerArea(&aPresContext, inner); - float p2t = aPresContext.GetPixelsToTwips(); - nsRecessedBorder recessedBorder(NSIntPixelsToTwips(1, p2t)); - nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this, inner, - inner, recessedBorder, 0); - inner.Deflate(NSIntPixelsToTwips(1, p2t), NSIntPixelsToTwips(1, p2t)); + float p2t = aPresContext.GetPixelsToTwips(); + nsRecessedBorder recessedBorder(NSIntPixelsToTwips(1, p2t)); + nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this, inner, + inner, recessedBorder, 0); + inner.Deflate(NSIntPixelsToTwips(1, p2t), NSIntPixelsToTwips(1, p2t)); - // Leave a 8 pixel left/right padding, and a 5 pixel top/bottom padding - inner.Deflate(NSIntPixelsToTwips(8, p2t), NSIntPixelsToTwips(5, p2t)); + // Leave a 5 pixel top/bottom padding + inner.Deflate(0, NSIntPixelsToTwips(5, p2t)); + +#if 0 + // If there's room then display the icon + if (!inner.IsEmpty()) { + nsIDeviceContext* dc = aRenderingContext.GetDeviceContext(); + nsIImage* icon; + + if (NS_SUCCEEDED(dc->LoadIconImage(NS_ICON_LOADING_IMAGE, icon))) { + // Leave a 6 pixel left padding + inner.Deflate(NSIntPixelsToTwips(6, p2t), 0); + + // XXX Clip... + aRenderingContext.DrawImage(icon, inner.x, inner.y); + NS_RELEASE(icon); + } + + NS_RELEASE(dc); + } +#endif + + // Now display the alt-text if there's room + if (!inner.IsEmpty()) { + nsAutoString altText; + if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute("ALT", altText)) { + // Leave a 8 pixel left/right padding + inner.Deflate(NSIntPixelsToTwips(8, p2t), 0); - // If there's room, then display the alt-text - if (!inner.IsEmpty()) { DisplayAltText(aPresContext, aRenderingContext, altText, inner); } } + return NS_OK; } diff --git a/mozilla/layout/html/base/src/nsImageFrame.cpp b/mozilla/layout/html/base/src/nsImageFrame.cpp index 78b9932b80a..95c54761676 100644 --- a/mozilla/layout/html/base/src/nsImageFrame.cpp +++ b/mozilla/layout/html/base/src/nsImageFrame.cpp @@ -45,6 +45,7 @@ #include "nsIFontMetrics.h" #include "nsCSSRendering.h" #include "nsIDOMHTMLImageElement.h" +#include "nsIDeviceContext.h" #define BROKEN_IMAGE_URL "resource:/res/html/broken-image.gif" @@ -617,26 +618,49 @@ ImageFrame::Paint(nsIPresContext& aPresContext, if (nsnull == image) { // No image yet. Draw the icon that indicates we're loading, and display // the alt-text - nsAutoString altText; - if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute("ALT", altText)) { - // Display a recessed one-pixel border in the inner area - nsRect inner; - GetInnerArea(&aPresContext, inner); + // Display a recessed one-pixel border in the inner area + nsRect inner; + GetInnerArea(&aPresContext, inner); - float p2t = aPresContext.GetPixelsToTwips(); - nsRecessedBorder recessedBorder(NSIntPixelsToTwips(1, p2t)); - nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this, inner, - inner, recessedBorder, 0); - inner.Deflate(NSIntPixelsToTwips(1, p2t), NSIntPixelsToTwips(1, p2t)); + float p2t = aPresContext.GetPixelsToTwips(); + nsRecessedBorder recessedBorder(NSIntPixelsToTwips(1, p2t)); + nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this, inner, + inner, recessedBorder, 0); + inner.Deflate(NSIntPixelsToTwips(1, p2t), NSIntPixelsToTwips(1, p2t)); - // Leave a 8 pixel left/right padding, and a 5 pixel top/bottom padding - inner.Deflate(NSIntPixelsToTwips(8, p2t), NSIntPixelsToTwips(5, p2t)); + // Leave a 5 pixel top/bottom padding + inner.Deflate(0, NSIntPixelsToTwips(5, p2t)); + +#if 0 + // If there's room then display the icon + if (!inner.IsEmpty()) { + nsIDeviceContext* dc = aRenderingContext.GetDeviceContext(); + nsIImage* icon; + + if (NS_SUCCEEDED(dc->LoadIconImage(NS_ICON_LOADING_IMAGE, icon))) { + // Leave a 6 pixel left padding + inner.Deflate(NSIntPixelsToTwips(6, p2t), 0); + + // XXX Clip... + aRenderingContext.DrawImage(icon, inner.x, inner.y); + NS_RELEASE(icon); + } + + NS_RELEASE(dc); + } +#endif + + // Now display the alt-text if there's room + if (!inner.IsEmpty()) { + nsAutoString altText; + if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute("ALT", altText)) { + // Leave a 8 pixel left/right padding + inner.Deflate(NSIntPixelsToTwips(8, p2t), 0); - // If there's room, then display the alt-text - if (!inner.IsEmpty()) { DisplayAltText(aPresContext, aRenderingContext, altText, inner); } } + return NS_OK; }