Consolidate PresContext classes into a single nsIPresContext implementation, and finish deCOMtaminating it. Bug 253470, r+sr=roc.

This commit is contained in:
bryner%brianryner.com 2004-07-29 19:41:39 +00:00
Родитель ee795a2d8b
Коммит 88f80381e3
123 изменённых файлов: 1350 добавлений и 1607 удалений

Просмотреть файл

@ -2989,8 +2989,7 @@ nsDocument::GetDir(nsAString& aDirection)
nsCOMPtr<nsIPresContext> context;
shell->GetPresContext(getter_AddRefs(context));
if (context) {
PRUint32 options;
context->GetBidi(&options);
PRUint32 options = context->GetBidi();
for (const DirTable* elt = dirAttributes; elt->mName; elt++) {
if (GET_BIDI_OPTION_DIRECTION(options) == elt->mValue) {
CopyASCIItoUTF16(elt->mName, aDirection);
@ -3022,8 +3021,7 @@ nsDocument::SetDir(const nsAString& aDirection)
shell->GetPresContext(getter_AddRefs(context));
NS_ENSURE_TRUE(context, NS_ERROR_UNEXPECTED);
PRUint32 options;
context->GetBidi(&options);
PRUint32 options = context->GetBidi();
for (const DirTable* elt = dirAttributes; elt->mName; elt++) {
if (aDirection == NS_ConvertASCIItoUCS2(elt->mName)) {

Просмотреть файл

@ -99,7 +99,6 @@
#include "nsILayoutHistoryState.h"
#include "nsLayoutAtoms.h"
#include "nsIParser.h"
#include "nsIPrintContext.h"
#include "nsGUIEvent.h"
#include "nsHTMLReflowState.h"
#include "nsIDOMHTMLAnchorElement.h"
@ -160,7 +159,6 @@ static const char sPrintOptionsContractID[] = "@mozilla.org/gfx/printset
#include "nsIPluginDocument.h"
// Print Preview
#include "nsIPrintPreviewContext.h"
#include "imgIContainer.h" // image animation mode constants
// Print Progress
@ -195,8 +193,6 @@ static const char sPrintOptionsContractID[] = "@mozilla.org/gfx/printset
#include "prenv.h"
#include <stdio.h>
static NS_DEFINE_CID(kGalleyContextCID, NS_GALLEYCONTEXT_CID);
static const char kDOMStringBundleURL[] =
"chrome://communicator/locale/dom/dom.properties";
@ -230,9 +226,6 @@ static PRLogModuleInfo * kPrintingLogMod = PR_NewLogModule("printing");
class DocumentViewerImpl;
// New PrintPreview
static NS_DEFINE_CID(kPrintPreviewContextCID, NS_PRINT_PREVIEW_CONTEXT_CID);
// a small delegate class used to avoid circular references
#ifdef XP_MAC
@ -797,15 +790,12 @@ DocumentViewerImpl::InitInternal(nsIWidget* aParentWidget,
if (aDoCreation) {
if (aParentWidget && !mPresContext) {
// Create presentation context
if (GetIsCreatingPrintPreview()) {
mPresContext = do_CreateInstance(kPrintPreviewContextCID, &rv);
} else {
mPresContext = do_CreateInstance(kGalleyContextCID, &rv);
}
if (NS_FAILED(rv))
return rv;
mPresContext = new nsIPresContext(GetIsCreatingPrintPreview() ?
nsIPresContext::eContext_PrintPreview :
nsIPresContext::eContext_Galley);
NS_ENSURE_TRUE(mPresContext, NS_ERROR_OUT_OF_MEMORY);
rv = mPresContext->Init(aDeviceContext);
nsresult rv = mPresContext->Init(aDeviceContext);
if (NS_FAILED(rv)) {
mPresContext = nsnull;
return rv;
@ -1500,8 +1490,8 @@ DocumentViewerImpl::Show(void)
}
NS_ASSERTION(!mPresContext, "Shouldn't have a prescontext if we have no shell!");
mPresContext = do_CreateInstance(kGalleyContextCID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
mPresContext = new nsIPresContext(nsIPresContext::eContext_Galley);
NS_ENSURE_TRUE(mPresContext, NS_ERROR_OUT_OF_MEMORY);
rv = mPresContext->Init(mDeviceContext);
if (NS_FAILED(rv)) {
@ -2644,7 +2634,7 @@ NS_IMETHODIMP DocumentViewerImpl::GetBidiOptions(PRUint32* aBidiOptions)
{
if (aBidiOptions) {
if (mPresContext) {
mPresContext->GetBidi(aBidiOptions);
*aBidiOptions = mPresContext->GetBidi();
}
else
*aBidiOptions = IBMBIDI_DEFAULT_BIDI_OPTIONS;

Просмотреть файл

@ -77,7 +77,6 @@ static const char sPrintOptionsContractID[] = "@mozilla.org/gfx/printset
#include "nsIDOMHTMLObjectElement.h"
// Print Preview
#include "nsIPrintPreviewContext.h"
#include "imgIContainer.h" // image animation mode constants
#include "nsIScrollableView.h"
#include "nsIScrollable.h"
@ -157,7 +156,6 @@ static const char kPrintingPromptService[] = "@mozilla.org/embedcomp/printingpro
#include "nsLayoutAtoms.h"
#include "nsFrameManager.h"
#include "nsIParser.h"
#include "nsIPrintContext.h"
#include "nsGUIEvent.h"
#include "nsHTMLReflowState.h"
#include "nsIDOMHTMLAnchorElement.h"
@ -173,10 +171,6 @@ static const char kPrintingPromptService[] = "@mozilla.org/embedcomp/printingpro
#include "nsPIDOMWindow.h"
#include "nsIFocusController.h"
// New PrintPreview
static NS_DEFINE_CID(kPrintPreviewContextCID, NS_PRINT_PREVIEW_CONTEXT_CID);
static NS_DEFINE_CID(kPrintContextCID, NS_PRINTCONTEXT_CID);
//-----------------------------------------------------
// PR LOGGING
#ifdef MOZ_LOGGING
@ -2567,23 +2561,11 @@ nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO, PRBool aDoCalcShrink)
// create the PresContext
PRBool containerIsSet = PR_FALSE;
nsresult rv;
if (mIsCreatingPrintPreview) {
nsCOMPtr<nsIPrintPreviewContext> printPreviewCon(do_CreateInstance(kPrintPreviewContextCID, &rv));
if (NS_FAILED(rv)) {
return rv;
}
aPO->mPresContext = do_QueryInterface(printPreviewCon);
printPreviewCon->SetPrintSettings(mPrt->mPrintSettings);
} else {
nsCOMPtr<nsIPrintContext> printcon(do_CreateInstance(kPrintContextCID, &rv));
if (NS_FAILED(rv)) {
return rv;
}
aPO->mPresContext = do_QueryInterface(printcon);
printcon->SetPrintSettings(mPrt->mPrintSettings);
}
aPO->mPresContext = new nsIPresContext(mIsCreatingPrintPreview ?
nsIPresContext::eContext_PrintPreview:
nsIPresContext::eContext_Print);
NS_ENSURE_TRUE(aPO->mPresContext, NS_ERROR_OUT_OF_MEMORY);
aPO->mPresContext->SetPrintSettings(mPrt->mPrintSettings);
// set the presentation context to the value in the print settings
PRBool printBGColors;
@ -2594,7 +2576,7 @@ nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO, PRBool aDoCalcShrink)
// init it with the DC
rv = aPO->mPresContext->Init(mPrt->mPrintDocDC);
nsresult rv = aPO->mPresContext->Init(mPrt->mPrintDocDC);
if (NS_FAILED(rv)) {
aPO->mPresContext = nsnull;
return rv;
@ -2779,7 +2761,7 @@ nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO, PRBool aDoCalcShrink)
return NS_OK;
}
aPO->mPresContext->SetPageDim(&adjRect);
aPO->mPresContext->SetPageDim(adjRect);
rv = aPO->mPresShell->InitialReflow(width, height);
if (NS_SUCCEEDED(rv)) {
// Transfer Selection Ranges to the new Print PresShell
@ -3322,9 +3304,7 @@ nsPrintEngine::DoPrint(nsPrintObject * aPO, PRBool aDoSyncPrinting, PRBool& aDon
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIPrintPreviewContext> ppContext = do_QueryInterface(poPresContext);
if (!ppContext) {
if (poPresContext->Type() != nsIPresContext::eContext_PrintPreview) {
nscoord sheight = seqFrame->GetSize().height;
nsRect r = poRootView->GetBounds();
@ -4491,9 +4471,8 @@ nsPrintEngine::FinishPrintPreview()
// Turning off the scaling of twips so any of the UI scrollbars
// will not get scaled
nsCOMPtr<nsIPrintPreviewContext> printPreviewContext(do_QueryInterface(mPresContext));
if (printPreviewContext) {
printPreviewContext->SetScalingOfTwips(PR_FALSE);
if (mPresContext->Type() == nsIPresContext::eContext_PrintPreview) {
mPresContext->SetScalingOfTwips(PR_FALSE);
mDeviceContext->SetCanonicalPixelScale(mPrtPreview->mOrigDCScale);
}
@ -4798,8 +4777,7 @@ void DumpLayoutData(char* aTitleStr,
}
#ifdef NS_PRINT_PREVIEW
nsCOMPtr<nsIPrintPreviewContext> ppContext = do_QueryInterface(aPresContext);
if (ppContext) {
if (aPresContext->Type() == nsIPresContext::eContext_PrintPreview) {
return;
}
#endif

Просмотреть файл

@ -198,9 +198,8 @@ nscoord CalcLength(const nsCSSValue& aValue,
}
nsCSSUnit unit = aValue.GetUnit();
if (unit == eCSSUnit_Pixel) {
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
return NSFloatPixelsToTwips(aValue.GetFloatValue(), p2t);
return NSFloatPixelsToTwips(aValue.GetFloatValue(),
aPresContext->ScaledPixelsToTwips());
}
// Common code for all units other than pixels:
aInherited = PR_TRUE;
@ -220,8 +219,7 @@ nscoord CalcLength(const nsCSSValue& aValue,
return NSToCoordRound((aValue.GetFloatValue() * (float)font->size) / 2.0f);
}
case eCSSUnit_XHeight: {
nsCOMPtr<nsIFontMetrics> fm;
aPresContext->GetMetricsFor(*font, getter_AddRefs(fm));
nsCOMPtr<nsIFontMetrics> fm = aPresContext->GetMetricsFor(*font);
nscoord xHeight;
fm->GetXHeight(xHeight);
return NSToCoordRound(aValue.GetFloatValue() * (float)xHeight);
@ -4340,8 +4338,7 @@ SetSVGLength(const nsCSSValue& aValue, float parentLength, float& length,
}
else {
length = (float) coord.GetCoordValue();
float twipsPerPix;
aPresContext->GetScaledPixelsToTwips(&twipsPerPix);
float twipsPerPix = aPresContext->ScaledPixelsToTwips();
if (twipsPerPix == 0.0f)
twipsPerPix = 1e-20f;
length /= twipsPerPix;

Просмотреть файл

@ -1161,9 +1161,8 @@ GetSubmissionFromForm(nsIHTMLContent* aForm,
//
// Get BIDI options
PRUint32 bidiOptions = 0;
PRUint8 ctrlsModAtSubmit = 0;
aPresContext->GetBidi(&bidiOptions);
PRUint32 bidiOptions = aPresContext->GetBidi();
ctrlsModAtSubmit = GET_BIDI_OPTION_CONTROLSTEXTMODE(bidiOptions);
// Get encoding type (default: urlencoded)

Просмотреть файл

@ -756,9 +756,7 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
nsCOMPtr<nsIPresContext> cx;
docShell->GetPresContext(getter_AddRefs(cx));
if(cx){
PRUint32 mBidiOption;
cx->GetBidi(&mBidiOption);
mTexttype = GET_BIDI_OPTION_TEXTTYPE(mBidiOption);
mTexttype = GET_BIDI_OPTION_TEXTTYPE(cx->GetBidi());
}
//
// The following logic is mirrored in nsWebShell::Embed!

Просмотреть файл

@ -232,9 +232,8 @@ ProcessTableRulesAttribute(nsStyleStruct* aStyleStruct,
borderData->SetBorderColor(aSide, borderColor);
}
// set the border width to be 1 pixel
float p2t;
aRuleData->mPresContext->GetScaledPixelsToTwips(&p2t);
nscoord onePixel = NSToCoordRound(p2t);
nscoord onePixel =
NSToCoordRound(aRuleData->mPresContext->ScaledPixelsToTwips());
nsStyleCoord coord(onePixel);
switch(aSide) {
case NS_SIDE_TOP:

Просмотреть файл

@ -218,9 +218,8 @@ nsStyleUtil::CalcFontPointSize(PRInt32 aHTMLSize, PRInt32 aBasePointSize,
}
// Make special call specifically for fonts (needed PrintPreview)
float t2p;
aPresContext->GetTwipsToPixelsForFonts(&t2p);
PRInt32 fontSize = NSTwipsToIntPixels(aBasePointSize, t2p);
PRInt32 fontSize = NSTwipsToIntPixels(aBasePointSize,
aPresContext->TwipsToPixelsForFonts());
if ((fontSize >= sFontSizeTableMin) && (fontSize <= sFontSizeTableMax))
{

Просмотреть файл

@ -1164,8 +1164,7 @@ nsChangeHint nsStyleDisplay::CalcDifference(const nsStyleDisplay& aOther) const
nsStyleVisibility::nsStyleVisibility(nsIPresContext* aPresContext)
{
PRUint32 bidiOptions;
aPresContext->GetBidi(&bidiOptions);
PRUint32 bidiOptions = aPresContext->GetBidi();
if (GET_BIDI_OPTION_DIRECTION(bidiOptions) == IBMBIDI_TEXTDIRECTION_RTL)
mDirection = NS_STYLE_DIRECTION_RTL;
else

Просмотреть файл

@ -436,9 +436,7 @@ nsSVGSVGElement::GetPixelUnitToMillimeterX(float *aPixelUnitToMillimeterX)
presShell->GetPresContext(getter_AddRefs(context));
if (!context) return NS_OK;
float TwipsPerPx;
context->GetScaledPixelsToTwips(&TwipsPerPx);
*aPixelUnitToMillimeterX = TwipsPerPx / TWIPS_PER_POINT_FLOAT / (72.0f * 0.03937f);
*aPixelUnitToMillimeterX = context->ScaledPixelsToTwips() / TWIPS_PER_POINT_FLOAT / (72.0f * 0.03937f);
return NS_OK;
}

Просмотреть файл

@ -59,6 +59,7 @@ REQUIRES = xpcom \
xpconnect \
unicharutil \
pref \
locale \
$(NULL)
CPPSRCS = \

Просмотреть файл

@ -71,6 +71,7 @@ REQUIRES = xpcom \
commandhandler \
composer \
appshell \
locale \
$(NULL)
CPPSRCS = \

Просмотреть файл

@ -78,6 +78,7 @@ REQUIRES = \
composer \
commandhandler \
ax_common \
locale \
$(NULL)
CPPSRCS = \

Просмотреть файл

@ -100,7 +100,6 @@
#include "nsIWindowWatcher.h"
#include "nsIObserverService.h"
#include "nsLayoutAtoms.h"
#include "nsIPrintPreviewContext.h"
#include "nsIPrivateTextEvent.h"
#include "nsIPrivateCompositionEvent.h"
@ -2495,8 +2494,7 @@ nsTypeAheadFind::GetTargetIfTypeAheadOkay(nsIDOMEvent *aEvent,
nsCOMPtr<nsIPresContext> presContext;
presShell->GetPresContext(getter_AddRefs(presContext));
nsCOMPtr<nsIPrintPreviewContext> printPreview(do_QueryInterface(presContext));
if (printPreview) {
if (presContext->Type() == nsIPresContext::eContext_PrintPreview) {
// Typeaheadfind is not designed to work in print preview.
// You can't navigate through the links there.
if (lastShell != presShell) {

Просмотреть файл

@ -36,6 +36,9 @@
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsITheme_h_
#define nsITheme_h_
#include "nsISupports.h"
#include "nsCOMPtr.h"
#include "nsColor.h"
@ -94,3 +97,5 @@ public:
// Creator function
extern NS_METHOD NS_NewNativeTheme(nsISupports *aOuter, REFNSIID aIID, void **aResult);
#endif

Просмотреть файл

@ -819,8 +819,7 @@ nsBidiPresUtils::FormatUnicodeText(nsIPresContext* aPresContext,
nsresult rv = NS_OK;
// ahmed
//adjusted for correct numeral shaping
PRUint32 bidiOptions;
aPresContext->GetBidi(&bidiOptions);
PRUint32 bidiOptions = aPresContext->GetBidi();
switch (GET_BIDI_OPTION_NUMERAL(bidiOptions)) {
case IBMBIDI_NUMERAL_HINDI:

Просмотреть файл

@ -103,7 +103,6 @@
#include "nsFormControlHelper.h"
#include "nsObjectFrame.h"
#include "nsRuleNode.h"
#include "nsIPrintPreviewContext.h"
#include "nsIDOMMutationEvent.h"
#include "nsChildIterator.h"
#include "nsCSSRendering.h"
@ -3709,7 +3708,8 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell,
// the entire canvas as specified by the CSS2 spec
PRBool isPaginated = aPresContext->IsPaginated();
nsCOMPtr<nsIPrintPreviewContext> printPreviewContext(do_QueryInterface(aPresContext));
PRBool isPrintPreview =
aPresContext->Type() == nsIPresContext::eContext_PrintPreview;
nsIFrame* rootFrame = nsnull;
nsIAtom* rootPseudo;
@ -3789,7 +3789,7 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell,
}
if (isPaginated) {
if (printPreviewContext) { // print preview
if (isPrintPreview) {
isScrollable = aPresContext->HasPaginatedScrolling();
} else {
isScrollable = PR_FALSE; // we are printing
@ -3814,7 +3814,7 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell,
nsIFrame* parentFrame = viewportFrame;
// If paginated, make sure we don't put scrollbars in
if (isPaginated && !printPreviewContext)
if (isPaginated && !isPrintPreview)
rootPseudoStyle = styleSet->ResolvePseudoStyleFor(nsnull,
rootPseudo,
viewportPseudoStyle);
@ -3911,7 +3911,7 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell,
rootFrame->Init(aPresContext, aDocElement, parentFrame,
rootPseudoStyle, nsnull);
if (!isPaginated || printPreviewContext) {
if (!isPaginated || isPrintPreview) {
if (isScrollable) {
FinishBuildingScrollFrame(aPresContext,
state,
@ -5809,11 +5809,13 @@ nsCSSFrameConstructor::BeginBuildingScrollFrame(nsIPresShell* aPresSh
// If the parent is a viewportFrame then we are the scrollbars for the UI
// if not then we are scrollbars inside the document.
PRBool noScalingOfTwips = PR_FALSE;
nsCOMPtr<nsIPrintPreviewContext> printPreviewContext(do_QueryInterface(aPresContext));
if (printPreviewContext) {
PRBool isPrintPreview =
aPresContext->Type() == nsIPresContext::eContext_PrintPreview;
if (isPrintPreview) {
noScalingOfTwips = aParentFrame->GetType() == nsLayoutAtoms::viewportFrame;
if (noScalingOfTwips) {
printPreviewContext->SetScalingOfTwips(PR_FALSE);
aPresContext->SetScalingOfTwips(PR_FALSE);
}
}
@ -5877,8 +5879,8 @@ nsCSSFrameConstructor::BeginBuildingScrollFrame(nsIPresShell* aPresSh
}
if (printPreviewContext && noScalingOfTwips) {
printPreviewContext->SetScalingOfTwips(PR_TRUE);
if (isPrintPreview && noScalingOfTwips) {
aPresContext->SetScalingOfTwips(PR_TRUE);
}
return aScrolledChildStyle;;
@ -5976,11 +5978,10 @@ nsCSSFrameConstructor::BuildScrollFrame(nsIPresShell* aPresShell,
// If the parent is a viewportFrame then we are the scrollbars for the UI
// if not then we are scrollbars inside the document.
PRBool noScalingOfTwips = PR_FALSE;
nsCOMPtr<nsIPrintPreviewContext> printPreviewContext(do_QueryInterface(aPresContext));
if (printPreviewContext) {
if (aPresContext->Type() == nsIPresContext::eContext_PrintPreview) {
noScalingOfTwips = aParentFrame->GetType() == nsLayoutAtoms::viewportFrame;
if (noScalingOfTwips) {
printPreviewContext->SetScalingOfTwips(PR_FALSE);
aPresContext->SetScalingOfTwips(PR_FALSE);
}
}
@ -6018,7 +6019,7 @@ nsCSSFrameConstructor::BuildScrollFrame(nsIPresShell* aPresShell,
aState.mFrameManager->SetPrimaryFrameFor( aContent, aNewFrame );
if (noScalingOfTwips) {
printPreviewContext->SetScalingOfTwips(PR_TRUE);
aPresContext->SetScalingOfTwips(PR_TRUE);
}
return NS_OK;
@ -9950,13 +9951,14 @@ nsCSSFrameConstructor::DoContentStateChanged(nsIPresContext* aPresContext,
if (primaryFrame) {
PRUint8 app = primaryFrame->GetStyleDisplay()->mAppearance;
if (app) {
nsCOMPtr<nsITheme> theme;
aPresContext->GetTheme(getter_AddRefs(theme));
PRBool repaint = PR_FALSE;
if (theme && theme->ThemeSupportsWidget(aPresContext, primaryFrame, app))
nsITheme *theme = aPresContext->GetTheme();
if (theme && theme->ThemeSupportsWidget(aPresContext, primaryFrame, app)) {
PRBool repaint = PR_FALSE;
theme->WidgetStateChanged(primaryFrame, app, nsnull, &repaint);
if (repaint)
ApplyRenderingChangeToTree(aPresContext, primaryFrame, nsnull, nsChangeHint_RepaintFrame);
if (repaint) {
ApplyRenderingChangeToTree(aPresContext, primaryFrame, nsnull, nsChangeHint_RepaintFrame);
}
}
}
}
@ -10042,8 +10044,7 @@ nsCSSFrameConstructor::AttributeChanged(nsIPresContext* aPresContext,
if (primaryFrame) {
const nsStyleDisplay* disp = primaryFrame->GetStyleDisplay();
if (disp->mAppearance) {
nsCOMPtr<nsITheme> theme;
aPresContext->GetTheme(getter_AddRefs(theme));
nsITheme *theme = aPresContext->GetTheme();
if (theme && theme->ThemeSupportsWidget(aPresContext, primaryFrame, disp->mAppearance)) {
PRBool repaint = PR_FALSE;
theme->WidgetStateChanged(primaryFrame, disp->mAppearance, aAttribute, &repaint);

Просмотреть файл

@ -58,7 +58,6 @@
#include "gfxIImageFrame.h"
#include "nsCSSRendering.h"
#include "nsCSSColorUtils.h"
#include "nsIPrintContext.h"
#include "nsITheme.h"
#include "nsThemeConstants.h"
#include "nsIServiceManager.h"
@ -1634,8 +1633,7 @@ void nsCSSRendering::PaintBorder(nsIPresContext* aPresContext,
// may be different! Always use |aStyleContext|!
const nsStyleDisplay* displayData = aStyleContext->GetStyleDisplay();
if (displayData->mAppearance) {
nsCOMPtr<nsITheme> theme;
aPresContext->GetTheme(getter_AddRefs(theme));
nsITheme *theme = aPresContext->GetTheme();
if (theme && theme->ThemeSupportsWidget(aPresContext, aForFrame, displayData->mAppearance))
return; // Let the theme handle it.
}
@ -1795,10 +1793,7 @@ void nsCSSRendering::PaintBorder(nsIPresContext* aPresContext,
}
}
/* Get our conversion values */
nscoord twipsPerPixel;
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
twipsPerPixel = NSIntPixelsToTwips(1,p2t);
nscoord twipsPerPixel = aPresContext->IntScaledPixelsToTwips(1);
static PRUint8 sideOrder[] = { NS_SIDE_BOTTOM, NS_SIDE_LEFT, NS_SIDE_TOP, NS_SIDE_RIGHT };
nscolor sideColor;
@ -2791,8 +2786,7 @@ nsCSSRendering::PaintBackgroundWithSC(nsIPresContext* aPresContext,
// renderer draw the background and bail out.
const nsStyleDisplay* displayData = aForFrame->GetStyleDisplay();
if (displayData->mAppearance) {
nsCOMPtr<nsITheme> theme;
aPresContext->GetTheme(getter_AddRefs(theme));
nsITheme *theme = aPresContext->GetTheme();
if (theme && theme->ThemeSupportsWidget(aPresContext, aForFrame, displayData->mAppearance)) {
theme->DrawWidgetBackground(&aRenderingContext, aForFrame,
displayData->mAppearance, aBorderArea, aDirtyRect);
@ -2834,14 +2828,14 @@ nsCSSRendering::PaintBackgroundWithSC(nsIPresContext* aPresContext,
// We have a background image
// Lookup the image
nsCOMPtr<imgIRequest> req;
nsresult rv = aPresContext->LoadImage(aColor.mBackgroundImage, aForFrame, getter_AddRefs(req));
imgIRequest *req = aPresContext->LoadImage(aColor.mBackgroundImage,
aForFrame);
PRUint32 status = imgIRequest::STATUS_ERROR;
if (req)
req->GetImageStatus(&status);
if (NS_FAILED(rv) || !req || !(status & imgIRequest::STATUS_FRAME_COMPLETE) || !(status & imgIRequest::STATUS_SIZE_AVAILABLE)) {
if (!req || !(status & imgIRequest::STATUS_FRAME_COMPLETE) || !(status & imgIRequest::STATUS_SIZE_AVAILABLE)) {
PaintBackgroundColor(aPresContext, aRenderingContext, aForFrame, bgClipArea,
aColor, aBorder, aPadding, canDrawBackgroundColor);
return;

Просмотреть файл

@ -99,7 +99,6 @@
#include "nsILayoutHistoryState.h"
#include "nsLayoutAtoms.h"
#include "nsIParser.h"
#include "nsIPrintContext.h"
#include "nsGUIEvent.h"
#include "nsHTMLReflowState.h"
#include "nsIDOMHTMLAnchorElement.h"
@ -160,7 +159,6 @@ static const char sPrintOptionsContractID[] = "@mozilla.org/gfx/printset
#include "nsIPluginDocument.h"
// Print Preview
#include "nsIPrintPreviewContext.h"
#include "imgIContainer.h" // image animation mode constants
// Print Progress
@ -195,8 +193,6 @@ static const char sPrintOptionsContractID[] = "@mozilla.org/gfx/printset
#include "prenv.h"
#include <stdio.h>
static NS_DEFINE_CID(kGalleyContextCID, NS_GALLEYCONTEXT_CID);
static const char kDOMStringBundleURL[] =
"chrome://communicator/locale/dom/dom.properties";
@ -230,9 +226,6 @@ static PRLogModuleInfo * kPrintingLogMod = PR_NewLogModule("printing");
class DocumentViewerImpl;
// New PrintPreview
static NS_DEFINE_CID(kPrintPreviewContextCID, NS_PRINT_PREVIEW_CONTEXT_CID);
// a small delegate class used to avoid circular references
#ifdef XP_MAC
@ -797,15 +790,12 @@ DocumentViewerImpl::InitInternal(nsIWidget* aParentWidget,
if (aDoCreation) {
if (aParentWidget && !mPresContext) {
// Create presentation context
if (GetIsCreatingPrintPreview()) {
mPresContext = do_CreateInstance(kPrintPreviewContextCID, &rv);
} else {
mPresContext = do_CreateInstance(kGalleyContextCID, &rv);
}
if (NS_FAILED(rv))
return rv;
mPresContext = new nsIPresContext(GetIsCreatingPrintPreview() ?
nsIPresContext::eContext_PrintPreview :
nsIPresContext::eContext_Galley);
NS_ENSURE_TRUE(mPresContext, NS_ERROR_OUT_OF_MEMORY);
rv = mPresContext->Init(aDeviceContext);
nsresult rv = mPresContext->Init(aDeviceContext);
if (NS_FAILED(rv)) {
mPresContext = nsnull;
return rv;
@ -1500,8 +1490,8 @@ DocumentViewerImpl::Show(void)
}
NS_ASSERTION(!mPresContext, "Shouldn't have a prescontext if we have no shell!");
mPresContext = do_CreateInstance(kGalleyContextCID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
mPresContext = new nsIPresContext(nsIPresContext::eContext_Galley);
NS_ENSURE_TRUE(mPresContext, NS_ERROR_OUT_OF_MEMORY);
rv = mPresContext->Init(mDeviceContext);
if (NS_FAILED(rv)) {
@ -2644,7 +2634,7 @@ NS_IMETHODIMP DocumentViewerImpl::GetBidiOptions(PRUint32* aBidiOptions)
{
if (aBidiOptions) {
if (mPresContext) {
mPresContext->GetBidi(aBidiOptions);
*aBidiOptions = mPresContext->GetBidi();
}
else
*aBidiOptions = IBMBIDI_DEFAULT_BIDI_OPTIONS;

Просмотреть файл

@ -35,7 +35,7 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsCOMPtr.h"
#include "nsPresContext.h"
#include "nsIPresContext.h"
#include "nsIPresShell.h"
#include "nsILinkHandler.h"
#include "nsIDocShellTreeItem.h"
@ -96,9 +96,9 @@ MakeColorPref(const char *colstr)
}
int PR_CALLBACK
nsPresContext::PrefChangedCallback(const char* aPrefName, void* instance_data)
nsIPresContext::PrefChangedCallback(const char* aPrefName, void* instance_data)
{
nsPresContext* presContext = (nsPresContext*)instance_data;
nsIPresContext* presContext = (nsIPresContext*)instance_data;
NS_ASSERTION(nsnull != presContext, "bad instance data");
if (nsnull != presContext) {
@ -109,7 +109,7 @@ nsPresContext::PrefChangedCallback(const char* aPrefName, void* instance_data)
#ifdef IBMBIDI
static PRBool
IsVisualCharset(const nsCAutoString& aCharset)
IsVisualCharset(const nsCString& aCharset)
{
if (aCharset.LowerCaseEqualsLiteral("ibm864") // Arabic//ahmed
|| aCharset.LowerCaseEqualsLiteral("ibm862") // Hebrew
@ -135,32 +135,32 @@ static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
#include "nsContentCID.h"
static NS_DEFINE_CID(kSelectionImageService, NS_SELECTIONIMAGESERVICE_CID);
// NOTE! nsPresContext::operator new() zeroes out all members, so don't
// NOTE! nsIPresContext::operator new() zeroes out all members, so don't
// bother initializing members to 0.
nsPresContext::nsPresContext()
: mDefaultVariableFont("serif", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
NS_FONT_WEIGHT_NORMAL, 0, NSIntPointsToTwips(12)),
nsIPresContext::nsIPresContext(nsPresContextType aType)
: mType(aType),
mCompatibilityMode(eCompatibility_FullStandards),
mImageAnimationModePref(imgIContainer::kNormalAnimMode),
mDefaultVariableFont("serif", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
NS_FONT_WEIGHT_NORMAL, 0, NSIntPointsToTwips(12)),
mDefaultFixedFont("monospace", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
NS_FONT_WEIGHT_NORMAL, 0, NSIntPointsToTwips(10)),
NS_FONT_WEIGHT_NORMAL, 0, NSIntPointsToTwips(10)),
mDefaultSerifFont("serif", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
NS_FONT_WEIGHT_NORMAL, 0, NSIntPointsToTwips(12)),
NS_FONT_WEIGHT_NORMAL, 0, NSIntPointsToTwips(12)),
mDefaultSansSerifFont("sans-serif", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
NS_FONT_WEIGHT_NORMAL, 0, NSIntPointsToTwips(12)),
NS_FONT_WEIGHT_NORMAL, 0, NSIntPointsToTwips(12)),
mDefaultMonospaceFont("monospace", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
NS_FONT_WEIGHT_NORMAL, 0, NSIntPointsToTwips(10)),
mDefaultCursiveFont("cursive", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
NS_FONT_WEIGHT_NORMAL, 0, NSIntPointsToTwips(12)),
mDefaultFantasyFont("fantasy", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
NS_FONT_WEIGHT_NORMAL, 0, NSIntPointsToTwips(12))
NS_FONT_WEIGHT_NORMAL, 0, NSIntPointsToTwips(10)),
mDefaultCursiveFont("cursive", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
NS_FONT_WEIGHT_NORMAL, 0, NSIntPointsToTwips(12)),
mDefaultFantasyFont("fantasy", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
NS_FONT_WEIGHT_NORMAL, 0, NSIntPointsToTwips(12))
{
// NOTE! nsPresContext::operator new() zeroes out all members, so don't
// NOTE! nsIPresContext::operator new() zeroes out all members, so don't
// bother initializing members to 0.
mCompatibilityMode = eCompatibility_FullStandards;
mImageAnimationMode = imgIContainer::kNormalAnimMode;
mImageAnimationModePref = imgIContainer::kNormalAnimMode;
mDoScaledTwips = PR_TRUE;
SetBackgroundImageDraw(PR_TRUE); // always draw the background
SetBackgroundColorDraw(PR_TRUE);
@ -184,9 +184,26 @@ nsPresContext::nsPresContext()
mFocusRingWidth = 1;
mLanguageSpecificTransformType = eLanguageSpecificTransformType_Unknown;
if (aType == eContext_Galley) {
mMedium = nsLayoutAtoms::screen;
mImageAnimationMode = imgIContainer::kNormalAnimMode;
} else {
SetBackgroundImageDraw(PR_FALSE);
SetBackgroundColorDraw(PR_FALSE);
mImageAnimationMode = imgIContainer::kDontAnimMode;
mNeverAnimate = PR_TRUE;
mMedium = nsLayoutAtoms::print;
mPaginated = PR_TRUE;
if (aType == eContext_PrintPreview) {
mCanPaginatedScroll = PR_TRUE;
mPageDim.SetRect(-1, -1, -1, -1);
} else {
mPageDim.SetRect(0, 0, 0, 0);
}
}
}
nsPresContext::~nsPresContext()
nsIPresContext::~nsIPresContext()
{
mImageLoaders.Enumerate(destroy_loads);
@ -200,28 +217,28 @@ nsPresContext::~nsPresContext()
// Unregister preference callbacks
nsContentUtils::UnregisterPrefCallback("font.",
nsPresContext::PrefChangedCallback,
nsIPresContext::PrefChangedCallback,
this);
nsContentUtils::UnregisterPrefCallback("browser.display.",
nsPresContext::PrefChangedCallback,
nsIPresContext::PrefChangedCallback,
this);
nsContentUtils::UnregisterPrefCallback("browser.underline_anchors",
nsPresContext::PrefChangedCallback,
nsIPresContext::PrefChangedCallback,
this);
nsContentUtils::UnregisterPrefCallback("browser.anchor_color",
nsPresContext::PrefChangedCallback,
nsIPresContext::PrefChangedCallback,
this);
nsContentUtils::UnregisterPrefCallback("browser.active_color",
nsPresContext::PrefChangedCallback,
nsIPresContext::PrefChangedCallback,
this);
nsContentUtils::UnregisterPrefCallback("browser.visited_color",
nsPresContext::PrefChangedCallback,
nsIPresContext::PrefChangedCallback,
this);
nsContentUtils::UnregisterPrefCallback("network.image.imageBehavior",
nsPresContext::PrefChangedCallback,
nsIPresContext::PrefChangedCallback,
this);
nsContentUtils::UnregisterPrefCallback("image.animation_mode",
nsPresContext::PrefChangedCallback,
nsIPresContext::PrefChangedCallback,
this);
#ifdef IBMBIDI
nsContentUtils::UnregisterPrefCallback("bidi.", PrefChangedCallback, this);
@ -234,7 +251,7 @@ nsPresContext::~nsPresContext()
NS_IF_RELEASE(mLangGroup);
}
NS_IMPL_ISUPPORTS2(nsPresContext, nsIPresContext, nsIObserver)
NS_IMPL_ISUPPORTS2(nsIPresContext, nsIPresContext, nsIObserver)
#define MAKE_FONT_PREF_KEY(_pref, _s0, _s1) \
_pref.Assign(_s0); \
@ -251,7 +268,7 @@ static const char* const kGenericFont[] = {
};
void
nsPresContext::GetFontPreferences()
nsIPresContext::GetFontPreferences()
{
if (!mLangGroup)
return;
@ -272,8 +289,7 @@ nsPresContext::GetFontPreferences()
font.minimum-size.[langGroup] = integer - settable by the user
*/
float p2t;
GetScaledPixelsToTwips(&p2t);
float p2t = ScaledPixelsToTwips();
mDefaultVariableFont.size = NSFloatPixelsToTwips((float)16, p2t);
mDefaultFixedFont.size = NSFloatPixelsToTwips((float)13, p2t);
@ -403,7 +419,7 @@ nsPresContext::GetFontPreferences()
}
void
nsPresContext::GetDocumentColorPreferences()
nsIPresContext::GetDocumentColorPreferences()
{
PRInt32 useAccessibilityTheme = 0;
PRBool usePrefColors = PR_TRUE;
@ -456,7 +472,7 @@ nsPresContext::GetDocumentColorPreferences()
}
void
nsPresContext::GetUserPreferences()
nsIPresContext::GetUserPreferences()
{
mFontScaler =
nsContentUtils::GetIntPref("browser.display.base_font_scaler",
@ -571,7 +587,7 @@ nsPresContext::GetUserPreferences()
}
void
nsPresContext::ClearStyleDataAndReflow()
nsIPresContext::ClearStyleDataAndReflow()
{
if (mShell) {
// Clear out all our style data.
@ -586,7 +602,7 @@ nsPresContext::ClearStyleDataAndReflow()
}
void
nsPresContext::PreferenceChanged(const char* aPrefName)
nsIPresContext::PreferenceChanged(const char* aPrefName)
{
nsCOMPtr<nsIDocShellTreeItem> docShell(do_QueryReferent(mContainer));
if (docShell) {
@ -605,11 +621,11 @@ nsPresContext::PreferenceChanged(const char* aPrefName)
}
mDeviceContext->FlushFontCache();
nsPresContext::ClearStyleDataAndReflow();
ClearStyleDataAndReflow();
}
NS_IMETHODIMP
nsPresContext::Init(nsIDeviceContext* aDeviceContext)
nsresult
nsIPresContext::Init(nsIDeviceContext* aDeviceContext)
{
NS_ASSERTION(!(mInitialized == PR_TRUE), "attempt to reinit pres context");
NS_ENSURE_ARG(aDeviceContext);
@ -635,28 +651,28 @@ nsPresContext::Init(nsIDeviceContext* aDeviceContext)
// Register callbacks so we're notified when the preferences change
nsContentUtils::RegisterPrefCallback("font.",
nsPresContext::PrefChangedCallback,
nsIPresContext::PrefChangedCallback,
this);
nsContentUtils::RegisterPrefCallback("browser.display.",
nsPresContext::PrefChangedCallback,
nsIPresContext::PrefChangedCallback,
this);
nsContentUtils::RegisterPrefCallback("browser.underline_anchors",
nsPresContext::PrefChangedCallback,
nsIPresContext::PrefChangedCallback,
this);
nsContentUtils::RegisterPrefCallback("browser.anchor_color",
nsPresContext::PrefChangedCallback,
nsIPresContext::PrefChangedCallback,
this);
nsContentUtils::RegisterPrefCallback("browser.active_color",
nsPresContext::PrefChangedCallback,
nsIPresContext::PrefChangedCallback,
this);
nsContentUtils::RegisterPrefCallback("browser.visited_color",
nsPresContext::PrefChangedCallback,
nsIPresContext::PrefChangedCallback,
this);
nsContentUtils::RegisterPrefCallback("network.image.imageBehavior",
nsPresContext::PrefChangedCallback,
nsIPresContext::PrefChangedCallback,
this);
nsContentUtils::RegisterPrefCallback("image.animation_mode",
nsPresContext::PrefChangedCallback,
nsIPresContext::PrefChangedCallback,
this);
#ifdef IBMBIDI
nsContentUtils::RegisterPrefCallback("bidi.", PrefChangedCallback,
@ -680,8 +696,8 @@ nsPresContext::Init(nsIDeviceContext* aDeviceContext)
// Note: We don't hold a reference on the shell; it has a reference to
// us
NS_IMETHODIMP
nsPresContext::SetShell(nsIPresShell* aShell)
void
nsIPresContext::SetShell(nsIPresShell* aShell)
{
if (mShell) {
// Remove ourselves as the charset observer from the shell's doc, because
@ -702,7 +718,7 @@ nsPresContext::SetShell(nsIPresShell* aShell)
if (doc) {
nsIURI *baseURI = doc->GetBaseURI();
if (!mNeverAnimate && baseURI) {
if (mMedium != nsLayoutAtoms::print && baseURI) {
PRBool isChrome = PR_FALSE;
PRBool isRes = PR_FALSE;
baseURI->SchemeIs("chrome", &isChrome);
@ -721,11 +737,10 @@ nsPresContext::SetShell(nsIPresShell* aShell)
}
}
}
return NS_OK;
}
void
nsPresContext::UpdateCharSet(const char* aCharSet)
nsIPresContext::UpdateCharSet(const char* aCharSet)
{
if (mLangService) {
NS_IF_RELEASE(mLangGroup);
@ -757,24 +772,24 @@ nsPresContext::UpdateCharSet(const char* aCharSet)
}
NS_IMETHODIMP
nsPresContext::Observe(nsISupports* aSubject,
const char* aTopic,
const PRUnichar* aData)
nsIPresContext::Observe(nsISupports* aSubject,
const char* aTopic,
const PRUnichar* aData)
{
if (!nsCRT::strcmp(aTopic, "charset")) {
UpdateCharSet(NS_LossyConvertUCS2toASCII(aData).get());
mDeviceContext->FlushFontCache();
nsPresContext::ClearStyleDataAndReflow();
ClearStyleDataAndReflow();
return NS_OK;
}
NS_WARNING("unrecognized topic in nsPresContext::Observe");
NS_WARNING("unrecognized topic in nsIPresContext::Observe");
return NS_ERROR_FAILURE;
}
void
nsPresContext::SetCompatibilityMode(nsCompatibility aMode)
nsIPresContext::SetCompatibilityMode(nsCompatibility aMode)
{
mCompatibilityMode = aMode;
@ -813,7 +828,7 @@ PR_STATIC_CALLBACK(PRBool) set_animation_mode(nsHashKey *aKey, void *aData, void
//
// Walks content and set the animation mode
// this is a way to turn on/off image animations
void nsPresContext::SetImgAnimations(nsIContent *aParent, PRUint16 aMode)
void nsIPresContext::SetImgAnimations(nsIContent *aParent, PRUint16 aMode)
{
nsCOMPtr<nsIImageLoadingContent> imgContent(do_QueryInterface(aParent));
if (imgContent) {
@ -830,12 +845,16 @@ void nsPresContext::SetImgAnimations(nsIContent *aParent, PRUint16 aMode)
}
void
nsPresContext::SetImageAnimationMode(PRUint16 aMode)
nsIPresContext::SetImageAnimationModeInternal(PRUint16 aMode)
{
NS_ASSERTION(aMode == imgIContainer::kNormalAnimMode ||
aMode == imgIContainer::kDontAnimMode ||
aMode == imgIContainer::kLoopOnceAnimMode, "Wrong Animation Mode is being set!");
// Image animation mode cannot be changed when rendering to a printer.
if (mMedium == nsLayoutAtoms::print)
return;
// This hash table contains a list of background images
// so iterate over it and set the mode
mImageLoaders.Enumerate(set_animation_mode, NS_INT32_TO_PTR(aMode));
@ -856,19 +875,28 @@ nsPresContext::SetImageAnimationMode(PRUint16 aMode)
mImageAnimationMode = aMode;
}
NS_IMETHODIMP
nsPresContext::GetMetricsFor(const nsFont& aFont, nsIFontMetrics** aResult)
void
nsIPresContext::SetImageAnimationModeExternal(PRUint16 aMode)
{
NS_PRECONDITION(aResult, "null out param");
SetImageAnimationModeInternal(aMode);
}
already_AddRefed<nsIFontMetrics>
nsIPresContext::GetMetricsForInternal(const nsFont& aFont)
{
nsIFontMetrics* metrics = nsnull;
mDeviceContext->GetMetricsFor(aFont, mLangGroup, metrics);
*aResult = metrics;
return NS_OK;
return metrics;
}
already_AddRefed<nsIFontMetrics>
nsIPresContext::GetMetricsForExternal(const nsFont& aFont)
{
return GetMetricsForInternal(aFont);
}
const nsFont*
nsPresContext::GetDefaultFont(PRUint8 aFontID) const
nsIPresContext::GetDefaultFontInternal(PRUint8 aFontID) const
{
const nsFont *font;
switch (aFontID) {
@ -903,14 +931,15 @@ nsPresContext::GetDefaultFont(PRUint8 aFontID) const
return font;
}
NS_IMETHODIMP
nsPresContext::GetTwipsToPixelsForFonts(float* aResult) const
const nsFont*
nsIPresContext::GetDefaultFontExternal(PRUint8 aFontID) const
{
NS_PRECONDITION(nsnull != aResult, "null ptr");
if (nsnull == aResult) {
return NS_ERROR_NULL_POINTER;
}
return GetDefaultFontInternal(aFontID);
}
float
nsIPresContext::TwipsToPixelsForFonts() const
{
float app2dev;
#ifdef NS_PRINT_PREVIEW
// If an alternative DC is available we want to use
@ -927,32 +956,30 @@ nsPresContext::GetTwipsToPixelsForFonts(float* aResult) const
#else
app2dev = mDeviceContext->AppUnitsToDevUnits();
#endif
*aResult = app2dev;
return NS_OK;
return app2dev;
}
NS_IMETHODIMP
nsPresContext::GetScaledPixelsToTwips(float* aResult) const
float
nsIPresContext::ScaledPixelsToTwips() const
{
NS_PRECONDITION(aResult, "null out param");
float scale;
float p2t;
p2t = mDeviceContext->DevUnitsToAppUnits();
mDeviceContext->GetCanonicalPixelScale(scale);
scale = p2t * scale;
if (mDoScaledTwips) {
mDeviceContext->GetCanonicalPixelScale(scale);
scale = p2t * scale;
} else {
scale = p2t;
}
*aResult = scale;
return NS_OK;
return scale;
}
nsresult
nsPresContext::LoadImage(imgIRequest* aImage,
nsIFrame* aTargetFrame,//may be null (precached image)
imgIRequest **aRequest)
imgIRequest*
nsIPresContext::LoadImage(imgIRequest* aImage, nsIFrame* aTargetFrame)
{
// look and see if we have a loader for the target frame.
@ -962,7 +989,7 @@ nsPresContext::LoadImage(imgIRequest* aImage,
if (!loader) {
loader = new nsImageLoader();
if (!loader)
return NS_ERROR_OUT_OF_MEMORY;
return nsnull;
NS_ADDREF(loader); // new
@ -972,16 +999,15 @@ nsPresContext::LoadImage(imgIRequest* aImage,
loader->Load(aImage);
NS_IF_ADDREF(*aRequest = loader->GetRequest());
imgIRequest *request = loader->GetRequest();
NS_RELEASE(loader);
return NS_OK;
return request;
}
void
nsPresContext::StopImagesFor(nsIFrame* aTargetFrame)
nsIPresContext::StopImagesFor(nsIFrame* aTargetFrame)
{
nsVoidKey key(aTargetFrame);
nsImageLoader *loader = NS_REINTERPRET_CAST(nsImageLoader*, mImageLoaders.Get(&key)); // addrefs
@ -996,7 +1022,7 @@ nsPresContext::StopImagesFor(nsIFrame* aTargetFrame)
void
nsPresContext::SetContainer(nsISupports* aHandler)
nsIPresContext::SetContainer(nsISupports* aHandler)
{
mContainer = do_GetWeakReference(aHandler);
if (mContainer) {
@ -1005,7 +1031,7 @@ nsPresContext::SetContainer(nsISupports* aHandler)
}
already_AddRefed<nsISupports>
nsPresContext::GetContainer()
nsIPresContext::GetContainerInternal()
{
nsISupports *result;
if (mContainer)
@ -1016,16 +1042,22 @@ nsPresContext::GetContainer()
return result;
}
already_AddRefed<nsISupports>
nsIPresContext::GetContainerExternal()
{
return GetContainerInternal();
}
#ifdef IBMBIDI
PRBool
nsPresContext::BidiEnabled() const
nsIPresContext::BidiEnabledInternal() const
{
PRBool bidiEnabled = PR_FALSE;
NS_ASSERTION(mShell, "PresShell must be set on PresContext before calling nsPresContext::GetBidiEnabled");
NS_ASSERTION(mShell, "PresShell must be set on PresContext before calling nsIPresContext::GetBidiEnabled");
if (mShell) {
nsCOMPtr<nsIDocument> doc;
mShell->GetDocument(getter_AddRefs(doc) );
NS_ASSERTION(doc, "PresShell has no document in nsPresContext::GetBidiEnabled");
NS_ASSERTION(doc, "PresShell has no document in nsIPresContext::GetBidiEnabled");
if (doc) {
bidiEnabled = doc->GetBidiEnabled();
}
@ -1033,8 +1065,14 @@ nsPresContext::BidiEnabled() const
return bidiEnabled;
}
PRBool
nsIPresContext::BidiEnabledExternal() const
{
return BidiEnabledInternal();
}
void
nsPresContext::SetBidiEnabled(PRBool aBidiEnabled) const
nsIPresContext::SetBidiEnabled(PRBool aBidiEnabled) const
{
if (mShell) {
nsCOMPtr<nsIDocument> doc;
@ -1045,23 +1083,17 @@ nsPresContext::SetBidiEnabled(PRBool aBidiEnabled) const
}
}
NS_IMETHODIMP
nsPresContext::GetBidiUtils(nsBidiPresUtils** aBidiUtils)
nsBidiPresUtils*
nsIPresContext::GetBidiUtils()
{
nsresult rv = NS_OK;
if (!mBidiUtils) {
if (!mBidiUtils)
mBidiUtils = new nsBidiPresUtils;
if (!mBidiUtils) {
rv = NS_ERROR_OUT_OF_MEMORY;
}
}
*aBidiUtils = mBidiUtils;
return rv;
return mBidiUtils;
}
NS_IMETHODIMP
nsPresContext::SetBidi(PRUint32 aSource, PRBool aForceReflow)
void
nsIPresContext::SetBidi(PRUint32 aSource, PRBool aForceReflow)
{
mBidi = aSource;
if (IBMBIDI_TEXTDIRECTION_RTL == GET_BIDI_OPTION_DIRECTION(mBidi)
@ -1078,22 +1110,13 @@ nsPresContext::SetBidi(PRUint32 aSource, PRBool aForceReflow)
SetVisualMode(IsVisualCharset(mCharset) );
}
if (mShell && aForceReflow) {
nsPresContext::ClearStyleDataAndReflow();
ClearStyleDataAndReflow();
}
return NS_OK;
}
NS_IMETHODIMP
nsPresContext::GetBidi(PRUint32* aDest) const
{
if (aDest)
*aDest = mBidi;
return NS_OK;
}
#endif //IBMBIDI
NS_IMETHODIMP
nsPresContext::GetTheme(nsITheme** aResult)
nsITheme*
nsIPresContext::GetTheme()
{
if (!mNoTheme && !mTheme) {
mTheme = do_GetService("@mozilla.org/chrome/chrome-native-theme;1");
@ -1101,13 +1124,11 @@ nsPresContext::GetTheme(nsITheme** aResult)
mNoTheme = PR_TRUE;
}
*aResult = mTheme;
NS_IF_ADDREF(*aResult);
return mTheme ? NS_OK : NS_ERROR_FAILURE;
return mTheme;
}
NS_IMETHODIMP
nsPresContext::ThemeChanged()
void
nsIPresContext::ThemeChanged()
{
// Tell the theme that it changed, so it can flush any handles to stale theme
// data.
@ -1118,14 +1139,12 @@ nsPresContext::ThemeChanged()
if (mLookAndFeel)
mLookAndFeel->LookAndFeelChanged();
if (!mShell)
return NS_OK;
return mShell->ReconstructStyleData();
if (mShell)
mShell->ReconstructStyleData();
}
NS_IMETHODIMP
nsPresContext::SysColorChanged()
void
nsIPresContext::SysColorChanged()
{
if (mLookAndFeel) {
// Don't use the cached values for the system colors
@ -1150,26 +1169,79 @@ nsPresContext::SysColorChanged()
// data without reflowing/updating views will lead to incorrect change hints
// later, because when generating change hints, any style structs which have
// been cleared and not reread are assumed to not be used at all.
nsPresContext::ClearStyleDataAndReflow();
ClearStyleDataAndReflow();
}
void
nsIPresContext::GetPageDim(nsRect* aActualRect, nsRect* aAdjRect)
{
if (mMedium == nsLayoutAtoms::print) {
if (aActualRect) {
PRInt32 width, height;
nsresult rv = mDeviceContext->GetDeviceSurfaceDimensions(width, height);
if (NS_SUCCEEDED(rv))
aActualRect->SetRect(0, 0, width, height);
}
if (aAdjRect)
*aAdjRect = mPageDim;
} else {
if (aActualRect)
aActualRect->SetRect(0, 0, 0, 0);
if (aAdjRect)
aAdjRect->SetRect(0, 0, 0, 0);
}
}
void
nsIPresContext::SetPageDim(const nsRect& aPageDim)
{
if (mMedium == nsLayoutAtoms::print)
mPageDim = aPageDim;
}
void
nsIPresContext::SetPaginatedScrolling(PRBool aPaginated)
{
if (mType == eContext_PrintPreview)
mCanPaginatedScroll = aPaginated;
}
void
nsIPresContext::SetPrintSettings(nsIPrintSettings *aPrintSettings)
{
if (mMedium == nsLayoutAtoms::print)
mPrintSettings = aPrintSettings;
}
nsresult
NS_NewPresContext(nsIPresContext::nsPresContextType aType,
nsIPresContext** aInstancePtrResult)
{
nsIPresContext *context = new nsIPresContext(aType);
if (!context)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*aInstancePtrResult = context);
return NS_OK;
}
#ifdef MOZ_REFLOW_PERF
NS_IMETHODIMP
nsPresContext::CountReflows(const char * aName, PRUint32 aType, nsIFrame * aFrame)
void
nsIPresContext::CountReflows(const char * aName,
PRUint32 aType, nsIFrame * aFrame)
{
if (mShell) {
mShell->CountReflows(aName, aType, aFrame);
}
return NS_OK;
}
NS_IMETHODIMP
nsPresContext::PaintCount(const char * aName, nsIRenderingContext* aRenderingContext, nsIFrame * aFrame, PRUint32 aColor)
void
nsIPresContext::PaintCount(const char * aName,
nsIRenderingContext* aRenderingContext,
nsIFrame * aFrame, PRUint32 aColor)
{
if (mShell) {
mShell->PaintCount(aName, aRenderingContext, this, aFrame, aColor);
}
return NS_OK;
}
#endif

Просмотреть файл

@ -46,11 +46,18 @@
#include "nsIPresShell.h"
#include "nsRect.h"
#include "nsIDeviceContext.h"
#include "nsHashtable.h"
#include "nsFont.h"
#include "nsIWeakReference.h"
#include "nsITheme.h"
#include "nsILanguageAtomService.h"
#include "nsIObserver.h"
#include "nsCRT.h"
#include "nsIPrintSettings.h"
#ifdef IBMBIDI
class nsBidiPresUtils;
#endif // IBMBIDI
struct nsFont;
struct nsRect;
class imgIRequest;
@ -69,7 +76,6 @@ class nsIURI;
class nsILookAndFeel;
class nsICSSPseudoComparator;
class nsIAtom;
class nsITheme;
struct nsStyleStruct;
struct nsStyleBackground;
@ -78,8 +84,8 @@ class nsIRenderingContext;
#endif
#define NS_IPRESCONTEXT_IID \
{ 0xa394329f, 0x3b10, 0x49ac, \
{0x8f, 0xf2, 0xeb, 0x0b, 0x66, 0x93, 0x82, 0x38} }
{ 0x96e4bc06, 0x8e72, 0x4941, \
{0xa6, 0x6c, 0x70, 0xee, 0x7d, 0x1b, 0x58, 0x21} }
enum nsWidgetType {
eWidgetType_Button = 1,
@ -109,20 +115,35 @@ const PRUint8 kPresContext_DefaultFixedFont_ID = 0x01; // kGenericFont_moz_fi
// An interface for presentation contexts. Presentation contexts are
// objects that provide an outer context for a presentation shell.
class nsIPresContext : public nsISupports {
class nsIPresContext : public nsIObserver {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPRESCONTEXT_IID)
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
enum nsPresContextType {
eContext_Galley, // unpaginated screen presentation
eContext_PrintPreview, // paginated screen presentation
eContext_Print // paginated printer presentation
};
nsIPresContext(nsPresContextType aType) NS_HIDDEN;
/**
* Initialize the presentation context from a particular device.
*/
NS_IMETHOD Init(nsIDeviceContext* aDeviceContext) = 0;
NS_HIDDEN_(nsresult) Init(nsIDeviceContext* aDeviceContext);
/**
* Set the presentation shell that this context is bound to.
* A presentation context may only be bound to a single shell.
*/
NS_IMETHOD SetShell(nsIPresShell* aShell) = 0;
NS_HIDDEN_(void) SetShell(nsIPresShell* aShell);
NS_HIDDEN_(nsPresContextType) Type() const { return mType; }
/**
* Get the PresentationShell that this context is bound to.
@ -151,13 +172,21 @@ public:
* relying on a default.
*/
nsCompatibility CompatibilityMode() const { return mCompatibilityMode; }
virtual void SetCompatibilityMode(nsCompatibility aMode) = 0;
NS_HIDDEN_(void) SetCompatibilityMode(nsCompatibility aMode);
/**
* Access the image animation mode for this context
*/
PRUint16 ImageAnimationMode() const { return mImageAnimationMode; }
virtual void SetImageAnimationMode(PRUint16 aMode) = 0;
virtual void SetImageAnimationModeExternal(PRUint16 aMode);
NS_HIDDEN_(void) SetImageAnimationModeInternal(PRUint16 aMode);
#ifdef _IMPL_NS_LAYOUT
void SetImageAnimationMode(PRUint16 aMode)
{ SetImageAnimationModeInternal(aMode); }
#else
void SetImageAnimationMode(PRUint16 aMode)
{ SetImageAnimationModeExternal(aMode); }
#endif
/**
* Get cached look and feel service. This is faster than obtaining it
@ -173,7 +202,7 @@ public:
/**
* Clear style data from the root frame downwards, and reflow.
*/
virtual void ClearStyleDataAndReflow() = 0;
NS_HIDDEN_(void) ClearStyleDataAndReflow();
void* AllocateFromShell(size_t aSize)
{
@ -191,13 +220,31 @@ public:
/**
* Get the font metrics for a given font.
*/
NS_IMETHOD GetMetricsFor(const nsFont& aFont, nsIFontMetrics** aResult) = 0;
virtual already_AddRefed<nsIFontMetrics>
GetMetricsForExternal(const nsFont& aFont);
NS_HIDDEN_(already_AddRefed<nsIFontMetrics>)
GetMetricsForInternal(const nsFont& aFont);
#ifdef _IMPL_NS_LAYOUT
already_AddRefed<nsIFontMetrics> GetMetricsFor(const nsFont& aFont)
{ return GetMetricsForInternal(aFont); }
#else
already_AddRefed<nsIFontMetrics> GetMetricsFor(const nsFont& aFont)
{ return GetMetricsForExternal(aFont); }
#endif
/**
* Get the default font correponding to the given ID. This object is
* read-only, you must copy the font to modify it.
*/
virtual const nsFont* GetDefaultFont(PRUint8 aFontID) const = 0;
virtual const nsFont* GetDefaultFontExternal(PRUint8 aFontID) const;
NS_HIDDEN_(const nsFont*) GetDefaultFontInternal(PRUint8 aFontID) const;
#ifdef _IMPL_NS_LAYOUT
const nsFont* GetDefaultFont(PRUint8 aFontID) const
{ return GetDefaultFontInternal(aFontID); }
#else
const nsFont* GetDefaultFont(PRUint8 aFontID) const
{ return GetDefaultFontExternal(aFontID); }
#endif
/** Get a cached boolean pref, by its type */
// * - initially created for bugs 31816, 20760, 22963
@ -263,19 +310,26 @@ public:
* method will be invoked (via the ViewManager) so that the
* appropriate damage repair is done.
*/
virtual nsresult LoadImage(imgIRequest* aImage,
nsIFrame* aTargetFrame,
imgIRequest **aRequest) = 0;
NS_HIDDEN_(imgIRequest*) LoadImage(imgIRequest* aImage,
nsIFrame* aTargetFrame);
/**
* This method is called when a frame is being destroyed to
* ensure that the image load gets disassociated from the prescontext
*/
virtual void StopImagesFor(nsIFrame* aTargetFrame) = 0;
NS_HIDDEN_(void) StopImagesFor(nsIFrame* aTargetFrame);
virtual void SetContainer(nsISupports* aContainer) = 0;
NS_HIDDEN_(void) SetContainer(nsISupports* aContainer);
virtual already_AddRefed<nsISupports> GetContainer() = 0;
virtual already_AddRefed<nsISupports> GetContainerExternal();
NS_HIDDEN_(already_AddRefed<nsISupports>) GetContainerInternal();
#ifdef _IMPL_NS_LAYOUT
already_AddRefed<nsISupports> GetContainer()
{ return GetContainerInternal(); }
#else
already_AddRefed<nsISupports> GetContainer()
{ return GetContainerExternal(); }
#endif
// XXX this are going to be replaced with set/get container
void SetLinkHandler(nsILinkHandler* aHandler) { mLinkHandler = aHandler; }
@ -305,7 +359,7 @@ public:
* Sets whether the presentation context can scroll for a paginated
* context.
*/
virtual void SetPaginatedScrolling(PRBool aResult) = 0;
NS_HIDDEN_(void) SetPaginatedScrolling(PRBool aResult);
/**
* Return true if this presentation context can scroll for paginated
@ -322,7 +376,7 @@ public:
* @param aActualRect returns the size of the actual device/surface
* @param aRect returns the adjusted size
*/
virtual void GetPageDim(nsRect* aActualRect, nsRect* aAdjRect) = 0;
NS_HIDDEN_(void) GetPageDim(nsRect* aActualRect, nsRect* aAdjRect);
/**
* Sets the "adjusted" rect for the page Dimimensions,
@ -331,20 +385,27 @@ public:
*
* @param aRect returns the adjusted size
*/
virtual void SetPageDim(nsRect* aRect) = 0;
NS_HIDDEN_(void) SetPageDim(const nsRect& aRect);
float PixelsToTwips() const { return mDeviceContext->DevUnitsToAppUnits(); }
float TwipsToPixels() const { return mDeviceContext->AppUnitsToDevUnits(); }
NS_IMETHOD GetTwipsToPixelsForFonts(float* aResult) const = 0;
NS_HIDDEN_(float) TwipsToPixelsForFonts() const;
//XXX this is probably not an ideal name. MMP
/**
* Do pixels to twips conversion taking into account
* differing size of a "pixel" from device to device.
*/
NS_IMETHOD GetScaledPixelsToTwips(float* aScale) const = 0;
NS_HIDDEN_(float) ScaledPixelsToTwips() const;
/* Convenience method for converting one pixel value to twips */
nscoord IntScaledPixelsToTwips(nscoord aPixels) const
{ return NSIntPixelsToTwips(aPixels, ScaledPixelsToTwips()); }
/* Set whether twip scaling is used */
void SetScalingOfTwips(PRBool aOn) { mDoScaledTwips = aOn; }
nsIDeviceContext* DeviceContext() { return mDeviceContext; }
nsIEventStateManager* EventStateManager() { return mEventManager; }
@ -394,14 +455,20 @@ public:
*
* @lina 07/12/2000
*/
virtual PRBool BidiEnabled() const = 0;
virtual PRBool BidiEnabledExternal() const;
NS_HIDDEN_(PRBool) BidiEnabledInternal() const;
#ifdef _IMPL_NS_LAYOUT
PRBool BidiEnabled() const { return BidiEnabledInternal(); }
#else
PRBool BidiEnabled() const { return BidiEnabledExternal(); }
#endif
/**
* Set bidi enabled. This means we should apply the Unicode Bidi Algorithm
*
* @lina 07/12/2000
*/
virtual void SetBidiEnabled(PRBool aBidiEnabled) const = 0;
NS_HIDDEN_(void) SetBidiEnabled(PRBool aBidiEnabled) const;
/**
* Set visual or implicit mode into the pres context.
@ -435,17 +502,18 @@ public:
/**
* Get a Bidi presentation utilities object
*/
NS_IMETHOD GetBidiUtils(nsBidiPresUtils** aBidiUtils) = 0;
NS_HIDDEN_(nsBidiPresUtils*) GetBidiUtils();
/**
* Set the Bidi options for the presentation context
*/
NS_IMETHOD SetBidi(PRUint32 aBidiOptions, PRBool aForceReflow = PR_FALSE) = 0;
NS_HIDDEN_(void) SetBidi(PRUint32 aBidiOptions,
PRBool aForceReflow = PR_FALSE);
/**
* Get the Bidi options for the presentation context
*/
NS_IMETHOD GetBidi(PRUint32* aBidiOptions) const = 0;
NS_HIDDEN_(PRUint32) GetBidi() const { return mBidi; }
/**
* Set the Bidi capabilities of the system
@ -478,7 +546,7 @@ public:
/*
* Obtain a native them for rendering our widgets (both form controls and html)
*/
NS_IMETHOD GetTheme(nsITheme** aResult) = 0;
NS_HIDDEN_(nsITheme*) GetTheme();
/*
* Notify the pres context that the theme has changed. An internal switch
@ -486,23 +554,42 @@ public:
* Otherwise, the OS is telling us that the native theme for the platform
* has changed.
*/
NS_IMETHOD ThemeChanged() = 0;
NS_HIDDEN_(void) ThemeChanged();
/*
* Notify the pres context that a system color has changed
*/
NS_IMETHOD SysColorChanged() = 0;
NS_HIDDEN_(void) SysColorChanged();
/** Printing methods below should only be used for Medium() == print **/
NS_HIDDEN_(void) SetPrintSettings(nsIPrintSettings *aPrintSettings);
nsIPrintSettings* GetPrintSettings() { return mPrintSettings; }
#ifdef MOZ_REFLOW_PERF
NS_IMETHOD CountReflows(const char * aName, PRUint32 aType, nsIFrame * aFrame) = 0;
NS_IMETHOD PaintCount(const char * aName, nsIRenderingContext* aRendingContext, nsIFrame * aFrame, PRUint32 aColor) = 0;
NS_HIDDEN_(void) CountReflows(const char * aName,
PRUint32 aType, nsIFrame * aFrame);
NS_HIDDEN_(void) PaintCount(const char * aName,
nsIRenderingContext* aRendingContext,
nsIFrame * aFrame, PRUint32 aColor);
#endif
protected:
NS_HIDDEN_(void) SetImgAnimations(nsIContent *aParent, PRUint16 aMode);
NS_HIDDEN_(void) GetDocumentColorPreferences();
NS_HIDDEN_(void) PreferenceChanged(const char* aPrefName);
static NS_HIDDEN_(int) PR_CALLBACK PrefChangedCallback(const char*, void*);
NS_HIDDEN_(void) GetUserPreferences();
NS_HIDDEN_(void) GetFontPreferences();
NS_HIDDEN_(void) UpdateCharSet(const char* aCharSet);
// IMPORTANT: The ownership implicit in the following member variables
// has been explicitly checked. If you add any members to this class,
// please make the ownership explicit (pinkerton, scc).
nsPresContextType mType;
nsIPresShell* mShell; // [WEAK]
nsIDeviceContext* mDeviceContext; // [STRONG] could be weak, but
// better safe than sorry.
@ -517,11 +604,24 @@ protected:
nsILinkHandler* mLinkHandler; // [WEAK]
nsIAtom* mLangGroup; // [STRONG]
nsSupportsHashtable mImageLoaders;
nsWeakPtr mContainer;
#ifdef IBMBIDI
nsBidiPresUtils* mBidiUtils;
nsCString mCharset; // the charset we are using
#endif
nsCOMPtr<nsITheme> mTheme;
nsCOMPtr<nsILanguageAtomService> mLangService;
nsCOMPtr<nsIPrintSettings> mPrintSettings;
nsLanguageSpecificTransformType mLanguageSpecificTransformType;
PRInt32 mFontScaler;
nscoord mMinimumFontSize;
nsRect mVisibleArea;
nsRect mPageDim;
nscolor mDefaultColor;
nscolor mBackgroundColor;
@ -538,6 +638,15 @@ protected:
nsCompatibility mCompatibilityMode;
PRUint16 mImageAnimationMode;
PRUint16 mImageAnimationModePref;
nsFont mDefaultVariableFont;
nsFont mDefaultFixedFont;
nsFont mDefaultSerifFont;
nsFont mDefaultSansSerifFont;
nsFont mDefaultMonospaceFont;
nsFont mDefaultCursiveFont;
nsFont mDefaultFantasyFont;
unsigned mUseDocumentFonts : 1;
unsigned mUseDocumentColors : 1;
@ -551,10 +660,35 @@ protected:
unsigned mNoTheme : 1;
unsigned mPaginated : 1;
unsigned mCanPaginatedScroll : 1;
unsigned mDoScaledTwips : 1;
unsigned mEnableJapaneseTransform : 1;
#ifdef IBMBIDI
unsigned mIsVisual : 1;
unsigned mIsBidiSystem : 1;
PRUint32 mBidi;
#endif
#ifdef DEBUG
PRBool mInitialized;
#endif
private:
~nsIPresContext() NS_HIDDEN;
// these are private, use the list in nsFont.h if you want a public list
enum {
eDefaultFont_Variable,
eDefaultFont_Fixed,
eDefaultFont_Serif,
eDefaultFont_SansSerif,
eDefaultFont_Monospace,
eDefaultFont_Cursive,
eDefaultFont_Fantasy,
eDefaultFont_COUNT
};
};
// Bit values for StartLoadImage's aImageStatus
@ -562,11 +696,6 @@ protected:
#define NS_LOAD_IMAGE_STATUS_SIZE 0x2
#define NS_LOAD_IMAGE_STATUS_BITS 0x4
// Factory method to create a "galley" presentation context (galley is
// a kind of view that has no limit to the size of a page)
nsresult
NS_NewGalleyContext(nsIPresContext** aInstancePtrResult);
#ifdef MOZ_REFLOW_PERF
#define DO_GLOBAL_REFLOW_COUNT(_name, _type) \

Просмотреть файл

@ -146,7 +146,6 @@
#include "nsIDOMWindowInternal.h"
#include "nsPIDOMWindow.h"
#include "nsIFocusController.h"
#include "nsIPrintPreviewContext.h"
// Drag & Drop, Clipboard
#include "nsWidgetsCID.h"
@ -196,7 +195,6 @@
#include "nsContentCID.h"
static NS_DEFINE_CID(kCSSStyleSheetCID, NS_CSS_STYLESHEET_CID);
static NS_DEFINE_IID(kRangeCID, NS_RANGE_CID);
static NS_DEFINE_CID(kPrintPreviewContextCID, NS_PRINT_PREVIEW_CONTEXT_CID);
// convert a color value to a string, in the CSS format #RRGGBB
// * - initially created for bugs 31816, 20760, 22963
@ -3541,8 +3539,7 @@ PresShell::GetPageSequenceFrame(nsIPageSequenceFrame** aResult) const
// if it is then get the scrolled frame
scrollable->GetScrolledFrame(nsnull, child);
} else {
nsCOMPtr<nsIPrintPreviewContext> ppContext = do_QueryInterface(mPresContext);
if (ppContext) {
if (mPresContext->Type() == nsIPresContext::eContext_PrintPreview) {
child = child->GetFirstChild(nsnull);
}
}
@ -5700,7 +5697,8 @@ PresShell::HandleEvent(nsIView *aView,
// Check for a theme change up front, since the frame type is irrelevant
if (aEvent->message == NS_THEMECHANGED && mPresContext) {
return mPresContext->ThemeChanged();
mPresContext->ThemeChanged();
return NS_OK;
}
// Check for a system color change up front, since the frame type is
@ -5717,7 +5715,8 @@ PresShell::HandleEvent(nsIView *aView,
if (view == aView) {
aHandled = PR_TRUE;
*aEventStatus = nsEventStatus_eConsumeDoDefault;
return mPresContext->SysColorChanged();
mPresContext->SysColorChanged();
return NS_OK;
}
}
return NS_OK;
@ -7027,16 +7026,12 @@ PresShell::VerifyIncrementalReflow()
nsIPresShell* sh;
// Create a presentation context to view the new frame tree
nsresult rv;
if (mPresContext->IsPaginated()) {
nsCOMPtr<nsIPrintPreviewContext> ppx = do_CreateInstance(kPrintPreviewContextCID, &rv);
if (NS_SUCCEEDED(rv)) {
ppx->QueryInterface(NS_GET_IID(nsIPresContext),(void**)&cx);
}
}
else {
rv = NS_NewGalleyContext(&cx);
}
NS_IF_ADDREF(cx = new nsIPresContext(mPresContext->IsPaginated() ?
nsIPresContext::eContext_PrintPreview :
nsIPresContext::eContext_Galley));
if (!cx)
return NS_ERROR_OUT_OF_MEMORY;
nsCOMPtr<nsISupports> container = mPresContext->GetContainer();
if (container) {
@ -7047,9 +7042,8 @@ PresShell::VerifyIncrementalReflow()
}
}
NS_ASSERTION(NS_SUCCEEDED (rv), "failed to create presentation context");
nsIDeviceContext *dc = mPresContext->DeviceContext();
rv = cx->Init(dc);
nsresult rv = cx->Init(dc);
NS_ENSURE_SUCCESS(rv, rv);
// Get our scrolling preference
@ -7548,8 +7542,7 @@ void ReflowCountMgr::PaintCount(const char * aName,
nsFont font("Times", NS_FONT_STYLE_NORMAL,NS_FONT_VARIANT_NORMAL,
NS_FONT_WEIGHT_NORMAL,0,NSIntPointsToTwips(8));
nsCOMPtr<nsIFontMetrics> fm;
aPresContext->GetMetricsFor(font, getter_AddRefs(fm));
nsCOMPtr<nsIFontMetrics> fm = aPresContext->GetMetricsFor(font);
aRenderingContext->SetFont(fm);
char buf[16];
sprintf(buf, "%d", counter->mCount);

Просмотреть файл

@ -74,8 +74,6 @@ nsIPercentHeightObserver.h \
nsIPresContext.h \
nsIPresShell.h \
nsIPresState.h \
nsIPrintContext.h \
nsIPrintPreviewContext.h \
nsIReflowCallback.h \
nsIScrollableFrame.h \
nsIScrollableViewProvider.h \

Просмотреть файл

@ -46,11 +46,18 @@
#include "nsIPresShell.h"
#include "nsRect.h"
#include "nsIDeviceContext.h"
#include "nsHashtable.h"
#include "nsFont.h"
#include "nsIWeakReference.h"
#include "nsITheme.h"
#include "nsILanguageAtomService.h"
#include "nsIObserver.h"
#include "nsCRT.h"
#include "nsIPrintSettings.h"
#ifdef IBMBIDI
class nsBidiPresUtils;
#endif // IBMBIDI
struct nsFont;
struct nsRect;
class imgIRequest;
@ -69,7 +76,6 @@ class nsIURI;
class nsILookAndFeel;
class nsICSSPseudoComparator;
class nsIAtom;
class nsITheme;
struct nsStyleStruct;
struct nsStyleBackground;
@ -78,8 +84,8 @@ class nsIRenderingContext;
#endif
#define NS_IPRESCONTEXT_IID \
{ 0xa394329f, 0x3b10, 0x49ac, \
{0x8f, 0xf2, 0xeb, 0x0b, 0x66, 0x93, 0x82, 0x38} }
{ 0x96e4bc06, 0x8e72, 0x4941, \
{0xa6, 0x6c, 0x70, 0xee, 0x7d, 0x1b, 0x58, 0x21} }
enum nsWidgetType {
eWidgetType_Button = 1,
@ -109,20 +115,35 @@ const PRUint8 kPresContext_DefaultFixedFont_ID = 0x01; // kGenericFont_moz_fi
// An interface for presentation contexts. Presentation contexts are
// objects that provide an outer context for a presentation shell.
class nsIPresContext : public nsISupports {
class nsIPresContext : public nsIObserver {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPRESCONTEXT_IID)
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
enum nsPresContextType {
eContext_Galley, // unpaginated screen presentation
eContext_PrintPreview, // paginated screen presentation
eContext_Print // paginated printer presentation
};
nsIPresContext(nsPresContextType aType) NS_HIDDEN;
/**
* Initialize the presentation context from a particular device.
*/
NS_IMETHOD Init(nsIDeviceContext* aDeviceContext) = 0;
NS_HIDDEN_(nsresult) Init(nsIDeviceContext* aDeviceContext);
/**
* Set the presentation shell that this context is bound to.
* A presentation context may only be bound to a single shell.
*/
NS_IMETHOD SetShell(nsIPresShell* aShell) = 0;
NS_HIDDEN_(void) SetShell(nsIPresShell* aShell);
NS_HIDDEN_(nsPresContextType) Type() const { return mType; }
/**
* Get the PresentationShell that this context is bound to.
@ -151,13 +172,21 @@ public:
* relying on a default.
*/
nsCompatibility CompatibilityMode() const { return mCompatibilityMode; }
virtual void SetCompatibilityMode(nsCompatibility aMode) = 0;
NS_HIDDEN_(void) SetCompatibilityMode(nsCompatibility aMode);
/**
* Access the image animation mode for this context
*/
PRUint16 ImageAnimationMode() const { return mImageAnimationMode; }
virtual void SetImageAnimationMode(PRUint16 aMode) = 0;
virtual void SetImageAnimationModeExternal(PRUint16 aMode);
NS_HIDDEN_(void) SetImageAnimationModeInternal(PRUint16 aMode);
#ifdef _IMPL_NS_LAYOUT
void SetImageAnimationMode(PRUint16 aMode)
{ SetImageAnimationModeInternal(aMode); }
#else
void SetImageAnimationMode(PRUint16 aMode)
{ SetImageAnimationModeExternal(aMode); }
#endif
/**
* Get cached look and feel service. This is faster than obtaining it
@ -173,7 +202,7 @@ public:
/**
* Clear style data from the root frame downwards, and reflow.
*/
virtual void ClearStyleDataAndReflow() = 0;
NS_HIDDEN_(void) ClearStyleDataAndReflow();
void* AllocateFromShell(size_t aSize)
{
@ -191,13 +220,31 @@ public:
/**
* Get the font metrics for a given font.
*/
NS_IMETHOD GetMetricsFor(const nsFont& aFont, nsIFontMetrics** aResult) = 0;
virtual already_AddRefed<nsIFontMetrics>
GetMetricsForExternal(const nsFont& aFont);
NS_HIDDEN_(already_AddRefed<nsIFontMetrics>)
GetMetricsForInternal(const nsFont& aFont);
#ifdef _IMPL_NS_LAYOUT
already_AddRefed<nsIFontMetrics> GetMetricsFor(const nsFont& aFont)
{ return GetMetricsForInternal(aFont); }
#else
already_AddRefed<nsIFontMetrics> GetMetricsFor(const nsFont& aFont)
{ return GetMetricsForExternal(aFont); }
#endif
/**
* Get the default font correponding to the given ID. This object is
* read-only, you must copy the font to modify it.
*/
virtual const nsFont* GetDefaultFont(PRUint8 aFontID) const = 0;
virtual const nsFont* GetDefaultFontExternal(PRUint8 aFontID) const;
NS_HIDDEN_(const nsFont*) GetDefaultFontInternal(PRUint8 aFontID) const;
#ifdef _IMPL_NS_LAYOUT
const nsFont* GetDefaultFont(PRUint8 aFontID) const
{ return GetDefaultFontInternal(aFontID); }
#else
const nsFont* GetDefaultFont(PRUint8 aFontID) const
{ return GetDefaultFontExternal(aFontID); }
#endif
/** Get a cached boolean pref, by its type */
// * - initially created for bugs 31816, 20760, 22963
@ -263,19 +310,26 @@ public:
* method will be invoked (via the ViewManager) so that the
* appropriate damage repair is done.
*/
virtual nsresult LoadImage(imgIRequest* aImage,
nsIFrame* aTargetFrame,
imgIRequest **aRequest) = 0;
NS_HIDDEN_(imgIRequest*) LoadImage(imgIRequest* aImage,
nsIFrame* aTargetFrame);
/**
* This method is called when a frame is being destroyed to
* ensure that the image load gets disassociated from the prescontext
*/
virtual void StopImagesFor(nsIFrame* aTargetFrame) = 0;
NS_HIDDEN_(void) StopImagesFor(nsIFrame* aTargetFrame);
virtual void SetContainer(nsISupports* aContainer) = 0;
NS_HIDDEN_(void) SetContainer(nsISupports* aContainer);
virtual already_AddRefed<nsISupports> GetContainer() = 0;
virtual already_AddRefed<nsISupports> GetContainerExternal();
NS_HIDDEN_(already_AddRefed<nsISupports>) GetContainerInternal();
#ifdef _IMPL_NS_LAYOUT
already_AddRefed<nsISupports> GetContainer()
{ return GetContainerInternal(); }
#else
already_AddRefed<nsISupports> GetContainer()
{ return GetContainerExternal(); }
#endif
// XXX this are going to be replaced with set/get container
void SetLinkHandler(nsILinkHandler* aHandler) { mLinkHandler = aHandler; }
@ -305,7 +359,7 @@ public:
* Sets whether the presentation context can scroll for a paginated
* context.
*/
virtual void SetPaginatedScrolling(PRBool aResult) = 0;
NS_HIDDEN_(void) SetPaginatedScrolling(PRBool aResult);
/**
* Return true if this presentation context can scroll for paginated
@ -322,7 +376,7 @@ public:
* @param aActualRect returns the size of the actual device/surface
* @param aRect returns the adjusted size
*/
virtual void GetPageDim(nsRect* aActualRect, nsRect* aAdjRect) = 0;
NS_HIDDEN_(void) GetPageDim(nsRect* aActualRect, nsRect* aAdjRect);
/**
* Sets the "adjusted" rect for the page Dimimensions,
@ -331,20 +385,27 @@ public:
*
* @param aRect returns the adjusted size
*/
virtual void SetPageDim(nsRect* aRect) = 0;
NS_HIDDEN_(void) SetPageDim(const nsRect& aRect);
float PixelsToTwips() const { return mDeviceContext->DevUnitsToAppUnits(); }
float TwipsToPixels() const { return mDeviceContext->AppUnitsToDevUnits(); }
NS_IMETHOD GetTwipsToPixelsForFonts(float* aResult) const = 0;
NS_HIDDEN_(float) TwipsToPixelsForFonts() const;
//XXX this is probably not an ideal name. MMP
/**
* Do pixels to twips conversion taking into account
* differing size of a "pixel" from device to device.
*/
NS_IMETHOD GetScaledPixelsToTwips(float* aScale) const = 0;
NS_HIDDEN_(float) ScaledPixelsToTwips() const;
/* Convenience method for converting one pixel value to twips */
nscoord IntScaledPixelsToTwips(nscoord aPixels) const
{ return NSIntPixelsToTwips(aPixels, ScaledPixelsToTwips()); }
/* Set whether twip scaling is used */
void SetScalingOfTwips(PRBool aOn) { mDoScaledTwips = aOn; }
nsIDeviceContext* DeviceContext() { return mDeviceContext; }
nsIEventStateManager* EventStateManager() { return mEventManager; }
@ -394,14 +455,20 @@ public:
*
* @lina 07/12/2000
*/
virtual PRBool BidiEnabled() const = 0;
virtual PRBool BidiEnabledExternal() const;
NS_HIDDEN_(PRBool) BidiEnabledInternal() const;
#ifdef _IMPL_NS_LAYOUT
PRBool BidiEnabled() const { return BidiEnabledInternal(); }
#else
PRBool BidiEnabled() const { return BidiEnabledExternal(); }
#endif
/**
* Set bidi enabled. This means we should apply the Unicode Bidi Algorithm
*
* @lina 07/12/2000
*/
virtual void SetBidiEnabled(PRBool aBidiEnabled) const = 0;
NS_HIDDEN_(void) SetBidiEnabled(PRBool aBidiEnabled) const;
/**
* Set visual or implicit mode into the pres context.
@ -435,17 +502,18 @@ public:
/**
* Get a Bidi presentation utilities object
*/
NS_IMETHOD GetBidiUtils(nsBidiPresUtils** aBidiUtils) = 0;
NS_HIDDEN_(nsBidiPresUtils*) GetBidiUtils();
/**
* Set the Bidi options for the presentation context
*/
NS_IMETHOD SetBidi(PRUint32 aBidiOptions, PRBool aForceReflow = PR_FALSE) = 0;
NS_HIDDEN_(void) SetBidi(PRUint32 aBidiOptions,
PRBool aForceReflow = PR_FALSE);
/**
* Get the Bidi options for the presentation context
*/
NS_IMETHOD GetBidi(PRUint32* aBidiOptions) const = 0;
NS_HIDDEN_(PRUint32) GetBidi() const { return mBidi; }
/**
* Set the Bidi capabilities of the system
@ -478,7 +546,7 @@ public:
/*
* Obtain a native them for rendering our widgets (both form controls and html)
*/
NS_IMETHOD GetTheme(nsITheme** aResult) = 0;
NS_HIDDEN_(nsITheme*) GetTheme();
/*
* Notify the pres context that the theme has changed. An internal switch
@ -486,23 +554,42 @@ public:
* Otherwise, the OS is telling us that the native theme for the platform
* has changed.
*/
NS_IMETHOD ThemeChanged() = 0;
NS_HIDDEN_(void) ThemeChanged();
/*
* Notify the pres context that a system color has changed
*/
NS_IMETHOD SysColorChanged() = 0;
NS_HIDDEN_(void) SysColorChanged();
/** Printing methods below should only be used for Medium() == print **/
NS_HIDDEN_(void) SetPrintSettings(nsIPrintSettings *aPrintSettings);
nsIPrintSettings* GetPrintSettings() { return mPrintSettings; }
#ifdef MOZ_REFLOW_PERF
NS_IMETHOD CountReflows(const char * aName, PRUint32 aType, nsIFrame * aFrame) = 0;
NS_IMETHOD PaintCount(const char * aName, nsIRenderingContext* aRendingContext, nsIFrame * aFrame, PRUint32 aColor) = 0;
NS_HIDDEN_(void) CountReflows(const char * aName,
PRUint32 aType, nsIFrame * aFrame);
NS_HIDDEN_(void) PaintCount(const char * aName,
nsIRenderingContext* aRendingContext,
nsIFrame * aFrame, PRUint32 aColor);
#endif
protected:
NS_HIDDEN_(void) SetImgAnimations(nsIContent *aParent, PRUint16 aMode);
NS_HIDDEN_(void) GetDocumentColorPreferences();
NS_HIDDEN_(void) PreferenceChanged(const char* aPrefName);
static NS_HIDDEN_(int) PR_CALLBACK PrefChangedCallback(const char*, void*);
NS_HIDDEN_(void) GetUserPreferences();
NS_HIDDEN_(void) GetFontPreferences();
NS_HIDDEN_(void) UpdateCharSet(const char* aCharSet);
// IMPORTANT: The ownership implicit in the following member variables
// has been explicitly checked. If you add any members to this class,
// please make the ownership explicit (pinkerton, scc).
nsPresContextType mType;
nsIPresShell* mShell; // [WEAK]
nsIDeviceContext* mDeviceContext; // [STRONG] could be weak, but
// better safe than sorry.
@ -517,11 +604,24 @@ protected:
nsILinkHandler* mLinkHandler; // [WEAK]
nsIAtom* mLangGroup; // [STRONG]
nsSupportsHashtable mImageLoaders;
nsWeakPtr mContainer;
#ifdef IBMBIDI
nsBidiPresUtils* mBidiUtils;
nsCString mCharset; // the charset we are using
#endif
nsCOMPtr<nsITheme> mTheme;
nsCOMPtr<nsILanguageAtomService> mLangService;
nsCOMPtr<nsIPrintSettings> mPrintSettings;
nsLanguageSpecificTransformType mLanguageSpecificTransformType;
PRInt32 mFontScaler;
nscoord mMinimumFontSize;
nsRect mVisibleArea;
nsRect mPageDim;
nscolor mDefaultColor;
nscolor mBackgroundColor;
@ -538,6 +638,15 @@ protected:
nsCompatibility mCompatibilityMode;
PRUint16 mImageAnimationMode;
PRUint16 mImageAnimationModePref;
nsFont mDefaultVariableFont;
nsFont mDefaultFixedFont;
nsFont mDefaultSerifFont;
nsFont mDefaultSansSerifFont;
nsFont mDefaultMonospaceFont;
nsFont mDefaultCursiveFont;
nsFont mDefaultFantasyFont;
unsigned mUseDocumentFonts : 1;
unsigned mUseDocumentColors : 1;
@ -551,10 +660,35 @@ protected:
unsigned mNoTheme : 1;
unsigned mPaginated : 1;
unsigned mCanPaginatedScroll : 1;
unsigned mDoScaledTwips : 1;
unsigned mEnableJapaneseTransform : 1;
#ifdef IBMBIDI
unsigned mIsVisual : 1;
unsigned mIsBidiSystem : 1;
PRUint32 mBidi;
#endif
#ifdef DEBUG
PRBool mInitialized;
#endif
private:
~nsIPresContext() NS_HIDDEN;
// these are private, use the list in nsFont.h if you want a public list
enum {
eDefaultFont_Variable,
eDefaultFont_Fixed,
eDefaultFont_Serif,
eDefaultFont_SansSerif,
eDefaultFont_Monospace,
eDefaultFont_Cursive,
eDefaultFont_Fantasy,
eDefaultFont_COUNT
};
};
// Bit values for StartLoadImage's aImageStatus
@ -562,11 +696,6 @@ protected:
#define NS_LOAD_IMAGE_STATUS_SIZE 0x2
#define NS_LOAD_IMAGE_STATUS_BITS 0x4
// Factory method to create a "galley" presentation context (galley is
// a kind of view that has no limit to the size of a page)
nsresult
NS_NewGalleyContext(nsIPresContext** aInstancePtrResult);
#ifdef MOZ_REFLOW_PERF
#define DO_GLOBAL_REFLOW_COUNT(_name, _type) \

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -46,11 +46,18 @@
#include "nsIPresShell.h"
#include "nsRect.h"
#include "nsIDeviceContext.h"
#include "nsHashtable.h"
#include "nsFont.h"
#include "nsIWeakReference.h"
#include "nsITheme.h"
#include "nsILanguageAtomService.h"
#include "nsIObserver.h"
#include "nsCRT.h"
#include "nsIPrintSettings.h"
#ifdef IBMBIDI
class nsBidiPresUtils;
#endif // IBMBIDI
struct nsFont;
struct nsRect;
class imgIRequest;
@ -69,7 +76,6 @@ class nsIURI;
class nsILookAndFeel;
class nsICSSPseudoComparator;
class nsIAtom;
class nsITheme;
struct nsStyleStruct;
struct nsStyleBackground;
@ -78,8 +84,8 @@ class nsIRenderingContext;
#endif
#define NS_IPRESCONTEXT_IID \
{ 0xa394329f, 0x3b10, 0x49ac, \
{0x8f, 0xf2, 0xeb, 0x0b, 0x66, 0x93, 0x82, 0x38} }
{ 0x96e4bc06, 0x8e72, 0x4941, \
{0xa6, 0x6c, 0x70, 0xee, 0x7d, 0x1b, 0x58, 0x21} }
enum nsWidgetType {
eWidgetType_Button = 1,
@ -109,20 +115,35 @@ const PRUint8 kPresContext_DefaultFixedFont_ID = 0x01; // kGenericFont_moz_fi
// An interface for presentation contexts. Presentation contexts are
// objects that provide an outer context for a presentation shell.
class nsIPresContext : public nsISupports {
class nsIPresContext : public nsIObserver {
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IPRESCONTEXT_IID)
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
enum nsPresContextType {
eContext_Galley, // unpaginated screen presentation
eContext_PrintPreview, // paginated screen presentation
eContext_Print // paginated printer presentation
};
nsIPresContext(nsPresContextType aType) NS_HIDDEN;
/**
* Initialize the presentation context from a particular device.
*/
NS_IMETHOD Init(nsIDeviceContext* aDeviceContext) = 0;
NS_HIDDEN_(nsresult) Init(nsIDeviceContext* aDeviceContext);
/**
* Set the presentation shell that this context is bound to.
* A presentation context may only be bound to a single shell.
*/
NS_IMETHOD SetShell(nsIPresShell* aShell) = 0;
NS_HIDDEN_(void) SetShell(nsIPresShell* aShell);
NS_HIDDEN_(nsPresContextType) Type() const { return mType; }
/**
* Get the PresentationShell that this context is bound to.
@ -151,13 +172,21 @@ public:
* relying on a default.
*/
nsCompatibility CompatibilityMode() const { return mCompatibilityMode; }
virtual void SetCompatibilityMode(nsCompatibility aMode) = 0;
NS_HIDDEN_(void) SetCompatibilityMode(nsCompatibility aMode);
/**
* Access the image animation mode for this context
*/
PRUint16 ImageAnimationMode() const { return mImageAnimationMode; }
virtual void SetImageAnimationMode(PRUint16 aMode) = 0;
virtual void SetImageAnimationModeExternal(PRUint16 aMode);
NS_HIDDEN_(void) SetImageAnimationModeInternal(PRUint16 aMode);
#ifdef _IMPL_NS_LAYOUT
void SetImageAnimationMode(PRUint16 aMode)
{ SetImageAnimationModeInternal(aMode); }
#else
void SetImageAnimationMode(PRUint16 aMode)
{ SetImageAnimationModeExternal(aMode); }
#endif
/**
* Get cached look and feel service. This is faster than obtaining it
@ -173,7 +202,7 @@ public:
/**
* Clear style data from the root frame downwards, and reflow.
*/
virtual void ClearStyleDataAndReflow() = 0;
NS_HIDDEN_(void) ClearStyleDataAndReflow();
void* AllocateFromShell(size_t aSize)
{
@ -191,13 +220,31 @@ public:
/**
* Get the font metrics for a given font.
*/
NS_IMETHOD GetMetricsFor(const nsFont& aFont, nsIFontMetrics** aResult) = 0;
virtual already_AddRefed<nsIFontMetrics>
GetMetricsForExternal(const nsFont& aFont);
NS_HIDDEN_(already_AddRefed<nsIFontMetrics>)
GetMetricsForInternal(const nsFont& aFont);
#ifdef _IMPL_NS_LAYOUT
already_AddRefed<nsIFontMetrics> GetMetricsFor(const nsFont& aFont)
{ return GetMetricsForInternal(aFont); }
#else
already_AddRefed<nsIFontMetrics> GetMetricsFor(const nsFont& aFont)
{ return GetMetricsForExternal(aFont); }
#endif
/**
* Get the default font correponding to the given ID. This object is
* read-only, you must copy the font to modify it.
*/
virtual const nsFont* GetDefaultFont(PRUint8 aFontID) const = 0;
virtual const nsFont* GetDefaultFontExternal(PRUint8 aFontID) const;
NS_HIDDEN_(const nsFont*) GetDefaultFontInternal(PRUint8 aFontID) const;
#ifdef _IMPL_NS_LAYOUT
const nsFont* GetDefaultFont(PRUint8 aFontID) const
{ return GetDefaultFontInternal(aFontID); }
#else
const nsFont* GetDefaultFont(PRUint8 aFontID) const
{ return GetDefaultFontExternal(aFontID); }
#endif
/** Get a cached boolean pref, by its type */
// * - initially created for bugs 31816, 20760, 22963
@ -263,19 +310,26 @@ public:
* method will be invoked (via the ViewManager) so that the
* appropriate damage repair is done.
*/
virtual nsresult LoadImage(imgIRequest* aImage,
nsIFrame* aTargetFrame,
imgIRequest **aRequest) = 0;
NS_HIDDEN_(imgIRequest*) LoadImage(imgIRequest* aImage,
nsIFrame* aTargetFrame);
/**
* This method is called when a frame is being destroyed to
* ensure that the image load gets disassociated from the prescontext
*/
virtual void StopImagesFor(nsIFrame* aTargetFrame) = 0;
NS_HIDDEN_(void) StopImagesFor(nsIFrame* aTargetFrame);
virtual void SetContainer(nsISupports* aContainer) = 0;
NS_HIDDEN_(void) SetContainer(nsISupports* aContainer);
virtual already_AddRefed<nsISupports> GetContainer() = 0;
virtual already_AddRefed<nsISupports> GetContainerExternal();
NS_HIDDEN_(already_AddRefed<nsISupports>) GetContainerInternal();
#ifdef _IMPL_NS_LAYOUT
already_AddRefed<nsISupports> GetContainer()
{ return GetContainerInternal(); }
#else
already_AddRefed<nsISupports> GetContainer()
{ return GetContainerExternal(); }
#endif
// XXX this are going to be replaced with set/get container
void SetLinkHandler(nsILinkHandler* aHandler) { mLinkHandler = aHandler; }
@ -305,7 +359,7 @@ public:
* Sets whether the presentation context can scroll for a paginated
* context.
*/
virtual void SetPaginatedScrolling(PRBool aResult) = 0;
NS_HIDDEN_(void) SetPaginatedScrolling(PRBool aResult);
/**
* Return true if this presentation context can scroll for paginated
@ -322,7 +376,7 @@ public:
* @param aActualRect returns the size of the actual device/surface
* @param aRect returns the adjusted size
*/
virtual void GetPageDim(nsRect* aActualRect, nsRect* aAdjRect) = 0;
NS_HIDDEN_(void) GetPageDim(nsRect* aActualRect, nsRect* aAdjRect);
/**
* Sets the "adjusted" rect for the page Dimimensions,
@ -331,20 +385,27 @@ public:
*
* @param aRect returns the adjusted size
*/
virtual void SetPageDim(nsRect* aRect) = 0;
NS_HIDDEN_(void) SetPageDim(const nsRect& aRect);
float PixelsToTwips() const { return mDeviceContext->DevUnitsToAppUnits(); }
float TwipsToPixels() const { return mDeviceContext->AppUnitsToDevUnits(); }
NS_IMETHOD GetTwipsToPixelsForFonts(float* aResult) const = 0;
NS_HIDDEN_(float) TwipsToPixelsForFonts() const;
//XXX this is probably not an ideal name. MMP
/**
* Do pixels to twips conversion taking into account
* differing size of a "pixel" from device to device.
*/
NS_IMETHOD GetScaledPixelsToTwips(float* aScale) const = 0;
NS_HIDDEN_(float) ScaledPixelsToTwips() const;
/* Convenience method for converting one pixel value to twips */
nscoord IntScaledPixelsToTwips(nscoord aPixels) const
{ return NSIntPixelsToTwips(aPixels, ScaledPixelsToTwips()); }
/* Set whether twip scaling is used */
void SetScalingOfTwips(PRBool aOn) { mDoScaledTwips = aOn; }
nsIDeviceContext* DeviceContext() { return mDeviceContext; }
nsIEventStateManager* EventStateManager() { return mEventManager; }
@ -394,14 +455,20 @@ public:
*
* @lina 07/12/2000
*/
virtual PRBool BidiEnabled() const = 0;
virtual PRBool BidiEnabledExternal() const;
NS_HIDDEN_(PRBool) BidiEnabledInternal() const;
#ifdef _IMPL_NS_LAYOUT
PRBool BidiEnabled() const { return BidiEnabledInternal(); }
#else
PRBool BidiEnabled() const { return BidiEnabledExternal(); }
#endif
/**
* Set bidi enabled. This means we should apply the Unicode Bidi Algorithm
*
* @lina 07/12/2000
*/
virtual void SetBidiEnabled(PRBool aBidiEnabled) const = 0;
NS_HIDDEN_(void) SetBidiEnabled(PRBool aBidiEnabled) const;
/**
* Set visual or implicit mode into the pres context.
@ -435,17 +502,18 @@ public:
/**
* Get a Bidi presentation utilities object
*/
NS_IMETHOD GetBidiUtils(nsBidiPresUtils** aBidiUtils) = 0;
NS_HIDDEN_(nsBidiPresUtils*) GetBidiUtils();
/**
* Set the Bidi options for the presentation context
*/
NS_IMETHOD SetBidi(PRUint32 aBidiOptions, PRBool aForceReflow = PR_FALSE) = 0;
NS_HIDDEN_(void) SetBidi(PRUint32 aBidiOptions,
PRBool aForceReflow = PR_FALSE);
/**
* Get the Bidi options for the presentation context
*/
NS_IMETHOD GetBidi(PRUint32* aBidiOptions) const = 0;
NS_HIDDEN_(PRUint32) GetBidi() const { return mBidi; }
/**
* Set the Bidi capabilities of the system
@ -478,7 +546,7 @@ public:
/*
* Obtain a native them for rendering our widgets (both form controls and html)
*/
NS_IMETHOD GetTheme(nsITheme** aResult) = 0;
NS_HIDDEN_(nsITheme*) GetTheme();
/*
* Notify the pres context that the theme has changed. An internal switch
@ -486,23 +554,42 @@ public:
* Otherwise, the OS is telling us that the native theme for the platform
* has changed.
*/
NS_IMETHOD ThemeChanged() = 0;
NS_HIDDEN_(void) ThemeChanged();
/*
* Notify the pres context that a system color has changed
*/
NS_IMETHOD SysColorChanged() = 0;
NS_HIDDEN_(void) SysColorChanged();
/** Printing methods below should only be used for Medium() == print **/
NS_HIDDEN_(void) SetPrintSettings(nsIPrintSettings *aPrintSettings);
nsIPrintSettings* GetPrintSettings() { return mPrintSettings; }
#ifdef MOZ_REFLOW_PERF
NS_IMETHOD CountReflows(const char * aName, PRUint32 aType, nsIFrame * aFrame) = 0;
NS_IMETHOD PaintCount(const char * aName, nsIRenderingContext* aRendingContext, nsIFrame * aFrame, PRUint32 aColor) = 0;
NS_HIDDEN_(void) CountReflows(const char * aName,
PRUint32 aType, nsIFrame * aFrame);
NS_HIDDEN_(void) PaintCount(const char * aName,
nsIRenderingContext* aRendingContext,
nsIFrame * aFrame, PRUint32 aColor);
#endif
protected:
NS_HIDDEN_(void) SetImgAnimations(nsIContent *aParent, PRUint16 aMode);
NS_HIDDEN_(void) GetDocumentColorPreferences();
NS_HIDDEN_(void) PreferenceChanged(const char* aPrefName);
static NS_HIDDEN_(int) PR_CALLBACK PrefChangedCallback(const char*, void*);
NS_HIDDEN_(void) GetUserPreferences();
NS_HIDDEN_(void) GetFontPreferences();
NS_HIDDEN_(void) UpdateCharSet(const char* aCharSet);
// IMPORTANT: The ownership implicit in the following member variables
// has been explicitly checked. If you add any members to this class,
// please make the ownership explicit (pinkerton, scc).
nsPresContextType mType;
nsIPresShell* mShell; // [WEAK]
nsIDeviceContext* mDeviceContext; // [STRONG] could be weak, but
// better safe than sorry.
@ -517,11 +604,24 @@ protected:
nsILinkHandler* mLinkHandler; // [WEAK]
nsIAtom* mLangGroup; // [STRONG]
nsSupportsHashtable mImageLoaders;
nsWeakPtr mContainer;
#ifdef IBMBIDI
nsBidiPresUtils* mBidiUtils;
nsCString mCharset; // the charset we are using
#endif
nsCOMPtr<nsITheme> mTheme;
nsCOMPtr<nsILanguageAtomService> mLangService;
nsCOMPtr<nsIPrintSettings> mPrintSettings;
nsLanguageSpecificTransformType mLanguageSpecificTransformType;
PRInt32 mFontScaler;
nscoord mMinimumFontSize;
nsRect mVisibleArea;
nsRect mPageDim;
nscolor mDefaultColor;
nscolor mBackgroundColor;
@ -538,6 +638,15 @@ protected:
nsCompatibility mCompatibilityMode;
PRUint16 mImageAnimationMode;
PRUint16 mImageAnimationModePref;
nsFont mDefaultVariableFont;
nsFont mDefaultFixedFont;
nsFont mDefaultSerifFont;
nsFont mDefaultSansSerifFont;
nsFont mDefaultMonospaceFont;
nsFont mDefaultCursiveFont;
nsFont mDefaultFantasyFont;
unsigned mUseDocumentFonts : 1;
unsigned mUseDocumentColors : 1;
@ -551,10 +660,35 @@ protected:
unsigned mNoTheme : 1;
unsigned mPaginated : 1;
unsigned mCanPaginatedScroll : 1;
unsigned mDoScaledTwips : 1;
unsigned mEnableJapaneseTransform : 1;
#ifdef IBMBIDI
unsigned mIsVisual : 1;
unsigned mIsBidiSystem : 1;
PRUint32 mBidi;
#endif
#ifdef DEBUG
PRBool mInitialized;
#endif
private:
~nsIPresContext() NS_HIDDEN;
// these are private, use the list in nsFont.h if you want a public list
enum {
eDefaultFont_Variable,
eDefaultFont_Fixed,
eDefaultFont_Serif,
eDefaultFont_SansSerif,
eDefaultFont_Monospace,
eDefaultFont_Cursive,
eDefaultFont_Fantasy,
eDefaultFont_COUNT
};
};
// Bit values for StartLoadImage's aImageStatus
@ -562,11 +696,6 @@ protected:
#define NS_LOAD_IMAGE_STATUS_SIZE 0x2
#define NS_LOAD_IMAGE_STATUS_BITS 0x4
// Factory method to create a "galley" presentation context (galley is
// a kind of view that has no limit to the size of a page)
nsresult
NS_NewGalleyContext(nsIPresContext** aInstancePtrResult);
#ifdef MOZ_REFLOW_PERF
#define DO_GLOBAL_REFLOW_COUNT(_name, _type) \

Просмотреть файл

@ -1,106 +0,0 @@
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = layout
LIBRARY_NAME = gkbase_s
REQUIRES = xpcom \
string \
dom \
content \
gfx \
widget \
view \
locale \
webshell \
necko \
uconv \
pref \
uriloader \
docshell \
imglib2 \
js \
xpconnect \
$(NULL)
CPPSRCS = \
nsAutoCopy.cpp \
nsCaret.cpp \
nsFrameList.cpp \
nsFrameTraversal.cpp \
nsFrameUtil.cpp \
nsGalleyContext.cpp \
nsImageLoader.cpp \
nsIntervalSet.cpp \
nsLayoutDebugger.cpp \
nsLayoutHistoryState.cpp \
nsLayoutUtils.cpp \
nsPresContext.cpp \
nsPresState.cpp \
nsPrintContext.cpp \
nsPrintPreviewContext.cpp \
nsSpaceManager.cpp \
nsStyleChangeList.cpp \
$(NULL)
ifdef IBMBIDI
CPPSRCS += \
nsBidiPresUtils.cpp \
nsBidi.cpp \
$(NULL)
endif
# we don't want the shared lib, but we want to force the creation of a static lib.
FORCE_STATIC_LIB = 1
include $(topsrcdir)/config/rules.mk
LOCAL_INCLUDES = \
-I$(topsrcdir)/content/events/src \
-I$(srcdir)/../../html/base/src \
-I$(srcdir)/../../html/style/src \
-I$(srcdir)/../../xul/base/src \
-I$(srcdir)/../../xul/content/src \
$(NULL)
DEFINES += -D_IMPL_NS_LAYOUT

Просмотреть файл

@ -819,8 +819,7 @@ nsBidiPresUtils::FormatUnicodeText(nsIPresContext* aPresContext,
nsresult rv = NS_OK;
// ahmed
//adjusted for correct numeral shaping
PRUint32 bidiOptions;
aPresContext->GetBidi(&bidiOptions);
PRUint32 bidiOptions = aPresContext->GetBidi();
switch (GET_BIDI_OPTION_NUMERAL(bidiOptions)) {
case IBMBIDI_NUMERAL_HINDI:

Просмотреть файл

Просмотреть файл

@ -35,7 +35,7 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsCOMPtr.h"
#include "nsPresContext.h"
#include "nsIPresContext.h"
#include "nsIPresShell.h"
#include "nsILinkHandler.h"
#include "nsIDocShellTreeItem.h"
@ -96,9 +96,9 @@ MakeColorPref(const char *colstr)
}
int PR_CALLBACK
nsPresContext::PrefChangedCallback(const char* aPrefName, void* instance_data)
nsIPresContext::PrefChangedCallback(const char* aPrefName, void* instance_data)
{
nsPresContext* presContext = (nsPresContext*)instance_data;
nsIPresContext* presContext = (nsIPresContext*)instance_data;
NS_ASSERTION(nsnull != presContext, "bad instance data");
if (nsnull != presContext) {
@ -109,7 +109,7 @@ nsPresContext::PrefChangedCallback(const char* aPrefName, void* instance_data)
#ifdef IBMBIDI
static PRBool
IsVisualCharset(const nsCAutoString& aCharset)
IsVisualCharset(const nsCString& aCharset)
{
if (aCharset.LowerCaseEqualsLiteral("ibm864") // Arabic//ahmed
|| aCharset.LowerCaseEqualsLiteral("ibm862") // Hebrew
@ -135,32 +135,32 @@ static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
#include "nsContentCID.h"
static NS_DEFINE_CID(kSelectionImageService, NS_SELECTIONIMAGESERVICE_CID);
// NOTE! nsPresContext::operator new() zeroes out all members, so don't
// NOTE! nsIPresContext::operator new() zeroes out all members, so don't
// bother initializing members to 0.
nsPresContext::nsPresContext()
: mDefaultVariableFont("serif", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
NS_FONT_WEIGHT_NORMAL, 0, NSIntPointsToTwips(12)),
nsIPresContext::nsIPresContext(nsPresContextType aType)
: mType(aType),
mCompatibilityMode(eCompatibility_FullStandards),
mImageAnimationModePref(imgIContainer::kNormalAnimMode),
mDefaultVariableFont("serif", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
NS_FONT_WEIGHT_NORMAL, 0, NSIntPointsToTwips(12)),
mDefaultFixedFont("monospace", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
NS_FONT_WEIGHT_NORMAL, 0, NSIntPointsToTwips(10)),
NS_FONT_WEIGHT_NORMAL, 0, NSIntPointsToTwips(10)),
mDefaultSerifFont("serif", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
NS_FONT_WEIGHT_NORMAL, 0, NSIntPointsToTwips(12)),
NS_FONT_WEIGHT_NORMAL, 0, NSIntPointsToTwips(12)),
mDefaultSansSerifFont("sans-serif", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
NS_FONT_WEIGHT_NORMAL, 0, NSIntPointsToTwips(12)),
NS_FONT_WEIGHT_NORMAL, 0, NSIntPointsToTwips(12)),
mDefaultMonospaceFont("monospace", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
NS_FONT_WEIGHT_NORMAL, 0, NSIntPointsToTwips(10)),
mDefaultCursiveFont("cursive", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
NS_FONT_WEIGHT_NORMAL, 0, NSIntPointsToTwips(12)),
mDefaultFantasyFont("fantasy", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
NS_FONT_WEIGHT_NORMAL, 0, NSIntPointsToTwips(12))
NS_FONT_WEIGHT_NORMAL, 0, NSIntPointsToTwips(10)),
mDefaultCursiveFont("cursive", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
NS_FONT_WEIGHT_NORMAL, 0, NSIntPointsToTwips(12)),
mDefaultFantasyFont("fantasy", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
NS_FONT_WEIGHT_NORMAL, 0, NSIntPointsToTwips(12))
{
// NOTE! nsPresContext::operator new() zeroes out all members, so don't
// NOTE! nsIPresContext::operator new() zeroes out all members, so don't
// bother initializing members to 0.
mCompatibilityMode = eCompatibility_FullStandards;
mImageAnimationMode = imgIContainer::kNormalAnimMode;
mImageAnimationModePref = imgIContainer::kNormalAnimMode;
mDoScaledTwips = PR_TRUE;
SetBackgroundImageDraw(PR_TRUE); // always draw the background
SetBackgroundColorDraw(PR_TRUE);
@ -184,9 +184,26 @@ nsPresContext::nsPresContext()
mFocusRingWidth = 1;
mLanguageSpecificTransformType = eLanguageSpecificTransformType_Unknown;
if (aType == eContext_Galley) {
mMedium = nsLayoutAtoms::screen;
mImageAnimationMode = imgIContainer::kNormalAnimMode;
} else {
SetBackgroundImageDraw(PR_FALSE);
SetBackgroundColorDraw(PR_FALSE);
mImageAnimationMode = imgIContainer::kDontAnimMode;
mNeverAnimate = PR_TRUE;
mMedium = nsLayoutAtoms::print;
mPaginated = PR_TRUE;
if (aType == eContext_PrintPreview) {
mCanPaginatedScroll = PR_TRUE;
mPageDim.SetRect(-1, -1, -1, -1);
} else {
mPageDim.SetRect(0, 0, 0, 0);
}
}
}
nsPresContext::~nsPresContext()
nsIPresContext::~nsIPresContext()
{
mImageLoaders.Enumerate(destroy_loads);
@ -200,28 +217,28 @@ nsPresContext::~nsPresContext()
// Unregister preference callbacks
nsContentUtils::UnregisterPrefCallback("font.",
nsPresContext::PrefChangedCallback,
nsIPresContext::PrefChangedCallback,
this);
nsContentUtils::UnregisterPrefCallback("browser.display.",
nsPresContext::PrefChangedCallback,
nsIPresContext::PrefChangedCallback,
this);
nsContentUtils::UnregisterPrefCallback("browser.underline_anchors",
nsPresContext::PrefChangedCallback,
nsIPresContext::PrefChangedCallback,
this);
nsContentUtils::UnregisterPrefCallback("browser.anchor_color",
nsPresContext::PrefChangedCallback,
nsIPresContext::PrefChangedCallback,
this);
nsContentUtils::UnregisterPrefCallback("browser.active_color",
nsPresContext::PrefChangedCallback,
nsIPresContext::PrefChangedCallback,
this);
nsContentUtils::UnregisterPrefCallback("browser.visited_color",
nsPresContext::PrefChangedCallback,
nsIPresContext::PrefChangedCallback,
this);
nsContentUtils::UnregisterPrefCallback("network.image.imageBehavior",
nsPresContext::PrefChangedCallback,
nsIPresContext::PrefChangedCallback,
this);
nsContentUtils::UnregisterPrefCallback("image.animation_mode",
nsPresContext::PrefChangedCallback,
nsIPresContext::PrefChangedCallback,
this);
#ifdef IBMBIDI
nsContentUtils::UnregisterPrefCallback("bidi.", PrefChangedCallback, this);
@ -234,7 +251,7 @@ nsPresContext::~nsPresContext()
NS_IF_RELEASE(mLangGroup);
}
NS_IMPL_ISUPPORTS2(nsPresContext, nsIPresContext, nsIObserver)
NS_IMPL_ISUPPORTS2(nsIPresContext, nsIPresContext, nsIObserver)
#define MAKE_FONT_PREF_KEY(_pref, _s0, _s1) \
_pref.Assign(_s0); \
@ -251,7 +268,7 @@ static const char* const kGenericFont[] = {
};
void
nsPresContext::GetFontPreferences()
nsIPresContext::GetFontPreferences()
{
if (!mLangGroup)
return;
@ -272,8 +289,7 @@ nsPresContext::GetFontPreferences()
font.minimum-size.[langGroup] = integer - settable by the user
*/
float p2t;
GetScaledPixelsToTwips(&p2t);
float p2t = ScaledPixelsToTwips();
mDefaultVariableFont.size = NSFloatPixelsToTwips((float)16, p2t);
mDefaultFixedFont.size = NSFloatPixelsToTwips((float)13, p2t);
@ -403,7 +419,7 @@ nsPresContext::GetFontPreferences()
}
void
nsPresContext::GetDocumentColorPreferences()
nsIPresContext::GetDocumentColorPreferences()
{
PRInt32 useAccessibilityTheme = 0;
PRBool usePrefColors = PR_TRUE;
@ -456,7 +472,7 @@ nsPresContext::GetDocumentColorPreferences()
}
void
nsPresContext::GetUserPreferences()
nsIPresContext::GetUserPreferences()
{
mFontScaler =
nsContentUtils::GetIntPref("browser.display.base_font_scaler",
@ -571,7 +587,7 @@ nsPresContext::GetUserPreferences()
}
void
nsPresContext::ClearStyleDataAndReflow()
nsIPresContext::ClearStyleDataAndReflow()
{
if (mShell) {
// Clear out all our style data.
@ -586,7 +602,7 @@ nsPresContext::ClearStyleDataAndReflow()
}
void
nsPresContext::PreferenceChanged(const char* aPrefName)
nsIPresContext::PreferenceChanged(const char* aPrefName)
{
nsCOMPtr<nsIDocShellTreeItem> docShell(do_QueryReferent(mContainer));
if (docShell) {
@ -605,11 +621,11 @@ nsPresContext::PreferenceChanged(const char* aPrefName)
}
mDeviceContext->FlushFontCache();
nsPresContext::ClearStyleDataAndReflow();
ClearStyleDataAndReflow();
}
NS_IMETHODIMP
nsPresContext::Init(nsIDeviceContext* aDeviceContext)
nsresult
nsIPresContext::Init(nsIDeviceContext* aDeviceContext)
{
NS_ASSERTION(!(mInitialized == PR_TRUE), "attempt to reinit pres context");
NS_ENSURE_ARG(aDeviceContext);
@ -635,28 +651,28 @@ nsPresContext::Init(nsIDeviceContext* aDeviceContext)
// Register callbacks so we're notified when the preferences change
nsContentUtils::RegisterPrefCallback("font.",
nsPresContext::PrefChangedCallback,
nsIPresContext::PrefChangedCallback,
this);
nsContentUtils::RegisterPrefCallback("browser.display.",
nsPresContext::PrefChangedCallback,
nsIPresContext::PrefChangedCallback,
this);
nsContentUtils::RegisterPrefCallback("browser.underline_anchors",
nsPresContext::PrefChangedCallback,
nsIPresContext::PrefChangedCallback,
this);
nsContentUtils::RegisterPrefCallback("browser.anchor_color",
nsPresContext::PrefChangedCallback,
nsIPresContext::PrefChangedCallback,
this);
nsContentUtils::RegisterPrefCallback("browser.active_color",
nsPresContext::PrefChangedCallback,
nsIPresContext::PrefChangedCallback,
this);
nsContentUtils::RegisterPrefCallback("browser.visited_color",
nsPresContext::PrefChangedCallback,
nsIPresContext::PrefChangedCallback,
this);
nsContentUtils::RegisterPrefCallback("network.image.imageBehavior",
nsPresContext::PrefChangedCallback,
nsIPresContext::PrefChangedCallback,
this);
nsContentUtils::RegisterPrefCallback("image.animation_mode",
nsPresContext::PrefChangedCallback,
nsIPresContext::PrefChangedCallback,
this);
#ifdef IBMBIDI
nsContentUtils::RegisterPrefCallback("bidi.", PrefChangedCallback,
@ -680,8 +696,8 @@ nsPresContext::Init(nsIDeviceContext* aDeviceContext)
// Note: We don't hold a reference on the shell; it has a reference to
// us
NS_IMETHODIMP
nsPresContext::SetShell(nsIPresShell* aShell)
void
nsIPresContext::SetShell(nsIPresShell* aShell)
{
if (mShell) {
// Remove ourselves as the charset observer from the shell's doc, because
@ -702,7 +718,7 @@ nsPresContext::SetShell(nsIPresShell* aShell)
if (doc) {
nsIURI *baseURI = doc->GetBaseURI();
if (!mNeverAnimate && baseURI) {
if (mMedium != nsLayoutAtoms::print && baseURI) {
PRBool isChrome = PR_FALSE;
PRBool isRes = PR_FALSE;
baseURI->SchemeIs("chrome", &isChrome);
@ -721,11 +737,10 @@ nsPresContext::SetShell(nsIPresShell* aShell)
}
}
}
return NS_OK;
}
void
nsPresContext::UpdateCharSet(const char* aCharSet)
nsIPresContext::UpdateCharSet(const char* aCharSet)
{
if (mLangService) {
NS_IF_RELEASE(mLangGroup);
@ -757,24 +772,24 @@ nsPresContext::UpdateCharSet(const char* aCharSet)
}
NS_IMETHODIMP
nsPresContext::Observe(nsISupports* aSubject,
const char* aTopic,
const PRUnichar* aData)
nsIPresContext::Observe(nsISupports* aSubject,
const char* aTopic,
const PRUnichar* aData)
{
if (!nsCRT::strcmp(aTopic, "charset")) {
UpdateCharSet(NS_LossyConvertUCS2toASCII(aData).get());
mDeviceContext->FlushFontCache();
nsPresContext::ClearStyleDataAndReflow();
ClearStyleDataAndReflow();
return NS_OK;
}
NS_WARNING("unrecognized topic in nsPresContext::Observe");
NS_WARNING("unrecognized topic in nsIPresContext::Observe");
return NS_ERROR_FAILURE;
}
void
nsPresContext::SetCompatibilityMode(nsCompatibility aMode)
nsIPresContext::SetCompatibilityMode(nsCompatibility aMode)
{
mCompatibilityMode = aMode;
@ -813,7 +828,7 @@ PR_STATIC_CALLBACK(PRBool) set_animation_mode(nsHashKey *aKey, void *aData, void
//
// Walks content and set the animation mode
// this is a way to turn on/off image animations
void nsPresContext::SetImgAnimations(nsIContent *aParent, PRUint16 aMode)
void nsIPresContext::SetImgAnimations(nsIContent *aParent, PRUint16 aMode)
{
nsCOMPtr<nsIImageLoadingContent> imgContent(do_QueryInterface(aParent));
if (imgContent) {
@ -830,12 +845,16 @@ void nsPresContext::SetImgAnimations(nsIContent *aParent, PRUint16 aMode)
}
void
nsPresContext::SetImageAnimationMode(PRUint16 aMode)
nsIPresContext::SetImageAnimationModeInternal(PRUint16 aMode)
{
NS_ASSERTION(aMode == imgIContainer::kNormalAnimMode ||
aMode == imgIContainer::kDontAnimMode ||
aMode == imgIContainer::kLoopOnceAnimMode, "Wrong Animation Mode is being set!");
// Image animation mode cannot be changed when rendering to a printer.
if (mMedium == nsLayoutAtoms::print)
return;
// This hash table contains a list of background images
// so iterate over it and set the mode
mImageLoaders.Enumerate(set_animation_mode, NS_INT32_TO_PTR(aMode));
@ -856,19 +875,28 @@ nsPresContext::SetImageAnimationMode(PRUint16 aMode)
mImageAnimationMode = aMode;
}
NS_IMETHODIMP
nsPresContext::GetMetricsFor(const nsFont& aFont, nsIFontMetrics** aResult)
void
nsIPresContext::SetImageAnimationModeExternal(PRUint16 aMode)
{
NS_PRECONDITION(aResult, "null out param");
SetImageAnimationModeInternal(aMode);
}
already_AddRefed<nsIFontMetrics>
nsIPresContext::GetMetricsForInternal(const nsFont& aFont)
{
nsIFontMetrics* metrics = nsnull;
mDeviceContext->GetMetricsFor(aFont, mLangGroup, metrics);
*aResult = metrics;
return NS_OK;
return metrics;
}
already_AddRefed<nsIFontMetrics>
nsIPresContext::GetMetricsForExternal(const nsFont& aFont)
{
return GetMetricsForInternal(aFont);
}
const nsFont*
nsPresContext::GetDefaultFont(PRUint8 aFontID) const
nsIPresContext::GetDefaultFontInternal(PRUint8 aFontID) const
{
const nsFont *font;
switch (aFontID) {
@ -903,14 +931,15 @@ nsPresContext::GetDefaultFont(PRUint8 aFontID) const
return font;
}
NS_IMETHODIMP
nsPresContext::GetTwipsToPixelsForFonts(float* aResult) const
const nsFont*
nsIPresContext::GetDefaultFontExternal(PRUint8 aFontID) const
{
NS_PRECONDITION(nsnull != aResult, "null ptr");
if (nsnull == aResult) {
return NS_ERROR_NULL_POINTER;
}
return GetDefaultFontInternal(aFontID);
}
float
nsIPresContext::TwipsToPixelsForFonts() const
{
float app2dev;
#ifdef NS_PRINT_PREVIEW
// If an alternative DC is available we want to use
@ -927,32 +956,30 @@ nsPresContext::GetTwipsToPixelsForFonts(float* aResult) const
#else
app2dev = mDeviceContext->AppUnitsToDevUnits();
#endif
*aResult = app2dev;
return NS_OK;
return app2dev;
}
NS_IMETHODIMP
nsPresContext::GetScaledPixelsToTwips(float* aResult) const
float
nsIPresContext::ScaledPixelsToTwips() const
{
NS_PRECONDITION(aResult, "null out param");
float scale;
float p2t;
p2t = mDeviceContext->DevUnitsToAppUnits();
mDeviceContext->GetCanonicalPixelScale(scale);
scale = p2t * scale;
if (mDoScaledTwips) {
mDeviceContext->GetCanonicalPixelScale(scale);
scale = p2t * scale;
} else {
scale = p2t;
}
*aResult = scale;
return NS_OK;
return scale;
}
nsresult
nsPresContext::LoadImage(imgIRequest* aImage,
nsIFrame* aTargetFrame,//may be null (precached image)
imgIRequest **aRequest)
imgIRequest*
nsIPresContext::LoadImage(imgIRequest* aImage, nsIFrame* aTargetFrame)
{
// look and see if we have a loader for the target frame.
@ -962,7 +989,7 @@ nsPresContext::LoadImage(imgIRequest* aImage,
if (!loader) {
loader = new nsImageLoader();
if (!loader)
return NS_ERROR_OUT_OF_MEMORY;
return nsnull;
NS_ADDREF(loader); // new
@ -972,16 +999,15 @@ nsPresContext::LoadImage(imgIRequest* aImage,
loader->Load(aImage);
NS_IF_ADDREF(*aRequest = loader->GetRequest());
imgIRequest *request = loader->GetRequest();
NS_RELEASE(loader);
return NS_OK;
return request;
}
void
nsPresContext::StopImagesFor(nsIFrame* aTargetFrame)
nsIPresContext::StopImagesFor(nsIFrame* aTargetFrame)
{
nsVoidKey key(aTargetFrame);
nsImageLoader *loader = NS_REINTERPRET_CAST(nsImageLoader*, mImageLoaders.Get(&key)); // addrefs
@ -996,7 +1022,7 @@ nsPresContext::StopImagesFor(nsIFrame* aTargetFrame)
void
nsPresContext::SetContainer(nsISupports* aHandler)
nsIPresContext::SetContainer(nsISupports* aHandler)
{
mContainer = do_GetWeakReference(aHandler);
if (mContainer) {
@ -1005,7 +1031,7 @@ nsPresContext::SetContainer(nsISupports* aHandler)
}
already_AddRefed<nsISupports>
nsPresContext::GetContainer()
nsIPresContext::GetContainerInternal()
{
nsISupports *result;
if (mContainer)
@ -1016,16 +1042,22 @@ nsPresContext::GetContainer()
return result;
}
already_AddRefed<nsISupports>
nsIPresContext::GetContainerExternal()
{
return GetContainerInternal();
}
#ifdef IBMBIDI
PRBool
nsPresContext::BidiEnabled() const
nsIPresContext::BidiEnabledInternal() const
{
PRBool bidiEnabled = PR_FALSE;
NS_ASSERTION(mShell, "PresShell must be set on PresContext before calling nsPresContext::GetBidiEnabled");
NS_ASSERTION(mShell, "PresShell must be set on PresContext before calling nsIPresContext::GetBidiEnabled");
if (mShell) {
nsCOMPtr<nsIDocument> doc;
mShell->GetDocument(getter_AddRefs(doc) );
NS_ASSERTION(doc, "PresShell has no document in nsPresContext::GetBidiEnabled");
NS_ASSERTION(doc, "PresShell has no document in nsIPresContext::GetBidiEnabled");
if (doc) {
bidiEnabled = doc->GetBidiEnabled();
}
@ -1033,8 +1065,14 @@ nsPresContext::BidiEnabled() const
return bidiEnabled;
}
PRBool
nsIPresContext::BidiEnabledExternal() const
{
return BidiEnabledInternal();
}
void
nsPresContext::SetBidiEnabled(PRBool aBidiEnabled) const
nsIPresContext::SetBidiEnabled(PRBool aBidiEnabled) const
{
if (mShell) {
nsCOMPtr<nsIDocument> doc;
@ -1045,23 +1083,17 @@ nsPresContext::SetBidiEnabled(PRBool aBidiEnabled) const
}
}
NS_IMETHODIMP
nsPresContext::GetBidiUtils(nsBidiPresUtils** aBidiUtils)
nsBidiPresUtils*
nsIPresContext::GetBidiUtils()
{
nsresult rv = NS_OK;
if (!mBidiUtils) {
if (!mBidiUtils)
mBidiUtils = new nsBidiPresUtils;
if (!mBidiUtils) {
rv = NS_ERROR_OUT_OF_MEMORY;
}
}
*aBidiUtils = mBidiUtils;
return rv;
return mBidiUtils;
}
NS_IMETHODIMP
nsPresContext::SetBidi(PRUint32 aSource, PRBool aForceReflow)
void
nsIPresContext::SetBidi(PRUint32 aSource, PRBool aForceReflow)
{
mBidi = aSource;
if (IBMBIDI_TEXTDIRECTION_RTL == GET_BIDI_OPTION_DIRECTION(mBidi)
@ -1078,22 +1110,13 @@ nsPresContext::SetBidi(PRUint32 aSource, PRBool aForceReflow)
SetVisualMode(IsVisualCharset(mCharset) );
}
if (mShell && aForceReflow) {
nsPresContext::ClearStyleDataAndReflow();
ClearStyleDataAndReflow();
}
return NS_OK;
}
NS_IMETHODIMP
nsPresContext::GetBidi(PRUint32* aDest) const
{
if (aDest)
*aDest = mBidi;
return NS_OK;
}
#endif //IBMBIDI
NS_IMETHODIMP
nsPresContext::GetTheme(nsITheme** aResult)
nsITheme*
nsIPresContext::GetTheme()
{
if (!mNoTheme && !mTheme) {
mTheme = do_GetService("@mozilla.org/chrome/chrome-native-theme;1");
@ -1101,13 +1124,11 @@ nsPresContext::GetTheme(nsITheme** aResult)
mNoTheme = PR_TRUE;
}
*aResult = mTheme;
NS_IF_ADDREF(*aResult);
return mTheme ? NS_OK : NS_ERROR_FAILURE;
return mTheme;
}
NS_IMETHODIMP
nsPresContext::ThemeChanged()
void
nsIPresContext::ThemeChanged()
{
// Tell the theme that it changed, so it can flush any handles to stale theme
// data.
@ -1118,14 +1139,12 @@ nsPresContext::ThemeChanged()
if (mLookAndFeel)
mLookAndFeel->LookAndFeelChanged();
if (!mShell)
return NS_OK;
return mShell->ReconstructStyleData();
if (mShell)
mShell->ReconstructStyleData();
}
NS_IMETHODIMP
nsPresContext::SysColorChanged()
void
nsIPresContext::SysColorChanged()
{
if (mLookAndFeel) {
// Don't use the cached values for the system colors
@ -1150,26 +1169,79 @@ nsPresContext::SysColorChanged()
// data without reflowing/updating views will lead to incorrect change hints
// later, because when generating change hints, any style structs which have
// been cleared and not reread are assumed to not be used at all.
nsPresContext::ClearStyleDataAndReflow();
ClearStyleDataAndReflow();
}
void
nsIPresContext::GetPageDim(nsRect* aActualRect, nsRect* aAdjRect)
{
if (mMedium == nsLayoutAtoms::print) {
if (aActualRect) {
PRInt32 width, height;
nsresult rv = mDeviceContext->GetDeviceSurfaceDimensions(width, height);
if (NS_SUCCEEDED(rv))
aActualRect->SetRect(0, 0, width, height);
}
if (aAdjRect)
*aAdjRect = mPageDim;
} else {
if (aActualRect)
aActualRect->SetRect(0, 0, 0, 0);
if (aAdjRect)
aAdjRect->SetRect(0, 0, 0, 0);
}
}
void
nsIPresContext::SetPageDim(const nsRect& aPageDim)
{
if (mMedium == nsLayoutAtoms::print)
mPageDim = aPageDim;
}
void
nsIPresContext::SetPaginatedScrolling(PRBool aPaginated)
{
if (mType == eContext_PrintPreview)
mCanPaginatedScroll = aPaginated;
}
void
nsIPresContext::SetPrintSettings(nsIPrintSettings *aPrintSettings)
{
if (mMedium == nsLayoutAtoms::print)
mPrintSettings = aPrintSettings;
}
nsresult
NS_NewPresContext(nsIPresContext::nsPresContextType aType,
nsIPresContext** aInstancePtrResult)
{
nsIPresContext *context = new nsIPresContext(aType);
if (!context)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*aInstancePtrResult = context);
return NS_OK;
}
#ifdef MOZ_REFLOW_PERF
NS_IMETHODIMP
nsPresContext::CountReflows(const char * aName, PRUint32 aType, nsIFrame * aFrame)
void
nsIPresContext::CountReflows(const char * aName,
PRUint32 aType, nsIFrame * aFrame)
{
if (mShell) {
mShell->CountReflows(aName, aType, aFrame);
}
return NS_OK;
}
NS_IMETHODIMP
nsPresContext::PaintCount(const char * aName, nsIRenderingContext* aRenderingContext, nsIFrame * aFrame, PRUint32 aColor)
void
nsIPresContext::PaintCount(const char * aName,
nsIRenderingContext* aRenderingContext,
nsIFrame * aFrame, PRUint32 aColor)
{
if (mShell) {
mShell->PaintCount(aName, aRenderingContext, this, aFrame, aColor);
}
return NS_OK;
}
#endif

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -105,14 +105,6 @@
#define NS_PRESSTATE_CID \
{ 0xa1fde861, 0xe802, 0x11d4, { 0x98, 0x85, 0x0, 0xc0, 0x4f, 0xa0, 0xcf, 0x4b } }
// {A1FDE85E-E802-11d4-9885-00C04FA0CF4B}
#define NS_GALLEYCONTEXT_CID \
{ 0xa1fde85e, 0xe802, 0x11d4, { 0x98, 0x85, 0x0, 0xc0, 0x4f, 0xa0, 0xcf, 0x4b } }
// {A1FDE85F-E802-11d4-9885-00C04FA0CF4B}
#define NS_PRINTCONTEXT_CID \
{ 0xa1fde85f, 0xe802, 0x11d4, { 0x98, 0x85, 0x0, 0xc0, 0x4f, 0xa0, 0xcf, 0x4b } }
// {95F46161-D177-11d2-BF86-00105A1B0627}
#define NS_HTML_CSS_STYLESHEET_CID \
{ 0x95f46161, 0xd177, 0x11d2, { 0xbf, 0x86, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } }
@ -157,10 +149,6 @@
{/* {a6cf90e5-15b3-11d2-932e-00805f8add32}*/ \
0xa6cf90e5, 0x15b3, 0x11d2, {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } }
/* a6cf90f7-15b3-11d2-932e-00805f8add32 */
#define NS_PRINT_PREVIEW_CONTEXT_CID \
{ 0xa6cf90f7, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
// {64F300A1-C88C-11d3-97FB-00400553EEF0}
#define NS_XBLSERVICE_CID \
{ 0x64f300a1, 0xc88c, 0x11d3, { 0x97, 0xfb, 0x0, 0x40, 0x5, 0x53, 0xee, 0xf0 } }

Просмотреть файл

@ -121,9 +121,7 @@
#include "nsTextTransformer.h"
#include "nsIFrameTraversal.h"
#include "nsISelectionImageService.h"
#include "nsIPrintContext.h"
#include "nsIAutoCopy.h"
#include "nsIPrintPreviewContext.h"
#include "nsCSSLoader.h"
#include "nsXULAtoms.h"
#include "nsLayoutCID.h"
@ -500,9 +498,6 @@ MAKE_CTOR(CreateNewFrameTraversal, nsIFrameTraversal, NS_CreateFrameTr
MAKE_CTOR(CreateNewLayoutHistoryState, nsILayoutHistoryState, NS_NewLayoutHistoryState)
MAKE_CTOR(CreateNewPresShell, nsIPresShell, NS_NewPresShell)
MAKE_CTOR(CreateNewPresState, nsIPresState, NS_NewPresState)
MAKE_CTOR(CreateNewGalleyContext, nsIPresContext, NS_NewGalleyContext)
MAKE_CTOR(CreateNewPrintContext, nsIPrintContext, NS_NewPrintContext)
MAKE_CTOR(CreateNewPrintPreviewContext, nsIPrintPreviewContext, NS_NewPrintPreviewContext)
#ifdef MOZ_XUL
MAKE_CTOR(CreateNewBoxObject, nsIBoxObject, NS_NewBoxObject)
MAKE_CTOR(CreateNewListBoxObject, nsIBoxObject, NS_NewListBoxObject)
@ -831,20 +826,6 @@ static const nsModuleComponentInfo gComponents[] = {
nsnull,
CreateNewPresState },
{ "Galley context",
NS_GALLEYCONTEXT_CID,
nsnull,
CreateNewGalleyContext },
{ "Print context",
NS_PRINTCONTEXT_CID,
nsnull,
CreateNewPrintContext },
{ "Print Preview context",
NS_PRINT_PREVIEW_CONTEXT_CID,
nsnull,
CreateNewPrintPreviewContext },
// XXX end ick
#ifdef MOZ_XUL

Просмотреть файл

@ -181,16 +181,16 @@ nsGfxCheckboxControlFrame::PaintCheckBox(nsIPresContext* aPresContext,
{
const nsStyleDisplay* disp = GetStyleDisplay();
if (disp->mAppearance) {
nsCOMPtr<nsITheme> theme;
aPresContext->GetTheme(getter_AddRefs(theme));
nsITheme *theme = aPresContext->GetTheme();
if (theme && theme->ThemeSupportsWidget(aPresContext, this, disp->mAppearance))
return; // No need to paint the checkbox. The theme will do it.
}
aRenderingContext.PushState();
// Get current checked state through content model.
if (!GetCheckboxState())
return; // we're not checked, nothing to paint.
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
aRenderingContext.PushState();
nsMargin borderPadding(0,0,0,0);
CalcBorderPadding(borderPadding);
@ -201,11 +201,10 @@ nsGfxCheckboxControlFrame::PaintCheckBox(nsIPresContext* aPresContext,
const nsStyleColor* color = GetStyleColor();
aRenderingContext.SetColor(color->mColor);
// Get current checked state through content model.
if ( GetCheckboxState() ) {
nsFormControlHelper::PaintCheckMark(aRenderingContext, p2t, checkRect);
}
nsFormControlHelper::PaintCheckMark(aRenderingContext,
aPresContext->ScaledPixelsToTwips(),
checkRect);
aRenderingContext.PopState();
}

Просмотреть файл

@ -171,8 +171,7 @@ nsGfxRadioControlFrame::PaintRadioButton(nsIPresContext* aPresContext,
{
const nsStyleDisplay* disp = GetStyleDisplay();
if (disp->mAppearance) {
nsCOMPtr<nsITheme> theme;
aPresContext->GetTheme(getter_AddRefs(theme));
nsITheme *theme = aPresContext->GetTheme();
if (theme && theme->ThemeSupportsWidget(aPresContext, this, disp->mAppearance))
return; // No need to paint the radio button. The theme will do it.
}

Просмотреть файл

@ -550,8 +550,7 @@ nsListControlFrame::Paint(nsIPresContext* aPresContext,
if (aWhichLayer == NS_FRAME_PAINT_LAYER_BACKGROUND) {
const nsStyleDisplay* displayData = GetStyleDisplay();
if (displayData->mAppearance) {
nsCOMPtr<nsITheme> theme;
aPresContext->GetTheme(getter_AddRefs(theme));
nsITheme *theme = aPresContext->GetTheme();
nsRect rect(0, 0, mRect.width, mRect.height);
if (theme && theme->ThemeSupportsWidget(aPresContext, this, displayData->mAppearance))
theme->DrawWidgetBackground(&aRenderingContext, this,
@ -687,9 +686,7 @@ void nsListControlFrame::PaintFocus(nsIRenderingContext& aRC, nsFramePaintLayer
nsILookAndFeel::eColor_WidgetSelectForeground :
nsILookAndFeel::eColor_WidgetSelectBackground, color);
float p2t;
mPresContext->GetScaledPixelsToTwips(&p2t);
nscoord onePixelInTwips = NSToCoordRound(p2t);
nscoord onePixelInTwips = mPresContext->IntScaledPixelsToTwips(1);
nsRect dirty;
nscolor colors[] = {color, color, color, color};

Просмотреть файл

@ -695,8 +695,7 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext,
#ifdef IBMBIDI
if (! mLines.empty()) {
if (aPresContext->BidiEnabled()) {
nsBidiPresUtils* bidiUtils;
aPresContext->GetBidiUtils(&bidiUtils);
nsBidiPresUtils* bidiUtils = aPresContext->GetBidiUtils();
if (bidiUtils) {
PRBool forceReflow;
nsresult rc = bidiUtils->Resolve(aPresContext, this,
@ -3946,8 +3945,7 @@ nsBlockFrame::PlaceLine(nsBlockReflowState& aState,
else {
if (aState.mPresContext->BidiEnabled()) {
if (!aState.mPresContext->IsVisualMode()) {
nsBidiPresUtils* bidiUtils;
aState.mPresContext->GetBidiUtils(&bidiUtils);
nsBidiPresUtils* bidiUtils = aState.mPresContext->GetBidiUtils();
if (bidiUtils && bidiUtils->IsSuccessful() ) {
nsIFrame* nextInFlow = (aLine.next() != end_lines())
@ -4959,10 +4957,7 @@ nsBlockFrame::ReflowFloat(nsBlockReflowState& aState,
// needed when prev. float has procentage width
// (maybe is a table flaw that makes table chose to round up
// but i don't want to change that, too risky)
nscoord twp;
float p2t;
aState.mPresContext->GetScaledPixelsToTwips(&p2t);
twp = NSIntPixelsToTwips(1,p2t);
nscoord twp = aState.mPresContext->IntScaledPixelsToTwips(1);
availWidth -= availWidth % twp;
}
}

Просмотреть файл

@ -336,7 +336,7 @@ nsBulletFrame::Paint(nsIPresContext* aPresContext,
case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_AM:
case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_TI_ER:
case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_TI_ET:
aPresContext->GetMetricsFor(myFont->mFont, getter_AddRefs(fm));
fm = aPresContext->GetMetricsFor(myFont->mFont);
#ifdef IBMBIDI
// If we can't render our numeral using the chars in the numbering
// system, we'll be using "decimal"...
@ -355,13 +355,12 @@ nsBulletFrame::Paint(nsIPresContext* aPresContext,
}
#ifdef IBMBIDI
if (charType != eCharType_LeftToRight) {
aPresContext->GetMetricsFor(myFont->mFont, getter_AddRefs(fm));
fm = aPresContext->GetMetricsFor(myFont->mFont);
aRenderingContext.SetFont(fm);
nscoord ascent;
fm->GetMaxAscent(ascent);
nsBidiPresUtils* bidiUtils;
aPresContext->GetBidiUtils(&bidiUtils);
nsBidiPresUtils* bidiUtils = aPresContext->GetBidiUtils();
if (bidiUtils) {
const PRUnichar* buffer = text.get();
PRInt32 textLength = text.Length();
@ -1467,8 +1466,7 @@ nsBulletFrame::GetDesiredSize(nsIPresContext* aCX,
}
const nsStyleFont* myFont = GetStyleFont();
nsCOMPtr<nsIFontMetrics> fm;
aCX->GetMetricsFor(myFont->mFont, getter_AddRefs(fm));
nsCOMPtr<nsIFontMetrics> fm = aCX->GetMetricsFor(myFont->mFont);
nscoord bulletSize;
float p2t;
float t2p;

Просмотреть файл

@ -5343,8 +5343,7 @@ static void DisplayReflowEnterPrint(nsIPresContext* aPresContext,
else
printf("cnt=%d \n", DR_state->mCount);
if (DR_state->mDisplayPixelErrors) {
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
float p2t = aPresContext->ScaledPixelsToTwips();
CheckPixelError(aReflowState.availableWidth, p2t);
CheckPixelError(aReflowState.availableHeight, p2t);
CheckPixelError(aReflowState.mComputedWidth, p2t);
@ -5422,8 +5421,7 @@ void nsFrame::DisplayReflowExit(nsIPresContext* aPresContext,
}
printf("\n");
if (DR_state->mDisplayPixelErrors) {
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
float p2t = aPresContext->ScaledPixelsToTwips();
CheckPixelError(aMetrics.width, p2t);
CheckPixelError(aMetrics.height, p2t);
if (aMetrics.mComputeMEW)

Просмотреть файл

@ -75,8 +75,6 @@
#include "nsXPIDLString.h"
#include "nsIScrollable.h"
#include "nsINameSpaceManager.h"
#include "nsIPrintContext.h"
#include "nsIPrintPreviewContext.h"
#include "nsIWidget.h"
#include "nsIWebBrowserPrint.h"
#include "nsWeakReference.h"
@ -261,25 +259,19 @@ nsSubDocumentFrame::Init(nsIPresContext* aPresContext,
}
// determine if we are a printcontext
PRBool shouldCreateDoc = PR_TRUE;
nsCOMPtr<nsIPrintContext> thePrinterContext(do_QueryInterface(aPresContext));
PRBool shouldCreateDoc;
if (aPresContext->Medium() == nsLayoutAtoms::print) {
if (aPresContext->Type() == nsIPresContext::eContext_PrintPreview) {
// for print preview we want to create the view and widget but
// we do not want to load the document, it is already loaded.
rv = CreateViewAndWidget(eContentTypeContent);
NS_ENSURE_SUCCESS(rv,rv);
}
if (thePrinterContext) {
// we are printing
shouldCreateDoc = PR_FALSE;
}
// for print preview we want to create the view and widget but
// we do not want to load the document, it is alerady loaded.
nsCOMPtr<nsIPrintPreviewContext> thePrintPreviewContext =
do_QueryInterface(aPresContext);
if (thePrintPreviewContext) {
rv = CreateViewAndWidget(eContentTypeContent);
NS_ENSURE_SUCCESS(rv,rv);
// we are in PrintPreview
shouldCreateDoc = PR_FALSE;
} else {
shouldCreateDoc = PR_TRUE;
}
if (shouldCreateDoc) {
@ -306,7 +298,7 @@ nsSubDocumentFrame::GetDesiredSize(nsIPresContext* aPresContext,
if (!mContent->IsContentOfType(nsIContent::eXUL))
// If no width/height was specified, use 300/150.
// This is for compatability with IE.
aPresContext->GetScaledPixelsToTwips(&p2t);
p2t = aPresContext->ScaledPixelsToTwips();
if (NS_UNCONSTRAINEDSIZE != aReflowState.mComputedWidth) {
aDesiredSize.width = aReflowState.mComputedWidth;

Просмотреть файл

@ -525,8 +525,7 @@ void nsHTMLFramesetFrame::CalculateRowCol(nsIPresContext* aPresContext,
PRInt32 numRelative = 0;
PRInt32* relative= new PRInt32[aNumSpecs];
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
float p2t = aPresContext->ScaledPixelsToTwips();
PRInt32 i, j;
// initialize the fixed, percent, relative indices, allocate the fixed sizes and zero the others
@ -637,8 +636,7 @@ PRInt32 nsHTMLFramesetFrame::GetBorderWidth(nsIPresContext* aPresContext,
return 0;
}
}
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
float p2t = aPresContext->ScaledPixelsToTwips();
nsHTMLValue htmlVal;
nsCOMPtr<nsIHTMLContent> content(do_QueryInterface(mContent));

Просмотреть файл

@ -66,7 +66,6 @@
#include "nsITextControlFrame.h"
#include "nsIDOMHTMLTextAreaElement.h"
#include "nsNodeInfoManager.h"
#include "nsIPrintPreviewContext.h"
#include "nsIURI.h"
#include "nsGUIEvent.h"
#include "nsContentCreatorFunctions.h"
@ -1934,13 +1933,10 @@ nsGfxScrollFrameInner::Layout(nsBoxLayoutState& aState)
GetScrolledSize(aState.PresContext(),&scrolledContentSize.width, &scrolledContentSize.height);
nsIPresContext* presContext = aState.PresContext();
float p2t;
presContext->GetScaledPixelsToTwips(&p2t);
mOnePixel = NSIntPixelsToTwips(1, p2t);
mOnePixel = presContext->IntScaledPixelsToTwips(1);
const nsStyleFont* font = mOuter->GetStyleFont();
const nsFont& f = font->mFont;
nsCOMPtr<nsIFontMetrics> fm;
presContext->GetMetricsFor(f, getter_AddRefs(fm));
nsCOMPtr<nsIFontMetrics> fm = presContext->GetMetricsFor(f);
nscoord fontHeight = 1;
NS_ASSERTION(fm,"FontMetrics is null assuming fontHeight == 1");
if (fm)

Просмотреть файл

@ -2500,8 +2500,7 @@ nsHTMLReflowState::IsBidiFormControl(nsIPresContext* aPresContext)
return PR_FALSE;
}
PRUint32 options;
aPresContext->GetBidi(&options);
PRUint32 options = aPresContext->GetBidi();
if (IBMBIDI_CONTROLSTEXTMODE_LOGICAL != GET_BIDI_OPTION_CONTROLSTEXTMODE(options)) {
return PR_FALSE;
}

Просмотреть файл

@ -747,12 +747,9 @@ nsImageFrame::GetDesiredSize(nsIPresContext* aPresContext,
// a * (b / c) because of its reduced accuracy relative to a * b / c
// or (a * b) / c (which are equivalent).
float t2p, sp2t;
t2p = aPresContext->TwipsToPixels();
aPresContext->GetScaledPixelsToTwips(&sp2t);
// convert from normal twips to scaled twips (printing...)
float t2st = t2p * sp2t; // twips to scaled twips
float t2st = aPresContext->TwipsToPixels() *
aPresContext->ScaledPixelsToTwips(); // twips to scaled twips
nscoord intrinsicWidth =
NSToCoordRound(float(mIntrinsicSize.width) * t2st);
nscoord intrinsicHeight =
@ -990,10 +987,8 @@ nsImageFrame::Reflow(nsIPresContext* aPresContext,
aMetrics.height > aReflowState.availableHeight) {
// split an image frame but not an image control frame
if (nsLayoutAtoms::imageFrame == GetType()) {
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
// our desired height was greater than 0, so to avoid infinite splitting, use 1 pixel as the min
aMetrics.height = PR_MAX(NSToCoordRound(p2t), aReflowState.availableHeight);
aMetrics.height = PR_MAX(NSToCoordRound(aPresContext->ScaledPixelsToTwips()), aReflowState.availableHeight);
aStatus = NS_FRAME_NOT_COMPLETE;
}
}
@ -1164,9 +1159,8 @@ nsImageFrame::DisplayAltFeedback(nsIPresContext* aPresContext,
GetInnerArea(aPresContext, inner);
// Display a recessed one pixel border
float p2t;
nscoord borderEdgeWidth;
aPresContext->GetScaledPixelsToTwips(&p2t);
float p2t = aPresContext->ScaledPixelsToTwips();
borderEdgeWidth = NSIntPixelsToTwips(ALT_BORDER_WIDTH, p2t);
// if inner area is empty, then make it big enough for at least the icon
@ -1987,8 +1981,7 @@ void nsImageFrame::InvalidateIcon()
// invalidate the inner area, where the icon lives
nsIPresContext *presContext = GetPresContext();
float p2t;
presContext->GetScaledPixelsToTwips(&p2t);
float p2t = presContext->ScaledPixelsToTwips();
nsRect inner;
GetInnerArea(presContext, inner);

Просмотреть файл

@ -95,8 +95,6 @@
#include "nsIDocumentEncoder.h"
#include "nsXPIDLString.h"
#include "nsIDOMRange.h"
#include "nsIPrintContext.h"
#include "nsIPrintPreviewContext.h"
#include "nsIPluginWidget.h"
#include "nsGUIEvent.h"
#include "nsIRenderingContext.h"
@ -879,8 +877,7 @@ nsObjectFrame::GetDesiredSize(nsIPresContext* aPresContext,
// for EMBED and APPLET, default to 240x200 for compatibility
nsIAtom *atom = mContent->Tag();
if (atom == nsHTMLAtoms::applet || atom == nsHTMLAtoms::embed) {
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
float p2t = aPresContext->ScaledPixelsToTwips();
if (aMetrics.width == NS_UNCONSTRAINEDSIZE) {
aMetrics.width = PR_MIN(PR_MAX(NSIntPixelsToTwips(EMBED_DEF_WIDTH, p2t),
aReflowState.mComputedMinWidth),
@ -982,9 +979,7 @@ nsObjectFrame::Reflow(nsIPresContext* aPresContext,
}
// if we are printing or print previewing, bail for now
nsCOMPtr<nsIPrintContext> thePrinterContext = do_QueryInterface(aPresContext);
nsCOMPtr<nsIPrintPreviewContext> thePrintPreviewContext = do_QueryInterface(aPresContext);
if (thePrinterContext || thePrintPreviewContext) {
if (aPresContext->Medium() == nsLayoutAtoms::print) {
aStatus = NS_FRAME_COMPLETE;
return rv;
}
@ -1515,14 +1510,12 @@ nsObjectFrame::Paint(nsIPresContext* aPresContext,
}
// If we are painting in Print Preview do nothing....
nsCOMPtr<nsIPrintPreviewContext> thePrintPreviewContext = do_QueryInterface(aPresContext);
if (thePrintPreviewContext) {
if (aPresContext->Type() == nsIPresContext::eContext_PrintPreview) {
return NS_OK;
}
// determine if we are printing
nsCOMPtr<nsIPrintContext> thePrinterContext = do_QueryInterface(aPresContext);
if (thePrinterContext) {
if (aPresContext->Type() == nsIPresContext::eContext_Print) {
// UNIX Plugins can't PP at this time, so draw an empty box
// we only want to print on the content layer pass
if (eFramePaintLayer_Content != aWhichLayer)
@ -3914,7 +3907,6 @@ NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void)
nsIView *view;
nsresult rv = NS_ERROR_FAILURE;
float p2t;
if (mOwner)
{
@ -3929,7 +3921,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void)
mInstance->GetValue(nsPluginInstanceVariable_WindowlessBool, (void *)&windowless);
// always create widgets in Twips, not pixels
mContext->GetScaledPixelsToTwips(&p2t);
float p2t = mContext->ScaledPixelsToTwips();
rv = mOwner->CreateWidget(mContext,
NSIntPixelsToTwips(mPluginWindow->width, p2t),
NSIntPixelsToTwips(mPluginWindow->height, p2t),

Просмотреть файл

@ -44,7 +44,6 @@
#include "nsIPresShell.h"
#include "nsIDeviceContext.h"
#include "nsReadableUtils.h"
#include "nsIPrintPreviewContext.h"
#include "nsSimplePageSequence.h"
#include "nsIView.h"

Просмотреть файл

@ -46,8 +46,6 @@
#include "nsCSSFrameConstructor.h"
#include "nsIDeviceContext.h"
#include "nsReadableUtils.h"
#include "nsIPrintPreviewContext.h"
#include "nsIPrintContext.h"
#include "nsPageContentFrame.h"
#include "nsTextFrame.h" // for function BinarySearchForPosition
@ -127,8 +125,8 @@ nsPageFrame::SetInitialChildList(nsIPresContext* aPresContext,
{
nsIView* view = aChildList->GetView();
if (view && mDoCreateWidget) {
nsCOMPtr<nsIPrintPreviewContext> ppContext = do_QueryInterface(aPresContext);
if (ppContext && view->GetNearestWidget(nsnull)) {
if (aPresContext->Type() == nsIPresContext::eContext_PrintPreview &&
view->GetNearestWidget(nsnull)) {
view->CreateWidget(kCChildCID);
}
}
@ -187,9 +185,7 @@ NS_IMETHODIMP nsPageFrame::Reflow(nsIPresContext* aPresContext,
nsSize maxSize(mPD->mReflowRect.width - mPD->mReflowMargin.right - mPD->mReflowMargin.left,
avHeight);
// Get the number of Twips per pixel from the PresContext
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
nscoord onePixelInTwips = NSToCoordRound(p2t);
nscoord onePixelInTwips = aPresContext->IntScaledPixelsToTwips(1);
NS_ASSERTION(maxSize.width >= onePixelInTwips, "maxSize.width must be >= 1 pixel");
NS_ASSERTION(maxSize.height >= onePixelInTwips, "maxSize.height must be >= 1 pixel");
// insurance against infinite reflow, when reflowing less than a pixel
@ -536,8 +532,7 @@ nsPageFrame::DrawHeaderFooter(nsIPresContext* aPresContext,
nsresult rv = NS_ERROR_FAILURE;
if (aPresContext->BidiEnabled()) {
nsBidiPresUtils* bidiUtils;
aPresContext->GetBidiUtils(&bidiUtils);
nsBidiPresUtils* bidiUtils = aPresContext->GetBidiUtils();
if (bidiUtils) {
PRUnichar* buffer = str.BeginWriting();
@ -598,8 +593,7 @@ nsPageFrame::Paint(nsIPresContext* aPresContext,
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) {
nsCOMPtr<nsIPrintPreviewContext> ppContext = do_QueryInterface(aPresContext);
if (ppContext) {
if (aPresContext->Type() == nsIPresContext::eContext_PrintPreview) {
// fill page with White
aRenderingContext.SetColor(NS_RGB(255,255,255));
rect.x = 0;
@ -648,9 +642,8 @@ nsPageFrame::Paint(nsIPresContext* aPresContext,
if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer && !mSupressHF) {
// For PrintPreview the
if (!mPD->mPrintSettings) {
nsCOMPtr<nsIPrintPreviewContext> ppContext = do_QueryInterface(aPresContext);
if (ppContext) {
ppContext->GetPrintSettings(getter_AddRefs(mPD->mPrintSettings));
if (aPresContext->Type() == nsIPresContext::eContext_PrintPreview) {
mPD->mPrintSettings = aPresContext->GetPrintSettings();
}
}
NS_ASSERTION(mPD->mPrintSettings, "Must have a good PrintSettings here!");
@ -776,9 +769,7 @@ nsPageBreakFrame::GetDesiredSize(nsIPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize)
{
NS_PRECONDITION(aPresContext, "null pres context");
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
nscoord onePixel = NSToCoordRound(p2t);
nscoord onePixel = aPresContext->IntScaledPixelsToTwips(1);
aDesiredSize.width = onePixel;
if (mHaveReflowed) {

Просмотреть файл

@ -46,8 +46,6 @@
#include "nsIFontMetrics.h"
#include "nsIPrintSettings.h"
#include "nsPageFrame.h"
#include "nsIPrintPreviewContext.h"
#include "nsIPrintContext.h"
#include "nsStyleConsts.h"
#include "nsRegion.h"
#include "nsLayoutAtoms.h"
@ -253,23 +251,16 @@ nsSimplePageSequenceFrame::Reflow(nsIPresContext* aPresContext,
// Turn on the scaling of twips so any of the scrollbars
// in the UI no longer get scaled
nsCOMPtr<nsIPrintPreviewContext> printPreviewContext(do_QueryInterface(aPresContext));
if (printPreviewContext) {
printPreviewContext->SetScalingOfTwips(PR_TRUE);
PRBool isPrintPreview =
aPresContext->Type() == nsIPresContext::eContext_PrintPreview;
if (isPrintPreview) {
aPresContext->SetScalingOfTwips(PR_TRUE);
}
nsCOMPtr<nsIPrintPreviewContext> ppContext = do_QueryInterface(aPresContext);
// See if we can get a Print Settings from the Context
if (!mPageData->mPrintSettings) {
if (ppContext) {
ppContext->GetPrintSettings(getter_AddRefs(mPageData->mPrintSettings));
} else {
nsCOMPtr<nsIPrintContext> prtContext = do_QueryInterface(aPresContext);
if (prtContext) {
prtContext->GetPrintSettings(getter_AddRefs(mPageData->mPrintSettings));
}
}
if (!mPageData->mPrintSettings &&
aPresContext->Medium() == nsLayoutAtoms::print) {
mPageData->mPrintSettings = aPresContext->GetPrintSettings();
}
// now get out margins
@ -310,13 +301,11 @@ nsSimplePageSequenceFrame::Reflow(nsIPresContext* aPresContext,
nsMargin deadSpaceMargin(0,0,0,0);
nsMargin extraMargin(0,0,0,0);
nsSize shadowSize(0,0);
if (ppContext) {
if (isPrintPreview) {
if (adjSize.width == width && adjSize.height == height) {
deadSpaceMargin.SizeTo(deadSpaceGap, deadSpaceGap, deadSpaceGap, deadSpaceGap);
extraMargin.SizeTo(extraGap, extraGap, extraGap, extraGap);
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
nscoord fourPixels = NSIntPixelsToTwips(4, p2t);
nscoord fourPixels = aPresContext->IntScaledPixelsToTwips(4);
shadowSize.SizeTo(fourPixels, fourPixels);
}
}
@ -509,8 +498,8 @@ nsSimplePageSequenceFrame::Reflow(nsIPresContext* aPresContext,
// Turn off the scaling of twips so any of the scrollbars
// in the document get scaled
if (printPreviewContext) {
printPreviewContext->SetScalingOfTwips(PR_FALSE);
if (isPrintPreview) {
aPresContext->SetScalingOfTwips(PR_FALSE);
}
NS_FRAME_TRACE_REFLOW_OUT("nsSimplePageSequeceFrame::Reflow", aStatus);

Просмотреть файл

@ -544,7 +544,7 @@ public:
if (mSmallCaps) {
nscoord originalSize = plainFont->size;
plainFont->size = nscoord(0.8 * plainFont->size);
aPresContext->GetMetricsFor(*plainFont, &mSmallFont);
mSmallFont = aPresContext->GetMetricsFor(*plainFont).get(); // addrefs
// Reset to the size value saved earlier.
plainFont->size = originalSize;
}
@ -2267,8 +2267,7 @@ nsTextFrame::PaintUnicodeText(nsIPresContext* aPresContext,
// base direction
aRenderingContext.SetRightToLeftText(PR_TRUE);
}
nsBidiPresUtils* bidiUtils;
aPresContext->GetBidiUtils(&bidiUtils);
nsBidiPresUtils* bidiUtils = aPresContext->GetBidiUtils();
if (bidiUtils) {
#ifdef DEBUG
PRInt32 rememberTextLength = textLength;
@ -2948,8 +2947,7 @@ nsTextFrame::PaintTextSlowly(nsIPresContext* aPresContext,
nsCharType charType = eCharType_LeftToRight;
if (aPresContext->BidiEnabled()) {
nsBidiPresUtils* bidiUtils;
aPresContext->GetBidiUtils(&bidiUtils);
nsBidiPresUtils* bidiUtils = aPresContext->GetBidiUtils();
if (bidiUtils) {
isOddLevel = NS_GET_EMBEDDING_LEVEL(this) & 1;
@ -5444,9 +5442,7 @@ nsTextFrame::Reflow(nsIPresContext* aPresContext,
// For now we add 1 pixel to the width of the invalidated rect.
// This fixes cases where the twips to pixel roundoff causes the invalidated
// rect's width to be one pixel short.
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
nscoord onePixel = NSIntPixelsToTwips(1, p2t);
nscoord onePixel = aPresContext->IntScaledPixelsToTwips(1);
maxFrameWidth = PR_MAX(maxFrameWidth, mRect.width) + onePixel;
maxFrameHeight = PR_MAX(maxFrameHeight, mRect.height);

Просмотреть файл

@ -1503,8 +1503,7 @@ nsTextTransformer::DoNumericShaping(PRUnichar* aText,
if (aTextLength <= 0)
return;
PRUint32 bidiOptions;
mPresContext->GetBidi(&bidiOptions);
PRUint32 bidiOptions = mPresContext->GetBidi();
switch (GET_BIDI_OPTION_NUMERAL(bidiOptions)) {

Просмотреть файл

@ -695,8 +695,7 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext,
#ifdef IBMBIDI
if (! mLines.empty()) {
if (aPresContext->BidiEnabled()) {
nsBidiPresUtils* bidiUtils;
aPresContext->GetBidiUtils(&bidiUtils);
nsBidiPresUtils* bidiUtils = aPresContext->GetBidiUtils();
if (bidiUtils) {
PRBool forceReflow;
nsresult rc = bidiUtils->Resolve(aPresContext, this,
@ -3946,8 +3945,7 @@ nsBlockFrame::PlaceLine(nsBlockReflowState& aState,
else {
if (aState.mPresContext->BidiEnabled()) {
if (!aState.mPresContext->IsVisualMode()) {
nsBidiPresUtils* bidiUtils;
aState.mPresContext->GetBidiUtils(&bidiUtils);
nsBidiPresUtils* bidiUtils = aState.mPresContext->GetBidiUtils();
if (bidiUtils && bidiUtils->IsSuccessful() ) {
nsIFrame* nextInFlow = (aLine.next() != end_lines())
@ -4959,10 +4957,7 @@ nsBlockFrame::ReflowFloat(nsBlockReflowState& aState,
// needed when prev. float has procentage width
// (maybe is a table flaw that makes table chose to round up
// but i don't want to change that, too risky)
nscoord twp;
float p2t;
aState.mPresContext->GetScaledPixelsToTwips(&p2t);
twp = NSIntPixelsToTwips(1,p2t);
nscoord twp = aState.mPresContext->IntScaledPixelsToTwips(1);
availWidth -= availWidth % twp;
}
}

Просмотреть файл

@ -336,7 +336,7 @@ nsBulletFrame::Paint(nsIPresContext* aPresContext,
case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_AM:
case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_TI_ER:
case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_TI_ET:
aPresContext->GetMetricsFor(myFont->mFont, getter_AddRefs(fm));
fm = aPresContext->GetMetricsFor(myFont->mFont);
#ifdef IBMBIDI
// If we can't render our numeral using the chars in the numbering
// system, we'll be using "decimal"...
@ -355,13 +355,12 @@ nsBulletFrame::Paint(nsIPresContext* aPresContext,
}
#ifdef IBMBIDI
if (charType != eCharType_LeftToRight) {
aPresContext->GetMetricsFor(myFont->mFont, getter_AddRefs(fm));
fm = aPresContext->GetMetricsFor(myFont->mFont);
aRenderingContext.SetFont(fm);
nscoord ascent;
fm->GetMaxAscent(ascent);
nsBidiPresUtils* bidiUtils;
aPresContext->GetBidiUtils(&bidiUtils);
nsBidiPresUtils* bidiUtils = aPresContext->GetBidiUtils();
if (bidiUtils) {
const PRUnichar* buffer = text.get();
PRInt32 textLength = text.Length();
@ -1467,8 +1466,7 @@ nsBulletFrame::GetDesiredSize(nsIPresContext* aCX,
}
const nsStyleFont* myFont = GetStyleFont();
nsCOMPtr<nsIFontMetrics> fm;
aCX->GetMetricsFor(myFont->mFont, getter_AddRefs(fm));
nsCOMPtr<nsIFontMetrics> fm = aCX->GetMetricsFor(myFont->mFont);
nscoord bulletSize;
float p2t;
float t2p;

Просмотреть файл

@ -5343,8 +5343,7 @@ static void DisplayReflowEnterPrint(nsIPresContext* aPresContext,
else
printf("cnt=%d \n", DR_state->mCount);
if (DR_state->mDisplayPixelErrors) {
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
float p2t = aPresContext->ScaledPixelsToTwips();
CheckPixelError(aReflowState.availableWidth, p2t);
CheckPixelError(aReflowState.availableHeight, p2t);
CheckPixelError(aReflowState.mComputedWidth, p2t);
@ -5422,8 +5421,7 @@ void nsFrame::DisplayReflowExit(nsIPresContext* aPresContext,
}
printf("\n");
if (DR_state->mDisplayPixelErrors) {
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
float p2t = aPresContext->ScaledPixelsToTwips();
CheckPixelError(aMetrics.width, p2t);
CheckPixelError(aMetrics.height, p2t);
if (aMetrics.mComputeMEW)

Просмотреть файл

@ -66,7 +66,6 @@
#include "nsITextControlFrame.h"
#include "nsIDOMHTMLTextAreaElement.h"
#include "nsNodeInfoManager.h"
#include "nsIPrintPreviewContext.h"
#include "nsIURI.h"
#include "nsGUIEvent.h"
#include "nsContentCreatorFunctions.h"
@ -1934,13 +1933,10 @@ nsGfxScrollFrameInner::Layout(nsBoxLayoutState& aState)
GetScrolledSize(aState.PresContext(),&scrolledContentSize.width, &scrolledContentSize.height);
nsIPresContext* presContext = aState.PresContext();
float p2t;
presContext->GetScaledPixelsToTwips(&p2t);
mOnePixel = NSIntPixelsToTwips(1, p2t);
mOnePixel = presContext->IntScaledPixelsToTwips(1);
const nsStyleFont* font = mOuter->GetStyleFont();
const nsFont& f = font->mFont;
nsCOMPtr<nsIFontMetrics> fm;
presContext->GetMetricsFor(f, getter_AddRefs(fm));
nsCOMPtr<nsIFontMetrics> fm = presContext->GetMetricsFor(f);
nscoord fontHeight = 1;
NS_ASSERTION(fm,"FontMetrics is null assuming fontHeight == 1");
if (fm)

Просмотреть файл

@ -2500,8 +2500,7 @@ nsHTMLReflowState::IsBidiFormControl(nsIPresContext* aPresContext)
return PR_FALSE;
}
PRUint32 options;
aPresContext->GetBidi(&options);
PRUint32 options = aPresContext->GetBidi();
if (IBMBIDI_CONTROLSTEXTMODE_LOGICAL != GET_BIDI_OPTION_CONTROLSTEXTMODE(options)) {
return PR_FALSE;
}

Просмотреть файл

@ -747,12 +747,9 @@ nsImageFrame::GetDesiredSize(nsIPresContext* aPresContext,
// a * (b / c) because of its reduced accuracy relative to a * b / c
// or (a * b) / c (which are equivalent).
float t2p, sp2t;
t2p = aPresContext->TwipsToPixels();
aPresContext->GetScaledPixelsToTwips(&sp2t);
// convert from normal twips to scaled twips (printing...)
float t2st = t2p * sp2t; // twips to scaled twips
float t2st = aPresContext->TwipsToPixels() *
aPresContext->ScaledPixelsToTwips(); // twips to scaled twips
nscoord intrinsicWidth =
NSToCoordRound(float(mIntrinsicSize.width) * t2st);
nscoord intrinsicHeight =
@ -990,10 +987,8 @@ nsImageFrame::Reflow(nsIPresContext* aPresContext,
aMetrics.height > aReflowState.availableHeight) {
// split an image frame but not an image control frame
if (nsLayoutAtoms::imageFrame == GetType()) {
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
// our desired height was greater than 0, so to avoid infinite splitting, use 1 pixel as the min
aMetrics.height = PR_MAX(NSToCoordRound(p2t), aReflowState.availableHeight);
aMetrics.height = PR_MAX(NSToCoordRound(aPresContext->ScaledPixelsToTwips()), aReflowState.availableHeight);
aStatus = NS_FRAME_NOT_COMPLETE;
}
}
@ -1164,9 +1159,8 @@ nsImageFrame::DisplayAltFeedback(nsIPresContext* aPresContext,
GetInnerArea(aPresContext, inner);
// Display a recessed one pixel border
float p2t;
nscoord borderEdgeWidth;
aPresContext->GetScaledPixelsToTwips(&p2t);
float p2t = aPresContext->ScaledPixelsToTwips();
borderEdgeWidth = NSIntPixelsToTwips(ALT_BORDER_WIDTH, p2t);
// if inner area is empty, then make it big enough for at least the icon
@ -1987,8 +1981,7 @@ void nsImageFrame::InvalidateIcon()
// invalidate the inner area, where the icon lives
nsIPresContext *presContext = GetPresContext();
float p2t;
presContext->GetScaledPixelsToTwips(&p2t);
float p2t = presContext->ScaledPixelsToTwips();
nsRect inner;
GetInnerArea(presContext, inner);

Просмотреть файл

@ -95,8 +95,6 @@
#include "nsIDocumentEncoder.h"
#include "nsXPIDLString.h"
#include "nsIDOMRange.h"
#include "nsIPrintContext.h"
#include "nsIPrintPreviewContext.h"
#include "nsIPluginWidget.h"
#include "nsGUIEvent.h"
#include "nsIRenderingContext.h"
@ -879,8 +877,7 @@ nsObjectFrame::GetDesiredSize(nsIPresContext* aPresContext,
// for EMBED and APPLET, default to 240x200 for compatibility
nsIAtom *atom = mContent->Tag();
if (atom == nsHTMLAtoms::applet || atom == nsHTMLAtoms::embed) {
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
float p2t = aPresContext->ScaledPixelsToTwips();
if (aMetrics.width == NS_UNCONSTRAINEDSIZE) {
aMetrics.width = PR_MIN(PR_MAX(NSIntPixelsToTwips(EMBED_DEF_WIDTH, p2t),
aReflowState.mComputedMinWidth),
@ -982,9 +979,7 @@ nsObjectFrame::Reflow(nsIPresContext* aPresContext,
}
// if we are printing or print previewing, bail for now
nsCOMPtr<nsIPrintContext> thePrinterContext = do_QueryInterface(aPresContext);
nsCOMPtr<nsIPrintPreviewContext> thePrintPreviewContext = do_QueryInterface(aPresContext);
if (thePrinterContext || thePrintPreviewContext) {
if (aPresContext->Medium() == nsLayoutAtoms::print) {
aStatus = NS_FRAME_COMPLETE;
return rv;
}
@ -1515,14 +1510,12 @@ nsObjectFrame::Paint(nsIPresContext* aPresContext,
}
// If we are painting in Print Preview do nothing....
nsCOMPtr<nsIPrintPreviewContext> thePrintPreviewContext = do_QueryInterface(aPresContext);
if (thePrintPreviewContext) {
if (aPresContext->Type() == nsIPresContext::eContext_PrintPreview) {
return NS_OK;
}
// determine if we are printing
nsCOMPtr<nsIPrintContext> thePrinterContext = do_QueryInterface(aPresContext);
if (thePrinterContext) {
if (aPresContext->Type() == nsIPresContext::eContext_Print) {
// UNIX Plugins can't PP at this time, so draw an empty box
// we only want to print on the content layer pass
if (eFramePaintLayer_Content != aWhichLayer)
@ -3914,7 +3907,6 @@ NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void)
nsIView *view;
nsresult rv = NS_ERROR_FAILURE;
float p2t;
if (mOwner)
{
@ -3929,7 +3921,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void)
mInstance->GetValue(nsPluginInstanceVariable_WindowlessBool, (void *)&windowless);
// always create widgets in Twips, not pixels
mContext->GetScaledPixelsToTwips(&p2t);
float p2t = mContext->ScaledPixelsToTwips();
rv = mOwner->CreateWidget(mContext,
NSIntPixelsToTwips(mPluginWindow->width, p2t),
NSIntPixelsToTwips(mPluginWindow->height, p2t),

Просмотреть файл

@ -44,7 +44,6 @@
#include "nsIPresShell.h"
#include "nsIDeviceContext.h"
#include "nsReadableUtils.h"
#include "nsIPrintPreviewContext.h"
#include "nsSimplePageSequence.h"
#include "nsIView.h"

Просмотреть файл

@ -46,8 +46,6 @@
#include "nsCSSFrameConstructor.h"
#include "nsIDeviceContext.h"
#include "nsReadableUtils.h"
#include "nsIPrintPreviewContext.h"
#include "nsIPrintContext.h"
#include "nsPageContentFrame.h"
#include "nsTextFrame.h" // for function BinarySearchForPosition
@ -127,8 +125,8 @@ nsPageFrame::SetInitialChildList(nsIPresContext* aPresContext,
{
nsIView* view = aChildList->GetView();
if (view && mDoCreateWidget) {
nsCOMPtr<nsIPrintPreviewContext> ppContext = do_QueryInterface(aPresContext);
if (ppContext && view->GetNearestWidget(nsnull)) {
if (aPresContext->Type() == nsIPresContext::eContext_PrintPreview &&
view->GetNearestWidget(nsnull)) {
view->CreateWidget(kCChildCID);
}
}
@ -187,9 +185,7 @@ NS_IMETHODIMP nsPageFrame::Reflow(nsIPresContext* aPresContext,
nsSize maxSize(mPD->mReflowRect.width - mPD->mReflowMargin.right - mPD->mReflowMargin.left,
avHeight);
// Get the number of Twips per pixel from the PresContext
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
nscoord onePixelInTwips = NSToCoordRound(p2t);
nscoord onePixelInTwips = aPresContext->IntScaledPixelsToTwips(1);
NS_ASSERTION(maxSize.width >= onePixelInTwips, "maxSize.width must be >= 1 pixel");
NS_ASSERTION(maxSize.height >= onePixelInTwips, "maxSize.height must be >= 1 pixel");
// insurance against infinite reflow, when reflowing less than a pixel
@ -536,8 +532,7 @@ nsPageFrame::DrawHeaderFooter(nsIPresContext* aPresContext,
nsresult rv = NS_ERROR_FAILURE;
if (aPresContext->BidiEnabled()) {
nsBidiPresUtils* bidiUtils;
aPresContext->GetBidiUtils(&bidiUtils);
nsBidiPresUtils* bidiUtils = aPresContext->GetBidiUtils();
if (bidiUtils) {
PRUnichar* buffer = str.BeginWriting();
@ -598,8 +593,7 @@ nsPageFrame::Paint(nsIPresContext* aPresContext,
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) {
nsCOMPtr<nsIPrintPreviewContext> ppContext = do_QueryInterface(aPresContext);
if (ppContext) {
if (aPresContext->Type() == nsIPresContext::eContext_PrintPreview) {
// fill page with White
aRenderingContext.SetColor(NS_RGB(255,255,255));
rect.x = 0;
@ -648,9 +642,8 @@ nsPageFrame::Paint(nsIPresContext* aPresContext,
if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer && !mSupressHF) {
// For PrintPreview the
if (!mPD->mPrintSettings) {
nsCOMPtr<nsIPrintPreviewContext> ppContext = do_QueryInterface(aPresContext);
if (ppContext) {
ppContext->GetPrintSettings(getter_AddRefs(mPD->mPrintSettings));
if (aPresContext->Type() == nsIPresContext::eContext_PrintPreview) {
mPD->mPrintSettings = aPresContext->GetPrintSettings();
}
}
NS_ASSERTION(mPD->mPrintSettings, "Must have a good PrintSettings here!");
@ -776,9 +769,7 @@ nsPageBreakFrame::GetDesiredSize(nsIPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize)
{
NS_PRECONDITION(aPresContext, "null pres context");
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
nscoord onePixel = NSToCoordRound(p2t);
nscoord onePixel = aPresContext->IntScaledPixelsToTwips(1);
aDesiredSize.width = onePixel;
if (mHaveReflowed) {

Просмотреть файл

@ -146,7 +146,6 @@
#include "nsIDOMWindowInternal.h"
#include "nsPIDOMWindow.h"
#include "nsIFocusController.h"
#include "nsIPrintPreviewContext.h"
// Drag & Drop, Clipboard
#include "nsWidgetsCID.h"
@ -196,7 +195,6 @@
#include "nsContentCID.h"
static NS_DEFINE_CID(kCSSStyleSheetCID, NS_CSS_STYLESHEET_CID);
static NS_DEFINE_IID(kRangeCID, NS_RANGE_CID);
static NS_DEFINE_CID(kPrintPreviewContextCID, NS_PRINT_PREVIEW_CONTEXT_CID);
// convert a color value to a string, in the CSS format #RRGGBB
// * - initially created for bugs 31816, 20760, 22963
@ -3541,8 +3539,7 @@ PresShell::GetPageSequenceFrame(nsIPageSequenceFrame** aResult) const
// if it is then get the scrolled frame
scrollable->GetScrolledFrame(nsnull, child);
} else {
nsCOMPtr<nsIPrintPreviewContext> ppContext = do_QueryInterface(mPresContext);
if (ppContext) {
if (mPresContext->Type() == nsIPresContext::eContext_PrintPreview) {
child = child->GetFirstChild(nsnull);
}
}
@ -5700,7 +5697,8 @@ PresShell::HandleEvent(nsIView *aView,
// Check for a theme change up front, since the frame type is irrelevant
if (aEvent->message == NS_THEMECHANGED && mPresContext) {
return mPresContext->ThemeChanged();
mPresContext->ThemeChanged();
return NS_OK;
}
// Check for a system color change up front, since the frame type is
@ -5717,7 +5715,8 @@ PresShell::HandleEvent(nsIView *aView,
if (view == aView) {
aHandled = PR_TRUE;
*aEventStatus = nsEventStatus_eConsumeDoDefault;
return mPresContext->SysColorChanged();
mPresContext->SysColorChanged();
return NS_OK;
}
}
return NS_OK;
@ -7027,16 +7026,12 @@ PresShell::VerifyIncrementalReflow()
nsIPresShell* sh;
// Create a presentation context to view the new frame tree
nsresult rv;
if (mPresContext->IsPaginated()) {
nsCOMPtr<nsIPrintPreviewContext> ppx = do_CreateInstance(kPrintPreviewContextCID, &rv);
if (NS_SUCCEEDED(rv)) {
ppx->QueryInterface(NS_GET_IID(nsIPresContext),(void**)&cx);
}
}
else {
rv = NS_NewGalleyContext(&cx);
}
NS_IF_ADDREF(cx = new nsIPresContext(mPresContext->IsPaginated() ?
nsIPresContext::eContext_PrintPreview :
nsIPresContext::eContext_Galley));
if (!cx)
return NS_ERROR_OUT_OF_MEMORY;
nsCOMPtr<nsISupports> container = mPresContext->GetContainer();
if (container) {
@ -7047,9 +7042,8 @@ PresShell::VerifyIncrementalReflow()
}
}
NS_ASSERTION(NS_SUCCEEDED (rv), "failed to create presentation context");
nsIDeviceContext *dc = mPresContext->DeviceContext();
rv = cx->Init(dc);
nsresult rv = cx->Init(dc);
NS_ENSURE_SUCCESS(rv, rv);
// Get our scrolling preference
@ -7548,8 +7542,7 @@ void ReflowCountMgr::PaintCount(const char * aName,
nsFont font("Times", NS_FONT_STYLE_NORMAL,NS_FONT_VARIANT_NORMAL,
NS_FONT_WEIGHT_NORMAL,0,NSIntPointsToTwips(8));
nsCOMPtr<nsIFontMetrics> fm;
aPresContext->GetMetricsFor(font, getter_AddRefs(fm));
nsCOMPtr<nsIFontMetrics> fm = aPresContext->GetMetricsFor(font);
aRenderingContext->SetFont(fm);
char buf[16];
sprintf(buf, "%d", counter->mCount);

Просмотреть файл

@ -46,8 +46,6 @@
#include "nsIFontMetrics.h"
#include "nsIPrintSettings.h"
#include "nsPageFrame.h"
#include "nsIPrintPreviewContext.h"
#include "nsIPrintContext.h"
#include "nsStyleConsts.h"
#include "nsRegion.h"
#include "nsLayoutAtoms.h"
@ -253,23 +251,16 @@ nsSimplePageSequenceFrame::Reflow(nsIPresContext* aPresContext,
// Turn on the scaling of twips so any of the scrollbars
// in the UI no longer get scaled
nsCOMPtr<nsIPrintPreviewContext> printPreviewContext(do_QueryInterface(aPresContext));
if (printPreviewContext) {
printPreviewContext->SetScalingOfTwips(PR_TRUE);
PRBool isPrintPreview =
aPresContext->Type() == nsIPresContext::eContext_PrintPreview;
if (isPrintPreview) {
aPresContext->SetScalingOfTwips(PR_TRUE);
}
nsCOMPtr<nsIPrintPreviewContext> ppContext = do_QueryInterface(aPresContext);
// See if we can get a Print Settings from the Context
if (!mPageData->mPrintSettings) {
if (ppContext) {
ppContext->GetPrintSettings(getter_AddRefs(mPageData->mPrintSettings));
} else {
nsCOMPtr<nsIPrintContext> prtContext = do_QueryInterface(aPresContext);
if (prtContext) {
prtContext->GetPrintSettings(getter_AddRefs(mPageData->mPrintSettings));
}
}
if (!mPageData->mPrintSettings &&
aPresContext->Medium() == nsLayoutAtoms::print) {
mPageData->mPrintSettings = aPresContext->GetPrintSettings();
}
// now get out margins
@ -310,13 +301,11 @@ nsSimplePageSequenceFrame::Reflow(nsIPresContext* aPresContext,
nsMargin deadSpaceMargin(0,0,0,0);
nsMargin extraMargin(0,0,0,0);
nsSize shadowSize(0,0);
if (ppContext) {
if (isPrintPreview) {
if (adjSize.width == width && adjSize.height == height) {
deadSpaceMargin.SizeTo(deadSpaceGap, deadSpaceGap, deadSpaceGap, deadSpaceGap);
extraMargin.SizeTo(extraGap, extraGap, extraGap, extraGap);
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
nscoord fourPixels = NSIntPixelsToTwips(4, p2t);
nscoord fourPixels = aPresContext->IntScaledPixelsToTwips(4);
shadowSize.SizeTo(fourPixels, fourPixels);
}
}
@ -509,8 +498,8 @@ nsSimplePageSequenceFrame::Reflow(nsIPresContext* aPresContext,
// Turn off the scaling of twips so any of the scrollbars
// in the document get scaled
if (printPreviewContext) {
printPreviewContext->SetScalingOfTwips(PR_FALSE);
if (isPrintPreview) {
aPresContext->SetScalingOfTwips(PR_FALSE);
}
NS_FRAME_TRACE_REFLOW_OUT("nsSimplePageSequeceFrame::Reflow", aStatus);

Просмотреть файл

@ -544,7 +544,7 @@ public:
if (mSmallCaps) {
nscoord originalSize = plainFont->size;
plainFont->size = nscoord(0.8 * plainFont->size);
aPresContext->GetMetricsFor(*plainFont, &mSmallFont);
mSmallFont = aPresContext->GetMetricsFor(*plainFont).get(); // addrefs
// Reset to the size value saved earlier.
plainFont->size = originalSize;
}
@ -2267,8 +2267,7 @@ nsTextFrame::PaintUnicodeText(nsIPresContext* aPresContext,
// base direction
aRenderingContext.SetRightToLeftText(PR_TRUE);
}
nsBidiPresUtils* bidiUtils;
aPresContext->GetBidiUtils(&bidiUtils);
nsBidiPresUtils* bidiUtils = aPresContext->GetBidiUtils();
if (bidiUtils) {
#ifdef DEBUG
PRInt32 rememberTextLength = textLength;
@ -2948,8 +2947,7 @@ nsTextFrame::PaintTextSlowly(nsIPresContext* aPresContext,
nsCharType charType = eCharType_LeftToRight;
if (aPresContext->BidiEnabled()) {
nsBidiPresUtils* bidiUtils;
aPresContext->GetBidiUtils(&bidiUtils);
nsBidiPresUtils* bidiUtils = aPresContext->GetBidiUtils();
if (bidiUtils) {
isOddLevel = NS_GET_EMBEDDING_LEVEL(this) & 1;
@ -5444,9 +5442,7 @@ nsTextFrame::Reflow(nsIPresContext* aPresContext,
// For now we add 1 pixel to the width of the invalidated rect.
// This fixes cases where the twips to pixel roundoff causes the invalidated
// rect's width to be one pixel short.
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
nscoord onePixel = NSIntPixelsToTwips(1, p2t);
nscoord onePixel = aPresContext->IntScaledPixelsToTwips(1);
maxFrameWidth = PR_MAX(maxFrameWidth, mRect.width) + onePixel;
maxFrameHeight = PR_MAX(maxFrameHeight, mRect.height);

Просмотреть файл

@ -1503,8 +1503,7 @@ nsTextTransformer::DoNumericShaping(PRUnichar* aText,
if (aTextLength <= 0)
return;
PRUint32 bidiOptions;
mPresContext->GetBidi(&bidiOptions);
PRUint32 bidiOptions = mPresContext->GetBidi();
switch (GET_BIDI_OPTION_NUMERAL(bidiOptions)) {

Просмотреть файл

@ -75,8 +75,6 @@
#include "nsXPIDLString.h"
#include "nsIScrollable.h"
#include "nsINameSpaceManager.h"
#include "nsIPrintContext.h"
#include "nsIPrintPreviewContext.h"
#include "nsIWidget.h"
#include "nsIWebBrowserPrint.h"
#include "nsWeakReference.h"
@ -261,25 +259,19 @@ nsSubDocumentFrame::Init(nsIPresContext* aPresContext,
}
// determine if we are a printcontext
PRBool shouldCreateDoc = PR_TRUE;
nsCOMPtr<nsIPrintContext> thePrinterContext(do_QueryInterface(aPresContext));
PRBool shouldCreateDoc;
if (aPresContext->Medium() == nsLayoutAtoms::print) {
if (aPresContext->Type() == nsIPresContext::eContext_PrintPreview) {
// for print preview we want to create the view and widget but
// we do not want to load the document, it is already loaded.
rv = CreateViewAndWidget(eContentTypeContent);
NS_ENSURE_SUCCESS(rv,rv);
}
if (thePrinterContext) {
// we are printing
shouldCreateDoc = PR_FALSE;
}
// for print preview we want to create the view and widget but
// we do not want to load the document, it is alerady loaded.
nsCOMPtr<nsIPrintPreviewContext> thePrintPreviewContext =
do_QueryInterface(aPresContext);
if (thePrintPreviewContext) {
rv = CreateViewAndWidget(eContentTypeContent);
NS_ENSURE_SUCCESS(rv,rv);
// we are in PrintPreview
shouldCreateDoc = PR_FALSE;
} else {
shouldCreateDoc = PR_TRUE;
}
if (shouldCreateDoc) {
@ -306,7 +298,7 @@ nsSubDocumentFrame::GetDesiredSize(nsIPresContext* aPresContext,
if (!mContent->IsContentOfType(nsIContent::eXUL))
// If no width/height was specified, use 300/150.
// This is for compatability with IE.
aPresContext->GetScaledPixelsToTwips(&p2t);
p2t = aPresContext->ScaledPixelsToTwips();
if (NS_UNCONSTRAINEDSIZE != aReflowState.mComputedWidth) {
aDesiredSize.width = aReflowState.mComputedWidth;

Просмотреть файл

@ -525,8 +525,7 @@ void nsHTMLFramesetFrame::CalculateRowCol(nsIPresContext* aPresContext,
PRInt32 numRelative = 0;
PRInt32* relative= new PRInt32[aNumSpecs];
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
float p2t = aPresContext->ScaledPixelsToTwips();
PRInt32 i, j;
// initialize the fixed, percent, relative indices, allocate the fixed sizes and zero the others
@ -637,8 +636,7 @@ PRInt32 nsHTMLFramesetFrame::GetBorderWidth(nsIPresContext* aPresContext,
return 0;
}
}
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
float p2t = aPresContext->ScaledPixelsToTwips();
nsHTMLValue htmlVal;
nsCOMPtr<nsIHTMLContent> content(do_QueryInterface(mContent));

Просмотреть файл

@ -181,16 +181,16 @@ nsGfxCheckboxControlFrame::PaintCheckBox(nsIPresContext* aPresContext,
{
const nsStyleDisplay* disp = GetStyleDisplay();
if (disp->mAppearance) {
nsCOMPtr<nsITheme> theme;
aPresContext->GetTheme(getter_AddRefs(theme));
nsITheme *theme = aPresContext->GetTheme();
if (theme && theme->ThemeSupportsWidget(aPresContext, this, disp->mAppearance))
return; // No need to paint the checkbox. The theme will do it.
}
aRenderingContext.PushState();
// Get current checked state through content model.
if (!GetCheckboxState())
return; // we're not checked, nothing to paint.
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
aRenderingContext.PushState();
nsMargin borderPadding(0,0,0,0);
CalcBorderPadding(borderPadding);
@ -201,11 +201,10 @@ nsGfxCheckboxControlFrame::PaintCheckBox(nsIPresContext* aPresContext,
const nsStyleColor* color = GetStyleColor();
aRenderingContext.SetColor(color->mColor);
// Get current checked state through content model.
if ( GetCheckboxState() ) {
nsFormControlHelper::PaintCheckMark(aRenderingContext, p2t, checkRect);
}
nsFormControlHelper::PaintCheckMark(aRenderingContext,
aPresContext->ScaledPixelsToTwips(),
checkRect);
aRenderingContext.PopState();
}

Просмотреть файл

@ -171,8 +171,7 @@ nsGfxRadioControlFrame::PaintRadioButton(nsIPresContext* aPresContext,
{
const nsStyleDisplay* disp = GetStyleDisplay();
if (disp->mAppearance) {
nsCOMPtr<nsITheme> theme;
aPresContext->GetTheme(getter_AddRefs(theme));
nsITheme *theme = aPresContext->GetTheme();
if (theme && theme->ThemeSupportsWidget(aPresContext, this, disp->mAppearance))
return; // No need to paint the radio button. The theme will do it.
}

Просмотреть файл

@ -550,8 +550,7 @@ nsListControlFrame::Paint(nsIPresContext* aPresContext,
if (aWhichLayer == NS_FRAME_PAINT_LAYER_BACKGROUND) {
const nsStyleDisplay* displayData = GetStyleDisplay();
if (displayData->mAppearance) {
nsCOMPtr<nsITheme> theme;
aPresContext->GetTheme(getter_AddRefs(theme));
nsITheme *theme = aPresContext->GetTheme();
nsRect rect(0, 0, mRect.width, mRect.height);
if (theme && theme->ThemeSupportsWidget(aPresContext, this, displayData->mAppearance))
theme->DrawWidgetBackground(&aRenderingContext, this,
@ -687,9 +686,7 @@ void nsListControlFrame::PaintFocus(nsIRenderingContext& aRC, nsFramePaintLayer
nsILookAndFeel::eColor_WidgetSelectForeground :
nsILookAndFeel::eColor_WidgetSelectBackground, color);
float p2t;
mPresContext->GetScaledPixelsToTwips(&p2t);
nscoord onePixelInTwips = NSToCoordRound(p2t);
nscoord onePixelInTwips = mPresContext->IntScaledPixelsToTwips(1);
nsRect dirty;
nscolor colors[] = {color, color, color, color};

Просмотреть файл

@ -103,7 +103,6 @@
#include "nsFormControlHelper.h"
#include "nsObjectFrame.h"
#include "nsRuleNode.h"
#include "nsIPrintPreviewContext.h"
#include "nsIDOMMutationEvent.h"
#include "nsChildIterator.h"
#include "nsCSSRendering.h"
@ -3709,7 +3708,8 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell,
// the entire canvas as specified by the CSS2 spec
PRBool isPaginated = aPresContext->IsPaginated();
nsCOMPtr<nsIPrintPreviewContext> printPreviewContext(do_QueryInterface(aPresContext));
PRBool isPrintPreview =
aPresContext->Type() == nsIPresContext::eContext_PrintPreview;
nsIFrame* rootFrame = nsnull;
nsIAtom* rootPseudo;
@ -3789,7 +3789,7 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell,
}
if (isPaginated) {
if (printPreviewContext) { // print preview
if (isPrintPreview) {
isScrollable = aPresContext->HasPaginatedScrolling();
} else {
isScrollable = PR_FALSE; // we are printing
@ -3814,7 +3814,7 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell,
nsIFrame* parentFrame = viewportFrame;
// If paginated, make sure we don't put scrollbars in
if (isPaginated && !printPreviewContext)
if (isPaginated && !isPrintPreview)
rootPseudoStyle = styleSet->ResolvePseudoStyleFor(nsnull,
rootPseudo,
viewportPseudoStyle);
@ -3911,7 +3911,7 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell,
rootFrame->Init(aPresContext, aDocElement, parentFrame,
rootPseudoStyle, nsnull);
if (!isPaginated || printPreviewContext) {
if (!isPaginated || isPrintPreview) {
if (isScrollable) {
FinishBuildingScrollFrame(aPresContext,
state,
@ -5809,11 +5809,13 @@ nsCSSFrameConstructor::BeginBuildingScrollFrame(nsIPresShell* aPresSh
// If the parent is a viewportFrame then we are the scrollbars for the UI
// if not then we are scrollbars inside the document.
PRBool noScalingOfTwips = PR_FALSE;
nsCOMPtr<nsIPrintPreviewContext> printPreviewContext(do_QueryInterface(aPresContext));
if (printPreviewContext) {
PRBool isPrintPreview =
aPresContext->Type() == nsIPresContext::eContext_PrintPreview;
if (isPrintPreview) {
noScalingOfTwips = aParentFrame->GetType() == nsLayoutAtoms::viewportFrame;
if (noScalingOfTwips) {
printPreviewContext->SetScalingOfTwips(PR_FALSE);
aPresContext->SetScalingOfTwips(PR_FALSE);
}
}
@ -5877,8 +5879,8 @@ nsCSSFrameConstructor::BeginBuildingScrollFrame(nsIPresShell* aPresSh
}
if (printPreviewContext && noScalingOfTwips) {
printPreviewContext->SetScalingOfTwips(PR_TRUE);
if (isPrintPreview && noScalingOfTwips) {
aPresContext->SetScalingOfTwips(PR_TRUE);
}
return aScrolledChildStyle;;
@ -5976,11 +5978,10 @@ nsCSSFrameConstructor::BuildScrollFrame(nsIPresShell* aPresShell,
// If the parent is a viewportFrame then we are the scrollbars for the UI
// if not then we are scrollbars inside the document.
PRBool noScalingOfTwips = PR_FALSE;
nsCOMPtr<nsIPrintPreviewContext> printPreviewContext(do_QueryInterface(aPresContext));
if (printPreviewContext) {
if (aPresContext->Type() == nsIPresContext::eContext_PrintPreview) {
noScalingOfTwips = aParentFrame->GetType() == nsLayoutAtoms::viewportFrame;
if (noScalingOfTwips) {
printPreviewContext->SetScalingOfTwips(PR_FALSE);
aPresContext->SetScalingOfTwips(PR_FALSE);
}
}
@ -6018,7 +6019,7 @@ nsCSSFrameConstructor::BuildScrollFrame(nsIPresShell* aPresShell,
aState.mFrameManager->SetPrimaryFrameFor( aContent, aNewFrame );
if (noScalingOfTwips) {
printPreviewContext->SetScalingOfTwips(PR_TRUE);
aPresContext->SetScalingOfTwips(PR_TRUE);
}
return NS_OK;
@ -9950,13 +9951,14 @@ nsCSSFrameConstructor::DoContentStateChanged(nsIPresContext* aPresContext,
if (primaryFrame) {
PRUint8 app = primaryFrame->GetStyleDisplay()->mAppearance;
if (app) {
nsCOMPtr<nsITheme> theme;
aPresContext->GetTheme(getter_AddRefs(theme));
PRBool repaint = PR_FALSE;
if (theme && theme->ThemeSupportsWidget(aPresContext, primaryFrame, app))
nsITheme *theme = aPresContext->GetTheme();
if (theme && theme->ThemeSupportsWidget(aPresContext, primaryFrame, app)) {
PRBool repaint = PR_FALSE;
theme->WidgetStateChanged(primaryFrame, app, nsnull, &repaint);
if (repaint)
ApplyRenderingChangeToTree(aPresContext, primaryFrame, nsnull, nsChangeHint_RepaintFrame);
if (repaint) {
ApplyRenderingChangeToTree(aPresContext, primaryFrame, nsnull, nsChangeHint_RepaintFrame);
}
}
}
}
@ -10042,8 +10044,7 @@ nsCSSFrameConstructor::AttributeChanged(nsIPresContext* aPresContext,
if (primaryFrame) {
const nsStyleDisplay* disp = primaryFrame->GetStyleDisplay();
if (disp->mAppearance) {
nsCOMPtr<nsITheme> theme;
aPresContext->GetTheme(getter_AddRefs(theme));
nsITheme *theme = aPresContext->GetTheme();
if (theme && theme->ThemeSupportsWidget(aPresContext, primaryFrame, disp->mAppearance)) {
PRBool repaint = PR_FALSE;
theme->WidgetStateChanged(primaryFrame, disp->mAppearance, aAttribute, &repaint);

Просмотреть файл

@ -58,7 +58,6 @@
#include "gfxIImageFrame.h"
#include "nsCSSRendering.h"
#include "nsCSSColorUtils.h"
#include "nsIPrintContext.h"
#include "nsITheme.h"
#include "nsThemeConstants.h"
#include "nsIServiceManager.h"
@ -1634,8 +1633,7 @@ void nsCSSRendering::PaintBorder(nsIPresContext* aPresContext,
// may be different! Always use |aStyleContext|!
const nsStyleDisplay* displayData = aStyleContext->GetStyleDisplay();
if (displayData->mAppearance) {
nsCOMPtr<nsITheme> theme;
aPresContext->GetTheme(getter_AddRefs(theme));
nsITheme *theme = aPresContext->GetTheme();
if (theme && theme->ThemeSupportsWidget(aPresContext, aForFrame, displayData->mAppearance))
return; // Let the theme handle it.
}
@ -1795,10 +1793,7 @@ void nsCSSRendering::PaintBorder(nsIPresContext* aPresContext,
}
}
/* Get our conversion values */
nscoord twipsPerPixel;
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
twipsPerPixel = NSIntPixelsToTwips(1,p2t);
nscoord twipsPerPixel = aPresContext->IntScaledPixelsToTwips(1);
static PRUint8 sideOrder[] = { NS_SIDE_BOTTOM, NS_SIDE_LEFT, NS_SIDE_TOP, NS_SIDE_RIGHT };
nscolor sideColor;
@ -2791,8 +2786,7 @@ nsCSSRendering::PaintBackgroundWithSC(nsIPresContext* aPresContext,
// renderer draw the background and bail out.
const nsStyleDisplay* displayData = aForFrame->GetStyleDisplay();
if (displayData->mAppearance) {
nsCOMPtr<nsITheme> theme;
aPresContext->GetTheme(getter_AddRefs(theme));
nsITheme *theme = aPresContext->GetTheme();
if (theme && theme->ThemeSupportsWidget(aPresContext, aForFrame, displayData->mAppearance)) {
theme->DrawWidgetBackground(&aRenderingContext, aForFrame,
displayData->mAppearance, aBorderArea, aDirtyRect);
@ -2834,14 +2828,14 @@ nsCSSRendering::PaintBackgroundWithSC(nsIPresContext* aPresContext,
// We have a background image
// Lookup the image
nsCOMPtr<imgIRequest> req;
nsresult rv = aPresContext->LoadImage(aColor.mBackgroundImage, aForFrame, getter_AddRefs(req));
imgIRequest *req = aPresContext->LoadImage(aColor.mBackgroundImage,
aForFrame);
PRUint32 status = imgIRequest::STATUS_ERROR;
if (req)
req->GetImageStatus(&status);
if (NS_FAILED(rv) || !req || !(status & imgIRequest::STATUS_FRAME_COMPLETE) || !(status & imgIRequest::STATUS_SIZE_AVAILABLE)) {
if (!req || !(status & imgIRequest::STATUS_FRAME_COMPLETE) || !(status & imgIRequest::STATUS_SIZE_AVAILABLE)) {
PaintBackgroundColor(aPresContext, aRenderingContext, aForFrame, bgClipArea,
aColor, aBorder, aPadding, canDrawBackgroundColor);
return;

Просмотреть файл

@ -217,8 +217,7 @@ BasicTableLayoutStrategy::BalanceColumnWidths(const nsHTMLReflowState& aReflowSt
#ifdef DEBUG_TABLE_REFLOW_TIMING
nsTableFrame::DebugTimeMethod(nsTableFrame::eBalanceCols, *mTableFrame, (nsHTMLReflowState&)aReflowState, PR_TRUE);
#endif
float p2t;
mTableFrame->GetPresContext()->GetScaledPixelsToTwips(&p2t);
float p2t = mTableFrame->GetPresContext()->ScaledPixelsToTwips();
ContinuingFrameCheck();
@ -1003,8 +1002,7 @@ BasicTableLayoutStrategy::AssignNonPctColumnWidths(nscoord aMax
PRInt32 colX, rowX;
mCellSpacingTotal = 0;
PRBool hasPctCol = PR_FALSE; // return value
float pixelToTwips;
mTableFrame->GetPresContext()->GetScaledPixelsToTwips(&pixelToTwips);
float pixelToTwips = mTableFrame->GetPresContext()->ScaledPixelsToTwips();
PRInt32 rawPropTotal = -1; // total of numbers of the type 1*, 2*, etc
PRInt32 numColsForColsAttr = 0; // Nav Quirks cols attribute for equal width cols
@ -1242,8 +1240,7 @@ BasicTableLayoutStrategy::CalcPctAdjTableWidth(const nsHTMLReflowState& aReflowS
PRInt32 numRows = mTableFrame->GetRowCount();
PRInt32 numCols = mTableFrame->GetColCount(); // consider cols at end without orig cells
PRInt32 colX, rowX;
float pixelToTwips;
mTableFrame->GetPresContext()->GetScaledPixelsToTwips(&pixelToTwips);
float pixelToTwips = mTableFrame->GetPresContext()->ScaledPixelsToTwips();
// For an auto table, determine the potentially new percent adjusted width based
// on percent cells/cols. This probably should only be a NavQuirks thing, since

Просмотреть файл

@ -1,300 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "FixedTableLayoutStrategy.h"
#include "nsTableFrame.h"
#include "nsTableCellFrame.h"
#include "nsStyleConsts.h"
#include "nsVoidArray.h"
FixedTableLayoutStrategy::FixedTableLayoutStrategy(nsTableFrame *aFrame)
: BasicTableLayoutStrategy(aFrame)
{
}
FixedTableLayoutStrategy::~FixedTableLayoutStrategy()
{
}
PRBool FixedTableLayoutStrategy::BalanceColumnWidths(const nsHTMLReflowState& aReflowState)
{
return PR_TRUE;
}
/*
* assign the width of all columns
* if there is a colframe with a width attribute, use it as the column width
* otherwise if there is a cell in the first row and it has a width attribute, use it
* if this cell includes a colspan, width is divided equally among spanned columns
* otherwise the cell get a proportion of the remaining space
* as determined by the table width attribute. If no table width attribute, it gets 0 width
*/
PRBool
FixedTableLayoutStrategy::AssignNonPctColumnWidths(nscoord aComputedWidth,
const nsHTMLReflowState& aReflowState)
{
// NS_ASSERTION(aComputedWidth != NS_UNCONSTRAINEDSIZE, "bad computed width");
const nsStylePosition* tablePosition = mTableFrame->GetStylePosition();
PRBool tableIsFixedWidth = eStyleUnit_Coord == tablePosition->mWidth.GetUnit() ||
eStyleUnit_Percent == tablePosition->mWidth.GetUnit();
PRInt32 numCols = mTableFrame->GetColCount();
PRInt32 colX;
float pixelToTwips;
mTableFrame->GetPresContext()->GetScaledPixelsToTwips(&pixelToTwips);
// availWidth is used as the basis for percentage width columns. It is aComputedWidth
// minus table border, padding, & cellspacing
nscoord spacingX = mTableFrame->GetCellSpacingX();
mCellSpacingTotal = spacingX;
for (colX = 0; colX < numCols; colX++){
if (mTableFrame->GetNumCellsOriginatingInCol(colX) > 0) {
mCellSpacingTotal += spacingX;
}
}
nscoord availWidth = (NS_UNCONSTRAINEDSIZE == aComputedWidth)
? NS_UNCONSTRAINEDSIZE
: aComputedWidth - aReflowState.mComputedBorderPadding.left -
aReflowState.mComputedBorderPadding.right -
mCellSpacingTotal;
PRInt32 specifiedCols = 0; // the number of columns whose width is given
nscoord totalColWidth = 0; // the sum of the widths of the columns
nscoord* colWidths = new nscoord[numCols];
if (!colWidths) return PR_FALSE;
memset(colWidths, WIDTH_NOT_SET, numCols*sizeof(nscoord));
nscoord* propInfo = new nscoord[numCols];
if (!propInfo) {
delete [] colWidths;
return PR_FALSE;
}
memset(propInfo, 0, numCols*sizeof(nscoord));
nscoord propTotal = 0;
nscoord percTotal = 0;
// for every column, determine its specified width
for (colX = 0; colX < numCols; colX++) {
// Get column information
nsTableColFrame* colFrame = mTableFrame->GetColFrame(colX);
if (!colFrame) {
NS_ASSERTION(PR_FALSE, "bad col frame");
return PR_FALSE;
}
// Get the columns's style
const nsStylePosition* colPosition = colFrame->GetStylePosition();
// get the fixed width if available
if (eStyleUnit_Coord == colPosition->mWidth.GetUnit()) {
colWidths[colX] = colPosition->mWidth.GetCoordValue();
colFrame->SetWidth(MIN_CON, colWidths[colX]);
} // get the percentage width
else if ((eStyleUnit_Percent == colPosition->mWidth.GetUnit()) &&
(aComputedWidth != NS_UNCONSTRAINEDSIZE)) {
// Only apply percentages if we're constrained.
float percent = colPosition->mWidth.GetPercentValue();
colWidths[colX] = nsTableFrame::RoundToPixel(NSToCoordRound(percent * (float)availWidth), pixelToTwips);
colFrame->SetWidth(PCT, colWidths[colX]);
percTotal+=colWidths[colX];
}
else if (eStyleUnit_Proportional == colPosition->mWidth.GetUnit() &&
colPosition->mWidth.GetIntValue() > 0) {
propInfo[colX] = colPosition->mWidth.GetIntValue();
propTotal += propInfo[colX];
}
else { // get width from the cell
nsTableCellFrame* cellFrame = mTableFrame->GetCellFrameAt(0, colX);
if (nsnull != cellFrame) {
// Get the cell's style
const nsStylePosition* cellPosition = cellFrame->GetStylePosition();
nscoord cellWidth = 0;
PRInt32 colSpan = mTableFrame->GetEffectiveColSpan(*cellFrame);
// Get fixed cell width if available
if (eStyleUnit_Coord == cellPosition->mWidth.GetUnit()) {
// need to add border and padding into fixed width
nsMargin borderPadding = nsTableFrame::GetBorderPadding(nsSize(aReflowState.mComputedWidth, 0),
pixelToTwips, cellFrame);
cellWidth = cellPosition->mWidth.GetCoordValue() + borderPadding.left + borderPadding.right;
colWidths[colX] = nsTableFrame::RoundToPixel(NSToCoordRound(((float) cellWidth) / ((float) colSpan)),
pixelToTwips);
colFrame->SetWidth(MIN_CON, colWidths[colX]);
}
else if ((eStyleUnit_Percent == cellPosition->mWidth.GetUnit()) &&
(aComputedWidth != NS_UNCONSTRAINEDSIZE)) {
float percent = cellPosition->mWidth.GetPercentValue();
// need to add border and padding into percent width
nsMargin borderPadding = nsTableFrame::GetBorderPadding(nsSize(aReflowState.mComputedWidth, 0),
pixelToTwips, cellFrame);
cellWidth = NSToCoordRound(percent * (float) availWidth) + borderPadding.left + borderPadding.right;
colWidths[colX] = nsTableFrame::RoundToPixel(NSToCoordRound(((float) cellWidth) / ((float) colSpan)),
pixelToTwips);
colFrame->SetWidth(PCT, colWidths[colX]);
percTotal += colWidths[colX];
}
}
}
if (colWidths[colX] >= 0) {
totalColWidth += colWidths[colX];
specifiedCols++;
}
}
nscoord lastColAllocated = -1;
nscoord remainingWidth = availWidth - totalColWidth;
if(availWidth == NS_UNCONSTRAINEDSIZE)
remainingWidth = 0;
if (remainingWidth >= 500000) {
// let's put a cap on the width so that it doesn't become insane.
remainingWidth = 100;
}
if (0 < remainingWidth) {
if (propTotal > 0) {
nscoord amountToAllocate = 0;
for (colX = 0; colX < numCols; colX++) {
if (propInfo[colX] > 0) {
// We're proportional
float percent = ((float)propInfo[colX])/((float)propTotal);
amountToAllocate += NSToCoordRound(percent * (float)remainingWidth);
colWidths[colX] = (amountToAllocate > 0) ?
nsTableFrame::RoundToPixel(amountToAllocate, pixelToTwips,
eRoundUpIfHalfOrMore) : 0;
totalColWidth += colWidths[colX];
amountToAllocate -= colWidths[colX];
lastColAllocated = colX;
}
}
}
else if (tableIsFixedWidth) {
if (numCols > specifiedCols) {
// allocate the extra space to the columns which have no width specified
nscoord colAlloc =
NSToCoordRound(((float)remainingWidth) /
(((float)numCols) - ((float)specifiedCols)));
nscoord amountToAllocate = 0;
for (colX = 0; colX < numCols; colX++) {
if (-1 == colWidths[colX]) {
amountToAllocate += colAlloc;
colWidths[colX] = (amountToAllocate > 0) ?
nsTableFrame::RoundToPixel(amountToAllocate,
pixelToTwips,
eRoundUpIfHalfOrMore) : 0;
totalColWidth += colWidths[colX];
amountToAllocate -= colWidths[colX];
lastColAllocated = colX;
}
}
}
else { // allocate the extra space to the columns which have width specified
float divisor = (float)totalColWidth;
nscoord amountToAllocate = 0;
for (colX = 0; colX < numCols; colX++) {
if (colWidths[colX] > 0) {
amountToAllocate += NSToCoordRound(remainingWidth * colWidths[colX] / divisor);
nscoord colAlloc = (amountToAllocate > 0) ?
nsTableFrame::RoundToPixel(amountToAllocate, pixelToTwips,
eRoundUpIfHalfOrMore) : 0;
colWidths[colX] += colAlloc;
totalColWidth += colAlloc;
amountToAllocate -= colAlloc;
lastColAllocated = colX;
}
}
}
}
}
nscoord overAllocation = ((availWidth >= 0) && (availWidth != NS_UNCONSTRAINEDSIZE))
? totalColWidth - availWidth : 0;
// set the column widths
for (colX = 0; colX < numCols; colX++) {
if (colWidths[colX] < 0)
colWidths[colX] = 0;
// if there was too much allocated due to rounding, remove it from the last col
if ((colX == lastColAllocated) && (overAllocation != 0)) {
nscoord thisRemoval = nsTableFrame::RoundToPixel(overAllocation, pixelToTwips);
colWidths[colX] -= thisRemoval;
totalColWidth -= thisRemoval;
totalColWidth -= colWidths[colX] - PR_MAX(0, colWidths[colX]);
colWidths[colX] = PR_MAX(0, colWidths[colX]);
}
}
overAllocation = ((availWidth >= 0) && (availWidth != NS_UNCONSTRAINEDSIZE))
? totalColWidth - availWidth : 0;
if(overAllocation > 0){
// reduce over specified percent col
nscoord amountToRemove = 0;
for (colX = 0; colX < numCols; colX++) {
nsTableColFrame* colFrame = mTableFrame->GetColFrame(colX);
if(( colFrame->GetWidth(PCT) > 0) && ( percTotal > 0)){
amountToRemove += NSToCoordRound(overAllocation* colWidths[colX] / (float) percTotal);
nscoord thisRemoval = (amountToRemove > 0) ?
nsTableFrame::RoundToPixel(amountToRemove, pixelToTwips,
eRoundUpIfHalfOrMore) : 0;
colWidths[colX] -= thisRemoval;
amountToRemove -= thisRemoval;
totalColWidth -= thisRemoval;
totalColWidth -= colWidths[colX] - PR_MAX(0, colWidths[colX]);
colWidths[colX] = PR_MAX(0, colWidths[colX]);
colFrame->SetWidth(PCT, colWidths[colX]);
}
}
}
for (colX = 0; colX < numCols; colX++) {
mTableFrame->SetColumnWidth(colX, colWidths[colX]);
}
// clean up
if (nsnull != colWidths) {
delete [] colWidths;
}
if (nsnull != propInfo) {
delete [] propInfo;
}
return PR_TRUE;
}

Просмотреть файл

@ -588,9 +588,9 @@ void nsTableCellFrame::VerticallyAlignChild(nsIPresContext* aPresContex
case NS_STYLE_VERTICAL_ALIGN_MIDDLE:
// Align the middle of the child frame with the middle of the content area,
kidYTop = (height - childHeight - bottomInset + topInset) / 2;
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
kidYTop = nsTableFrame::RoundToPixel(kidYTop, p2t, eAlwaysRoundDown);
kidYTop = nsTableFrame::RoundToPixel(kidYTop,
aPresContext->ScaledPixelsToTwips(),
eAlwaysRoundDown);
}
firstKid->SetPosition(nsPoint(kidRect.x, kidYTop));
nsHTMLReflowMetrics desiredSize(PR_FALSE);
@ -726,8 +726,7 @@ NS_METHOD nsTableCellFrame::Reflow(nsIPresContext* aPresContext,
#if defined DEBUG_TABLE_REFLOW_TIMING
nsTableFrame::DebugReflow(this, (nsHTMLReflowState&)aReflowState);
#endif
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
float p2t = aPresContext->ScaledPixelsToTwips();
// work around pixel rounding errors, round down to ensure we don't exceed the avail height in
nscoord availHeight = aReflowState.availableHeight;

Просмотреть файл

@ -1153,12 +1153,10 @@ return;}
return aReturn;}
#define GET_PIXELS_TO_TWIPS(presContext,var) \
float var; \
(presContext)->GetScaledPixelsToTwips(&var);
float var = (presContext)->ScaledPixelsToTwips();
#define GET_TWIPS_TO_PIXELS(presContext,var) \
float var; \
(presContext)->GetScaledPixelsToTwips(&var); \
float var = (presContext)->ScaledPixelsToTwips(); \
var = 1.0f / var;
#endif

Просмотреть файл

@ -54,7 +54,6 @@
#endif
#include "nsIServiceManager.h"
#include "nsIDOMNode.h"
#include "nsIPrintContext.h"
/* ----------- nsTableCaptionFrame ---------- */
@ -941,9 +940,9 @@ nsTableOuterFrame::BalanceLeftRightCaption(nsIPresContext* aPresContext,
else {
aCaptionWidth = (nscoord) ((capPercent / innerPercent) * aInnerWidth);
}
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
aCaptionWidth = nsTableFrame::RoundToPixel(aCaptionWidth, p2t, eAlwaysRoundDown);
aCaptionWidth = nsTableFrame::RoundToPixel(aCaptionWidth,
aPresContext->ScaledPixelsToTwips(),
eAlwaysRoundDown);
}
nsresult
@ -963,8 +962,7 @@ nsTableOuterFrame::GetCaptionOrigin(nsIPresContext* aPresContext,
}
if (!mCaptionFrame) return NS_OK;
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
float p2t = aPresContext->ScaledPixelsToTwips();
switch(aCaptionSide) {
case NS_SIDE_BOTTOM: {
@ -1075,8 +1073,7 @@ nsTableOuterFrame::GetInnerOrigin(nsIPresContext* aPresContext,
return NS_OK;
}
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
float p2t = aPresContext->ScaledPixelsToTwips();
nscoord minCapWidth = aCaptionSize.width;
if (NS_AUTOMARGIN != aCaptionMargin.left)
@ -1261,11 +1258,11 @@ nsTableOuterFrame::OuterReflowChild(nsIPresContext* aPresContext,
aMargin = aPadding = nsMargin(0,0,0,0);
// work around pixel rounding errors, round down to ensure we don't exceed the avail height in
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
nscoord availHeight = aOuterRS.availableHeight;
if (NS_UNCONSTRAINEDSIZE != availHeight) {
availHeight = nsTableFrame::RoundToPixel(availHeight, p2t, eAlwaysRoundDown);
availHeight = nsTableFrame::RoundToPixel(availHeight,
aPresContext->ScaledPixelsToTwips(),
eAlwaysRoundDown);
}
nsSize availSize(aAvailWidth, availHeight);
if (mCaptionFrame == aChildFrame) {

Просмотреть файл

@ -246,7 +246,7 @@ TableBackgroundPainter::TableBackgroundPainter(nsTableFrame* aTableFrame,
mZeroPadding.RecalcData();
mPresContext->GetScaledPixelsToTwips(&mP2t);
mP2t = mPresContext->ScaledPixelsToTwips();
mIsBorderCollapse = aTableFrame->IsBorderCollapse();
#ifdef DEBUG
mCompatMode = mPresContext->CompatibilityMode();

Просмотреть файл

@ -2078,9 +2078,7 @@ nsMathMLChar::PaintVertically(nsIPresContext* aPresContext,
nsRect clipRect;
nscoord dx, dy;
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
nscoord onePixel = NSIntPixelsToTwips(1, p2t);
nscoord onePixel = aPresContext->IntScaledPixelsToTwips(1);
// get metrics data to be re-used later
PRInt32 i;
@ -2255,9 +2253,7 @@ nsMathMLChar::PaintHorizontally(nsIPresContext* aPresContext,
nsRect clipRect;
nscoord dx, dy;
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
nscoord onePixel = NSIntPixelsToTwips(1, p2t);
nscoord onePixel = aPresContext->IntScaledPixelsToTwips(1);
// get metrics data to be re-used later
PRInt32 i;

Просмотреть файл

@ -418,9 +418,8 @@ nsMathMLFrame::CalcLength(nsIPresContext* aPresContext,
nsCSSUnit unit = aCSSValue.GetUnit();
if (eCSSUnit_Pixel == unit) {
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
return NSFloatPixelsToTwips(aCSSValue.GetFloatValue(), p2t);
return NSFloatPixelsToTwips(aCSSValue.GetFloatValue(),
aPresContext->ScaledPixelsToTwips());
}
else if (eCSSUnit_EM == unit) {
const nsStyleFont* font = aStyleContext->GetStyleFont();
@ -429,8 +428,7 @@ nsMathMLFrame::CalcLength(nsIPresContext* aPresContext,
else if (eCSSUnit_XHeight == unit) {
nscoord xHeight;
const nsStyleFont* font = aStyleContext->GetStyleFont();
nsCOMPtr<nsIFontMetrics> fm;
aPresContext->GetMetricsFor(font->mFont, getter_AddRefs(fm));
nsCOMPtr<nsIFontMetrics> fm = aPresContext->GetMetricsFor(font->mFont);
fm->GetXHeight(xHeight);
return NSToCoordRound(aCSSValue.GetFloatValue() * (float)xHeight);
}

Просмотреть файл

@ -268,8 +268,7 @@ public:
nscoord& aSubDrop)
{
const nsStyleFont* font = aChild->GetStyleFont();
nsCOMPtr<nsIFontMetrics> fm;
aPresContext->GetMetricsFor(font->mFont, getter_AddRefs(fm));
nsCOMPtr<nsIFontMetrics> fm = aPresContext->GetMetricsFor(font->mFont);
GetSubDrop(fm, aSubDrop);
}
@ -279,8 +278,7 @@ public:
nscoord& aSupDrop)
{
const nsStyleFont* font = aChild->GetStyleFont();
nsCOMPtr<nsIFontMetrics> fm;
aPresContext->GetMetricsFor(font->mFont, getter_AddRefs(fm));
nsCOMPtr<nsIFontMetrics> fm = aPresContext->GetMetricsFor(font->mFont);
GetSupDrop(fm, aSupDrop);
}

Просмотреть файл

@ -205,8 +205,8 @@ nsMathMLTokenFrame::Place(nsIPresContext* aPresContext,
PRBool aPlaceOrigin,
nsHTMLReflowMetrics& aDesiredSize)
{
nsCOMPtr<nsIFontMetrics> fm;
aPresContext->GetMetricsFor(GetStyleFont()->mFont, getter_AddRefs(fm));
nsCOMPtr<nsIFontMetrics> fm =
aPresContext->GetMetricsFor(GetStyleFont()->mFont);
nscoord ascent, descent;
fm->GetMaxAscent(ascent);
fm->GetMaxDescent(descent);

Просмотреть файл

@ -292,9 +292,7 @@ nsMathMLmfracFrame::Place(nsIPresContext* aPresContext,
//////////////////
// Get shifts
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
nscoord onePixel = NSIntPixelsToTwips(1, p2t);
nscoord onePixel = aPresContext->IntScaledPixelsToTwips(1);
aRenderingContext.SetFont(GetStyleFont()->mFont, nsnull);
nsCOMPtr<nsIFontMetrics> fm;

Просмотреть файл

@ -431,8 +431,8 @@ nsMathMLmoFrame::ProcessOperatorData(nsIPresContext* aPresContext)
// cache the default values of lspace & rspace that we get from the dictionary.
// since these values are relative to the 'em' unit, convert to twips now
nscoord em;
nsCOMPtr<nsIFontMetrics> fm;
aPresContext->GetMetricsFor(GetStyleFont()->mFont, getter_AddRefs(fm));
nsCOMPtr<nsIFontMetrics> fm =
aPresContext->GetMetricsFor(GetStyleFont()->mFont);
GetEmHeight(fm, em);
mEmbellishData.leftSpace = NSToCoordRound(lspace * em);
@ -493,9 +493,7 @@ nsMathMLmoFrame::ProcessOperatorData(nsIPresContext* aPresContext)
// little extra tuning to round lspace & rspace to at least a pixel so that
// operators don't look as if they are colliding with their operands
if (leftSpace || rightSpace) {
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
nscoord onePixel = NSIntPixelsToTwips(1, p2t);
nscoord onePixel = aPresContext->IntScaledPixelsToTwips(1);
if (leftSpace && leftSpace < onePixel)
leftSpace = onePixel;
if (rightSpace && rightSpace < onePixel)

Просмотреть файл

@ -306,9 +306,7 @@ nsMathMLmoverFrame::Place(nsIPresContext* aPresContext,
GetReflowAndBoundingMetricsFor(baseFrame, baseSize, bmBase);
GetReflowAndBoundingMetricsFor(overFrame, overSize, bmOver);
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
nscoord onePixel = NSIntPixelsToTwips(1, p2t);
nscoord onePixel = aPresContext->IntScaledPixelsToTwips(1);
////////////////////
// Place Children

Просмотреть файл

@ -284,9 +284,7 @@ nsMathMLmrootFrame::Reflow(nsIPresContext* aPresContext,
// the thickness of the overline
ruleThickness = bmSqr.ascent;
// make sure that the rule appears on on screen
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
nscoord onePixel = NSIntPixelsToTwips(1, p2t);
nscoord onePixel = aPresContext->IntScaledPixelsToTwips(1);
if (ruleThickness < onePixel) {
ruleThickness = onePixel;
}

Просмотреть файл

@ -253,9 +253,7 @@ nsMathMLmsqrtFrame::Reflow(nsIPresContext* aPresContext,
// the thickness of the overline
ruleThickness = bmSqr.ascent;
// make sure that the rule appears on the screen
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
nscoord onePixel = NSIntPixelsToTwips(1, p2t);
nscoord onePixel = aPresContext->IntScaledPixelsToTwips(1);
if (ruleThickness < onePixel) {
ruleThickness = onePixel;
}

Просмотреть файл

@ -142,9 +142,7 @@ nsMathMLmsubFrame::PlaceSubScript (nsIPresContext* aPresContext,
if (!mathMLFrame) return NS_ERROR_INVALID_ARG;
// force the scriptSpace to be atleast 1 pixel
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
aScriptSpace = PR_MAX(NSIntPixelsToTwips(1, p2t), aScriptSpace);
aScriptSpace = PR_MAX(aPresContext->IntScaledPixelsToTwips(1), aScriptSpace);
////////////////////////////////////
// Get the children's desired sizes
@ -179,10 +177,9 @@ nsMathMLmsubFrame::PlaceSubScript (nsIPresContext* aPresContext,
// get min subscript shift limit from x-height
// = h(x) - 4/5 * sigma_5, Rule 18b, App. G, TeXbook
nscoord xHeight = 0;
nsCOMPtr<nsIFontMetrics> fm;
nsCOMPtr<nsIFontMetrics> fm =
aPresContext->GetMetricsFor(baseFrame->GetStyleFont()->mFont);
aPresContext->GetMetricsFor (baseFrame->GetStyleFont()->mFont,
getter_AddRefs(fm));
fm->GetXHeight (xHeight);
nscoord minShiftFromXHeight = (nscoord)
(bmSubScript.ascent - (4.0f/5.0f) * xHeight);

Просмотреть файл

@ -158,9 +158,7 @@ nsMathMLmsubsupFrame::PlaceSubSupScript(nsIPresContext* aPresContext,
if (!mathMLFrame) return NS_ERROR_INVALID_ARG;
// force the scriptSpace to be atleast 1 pixel
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
nscoord onePixel = NSIntPixelsToTwips(1, p2t);
nscoord onePixel = aPresContext->IntScaledPixelsToTwips(1);
aScriptSpace = PR_MAX(onePixel, aScriptSpace);
////////////////////////////////////

Просмотреть файл

@ -142,9 +142,7 @@ nsMathMLmsupFrame::PlaceSuperScript(nsIPresContext* aPresContext,
if (!mathMLFrame) return NS_ERROR_INVALID_ARG;
// force the scriptSpace to be at least 1 pixel
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
nscoord onePixel = NSIntPixelsToTwips(1, p2t);
nscoord onePixel = aPresContext->IntScaledPixelsToTwips(1);
aScriptSpace = PR_MAX(onePixel, aScriptSpace);
////////////////////////////////////
@ -180,10 +178,9 @@ nsMathMLmsupFrame::PlaceSuperScript(nsIPresContext* aPresContext,
// get min supscript shift limit from x-height
// = d(x) + 1/4 * sigma_5, Rule 18c, App. G, TeXbook
nscoord xHeight = 0;
nsCOMPtr<nsIFontMetrics> fm;
nsCOMPtr<nsIFontMetrics> fm =
aPresContext->GetMetricsFor(baseFrame->GetStyleFont()->mFont);
aPresContext->GetMetricsFor (baseFrame->GetStyleFont()->mFont,
getter_AddRefs(fm));
fm->GetXHeight (xHeight);
nscoord minShiftFromXHeight = (nscoord)
(bmSupScript.descent + (1.0f/4.0f) * xHeight);

Просмотреть файл

@ -303,9 +303,7 @@ nsMathMLmunderFrame::Place(nsIPresContext* aPresContext,
GetReflowAndBoundingMetricsFor(baseFrame, baseSize, bmBase);
GetReflowAndBoundingMetricsFor(underFrame, underSize, bmUnder);
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
nscoord onePixel = NSIntPixelsToTwips(1, p2t);
nscoord onePixel = aPresContext->IntScaledPixelsToTwips(1);
////////////////////
// Place Children

Просмотреть файл

@ -346,9 +346,7 @@ nsMathMLmunderoverFrame::Place(nsIPresContext* aPresContext,
GetReflowAndBoundingMetricsFor(underFrame, underSize, bmUnder);
GetReflowAndBoundingMetricsFor(overFrame, overSize, bmOver);
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
nscoord onePixel = NSIntPixelsToTwips(1, p2t);
nscoord onePixel = aPresContext->IntScaledPixelsToTwips(1);
////////////////////
// Place Children

Просмотреть файл

@ -77,7 +77,6 @@ static const char sPrintOptionsContractID[] = "@mozilla.org/gfx/printset
#include "nsIDOMHTMLObjectElement.h"
// Print Preview
#include "nsIPrintPreviewContext.h"
#include "imgIContainer.h" // image animation mode constants
#include "nsIScrollableView.h"
#include "nsIScrollable.h"
@ -157,7 +156,6 @@ static const char kPrintingPromptService[] = "@mozilla.org/embedcomp/printingpro
#include "nsLayoutAtoms.h"
#include "nsFrameManager.h"
#include "nsIParser.h"
#include "nsIPrintContext.h"
#include "nsGUIEvent.h"
#include "nsHTMLReflowState.h"
#include "nsIDOMHTMLAnchorElement.h"
@ -173,10 +171,6 @@ static const char kPrintingPromptService[] = "@mozilla.org/embedcomp/printingpro
#include "nsPIDOMWindow.h"
#include "nsIFocusController.h"
// New PrintPreview
static NS_DEFINE_CID(kPrintPreviewContextCID, NS_PRINT_PREVIEW_CONTEXT_CID);
static NS_DEFINE_CID(kPrintContextCID, NS_PRINTCONTEXT_CID);
//-----------------------------------------------------
// PR LOGGING
#ifdef MOZ_LOGGING
@ -2567,23 +2561,11 @@ nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO, PRBool aDoCalcShrink)
// create the PresContext
PRBool containerIsSet = PR_FALSE;
nsresult rv;
if (mIsCreatingPrintPreview) {
nsCOMPtr<nsIPrintPreviewContext> printPreviewCon(do_CreateInstance(kPrintPreviewContextCID, &rv));
if (NS_FAILED(rv)) {
return rv;
}
aPO->mPresContext = do_QueryInterface(printPreviewCon);
printPreviewCon->SetPrintSettings(mPrt->mPrintSettings);
} else {
nsCOMPtr<nsIPrintContext> printcon(do_CreateInstance(kPrintContextCID, &rv));
if (NS_FAILED(rv)) {
return rv;
}
aPO->mPresContext = do_QueryInterface(printcon);
printcon->SetPrintSettings(mPrt->mPrintSettings);
}
aPO->mPresContext = new nsIPresContext(mIsCreatingPrintPreview ?
nsIPresContext::eContext_PrintPreview:
nsIPresContext::eContext_Print);
NS_ENSURE_TRUE(aPO->mPresContext, NS_ERROR_OUT_OF_MEMORY);
aPO->mPresContext->SetPrintSettings(mPrt->mPrintSettings);
// set the presentation context to the value in the print settings
PRBool printBGColors;
@ -2594,7 +2576,7 @@ nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO, PRBool aDoCalcShrink)
// init it with the DC
rv = aPO->mPresContext->Init(mPrt->mPrintDocDC);
nsresult rv = aPO->mPresContext->Init(mPrt->mPrintDocDC);
if (NS_FAILED(rv)) {
aPO->mPresContext = nsnull;
return rv;
@ -2779,7 +2761,7 @@ nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO, PRBool aDoCalcShrink)
return NS_OK;
}
aPO->mPresContext->SetPageDim(&adjRect);
aPO->mPresContext->SetPageDim(adjRect);
rv = aPO->mPresShell->InitialReflow(width, height);
if (NS_SUCCEEDED(rv)) {
// Transfer Selection Ranges to the new Print PresShell
@ -3322,9 +3304,7 @@ nsPrintEngine::DoPrint(nsPrintObject * aPO, PRBool aDoSyncPrinting, PRBool& aDon
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIPrintPreviewContext> ppContext = do_QueryInterface(poPresContext);
if (!ppContext) {
if (poPresContext->Type() != nsIPresContext::eContext_PrintPreview) {
nscoord sheight = seqFrame->GetSize().height;
nsRect r = poRootView->GetBounds();
@ -4491,9 +4471,8 @@ nsPrintEngine::FinishPrintPreview()
// Turning off the scaling of twips so any of the UI scrollbars
// will not get scaled
nsCOMPtr<nsIPrintPreviewContext> printPreviewContext(do_QueryInterface(mPresContext));
if (printPreviewContext) {
printPreviewContext->SetScalingOfTwips(PR_FALSE);
if (mPresContext->Type() == nsIPresContext::eContext_PrintPreview) {
mPresContext->SetScalingOfTwips(PR_FALSE);
mDeviceContext->SetCanonicalPixelScale(mPrtPreview->mOrigDCScale);
}
@ -4798,8 +4777,7 @@ void DumpLayoutData(char* aTitleStr,
}
#ifdef NS_PRINT_PREVIEW
nsCOMPtr<nsIPrintPreviewContext> ppContext = do_QueryInterface(aPresContext);
if (ppContext) {
if (aPresContext->Type() == nsIPresContext::eContext_PrintPreview) {
return;
}
#endif

Просмотреть файл

@ -232,9 +232,8 @@ ProcessTableRulesAttribute(nsStyleStruct* aStyleStruct,
borderData->SetBorderColor(aSide, borderColor);
}
// set the border width to be 1 pixel
float p2t;
aRuleData->mPresContext->GetScaledPixelsToTwips(&p2t);
nscoord onePixel = NSToCoordRound(p2t);
nscoord onePixel =
NSToCoordRound(aRuleData->mPresContext->ScaledPixelsToTwips());
nsStyleCoord coord(onePixel);
switch(aSide) {
case NS_SIDE_TOP:

Просмотреть файл

@ -198,9 +198,8 @@ nscoord CalcLength(const nsCSSValue& aValue,
}
nsCSSUnit unit = aValue.GetUnit();
if (unit == eCSSUnit_Pixel) {
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
return NSFloatPixelsToTwips(aValue.GetFloatValue(), p2t);
return NSFloatPixelsToTwips(aValue.GetFloatValue(),
aPresContext->ScaledPixelsToTwips());
}
// Common code for all units other than pixels:
aInherited = PR_TRUE;
@ -220,8 +219,7 @@ nscoord CalcLength(const nsCSSValue& aValue,
return NSToCoordRound((aValue.GetFloatValue() * (float)font->size) / 2.0f);
}
case eCSSUnit_XHeight: {
nsCOMPtr<nsIFontMetrics> fm;
aPresContext->GetMetricsFor(*font, getter_AddRefs(fm));
nsCOMPtr<nsIFontMetrics> fm = aPresContext->GetMetricsFor(*font);
nscoord xHeight;
fm->GetXHeight(xHeight);
return NSToCoordRound(aValue.GetFloatValue() * (float)xHeight);
@ -4340,8 +4338,7 @@ SetSVGLength(const nsCSSValue& aValue, float parentLength, float& length,
}
else {
length = (float) coord.GetCoordValue();
float twipsPerPix;
aPresContext->GetScaledPixelsToTwips(&twipsPerPix);
float twipsPerPix = aPresContext->ScaledPixelsToTwips();
if (twipsPerPix == 0.0f)
twipsPerPix = 1e-20f;
length /= twipsPerPix;

Просмотреть файл

@ -1164,8 +1164,7 @@ nsChangeHint nsStyleDisplay::CalcDifference(const nsStyleDisplay& aOther) const
nsStyleVisibility::nsStyleVisibility(nsIPresContext* aPresContext)
{
PRUint32 bidiOptions;
aPresContext->GetBidi(&bidiOptions);
PRUint32 bidiOptions = aPresContext->GetBidi();
if (GET_BIDI_OPTION_DIRECTION(bidiOptions) == IBMBIDI_TEXTDIRECTION_RTL)
mDirection = NS_STYLE_DIRECTION_RTL;
else

Просмотреть файл

@ -218,9 +218,8 @@ nsStyleUtil::CalcFontPointSize(PRInt32 aHTMLSize, PRInt32 aBasePointSize,
}
// Make special call specifically for fonts (needed PrintPreview)
float t2p;
aPresContext->GetTwipsToPixelsForFonts(&t2p);
PRInt32 fontSize = NSTwipsToIntPixels(aBasePointSize, t2p);
PRInt32 fontSize = NSTwipsToIntPixels(aBasePointSize,
aPresContext->TwipsToPixelsForFonts());
if ((fontSize >= sFontSizeTableMin) && (fontSize <= sFontSizeTableMax))
{

Просмотреть файл

@ -709,10 +709,7 @@ float nsSVGForeignObjectFrame::GetPxPerTwips()
float nsSVGForeignObjectFrame::GetTwipsPerPx()
{
float twipsPerPx=16.0f;
GetPresContext()->GetScaledPixelsToTwips(&twipsPerPx);
return twipsPerPx;
return GetPresContext()->ScaledPixelsToTwips();
}
void nsSVGForeignObjectFrame::TransformPoint(float& x, float& y)

Просмотреть файл

@ -367,9 +367,8 @@ nsSVGOuterSVGFrame::Reflow(nsIPresContext* aPresContext,
#if defined(DEBUG) && defined(SVG_DEBUG_PRINTING)
{
printf("nsSVGOuterSVGFrame(%p)::Reflow()[\n",this);
float twipsPerScPx,twipsPerPx;
aPresContext->GetScaledPixelsToTwips(&twipsPerScPx);
twipsPerPx = aPresContext->PixelsToTwips();
float twipsPerScPx = aPresContext->ScaledPixelsToTwips();
float twipsPerPx = aPresContext->PixelsToTwips();
printf("tw/sc(px)=%f tw/px=%f\n", twipsPerScPx, twipsPerPx);
printf("]\n");
}
@ -789,9 +788,8 @@ nsSVGOuterSVGFrame::Paint(nsIPresContext* aPresContext,
float sx=1.0f,sy=1.0f;
xform->TransformNoXLate(&sx,&sy);
printf("scale=(%f,%f)\n", sx, sy);
float twipsPerScPx,twipsPerPx;
aPresContext->GetScaledPixelsToTwips(&twipsPerScPx);
twipsPerPx = aPresContext->PixelsToTwips();
float twipsPerScPx = aPresContext->ScaledPixelsToTwips();
float twipsPerPx = aPresContext->PixelsToTwips();
printf("tw/sc(px)=%f tw/px=%f\n", twipsPerScPx, twipsPerPx);
int fontsc;
aPresContext->GetFontScaler(&fontsc);
@ -1042,9 +1040,7 @@ float nsSVGOuterSVGFrame::GetPxPerTwips()
float nsSVGOuterSVGFrame::GetTwipsPerPx()
{
float twipsPerPx;
GetPresContext()->GetScaledPixelsToTwips(&twipsPerPx);
return twipsPerPx;
return GetPresContext()->ScaledPixelsToTwips();
}
void nsSVGOuterSVGFrame::InitiateReflow()
@ -1177,9 +1173,7 @@ nsSVGOuterSVGFrame::SetViewportDimensions(nsISVGViewportRect* vp,
nsresult
nsSVGOuterSVGFrame::SetViewportScale(nsISVGViewportRect* vp, nsIPresContext *context)
{
float TwipsPerPx;
context->GetScaledPixelsToTwips(&TwipsPerPx);
float mmPerPx = TwipsPerPx / TWIPS_PER_POINT_FLOAT / (72.0f * 0.03937f);
float mmPerPx = context->ScaledPixelsToTwips() / TWIPS_PER_POINT_FLOAT / (72.0f * 0.03937f);
nsCOMPtr<nsIDOMSVGNumber> scaleX;
{

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше