Fixes for printing bugs 84017 and 89151. The fix for bug 84017 removes the need for a resize reflow to get form frame values to print. The restoration of these values into the new frame model is done as part of the initial reflow. The fix for bug 89151 gets rid of the extra frame model built and forces printed images to come out of the decoded image cache. r=darinf, heikki, sr=rpotts

This commit is contained in:
vidur%netscape.com 2001-09-29 17:50:15 +00:00
parent 4d223104e1
commit 4966d85f91
38 changed files with 146 additions and 265 deletions

View File

@ -345,10 +345,6 @@ public:
void OnStartPrinting();
nsCOMPtr<nsIDeviceContext> mPrintDC;
nsCOMPtr<nsIPresContext> mPrintPC;
nsCOMPtr<nsIStyleSet> mPrintSS;
nsCOMPtr<nsIPresShell> mPrintPS;
nsCOMPtr<nsIViewManager> mPrintVM;
nsIView *mPrintView;
FILE *mFilePointer; // a file where information can go to when printing
@ -719,19 +715,13 @@ PrintData::~PrintData()
// printing is complete, clean up now
if (mPrintPS) {
// XXX we never call BeginObservingDocument on this pres shell.
mPrintPS->EndObservingDocument();
mPrintPS->Destroy();
}
OnEndPrinting(NS_OK); // removes listener
if (mPrintPS) {
mPrintDC->EndDocument();
if (mPrintDC) {
#ifdef DEBUG_PRINTING
fprintf(mDebugFD, "****************** End Document ************************\n");
#endif
mPrintDC->EndDocument();
}
delete mPrintObject;
@ -2839,6 +2829,9 @@ DocumentViewerImpl::ReflowPrintObject(PrintObject * aPO)
NS_ENSURE_SUCCESS(GetPresShell(*(getter_AddRefs(presShell))), NS_ERROR_FAILURE);
presShell->CaptureHistoryState(getter_AddRefs(layoutState),PR_TRUE);
// set it on the new pres shell
aPO->mPresShell->SetHistoryState(layoutState);
aPO->mPresShell->BeginObservingDocument();
nsMargin margin(0,0,0,0);
@ -2877,12 +2870,7 @@ DocumentViewerImpl::ReflowPrintObject(PrintObject * aPO)
}
aPO->mPresContext->SetPageDim(&adjRect);
// XXX replace this line with the commented one below when bug 101264 is fixed
// By doing an intitial reflow with an unconstrained height, we avoid doing a
// resize reflow where frames have already been split and avoid buggy pull up code.
// See also bug 101264 in nsSimplePageSequencer::Reflow.
rv = aPO->mPresShell->InitialReflow(width, NS_MAXSIZE);
//rv = aPO->mPresShell->InitialReflow(width, height);
rv = aPO->mPresShell->InitialReflow(width, height);
if (NS_SUCCEEDED(rv)) {
// Transfer Selection Ranges to the new Print PresShell
@ -2918,22 +2906,9 @@ DocumentViewerImpl::ReflowPrintObject(PrintObject * aPO)
fclose(fd);
}
#endif
// update the history from the old presentation shell
nsCOMPtr<nsIFrameManager> fm;
rv = aPO->mPresShell->GetFrameManager(getter_AddRefs(fm));
if(NS_SUCCEEDED(rv) && fm) {
nsIFrame* root;
aPO->mPresShell->GetRootFrame(&root);
fm->RestoreFrameState(aPO->mPresContext, root, layoutState);
}
}
aPO->mPresShell->EndObservingDocument();
// EndObserving document no longer does a reflow.. which history needs.. or we
// get a blank page for text fields. this will reflow.. fixes bug 84017.
// XXX remove this line when bug 101264 is fixed
aPO->mPresShell->ResizeReflow(width, height);
return rv;
}
@ -4407,85 +4382,6 @@ nsresult rv;
NS_RELEASE(devspec);
if(webContainer) {
// load the document and do the initial reflow on the entire document
nsCOMPtr<nsIPrintContext> printcon(do_CreateInstance(kPrintContextCID, &rv));
if (NS_FAILED(rv)) {
gCurrentlyPrinting = PR_FALSE;
ShowPrintErrorDialog(rv);
return rv;
} else {
mPrt->mPrintPC = do_QueryInterface(printcon, &rv);
if (NS_FAILED(rv)) {
gCurrentlyPrinting = PR_FALSE;
ShowPrintErrorDialog(rv);
return rv;
}
}
PRInt32 width, height;
mPrt->mPrintDC->GetDeviceSurfaceDimensions(width,height);
// XXX - Hack Alert
// OK, so ther eis a selection, we will print the entire selection
// on one page and then crop the page.
// This means you can never print any selection that is longer than one page
// put it keeps it from page breaking in the middle of your print of the selection
if (isSelection) {
//height = 0x0FFFFFFF;
}
mPrt->mPrintPC->Init(mPrt->mPrintDC);
mPrt->mPrintPC->SetContainer(webContainer);
CreateStyleSet(mDocument, getter_AddRefs(mPrt->mPrintSS));
mPrt->mPrintPS = do_CreateInstance(kPresShellCID, &rv);
if(NS_FAILED(rv)){
gCurrentlyPrinting = PR_FALSE;
ShowPrintErrorDialog(rv);
return rv;
}
mPrt->mPrintVM = do_CreateInstance(kViewManagerCID, &rv);
if(NS_FAILED(rv)) {
gCurrentlyPrinting = PR_FALSE;
ShowPrintErrorDialog(rv);
return rv;
}
rv = mPrt->mPrintVM->Init(mPrt->mPrintDC);
if(NS_FAILED(rv)) {
gCurrentlyPrinting = PR_FALSE;
ShowPrintErrorDialog(rv);
return rv;
}
rv = CallCreateInstance(kViewCID, &mPrt->mPrintView);
if(NS_FAILED(rv)) {
gCurrentlyPrinting = PR_FALSE;
ShowPrintErrorDialog(rv);
return rv;
}
nsRect tbounds = nsRect(0,0,width,height);
rv = mPrt->mPrintView->Init(mPrt->mPrintVM,tbounds,nsnull);
if(NS_FAILED(rv)) {
gCurrentlyPrinting = PR_FALSE;
ShowPrintErrorDialog(rv);
return rv;
}
// setup hierarchical relationship in view manager
mPrt->mPrintVM->SetRootView(mPrt->mPrintView);
mPrt->mPrintPS->Init(mDocument,mPrt->mPrintPC,mPrt->mPrintVM,mPrt->mPrintSS);
// Compatability mode must be set in the mPrintPC or the document
// will be printed in "Standard" mode even if it was a "Quirks" doc
nsCompatibility mode;
mPresContext->GetCompatibilityMode(&mode);
mPrt->mPrintPC->SetCompatibilityMode(mode);
mPrt->mPrintPS->InitialReflow(width,height);
#ifdef DEBUG_dcone
float a1,a2;
PRInt32 i1,i2;

View File

@ -44,6 +44,7 @@ REQUIRES = xpcom \
pref \
htmlparser \
view \
necko \
$(NULL)
CPPSRCS = \

View File

@ -42,6 +42,7 @@ REQUIRES = xpcom \
gfx \
layout \
layout_xul \
necko \
$(NULL)
include <$(DEPTH)\config\config.mak>

View File

@ -941,7 +941,7 @@ nsHTMLImageElement::SetSrcInner(nsIURI* aBaseURL,
doc->GetDocumentLoadGroup(getter_AddRefs(loadGroup));
}
il->LoadImage(uri, loadGroup, this, sup, nsIRequest::LOAD_NORMAL, getter_AddRefs(mRequest));
il->LoadImage(uri, loadGroup, this, sup, nsIRequest::LOAD_NORMAL, nsnull, getter_AddRefs(mRequest));
}
}

