we're like almost building n stuff!

git-svn-id: svn://10.0.0.236/branches/GFX2_20001016_BRANCH@82372 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
pavlov%netscape.com
2000-11-07 04:35:59 +00:00
parent e2b93fb611
commit c2bf0dbf0b
9 changed files with 73 additions and 122 deletions

View File

@@ -40,13 +40,16 @@
#include "nsIDOMWindowInternal.h"
#include "nsIWebBrowserChrome.h"
#include "nsPoint.h"
#include "nsGfxCIID.h"
#include "nsIPrompt.h"
#include "nsTextFormatter.h"
#include "nsIHTTPEventSink.h"
#include "nsISecurityEventSink.h"
#include "nsScriptSecurityManager.h"
#include "nsIOutputDevice.h"
#include "nsIWindow.h"
// Local Includes
#include "nsDocShell.h"
#include "nsDocShellLoadInfo.h"
@@ -87,7 +90,6 @@
#include "nsIDOMXULDocument.h"
#include "nsIDOMXULCommandDispatcher.h"
static NS_DEFINE_IID(kDeviceContextCID, NS_DEVICE_CONTEXT_CID);
static NS_DEFINE_CID(kPlatformCharsetCID, NS_PLATFORMCHARSET_CID);
static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID);
static NS_DEFINE_CID(kSimpleURICID, NS_SIMPLEURI_CID);
@@ -713,17 +715,15 @@ NS_IMETHODIMP nsDocShell::SetViewMode(PRInt32 aViewMode)
NS_IMETHODIMP nsDocShell::GetZoom(float* zoom)
{
NS_ENSURE_ARG_POINTER(zoom);
NS_ENSURE_SUCCESS(EnsureDeviceContext(), NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(mDeviceContext->GetZoom(*zoom), NS_ERROR_FAILURE);
// XXX pav
return NS_OK;
}
NS_IMETHODIMP nsDocShell::SetZoom(float zoom)
{
NS_ENSURE_SUCCESS(EnsureDeviceContext(), NS_ERROR_FAILURE);
mDeviceContext->SetZoom(zoom);
// XXX pav
// get the pres shell
nsCOMPtr<nsIPresShell> presShell;
@@ -750,7 +750,7 @@ NS_IMETHODIMP nsDocShell::SetZoom(float zoom)
return NS_OK;
}
NS_IMETHODIMP nsDocShell::GetMarginWidth(PRInt32* aWidth)
NS_IMETHODIMP nsDocShell::GetMarginWidth(gfx_dimension* aWidth)
{
NS_ENSURE_ARG_POINTER(aWidth);
@@ -758,13 +758,13 @@ NS_IMETHODIMP nsDocShell::GetMarginWidth(PRInt32* aWidth)
return NS_OK;
}
NS_IMETHODIMP nsDocShell::SetMarginWidth(PRInt32 aWidth)
NS_IMETHODIMP nsDocShell::SetMarginWidth(gfx_dimension aWidth)
{
mMarginWidth = aWidth;
return NS_OK;
}
NS_IMETHODIMP nsDocShell::GetMarginHeight(PRInt32* aHeight)
NS_IMETHODIMP nsDocShell::GetMarginHeight(gfx_dimension* aHeight)
{
NS_ENSURE_ARG_POINTER(aHeight);
@@ -772,7 +772,7 @@ NS_IMETHODIMP nsDocShell::GetMarginHeight(PRInt32* aHeight)
return NS_OK;
}
NS_IMETHODIMP nsDocShell::SetMarginHeight(PRInt32 aHeight)
NS_IMETHODIMP nsDocShell::SetMarginHeight(gfx_dimension aHeight)
{
mMarginHeight = aHeight;
return NS_OK;
@@ -1631,8 +1631,8 @@ NS_IMETHODIMP nsDocShell::GetSessionHistory(nsISHistory** aSessionHistory)
// nsDocShell::nsIBaseWindow
//*****************************************************************************
NS_IMETHODIMP nsDocShell::InitWindow(nativeWindow parentNativeWindow,
nsIWidget* parentWidget, PRInt32 x, PRInt32 y, PRInt32 cx, PRInt32 cy)
NS_IMETHODIMP nsDocShell::InitWindow(void* parentNativeWindow,
nsIWindow* parentWidget, PRInt32 x, PRInt32 y, PRInt32 cx, PRInt32 cy)
{
NS_ENSURE_ARG(parentWidget); // DocShells must get a widget for a parent
@@ -1835,7 +1835,7 @@ NS_IMETHODIMP nsDocShell::Repaint(PRBool aForce)
return NS_OK;
}
NS_IMETHODIMP nsDocShell::GetParentWidget(nsIWidget** parentWidget)
NS_IMETHODIMP nsDocShell::GetParentWidget(nsIWindow** parentWidget)
{
NS_ENSURE_ARG_POINTER(parentWidget);
@@ -1845,7 +1845,7 @@ NS_IMETHODIMP nsDocShell::GetParentWidget(nsIWidget** parentWidget)
return NS_OK;
}
NS_IMETHODIMP nsDocShell::SetParentWidget(nsIWidget* aParentWidget)
NS_IMETHODIMP nsDocShell::SetParentWidget(nsIWindow* aParentWidget)
{
NS_ENSURE_STATE(!mContentViewer);
@@ -1854,23 +1854,6 @@ NS_IMETHODIMP nsDocShell::SetParentWidget(nsIWidget* aParentWidget)
return NS_OK;
}
NS_IMETHODIMP nsDocShell::GetParentNativeWindow(nativeWindow* parentNativeWindow)
{
NS_ENSURE_ARG_POINTER(parentNativeWindow);
if(mParentWidget)
*parentNativeWindow = mParentWidget->GetNativeData(NS_NATIVE_WIDGET);
else
*parentNativeWindow = nsnull;
return NS_OK;
}
NS_IMETHODIMP nsDocShell::SetParentNativeWindow(nativeWindow parentNativeWindow)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsDocShell::GetVisibility(PRBool* aVisibility)
{
NS_ENSURE_ARG_POINTER(aVisibility);
@@ -1918,7 +1901,7 @@ NS_IMETHODIMP nsDocShell::SetVisibility(PRBool aVisibility)
return NS_OK;
}
NS_IMETHODIMP nsDocShell::GetMainWidget(nsIWidget** aMainWidget)
NS_IMETHODIMP nsDocShell::GetMainWindow(nsIWindow** aMainWidget)
{
// We don't create our own widget, so simply return the parent one.
return GetParentWidget(aMainWidget);
@@ -1926,10 +1909,12 @@ NS_IMETHODIMP nsDocShell::GetMainWidget(nsIWidget** aMainWidget)
NS_IMETHODIMP nsDocShell::SetFocus()
{
nsCOMPtr<nsIWidget> mainWidget;
GetMainWidget(getter_AddRefs(mainWidget));
if(mainWidget)
mainWidget->SetFocus();
nsCOMPtr<nsIWindow> mainWidget;
GetMainWindow(getter_AddRefs(mainWidget));
if(mainWidget) {
// XXX pav
// mainWidget->SetFocus();
}
return NS_OK;
}
@@ -2163,8 +2148,8 @@ NS_IMETHODIMP nsDocShell::GetScrollRange(PRInt32 scrollOrientation,
return NS_ERROR_FAILURE;
}
PRInt32 cx;
PRInt32 cy;
gfx_coord cx;
gfx_coord cy;
NS_ENSURE_SUCCESS(scrollView->GetContainerSize(&cx, &cy), NS_ERROR_FAILURE);
*minPos = 0;
@@ -2449,11 +2434,11 @@ NS_IMETHODIMP nsDocShell::RefreshURI(nsIURI *aURI, PRInt32 aDelay, PRBool aRepea
NS_ERROR_FAILURE);
}
nsCOMPtr<nsITimer> timer = do_CreateInstance("@mozilla.org/timer;1");
nsCOMPtr<nsITimer> timer = do_CreateInstance("@mozilla.org/gfx.timer;2");
NS_ENSURE_TRUE(timer, NS_ERROR_FAILURE);
mRefreshURIList->AppendElement(timer); // owning timer ref
timer->Init(refreshTimer, aDelay);
timer->Init(refreshTimer, aDelay, nsITimer::NS_PRIORITY_NORMAL, nsITimer::NS_TYPE_ONE_SHOT);
return NS_OK;
}
@@ -2597,30 +2582,6 @@ NS_IMETHODIMP nsDocShell::EnsureContentViewer()
return CreateAboutBlankContentViewer();
}
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));
float dev2twip;
mDeviceContext->GetDevUnitsToTwips(dev2twip);
mDeviceContext->SetDevUnitsToAppUnits(dev2twip);
float twip2dev;
mDeviceContext->GetTwipsToDevUnits(twip2dev);
mDeviceContext->SetAppUnitsToDevUnits(twip2dev);
mDeviceContext->SetGamma(1.0f);
return NS_OK;
}
NS_IMETHODIMP nsDocShell::CreateAboutBlankContentViewer()
{
// XXX
@@ -2856,18 +2817,24 @@ NS_IMETHODIMP nsDocShell::SetupNewViewer(nsIContentViewer* aNewViewer)
mContentViewer = aNewViewer;
nsCOMPtr<nsIWidget> widget;
NS_ENSURE_SUCCESS(GetMainWidget(getter_AddRefs(widget)), NS_ERROR_FAILURE);
nsCOMPtr<nsIWindow> widget;
NS_ENSURE_SUCCESS(GetMainWindow(getter_AddRefs(widget)), NS_ERROR_FAILURE);
nsRect bounds(x, y, cx, cy);
NS_ENSURE_SUCCESS(EnsureDeviceContext(), NS_ERROR_FAILURE);
// XXX pav
nsCOMPtr<nsIOutputDevice> mOutputDevice;
if(NS_FAILED(mContentViewer->Init(widget,
mDeviceContext, bounds)))
{
mContentViewer = nsnull;
NS_ERROR("ContentViewer Initialization failed");
return NS_ERROR_FAILURE;
}
mOutputDevice,
bounds)))
{
mContentViewer = nsnull;
NS_ERROR("ContentViewer Initialization failed");
return NS_ERROR_FAILURE;
}
// XXX: It looks like the LayoutState gets restored again in Embed()
// right after the call to SetupNewViewer(...)
@@ -4429,7 +4396,7 @@ NS_INTERFACE_MAP_END_THREADSAFE
// nsRefreshTimer::nsITimerCallback
//*****************************************************************************
NS_IMETHODIMP_(void) nsRefreshTimer::Notify(nsITimer *aTimer)
NS_IMETHODIMP nsRefreshTimer::Notify(nsITimer *aTimer)
{
NS_ASSERTION(mDocShell, "DocShell is somehow null");
@@ -4446,5 +4413,7 @@ NS_IMETHODIMP_(void) nsRefreshTimer::Notify(nsITimer *aTimer)
* LoadURL(...) will cancel all refresh timers... This causes the Timer and
* its refreshData instance to be released...
*/
return NS_OK;
}

