mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 585817. Part 2: Change nsIPresShell::CreateRenderingContext to GetReferenceRenderingContext, that uses the shared 1x1 surface, and use it all over the place. r=mats,sr=dbaron
This commit is contained in:
parent
e2e4b00b49
commit
06241c1e45
@ -259,8 +259,7 @@ __try {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIRenderingContext> rc;
|
||||
presShell->CreateRenderingContext(frame, getter_AddRefs(rc));
|
||||
nsCOMPtr<nsIRenderingContext> rc = presShell->GetReferenceRenderingContext();
|
||||
if (!rc) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
@ -3264,8 +3264,8 @@ NS_IMETHODIMP DocumentViewerImpl::SizeToContent()
|
||||
|
||||
nscoord prefWidth;
|
||||
{
|
||||
nsCOMPtr<nsIRenderingContext> rcx;
|
||||
presShell->CreateRenderingContext(root, getter_AddRefs(rcx));
|
||||
nsCOMPtr<nsIRenderingContext> rcx =
|
||||
presShell->GetReferenceRenderingContext();
|
||||
NS_ENSURE_TRUE(rcx, NS_ERROR_FAILURE);
|
||||
prefWidth = root->GetPrefWidth(rcx);
|
||||
}
|
||||
|
@ -139,8 +139,8 @@ typedef struct CapturingContentInfo {
|
||||
} CapturingContentInfo;
|
||||
|
||||
#define NS_IPRESSHELL_IID \
|
||||
{ 0xe82aae32, 0x2d68, 0x452a, \
|
||||
{ 0x88, 0x95, 0x86, 0xc6, 0x07, 0xe1, 0xec, 0x91 } }
|
||||
{ 0xe63a350c, 0x4e04, 0x4056, \
|
||||
{ 0x8d, 0xa0, 0x51, 0xcc, 0x55, 0x68, 0x68, 0x42 } }
|
||||
|
||||
// Constants for ScrollContentIntoView() function
|
||||
#define NS_PRESSHELL_SCROLL_TOP 0
|
||||
@ -479,11 +479,11 @@ public:
|
||||
virtual NS_HIDDEN_(void) ClearFrameRefs(nsIFrame* aFrame) = 0;
|
||||
|
||||
/**
|
||||
* Given a frame, create a rendering context suitable for use with
|
||||
* the frame.
|
||||
* Get a reference rendering context. This is a context that should not
|
||||
* be rendered to, but is suitable for measuring text and performing
|
||||
* other non-rendering operations.
|
||||
*/
|
||||
virtual NS_HIDDEN_(nsresult) CreateRenderingContext(nsIFrame *aFrame,
|
||||
nsIRenderingContext** aContext) = 0;
|
||||
virtual already_AddRefed<nsIRenderingContext> GetReferenceRenderingContext() = 0;
|
||||
|
||||
/**
|
||||
* Informs the pres shell that the document is now at the anchor with
|
||||
|
@ -753,8 +753,7 @@ public:
|
||||
virtual NS_HIDDEN_(void) CancelReflowCallback(nsIReflowCallback* aCallback);
|
||||
|
||||
virtual NS_HIDDEN_(void) ClearFrameRefs(nsIFrame* aFrame);
|
||||
virtual NS_HIDDEN_(nsresult) CreateRenderingContext(nsIFrame *aFrame,
|
||||
nsIRenderingContext** aContext);
|
||||
virtual NS_HIDDEN_(already_AddRefed<nsIRenderingContext>) GetReferenceRenderingContext();
|
||||
virtual NS_HIDDEN_(nsresult) GoToAnchor(const nsAString& aAnchorName, PRBool aScroll);
|
||||
virtual NS_HIDDEN_(nsresult) ScrollToAnchor();
|
||||
|
||||
@ -3675,51 +3674,22 @@ PresShell::ClearFrameRefs(nsIFrame* aFrame)
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
PresShell::CreateRenderingContext(nsIFrame *aFrame,
|
||||
nsIRenderingContext** aResult)
|
||||
already_AddRefed<nsIRenderingContext>
|
||||
PresShell::GetReferenceRenderingContext()
|
||||
{
|
||||
NS_TIME_FUNCTION_MIN(1.0);
|
||||
|
||||
NS_PRECONDITION(nsnull != aResult, "null ptr");
|
||||
if (nsnull == aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
nsIWidget* widget = nsnull;
|
||||
nsPoint offset(0,0);
|
||||
nsIDeviceContext* devCtx = mPresContext->DeviceContext();
|
||||
nsRefPtr<nsIRenderingContext> rc;
|
||||
if (mPresContext->IsScreen()) {
|
||||
// Get the widget to create the rendering context for and calculate
|
||||
// the offset from the frame to it.
|
||||
nsPoint viewOffset;
|
||||
nsIView* view = aFrame->GetClosestView(&viewOffset);
|
||||
nsPoint widgetOffset;
|
||||
widget = view->GetNearestWidget(&widgetOffset);
|
||||
offset = viewOffset + widgetOffset;
|
||||
devCtx->CreateRenderingContextInstance(*getter_AddRefs(rc));
|
||||
if (rc) {
|
||||
rc->Init(devCtx, gfxPlatform::GetPlatform()->ScreenReferenceSurface());
|
||||
}
|
||||
} else {
|
||||
nsIFrame* pageFrame = nsLayoutUtils::GetPageFrame(aFrame);
|
||||
// This might not always come up with a frame, i.e. during reflow;
|
||||
// that's fine, because the translation doesn't matter during reflow.
|
||||
if (pageFrame)
|
||||
offset = aFrame->GetOffsetTo(pageFrame);
|
||||
devCtx->CreateRenderingContext(*getter_AddRefs(rc));
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
nsIRenderingContext* result = nsnull;
|
||||
nsIDeviceContext *deviceContext = mPresContext->DeviceContext();
|
||||
if (widget) {
|
||||
rv = deviceContext->CreateRenderingContext(widget, result);
|
||||
}
|
||||
else {
|
||||
rv = deviceContext->CreateRenderingContext(result);
|
||||
}
|
||||
*aResult = result;
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
result->Translate(offset.x, offset.y);
|
||||
}
|
||||
|
||||
return rv;
|
||||
return rc.forget();
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -7518,11 +7488,8 @@ PresShell::DoReflow(nsIFrame* target, PRBool aInterruptible)
|
||||
|
||||
nsIFrame* rootFrame = FrameManager()->GetRootFrame();
|
||||
|
||||
nsCOMPtr<nsIRenderingContext> rcx;
|
||||
// Always create the rendering context relative to the root frame during
|
||||
// reflow; otherwise, it crashes on the mac (I'm not quite sure why)
|
||||
nsresult rv = CreateRenderingContext(rootFrame, getter_AddRefs(rcx));
|
||||
if (NS_FAILED(rv)) {
|
||||
nsCOMPtr<nsIRenderingContext> rcx = GetReferenceRenderingContext();
|
||||
if (!rcx) {
|
||||
NS_NOTREACHED("CreateRenderingContext failure");
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
@ -607,9 +607,8 @@ nsSimplePageSequenceFrame::PrintNextPage()
|
||||
PR_PL(("SeqFr::PrintNextPage -> %p PageNo: %d", pf, mPageNum));
|
||||
|
||||
nsCOMPtr<nsIRenderingContext> renderingContext;
|
||||
PresContext()->PresShell()->
|
||||
CreateRenderingContext(mCurrentPageFrame,
|
||||
getter_AddRefs(renderingContext));
|
||||
dc->CreateRenderingContext(*getter_AddRefs(renderingContext));
|
||||
NS_ENSURE_TRUE(renderingContext, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
#if defined(XP_UNIX) && !defined(XP_MACOSX)
|
||||
// On linux, need to rotate landscape-mode output on printed surfaces
|
||||
|
@ -1493,9 +1493,8 @@ GetReferenceRenderingContext(nsTextFrame* aTextFrame, nsIRenderingContext* aRC)
|
||||
{
|
||||
nsCOMPtr<nsIRenderingContext> tmp = aRC;
|
||||
if (!tmp) {
|
||||
nsresult rv = aTextFrame->PresContext()->PresShell()->
|
||||
CreateRenderingContext(aTextFrame, getter_AddRefs(tmp));
|
||||
if (NS_FAILED(rv))
|
||||
tmp = aTextFrame->PresContext()->PresShell()->GetReferenceRenderingContext();
|
||||
if (!tmp)
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
|
@ -155,23 +155,26 @@ inFlasher::DrawElementOutline(nsIDOMElement* aElement)
|
||||
PRBool isFirstFrame = PR_TRUE;
|
||||
|
||||
while (frame) {
|
||||
nsPoint offset;
|
||||
nsIWidget* widget = frame->GetNearestWidget(offset);
|
||||
if (widget) {
|
||||
nsCOMPtr<nsIRenderingContext> rcontext;
|
||||
nsresult rv =
|
||||
presShell->CreateRenderingContext(frame, getter_AddRefs(rcontext));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsRect rect(nsPoint(0,0), frame->GetSize());
|
||||
frame->PresContext()->DeviceContext()->
|
||||
CreateRenderingContext(widget, *getter_AddRefs(rcontext));
|
||||
if (rcontext) {
|
||||
nsRect rect(offset, frame->GetSize());
|
||||
if (mInvert) {
|
||||
rcontext->InvertRect(rect);
|
||||
}
|
||||
|
||||
frame = frame->GetNextContinuation();
|
||||
|
||||
PRBool isLastFrame = (frame == nsnull);
|
||||
PRBool isLastFrame = frame->GetNextContinuation() == nsnull;
|
||||
DrawOutline(rect.x, rect.y, rect.width, rect.height, rcontext,
|
||||
isFirstFrame, isLastFrame);
|
||||
isFirstFrame = PR_FALSE;
|
||||
}
|
||||
}
|
||||
frame = frame->GetNextContinuation();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -569,10 +569,10 @@ nsSVGForeignObjectFrame::DoReflow()
|
||||
|
||||
// initiate a synchronous reflow here and now:
|
||||
nsSize availableSpace(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
|
||||
nsCOMPtr<nsIRenderingContext> renderingContext;
|
||||
nsIPresShell* presShell = presContext->PresShell();
|
||||
NS_ASSERTION(presShell, "null presShell");
|
||||
presShell->CreateRenderingContext(this,getter_AddRefs(renderingContext));
|
||||
nsCOMPtr<nsIRenderingContext> renderingContext =
|
||||
presShell->GetReferenceRenderingContext();
|
||||
if (!renderingContext)
|
||||
return;
|
||||
|
||||
|
@ -664,10 +664,9 @@ nsSplitterFrameInner::MouseDown(nsIDOMEvent* aMouseEvent)
|
||||
if (childIndex == childCount - 1 && GetResizeAfter() != Grow)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIRenderingContext> rc;
|
||||
nsresult rv = outerPresContext->PresShell()->
|
||||
CreateRenderingContext(mOuter, getter_AddRefs(rc));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIRenderingContext> rc =
|
||||
outerPresContext->PresShell()->GetReferenceRenderingContext();
|
||||
NS_ENSURE_TRUE(rc, NS_ERROR_FAILURE);
|
||||
nsBoxLayoutState state(outerPresContext, rc);
|
||||
mCurrentPos = 0;
|
||||
mPressed = PR_TRUE;
|
||||
|
@ -270,8 +270,10 @@ nsTreeBodyFrame::CalcMaxRowWidth()
|
||||
nscoord rowWidth;
|
||||
nsTreeColumn* col;
|
||||
|
||||
nsCOMPtr<nsIRenderingContext> rc;
|
||||
PresContext()->PresShell()->CreateRenderingContext(this, getter_AddRefs(rc));
|
||||
nsCOMPtr<nsIRenderingContext> rc =
|
||||
PresContext()->PresShell()->GetReferenceRenderingContext();
|
||||
if (!rc)
|
||||
return 0;
|
||||
|
||||
for (PRInt32 row = 0; row < mRowCount; ++row) {
|
||||
rowWidth = 0;
|
||||
@ -1173,8 +1175,10 @@ nsTreeBodyFrame::GetCoordsForCellItem(PRInt32 aRow, nsITreeColumn* aCol, const n
|
||||
// interfere with our computations.
|
||||
AdjustForBorderPadding(cellContext, cellRect);
|
||||
|
||||
nsCOMPtr<nsIRenderingContext> rc;
|
||||
presContext->PresShell()->CreateRenderingContext(this, getter_AddRefs(rc));
|
||||
nsCOMPtr<nsIRenderingContext> rc =
|
||||
presContext->PresShell()->GetReferenceRenderingContext();
|
||||
if (!rc)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
// 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
|
||||
@ -1521,6 +1525,12 @@ nsTreeBodyFrame::GetItemWithinCellAt(nscoord aX, const nsRect& aCellRect,
|
||||
// Handle right alignment hit testing.
|
||||
PRBool isRTL = GetStyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL;
|
||||
|
||||
nsPresContext* presContext = PresContext();
|
||||
nsCOMPtr<nsIRenderingContext> rc =
|
||||
presContext->PresShell()->GetReferenceRenderingContext();
|
||||
if (!rc)
|
||||
return nsCSSAnonBoxes::moztreecell;
|
||||
|
||||
if (aColumn->IsPrimary()) {
|
||||
// If we're the primary column, we have indentation and a twisty.
|
||||
PRInt32 level;
|
||||
@ -1548,10 +1558,6 @@ nsTreeBodyFrame::GetItemWithinCellAt(nscoord aX, const nsRect& aCellRect,
|
||||
hasTwisty = PR_TRUE;
|
||||
}
|
||||
|
||||
nsPresContext* presContext = PresContext();
|
||||
nsCOMPtr<nsIRenderingContext> rc;
|
||||
presContext->PresShell()->CreateRenderingContext(this, getter_AddRefs(rc));
|
||||
|
||||
// Resolve style for the twisty.
|
||||
nsStyleContext* twistyContext = GetPseudoStyleContext(nsCSSAnonBoxes::moztreetwisty);
|
||||
|
||||
@ -1622,12 +1628,9 @@ nsTreeBodyFrame::GetItemWithinCellAt(nscoord aX, const nsRect& aCellRect,
|
||||
|
||||
AdjustForBorderPadding(textContext, textRect);
|
||||
|
||||
nsCOMPtr<nsIRenderingContext> renderingContext;
|
||||
PresContext()->PresShell()->CreateRenderingContext(this, getter_AddRefs(renderingContext));
|
||||
nsLayoutUtils::SetFontFromStyle(rc, textContext);
|
||||
|
||||
nsLayoutUtils::SetFontFromStyle(renderingContext, textContext);
|
||||
|
||||
AdjustForCellText(cellText, aRowIndex, aColumn, *renderingContext, textRect);
|
||||
AdjustForCellText(cellText, aRowIndex, aColumn, *rc, textRect);
|
||||
if (isRTL)
|
||||
textRect.x = currX + remainingWidth - textRect.width;
|
||||
|
||||
@ -1775,10 +1778,9 @@ nsTreeBodyFrame::IsCellCropped(PRInt32 aRow, nsITreeColumn* aCol, PRBool *_retva
|
||||
if (!col)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
||||
nsCOMPtr<nsIRenderingContext> rc;
|
||||
rv = PresContext()->PresShell()->
|
||||
CreateRenderingContext(this, getter_AddRefs(rc));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIRenderingContext> rc =
|
||||
PresContext()->PresShell()->GetReferenceRenderingContext();
|
||||
NS_ENSURE_TRUE(rc, NS_ERROR_FAILURE);
|
||||
|
||||
rv = GetCellWidth(aRow, col, rc, desiredSize, currentSize);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
Loading…
Reference in New Issue
Block a user