View File

@ -535,7 +535,7 @@ nsXBLPrototypeBinding::LoadResources(PRBool* aResult)
// Now kick off the image load
nsCOMPtr<imgIRequest> req;
il->LoadImage(url, nsnull, nsnull, nsnull, nsIRequest::LOAD_BACKGROUND, getter_AddRefs(req));
il->LoadImage(url, nsnull, nsnull, nsnull, nsIRequest::LOAD_BACKGROUND, nsnull, getter_AddRefs(req));
}
else
#endif

View File

@ -345,10 +345,6 @@ public:
void OnStartPrinting();
nsCOMPtr<nsIDeviceContext> mPrintDC;
nsCOMPtr<nsIPresContext> mPrintPC;
nsCOMPtr<nsIStyleSet> mPrintSS;
nsCOMPtr<nsIPresShell> mPrintPS;
nsCOMPtr<nsIViewManager> mPrintVM;
nsIView *mPrintView;
FILE *mFilePointer; // a file where information can go to when printing
@ -719,19 +715,13 @@ PrintData::~PrintData()
// printing is complete, clean up now
if (mPrintPS) {
// XXX we never call BeginObservingDocument on this pres shell.
mPrintPS->EndObservingDocument();
mPrintPS->Destroy();
}
OnEndPrinting(NS_OK); // removes listener
if (mPrintPS) {
mPrintDC->EndDocument();
if (mPrintDC) {
#ifdef DEBUG_PRINTING
fprintf(mDebugFD, "****************** End Document ************************\n");
#endif
mPrintDC->EndDocument();
}
delete mPrintObject;
@ -2839,6 +2829,9 @@ DocumentViewerImpl::ReflowPrintObject(PrintObject * aPO)
NS_ENSURE_SUCCESS(GetPresShell(*(getter_AddRefs(presShell))), NS_ERROR_FAILURE);
presShell->CaptureHistoryState(getter_AddRefs(layoutState),PR_TRUE);
// set it on the new pres shell
aPO->mPresShell->SetHistoryState(layoutState);
aPO->mPresShell->BeginObservingDocument();
nsMargin margin(0,0,0,0);
@ -2877,12 +2870,7 @@ DocumentViewerImpl::ReflowPrintObject(PrintObject * aPO)
}
aPO->mPresContext->SetPageDim(&adjRect);
// XXX replace this line with the commented one below when bug 101264 is fixed
// By doing an intitial reflow with an unconstrained height, we avoid doing a
// resize reflow where frames have already been split and avoid buggy pull up code.
// See also bug 101264 in nsSimplePageSequencer::Reflow.
rv = aPO->mPresShell->InitialReflow(width, NS_MAXSIZE);
//rv = aPO->mPresShell->InitialReflow(width, height);
rv = aPO->mPresShell->InitialReflow(width, height);
if (NS_SUCCEEDED(rv)) {
// Transfer Selection Ranges to the new Print PresShell
@ -2918,22 +2906,9 @@ DocumentViewerImpl::ReflowPrintObject(PrintObject * aPO)
fclose(fd);
}
#endif
// update the history from the old presentation shell
nsCOMPtr<nsIFrameManager> fm;
rv = aPO->mPresShell->GetFrameManager(getter_AddRefs(fm));
if(NS_SUCCEEDED(rv) && fm) {
nsIFrame* root;
aPO->mPresShell->GetRootFrame(&root);
fm->RestoreFrameState(aPO->mPresContext, root, layoutState);
}
}
aPO->mPresShell->EndObservingDocument();
// EndObserving document no longer does a reflow.. which history needs.. or we
// get a blank page for text fields. this will reflow.. fixes bug 84017.
// XXX remove this line when bug 101264 is fixed
aPO->mPresShell->ResizeReflow(width, height);
return rv;
}
@ -4407,85 +4382,6 @@ nsresult rv;
NS_RELEASE(devspec);
if(webContainer) {
// load the document and do the initial reflow on the entire document
nsCOMPtr<nsIPrintContext> printcon(do_CreateInstance(kPrintContextCID, &rv));
if (NS_FAILED(rv)) {
gCurrentlyPrinting = PR_FALSE;
ShowPrintErrorDialog(rv);
return rv;
} else {
mPrt->mPrintPC = do_QueryInterface(printcon, &rv);
if (NS_FAILED(rv)) {
gCurrentlyPrinting = PR_FALSE;
ShowPrintErrorDialog(rv);
return rv;
}
}
PRInt32 width, height;
mPrt->mPrintDC->GetDeviceSurfaceDimensions(width,height);
// XXX - Hack Alert
// OK, so ther eis a selection, we will print the entire selection
// on one page and then crop the page.
// This means you can never print any selection that is longer than one page
// put it keeps it from page breaking in the middle of your print of the selection
if (isSelection) {
//height = 0x0FFFFFFF;
}
mPrt->mPrintPC->Init(mPrt->mPrintDC);
mPrt->mPrintPC->SetContainer(webContainer);
CreateStyleSet(mDocument, getter_AddRefs(mPrt->mPrintSS));
mPrt->mPrintPS = do_CreateInstance(kPresShellCID, &rv);
if(NS_FAILED(rv)){
gCurrentlyPrinting = PR_FALSE;
ShowPrintErrorDialog(rv);
return rv;
}
mPrt->mPrintVM = do_CreateInstance(kViewManagerCID, &rv);
if(NS_FAILED(rv)) {
gCurrentlyPrinting = PR_FALSE;
ShowPrintErrorDialog(rv);
return rv;
}
rv = mPrt->mPrintVM->Init(mPrt->mPrintDC);
if(NS_FAILED(rv)) {
gCurrentlyPrinting = PR_FALSE;
ShowPrintErrorDialog(rv);
return rv;
}
rv = CallCreateInstance(kViewCID, &mPrt->mPrintView);
if(NS_FAILED(rv)) {
gCurrentlyPrinting = PR_FALSE;
ShowPrintErrorDialog(rv);
return rv;
}
nsRect tbounds = nsRect(0,0,width,height);
rv = mPrt->mPrintView->Init(mPrt->mPrintVM,tbounds,nsnull);
if(NS_FAILED(rv)) {
gCurrentlyPrinting = PR_FALSE;
ShowPrintErrorDialog(rv);
return rv;
}
// setup hierarchical relationship in view manager
mPrt->mPrintVM->SetRootView(mPrt->mPrintView);
mPrt->mPrintPS->Init(mDocument,mPrt->mPrintPC,mPrt->mPrintVM,mPrt->mPrintSS);
// Compatability mode must be set in the mPrintPC or the document
// will be printed in "Standard" mode even if it was a "Quirks" doc
nsCompatibility mode;
mPresContext->GetCompatibilityMode(&mode);
mPrt->mPrintPC->SetCompatibilityMode(mode);
mPrt->mPrintPS->InitialReflow(width,height);
#ifdef DEBUG_dcone
float a1,a2;
PRInt32 i1,i2;

View File

@ -2167,6 +2167,11 @@ FrameManager::RestoreFrameStateFor(nsIPresContext* aPresContext, nsIFrame* aFram
nsresult rv = NS_OK;
nsCOMPtr<nsIContent> content;
rv = aFrame->GetContent(getter_AddRefs(content));
// If we don't have content, we can't generate a hash
// key and there's probably no state information for us.
if (!content) {
return rv;
}
nsCAutoString stateKey;
rv = GenerateStateKey(content, aID, stateKey);

View File

@ -119,7 +119,7 @@ nsImageLoader::Load(const nsAReadableString &aURI)
if (NS_FAILED(rv)) return rv;
return il->LoadImage(uri, loadGroup, NS_STATIC_CAST(imgIDecoderObserver *, this),
nsnull, nsIRequest::LOAD_BACKGROUND, getter_AddRefs(mRequest));
nsnull, nsIRequest::LOAD_BACKGROUND, nsnull, getter_AddRefs(mRequest));
}

