Bug 109772. Some nsIView deCOMtamination. Fixed the API for GetNeearestWidget to be sensible. r+sr=dbaron

This commit is contained in:
roc+%cs.cmu.edu 2004-01-30 03:20:41 +00:00
Родитель fe2e0655fe
Коммит a2c6a75e31
16 изменённых файлов: 146 добавлений и 370 удалений

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

@ -4072,13 +4072,6 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsIPresShell* aPresShell,
InitializeSelectFrame(aPresShell, aPresContext, aState, listFrame, scrolledFrame, aContent, comboboxFrame,
listStyle, PR_FALSE, PR_FALSE, PR_TRUE);
newFrame = listFrame;
// XXX Temporary for Bug 19416
{
nsIView* lstView = scrolledFrame->GetView();
if (lstView) {
lstView->IgnoreSetPosition(PR_TRUE);
}
}
// Set flag so the events go to the listFrame not child frames.
// XXX: We should replace this with a real widget manager similar

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

@ -1703,18 +1703,9 @@ nsComboboxControlFrame::ShowDropDown(PRBool aDoDropDown)
}
if (!mDroppedDown && aDoDropDown) {
// XXX Temporary for Bug 19416
nsIView* lstView = mDropdownFrame->GetView();
if (lstView) {
lstView->IgnoreSetPosition(PR_FALSE);
}
if (mListControlFrame) {
mListControlFrame->SyncViewWithFrame(mPresContext);
}
// XXX Temporary for Bug 19416
if (lstView) {
lstView->IgnoreSetPosition(PR_TRUE);
}
ToggleList(mPresContext);
return NS_OK;
} else if (mDroppedDown && !aDoDropDown) {

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

@ -1216,10 +1216,7 @@ nsObjectFrame::InstantiateWidget(nsIPresContext* aPresContext,
return rv;
}
nsCOMPtr<nsIWidget> parent;
parentWithView->GetOffsetFromWidget(nsnull, nsnull, *getter_AddRefs(parent));
mWidget->Create(NS_STATIC_CAST(nsIWidget*, parent), r, nsnull, nsnull);
mWidget->Create(parentWithView->GetNearestWidget(nsnull), r, nsnull, nsnull);
mWidget->Show(PR_TRUE);
return rv;
}
@ -4049,28 +4046,13 @@ static void ConvertRelativeToWindowAbsolute(nsIFrame* aFrame,
aAbs = aFrame->GetPosition();
}
NS_ASSERTION(view, "the object frame does not have a view");
if (view) {
// Caclulate the views offset from its nearest widget
nscoord viewx = 0;
nscoord viewy = 0;
aContainerWidget = view->GetWidget();
NS_IF_ADDREF(aContainerWidget);
if (!aContainerWidget) {
view->GetOffsetFromWidget(&viewx, &viewy, aContainerWidget/**getter_AddRefs(widget)*/);
aAbs.x += viewx;
aAbs.y += viewy;
// GetOffsetFromWidget does not include the views offset, so we need to add
// that in.
aAbs += view->GetPosition();
}
nsRect widgetBounds;
aContainerWidget->GetBounds(widgetBounds);
} else {
NS_ASSERTION(PR_FALSE, "the object frame does not have a view");
// Calculate the view's offset from its nearest widget
nsPoint viewOffset;
aContainerWidget = view->GetNearestWidget(&viewOffset);
NS_IF_ADDREF(aContainerWidget);
aAbs += viewOffset;
}
// Add relative coordinate to the absolute coordinate that has been calculated

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

