Bug 403565. Give each contentviewer it's own device context. r+sr=bzbarsky

This commit is contained in:
roc+%cs.cmu.edu 2008-01-21 02:05:39 +00:00
Родитель eaaf677338
Коммит 51e6a38964
4 изменённых файлов: 6 добавлений и 40 удалений

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

@ -3782,15 +3782,6 @@ nsDocShell::SetParentWidget(nsIWidget * aParentWidget)
{ {
mParentWidget = aParentWidget; mParentWidget = aParentWidget;
if (!mParentWidget) {
// If the parent widget is set to null we don't want to hold
// on to the current device context any more since it is
// associated with the parent widget we no longer own. We'll
// need to create a new device context if one is needed again.
mDeviceContext = nsnull;
}
return NS_OK; return NS_OK;
} }
@ -5112,24 +5103,6 @@ nsDocShell::EnsureContentViewer()
return rv; return rv;
} }
NS_IMETHODIMP
nsDocShell::EnsureDeviceContext()
{
if (mDeviceContext)
return NS_OK;
mDeviceContext = do_CreateInstance(kDeviceContextCID);
NS_ENSURE_TRUE(mDeviceContext, NS_ERROR_FAILURE);
nsCOMPtr<nsIWidget> widget;
GetMainWidget(getter_AddRefs(widget));
NS_ENSURE_TRUE(widget, NS_ERROR_FAILURE);
mDeviceContext->Init(widget->GetNativeData(NS_NATIVE_WIDGET));
return NS_OK;
}
nsresult nsresult
nsDocShell::CreateAboutBlankContentViewer(nsIPrincipal* aPrincipal) nsDocShell::CreateAboutBlankContentViewer(nsIPrincipal* aPrincipal)
{ {
@ -6272,13 +6245,16 @@ nsDocShell::SetupNewViewer(nsIContentViewer * aNewViewer)
nsCOMPtr<nsIWidget> widget; nsCOMPtr<nsIWidget> widget;
NS_ENSURE_SUCCESS(GetMainWidget(getter_AddRefs(widget)), NS_ERROR_FAILURE); NS_ENSURE_SUCCESS(GetMainWidget(getter_AddRefs(widget)), NS_ERROR_FAILURE);
nsCOMPtr<nsIDeviceContext> deviceContext;
if (widget) { if (widget) {
NS_ENSURE_SUCCESS(EnsureDeviceContext(), NS_ERROR_FAILURE); deviceContext = do_CreateInstance(kDeviceContextCID);
NS_ENSURE_TRUE(deviceContext, NS_ERROR_FAILURE);
deviceContext->Init(widget->GetNativeData(NS_NATIVE_WIDGET));
} }
nsRect bounds(x, y, cx, cy); nsRect bounds(x, y, cx, cy);
if (NS_FAILED(mContentViewer->Init(widget, mDeviceContext, bounds))) { if (NS_FAILED(mContentViewer->Init(widget, deviceContext, bounds))) {
mContentViewer = nsnull; mContentViewer = nsnull;
NS_ERROR("ContentViewer Initialization failed"); NS_ERROR("ContentViewer Initialization failed");
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;

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

@ -240,7 +240,6 @@ protected:
// Content Viewer Management // Content Viewer Management
NS_IMETHOD EnsureContentViewer(); NS_IMETHOD EnsureContentViewer();
NS_IMETHOD EnsureDeviceContext();
// aPrincipal can be passed in if the caller wants. If null is // aPrincipal can be passed in if the caller wants. If null is
// passed in, the about:blank principal will end up being used. // passed in, the about:blank principal will end up being used.
nsresult CreateAboutBlankContentViewer(nsIPrincipal* aPrincipal); nsresult CreateAboutBlankContentViewer(nsIPrincipal* aPrincipal);
@ -600,7 +599,6 @@ protected:
nsRect mBounds; // Dimensions of the docshell nsRect mBounds; // Dimensions of the docshell
nsCOMPtr<nsIContentViewer> mContentViewer; nsCOMPtr<nsIContentViewer> mContentViewer;
nsCOMPtr<nsIDocumentCharsetInfo> mDocumentCharsetInfo; nsCOMPtr<nsIDocumentCharsetInfo> mDocumentCharsetInfo;
nsCOMPtr<nsIDeviceContext> mDeviceContext;
nsCOMPtr<nsIWidget> mParentWidget; nsCOMPtr<nsIWidget> mParentWidget;
nsCOMPtr<nsIPrefBranch> mPrefs; nsCOMPtr<nsIPrefBranch> mPrefs;

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

@ -565,7 +565,6 @@ nsWebShell::~nsWebShell()
// recursively if the refcount is allowed to remain 0 // recursively if the refcount is allowed to remain 0
mContentViewer=nsnull; mContentViewer=nsnull;
mDeviceContext=nsnull;
InitFrameData(); InitFrameData();

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

@ -1505,10 +1505,7 @@ DocumentViewerImpl::Destroy()
mPreviousViewer = nsnull; mPreviousViewer = nsnull;
} }
if (mDeviceContext) { mDeviceContext = nsnull;
mDeviceContext->FlushFontCache();
mDeviceContext = nsnull;
}
if (mPresShell) { if (mPresShell) {
// Break circular reference (or something) // Break circular reference (or something)
@ -1959,10 +1956,6 @@ DocumentViewerImpl::Hide(void)
return NS_OK; return NS_OK;
} }
if (mDeviceContext) {
mDeviceContext->FlushFontCache();
}
// Break circular reference (or something) // Break circular reference (or something)
mPresShell->EndObservingDocument(); mPresShell->EndObservingDocument();
nsCOMPtr<nsISelection> selection; nsCOMPtr<nsISelection> selection;