View File

@ -1332,6 +1332,13 @@ nsPresContext::GetDeviceContext(nsIDeviceContext** aResult) const
return NS_OK;
}
NS_IMETHODIMP
nsPresContext::GetImageLoadFlags(nsLoadFlags& aLoadFlags)
{
aLoadFlags = nsIRequest::LOAD_NORMAL;
return NS_OK;
}
NS_IMETHODIMP
nsPresContext::LoadImage(const nsString& aURL,
nsIFrame* aTargetFrame,

View File

@ -42,6 +42,7 @@
#include "nsColor.h"
#include "nsCoord.h"
#include "nsAWritableString.h"
#include "nsIRequest.h"
#ifdef IBMBIDI
class nsBidiPresUtils;
#endif // IBMBIDI
@ -165,6 +166,11 @@ public:
NS_IMETHOD GetImageAnimationMode(nsImageAnimation* aModeResult) = 0;
NS_IMETHOD SetImageAnimationMode(nsImageAnimation aMode) = 0;
/**
* Get an special load flags for images for this context
*/
NS_IMETHOD GetImageLoadFlags(nsLoadFlags& aLoadFlags) = 0;
/**
* Get look and feel object
*/

View File

@ -2630,6 +2630,11 @@ PresShell::InitialReflow(nscoord aWidth, nscoord aHeight)
}
if (rootFrame) {
nsCOMPtr<nsILayoutHistoryState> historyState = do_QueryReferent(mHistoryState);
if (historyState) {
mFrameManager->RestoreFrameState(mPresContext, rootFrame, historyState);
}
MOZ_TIMER_DEBUGLOG(("Reset and start: Reflow: PresShell::InitialReflow(), this=%p\n", this));
MOZ_TIMER_RESET(mReflowWatch);
MOZ_TIMER_START(mReflowWatch);

View File

@ -42,6 +42,7 @@
#include "nsColor.h"
#include "nsCoord.h"
#include "nsAWritableString.h"
#include "nsIRequest.h"
#ifdef IBMBIDI
class nsBidiPresUtils;
#endif // IBMBIDI
@ -165,6 +166,11 @@ public:
NS_IMETHOD GetImageAnimationMode(nsImageAnimation* aModeResult) = 0;
NS_IMETHOD SetImageAnimationMode(nsImageAnimation aMode) = 0;
/**
* Get an special load flags for images for this context
*/
NS_IMETHOD GetImageLoadFlags(nsLoadFlags& aLoadFlags) = 0;
/**
* Get look and feel object
*/

View File

@ -42,6 +42,7 @@
#include "nsColor.h"
#include "nsCoord.h"
#include "nsAWritableString.h"
#include "nsIRequest.h"
#ifdef IBMBIDI
class nsBidiPresUtils;
#endif // IBMBIDI
@ -165,6 +166,11 @@ public:
NS_IMETHOD GetImageAnimationMode(nsImageAnimation* aModeResult) = 0;
NS_IMETHOD SetImageAnimationMode(nsImageAnimation aMode) = 0;
/**
* Get an special load flags for images for this context
*/
NS_IMETHOD GetImageLoadFlags(nsLoadFlags& aLoadFlags) = 0;
/**
* Get look and feel object
*/

View File

@ -119,7 +119,7 @@ nsImageLoader::Load(const nsAReadableString &aURI)
if (NS_FAILED(rv)) return rv;
return il->LoadImage(uri, loadGroup, NS_STATIC_CAST(imgIDecoderObserver *, this),
nsnull, nsIRequest::LOAD_BACKGROUND, getter_AddRefs(mRequest));
nsnull, nsIRequest::LOAD_BACKGROUND, nsnull, getter_AddRefs(mRequest));
}

