From d26ba47d29a4898e561a6c58fb207cea86f11056 Mon Sep 17 00:00:00 2001 From: "tbogard%aol.net" Date: Mon, 1 Nov 1999 04:02:24 +0000 Subject: [PATCH] Implemented GetZoom and SetZoom. Removed some left over comment code. --- docshell/base/nsDocShellBase.cpp | 83 ++++++++++---------------------- 1 file changed, 26 insertions(+), 57 deletions(-) diff --git a/docshell/base/nsDocShellBase.cpp b/docshell/base/nsDocShellBase.cpp index 073052a6cd1..3e56d65a41e 100644 --- a/docshell/base/nsDocShellBase.cpp +++ b/docshell/base/nsDocShellBase.cpp @@ -23,6 +23,7 @@ #include "nsIDocument.h" #include "nsIDOMDocument.h" #include "nsIDocumentViewer.h" +#include "nsIDeviceContext.h" #include "nsDocShellBase.h" @@ -212,21 +213,36 @@ NS_IMETHODIMP nsDocShellBase::GetRootDocShell(nsIDocShell** aRootDocShell) NS_IMETHODIMP nsDocShellBase::GetZoom(float* zoom) { NS_ENSURE_ARG_POINTER(zoom); + NS_ENSURE_STATE(mContentViewer); - //XXX First Check - /** - * Set/Get the document scale factor - */ - return NS_ERROR_FAILURE; + nsCOMPtr presContext; + NS_ENSURE_SUCCESS(GetPresContext(getter_AddRefs(presContext)), + NS_ERROR_FAILURE); + + nsCOMPtr deviceContext; + NS_ENSURE_SUCCESS(presContext->GetDeviceContext(getter_AddRefs(deviceContext)), + NS_ERROR_FAILURE); + + NS_ENSURE_SUCCESS(deviceContext->GetZoom(*zoom), NS_ERROR_FAILURE); + + return NS_OK; } NS_IMETHODIMP nsDocShellBase::SetZoom(float zoom) { - //XXX First Check - /** - * Set/Get the document scale factor - */ - return NS_ERROR_FAILURE; + NS_ENSURE_STATE(mContentViewer); + + nsCOMPtr presContext; + NS_ENSURE_SUCCESS(GetPresContext(getter_AddRefs(presContext)), + NS_ERROR_FAILURE); + + nsCOMPtr deviceContext; + NS_ENSURE_SUCCESS(presContext->GetDeviceContext(getter_AddRefs(deviceContext)), + NS_ERROR_FAILURE); + + NS_ENSURE_SUCCESS(deviceContext->SetZoom(zoom), NS_ERROR_FAILURE); + + return NS_OK; } //***************************************************************************** @@ -1037,50 +1053,3 @@ nsresult nsDocShellBase::GetPresShell(nsIPresShell** aPresShell) return NS_OK; } - -/* - -// null result aPresContext is legal -NS_IMETHODIMP nsDocShellBase::GetPresContext(nsIPresContext** aPresContext) -{ - NS_ENSURE_ARG_POINTER(aPresContext); - - nsCOMPtr cv; - NS_ENSURE_SUCCESS(GetContentViewer(getter_AddRefs(cv))); - // null content viewer is legal - - if (cv) - { - nsIDocumentViewer* docv = nsnull; - cv->QueryInterface(kIDocumentViewerIID, (void**) &docv); - if (docv) - { - nsIPresContext* cx; - NS_ENSURE_SUCCESS(docv->GetPresContext(aPresContext)); - } - } - - return NS_OK; -} - - -NS_IMETHODIMP nsDocShellBase::GetDocument(nsIDOMDocument** aDocument) -{ - NS_ENSURE_ARG_POINTER(aDocument); - - nsCOMPtr presShell; - NS_ENSURE_SUCCESS(GetPresShell(getter_AddRefs(presShell))); - NS_ENSURE(presShell, NS_ERROR_FAILURE); - - nsCOMPtrdoc; - NS_ENSURE_SUCCESS(PresShell->GetDocument(getter_AddRefs(doc)), NS_ERROR_FAILURE); - NS_ENSURE(doc, NS_ERROR_NULL_POINTER); - - // the result's addref comes from this QueryInterface call - NS_ENSURE_SUCCESS(CallQueryInterface(doc, aDocument), NS_ERROR_FAILURE); - - return NS_OK; -} - - - */ \ No newline at end of file