Bug 651021 - Make nsRenderingContext a stack class. r=jrmuizel

This commit is contained in:
Jonathan Watt 2014-10-31 20:08:49 +00:00
Родитель 3cacbfa9b0
Коммит bf49eb7f25
29 изменённых файлов: 118 добавлений и 135 удалений

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

@ -6,6 +6,7 @@
#include "nsDeviceContext.h"
#include <algorithm> // for max
#include "gfxASurface.h" // for gfxASurface, etc
#include "gfxContext.h"
#include "gfxFont.h" // for gfxFontGroup
#include "gfxImageSurface.h" // for gfxImageSurface
#include "gfxPoint.h" // for gfxSize
@ -385,7 +386,7 @@ nsDeviceContext::Init(nsIWidget *aWidget)
return NS_OK;
}
already_AddRefed<nsRenderingContext>
already_AddRefed<gfxContext>
nsDeviceContext::CreateRenderingContext()
{
nsRefPtr<gfxASurface> printingSurface = mPrintingSurface;
@ -400,7 +401,6 @@ nsDeviceContext::CreateRenderingContext()
printingSurface = mCachedPrintingSurface;
}
#endif
nsRefPtr<nsRenderingContext> pContext = new nsRenderingContext();
RefPtr<gfx::DrawTarget> dt =
gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(printingSurface,
@ -409,13 +409,10 @@ nsDeviceContext::CreateRenderingContext()
#ifdef XP_MACOSX
dt->AddUserData(&gfxContext::sDontUseAsSourceKey, dt, nullptr);
#endif
dt->AddUserData(&sDisablePixelSnapping, (void*)0x1, nullptr);
pContext->Init(dt);
pContext->GetDrawTarget()->AddUserData(&sDisablePixelSnapping,
(void*)0x1, nullptr);
pContext->ThebesContext()->SetMatrix(gfxMatrix::Scaling(mPrintingScale,
mPrintingScale));
nsRefPtr<gfxContext> pContext = new gfxContext(dt);
pContext->SetMatrix(gfxMatrix::Scaling(mPrintingScale, mPrintingScale));
return pContext.forget();
}

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