View File

@ -1332,6 +1332,13 @@ nsPresContext::GetDeviceContext(nsIDeviceContext** aResult) const
return NS_OK;
}
NS_IMETHODIMP
nsPresContext::GetImageLoadFlags(nsLoadFlags& aLoadFlags)
{
aLoadFlags = nsIRequest::LOAD_NORMAL;
return NS_OK;
}
NS_IMETHODIMP
nsPresContext::LoadImage(const nsString& aURL,
nsIFrame* aTargetFrame,

View File

@ -74,6 +74,7 @@ public:
NS_IMETHOD SetWidgetRenderingMode(nsWidgetRendering aMode);
NS_IMETHOD GetImageAnimationMode(nsImageAnimation* aModeResult);
NS_IMETHOD SetImageAnimationMode(nsImageAnimation aMode);
NS_IMETHOD GetImageLoadFlags(nsLoadFlags& aLoadFlags);
NS_IMETHOD GetLookAndFeel(nsILookAndFeel** aLookAndFeel);
NS_IMETHOD GetBaseURL(nsIURI** aURLResult);
NS_IMETHOD GetMedium(nsIAtom** aMediumResult) = 0;

View File

@ -57,6 +57,7 @@ public:
PrintContext();
~PrintContext();
NS_IMETHOD GetImageLoadFlags(nsLoadFlags& aLoadFlags);
NS_IMETHOD GetMedium(nsIAtom** aMedium);
NS_IMETHOD IsPaginated(PRBool* aResult);
NS_IMETHOD GetPageDim(nsRect* aActualRect, nsRect* aAdjRect);
@ -93,7 +94,12 @@ PrintContext::QueryInterface(REFNSIID aIID, void** aInstancePtr)
return nsPresContext::QueryInterface(aIID, aInstancePtr);
}
NS_IMETHODIMP
PrintContext::GetImageLoadFlags(nsLoadFlags& aLoadFlags)
{
aLoadFlags = nsIRequest::LOAD_FROM_CACHE | nsIRequest::VALIDATE_NEVER | nsIRequest::LOAD_NORMAL;
return NS_OK;
}
NS_IMETHODIMP
PrintContext::GetMedium(nsIAtom** aResult)