View File

@@ -1,4 +1,4 @@
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
@@ -36,7 +36,6 @@
#include "nsCDocShell.h"
#include "nsIDocShellTreeOwner.h"
#include "nsIContentViewerContainer.h"
#include "nsIDeviceContext.h"
#include "nsIDocumentLoader.h"
#include "nsIDocumentLoaderObserver.h"
@@ -51,6 +50,8 @@
#include "nsPoint.h" // mCurrent/mDefaultScrollbarPreferences
#include "nsString.h"
#include "nsIWindow.h"
#define SH_IN_FRAMES 1
// Interfaces Needed
@@ -106,7 +107,7 @@ public:
NS_DECL_ISUPPORTS
// nsITimerCallback interface
NS_IMETHOD_(void) Notify(nsITimer *timer);
NS_IMETHOD Notify(nsITimer *timer);
nsCOMPtr<nsIDocShell> mDocShell;
nsCOMPtr<nsIURI> mURI;
@@ -187,7 +188,6 @@ protected:
// Content Viewer Management
NS_IMETHOD EnsureContentViewer();
NS_IMETHOD EnsureDeviceContext();
NS_IMETHOD CreateAboutBlankContentViewer();
NS_IMETHOD CreateContentViewer(const char* aContentType,
nsIChannel* aOpenedChannel, nsIStreamListener** aContentHandler);
@@ -271,10 +271,9 @@ protected:
nsDocShellInitInfo* mInitInfo;
nsCOMPtr<nsIContentViewer> mContentViewer;
nsCOMPtr<nsIDocumentCharsetInfo> mDocumentCharsetInfo;
nsCOMPtr<nsIDeviceContext> mDeviceContext;
nsCOMPtr<nsIDocumentLoader>mDocLoader;
nsCOMPtr<nsIDocumentLoaderObserver> mDocLoaderObserver;
nsCOMPtr<nsIWidget> mParentWidget;
nsCOMPtr<nsIWindow> mParentWidget;
nsCOMPtr<nsIPref> mPrefs;
nsCOMPtr<nsIURI> mCurrentURI;
nsCOMPtr<nsIURI> mReferrerURI;