@ -127,11 +127,8 @@ nsPageFrame::SetInitialChildList(nsIPresContext* aPresContext,
{
nsIView* view = aChildList->GetView();
if (view && mDoCreateWidget) {
nscoord dx, dy;
nsCOMPtr<nsIWidget> widget;
view->GetOffsetFromWidget(&dx, &dy, *getter_AddRefs(widget));
nsCOMPtr<nsIPrintPreviewContext> ppContext = do_QueryInterface(aPresContext);
if (ppContext && widget) {
if (ppContext && view->GetNearestWidget(nsnull)) {
view->CreateWidget(kCChildCID);
}
}

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

@ -1216,10 +1216,7 @@ nsObjectFrame::InstantiateWidget(nsIPresContext* aPresContext,
return rv;
}
nsCOMPtr<nsIWidget> parent;
parentWithView->GetOffsetFromWidget(nsnull, nsnull, *getter_AddRefs(parent));
mWidget->Create(NS_STATIC_CAST(nsIWidget*, parent), r, nsnull, nsnull);
mWidget->Create(parentWithView->GetNearestWidget(nsnull), r, nsnull, nsnull);
mWidget->Show(PR_TRUE);
return rv;
}
@ -4049,28 +4046,13 @@ static void ConvertRelativeToWindowAbsolute(nsIFrame* aFrame,
aAbs = aFrame->GetPosition();
}
NS_ASSERTION(view, "the object frame does not have a view");
if (view) {
// Caclulate the views offset from its nearest widget
nscoord viewx = 0;
nscoord viewy = 0;
aContainerWidget = view->GetWidget();
NS_IF_ADDREF(aContainerWidget);
if (!aContainerWidget) {
view->GetOffsetFromWidget(&viewx, &viewy, aContainerWidget/**getter_AddRefs(widget)*/);
aAbs.x += viewx;
aAbs.y += viewy;
// GetOffsetFromWidget does not include the views offset, so we need to add
// that in.
aAbs += view->GetPosition();
}
nsRect widgetBounds;
aContainerWidget->GetBounds(widgetBounds);
} else {
NS_ASSERTION(PR_FALSE, "the object frame does not have a view");
// Calculate the view's offset from its nearest widget
nsPoint viewOffset;
aContainerWidget = view->GetNearestWidget(&viewOffset);
NS_IF_ADDREF(aContainerWidget);
aAbs += viewOffset;
}
// Add relative coordinate to the absolute coordinate that has been calculated

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

@ -127,11 +127,8 @@ nsPageFrame::SetInitialChildList(nsIPresContext* aPresContext,
{
nsIView* view = aChildList->GetView();
if (view && mDoCreateWidget) {
nscoord dx, dy;
nsCOMPtr<nsIWidget> widget;
view->GetOffsetFromWidget(&dx, &dy, *getter_AddRefs(widget));
nsCOMPtr<nsIPrintPreviewContext> ppContext = do_QueryInterface(aPresContext);
if (ppContext && widget) {
if (ppContext && view->GetNearestWidget(nsnull)) {
view->CreateWidget(kCChildCID);
}
}

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

@ -1703,18 +1703,9 @@ nsComboboxControlFrame::ShowDropDown(PRBool aDoDropDown)
}
if (!mDroppedDown && aDoDropDown) {
// XXX Temporary for Bug 19416
nsIView* lstView = mDropdownFrame->GetView();
if (lstView) {
lstView->IgnoreSetPosition(PR_FALSE);
}
if (mListControlFrame) {
mListControlFrame->SyncViewWithFrame(mPresContext);
}
// XXX Temporary for Bug 19416
if (lstView) {
lstView->IgnoreSetPosition(PR_TRUE);
}
ToggleList(mPresContext);
return NS_OK;
} else if (mDroppedDown && !aDoDropDown) {

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

@ -4072,13 +4072,6 @@ nsCSSFrameConstructor::ConstructSelectFrame(nsIPresShell* aPresShell,
InitializeSelectFrame(aPresShell, aPresContext, aState, listFrame, scrolledFrame, aContent, comboboxFrame,
listStyle, PR_FALSE, PR_FALSE, PR_TRUE);
newFrame = listFrame;
// XXX Temporary for Bug 19416
{
nsIView* lstView = scrolledFrame->GetView();
if (lstView) {
lstView->IgnoreSetPosition(PR_TRUE);
}
}
// Set flag so the events go to the listFrame not child frames.
// XXX: We should replace this with a real widget manager similar

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

@ -559,14 +559,13 @@ nsMenuPopupFrame::AdjustClientXYForNestedDocuments ( nsIDOMXULDocument* inPopupD
return;
// Find the widget associated with the popup's document
nsCOMPtr<nsIWidget> popupDocumentWidget;
nsIWidget* popupDocumentWidget = nsnull;
nsIViewManager* viewManager = inPopupShell->GetViewManager();
if ( viewManager ) {
nsIView* rootView;
viewManager->GetRootView(rootView);
nscoord wOffsetX, wOffsetY;
if ( rootView )
rootView->GetOffsetFromWidget(&wOffsetX, &wOffsetY, *getter_AddRefs(popupDocumentWidget));
popupDocumentWidget = rootView->GetNearestWidget(nsnull);
}
NS_WARN_IF_FALSE(popupDocumentWidget, "ACK, BAD WIDGET");
@ -610,8 +609,7 @@ nsMenuPopupFrame::AdjustClientXYForNestedDocuments ( nsIDOMXULDocument* inPopupD
nsIView* rootViewTarget;
viewManagerTarget->GetRootView(rootViewTarget);
if ( rootViewTarget ) {
nscoord unusedX, unusedY;
rootViewTarget->GetOffsetFromWidget(&unusedX, &unusedY, *getter_AddRefs(targetDocumentWidget));
targetDocumentWidget = rootViewTarget->GetNearestWidget(nsnull);
}
}
}

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

@ -133,16 +133,19 @@ public:
* @param aManager view manager that "owns" the view. The view does NOT
* hold a reference to the view manager
* @param aBounds initial bounds for view
* XXX We should eliminate this parameter; you can set the bounds after Init
* @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.
* XXX We should eliminate this parameter!
* @param aVisibilityFlag initial visibility state of view
* XXX We should eliminate this parameter; you can set it after Init
* @result The result of the initialization, NS_OK if no errors
*/
NS_IMETHOD Init(nsIViewManager* aManager,
const nsRect &aBounds,
const nsIView *aParent,
nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow) = 0;
nsresult Init(nsIViewManager* aManager,
const nsRect &aBounds,
const nsIView *aParent,
nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow);
/**
* Destroy the view.
@ -154,7 +157,7 @@ public:
* SetRootView(NULL) if the view is the root view and calling RemoveChild()
* otherwise.
*/
NS_IMETHOD Destroy() = 0;
void Destroy();
/**
* Get the view manager which "owns" the view.
@ -173,7 +176,6 @@ public:
* @param y out parameter for y position
*/
nsPoint GetPosition() const {
// this assertion should go away once we're confident that it's not needed
NS_ASSERTION(!IsRoot() || (mPosX == 0 && mPosY == 0),
"root views should always have explicit position of (0,0)");
return nsPoint(mPosX, mPosY);
@ -186,12 +188,7 @@ public:
* if the view has content above or to the left of its origin.
* @param aBounds out parameter for bounds
*/
nsRect GetBounds() const {
// this assertion should go away once we're confident that it's not needed
NS_ASSERTION(!IsRoot() || (mDimBounds.x == 0 && mDimBounds.y == 0),
"root views should always have explicit position of (0,0)");
return mDimBounds;
}
nsRect GetBounds() const { return mDimBounds; }
/**
* Called to query the visibility state of a view.
@ -248,6 +245,14 @@ public:
*/
float GetOpacity() const { return mOpacity; }
/**
* Used to ask a view if it has any areas within its bounding box
* that are transparent. This is not the same as opacity - opacity can
* be set externally, transparency is a quality of the view itself.
* @result Returns PR_TRUE if there are transparent areas, PR_FALSE otherwise.
*/
PRBool IsTransparent() const { return (mVFlags & NS_VIEW_FLAG_TRANSPARENT) != 0; }
/**
* Indicate that this view is always painted onto a uniform field of pixels. Thus,
* even if the view is transparent, it may still be bitblit scrollable because
@ -269,7 +274,7 @@ public:
* Set the view's link to client owned data.
* @param aData - data to associate with view. nsnull to disassociate
*/
NS_IMETHOD SetClientData(void *aData) = 0;
void SetClientData(void *aData) { mClientData = aData; }
/**
* Query the view for it's link to client owned data.
@ -279,16 +284,18 @@ public:
/**
* Get the nearest widget in this view or a parent of this view and
* the offset from the view that contains the widget to this view
* @param aDx out parameter for x offset
* @param aDy out parameter for y offset
* @return widget (if there is one) closest to view
* the offset from the widget's origin to this view's origin
* @param aOffset the offset from this view's origin to the widget's origin
* @return the widget closest to this view; can be null because some view trees
* don't have widgets at all (e.g., printing), but if any view in the view tree
* has a widget, then it's safe to assume this will not return null
* XXX Remove this 'virtual' when gfx+widget are merged into gklayout;
* Mac widget depends on this method, which is BOGUS!
*/
NS_IMETHOD GetOffsetFromWidget(nscoord *aDx, nscoord *aDy, nsIWidget *&aWidget) = 0;
virtual nsIWidget* GetNearestWidget(nsPoint* aOffset);
/**
* Create a widget to associate with this view. This is a helper
* function for SetWidget.
* Create a widget to associate with this view.
* @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
@ -302,12 +309,12 @@ public:
* assistive technology like screen readers.
* @return error status
*/
NS_IMETHOD CreateWidget(const nsIID &aWindowIID,
nsWidgetInitData *aWidgetInitData = nsnull,
nsNativeWidget aNative = nsnull,
PRBool aEnableDragDrop = PR_TRUE,
PRBool aResetVisibility = PR_TRUE,
nsContentType aWindowType = eContentTypeInherit) = 0;
nsresult CreateWidget(const nsIID &aWindowIID,
nsWidgetInitData *aWidgetInitData = nsnull,
nsNativeWidget aNative = nsnull,
PRBool aEnableDragDrop = PR_TRUE,
PRBool aResetVisibility = PR_TRUE,
nsContentType aWindowType = eContentTypeInherit);
/**
* In 4.0, the "cutout" nature of a view is queryable.
@ -323,22 +330,20 @@ public:
*/
PRBool HasWidget() const { return mWindow != nsnull; }
// XXX Temporary for Bug #19416
NS_IMETHOD IgnoreSetPosition(PRBool aShouldIgnore) = 0;
#ifdef DEBUG
/**
* Output debug info to FILE
* @param out output file handle
* @param aIndent indentation depth
* NOTE: virtual so that debugging tools not linked into gklayout can access it
*/
NS_IMETHOD List(FILE* out, PRInt32 aIndent = 0) const = 0;
virtual void List(FILE* out, PRInt32 aIndent = 0) const;
#endif // DEBUG
/**
* @result true iff this is the root view for its view manager
*/
virtual PRBool IsRoot() const = 0;
PRBool IsRoot() const;
private:
NS_IMETHOD_(nsrefcnt) AddRef(void) = 0;
@ -357,6 +362,8 @@ protected:
nsRect mDimBounds; // relative to parent
float mOpacity;
PRUint32 mVFlags;
virtual ~nsIView() {}
};
#endif

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

@ -380,15 +380,7 @@ NS_IMETHODIMP nsScrollPortView::GetScrollbarVisibility(PRBool *aVerticalVisible,
void nsScrollPortView::AdjustChildWidgets(nsScrollPortView *aScrolling, nsView *aView, nscoord aDx, nscoord aDy, float scale)
{
if (aScrolling == aView)
{
nsIWidget *widget;
nscoord dx, dy;
aScrolling->GetOffsetFromWidget(&dx, &dy, widget);
aDx += dx;
aDy += dy;
NS_IF_RELEASE(widget);
}
NS_ASSERTION(aScrolling != aView, "We should only be scrolling children of aScrolling");
nsPoint pt = aView->GetPosition();

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

@ -217,10 +217,10 @@ nsView* nsView::GetViewFor(nsIWidget* aWidget)
return nsnull;
}
NS_IMETHODIMP nsView::Init(nsIViewManager* aManager,
const nsRect &aBounds,
const nsIView *aParent,
nsViewVisibility aVisibilityFlag)
nsresult nsIView::Init(nsIViewManager* aManager,
const nsRect &aBounds,
const nsIView *aParent,
nsViewVisibility aVisibilityFlag)
{
//printf(" \n callback=%d data=%d", aWidgetCreateCallback, aCallbackData);
NS_PRECONDITION(nsnull != aManager, "null ptr");
@ -233,31 +233,21 @@ NS_IMETHODIMP nsView::Init(nsIViewManager* aManager,
// we don't hold a reference to the view manager
mViewManager = NS_STATIC_CAST(nsViewManager*, aManager);
SetPosition(aBounds.x, aBounds.y);
nsView* v = NS_STATIC_CAST(nsView*, this);
v->SetPosition(aBounds.x, aBounds.y);
nsRect dim(0, 0, aBounds.width, aBounds.height);
v->SetDimensions(dim, PR_FALSE);
v->SetVisibility(aVisibilityFlag);
SetDimensions(dim, PR_FALSE);
//temporarily set it...
SetParent(NS_CONST_CAST(nsView*, NS_STATIC_CAST(const nsView*, aParent)));
SetVisibility(aVisibilityFlag);
// XXX Don't clear this or we hork the scrolling view when creating the clip
// view's widget. It needs to stay set and later the view manager will reset it
// when the view is inserted into the view hierarchy...
#if 0
//clear this again...
SetParent(nsnull);
#endif
// We shouldn't set the parent here. It should be set when we put this view
// into the view hierarchy.
v->SetParent(NS_STATIC_CAST(nsView*, NS_CONST_CAST(nsIView*, aParent)));
return NS_OK;
}
NS_IMETHODIMP nsView::Destroy()
void nsIView::Destroy()
{
delete this;
return NS_OK;
}
NS_IMETHODIMP nsView::Paint(nsIRenderingContext& rc, const nsRect& rect,
@ -292,18 +282,6 @@ NS_IMETHODIMP nsView::Paint(nsIRenderingContext& rc, const nsIRegion& region,
return NS_ERROR_NOT_IMPLEMENTED;
}
// XXX Start Temporary fix for Bug #19416
NS_IMETHODIMP nsView::IgnoreSetPosition(PRBool aShouldIgnore)
{
mShouldIgnoreSetPosition = aShouldIgnore;
// resync here
if (!mShouldIgnoreSetPosition) {
SetPosition(mPosX, mPosY);
}
return NS_OK;
}
// XXX End Temporary fix for Bug #19416
void nsView::SetPosition(nscoord aX, nscoord aY)
{
mDimBounds.x += aX - mPosX;
@ -311,12 +289,9 @@ void nsView::SetPosition(nscoord aX, nscoord aY)
mPosX = aX;
mPosY = aY;
// XXX Start Temporary fix for Bug #19416
if (mShouldIgnoreSetPosition) {
return;
}
NS_ASSERTION(GetParent() || (aX == 0 && aY == 0),
"Don't try to move the root widget to something non-zero");
// XXX End Temporary fix for Bug #19416
ResetWidgetPosition(PR_TRUE);
}
@ -345,18 +320,18 @@ void nsView::ResetWidgetPosition(PRBool aRecurse) {
nsIDeviceContext *dx;
float scale;
nsIWidget *pwidget = nsnull;
nscoord parx = 0, pary = 0;
mViewManager->GetDeviceContext(dx);
dx->GetAppUnitsToDevUnits(scale);
NS_RELEASE(dx);
GetOffsetFromWidget(&parx, &pary, pwidget);
NS_IF_RELEASE(pwidget);
nsPoint offset(0, 0);
if (GetParent()) {
GetParent()->GetNearestWidget(&offset);
}
mWindow->Move(NSTwipsToIntPixels((mDimBounds.x + parx), scale),
NSTwipsToIntPixels((mDimBounds.y + pary), scale));
mWindow->Move(NSTwipsToIntPixels((mDimBounds.x + offset.x), scale),
NSTwipsToIntPixels((mDimBounds.y + offset.y), scale));
} else if (aRecurse) {
// reposition any widgets under this view
for (nsView* v = GetFirstChild(); v; v = v->GetNextSibling()) {
@ -376,40 +351,6 @@ NS_IMETHODIMP nsView::SynchWidgetSizePosition()
mViewManager->GetDeviceContext(dx);
dx->GetAppUnitsToDevUnits(t2p);
NS_RELEASE(dx);
#if 0
/* You would think that doing a move and resize all in one operation would
* be faster but its not. Something is really broken here. So I'm comenting
* this out for now
*/
// if we moved and resized do it all in one shot
if (mVFlags & NS_VIEW_PUBLIC_FLAG_WIDGET_MOVED && mVFlags & NS_VIEW_PUBLIC_FLAG_WIDGET_RESIZED)
{
nscoord parx = 0, pary = 0;
nsIWidget *pwidget = nsnull;
GetOffsetFromWidget(&parx, &pary, pwidget);
NS_IF_RELEASE(pwidget);
PRInt32 x = NSTwipsToIntPixels(mDimBounds.x + parx, t2p);
PRInt32 y = NSTwipsToIntPixels(mDimBounds.y + pary, t2p);
PRInt32 width = NSTwipsToIntPixels(mDimBounds.width, t2p);
PRInt32 height = NSTwipsToIntPixels(mDimBounds.height, t2p);
nsRect bounds;
mWindow->GetBounds(bounds);
if (bounds.x == x && bounds.y == y )
mVFlags &= ~NS_VIEW_FLAG_WIDGET_MOVED;
else if (bounds.width == width && bounds.height == bounds.height)
mVFlags &= ~NS_VIEW_FLAG_WIDGET_RESIZED;
else {
mWindow->Resize(x,y,width,height, PR_TRUE);
mVFlags &= ~NS_VIEW_FLAG_WIDGET_RESIZED;
mVFlags &= ~NS_VIEW_FLAG_WIDGET_MOVED;
return NS_OK;
}
}
#endif
// if we just resized do it
if (mVFlags & NS_VIEW_FLAG_WIDGET_RESIZED)
{
@ -421,9 +362,6 @@ NS_IMETHODIMP nsView::SynchWidgetSizePosition()
mWindow->GetBounds(bounds);
if (bounds.width != width || bounds.height != bounds.height) {
#ifdef DEBUG_evaughan
printf("%d) Resize(%d,%d)\n", this, width, height);
#endif
mWindow->Resize(width,height, PR_TRUE);
}
@ -432,22 +370,16 @@ NS_IMETHODIMP nsView::SynchWidgetSizePosition()
if (mVFlags & NS_VIEW_FLAG_WIDGET_MOVED) {
// if we just moved do it.
nscoord parx = 0, pary = 0;
nsIWidget *pwidget = nsnull;
nsPoint offset;
GetParent()->GetNearestWidget(&offset);
GetOffsetFromWidget(&parx, &pary, pwidget);
NS_IF_RELEASE(pwidget);
PRInt32 x = NSTwipsToIntPixels(mDimBounds.x + parx, t2p);
PRInt32 y = NSTwipsToIntPixels(mDimBounds.y + pary, t2p);
PRInt32 x = NSTwipsToIntPixels(mDimBounds.x + offset.x, t2p);
PRInt32 y = NSTwipsToIntPixels(mDimBounds.y + offset.y, t2p);
nsRect bounds;
mWindow->GetBounds(bounds);
if (bounds.x != x || bounds.y != y) {
#ifdef DEBUG_evaughan
printf("%d) Move(%d,%d)\n", this, x, y);
#endif
mWindow->Move(x,y);
}
@ -488,18 +420,18 @@ void nsView::SetDimensions(const nsRect& aRect, PRBool aPaint)
nsIDeviceContext *dx;
float t2p;
nsIWidget *pwidget = nsnull;
nscoord parx = 0, pary = 0;
mViewManager->GetDeviceContext(dx);
dx->GetAppUnitsToDevUnits(t2p);
GetOffsetFromWidget(&parx, &pary, pwidget);
NS_IF_RELEASE(pwidget);
if (needToMoveWidget) {
mWindow->Move(NSTwipsToIntPixels((mDimBounds.x + parx), t2p),
NSTwipsToIntPixels((mDimBounds.y + pary), t2p));
NS_ASSERTION(GetParent(), "Don't try to move the root widget, dude");
nsPoint offset;
GetParent()->GetNearestWidget(&offset);
mWindow->Move(NSTwipsToIntPixels((mDimBounds.x + offset.x), t2p),
NSTwipsToIntPixels((mDimBounds.y + offset.y), t2p));
}
mWindow->Resize(NSTwipsToIntPixels(mDimBounds.width, t2p), NSTwipsToIntPixels(mDimBounds.height, t2p),
aPaint);
@ -606,12 +538,6 @@ NS_IMETHODIMP nsView::SetOpacity(float opacity)
return NS_OK;
}
NS_IMETHODIMP nsView::HasTransparency(PRBool &aTransparent) const
{
aTransparent = (mVFlags & NS_VIEW_FLAG_TRANSPARENT) ? PR_TRUE : PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP nsView::SetContentTransparency(PRBool aTransparent)
{
if (aTransparent == PR_TRUE)
@ -622,13 +548,7 @@ NS_IMETHODIMP nsView::SetContentTransparency(PRBool aTransparent)
return NS_OK;
}
NS_IMETHODIMP nsView::SetClientData(void *aData)
{
mClientData = aData;
return NS_OK;
}
NS_IMETHODIMP nsView::CreateWidget(const nsIID &aWindowIID,
nsresult nsIView::CreateWidget(const nsIID &aWindowIID,
nsWidgetInitData *aWidgetInitData,
nsNativeWidget aNative,
PRBool aEnableDragDrop,
@ -646,7 +566,8 @@ NS_IMETHODIMP nsView::CreateWidget(const nsIID &aWindowIID,
trect *= scale;
if (NS_OK == LoadWidget(aWindowIID))
nsView* v = NS_STATIC_CAST(nsView*, this);
if (NS_OK == v->LoadWidget(aWindowIID))
{
PRBool usewidgets;
@ -673,11 +594,10 @@ NS_IMETHODIMP nsView::CreateWidget(const nsIID &aWindowIID,
GetParent()->GetViewManager() != mViewManager)
initData.mListenForResizes = PR_TRUE;
nsIWidget *parent;
GetOffsetFromWidget(nsnull, nsnull, parent);
mWindow->Create(parent, trect, ::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
NS_IF_RELEASE(parent);
nsIWidget* parentWidget = GetParent() ? GetParent()->GetNearestWidget(nsnull)
: nsnull;
mWindow->Create(parentWidget, trect,
::HandleEvent, dx, nsnull, nsnull, aWidgetInitData);
}
if (aEnableDragDrop) {
mWindow->EnableDragDrop(PR_TRUE);
@ -691,7 +611,7 @@ NS_IMETHODIMP nsView::CreateWidget(const nsIID &aWindowIID,
//make sure visibility state is accurate
if (aResetVisibility) {
SetVisibility(GetVisibility());
v->SetVisibility(GetVisibility());
}
NS_RELEASE(dx);
@ -740,7 +660,7 @@ nsresult nsView::LoadWidget(const nsCID &aClassIID)
}
#ifdef DEBUG
NS_IMETHODIMP nsView::List(FILE* out, PRInt32 aIndent) const
void nsIView::List(FILE* out, PRInt32 aIndent) const
{
PRInt32 i;
for (i = aIndent; --i >= 0; ) fputs(" ", out);
@ -767,66 +687,48 @@ NS_IMETHODIMP nsView::List(FILE* out, PRInt32 aIndent) const
nsRect brect = GetBounds();
fprintf(out, "{%d,%d,%d,%d}",
brect.x, brect.y, brect.width, brect.height);
if (IsZPlaceholderView()) {
const nsView* v = NS_STATIC_CAST(const nsView*, this);
if (v->IsZPlaceholderView()) {
fprintf(out, " z-placeholder(%p)",
(void*)NS_STATIC_CAST(const nsZPlaceholderView*, this)->GetReparentedView());
}
if (mZParent) {
fprintf(out, " zparent=%p", (void*)mZParent);
if (v->GetZParent()) {
fprintf(out, " zparent=%p", (void*)v->GetZParent());
}
PRBool hasTransparency;
HasTransparency(hasTransparency);
fprintf(out, " z=%d vis=%d opc=%1.3f tran=%d clientData=%p <\n",
mZIndex, mVis, mOpacity, hasTransparency, mClientData);
mZIndex, mVis, mOpacity, IsTransparent(), mClientData);
for (nsView* kid = mFirstChild; kid; kid = kid->GetNextSibling()) {
NS_ASSERTION(kid->GetParent() == this, "incorrect parent");
kid->List(out, aIndent + 1);
}
for (i = aIndent; --i >= 0; ) fputs(" ", out);
fputs(">\n", out);
return NS_OK;
}
#endif // DEBUG
NS_IMETHODIMP nsView::GetOffsetFromWidget(nscoord *aDx, nscoord *aDy, nsIWidget *&aWidget)
nsIWidget* nsIView::GetNearestWidget(nsPoint* aOffset)
{
nsView *ancestor = GetParent();
aWidget = nsnull;
if (aDx) *aDx = 0;
if (aDy) *aDy = 0;
while (ancestor)
{
aWidget = ancestor->GetWidget();
if (aWidget) {
NS_ADDREF(aWidget);
// the widget's (0,0) is at the top left of the view's bounds, NOT its position
if (aDx && aDy)
{
nsRect r;
ancestor->GetDimensions(r);
*aDx -= r.x;
*aDy -= r.y;
}
return NS_OK;
nsPoint pt(0, 0);
nsView* v;
for (v = NS_STATIC_CAST(nsView*, this);
v && !v->HasWidget(); v = v->GetParent()) {
pt += v->GetPosition();
}
if (!v) {
if (aOffset) {
*aOffset = pt;
}
if (aDx && aDy)
{
ancestor->ConvertToParentCoords(aDx, aDy);
}
ancestor = ancestor->GetParent();
return NS_STATIC_CAST(nsView*, this)->GetViewManager()->GetWidget();
}
if (nsnull == aWidget) {
// The root view doesn't have a widget
// but maybe the view manager does.
GetViewManager()->GetWidget(&aWidget);
// pt is now the offset from v's origin to this's origin
// The widget's origin is the top left corner of v's bounds, which may
// not coincide with v's origin
if (aOffset) {
nsRect vBounds = v->GetBounds();
*aOffset = pt + v->GetPosition() - nsPoint(vBounds.x, vBounds.y);
}
return NS_OK;
return v->GetWidget();
}
nsresult nsView::GetDirtyRegion(nsIRegion*& aRegion)
@ -842,7 +744,7 @@ nsresult nsView::GetDirtyRegion(nsIRegion*& aRegion)
return NS_OK;
}
PRBool nsView::IsRoot() const
PRBool nsIView::IsRoot() const
{
NS_ASSERTION(mViewManager != nsnull," View manager is null in nsView::IsRoot()");
return mViewManager->GetRootView() == this;

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

@ -77,31 +77,6 @@ public:
// nsISupports
NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
// nsIView
NS_IMETHOD Init(nsIViewManager* aManager,
const nsRect &aBounds,
const nsIView *aParent,
nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow);
/**
* Used to ask a view if it has any areas within its bounding box
* that are transparent. This is not the same as opacity - opacity can
* be set externally, transparency is a quality of the view itself.
* @result Returns PR_TRUE if there are transparent areas, PR_FALSE otherwise.
*/
NS_IMETHOD HasTransparency(PRBool &aTransparent) const;
NS_IMETHOD SetClientData(void *aData);
NS_IMETHOD GetOffsetFromWidget(nscoord *aDx, nscoord *aDy, nsIWidget *&aWidget);
NS_IMETHOD CreateWidget(const nsIID &aWindowIID,
nsWidgetInitData *aWidgetInitData = nsnull,
nsNativeWidget aNative = nsnull,
PRBool aEnableDragDrop = PR_TRUE,
PRBool aResetVisibility = PR_TRUE,
nsContentType aContentType = eContentTypeInherit);
#ifdef DEBUG
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const;
#endif
NS_IMETHOD Destroy();
/**
* Called to indicate that the specified rect of the view
* needs to be drawn via the rendering context. The rect
@ -228,9 +203,6 @@ public:
NS_IMETHOD GetClippedRect(nsRect& aClippedRect, PRBool& aIsClipped, PRBool& aEmpty) const;
// XXX Temporary for Bug #19416
NS_IMETHOD IgnoreSetPosition(PRBool aShouldIgnore);
/**
* Sync your widget size and position with the view
*/
@ -240,9 +212,6 @@ public:
// Helper function to get the view that's associated with a widget
static nsView* GetViewFor(nsIWidget* aWidget);
// Helper function to determine if the view instance is the root view
virtual PRBool IsRoot() const;
// Helper function to determine if the view point is inside of a view
PRBool PointIsInside(nsView& aView, nscoord x, nscoord y) const;
@ -284,10 +253,10 @@ public:
void ConvertFromParentCoords(nscoord* aX, nscoord* aY) const { *aX -= mPosX; *aY -= mPosY; }
void ResetWidgetPosition(PRBool aRecurse);
void SetPositionIgnoringChildWidgets(nscoord aX, nscoord aY);
nsresult LoadWidget(const nsCID &aClassIID);
protected:
virtual ~nsView();
virtual nsresult LoadWidget(const nsCID &aClassIID);
protected:
nsZPlaceholderView*mZParent;
@ -295,8 +264,6 @@ protected:
//XXX should there be pointers to last child so backward walking is fast?
nsRect mChildClip;
nsIRegion* mDirtyRegion;
// Bug #19416
PRPackedBool mShouldIgnoreSetPosition;
PRPackedBool mChildRemoved;
private:

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

@ -3013,11 +3013,8 @@ NS_IMETHODIMP nsViewManager::SetViewZIndex(nsIView *aView, PRBool aAutoZIndex, P
NS_IMETHODIMP nsViewManager::SetViewContentTransparency(nsIView *aView, PRBool aTransparent)
{
nsView* view = NS_STATIC_CAST(nsView*, aView);
PRBool trans;
view->HasTransparency(trans);
if (trans != aTransparent) {
if (view->IsTransparent() != aTransparent) {
view->SetContentTransparency(aTransparent);
if (IsViewInserted(view)) {
@ -3502,10 +3499,8 @@ PRBool nsViewManager::CreateDisplayList(nsView *aView, PRBool aReparentedViewsPr
bounds.y -= aOriginY;
if (aEventProcessing || aView->GetOpacity() > 0.0f) {
PRBool transparent;
aView->HasTransparency(transparent);
PRUint32 flags = VIEW_RENDERED;
if (transparent)
if (aView->IsTransparent())
flags |= VIEW_TRANSPARENT;
retval = AddToDisplayList(aView, aResult, bounds, irect, flags,
aX - aOriginX, aY - aOriginY,
@ -3744,9 +3739,7 @@ nsRect nsViewManager::OptimizeTranslucentRegions(
r.UnionRect(r, element->mBounds);
// the bounds of a non-transparent element are added to the opaque
// region
PRBool transparent;
element->mView->HasTransparency(transparent);
if (!transparent && aOpaqueRegion) {
if (!element->mView->IsTransparent() && aOpaqueRegion) {
aOpaqueRegion->Or(*aOpaqueRegion, element->mBounds);
}
}

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

@ -202,6 +202,7 @@ public:
NS_IMETHOD GetWidgetForView(nsIView *aView, nsIWidget **aWidget);
NS_IMETHOD GetWidget(nsIWidget **aWidget);
nsIWidget* GetWidget() { return mRootWindow; }
NS_IMETHOD ForceUpdate();
NS_IMETHOD IsCachingWidgetChanges(PRBool* aCaching);

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

@ -157,7 +157,6 @@ nsDragService::ComputeGlobalRectFromFrame ( nsIDOMNode* aDOMNode, Rect & outScre
}
#endif
PRBool haveRectFlag = PR_FALSE;
outScreenRect.left = outScreenRect.right = outScreenRect.top = outScreenRect.bottom = 0;
// Get the frame for this content node (note: frames are not refcounted)
@ -183,37 +182,28 @@ nsDragService::ComputeGlobalRectFromFrame ( nsIDOMNode* aDOMNode, Rect & outScre
return PR_FALSE;
// get the widget associated with the containing view.
nsCOMPtr<nsIWidget> aWidget;
nscoord widgetOffsetX = 0, widgetOffsetY = 0;
containingView->GetOffsetFromWidget ( &widgetOffsetX, &widgetOffsetY, *getter_AddRefs(aWidget) );
if (aWidget) {
float t2p = 1.0;
presContext->GetTwipsToPixels(&t2p);
nsPoint widgetOffset;
nsIWidget* aWidget = containingView->GetNearestWidget ( &widgetOffset );
// GetOffsetFromWidget() actually returns the _parent's_ offset from its widget, so we
// still have to add in the offset to |containingView|'s parent ourselves.
nsPoint viewOffsetToParent = containingView->GetPosition();
// Shift our offset rect by offset into our view, the view's offset to its parent, and
// the parent's offset to the closest widget. Then convert that to global coordinates.
// Recall that WidgetToScreen() will give us the global coordinates of the rectangle we
// give it, but it expects everything to be in pixels.
nsRect screenOffset;
screenOffset.MoveBy ( NSTwipsToIntPixels(widgetOffsetX + viewOffsetToParent.x + viewOffset.x, t2p),
NSTwipsToIntPixels(widgetOffsetY + viewOffsetToParent.y + viewOffset.y, t2p) );
aWidget->WidgetToScreen ( screenOffset, screenOffset );
float t2p = 1.0;
presContext->GetTwipsToPixels(&t2p);
// stash it all in a mac rect
outScreenRect.left = screenOffset.x;
outScreenRect.top = screenOffset.y;
outScreenRect.right = outScreenRect.left + NSTwipsToIntPixels(rect.width, t2p);
outScreenRect.bottom = outScreenRect.top + NSTwipsToIntPixels(rect.height, t2p);
// Shift our offset rect by offset into our view, and
// the view's offset to the closest widget. Then convert that to global coordinates.
// Recall that WidgetToScreen() will give us the global coordinates of the rectangle we
// give it, but it expects everything to be in pixels.
nsRect screenOffset;
screenOffset.MoveBy ( NSTwipsToIntPixels(widgetOffset.x + viewOffset.x, t2p),
NSTwipsToIntPixels(widgetOffset.y + viewOffset.y, t2p) );
aWidget->WidgetToScreen ( screenOffset, screenOffset );
// stash it all in a mac rect
outScreenRect.left = screenOffset.x;
outScreenRect.top = screenOffset.y;
outScreenRect.right = outScreenRect.left + NSTwipsToIntPixels(rect.width, t2p);
outScreenRect.bottom = outScreenRect.top + NSTwipsToIntPixels(rect.height, t2p);
haveRectFlag = PR_TRUE;
}
return haveRectFlag;
return PR_TRUE;
} // ComputeGlobalRectFromFrame