View File

@ -40,6 +40,7 @@ REQUIRES = xpcom \
widget \
locale \
timer \
necko \
$(NULL)
CPPSRCS = \

View File

@ -29,6 +29,7 @@ REQUIRES = xpcom \
gfx \
content \
layout_xul \
necko \
$(NULL)
include <$(DEPTH)/config/config.mak>

View File

@ -145,7 +145,7 @@ nsBulletFrame::Init(nsIPresContext* aPresContext,
NS_RELEASE(listener);
}
il->LoadImage(imgURI, loadGroup, mListener, aPresContext, nsIRequest::LOAD_NORMAL, getter_AddRefs(mImageRequest));
il->LoadImage(imgURI, loadGroup, mListener, aPresContext, nsIRequest::LOAD_NORMAL, nsnull, getter_AddRefs(mImageRequest));
}
return NS_OK;
@ -1383,7 +1383,7 @@ nsBulletFrame::Reflow(nsIPresContext* aPresContext,
nsCOMPtr<nsILoadGroup> loadGroup;
GetLoadGroup(aPresContext, getter_AddRefs(loadGroup));
il->LoadImage(newURI, loadGroup, mListener, aPresContext, nsIRequest::LOAD_NORMAL, getter_AddRefs(mImageRequest));
il->LoadImage(newURI, loadGroup, mListener, aPresContext, nsIRequest::LOAD_NORMAL, nsnull, getter_AddRefs(mImageRequest));
}
}
}

View File

@ -1547,6 +1547,11 @@ nsImageFrame::LoadImage(const nsAReadableString& aSpec, nsIPresContext *aPresCon
nsCOMPtr<nsILoadGroup> loadGroup;
GetLoadGroup(aPresContext, getter_AddRefs(loadGroup));
nsLoadFlags loadFlags = nsIRequest::LOAD_NORMAL;
if (aPresContext) {
aPresContext->GetImageLoadFlags(loadFlags);
}
/* get the URI, convert internal-gopher-stuff if needed */
nsCOMPtr<nsIURI> uri;
GetURI(aSpec, getter_AddRefs(uri));
@ -1556,7 +1561,7 @@ nsImageFrame::LoadImage(const nsAReadableString& aSpec, nsIPresContext *aPresCon
/* set this back to FALSE before we do the real load */
mInitialLoadCompleted = PR_FALSE;
return il->LoadImage(uri, loadGroup, mListener, aPresContext, nsIRequest::LOAD_NORMAL, aRequest);
return il->LoadImage(uri, loadGroup, mListener, aPresContext, loadFlags, nsnull, aRequest);
}
#define INTERNAL_GOPHER_LENGTH 16 /* "internal-gopher-" length */

View File

@ -304,12 +304,6 @@ nsSimplePageSequenceFrame::Reflow(nsIPresContext* aPresContext,
nsRect adjSize;
aPresContext->GetPageDim(&pageSize, &adjSize);
// XXX remove these 4 lines when bug 101264 is fixed. See also bug 101264 in nsDocumentViewer::ReflowPrintObject
if (NS_UNCONSTRAINEDSIZE == aReflowState.availableHeight) {
pageSize.height = NS_UNCONSTRAINEDSIZE;
adjSize.height = NS_UNCONSTRAINEDSIZE;
}
PRBool suppressLeftMargin = PR_FALSE;
PRBool suppressRightMargin = PR_FALSE;
PRBool suppressTopMargin = PR_FALSE;
@ -382,11 +376,7 @@ nsSimplePageSequenceFrame::Reflow(nsIPresContext* aPresContext,
availSize, reflowReason);
nsReflowStatus status;
kidReflowState.availableWidth = pageSize.width - margin.left - margin.right;
// XXX remove these 3 lines when bug 101264 is fixed. See also bug 101264 in nsDocumentViewer::ReflowPrintObject
if (NS_UNCONSTRAINEDSIZE != pageSize.height) {
kidReflowState.availableHeight = pageSize.height - margin.top - margin.bottom;
}
//kidReflowState.availableHeight = pageSize.height - margin.top - margin.bottom;
kidReflowState.availableHeight = pageSize.height - margin.top - margin.bottom;
kidReflowState.mComputedWidth = kidReflowState.availableWidth;
//kidReflowState.mComputedHeight = kidReflowState.availableHeight;

View File

@ -145,7 +145,7 @@ nsBulletFrame::Init(nsIPresContext* aPresContext,
NS_RELEASE(listener);
}
il->LoadImage(imgURI, loadGroup, mListener, aPresContext, nsIRequest::LOAD_NORMAL, getter_AddRefs(mImageRequest));
il->LoadImage(imgURI, loadGroup, mListener, aPresContext, nsIRequest::LOAD_NORMAL, nsnull, getter_AddRefs(mImageRequest));
}
return NS_OK;
@ -1383,7 +1383,7 @@ nsBulletFrame::Reflow(nsIPresContext* aPresContext,
nsCOMPtr<nsILoadGroup> loadGroup;
GetLoadGroup(aPresContext, getter_AddRefs(loadGroup));
il->LoadImage(newURI, loadGroup, mListener, aPresContext, nsIRequest::LOAD_NORMAL, getter_AddRefs(mImageRequest));
il->LoadImage(newURI, loadGroup, mListener, aPresContext, nsIRequest::LOAD_NORMAL, nsnull, getter_AddRefs(mImageRequest));
}
}
}

