bug 292998

- move textZoom storage to the prescontext from the documentviewer
- copy the textZoom between document viewers for fastback
r=bryner sr=dbaron
This commit is contained in:
cbiesinger%web.de 2005-08-13 11:54:22 +00:00
parent 89d68b8b89
commit 26a83fee9a
12 changed files with 43 additions and 52 deletions

View File

@ -5157,6 +5157,12 @@ nsDocShell::RestoreFromHistory()
mSavingOldViewer = CanSavePresentation(mLoadType, request);
}
nsCOMPtr<nsIMarkupDocumentViewer> oldMUDV(do_QueryInterface(mContentViewer));
nsCOMPtr<nsIMarkupDocumentViewer> newMUDV(do_QueryInterface(viewer));
float zoom = 1.0;
if (oldMUDV && newMUDV)
oldMUDV->GetTextZoom(&zoom);
// Notify the old content viewer that it's being hidden.
FirePageHideNotification(!mSavingOldViewer);
// Set mFiredUnloadEvent = PR_FALSE so that the unload handler for the
@ -5260,6 +5266,10 @@ nsDocShell::RestoreFromHistory()
if (++gNumberOfDocumentsLoading == 1)
PL_FavorPerformanceHint(PR_TRUE, NS_EVENT_STARVATION_DELAY_HINT);
if (oldMUDV && newMUDV)
newMUDV->SetTextZoom(zoom);
nsCOMPtr<nsIDOMDocument> domDoc;
mContentViewer->GetDOMDocument(getter_AddRefs(domDoc));
nsCOMPtr<nsIDocument> document = do_QueryInterface(domDoc);

View File

