Guarantee that the pres context's device context will be non-null by returning failure from Init() if it's null. Rename inline getter GetDeviceContext() to DeviceContext(), convert all callers to use the inline getter, and remove the virtual/refcounting getter. Bug 229371, r+sr=dbaron.

This commit is contained in:
bryner%brianryner.com 2004-02-02 22:17:21 +00:00
Родитель 020bd42dc1
Коммит 05a0e4f624
42 изменённых файлов: 544 добавлений и 750 удалений

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

@ -1697,8 +1697,7 @@ DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget,
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIDeviceContext> dx;
mPresContext->GetDeviceContext(getter_AddRefs(dx));
nsIDeviceContext *dx = mPresContext->DeviceContext();
nsRect tbounds = aBounds;
float p2t;

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

@ -726,7 +726,6 @@ nsPrintEngine::Print(nsIPrintSettings* aPrintSettings,
#endif
nsCOMPtr<nsIDeviceContextSpec> devspec;
nsCOMPtr<nsIDeviceContext> dx;
mPrt->mPrintDC = nsnull; // XXX why?
#ifdef NS_DEBUG
@ -806,9 +805,8 @@ nsPrintEngine::Print(nsIPrintSettings* aPrintSettings,
CHECK_RUNTIME_ERROR_CONDITION(nsIDebugObject::PRT_RUNTIME_NODEVSPEC, rv, NS_ERROR_FAILURE);
if (NS_SUCCEEDED(rv)) {
rv = mPresContext->GetDeviceContext(getter_AddRefs(dx));
if (NS_SUCCEEDED(rv)) {
rv = dx->GetDeviceContextFor(devspec, *getter_AddRefs(mPrt->mPrintDC));
rv = mPresContext->DeviceContext()->
GetDeviceContextFor(devspec, *getter_AddRefs(mPrt->mPrintDC));
if (NS_SUCCEEDED(rv)) {
// Get the Original PixelScale incase we need to start changing it
mPrt->mPrintDC->GetCanonicalPixelScale(mPrt->mOrigDCScale);
@ -827,7 +825,8 @@ nsPrintEngine::Print(nsIPrintSettings* aPrintSettings,
printf("CRITICAL PRINTING INFORMATION\n");
// DEVICE CONTEXT INFORMATION from PresContext
printf("DeviceContext of Presentation Context(%x)\n",dx);
nsIDeviceContext *dx = mPresContext->DeviceContext();
printf("DeviceContext of Presentation Context(%x)\n", dx);
dx->GetDevUnitsToTwips(a1);
dx->GetTwipsToDevUnits(a2);
printf(" DevToTwips = %f TwipToDev = %f\n",a1,a2);
@ -985,7 +984,6 @@ nsPrintEngine::Print(nsIPrintSettings* aPrintSettings,
}
}
}
}
} else {
mPrt->mPrintSettings->SetIsCancelled(PR_TRUE);
}

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

@ -1560,18 +1560,16 @@ nsRuleNode::SetFont(nsIPresContext* aPresContext, nsStyleContext* aContext,
case NS_STYLE_FONT_FIELD: sysID = eSystemFont_Field; break;
}
nsCOMPtr<nsIDeviceContext> dc;
aPresContext->GetDeviceContext(getter_AddRefs(dc));
if (dc) {
// GetSystemFont sets the font face but not necessarily the size
aFont->mFont.size = defaultVariableFont->size;
if (NS_FAILED(dc->GetSystemFont(sysID, &aFont->mFont))) {
if (NS_FAILED(aPresContext->DeviceContext()->GetSystemFont(sysID,
&aFont->mFont))) {
aFont->mFont.name = defaultVariableFont->name;
}
// this becomes our cascading size
aFont->mSize = aFont->mFont.size
= nsStyleFont::ZoomText(aPresContext, aFont->mFont.size);
}
aFont->mSize = aFont->mFont.size =
nsStyleFont::ZoomText(aPresContext, aFont->mFont.size);
aFont->mFont.familyNameQuirks = PR_FALSE;

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

@ -6957,16 +6957,6 @@ nsTypedSelection::GetPointFromOffset(nsIFrame *aFrame, PRInt32 aContentOffset, n
if (!presContext)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIDeviceContext> deviceContext;
rv = presContext->GetDeviceContext(getter_AddRefs(deviceContext));
if (NS_FAILED(rv))
return rv;
if (!deviceContext)
return NS_ERROR_NULL_POINTER;
//
// Now get the closest view with a widget so we can create
// a rendering context.
@ -6999,7 +6989,8 @@ nsTypedSelection::GetPointFromOffset(nsIFrame *aFrame, PRInt32 aContentOffset, n
nsCOMPtr<nsIRenderingContext> rendContext;
rv = deviceContext->CreateRenderingContext(closestView, *getter_AddRefs(rendContext));
rv = presContext->DeviceContext()->
CreateRenderingContext(closestView, *getter_AddRefs(rendContext));
if (NS_FAILED(rv))
return rv;

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

@ -1371,15 +1371,11 @@ nsEventStateManager::GenerateDragGesture(nsIPresContext* aPresContext,
// figure out the delta in twips, since that is how it is in the event.
// Do we need to do this conversion every time?
// Will the pres context really change on us or can we cache it?
nsCOMPtr<nsIDeviceContext> devContext;
aPresContext->GetDeviceContext (getter_AddRefs(devContext));
nscoord thresholdX = 0, thresholdY = 0;
if (devContext) {
float pixelsToTwips = 0.0;
devContext->GetDevUnitsToTwips(pixelsToTwips);
thresholdX = NSIntPixelsToTwips(pixelThresholdX, pixelsToTwips);
thresholdY = NSIntPixelsToTwips(pixelThresholdY, pixelsToTwips);
}
float pixelsToTwips;
aPresContext->DeviceContext()->GetDevUnitsToTwips(pixelsToTwips);
nscoord thresholdX = NSIntPixelsToTwips(pixelThresholdX, pixelsToTwips);
nscoord thresholdY = NSIntPixelsToTwips(pixelThresholdY, pixelsToTwips);
// fire drag gesture if mouse has moved enough
if (abs(aEvent->point.x - mGestureDownPoint.x) > thresholdX ||

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

@ -223,10 +223,8 @@ nsChangeHint nsStyleFont::CalcDifference(const nsStyleFont& aOther) const
inline float
TextZoomFor(nsIPresContext* aPresContext)
{
nsCOMPtr<nsIDeviceContext> dc;
aPresContext->GetDeviceContext(getter_AddRefs(dc));
float textZoom;
dc->GetTextZoom(textZoom);
aPresContext->DeviceContext()->GetTextZoom(textZoom);
return textZoom;
}

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

@ -130,7 +130,7 @@ ScreenImpl::GetHeight(PRInt32* aHeight)
NS_IMETHODIMP
ScreenImpl::GetPixelDepth(PRInt32* aPixelDepth)
{
nsCOMPtr<nsIDeviceContext> context(GetDeviceContext());
nsIDeviceContext* context = GetDeviceContext();
if (!context) {
*aPixelDepth = -1;
@ -196,7 +196,7 @@ ScreenImpl::GetAvailTop(PRInt32* aAvailTop)
return rv;
}
already_AddRefed<nsIDeviceContext>
nsIDeviceContext*
ScreenImpl::GetDeviceContext()
{
if(!mDocShell)
@ -214,7 +214,7 @@ ScreenImpl::GetDeviceContext()
nsIDeviceContext* context = nsnull;
if(presContext)
presContext->GetDeviceContext(&context);
context = presContext->DeviceContext();
return context;
}
@ -222,7 +222,7 @@ ScreenImpl::GetDeviceContext()
nsresult
ScreenImpl::GetRect(nsRect& aRect)
{
nsCOMPtr<nsIDeviceContext> context(GetDeviceContext());
nsIDeviceContext *context = GetDeviceContext();
if (!context) {
return NS_ERROR_FAILURE;
@ -247,7 +247,7 @@ ScreenImpl::GetRect(nsRect& aRect)
nsresult
ScreenImpl::GetAvailRect(nsRect& aRect)
{
nsCOMPtr<nsIDeviceContext> context(GetDeviceContext());
nsIDeviceContext *context = GetDeviceContext();
if (!context) {
return NS_ERROR_FAILURE;

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

@ -71,7 +71,7 @@ public:
protected:
already_AddRefed<nsIDeviceContext> GetDeviceContext();
nsIDeviceContext* GetDeviceContext();
nsresult GetRect(nsRect& aRect);
nsresult GetAvailRect(nsRect& aRect);

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

@ -343,17 +343,10 @@ NS_IMETHODIMP nsCaret::GetCaretCoordinates(EViewCoordinates aRelativeToType, nsI
if (NS_FAILED(err))
return err;
// ... then get a device context
nsCOMPtr<nsIDeviceContext> dx;
err = presContext->GetDeviceContext(getter_AddRefs(dx));
if (NS_FAILED(err))
return err;
if (!dx)
return NS_ERROR_UNEXPECTED;
// ... then tell it to make a rendering context
nsCOMPtr<nsIRenderingContext> rendContext;
err = dx->CreateRenderingContext(drawingView, *getter_AddRefs(rendContext));
err = presContext->DeviceContext()->
CreateRenderingContext(drawingView, *getter_AddRefs(rendContext));
if (NS_FAILED(err))
return err;
if (!rendContext)
@ -984,11 +977,10 @@ void nsCaret::GetCaretRectAndInvert()
{
mRendContext = nsnull; // free existing one if we have one
nsCOMPtr<nsIDeviceContext> dx;
if (NS_FAILED(presContext->GetDeviceContext(getter_AddRefs(dx))) || !dx)
return;
nsresult rv = presContext->DeviceContext()->
CreateRenderingContext(drawingView, *getter_AddRefs(mRendContext));
if (NS_FAILED(dx->CreateRenderingContext(drawingView, *getter_AddRefs(mRendContext))) || !mRendContext)
if (NS_FAILED(rv) || !mRendContext)
return;
}
@ -1037,11 +1029,8 @@ void nsCaret::GetCaretRectAndInvert()
if (mCaretTwipsWidth < 0) // need to re-compute the pixel width
{
float tDevUnitsToTwips = 15;
nsCOMPtr<nsIDeviceContext> dx;
presContext->GetDeviceContext(getter_AddRefs(dx));
if (dx)
dx->GetDevUnitsToTwips(tDevUnitsToTwips);
float tDevUnitsToTwips;
presContext->DeviceContext()->GetDevUnitsToTwips(tDevUnitsToTwips);
mCaretTwipsWidth = (nscoord)(tDevUnitsToTwips * (float)mCaretPixelsWidth);
}
caretRect.width = mCaretTwipsWidth;

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

@ -1697,8 +1697,7 @@ DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget,
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIDeviceContext> dx;
mPresContext->GetDeviceContext(getter_AddRefs(dx));
nsIDeviceContext *dx = mPresContext->DeviceContext();
nsRect tbounds = aBounds;
float p2t;

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

@ -608,19 +608,18 @@ nsPresContext::PreferenceChanged(const char* aPrefName)
mShell->SetPreferenceStyleRules(PR_TRUE);
}
if (mDeviceContext) {
mDeviceContext->FlushFontCache();
nsPresContext::ClearStyleDataAndReflow();
}
}
NS_IMETHODIMP
nsPresContext::Init(nsIDeviceContext* aDeviceContext)
{
NS_ASSERTION(!(mInitialized == PR_TRUE), "attempt to reinit pres context");
NS_ENSURE_ARG(aDeviceContext);
mDeviceContext = aDeviceContext;
NS_IF_ADDREF(mDeviceContext);
NS_ADDREF(mDeviceContext);
// Get the look and feel service here; default colors will be initialized
// from calling GetUserPreferences() below.
@ -743,10 +742,9 @@ nsPresContext::Observe(nsISupports* aSubject,
{
if (!nsCRT::strcmp(aTopic, "charset")) {
UpdateCharSet(NS_LossyConvertUCS2toASCII(aData).get());
if (mDeviceContext) {
mDeviceContext->FlushFontCache();
nsPresContext::ClearStyleDataAndReflow();
}
return NS_OK;
}
@ -872,13 +870,11 @@ nsPresContext::GetMetricsFor(const nsFont& aFont, nsIFontMetrics** aResult)
NS_PRECONDITION(aResult, "null out param");
nsIFontMetrics* metrics = nsnull;
if (mDeviceContext) {
nsCOMPtr<nsIAtom> langGroup;
if (mLanguage) {
mLanguage->GetLanguageGroup(getter_AddRefs(langGroup));
}
mDeviceContext->GetMetricsFor(aFont, langGroup, metrics);
}
*aResult = metrics;
return NS_OK;
}
@ -940,10 +936,8 @@ nsPresContext::GetPixelsToTwips(float* aResult) const
{
NS_PRECONDITION(aResult, "null out param");
float p2t = 1.0f;
if (mDeviceContext) {
float p2t;
mDeviceContext->GetDevUnitsToAppUnits(p2t);
}
*aResult = p2t;
return NS_OK;
}
@ -953,11 +947,7 @@ nsPresContext::GetTwipsToPixels(float* aResult) const
{
NS_PRECONDITION(aResult, "null out param");
float app2dev = 1.0f;
if (mDeviceContext) {
mDeviceContext->GetAppUnitsToDevUnits(app2dev);
}
*aResult = app2dev;
mDeviceContext->GetAppUnitsToDevUnits(*aResult);
return NS_OK;
}
@ -969,8 +959,7 @@ nsPresContext::GetTwipsToPixelsForFonts(float* aResult) const
return NS_ERROR_NULL_POINTER;
}
float app2dev = 1.0f;
if (mDeviceContext) {
float app2dev;
#ifdef NS_PRINT_PREVIEW
// If an alternative DC is available we want to use
// it to get the scaling factor for fonts. Usually, the AltDC
@ -986,7 +975,6 @@ nsPresContext::GetTwipsToPixelsForFonts(float* aResult) const
#else
mDeviceContext->GetAppUnitsToDevUnits(app2dev);
#endif
}
*aResult = app2dev;
return NS_OK;
}
@ -998,24 +986,14 @@ nsPresContext::GetScaledPixelsToTwips(float* aResult) const
{
NS_PRECONDITION(aResult, "null out param");
float scale = 1.0f;
if (mDeviceContext)
{
float scale;
float p2t;
mDeviceContext->GetDevUnitsToAppUnits(p2t);
mDeviceContext->GetCanonicalPixelScale(scale);
scale = p2t * scale;
}
*aResult = scale;
return NS_OK;
}
NS_IMETHODIMP
nsPresContext::GetDeviceContext(nsIDeviceContext** aResult) const
{
NS_PRECONDITION(aResult, "null out param");
*aResult = mDeviceContext;
NS_IF_ADDREF(*aResult);
*aResult = scale;
return NS_OK;
}

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

@ -325,8 +325,7 @@ public:
*/
NS_IMETHOD GetScaledPixelsToTwips(float* aScale) const = 0;
NS_IMETHOD GetDeviceContext(nsIDeviceContext** aResult) const = 0;
nsIDeviceContext* GetDeviceContext() { return mDeviceContext; }
nsIDeviceContext* DeviceContext() { return mDeviceContext; }
NS_IMETHOD GetEventStateManager(nsIEventStateManager** aManager) = 0;
nsIEventStateManager* GetEventStateManager();

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

@ -3909,17 +3909,13 @@ PresShell::CreateRenderingContext(nsIFrame *aFrame,
view->GetViewManager()->GetWidgetForView(view, getter_AddRefs(widget));
}
nsCOMPtr<nsIDeviceContext> dx;
nsIRenderingContext* result = nsnull;
rv = mPresContext->GetDeviceContext(getter_AddRefs(dx));
if (NS_SUCCEEDED(rv) && dx) {
if (nsnull != widget) {
rv = dx->CreateRenderingContext(widget.get(), result);
nsIDeviceContext *deviceContext = mPresContext->DeviceContext();
if (widget) {
rv = deviceContext->CreateRenderingContext(widget.get(), result);
}
else {
rv = dx->CreateRenderingContext(result);
}
rv = deviceContext->CreateRenderingContext(result);
}
*aResult = result;
@ -7032,8 +7028,7 @@ PresShell::VerifyIncrementalReflow()
}
NS_ASSERTION(NS_SUCCEEDED (rv), "failed to create presentation context");
nsCOMPtr<nsIDeviceContext> dc;
mPresContext->GetDeviceContext(getter_AddRefs(dc));
nsIDeviceContext *dc = mPresContext->DeviceContext();
rv = cx->Init(dc);
NS_ENSURE_SUCCESS(rv, rv);

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

@ -325,8 +325,7 @@ public:
*/
NS_IMETHOD GetScaledPixelsToTwips(float* aScale) const = 0;
NS_IMETHOD GetDeviceContext(nsIDeviceContext** aResult) const = 0;
nsIDeviceContext* GetDeviceContext() { return mDeviceContext; }
nsIDeviceContext* DeviceContext() { return mDeviceContext; }
NS_IMETHOD GetEventStateManager(nsIEventStateManager** aManager) = 0;
nsIEventStateManager* GetEventStateManager();

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

@ -325,8 +325,7 @@ public:
*/
NS_IMETHOD GetScaledPixelsToTwips(float* aScale) const = 0;
NS_IMETHOD GetDeviceContext(nsIDeviceContext** aResult) const = 0;
nsIDeviceContext* GetDeviceContext() { return mDeviceContext; }
nsIDeviceContext* DeviceContext() { return mDeviceContext; }
NS_IMETHOD GetEventStateManager(nsIEventStateManager** aManager) = 0;
nsIEventStateManager* GetEventStateManager();

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

@ -343,17 +343,10 @@ NS_IMETHODIMP nsCaret::GetCaretCoordinates(EViewCoordinates aRelativeToType, nsI
if (NS_FAILED(err))
return err;
// ... then get a device context
nsCOMPtr<nsIDeviceContext> dx;
err = presContext->GetDeviceContext(getter_AddRefs(dx));
if (NS_FAILED(err))
return err;
if (!dx)
return NS_ERROR_UNEXPECTED;
// ... then tell it to make a rendering context
nsCOMPtr<nsIRenderingContext> rendContext;
err = dx->CreateRenderingContext(drawingView, *getter_AddRefs(rendContext));
err = presContext->DeviceContext()->
CreateRenderingContext(drawingView, *getter_AddRefs(rendContext));
if (NS_FAILED(err))
return err;
if (!rendContext)
@ -984,11 +977,10 @@ void nsCaret::GetCaretRectAndInvert()
{
mRendContext = nsnull; // free existing one if we have one
nsCOMPtr<nsIDeviceContext> dx;
if (NS_FAILED(presContext->GetDeviceContext(getter_AddRefs(dx))) || !dx)
return;
nsresult rv = presContext->DeviceContext()->
CreateRenderingContext(drawingView, *getter_AddRefs(mRendContext));
if (NS_FAILED(dx->CreateRenderingContext(drawingView, *getter_AddRefs(mRendContext))) || !mRendContext)
if (NS_FAILED(rv) || !mRendContext)
return;
}
@ -1037,11 +1029,8 @@ void nsCaret::GetCaretRectAndInvert()
if (mCaretTwipsWidth < 0) // need to re-compute the pixel width
{
float tDevUnitsToTwips = 15;
nsCOMPtr<nsIDeviceContext> dx;
presContext->GetDeviceContext(getter_AddRefs(dx));
if (dx)
dx->GetDevUnitsToTwips(tDevUnitsToTwips);
float tDevUnitsToTwips;
presContext->DeviceContext()->GetDevUnitsToTwips(tDevUnitsToTwips);
mCaretTwipsWidth = (nscoord)(tDevUnitsToTwips * (float)mCaretPixelsWidth);
}
caretRect.width = mCaretTwipsWidth;

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

@ -608,19 +608,18 @@ nsPresContext::PreferenceChanged(const char* aPrefName)
mShell->SetPreferenceStyleRules(PR_TRUE);
}
if (mDeviceContext) {
mDeviceContext->FlushFontCache();
nsPresContext::ClearStyleDataAndReflow();
}
}
NS_IMETHODIMP
nsPresContext::Init(nsIDeviceContext* aDeviceContext)
{
NS_ASSERTION(!(mInitialized == PR_TRUE), "attempt to reinit pres context");
NS_ENSURE_ARG(aDeviceContext);
mDeviceContext = aDeviceContext;
NS_IF_ADDREF(mDeviceContext);
NS_ADDREF(mDeviceContext);
// Get the look and feel service here; default colors will be initialized
// from calling GetUserPreferences() below.
@ -743,10 +742,9 @@ nsPresContext::Observe(nsISupports* aSubject,
{
if (!nsCRT::strcmp(aTopic, "charset")) {
UpdateCharSet(NS_LossyConvertUCS2toASCII(aData).get());
if (mDeviceContext) {
mDeviceContext->FlushFontCache();
nsPresContext::ClearStyleDataAndReflow();
}
return NS_OK;
}
@ -872,13 +870,11 @@ nsPresContext::GetMetricsFor(const nsFont& aFont, nsIFontMetrics** aResult)
NS_PRECONDITION(aResult, "null out param");
nsIFontMetrics* metrics = nsnull;
if (mDeviceContext) {
nsCOMPtr<nsIAtom> langGroup;
if (mLanguage) {
mLanguage->GetLanguageGroup(getter_AddRefs(langGroup));
}
mDeviceContext->GetMetricsFor(aFont, langGroup, metrics);
}
*aResult = metrics;
return NS_OK;
}
@ -940,10 +936,8 @@ nsPresContext::GetPixelsToTwips(float* aResult) const
{
NS_PRECONDITION(aResult, "null out param");
float p2t = 1.0f;
if (mDeviceContext) {
float p2t;
mDeviceContext->GetDevUnitsToAppUnits(p2t);
}
*aResult = p2t;
return NS_OK;
}
@ -953,11 +947,7 @@ nsPresContext::GetTwipsToPixels(float* aResult) const
{
NS_PRECONDITION(aResult, "null out param");
float app2dev = 1.0f;
if (mDeviceContext) {
mDeviceContext->GetAppUnitsToDevUnits(app2dev);
}
*aResult = app2dev;
mDeviceContext->GetAppUnitsToDevUnits(*aResult);
return NS_OK;
}
@ -969,8 +959,7 @@ nsPresContext::GetTwipsToPixelsForFonts(float* aResult) const
return NS_ERROR_NULL_POINTER;
}
float app2dev = 1.0f;
if (mDeviceContext) {
float app2dev;
#ifdef NS_PRINT_PREVIEW
// If an alternative DC is available we want to use
// it to get the scaling factor for fonts. Usually, the AltDC
@ -986,7 +975,6 @@ nsPresContext::GetTwipsToPixelsForFonts(float* aResult) const
#else
mDeviceContext->GetAppUnitsToDevUnits(app2dev);
#endif
}
*aResult = app2dev;
return NS_OK;
}
@ -998,24 +986,14 @@ nsPresContext::GetScaledPixelsToTwips(float* aResult) const
{
NS_PRECONDITION(aResult, "null out param");
float scale = 1.0f;
if (mDeviceContext)
{
float scale;
float p2t;
mDeviceContext->GetDevUnitsToAppUnits(p2t);
mDeviceContext->GetCanonicalPixelScale(scale);
scale = p2t * scale;
}
*aResult = scale;
return NS_OK;
}
NS_IMETHODIMP
nsPresContext::GetDeviceContext(nsIDeviceContext** aResult) const
{
NS_PRECONDITION(aResult, "null out param");
*aResult = mDeviceContext;
NS_IF_ADDREF(*aResult);
*aResult = scale;
return NS_OK;
}

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

@ -100,7 +100,6 @@ public:
NS_IMETHOD GetTwipsToPixels(float* aResult) const;
NS_IMETHOD GetTwipsToPixelsForFonts(float* aResult) const;
NS_IMETHOD GetScaledPixelsToTwips(float* aScale) const;
NS_IMETHOD GetDeviceContext(nsIDeviceContext** aResult) const;
NS_IMETHOD GetEventStateManager(nsIEventStateManager** aManager);
nsIEventStateManager* GetEventStateManager() {
return nsIPresContext::GetEventStateManager();

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

@ -805,11 +805,8 @@ nsComboboxControlFrame::ReflowItems(nsIPresContext* aPresContext,
{
//printf("*****************\n");
const nsStyleFont* dspFont = mDisplayFrame->GetStyleFont();
nsCOMPtr<nsIDeviceContext> deviceContext;
aPresContext->GetDeviceContext(getter_AddRefs(deviceContext));
NS_ASSERTION(deviceContext, "Couldn't get the device context");
nsIFontMetrics * fontMet;
deviceContext->GetMetricsFor(dspFont->mFont, fontMet);
aPresContext->DeviceContext()->GetMetricsFor(dspFont->mFont, fontMet);
nscoord visibleHeight;
//nsCOMPtr<nsIFontMetrics> fontMet;
@ -1242,15 +1239,10 @@ nsComboboxControlFrame::Reflow(nsIPresContext* aPresContext,
// the default size of the of scrollbar
// that will be the default width of the dropdown button
// the height will be the height of the text
nscoord scrollbarWidth = 0;
nsCOMPtr<nsIDeviceContext> dx;
aPresContext->GetDeviceContext(getter_AddRefs(dx));
if (dx) {
float w, h;
// Get the width in Device pixels times p2t
dx->GetScrollBarDimensions(w, h);
scrollbarWidth = NSToCoordRound(w);
}
aPresContext->DeviceContext()->GetScrollBarDimensions(w, h);
nscoord scrollbarWidth = NSToCoordRound(w);
// set up a new reflow state for use throughout
nsHTMLReflowState firstPassState(aReflowState);

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

@ -862,14 +862,12 @@ nsFormControlFrame::SetSuggestedSize(nscoord aWidth, nscoord aHeight)
}
nsresult
nsFormControlFrame::GetScreenHeight(nsIPresContext* aPresContext, nscoord& aHeight)
nsFormControlFrame::GetScreenHeight(nsIPresContext* aPresContext,
nscoord& aHeight)
{
aHeight = 0;
nsCOMPtr<nsIDeviceContext> context;
aPresContext->GetDeviceContext( getter_AddRefs(context) );
if ( context ) {
nsRect screen;
nsIDeviceContext *context = aPresContext->DeviceContext();
PRBool dropdownCanOverlapOSBar = PR_FALSE;
nsILookAndFeel *lookAndFeel = aPresContext->LookAndFeel();
lookAndFeel->GetMetric(nsILookAndFeel::eMetric_MenusCanOverlapOSBar,
@ -883,9 +881,6 @@ nsFormControlFrame::GetScreenHeight(nsIPresContext* aPresContext, nscoord& aHeig
context->GetDevUnitsToAppUnits(devUnits);
aHeight = NSToIntRound(float(screen.height) / devUnits );
return NS_OK;
}
return NS_ERROR_FAILURE;
}
// Calculate a frame's position in screen coordinates

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

@ -146,11 +146,8 @@ nsresult nsFormControlHelper::GetFrameFontFM(nsIPresContext* aPresContext,
const nsFont * font = nsnull;
// Get frame font
if (NS_SUCCEEDED(aFrame->GetFont(aPresContext, font))) {
nsCOMPtr<nsIDeviceContext> deviceContext;
aPresContext->GetDeviceContext(getter_AddRefs(deviceContext));
NS_ASSERTION(deviceContext, "Couldn't get the device context");
if (font != nsnull) { // Get font metrics
return deviceContext->GetMetricsFor(*font, *aFontMet);
if (font) { // Get font metrics
return aPresContext->DeviceContext()->GetMetricsFor(*font, *aFontMet);
}
}
return NS_ERROR_FAILURE;

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

@ -1184,11 +1184,9 @@ nsListControlFrame::Reflow(nsIPresContext* aPresContext,
nsStyleContext* optStyle = optFrame->GetStyleContext();
if (optStyle) {
const nsStyleFont* styleFont = optStyle->GetStyleFont();
nsCOMPtr<nsIDeviceContext> deviceContext;
aPresContext->GetDeviceContext(getter_AddRefs(deviceContext));
NS_ASSERTION(deviceContext, "Couldn't get the device context");
nsIFontMetrics * fontMet;
result = deviceContext->GetMetricsFor(styleFont->mFont, fontMet);
result = aPresContext->DeviceContext()->
GetMetricsFor(styleFont->mFont, fontMet);
if (NS_SUCCEEDED(result) && fontMet != nsnull) {
if (fontMet) {
fontMet->GetHeight(heightOfARow);

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

@ -1410,24 +1410,17 @@ nsTextControlFrame::ReflowStandard(nsIPresContext* aPresContext,
float p2t;
aPresContext->GetPixelsToTwips(&p2t);
nscoord scrollbarWidth = 0;
nscoord scrollbarHeight = 0;
nsCOMPtr<nsIDeviceContext> dx;
aPresContext->GetDeviceContext(getter_AddRefs(dx));
if (dx) {
nsIDeviceContext *dx = aPresContext->DeviceContext();
float scale;
dx->GetCanonicalPixelScale(scale);
float sbWidth;
float sbHeight;
dx->GetScrollBarDimensions(sbWidth, sbHeight);
scrollbarWidth = PRInt32(sbWidth * scale);
scrollbarHeight = PRInt32(sbHeight * scale);
} else {
NS_WARNING("Dude! No DeviceContext! Not cool!");
scrollbarWidth = nsFormControlFrame::GetScrollbarWidth(p2t);
scrollbarHeight = scrollbarWidth;
}
nscoord scrollbarWidth = PRInt32(sbWidth * scale);
nscoord scrollbarHeight = PRInt32(sbHeight * scale);
aDesiredSize.height += scrollbarHeight;
minSize.height += scrollbarHeight;

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

@ -669,11 +669,9 @@ nsPageFrame::Paint(nsIPresContext* aPresContext,
aRenderingContext.SetColor(NS_RGB(0,0,0));
// Get the FontMetrics to determine width.height of strings
nsCOMPtr<nsIDeviceContext> deviceContext;
aPresContext->GetDeviceContext(getter_AddRefs(deviceContext));
NS_ASSERTION(deviceContext, "Couldn't get the device context");
nsCOMPtr<nsIFontMetrics> fontMet;
deviceContext->GetMetricsFor(*mPD->mHeadFootFont, nsnull, *getter_AddRefs(fontMet));
aPresContext->DeviceContext()->GetMetricsFor(*mPD->mHeadFootFont, nsnull,
*getter_AddRefs(fontMet));
nscoord ascent = 0;
nscoord visibleHeight = 0;
if (fontMet) {

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

@ -6957,16 +6957,6 @@ nsTypedSelection::GetPointFromOffset(nsIFrame *aFrame, PRInt32 aContentOffset, n
if (!presContext)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIDeviceContext> deviceContext;
rv = presContext->GetDeviceContext(getter_AddRefs(deviceContext));
if (NS_FAILED(rv))
return rv;
if (!deviceContext)
return NS_ERROR_NULL_POINTER;
//
// Now get the closest view with a widget so we can create
// a rendering context.
@ -6999,7 +6989,8 @@ nsTypedSelection::GetPointFromOffset(nsIFrame *aFrame, PRInt32 aContentOffset, n
nsCOMPtr<nsIRenderingContext> rendContext;
rv = deviceContext->CreateRenderingContext(closestView, *getter_AddRefs(rendContext));
rv = presContext->DeviceContext()->
CreateRenderingContext(closestView, *getter_AddRefs(rendContext));
if (NS_FAILED(rv))
return rv;

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

@ -295,11 +295,8 @@ nsSimplePageSequenceFrame::Reflow(nsIPresContext* aPresContext,
// and if this Document is in the upper left hand corner
// we need to suppress the top margin or it will reflow too small
// Start by getting the actual printer page dimensions to see if we are not a whole page
nsCOMPtr<nsIDeviceContext> dc;
aPresContext->GetDeviceContext(getter_AddRefs(dc));
NS_ASSERTION(dc, "nsIDeviceContext can't be NULL!");
nscoord width, height;
dc->GetDeviceSurfaceDimensions(width, height);
aPresContext->DeviceContext()->GetDeviceSurfaceDimensions(width, height);
// Compute the size of each page and the x coordinate that each page will
// be placed at
@ -657,10 +654,6 @@ nsSimplePageSequenceFrame::StartPrint(nsIPresContext* aPresContext,
}
// Begin printing of the document
nsCOMPtr<nsIDeviceContext> dc;
aPresContext->GetDeviceContext(getter_AddRefs(dc));
NS_ASSERTION(dc, "nsIDeviceContext can't be NULL!");
nsresult rv = NS_OK;
#if defined(DEBUG_rods) || defined(DEBUG_dcone)
@ -699,8 +692,8 @@ nsSimplePageSequenceFrame::StartPrint(nsIPresContext* aPresContext,
if (mDoingPageRange) {
// XXX because of the hack for making the selection all print on one page
// we must make sure that the page is sized correctly before printing.
PRInt32 width,height;
dc->GetDeviceSurfaceDimensions(width,height);
PRInt32 width, height;
aPresContext->DeviceContext()->GetDeviceSurfaceDimensions(width, height);
PRInt32 pageNum = 1;
nscoord y = 0;//mMargin.top;
@ -811,8 +804,7 @@ nsSimplePageSequenceFrame::PrintNextPage(nsIPresContext* aPresContext)
mPageData->mPrintSettings->GetPrintOptions(nsIPrintSettings::kPrintOddPages, &printOddPages);
// Begin printing of the document
nsCOMPtr<nsIDeviceContext> dc;
aPresContext->GetDeviceContext(getter_AddRefs(dc));
nsIDeviceContext *dc = aPresContext->DeviceContext();
NS_ASSERTION(dc, "nsIDeviceContext can't be NULL!");
nsIViewManager* vm = aPresContext->GetViewManager();
@ -965,13 +957,9 @@ nsSimplePageSequenceFrame::DoPageEnd(nsIPresContext* aPresContext)
nsresult rv = NS_OK;
if (mPrintThisPage) {
nsCOMPtr<nsIDeviceContext> dc;
aPresContext->GetDeviceContext(getter_AddRefs(dc));
NS_ASSERTION(dc, "nsIDeviceContext can't be NULL!");
if(mSkipPageEnd){
PR_PL(("***************** End Page (DoPageEnd) *****************\n"));
nsresult rv = dc->EndPage();
nsresult rv = aPresContext->DeviceContext()->EndPage();
if (NS_FAILED(rv)) {
return rv;
}

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

@ -669,11 +669,9 @@ nsPageFrame::Paint(nsIPresContext* aPresContext,
aRenderingContext.SetColor(NS_RGB(0,0,0));
// Get the FontMetrics to determine width.height of strings
nsCOMPtr<nsIDeviceContext> deviceContext;
aPresContext->GetDeviceContext(getter_AddRefs(deviceContext));
NS_ASSERTION(deviceContext, "Couldn't get the device context");
nsCOMPtr<nsIFontMetrics> fontMet;
deviceContext->GetMetricsFor(*mPD->mHeadFootFont, nsnull, *getter_AddRefs(fontMet));
aPresContext->DeviceContext()->GetMetricsFor(*mPD->mHeadFootFont, nsnull,
*getter_AddRefs(fontMet));
nscoord ascent = 0;
nscoord visibleHeight = 0;
if (fontMet) {

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

@ -3909,17 +3909,13 @@ PresShell::CreateRenderingContext(nsIFrame *aFrame,
view->GetViewManager()->GetWidgetForView(view, getter_AddRefs(widget));
}
nsCOMPtr<nsIDeviceContext> dx;
nsIRenderingContext* result = nsnull;
rv = mPresContext->GetDeviceContext(getter_AddRefs(dx));
if (NS_SUCCEEDED(rv) && dx) {
if (nsnull != widget) {
rv = dx->CreateRenderingContext(widget.get(), result);
nsIDeviceContext *deviceContext = mPresContext->DeviceContext();
if (widget) {
rv = deviceContext->CreateRenderingContext(widget.get(), result);
}
else {
rv = dx->CreateRenderingContext(result);
}
rv = deviceContext->CreateRenderingContext(result);
}
*aResult = result;
@ -7032,8 +7028,7 @@ PresShell::VerifyIncrementalReflow()
}
NS_ASSERTION(NS_SUCCEEDED (rv), "failed to create presentation context");
nsCOMPtr<nsIDeviceContext> dc;
mPresContext->GetDeviceContext(getter_AddRefs(dc));
nsIDeviceContext *dc = mPresContext->DeviceContext();
rv = cx->Init(dc);
NS_ENSURE_SUCCESS(rv, rv);

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

@ -295,11 +295,8 @@ nsSimplePageSequenceFrame::Reflow(nsIPresContext* aPresContext,
// and if this Document is in the upper left hand corner
// we need to suppress the top margin or it will reflow too small
// Start by getting the actual printer page dimensions to see if we are not a whole page
nsCOMPtr<nsIDeviceContext> dc;
aPresContext->GetDeviceContext(getter_AddRefs(dc));
NS_ASSERTION(dc, "nsIDeviceContext can't be NULL!");
nscoord width, height;
dc->GetDeviceSurfaceDimensions(width, height);
aPresContext->DeviceContext()->GetDeviceSurfaceDimensions(width, height);
// Compute the size of each page and the x coordinate that each page will
// be placed at
@ -657,10 +654,6 @@ nsSimplePageSequenceFrame::StartPrint(nsIPresContext* aPresContext,
}
// Begin printing of the document
nsCOMPtr<nsIDeviceContext> dc;
aPresContext->GetDeviceContext(getter_AddRefs(dc));
NS_ASSERTION(dc, "nsIDeviceContext can't be NULL!");
nsresult rv = NS_OK;
#if defined(DEBUG_rods) || defined(DEBUG_dcone)
@ -699,8 +692,8 @@ nsSimplePageSequenceFrame::StartPrint(nsIPresContext* aPresContext,
if (mDoingPageRange) {
// XXX because of the hack for making the selection all print on one page
// we must make sure that the page is sized correctly before printing.
PRInt32 width,height;
dc->GetDeviceSurfaceDimensions(width,height);
PRInt32 width, height;
aPresContext->DeviceContext()->GetDeviceSurfaceDimensions(width, height);
PRInt32 pageNum = 1;
nscoord y = 0;//mMargin.top;
@ -811,8 +804,7 @@ nsSimplePageSequenceFrame::PrintNextPage(nsIPresContext* aPresContext)
mPageData->mPrintSettings->GetPrintOptions(nsIPrintSettings::kPrintOddPages, &printOddPages);
// Begin printing of the document
nsCOMPtr<nsIDeviceContext> dc;
aPresContext->GetDeviceContext(getter_AddRefs(dc));
nsIDeviceContext *dc = aPresContext->DeviceContext();
NS_ASSERTION(dc, "nsIDeviceContext can't be NULL!");
nsIViewManager* vm = aPresContext->GetViewManager();
@ -965,13 +957,9 @@ nsSimplePageSequenceFrame::DoPageEnd(nsIPresContext* aPresContext)
nsresult rv = NS_OK;
if (mPrintThisPage) {
nsCOMPtr<nsIDeviceContext> dc;
aPresContext->GetDeviceContext(getter_AddRefs(dc));
NS_ASSERTION(dc, "nsIDeviceContext can't be NULL!");
if(mSkipPageEnd){
PR_PL(("***************** End Page (DoPageEnd) *****************\n"));
nsresult rv = dc->EndPage();
nsresult rv = aPresContext->DeviceContext()->EndPage();
if (NS_FAILED(rv)) {
return rv;
}

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

@ -805,11 +805,8 @@ nsComboboxControlFrame::ReflowItems(nsIPresContext* aPresContext,
{
//printf("*****************\n");
const nsStyleFont* dspFont = mDisplayFrame->GetStyleFont();
nsCOMPtr<nsIDeviceContext> deviceContext;
aPresContext->GetDeviceContext(getter_AddRefs(deviceContext));
NS_ASSERTION(deviceContext, "Couldn't get the device context");
nsIFontMetrics * fontMet;
deviceContext->GetMetricsFor(dspFont->mFont, fontMet);
aPresContext->DeviceContext()->GetMetricsFor(dspFont->mFont, fontMet);
nscoord visibleHeight;
//nsCOMPtr<nsIFontMetrics> fontMet;
@ -1242,15 +1239,10 @@ nsComboboxControlFrame::Reflow(nsIPresContext* aPresContext,
// the default size of the of scrollbar
// that will be the default width of the dropdown button
// the height will be the height of the text
nscoord scrollbarWidth = 0;
nsCOMPtr<nsIDeviceContext> dx;
aPresContext->GetDeviceContext(getter_AddRefs(dx));
if (dx) {
float w, h;
// Get the width in Device pixels times p2t
dx->GetScrollBarDimensions(w, h);
scrollbarWidth = NSToCoordRound(w);
}
aPresContext->DeviceContext()->GetScrollBarDimensions(w, h);
nscoord scrollbarWidth = NSToCoordRound(w);
// set up a new reflow state for use throughout
nsHTMLReflowState firstPassState(aReflowState);

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

@ -862,14 +862,12 @@ nsFormControlFrame::SetSuggestedSize(nscoord aWidth, nscoord aHeight)
}
nsresult
nsFormControlFrame::GetScreenHeight(nsIPresContext* aPresContext, nscoord& aHeight)
nsFormControlFrame::GetScreenHeight(nsIPresContext* aPresContext,
nscoord& aHeight)
{
aHeight = 0;
nsCOMPtr<nsIDeviceContext> context;
aPresContext->GetDeviceContext( getter_AddRefs(context) );
if ( context ) {
nsRect screen;
nsIDeviceContext *context = aPresContext->DeviceContext();
PRBool dropdownCanOverlapOSBar = PR_FALSE;
nsILookAndFeel *lookAndFeel = aPresContext->LookAndFeel();
lookAndFeel->GetMetric(nsILookAndFeel::eMetric_MenusCanOverlapOSBar,
@ -883,9 +881,6 @@ nsFormControlFrame::GetScreenHeight(nsIPresContext* aPresContext, nscoord& aHeig
context->GetDevUnitsToAppUnits(devUnits);
aHeight = NSToIntRound(float(screen.height) / devUnits );
return NS_OK;
}
return NS_ERROR_FAILURE;
}
// Calculate a frame's position in screen coordinates

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

@ -146,11 +146,8 @@ nsresult nsFormControlHelper::GetFrameFontFM(nsIPresContext* aPresContext,
const nsFont * font = nsnull;
// Get frame font
if (NS_SUCCEEDED(aFrame->GetFont(aPresContext, font))) {
nsCOMPtr<nsIDeviceContext> deviceContext;
aPresContext->GetDeviceContext(getter_AddRefs(deviceContext));
NS_ASSERTION(deviceContext, "Couldn't get the device context");
if (font != nsnull) { // Get font metrics
return deviceContext->GetMetricsFor(*font, *aFontMet);
if (font) { // Get font metrics
return aPresContext->DeviceContext()->GetMetricsFor(*font, *aFontMet);
}
}
return NS_ERROR_FAILURE;

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

@ -1184,11 +1184,9 @@ nsListControlFrame::Reflow(nsIPresContext* aPresContext,
nsStyleContext* optStyle = optFrame->GetStyleContext();
if (optStyle) {
const nsStyleFont* styleFont = optStyle->GetStyleFont();
nsCOMPtr<nsIDeviceContext> deviceContext;
aPresContext->GetDeviceContext(getter_AddRefs(deviceContext));
NS_ASSERTION(deviceContext, "Couldn't get the device context");
nsIFontMetrics * fontMet;
result = deviceContext->GetMetricsFor(styleFont->mFont, fontMet);
result = aPresContext->DeviceContext()->
GetMetricsFor(styleFont->mFont, fontMet);
if (NS_SUCCEEDED(result) && fontMet != nsnull) {
if (fontMet) {
fontMet->GetHeight(heightOfARow);

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

@ -1410,24 +1410,17 @@ nsTextControlFrame::ReflowStandard(nsIPresContext* aPresContext,
float p2t;
aPresContext->GetPixelsToTwips(&p2t);
nscoord scrollbarWidth = 0;
nscoord scrollbarHeight = 0;
nsCOMPtr<nsIDeviceContext> dx;
aPresContext->GetDeviceContext(getter_AddRefs(dx));
if (dx) {
nsIDeviceContext *dx = aPresContext->DeviceContext();
float scale;
dx->GetCanonicalPixelScale(scale);
float sbWidth;
float sbHeight;
dx->GetScrollBarDimensions(sbWidth, sbHeight);
scrollbarWidth = PRInt32(sbWidth * scale);
scrollbarHeight = PRInt32(sbHeight * scale);
} else {
NS_WARNING("Dude! No DeviceContext! Not cool!");
scrollbarWidth = nsFormControlFrame::GetScrollbarWidth(p2t);
scrollbarHeight = scrollbarWidth;
}
nscoord scrollbarWidth = PRInt32(sbWidth * scale);
nscoord scrollbarHeight = PRInt32(sbHeight * scale);
aDesiredSize.height += scrollbarHeight;
minSize.height += scrollbarHeight;

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

@ -121,8 +121,7 @@ CheckFontExistence(nsIPresContext* aPresContext, const nsString& aFontName)
{
PRBool aliased;
nsAutoString localName;
nsCOMPtr<nsIDeviceContext> deviceContext;
aPresContext->GetDeviceContext(getter_AddRefs(deviceContext));
nsIDeviceContext *deviceContext = aPresContext->DeviceContext();
deviceContext->GetLocalFontName(aFontName, localName, aliased);
PRBool rv = (aliased || (NS_OK == deviceContext->CheckFontExistence(localName)));
// (see bug 35824 for comments about the aliased localName)

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

@ -726,7 +726,6 @@ nsPrintEngine::Print(nsIPrintSettings* aPrintSettings,
#endif
nsCOMPtr<nsIDeviceContextSpec> devspec;
nsCOMPtr<nsIDeviceContext> dx;
mPrt->mPrintDC = nsnull; // XXX why?
#ifdef NS_DEBUG
@ -806,9 +805,8 @@ nsPrintEngine::Print(nsIPrintSettings* aPrintSettings,
CHECK_RUNTIME_ERROR_CONDITION(nsIDebugObject::PRT_RUNTIME_NODEVSPEC, rv, NS_ERROR_FAILURE);
if (NS_SUCCEEDED(rv)) {
rv = mPresContext->GetDeviceContext(getter_AddRefs(dx));
if (NS_SUCCEEDED(rv)) {
rv = dx->GetDeviceContextFor(devspec, *getter_AddRefs(mPrt->mPrintDC));
rv = mPresContext->DeviceContext()->
GetDeviceContextFor(devspec, *getter_AddRefs(mPrt->mPrintDC));
if (NS_SUCCEEDED(rv)) {
// Get the Original PixelScale incase we need to start changing it
mPrt->mPrintDC->GetCanonicalPixelScale(mPrt->mOrigDCScale);
@ -827,7 +825,8 @@ nsPrintEngine::Print(nsIPrintSettings* aPrintSettings,
printf("CRITICAL PRINTING INFORMATION\n");
// DEVICE CONTEXT INFORMATION from PresContext
printf("DeviceContext of Presentation Context(%x)\n",dx);
nsIDeviceContext *dx = mPresContext->DeviceContext();
printf("DeviceContext of Presentation Context(%x)\n", dx);
dx->GetDevUnitsToTwips(a1);
dx->GetTwipsToDevUnits(a2);
printf(" DevToTwips = %f TwipToDev = %f\n",a1,a2);
@ -985,7 +984,6 @@ nsPrintEngine::Print(nsIPrintSettings* aPrintSettings,
}
}
}
}
} else {
mPrt->mPrintSettings->SetIsCancelled(PR_TRUE);
}

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

@ -1560,18 +1560,16 @@ nsRuleNode::SetFont(nsIPresContext* aPresContext, nsStyleContext* aContext,
case NS_STYLE_FONT_FIELD: sysID = eSystemFont_Field; break;
}
nsCOMPtr<nsIDeviceContext> dc;
aPresContext->GetDeviceContext(getter_AddRefs(dc));
if (dc) {
// GetSystemFont sets the font face but not necessarily the size
aFont->mFont.size = defaultVariableFont->size;
if (NS_FAILED(dc->GetSystemFont(sysID, &aFont->mFont))) {
if (NS_FAILED(aPresContext->DeviceContext()->GetSystemFont(sysID,
&aFont->mFont))) {
aFont->mFont.name = defaultVariableFont->name;
}
// this becomes our cascading size
aFont->mSize = aFont->mFont.size
= nsStyleFont::ZoomText(aPresContext, aFont->mFont.size);
}
aFont->mSize = aFont->mFont.size =
nsStyleFont::ZoomText(aPresContext, aFont->mFont.size);
aFont->mFont.familyNameQuirks = PR_FALSE;

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

@ -223,10 +223,8 @@ nsChangeHint nsStyleFont::CalcDifference(const nsStyleFont& aOther) const
inline float
TextZoomFor(nsIPresContext* aPresContext)
{
nsCOMPtr<nsIDeviceContext> dc;
aPresContext->GetDeviceContext(getter_AddRefs(dc));
float textZoom;
dc->GetTextZoom(textZoom);
aPresContext->DeviceContext()->GetTextZoom(textZoom);
return textZoom;
}

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

@ -648,10 +648,8 @@ nsBox::GetBorder(nsMargin& aMargin)
nsCOMPtr<nsIPresContext> context;
shell->GetPresContext(getter_AddRefs(context));
if (gTheme->ThemeSupportsWidget(context, frame, disp->mAppearance)) {
nsCOMPtr<nsIDeviceContext> dc;
context->GetDeviceContext(getter_AddRefs(dc));
nsMargin margin(0,0,0,0);
gTheme->GetWidgetBorder(dc, frame,
gTheme->GetWidgetBorder(context->DeviceContext(), frame,
disp->mAppearance, &margin);
float p2t;
context->GetScaledPixelsToTwips(&p2t);

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

@ -259,10 +259,9 @@ nsListBoxBodyFrame::Init(nsIPresContext* aPresContext, nsIContent* aContent,
nsBoxLayoutState boxLayoutState(aPresContext);
nsCOMPtr<nsIDeviceContext> dc;
aPresContext->GetDeviceContext(getter_AddRefs(dc));
nsCOMPtr<nsIFontMetrics> fm;
dc->GetMetricsFor(aContext->GetStyleFont()->mFont, *getter_AddRefs(fm));
aPresContext->DeviceContext()->GetMetricsFor(aContext->GetStyleFont()->mFont,
*getter_AddRefs(fm));
fm->GetHeight(mRowHeight);
return rv;
@ -748,10 +747,10 @@ nsListBoxBodyFrame::ComputeIntrinsicWidth(nsBoxLayoutState& aBoxLayoutState)
text->AppendTextTo(value);
}
}
nsCOMPtr<nsIDeviceContext> dc;
presContext->GetDeviceContext(getter_AddRefs(dc));
nsCOMPtr<nsIFontMetrics> fm;
dc->GetMetricsFor(styleContext->GetStyleFont()->mFont, *getter_AddRefs(fm));
presContext->DeviceContext()->
GetMetricsFor(styleContext->GetStyleFont()->mFont,
*getter_AddRefs(fm));
rendContext->SetFont(fm);
nscoord textWidth;

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

@ -392,10 +392,9 @@ nsTextBoxFrame::PaintTitle(nsIPresContext* aPresContext,
nscoord offset;
nscoord size;
nscoord baseline;
nsCOMPtr<nsIDeviceContext> deviceContext;
nsCOMPtr<nsIFontMetrics> fontMet;
aPresContext->GetDeviceContext(getter_AddRefs(deviceContext));
deviceContext->GetMetricsFor(fontStyle->mFont, *getter_AddRefs(fontMet));
aPresContext->DeviceContext()->GetMetricsFor(fontStyle->mFont,
*getter_AddRefs(fontMet));
fontMet->GetMaxAscent(baseline);
if (decorations & (NS_FONT_DECORATION_OVERLINE | NS_FONT_DECORATION_UNDERLINE)) {
@ -512,11 +511,9 @@ nsTextBoxFrame::CalculateTitleForWidth(nsIPresContext* aPresContext,
if (mTitle.IsEmpty())
return;
nsCOMPtr<nsIDeviceContext> deviceContext;
aPresContext->GetDeviceContext(getter_AddRefs(deviceContext));
nsCOMPtr<nsIFontMetrics> fontMet;
deviceContext->GetMetricsFor(GetStyleFont()->mFont, *getter_AddRefs(fontMet));
aPresContext->DeviceContext()->GetMetricsFor(GetStyleFont()->mFont,
*getter_AddRefs(fontMet));
aRenderingContext.SetFont(fontMet);
// see if the text will completely fit in the width given
@ -789,11 +786,9 @@ void
nsTextBoxFrame::GetTextSize(nsIPresContext* aPresContext, nsIRenderingContext& aRenderingContext,
const nsString& aString, nsSize& aSize, nscoord& aAscent)
{
nsCOMPtr<nsIDeviceContext> deviceContext;
aPresContext->GetDeviceContext(getter_AddRefs(deviceContext));
nsCOMPtr<nsIFontMetrics> fontMet;
deviceContext->GetMetricsFor(GetStyleFont()->mFont, *getter_AddRefs(fontMet));
aPresContext->DeviceContext()->GetMetricsFor(GetStyleFont()->mFont,
*getter_AddRefs(fontMet));
fontMet->GetHeight(aSize.height);
aRenderingContext.SetFont(fontMet);
aRenderingContext.GetWidth(aString, aSize.width);

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

@ -1383,11 +1383,9 @@ nsTreeBodyFrame::GetCoordsForCellItem(PRInt32 aRow, const PRUnichar *aColID, con
// we add in borders and padding to the text dimension and give that back.
nsStyleContext* textContext = GetPseudoStyleContext(nsCSSAnonBoxes::moztreecelltext);
nsCOMPtr<nsIDeviceContext> dc;
mPresContext->GetDeviceContext(getter_AddRefs(dc));
nsCOMPtr<nsIFontMetrics> fm;
dc->GetMetricsFor(textContext->GetStyleFont()->mFont, *getter_AddRefs(fm));
mPresContext->DeviceContext()->
GetMetricsFor(textContext->GetStyleFont()->mFont, *getter_AddRefs(fm));
nscoord height;
fm->GetHeight(height);
@ -2828,11 +2826,10 @@ nsTreeBodyFrame::PaintText(PRInt32 aRowIndex,
textRect.Deflate(bp);
// Compute our text size.
nsCOMPtr<nsIDeviceContext> deviceContext;
aPresContext->GetDeviceContext(getter_AddRefs(deviceContext));
nsCOMPtr<nsIFontMetrics> fontMet;
deviceContext->GetMetricsFor(textContext->GetStyleFont()->mFont, *getter_AddRefs(fontMet));
aPresContext->DeviceContext()->
GetMetricsFor(textContext->GetStyleFont()->mFont,
*getter_AddRefs(fontMet));
nscoord height, baseline;
fontMet->GetHeight(height);