From 082fcd183839709466ed02e6423711db6a5e328b Mon Sep 17 00:00:00 2001 From: "kipp%netscape.com" Date: Sat, 26 Sep 1998 18:36:01 +0000 Subject: [PATCH] use image-loader call back to trigger bullet frame reflows git-svn-id: svn://10.0.0.236/trunk@11162 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/generic/nsBlockFrame.cpp | 32 +++++++++++++++++-- mozilla/layout/generic/nsBlockReflowState.cpp | 32 +++++++++++++++++-- mozilla/layout/generic/nsBlockReflowState.h | 32 +++++++++++++++++-- mozilla/layout/html/base/src/nsBlockFrame.cpp | 32 +++++++++++++++++-- .../html/base/src/nsBlockReflowState.cpp | 32 +++++++++++++++++-- .../layout/html/base/src/nsBlockReflowState.h | 32 +++++++++++++++++-- 6 files changed, 174 insertions(+), 18 deletions(-) diff --git a/mozilla/layout/generic/nsBlockFrame.cpp b/mozilla/layout/generic/nsBlockFrame.cpp index b6344a91102..190083e3d88 100644 --- a/mozilla/layout/generic/nsBlockFrame.cpp +++ b/mozilla/layout/generic/nsBlockFrame.cpp @@ -445,7 +445,7 @@ BulletFrame::QueryInterface(REFNSIID aIID, void** aInstancePtrResult) return nsFrame::QueryInterface(aIID, aInstancePtrResult); } -NS_METHOD +NS_IMETHODIMP BulletFrame::DeleteFrame(nsIPresContext& aPresContext) { // Release image loader first so that it's refcnt can go to zero @@ -462,7 +462,7 @@ BulletFrame::ListTag(FILE* out) const return NS_OK; } -NS_METHOD +NS_IMETHODIMP BulletFrame::List(FILE* out, PRInt32 aIndent) const { PRInt32 i; @@ -724,6 +724,31 @@ BulletFrame::GetListItemText(nsIPresContext& aCX, #define MIN_BULLET_SIZE 5 // from laytext.c +static nsresult +UpdateBulletCB(nsIPresContext& aPresContext, nsIFrame* aFrame, PRIntn aStatus) +{ + nsresult rv = NS_OK; + if (NS_IMAGE_LOAD_STATUS_SIZE_AVAILABLE & aStatus) { + // Now that the size is available, trigger a reflow of the bullet + // frame. + nsIPresShell* shell; + shell = aPresContext.GetShell(); + if (nsnull != shell) { + nsIReflowCommand* cmd; + rv = NS_NewHTMLReflowCommand(&cmd, aFrame, + nsIReflowCommand::ContentChanged); + if (NS_OK == rv) { + shell->EnterReflowLock(); + shell->AppendReflowCommand(cmd); + NS_RELEASE(cmd); + shell->ExitReflowLock(); + } + NS_RELEASE(shell); + } + } + return rv; +} + void BulletFrame::GetDesiredSize(nsIPresContext* aCX, const nsReflowState& aReflowState, @@ -735,7 +760,8 @@ BulletFrame::GetDesiredSize(nsIPresContext* aCX, if (myList->mListStyleImage.Length() > 0) { mImageLoader.SetURL(myList->mListStyleImage); - mImageLoader.GetDesiredSize(aCX, aReflowState, aMetrics); + mImageLoader.GetDesiredSize(aCX, aReflowState, this, UpdateBulletCB, + aMetrics); if (!mImageLoader.GetLoadImageFailed()) { nsHTMLContainerFrame::CreateViewForFrame(*aCX, this, mStyleContext, PR_FALSE); diff --git a/mozilla/layout/generic/nsBlockReflowState.cpp b/mozilla/layout/generic/nsBlockReflowState.cpp index b6344a91102..190083e3d88 100644 --- a/mozilla/layout/generic/nsBlockReflowState.cpp +++ b/mozilla/layout/generic/nsBlockReflowState.cpp @@ -445,7 +445,7 @@ BulletFrame::QueryInterface(REFNSIID aIID, void** aInstancePtrResult) return nsFrame::QueryInterface(aIID, aInstancePtrResult); } -NS_METHOD +NS_IMETHODIMP BulletFrame::DeleteFrame(nsIPresContext& aPresContext) { // Release image loader first so that it's refcnt can go to zero @@ -462,7 +462,7 @@ BulletFrame::ListTag(FILE* out) const return NS_OK; } -NS_METHOD +NS_IMETHODIMP BulletFrame::List(FILE* out, PRInt32 aIndent) const { PRInt32 i; @@ -724,6 +724,31 @@ BulletFrame::GetListItemText(nsIPresContext& aCX, #define MIN_BULLET_SIZE 5 // from laytext.c +static nsresult +UpdateBulletCB(nsIPresContext& aPresContext, nsIFrame* aFrame, PRIntn aStatus) +{ + nsresult rv = NS_OK; + if (NS_IMAGE_LOAD_STATUS_SIZE_AVAILABLE & aStatus) { + // Now that the size is available, trigger a reflow of the bullet + // frame. + nsIPresShell* shell; + shell = aPresContext.GetShell(); + if (nsnull != shell) { + nsIReflowCommand* cmd; + rv = NS_NewHTMLReflowCommand(&cmd, aFrame, + nsIReflowCommand::ContentChanged); + if (NS_OK == rv) { + shell->EnterReflowLock(); + shell->AppendReflowCommand(cmd); + NS_RELEASE(cmd); + shell->ExitReflowLock(); + } + NS_RELEASE(shell); + } + } + return rv; +} + void BulletFrame::GetDesiredSize(nsIPresContext* aCX, const nsReflowState& aReflowState, @@ -735,7 +760,8 @@ BulletFrame::GetDesiredSize(nsIPresContext* aCX, if (myList->mListStyleImage.Length() > 0) { mImageLoader.SetURL(myList->mListStyleImage); - mImageLoader.GetDesiredSize(aCX, aReflowState, aMetrics); + mImageLoader.GetDesiredSize(aCX, aReflowState, this, UpdateBulletCB, + aMetrics); if (!mImageLoader.GetLoadImageFailed()) { nsHTMLContainerFrame::CreateViewForFrame(*aCX, this, mStyleContext, PR_FALSE); diff --git a/mozilla/layout/generic/nsBlockReflowState.h b/mozilla/layout/generic/nsBlockReflowState.h index b6344a91102..190083e3d88 100644 --- a/mozilla/layout/generic/nsBlockReflowState.h +++ b/mozilla/layout/generic/nsBlockReflowState.h @@ -445,7 +445,7 @@ BulletFrame::QueryInterface(REFNSIID aIID, void** aInstancePtrResult) return nsFrame::QueryInterface(aIID, aInstancePtrResult); } -NS_METHOD +NS_IMETHODIMP BulletFrame::DeleteFrame(nsIPresContext& aPresContext) { // Release image loader first so that it's refcnt can go to zero @@ -462,7 +462,7 @@ BulletFrame::ListTag(FILE* out) const return NS_OK; } -NS_METHOD +NS_IMETHODIMP BulletFrame::List(FILE* out, PRInt32 aIndent) const { PRInt32 i; @@ -724,6 +724,31 @@ BulletFrame::GetListItemText(nsIPresContext& aCX, #define MIN_BULLET_SIZE 5 // from laytext.c +static nsresult +UpdateBulletCB(nsIPresContext& aPresContext, nsIFrame* aFrame, PRIntn aStatus) +{ + nsresult rv = NS_OK; + if (NS_IMAGE_LOAD_STATUS_SIZE_AVAILABLE & aStatus) { + // Now that the size is available, trigger a reflow of the bullet + // frame. + nsIPresShell* shell; + shell = aPresContext.GetShell(); + if (nsnull != shell) { + nsIReflowCommand* cmd; + rv = NS_NewHTMLReflowCommand(&cmd, aFrame, + nsIReflowCommand::ContentChanged); + if (NS_OK == rv) { + shell->EnterReflowLock(); + shell->AppendReflowCommand(cmd); + NS_RELEASE(cmd); + shell->ExitReflowLock(); + } + NS_RELEASE(shell); + } + } + return rv; +} + void BulletFrame::GetDesiredSize(nsIPresContext* aCX, const nsReflowState& aReflowState, @@ -735,7 +760,8 @@ BulletFrame::GetDesiredSize(nsIPresContext* aCX, if (myList->mListStyleImage.Length() > 0) { mImageLoader.SetURL(myList->mListStyleImage); - mImageLoader.GetDesiredSize(aCX, aReflowState, aMetrics); + mImageLoader.GetDesiredSize(aCX, aReflowState, this, UpdateBulletCB, + aMetrics); if (!mImageLoader.GetLoadImageFailed()) { nsHTMLContainerFrame::CreateViewForFrame(*aCX, this, mStyleContext, PR_FALSE); diff --git a/mozilla/layout/html/base/src/nsBlockFrame.cpp b/mozilla/layout/html/base/src/nsBlockFrame.cpp index b6344a91102..190083e3d88 100644 --- a/mozilla/layout/html/base/src/nsBlockFrame.cpp +++ b/mozilla/layout/html/base/src/nsBlockFrame.cpp @@ -445,7 +445,7 @@ BulletFrame::QueryInterface(REFNSIID aIID, void** aInstancePtrResult) return nsFrame::QueryInterface(aIID, aInstancePtrResult); } -NS_METHOD +NS_IMETHODIMP BulletFrame::DeleteFrame(nsIPresContext& aPresContext) { // Release image loader first so that it's refcnt can go to zero @@ -462,7 +462,7 @@ BulletFrame::ListTag(FILE* out) const return NS_OK; } -NS_METHOD +NS_IMETHODIMP BulletFrame::List(FILE* out, PRInt32 aIndent) const { PRInt32 i; @@ -724,6 +724,31 @@ BulletFrame::GetListItemText(nsIPresContext& aCX, #define MIN_BULLET_SIZE 5 // from laytext.c +static nsresult +UpdateBulletCB(nsIPresContext& aPresContext, nsIFrame* aFrame, PRIntn aStatus) +{ + nsresult rv = NS_OK; + if (NS_IMAGE_LOAD_STATUS_SIZE_AVAILABLE & aStatus) { + // Now that the size is available, trigger a reflow of the bullet + // frame. + nsIPresShell* shell; + shell = aPresContext.GetShell(); + if (nsnull != shell) { + nsIReflowCommand* cmd; + rv = NS_NewHTMLReflowCommand(&cmd, aFrame, + nsIReflowCommand::ContentChanged); + if (NS_OK == rv) { + shell->EnterReflowLock(); + shell->AppendReflowCommand(cmd); + NS_RELEASE(cmd); + shell->ExitReflowLock(); + } + NS_RELEASE(shell); + } + } + return rv; +} + void BulletFrame::GetDesiredSize(nsIPresContext* aCX, const nsReflowState& aReflowState, @@ -735,7 +760,8 @@ BulletFrame::GetDesiredSize(nsIPresContext* aCX, if (myList->mListStyleImage.Length() > 0) { mImageLoader.SetURL(myList->mListStyleImage); - mImageLoader.GetDesiredSize(aCX, aReflowState, aMetrics); + mImageLoader.GetDesiredSize(aCX, aReflowState, this, UpdateBulletCB, + aMetrics); if (!mImageLoader.GetLoadImageFailed()) { nsHTMLContainerFrame::CreateViewForFrame(*aCX, this, mStyleContext, PR_FALSE); diff --git a/mozilla/layout/html/base/src/nsBlockReflowState.cpp b/mozilla/layout/html/base/src/nsBlockReflowState.cpp index b6344a91102..190083e3d88 100644 --- a/mozilla/layout/html/base/src/nsBlockReflowState.cpp +++ b/mozilla/layout/html/base/src/nsBlockReflowState.cpp @@ -445,7 +445,7 @@ BulletFrame::QueryInterface(REFNSIID aIID, void** aInstancePtrResult) return nsFrame::QueryInterface(aIID, aInstancePtrResult); } -NS_METHOD +NS_IMETHODIMP BulletFrame::DeleteFrame(nsIPresContext& aPresContext) { // Release image loader first so that it's refcnt can go to zero @@ -462,7 +462,7 @@ BulletFrame::ListTag(FILE* out) const return NS_OK; } -NS_METHOD +NS_IMETHODIMP BulletFrame::List(FILE* out, PRInt32 aIndent) const { PRInt32 i; @@ -724,6 +724,31 @@ BulletFrame::GetListItemText(nsIPresContext& aCX, #define MIN_BULLET_SIZE 5 // from laytext.c +static nsresult +UpdateBulletCB(nsIPresContext& aPresContext, nsIFrame* aFrame, PRIntn aStatus) +{ + nsresult rv = NS_OK; + if (NS_IMAGE_LOAD_STATUS_SIZE_AVAILABLE & aStatus) { + // Now that the size is available, trigger a reflow of the bullet + // frame. + nsIPresShell* shell; + shell = aPresContext.GetShell(); + if (nsnull != shell) { + nsIReflowCommand* cmd; + rv = NS_NewHTMLReflowCommand(&cmd, aFrame, + nsIReflowCommand::ContentChanged); + if (NS_OK == rv) { + shell->EnterReflowLock(); + shell->AppendReflowCommand(cmd); + NS_RELEASE(cmd); + shell->ExitReflowLock(); + } + NS_RELEASE(shell); + } + } + return rv; +} + void BulletFrame::GetDesiredSize(nsIPresContext* aCX, const nsReflowState& aReflowState, @@ -735,7 +760,8 @@ BulletFrame::GetDesiredSize(nsIPresContext* aCX, if (myList->mListStyleImage.Length() > 0) { mImageLoader.SetURL(myList->mListStyleImage); - mImageLoader.GetDesiredSize(aCX, aReflowState, aMetrics); + mImageLoader.GetDesiredSize(aCX, aReflowState, this, UpdateBulletCB, + aMetrics); if (!mImageLoader.GetLoadImageFailed()) { nsHTMLContainerFrame::CreateViewForFrame(*aCX, this, mStyleContext, PR_FALSE); diff --git a/mozilla/layout/html/base/src/nsBlockReflowState.h b/mozilla/layout/html/base/src/nsBlockReflowState.h index b6344a91102..190083e3d88 100644 --- a/mozilla/layout/html/base/src/nsBlockReflowState.h +++ b/mozilla/layout/html/base/src/nsBlockReflowState.h @@ -445,7 +445,7 @@ BulletFrame::QueryInterface(REFNSIID aIID, void** aInstancePtrResult) return nsFrame::QueryInterface(aIID, aInstancePtrResult); } -NS_METHOD +NS_IMETHODIMP BulletFrame::DeleteFrame(nsIPresContext& aPresContext) { // Release image loader first so that it's refcnt can go to zero @@ -462,7 +462,7 @@ BulletFrame::ListTag(FILE* out) const return NS_OK; } -NS_METHOD +NS_IMETHODIMP BulletFrame::List(FILE* out, PRInt32 aIndent) const { PRInt32 i; @@ -724,6 +724,31 @@ BulletFrame::GetListItemText(nsIPresContext& aCX, #define MIN_BULLET_SIZE 5 // from laytext.c +static nsresult +UpdateBulletCB(nsIPresContext& aPresContext, nsIFrame* aFrame, PRIntn aStatus) +{ + nsresult rv = NS_OK; + if (NS_IMAGE_LOAD_STATUS_SIZE_AVAILABLE & aStatus) { + // Now that the size is available, trigger a reflow of the bullet + // frame. + nsIPresShell* shell; + shell = aPresContext.GetShell(); + if (nsnull != shell) { + nsIReflowCommand* cmd; + rv = NS_NewHTMLReflowCommand(&cmd, aFrame, + nsIReflowCommand::ContentChanged); + if (NS_OK == rv) { + shell->EnterReflowLock(); + shell->AppendReflowCommand(cmd); + NS_RELEASE(cmd); + shell->ExitReflowLock(); + } + NS_RELEASE(shell); + } + } + return rv; +} + void BulletFrame::GetDesiredSize(nsIPresContext* aCX, const nsReflowState& aReflowState, @@ -735,7 +760,8 @@ BulletFrame::GetDesiredSize(nsIPresContext* aCX, if (myList->mListStyleImage.Length() > 0) { mImageLoader.SetURL(myList->mListStyleImage); - mImageLoader.GetDesiredSize(aCX, aReflowState, aMetrics); + mImageLoader.GetDesiredSize(aCX, aReflowState, this, UpdateBulletCB, + aMetrics); if (!mImageLoader.GetLoadImageFailed()) { nsHTMLContainerFrame::CreateViewForFrame(*aCX, this, mStyleContext, PR_FALSE);