зеркало из https://github.com/mozilla/gecko-dev.git
removed widget parameters from nsIView::Init(). added CreateWidget() and SetWidget()
APIs to replace this functionality. also added CreateScrollControls() to nsIScrollableView.
This commit is contained in:
Родитель
0d4d3ce5d5
Коммит
dff35cf838
|
@ -1190,12 +1190,19 @@ PresShell::VerifyIncrementalReflow()
|
|||
// tbounds *= mPresContext->GetPixelsToTwips();
|
||||
rv = nsRepository::CreateInstance(kScrollingViewCID, nsnull, kIViewIID,
|
||||
(void **) &view);
|
||||
if ((NS_OK != rv) || (NS_OK != view->Init(vm, tbounds, nsnull, &kWidgetCID,
|
||||
nsnull, nativeParentWidget))) {
|
||||
if ((NS_OK != rv) || (NS_OK != view->Init(vm, tbounds, nsnull))) {
|
||||
NS_ASSERTION(NS_OK == rv, "failed to create scroll view");
|
||||
}
|
||||
|
||||
//now create the widget for the view
|
||||
rv = view->CreateWidget(kWidgetCID, nsnull, nativeParentWidget);
|
||||
if (NS_OK != rv) {
|
||||
NS_ASSERTION(NS_OK == rv, "failed to create scroll view widget");
|
||||
}
|
||||
|
||||
rv = view->QueryInterface(kScrollViewIID, (void**)&scrollView);
|
||||
if (NS_OK == rv) {
|
||||
scrollView->CreateScrollControls(nativeParentWidget);
|
||||
scrollView->SetScrollPreference(scrolling);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -252,17 +252,22 @@ nsFormControlFrame::Reflow(nsIPresContext& aPresContext,
|
|||
const nsIID& id = GetCID();
|
||||
nsWidgetInitData* initData = GetWidgetInitData(aPresContext); // needs to be deleted
|
||||
// initialize the view as hidden since we don't know the (x,y) until Paint
|
||||
result = view->Init(viewMan, boundBox, parView, &id, initData,
|
||||
nsnull, nsnull, nsViewVisibility_kHide);
|
||||
if (nsnull != initData) {
|
||||
delete(initData);
|
||||
}
|
||||
result = view->Init(viewMan, boundBox, parView,
|
||||
nsnull, nsViewVisibility_kHide);
|
||||
if (NS_OK != result) {
|
||||
NS_ASSERTION(0, "widget initialization failed");
|
||||
aStatus = NS_FRAME_NOT_COMPLETE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
viewMan->InsertChild(parView, view, 0);
|
||||
|
||||
view->CreateWidget(id, initData);
|
||||
|
||||
if (nsnull != initData) {
|
||||
delete(initData);
|
||||
}
|
||||
|
||||
// set our widget
|
||||
result = GetWidget(view, &mWidget);
|
||||
if ((NS_OK == result) && mWidget) { // keep the ref on mWidget
|
||||
|
@ -279,7 +284,6 @@ nsFormControlFrame::Reflow(nsIPresContext& aPresContext,
|
|||
NS_ASSERTION(0, "could not get widget");
|
||||
}
|
||||
|
||||
viewMan->InsertChild(parView, view, 0);
|
||||
SetView(view);
|
||||
|
||||
if ((aDesiredSize.width != boundBox.width) || (aDesiredSize.height != boundBox.height)) {
|
||||
|
|
|
@ -691,8 +691,9 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext& aPresContext,
|
|||
|
||||
nsIViewManager* viewMan = presShell->GetViewManager();
|
||||
NS_RELEASE(presShell);
|
||||
rv = view->Init(viewMan, viewBounds, parView, &kCChildCID);
|
||||
rv = view->Init(viewMan, viewBounds, parView);
|
||||
viewMan->InsertChild(parView, view, 0);
|
||||
rv = view->CreateWidget(kCChildCID);
|
||||
NS_RELEASE(viewMan);
|
||||
SetView(view);
|
||||
|
||||
|
|
|
@ -244,11 +244,12 @@ nsObjectFrame::CreateWidget(nscoord aWidth, nscoord aHeight, PRBool aViewOnly)
|
|||
{
|
||||
// nsWidgetInitData* initData = GetWidgetInitData(*aPresContext); // needs to be deleted
|
||||
// initialize the view as hidden since we don't know the (x,y) until Paint
|
||||
result = view->Init(viewMan, boundBox, parView, &kWidgetCID, nsnull,
|
||||
nsnull, nsnull, nsViewVisibility_kHide);
|
||||
result = view->Init(viewMan, boundBox, parView, nsnull,
|
||||
nsViewVisibility_kHide);
|
||||
// if (nsnull != initData) {
|
||||
// delete(initData);
|
||||
// }
|
||||
|
||||
if (NS_OK != result) {
|
||||
result = NS_OK; //XXX why OK? MMP
|
||||
goto exit; //XXX sue me. MMP
|
||||
|
@ -268,6 +269,13 @@ nsObjectFrame::CreateWidget(nscoord aWidth, nscoord aHeight, PRBool aViewOnly)
|
|||
#endif
|
||||
|
||||
viewMan->InsertChild(parView, view, 0);
|
||||
|
||||
result = view->CreateWidget(kWidgetCID);
|
||||
|
||||
if (NS_OK != result) {
|
||||
result = NS_OK; //XXX why OK? MMP
|
||||
goto exit; //XXX sue me. MMP
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
|
|
|
@ -1073,8 +1073,7 @@ nsBodyFrame::CreateAbsoluteView(nsIStyleContext* aStyleContext) const
|
|||
|
||||
// Initialize the view with a size of (0, 0). When we're done reflowing
|
||||
// the frame the view will be sized and positioned
|
||||
view->Init(viewManager, nsRect(0, 0, 0, 0), containingView, nsnull,
|
||||
nsnull, nsnull, pClip);
|
||||
view->Init(viewManager, nsRect(0, 0, 0, 0), containingView, pClip);
|
||||
viewManager->InsertChild(containingView, view, zIndex);
|
||||
// If the background color is transparent then mark the view as having
|
||||
// transparent content.
|
||||
|
|
|
@ -244,11 +244,12 @@ nsObjectFrame::CreateWidget(nscoord aWidth, nscoord aHeight, PRBool aViewOnly)
|
|||
{
|
||||
// nsWidgetInitData* initData = GetWidgetInitData(*aPresContext); // needs to be deleted
|
||||
// initialize the view as hidden since we don't know the (x,y) until Paint
|
||||
result = view->Init(viewMan, boundBox, parView, &kWidgetCID, nsnull,
|
||||
nsnull, nsnull, nsViewVisibility_kHide);
|
||||
result = view->Init(viewMan, boundBox, parView, nsnull,
|
||||
nsViewVisibility_kHide);
|
||||
// if (nsnull != initData) {
|
||||
// delete(initData);
|
||||
// }
|
||||
|
||||
if (NS_OK != result) {
|
||||
result = NS_OK; //XXX why OK? MMP
|
||||
goto exit; //XXX sue me. MMP
|
||||
|
@ -268,6 +269,13 @@ nsObjectFrame::CreateWidget(nscoord aWidth, nscoord aHeight, PRBool aViewOnly)
|
|||
#endif
|
||||
|
||||
viewMan->InsertChild(parView, view, 0);
|
||||
|
||||
result = view->CreateWidget(kWidgetCID);
|
||||
|
||||
if (NS_OK != result) {
|
||||
result = NS_OK; //XXX why OK? MMP
|
||||
goto exit; //XXX sue me. MMP
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
|
|
|
@ -1190,12 +1190,19 @@ PresShell::VerifyIncrementalReflow()
|
|||
// tbounds *= mPresContext->GetPixelsToTwips();
|
||||
rv = nsRepository::CreateInstance(kScrollingViewCID, nsnull, kIViewIID,
|
||||
(void **) &view);
|
||||
if ((NS_OK != rv) || (NS_OK != view->Init(vm, tbounds, nsnull, &kWidgetCID,
|
||||
nsnull, nativeParentWidget))) {
|
||||
if ((NS_OK != rv) || (NS_OK != view->Init(vm, tbounds, nsnull))) {
|
||||
NS_ASSERTION(NS_OK == rv, "failed to create scroll view");
|
||||
}
|
||||
|
||||
//now create the widget for the view
|
||||
rv = view->CreateWidget(kWidgetCID, nsnull, nativeParentWidget);
|
||||
if (NS_OK != rv) {
|
||||
NS_ASSERTION(NS_OK == rv, "failed to create scroll view widget");
|
||||
}
|
||||
|
||||
rv = view->QueryInterface(kScrollViewIID, (void**)&scrollView);
|
||||
if (NS_OK == rv) {
|
||||
scrollView->CreateScrollControls(nativeParentWidget);
|
||||
scrollView->SetScrollPreference(scrolling);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -170,8 +170,7 @@ nsScrollFrame::CreateScrollingView()
|
|||
}
|
||||
|
||||
// Initialize the scrolling view
|
||||
view->Init(viewManager, mRect, parentView, nsnull, nsnull, nsnull,
|
||||
nsnull);
|
||||
view->Init(viewManager, mRect, parentView);
|
||||
|
||||
// Insert the view into the view hierarchy
|
||||
viewManager->InsertChild(parentView, view, zIndex);
|
||||
|
@ -189,6 +188,9 @@ nsScrollFrame::CreateScrollingView()
|
|||
nsIScrollableView* scrollingView;
|
||||
view->QueryInterface(kScrollViewIID, (void**)&scrollingView);
|
||||
|
||||
//create widgets for scrolling
|
||||
scrollingView->CreateScrollControls();
|
||||
|
||||
// Set the scroll prefrence
|
||||
nsScrollPreference scrollPref = (NS_STYLE_OVERFLOW_SCROLL == display->mOverflow)
|
||||
? nsScrollPreference_kAlwaysScroll :
|
||||
|
@ -211,8 +213,7 @@ nsScrollFrame::CreateScrollingView()
|
|||
mFirstChild->SetView(scrolledView);
|
||||
|
||||
// Initialize the view
|
||||
scrolledView->Init(viewManager, nsRect(0, 0, 0, 0), parentView, nsnull,
|
||||
nsnull, nsnull, nsnull);
|
||||
scrolledView->Init(viewManager, nsRect(0, 0, 0, 0), parentView);
|
||||
|
||||
// Set it as the scrolling view's scrolled view
|
||||
scrollingView->SetScrolledView(scrolledView);
|
||||
|
|
|
@ -691,8 +691,9 @@ nsHTMLFrameInnerFrame::CreateWebShell(nsIPresContext& aPresContext,
|
|||
|
||||
nsIViewManager* viewMan = presShell->GetViewManager();
|
||||
NS_RELEASE(presShell);
|
||||
rv = view->Init(viewMan, viewBounds, parView, &kCChildCID);
|
||||
rv = view->Init(viewMan, viewBounds, parView);
|
||||
viewMan->InsertChild(parView, view, 0);
|
||||
rv = view->CreateWidget(kCChildCID);
|
||||
NS_RELEASE(viewMan);
|
||||
SetView(view);
|
||||
|
||||
|
|
|
@ -252,17 +252,22 @@ nsFormControlFrame::Reflow(nsIPresContext& aPresContext,
|
|||
const nsIID& id = GetCID();
|
||||
nsWidgetInitData* initData = GetWidgetInitData(aPresContext); // needs to be deleted
|
||||
// initialize the view as hidden since we don't know the (x,y) until Paint
|
||||
result = view->Init(viewMan, boundBox, parView, &id, initData,
|
||||
nsnull, nsnull, nsViewVisibility_kHide);
|
||||
if (nsnull != initData) {
|
||||
delete(initData);
|
||||
}
|
||||
result = view->Init(viewMan, boundBox, parView,
|
||||
nsnull, nsViewVisibility_kHide);
|
||||
if (NS_OK != result) {
|
||||
NS_ASSERTION(0, "widget initialization failed");
|
||||
aStatus = NS_FRAME_NOT_COMPLETE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
viewMan->InsertChild(parView, view, 0);
|
||||
|
||||
view->CreateWidget(id, initData);
|
||||
|
||||
if (nsnull != initData) {
|
||||
delete(initData);
|
||||
}
|
||||
|
||||
// set our widget
|
||||
result = GetWidget(view, &mWidget);
|
||||
if ((NS_OK == result) && mWidget) { // keep the ref on mWidget
|
||||
|
@ -279,7 +284,6 @@ nsFormControlFrame::Reflow(nsIPresContext& aPresContext,
|
|||
NS_ASSERTION(0, "could not get widget");
|
||||
}
|
||||
|
||||
viewMan->InsertChild(parView, view, 0);
|
||||
SetView(view);
|
||||
|
||||
if ((aDesiredSize.width != boundBox.width) || (aDesiredSize.height != boundBox.height)) {
|
||||
|
|
|
@ -50,6 +50,14 @@ typedef enum
|
|||
class nsIScrollableView : public nsISupports
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Create the controls used to allow scrolling. Call this method
|
||||
* before anything else is done with the scrollable view.
|
||||
* @param aNative native widget to use as parent for control widgets
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD CreateScrollControls(nsNativeWidget aNative = nsnull) = 0;
|
||||
|
||||
/**
|
||||
* Compute the size of the scrolled container.
|
||||
*/
|
||||
|
|
|
@ -84,14 +84,6 @@ public:
|
|||
* @param aParent intended parent for view. this is not actually set in the
|
||||
* nsIView through this method. it is only used by the initialization
|
||||
* code to walk up the view tree, if necessary, to find resources.
|
||||
* @param aWindowIID IID for Widget type that this view
|
||||
* should have associated with it. if nsull, then no
|
||||
* width will be created for this view
|
||||
* @param aWidgetInitData data used to initialize this view's widget before
|
||||
* its create is called.
|
||||
* @param aNative native window that will be used as parent of
|
||||
* aWindowIID. if nsnull, then parent will be derived from
|
||||
* parent view and it's ancestors
|
||||
* @param aCilpRect initial clip rect of view
|
||||
* @param aVisibilityFlag initial visibility state of view
|
||||
* @result The result of the initialization, NS_OK if no errors
|
||||
|
@ -99,9 +91,6 @@ public:
|
|||
NS_IMETHOD Init(nsIViewManager* aManager,
|
||||
const nsRect &aBounds,
|
||||
const nsIView *aParent,
|
||||
const nsIID *aWindowIID = nsnull,
|
||||
nsWidgetInitData *aWidgetInitData = nsnull,
|
||||
nsNativeWidget aNative = nsnull,
|
||||
const nsViewClip *aClip = nsnull,
|
||||
nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow) = 0;
|
||||
|
||||
|
@ -123,14 +112,6 @@ public:
|
|||
*/
|
||||
NS_IMETHOD GetViewManager(nsIViewManager *&aViewMgr) = 0;
|
||||
|
||||
/**
|
||||
* In 4.0, the "cutout" nature of a view is queryable.
|
||||
* If we believe that all cutout view have a native widget, this
|
||||
* could be a replacement.
|
||||
* @result widget that this view contains
|
||||
*/
|
||||
NS_IMETHOD GetWidget(nsIWidget *&aWidget) = 0;
|
||||
|
||||
/**
|
||||
* Called to indicate that the specified rect of the view
|
||||
* needs to be drawn via the rendering context. The rect
|
||||
|
@ -396,6 +377,43 @@ public:
|
|||
*/
|
||||
NS_IMETHOD SetDirtyRegion(nsIRegion *aRegion) = 0;
|
||||
|
||||
/**
|
||||
* Create a widget to associate with this view. This is a helper
|
||||
* function for SetWidget.
|
||||
* @param aWindowIID IID for Widget type that this view
|
||||
* should have associated with it. if nsull, then no
|
||||
* width will be created for this view
|
||||
* @param aWidgetInitData data used to initialize this view's widget before
|
||||
* its create is called.
|
||||
* @param aNative native window that will be used as parent of
|
||||
* aWindowIID. if nsnull, then parent will be derived from
|
||||
* parent view and it's ancestors
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD CreateWidget(const nsIID &aWindowIID,
|
||||
nsWidgetInitData *aWidgetInitData = nsnull,
|
||||
nsNativeWidget aNative = nsnull) = 0;
|
||||
|
||||
/**
|
||||
* Set the widget associated with this view.
|
||||
* @param aWidget widget to associate with view. It is an error
|
||||
* to associate a widget with more than one view. To disassociate
|
||||
* a widget from a view, use nsnull. If there are no more references
|
||||
* to the widget that may have been associated with the view, it will
|
||||
* be destroyed.
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHOD SetWidget(nsIWidget *aWidget) = 0;
|
||||
|
||||
/**
|
||||
* In 4.0, the "cutout" nature of a view is queryable.
|
||||
* If we believe that all cutout view have a native widget, this
|
||||
* could be a replacement.
|
||||
* @param aWidget out parameter for widget that this view contains,
|
||||
* or nsnull if there is none.
|
||||
*/
|
||||
NS_IMETHOD GetWidget(nsIWidget *&aWidget) = 0;
|
||||
|
||||
/**
|
||||
* Output debug info to FILE
|
||||
* @param out output file handle
|
||||
|
|
|
@ -395,105 +395,6 @@ nsrefcnt nsScrollingView :: Release()
|
|||
return 1;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsScrollingView :: Init(nsIViewManager* aManager,
|
||||
const nsRect &aBounds,
|
||||
const nsIView *aParent,
|
||||
const nsIID *aWindowIID,
|
||||
nsWidgetInitData *aWidgetInitData,
|
||||
nsNativeWidget aNative,
|
||||
const nsViewClip *aClip,
|
||||
nsViewVisibility aVisibilityFlag)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
rv = nsView :: Init(aManager, aBounds, aParent, aWindowIID, aWidgetInitData,
|
||||
aNative, aClip, aVisibilityFlag);
|
||||
|
||||
if (rv == NS_OK)
|
||||
{
|
||||
nsIDeviceContext *dx;
|
||||
mViewManager->GetDeviceContext(dx);
|
||||
|
||||
// Create a clip view
|
||||
mClipView = new nsView;
|
||||
|
||||
if (nsnull != mClipView)
|
||||
{
|
||||
// The clip view needs a widget to clip any of the scrolled view's
|
||||
// child views with widgets. Note that the clip view has an opacity
|
||||
// of 0.0f (completely transparent)
|
||||
// XXX The clip widget should be created on demand only...
|
||||
rv = mClipView->Init(mViewManager, aBounds, this, &kWidgetCID, nsnull,
|
||||
mWindow ? nsnull : aNative, nsnull);
|
||||
mViewManager->InsertChild(this, mClipView, -1);
|
||||
mViewManager->SetViewOpacity(mClipView, 0.0f);
|
||||
}
|
||||
|
||||
// Create a view for a corner cover
|
||||
mCornerView = new CornerView;
|
||||
|
||||
if (nsnull != mCornerView)
|
||||
{
|
||||
nsRect trect;
|
||||
float sbWidth, sbHeight;
|
||||
|
||||
dx->GetScrollBarDimensions(sbWidth, sbHeight);
|
||||
trect.width = NSToCoordRound(sbWidth);
|
||||
trect.x = aBounds.x + aBounds.XMost() - trect.width;
|
||||
trect.height = NSToCoordRound(sbHeight);
|
||||
trect.y = aBounds.y + aBounds.YMost() - trect.height;
|
||||
|
||||
rv = mCornerView->Init(mViewManager, trect, this, nsnull, nsnull, nsnull,
|
||||
nsnull, nsViewVisibility_kHide);
|
||||
mViewManager->InsertChild(this, mCornerView, -1);
|
||||
}
|
||||
|
||||
// Create a view for a vertical scrollbar
|
||||
mVScrollBarView = new ScrollBarView(this);
|
||||
|
||||
if (nsnull != mVScrollBarView)
|
||||
{
|
||||
nsRect trect = aBounds;
|
||||
float sbWidth, sbHeight;
|
||||
|
||||
dx->GetScrollBarDimensions(sbWidth, sbHeight);
|
||||
trect.width = NSToCoordRound(sbWidth);
|
||||
trect.x += aBounds.XMost() - trect.width;
|
||||
trect.height -= NSToCoordRound(sbHeight);
|
||||
|
||||
static NS_DEFINE_IID(kCScrollbarIID, NS_VERTSCROLLBAR_CID);
|
||||
|
||||
rv = mVScrollBarView->Init(mViewManager, trect, this, &kCScrollbarIID, nsnull,
|
||||
mWindow ? nsnull : aNative);
|
||||
mViewManager->InsertChild(this, mVScrollBarView, -3);
|
||||
}
|
||||
|
||||
// Create a view for a horizontal scrollbar
|
||||
mHScrollBarView = new ScrollBarView(this);
|
||||
|
||||
if (nsnull != mHScrollBarView)
|
||||
{
|
||||
nsRect trect = aBounds;
|
||||
float sbWidth, sbHeight;
|
||||
|
||||
dx->GetScrollBarDimensions(sbWidth, sbHeight);
|
||||
trect.height = NSToCoordRound(sbHeight);
|
||||
trect.y += aBounds.YMost() - trect.height;
|
||||
trect.width -= NSToCoordRound(sbWidth);
|
||||
|
||||
static NS_DEFINE_IID(kCHScrollbarIID, NS_HORZSCROLLBAR_CID);
|
||||
|
||||
rv = mHScrollBarView->Init(mViewManager, trect, this, &kCHScrollbarIID, nsnull,
|
||||
mWindow ? nsnull : aNative);
|
||||
mViewManager->InsertChild(this, mHScrollBarView, -3);
|
||||
}
|
||||
|
||||
NS_RELEASE(dx);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsScrollingView :: SetDimensions(nscoord width, nscoord height, PRBool aPaint)
|
||||
{
|
||||
nsIDeviceContext *dx;
|
||||
|
@ -953,6 +854,100 @@ NS_IMETHODIMP nsScrollingView :: HandleEvent(nsGUIEvent *aEvent, PRUint32 aEvent
|
|||
return nsView::HandleEvent(aEvent, aEventFlags, aStatus);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsScrollingView :: CreateScrollControls(nsNativeWidget aNative)
|
||||
{
|
||||
nsIDeviceContext *dx;
|
||||
mViewManager->GetDeviceContext(dx);
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
// Create a clip view
|
||||
mClipView = new nsView;
|
||||
|
||||
if (nsnull != mClipView)
|
||||
{
|
||||
// The clip view needs a widget to clip any of the scrolled view's
|
||||
// child views with widgets. Note that the clip view has an opacity
|
||||
// of 0.0f (completely transparent)
|
||||
// XXX The clip widget should be created on demand only...
|
||||
rv = mClipView->Init(mViewManager, mBounds, this);
|
||||
mViewManager->InsertChild(this, mClipView, -1);
|
||||
mViewManager->SetViewOpacity(mClipView, 0.0f);
|
||||
rv = mClipView->CreateWidget(kWidgetCID, nsnull,
|
||||
mWindow ? nsnull : aNative);
|
||||
}
|
||||
|
||||
// Create a view for a corner cover
|
||||
mCornerView = new CornerView;
|
||||
|
||||
if (nsnull != mCornerView)
|
||||
{
|
||||
nsRect trect;
|
||||
float sbWidth, sbHeight;
|
||||
|
||||
dx->GetScrollBarDimensions(sbWidth, sbHeight);
|
||||
trect.width = NSToCoordRound(sbWidth);
|
||||
trect.x = mBounds.x + mBounds.XMost() - trect.width;
|
||||
trect.height = NSToCoordRound(sbHeight);
|
||||
trect.y = mBounds.y + mBounds.YMost() - trect.height;
|
||||
|
||||
rv = mCornerView->Init(mViewManager, trect, this,
|
||||
nsnull, nsViewVisibility_kHide);
|
||||
mViewManager->InsertChild(this, mCornerView, -1);
|
||||
}
|
||||
|
||||
// Create a view for a vertical scrollbar
|
||||
mVScrollBarView = new ScrollBarView(this);
|
||||
|
||||
if (nsnull != mVScrollBarView)
|
||||
{
|
||||
nsRect trect = mBounds;
|
||||
float sbWidth, sbHeight;
|
||||
|
||||
dx->GetScrollBarDimensions(sbWidth, sbHeight);
|
||||
trect.width = NSToCoordRound(sbWidth);
|
||||
trect.x += mBounds.XMost() - trect.width;
|
||||
trect.height -= NSToCoordRound(sbHeight);
|
||||
|
||||
static NS_DEFINE_IID(kCScrollbarIID, NS_VERTSCROLLBAR_CID);
|
||||
|
||||
rv = mVScrollBarView->Init(mViewManager, trect, this);
|
||||
mViewManager->InsertChild(this, mVScrollBarView, -3);
|
||||
rv = mVScrollBarView->CreateWidget(kCScrollbarIID, nsnull,
|
||||
mWindow ? nsnull : aNative);
|
||||
}
|
||||
|
||||
// Create a view for a horizontal scrollbar
|
||||
mHScrollBarView = new ScrollBarView(this);
|
||||
|
||||
if (nsnull != mHScrollBarView)
|
||||
{
|
||||
nsRect trect = mBounds;
|
||||
float sbWidth, sbHeight;
|
||||
|
||||
dx->GetScrollBarDimensions(sbWidth, sbHeight);
|
||||
trect.height = NSToCoordRound(sbHeight);
|
||||
trect.y += mBounds.YMost() - trect.height;
|
||||
trect.width -= NSToCoordRound(sbWidth);
|
||||
|
||||
static NS_DEFINE_IID(kCHScrollbarIID, NS_HORZSCROLLBAR_CID);
|
||||
|
||||
rv = mHScrollBarView->Init(mViewManager, trect, this);
|
||||
mViewManager->InsertChild(this, mHScrollBarView, -3);
|
||||
rv = mHScrollBarView->CreateWidget(kCHScrollbarIID, nsnull,
|
||||
mWindow ? nsnull : aNative);
|
||||
}
|
||||
|
||||
NS_RELEASE(dx);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsScrollingView :: SetWidget(nsIWidget *aWidget)
|
||||
{
|
||||
NS_ASSERTION(PR_FALSE, "please don't try and set a widget here");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsScrollingView :: ComputeContainerSize()
|
||||
{
|
||||
nsIView *scrolledView;
|
||||
|
@ -1392,7 +1387,13 @@ NS_IMETHODIMP nsScrollingView :: SetScrolledView(nsIView *aScrolledView)
|
|||
|
||||
NS_IMETHODIMP nsScrollingView :: GetScrolledView(nsIView *&aScrolledView) const
|
||||
{
|
||||
return mClipView->GetChild(0, aScrolledView);
|
||||
if (nsnull != mClipView)
|
||||
return mClipView->GetChild(0, aScrolledView);
|
||||
else
|
||||
{
|
||||
aScrolledView = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsScrollingView :: GetScrollPosition(nscoord &aX, nscoord &aY) const
|
||||
|
|
|
@ -35,23 +35,16 @@ public:
|
|||
NS_IMETHOD QueryInterface(REFNSIID aIID,
|
||||
void** aInstancePtr);
|
||||
|
||||
NS_IMETHOD Init(nsIViewManager* aManager,
|
||||
const nsRect &aBounds,
|
||||
const nsIView *aParent,
|
||||
const nsIID *aWindowIID = nsnull,
|
||||
nsWidgetInitData *aWidgetInitData = nsnull,
|
||||
nsNativeWidget aNative = nsnull,
|
||||
const nsViewClip *aClip = nsnull,
|
||||
nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow);
|
||||
|
||||
//overrides
|
||||
NS_IMETHOD SetDimensions(nscoord width, nscoord height, PRBool aPaint = PR_TRUE);
|
||||
NS_IMETHOD SetPosition(nscoord aX, nscoord aY);
|
||||
NS_IMETHOD HandleEvent(nsGUIEvent *aEvent, PRUint32 aEventFlags, nsEventStatus &aStatus);
|
||||
NS_IMETHOD Paint(nsIRenderingContext& rc, const nsRect& rect,
|
||||
PRUint32 aPaintFlags, PRBool &aResult);
|
||||
NS_IMETHOD SetWidget(nsIWidget *aWidget);
|
||||
|
||||
//nsIScrollableView interface
|
||||
NS_IMETHOD CreateScrollControls(nsNativeWidget aNative = nsnull);
|
||||
NS_IMETHOD ComputeContainerSize();
|
||||
NS_IMETHOD GetContainerSize(nscoord *aWidth, nscoord *aHeight) const;
|
||||
NS_IMETHOD SetScrolledView(nsIView *aScrolledView);
|
||||
|
|
|
@ -193,9 +193,6 @@ nsIView* nsView::GetViewFor(nsIWidget* aWidget)
|
|||
NS_IMETHODIMP nsView :: Init(nsIViewManager* aManager,
|
||||
const nsRect &aBounds,
|
||||
const nsIView *aParent,
|
||||
const nsCID *aWindowCIID,
|
||||
nsWidgetInitData *aWidgetInitData,
|
||||
nsNativeWidget aNative,
|
||||
const nsViewClip *aClip,
|
||||
nsViewVisibility aVisibilityFlag)
|
||||
{
|
||||
|
@ -225,34 +222,6 @@ NS_IMETHODIMP nsView :: Init(nsIViewManager* aManager,
|
|||
//temporarily set it...
|
||||
SetParent((nsIView *)aParent);
|
||||
|
||||
// check if a real window has to be created
|
||||
if (aWindowCIID)
|
||||
{
|
||||
nsIDeviceContext *dx;
|
||||
nsRect trect = aBounds;
|
||||
float scale;
|
||||
|
||||
mViewManager->GetDeviceContext(dx);
|
||||
dx->GetAppUnitsToDevUnits(scale);
|
||||
|
||||
trect *= scale;
|
||||
|
||||
if (NS_OK == LoadWidget(*aWindowCIID))
|
||||
{
|
||||
if (aNative)
|
||||
mWindow->Create(aNative, trect, ::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
|
||||
else
|
||||
{
|
||||
nsIWidget *parent;
|
||||
GetOffsetFromWidget(nsnull, nsnull, parent);
|
||||
mWindow->Create(parent, trect, ::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
|
||||
NS_IF_RELEASE(parent);
|
||||
}
|
||||
}
|
||||
|
||||
NS_RELEASE(dx);
|
||||
}
|
||||
|
||||
SetVisibility(aVisibilityFlag);
|
||||
|
||||
// XXX Don't clear this or we hork the scrolling view when creating the clip
|
||||
|
@ -279,13 +248,6 @@ NS_IMETHODIMP nsView :: GetViewManager(nsIViewManager *&aViewMgr)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsView :: GetWidget(nsIWidget *&aWidget)
|
||||
{
|
||||
NS_IF_ADDREF(mWindow);
|
||||
aWidget = mWindow;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsView :: Paint(nsIRenderingContext& rc, const nsRect& rect,
|
||||
PRUint32 aPaintFlags, PRBool &aResult)
|
||||
{
|
||||
|
@ -1160,6 +1122,67 @@ NS_IMETHODIMP nsView :: GetClientData(void *&aData)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsView :: CreateWidget(const nsIID &aWindowIID,
|
||||
nsWidgetInitData *aWidgetInitData,
|
||||
nsNativeWidget aNative)
|
||||
{
|
||||
nsIDeviceContext *dx;
|
||||
nsRect trect = mBounds;
|
||||
float scale;
|
||||
|
||||
NS_IF_RELEASE(mWindow);
|
||||
|
||||
mViewManager->GetDeviceContext(dx);
|
||||
dx->GetAppUnitsToDevUnits(scale);
|
||||
|
||||
trect *= scale;
|
||||
|
||||
if (NS_OK == LoadWidget(aWindowIID))
|
||||
{
|
||||
if (aNative)
|
||||
mWindow->Create(aNative, trect, ::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
|
||||
else
|
||||
{
|
||||
nsIWidget *parent;
|
||||
GetOffsetFromWidget(nsnull, nsnull, parent);
|
||||
mWindow->Create(parent, trect, ::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
|
||||
NS_IF_RELEASE(parent);
|
||||
}
|
||||
}
|
||||
|
||||
//make sure visibility state is accurate
|
||||
|
||||
nsViewVisibility vis;
|
||||
|
||||
GetVisibility(vis);
|
||||
SetVisibility(vis);
|
||||
|
||||
NS_RELEASE(dx);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsView :: SetWidget(nsIWidget *aWidget)
|
||||
{
|
||||
NS_IF_RELEASE(mWindow);
|
||||
mWindow = aWidget;
|
||||
|
||||
if (nsnull != mWindow)
|
||||
{
|
||||
NS_ADDREF(mWindow);
|
||||
mWindow->SetClientData((void *)this);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsView :: GetWidget(nsIWidget *&aWidget)
|
||||
{
|
||||
NS_IF_ADDREF(mWindow);
|
||||
aWidget = mWindow;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//
|
||||
// internal window creation functions
|
||||
//
|
||||
|
|
|
@ -48,15 +48,11 @@ public:
|
|||
NS_IMETHOD Init(nsIViewManager* aManager,
|
||||
const nsRect &aBounds,
|
||||
const nsIView *aParent,
|
||||
const nsCID *aWindowIID = nsnull,
|
||||
nsWidgetInitData *aWidgetInitData = nsnull,
|
||||
nsNativeWidget aNative = nsnull,
|
||||
const nsViewClip *aClip = nsnull,
|
||||
nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow);
|
||||
|
||||
NS_IMETHOD Destroy();
|
||||
NS_IMETHOD GetViewManager(nsIViewManager *&aViewMgr);
|
||||
NS_IMETHOD GetWidget(nsIWidget *&aWidget);
|
||||
NS_IMETHOD Paint(nsIRenderingContext& rc, const nsRect& rect,
|
||||
PRUint32 aPaintFlags, PRBool &aResult);
|
||||
NS_IMETHOD Paint(nsIRenderingContext& rc, const nsIRegion& region,
|
||||
|
@ -94,6 +90,11 @@ public:
|
|||
NS_IMETHOD GetOffsetFromWidget(nscoord *aDx, nscoord *aDy, nsIWidget *&aWidget);
|
||||
NS_IMETHOD GetDirtyRegion(nsIRegion*& aRegion);
|
||||
NS_IMETHOD SetDirtyRegion(nsIRegion* aRegion);
|
||||
NS_IMETHOD CreateWidget(const nsIID &aWindowIID,
|
||||
nsWidgetInitData *aWidgetInitData = nsnull,
|
||||
nsNativeWidget aNative = nsnull);
|
||||
NS_IMETHOD SetWidget(nsIWidget *aWidget);
|
||||
NS_IMETHOD GetWidget(nsIWidget *&aWidget);
|
||||
virtual void List(FILE* out = stdout, PRInt32 aIndent = 0) const;
|
||||
|
||||
// Helper function to get the view that's associated with a widget
|
||||
|
|
|
@ -500,15 +500,18 @@ nsresult DocumentViewerImpl::MakeWindow(nsNativeWidget aNativeParent,
|
|||
static NS_DEFINE_IID(kWidgetCID, NS_CHILD_CID);
|
||||
if ((NS_OK != rv) || (NS_OK != mView->Init(mViewManager,
|
||||
tbounds,
|
||||
nsnull,
|
||||
&kWidgetCID,
|
||||
nsnull,
|
||||
aNativeParent))) {
|
||||
nsnull))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = mView->CreateWidget(kWidgetCID, nsnull, aNativeParent);
|
||||
|
||||
if (rv != NS_OK)
|
||||
return rv;
|
||||
|
||||
// Setup hierarchical relationship in view manager
|
||||
mViewManager->SetRootView(mView);
|
||||
|
||||
mView->GetWidget(mWindow);
|
||||
|
||||
//set frame rate to 25 fps
|
||||
|
|
Загрузка…
Ссылка в новой задаче