This commit is contained in:
michaelp%netscape.com 1998-11-14 01:58:34 +00:00
Родитель f186598ef5
Коммит d7d8293d07
12 изменённых файлов: 287 добавлений и 90 удалений

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

@ -354,6 +354,11 @@ public:
* @return error status
*/
NS_IMETHOD EnableRefresh(void) = 0;
//XXX this needs to take parameters to tell
//it what part of the document to display, not just the
//whole thing. MMP
NS_IMETHOD Display(void) = 0;
};
//when the refresh happens, should it be double buffered?

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

@ -332,7 +332,15 @@ NS_IMETHODIMP nsView :: Paint(nsIRenderingContext& rc, const nsRect& rect,
kid->GetWidget(widget);
hasWidget = (widget != nsnull);
NS_IF_RELEASE(widget);
if (nsnull != widget)
{
void *thing;
thing = widget->GetNativeData(NS_NATIVE_WIDGET);
NS_RELEASE(widget);
if (nsnull == thing)
hasWidget = PR_FALSE;
}
if (!hasWidget)
{
nsRect kidRect;
@ -1138,6 +1146,12 @@ NS_IMETHODIMP nsView :: CreateWidget(const nsIID &aWindowIID,
trect *= scale;
if (NS_OK == LoadWidget(aWindowIID))
{
PRBool usewidgets;
dx->SupportsNativeWidgets(usewidgets);
if (PR_TRUE == usewidgets)
{
if (aNative)
mWindow->Create(aNative, trect, ::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
@ -1149,6 +1163,7 @@ NS_IMETHODIMP nsView :: CreateWidget(const nsIID &aWindowIID,
NS_IF_RELEASE(parent);
}
}
}
//make sure visibility state is accurate

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

@ -517,8 +517,10 @@ NS_IMETHODIMP nsViewManager :: UpdateView(nsIView *aView, const nsRect &aRect, P
// Get the parent view
widgetView->GetParent(widgetView);
} while (nsnull != widgetView);
NS_ASSERTION(nsnull != widgetView, "no widget");
// NS_ASSERTION(nsnull != widgetView, "no widget"); this assertion not valid for printing...MMP
if (nsnull != widgetView)
{
// Convert damage rect to coordinate space of containing view with
// a widget
// XXX Consolidate this code with the code above...
@ -554,6 +556,7 @@ NS_IMETHODIMP nsViewManager :: UpdateView(nsIView *aView, const nsRect &aRect, P
if (deltams > (1000 / (PRInt32)mFrameRate))
Composite();
}
}
return NS_OK;
}
@ -1311,3 +1314,40 @@ NS_IMETHODIMP nsViewManager :: EnableRefresh(void)
return NS_OK;
}
NS_IMETHODIMP nsViewManager :: Display(void)
{
nsRect wrect;
nsIRenderingContext *localcx = nsnull;
nsDrawingSurface ds = nsnull;
nsRect trect;
if (PR_FALSE == mRefreshEnabled)
return NS_OK;
NS_ASSERTION(!(PR_TRUE == mPainting), "recursive painting not permitted");
mPainting = PR_TRUE;
mContext->CreateRenderingContext(localcx);
//couldn't get rendering context. this is ok if at startup
if (nsnull == localcx)
{
return NS_ERROR_FAILURE;
}
mRootView->GetBounds(trect);
PRBool result;
localcx->SetClipRect(trect, nsClipCombine_kReplace, result);
// Paint the view. The clipping rect was set above set don't clip again.
mRootView->Paint(*localcx, trect, NS_VIEW_FLAG_CLIP_SET, result);
NS_RELEASE(localcx);
mPainting = PR_FALSE;
return NS_OK;
}

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

@ -110,6 +110,8 @@ public:
nsDrawingSurface GetDrawingSurface(nsIRenderingContext &aContext, nsRect& aBounds);
NS_IMETHOD Display(void);
private:
virtual ~nsViewManager();
nsIRenderingContext *CreateRenderingContext(nsIView &aView);

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

@ -68,6 +68,8 @@ public:
virtual void Show() = 0;
virtual void Hide() = 0;
NS_IMETHOD Print(void) = 0;
};
#endif /* nsIContentViewer_h___ */

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

@ -29,6 +29,7 @@
#include "nsIPresShell.h"
#include "nsIStyleSet.h"
#include "nsIStyleSheet.h"
#include "nsIFrame.h"
#include "nsIScriptContextOwner.h"
#include "nsIScriptGlobalObject.h"
@ -37,10 +38,15 @@
#include "nsViewsCID.h"
#include "nsWidgetsCID.h"
#include "nsGfxCIID.h"
#include "nsIDeviceContext.h"
#include "nsIDeviceContextSpec.h"
#include "nsIDeviceContextSpecFactory.h"
#include "nsIViewManager.h"
#include "nsIView.h"
#include "nsIPref.h"
#include "nsIURL.h"
class DocumentViewerImpl : public nsIDocumentViewer
@ -74,6 +80,7 @@ public:
virtual void Move(PRInt32 aX, PRInt32 aY);
virtual void Show();
virtual void Hide();
NS_IMETHOD Print(void);
// nsIDocumentViewer interface...
@ -108,7 +115,6 @@ protected:
nsIPresContext* mPresContext;
nsIPresShell* mPresShell;
nsIStyleSheet* mUAStyleSheet;
};
//Class IDs
@ -434,6 +440,102 @@ void DocumentViewerImpl::Hide()
}
static NS_DEFINE_IID(kIDeviceContextSpecFactoryIID, NS_IDEVICE_CONTEXT_SPEC_FACTORY_IID);
static NS_DEFINE_IID(kDeviceContextSpecFactoryCID, NS_DEVICE_CONTEXT_SPEC_FACTORY_CID);
NS_IMETHODIMP DocumentViewerImpl :: Print(void)
{
nsIDeviceContextSpecFactory *factory = nsnull;
nsRepository::CreateInstance(kDeviceContextSpecFactoryCID, nsnull,
kIDeviceContextSpecFactoryIID, (void **)&factory);
if (nsnull != factory)
{
nsIDeviceContextSpec *devspec = nsnull;
nsIDeviceContext *dx = nsnull;
nsIDeviceContext *newdx = nsnull;
factory->CreateDeviceContextSpec(nsnull, devspec, PR_FALSE);
dx = mPresContext->GetDeviceContext();
if (NS_OK == dx->GetDeviceContextFor(devspec, newdx))
{
nsIPresShell *ps;
nsIPresContext *cx;
nsIStyleSet *ss;
nsIPref *prefs;
nsIViewManager *vm;
PRInt32 width, height;
nsIView *view;
NS_RELEASE(devspec);
newdx->GetDeviceSurfaceDimensions(width, height);
NS_NewGalleyContext(&cx);
mPresContext->GetPrefs(prefs);
cx->Init(newdx, prefs);
CreateStyleSet(mDocument, &ss);
NS_NewPresShell(&ps);
{
nsresult rv;
rv = nsRepository::CreateInstance(kViewManagerCID,
nsnull,
kIViewManagerIID,
(void **)&vm);
if ((NS_OK != rv) || (NS_OK != vm->Init(newdx))) {
NS_ASSERTION(PR_FALSE, "can't get good VM");
}
nsRect tbounds = nsRect(0, 0, width, height);
// Create a child window of the parent that is our "root view/window"
// Create a view
rv = nsRepository::CreateInstance(kViewCID,
nsnull,
kIViewIID,
(void **)&view);
if ((NS_OK != rv) || (NS_OK != view->Init(vm,
tbounds,
nsnull))) {
NS_ASSERTION(PR_FALSE, "can't get good view");
}
// Setup hierarchical relationship in view manager
vm->SetRootView(view);
}
ps->Init(mDocument, cx, vm, ss);
//lay it out...
ps->InitialReflow(width, height);
newdx->BeginDocument();
newdx->BeginPage();
vm->Display();
newdx->EndPage();
newdx->EndDocument();
NS_RELEASE(ps);
NS_RELEASE(vm);
NS_RELEASE(ss);
NS_RELEASE(newdx);
NS_RELEASE(prefs);
}
NS_RELEASE(dx);
NS_RELEASE(factory);
}
return NS_OK;
}
void DocumentViewerImpl::ForceRefresh()
{

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

@ -134,6 +134,7 @@ public:
virtual void Move(PRInt32 aX, PRInt32 aY);
virtual void Show();
virtual void Hide();
NS_IMETHOD Print(void);
~PluginViewerImpl();
@ -430,6 +431,11 @@ PluginViewerImpl::Hide()
}
}
NS_IMETHODIMP PluginViewerImpl :: Print(void)
{
return NS_OK;
}
void
PluginViewerImpl::ForceRefresh()
{

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

@ -444,6 +444,10 @@ nsBrowserWindow::DispatchMenuItem(PRInt32 aID)
case VIEWER_THREE_COLUMN:
ShowPrintPreview(aID);
break;
case VIEWER_PRINT:
DoPrint();
break;
}
return nsEventStatus_eIgnore;
@ -1908,6 +1912,19 @@ nsBrowserWindow::ShowPrintPreview(PRInt32 aID)
}
}
void nsBrowserWindow::DoPrint(void)
{
nsIContentViewer *viewer = nsnull;
mWebShell->GetContentViewer(viewer);
if (nsnull != viewer)
{
viewer->Print();
NS_RELEASE(viewer);
}
}
//----------------------------------------------------------------------
void

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