View File

@ -2167,6 +2167,11 @@ FrameManager::RestoreFrameStateFor(nsIPresContext* aPresContext, nsIFrame* aFram
nsresult rv = NS_OK;
nsCOMPtr<nsIContent> content;
rv = aFrame->GetContent(getter_AddRefs(content));
// If we don't have content, we can't generate a hash
// key and there's probably no state information for us.
if (!content) {
return rv;
}
nsCAutoString stateKey;
rv = GenerateStateKey(content, aID, stateKey);

View File

@ -1547,6 +1547,11 @@ nsImageFrame::LoadImage(const nsAReadableString& aSpec, nsIPresContext *aPresCon
nsCOMPtr<nsILoadGroup> loadGroup;
GetLoadGroup(aPresContext, getter_AddRefs(loadGroup));
nsLoadFlags loadFlags = nsIRequest::LOAD_NORMAL;
if (aPresContext) {
aPresContext->GetImageLoadFlags(loadFlags);
}
/* get the URI, convert internal-gopher-stuff if needed */
nsCOMPtr<nsIURI> uri;
GetURI(aSpec, getter_AddRefs(uri));
@ -1556,7 +1561,7 @@ nsImageFrame::LoadImage(const nsAReadableString& aSpec, nsIPresContext *aPresCon
/* set this back to FALSE before we do the real load */
mInitialLoadCompleted = PR_FALSE;
return il->LoadImage(uri, loadGroup, mListener, aPresContext, nsIRequest::LOAD_NORMAL, aRequest);
return il->LoadImage(uri, loadGroup, mListener, aPresContext, loadFlags, nsnull, aRequest);
}
#define INTERNAL_GOPHER_LENGTH 16 /* "internal-gopher-" length */

View File

@ -2630,6 +2630,11 @@ PresShell::InitialReflow(nscoord aWidth, nscoord aHeight)
}
if (rootFrame) {
nsCOMPtr<nsILayoutHistoryState> historyState = do_QueryReferent(mHistoryState);
if (historyState) {
mFrameManager->RestoreFrameState(mPresContext, rootFrame, historyState);
}
MOZ_TIMER_DEBUGLOG(("Reset and start: Reflow: PresShell::InitialReflow(), this=%p\n", this));
MOZ_TIMER_RESET(mReflowWatch);
MOZ_TIMER_START(mReflowWatch);

View File

@ -304,12 +304,6 @@ nsSimplePageSequenceFrame::Reflow(nsIPresContext* aPresContext,
nsRect adjSize;
aPresContext->GetPageDim(&pageSize, &adjSize);
// XXX remove these 4 lines when bug 101264 is fixed. See also bug 101264 in nsDocumentViewer::ReflowPrintObject
if (NS_UNCONSTRAINEDSIZE == aReflowState.availableHeight) {
pageSize.height = NS_UNCONSTRAINEDSIZE;
adjSize.height = NS_UNCONSTRAINEDSIZE;
}
PRBool suppressLeftMargin = PR_FALSE;
PRBool suppressRightMargin = PR_FALSE;
PRBool suppressTopMargin = PR_FALSE;
@ -382,11 +376,7 @@ nsSimplePageSequenceFrame::Reflow(nsIPresContext* aPresContext,
availSize, reflowReason);
nsReflowStatus status;
kidReflowState.availableWidth = pageSize.width - margin.left - margin.right;
// XXX remove these 3 lines when bug 101264 is fixed. See also bug 101264 in nsDocumentViewer::ReflowPrintObject
if (NS_UNCONSTRAINEDSIZE != pageSize.height) {
kidReflowState.availableHeight = pageSize.height - margin.top - margin.bottom;
}
//kidReflowState.availableHeight = pageSize.height - margin.top - margin.bottom;
kidReflowState.availableHeight = pageSize.height - margin.top - margin.bottom;
kidReflowState.mComputedWidth = kidReflowState.availableWidth;
//kidReflowState.mComputedHeight = kidReflowState.availableHeight;

View File

@ -38,6 +38,7 @@ REQUIRES = xpcom \
webshell \
view \
accessibility \
necko \
$(NULL)
CPPSRCS = \

View File

@ -33,6 +33,7 @@ REQUIRES = xpcom \
accessibility \
gfx \
content \
necko \
$(NULL)

View File

@ -287,7 +287,7 @@ nsImageBoxFrame::UpdateImage(nsIPresContext* aPresContext, PRBool& aResize)
nsCOMPtr<nsILoadGroup> loadGroup;
GetLoadGroup(aPresContext, getter_AddRefs(loadGroup));
il->LoadImage(srcURI, loadGroup, mListener, aPresContext, nsIRequest::LOAD_NORMAL, getter_AddRefs(mImageRequest));
il->LoadImage(srcURI, loadGroup, mListener, aPresContext, nsIRequest::LOAD_NORMAL, nsnull, getter_AddRefs(mImageRequest));
aResize = PR_TRUE;

View File

@ -1336,7 +1336,7 @@ nsOutlinerBodyFrame::GetImage(PRInt32 aRowIndex, const PRUnichar* aColID,
nsresult rv;
nsCOMPtr<imgILoader> il(do_GetService("@mozilla.org/image/loader;1", &rv));
il->LoadImage(srcURI, nsnull, listener, mPresContext, nsIRequest::LOAD_NORMAL, getter_AddRefs(imageRequest));
il->LoadImage(srcURI, nsnull, listener, mPresContext, nsIRequest::LOAD_NORMAL, nsnull, getter_AddRefs(imageRequest));
if (!mImageCache) {
mImageCache = new nsSupportsHashtable(32);

View File

@ -1336,7 +1336,7 @@ nsOutlinerBodyFrame::GetImage(PRInt32 aRowIndex, const PRUnichar* aColID,
nsresult rv;
nsCOMPtr<imgILoader> il(do_GetService("@mozilla.org/image/loader;1", &rv));
il->LoadImage(srcURI, nsnull, listener, mPresContext, nsIRequest::LOAD_NORMAL, getter_AddRefs(imageRequest));
il->LoadImage(srcURI, nsnull, listener, mPresContext, nsIRequest::LOAD_NORMAL, nsnull, getter_AddRefs(imageRequest));
if (!mImageCache) {
mImageCache = new nsSupportsHashtable(32);

View File

@ -53,8 +53,10 @@ interface imgILoader : nsISupports
* @param aObserver the observer
* @param aCX some random data
* @param aLoadFlags Load flags for the request
* @param aCacheKey cache key to use for a load if the original
* image came from a request that had post data
*/
imgIRequest loadImage(in nsIURI aURI, in nsILoadGroup aLoadGroup, in imgIDecoderObserver aObserver, in nsISupports aCX, in nsLoadFlags aLoadFlags);
imgIRequest loadImage(in nsIURI aURI, in nsILoadGroup aLoadGroup, in imgIDecoderObserver aObserver, in nsISupports aCX, in nsLoadFlags aLoadFlags, in nsISupports cacheKey);
/**
* Start the load and decode of an image.

View File

@ -108,8 +108,10 @@ void GetCacheSession(nsIURI *aURI, nsICacheSession **_retval)
if (isChrome)
gChromeSession = newSession;
else
else {
gSession = newSession;
gSession->SetDoomEntriesIfExpired(PR_FALSE);
}
*_retval = newSession;
NS_ADDREF(*_retval);
@ -172,7 +174,20 @@ PRBool imgCache::Put(nsIURI *aKey, imgRequest *request, nsICacheEntryDescriptor
return PR_TRUE;
}
PRBool imgCache::Get(nsIURI *aKey, imgRequest **aRequest, nsICacheEntryDescriptor **aEntry)
static PRUint32
SecondsFromPRTime(PRTime prTime)
{
PRInt64 microSecondsPerSecond, intermediateResult;
PRUint32 seconds;
LL_I2L(microSecondsPerSecond, PR_USEC_PER_SEC);
LL_DIV(intermediateResult, prTime, microSecondsPerSecond);
LL_L2UI(seconds, intermediateResult);
return seconds;
}
PRBool imgCache::Get(nsIURI *aKey, PRBool aDoomIfExpired, imgRequest **aRequest, nsICacheEntryDescriptor **aEntry)
{
LOG_STATIC_FUNC(gImgLog, "imgCache::Get");
@ -192,6 +207,15 @@ PRBool imgCache::Get(nsIURI *aKey, imgRequest **aRequest, nsICacheEntryDescripto
if (NS_FAILED(rv) || !entry)
return PR_FALSE;
if (aDoomIfExpired) {
PRUint32 expirationTime;
entry->GetExpirationTime(&expirationTime);
if (expirationTime && (expirationTime <= SecondsFromPRTime(PR_Now()))) {
entry->Doom();
return PR_FALSE;
}
}
nsCOMPtr<nsISupports> sup;
entry->GetCacheElement(getter_AddRefs(sup));

View File

@ -50,7 +50,7 @@ public:
/* additional members */
static PRBool Put(nsIURI *aKey, imgRequest *request, nsICacheEntryDescriptor **aEntry);
static PRBool Get(nsIURI *aKey, imgRequest **aRequest, nsICacheEntryDescriptor **aEntry);
static PRBool Get(nsIURI *aKey, PRBool aDoomIfExpired, imgRequest **aRequest, nsICacheEntryDescriptor **aEntry);
static PRBool Remove(nsIURI *aKey);
static nsresult ClearChromeImageCache();

View File

@ -28,6 +28,7 @@
#include "nsIChannel.h"
#include "nsIHttpChannel.h"
#include "nsICachingChannel.h"
#include "nsIIOService.h"
#include "nsILoadGroup.h"
#include "nsIProxyObjectManager.h"
@ -93,8 +94,8 @@ imgLoader::~imgLoader()
#define SHOULD_RELOAD(flags) (flags & nsIRequest::LOAD_BYPASS_CACHE || flags & nsIRequest::VALIDATE_ALWAYS)
/* imgIRequest loadImage (in nsIURI aURI, in nsILoadGroup aLoadGroup, in imgIDecoderObserver aObserver, in nsISupports aCX, in nsLoadFlags aLoadFlags); */
NS_IMETHODIMP imgLoader::LoadImage(nsIURI *aURI, nsILoadGroup *aLoadGroup, imgIDecoderObserver *aObserver, nsISupports *aCX, nsLoadFlags aLoadFlags, imgIRequest **_retval)
/* imgIRequest loadImage (in nsIURI aURI, in nsILoadGroup aLoadGroup, in imgIDecoderObserver aObserver, in nsISupports aCX, in nsLoadFlags aLoadFlags, in nsISupports aCacheKey); */
NS_IMETHODIMP imgLoader::LoadImage(nsIURI *aURI, nsILoadGroup *aLoadGroup, imgIDecoderObserver *aObserver, nsISupports *aCX, nsLoadFlags aLoadFlags, nsISupports* aCacheKey, imgIRequest **_retval)
{
NS_ASSERTION(aURI, "imgLoader::LoadImage -- NULL URI pointer");
@ -109,8 +110,12 @@ NS_IMETHODIMP imgLoader::LoadImage(nsIURI *aURI, nsILoadGroup *aLoadGroup, imgID
imgRequest *request = nsnull;
// XXX For now ignore the cache key. We will need it in the future
// for correctly dealing with image load requests that are a result
// of post data.
nsCOMPtr<nsICacheEntryDescriptor> entry;
imgCache::Get(aURI, &request, getter_AddRefs(entry)); // addrefs request
imgCache::Get(aURI, !(aLoadFlags & nsIRequest::LOAD_FROM_CACHE),
&request, getter_AddRefs(entry)); // addrefs request
if (request && entry) {
/* this isn't exactly what I want here. This code will re-doom every
@ -122,7 +127,8 @@ NS_IMETHODIMP imgLoader::LoadImage(nsIURI *aURI, nsILoadGroup *aLoadGroup, imgID
if (SHOULD_RELOAD(aLoadFlags)) {
doomRequest = PR_TRUE;
} else if (aLoadGroup) {
} else if (!(aLoadFlags & nsIRequest::LOAD_FROM_CACHE) &&
aLoadGroup) {
nsLoadFlags flags = 0;
aLoadGroup->GetLoadFlags(&flags);
if (SHOULD_RELOAD(flags)) {
@ -264,7 +270,7 @@ NS_IMETHODIMP imgLoader::LoadImageWithChannel(nsIChannel *channel, imgIDecoderOb
channel->GetOriginalURI(getter_AddRefs(uri));
nsCOMPtr<nsICacheEntryDescriptor> entry;
imgCache::Get(uri, &request, getter_AddRefs(entry)); // addrefs request
imgCache::Get(uri, PR_TRUE, &request, getter_AddRefs(entry)); // addrefs request
if (request) {
// we have this in our cache already.. cancel the current (document) load

View File

@ -41,6 +41,7 @@ REQUIRES = xpcom \
locale \
timer \
pref \
necko \
$(NULL)
EXTRA_DSO_LIBS = gkgfx

View File

@ -34,6 +34,7 @@ REQUIRES = xpcom \
timer \
pref \
content \
necko \
$(NULL)
DEFINES =-D_IMPL_NS_VIEW -DWIN32_LEAN_AND_MEAN