Bug 73382. Clean up view manager interfaces, 2nd attempt. r=kmcclusk,rs=attinasi

This commit is contained in:
roc+%cs.cmu.edu 2001-12-01 14:31:45 +00:00
Родитель 25f910bd7e
Коммит c88233916b
64 изменённых файлов: 1154 добавлений и 1067 удалений

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

@ -2917,6 +2917,7 @@ DocumentViewerImpl::ReflowPrintObject(PrintObject * aPO)
if (NS_FAILED(rv)) {
return rv;
}
rv = aPO->mViewManager->Init(mPrt->mPrintDocDC);
if (NS_FAILED(rv)) {
return rv;
@ -3762,8 +3763,9 @@ DocumentViewerImpl::DoPrint(PrintObject * aPO, PRBool aDoSyncPrinting, PRBool& a
nsRect r;
poRootView->GetBounds(r);
r.x = r.y = 0;
r.height = srect.height;
poRootView->SetBounds(r);
aPO->mViewManager->ResizeView(poRootView, r, PR_FALSE);
rootFrame->GetRect(r);
@ -4036,7 +4038,10 @@ DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget,
// Initialize the view manager with an offset. This allows the viewmanager
// to manage a coordinate space offset from (0,0)
rv = mViewManager->Init(dx, tbounds.x, tbounds.y);
rv = mViewManager->Init(dx);
if (NS_FAILED(rv))
return rv;
rv = mViewManager->SetWindowOffset(tbounds.x, tbounds.y);
if (NS_FAILED(rv))
return rv;

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

@ -7189,7 +7189,8 @@ nsTypedSelection::GetSelectionRegionRectAndScrollableView(SelectionRegion aRegio
if (NS_FAILED(result))
return result;
result = clipView->GetDimensions(&clipRect.width, &clipRect.height);
result = clipView->GetBounds(clipRect);
clipRect.x = clipRect.y = 0;
if (NS_FAILED(result))
return result;
@ -7249,9 +7250,9 @@ nsTypedSelection::ScrollRectIntoView(nsIScrollableView *aScrollableView,
const nsIView* clipView;
nsRect visibleRect;
aScrollableView->GetScrollPosition(visibleRect.x, visibleRect.y);
aScrollableView->GetClipView(&clipView);
clipView->GetDimensions(&visibleRect.width, &visibleRect.height);
clipView->GetBounds(visibleRect);
aScrollableView->GetScrollPosition(visibleRect.x, visibleRect.y);
// The actual scroll offsets
nscoord scrollOffsetX = visibleRect.x;

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

@ -1105,13 +1105,12 @@ nsGenericHTMLElement::GetClientHeight(PRInt32* aClientHeight)
if (scrollView) {
const nsIView *view = nsnull;
nscoord xClip, yClip;
nsRect r;
scrollView->GetClipView(&view);
view->GetBounds(r);
view->GetDimensions(&xClip, &yClip);
*aClientHeight = NSTwipsToIntPixels(yClip, t2p);
*aClientHeight = NSTwipsToIntPixels(r.height, t2p);
}
return rv;
@ -1131,13 +1130,12 @@ nsGenericHTMLElement::GetClientWidth(PRInt32* aClientWidth)
if (scrollView) {
const nsIView *view = nsnull;
nscoord xClip, yClip;
nsRect r;
scrollView->GetClipView(&view);
view->GetBounds(r);
view->GetDimensions(&xClip, &yClip);
*aClientWidth = NSTwipsToIntPixels(xClip, t2p);
*aClientWidth = NSTwipsToIntPixels(r.width, t2p);
}
return rv;

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

@ -70,6 +70,7 @@
#include "nsLayoutAtoms.h"
#include "nsRuleWalker.h"
#include "nsIBodySuper.h"
#include "nsIViewManager.h"
//----------------------------------------------------------------------
@ -536,11 +537,9 @@ HandleFixedBackground(nsIPresContext* aPresContext,
canvasFrame->GetView(aPresContext, (nsIView**)&viewportView);
}
if (viewportView) {
if (aIsFixed) {
viewportView->SetViewFlags(NS_VIEW_PUBLIC_FLAG_DONT_BITBLT);
} else {
viewportView->ClearViewFlags(NS_VIEW_PUBLIC_FLAG_DONT_BITBLT);
}
nsCOMPtr<nsIViewManager> vm;
aPresShell->GetViewManager(getter_AddRefs(vm));
vm->SetViewBitBltEnabled(viewportView, !aIsFixed);
}
}

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

@ -2664,7 +2664,12 @@ nsHTMLDocument::GetPixelDimensions(nsIPresShell* aShell,
scrollableView->GetScrolledView(view);
}
result = view->GetDimensions(&size.width, &size.height);
nsRect r;
result = view->GetBounds(r);
if (NS_SUCCEEDED(result)) {
size.height = r.height;
size.width = r.width;
}
}
// If we don't have a view, use the frame size
else {

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

@ -3119,7 +3119,12 @@ nsXULDocument::GetPixelDimensions(nsIPresShell* aShell,
scrollableView->GetScrolledView(view);
}
result = view->GetDimensions(&size.width, &size.height);
nsRect r;
result = view->GetBounds(r);
if (NS_SUCCEEDED(result)) {
size.height = r.height;
size.width = r.width;
}
}
// If we don't have a view, use the frame size
else {

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

@ -3378,9 +3378,11 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresShell* aPresShell,
// Not all shells have scroll frames, even in scrollable presContext (bug 30317)
if (view) {
PRUint32 viewFlags;
view->GetViewFlags(&viewFlags);
view->SetViewFlags(viewFlags | NS_VIEW_PUBLIC_FLAG_DONT_BITBLT);
nsCOMPtr<nsIViewManager> vm;
view->GetViewManager(*getter_AddRefs(vm));
if (vm) {
vm->SetViewBitBltEnabled(view, PR_FALSE);
}
}
}

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

@ -2421,9 +2421,9 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext,
rootFrame->GetView(aPresContext, &viewportView);
NS_ASSERTION(viewportView, "no viewport view");
viewportView->GetBounds(viewportArea);
viewportArea.x = 0;
viewportArea.y = 0;
viewportView->GetDimensions(&viewportArea.width, &viewportArea.height);
}
// Get the anchor point

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

@ -2917,6 +2917,7 @@ DocumentViewerImpl::ReflowPrintObject(PrintObject * aPO)
if (NS_FAILED(rv)) {
return rv;
}
rv = aPO->mViewManager->Init(mPrt->mPrintDocDC);
if (NS_FAILED(rv)) {
return rv;
@ -3762,8 +3763,9 @@ DocumentViewerImpl::DoPrint(PrintObject * aPO, PRBool aDoSyncPrinting, PRBool& a
nsRect r;
poRootView->GetBounds(r);
r.x = r.y = 0;
r.height = srect.height;
poRootView->SetBounds(r);
aPO->mViewManager->ResizeView(poRootView, r, PR_FALSE);
rootFrame->GetRect(r);
@ -4036,7 +4038,10 @@ DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget,
// Initialize the view manager with an offset. This allows the viewmanager
// to manage a coordinate space offset from (0,0)
rv = mViewManager->Init(dx, tbounds.x, tbounds.y);
rv = mViewManager->Init(dx);
if (NS_FAILED(rv))
return rv;
rv = mViewManager->SetWindowOffset(tbounds.x, tbounds.y);
if (NS_FAILED(rv))
return rv;

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

@ -4135,9 +4135,9 @@ PresShell::ScrollFrameIntoView(nsIFrame *aFrame,
const nsIView* clipView;
nsRect visibleRect;
scrollingView->GetScrollPosition(visibleRect.x, visibleRect.y);
scrollingView->GetClipView(&clipView);
clipView->GetDimensions(&visibleRect.width, &visibleRect.height);
clipView->GetBounds(visibleRect); // get width and height
scrollingView->GetScrollPosition(visibleRect.x, visibleRect.y);
// The actual scroll offsets
nscoord scrollOffsetX = visibleRect.x;

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

@ -555,7 +555,8 @@ nsComboboxControlFrame::ShowPopup(PRBool aShowPopup)
if (aShowPopup) {
nsRect rect;
mDropdownFrame->GetRect(rect);
viewManager->ResizeView(view, rect.width, rect.height);
rect.x = rect.y = 0;
viewManager->ResizeView(view, rect);
nsIScrollableView* scrollingView;
if (NS_SUCCEEDED(view->QueryInterface(NS_GET_IID(nsIScrollableView), (void**)&scrollingView))) {
scrollingView->ComputeScrollOffsets(PR_TRUE);
@ -563,7 +564,8 @@ nsComboboxControlFrame::ShowPopup(PRBool aShowPopup)
viewManager->SetViewVisibility(view, nsViewVisibility_kShow);
} else {
viewManager->SetViewVisibility(view, nsViewVisibility_kHide);
viewManager->ResizeView(view, 0, 0);
nsRect emptyRect(0, 0, 0, 0);
viewManager->ResizeView(view, emptyRect);
}
// fire a popup dom event
@ -659,7 +661,8 @@ nsComboboxControlFrame::ReflowComboChildFrame(nsIFrame* aFrame,
nsCOMPtr<nsIViewManager> viewManager;
view->GetViewManager(*getter_AddRefs(viewManager));
viewManager->SetViewVisibility(view, nsViewVisibility_kHide);
viewManager->ResizeView(view, 0, 0);
nsRect emptyRect(0, 0, 0, 0);
viewManager->ResizeView(view, emptyRect);
}
// Reflow child

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

@ -519,8 +519,13 @@ nsFormControlFrame::DidReflow(nsIPresContext* aPresContext,
nsViewVisibility oldVis;
// only change if different.
view->GetVisibility(oldVis);
if (newVis != oldVis)
view->SetVisibility(newVis);
if (newVis != oldVis) {
nsCOMPtr<nsIViewManager> vm;
view->GetViewManager(*getter_AddRefs(vm));
if (vm) {
vm->SetViewVisibility(view, newVis);
}
}
}
}

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

@ -293,8 +293,9 @@ nsImageControlFrame::Init(nsIPresContext* aPresContext,
// the view's size is not know yet, but its size will be kept in synch with our frame.
nsRect boundBox(0, 0, 0, 0);
result = view->Init(viewMan, boundBox, parView);
view->SetContentTransparency(PR_TRUE);
viewMan->InsertChild(parView, view, 0);
viewMan->SetViewContentTransparency(view, PR_TRUE);
// XXX put the view last in document order until we know how to do better
viewMan->InsertChild(parView, view, nsnull, PR_TRUE);
SetView(aPresContext, view);
const nsStyleVisibility* vis = (const nsStyleVisibility*) mStyleContext->GetStyleData(eStyleStruct_Visibility);

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

@ -2226,8 +2226,11 @@ nsresult
nsListControlFrame::CreateScrollingViewWidget(nsIView* aView, const nsStyleDisplay* aDisplay)
{
if (IsInDropDownMode() == PR_TRUE) {
nsCOMPtr<nsIViewManager> vm;
aView->GetViewManager(*getter_AddRefs(vm));
vm->SetViewFloating(aView, PR_TRUE);
nsWidgetInitData widgetData;
aView->SetFloating(PR_TRUE);
widgetData.mWindowType = eWindowType_popup;
widgetData.mBorderStyle = eBorderStyle_default;
@ -2297,13 +2300,13 @@ nsListControlFrame::SyncViewWithFrame(nsIPresContext* aPresContext)
//nsSize size;
//GetSize(size);
nscoord width;
nscoord height;
view->GetDimensions(&width, &height);
//nscoord width;
//nscoord height;
//view->GetDimensions(&width, &height);
if (width != mRect.width || height != mRect.height) {
//if (width != mRect.width || height != mRect.height) {
//viewManager->ResizeView(view, mRect.width, mRect.height);
}
//}
nscoord x;
nscoord y;
view->GetPosition(&x, &y);

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

@ -57,6 +57,11 @@
#include "nsLayoutAtoms.h"
#include "nsIViewManager.h"
#include "nsIWidget.h"
#include "nsIRegion.h"
#include "nsGfxCIID.h"
#include "nsIServiceManager.h"
static NS_DEFINE_CID(kRegionCID, NS_REGION_CID);
#ifdef NS_DEBUG
#undef NOISY
@ -447,6 +452,20 @@ nsContainerFrame::PositionFrameView(nsIPresContext* aPresContext,
}
}
static nsIRegion* CreateRegion()
{
nsIRegion* region;
nsresult rv = nsComponentManager::CreateInstance(kRegionCID, nsnull, NS_GET_IID(nsIRegion), (void**)&region);
if (NS_SUCCEEDED(rv)) {
if (NS_SUCCEEDED(region->Init())) {
return region;
} else {
NS_RELEASE(region);
}
}
return nsnull;
}
void
nsContainerFrame::SyncFrameViewAfterReflow(nsIPresContext* aPresContext,
nsIFrame* aFrame,
@ -473,11 +492,10 @@ nsContainerFrame::SyncFrameViewAfterReflow(nsIPresContext* aPresContext,
// area, then size the view large enough to include those child
// frames
if ((kidState & NS_FRAME_OUTSIDE_CHILDREN) && aCombinedArea) {
vm->ResizeView(aView, aCombinedArea->XMost(), aCombinedArea->YMost());
vm->ResizeView(aView, *aCombinedArea);
} else {
nscoord width, height;
aView->GetDimensions(&width, &height);
nsRect bounds;
aView->GetBounds(bounds);
// If the width is unchanged and the height is not decreased then repaint only the
// newly exposed or contracted area, otherwise repaint the union of the old and new areas
@ -486,8 +504,9 @@ nsContainerFrame::SyncFrameViewAfterReflow(nsIPresContext* aPresContext,
// This is because some frames do not invalidate themselves properly. see bug 73825.
// Once bug 73825 is fixed, we should always pass PR_TRUE instead of
// frameSize.width == width && frameSize.height >= height.
vm->ResizeView(aView, frameSize.width, frameSize.height,
(frameSize.width == width && frameSize.height >= height));
nsRect newSize(0, 0, frameSize.width, frameSize.height);
vm->ResizeView(aView, newSize,
(frameSize.width == bounds.width && frameSize.height >= bounds.height));
}
}
@ -581,8 +600,7 @@ nsContainerFrame::SyncFrameViewAfterReflow(nsIPresContext* aPresContext,
autoZIndex = PR_TRUE;
}
vm->SetViewZIndex(aView, zIndex);
vm->SetViewAutoZIndex(aView, autoZIndex);
vm->SetViewZIndex(aView, autoZIndex, zIndex);
// There are two types of clipping:
// - 'clip' which only applies to absolutely positioned elements, and is
@ -647,21 +665,20 @@ nsContainerFrame::SyncFrameViewAfterReflow(nsIPresContext* aPresContext,
}
// Set clipping of child views.
if (hasClip) {
aView->SetChildClip(clipRect.x, clipRect.y, clipRect.XMost(), clipRect.YMost());
} else {
aView->SetChildClip(overflowClipRect.x, overflowClipRect.y,
overflowClipRect.XMost(), overflowClipRect.YMost());
nsIRegion *region = CreateRegion();
if (region != nsnull) {
if (hasClip) {
region->SetTo(clipRect.x, clipRect.y, clipRect.width, clipRect.height);
} else {
region->SetTo(overflowClipRect.x, overflowClipRect.y,
overflowClipRect.width, overflowClipRect.height);
}
vm->SetViewChildClipRegion(aView, region);
NS_RELEASE(region);
}
PRUint32 vflags;
aView->GetViewFlags(&vflags);
aView->SetViewFlags(vflags | NS_VIEW_PUBLIC_FLAG_CLIPCHILDREN);
} else {
// Remove clipping of child views.
PRUint32 vflags;
aView->GetViewFlags(&vflags);
aView->SetViewFlags(vflags & ~NS_VIEW_PUBLIC_FLAG_CLIPCHILDREN);
vm->SetViewChildClipRegion(aView, nsnull);
}
NS_RELEASE(vm);

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

@ -978,8 +978,13 @@ nsHTMLFrameInnerFrame::DidReflow(nsIPresContext* aPresContext,
nsViewVisibility oldVis;
// only change if different.
view->GetVisibility(oldVis);
if (newVis != oldVis)
view->SetVisibility(newVis);
if (newVis != oldVis) {
nsCOMPtr<nsIViewManager> vm;
view->GetViewManager(*getter_AddRefs(vm));
if (vm != nsnull) {
vm->SetViewVisibility(view, newVis);
}
}
}
}
@ -1352,7 +1357,8 @@ nsHTMLFrameInnerFrame::CreateViewAndWidget(nsIPresContext* aPresContext,
nsCOMPtr<nsIViewManager> viewMan;
presShell->GetViewManager(getter_AddRefs(viewMan));
rv = view->Init(viewMan, viewBounds, parView);
viewMan->InsertChild(parView, view, 0);
// XXX put it at the end of the document order until we can do better
viewMan->InsertChild(parView, view, nsnull, PR_TRUE);
nsWidgetInitData initData;
initData.clipChildren = PR_TRUE;
@ -1365,7 +1371,7 @@ nsHTMLFrameInnerFrame::CreateViewAndWidget(nsIPresContext* aPresContext,
const nsStyleVisibility* vis;
GetStyleData(eStyleStruct_Visibility, ((const nsStyleStruct *&)vis));
if (!vis->IsVisible()) {
view->SetVisibility(nsViewVisibility_kHide);
viewMan->SetViewVisibility(view, nsViewVisibility_kHide);
}
view->GetWidget(*aWidget);
return rv;

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

@ -351,7 +351,8 @@ nsHTMLFramesetFrame::Init(nsIPresContext* aPresContext,
parWithView->GetView(aPresContext, &parView);
nsRect boundBox(0, 0, 0, 0);
result = view->Init(viewMan, boundBox, parView);
viewMan->InsertChild(parView, view, 0);
// XXX Put it last in document order until we can do better
viewMan->InsertChild(parView, view, nsnull, PR_TRUE);
SetView(aPresContext, view);
nsCOMPtr<nsIPresShell> shell;
@ -1600,16 +1601,15 @@ nsHTMLFramesetFrame::StartMouseDrag(nsIPresContext* aPresContext,
nsIView* view;
GetView(aPresContext, &view);
if (view) {
nsIViewManager* viewMan;
view->GetViewManager(viewMan);
nsCOMPtr<nsIViewManager> viewMan;
view->GetViewManager(*getter_AddRefs(viewMan));
if (viewMan) {
PRBool ignore;
viewMan->GrabMouseEvents(view, ignore);
NS_RELEASE(viewMan);
mDragger = aBorder;
//XXX This should go away! Border should have own view instead
view->SetViewFlags(NS_VIEW_PUBLIC_FLAG_DONT_CHECK_CHILDREN);
viewMan->SetViewCheckChildEvents(view, PR_FALSE);
// The point isn't in frameset coords, but we're using it to compute
// moves relative to the start position.
@ -1686,7 +1686,7 @@ nsHTMLFramesetFrame::MouseDrag(nsIPresContext* aPresContext,
nsIView* root;
vm->GetRootView(root);
if (root) {
vm->UpdateView(root, NS_VMREFRESH_IMMEDIATE | NS_VMREFRESH_AUTO_DOUBLE_BUFFER);
vm->UpdateView(root, NS_VMREFRESH_IMMEDIATE);
}
}
}
@ -1698,15 +1698,14 @@ nsHTMLFramesetFrame::EndMouseDrag(nsIPresContext* aPresContext)
nsIView* view;
GetView(aPresContext, &view);
if (view) {
nsIViewManager* viewMan;
view->GetViewManager(viewMan);
nsCOMPtr<nsIViewManager> viewMan;
view->GetViewManager(*getter_AddRefs(viewMan));
if (viewMan) {
mDragger = nsnull;
PRBool ignore;
viewMan->GrabMouseEvents(nsnull, ignore);
NS_RELEASE(viewMan);
//XXX This should go away! Border should have own view instead
view->ClearViewFlags(NS_VIEW_PUBLIC_FLAG_DONT_CHECK_CHILDREN);
viewMan->SetViewCheckChildEvents(view, PR_TRUE);
}
}
gDragInProgress = PR_FALSE;

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

@ -190,6 +190,9 @@ ReparentFrameViewTo(nsIPresContext* aPresContext,
{
nsIView* view;
// XXX What to do about placeholder views for "position: fixed" elements?
// They should be reparented too.
// Does aFrame have a view?
aFrame->GetView(aPresContext, &view);
if (view) {
@ -197,19 +200,11 @@ ReparentFrameViewTo(nsIPresContext* aPresContext,
//nsIView* parentView;
//NS_ASSERTION(parentView == aOldParentView, "unexpected parent view");
// Change the parent view.
PRInt32 zIndex;
view->GetZIndex(zIndex);
// Remove the view using it's parent instead
// of aOldParentView which is wrong.
nsIView* vp = nsnull;
view->GetParent(vp);
aViewManager->RemoveChild(vp, view);
aViewManager->RemoveChild(view);
// XXX We need to insert this view in the correct place within its z-order...
// XXX What should we do about the Z-placeholder-child if this frame is position:fixed?
aViewManager->InsertChild(aNewParentView, view, zIndex);
// The view will remember the Z-order and other attributes that have been set on it.
// XXX Pretend this view is last of the parent's views in document order
aViewManager->InsertChild(aNewParentView, view, nsnull, PR_TRUE);
} else {
// Iterate the child frames, and check each child frame to see if it has
// a view
@ -570,9 +565,7 @@ nsHTMLContainerFrame::CreateViewForFrame(nsIPresContext* aPresContext,
// If the frame has a fixed background attachment, then indicate that the
// view's contents should be repainted and not bitblt'd
if (fixedBackgroundAttachment) {
PRUint32 viewFlags;
view->GetViewFlags(&viewFlags);
view->SetViewFlags(viewFlags | NS_VIEW_PUBLIC_FLAG_DONT_BITBLT);
viewManager->SetViewBitBltEnabled(view, PR_FALSE);
}
// Insert the view into the view hierarchy. If the parent view is a
@ -590,12 +583,10 @@ nsHTMLContainerFrame::CreateViewForFrame(nsIPresContext* aPresContext,
} else if (position->mZIndex.GetUnit() == eStyleUnit_Auto) {
autoZIndex = PR_TRUE;
}
viewManager->InsertChild(parentView, view, zIndex);
if (autoZIndex) {
viewManager->SetViewAutoZIndex(view, PR_TRUE);
}
viewManager->SetViewZIndex(view, autoZIndex, zIndex);
// XXX Drop it at the end of the document order until we can do better
viewManager->InsertChild(parentView, view, nsnull, PR_TRUE);
if (nsnull != aContentParentFrame) {
// If, for some reason, GetView below fails to initialize zParentView,
@ -616,7 +607,7 @@ nsHTMLContainerFrame::CreateViewForFrame(nsIPresContext* aPresContext,
}
if (zParentView != parentView) {
viewManager->InsertZPlaceholder(zParentView, view, zIndex);
viewManager->InsertZPlaceholder(zParentView, view, nsnull, PR_TRUE);
}
}
}
@ -663,7 +654,7 @@ nsHTMLContainerFrame::CreateViewForFrame(nsIPresContext* aPresContext,
}
} else {
view->SetVisibility(nsViewVisibility_kHide);
viewManager->SetViewVisibility(view, nsViewVisibility_kHide);
}
// XXX If it's fixed positioned, then create a widget so it floats

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

@ -1249,9 +1249,14 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame,
aFrame->GetView(mPresContext, &view);
if (view) {
nsIViewManager *vm;
view->GetViewManager(vm);
vm->ResizeView(view, metrics.width, metrics.height);
#if 0 // XXX This is the correct code. We'll turn it on later to mitigate risk.
vm->ResizeView(view, pfd->mCombinedArea);
#else // imitate the old, wrong code
nsRect r(0, 0, metrics.width, metrics.height);
vm->ResizeView(view, r);
#endif
NS_RELEASE(vm);
}

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

@ -725,7 +725,9 @@ nsObjectFrame::CreateWidget(nsIPresContext* aPresContext,
viewMan->AllowDoubleBuffering(doubleBuffer);
#endif
viewMan->InsertChild(parView, view, 0);
// XXX Put this last in document order
// XXX Should we be setting the z-index here?
viewMan->InsertChild(parView, view, nsnull, PR_TRUE);
if(aViewOnly != PR_TRUE) {
@ -764,9 +766,11 @@ nsObjectFrame::CreateWidget(nsIPresContext* aPresContext,
nsIView* parentWithView;
nsPoint origin;
view->SetVisibility(nsViewVisibility_kShow);
nsRect r(0, 0, mRect.width, mRect.height);
viewMan->SetViewVisibility(view, nsViewVisibility_kShow);
GetOffsetFromView(aPresContext, origin, &parentWithView);
viewMan->ResizeView(view, mRect.width, mRect.height);
viewMan->ResizeView(view, r);
viewMan->MoveViewTo(view, origin.x, origin.y);
}
@ -1471,7 +1475,11 @@ nsObjectFrame::DidReflow(nsIPresContext* aPresContext,
nsIView* view = nsnull;
GetView(aPresContext, &view);
if (nsnull != view) {
view->SetVisibility(nsViewVisibility_kShow);
nsCOMPtr<nsIViewManager> vm;
view->GetViewManager(*getter_AddRefs(vm));
if (vm) {
vm->SetViewVisibility(view, nsViewVisibility_kShow);
}
}
if (nsnull != mInstanceOwner) {
@ -3575,7 +3583,12 @@ NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void)
view->GetWidget(mWidget);
PRBool fTransparent;
mInstance->GetValue(nsPluginInstanceVariable_TransparentBool, (void *)&fTransparent);
view->SetContentTransparency(fTransparent);
nsCOMPtr<nsIViewManager> vm;
view->GetViewManager(*getter_AddRefs(vm));
if (vm) {
vm->SetViewContentTransparency(view, fTransparent);
}
}
if (PR_TRUE == windowless)

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

@ -7189,7 +7189,8 @@ nsTypedSelection::GetSelectionRegionRectAndScrollableView(SelectionRegion aRegio
if (NS_FAILED(result))
return result;
result = clipView->GetDimensions(&clipRect.width, &clipRect.height);
result = clipView->GetBounds(clipRect);
clipRect.x = clipRect.y = 0;
if (NS_FAILED(result))
return result;
@ -7249,9 +7250,9 @@ nsTypedSelection::ScrollRectIntoView(nsIScrollableView *aScrollableView,
const nsIView* clipView;
nsRect visibleRect;
aScrollableView->GetScrollPosition(visibleRect.x, visibleRect.y);
aScrollableView->GetClipView(&clipView);
clipView->GetDimensions(&visibleRect.width, &visibleRect.height);
clipView->GetBounds(visibleRect);
aScrollableView->GetScrollPosition(visibleRect.x, visibleRect.y);
// The actual scroll offsets
nscoord scrollOffsetX = visibleRect.x;

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

@ -51,6 +51,7 @@
#include "nsIPrintOptions.h"
#include "nsPageFrame.h"
#include "nsIPrintPreviewContext.h"
#include "nsIRegion.h"
#include "nsIPref.h" // for header/footer gap & ExtraMargin for Print Preview
@ -78,6 +79,7 @@ static NS_DEFINE_CID(kLocaleServiceCID, NS_LOCALESERVICE_CID);
#include "nsIServiceManager.h"
static NS_DEFINE_CID(kPrintOptionsCID, NS_PRINTOPTIONS_CID);
//
static NS_DEFINE_CID(kRegionCID, NS_REGION_CID);
#if defined(DEBUG_rods) || defined(DEBUG_dcone)
#define DEBUG_PRINTING
@ -578,6 +580,20 @@ nsSimplePageSequenceFrame::SetPageNumberFormat(const char* aPropName, const char
}
static nsIRegion* CreateRegion()
{
nsIRegion* region;
nsresult rv = nsComponentManager::CreateInstance(kRegionCID, nsnull, NS_GET_IID(nsIRegion), (void**)&region);
if (NS_SUCCEEDED(rv)) {
if (NS_SUCCEEDED(region->Init())) {
return region;
} else {
NS_RELEASE(region);
}
}
return nsnull;
}
NS_IMETHODIMP
nsSimplePageSequenceFrame::StartPrint(nsIPresContext* aPresContext,
nsIPrintOptions* aPrintOptions)
@ -662,29 +678,39 @@ nsSimplePageSequenceFrame::StartPrint(nsIPresContext* aPresContext,
PRInt32 pageNum = 1;
nscoord y = 0;//mMargin.top;
nsCOMPtr<nsIRegion> emptyRegion = getter_AddRefs(CreateRegion());
for (nsIFrame* page = mFrames.FirstChild(); nsnull != page; page->GetNextSibling(&page)) {
nsIView* view;
nsIView* view = nsnull;
page->GetView(aPresContext, &view);
NS_ASSERTION(nsnull != view, "no page view");
nsCOMPtr<nsIViewManager> vm;
view->GetViewManager(*getter_AddRefs(vm));
NS_ASSERTION(nsnull != vm, "no view manager");
if (pageNum < mFromPageNum || pageNum > mToPageNum) {
// Hide the pages that won't be printed to the Viewmanager
// doesn't put them in the display list. Also, makde
// sure the child views don't get asked to print
// but my guess is that there won't be any
view->SetVisibility(nsViewVisibility_kHide);
view->SetChildClip(0,0,0,0);
view->SetViewFlags(NS_VIEW_PUBLIC_FLAG_CLIPCHILDREN);
vm->SetViewVisibility(view, nsViewVisibility_kHide);
vm->SetViewChildClipRegion(view, emptyRegion);
} else {
nsRect rect;
page->GetRect(rect);
rect.y = y;
rect.height = height;
page->SetRect(aPresContext, rect);
nsRect viewRect;
view->GetBounds(viewRect);
viewRect.y = y;
viewRect.height = height;
view->SetBounds(viewRect);
vm->MoveViewTo(view, viewRect.x, viewRect.y);
viewRect.x = 0;
viewRect.y = 0;
vm->ResizeView(view, viewRect);
y += rect.height + mMargin.top + mMargin.bottom;
}
pageNum++;
@ -836,7 +862,10 @@ nsSimplePageSequenceFrame::PrintNextPage(nsIPresContext* aPresContext,
containerView->GetBounds(containerRect);
containerRect.y -= mYSelOffset;
containerRect.height = height-mYSelOffset;
containerView->SetBounds(containerRect, PR_FALSE);
vm->MoveViewTo(containerView, containerRect.x, containerRect.y);
nsRect r(0, 0, containerRect.width, containerRect.height);
vm->ResizeView(containerView, r, PR_FALSE);
clipRect.SetRect(mMargin.left, mMargin.right, width, height);
nsPageFrame * pf = NS_STATIC_CAST(nsPageFrame*, childFrame);
@ -862,7 +891,7 @@ nsSimplePageSequenceFrame::PrintNextPage(nsIPresContext* aPresContext,
PRINT_DEBUG_MSG4("SeqFr::Paint -> %p PageNo: %d View: %p", pf, mPageNum, view);
PRINT_DEBUG_MSG3(" At: %d,%d\n", mMargin.left+mOffsetX, mMargin.top+mOffsetY);
view->SetContentTransparency(PR_FALSE);
vm->SetViewContentTransparency(view, PR_FALSE);
vm->Display(view, mOffsetX, mOffsetY, clipRect);
@ -889,8 +918,9 @@ nsSimplePageSequenceFrame::PrintNextPage(nsIPresContext* aPresContext,
pf->SetPageNumInfo(mPrintedPageNum, mTotalPages);
containerRect.y -= height;
containerRect.height += height;
containerView->SetBounds(containerRect, PR_FALSE);
vm->MoveViewTo(containerView, containerRect.x, containerRect.y);
nsRect r(0, 0, containerRect.width, containerRect.height);
vm->ResizeView(containerView, r, PR_FALSE);
} else {
continuePrinting = PR_FALSE;
}

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

@ -57,6 +57,11 @@
#include "nsLayoutAtoms.h"
#include "nsIViewManager.h"
#include "nsIWidget.h"
#include "nsIRegion.h"
#include "nsGfxCIID.h"
#include "nsIServiceManager.h"
static NS_DEFINE_CID(kRegionCID, NS_REGION_CID);
#ifdef NS_DEBUG
#undef NOISY
@ -447,6 +452,20 @@ nsContainerFrame::PositionFrameView(nsIPresContext* aPresContext,
}
}
static nsIRegion* CreateRegion()
{
nsIRegion* region;
nsresult rv = nsComponentManager::CreateInstance(kRegionCID, nsnull, NS_GET_IID(nsIRegion), (void**)&region);
if (NS_SUCCEEDED(rv)) {
if (NS_SUCCEEDED(region->Init())) {
return region;
} else {
NS_RELEASE(region);
}
}
return nsnull;
}
void
nsContainerFrame::SyncFrameViewAfterReflow(nsIPresContext* aPresContext,
nsIFrame* aFrame,
@ -473,11 +492,10 @@ nsContainerFrame::SyncFrameViewAfterReflow(nsIPresContext* aPresContext,
// area, then size the view large enough to include those child
// frames
if ((kidState & NS_FRAME_OUTSIDE_CHILDREN) && aCombinedArea) {
vm->ResizeView(aView, aCombinedArea->XMost(), aCombinedArea->YMost());
vm->ResizeView(aView, *aCombinedArea);
} else {
nscoord width, height;
aView->GetDimensions(&width, &height);
nsRect bounds;
aView->GetBounds(bounds);
// If the width is unchanged and the height is not decreased then repaint only the
// newly exposed or contracted area, otherwise repaint the union of the old and new areas
@ -486,8 +504,9 @@ nsContainerFrame::SyncFrameViewAfterReflow(nsIPresContext* aPresContext,
// This is because some frames do not invalidate themselves properly. see bug 73825.
// Once bug 73825 is fixed, we should always pass PR_TRUE instead of
// frameSize.width == width && frameSize.height >= height.
vm->ResizeView(aView, frameSize.width, frameSize.height,
(frameSize.width == width && frameSize.height >= height));
nsRect newSize(0, 0, frameSize.width, frameSize.height);
vm->ResizeView(aView, newSize,
(frameSize.width == bounds.width && frameSize.height >= bounds.height));
}
}
@ -581,8 +600,7 @@ nsContainerFrame::SyncFrameViewAfterReflow(nsIPresContext* aPresContext,
autoZIndex = PR_TRUE;
}
vm->SetViewZIndex(aView, zIndex);
vm->SetViewAutoZIndex(aView, autoZIndex);
vm->SetViewZIndex(aView, autoZIndex, zIndex);
// There are two types of clipping:
// - 'clip' which only applies to absolutely positioned elements, and is
@ -647,21 +665,20 @@ nsContainerFrame::SyncFrameViewAfterReflow(nsIPresContext* aPresContext,
}
// Set clipping of child views.
if (hasClip) {
aView->SetChildClip(clipRect.x, clipRect.y, clipRect.XMost(), clipRect.YMost());
} else {
aView->SetChildClip(overflowClipRect.x, overflowClipRect.y,
overflowClipRect.XMost(), overflowClipRect.YMost());
nsIRegion *region = CreateRegion();
if (region != nsnull) {
if (hasClip) {
region->SetTo(clipRect.x, clipRect.y, clipRect.width, clipRect.height);
} else {
region->SetTo(overflowClipRect.x, overflowClipRect.y,
overflowClipRect.width, overflowClipRect.height);
}
vm->SetViewChildClipRegion(aView, region);
NS_RELEASE(region);
}
PRUint32 vflags;
aView->GetViewFlags(&vflags);
aView->SetViewFlags(vflags | NS_VIEW_PUBLIC_FLAG_CLIPCHILDREN);
} else {
// Remove clipping of child views.
PRUint32 vflags;
aView->GetViewFlags(&vflags);
aView->SetViewFlags(vflags & ~NS_VIEW_PUBLIC_FLAG_CLIPCHILDREN);
vm->SetViewChildClipRegion(aView, nsnull);
}
NS_RELEASE(vm);

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

@ -190,6 +190,9 @@ ReparentFrameViewTo(nsIPresContext* aPresContext,
{
nsIView* view;
// XXX What to do about placeholder views for "position: fixed" elements?
// They should be reparented too.
// Does aFrame have a view?
aFrame->GetView(aPresContext, &view);
if (view) {
@ -197,19 +200,11 @@ ReparentFrameViewTo(nsIPresContext* aPresContext,
//nsIView* parentView;
//NS_ASSERTION(parentView == aOldParentView, "unexpected parent view");
// Change the parent view.
PRInt32 zIndex;
view->GetZIndex(zIndex);
// Remove the view using it's parent instead
// of aOldParentView which is wrong.
nsIView* vp = nsnull;
view->GetParent(vp);
aViewManager->RemoveChild(vp, view);
aViewManager->RemoveChild(view);
// XXX We need to insert this view in the correct place within its z-order...
// XXX What should we do about the Z-placeholder-child if this frame is position:fixed?
aViewManager->InsertChild(aNewParentView, view, zIndex);
// The view will remember the Z-order and other attributes that have been set on it.
// XXX Pretend this view is last of the parent's views in document order
aViewManager->InsertChild(aNewParentView, view, nsnull, PR_TRUE);
} else {
// Iterate the child frames, and check each child frame to see if it has
// a view
@ -570,9 +565,7 @@ nsHTMLContainerFrame::CreateViewForFrame(nsIPresContext* aPresContext,
// If the frame has a fixed background attachment, then indicate that the
// view's contents should be repainted and not bitblt'd
if (fixedBackgroundAttachment) {
PRUint32 viewFlags;
view->GetViewFlags(&viewFlags);
view->SetViewFlags(viewFlags | NS_VIEW_PUBLIC_FLAG_DONT_BITBLT);
viewManager->SetViewBitBltEnabled(view, PR_FALSE);
}
// Insert the view into the view hierarchy. If the parent view is a
@ -590,12 +583,10 @@ nsHTMLContainerFrame::CreateViewForFrame(nsIPresContext* aPresContext,
} else if (position->mZIndex.GetUnit() == eStyleUnit_Auto) {
autoZIndex = PR_TRUE;
}
viewManager->InsertChild(parentView, view, zIndex);
if (autoZIndex) {
viewManager->SetViewAutoZIndex(view, PR_TRUE);
}
viewManager->SetViewZIndex(view, autoZIndex, zIndex);
// XXX Drop it at the end of the document order until we can do better
viewManager->InsertChild(parentView, view, nsnull, PR_TRUE);
if (nsnull != aContentParentFrame) {
// If, for some reason, GetView below fails to initialize zParentView,
@ -616,7 +607,7 @@ nsHTMLContainerFrame::CreateViewForFrame(nsIPresContext* aPresContext,
}
if (zParentView != parentView) {
viewManager->InsertZPlaceholder(zParentView, view, zIndex);
viewManager->InsertZPlaceholder(zParentView, view, nsnull, PR_TRUE);
}
}
}
@ -663,7 +654,7 @@ nsHTMLContainerFrame::CreateViewForFrame(nsIPresContext* aPresContext,
}
} else {
view->SetVisibility(nsViewVisibility_kHide);
viewManager->SetViewVisibility(view, nsViewVisibility_kHide);
}
// XXX If it's fixed positioned, then create a widget so it floats

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

@ -1249,9 +1249,14 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame,
aFrame->GetView(mPresContext, &view);
if (view) {
nsIViewManager *vm;
view->GetViewManager(vm);
vm->ResizeView(view, metrics.width, metrics.height);
#if 0 // XXX This is the correct code. We'll turn it on later to mitigate risk.
vm->ResizeView(view, pfd->mCombinedArea);
#else // imitate the old, wrong code
nsRect r(0, 0, metrics.width, metrics.height);
vm->ResizeView(view, r);
#endif
NS_RELEASE(vm);
}

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

@ -725,7 +725,9 @@ nsObjectFrame::CreateWidget(nsIPresContext* aPresContext,
viewMan->AllowDoubleBuffering(doubleBuffer);
#endif
viewMan->InsertChild(parView, view, 0);
// XXX Put this last in document order
// XXX Should we be setting the z-index here?
viewMan->InsertChild(parView, view, nsnull, PR_TRUE);
if(aViewOnly != PR_TRUE) {
@ -764,9 +766,11 @@ nsObjectFrame::CreateWidget(nsIPresContext* aPresContext,
nsIView* parentWithView;
nsPoint origin;
view->SetVisibility(nsViewVisibility_kShow);
nsRect r(0, 0, mRect.width, mRect.height);
viewMan->SetViewVisibility(view, nsViewVisibility_kShow);
GetOffsetFromView(aPresContext, origin, &parentWithView);
viewMan->ResizeView(view, mRect.width, mRect.height);
viewMan->ResizeView(view, r);
viewMan->MoveViewTo(view, origin.x, origin.y);
}
@ -1471,7 +1475,11 @@ nsObjectFrame::DidReflow(nsIPresContext* aPresContext,
nsIView* view = nsnull;
GetView(aPresContext, &view);
if (nsnull != view) {
view->SetVisibility(nsViewVisibility_kShow);
nsCOMPtr<nsIViewManager> vm;
view->GetViewManager(*getter_AddRefs(vm));
if (vm) {
vm->SetViewVisibility(view, nsViewVisibility_kShow);
}
}
if (nsnull != mInstanceOwner) {
@ -3575,7 +3583,12 @@ NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void)
view->GetWidget(mWidget);
PRBool fTransparent;
mInstance->GetValue(nsPluginInstanceVariable_TransparentBool, (void *)&fTransparent);
view->SetContentTransparency(fTransparent);
nsCOMPtr<nsIViewManager> vm;
view->GetViewManager(*getter_AddRefs(vm));
if (vm) {
vm->SetViewContentTransparency(view, fTransparent);
}
}
if (PR_TRUE == windowless)

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

@ -4135,9 +4135,9 @@ PresShell::ScrollFrameIntoView(nsIFrame *aFrame,
const nsIView* clipView;
nsRect visibleRect;
scrollingView->GetScrollPosition(visibleRect.x, visibleRect.y);
scrollingView->GetClipView(&clipView);
clipView->GetDimensions(&visibleRect.width, &visibleRect.height);
clipView->GetBounds(visibleRect); // get width and height
scrollingView->GetScrollPosition(visibleRect.x, visibleRect.y);
// The actual scroll offsets
nscoord scrollOffsetX = visibleRect.x;

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

@ -141,7 +141,10 @@ nsScrollFrame::GetClipSize( nsIPresContext* aPresContext,
if (NS_SUCCEEDED(CallQueryInterface(view, &scrollingView))) {
const nsIView* clip = nsnull;
scrollingView->GetClipView(&clip);
clip->GetDimensions(aWidth, aHeight);
nsRect r;
clip->GetBounds(r);
*aWidth = r.width;
*aHeight = r.height;
} else {
*aWidth = 0;
*aHeight = 0;
@ -426,9 +429,12 @@ nsScrollFrame::CreateScrollingView(nsIPresContext* aPresContext)
// Get the z-index
PRInt32 zIndex = 0;
PRBool autoZIndex = PR_FALSE;
if (eStyleUnit_Integer == position->mZIndex.GetUnit()) {
zIndex = position->mZIndex.GetIntValue();
} else if (position->mZIndex.GetUnit() == eStyleUnit_Auto) {
autoZIndex = PR_TRUE;
}
// Initialize the scrolling view
@ -437,8 +443,12 @@ nsScrollFrame::CreateScrollingView(nsIPresContext* aPresContext)
nsViewVisibility_kShow :
nsViewVisibility_kHide);
// Initialize the view's z-index
viewManager->SetViewZIndex(view, autoZIndex, zIndex);
// Insert the view into the view hierarchy
viewManager->InsertChild(parentView, view, zIndex);
// XXX Put it last in document order, until we can do better
viewManager->InsertChild(parentView, view, nsnull, PR_TRUE);
// Set the view's opacity
viewManager->SetViewOpacity(view, vis->mOpacity);

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

@ -51,6 +51,7 @@
#include "nsIPrintOptions.h"
#include "nsPageFrame.h"
#include "nsIPrintPreviewContext.h"
#include "nsIRegion.h"
#include "nsIPref.h" // for header/footer gap & ExtraMargin for Print Preview
@ -78,6 +79,7 @@ static NS_DEFINE_CID(kLocaleServiceCID, NS_LOCALESERVICE_CID);
#include "nsIServiceManager.h"
static NS_DEFINE_CID(kPrintOptionsCID, NS_PRINTOPTIONS_CID);
//
static NS_DEFINE_CID(kRegionCID, NS_REGION_CID);
#if defined(DEBUG_rods) || defined(DEBUG_dcone)
#define DEBUG_PRINTING
@ -578,6 +580,20 @@ nsSimplePageSequenceFrame::SetPageNumberFormat(const char* aPropName, const char
}
static nsIRegion* CreateRegion()
{
nsIRegion* region;
nsresult rv = nsComponentManager::CreateInstance(kRegionCID, nsnull, NS_GET_IID(nsIRegion), (void**)&region);
if (NS_SUCCEEDED(rv)) {
if (NS_SUCCEEDED(region->Init())) {
return region;
} else {
NS_RELEASE(region);
}
}
return nsnull;
}
NS_IMETHODIMP
nsSimplePageSequenceFrame::StartPrint(nsIPresContext* aPresContext,
nsIPrintOptions* aPrintOptions)
@ -662,29 +678,39 @@ nsSimplePageSequenceFrame::StartPrint(nsIPresContext* aPresContext,
PRInt32 pageNum = 1;
nscoord y = 0;//mMargin.top;
nsCOMPtr<nsIRegion> emptyRegion = getter_AddRefs(CreateRegion());
for (nsIFrame* page = mFrames.FirstChild(); nsnull != page; page->GetNextSibling(&page)) {
nsIView* view;
nsIView* view = nsnull;
page->GetView(aPresContext, &view);
NS_ASSERTION(nsnull != view, "no page view");
nsCOMPtr<nsIViewManager> vm;
view->GetViewManager(*getter_AddRefs(vm));
NS_ASSERTION(nsnull != vm, "no view manager");
if (pageNum < mFromPageNum || pageNum > mToPageNum) {
// Hide the pages that won't be printed to the Viewmanager
// doesn't put them in the display list. Also, makde
// sure the child views don't get asked to print
// but my guess is that there won't be any
view->SetVisibility(nsViewVisibility_kHide);
view->SetChildClip(0,0,0,0);
view->SetViewFlags(NS_VIEW_PUBLIC_FLAG_CLIPCHILDREN);
vm->SetViewVisibility(view, nsViewVisibility_kHide);
vm->SetViewChildClipRegion(view, emptyRegion);
} else {
nsRect rect;
page->GetRect(rect);
rect.y = y;
rect.height = height;
page->SetRect(aPresContext, rect);
nsRect viewRect;
view->GetBounds(viewRect);
viewRect.y = y;
viewRect.height = height;
view->SetBounds(viewRect);
vm->MoveViewTo(view, viewRect.x, viewRect.y);
viewRect.x = 0;
viewRect.y = 0;
vm->ResizeView(view, viewRect);
y += rect.height + mMargin.top + mMargin.bottom;
}
pageNum++;
@ -836,7 +862,10 @@ nsSimplePageSequenceFrame::PrintNextPage(nsIPresContext* aPresContext,
containerView->GetBounds(containerRect);
containerRect.y -= mYSelOffset;
containerRect.height = height-mYSelOffset;
containerView->SetBounds(containerRect, PR_FALSE);
vm->MoveViewTo(containerView, containerRect.x, containerRect.y);
nsRect r(0, 0, containerRect.width, containerRect.height);
vm->ResizeView(containerView, r, PR_FALSE);
clipRect.SetRect(mMargin.left, mMargin.right, width, height);
nsPageFrame * pf = NS_STATIC_CAST(nsPageFrame*, childFrame);
@ -862,7 +891,7 @@ nsSimplePageSequenceFrame::PrintNextPage(nsIPresContext* aPresContext,
PRINT_DEBUG_MSG4("SeqFr::Paint -> %p PageNo: %d View: %p", pf, mPageNum, view);
PRINT_DEBUG_MSG3(" At: %d,%d\n", mMargin.left+mOffsetX, mMargin.top+mOffsetY);
view->SetContentTransparency(PR_FALSE);
vm->SetViewContentTransparency(view, PR_FALSE);
vm->Display(view, mOffsetX, mOffsetY, clipRect);
@ -889,8 +918,9 @@ nsSimplePageSequenceFrame::PrintNextPage(nsIPresContext* aPresContext,
pf->SetPageNumInfo(mPrintedPageNum, mTotalPages);
containerRect.y -= height;
containerRect.height += height;
containerView->SetBounds(containerRect, PR_FALSE);
vm->MoveViewTo(containerView, containerRect.x, containerRect.y);
nsRect r(0, 0, containerRect.width, containerRect.height);
vm->ResizeView(containerView, r, PR_FALSE);
} else {
continuePrinting = PR_FALSE;
}

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

@ -978,8 +978,13 @@ nsHTMLFrameInnerFrame::DidReflow(nsIPresContext* aPresContext,
nsViewVisibility oldVis;
// only change if different.
view->GetVisibility(oldVis);
if (newVis != oldVis)
view->SetVisibility(newVis);
if (newVis != oldVis) {
nsCOMPtr<nsIViewManager> vm;
view->GetViewManager(*getter_AddRefs(vm));
if (vm != nsnull) {
vm->SetViewVisibility(view, newVis);
}
}
}
}
@ -1352,7 +1357,8 @@ nsHTMLFrameInnerFrame::CreateViewAndWidget(nsIPresContext* aPresContext,
nsCOMPtr<nsIViewManager> viewMan;
presShell->GetViewManager(getter_AddRefs(viewMan));
rv = view->Init(viewMan, viewBounds, parView);
viewMan->InsertChild(parView, view, 0);
// XXX put it at the end of the document order until we can do better
viewMan->InsertChild(parView, view, nsnull, PR_TRUE);
nsWidgetInitData initData;
initData.clipChildren = PR_TRUE;
@ -1365,7 +1371,7 @@ nsHTMLFrameInnerFrame::CreateViewAndWidget(nsIPresContext* aPresContext,
const nsStyleVisibility* vis;
GetStyleData(eStyleStruct_Visibility, ((const nsStyleStruct *&)vis));
if (!vis->IsVisible()) {
view->SetVisibility(nsViewVisibility_kHide);
viewMan->SetViewVisibility(view, nsViewVisibility_kHide);
}
view->GetWidget(*aWidget);
return rv;

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

@ -351,7 +351,8 @@ nsHTMLFramesetFrame::Init(nsIPresContext* aPresContext,
parWithView->GetView(aPresContext, &parView);
nsRect boundBox(0, 0, 0, 0);
result = view->Init(viewMan, boundBox, parView);
viewMan->InsertChild(parView, view, 0);
// XXX Put it last in document order until we can do better
viewMan->InsertChild(parView, view, nsnull, PR_TRUE);
SetView(aPresContext, view);
nsCOMPtr<nsIPresShell> shell;
@ -1600,16 +1601,15 @@ nsHTMLFramesetFrame::StartMouseDrag(nsIPresContext* aPresContext,
nsIView* view;
GetView(aPresContext, &view);
if (view) {
nsIViewManager* viewMan;
view->GetViewManager(viewMan);
nsCOMPtr<nsIViewManager> viewMan;
view->GetViewManager(*getter_AddRefs(viewMan));
if (viewMan) {
PRBool ignore;
viewMan->GrabMouseEvents(view, ignore);
NS_RELEASE(viewMan);
mDragger = aBorder;
//XXX This should go away! Border should have own view instead
view->SetViewFlags(NS_VIEW_PUBLIC_FLAG_DONT_CHECK_CHILDREN);
viewMan->SetViewCheckChildEvents(view, PR_FALSE);
// The point isn't in frameset coords, but we're using it to compute
// moves relative to the start position.
@ -1686,7 +1686,7 @@ nsHTMLFramesetFrame::MouseDrag(nsIPresContext* aPresContext,
nsIView* root;
vm->GetRootView(root);
if (root) {
vm->UpdateView(root, NS_VMREFRESH_IMMEDIATE | NS_VMREFRESH_AUTO_DOUBLE_BUFFER);
vm->UpdateView(root, NS_VMREFRESH_IMMEDIATE);
}
}
}
@ -1698,15 +1698,14 @@ nsHTMLFramesetFrame::EndMouseDrag(nsIPresContext* aPresContext)
nsIView* view;
GetView(aPresContext, &view);
if (view) {
nsIViewManager* viewMan;
view->GetViewManager(viewMan);
nsCOMPtr<nsIViewManager> viewMan;
view->GetViewManager(*getter_AddRefs(viewMan));
if (viewMan) {
mDragger = nsnull;
PRBool ignore;
viewMan->GrabMouseEvents(nsnull, ignore);
NS_RELEASE(viewMan);
//XXX This should go away! Border should have own view instead
view->ClearViewFlags(NS_VIEW_PUBLIC_FLAG_DONT_CHECK_CHILDREN);
viewMan->SetViewCheckChildEvents(view, PR_TRUE);
}
}
gDragInProgress = PR_FALSE;

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

@ -555,7 +555,8 @@ nsComboboxControlFrame::ShowPopup(PRBool aShowPopup)
if (aShowPopup) {
nsRect rect;
mDropdownFrame->GetRect(rect);
viewManager->ResizeView(view, rect.width, rect.height);
rect.x = rect.y = 0;
viewManager->ResizeView(view, rect);
nsIScrollableView* scrollingView;
if (NS_SUCCEEDED(view->QueryInterface(NS_GET_IID(nsIScrollableView), (void**)&scrollingView))) {
scrollingView->ComputeScrollOffsets(PR_TRUE);
@ -563,7 +564,8 @@ nsComboboxControlFrame::ShowPopup(PRBool aShowPopup)
viewManager->SetViewVisibility(view, nsViewVisibility_kShow);
} else {
viewManager->SetViewVisibility(view, nsViewVisibility_kHide);
viewManager->ResizeView(view, 0, 0);
nsRect emptyRect(0, 0, 0, 0);
viewManager->ResizeView(view, emptyRect);
}
// fire a popup dom event
@ -659,7 +661,8 @@ nsComboboxControlFrame::ReflowComboChildFrame(nsIFrame* aFrame,
nsCOMPtr<nsIViewManager> viewManager;
view->GetViewManager(*getter_AddRefs(viewManager));
viewManager->SetViewVisibility(view, nsViewVisibility_kHide);
viewManager->ResizeView(view, 0, 0);
nsRect emptyRect(0, 0, 0, 0);
viewManager->ResizeView(view, emptyRect);
}
// Reflow child

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

@ -519,8 +519,13 @@ nsFormControlFrame::DidReflow(nsIPresContext* aPresContext,
nsViewVisibility oldVis;
// only change if different.
view->GetVisibility(oldVis);
if (newVis != oldVis)
view->SetVisibility(newVis);
if (newVis != oldVis) {
nsCOMPtr<nsIViewManager> vm;
view->GetViewManager(*getter_AddRefs(vm));
if (vm) {
vm->SetViewVisibility(view, newVis);
}
}
}
}

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

@ -293,8 +293,9 @@ nsImageControlFrame::Init(nsIPresContext* aPresContext,
// the view's size is not know yet, but its size will be kept in synch with our frame.
nsRect boundBox(0, 0, 0, 0);
result = view->Init(viewMan, boundBox, parView);
view->SetContentTransparency(PR_TRUE);
viewMan->InsertChild(parView, view, 0);
viewMan->SetViewContentTransparency(view, PR_TRUE);
// XXX put the view last in document order until we know how to do better
viewMan->InsertChild(parView, view, nsnull, PR_TRUE);
SetView(aPresContext, view);
const nsStyleVisibility* vis = (const nsStyleVisibility*) mStyleContext->GetStyleData(eStyleStruct_Visibility);

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

@ -2226,8 +2226,11 @@ nsresult
nsListControlFrame::CreateScrollingViewWidget(nsIView* aView, const nsStyleDisplay* aDisplay)
{
if (IsInDropDownMode() == PR_TRUE) {
nsCOMPtr<nsIViewManager> vm;
aView->GetViewManager(*getter_AddRefs(vm));
vm->SetViewFloating(aView, PR_TRUE);
nsWidgetInitData widgetData;
aView->SetFloating(PR_TRUE);
widgetData.mWindowType = eWindowType_popup;
widgetData.mBorderStyle = eBorderStyle_default;
@ -2297,13 +2300,13 @@ nsListControlFrame::SyncViewWithFrame(nsIPresContext* aPresContext)
//nsSize size;
//GetSize(size);
nscoord width;
nscoord height;
view->GetDimensions(&width, &height);
//nscoord width;
//nscoord height;
//view->GetDimensions(&width, &height);
if (width != mRect.width || height != mRect.height) {
//if (width != mRect.width || height != mRect.height) {
//viewManager->ResizeView(view, mRect.width, mRect.height);
}
//}
nscoord x;
nscoord y;
view->GetPosition(&x, &y);

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

@ -3378,9 +3378,11 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsIPresShell* aPresShell,
// Not all shells have scroll frames, even in scrollable presContext (bug 30317)
if (view) {
PRUint32 viewFlags;
view->GetViewFlags(&viewFlags);
view->SetViewFlags(viewFlags | NS_VIEW_PUBLIC_FLAG_DONT_BITBLT);
nsCOMPtr<nsIViewManager> vm;
view->GetViewManager(*getter_AddRefs(vm));
if (vm) {
vm->SetViewBitBltEnabled(view, PR_FALSE);
}
}
}

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

@ -2421,9 +2421,9 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext,
rootFrame->GetView(aPresContext, &viewportView);
NS_ASSERTION(viewportView, "no viewport view");
viewportView->GetBounds(viewportArea);
viewportArea.x = 0;
viewportArea.y = 0;
viewportView->GetDimensions(&viewportArea.width, &viewportArea.height);
}
// Get the anchor point

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

@ -802,20 +802,22 @@ nsBox::CollapseChild(nsBoxLayoutState& aState, nsIFrame* aFrame, PRBool aHide)
// will be clipped.
if (view) {
// already hidden? We are done.
nsViewVisibility v;
view->GetVisibility(v);
//nsViewVisibility v;
//view->GetVisibility(v);
//if (v == nsViewVisibility_kHide)
//return NS_OK;
nsCOMPtr<nsIViewManager> vm;
view->GetViewManager(*getter_AddRefs(vm));
if (aHide) {
vm->SetViewVisibility(view, nsViewVisibility_kHide);
} else {
vm->SetViewVisibility(view, nsViewVisibility_kShow);
}
nsCOMPtr<nsIWidget> widget;
view->GetWidget(*getter_AddRefs(widget));
if (aHide) {
view->SetVisibility(nsViewVisibility_kHide);
} else {
view->SetVisibility(nsViewVisibility_kShow);
}
if (widget) {
return NS_OK;
}
}

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

@ -2615,9 +2615,7 @@ nsBoxFrame::CreateViewForFrame(nsIPresContext* aPresContext,
// If the frame has a fixed background attachment, then indicate that the
// view's contents should be repainted and not bitblt'd
if (fixedBackgroundAttachment) {
PRUint32 viewFlags;
view->GetViewFlags(&viewFlags);
view->SetViewFlags(viewFlags | NS_VIEW_PUBLIC_FLAG_DONT_BITBLT);
viewManager->SetViewBitBltEnabled(view, PR_FALSE);
}
// Insert the view into the view hierarchy. If the parent view is a
@ -2626,11 +2624,9 @@ nsBoxFrame::CreateViewForFrame(nsIPresContext* aPresContext,
if (NS_SUCCEEDED(parentView->QueryInterface(NS_GET_IID(nsIScrollableView), (void**)&scrollingView))) {
scrollingView->SetScrolledView(view);
} else {
viewManager->InsertChild(parentView, view, zIndex);
if (autoZIndex) {
viewManager->SetViewAutoZIndex(view, PR_TRUE);
}
viewManager->SetViewZIndex(view, autoZIndex, zIndex);
// XXX put view last in document order until we can do better
viewManager->InsertChild(parentView, view, nsnull, PR_TRUE);
}
// See if the view should be hidden
@ -2683,7 +2679,7 @@ nsBoxFrame::CreateViewForFrame(nsIPresContext* aPresContext,
}
} else {
view->SetVisibility(nsViewVisibility_kHide);
viewManager->SetViewVisibility(view, nsViewVisibility_kHide);
}
viewManager->SetViewOpacity(view, vis->mOpacity);

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

@ -230,7 +230,8 @@ nsDeckFrame::HideBox(nsIPresContext* aPresContext, nsIBox* aBox)
nsCOMPtr<nsIViewManager> viewManager;
view->GetViewManager(*getter_AddRefs(viewManager));
viewManager->SetViewVisibility(view, nsViewVisibility_kHide);
viewManager->ResizeView(view, 0, 0);
nsRect r(0, 0, 0, 0);
viewManager->ResizeView(view, r);
}
}
@ -247,7 +248,8 @@ nsDeckFrame::ShowBox(nsIPresContext* aPresContext, nsIBox* aBox)
if (view) {
nsCOMPtr<nsIViewManager> viewManager;
view->GetViewManager(*getter_AddRefs(viewManager));
viewManager->ResizeView(view, rect.width, rect.height);
rect.x = rect.y = 0;
viewManager->ResizeView(view, rect);
viewManager->SetViewVisibility(view, nsViewVisibility_kShow);
}
}

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

@ -639,7 +639,8 @@ nsMenuFrame::ActivateMenu(PRBool aActivateFlag)
menuPopup->GetView(mPresContext, &view);
nsCOMPtr<nsIViewManager> viewManager;
view->GetViewManager(*getter_AddRefs(viewManager));
viewManager->ResizeView(view, rect.width, rect.height);
rect.x = rect.y = 0;
viewManager->ResizeView(view, rect);
// make sure the scrolled window is at 0,0
if (mLastPref.height <= rect.height) {
@ -652,7 +653,7 @@ nsMenuFrame::ActivateMenu(PRBool aActivateFlag)
}
}
viewManager->UpdateView(view, nsRect(0,0, rect.width, rect.height), NS_VMREFRESH_IMMEDIATE);
viewManager->UpdateView(view, rect, NS_VMREFRESH_IMMEDIATE);
viewManager->SetViewVisibility(view, nsViewVisibility_kShow);
} else {
@ -663,7 +664,8 @@ nsMenuFrame::ActivateMenu(PRBool aActivateFlag)
nsCOMPtr<nsIViewManager> viewManager;
view->GetViewManager(*getter_AddRefs(viewManager));
viewManager->SetViewVisibility(view, nsViewVisibility_kHide);
viewManager->ResizeView(view, 0, 0);
nsRect r(0, 0, 0, 0);
viewManager->ResizeView(view, r);
}
// set here so hide chain can close the menu as well.
mMenuOpen = PR_FALSE;
@ -813,7 +815,11 @@ nsMenuFrame::OpenMenuInternal(PRBool aActivateFlag)
nsIView* view = nsnull;
menuPopup->GetView(mPresContext, &view);
view->SetVisibility(nsViewVisibility_kHide);
nsCOMPtr<nsIViewManager> vm;
view->GetViewManager(*getter_AddRefs(vm));
if (vm) {
vm->SetViewVisibility(view, nsViewVisibility_kHide);
}
menuPopup->SyncViewWithFrame(mPresContext, popupAnchor, popupAlign, this, -1, -1);
nsRect rect;
menuPopup->GetBounds(rect);
@ -991,7 +997,8 @@ nsMenuFrame::DoLayout(nsBoxLayoutState& aState)
popupChild->GetView(aState.GetPresContext(), &view);
nsCOMPtr<nsIViewManager> viewManager;
view->GetViewManager(*getter_AddRefs(viewManager));
viewManager->ResizeView(view, bounds.width, bounds.height);
nsRect r(0, 0, bounds.width, bounds.height);
viewManager->ResizeView(view, r);
}
}

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

@ -187,26 +187,22 @@ nsMenuPopupFrame::Init(nsIPresContext* aPresContext,
nsIView* ourView;
GetView(aPresContext, &ourView);
nsIFrame* parent;
GetParentWithView(aPresContext, &parent);
nsIView* parentView;
parent->GetView(aPresContext, &parentView);
nsCOMPtr<nsIViewManager> viewManager;
parentView->GetViewManager(*getter_AddRefs(viewManager));
ourView->GetViewManager(*getter_AddRefs(viewManager));
// Remove the view from its old position.
viewManager->RemoveChild(parentView, ourView);
viewManager->RemoveChild(ourView);
// Reinsert ourselves as the root view with a maximum z-index.
nsIView* rootView;
viewManager->GetRootView(rootView);
viewManager->InsertChild(rootView, ourView, kMaxZ);
viewManager->SetViewZIndex(ourView, PR_FALSE, kMaxZ);
viewManager->InsertChild(rootView, ourView, nsnull, PR_TRUE);
// XXX Hack. The menu's view should float above all other views,
// so we use the nsIView::SetFloating() to tell the view manager
// about that constraint.
ourView->SetFloating(PR_TRUE);
viewManager->SetViewFloating(ourView, PR_TRUE);
// XXX Hack. Change our transparency to be non-transparent
// until the bug related to update of transparency on show/hide
@ -215,12 +211,11 @@ nsMenuPopupFrame::Init(nsIPresContext* aPresContext,
// Create a widget for ourselves.
nsWidgetInitData widgetData;
ourView->SetZIndex(kMaxZ);
widgetData.mWindowType = eWindowType_popup;
widgetData.mBorderStyle = eBorderStyle_default;
// XXX make sure we are hidden (shouldn't this be done automatically?)
ourView->SetVisibility(nsViewVisibility_kHide);
viewManager->SetViewVisibility(ourView, nsViewVisibility_kHide);
#if defined(XP_MAC) || defined(XP_MACOSX)
printf("XP Popups: This is a nag to indicate that an inconsistent hack is being done on the Mac for popups.\n");
static NS_DEFINE_IID(kCPopupCID, NS_POPUP_CID);

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

@ -256,7 +256,8 @@ nsPopupSetFrame::DoLayout(nsBoxLayoutState& aState)
popupChild->GetView(aState.GetPresContext(), &view);
nsCOMPtr<nsIViewManager> viewManager;
view->GetViewManager(*getter_AddRefs(viewManager));
viewManager->ResizeView(view, bounds.width, bounds.height);
nsRect r(0, 0, bounds.width, bounds.height);
viewManager->ResizeView(view, r);
viewManager->SetViewVisibility(view, nsViewVisibility_kShow);
}
}
@ -510,7 +511,8 @@ nsPopupSetFrame::ActivatePopup(nsPopupFrameList* aEntry, PRBool aActivateFlag)
nsCOMPtr<nsIViewManager> viewManager;
view->GetViewManager(*getter_AddRefs(viewManager));
viewManager->SetViewVisibility(view, nsViewVisibility_kHide);
viewManager->ResizeView(view, 0, 0);
nsRect r(0, 0, 0, 0);
viewManager->ResizeView(view, r);
}
}
}

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

@ -272,17 +272,22 @@ nsScrollBoxFrame::CreateScrollingView(nsIPresContext* aPresContext)
// Get the z-index
PRInt32 zIndex = 0;
PRBool autoZIndex = PR_FALSE;
if (eStyleUnit_Integer == position->mZIndex.GetUnit()) {
zIndex = position->mZIndex.GetIntValue();
} else if (eStyleUnit_Auto == position->mZIndex.GetUnit()) {
autoZIndex = PR_TRUE;
}
// Initialize the scrolling view
view->Init(viewManager, mRect, parentView, vis->IsVisibleOrCollapsed() ?
nsViewVisibility_kShow : nsViewVisibility_kHide);
viewManager->SetViewZIndex(view, autoZIndex, zIndex);
// Insert the view into the view hierarchy
viewManager->InsertChild(parentView, view, zIndex);
// XXX Put view last in document order until we know how to do better
viewManager->InsertChild(parentView, view, nsnull, PR_TRUE);
// Set the view's opacity
viewManager->SetViewOpacity(view, vis->mOpacity);
@ -425,7 +430,8 @@ nsScrollBoxFrame::DoLayout(nsBoxLayoutState& aState)
frame->GetView(presContext, &view);
nsCOMPtr<nsIViewManager> vm;
view->GetViewManager(*getter_AddRefs(vm));
vm->ResizeView(view, childRect.width, childRect.height);
nsRect r(0, 0, childRect.width, childRect.height);
vm->ResizeView(view, r);
}
nsIScrollableView* scrollingView;

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

@ -45,6 +45,7 @@
#include "nsScrollbarFrame.h"
#include "nsScrollbarButtonFrame.h"
#include "nsIView.h"
#include "nsIViewManager.h"
//
@ -87,7 +88,9 @@ nsScrollbarFrame::Init(nsIPresContext* aPresContext,
CreateViewForFrame(aPresContext,this,aContext,PR_TRUE);
nsIView* view;
GetView(aPresContext, &view);
view->SetContentTransparency(PR_TRUE);
nsCOMPtr<nsIViewManager> vm;
view->GetViewManager(*getter_AddRefs(vm));
vm->SetViewContentTransparency(view, PR_TRUE);
return rv;
}

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

@ -133,7 +133,9 @@ nsSliderFrame::Init(nsIPresContext* aPresContext,
CreateViewForFrame(aPresContext,this,aContext,PR_TRUE);
nsIView* view;
GetView(aPresContext, &view);
view->SetContentTransparency(PR_TRUE);
nsCOMPtr<nsIViewManager> vm;
view->GetViewManager(*getter_AddRefs(vm));
vm->SetViewContentTransparency(view, PR_TRUE);
// XXX Hack
mPresContext = aPresContext;
return rv;

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

@ -372,17 +372,14 @@ nsSplitterFrame::Init(nsIPresContext* aPresContext,
nsIView* view;
GetView(aPresContext, &view);
if (realTimeDrag) {
view->SetContentTransparency(PR_TRUE);
view->SetZIndex(kMaxZ);
}
else {
nsCOMPtr<nsIViewManager> viewManager;
view->GetViewManager(*getter_AddRefs(viewManager));
viewManager->SetViewContentTransparency(view, PR_TRUE);
viewManager->SetViewZIndex(view, PR_FALSE, kMaxZ);
if (!realTimeDrag) {
// currently this only works on win32 and mac
static NS_DEFINE_CID(kCChildCID, NS_CHILD_CID);
nsCOMPtr<nsIViewManager> viewManager;
view->GetViewManager(*getter_AddRefs(viewManager));
viewManager->SetViewContentTransparency(view, PR_TRUE);
viewManager->SetViewZIndex(view, kMaxZ);
// Need to have a widget to appear on top of other widgets.
view->CreateWidget(kCChildCID);

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

@ -724,7 +724,7 @@ nsXULTreeGroupFrame :: ForceDrawFrame(nsIPresContext* aPresContext, nsIFrame * a
nsCOMPtr<nsIViewManager> viewMgr;
view->GetViewManager(*getter_AddRefs(viewMgr));
if (viewMgr)
viewMgr->UpdateView(view, rect, NS_VMREFRESH_AUTO_DOUBLE_BUFFER | NS_VMREFRESH_IMMEDIATE);
viewMgr->UpdateView(view, rect, NS_VMREFRESH_IMMEDIATE);
}
} // ForceDrawFrame

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

@ -7,7 +7,6 @@ nsIViewManager.h
nsIScrollableView.h
nsViewsCID.h
nsIViewObserver.h
nsIClipView.h
nsIScrollPositionListener.h
nsICompositeListener.h
nsIEventProcessor.h

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

@ -34,7 +34,6 @@ EXPORTS = \
nsIScrollableView.h \
nsViewsCID.h \
nsIViewObserver.h \
nsIClipView.h \
nsIScrollPositionListener.h \
nsICompositeListener.h \
nsIEventProcessor.h \

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

@ -24,7 +24,7 @@ DEPTH=..\..
DEFINES=-D_IMPL_NS_UI
EXPORTS=nsIView.h nsIViewManager.h nsIScrollableView.h nsViewsCID.h nsIViewObserver.h \
nsIClipView.h nsIScrollPositionListener.h nsICompositeListener.h nsIEventProcessor.h
nsIScrollPositionListener.h nsICompositeListener.h nsIEventProcessor.h
MODULE=view
include <$(DEPTH)\config\rules.mak>

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

@ -38,13 +38,6 @@
#ifndef nsIClipView_h___
#define nsIClipView_h___
#include "nsISupports.h"
// IID for the nsIClipView interface
#define NS_ICLIPVIEW_IID \
{ 0x4cc36160, 0xd282, 0x11d2, \
{ 0x90, 0x67, 0x00, 0x60, 0xb0, 0xf1, 0x99, 0xa2 } }
/**
* this is here so that we can query a view to see if it
* exists for clipping.
@ -89,10 +82,5 @@
* But a bugger when he's pissed
*
*/
class nsIClipView : public nsISupports
{
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ICLIPVIEW_IID)
};
#endif

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

@ -30,6 +30,7 @@ class nsIView;
class nsIViewManager;
class nsIRenderingContext;
class nsIRegion;
struct nsRect;
// IID for the nsICompositeListener interface
// {5661ce55-7c42-11d3-009d-1d060b0f8baff}

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

@ -38,44 +38,23 @@
#ifndef nsIView_h___
#define nsIView_h___
#include <stdio.h>
#include "nsISupports.h"
#include "nsCoord.h"
#include "nsEvent.h"
#include <stdio.h>
struct nsGUIEvent;
class nsIViewManager;
class nsIWidget;
struct nsWidgetInitData;
typedef void* nsNativeWidget;
class nsIViewManager;
class nsIRegion;
class nsIRenderingContext;
class nsTransform2D;
class nsIFrame;
class nsIViewObserver;
class nsVoidArray;
struct nsRect;
//this is used by the view clipping APIs since the description of
//a clip rect is different than a rect
struct nsViewClip {
nscoord mLeft;
nscoord mRight;
nscoord mTop;
nscoord mBottom;
};
// Enumerated type to indicate the visibility of a layer.
// hide - the layer is not shown.
// show - the layer is shown irrespective of the visibility of
// the layer's parent.
// inherit - the layer inherits its visibility from its parent.
enum nsViewVisibility {
nsViewVisibility_kHide = 0,
nsViewVisibility_kShow = 1,
nsViewVisibility_kInherit = 2
nsViewVisibility_kShow = 1
};
// IID for the nsIView interface
@ -89,10 +68,13 @@ enum nsViewVisibility {
* View interface
*
* Views are NOT reference counted. Use the Destroy() member function to
* destroy a frame.
* destroy a view.
*
* The lifetime of the view hierarchy is bounded by the lifetime of the
* view manager that owns the views.
*
* Most of the methods here are read-only. To set the corresponding properties
* of a view, go through nsIViewManager.
*/
class nsIView : public nsISupports
{
@ -128,172 +110,53 @@ public:
NS_IMETHOD Destroy() = 0;
/**
* Get the view manager the "owns" the view
* @result view manager
* Get the view manager which "owns" the view.
* This method might require some expensive traversal work in the future. If you can get the
* view manager from somewhere else, do that instead.
* @result the view manager
*/
NS_IMETHOD GetViewManager(nsIViewManager *&aViewMgr) const = 0;
/**
* Called to indicate that the specified rect of the view
* needs to be drawn via the rendering context. The rect
* is specified in view coordinates.
* @param rc rendering context to paint into
* @param rect damage area
* @param aPaintFlags see nsIView.h for flag definitions
* @return PR_TRUE if the entire clip region has been eliminated, else PR_FALSE
*/
NS_IMETHOD Paint(nsIRenderingContext& rc, const nsRect& rect,
PRUint32 aPaintFlags, PRBool &aResult) = 0;
/**
* Called to indicate that the specified region of the view
* needs to be drawn via the rendering context. The region
* is specified in view coordinates.
* @param rc rendering context to paint into
* @param region damage area
* @param aPaintFlags see nsIView.h for flag definitions
* @return PR_TRUE if the entire clip region has been eliminated, else PR_FALSE
*/
NS_IMETHOD Paint(nsIRenderingContext& rc, const nsIRegion& region,
PRUint32 aPaintFlags, PRBool &aResult) = 0;
/**
* Called to indicate that the specified event should be handled
* by the view. This method should return nsEventStatus_eConsumeDoDefault
* or nsEventStatus_eConsumeNoDefault if the event has been handled.
* @param event event to process
* @param aEventFlags see nsIView.h for flag definitions
* @result processing status
*/
NS_IMETHOD HandleEvent(nsGUIEvent *event,
PRUint32 aEventFlags,
nsEventStatus* aStatus,
PRBool aForceHandle,
PRBool& aHandled) = 0;
/**
* Called to indicate that the position of the view has been changed.
* The specified coordinates are in the parent view's coordinate space.
* @param x new x position
* @param y new y position
*/
NS_IMETHOD SetPosition(nscoord x, nscoord y) = 0;
/**
* Called to get the position of a view.
* The specified coordinates are in the parent view's coordinate space.
* This is the (0, 0) origin of the coordinate space established by this view.
* @param x out parameter for x position
* @param y out parameter for y position
*/
NS_IMETHOD GetPosition(nscoord *x, nscoord *y) const = 0;
NS_IMETHOD GetPosition(nscoord *aX, nscoord *aY) const = 0;
/**
* Called to indicate that the dimensions of the view (actually the
* width and height of the clip) have been changed.
* @param width new width
* @param height new height
*/
NS_IMETHOD SetDimensions(nscoord width, nscoord height, PRBool aPaint = PR_TRUE) = 0;
NS_IMETHOD GetDimensions(nscoord *width, nscoord *height) const = 0;
/**
* Called to indicate that the dimensions and position of the view have
* been changed.
* @param aBounds new bounds
*/
NS_IMETHOD SetBounds(const nsRect &aBounds, PRBool aPaint = PR_TRUE) = 0;
/**
* Called to indicate that the dimensions and position of the view have
* been changed.
* @param aX new x position
* @param aY new y position
* @param aWidth new width
* @param aHeight new height
*/
NS_IMETHOD SetBounds(nscoord aX, nscoord aY,
nscoord aWidth, nscoord aHeight,
PRBool aPaint = PR_TRUE) = 0;
/**
* Called to get the dimensions and position of the view.
* Called to get the dimensions and position of the view's bounds.
* The view's bounds (x,y) are in the coordinate space of the parent view.
* The view's bounds (x,y) might not be the same as the view's position,
* if the view has content above or to the left of its origin.
* @param aBounds out parameter for bounds
*/
NS_IMETHOD GetBounds(nsRect &aBounds) const = 0;
/**
* Called to set the clip of the children of this view.
* The clip is relative to the origin of the view.
* All of the children of this view will be clipped using
* the specified rectangle
* @param aLeft new left position
* @param aTop new top position
* @param aRight new right position
* @param aBottom new bottom position
*/
NS_IMETHOD SetChildClip(nscoord aLeft, nscoord aTop, nscoord aRight, nscoord aBottom) = 0;
/**
* Called to get the dimensions and position of the clip for the view.
* @param aLeft left position
* @param aTop top position
* @param aRight right position
* @param aBottom bottom position
*/
NS_IMETHOD GetChildClip(nscoord *aLeft, nscoord *aTop, nscoord *aRight, nscoord *aBottom) const = 0;
/**
* Called to indicate that the visibility of a view has been
* changed.
* @param visibility new visibility state
*/
NS_IMETHOD SetVisibility(nsViewVisibility aVisibility) = 0;
/**
* Called to query the visibility state of a view.
* @result current visibility state
*/
NS_IMETHOD GetVisibility(nsViewVisibility &aVisibility) const = 0;
/**
* Called to indicate that the z-index of a view has been changed.
* The z-index is relative to all siblings of the view.
* @param zindex new z depth
*/
NS_IMETHOD SetZIndex(PRInt32 aZIndex) = 0;
/**
* Called to query the z-index of a view.
* The z-index is relative to all siblings of the view.
* @result current z depth
*/
NS_IMETHOD GetZIndex(PRInt32 &aZIndex) const = 0;
NS_IMETHOD GetZIndex(PRBool &aAuto, PRInt32 &aZIndex) const = 0;
/**
* Indicate that the z-index of a view is "auto". An "auto" z-index
* means that the view does not define a new stacking context,
* which means that the z-indicies of the view's children are
* relative to the view's siblings.
* @param aAutoZIndex if true then z-index will be auto
*/
NS_IMETHOD SetAutoZIndex(PRBool aAutoZIndex) = 0;
/**
* Returns true if an auto z-index is set for this view.
* @result current state of auto z-indexing
*/
NS_IMETHOD GetAutoZIndex(PRBool &aAutoZIndex) const = 0;
/**
* Set/Get whether the view "floats" above all other views,
* Get whether the view "floats" above all other views,
* which tells the compositor not to consider higher views in
* the view hierarchy that would geometrically intersect with
* this view. This is a hack, but it fixes some problems with
* views that need to be drawn in front of all other views.
* @result PR_TRUE if the view floats, PR_FALSE otherwise.
*/
NS_IMETHOD SetFloating(PRBool aFloatingView) = 0;
NS_IMETHOD GetFloating(PRBool &aFloatingView) const = 0;
NS_IMETHOD GetFloating(PRBool &aFloatingView) const = 0;
/**
* Called to query the parent of the view.
@ -308,15 +171,7 @@ public:
NS_IMETHOD GetNextSibling(nsIView *&aNextSibling) const = 0;
/**
* Note: This didn't exist in 4.0. Called to set the opacity of a view.
* A value of 0.0 means completely transparent. A value of 1.0 means
* completely opaque.
* @param opacity new opacity value
*/
NS_IMETHOD SetOpacity(float aOpacity) = 0;
/**
* Note: This didn't exist in 4.0. Called to set the opacity of a view.
* Note: This didn't exist in 4.0. Called to get the opacity of a view.
* A value of 0.0 means completely transparent. A value of 1.0 means
* completely opaque.
* @result view's opacity value
@ -331,13 +186,6 @@ public:
*/
NS_IMETHOD HasTransparency(PRBool &aTransparent) const = 0;
/**
* Used set the transparency status of the content in a view. see
* HasTransparency().
* @param aTransparent PR_TRUE if there are transparent areas, PR_FALSE otherwise.
*/
NS_IMETHOD SetContentTransparency(PRBool aTransparent) = 0;
/**
* Set the view's link to client owned data.
* @param aData - data to associate with view. nsnull to disassociate
@ -359,12 +207,6 @@ public:
*/
NS_IMETHOD GetOffsetFromWidget(nscoord *aDx, nscoord *aDy, nsIWidget *&aWidget) = 0;
/**
* Gets the dirty region associated with this view. Used by the view
* manager.
*/
NS_IMETHOD GetDirtyRegion(nsIRegion *&aRegion) const = 0;
/**
* Create a widget to associate with this view. This is a helper
* function for SetWidget.
@ -384,17 +226,6 @@ public:
PRBool aEnableDragDrop = PR_TRUE,
PRBool aResetVisibility = PR_TRUE) = 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
@ -404,132 +235,25 @@ public:
*/
NS_IMETHOD GetWidget(nsIWidget *&aWidget) const = 0;
/**
* Returns PR_TRUE if the view has a widget associated with it.
* @param aHasWidget out parameter that indicates whether a view has a widget.
*/
NS_IMETHOD HasWidget(PRBool *aHasWidget) const = 0;
// XXX Temporary for Bug #19416
NS_IMETHOD IgnoreSetPosition(PRBool aShouldIgnore) = 0;
/**
* Output debug info to FILE
* @param out output file handle
* @param aIndent indentation depth
*/
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const = 0;
/**
* Set flags on view to allow customization of view behavior during
* event handling
* @param aFlags flags to be added to view
*/
NS_IMETHOD SetViewFlags(PRUint32 aFlags) = 0;
/**
* Remove flags from view to allow customization of view behavior during
* event handling
* @param aFlags flags to be removed from view
*/
NS_IMETHOD ClearViewFlags(PRUint32 aFlags) = 0;
/**
* Get flags on view to allow customization of view behavior during
* event handling
* @param aFlags out parameter for view flags
*/
NS_IMETHOD GetViewFlags(PRUint32 *aFlags) const = 0;
/**
* Used by the compositor for temporary marking of a view during
* compositing. This will eventually replace GetScratchPoint above.
*/
NS_IMETHOD SetCompositorFlags(PRUint32 aFlags) = 0;
NS_IMETHOD GetCompositorFlags(PRUint32 *aFlags) = 0;
// XXX Temporary for Bug #19416
NS_IMETHOD IgnoreSetPosition(PRBool aShouldIgnore) = 0;
/**
* Sync your widget size and position with the view
*/
NS_IMETHOD SynchWidgetSizePosition() = 0;
/**
* Return a rectangle containing the view's bounds adjusted for it's ancestors clipping
* @param aClippedRect views bounds adjusted for ancestors clipping. If aEmpty is TRUE it
* aClippedRect is set to an empty rect.
* @param aIsClipped returns with PR_TRUE if view's rectangle is clipped by an ancestor
* @param aEmpty returns with PR_TRUE if view's rectangle is 'clipped out'
*/
NS_IMETHOD GetClippedRect(nsRect& aClippedRect, PRBool& aIsClipped, PRBool& aEmpty) const = 0;
NS_IMETHOD List(FILE* out, PRInt32 aIndent = 0) const = 0;
private:
NS_IMETHOD_(nsrefcnt) AddRef(void) = 0;
NS_IMETHOD_(nsrefcnt) Release(void) = 0;
};
//this is passed down to child views during painting and event handling
//so that a child can determine if it is hidden or shown when it's
//visibility state is set to inherit
#define NS_VIEW_FLAG_PARENT_HIDDEN 0x0001
//when painting, if we have determined that we need to do a combination
//of front to back and back to front painting, this flag will be set
//while in the back to front pass
#define NS_VIEW_FLAG_BACK_TO_FRONT 0x0002
//during event propagation, see if parent views can handle the event
#define NS_VIEW_FLAG_CHECK_PARENT 0x0004
//during event propagation, see if child views can handle the event
#define NS_VIEW_FLAG_CHECK_CHILDREN 0x0008
//during event propagation, see if sibling views can handle the event
#define NS_VIEW_FLAG_CHECK_SIBLINGS 0x0010
//passed down through the class hierarchy
//to indicate that the clip is set by an
//outer class
#define NS_VIEW_FLAG_CLIP_SET 0x0020
//when painting, if we have determined that we need to do a combination
//of front to back and back to front painting, this flag will be set
//while in the front to back pass
#define NS_VIEW_FLAG_FRONT_TO_BACK 0x0040
//temporary hack so that michael can work on the new
//compositor and make checkins without busting the rest
//of the world.
#define NS_VIEW_FLAG_JUST_PAINT 0x0080
//the following are public flags accessed through the *ViewFlags methods.
//Flag to determine whether the view will check if events can be handled
//by its children or just handle the events itself
#define NS_VIEW_PUBLIC_FLAG_DONT_CHECK_CHILDREN 0x0001
//the view is dying.
#define NS_VIEW_PUBLIC_FLAG_DYING 0x0002
//the view is transparent
#define NS_VIEW_PUBLIC_FLAG_TRANSPARENT 0x0004
//indicates that a view should not zoom values to/from widgets
#define NS_VIEW_PUBLIC_FLAG_DONT_ZOOM 0x0008
//indicates that the view should not be bitblt'd when moved
//or scrolled and instead must be repainted
#define NS_VIEW_PUBLIC_FLAG_DONT_BITBLT 0x0010
// indicates that the view is using auto z-indexing
#define NS_VIEW_PUBLIC_FLAG_AUTO_ZINDEX 0x0020
// indicatest hat the view is a floating view.
#define NS_VIEW_PUBLIC_FLAG_FLOATING 0x0040
// set if our widget resized.
#define NS_VIEW_PUBLIC_FLAG_WIDGET_RESIZED 0x0080
// set if our widget moved.
#define NS_VIEW_PUBLIC_FLAG_WIDGET_MOVED 0x0100
// indicates that the view should clip its child views using ClipRect specified
// by SetClip
#define NS_VIEW_PUBLIC_FLAG_CLIPCHILDREN 0x0200
#endif

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

@ -39,21 +39,18 @@
#define nsIViewManager_h___
#include "nscore.h"
#include "nsISupports.h"
#include "nsCoord.h"
#include "nsIView.h"
#include "nsColor.h"
#include "nsEvent.h"
class nsIRegion;
class nsIEvent;
class nsIPresContext;
class nsIView;
class nsIScrollableView;
class nsIWidget;
class nsICompositeListener;
struct nsRect;
class nsIDeviceContext;
class nsIEventProcessor;
class nsIViewObserver;
class nsIRegion;
enum nsContentQuality {
nsContentQuality_kGood = 0,
@ -75,12 +72,9 @@ public:
* Initialize the ViewManager
* Note: this instance does not hold a reference to the viewobserver
* because it holds a reference to this instance.
* @param aContext the device context to use.
* @param aX X offset of the view manager's coordinate space in twips
* @param aY Y offset of the view manager's coordinate space in twips
* @result The result of the initialization, NS_OK if no errors
*/
NS_IMETHOD Init(nsIDeviceContext* aContext, nscoord aX = 0, nscoord aY = 0) = 0;
NS_IMETHOD Init(nsIDeviceContext* aContext) = 0;
/**
* Get the root of the view tree.
@ -92,35 +86,39 @@ public:
* Set the root of the view tree. Does not destroy the current root view.
* One of following must be true:
* a) the aWidget parameter is an nsIWidget instance to render into
* that is not owned by any view or
* b) aView has a nsIWidget instance or
* c) aView has a parent view managed by a different view manager
* that is not owned by any view and aView has no widget, or
* b) aView has a nsIWidget instance and aWidget is null, or
* c) aView has a parent view managed by a different view manager and
* aWidget is null
* @param aView view to set as root
* @param aWidget widget to render into. (Can not be owned by a view)
*/
NS_IMETHOD SetRootView(nsIView *aView, nsIWidget* aWidget = nsnull) = 0;
/**
* Get/Set the offset within the root widget (see above) at which to render.
* @param aX out parameter for offset X in window in twips
* @param aY out parameter for offset Y in window in twips
*/
NS_IMETHOD GetWindowOffset(nscoord *aX, nscoord *aY) = 0;
NS_IMETHOD SetWindowOffset(nscoord aX, nscoord aY) = 0;
/**
* Get the dimensions of the root window. The dimensions are in
* twips
* @param width out parameter for width of window in twips
* @param height out parameter for height of window in twips
* @param aWidth out parameter for width of window in twips
* @param aHeight out parameter for height of window in twips
*/
NS_IMETHOD GetWindowDimensions(nscoord *width, nscoord *height) = 0;
NS_IMETHOD GetWindowDimensions(nscoord *aWidth, nscoord *aHeight) = 0;
/**
* Set the dimensions of the root window.
* Called if the root window is resized. The dimensions are in
* twips
* @param width of window in twips
* @param height of window in twips
* @param aWidth of window in twips
* @param aHeight of window in twips
*/
NS_IMETHOD SetWindowDimensions(nscoord width, nscoord height) = 0;
/**
* Reset the state of scrollbars and the scrolling region
*/
NS_IMETHOD ResetScrolling(void) = 0;
NS_IMETHOD SetWindowDimensions(nscoord aWidth, nscoord aHeight) = 0;
/**
* Called to force a redrawing of any dirty areas.
@ -152,15 +150,6 @@ public:
*/
NS_IMETHOD UpdateAllViews(PRUint32 aUpdateFlags) = 0;
/**
* Called to inform the view manager that a view has scrolled.
* The view manager will invalidate any widgets which may need
* to be rerendered.
* @param aView view to paint. should be root view
* @param aUpdateFlags see bottom of nsIViewManager.h for description
*/
NS_IMETHOD UpdateViewAfterScroll(nsIView *aView, PRInt32 aDX, PRInt32 aDY) = 0;
/**
* Called to dispatch an event to the appropriate view. Often called
* as a result of receiving a mouse or keyboard event from the widget
@ -201,83 +190,90 @@ public:
NS_IMETHOD GetKeyEventGrabber(nsIView *&aView) = 0;
/**
* Given a parent view, insert another view as its child. If above
* is PR_TRUE, the view is inserted above (in z-order) the sibling. If
* it is PR_FALSE, the view is inserted below.
* Given a parent view, insert another view as its child.
* aSibling and aAbove control the "document order" for the insertion.
* If aSibling is null, the view is inserted at the end of the document order
* if aAfter is PR_TRUE, otherwise it is inserted at the beginning.
* If aSibling is non-null, then if aAfter is PR_TRUE, the view is inserted
* after the sibling in document order (appearing above the sibling unless
* overriden by z-order).
* If it is PR_FALSE, the view is inserted before the sibling.
* The view manager generates the appopriate dirty regions.
* @param parent parent view
* @param child child view
* @param sibling sibling view
* @param above boolean above or below state
* @param aParent parent view
* @param aChild child view
* @param aSibling sibling view
* @param aAfter after or before in the document order
*/
NS_IMETHOD InsertChild(nsIView *aParent, nsIView *aChild, nsIView *aSibling,
PRBool aAbove) = 0;
PRBool aAfter) = 0;
/**
* Given a parent view, insert another view as its child. The zindex
* indicates where the child should be inserted relative to other
* children of the parent.
* The view manager generates the appopriate dirty regions.
* @param parent parent view
* @param child child view
* @param zindex z depth of child
* Given a parent view, insert a placeholder for a view that logically
* belongs to this parent but has to be moved somewhere else for geometry
* reasons ("fixed" positioning).
* @param aParent parent view
* @param aChild child view
* @param aSibling sibling view
* @param aAfter after or before in the document order
*/
NS_IMETHOD InsertChild(nsIView *aParent, nsIView *aChild,
PRInt32 aZIndex) = 0;
NS_IMETHOD InsertZPlaceholder(nsIView *aParent, nsIView *aZChild,
PRInt32 aZIndex) = 0;
NS_IMETHOD InsertZPlaceholder(nsIView *aParent, nsIView *aChild, nsIView *aSibling,
PRBool aAfter) = 0;
/**
* Remove a specific child of a view.
* The view manager generates the appopriate dirty regions.
* @param parent parent view
* @param child child view
* Remove a specific child view from its parent. This will NOT remove its placeholder
* if there is one.
* The view manager generates the appropriate dirty regions.
* @param aParent parent view
* @param aChild child view
*/
NS_IMETHOD RemoveChild(nsIView *aParent, nsIView *aChild) = 0;
NS_IMETHOD RemoveChild(nsIView *aChild) = 0;
/**
* Move a view's position by the specified amount.
* The view manager generates the appopriate dirty regions.
* Move a view to the specified position, provided in parent coordinates.
* The new position is the (0, 0) origin for the view's coordinate system.
* The view's bounds may extend above or to the left of this point.
* The view manager generates the appropriate dirty regions.
* @param aView view to move
* @param x x offset to add to current view position
* @param y y offset to add to current view position
*/
NS_IMETHOD MoveViewBy(nsIView *aView, nscoord aX, nscoord aY) = 0;
/**
* Move a view to the specified position,
* provided in parent coordinates.
* The view manager generates the appopriate dirty regions.
* @param aView view to move
* @param x x value for new view position
* @param y y value for new view position
* @param aX x value for new view position
* @param aY y value for new view position
*/
NS_IMETHOD MoveViewTo(nsIView *aView, nscoord aX, nscoord aY) = 0;
/**
* Resize a view to the specified width and height.
* The view manager generates the appopriate dirty regions.
* Resize a view. In addition to setting the width and height, you can
* set the x and y of its bounds relative to its position. Negative x and y
* will let the view extend above and to the left of the (0,0) point in its
* coordinate system.
* The view manager generates the appropriate dirty regions.
* @param aView view to move
* @param width new view width
* @param height new view height
* @param RepaintExposedAreaOnly if PR_TRUE Repaint only the expanded or contracted region,
* if PR_FALSE Repaint the union of the old and new rectangles.
*
* @param the new bounds relative to the current position
* @param RepaintExposedAreaOnly
* if PR_TRUE Repaint only the expanded or contracted region,
* if PR_FALSE Repaint the union of the old and new rectangles.
*/
NS_IMETHOD ResizeView(nsIView *aView, nscoord aWidth, nscoord aHeight, PRBool aRepaintExposedAreaOnly = PR_FALSE) = 0;
NS_IMETHOD ResizeView(nsIView *aView, const nsRect &aRect,
PRBool aRepaintExposedAreaOnly = PR_FALSE) = 0;
/**
* Set the clipping of a view's children
* The view manager generates the appopriate dirty regions.
* @param aView view set clip children rect on
* @param rect new clipping rect for view's children
* Set the region to which a view's children are clipped.
* The view itself is not clipped to this region; this allows for effects where part of the view is
* drawn outside the clip region (e.g., its borders and background).
* The view manager generates the appropriate dirty regions.
* @param aView view to set clipping for
* @param aRegion
* if null then no clipping is required; everything the view paints is guaranteed
* to be inside its bounds, and all child views will also be inside this view's bounds.
* if non-null, then we will clip this view's child views to the region.
* The child views need not be within the bounds of this view, but the
* region must lie entirely inside this view's bounds. The view manager copies the region.
*
* XXX Currently we only support regions consisting of a single rectangle.
*/
NS_IMETHOD SetViewChildClip(nsIView *aView, nsRect *aRect) = 0;
NS_IMETHOD SetViewChildClipRegion(nsIView *aView, nsIRegion *aRegion) = 0;
/**
* Set the visibility of a view.
* The view manager generates the appopriate dirty regions.
* The view manager generates the appropriate dirty regions.
* @param aView view to change visibility state of
* @param visible new visibility state
*/
@ -287,38 +283,34 @@ public:
* Set the z-index of a view. Positive z-indices mean that a view
* is above its parent in z-order. Negative z-indices mean that a
* view is below its parent.
* The view manager generates the appopriate dirty regions.
* @param aView view to change z depth of
* @param zindex new z depth
*/
NS_IMETHOD SetViewZIndex(nsIView *aView, PRInt32 aZindex) = 0;
/**
* Indicate that the z-index of a view is "auto". An "auto" z-index
* The view manager generates the appropriate dirty regions.
* @param aAutoZIndex indicate that the z-index of a view is "auto". An "auto" z-index
* means that the view does not define a new stacking context,
* which means that the z-indicies of the view's children are
* relative to the view's siblings.
* The view manager generates the appopriate dirty regions.
* @param aView view to change z depth of
* @param zindex new z depth
*/
NS_IMETHOD SetViewAutoZIndex(nsIView *aView, PRBool aAutoZIndex) = 0;
NS_IMETHOD SetViewZIndex(nsIView *aView, PRBool aAutoZIndex, PRInt32 aZindex) = 0;
/**
* Used to move a view above another in z-order.
* The view manager generates the appopriate dirty regions.
* @param aView view to change z depth of
* @param other view to move aView above
* Set whether the view "floats" above all other views,
* which tells the compositor not to consider higher views in
* the view hierarchy that would geometrically intersect with
* this view. This is a hack, but it fixes some problems with
* views that need to be drawn in front of all other views.
*/
NS_IMETHOD MoveViewAbove(nsIView *aView, nsIView *aOther) = 0;
NS_IMETHOD SetViewFloating(nsIView *aView, PRBool aFloatingView) = 0;
/**
* Used to move a view below another in z-order.
* The view manager generates the appopriate dirty regions.
* @param aView view to change z depth of
* @param other view to move aView below
* Set whether the view can be bitblitted during scrolling.
*/
NS_IMETHOD MoveViewBelow(nsIView *aView, nsIView *aOther) = 0;
NS_IMETHOD SetViewBitBltEnabled(nsIView *aView, PRBool aEnable) = 0;
/**
* Set whether the view's children should be searched during event processing.
*/
NS_IMETHOD SetViewCheckChildEvents(nsIView *aView, PRBool aEnable) = 0;
/**
* Used set the transparency status of the content in a view. see
@ -368,7 +360,7 @@ public:
NS_IMETHOD GetShowQuality(PRBool &aResult) = 0;
/**
* Select whether quality level should be displayed in root view
* Select quality level
* @param aShow if PR_TRUE, quality level will be displayed, else hidden
*/
NS_IMETHOD SetQuality(nsContentQuality aQuality) = 0;
@ -441,11 +433,11 @@ public:
/**
* Retrieve the widget that a view renders into.
* The view must be in the view hierarchy.
* @param aView the view to get the widget for
* @param aWidget the widget that aView renders into.
* @result error status
*/
NS_IMETHOD GetWidgetForView(nsIView *aView, nsIWidget **aWidget) = 0;
/**
@ -461,25 +453,13 @@ public:
* Callers should use UpdateView(view, NS_VMREFRESH_IMMEDIATE) in most cases instead
* @result error status
*/
NS_IMETHOD ForceUpdate() = 0;
/**
* Get view manager offset specified in nsIViewManager::Init
* @param aX x offset in twips
* @param aY y offset in twips
* @result error status
*/
NS_IMETHOD GetOffset(nscoord *aX, nscoord *aY) = 0;
/**
* Turn widget on or off widget movement caching
*/
NS_IMETHOD IsCachingWidgetChanges(PRBool* aCaching)=0;
/**
* Pass true to cache widget changes. pass false to stop. When false is passed
* All widget changes will be applied.
@ -541,11 +521,12 @@ public:
/**
* Determine if a rectangle specified in the view's coordinate system
* is completely, or partially visible.
* The view must be in the view hierarchy.
* @param aView view that aRect coordinates are specified relative to
* @param aRect rectangle in twips to test for visibility
* @returns PR_TRUE if the rect is visible, PR_FALSE otherwise.
*/
NS_IMETHOD IsRectVisible(nsIView *aView, const nsRect &aRect, PRBool aMustBeFullyVisible, PRBool *isVisible)=0;
NS_IMETHOD IsRectVisible(nsIView *aView, const nsRect &aRect, PRBool aMustBeFullyVisible, PRBool *aIsVisible)=0;
/**
* Installs an event process that indicates whether the event should be disacrded or not
@ -556,14 +537,9 @@ public:
NS_IMETHOD SetEventProcessor(nsIEventProcessor* aEventProcessor)=0;
};
//when the refresh happens, should it be double buffered?
#define NS_VMREFRESH_DOUBLE_BUFFER 0x0001
//update view now?
#define NS_VMREFRESH_IMMEDIATE 0x0002
//prevent "sync painting"
#define NS_VMREFRESH_NO_SYNC 0x0004
//if the total damage area is greater than 25% of the
//area of the root view, use double buffering
#define NS_VMREFRESH_AUTO_DOUBLE_BUFFER 0x0008
#endif // nsIViewManager_h___

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

@ -47,7 +47,6 @@
#include "nsIScrollableView.h"
#include "nsIFrame.h"
#include "nsILookAndFeel.h"
#include "nsIClipView.h"
#include "nsISupportsArray.h"
#include "nsIScrollPositionListener.h"
#include "nsIRegion.h"
@ -427,7 +426,7 @@ NS_IMETHODIMP nsScrollPortView::SetScrolledView(nsIView *aScrolledView)
if (count == 1)
{
nsView* child = GetFirstChild();
mViewManager->RemoveChild(this, child);
mViewManager->RemoveChild(child);
}
return mViewManager->InsertChild(this, aScrolledView, 0);
@ -505,9 +504,8 @@ NS_IMETHODIMP nsScrollPortView::ScrollByWhole(PRBool aTop)
if (!aTop) {
nsSize scrolledSize;
nsIView* scrolledView = nsnull;
GetScrolledView(scrolledView);
scrolledView->GetDimensions(&scrolledSize.width, &scrolledSize.height);
nsView* scrolledView = GetScrolledView();
scrolledView->GetDimensions(&scrolledSize.width, &scrolledSize.height);
newPos = scrolledSize.height;
}
@ -528,7 +526,7 @@ PRBool nsScrollPortView::CannotBitBlt(nsView* aScrolledView)
return ((trans || opacity) && !(mScrollProperties & NS_SCROLL_PROPERTY_ALWAYS_BLIT)) ||
(mScrollProperties & NS_SCROLL_PROPERTY_NEVER_BLIT) ||
(scrolledViewFlags & NS_VIEW_PUBLIC_FLAG_DONT_BITBLT);
(scrolledViewFlags & NS_VIEW_FLAG_DONT_BITBLT);
}

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

@ -104,6 +104,7 @@ public:
PRUint32 aPaintFlags, PRBool &Result);
NS_IMETHOD Paint(nsIRenderingContext& aRC, const nsIRegion& aRegion,
PRUint32 aPaintFlags, PRBool &Result);
nsView* GetScrolledView() const { return GetFirstChild(); }
private:
NS_IMETHOD_(nsrefcnt) AddRef(void);
@ -116,7 +117,6 @@ protected:
//NS_IMETHOD_(void) Notify(nsITimer *timer);
//private
nsView* GetScrolledView() const { return GetFirstChild(); }
void AdjustChildWidgets(nsScrollPortView *aScrolling, nsView *aView, nscoord aDx, nscoord aDy, float aScale);
void Scroll(nsView *aScrolledView, PRInt32 aDx, PRInt32 aDy, float scale, PRUint32 aUpdateFlags);
PRBool CannotBitBlt(nsView* aScrolledView);

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

@ -47,7 +47,6 @@
#include "nsIScrollableView.h"
#include "nsIFrame.h"
#include "nsILookAndFeel.h"
#include "nsIClipView.h"
#include "nsISupportsArray.h"
#include "nsIScrollPositionListener.h"
#include "nsIRegion.h"
@ -830,7 +829,7 @@ NS_IMETHODIMP nsScrollingView::CreateScrollControls(nsNativeWidget aNative)
// of 0.0f (completely transparent)
// XXX The clip widget should be created on demand only...
rv = mClipView->Init(mViewManager, mBounds, this);
rv = mViewManager->InsertChild(this, mClipView, mZindex);
rv = mViewManager->InsertChild(this, mClipView, mZIndex);
rv = mViewManager->SetViewOpacity(mClipView, 0.0f);
rv = mClipView->CreateWidget(kWidgetCID, &initData,
mWindow ? nsnull : aNative);
@ -851,7 +850,7 @@ NS_IMETHODIMP nsScrollingView::CreateScrollControls(nsNativeWidget aNative)
trect.y = mBounds.y + mBounds.YMost() - trect.height;
rv = mCornerView->Init(mViewManager, trect, this, nsViewVisibility_kHide);
mViewManager->InsertChild(this, mCornerView, mZindex);
mViewManager->InsertChild(this, mCornerView, mZIndex);
mCornerView->CreateWidget(kWidgetCID, &initData,
mWindow ? nsnull : aNative);
}
@ -872,7 +871,7 @@ NS_IMETHODIMP nsScrollingView::CreateScrollControls(nsNativeWidget aNative)
static NS_DEFINE_IID(kCScrollbarIID, NS_VERTSCROLLBAR_CID);
rv = mVScrollBarView->Init(mViewManager, trect, this);
rv = mViewManager->InsertChild(this, mVScrollBarView, mZindex);
rv = mViewManager->InsertChild(this, mVScrollBarView, mZIndex);
rv = mVScrollBarView->CreateWidget(kCScrollbarIID, &initData,
mWindow ? nsnull : aNative,
PR_FALSE);
@ -932,7 +931,7 @@ NS_IMETHODIMP nsScrollingView::CreateScrollControls(nsNativeWidget aNative)
static NS_DEFINE_IID(kCHScrollbarIID, NS_HORZSCROLLBAR_CID);
rv = mHScrollBarView->Init(mViewManager, trect, this);
rv = mViewManager->InsertChild(this, mHScrollBarView, mZindex);
rv = mViewManager->InsertChild(this, mHScrollBarView, mZIndex);
rv = mHScrollBarView->CreateWidget(kCHScrollbarIID, &initData,
mWindow ? nsnull : aNative,
PR_FALSE);
@ -952,15 +951,17 @@ NS_IMETHODIMP nsScrollingView::SetWidget(nsIWidget *aWidget)
return NS_OK;
}
NS_IMETHODIMP nsScrollingView::SetZIndex(PRInt32 aZIndex)
NS_IMETHODIMP nsScrollingView::SetZIndex(PRBool aAuto, PRInt32 aZIndex)
{
nsView::SetZIndex(aZIndex);
nsView::SetZIndex(aAuto, aZIndex);
// inform all views that the z-index has changed.
if (mClipView) mViewManager->SetViewZIndex(mClipView, aZIndex);
if (mCornerView) mViewManager->SetViewZIndex(mCornerView, aZIndex);
if (mVScrollBarView) mViewManager->SetViewZIndex(mVScrollBarView, aZIndex);
if (mHScrollBarView) mViewManager->SetViewZIndex(mHScrollBarView, aZIndex);
// XXX why are we doing this? they're all a child of this view, so they
// shouldn't need to be re-z-indexed.
if (mClipView) mViewManager->SetViewZIndex(mClipView, aAuto, aZIndex);
if (mCornerView) mViewManager->SetViewZIndex(mCornerView, aAuto, aZIndex);
if (mVScrollBarView) mViewManager->SetViewZIndex(mVScrollBarView, aAuto, aZIndex);
if (mHScrollBarView) mViewManager->SetViewZIndex(mHScrollBarView, aAuto, aZIndex);
return NS_OK;
}
@ -1682,7 +1683,7 @@ PRBool nsScrollingView::CannotBitBlt(nsView* aScrolledView)
return ((trans || opacity) && !(mScrollProperties & NS_SCROLL_PROPERTY_ALWAYS_BLIT)) ||
(mScrollProperties & NS_SCROLL_PROPERTY_NEVER_BLIT) ||
(scrolledViewFlags & NS_VIEW_PUBLIC_FLAG_DONT_BITBLT);
(scrolledViewFlags & NS_VIEW_FLAG_DONT_BITBLT);
}
void nsScrollingView::Scroll(nsView *aScrolledView, PRInt32 aDx, PRInt32 aDy,

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

@ -68,7 +68,7 @@ public:
NS_IMETHOD SetVisibility(nsViewVisibility visibility);
NS_IMETHOD SetWidget(nsIWidget *aWidget);
NS_IMETHOD SetZIndex(PRInt32 aZIndex);
NS_IMETHOD SetZIndex(PRBool aAuto, PRInt32 aZIndex);
//nsIScrollableView interface
NS_IMETHOD CreateScrollControls(nsNativeWidget aNative = nsnull);
@ -98,6 +98,7 @@ public:
NS_IMETHOD ScrollByWhole(PRBool aTop);
NS_IMETHOD GetClipView(const nsIView** aClipView) const;
nsView* GetClipView() const { return mClipView; }
NS_IMETHOD AddScrollPositionListener(nsIScrollPositionListener* aListener);
NS_IMETHOD RemoveScrollPositionListener(nsIScrollPositionListener* aListener);
@ -113,8 +114,7 @@ public:
// Update the visibility of the nsScrollingView's components (ClipView, CornerView, ScrollBarView's)
// @param aScrollingViewVisibility Visibility setting of the ScrollingView to consider when
// setting the visibility of the components. If aScrollingViewVisibility == nsViewVisibility_kInherit then
// UpdateComponent has no effect.
// setting the visibility of the components.
// @returns the result of calling SetComponentVisibility for each component.
nsresult UpdateComponentVisibility(nsViewVisibility aScrollingViewVisibility);

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

@ -52,7 +52,6 @@
#include "nsVoidArray.h"
#include "nsGfxCIID.h"
#include "nsIRegion.h"
#include "nsIClipView.h"
static NS_DEFINE_IID(kRegionCID, NS_REGION_CID);
@ -86,7 +85,7 @@ nsEventStatus PR_CALLBACK HandleEvent(nsGUIEvent *aEvent)
MOZ_DECL_CTOR_COUNTER(nsView)
nsView :: nsView()
nsView::nsView()
{
MOZ_COUNT_CTOR(nsView);
@ -98,12 +97,10 @@ nsView :: nsView()
mChildRemoved = PR_FALSE;
}
nsView :: ~nsView()
nsView::~nsView()
{
MOZ_COUNT_DTOR(nsView);
mVFlags |= NS_VIEW_PUBLIC_FLAG_DYING;
while (GetFirstChild() != nsnull)
{
GetFirstChild()->Destroy();
@ -124,7 +121,7 @@ nsView :: ~nsView()
{
if (nsnull != mParent)
{
mViewManager->RemoveChild(mParent, this);
mViewManager->RemoveChild(this);
}
}
}
@ -211,7 +208,7 @@ nsView* nsView::GetViewFor(nsIWidget* aWidget)
return nsnull;
}
NS_IMETHODIMP nsView :: Init(nsIViewManager* aManager,
NS_IMETHODIMP nsView::Init(nsIViewManager* aManager,
const nsRect &aBounds,
const nsIView *aParent,
nsViewVisibility aVisibilityFlag)
@ -250,23 +247,22 @@ NS_IMETHODIMP nsView :: Init(nsIViewManager* aManager,
return NS_OK;
}
NS_IMETHODIMP nsView :: Destroy()
NS_IMETHODIMP nsView::Destroy()
{
delete this;
return NS_OK;
}
NS_IMETHODIMP nsView :: GetViewManager(nsIViewManager *&aViewMgr) const
NS_IMETHODIMP nsView::GetViewManager(nsIViewManager *&aViewMgr) const
{
NS_IF_ADDREF(mViewManager);
aViewMgr = mViewManager;
return NS_OK;
}
NS_IMETHODIMP nsView :: Paint(nsIRenderingContext& rc, const nsRect& rect,
NS_IMETHODIMP nsView::Paint(nsIRenderingContext& rc, const nsRect& rect,
PRUint32 aPaintFlags, PRBool &aResult)
{
NS_ASSERTION(aPaintFlags & NS_VIEW_FLAG_JUST_PAINT, "Only simple painting supported by nsView");
// Just paint, assume compositor knows what it's doing.
if (nsnull != mClientData) {
nsCOMPtr<nsIViewObserver> observer;
@ -277,7 +273,7 @@ NS_IMETHODIMP nsView :: Paint(nsIRenderingContext& rc, const nsRect& rect,
return NS_OK;
}
NS_IMETHODIMP nsView :: Paint(nsIRenderingContext& rc, const nsIRegion& region,
NS_IMETHODIMP nsView::Paint(nsIRenderingContext& rc, const nsIRegion& region,
PRUint32 aPaintFlags, PRBool &aResult)
{
// XXX apply region to rc
@ -296,7 +292,7 @@ NS_IMETHODIMP nsView :: Paint(nsIRenderingContext& rc, const nsIRegion& region,
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsView :: HandleEvent(nsGUIEvent *event, PRUint32 aEventFlags,
NS_IMETHODIMP nsView::HandleEvent(nsGUIEvent *event, PRUint32 aEventFlags,
nsEventStatus* aStatus, PRBool aForceHandle, PRBool& aHandled)
{
NS_ENSURE_ARG_POINTER(aStatus);
@ -320,7 +316,7 @@ NS_IMETHODIMP nsView :: HandleEvent(nsGUIEvent *event, PRUint32 aEventFlags,
*aStatus = nsEventStatus_eIgnore;
//see if any of this view's children can process the event
if ( !(mVFlags & NS_VIEW_PUBLIC_FLAG_DONT_CHECK_CHILDREN) ) {
if ( !(mVFlags & NS_VIEW_FLAG_DONT_CHECK_CHILDREN) ) {
nsRect trect;
nscoord x, y;
@ -343,7 +339,7 @@ NS_IMETHODIMP nsView :: HandleEvent(nsGUIEvent *event, PRUint32 aEventFlags,
event->point.x -= trect.x;
event->point.y -= trect.y;
pKid->HandleEvent(event, NS_VIEW_FLAG_CHECK_CHILDREN, aStatus, PR_FALSE, aHandled);
pKid->HandleEvent(event, 0, aStatus, PR_FALSE, aHandled);
event->point.x += trect.x;
event->point.y += trect.y;
@ -390,7 +386,7 @@ NS_IMETHODIMP nsView :: HandleEvent(nsGUIEvent *event, PRUint32 aEventFlags,
}
// XXX Start Temporary fix for Bug #19416
NS_IMETHODIMP nsView :: IgnoreSetPosition(PRBool aShouldIgnore)
NS_IMETHODIMP nsView::IgnoreSetPosition(PRBool aShouldIgnore)
{
mShouldIgnoreSetPosition = aShouldIgnore;
// resync here
@ -401,7 +397,7 @@ NS_IMETHODIMP nsView :: IgnoreSetPosition(PRBool aShouldIgnore)
}
// XXX End Temporary fix for Bug #19416
NS_IMETHODIMP nsView :: SetPosition(nscoord aX, nscoord aY)
NS_IMETHODIMP nsView::SetPosition(nscoord aX, nscoord aY)
{
nscoord x = aX;
nscoord y = aY;
@ -411,7 +407,7 @@ NS_IMETHODIMP nsView :: SetPosition(nscoord aX, nscoord aY)
// while allowing layout to assume it's coordinate space origin is (0,0)
nscoord offsetX;
nscoord offsetY;
mViewManager->GetOffset(&offsetX, &offsetY);
mViewManager->GetWindowOffset(&offsetX, &offsetY);
x += offsetX;
y += offsetY;
}
@ -431,7 +427,7 @@ NS_IMETHODIMP nsView :: SetPosition(nscoord aX, nscoord aY)
PRBool caching = PR_FALSE;
mViewManager->IsCachingWidgetChanges(&caching);
if (caching) {
mVFlags |= NS_VIEW_PUBLIC_FLAG_WIDGET_MOVED;
mVFlags |= NS_VIEW_FLAG_WIDGET_MOVED;
return NS_OK;
}
@ -454,10 +450,10 @@ NS_IMETHODIMP nsView :: SetPosition(nscoord aX, nscoord aY)
return NS_OK;
}
NS_IMETHODIMP nsView :: SynchWidgetSizePosition()
NS_IMETHODIMP nsView::SynchWidgetSizePosition()
{
// if the widget was moved or resized
if (mVFlags & NS_VIEW_PUBLIC_FLAG_WIDGET_MOVED || mVFlags & NS_VIEW_PUBLIC_FLAG_WIDGET_RESIZED)
if (mVFlags & NS_VIEW_FLAG_WIDGET_MOVED || mVFlags & NS_VIEW_FLAG_WIDGET_RESIZED)
{
nsIDeviceContext *dx;
float t2p;
@ -488,20 +484,20 @@ NS_IMETHODIMP nsView :: SynchWidgetSizePosition()
nsRect bounds;
mWindow->GetBounds(bounds);
if (bounds.x == x && bounds.y == y )
mVFlags &= ~NS_VIEW_PUBLIC_FLAG_WIDGET_MOVED;
mVFlags &= ~NS_VIEW_FLAG_WIDGET_MOVED;
else if (bounds.width == width && bounds.height == bounds.height)
mVFlags &= ~NS_VIEW_PUBLIC_FLAG_WIDGET_RESIZED;
mVFlags &= ~NS_VIEW_FLAG_WIDGET_RESIZED;
else {
printf("%d) SetBounds(%d,%d,%d,%d)\n", this, x, y, width, height);
mWindow->Resize(x,y,width,height, PR_TRUE);
mVFlags &= ~NS_VIEW_PUBLIC_FLAG_WIDGET_RESIZED;
mVFlags &= ~NS_VIEW_PUBLIC_FLAG_WIDGET_MOVED;
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_PUBLIC_FLAG_WIDGET_RESIZED)
if (mVFlags & NS_VIEW_FLAG_WIDGET_RESIZED)
{
PRInt32 width = NSTwipsToIntPixels(mBounds.width, t2p);
@ -517,10 +513,10 @@ NS_IMETHODIMP nsView :: SynchWidgetSizePosition()
mWindow->Resize(width,height, PR_TRUE);
}
mVFlags &= ~NS_VIEW_PUBLIC_FLAG_WIDGET_RESIZED;
mVFlags &= ~NS_VIEW_FLAG_WIDGET_RESIZED;
}
if (mVFlags & NS_VIEW_PUBLIC_FLAG_WIDGET_MOVED) {
if (mVFlags & NS_VIEW_FLAG_WIDGET_MOVED) {
// if we just moved do it.
nscoord parx = 0, pary = 0;
nsIWidget *pwidget = nsnull;
@ -541,7 +537,7 @@ NS_IMETHODIMP nsView :: SynchWidgetSizePosition()
mWindow->Move(x,y);
}
mVFlags &= ~NS_VIEW_PUBLIC_FLAG_WIDGET_MOVED;
mVFlags &= ~NS_VIEW_FLAG_WIDGET_MOVED;
}
}
@ -549,7 +545,7 @@ NS_IMETHODIMP nsView :: SynchWidgetSizePosition()
return NS_OK;
}
NS_IMETHODIMP nsView :: GetPosition(nscoord *x, nscoord *y) const
NS_IMETHODIMP nsView::GetPosition(nscoord *x, nscoord *y) const
{
nsView *rootView = mViewManager->GetRootView();
@ -568,7 +564,7 @@ NS_IMETHODIMP nsView :: GetPosition(nscoord *x, nscoord *y) const
return NS_OK;
}
NS_IMETHODIMP nsView :: SetDimensions(nscoord width, nscoord height, PRBool aPaint)
NS_IMETHODIMP nsView::SetDimensions(nscoord width, nscoord height, PRBool aPaint)
{
if ((mBounds.width == width) &&
(mBounds.height == height))
@ -601,7 +597,7 @@ NS_IMETHODIMP nsView :: SetDimensions(nscoord width, nscoord height, PRBool aPai
PRBool caching = PR_FALSE;
mViewManager->IsCachingWidgetChanges(&caching);
if (caching) {
mVFlags |= NS_VIEW_PUBLIC_FLAG_WIDGET_RESIZED;
mVFlags |= NS_VIEW_FLAG_WIDGET_RESIZED;
return NS_OK;
}
@ -620,28 +616,28 @@ NS_IMETHODIMP nsView :: SetDimensions(nscoord width, nscoord height, PRBool aPai
return NS_OK;
}
NS_IMETHODIMP nsView :: GetDimensions(nscoord *width, nscoord *height) const
NS_IMETHODIMP nsView::GetDimensions(nscoord *width, nscoord *height) const
{
*width = mBounds.width;
*height = mBounds.height;
return NS_OK;
}
NS_IMETHODIMP nsView :: SetBounds(const nsRect &aBounds, PRBool aPaint)
NS_IMETHODIMP nsView::SetBounds(const nsRect &aBounds, PRBool aPaint)
{
SetPosition(aBounds.x, aBounds.y);
SetDimensions(aBounds.width, aBounds.height, aPaint);
return NS_OK;
}
NS_IMETHODIMP nsView :: SetBounds(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight, PRBool aPaint)
NS_IMETHODIMP nsView::SetBounds(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight, PRBool aPaint)
{
SetPosition(aX, aY);
SetDimensions(aWidth, aHeight, aPaint);
return NS_OK;
}
NS_IMETHODIMP nsView :: GetBounds(nsRect &aBounds) const
NS_IMETHODIMP nsView::GetBounds(nsRect &aBounds) const
{
NS_ASSERTION(mViewManager, "mViewManager is null!");
if (!mViewManager) {
@ -658,7 +654,7 @@ NS_IMETHODIMP nsView :: GetBounds(nsRect &aBounds) const
return NS_OK;
}
NS_IMETHODIMP nsView :: SetChildClip(nscoord aLeft, nscoord aTop, nscoord aRight, nscoord aBottom)
NS_IMETHODIMP nsView::SetChildClip(nscoord aLeft, nscoord aTop, nscoord aRight, nscoord aBottom)
{
NS_PRECONDITION(aLeft <= aRight && aTop <= aBottom, "bad clip values");
mChildClip.mLeft = aLeft;
@ -666,10 +662,12 @@ NS_IMETHODIMP nsView :: SetChildClip(nscoord aLeft, nscoord aTop, nscoord aRight
mChildClip.mRight = aRight;
mChildClip.mBottom = aBottom;
return NS_OK;
}
NS_IMETHODIMP nsView :: GetChildClip(nscoord *aLeft, nscoord *aTop, nscoord *aRight, nscoord *aBottom) const
NS_IMETHODIMP nsView::GetChildClip(nscoord *aLeft, nscoord *aTop, nscoord *aRight, nscoord *aBottom) const
{
*aLeft = mChildClip.mLeft;
*aTop = mChildClip.mTop;
@ -678,7 +676,7 @@ NS_IMETHODIMP nsView :: GetChildClip(nscoord *aLeft, nscoord *aTop, nscoord *aRi
return NS_OK;
}
NS_IMETHODIMP nsView :: SetVisibility(nsViewVisibility aVisibility)
NS_IMETHODIMP nsView::SetVisibility(nsViewVisibility aVisibility)
{
mVis = aVisibility;
@ -707,51 +705,25 @@ NS_IMETHODIMP nsView :: SetVisibility(nsViewVisibility aVisibility)
return NS_OK;
}
NS_IMETHODIMP nsView :: GetVisibility(nsViewVisibility &aVisibility) const
NS_IMETHODIMP nsView::GetVisibility(nsViewVisibility &aVisibility) const
{
aVisibility = mVis;
return NS_OK;
}
NS_IMETHODIMP nsView::SetZIndex(PRInt32 aZIndex)
NS_IMETHODIMP nsView::GetZIndex(PRBool &aAuto, PRInt32 &aZIndex) const
{
mZindex = aZIndex;
if (nsnull != mWindow) {
mWindow->SetZIndex(aZIndex);
}
return NS_OK;
}
NS_IMETHODIMP nsView::GetZIndex(PRInt32 &aZIndex) const
{
aZIndex = mZindex;
aAuto = (mVFlags & NS_VIEW_FLAG_AUTO_ZINDEX) != 0;
aZIndex = mZIndex;
return NS_OK;
}
NS_IMETHODIMP nsView::SetAutoZIndex(PRBool aAutoZIndex)
{
if (aAutoZIndex)
mVFlags |= NS_VIEW_PUBLIC_FLAG_AUTO_ZINDEX;
else
mVFlags &= ~NS_VIEW_PUBLIC_FLAG_AUTO_ZINDEX;
return NS_OK;
}
NS_IMETHODIMP nsView::GetAutoZIndex(PRBool &aAutoZIndex) const
{
aAutoZIndex = ((mVFlags & NS_VIEW_PUBLIC_FLAG_AUTO_ZINDEX) != 0);
return NS_OK;
}
NS_IMETHODIMP nsView::SetFloating(PRBool aFloatingView)
{
if (aFloatingView)
mVFlags |= NS_VIEW_PUBLIC_FLAG_FLOATING;
mVFlags |= NS_VIEW_FLAG_FLOATING;
else
mVFlags &= ~NS_VIEW_PUBLIC_FLAG_FLOATING;
mVFlags &= ~NS_VIEW_FLAG_FLOATING;
#if 0
// recursively make all sub-views "floating" grr.
@ -767,23 +739,23 @@ NS_IMETHODIMP nsView::SetFloating(PRBool aFloatingView)
NS_IMETHODIMP nsView::GetFloating(PRBool &aFloatingView) const
{
aFloatingView = ((mVFlags & NS_VIEW_PUBLIC_FLAG_FLOATING) != 0);
aFloatingView = ((mVFlags & NS_VIEW_FLAG_FLOATING) != 0);
return NS_OK;
}
NS_IMETHODIMP nsView :: GetParent(nsIView *&aParent) const
NS_IMETHODIMP nsView::GetParent(nsIView *&aParent) const
{
aParent = mParent;
return NS_OK;
}
NS_IMETHODIMP nsView :: GetNextSibling(nsIView *&aNextSibling) const
NS_IMETHODIMP nsView::GetNextSibling(nsIView *&aNextSibling) const
{
aNextSibling = mNextSibling;
return NS_OK;
}
void nsView :: InsertChild(nsView *aChild, nsView *aSibling)
void nsView::InsertChild(nsView *aChild, nsView *aSibling)
{
NS_PRECONDITION(nsnull != aChild, "null ptr");
@ -810,7 +782,7 @@ void nsView :: InsertChild(nsView *aChild, nsView *aSibling)
}
}
void nsView :: RemoveChild(nsView *child)
void nsView::RemoveChild(nsView *child)
{
NS_PRECONDITION(nsnull != child, "null ptr");
@ -840,7 +812,7 @@ void nsView :: RemoveChild(nsView *child)
}
}
nsView* nsView :: GetChild(PRInt32 aIndex) const
nsView* nsView::GetChild(PRInt32 aIndex) const
{
for (nsView* child = GetFirstChild(); child != nsnull; child = child->GetNextSibling()) {
if (aIndex == 0) {
@ -851,47 +823,47 @@ nsView* nsView :: GetChild(PRInt32 aIndex) const
return nsnull;
}
NS_IMETHODIMP nsView :: SetOpacity(float opacity)
NS_IMETHODIMP nsView::SetOpacity(float opacity)
{
mOpacity = opacity;
return NS_OK;
}
NS_IMETHODIMP nsView :: GetOpacity(float &aOpacity) const
NS_IMETHODIMP nsView::GetOpacity(float &aOpacity) const
{
aOpacity = mOpacity;
return NS_OK;
}
NS_IMETHODIMP nsView :: HasTransparency(PRBool &aTransparent) const
NS_IMETHODIMP nsView::HasTransparency(PRBool &aTransparent) const
{
aTransparent = (mVFlags & NS_VIEW_PUBLIC_FLAG_TRANSPARENT) ? PR_TRUE : PR_FALSE;
aTransparent = (mVFlags & NS_VIEW_FLAG_TRANSPARENT) ? PR_TRUE : PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP nsView :: SetContentTransparency(PRBool aTransparent)
NS_IMETHODIMP nsView::SetContentTransparency(PRBool aTransparent)
{
if (aTransparent == PR_TRUE)
mVFlags |= NS_VIEW_PUBLIC_FLAG_TRANSPARENT;
mVFlags |= NS_VIEW_FLAG_TRANSPARENT;
else
mVFlags &= ~NS_VIEW_PUBLIC_FLAG_TRANSPARENT;
mVFlags &= ~NS_VIEW_FLAG_TRANSPARENT;
return NS_OK;
}
NS_IMETHODIMP nsView :: SetClientData(void *aData)
NS_IMETHODIMP nsView::SetClientData(void *aData)
{
mClientData = aData;
return NS_OK;
}
NS_IMETHODIMP nsView :: GetClientData(void *&aData) const
NS_IMETHODIMP nsView::GetClientData(void *&aData) const
{
aData = mClientData;
return NS_OK;
}
NS_IMETHODIMP nsView :: CreateWidget(const nsIID &aWindowIID,
NS_IMETHODIMP nsView::CreateWidget(const nsIID &aWindowIID,
nsWidgetInitData *aWidgetInitData,
nsNativeWidget aNative,
PRBool aEnableDragDrop,
@ -930,7 +902,7 @@ NS_IMETHODIMP nsView :: CreateWidget(const nsIID &aWindowIID,
}
// propagate the z-index to the widget.
mWindow->SetZIndex(mZindex);
mWindow->SetZIndex(mZIndex);
}
}
@ -948,7 +920,17 @@ NS_IMETHODIMP nsView :: CreateWidget(const nsIID &aWindowIID,
return NS_OK;
}
NS_IMETHODIMP nsView :: SetWidget(nsIWidget *aWidget)
void nsView::SetZIndex(PRBool aAuto, PRInt32 aZIndex)
{
mVFlags = (mVFlags & ~NS_VIEW_FLAG_AUTO_ZINDEX) | (aAuto ? NS_VIEW_FLAG_AUTO_ZINDEX : 0);
mZIndex = aZIndex;
if (nsnull != mWindow) {
mWindow->SetZIndex(aZIndex);
}
}
NS_IMETHODIMP nsView::SetWidget(nsIWidget *aWidget)
{
NS_IF_RELEASE(mWindow);
mWindow = aWidget;
@ -962,7 +944,7 @@ NS_IMETHODIMP nsView :: SetWidget(nsIWidget *aWidget)
return NS_OK;
}
NS_IMETHODIMP nsView :: GetWidget(nsIWidget *&aWidget) const
NS_IMETHODIMP nsView::GetWidget(nsIWidget *&aWidget) const
{
NS_IF_ADDREF(mWindow);
aWidget = mWindow;
@ -978,7 +960,7 @@ NS_IMETHODIMP nsView::HasWidget(PRBool *aHasWidget) const
//
// internal window creation functions
//
nsresult nsView :: LoadWidget(const nsCID &aClassIID)
nsresult nsView::LoadWidget(const nsCID &aClassIID)
{
nsresult rv = nsComponentManager::CreateInstance(aClassIID, nsnull, NS_GET_IID(nsIWidget), (void**)&mWindow);
@ -1020,7 +1002,7 @@ NS_IMETHODIMP nsView::List(FILE* out, PRInt32 aIndent) const
brect.x, brect.y, brect.width, brect.height);
PRBool hasTransparency;
HasTransparency(hasTransparency);
fprintf(out, " z=%d vis=%d opc=%1.3f tran=%d clientData=%p <\n", mZindex, mVis, mOpacity, hasTransparency, mClientData);
fprintf(out, " z=%d vis=%d opc=%1.3f tran=%d clientData=%p <\n", mZIndex, mVis, mOpacity, hasTransparency, mClientData);
nsView* kid = mFirstChild;
while (nsnull != kid) {
kid->List(out, aIndent + 1);
@ -1032,25 +1014,25 @@ NS_IMETHODIMP nsView::List(FILE* out, PRInt32 aIndent) const
return NS_OK;
}
NS_IMETHODIMP nsView :: SetViewFlags(PRUint32 aFlags)
NS_IMETHODIMP nsView::SetViewFlags(PRUint32 aFlags)
{
mVFlags |= aFlags;
return NS_OK;
}
NS_IMETHODIMP nsView :: ClearViewFlags(PRUint32 aFlags)
NS_IMETHODIMP nsView::ClearViewFlags(PRUint32 aFlags)
{
mVFlags &= ~aFlags;
return NS_OK;
}
NS_IMETHODIMP nsView :: GetViewFlags(PRUint32 *aFlags) const
NS_IMETHODIMP nsView::GetViewFlags(PRUint32 *aFlags) const
{
*aFlags = mVFlags;
return NS_OK;
}
NS_IMETHODIMP nsView :: GetOffsetFromWidget(nscoord *aDx, nscoord *aDy, nsIWidget *&aWidget)
NS_IMETHODIMP nsView::GetOffsetFromWidget(nscoord *aDx, nscoord *aDy, nsIWidget *&aWidget)
{
nsView *ancestor = GetParent();
aWidget = nsnull;
@ -1123,7 +1105,7 @@ NS_IMETHODIMP nsView::GetCompositorFlags(PRUint32 *aFlags)
return NS_OK;
}
PRBool nsView :: IsRoot()
PRBool nsView::IsRoot()
{
NS_ASSERTION(mViewManager != nsnull," View manager is null in nsView::IsRoot()");
return mViewManager->GetRootView() == this;
@ -1168,7 +1150,7 @@ NS_IMETHODIMP nsView::GetClippedRect(nsRect& aClippedRect, PRBool& aIsClipped, P
while (parentView) {
PRUint32 flags;
parentView->GetViewFlags(&flags);
if (flags & NS_VIEW_PUBLIC_FLAG_CLIPCHILDREN) {
if (flags & NS_VIEW_FLAG_CLIPCHILDREN) {
aIsClipped = PR_TRUE;
// Adjust for clip specified by ancestor
nscoord clipLeft;

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

@ -44,14 +44,53 @@
#include "nsIWidget.h"
#include "nsIFactory.h"
#include "nsIViewObserver.h"
#include "nsEvent.h"
#include <stdio.h>
//mmptemp
class nsIPresContext;
struct nsViewClip {
nscoord mLeft;
nscoord mRight;
nscoord mTop;
nscoord mBottom;
};
class nsIRegion;
class nsIRenderingContext;
class nsIViewManager;
class nsViewManager;
class nsZPlaceholderView;
// IID for the nsIClipView interface
#define NS_ICLIPVIEW_IID \
{ 0x4cc36160, 0xd282, 0x11d2, \
{ 0x90, 0x67, 0x00, 0x60, 0xb0, 0xf1, 0x99, 0xa2 } }
class nsIClipView : public nsISupports
{
public:
NS_DEFINE_STATIC_IID_ACCESSOR(NS_ICLIPVIEW_IID)
};
//the view is transparent
#define NS_VIEW_FLAG_TRANSPARENT 0x0004
// indicates that the view is using auto z-indexing
#define NS_VIEW_FLAG_AUTO_ZINDEX 0x0020
// indicates that the view is a floating view.
#define NS_VIEW_FLAG_FLOATING 0x0040
// set if our widget resized.
#define NS_VIEW_FLAG_WIDGET_RESIZED 0x0080
// set if our widget moved.
#define NS_VIEW_FLAG_WIDGET_MOVED 0x0100
#define NS_VIEW_FLAG_CLIPCHILDREN 0x0200
//indicates that the view should not be bitblt'd when moved
//or scrolled and instead must be repainted
#define NS_VIEW_FLAG_DONT_BITBLT 0x0010
//Flag to determine whether the view will check if events can be handled
//by its children or just handle the events itself
#define NS_VIEW_FLAG_DONT_CHECK_CHILDREN 0x0001
class nsView : public nsIView
{
public:
@ -67,65 +106,210 @@ public:
const nsRect &aBounds,
const nsIView *aParent,
nsViewVisibility aVisibilityFlag = nsViewVisibility_kShow);
NS_IMETHOD Destroy();
NS_IMETHOD GetViewManager(nsIViewManager *&aViewMgr) const;
NS_IMETHOD Paint(nsIRenderingContext& rc, const nsRect& rect,
PRUint32 aPaintFlags, PRBool &aResult);
NS_IMETHOD Paint(nsIRenderingContext& rc, const nsIRegion& region,
PRUint32 aPaintFlags, PRBool &aResult);
NS_IMETHOD HandleEvent(nsGUIEvent *event,
PRUint32 aEventFlags,
nsEventStatus* aStatus,
PRBool aForceHandle,
PRBool& aHandled);
NS_IMETHOD SetPosition(nscoord x, nscoord y);
NS_IMETHOD GetPosition(nscoord *x, nscoord *y) const;
NS_IMETHOD SetDimensions(nscoord width, nscoord height, PRBool aPaint = PR_TRUE);
NS_IMETHOD GetDimensions(nscoord *width, nscoord *height) const;
NS_IMETHOD SetBounds(const nsRect &aBounds, PRBool aPaint = PR_TRUE);
NS_IMETHOD SetBounds(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight, PRBool aPaint = PR_TRUE);
NS_IMETHOD GetBounds(nsRect &aBounds) const;
NS_IMETHOD SetChildClip(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD GetChildClip(nscoord *aLeft, nscoord *aTop, nscoord *aRight, nscoord *aBottom) const;
NS_IMETHOD SetVisibility(nsViewVisibility visibility);
NS_IMETHOD GetVisibility(nsViewVisibility &aVisibility) const;
NS_IMETHOD SetZIndex(PRInt32 aZIndex);
NS_IMETHOD GetZIndex(PRInt32 &aZIndex) const;
NS_IMETHOD SetAutoZIndex(PRBool aAutoZIndex);
NS_IMETHOD GetAutoZIndex(PRBool &aAutoZIndex) const;
NS_IMETHOD SetFloating(PRBool aFloatingView);
NS_IMETHOD GetZIndex(PRBool &aAuto, PRInt32 &aZIndex) const;
PRInt32 GetZIndex() const { return mZIndex; }
PRBool GetZIndexIsAuto() const { return (mVFlags & NS_VIEW_FLAG_AUTO_ZINDEX) != 0; }
NS_IMETHOD GetFloating(PRBool &aFloatingView) const;
NS_IMETHOD GetParent(nsIView *&aParent) const;
NS_IMETHOD GetNextSibling(nsIView *&aNextSibling) const;
NS_IMETHOD SetOpacity(float opacity);
NS_IMETHOD GetOpacity(float &aOpacity) const;
NS_IMETHOD HasTransparency(PRBool &aTransparent) const;
NS_IMETHOD SetContentTransparency(PRBool aTransparent);
NS_IMETHOD SetClientData(void *aData);
NS_IMETHOD GetClientData(void *&aData) const;
NS_IMETHOD GetOffsetFromWidget(nscoord *aDx, nscoord *aDy, nsIWidget *&aWidget);
NS_IMETHOD GetDirtyRegion(nsIRegion*& aRegion) const;
NS_IMETHOD CreateWidget(const nsIID &aWindowIID,
nsWidgetInitData *aWidgetInitData = nsnull,
nsNativeWidget aNative = nsnull,
PRBool aEnableDragDrop = PR_TRUE,
PRBool aResetVisibility = PR_TRUE);
NS_IMETHOD SetWidget(nsIWidget *aWidget);
NS_IMETHOD GetWidget(nsIWidget *&aWidget) const;
NS_IMETHOD HasWidget(PRBool *aHasWidget) const;
NS_IMETHOD List(FILE* out = stdout, PRInt32 aIndent = 0) const;
NS_IMETHOD Destroy();
/**
* Called to indicate that the specified rect of the view
* needs to be drawn via the rendering context. The rect
* is specified in view coordinates.
* @param rc rendering context to paint into
* @param rect damage area
* @param aPaintFlags see nsIView.h for flag definitions
* @return PR_TRUE if the entire clip region has been eliminated, else PR_FALSE
*/
NS_IMETHOD Paint(nsIRenderingContext& rc, const nsRect& rect,
PRUint32 aPaintFlags, PRBool &aResult);
/**
* Called to indicate that the specified region of the view
* needs to be drawn via the rendering context. The region
* is specified in view coordinates.
* @param rc rendering context to paint into
* @param region damage area
* @param aPaintFlags see nsIView.h for flag definitions
* @return PR_TRUE if the entire clip region has been eliminated, else PR_FALSE
*/
NS_IMETHOD Paint(nsIRenderingContext& rc, const nsIRegion& region,
PRUint32 aPaintFlags, PRBool &aResult);
/**
* Called to indicate that the specified event should be handled
* by the view. This method should return nsEventStatus_eConsumeDoDefault
* or nsEventStatus_eConsumeNoDefault if the event has been handled.
* @param event event to process
* @param aEventFlags see nsIView.h for flag definitions
* @result processing status
*/
NS_IMETHOD HandleEvent(nsGUIEvent *event,
PRUint32 aEventFlags,
nsEventStatus* aStatus,
PRBool aForceHandle,
PRBool& aHandled);
/**
* Called to indicate that the position of the view has been changed.
* The specified coordinates are in the parent view's coordinate space.
* @param x new x position
* @param y new y position
*/
NS_IMETHOD SetPosition(nscoord x, nscoord y);
/**
* Called to indicate that the dimensions of the view (actually the
* width and height of the clip) have been changed.
* @param width new width
* @param height new height
*/
NS_IMETHOD SetDimensions(nscoord width, nscoord height, PRBool aPaint = PR_TRUE);
NS_IMETHOD GetDimensions(nscoord *width, nscoord *height) const;
/**
* Called to indicate that the dimensions and position of the view have
* been changed.
* @param aBounds new bounds
*/
NS_IMETHOD SetBounds(const nsRect &aBounds, PRBool aPaint = PR_TRUE);
/**
* Called to indicate that the dimensions and position of the view have
* been changed.
* @param aX new x position
* @param aY new y position
* @param aWidth new width
* @param aHeight new height
*/
NS_IMETHOD SetBounds(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight, PRBool aPaint = PR_TRUE);
/**
* Called to set the clip of the children of this view.
* The clip is relative to the origin of the view.
* All of the children of this view will be clipped using
* the specified rectangle
* @param aLeft new left position
* @param aTop new top position
* @param aRight new right position
* @param aBottom new bottom position
*/
NS_IMETHOD SetChildClip(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
/**
* Called to get the dimensions and position of the clip for the view.
* @param aLeft left position
* @param aTop top position
* @param aRight right position
* @param aBottom bottom position
*/
NS_IMETHOD GetChildClip(nscoord *aLeft, nscoord *aTop, nscoord *aRight, nscoord *aBottom) const;
/**
* Called to indicate that the visibility of a view has been
* changed.
* @param visibility new visibility state
*/
NS_IMETHOD SetVisibility(nsViewVisibility visibility);
/**
* Called to indicate that the z-index of a view has been changed.
* The z-index is relative to all siblings of the view.
* @param aAuto Indicate that the z-index of a view is "auto". An "auto" z-index
* means that the view does not define a new stacking context,
* which means that the z-indicies of the view's children are
* relative to the view's siblings.
* @param zindex new z depth
*/
void SetZIndex(PRBool aAuto, PRInt32 aZIndex);
/**
* Set/Get whether the view "floats" above all other views,
* which tells the compositor not to consider higher views in
* the view hierarchy that would geometrically intersect with
* this view. This is a hack, but it fixes some problems with
* views that need to be drawn in front of all other views.
* @result PR_TRUE if the view floats, PR_FALSE otherwise.
*/
NS_IMETHOD SetFloating(PRBool aFloatingView);
/**
* Note: This didn't exist in 4.0. Called to set the opacity of a view.
* A value of 0.0 means completely transparent. A value of 1.0 means
* completely opaque.
* @param opacity new opacity value
*/
NS_IMETHOD SetOpacity(float opacity);
/**
* Used set the transparency status of the content in a view. see
* HasTransparency().
* @param aTransparent PR_TRUE if there are transparent areas, PR_FALSE otherwise.
*/
NS_IMETHOD SetContentTransparency(PRBool aTransparent);
/**
* Gets the dirty region associated with this view. Used by the view
* manager.
*/
NS_IMETHOD GetDirtyRegion(nsIRegion*& aRegion) const;
/**
* 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);
/**
* Set flags on view to allow customization of view behavior during
* event handling
* @param aFlags flags to be added to view
*/
NS_IMETHOD SetViewFlags(PRUint32 aFlags);
/**
* Remove flags from view to allow customization of view behavior during
* event handling
* @param aFlags flags to be removed from view
*/
NS_IMETHOD ClearViewFlags(PRUint32 aFlags);
/**
* Get flags on view to allow customization of view behavior during
* event handling
* @param aFlags out parameter for view flags
*/
NS_IMETHOD GetViewFlags(PRUint32 *aFlags) const;
/**
* Used by the compositor for temporary marking of a view during
* compositing. This will eventually replace GetScratchPoint above.
*/
NS_IMETHOD SetCompositorFlags(PRUint32 aFlags);
NS_IMETHOD GetCompositorFlags(PRUint32 *aFlags);
/**
* Return a rectangle containing the view's bounds adjusted for it's ancestors clipping
* @param aClippedRect views bounds adjusted for ancestors clipping. If aEmpty is TRUE it
* aClippedRect is set to an empty rect.
* @param aIsClipped returns with PR_TRUE if view's rectangle is clipped by an ancestor
* @param aEmpty returns with PR_TRUE if view's rectangle is 'clipped out'
*/
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
*/
NS_IMETHOD SynchWidgetSizePosition();
@ -155,6 +339,8 @@ public: // NOT in nsIView, so only available in view module
void SetZParent(nsZPlaceholderView *aZParent) { mZParent = aZParent; }
void SetNextSibling(nsView *aSibling) { mNextSibling = aSibling; }
PRUint32 GetViewFlags() const { return mVFlags; }
protected:
virtual ~nsView();
//
@ -171,7 +357,7 @@ protected:
nsView *mNextSibling;
nsView *mFirstChild;
void *mClientData;
PRInt32 mZindex;
PRInt32 mZIndex;
nsViewVisibility mVis;
PRInt32 mNumKids;
nsRect mBounds;

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

@ -46,7 +46,6 @@
#include "nsIScrollableView.h"
#include "nsView.h"
#include "nsIScrollbar.h"
#include "nsIClipView.h"
#include "nsISupportsArray.h"
#include "nsICompositeListener.h"
#include "nsCOMPtr.h"
@ -61,6 +60,25 @@ static NS_DEFINE_IID(kRegionCID, NS_REGION_CID);
static NS_DEFINE_IID(kRenderingContextCID, NS_RENDERING_CONTEXT_CID);
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
/**
XXX TODO XXX
DeCOMify newly private methods
Move event handling into nsViewManager
Make event handling use CreateDisplayList
Reverse storage order of views so that LAST view in document order is the LAST child
of its parent view
Audit users of nsIView::GetPosition and nsIView::GetBounds, then
fix nsContainerFrame::SyncFrameViewAfterReflow to size views to contain
left-or-above content
Remove nsIClipView stuff and just use the CLIPCHILDREN flag
Put in support for hierarchy of viewmanagers (handle nsViewManager::SetRootView
case where aWidget == null and aView has a non-null parent with a different view
manager)
Fix opacity model to conform to SVG (requires backbuffer stack)
Optimize view storage
*/
/**
A note about platform assumptions:
@ -170,7 +188,7 @@ void nsViewManager::DestroyZTreeNode(DisplayZTreeNode* aNode)
if (aNode) {
if (mMapPlaceholderViewToZTreeNode.Count() > 0) {
nsVoidKey key(aNode->mView);
DisplayZTreeNode* placeholder = (DisplayZTreeNode *)mMapPlaceholderViewToZTreeNode.Remove(&key);
mMapPlaceholderViewToZTreeNode.Remove(&key);
}
DestroyZTreeNode(aNode->mZChild);
@ -423,7 +441,7 @@ static nsresult CreateRegion(nsIComponentManager* componentManager, nsIRegion* *
// We don't hold a reference to the presentation context because it
// holds a reference to us.
NS_IMETHODIMP nsViewManager::Init(nsIDeviceContext* aContext, nscoord aX, nscoord aY)
NS_IMETHODIMP nsViewManager::Init(nsIDeviceContext* aContext)
{
nsresult rv;
@ -459,9 +477,6 @@ NS_IMETHODIMP nsViewManager::Init(nsIDeviceContext* aContext, nscoord aX, nscoor
CreateRegion(componentManager, &mTmpRgn);
}
mX = aX;
mY = aY;
if (nsnull == mEventQueue) {
// Cache the event queue of the current UI thread
nsCOMPtr<nsIEventQueueService> eventService =
@ -487,7 +502,7 @@ NS_IMETHODIMP nsViewManager::GetRootView(nsIView *&aView)
return NS_OK;
}
NS_IMETHODIMP nsViewManager :: SetRootView(nsIView *aView, nsIWidget* aWidget)
NS_IMETHODIMP nsViewManager::SetRootView(nsIView *aView, nsIWidget* aWidget)
{
nsView* view = NS_STATIC_CAST(nsView*, aView);
@ -524,6 +539,23 @@ NS_IMETHODIMP nsViewManager :: SetRootView(nsIView *aView, nsIWidget* aWidget)
return NS_OK;
}
NS_IMETHODIMP nsViewManager::GetWindowOffset(nscoord *aX, nscoord *aY)
{
NS_ASSERTION(aX != nsnull, "aX pointer is null");
NS_ASSERTION(aY != nsnull, "aY pointer is null");
*aX = mX;
*aY = mY;
return NS_OK;
}
NS_IMETHODIMP nsViewManager::SetWindowOffset(nscoord aX, nscoord aY)
{
mX = aX;
mY = aY;
return NS_OK;
}
NS_IMETHODIMP nsViewManager::GetWindowDimensions(nscoord *width, nscoord *height)
{
if (nsnull != mRootView)
@ -806,9 +838,9 @@ static void SortByZOrder(DisplayZTreeNode *aNode, nsVoidArray &aBuffer, nsVoidAr
PRInt32 explicitZIndex = 0;
if (nsnull != aNode->mView) {
aNode->mView->GetAutoZIndex(autoZIndex);
autoZIndex = aNode->mView->GetZIndexIsAuto();
if (!autoZIndex) {
aNode->mView->GetZIndex(explicitZIndex);
explicitZIndex = aNode->mView->GetZIndex();
}
}
@ -1172,7 +1204,7 @@ void nsViewManager::RenderView(nsView *aView, nsIRenderingContext &aRC, const ns
// should use blender here if opacity < 1.0
aView->Paint(aRC, drect, NS_VIEW_FLAG_JUST_PAINT, aResult);
aView->Paint(aRC, drect, 0, aResult);
aRC.PopState(aResult);
}
@ -1190,7 +1222,7 @@ void nsViewManager::RenderDisplayListElement(DisplayListElement2* element, nsIRe
nsRect drect(element->mBounds.x - x, element->mBounds.y - y,
element->mBounds.width, element->mBounds.height);
element->mView->Paint(aRC, drect, NS_VIEW_FLAG_JUST_PAINT, clipEmpty);
element->mView->Paint(aRC, drect, 0, clipEmpty);
aRC.PopState(clipEmpty);
}
@ -1267,7 +1299,7 @@ void nsViewManager::PaintView(nsView *aView, nsIRenderingContext &aRC, nscoord x
aRC.PushState();
aRC.Translate(x, y);
PRBool unused;
aView->Paint(aRC, aDamageRect, NS_VIEW_FLAG_JUST_PAINT, unused);
aView->Paint(aRC, aDamageRect, 0, unused);
aRC.PopState(unused);
}
@ -1498,7 +1530,7 @@ PRBool nsViewManager::UpdateAllCoveringWidgets(nsView *aView, nsView *aTarget,
PRUint32 flags = 0;
aView->GetViewFlags(&flags);
PRBool isBlittable = (flags & NS_VIEW_PUBLIC_FLAG_DONT_BITBLT) == 0;
PRBool isBlittable = (flags & NS_VIEW_FLAG_DONT_BITBLT) == 0;
nsView* childView = aView->GetFirstChild();
PRBool childCovers = PR_FALSE;
@ -1877,12 +1909,7 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aS
aEvent->point.y += offset.y;
PRBool handled = PR_FALSE;
view->HandleEvent(aEvent, NS_VIEW_FLAG_CHECK_CHILDREN |
NS_VIEW_FLAG_CHECK_PARENT |
NS_VIEW_FLAG_CHECK_SIBLINGS,
aStatus,
PR_TRUE,
handled);
view->HandleEvent(aEvent, 0, aStatus, PR_TRUE, handled);
aEvent->point.x -= offset.x;
aEvent->point.y -= offset.y;
@ -1950,7 +1977,7 @@ NS_IMETHODIMP nsViewManager::GetKeyEventGrabber(nsIView *&aView)
}
NS_IMETHODIMP nsViewManager::InsertChild(nsIView *aParent, nsIView *aChild, nsIView *aSibling,
PRBool aAbove)
PRBool aAfter)
{
nsView* parent = NS_STATIC_CAST(nsView*, aParent);
nsView* child = NS_STATIC_CAST(nsView*, aChild);
@ -1958,6 +1985,9 @@ NS_IMETHODIMP nsViewManager::InsertChild(nsIView *aParent, nsIView *aChild, nsIV
NS_PRECONDITION(nsnull != parent, "null ptr");
NS_PRECONDITION(nsnull != child, "null ptr");
NS_ASSERTION(sibling == nsnull || sibling->GetParent() == parent,
"tried to insert view with invalid sibling");
NS_ASSERTION(!IsViewInserted(child), "tried to insert an already-inserted view");
if ((nsnull != parent) && (nsnull != child))
{
@ -1966,6 +1996,9 @@ NS_IMETHODIMP nsViewManager::InsertChild(nsIView *aParent, nsIView *aChild, nsIV
//verify that the sibling exists...
#if 0 // This is the correct code, but we can't activate it yet without breaking things.
// We will turn this on when event handling and everything else has been
// brainfixed to understand z-indexes.
while (nsnull != kid)
{
if (kid == sibling)
@ -1977,16 +2010,36 @@ NS_IMETHODIMP nsViewManager::InsertChild(nsIView *aParent, nsIView *aChild, nsIV
kid = kid->GetNextSibling();
}
if (nsnull != kid)
{
//it's there, so do the insertion
// either kid == sibling and prev is the child before sibling, or null
// if sibling is the first child,
// OR kid == null, the sibling was null or not there, and prev == last child view
// The following code works in both cases.
if (PR_TRUE == aAbove)
parent->InsertChild(child, prev);
else
parent->InsertChild(child, sibling);
if (PR_TRUE == aAfter)
// the child views are ordered in REVERSE document order;
// LAST view in document order is the FIRST child
// so we insert the new view just in front of sibling, or as the first child
// if sibling is null
parent->InsertChild(child, prev);
else
parent->InsertChild(child, kid);
#else // for now, don't keep consistent document order, but order things by z-index instead
// essentially we're emulating the old InsertChild(parent, child, zindex)
PRInt32 zIndex = child->GetZIndex();
while (nsnull != kid)
{
PRInt32 idx = kid->GetZIndex();
if (zIndex >= idx)
break;
prev = kid;
kid = kid->GetNextSibling();
}
parent->InsertChild(child, prev);
#endif
UpdateTransCnt(nsnull, child);
// if the parent view is marked as "floating", make the newly added view float as well.
@ -2006,7 +2059,8 @@ NS_IMETHODIMP nsViewManager::InsertChild(nsIView *aParent, nsIView *aChild, nsIV
return NS_OK;
}
NS_IMETHODIMP nsViewManager::InsertZPlaceholder(nsIView *aParent, nsIView *aChild, PRInt32 aZIndex)
NS_IMETHODIMP nsViewManager::InsertZPlaceholder(nsIView *aParent, nsIView *aChild,
nsIView *aSibling, PRBool aAfter)
{
nsView* parent = NS_STATIC_CAST(nsView*, aParent);
nsView* child = NS_STATIC_CAST(nsView*, aChild);
@ -2014,33 +2068,14 @@ NS_IMETHODIMP nsViewManager::InsertZPlaceholder(nsIView *aParent, nsIView *aChil
NS_PRECONDITION(nsnull != parent, "null ptr");
NS_PRECONDITION(nsnull != child, "null ptr");
if ((nsnull != parent) && (nsnull != child))
{
nsView *kid = parent->GetFirstChild();
nsView *prev = nsnull;
while (nsnull != kid)
{
PRInt32 idx;
kid->GetZIndex(idx);
if (aZIndex >= idx)
break;
prev = kid;
kid = kid->GetNextSibling();
}
nsZPlaceholderView* placeholder = new nsZPlaceholderView();
nsRect bounds(0, 0, 0, 0);
placeholder->Init(this, bounds, parent, nsViewVisibility_kHide);
placeholder->SetReparentedView(child);
child->SetZParent(placeholder);
placeholder->SetZIndex(aZIndex);
parent->InsertChild(placeholder, prev);
}
return NS_OK;
nsZPlaceholderView* placeholder = new nsZPlaceholderView();
nsRect bounds(0, 0, 0, 0);
placeholder->Init(this, bounds, parent, nsViewVisibility_kHide);
placeholder->SetReparentedView(child);
placeholder->SetZIndex(child->GetZIndexIsAuto(), child->GetZIndex());
child->SetZParent(placeholder);
return InsertChild(parent, placeholder, aSibling, aAfter);
}
NS_IMETHODIMP nsViewManager::InsertChild(nsIView *aParent, nsIView *aChild, PRInt32 aZIndex)
@ -2060,9 +2095,7 @@ NS_IMETHODIMP nsViewManager::InsertChild(nsIView *aParent, nsIView *aChild, PRIn
while (nsnull != kid)
{
PRInt32 idx;
kid->GetZIndex(idx);
PRInt32 idx = kid->GetZIndex();
if (aZIndex >= idx)
break;
@ -2075,7 +2108,7 @@ NS_IMETHODIMP nsViewManager::InsertChild(nsIView *aParent, nsIView *aChild, PRIn
//in case this hasn't been set yet... maybe we should not do this? MMP
child->SetZIndex(aZIndex);
child->SetZIndex(child->GetZIndexIsAuto(), aZIndex);
parent->InsertChild(child, prev);
UpdateTransCnt(nsnull, child);
@ -2096,14 +2129,14 @@ NS_IMETHODIMP nsViewManager::InsertChild(nsIView *aParent, nsIView *aChild, PRIn
return NS_OK;
}
NS_IMETHODIMP nsViewManager::RemoveChild(nsIView *aParent, nsIView *aChild)
NS_IMETHODIMP nsViewManager::RemoveChild(nsIView *aChild)
{
nsView* parent = NS_STATIC_CAST(nsView*, aParent);
nsView* child = NS_STATIC_CAST(nsView*, aChild);
NS_PRECONDITION(nsnull != parent, "null ptr");
NS_PRECONDITION(nsnull != child, "null ptr");
nsView* parent = child->GetParent();
if ((nsnull != parent) && (nsnull != child))
{
UpdateTransCnt(child, nsnull);
@ -2149,11 +2182,13 @@ NS_IMETHODIMP nsViewManager::MoveViewTo(nsIView *aView, nscoord aX, nscoord aY)
return NS_OK;
}
NS_IMETHODIMP nsViewManager::ResizeView(nsIView *aView, nscoord width, nscoord height, PRBool aRepaintExposedAreaOnly)
NS_IMETHODIMP nsViewManager::ResizeView(nsIView *aView, const nsRect &aRect, PRBool aRepaintExposedAreaOnly)
{
nscoord oldWidth, oldHeight;
nsView* view = NS_STATIC_CAST(nsView*, aView);
PRInt32 width = aRect.width;
PRInt32 height = aRect.height;
view->GetDimensions(&oldWidth, &oldHeight);
if ((width != oldWidth) || (height != oldHeight)) {
nscoord x = 0, y = 0;
@ -2224,16 +2259,63 @@ NS_IMETHODIMP nsViewManager::ResizeView(nsIView *aView, nscoord width, nscoord h
return NS_OK;
}
NS_IMETHODIMP nsViewManager::SetViewChildClip(nsIView *aView, nsRect *aRect)
NS_IMETHODIMP nsViewManager::SetViewChildClipRegion(nsIView *aView, nsIRegion *aRegion)
{
nsView* view = NS_STATIC_CAST(nsView*, aView);
NS_ASSERTION(!(nsnull == view), "no view");
// XXX Shouldn't we repaint the view here?
if (aRegion != nsnull) {
nsRect newClip;
aRegion->GetBoundingBox(&newClip.x, &newClip.y, &newClip.width, &newClip.height);
view->SetViewFlags(view->GetViewFlags() | NS_VIEW_FLAG_CLIPCHILDREN);
view->SetChildClip(newClip.x, newClip.y, newClip.XMost(), newClip.YMost());
} else {
view->SetViewFlags(view->GetViewFlags() & ~NS_VIEW_FLAG_CLIPCHILDREN);
}
return NS_OK;
}
NS_IMETHODIMP nsViewManager::SetViewBitBltEnabled(nsIView *aView, PRBool aEnable)
{
nsView* view = NS_STATIC_CAST(nsView*, aView);
NS_ASSERTION(!(nsnull == view), "no view");
NS_ASSERTION(!(nsnull == aRect), "no clip");
view->SetChildClip(aRect->x, aRect->y, aRect->XMost(), aRect->YMost());
if (aEnable) {
view->SetViewFlags(view->GetViewFlags() & ~NS_VIEW_FLAG_DONT_BITBLT);
} else {
view->SetViewFlags(view->GetViewFlags() | NS_VIEW_FLAG_DONT_BITBLT);
}
UpdateView(view, *aRect, NS_VMREFRESH_NO_SYNC);
return NS_OK;
}
NS_IMETHODIMP nsViewManager::SetViewCheckChildEvents(nsIView *aView, PRBool aEnable)
{
nsView* view = NS_STATIC_CAST(nsView*, aView);
NS_ASSERTION(!(nsnull == view), "no view");
if (aEnable) {
view->SetViewFlags(view->GetViewFlags() & ~NS_VIEW_FLAG_DONT_CHECK_CHILDREN);
} else {
view->SetViewFlags(view->GetViewFlags() | NS_VIEW_FLAG_DONT_CHECK_CHILDREN);
}
return NS_OK;
}
NS_IMETHODIMP nsViewManager::SetViewFloating(nsIView *aView, PRBool aFloating)
{
nsView* view = NS_STATIC_CAST(nsView*, aView);
NS_ASSERTION(!(nsnull == view), "no view");
view->SetFloating(aFloating);
return NS_OK;
}
@ -2247,137 +2329,90 @@ NS_IMETHODIMP nsViewManager::SetViewVisibility(nsIView *aView, nsViewVisibility
if (aVisible != oldVisible) {
view->SetVisibility(aVisible);
PRBool hasWidget = PR_FALSE;
view->HasWidget(&hasWidget);
if (!hasWidget) {
if (nsViewVisibility_kHide == aVisible) {
nsView* parentView = view->GetParent();
if (parentView) {
nsRect bounds;
view->GetBounds(bounds);
UpdateView(parentView, bounds, NS_VMREFRESH_NO_SYNC);
if (IsViewInserted(view)) {
PRBool hasWidget = PR_FALSE;
view->HasWidget(&hasWidget);
if (!hasWidget) {
if (nsViewVisibility_kHide == aVisible) {
nsView* parentView = view->GetParent();
if (parentView) {
nsRect bounds;
view->GetBounds(bounds);
UpdateView(parentView, bounds, NS_VMREFRESH_NO_SYNC);
}
}
else {
UpdateView(view, NS_VMREFRESH_NO_SYNC);
}
}
else {
UpdateView(view, NS_VMREFRESH_NO_SYNC);
}
}
}
return NS_OK;
}
NS_IMETHODIMP nsViewManager::SetViewZIndex(nsIView *aView, PRInt32 aZIndex)
PRBool nsViewManager::IsViewInserted(nsView *aView)
{
if (mRootView == aView) {
return PR_TRUE;
} else if (aView->GetParent() == nsnull) {
return PR_FALSE;
} else {
nsView* view = aView->GetParent()->GetFirstChild();
while (view != nsnull) {
if (view == aView) {
return PR_TRUE;
}
view = view->GetNextSibling();
}
return PR_FALSE;
}
}
NS_IMETHODIMP nsViewManager::SetViewZIndex(nsIView *aView, PRBool aAutoZIndex, PRInt32 aZIndex)
{
nsView* view = NS_STATIC_CAST(nsView*, aView);
nsresult rv = NS_OK;
NS_ASSERTION((view != nsnull), "no view");
PRInt32 oldidx;
view->GetZIndex(oldidx);
if (oldidx != aZIndex) {
nsView *parent = view->GetParent();
if (nsnull != parent) {
//we don't just call the view manager's RemoveChild()
//so that we can avoid two trips trough the UpdateView()
//code (one for removal, one for insertion). MMP
parent->RemoveChild(view);
UpdateTransCnt(view, nsnull);
rv = InsertChild(parent, view, aZIndex);
}
// XXX The following else block is a workaround and should be cleaned up (bug 43410)
} else {
nsCOMPtr<nsIWidget> widget;
view->GetWidget(*getter_AddRefs(widget));
if (widget) {
widget->SetZIndex(aZIndex);
}
if (aAutoZIndex) {
aZIndex = 0;
}
nsZPlaceholderView* zParentView = view->GetZParent();
if (nsnull != zParentView) {
SetViewZIndex(zParentView, aZIndex);
PRInt32 oldidx = view->GetZIndex();
view->SetZIndex(aAutoZIndex, aZIndex);
if (IsViewInserted(view)) {
if (oldidx != aZIndex) {
nsView *parent = view->GetParent();
if (nsnull != parent) {
//we don't just call the view manager's RemoveChild()
//so that we can avoid two trips trough the UpdateView()
//code (one for removal, one for insertion). MMP
parent->RemoveChild(view);
UpdateTransCnt(view, nsnull);
rv = InsertChild(parent, view, aZIndex);
}
// XXX The following else block is a workaround and should be cleaned up (bug 43410)
} else {
nsCOMPtr<nsIWidget> widget;
view->GetWidget(*getter_AddRefs(widget));
if (widget) {
widget->SetZIndex(aZIndex);
}
}
nsZPlaceholderView* zParentView = view->GetZParent();
if (nsnull != zParentView) {
SetViewZIndex(zParentView, aAutoZIndex, aZIndex);
}
}
return rv;
}
NS_IMETHODIMP nsViewManager::SetViewAutoZIndex(nsIView *aView, PRBool aAutoZIndex)
{
nsView* view = NS_STATIC_CAST(nsView*, aView);
return view->SetAutoZIndex(aAutoZIndex);
}
NS_IMETHODIMP nsViewManager::MoveViewAbove(nsIView *aView, nsIView *aOther)
{
nsView* view = NS_STATIC_CAST(nsView*, aView);
nsView* other = NS_STATIC_CAST(nsView*, aOther);
nsresult rv;
NS_ASSERTION(!(nsnull == view), "no view");
NS_ASSERTION(!(nsnull == other), "no view");
nsView *nextview = view->GetNextSibling();
if (nextview != other)
{
nsView *parent = view->GetParent();
if (nsnull != parent)
{
//we don't just call the view manager's RemoveChild()
//so that we can avoid two trips trough the UpdateView()
//code (one for removal, one for insertion). MMP
parent->RemoveChild(view);
UpdateTransCnt(view, nsnull);
rv = InsertChild(parent, view, other, PR_TRUE);
}
else
rv = NS_OK;
}
else
rv = NS_OK;
return rv;
}
NS_IMETHODIMP nsViewManager::MoveViewBelow(nsIView *aView, nsIView *aOther)
{
nsresult rv;
nsView* view = NS_STATIC_CAST(nsView*, aView);
nsView* other = NS_STATIC_CAST(nsView*, aOther);
NS_ASSERTION(!(nsnull == view), "no view");
NS_ASSERTION(!(nsnull == other), "no view");
nsView *nextview = other->GetNextSibling();
if (nextview != view)
{
nsView *parent = view->GetParent();
if (nsnull != parent)
{
//we don't just call the view manager's RemoveChild()
//so that we can avoid two trips trough the UpdateView()
//code (one for removal, one for insertion). MMP
parent->RemoveChild(view);
UpdateTransCnt(view, nsnull);
rv = InsertChild(parent, view, other, PR_FALSE);
}
else
rv = NS_OK;
}
else
rv = NS_OK;
return rv;
}
NS_IMETHODIMP nsViewManager::SetViewContentTransparency(nsIView *aView, PRBool aTransparent)
{
nsView* view = NS_STATIC_CAST(nsView*, aView);
@ -2385,7 +2420,7 @@ NS_IMETHODIMP nsViewManager::SetViewContentTransparency(nsIView *aView, PRBool a
view->HasTransparency(trans);
if (trans != aTransparent)
if (trans != aTransparent && IsViewInserted(view))
{
UpdateTransCnt(view, nsnull);
view->SetContentTransparency(aTransparent);
@ -2403,7 +2438,7 @@ NS_IMETHODIMP nsViewManager::SetViewOpacity(nsIView *aView, float aOpacity)
view->GetOpacity(opacity);
if (opacity != aOpacity)
if (opacity != aOpacity && IsViewInserted(view))
{
UpdateTransCnt(view, nsnull);
view->SetOpacity(aOpacity);
@ -2919,15 +2954,6 @@ NS_IMETHODIMP nsViewManager::ForceUpdate()
return NS_OK;
}
NS_IMETHODIMP nsViewManager::GetOffset(nscoord *aX, nscoord *aY)
{
NS_ASSERTION(aX != nsnull, "aX pointer is null");
NS_ASSERTION(aY != nsnull, "aY pointer is null");
*aX = mX;
*aY = mY;
return NS_OK;
}
static nsresult EnsureZTreeNodeCreated(nsView* aView, DisplayZTreeNode* &aNode) {
if (nsnull == aNode) {
aNode = new DisplayZTreeNode;
@ -3043,8 +3069,7 @@ PRBool nsViewManager::CreateDisplayList(nsView *aView, PRBool aReparentedViewsPr
for (childView = aView->GetFirstChild(); nsnull != childView;
childView = childView->GetNextSibling()) {
PRInt32 zindex;
childView->GetZIndex(zindex);
PRInt32 zindex = childView->GetZIndex();
if (zindex < 0)
break;
@ -3393,8 +3418,7 @@ void nsViewManager::ShowDisplayList(PRInt32 flatlen)
PRUint32 flags = element->mFlags;
nsView* parent = view->GetParent();
PRInt32 zindex;
view->GetZIndex(zindex);
PRInt32 zindex = view->GetZIndex();
nest[nestcnt << 1] = 0;
@ -3508,10 +3532,12 @@ nsresult nsViewManager::GetVisibleRect(nsRect& aVisibleRect)
if (scrollingView) {
// Determine the visible rect in the scrolled view's coordinate space.
// The size of the visible area is the clip view size
const nsIView* clipView;
const nsIView* clipViewI;
scrollingView->GetScrollPosition(aVisibleRect.x, aVisibleRect.y);
scrollingView->GetClipView(&clipView);
scrollingView->GetClipView(&clipViewI);
const nsView* clipView = NS_STATIC_CAST(const nsView*, clipViewI);
clipView->GetDimensions(&aVisibleRect.width, &aVisibleRect.height);
} else {
rv = NS_ERROR_FAILURE;

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

@ -54,10 +54,12 @@
#include "nsView.h"
#include "nsIEventProcessor.h"
class nsIRegion;
class nsIEvent;
class nsIPresContext;
class nsISupportsArray;
struct DisplayListElement2;
struct DisplayZTreeNode;
class nsView;
//Uncomment the following line to enable generation of viewmanager performance data.
#ifdef MOZ_PERF_METRICS
@ -125,11 +127,14 @@ public:
NS_DECL_ISUPPORTS
NS_IMETHOD Init(nsIDeviceContext* aContext, nscoord aX = 0, nscoord aY = 0);
NS_IMETHOD Init(nsIDeviceContext* aContext);
NS_IMETHOD GetRootView(nsIView *&aView);
NS_IMETHOD SetRootView(nsIView *aView, nsIWidget* aWidget=nsnull);
NS_IMETHOD GetWindowOffset(nscoord *aX, nscoord *aY);
NS_IMETHOD SetWindowOffset(nscoord aX, nscoord aY);
NS_IMETHOD GetWindowDimensions(nscoord *width, nscoord *height);
NS_IMETHOD SetWindowDimensions(nscoord width, nscoord height);
@ -140,6 +145,13 @@ public:
NS_IMETHOD UpdateView(nsIView *aView, PRUint32 aUpdateFlags);
NS_IMETHOD UpdateView(nsIView *aView, const nsRect &aRect, PRUint32 aUpdateFlags);
NS_IMETHOD UpdateAllViews(PRUint32 aUpdateFlags);
/**
* Called to inform the view manager that a view has scrolled.
* The view manager will invalidate any widgets which may need
* to be rerendered.
* @param aView view to paint. should be root view
* @param aUpdateFlags see bottom of nsIViewManager.h for description
*/
NS_IMETHOD UpdateViewAfterScroll(nsIView *aView, PRInt32 aDX, PRInt32 aDY);
NS_IMETHOD DispatchEvent(nsGUIEvent *aEvent, nsEventStatus* aStatus);
@ -156,27 +168,28 @@ public:
NS_IMETHOD InsertChild(nsIView *parent, nsIView *child,
PRInt32 zindex);
NS_IMETHOD InsertZPlaceholder(nsIView *aParent, nsIView *aZChild,
PRInt32 aZIndex);
NS_IMETHOD InsertZPlaceholder(nsIView *parent, nsIView *child, nsIView *sibling,
PRBool above);
NS_IMETHOD RemoveChild(nsIView *parent, nsIView *child);
NS_IMETHOD RemoveChild(nsIView *parent);
NS_IMETHOD MoveViewBy(nsIView *aView, nscoord aX, nscoord aY);
NS_IMETHOD MoveViewTo(nsIView *aView, nscoord aX, nscoord aY);
NS_IMETHOD ResizeView(nsIView *aView, nscoord aWidth, nscoord aHeight, PRBool aRepaintExposedAreaOnly = PR_FALSE);
NS_IMETHOD ResizeView(nsIView *aView, const nsRect &aRect, PRBool aRepaintExposedAreaOnly = PR_FALSE);
NS_IMETHOD SetViewChildClip(nsIView *aView, nsRect *aRect);
NS_IMETHOD SetViewChildClipRegion(nsIView *aView, nsIRegion *aRegion);
NS_IMETHOD SetViewBitBltEnabled(nsIView *aView, PRBool aEnable);
NS_IMETHOD SetViewCheckChildEvents(nsIView *aView, PRBool aEnable);
NS_IMETHOD SetViewFloating(nsIView *aView, PRBool aFloating);
NS_IMETHOD SetViewVisibility(nsIView *aView, nsViewVisibility aVisible);
NS_IMETHOD SetViewZIndex(nsIView *aView, PRInt32 aZIndex);
NS_IMETHOD SetViewAutoZIndex(nsIView *aView, PRBool aAutoZIndex);
NS_IMETHOD MoveViewAbove(nsIView *aView, nsIView *aOther);
NS_IMETHOD MoveViewBelow(nsIView *aView, nsIView *aOther);
NS_IMETHOD SetViewZIndex(nsIView *aView, PRBool aAuto, PRInt32 aZIndex);
NS_IMETHOD SetViewContentTransparency(nsIView *aView, PRBool aTransparent);
NS_IMETHOD SetViewOpacity(nsIView *aView, float aOpacity);
@ -209,7 +222,6 @@ public:
NS_IMETHOD GetWidgetForView(nsIView *aView, nsIWidget **aWidget);
NS_IMETHOD GetWidget(nsIWidget **aWidget);
NS_IMETHOD ForceUpdate();
NS_IMETHOD GetOffset(nscoord *aX, nscoord *aY);
NS_IMETHOD IsCachingWidgetChanges(PRBool* aCaching);
NS_IMETHOD CacheWidgetChanges(PRBool aCache);
@ -244,7 +256,6 @@ private:
PRBool UpdateAllCoveringWidgets(nsView *aView, nsView *aTarget, nsRect &aDamagedRect, PRBool aOnlyRepaintIfUnblittable);
void UpdateViews(nsView *aView, PRUint32 aUpdateFlags);
void Refresh(nsView *aView, nsIRenderingContext *aContext,
@ -289,6 +300,8 @@ private:
// Utilities
PRBool IsViewInserted(nsView *aView);
/**
* Returns the nearest parent view with an attached widget. Can be the
* same view as passed-in.
@ -458,4 +471,7 @@ protected:
#endif
};
//when the refresh happens, should it be double buffered?
#define NS_VMREFRESH_DOUBLE_BUFFER 0x0001
#endif /* nsViewManager_h___ */

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

@ -281,7 +281,7 @@ void nsXPBaseWindow::ForceRefresh()
nsIView* root;
vm->GetRootView(root);
if (nsnull != root) {
vm->UpdateView(root, NS_VMREFRESH_IMMEDIATE | NS_VMREFRESH_AUTO_DOUBLE_BUFFER);
vm->UpdateView(root, NS_VMREFRESH_IMMEDIATE);
}
}
NS_RELEASE(shell);