mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Use revised image loading apis
This commit is contained in:
parent
81c9f5e866
commit
b3cd5aa101
@ -44,11 +44,47 @@ nsBulletFrame::~nsBulletFrame()
|
||||
NS_IMETHODIMP
|
||||
nsBulletFrame::DeleteFrame(nsIPresContext& aPresContext)
|
||||
{
|
||||
// Release image loader first so that its refcnt can go to zero
|
||||
mImageLoader.DestroyLoader();
|
||||
// Stop image loading first
|
||||
mImageLoader.StopAllLoadImages(&aPresContext);
|
||||
|
||||
// Let base class do the rest
|
||||
return nsFrame::DeleteFrame(aPresContext);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBulletFrame::Init(nsIPresContext& aPresContext,
|
||||
nsIContent* aContent,
|
||||
nsIFrame* aParent,
|
||||
nsIStyleContext* aContext,
|
||||
nsIFrame* aPrevInFlow)
|
||||
{
|
||||
nsresult rv = nsFrame::Init(aPresContext, aContent, aParent,
|
||||
aContext, aPrevInFlow);
|
||||
|
||||
nsIURL* baseURL = nsnull;
|
||||
nsIHTMLContent* htmlContent;
|
||||
rv = mContent->QueryInterface(kIHTMLContentIID, (void**)&htmlContent);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
htmlContent->GetBaseURL(baseURL);
|
||||
NS_RELEASE(htmlContent);
|
||||
}
|
||||
else {
|
||||
nsIDocument* doc;
|
||||
rv = mContent->GetDocument(doc);
|
||||
if (NS_SUCCEEDED(rv) && doc) {
|
||||
doc->GetBaseURL(baseURL);
|
||||
NS_RELEASE(doc);
|
||||
}
|
||||
}
|
||||
const nsStyleList* myList = (const nsStyleList*)
|
||||
mStyleContext->GetStyleData(eStyleStruct_List);
|
||||
mImageLoader.Init(this, UpdateBulletCB, this,
|
||||
baseURL, myList->mListStyleImage);
|
||||
NS_IF_RELEASE(baseURL);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBulletFrame::GetFrameName(nsString& aResult) const
|
||||
{
|
||||
@ -385,7 +421,8 @@ static PRUnichar gCJKIdeographic10KUnit[4] =
|
||||
};
|
||||
|
||||
static void CJKIdeographicToText(PRInt32 ordinal, nsString& result,
|
||||
const PRUnichar* digits, const PRUnichar *unit,
|
||||
const PRUnichar* digits,
|
||||
const PRUnichar *unit,
|
||||
const PRUnichar* unit10k)
|
||||
{
|
||||
// In theory, we need the following if condiction,
|
||||
@ -688,15 +725,19 @@ nsBulletFrame::GetListItemText(nsIPresContext& aCX,
|
||||
|
||||
#define MIN_BULLET_SIZE 5 // from laytext.c
|
||||
|
||||
static nsresult
|
||||
UpdateBulletCB(nsIPresContext& aPresContext, nsIFrame* aFrame, PRIntn aStatus)
|
||||
nsresult
|
||||
nsBulletFrame::UpdateBulletCB(nsIPresContext* aPresContext,
|
||||
nsHTMLImageLoader* aLoader,
|
||||
nsIFrame* aFrame,
|
||||
void* aClosure,
|
||||
PRUint32 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.
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
rv = aPresContext.GetShell(getter_AddRefs(shell));
|
||||
rv = aPresContext->GetShell(getter_AddRefs(shell));
|
||||
if (NS_SUCCEEDED(rv) && shell) {
|
||||
nsIReflowCommand* cmd;
|
||||
rv = NS_NewHTMLReflowCommand(&cmd, aFrame,
|
||||
@ -722,24 +763,7 @@ nsBulletFrame::GetDesiredSize(nsIPresContext* aCX,
|
||||
nscoord ascent;
|
||||
|
||||
if (myList->mListStyleImage.Length() > 0) {
|
||||
mImageLoader.SetURLSpec(myList->mListStyleImage);
|
||||
nsIURL* baseURL = nsnull;
|
||||
nsIHTMLContent* htmlContent;
|
||||
if (NS_SUCCEEDED(mContent->QueryInterface(kIHTMLContentIID, (void**)&htmlContent))) {
|
||||
htmlContent->GetBaseURL(baseURL);
|
||||
NS_RELEASE(htmlContent);
|
||||
}
|
||||
else {
|
||||
nsIDocument* doc;
|
||||
if (NS_SUCCEEDED(mContent->GetDocument(doc))) {
|
||||
doc->GetBaseURL(baseURL);
|
||||
NS_RELEASE(doc);
|
||||
}
|
||||
}
|
||||
mImageLoader.SetBaseURL(baseURL);
|
||||
NS_IF_RELEASE(baseURL);
|
||||
mImageLoader.GetDesiredSize(aCX, aReflowState, this, UpdateBulletCB,
|
||||
aMetrics);
|
||||
mImageLoader.GetDesiredSize(aCX, &aReflowState, aMetrics);
|
||||
if (!mImageLoader.GetLoadImageFailed()) {
|
||||
nsHTMLContainerFrame::CreateViewForFrame(*aCX, this, mStyleContext,
|
||||
PR_FALSE);
|
||||
|
@ -19,7 +19,8 @@
|
||||
#ifndef nsBulletFrame_h___
|
||||
#define nsBulletFrame_h___
|
||||
|
||||
#include "nsHTMLImage.h"
|
||||
#include "nsFrame.h"
|
||||
#include "nsHTMLImageLoader.h"
|
||||
#include "nsIStyleContext.h"
|
||||
|
||||
/**
|
||||
@ -32,6 +33,11 @@ public:
|
||||
virtual ~nsBulletFrame();
|
||||
|
||||
// nsIFrame
|
||||
NS_IMETHOD Init(nsIPresContext& aPresContext,
|
||||
nsIContent* aContent,
|
||||
nsIFrame* aParent,
|
||||
nsIStyleContext* aContext,
|
||||
nsIFrame* aPrevInFlow);
|
||||
NS_IMETHOD DeleteFrame(nsIPresContext& aPresContext);
|
||||
NS_IMETHOD Paint(nsIPresContext &aCX,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
@ -57,6 +63,12 @@ protected:
|
||||
const nsStyleList& aStyleList,
|
||||
nsString& aResult);
|
||||
|
||||
static nsresult UpdateBulletCB(nsIPresContext* aPresContext,
|
||||
nsHTMLImageLoader* aLoader,
|
||||
nsIFrame* aFrame,
|
||||
void* aClosure,
|
||||
PRUint32 aStatus);
|
||||
|
||||
PRInt32 mOrdinal;
|
||||
nsMargin mPadding;
|
||||
nsHTMLImageLoader mImageLoader;
|
||||
|
@ -44,11 +44,47 @@ nsBulletFrame::~nsBulletFrame()
|
||||
NS_IMETHODIMP
|
||||
nsBulletFrame::DeleteFrame(nsIPresContext& aPresContext)
|
||||
{
|
||||
// Release image loader first so that its refcnt can go to zero
|
||||
mImageLoader.DestroyLoader();
|
||||
// Stop image loading first
|
||||
mImageLoader.StopAllLoadImages(&aPresContext);
|
||||
|
||||
// Let base class do the rest
|
||||
return nsFrame::DeleteFrame(aPresContext);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBulletFrame::Init(nsIPresContext& aPresContext,
|
||||
nsIContent* aContent,
|
||||
nsIFrame* aParent,
|
||||
nsIStyleContext* aContext,
|
||||
nsIFrame* aPrevInFlow)
|
||||
{
|
||||
nsresult rv = nsFrame::Init(aPresContext, aContent, aParent,
|
||||
aContext, aPrevInFlow);
|
||||
|
||||
nsIURL* baseURL = nsnull;
|
||||
nsIHTMLContent* htmlContent;
|
||||
rv = mContent->QueryInterface(kIHTMLContentIID, (void**)&htmlContent);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
htmlContent->GetBaseURL(baseURL);
|
||||
NS_RELEASE(htmlContent);
|
||||
}
|
||||
else {
|
||||
nsIDocument* doc;
|
||||
rv = mContent->GetDocument(doc);
|
||||
if (NS_SUCCEEDED(rv) && doc) {
|
||||
doc->GetBaseURL(baseURL);
|
||||
NS_RELEASE(doc);
|
||||
}
|
||||
}
|
||||
const nsStyleList* myList = (const nsStyleList*)
|
||||
mStyleContext->GetStyleData(eStyleStruct_List);
|
||||
mImageLoader.Init(this, UpdateBulletCB, this,
|
||||
baseURL, myList->mListStyleImage);
|
||||
NS_IF_RELEASE(baseURL);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBulletFrame::GetFrameName(nsString& aResult) const
|
||||
{
|
||||
@ -385,7 +421,8 @@ static PRUnichar gCJKIdeographic10KUnit[4] =
|
||||
};
|
||||
|
||||
static void CJKIdeographicToText(PRInt32 ordinal, nsString& result,
|
||||
const PRUnichar* digits, const PRUnichar *unit,
|
||||
const PRUnichar* digits,
|
||||
const PRUnichar *unit,
|
||||
const PRUnichar* unit10k)
|
||||
{
|
||||
// In theory, we need the following if condiction,
|
||||
@ -688,15 +725,19 @@ nsBulletFrame::GetListItemText(nsIPresContext& aCX,
|
||||
|
||||
#define MIN_BULLET_SIZE 5 // from laytext.c
|
||||
|
||||
static nsresult
|
||||
UpdateBulletCB(nsIPresContext& aPresContext, nsIFrame* aFrame, PRIntn aStatus)
|
||||
nsresult
|
||||
nsBulletFrame::UpdateBulletCB(nsIPresContext* aPresContext,
|
||||
nsHTMLImageLoader* aLoader,
|
||||
nsIFrame* aFrame,
|
||||
void* aClosure,
|
||||
PRUint32 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.
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
rv = aPresContext.GetShell(getter_AddRefs(shell));
|
||||
rv = aPresContext->GetShell(getter_AddRefs(shell));
|
||||
if (NS_SUCCEEDED(rv) && shell) {
|
||||
nsIReflowCommand* cmd;
|
||||
rv = NS_NewHTMLReflowCommand(&cmd, aFrame,
|
||||
@ -722,24 +763,7 @@ nsBulletFrame::GetDesiredSize(nsIPresContext* aCX,
|
||||
nscoord ascent;
|
||||
|
||||
if (myList->mListStyleImage.Length() > 0) {
|
||||
mImageLoader.SetURLSpec(myList->mListStyleImage);
|
||||
nsIURL* baseURL = nsnull;
|
||||
nsIHTMLContent* htmlContent;
|
||||
if (NS_SUCCEEDED(mContent->QueryInterface(kIHTMLContentIID, (void**)&htmlContent))) {
|
||||
htmlContent->GetBaseURL(baseURL);
|
||||
NS_RELEASE(htmlContent);
|
||||
}
|
||||
else {
|
||||
nsIDocument* doc;
|
||||
if (NS_SUCCEEDED(mContent->GetDocument(doc))) {
|
||||
doc->GetBaseURL(baseURL);
|
||||
NS_RELEASE(doc);
|
||||
}
|
||||
}
|
||||
mImageLoader.SetBaseURL(baseURL);
|
||||
NS_IF_RELEASE(baseURL);
|
||||
mImageLoader.GetDesiredSize(aCX, aReflowState, this, UpdateBulletCB,
|
||||
aMetrics);
|
||||
mImageLoader.GetDesiredSize(aCX, &aReflowState, aMetrics);
|
||||
if (!mImageLoader.GetLoadImageFailed()) {
|
||||
nsHTMLContainerFrame::CreateViewForFrame(*aCX, this, mStyleContext,
|
||||
PR_FALSE);
|
||||
|
@ -19,7 +19,8 @@
|
||||
#ifndef nsBulletFrame_h___
|
||||
#define nsBulletFrame_h___
|
||||
|
||||
#include "nsHTMLImage.h"
|
||||
#include "nsFrame.h"
|
||||
#include "nsHTMLImageLoader.h"
|
||||
#include "nsIStyleContext.h"
|
||||
|
||||
/**
|
||||
@ -32,6 +33,11 @@ public:
|
||||
virtual ~nsBulletFrame();
|
||||
|
||||
// nsIFrame
|
||||
NS_IMETHOD Init(nsIPresContext& aPresContext,
|
||||
nsIContent* aContent,
|
||||
nsIFrame* aParent,
|
||||
nsIStyleContext* aContext,
|
||||
nsIFrame* aPrevInFlow);
|
||||
NS_IMETHOD DeleteFrame(nsIPresContext& aPresContext);
|
||||
NS_IMETHOD Paint(nsIPresContext &aCX,
|
||||
nsIRenderingContext& aRenderingContext,
|
||||
@ -57,6 +63,12 @@ protected:
|
||||
const nsStyleList& aStyleList,
|
||||
nsString& aResult);
|
||||
|
||||
static nsresult UpdateBulletCB(nsIPresContext* aPresContext,
|
||||
nsHTMLImageLoader* aLoader,
|
||||
nsIFrame* aFrame,
|
||||
void* aClosure,
|
||||
PRUint32 aStatus);
|
||||
|
||||
PRInt32 mOrdinal;
|
||||
nsMargin mPadding;
|
||||
nsHTMLImageLoader mImageLoader;
|
||||
|
Loading…
Reference in New Issue
Block a user