@ -138,6 +138,7 @@ public:
NS_IMETHOD ForceRefresh();
void ShowPrintPreview(PRInt32 aID);
void DoPrint(void);
#ifdef NS_DEBUG
void DumpContent(FILE *out = stdout);

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

@ -97,6 +97,8 @@ static NS_DEFINE_IID(kCFontMetricsIID, NS_FONT_METRICS_CID);
static NS_DEFINE_IID(kCImageIID, NS_IMAGE_CID);
static NS_DEFINE_IID(kCRegionIID, NS_REGION_CID);
static NS_DEFINE_IID(kCBlenderIID, NS_BLENDER_CID);
static NS_DEFINE_IID(kCDeviceContextSpecCID, NS_DEVICE_CONTEXT_SPEC_CID);
static NS_DEFINE_IID(kCDeviceContextSpecFactoryCID, NS_DEVICE_CONTEXT_SPEC_FACTORY_CID);
static NS_DEFINE_IID(kCViewManagerCID, NS_VIEW_MANAGER_CID);
static NS_DEFINE_IID(kCViewCID, NS_VIEW_CID);
static NS_DEFINE_IID(kCScrollingViewCID, NS_SCROLLING_VIEW_CID);
@ -140,6 +142,8 @@ NS_SetupRegistry()
nsRepository::RegisterFactory(kCImageIID, GFXWIN_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCRegionIID, GFXWIN_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCBlenderIID, GFXWIN_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCDeviceContextSpecCID, GFXWIN_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCDeviceContextSpecFactoryCID, GFXWIN_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCViewManagerCID, VIEW_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCViewCID, VIEW_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCScrollingViewCID, VIEW_DLL, PR_FALSE, PR_FALSE);

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

@ -63,6 +63,8 @@
#define VIEWER_TWO_COLUMN 40041
#define VIEWER_THREE_COLUMN 40042
#define VIEWER_PRINT 40050
#define JS_CONSOLE 40100
#define EDITOR_MODE 40120
#define VIEWER_PREFS 40130

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

@ -48,6 +48,7 @@ VIEWER MENU DISCARDABLE
MENUITEM "Two Column", VIEWER_TWO_COLUMN
MENUITEM "Three Column", VIEWER_THREE_COLUMN
}
MENUITEM "Print", VIEWER_PRINT
MENUITEM "&Exit", VIEWER_EXIT
}
POPUP "&Edit"