@ -109,9 +109,6 @@ public:
NS_IMETHOD SetZoom(float aZoom);
NS_IMETHOD GetZoom(float &aZoom) const;
NS_IMETHOD SetTextZoom(float aTextZoom);
NS_IMETHOD GetTextZoom(float &aTextZoom) const;
NS_IMETHOD FirstExistingFont(const nsFont& aFont, nsString& aFaceName);
NS_IMETHOD GetLocalFontName(const nsString& aFaceName, nsString& aLocalName,
@ -154,7 +151,6 @@ protected:
nsFontCache *mFontCache;
nsCOMPtr<nsIAtom> mLocaleLangGroup; // XXX temp fix for performance bug - erik
float mZoom;
float mTextZoom;
nsHashtable* mFontAliasTable;
float mCPixelScale;

View File

@ -174,8 +174,8 @@ const PRUint8 kUseAltDCFor_SURFACE_DIM = 0x08; // Use it for getting the Sur
#endif
#define NS_IDEVICE_CONTEXT_IID \
{ 0x5931c580, 0xb917, 0x11d1, \
{ 0xa8, 0x24, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } }
{ 0xb31ad9ce, 0x40cb, 0x43c4, \
{ 0x90, 0xf8, 0x0f, 0x30, 0x53, 0xf6, 0xb8, 0xea } }
//a cross platform way of specifying a native palette handle
typedef void * nsPalette;
@ -396,12 +396,6 @@ public:
NS_IMETHOD SetZoom(float aZoom) = 0;
NS_IMETHOD GetZoom(float &aZoom) const = 0;
//get and set the text zoom value used for display-time scaling.
//default is 1.0 (no zoom). The device context doesn't do anything
//with this value. It's merely a convenient place to store it.
NS_IMETHOD SetTextZoom(float aTextZoom) = 0;
NS_IMETHOD GetTextZoom(float &aTextZoom) const = 0;
/**
* Check to see if a particular named font exists.
* @param aFontName character string of font face name

View File

@ -107,7 +107,6 @@ nsCairoDeviceContext::nsCairoDeviceContext()
mAppUnitsToDevUnits = 1.0f;
mCPixelScale = 1.0f;
mZoom = 1.0f;
mTextZoom = 1.0f;
#ifdef MOZ_ENABLE_XLIB
mXlibRgbHandle = xxlib_find_handle(XXLIBRGB_DEFAULT_HANDLE);

View File

@ -60,7 +60,6 @@ DeviceContextImpl::DeviceContextImpl()
mAppUnitsToDevUnits = 1.0f;
mCPixelScale = 1.0f;
mZoom = 1.0f;
mTextZoom = 1.0f;
mWidget = nsnull;
mFontAliasTable = nsnull;
@ -354,18 +353,6 @@ NS_IMETHODIMP DeviceContextImpl::GetZoom(float &aZoom) const
return NS_OK;
}
NS_IMETHODIMP DeviceContextImpl::SetTextZoom(float aTextZoom)
{
mTextZoom = aTextZoom;
return NS_OK;
}
NS_IMETHODIMP DeviceContextImpl::GetTextZoom(float &aTextZoom) const
{
aTextZoom = mTextZoom;
return NS_OK;
}
NS_IMETHODIMP DeviceContextImpl::GetDepth(PRUint32& aDepth)
{
aDepth = 24;

View File

@ -2552,14 +2552,8 @@ DocumentViewerImpl::SetTextZoom(float aTextZoom)
CallChildren(SetChildTextZoom, &textZoomInfo);
// Now change our own zoom
if (mDeviceContext) {
float oldTextZoom = 1.0; // just in case mDeviceContext doesn't implement
// Don't reflow if there's no change in the textZoom.
mDeviceContext->GetTextZoom(oldTextZoom);
mDeviceContext->SetTextZoom(aTextZoom);
if (oldTextZoom != aTextZoom && mPresContext) {
mPresContext->ClearStyleDataAndReflow();
}
if (mPresContext && aTextZoom != mPresContext->TextZoom()) {
mPresContext->SetTextZoom(aTextZoom);
}
if (mViewManager) {
@ -2574,8 +2568,9 @@ DocumentViewerImpl::GetTextZoom(float* aTextZoom)
{
NS_ENSURE_ARG_POINTER(aTextZoom);
if (mDeviceContext) {
return mDeviceContext->GetTextZoom(*aTextZoom);
if (mPresContext) {
*aTextZoom = mPresContext->TextZoom();
return NS_OK;
}
*aTextZoom = 1.0;

View File

@ -145,6 +145,7 @@ static NS_DEFINE_CID(kSelectionImageService, NS_SELECTIONIMAGESERVICE_CID);
nsPresContext::nsPresContext(nsPresContextType aType)
: mType(aType),
mTextZoom(1.0),
mViewportStyleOverflow(NS_STYLE_OVERFLOW_AUTO, NS_STYLE_OVERFLOW_AUTO),
mCompatibilityMode(eCompatibility_FullStandards),
mImageAnimationModePref(imgIContainer::kNormalAnimMode),
@ -989,6 +990,12 @@ nsPresContext::ScaledPixelsToTwips() const
return scale;
}
void
nsPresContext::SetTextZoomExternal(float aZoom)
{
SetTextZoomInternal(aZoom);
}
imgIRequest*
nsPresContext::LoadImage(imgIRequest* aImage, nsIFrame* aTargetFrame)
{

View File

@ -418,6 +418,20 @@ public:
nsIEventStateManager* EventStateManager() { return mEventManager; }
nsIAtom* GetLangGroup() { return mLangGroup; }
float TextZoom() { return mTextZoom; }
void SetTextZoomInternal(float aZoom) {
mTextZoom = aZoom;
ClearStyleDataAndReflow();
}
virtual NS_HIDDEN_(void) SetTextZoomExternal(float aZoom);
#ifdef _IMPL_NS_LAYOUT
void SetTextZoom(float aZoom) { SetTextZoomInternal(aZoom); }
#else
void SetTextZoom(float aZoom) { SetTextZoomExternal(aZoom); }
#endif
/**
* Get the language-specific transform type for the current document.
* This tells us whether we need to perform special language-dependent
@ -644,6 +658,8 @@ protected:
nsSupportsHashtable mImageLoaders;
nsWeakPtr mContainer;
float mTextZoom; // Text zoom, defaults to 1.0
#ifdef IBMBIDI
nsBidiPresUtils* mBidiUtils;
#endif

View File

@ -82,7 +82,7 @@ nsPrintData::nsPrintData(ePrintDataType aType) :
mIsAborted(PR_FALSE), mPreparingForPrint(PR_FALSE), mDocWasToBeDestroyed(PR_FALSE),
mShrinkToFit(PR_FALSE), mPrintFrameType(nsIPrintSettings::kFramesAsIs),
mNumPrintableDocs(0), mNumDocsPrinted(0), mNumPrintablePages(0), mNumPagesPrinted(0),
mShrinkRatio(1.0), mOrigDCScale(1.0), mOrigTextZoom(1.0), mOrigZoom(1.0), mPPEventListeners(NULL),
mShrinkRatio(1.0), mOrigDCScale(1.0), mOrigZoom(1.0), mPPEventListeners(NULL),
mBrandName(nsnull)
{
@ -106,7 +106,6 @@ nsPrintData::~nsPrintData()
// Set the cached Zoom value back into the DC
if (mPrintDC) {
mPrintDC->SetTextZoom(mOrigTextZoom);
mPrintDC->SetZoom(mOrigZoom);
}

View File

@ -160,7 +160,6 @@ public:
PRInt32 mNumPagesPrinted;
float mShrinkRatio;
float mOrigDCScale;
float mOrigTextZoom;
float mOrigZoom;
nsCOMPtr<nsIPrintSession> mPrintSession;

View File

@ -1040,7 +1040,6 @@ nsPrintEngine::PrintPreview(nsIPrintSettings* aPrintSettings,
// over to the new PrintData object
if (mOldPrtPreview) {
mPrt->mOrigZoom = mOldPrtPreview->mOrigZoom;
mPrt->mOrigTextZoom = mOldPrtPreview->mOrigTextZoom;
mPrt->mOrigDCScale = mOldPrtPreview->mOrigDCScale;
} else {
@ -1201,9 +1200,7 @@ nsPrintEngine::PrintPreview(nsIPrintSettings* aPrintSettings,
mPrt->mPrintDC = mDeviceContext;
// Cache original Zoom value and then set it to 1.0
mPrt->mPrintDC->GetTextZoom(mPrt->mOrigTextZoom);
mPrt->mPrintDC->GetZoom(mPrt->mOrigZoom);
mPrt->mPrintDC->SetTextZoom(1.0f);
mPrt->mPrintDC->SetZoom(1.0f);
if (mDeviceContext) {

View File

@ -225,24 +225,16 @@ nsChangeHint nsStyleFont::MaxDifference()
}
#endif
inline float
TextZoomFor(nsPresContext* aPresContext)
{
float textZoom;
aPresContext->DeviceContext()->GetTextZoom(textZoom);
return textZoom;
}
/* static */ nscoord
nsStyleFont::ZoomText(nsPresContext *aPresContext, nscoord aSize)
{
return nscoord(float(aSize) * TextZoomFor(aPresContext));
return nscoord(float(aSize) * aPresContext->TextZoom());
}
/* static */ nscoord
nsStyleFont::UnZoomText(nsPresContext *aPresContext, nscoord aSize)
{
return nscoord(float(aSize) / TextZoomFor(aPresContext));
return nscoord(float(aSize) / aPresContext->TextZoom());
}
nsChangeHint nsStyleFont::CalcFontDifference(const nsFont& aFont1, const nsFont& aFont2)