@ -21,6 +21,7 @@
#include "mozilla/AppUnits.h" // for AppUnits
class gfxASurface;
class gfxContext;
class gfxTextPerfMetrics;
class gfxUserFontSet;
struct nsFont;
@ -32,7 +33,6 @@ class nsIScreen;
class nsIScreenManager;
class nsIWidget;
struct nsRect;
class nsRenderingContext;
class nsDeviceContext MOZ_FINAL
{
@ -61,7 +61,7 @@ public:
*
* @return the new rendering context (guaranteed to be non-null)
*/
already_AddRefed<nsRenderingContext> CreateRenderingContext();
already_AddRefed<gfxContext> CreateRenderingContext();
/**
* Gets the number of app units in one CSS pixel; this number is global,

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

@ -8,7 +8,7 @@
#include "gfxContext.h"
#include "mozilla/Attributes.h"
#include "nsISupportsImpl.h"
#include "nsCOMPtr.h"
#include "nsRefPtr.h"
namespace mozilla {
@ -17,12 +17,24 @@ class DrawTarget;
}
}
class nsRenderingContext MOZ_FINAL
class MOZ_STACK_CLASS nsRenderingContext MOZ_FINAL
{
typedef mozilla::gfx::DrawTarget DrawTarget;
public:
NS_INLINE_DECL_REFCOUNTING(nsRenderingContext)
nsRenderingContext() {}
nsRenderingContext(gfxContext* aThebesContext)
: mThebes(aThebesContext)
{}
nsRenderingContext(already_AddRefed<gfxContext>&& aThebesContext)
: mThebes(aThebesContext)
{}
nsRenderingContext(DrawTarget* aDrawTarget) {
Init(aDrawTarget);
}
void Init(gfxContext* aThebesContext);
void Init(DrawTarget* aDrawTarget);
@ -32,9 +44,6 @@ public:
DrawTarget *GetDrawTarget() { return mThebes->GetDrawTarget(); }
private:
// Private destructor, to discourage deletion outside of Release():
~nsRenderingContext() {}
nsRefPtr<gfxContext> mThebes;
};

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

@ -4240,10 +4240,9 @@ static void DebugPaintItem(DrawTarget& aDrawTarget,
SurfaceFormat::B8G8R8A8);
nsRefPtr<gfxContext> context = new gfxContext(tempDT);
context->SetMatrix(gfxMatrix::Translation(-bounds.x, -bounds.y));
nsRefPtr<nsRenderingContext> ctx = new nsRenderingContext();
ctx->Init(context);
nsRenderingContext ctx(context);
aItem->Paint(aBuilder, ctx);
aItem->Paint(aBuilder, &ctx);
RefPtr<SourceSurface> surface = tempDT->Snapshot();
DumpPaintedImage(aItem, surface);
@ -4513,8 +4512,7 @@ FrameLayerBuilder::DrawPaintedLayer(PaintedLayer* aLayer,
userData->mXScale, userData->mYScale);
}
nsRefPtr<nsRenderingContext> rc = new nsRenderingContext();
rc->Init(aContext);
nsRenderingContext rc(aContext);
if (shouldDrawRectsSeparately) {
nsIntRegionRectIterator it(aRegionToDraw);
@ -4533,7 +4531,7 @@ FrameLayerBuilder::DrawPaintedLayer(PaintedLayer* aLayer,
aContext->CurrentMatrix().Translate(aLayer->GetResidualTranslation() - gfxPoint(offset.x, offset.y)).
Scale(userData->mXScale, userData->mYScale));
layerBuilder->PaintItems(entry->mItems, *iterRect, aContext, rc,
layerBuilder->PaintItems(entry->mItems, *iterRect, aContext, &rc,
builder, presContext,
offset, userData->mXScale, userData->mYScale,
entry->mCommonClipCount);
@ -4546,7 +4544,7 @@ FrameLayerBuilder::DrawPaintedLayer(PaintedLayer* aLayer,
aContext->CurrentMatrix().Translate(aLayer->GetResidualTranslation() - gfxPoint(offset.x, offset.y)).
Scale(userData->mXScale,userData->mYScale));
layerBuilder->PaintItems(entry->mItems, aRegionToDraw.GetBounds(), aContext, rc,
layerBuilder->PaintItems(entry->mItems, aRegionToDraw.GetBounds(), aContext, &rc,
builder, presContext,
offset, userData->mXScale, userData->mYScale,
entry->mCommonClipCount);

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

@ -439,8 +439,8 @@ RestyleManager::RecomputePosition(nsIFrame* aFrame)
// the frame, and then get the offsets and size from it. If the frame's size
// doesn't need to change, we can simply update the frame position. Otherwise
// we fall back to a reflow.
nsRefPtr<nsRenderingContext> rc =
aFrame->PresContext()->PresShell()->CreateReferenceRenderingContext();
nsRenderingContext rc(
aFrame->PresContext()->PresShell()->CreateReferenceRenderingContext());
// Construct a bogus parent reflow state so that there's a usable
// containing block reflow state.
@ -451,7 +451,7 @@ RestyleManager::RecomputePosition(nsIFrame* aFrame)
nsFrameState savedState = parentFrame->GetStateBits();
nsHTMLReflowState parentReflowState(aFrame->PresContext(), parentFrame,
rc, parentSize);
&rc, parentSize);
parentFrame->RemoveStateBits(~nsFrameState(0));
parentFrame->AddStateBits(savedState);

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

@ -1346,18 +1346,17 @@ nsCSSRendering::PaintBoxShadowOuter(nsPresContext* aPresContext,
// Draw the widget shape
gfxContextMatrixAutoSaveRestore save(shadowContext);
nsRefPtr<nsRenderingContext> wrapperCtx = new nsRenderingContext();
wrapperCtx->Init(shadowContext);
gfxPoint devPixelOffset =
nsLayoutUtils::PointToGfxPoint(nsPoint(shadowItem->mXOffset,
shadowItem->mYOffset),
aPresContext->AppUnitsPerDevPixel());
wrapperCtx->ThebesContext()->SetMatrix(
wrapperCtx->ThebesContext()->CurrentMatrix().Translate(devPixelOffset));
shadowContext->SetMatrix(
shadowContext->CurrentMatrix().Translate(devPixelOffset));
nsRect nativeRect;
nativeRect.IntersectRect(frameRect, aDirtyRect);
aPresContext->GetTheme()->DrawWidgetBackground(wrapperCtx, aForFrame,
nsRenderingContext wrapperCtx(shadowContext);
aPresContext->GetTheme()->DrawWidgetBackground(&wrapperCtx, aForFrame,
styleDisplay->mAppearance, aFrameArea, nativeRect);
blurringArea.DoPaint();

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

@ -3340,9 +3340,8 @@ nsDocumentViewer::GetContentSize(int32_t* aWidth, int32_t* aHeight)
nscoord prefWidth;
{
nsRefPtr<nsRenderingContext> rcx =
presShell->CreateReferenceRenderingContext();
prefWidth = root->GetPrefISize(rcx);
nsRenderingContext rcx(presShell->CreateReferenceRenderingContext());
prefWidth = root->GetPrefISize(&rcx);
}
nsresult rv = presShell->ResizeReflow(prefWidth, NS_UNCONSTRAINEDSIZE);

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

@ -600,7 +600,7 @@ public:
* be rendered to, but is suitable for measuring text and performing
* other non-rendering operations. Guaranteed to return non-null.
*/
virtual already_AddRefed<nsRenderingContext> CreateReferenceRenderingContext() = 0;
virtual already_AddRefed<gfxContext> CreateReferenceRenderingContext() = 0;
/**
* Informs the pres shell that the document is now at the anchor with

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

@ -4852,15 +4852,14 @@ nsLayoutUtils::PaintTextShadow(const nsIFrame* aFrame,
// Conjure an nsRenderingContext from a gfxContext for drawing the text
// to blur.
nsRefPtr<nsRenderingContext> renderingContext = new nsRenderingContext();
renderingContext->Init(shadowContext);
nsRenderingContext renderingContext(shadowContext);
aDestCtx->Save();
aDestCtx->NewPath();
aDestCtx->SetColor(gfxRGBA(shadowColor));
// The callback will draw whatever we want to blur as a shadow.
aCallback(renderingContext, shadowOffset, shadowColor, aCallbackData);
aCallback(&renderingContext, shadowOffset, shadowColor, aCallbackData);
contextBoxBlur.DoPaint();
aDestCtx->Restore();

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

@ -3118,14 +3118,13 @@ PresShell::ClearFrameRefs(nsIFrame* aFrame)
}
}
already_AddRefed<nsRenderingContext>
already_AddRefed<gfxContext>
PresShell::CreateReferenceRenderingContext()
{
nsDeviceContext* devCtx = mPresContext->DeviceContext();
nsRefPtr<nsRenderingContext> rc;
nsRefPtr<gfxContext> rc;
if (mPresContext->IsScreen()) {
rc = new nsRenderingContext();
rc->Init(gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget());
rc = new gfxContext(gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget());
} else {
rc = devCtx->CreateRenderingContext();
}
@ -4884,8 +4883,7 @@ PresShell::RenderDocument(const nsRect& aRect, uint32_t aFlags,
AutoSaveRestoreRenderingState _(this);
nsRefPtr<nsRenderingContext> rc = new nsRenderingContext();
rc->Init(aThebesContext);
nsRenderingContext rc(aThebesContext);
bool wouldFlushRetainedLayers = false;
uint32_t flags = nsLayoutUtils::PAINT_IGNORE_SUPPRESSION;
@ -4928,7 +4926,7 @@ PresShell::RenderDocument(const nsRect& aRect, uint32_t aFlags,
flags &= ~nsLayoutUtils::PAINT_WIDGET_LAYERS;
}
nsLayoutUtils::PaintFrame(rc, rootFrame, nsRegion(aRect),
nsLayoutUtils::PaintFrame(&rc, rootFrame, nsRegion(aRect),
aBackgroundColor, flags);
// if we had to use a group, paint it to the destination now
@ -5203,8 +5201,7 @@ PresShell::PaintRangePaintInfo(nsTArray<nsAutoPtr<RangePaintInfo> >* aItems,
}
}
nsRefPtr<nsRenderingContext> rc = new nsRenderingContext();
rc->Init(ctx);
nsRenderingContext rc(ctx);
gfxMatrix initialTM = ctx->CurrentMatrix();
@ -5241,7 +5238,7 @@ PresShell::PaintRangePaintInfo(nsTArray<nsAutoPtr<RangePaintInfo> >* aItems,
ctx->SetMatrix(initialTM.Translate(rootOffset));
aArea.MoveBy(-rangeInfo->mRootOffset.x, -rangeInfo->mRootOffset.y);
nsRegion visible(aArea);
rangeInfo->mList.PaintRoot(&rangeInfo->mBuilder, rc, nsDisplayList::PAINT_DEFAULT);
rangeInfo->mList.PaintRoot(&rangeInfo->mBuilder, &rc, nsDisplayList::PAINT_DEFAULT);
aArea.MoveBy(rangeInfo->mRootOffset.x, rangeInfo->mRootOffset.y);
}
@ -8930,7 +8927,7 @@ PresShell::DoReflow(nsIFrame* target, bool aInterruptible)
nsIFrame* rootFrame = mFrameConstructor->GetRootFrame();
nsRefPtr<nsRenderingContext> rcx = CreateReferenceRenderingContext();
nsRenderingContext rcx(CreateReferenceRenderingContext());
#ifdef DEBUG
mCurrentReflowRoot = target;
@ -8955,7 +8952,7 @@ PresShell::DoReflow(nsIFrame* target, bool aInterruptible)
// Don't pass size directly to the reflow state, since a
// constrained height implies page/column breaking.
LogicalSize reflowSize(wm, size.ISize(wm), NS_UNCONSTRAINEDSIZE);
nsHTMLReflowState reflowState(mPresContext, target, rcx, reflowSize,
nsHTMLReflowState reflowState(mPresContext, target, &rcx, reflowSize,
nsHTMLReflowState::CALLER_WILL_INIT);
reflowState.mOrthogonalLimit = size.BSize(wm);
@ -9036,7 +9033,7 @@ PresShell::DoReflow(nsIFrame* target, bool aInterruptible)
target->GetView(),
boundsRelativeToTarget);
nsContainerFrame::SyncWindowProperties(mPresContext, target,
target->GetView(), rcx);
target->GetView(), &rcx);
target->DidReflow(mPresContext, nullptr, nsDidReflowStatus::FINISHED);
if (target == rootFrame && size.BSize(wm) == NS_UNCONSTRAINEDSIZE) {

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

@ -125,7 +125,7 @@ public:
virtual void CancelReflowCallback(nsIReflowCallback* aCallback) MOZ_OVERRIDE;
virtual void ClearFrameRefs(nsIFrame* aFrame) MOZ_OVERRIDE;
virtual already_AddRefed<nsRenderingContext> CreateReferenceRenderingContext();
virtual already_AddRefed<gfxContext> CreateReferenceRenderingContext();
virtual nsresult GoToAnchor(const nsAString& aAnchorName, bool aScroll,
uint32_t aAdditionalScrollFlags = 0) MOZ_OVERRIDE;
virtual nsresult ScrollToAnchor() MOZ_OVERRIDE;

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

@ -35,10 +35,7 @@ public:
: mFrame(aFrame) {}
virtual already_AddRefed<gfxContext> GetRefContext() MOZ_OVERRIDE
{
nsRefPtr<nsRenderingContext> rc =
mFrame->PresContext()->PresShell()->CreateReferenceRenderingContext();
nsRefPtr<gfxContext> ctx = rc->ThebesContext();
return ctx.forget();
return mFrame->PresContext()->PresShell()->CreateReferenceRenderingContext();
}
private:
nsIFrame* mFrame;
@ -758,13 +755,13 @@ TextOverflow::Marker::SetupString(nsIFrame* aFrame)
mWidth = 0;
}
} else {
nsRefPtr<nsRenderingContext> rc =
aFrame->PresContext()->PresShell()->CreateReferenceRenderingContext();
nsRenderingContext rc(
aFrame->PresContext()->PresShell()->CreateReferenceRenderingContext());
nsRefPtr<nsFontMetrics> fm;
nsLayoutUtils::GetFontMetricsForFrame(aFrame, getter_AddRefs(fm),
nsLayoutUtils::FontSizeInflationFor(aFrame));
mWidth = nsLayoutUtils::AppUnitWidthOfStringBidi(mStyle->mString, aFrame,
*fm, *rc);
*fm, rc);
}
mIntrinsicISize = mWidth;
mInitialized = true;

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

@ -306,7 +306,7 @@ nsDisplayCanvasBackgroundImage::Paint(nsDisplayListBuilder* aBuilder,
nsPoint offset = ToReferenceFrame();
nsRect bgClipRect = frame->CanvasArea() + offset;
nsRefPtr<nsRenderingContext> context;
nsRenderingContext context;
nsRefPtr<gfxContext> dest = aCtx->ThebesContext();
RefPtr<DrawTarget> dt;
gfxRect destRect;
@ -328,14 +328,13 @@ nsDisplayCanvasBackgroundImage::Paint(nsDisplayListBuilder* aBuilder,
nsRefPtr<gfxContext> ctx = new gfxContext(dt);
ctx->SetMatrix(
ctx->CurrentMatrix().Translate(-destRect.x, -destRect.y));
context = new nsRenderingContext();
context->Init(ctx);
context.Init(ctx);
}
}
#endif
PaintInternal(aBuilder,
dt ? context.get() : aCtx,
dt ? &context : aCtx,
dt ? bgClipRect: mVisibleRect,
&bgClipRect);

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

@ -1328,10 +1328,10 @@ nsFlexContainerFrame::
// Measure content, if needed (w/ intrinsic-width method or a reflow)
if (minSizeNeedsToMeasureContent || flexBasisNeedsToMeasureContent) {
if (IsAxisHorizontal(aAxisTracker.GetMainAxis())) {
nsRefPtr<nsRenderingContext> rctx =
aPresContext->PresShell()->CreateReferenceRenderingContext();
nsRenderingContext rctx(
aPresContext->PresShell()->CreateReferenceRenderingContext());
if (minSizeNeedsToMeasureContent) {
resolvedMinSize = std::min(resolvedMinSize, aFlexItem.Frame()->GetMinISize(rctx));
resolvedMinSize = std::min(resolvedMinSize, aFlexItem.Frame()->GetMinISize(&rctx));
}
NS_ASSERTION(!flexBasisNeedsToMeasureContent,
"flex-basis:auto should have been resolved in the "

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

@ -647,11 +647,10 @@ nsSimplePageSequenceFrame::PrePrintNextPage(nsITimerCallback* aCallback, bool* a
mCalledBeginPage = true;
nsRefPtr<nsRenderingContext> renderingContext =
dc->CreateRenderingContext();
nsRefPtr<gfxContext> renderingContext = dc->CreateRenderingContext();
nsRefPtr<gfxASurface> renderingSurface =
renderingContext->ThebesContext()->CurrentSurface();
renderingContext->CurrentSurface();
NS_ENSURE_TRUE(renderingSurface, NS_ERROR_OUT_OF_MEMORY);
for (int32_t i = mCurrentCanvasList.Length() - 1; i >= 0 ; i--) {
@ -777,12 +776,11 @@ nsSimplePageSequenceFrame::PrintNextPage()
PR_PL(("SeqFr::PrintNextPage -> %p PageNo: %d", pf, mPageNum));
nsRefPtr<nsRenderingContext> renderingContext =
dc->CreateRenderingContext();
nsRenderingContext renderingContext(dc->CreateRenderingContext());
nsRect drawingRect(nsPoint(0, 0), currentPage->GetSize());
nsRegion drawingRegion(drawingRect);
nsLayoutUtils::PaintFrame(renderingContext, currentPage,
nsLayoutUtils::PaintFrame(&renderingContext, currentPage,
drawingRegion, NS_RGBA(0,0,0,0),
nsLayoutUtils::PAINT_SYNC_DECODE_IMAGES);

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

@ -1769,11 +1769,7 @@ GetFontGroupForFrame(nsIFrame* aFrame, float aFontSizeInflation,
static already_AddRefed<gfxContext>
CreateReferenceThebesContext(nsTextFrame* aTextFrame)
{
nsRefPtr<nsRenderingContext> tmp =
aTextFrame->PresContext()->PresShell()->CreateReferenceRenderingContext();
nsRefPtr<gfxContext> ctx = tmp->ThebesContext();
return ctx.forget();
return aTextFrame->PresContext()->PresShell()->CreateReferenceRenderingContext();
}
/**

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

@ -2264,8 +2264,8 @@ nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO)
fprintf(fd, "Title: %s\n", docStr.get());
fprintf(fd, "URL: %s\n", urlStr.get());
fprintf(fd, "--------------- Frames ----------------\n");
nsRefPtr<nsRenderingContext> renderingContext =
mPrt->mPrintDocDC->CreateRenderingContext();
//nsRefPtr<gfxContext> renderingContext =
// mPrt->mPrintDocDC->CreateRenderingContext();
RootFrameList(aPO->mPresContext, fd, 0);
//DumpFrames(fd, aPO->mPresContext, renderingContext, theRootFrame, 0);
fprintf(fd, "---------------------------------------\n\n");
@ -2504,8 +2504,7 @@ nsPrintEngine::DoPrint(nsPrintObject * aPO)
poPresContext->SetIsRenderingOnlySelection(true);
// temporarily creating rendering context
// which is needed to find the selection frames
nsRefPtr<nsRenderingContext> rc =
mPrt->mPrintDC->CreateRenderingContext();
nsRenderingContext rc(mPrt->mPrintDC->CreateRenderingContext());
// find the starting and ending page numbers
// via the selection
@ -2519,7 +2518,7 @@ nsPrintEngine::DoPrint(nsPrintObject * aPO)
nsRefPtr<Selection> selectionPS =
poPresShell->GetCurrentSelection(nsISelectionController::SELECTION_NORMAL);
rv = GetPageRangeForSelection(poPresShell, poPresContext, *rc, selectionPS, pageSequence,
rv = GetPageRangeForSelection(poPresShell, poPresContext, rc, selectionPS, pageSequence,
&startFrame, startPageNum, startRect,
&endFrame, endPageNum, endRect);
if (NS_SUCCEEDED(rv)) {
@ -3810,8 +3809,8 @@ void DumpLayoutData(char* aTitleStr,
fprintf(fd, "URL: %s\n", aURLStr?aURLStr:"");
fprintf(fd, "--------------- Frames ----------------\n");
fprintf(fd, "--------------- Frames ----------------\n");
nsRefPtr<nsRenderingContext> renderingContext =
aDC->CreateRenderingContext();
//nsRefPtr<gfxContext> renderingContext =
// aDC->CreateRenderingContext();
RootFrameList(aPresContext, fd, 0);
//DumpFrames(fd, aPresContext, renderingContext, aRootFrame, 0);
fprintf(fd, "---------------------------------------\n\n");

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

@ -325,9 +325,9 @@ static nsSize CalcViewportUnitsScale(nsPresContext* aPresContext)
if (styles.mHorizontal == NS_STYLE_OVERFLOW_SCROLL ||
styles.mVertical == NS_STYLE_OVERFLOW_SCROLL) {
// Gather scrollbar size information.
nsRefPtr<nsRenderingContext> context =
aPresContext->PresShell()->CreateReferenceRenderingContext();
nsMargin sizes(scrollFrame->GetDesiredScrollbarSizes(aPresContext, context));
nsRenderingContext context(
aPresContext->PresShell()->CreateReferenceRenderingContext());
nsMargin sizes(scrollFrame->GetDesiredScrollbarSizes(aPresContext, &context));
if (styles.mHorizontal == NS_STYLE_OVERFLOW_SCROLL) {
// 'overflow-x: scroll' means we must consider the horizontal scrollbar,

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

@ -5234,8 +5234,8 @@ SVGTextFrame::DoReflow()
if (!kid)
return;
nsRefPtr<nsRenderingContext> renderingContext =
presContext->PresShell()->CreateReferenceRenderingContext();
nsRenderingContext renderingContext(
presContext->PresShell()->CreateReferenceRenderingContext());
if (UpdateFontSizeScaleFactor()) {
// If the font size scale factor changed, we need the block to report
@ -5245,10 +5245,10 @@ SVGTextFrame::DoReflow()
mState |= NS_STATE_SVG_TEXT_IN_REFLOW;
nscoord inlineSize = kid->GetPrefISize(renderingContext);
nscoord inlineSize = kid->GetPrefISize(&renderingContext);
WritingMode wm = kid->GetWritingMode();
nsHTMLReflowState reflowState(presContext, kid,
renderingContext,
&renderingContext,
LogicalSize(wm, inlineSize,
NS_UNCONSTRAINEDSIZE));
nsHTMLReflowMetrics desiredSize(reflowState);

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

@ -448,9 +448,8 @@ nsFilterInstance::BuildSourceImage(DrawTarget* aTargetDT)
ctx->CurrentMatrix().Translate(-neededRect.TopLeft()).
PreMultiply(deviceToFilterSpace));
nsRefPtr<nsRenderingContext> tmpCtx(new nsRenderingContext());
tmpCtx->Init(ctx);
mPaintCallback->Paint(tmpCtx, mTargetFrame, mPaintTransform, &dirty);
nsRenderingContext tmpCtx(ctx);
mPaintCallback->Paint(&tmpCtx, mTargetFrame, mPaintTransform, &dirty);
mSourceGraphic.mSourceSurface = offscreenDT->Snapshot();
mSourceGraphic.mSurfaceRect = ToIntRect(neededRect);

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

@ -525,14 +525,14 @@ nsSVGForeignObjectFrame::DoReflow()
return;
// initiate a synchronous reflow here and now:
nsRefPtr<nsRenderingContext> renderingContext =
presContext->PresShell()->CreateReferenceRenderingContext();
nsRenderingContext renderingContext(
presContext->PresShell()->CreateReferenceRenderingContext());
mInReflow = true;
WritingMode wm = kid->GetWritingMode();
nsHTMLReflowState reflowState(presContext, kid,
renderingContext,
&renderingContext,
LogicalSize(wm, GetLogicalSize(wm).ISize(wm),
NS_UNCONSTRAINEDSIZE));
nsHTMLReflowMetrics desiredSize(reflowState);

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

@ -642,8 +642,6 @@ PaintFrameCallback::operator()(gfxContext* aContext,
mFrame->AddStateBits(NS_FRAME_DRAWING_AS_PAINTSERVER);
nsRefPtr<nsRenderingContext> context(new nsRenderingContext());
context->Init(aContext);
aContext->Save();
// Clip to aFillRect so that we don't paint outside.
@ -684,7 +682,8 @@ PaintFrameCallback::operator()(gfxContext* aContext,
if (mFlags & nsSVGIntegrationUtils::FLAG_SYNC_DECODE_IMAGES) {
flags |= nsLayoutUtils::PAINT_SYNC_DECODE_IMAGES;
}
nsLayoutUtils::PaintFrame(context, mFrame,
nsRenderingContext context(aContext);
nsLayoutUtils::PaintFrame(&context, mFrame,
dirty, NS_RGBA(0, 0, 0, 0),
flags);

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

@ -226,9 +226,8 @@ nsSVGMaskFrame::GetMaskForMaskedFrame(gfxContext* aContext,
gfxMatrix maskSurfaceMatrix =
aContext->CurrentMatrix() * gfxMatrix::Translation(-maskSurfaceRect.TopLeft());
nsRefPtr<nsRenderingContext> tmpCtx = new nsRenderingContext();
tmpCtx->Init(maskDT);
tmpCtx->ThebesContext()->SetMatrix(maskSurfaceMatrix);
nsRenderingContext tmpCtx(maskDT);
tmpCtx.ThebesContext()->SetMatrix(maskSurfaceMatrix);
mMatrixForChildren = GetMaskTransform(aMaskedFrame) * aMatrix;
@ -244,7 +243,7 @@ nsSVGMaskFrame::GetMaskForMaskedFrame(gfxContext* aContext,
m = static_cast<nsSVGElement*>(kid->GetContent())->
PrependLocalTransformsTo(m);
}
nsSVGUtils::PaintFrameWithEffects(kid, tmpCtx, mMatrixForChildren);
nsSVGUtils::PaintFrameWithEffects(kid, &tmpCtx, mMatrixForChildren);
}
RefPtr<SourceSurface> maskSnapshot = maskDT->Snapshot();

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

@ -378,9 +378,8 @@ nsSVGPatternFrame::PaintPattern(const DrawTarget* aDrawTarget,
return nullptr;
}
nsRefPtr<nsRenderingContext> context(new nsRenderingContext());
context->Init(dt);
gfxContext* gfx = context->ThebesContext();
nsRenderingContext context(dt);
gfxContext* gfx = context.ThebesContext();
// Fill with transparent black
gfx->SetOperator(gfxContext::OPERATOR_CLEAR);
@ -417,7 +416,7 @@ nsSVGPatternFrame::PaintPattern(const DrawTarget* aDrawTarget,
tm = static_cast<nsSVGElement*>(kid->GetContent())->
PrependLocalTransformsTo(tm, nsSVGElement::eUserSpaceToParent);
}
nsSVGUtils::PaintFrameWithEffects(kid, context, tm);
nsSVGUtils::PaintFrameWithEffects(kid, &context, tm);
}
patternWithChildren->RemoveStateBits(NS_FRAME_DRAWING_AS_PAINTSERVER);
}

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

@ -1589,8 +1589,7 @@ nsSVGUtils::PaintSVGGlyph(Element* aElement, gfxContext* aContext,
}
aContext->GetDrawTarget()->AddUserData(&gfxTextContextPaint::sUserDataKey,
aContextPaint, nullptr);
nsRefPtr<nsRenderingContext> context(new nsRenderingContext());
context->Init(aContext);
nsRenderingContext context(aContext);
svgFrame->NotifySVGChanged(nsISVGChildFrame::TRANSFORM_CHANGED);
gfxMatrix m;
if (frame->GetContent()->IsSVG()) {
@ -1599,7 +1598,7 @@ nsSVGUtils::PaintSVGGlyph(Element* aElement, gfxContext* aContext,
m = static_cast<nsSVGElement*>(frame->GetContent())->
PrependLocalTransformsTo(gfxMatrix(), nsSVGElement::eUserSpaceToParent);
}
nsresult rv = svgFrame->PaintSVG(context, m);
nsresult rv = svgFrame->PaintSVG(&context, m);
return NS_SUCCEEDED(rv);
}

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

@ -12,6 +12,7 @@
#include "nsImageBoxFrame.h"
#include "nsGkAtoms.h"
#include "nsRenderingContext.h"
#include "nsStyleContext.h"
#include "nsStyleConsts.h"
#include "nsCOMPtr.h"

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

@ -634,9 +634,9 @@ nsSplitterFrameInner::MouseDown(nsIDOMEvent* aMouseEvent)
if (childIndex == childCount - 1 && GetResizeAfter() != Grow)
return NS_OK;
nsRefPtr<nsRenderingContext> rc =
outerPresContext->PresShell()->CreateReferenceRenderingContext();
nsBoxLayoutState state(outerPresContext, rc);
nsRenderingContext rc(
outerPresContext->PresShell()->CreateReferenceRenderingContext());
nsBoxLayoutState state(outerPresContext, &rc);
mCurrentPos = 0;
mPressed = true;

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

@ -501,10 +501,10 @@ nsTextBoxFrame::DrawText(nsRenderingContext& aRenderingContext,
}
}
nsRefPtr<nsRenderingContext> refContext =
PresContext()->PresShell()->CreateReferenceRenderingContext();
nsRenderingContext refContext(
PresContext()->PresShell()->CreateReferenceRenderingContext());
CalculateUnderline(*refContext, *fontMet);
CalculateUnderline(refContext, *fontMet);
nscolor c = aOverrideColor ? *aOverrideColor : StyleColor()->mColor;
ColorPattern color(ToDeviceColor(c));
@ -522,7 +522,7 @@ nsTextBoxFrame::DrawText(nsRenderingContext& aRenderingContext,
posResolve.logicalIndex = mAccessKeyInfo->mAccesskeyIndex;
rv = nsBidiPresUtils::RenderText(mCroppedTitle.get(), mCroppedTitle.Length(), level,
presContext, aRenderingContext,
*refContext, *fontMet,
refContext, *fontMet,
aTextRect.x, baseline,
&posResolve,
1);
@ -533,7 +533,7 @@ nsTextBoxFrame::DrawText(nsRenderingContext& aRenderingContext,
{
rv = nsBidiPresUtils::RenderText(mCroppedTitle.get(), mCroppedTitle.Length(), level,
presContext, aRenderingContext,
*refContext, *fontMet,
refContext, *fontMet,
aTextRect.x, baseline);
}
}
@ -548,14 +548,14 @@ nsTextBoxFrame::DrawText(nsRenderingContext& aRenderingContext,
mAccessKeyInfo->mBeforeWidth = nsLayoutUtils::
AppUnitWidthOfString(mCroppedTitle.get(),
mAccessKeyInfo->mAccesskeyIndex,
*fontMet, *refContext);
*fontMet, refContext);
else
mAccessKeyInfo->mBeforeWidth = 0;
}
fontMet->DrawString(mCroppedTitle.get(), mCroppedTitle.Length(),
aTextRect.x, baseline, &aRenderingContext,
refContext.get());
&refContext);
}
if (mAccessKeyInfo && mAccessKeyInfo->mAccesskeyIndex != kNotFound) {

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

@ -248,15 +248,15 @@ nsTreeBodyFrame::CalcMaxRowWidth()
nscoord rowWidth;
nsTreeColumn* col;
nsRefPtr<nsRenderingContext> rc =
PresContext()->PresShell()->CreateReferenceRenderingContext();
nsRenderingContext rc(
PresContext()->PresShell()->CreateReferenceRenderingContext());
for (int32_t row = 0; row < mRowCount; ++row) {
rowWidth = 0;
for (col = mColumns->GetFirstColumn(); col; col = col->GetNext()) {
nscoord desiredWidth, currentWidth;
nsresult rv = GetCellWidth(row, col, rc, desiredWidth, currentWidth);
nsresult rv = GetCellWidth(row, col, &rc, desiredWidth, currentWidth);
if (NS_FAILED(rv)) {
NS_NOTREACHED("invalid column");
continue;
@ -1166,8 +1166,8 @@ nsTreeBodyFrame::GetCoordsForCellItem(int32_t aRow, nsITreeColumn* aCol, const n
// interfere with our computations.
AdjustForBorderPadding(cellContext, cellRect);
nsRefPtr<nsRenderingContext> rc =
presContext->PresShell()->CreateReferenceRenderingContext();
nsRenderingContext rc(
presContext->PresShell()->CreateReferenceRenderingContext());
// Now we'll start making our way across the cell, starting at the edge of
// the cell and proceeding until we hit the right edge. |cellX| is the
@ -1191,7 +1191,7 @@ nsTreeBodyFrame::GetCoordsForCellItem(int32_t aRow, nsITreeColumn* aCol, const n
nsRect twistyRect(cellRect);
nsStyleContext* twistyContext = GetPseudoStyleContext(nsCSSAnonBoxes::moztreetwisty);
GetTwistyRect(aRow, currCol, imageRect, twistyRect, presContext,
*rc, twistyContext);
rc, twistyContext);
if (NS_LITERAL_CSTRING("twisty").Equals(aElement)) {
// If we're looking for the twisty Rect, just return the size
@ -1269,7 +1269,7 @@ nsTreeBodyFrame::GetCoordsForCellItem(int32_t aRow, nsITreeColumn* aCol, const n
GetBorderPadding(textContext, bp);
textRect.height += bp.top + bp.bottom;
AdjustForCellText(cellText, aRow, currCol, *rc, *fm, textRect);
AdjustForCellText(cellText, aRow, currCol, rc, *fm, textRect);
theRect = textRect;
}
@ -1515,8 +1515,8 @@ nsTreeBodyFrame::GetItemWithinCellAt(nscoord aX, const nsRect& aCellRect,
bool isRTL = StyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL;
nsPresContext* presContext = PresContext();
nsRefPtr<nsRenderingContext> rc =
presContext->PresShell()->CreateReferenceRenderingContext();
nsRenderingContext rc(
presContext->PresShell()->CreateReferenceRenderingContext());
if (aColumn->IsPrimary()) {
// If we're the primary column, we have indentation and a twisty.
@ -1550,7 +1550,7 @@ nsTreeBodyFrame::GetItemWithinCellAt(nscoord aX, const nsRect& aCellRect,
nsRect imageSize;
GetTwistyRect(aRowIndex, aColumn, imageSize, twistyRect, presContext,
*rc, twistyContext);
rc, twistyContext);
// We will treat a click as hitting the twisty if it happens on the margins, borders, padding,
// or content of the twisty object. By allowing a "slop" into the margin, we make it a little
@ -1618,7 +1618,7 @@ nsTreeBodyFrame::GetItemWithinCellAt(nscoord aX, const nsRect& aCellRect,
nsRefPtr<nsFontMetrics> fm;
nsLayoutUtils::GetFontMetricsForStyleContext(textContext,
getter_AddRefs(fm));
AdjustForCellText(cellText, aRowIndex, aColumn, *rc, *fm, textRect);
AdjustForCellText(cellText, aRowIndex, aColumn, rc, *fm, textRect);
if (aX >= textRect.x && aX < textRect.x + textRect.width)
return nsCSSAnonBoxes::moztreecelltext;
@ -1764,10 +1764,10 @@ nsTreeBodyFrame::IsCellCropped(int32_t aRow, nsITreeColumn* aCol, bool *_retval)
if (!col)
return NS_ERROR_INVALID_ARG;
nsRefPtr<nsRenderingContext> rc =
PresContext()->PresShell()->CreateReferenceRenderingContext();
nsRenderingContext rc(
PresContext()->PresShell()->CreateReferenceRenderingContext());
rv = GetCellWidth(aRow, col, rc, desiredSize, currentSize);
rv = GetCellWidth(aRow, col, &rc, desiredSize, currentSize);
NS_ENSURE_SUCCESS(rv, rv);
*_retval = desiredSize > currentSize;