View File

@@ -150,18 +150,7 @@ interface nsIBaseWindow : nsISupports
On controls that don't support widgets, setting this will return a
NS_ERROR_NOT_IMPLEMENTED error.
*/
[noscript] attribute nsIWindow parentWidget;
/*
This is the native window parent of the control.
Setting this after Create() has been called may not be supported by some
implementations.
On controls that don't support setting nativeWindow parents, setting this
will return a NS_ERROR_NOT_IMPLEMENTED error.
*/
attribute nativeWindow parentNativeWindow;
attribute nsIWindow parentWidget;
/*
Attribute controls the visibility of the object behind this interface.
@@ -175,7 +164,7 @@ interface nsIBaseWindow : nsISupports
on the object, this may return the parent widget in which this object
lives if it has not had to create it's own widget.
*/
readonly attribute nsIWindow mainWidget;
readonly attribute nsIWindow mainWindow;
/**
* Give the window focus.

View File

@@ -22,6 +22,7 @@
*/
#include "nsISupports.idl"
#include "gfxtypes.idl"
#include "domstubs.idl"
#include "nsIURIContentListener.idl"
#include "nsIURI.idl"
@@ -167,11 +168,11 @@ interface nsIDocShell : nsISupports
/*
XXX Comment here!
*/
attribute long marginWidth;
attribute gfx_dimension marginWidth;
/*
XXX Comment here!
*/
attribute long marginHeight;
attribute gfx_dimension marginHeight;
};

View File

@@ -59,8 +59,6 @@ typedef unsigned long HMTX;
#include "nsCRT.h"
#include "nsVoidArray.h"
#include "nsString.h"
#include "nsWidgetsCID.h"
#include "nsGfxCIID.h"
#include "plevent.h"
#include "prprf.h"
#include "nsIPluginHost.h"
@@ -194,7 +192,6 @@ nsWebShell::~nsWebShell()
NS_IF_RELEASE(mThreadEventQueue);
mContentViewer=nsnull;
mDeviceContext=nsnull;
NS_IF_RELEASE(mContainer);
if (mScriptGlobal) {

View File

@@ -1411,17 +1411,16 @@ NS_IMETHODIMP GlobalWindowImpl::GetScrollX(PRInt32* aScrollX)
NS_ENSURE_ARG_POINTER(aScrollX);
nsresult result = NS_OK;
nsIScrollableView *view; // no addref/release for views
float p2t, t2p;
*aScrollX = 0;
FlushPendingNotifications();
GetScrollInfo(&view, &p2t, &t2p);
GetScrollInfo(&view);
if (view) {
gfx_coord xPos, yPos;
result = view->GetScrollPosition(xPos, yPos);
*aScrollX = xPos; // pixels
*aScrollX = GFXCoordToIntRound(xPos); // pixels
}
return result;
@@ -1432,17 +1431,16 @@ NS_IMETHODIMP GlobalWindowImpl::GetScrollY(PRInt32* aScrollY)
NS_ENSURE_ARG_POINTER(aScrollY);
nsresult result = NS_OK;
nsIScrollableView *view; // no addref/release for views
float p2t, t2p;
*aScrollY = 0;
FlushPendingNotifications();
GetScrollInfo(&view, &p2t, &t2p);
GetScrollInfo(&view);
if (view) {
gfx_coord xPos, yPos;
result = view->GetScrollPosition(xPos, yPos);
*aScrollY = yPos; // pixels
*aScrollY = GFXCoordToIntRound(yPos); // pixels
}
return result;
@@ -1804,9 +1802,8 @@ NS_IMETHODIMP GlobalWindowImpl::ScrollTo(PRInt32 aXScroll, PRInt32 aYScroll)
{
nsresult result;
nsIScrollableView *view; // no addref/release for views
float p2t, t2p;
result = GetScrollInfo(&view, &p2t, &t2p);
result = GetScrollInfo(&view);
if (view) {
result = view->ScrollTo(aXScroll,
@@ -1822,9 +1819,8 @@ NS_IMETHODIMP GlobalWindowImpl::ScrollBy(PRInt32 aXScrollDif,
{
nsresult result;
nsIScrollableView *view; // no addref/release for views
float p2t, t2p;
result = GetScrollInfo(&view, &p2t, &t2p);
result = GetScrollInfo(&view);
if (view) {
gfx_coord xPos, yPos;
@@ -1843,9 +1839,8 @@ NS_IMETHODIMP GlobalWindowImpl::ScrollByLines(PRInt32 numLines)
{
nsresult result;
nsIScrollableView *view = nsnull; // no addref/release for views
float p2t, t2p;
result = GetScrollInfo(&view, &p2t, &t2p);
result = GetScrollInfo(&view);
if (view)
{
result = view->ScrollByLines(0, numLines);
@@ -1858,9 +1853,8 @@ NS_IMETHODIMP GlobalWindowImpl::ScrollByPages(PRInt32 numPages)
{
nsresult result;
nsIScrollableView *view = nsnull; // no addref/release for views
float p2t, t2p;
result = GetScrollInfo(&view, &p2t, &t2p);
result = GetScrollInfo(&view);
if (view)
{
result = view->ScrollByPages(numPages);
@@ -2012,7 +2006,7 @@ NS_IMETHODIMP GlobalWindowImpl::SetCursor(const nsAReadableString& aCursor)
NS_ENSURE_TRUE(rootView, NS_ERROR_FAILURE);
nsCOMPtr<nsIWindow> window;
rootView->GetWidget(*getter_AddRefs(window));
rootView->GetWidget(getter_AddRefs(window));
NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
// Call esm and set cursor.
@@ -2728,7 +2722,7 @@ NS_IMETHODIMP GlobalWindowImpl::Activate()
NS_ENSURE_TRUE(rootView, NS_ERROR_FAILURE);
nsCOMPtr<nsIWindow> window;
rootView->GetWidget(*getter_AddRefs(window));
rootView->GetWidget(getter_AddRefs(window));
NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
nsEventStatus status;
@@ -2767,7 +2761,7 @@ NS_IMETHODIMP GlobalWindowImpl::Deactivate()
NS_ENSURE_TRUE(rootView, NS_ERROR_FAILURE);
nsCOMPtr<nsIWindow> window;
rootView->GetWidget(*getter_AddRefs(window));
rootView->GetWidget(getter_AddRefs(window));
NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
nsEventStatus status;
@@ -4105,14 +4099,11 @@ GlobalWindowImpl::GetWebBrowserChrome(nsIWebBrowserChrome **aBrowserChrome)
}
NS_IMETHODIMP
GlobalWindowImpl::GetScrollInfo(nsIScrollableView **aScrollableView,
float *aP2T, float *aT2P)
GlobalWindowImpl::GetScrollInfo(nsIScrollableView **aScrollableView)
{
nsCOMPtr<nsIPresContext> presContext;
mDocShell->GetPresContext(getter_AddRefs(presContext));
if (presContext) {
presContext->GetPixelsToTwips(aP2T);
presContext->GetTwipsToPixels(aT2P);
nsCOMPtr<nsIPresShell> presShell;
presContext->GetShell(getter_AddRefs(presShell));

View File

@@ -213,8 +213,7 @@ protected:
NS_IMETHOD GetTreeOwner(nsIDocShellTreeOwner** aTreeOwner);
NS_IMETHOD GetTreeOwner(nsIBaseWindow** aTreeOwner);
NS_IMETHOD GetWebBrowserChrome(nsIWebBrowserChrome** aBrowserChrome);
NS_IMETHOD GetScrollInfo(nsIScrollableView** aScrollableView, float* aP2T,
float* aT2P);
NS_IMETHOD GetScrollInfo(nsIScrollableView** aScrollableView);
nsresult RegisterEventListener(const char* aEventName,
REFNSIID aIID);
void FlushPendingNotifications();

View File

@@ -81,7 +81,8 @@ NS_IMETHODIMP nsTopLevelWindow::Init(nsIWindow *aParent,
gfx_coord aX,
gfx_coord aY,
gfx_dimension aWidth,
gfx_dimension aHeight)
gfx_dimension aHeight,
PRInt32 aBorder)
{
mBounds.SetRect(aX, aY, aWidth, aHeight);
mDepth = 24; // this could be wrong :)

View File

@@ -38,6 +38,11 @@ typedef enum
nsImageType_kART = 6
} nsImageType;
#define NS_IMAGEMANAGER_CID \
{ 0x140d2dd1, 0x96f4, 0x11d3, \
{ 0x8a, 0xf3, 0x0, 0x10, 0x5a, 0x1b, 0x88, 0x60 } }
// IID for the nsIImageManager interface
#define NS_IIMAGEMANAGER_IID \
{ 0x9f327100, 0xad5a, 0x11d1, \